-
Notifications
You must be signed in to change notification settings - Fork 87
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
Secp256r1 signature recovery and Ed25519 verification #486
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
5ad205a
Add support for Secp256r1 signature recovery
Dentosal 31f3815
Move crypto impls to fuel-crypto, add ED19 opcode
Dentosal b3368cf
Merge branch 'master' into dento/secp256r1
Dentosal 6e2dc4b
Fix formatting and imports after merge
Dentosal ae2bfa6
Fix ed25519 tests
Dentosal 6eedbaa
Use uncompressed public keys for secp256r1
Dentosal 92c2feb
Signature normalization
Dentosal 5a95708
Merge branch 'master' into dento/secp256r1
Dentosal 23bc5e2
Update newly merged tests to use the new eck1 instruction
Dentosal 1a3abb2
Workaround on self-dependency feature-enable for tests
Dentosal 728b90f
Fix changelog entries that merge messed up
Dentosal beccf9e
Fix entry order in changelog
Dentosal 3497153
Fix no_std build
Dentosal 8465fbf
Merge branch 'master' into dento/secp256r1
Dentosal 10eb824
Use verify_strict for ed25519
Dentosal d82082b
Document panic conditions of encode_signature
Dentosal d7a1228
fmt
Dentosal 51e2198
Added `test-helpers` feature to `fuel-crypto`
xgreenx 661514d
Merge branch 'master' into dento/secp256r1
xgreenx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//! ED25519 signature verification | ||
|
||
use ed25519_dalek::Signature; | ||
use fuel_types::{ | ||
Bytes32, | ||
Bytes64, | ||
}; | ||
|
||
use crate::{ | ||
Error, | ||
Message, | ||
}; | ||
|
||
/// Verify a signature against a message digest and a public key. | ||
pub fn verify( | ||
pub_key: &Bytes32, | ||
signature: &Bytes64, | ||
message: &Message, | ||
) -> Result<(), Error> { | ||
let Ok(signature) = Signature::from_bytes(&**signature) else { | ||
return Err(Error::InvalidSignature); | ||
}; | ||
|
||
let Ok(pub_key) = ed25519_dalek::PublicKey::from_bytes(&**pub_key) else { | ||
return Err(Error::InvalidPublicKey); | ||
}; | ||
|
||
if pub_key.verify_strict(&**message, &signature).is_ok() { | ||
Ok(()) | ||
} else { | ||
Err(Error::InvalidSignature) | ||
} | ||
} |
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
This file was deleted.
Oops, something went wrong.
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
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
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
File renamed without changes.
File renamed without changes.
Oops, something went wrong.
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.
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.
should we rexport the dalek lib, (maybe even under test-helpers)? That way applications using ed25519 don't have to worry about importing the correct version of dalek or pontentially compiling it twice.