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
messages
is a slice of byte slices, one per signed message.signatures
is a slice ofSignature
s.public_keys
is a slice ofPublicKey
s.deduplicate_public_keys
csprng
is 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
Result
whoseOk
value is an empty tuple and whoseErr
value is aSignatureError
containing 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() );