pub fn pack_into_inputs<E, CS>(mut cs: CS, bits: &[Boolean]) -> Result<(), SynthesisError>
where
    E: ScalarEngine,
    CS: ConstraintSystem<E>,
{
    for (i, bits) in bits.chunks(E::Fr::CAPACITY as usize).enumerate() {
        let mut num = Num::<E>::zero();
        let mut coeff = E::Fr::one();
        for bit in bits {
            num = num.add_bool_with_coeff(CS::one(), bit, coeff);

            coeff.double();
        }

        let input = cs.alloc_input(|| format!("input {}", i), || Ok(*num.get_value().get()?))?;

        // num * 1 = input
        cs.enforce(
            || format!("packing constraint {}", i),
            |_| num.lc(E::Fr::one()),
            |lc| lc + CS::one(),
            |lc| lc + input,
        );
    }

    Ok(())
}
/// Takes a sequence of booleans and exposes them as compact
/// public inputs
Takes a sequence of booleans and exposes them as compact
public inputs
Takes a sequence of booleans and exposes them as compact public inputs
pub fn pack_into_inputs<E, CS>(mut cs: CS, bits: &[Boolean]) -> Result<(), SynthesisError>
where
    E: ScalarEngine,
    CS: ConstraintSystem<E>,
{
    for (i, bits) in bits.chunks(E::Fr::CAPACITY as usize).enumerate() {
        let mut num = Num::<E>::zero();
        let mut coeff = E::Fr::one();
        for bit in bits {
            num = num.add_bool_with_coeff(CS::one(), bit, coeff);
            coeff.double();
        }
        let input = cs.alloc_input(|| format!("input {}", i), || Ok(*num.get_value().get()?))?;
        // num * 1 = input
        cs.enforce(
            || format!("packing constraint {}", i),
            |_| num.lc(E::Fr::one()),
            |lc| lc + CS::one(),
            |lc| lc + input,
        );
    }
    Ok(())
}
pub fn pack_into_inputs < E , CS > ( mut cs : CS , bits : & [ Boolean ] ) -> Result < ( ) , SynthesisError > where E : ScalarEngine , CS : ConstraintSystem < E > , { for ( i , bits ) in bits . chunks ( E :: Fr :: CAPACITY as usize ) . enumerate ( ) { let mut num = Num :: < E > :: zero ( ) ; let mut coeff = E :: Fr :: one ( ) ; for bit in bits { num = num . add_bool_with_coeff ( CS :: one ( ) , bit , coeff ) ; coeff . double ( ) ; } let input = cs . alloc_input ( | | format ! ( " " i ) , | | Ok ( * num . get_value ( ) . get ( ) ? ) ) ? ; // num * 1 = input cs . enforce ( | | format ! ( " " i ) , | _ | num . lc ( E :: Fr :: one ( ) ) , | lc | lc + CS :: one ( ) , | lc | lc + input , ) ; } Ok ( ( ) ) }
Takes a sequence of booleans and exposes them as compact
public inputs
Takes a sequence of booleans and exposes them as compact public inputs
cs
CS
bits
&[Boolean]
cs
CS
bits
&[Boolean]