Function schnorrkel::verify_batch
source · pub fn verify_batch<T, I>(
transcripts: I,
signatures: &[Signature],
public_keys: &[PublicKey],
deduplicate_public_keys: bool,
) -> SignatureResult<()>where
T: SigningTranscript,
I: IntoIterator<Item = T>,Expand description
Verify a batch of signatures on messages with their respective public_keys.
§Inputs
messagesis a slice of byte slices, one per signed message.signaturesis a slice ofSignatures.public_keysis a slice ofPublicKeys.deduplicate_public_keyscsprngis an implementation ofRngCore+CryptoRng, such asrand::ThreadRng.
§Panics
This function will panic if the messages, signatures, and public_keys`
slices are not equal length.
§Returns
- A
ResultwhoseOkvalue is an empty tuple and whoseErrvalue is aSignatureErrorcontaining a description of the internal error which occurred.
§Examples
use schnorrkel::{Keypair,PublicKey,Signature,verify_batch,signing_context};
let ctx = signing_context(b"some batch");
let mut csprng = rand::thread_rng();
let keypairs: Vec<Keypair> = (0..64).map(|_| Keypair::generate_with(&mut csprng)).collect();
let msg: &[u8] = b"They're good dogs Brant";
let signatures: Vec<Signature> = keypairs.iter().map(|key| key.sign(ctx.bytes(&msg))).collect();
let public_keys: Vec<PublicKey> = keypairs.iter().map(|key| key.public).collect();
let transcripts = std::iter::once(ctx.bytes(msg)).cycle().take(64);
assert!( verify_batch(transcripts, &signatures[..], &public_keys[..], false).is_ok() );