/// Compute a `LinearCombination` from a vector of `AllocatedNum`s, that are in fact bits. Used for range checks.
Compute a `LinearCombination` from a vector of `AllocatedNum`s, that are in fact bits. Used for range checks.
Compute a ` LinearCombination ` from a vector of ` AllocatedNum ` s that are in fact bits . Used for range checks .
pub fn lc_from_allocated_num_bits<Scalar: PrimeField, CS: ConstraintSystem<Scalar>>(
    bits: &[AllocatedNum<Scalar>],
) -> LinearCombination<Scalar> {
    assert!(bits.len() <= Scalar::CAPACITY as usize);
    // Initialise the value in number format.
    let mut lc = LinearCombination::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() {
        lc = lc + (coefficient, bit.get_variable());
        coefficient = coefficient.double();
    }
    // Return the number format of the input bits.
    lc
}
pub fn lc_from_allocated_num_bits < Scalar : PrimeField , CS : ConstraintSystem < Scalar > > ( bits : & [ AllocatedNum < Scalar > ] , ) -> LinearCombination < Scalar > { assert ! ( bits len ( ) Scalar CAPACITY as usize ) ; // Initialise the value in number format. let mut lc = LinearCombination :: 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 ( ) { lc = lc + ( coefficient , bit . get_variable ( ) ) ; coefficient = coefficient . double ( ) ; } // Return the number format of the input bits. lc }
Compute a `LinearCombination` from a vector of `AllocatedNum`s, that are in fact bits.
Compute a ` LinearCombination ` from a vector of ` AllocatedNum ` s that are in fact bits .
bits
&[AllocatedNum<Scalar>]