-
Notifications
You must be signed in to change notification settings - Fork 1
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
PEM and DER keys import test vectors #93
Comments
Hey @ochikov @petreze @bamzedev @deyanzz @rwalworth @SimiHunjan @rbair23 @izik1 We've created test vectors for PEM and DER key import. Please comment if you think we should add more tests |
hi! I mostly agree with these as-is, but I wanted to share some findings so that others don't have to go finding the same information again:
An example of wrapping an EcPrivateKey into a PrivateKeyInfo is as follows (note, there's no public key here because it's isn't required, if I included it, the public key would go in the EcPrivateKey not the PrivateKeyInfo):
Which should leave you with this key private key:
(same key as "Test unencrypted uncompressed PEM") edit: I'm not sure we need to support that format of key, to be clear, I'm mostly just mentioning it because it exists. |
Problem
Currently the SDKs are not compatible with ECDSA keys generated by OpenSSL. This can be confusing for users that reuse their keys on different chains and have used OpenSSL to generate their keys.
Solution
We need to support importing both the current and the OpenSSL versions keys. We provide test vectors for checking if the implementation is correct:
Test vector for ED25519 private key
PEM import
Test unencrypted PEM private key
PEM:
Private key:
e81b8da1e012a17b3d8d2dd9d51fd95534bb5311a0a8a2fdfcb00e5cdee25be5
Public key:
f7b9aa4a8e4eee94e4277dfe757d8d7cde027e7cd5349b7d8e6ee21c9b9395be
Test encrypted PEM private key
Encrypted PEM:
Passphrase:
asdasd123
Private key:
fa0857e963946d5f5e035684c40354d3cd3dcc80c0fb77beac2ef7c4b5271599
Public key:
202af61e141465d4bf2c356d37d18bd026c246bde4eb73258722ad11f790be4e
DER import
Test OpenSSL DER private key
Private key DER:
Private key:
feb858a4a69600a5eef2d9c76f7fb84fc0b6627f29e0ab17e160f640c267d404
Public key:
8ccd31b53d1835b467aac795dab19b274dd3b37e3daf12fcec6bc02bac87b53d
Test OpenSSL DER public key
Public key DER:
Public key:
8ccd31b53d1835b467aac795dab19b274dd3b37e3daf12fcec6bc02bac87b53d
Test vector for ECDSA private key
PEM import
Test unencrypted uncompressed PEM
PEM:
Private key:
6f08fa32a2fa21956bbb6d6df9e59cc2f901dbcfba06e00569ec7988eb95eeaa
Public key:
02a9fe4198c781ce453545af5401b649a37b72b553a56fb7ab4dcdfa2d12cfdb49
Test unencrypted compressed PEM
PEM:
Private key:
e1f285c9701db85addfdbcd4abddf3ce2b841ce5b71189c4267269009a807f63
Public key:
02444afa80565ae0aee104ff9b036e5576043ed0004580cfa0e51630fd6e93d4e8
Test encrypted uncompressed PEM
Encrypted PEM:
Passphrase:
asdasd123
Private key:
cf49eb5206c1b0468854d6ea7b370590619625514f71ff93608a18465e4012ad
Public key:
025f0d14a7562d6319e5b8f91620d2ce9ad13d9abf21cfe9bd0a092c0f35bf1701
Test encrypted compressed PEM
Encrypted PEM:
Passphrase:
asdasd123
Private key:
c0d3e16ba5a1abbeac4cd327a3c3c1cc10438431d0bac019054e573e67768bb5
Public key:
02065f736378134c53c7a2ee46f199fb93b9b32337be4e95660677046476995544
DER import
Test legacy DER private key
Private key DER:
Private key:
8c2cdc9575fe67493443967d74958fd7808a3787fd3337e99cfeebbc7566b586
Public key:
028173079d2e996ef6b2d064fc82d5fc7094367211e28422bec50a2f75c365f5fd
Test legacy DER public key
Public key DER:
Public key:
028173079d2e996ef6b2d064fc82d5fc7094367211e28422bec50a2f75c365f5fd
Test OpenSSL compatible compressed DER private key
Private key DER:
Private key:
ac318ea8ff8d991ab2f16172b4738e74dc35a56681199cfb1c0cb2e7cb560ffd
Public key:
036843f5cb338bbb4cdb21b0da4ea739d910951d6e8a5f703d313efe31afe788f4
Test OpenSSL compatible compressed DER public key
Public key DER:
Public key:
036843f5cb338bbb4cdb21b0da4ea739d910951d6e8a5f703d313efe31afe788f4
Test OpenSSL compatible uncompressed DER private key
Private key DER:
Private key:
8927647ad12b29646a1d051da8453462937bb2c813c6815cac6c0b720526ffc6
Public key:
03aaac1c3ac1bea0245b8e00ce1e2018f9eab61b6331fbef7266f2287750a65977
Test OpenSSL compatible uncompressed DER public key
Public key DER:
Public key:
03aaac1c3ac1bea0245b8e00ce1e2018f9eab61b6331fbef7266f2287750a65977
Test OpenSSL compatible DER private key without public key
Private key DER:
Private key:
a6170a6aa6389a5bd3a3a8f9375f57bd91aa7f7d8b8b46ce0b702e000a21a5fe
Public key:
03b69a75a5ddb1c0747e995d47555019e5d8a28003ab5202bd92f534361fb4ec8a
Alternatives
No response
The text was updated successfully, but these errors were encountered: