-
Notifications
You must be signed in to change notification settings - Fork 145
feat: FIP-0079: syscall for aggregated bls verification #2003
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
32b9034
feat: syscall for aggregated bls verification (FIP-0079)
hanabi1224 b946e34
Merge remote-tracking branch 'origin/master' into hm/fip-0079
hanabi1224 82418e1
tests
hanabi1224 3d8fab2
use feature `verify-signature` instead of `no-verify-signature`
hanabi1224 169d615
feature flag sig_cost and on_verify_signature
hanabi1224 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -220,6 +220,7 @@ pub trait ActorOps { | |
fn balance_of(&self, actor_id: ActorID) -> Result<TokenAmount>; | ||
} | ||
|
||
#[cfg(feature = "verify-signature")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we not put this on the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It appears that the answer is no. Oh well... |
||
/// Cryptographic primitives provided by the kernel. | ||
#[delegatable_trait] | ||
pub trait CryptoOps { | ||
|
@@ -232,6 +233,56 @@ pub trait CryptoOps { | |
plaintext: &[u8], | ||
) -> Result<bool>; | ||
|
||
/// Verifies a BLS aggregate signature. In the case where there is one signer/signed plaintext, | ||
/// this is equivalent to verifying a non-aggregated BLS signature. | ||
/// | ||
/// Returns: | ||
/// - `Ok(true)` on a valid signature. | ||
/// - `Ok(false)` on an invalid signature or if the signature or public keys' bytes represent an | ||
/// invalid curve point. | ||
/// - `Err(IllegalArgument)` if `pub_keys.len() != plaintexts.len()`. | ||
fn verify_bls_aggregate( | ||
&self, | ||
aggregate_sig: &[u8; fvm_shared::crypto::signature::BLS_SIG_LEN], | ||
pub_keys: &[[u8; fvm_shared::crypto::signature::BLS_PUB_LEN]], | ||
plaintexts_concat: &[u8], | ||
plaintext_lens: &[u32], | ||
) -> Result<bool>; | ||
|
||
/// Given a message hash and its signature, recovers the public key of the signer. | ||
fn recover_secp_public_key( | ||
&self, | ||
hash: &[u8; SECP_SIG_MESSAGE_HASH_SIZE], | ||
signature: &[u8; SECP_SIG_LEN], | ||
) -> Result<[u8; SECP_PUB_LEN]>; | ||
|
||
/// Hashes input `data_in` using with the specified hash function, writing the output to | ||
/// `digest_out`, returning the size of the digest written to `digest_out`. If `digest_out` is | ||
/// to small to fit the entire digest, it will be truncated. If too large, the leftover space | ||
/// will not be overwritten. | ||
fn hash(&self, code: u64, data: &[u8]) -> Result<Multihash>; | ||
} | ||
|
||
#[cfg(not(feature = "verify-signature"))] | ||
/// Cryptographic primitives provided by the kernel. | ||
#[delegatable_trait] | ||
pub trait CryptoOps { | ||
/// Verifies a BLS aggregate signature. In the case where there is one signer/signed plaintext, | ||
/// this is equivalent to verifying a non-aggregated BLS signature. | ||
/// | ||
/// Returns: | ||
/// - `Ok(true)` on a valid signature. | ||
/// - `Ok(false)` on an invalid signature or if the signature or public keys' bytes represent an | ||
/// invalid curve point. | ||
/// - `Err(IllegalArgument)` if `pub_keys.len() != plaintexts.len()`. | ||
fn verify_bls_aggregate( | ||
&self, | ||
aggregate_sig: &[u8; fvm_shared::crypto::signature::BLS_SIG_LEN], | ||
pub_keys: &[[u8; fvm_shared::crypto::signature::BLS_PUB_LEN]], | ||
plaintexts_concat: &[u8], | ||
plaintext_lens: &[u32], | ||
) -> Result<bool>; | ||
|
||
/// Given a message hash and its signature, recovers the public key of the signer. | ||
fn recover_secp_public_key( | ||
&self, | ||
|
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.