pub fn verify_batch(batch: &[DeferredVerification]) -> Result<(), MusigError> {
        // Get the total number of points in batch
        let dyn_length: usize = batch.iter().map(|p| p.dynamic_point_weights.len()).sum();
        let length = 2 + dyn_length; // include the (B, B_blinding) pair

        let mut weights: Vec<Scalar> = Vec::with_capacity(length + 2);
        let mut points: Vec<Option<RistrettoPoint>> = Vec::with_capacity(length);

        // Add base points
        points.push(Some(RISTRETTO_BASEPOINT_POINT));
        weights.push(Scalar::zero());

        let mut rng = rand::thread_rng();

        // Iterate over every point, adding both weights and points to
        // our arrays
        for p in batch.iter() {
            // Sample free variable e
            let e = Scalar::random(&mut rng);

            weights[0] = weights[0] + e * p.static_point_weight;

            // Add weights and points for arbitrary points
            let arbitrary_scalars = p.dynamic_point_weights.iter().map(|p| p.0 * e);
            let arbitrary_points = p.dynamic_point_weights.iter().map(|p| p.1.decompress());
            weights.extend(arbitrary_scalars);
            points.extend(arbitrary_points);
        }

        let check = RistrettoPoint::optional_multiscalar_mul(weights, points)
            .ok_or(MusigError::PointOperationFailed)?;
        if !check.is_identity() {
            return Err(MusigError::PointOperationFailed);
        }

        Ok(())
    }
/// Batched evaluation of deferred signature verification.
Batched evaluation of deferred signature verification.
Batched evaluation of deferred signature verification .
pub fn verify_batch(batch: &[DeferredVerification]) -> Result<(), MusigError> {
        // Get the total number of points in batch
        let dyn_length: usize = batch.iter().map(|p| p.dynamic_point_weights.len()).sum();
        let length = 2 + dyn_length; // include the (B, B_blinding) pair
        let mut weights: Vec<Scalar> = Vec::with_capacity(length + 2);
        let mut points: Vec<Option<RistrettoPoint>> = Vec::with_capacity(length);
        // Add base points
        points.push(Some(RISTRETTO_BASEPOINT_POINT));
        weights.push(Scalar::zero());
        let mut rng = rand::thread_rng();
        // Iterate over every point, adding both weights and points to
        // our arrays
        for p in batch.iter() {
            // Sample free variable e
            let e = Scalar::random(&mut rng);
            weights[0] = weights[0] + e * p.static_point_weight;
            // Add weights and points for arbitrary points
            let arbitrary_scalars = p.dynamic_point_weights.iter().map(|p| p.0 * e);
            let arbitrary_points = p.dynamic_point_weights.iter().map(|p| p.1.decompress());
            weights.extend(arbitrary_scalars);
            points.extend(arbitrary_points);
        }
        let check = RistrettoPoint::optional_multiscalar_mul(weights, points)
            .ok_or(MusigError::PointOperationFailed)?;
        if !check.is_identity() {
            return Err(MusigError::PointOperationFailed);
        }
        Ok(())
    }
pub fn verify_batch ( batch : & [ DeferredVerification ] ) -> Result < ( ) , MusigError > { // Get the total number of points in batch let dyn_length : usize = batch . iter ( ) . map ( | p | p . dynamic_point_weights . len ( ) ) . sum ( ) ; let length = 2 + dyn_length ; // include the (B, B_blinding) pair let mut weights : Vec < Scalar > = Vec :: with_capacity ( length + 2 ) ; let mut points : Vec < Option < RistrettoPoint > > = Vec :: with_capacity ( length ) ; // Add base points points . push ( Some ( RISTRETTO_BASEPOINT_POINT ) ) ; weights . push ( Scalar :: zero ( ) ) ; let mut rng = rand :: thread_rng ( ) ; // Iterate over every point, adding both weights and points to // our arrays for p in batch . iter ( ) { // Sample free variable e let e = Scalar :: random ( & mut rng ) ; weights [ 0 ] = weights [ 0 ] + e * p . static_point_weight ; // Add weights and points for arbitrary points let arbitrary_scalars = p . dynamic_point_weights . iter ( ) . map ( | p | p . 0 * e ) ; let arbitrary_points = p . dynamic_point_weights . iter ( ) . map ( | p | p . 1 . decompress ( ) ) ; weights . extend ( arbitrary_scalars ) ; points . extend ( arbitrary_points ) ; } let check = RistrettoPoint :: optional_multiscalar_mul ( weights , points ) . ok_or ( MusigError :: PointOperationFailed ) ? ; if ! check . is_identity ( ) { return Err ( MusigError :: PointOperationFailed ) ; } Ok ( ( ) ) }
Batched evaluation of deferred signature verification.
Batched evaluation of deferred signature verification .
batch
&[DeferredVerification]
batch
&[DeferredVerification]