-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sec1: can't decode secp256k1 pem #1116
Comments
It's definitely not. Specifically this part: let doc = pkcs8::SecretDocument::from_sec1_pem(&pem).expect("decode sec1"); I'm not sure how you managed to discover this compiles, but it's leveraging a default impl of SEC1 support for types which impl the PKCS#8 traits, i.e. you're mixing SEC1 and PKCS#8. SEC1 is described independently of PKCS#8, and PKCS#8 wraps it, with the blanket impl intended to provide PKCS#8 support to types which impl the Have a look at the Sorry this isn't better documented, but right now the |
To describe this a little better, The next thing you try to do is decode the PKCS#8-encoded key as a If you really want to work directly with the SEC1 format, it'd be good to avoid using the |
Thanks for the explanation, the error makes a lot more sense now. I had initially tried to just call |
Unfortunately In other crates in this repo we've made types like |
With a simple setup to generate a secp256k1 key pair, encode it to a pem, and then immediately decode the same pem and assert the secret keys are the same:
It fails to decode the pem's der contents, which panics with the message:
Manually testing via
openssl ec
, it can correctly decode the pem output, here's an example:I'm not sure if this usage is correct, but couldn't find a test or example that decodes a sec1 pem file, and it was pretty poorly documented otherwise.
The text was updated successfully, but these errors were encountered: