-
Notifications
You must be signed in to change notification settings - Fork 16
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
Support secp256k1 and ed25519 keys #2564
Conversation
99c4597
to
a18eace
Compare
a18eace
to
0ee4a22
Compare
658f900
to
9bda90a
Compare
|
||
const ( | ||
// ECP256Key is the key type for EC P-256 | ||
ECP256Key KeyType = "secp256r1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"official" name is P-256
? What happened to 384 en 521?
case ed25519.PrivateKey: | ||
signer = k | ||
if err != nil { | ||
if err.Error() == "x509: failed to parse private key (use ParseECPrivateKey instead for this key format)" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An error message could very well change with an update. Could you check against a error const or maybe always try to parse using parseECPrivateKey
on failure?
func parseECPrivateKey(block *pem.Block) (crypto.Signer, error) { | ||
pk, err := x509.ParseECPrivateKey(block.Bytes) | ||
if err != nil { | ||
if err.Error() == "x509: unknown elliptic curve" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, very dodgy check.
See [the did core spec](https://www.w3.org/TR/did-core/#verification-method-types) for more information. | ||
default: JsonWebKey2020 | ||
enum: | ||
- JsonWebKey2020 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't JsonWebKey2020 support all algo's?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass key type but let proof format up to the impl?
@@ -137,3 +144,20 @@ func buildDocument(subject did.DID, verificationMethods []did.VerificationMethod | |||
} | |||
return document | |||
} | |||
|
|||
func cryptoKeyType(verificationMethodType ssi.KeyType) (crypto.KeyType, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mapping is wrong. all secp EC keys and RSA keys can be expressed with JsonWebKey2020.
Can use changes from #2686 |
Too outdated, wrong and we now support ES256K in some form. |
TODO: