Skip to content

Commit f87f669

Browse files
Merge pull request #96 from dashpay/fix/mnlist-engine-test-failures
fix: mnlist engine test failures
2 parents 408d4c7 + 92d4f17 commit f87f669

File tree

2 files changed

+10
-59
lines changed

2 files changed

+10
-59
lines changed

dash/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ hex = { version= "0.4" }
6666
bincode = { version= "=2.0.0-rc.3", optional = true }
6767
bincode_derive = { version= "=2.0.0-rc.3", optional = true }
6868
bitflags = "2.9.0"
69-
blsful = { git = "https://github.com/dashpay/agora-blsful", rev = "5f017aa1a0452ebc73e47f219f50c906522df4ea", optional = true }
69+
blsful = { git = "https://github.com/dashpay/agora-blsful", rev = "be108b2cf6ac64eedbe04f91c63731533c8956bc", optional = true }
7070
ed25519-dalek = { version = "2.1", features = ["rand_core"], optional = true }
7171
blake3 = "1.8.1"
7272
thiserror = "2"

dash/src/sml/quorum_entry/validation.rs

Lines changed: 9 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use blsful::verify_secure_basic_with_mode;
2-
use blsful::{Bls12381G2Impl, PublicKey, SerializationFormat, Signature, SignatureSchemes};
3-
use hashes::Hash;
4-
51
use crate::sml::masternode_list_entry::MasternodeListEntry;
62
use crate::sml::quorum_entry::qualified_quorum_entry::QualifiedQuorumEntry;
73
use 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

99
impl 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

Comments
 (0)