#[cfg(feature = "std")] use sha2::Sha256; #[cfg(feature = "std")] use w3f_bls::{ multi_pop_aggregator::MultiMessageSignatureAggregatorAssumingPoP, schnorr_pop::SchnorrPoP, Keypair, Message, ProofOfPossession, ProofOfPossessionGenerator, PublicKey, Signed, ZBLS, }; /// Run using /// ```sh /// cargo run --example aggregated_with_pop /// ``` fn main() { #[cfg(feature = "std")] { let mut keypairs = [ Keypair::::generate(::rand::thread_rng()), Keypair::::generate(::rand::thread_rng()), ]; let msgs = [ "The ships", "hung in the sky", "in much the same way", "that bricks don’t.", ] .iter() .map(|m| Message::new(b"Some context", m.as_bytes())) .collect::>(); let sigs = msgs .iter() .zip(keypairs.iter_mut()) .map(|(m, k)| k.sign(m)) .collect::>(); let publickeys = keypairs .iter() .map(|k| k.public.clone()) .collect::>(); let pops = keypairs.iter_mut().map(|k|(ProofOfPossessionGenerator::, SchnorrPoP>::generate_pok(k))).collect::>(); //first make sure public keys have valid pop let publickeys = publickeys .iter() .zip(pops.iter()) .map(|(publickey, pop)| { assert!(ProofOfPossession::>::verify( pop, publickey )); publickey }) .collect::>(); let batch_poped = msgs.iter().zip(publickeys).zip(sigs).fold( MultiMessageSignatureAggregatorAssumingPoP::::new(), |mut bpop, ((message, publickey), sig)| { bpop.add_message_n_publickey(message, &publickey); bpop.add_signature(&sig); bpop }, ); assert!(batch_poped.verify()) } }