fn gen_lagrange_coeff(
    signer_index: u64,
    signing_package: &SigningPackage,
) -> Result<Scalar, &'static str> {
    let mut num = Scalar::one();
    let mut den = Scalar::one();
    for commitment in signing_package.signing_commitments.iter() {
        if commitment.index == signer_index {
            continue;
        }
        num *= Scalar::from(commitment.index as u64);
        den *= Scalar::from(commitment.index as u64) - Scalar::from(signer_index as u64);
    }

    if den == Scalar::zero() {
        return Err("Duplicate shares provided");
    }

    // TODO: handle this unwrap better like other CtOption's
    let lagrange_coeff = num * den.invert().unwrap();

    Ok(lagrange_coeff)
}
/// Generates the lagrange coefficient for the i'th participant.
Generates the lagrange coefficient for the i'th participant.
Generates the lagrange coefficient for the i ' th participant .
fn gen_lagrange_coeff(
    signer_index: u64,
    signing_package: &SigningPackage,
) -> Result<Scalar, &'static str> {
    let mut num = Scalar::one();
    let mut den = Scalar::one();
    for commitment in signing_package.signing_commitments.iter() {
        if commitment.index == signer_index {
            continue;
        }
        num *= Scalar::from(commitment.index as u64);
        den *= Scalar::from(commitment.index as u64) - Scalar::from(signer_index as u64);
    }
    if den == Scalar::zero() {
        return Err("Duplicate shares provided");
    }
    // TODO: handle this unwrap better like other CtOption's
    let lagrange_coeff = num * den.invert().unwrap();
    Ok(lagrange_coeff)
}
fn gen_lagrange_coeff ( signer_index : u64 , signing_package : & SigningPackage , ) -> Result < Scalar , & ' static str > { let mut num = Scalar :: one ( ) ; let mut den = Scalar :: one ( ) ; for commitment in signing_package . signing_commitments . iter ( ) { if commitment . index == signer_index { continue ; } num *= Scalar :: from ( commitment . index as u64 ) ; den *= Scalar :: from ( commitment . index as u64 ) - Scalar :: from ( signer_index as u64 ) ; } if den == Scalar :: zero ( ) { return Err ( " " ) ; } // TODO: handle this unwrap better like other CtOption's let lagrange_coeff = num * den . invert ( ) . unwrap ( ) ; Ok ( lagrange_coeff ) }
Generates the lagrange coefficient for the i'th participant.
Generates the lagrange coefficient for the i ' th participant .
signer_index
u64
signing_package
&SigningPackage