1- use blsful:: verify_secure_basic_with_mode;
2- use blsful:: { Bls12381G2Impl , PublicKey , SerializationFormat , Signature , SignatureSchemes } ;
3- use hashes:: Hash ;
4-
51use crate :: sml:: masternode_list_entry:: MasternodeListEntry ;
62use crate :: sml:: quorum_entry:: qualified_quorum_entry:: QualifiedQuorumEntry ;
73use crate :: sml:: quorum_validation_error:: QuorumValidationError ;
4+ use blsful:: inner_types:: GroupEncoding ;
5+ use blsful:: verify_secure_basic_with_mode;
6+ use blsful:: { Bls12381G2Impl , PublicKey , SerializationFormat , Signature , SignatureSchemes } ;
7+ use hashes:: Hash ;
88
99impl QualifiedQuorumEntry {
1010 /// Verifies the aggregated commitment signature for the quorum.
@@ -36,18 +36,12 @@ impl QualifiedQuorumEntry {
3636 let message = message. as_slice ( ) ;
3737
3838 // Collect public keys with proper legacy/modern deserialization
39- let mut uses_any_legacy = false ;
4039 let public_keys: Vec < PublicKey < Bls12381G2Impl > > = operator_keys
4140 . into_iter ( )
4241 . filter_map ( |masternode_list_entry| {
4342 let bytes = masternode_list_entry. operator_public_key . as_ref ( ) ;
4443 let is_legacy = masternode_list_entry. use_legacy_bls_keys ( ) ;
4544
46- // Track if any key uses legacy format
47- if is_legacy {
48- uses_any_legacy = true ;
49- }
50-
5145 let format = if is_legacy {
5246 SerializationFormat :: Legacy
5347 } else {
@@ -68,55 +62,12 @@ impl QualifiedQuorumEntry {
6862 . collect ( ) ;
6963
7064 // Deserialize the aggregated signature
71- // Note: We may need to handle legacy format for signatures as well
72- let sig_bytes = self . quorum_entry . all_commitment_aggregated_signature . as_bytes ( ) ;
73- let sig_format = if uses_any_legacy {
74- SerializationFormat :: Legacy
75- } else {
76- SerializationFormat :: Modern
77- } ;
78- let signature = Signature :: < Bls12381G2Impl > :: from_bytes_with_mode (
79- sig_bytes,
80- SignatureSchemes :: Basic ,
81- sig_format, // Use same format as keys
82- )
83- . map_err ( |e| {
84- QuorumValidationError :: AllCommitmentAggregatedSignatureNotValid ( e. to_string ( ) )
85- } ) ?;
86-
87- // Extract the inner signature for verify_secure
88- let inner_sig = match signature {
89- Signature :: Basic ( sig) => sig,
90- _ => {
91- return Err ( QuorumValidationError :: AllCommitmentAggregatedSignatureNotValid (
92- "Expected Basic signature scheme" . to_string ( ) ,
93- ) ) ;
94- }
95- } ;
65+ let signature: Signature < Bls12381G2Impl > =
66+ self . quorum_entry . all_commitment_aggregated_signature . try_into ( ) ?;
9667
97- // Verify using secure aggregation
98- // The legacy flag must match whether ANY of the keys used legacy format
99- let verified = verify_secure_basic_with_mode :: < Bls12381G2Impl , _ > (
100- & public_keys,
101- inner_sig,
102- message,
103- sig_format, // Use same format as keys and signature
104- )
105- . is_ok ( ) ;
106-
107- if verified {
108- Ok ( ( ) )
109- } else {
110- Err ( QuorumValidationError :: AllCommitmentAggregatedSignatureNotValid ( format ! (
111- "Signature verification failed: {} keys parsed, {} format used" ,
112- public_keys. len( ) ,
113- if uses_any_legacy {
114- "legacy"
115- } else {
116- "modern"
117- }
118- ) ) )
119- }
68+ signature. verify_secure ( & public_keys, message) . map_err ( |e| {
69+ QuorumValidationError :: AllCommitmentAggregatedSignatureNotValid ( e. to_string ( ) )
70+ } )
12071 }
12172
12273 /// Verifies the quorum's threshold signature.
0 commit comments