-
Notifications
You must be signed in to change notification settings - Fork 41
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 BLST bindings: Error handling for infinite values of sigs and vks #2322
base: main
Are you sure you want to change the base?
Conversation
Test Results 3 files ± 0 55 suites +3 11m 31s ⏱️ + 1m 7s Results for commit cf63d31. ± Comparison against base commit 01e15ab. This pull request removes 48 and adds 89 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
Co-authored-by: Jean-Philippe Raynaud <[email protected]>
let verify_aggregate = Signature::verify_aggregate(&msg, &mvks, &sigs); | ||
assert!(verify_aggregate.is_ok(), "Aggregate verification {verify_aggregate:?}"); | ||
|
||
match Signature::aggregate(&mvks, &sigs) { | ||
Ok((agg_vk, agg_sig)) => { | ||
batch_msgs.push(msg.to_vec()); | ||
batch_vk.push(agg_vk); | ||
batch_sig.push(agg_sig); | ||
} | ||
Err(MultiSignatureError::AggregateSignatureInvalid) => { | ||
println!("Aggregation failed."); | ||
} | ||
_ => unreachable!(), | ||
} | ||
} | ||
assert!(Signature::batch_verify_aggregates(&batch_msgs, &batch_vk, &batch_sig).is_ok()); | ||
let batch_verify_aggregates = Signature::batch_verify_aggregates(&batch_msgs, &batch_vk, &batch_sig); | ||
assert!(batch_verify_aggregates.is_ok(), "{batch_verify_aggregates:?}"); |
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 should be also rolled back as we have discussed.
match self.0.validate(true) { | ||
Ok(_) => blst_err_to_mithril( | ||
self.0.verify(false, msg, &[], &[], &mvk.0, false), | ||
Some(*self), | ||
None, | ||
), | ||
Err(e) => blst_err_to_mithril(e, Some(*self), None), | ||
} |
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.
Maybe this would be more readable:
match self.0.validate(true) { | |
Ok(_) => blst_err_to_mithril( | |
self.0.verify(false, msg, &[], &[], &mvk.0, false), | |
Some(*self), | |
None, | |
), | |
Err(e) => blst_err_to_mithril(e, Some(*self), None), | |
} | |
blst_err_to_mithril( | |
self.0.validate(true).map_or_else( | |
|e| e, | |
|_| self.0.verify(false, msg, &[], &[], &mvk.0, false), | |
), | |
Some(*self), | |
None, | |
) |
Content
If there is any identity element in the following vectors:
The content of the following vectors in
mithril-stm/src/multi_sig.rs
:Becomes vectors full of identity elements.
This PR includes the changes to avoid having an identity element in signature and verification lists.
In
mithril-stm/src/multi_sig.rs
:Signature::verify
function is updated: If signature is an infinity value, it returns an error.VerificationKeyPoP::check
function is updated: If the verification key is an infinity value, it returns an error.test_infinity_sig
test is added.test_infinity_vk
test is added.test_keyreg_with_infinity_vk
test is added.In
mithril-stm/src/error.rs
:MultiSignatureError
is updated to coverSignatureInfinity
VerificationKeyInfinity
impl From<MultiSignatureError> for StmSignatureError
is updated.impl<D: Digest + FixedOutput> From<MultiSignatureError> for StmAggregateSignatureError<D>
is updated.impl From<MultiSignatureError> for CoreVerifierError
is updated.pub(crate) fn blst_err_to_mithril
is updated.Pre-submit checklist
Issue(s)
Closes #2321