pub fn new(pubkeys: Vec<VerificationKey>) -> Result<Self, MusigError> {
        match pubkeys.len() {
            0 => {
                return Err(MusigError::BadArguments);
            }
            1 => {
                return Ok(Multikey {
                    transcript: None,
                    aggregated_key: pubkeys[0],
                });
            }
            _ => {}
        }

        // Create transcript for Multikey
        let mut transcript = Transcript::new(b"Musig.aggregated-key");
        transcript.commit_u64(b"n", pubkeys.len() as u64);

        // Commit pubkeys into the transcript
        // <L> = H(X_1 || X_2 || ... || X_n)
        for X in &pubkeys {
            transcript.commit_point(b"X", &X.0);
        }

        // aggregated_key = sum_i ( a_i * X_i )
        let mut aggregated_key = RistrettoPoint::default();
        for X in &pubkeys {
            let a = Multikey::compute_factor(&transcript, X);
            let X = X.0.decompress().ok_or(MusigError::InvalidPoint)?;
            aggregated_key = aggregated_key + a * X;
        }

        Ok(Multikey {
            transcript: Some(transcript),
            aggregated_key: VerificationKey(aggregated_key.compress()),
        })
    }
/// Constructs a new MuSig multikey aggregating the pubkeys.
Constructs a new MuSig multikey aggregating the pubkeys.
Constructs a new MuSig multikey aggregating the pubkeys .
pub fn new(pubkeys: Vec<VerificationKey>) -> Result<Self, MusigError> {
        match pubkeys.len() {
            0 => {
                return Err(MusigError::BadArguments);
            }
            1 => {
                return Ok(Multikey {
                    transcript: None,
                    aggregated_key: pubkeys[0],
                });
            }
            _ => {}
        }
        // Create transcript for Multikey
        let mut transcript = Transcript::new(b"Musig.aggregated-key");
        transcript.commit_u64(b"n", pubkeys.len() as u64);
        // Commit pubkeys into the transcript
        // <L> = H(X_1 || X_2 || ... || X_n)
        for X in &pubkeys {
            transcript.commit_point(b"X", &X.0);
        }
        // aggregated_key = sum_i ( a_i * X_i )
        let mut aggregated_key = RistrettoPoint::default();
        for X in &pubkeys {
            let a = Multikey::compute_factor(&transcript, X);
            let X = X.0.decompress().ok_or(MusigError::InvalidPoint)?;
            aggregated_key = aggregated_key + a * X;
        }
        Ok(Multikey {
            transcript: Some(transcript),
            aggregated_key: VerificationKey(aggregated_key.compress()),
        })
    }
pub fn new ( pubkeys : Vec < VerificationKey > ) -> Result < Self , MusigError > { match pubkeys . len ( ) { 0 => { return Err ( MusigError :: BadArguments ) ; } 1 => { return Ok ( Multikey { transcript : None , aggregated_key : pubkeys [ 0 ] , } ) ; } _ => { } } // Create transcript for Multikey let mut transcript = Transcript :: new ( b" " ) ; transcript . commit_u64 ( b" " , pubkeys . len ( ) as u64 ) ; // Commit pubkeys into the transcript // <L> = H(X_1 || X_2 || ... || X_n) for X in & pubkeys { transcript . commit_point ( b" " , & X . 0 ) ; } // aggregated_key = sum_i ( a_i * X_i ) let mut aggregated_key = RistrettoPoint :: default ( ) ; for X in & pubkeys { let a = Multikey :: compute_factor ( & transcript , X ) ; let X = X . 0 . decompress ( ) . ok_or ( MusigError :: InvalidPoint ) ? ; aggregated_key = aggregated_key + a * X ; } Ok ( Multikey { transcript : Some ( transcript ) , aggregated_key : VerificationKey ( aggregated_key . compress ( ) ) , } ) }
Constructs a new MuSig multikey aggregating the pubkeys.
Constructs a new MuSig multikey aggregating the pubkeys .
pubkeys
Vec<VerificationKey>
pubkeys
Vec<VerificationKey>