/// Compute a `Num` from a vector of bits.
Compute a `Num` from a vector of bits.
Compute a ` Num ` from a vector of bits .
pub fn num_from_bits<Scalar: PrimeField, CS: ConstraintSystem<Scalar>>(
    bits: &[Boolean],
) -> Num<Scalar> {
    assert!(bits.len() <= Scalar::CAPACITY as usize);
    // Initialise the value in number format.
    let mut value_num = Num::zero();
    // Initialise the coefficient for double-and-add to 1.
    let mut coefficient = Scalar::one();
    // Execute double-and-add algorithm to construct the number format from the bit format.
    // Note: reverse the bits, such that the complete number is correct.
    for bit in bits.iter().rev() {
        value_num = value_num.add_bool_with_coeff(CS::one(), bit, coefficient);
        coefficient = coefficient.double();
    }
    // Return the number format of the input bits.
    value_num
}
pub fn num_from_bits < Scalar : PrimeField , CS : ConstraintSystem < Scalar > > ( bits : & [ Boolean ] , ) -> Num < Scalar > { assert ! ( bits len ( ) Scalar CAPACITY as usize ) ; // Initialise the value in number format. let mut value_num = Num :: zero ( ) ; // Initialise the coefficient for double-and-add to 1. let mut coefficient = Scalar :: one ( ) ; // Execute double-and-add algorithm to construct the number format from the bit format. // Note: reverse the bits, such that the complete number is correct. for bit in bits . iter ( ) . rev ( ) { value_num = value_num . add_bool_with_coeff ( CS :: one ( ) , bit , coefficient ) ; coefficient = coefficient . double ( ) ; } // Return the number format of the input bits. value_num }
Compute a `Num` from a vector of bits.
Compute a ` Num ` from a vector of bits .
bits
&[Boolean]