Skip to content

Commit

Permalink
feat: add batch verification to ed25519
Browse files Browse the repository at this point in the history
  • Loading branch information
huitseeker authored and punwai committed Jul 15, 2022
1 parent 7f7db14 commit f1c2cb9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions crypto/src/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ impl VerifyingKey for Ed25519PublicKey {
type Sig = Ed25519Signature;
type Bytes = Ed25519PublicKeyBytes;
const LENGTH: usize = ed25519_dalek::PUBLIC_KEY_LENGTH;

fn verify_batch(msg: &[u8], pks: &[Self], sigs: &[Self::Sig]) -> Result<(), signature::Error> {
let msgs = vec![msg; pks.len()];
// TODO: replace this with some unsafe - but faster & non-alloc - implementation
let sigs: Vec<_> = sigs.iter().map(|s| s.0).collect();
let pks: Vec<_> = pks.iter().map(|p| p.0).collect();

ed25519_dalek::verify_batch(&msgs, &sigs, &pks)
}
}

impl Verifier<Ed25519Signature> for Ed25519PublicKey {
Expand Down

0 comments on commit f1c2cb9

Please sign in to comment.