-
Notifications
You must be signed in to change notification settings - Fork 30
test: add Ed25519 conformance tests #219
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
Conversation
- Add sign1-sign-0007.json: Ed25519 signing test vector - Add sign1-verify-0007.json: Ed25519 verification test vector - Add sign1-verify-negative-0004.json: Ed25519 negative verification test - Update conformance_test.go to support OKP key type and EdDSA algorithm - Add mustBase64ToBytes() helper for base64url decoding - Modify testSign1() to use nil rand for deterministic EdDSA signatures Fixes veraison#171 Signed-off-by: Sukuna0007Abhi <[email protected]>
| return cose.AlgorithmES384 | ||
| case "ES512": | ||
| return cose.AlgorithmES512 | ||
| case "EdDSA": |
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.
Technically this could also mean Ed448.
Consider if anything here is helpful:
https://datatracker.ietf.org/doc/draft-ietf-jose-fully-specified-algorithms/13/
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.
Sure sir @OR13 , thanks for the approval
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.
Hi sir @OR13 Good point about Ed448. I've added placeholder support for it with proper error messages and comments about the key size differences (57-byte vs 32-byte seeds). The code structure now makes it easy to add Ed448 implementation later when golang.org/x/crypto/ed448 is integrated. Both curves correctly use AlgorithmEdDSA = -8 with curve differentiation in the key's "crv" field.
- Add Ed448 case with clear 'not yet implemented' message - Add comments about Ed448 key size differences (57 vs 32 bytes) - Document that Ed448 would require golang.org/x/crypto/ed448 - Maintain backward compatibility while preparing for future expansion This addresses the mentor's suggestion about supporting both Ed25519 and Ed448 under the EdDSA algorithm identifier. Signed-off-by: Sukuna0007Abhi <[email protected]>
|
Ready for review and merge as sir @OR13 approved it |
|
@shizhMSFT, @qmuntal can either of you PTAL? |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #219 +/- ##
==========================================
+ Coverage 91.23% 91.37% +0.14%
==========================================
Files 13 13
Lines 2133 2133
==========================================
+ Hits 1946 1949 +3
+ Misses 128 125 -3
Partials 59 59 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Pull Request Overview
This PR adds conformance tests for Ed25519 signatures using the EdDSA algorithm to address issue #171. The change extends the existing test suite with Ed25519 cryptographic support and ensures deterministic signature generation.
- Adds Ed25519 test vectors for signing, verification, and negative verification scenarios
- Implements OKP (Octet Key Pair) key type support with Ed25519 curve handling
- Modifies signature generation to use nil rand parameter for deterministic EdDSA signatures
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| testdata/sign1-sign-0007.json | Ed25519 signing test vector with expected deterministic output |
| testdata/sign1-verify-0007.json | Ed25519 verification test vector for valid signature |
| testdata/sign1-verify-negative-0004.json | Ed25519 negative test case with invalid signature |
| conformance_test.go | Adds OKP key support, EdDSA algorithm handling, and deterministic signing logic |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
conformance_test.go
Outdated
| case "OKP": | ||
| // Only Ed25519 is supported for now | ||
| switch key["crv"] { | ||
| case "Ed25519": | ||
| publicKey := mustBase64ToBytes(key["x"]) | ||
| if len(publicKey) != ed25519.PublicKeySize { | ||
| return nil, errors.New("invalid Ed25519 public key size") | ||
| } | ||
| if private { | ||
| privateKey := mustBase64ToBytes(key["d"]) | ||
| if len(privateKey) != ed25519.SeedSize { | ||
| return nil, errors.New("invalid Ed25519 private key size") | ||
| } | ||
| // Ed25519 private key is 64 bytes: 32-byte seed + 32-byte public key | ||
| fullPrivateKey := ed25519.NewKeyFromSeed(privateKey) | ||
| return fullPrivateKey, nil | ||
| } | ||
| // For public key only operations, we need to return a type that satisfies crypto.Signer | ||
| // but this won't work for verify-only operations. We'll handle this in getSigner. | ||
| return nil, errors.New("OKP public-only key not supported in this context") |
Copilot
AI
Oct 6, 2025
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.
The OKP key handling logic is duplicated between the getKey function and the getSigner function. Consider extracting the Ed25519 key creation logic into a separate helper function to reduce code duplication.
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 is a very valid comment, which needs to be incorporated!
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.
Ok sir @yogeshbdeshpande I will more review this one...
conformance_test.go
Outdated
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| t.Logf("Test case: %s, Key type: %s", tc.Title, tc.Key["kty"]) |
Copilot
AI
Oct 6, 2025
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.
The debug logging statements should be removed or replaced with conditional debug logging. These logs will clutter test output in normal runs and are typically only needed during development.
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 one is great, changes will be made fr...
conformance_test.go
Outdated
| } | ||
| t.Logf("Algorithm: %s, using rand: %v", tc.Alg, rand) | ||
| t.Logf("Payload: %x", sigMsg.Payload) | ||
| t.Logf("Protected: %+v", sigMsg.Headers.Protected) |
Copilot
AI
Oct 6, 2025
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.
The debug logging statements should be removed or replaced with conditional debug logging. These logs will clutter test output in normal runs and are typically only needed during development.
| t.Logf("Protected: %+v", sigMsg.Headers.Protected) | |
| if testing.Verbose() { | |
| t.Logf("Protected: %+v", sigMsg.Headers.Protected) | |
| } |
shizhMSFT
left a comment
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.
Thanks for your contribution! No special concerns and LGTM.
I've changed the PR title to conventional commits as this PR will be squash merged.
Please also take a look at the comments provided by Copilot and validate if they are relevant.
|
Thanks sir @shizhMSFT for the approval, I will review the suggestions of copilot and if needed I will update the code, |
- Remove verbose debug logging to match existing test style - Extract Ed25519 key creation logic into createEd25519Key() helper function - Eliminate code duplication between getSigner() and getKey() functions - Improve code maintainability while preserving all functionality Addresses feedback from @yogeshbdeshpande and GitHub Copilot code review. Signed-off-by: Sukuna0007Abhi <[email protected]>
|
Hi sir @shizhMSFT @SteveLasker @yogeshbdeshpande @henkbirkholz @OR13 @thomas-fossati @qmuntal ready for review and merge, as I addressed all copilot suggestions also |
shizhMSFT
left a comment
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.
LGTM
|
Thanks sir @shizhMSFT |
| if tc.Key["kty"] == "OKP" { | ||
| switch tc.Key["crv"] { | ||
| case "Ed25519": | ||
| // Note: Ed448 would require different key size validation (57 bytes) |
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.
Is comment on line 207 correct ?
Should it not be Ed25519 ?
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.
Yes sir @yogeshbdeshpande you're right I didn't put another line though,
I am actually thought of putting "We're currently handling Ed25519, but if we added Ed448, it would require different key size validation (57 bytes)"
But now I think it's merged so any member can change and commit this comment change part ,
Thanks great catching sir...
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.
@Sukuna0007Abhi , please create a small minor edit PR and work on improving this...
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.
Sure sir @yogeshbdeshpande will do that
SteveLasker
left a comment
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.
Thank you @Sukuna0007Abhi for the contribution and thanks @OR13, @shizhMSFT, @yogeshbdeshpande for the review.
LGTM
|
Thank you sir @SteveLasker @OR13 @yogeshbdeshpande @shizhMSFT @henkbirkholz @thomas-fossati @setrofim ; |
Description
This PR adds conformance tests for Ed25519 signatures to address issue #171.
Changes
sign1-sign-0007.json: Ed25519 signing test vectorsign1-verify-0007.json: Ed25519 verification test vectorsign1-verify-negative-0004.json: Ed25519 negative verification testconformance_test.goto support OKP (Octet Key Pair) key type and EdDSA algorithmmustBase64ToBytes()helper function for base64url decodingtestSign1()to use nil rand parameter for deterministic EdDSA signaturesTest Results
All 21 conformance tests now pass (up from 18):
Technical Notes
nilfor the rand parameter, unlike ECDSA/RSA which usezeroSourceFixes #171
Ready for review sir @thomas-fossati @setrofim @yogeshbdeshpande @SimonFrost-Arm @OR13 @henkbirkholz