Skip to content
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

Replace the quadradic duplicate check logic with a linear version #72

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/signature.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::io;
use std::{collections::HashSet, io};

#[cfg(feature = "multicore")]
use rayon::prelude::*;
Expand Down Expand Up @@ -139,12 +139,15 @@ pub fn verify(signature: &Signature, hashes: &[G2Projective], public_keys: &[Pub
// Enforce that messages are distinct as a countermeasure against BLS's rogue-key attack.
// See Section 3.1. of the IRTF's BLS signatures spec:
// https://tools.ietf.org/html/draft-irtf-cfrg-bls-signature-02#section-3.1
for i in 0..(n_hashes - 1) {
for j in (i + 1)..n_hashes {
if hashes[i] == hashes[j] {
return false;
}
}
if hashes
.iter()
// This is the best way to get something we can actually hash.
.map(|h| G2Affine::from(h).to_compressed())
.collect::<HashSet<_>>()
DrPeterVanNostrand marked this conversation as resolved.
Show resolved Hide resolved
.len()
!= hashes.len()
{
return false;
}

#[cfg(feature = "multicore")]
Expand Down
Loading