fn assert_less_than_r<E: Engine, CS: ConstraintSystem<E>>(bits: &[Bit], cs: &mut CS)
    -> Result<(), Error>
{
    let mut r_bits = vec![];
    for b in BitIterator::new(Fr::char()) {
        r_bits.push(FunBit::Constant(b));
    }
    r_bits.reverse();
    r_bits.truncate(E::Fr::num_bits() as usize);

    let mut carry = FunBit::Constant(false);

    for (a, b) in r_bits.into_iter().zip(bits.iter().cloned()) {
        let b = FunBit::from_bit(b);

        let t1 = a.xor(&b, cs)?;
        let t2 = a.not().and(&b, cs)?;
        let t3 = t1.not().and(&carry, cs)?;
        let t4 = t2.or(&t3, cs)?;

        carry = t4;
    }

    // dirty and somewhat cheap
    carry.assert_is_false(cs);

    Ok(())
}
/// Takes little-endian order bits, subtracts Fr and asserts
/// no carry.
Takes little-endian order bits, subtracts Fr and asserts
no carry.
Takes little - endian order bits subtracts Fr and asserts no carry .
fn assert_less_than_r<E: Engine, CS: ConstraintSystem<E>>(bits: &[Bit], cs: &mut CS)
    -> Result<(), Error>
{
    let mut r_bits = vec![];
    for b in BitIterator::new(Fr::char()) {
        r_bits.push(FunBit::Constant(b));
    }
    r_bits.reverse();
    r_bits.truncate(E::Fr::num_bits() as usize);
    let mut carry = FunBit::Constant(false);
    for (a, b) in r_bits.into_iter().zip(bits.iter().cloned()) {
        let b = FunBit::from_bit(b);
        let t1 = a.xor(&b, cs)?;
        let t2 = a.not().and(&b, cs)?;
        let t3 = t1.not().and(&carry, cs)?;
        let t4 = t2.or(&t3, cs)?;
        carry = t4;
    }
    // dirty and somewhat cheap
    carry.assert_is_false(cs);
    Ok(())
}
fn assert_less_than_r < E : Engine , CS : ConstraintSystem < E > > ( bits : & [ Bit ] , cs : & mut CS ) -> Result < ( ) , Error > { let mut r_bits = vec ! [ ] ; for b in BitIterator :: new ( Fr :: char ( ) ) { r_bits . push ( FunBit :: Constant ( b ) ) ; } r_bits . reverse ( ) ; r_bits . truncate ( E :: Fr :: num_bits ( ) as usize ) ; let mut carry = FunBit :: Constant ( false ) ; for ( a , b ) in r_bits . into_iter ( ) . zip ( bits . iter ( ) . cloned ( ) ) { let b = FunBit :: from_bit ( b ) ; let t1 = a . xor ( & b , cs ) ? ; let t2 = a . not ( ) . and ( & b , cs ) ? ; let t3 = t1 . not ( ) . and ( & carry , cs ) ? ; let t4 = t2 . or ( & t3 , cs ) ? ; carry = t4 ; } // dirty and somewhat cheap carry . assert_is_false ( cs ) ; Ok ( ( ) ) }
Takes little-endian order bits, subtracts Fr and asserts
no carry.
Takes little - endian order bits subtracts Fr and asserts no carry .
bits
&[Bit]
cs
&mut CS
bits
&[Bit]
cs
&mut CS