-
Notifications
You must be signed in to change notification settings - Fork 144
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
fix: ECDSA and ED25519 public key mismatch when you get it from mnemonic #2451
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Ivaylo Nikolov <ivaylo.nikolov@limechain.tech>
Signed-off-by: Ivaylo Nikolov <ivaylo.nikolov@limechain.tech>
Signed-off-by: Ivaylo Nikolov <ivaylo.nikolov@limechain.tech>
gsstoykov
reviewed
Aug 7, 2024
Signed-off-by: Ivaylo Nikolov <ivaylo.nikolov@limechain.tech>
Signed-off-by: Ivaylo Nikolov <ivaylo.nikolov@limechain.tech>
Signed-off-by: Ivaylo Nikolov <ivaylo.nikolov@limechain.tech>
Quality Gate failedFailed conditions |
svetoslav-nikol0v
approved these changes
Aug 9, 2024
agadzhalov
approved these changes
Aug 9, 2024
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
This was referenced Aug 12, 2024
ivaylogarnev-limechain
pushed a commit
that referenced
this pull request
Aug 22, 2024
…nic (#2451) * fix: ecdsa public key mismatch when converting from mnemonic Signed-off-by: Ivaylo Nikolov <ivaylo.nikolov@limechain.tech> * fix: ed25519 public key mismatch when converting from mnemonic Signed-off-by: Ivaylo Nikolov <ivaylo.nikolov@limechain.tech> * refactor: add privatekey offset variable for better naming Signed-off-by: Ivaylo Nikolov <ivaylo.nikolov@limechain.tech> * feat(test): update stress test count Signed-off-by: Ivaylo Nikolov <ivaylo.nikolov@limechain.tech> * fix(test): remove await when unnecessary Signed-off-by: Ivaylo Nikolov <ivaylo.nikolov@limechain.tech> * fix(tests): add timeout on beforeEach test so it has enough time Signed-off-by: Ivaylo Nikolov <ivaylo.nikolov@limechain.tech> --------- Signed-off-by: Ivaylo Nikolov <ivaylo.nikolov@limechain.tech>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
This PR modifies the crypto package and in particular the ECDSA and ED25519 private key classes. A user found out that a mnemonic and a key that share the same private key mismatch their public key. In order to fix it, this PR modifies the ECDSA and ED25519 so they don't add trailing zeroes. This addition only happens only when the private key is shorter than 32 bytes. Example: 3030020100300706052b8104000a04220420a5b9dedc7c7767c4a88a0ac3cc6b9171948bada579226bd550d3342db11dc800
The last 2 trailing zeroes should be added after the DER prefix bytes (3030020100300706052b8104000a04220420)
e.g 3030020100300706052b8104000a0422042000a5b9dedc7c7767c4a88a0ac3cc6b9171948bada579226bd550d3342db11dc8
Fixes
#2419
Notes for reviewer:
Not sure if 100 tests are enough of a stress test but otherwise the test gets slow. For example 10000 iterations take around 15 seconds per test case. Considering there is 4 of these per file, thats gonna take 2 minute in total which in my opiion is a lot.
Checklist