Skip to content

Commit

Permalink
arbitrary comparison for BLSVerKey
Browse files Browse the repository at this point in the history
  • Loading branch information
mrain committed Jan 12, 2024
1 parent b0d5562 commit 27b776f
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion primitives/src/signatures/bls_over_bn254.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,17 @@ impl AggregateableSignatureSchemes for BLSOverBN254CurveSignatureScheme {
// =====================================================
#[tagged(tag::BLS_SIGNING_KEY)]
#[derive(
Clone, Hash, Default, Zeroize, Eq, PartialEq, CanonicalSerialize, CanonicalDeserialize, Debug,
Clone,
Hash,
Default,
Zeroize,
Eq,
PartialEq,
CanonicalSerialize,
CanonicalDeserialize,
Debug,
Ord,
PartialOrd,
)]
#[zeroize(drop)]
/// Signing key for BLS signature.
Expand All @@ -250,6 +260,17 @@ impl PartialEq for VerKey {
}
}

// An arbitrary comparison for VerKey. Doesn't mean anything.
impl PartialOrd for VerKey {
fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
let mut bytes = ark_std::vec![];
CanonicalSerialize::serialize_compressed(self, &mut bytes).unwrap();
let mut others = ark_std::vec![];
CanonicalSerialize::serialize_compressed(other, &mut others).unwrap();
bytes.partial_cmp(&others)
}
}

impl VerKey {
/// Convert the verification key into the affine form.
pub fn to_affine(&self) -> G2Affine {
Expand Down

0 comments on commit 27b776f

Please sign in to comment.