Skip to content
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

Closed
wants to merge 2 commits into from
Closed

Conversation

reinkrul
Copy link
Member

@reinkrul reinkrul commented Oct 26, 2023

TODO:

  • JWT signing test for ed25519

@reinkrul reinkrul force-pushed the secp256k1-support branch 2 times, most recently from 99c4597 to a18eace Compare November 23, 2023 13:32
@reinkrul reinkrul changed the title Support for secp256k1 Support secp256k1 and ed25519 keys Dec 12, 2023
@reinkrul reinkrul marked this pull request as ready for review December 12, 2023 14:37

const (
// ECP256Key is the key type for EC P-256
ECP256Key KeyType = "secp256r1"
Copy link
Member

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)" {
Copy link
Member

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" {
Copy link
Member

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
Copy link
Member

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?

Copy link
Member

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) {
Copy link
Member

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.

@woutslakhorst
Copy link
Member

Can use changes from #2686

@woutslakhorst woutslakhorst mentioned this pull request Feb 27, 2024
@reinkrul
Copy link
Member Author

Too outdated, wrong and we now support ES256K in some form.

@reinkrul reinkrul closed this Mar 26, 2024
@reinkrul reinkrul deleted the secp256k1-support branch March 26, 2024 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants