fn witness_bits<Scalar: PrimeField, CS: ConstraintSystem<Scalar>>(
    mut cs: CS,
    value: Option<&[u8]>,
    num_bits: usize,
) -> Result<Vec<Boolean>, SynthesisError> {
    let bit_values = if let Some(value) = value {
        let mut tmp = vec![];
        for b in value
            .iter()
            .flat_map(|&m| (0..8).rev().map(move |i| m >> i & 1 == 1))
        {
            tmp.push(Some(b));
        }
        tmp
    } else {
        vec![None; num_bits]
    };
    assert_eq!(bit_values.len(), num_bits);

    let mut bits = vec![];

    for (i, value) in bit_values.into_iter().enumerate() {
        bits.push(Boolean::from(AllocatedBit::alloc(
            cs.namespace(|| format!("bit {}", i)),
            value,
        )?));
    }

    Ok(bits)
}
/// Witness some bytes to the circuit.
Witness some bytes to the circuit.
Witness some bytes to the circuit .
fn witness_bits<Scalar: PrimeField, CS: ConstraintSystem<Scalar>>(
    mut cs: CS,
    value: Option<&[u8]>,
    num_bits: usize,
) -> Result<Vec<Boolean>, SynthesisError> {
    let bit_values = if let Some(value) = value {
        let mut tmp = vec![];
        for b in value
            .iter()
            .flat_map(|&m| (0..8).rev().map(move |i| m >> i & 1 == 1))
        {
            tmp.push(Some(b));
        }
        tmp
    } else {
        vec![None; num_bits]
    };
    assert_eq!(bit_values.len(), num_bits);
    let mut bits = vec![];
    for (i, value) in bit_values.into_iter().enumerate() {
        bits.push(Boolean::from(AllocatedBit::alloc(
            cs.namespace(|| format!("bit {}", i)),
            value,
        )?));
    }
    Ok(bits)
}
fn witness_bits < Scalar : PrimeField , CS : ConstraintSystem < Scalar > > ( mut cs : CS , value : Option < & [ u8 ] > , num_bits : usize , ) -> Result < Vec < Boolean > , SynthesisError > { let bit_values = if let Some ( value ) = value { let mut tmp = vec ! [ ] ; for b in value . iter ( ) . flat_map ( | & m | ( 0 .. 8 ) . rev ( ) . map ( move | i | m >> i & 1 == 1 ) ) { tmp . push ( Some ( b ) ) ; } tmp } else { vec ! [ None num_bits ] } ; assert_eq ! ( bit_values len ( ) num_bits ) ; let mut bits = vec ! [ ] ; for ( i , value ) in bit_values . into_iter ( ) . enumerate ( ) { bits . push ( Boolean :: from ( AllocatedBit :: alloc ( cs . namespace ( | | format ! ( " " i ) ) , value , ) ? ) ) ; } Ok ( bits ) }
Witness some bytes to the circuit.
Witness some bytes to the circuit .
cs
CS
value
Option<&[u8]>
num_bits
usize
cs
CS
value
Option<&[u8]>
num_bits
usize