[−][src]Function schnorrkel::sign::verify_batch
pub fn verify_batch<T, I>(
transcripts: I,
signatures: &[Signature],
public_keys: &[PublicKey]
) -> SignatureResult<()> where
T: SigningTranscript,
I: IntoIterator<Item = T>,
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.csprng
is an implementation ofRng + 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 emtpy tuple and whoseErr
value is aSignatureError
containing a description of the internal error which occured.
Examples
extern crate schnorrkel; extern crate rand; use schnorrkel::{Keypair,PublicKey,Signature,verify_batch,signing_context}; use rand::thread_rng; use rand::rngs::ThreadRng; let ctx = signing_context(b"some batch"); let mut csprng: ThreadRng = thread_rng(); let keypairs: Vec<Keypair> = (0..64).map(|_| Keypair::generate(&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[..]).is_ok() );