-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Secp256r1 signature recovery and Ed25519 verification (#486)
* Add support for Secp256r1 signature recovery * Move crypto impls to fuel-crypto, add ED19 opcode * Fix formatting and imports after merge * Fix ed25519 tests * Use uncompressed public keys for secp256r1 * Signature normalization * Update newly merged tests to use the new eck1 instruction * Workaround on self-dependency feature-enable for tests * Fix changelog entries that merge messed up * Fix entry order in changelog * Fix no_std build * Use verify_strict for ed25519 * Document panic conditions of encode_signature * fmt * Added `test-helpers` feature to `fuel-crypto` --------- Co-authored-by: green <xgreenx9999@gmail.com>
- Loading branch information
Showing
30 changed files
with
778 additions
and
318 deletions.
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.