Rename into_bits and into_bits_strict to signify endianness.

This commit is contained in:
Sean Bowe 2018-03-05 15:12:51 -07:00
parent 3971ecd375
commit 8cbcd7739c
No known key found for this signature in database
GPG Key ID: 95684257D8F8B031
3 changed files with 12 additions and 10 deletions

View File

@ -105,11 +105,11 @@ impl<E: JubjubEngine> EdwardsPoint<E> {
{ {
let mut tmp = vec![]; let mut tmp = vec![];
let x = self.x.into_bits_strict( let x = self.x.into_bits_le_strict(
cs.namespace(|| "unpack x") cs.namespace(|| "unpack x")
)?; )?;
let y = self.y.into_bits_strict( let y = self.y.into_bits_le_strict(
cs.namespace(|| "unpack y") cs.namespace(|| "unpack y")
)?; )?;

View File

@ -250,10 +250,12 @@ impl<'a, E: JubjubEngine> Circuit<E> for Spend<'a, E> {
)?; )?;
// We don't need to be strict, because the function is // We don't need to be strict, because the function is
// collision-resistant. // collision-resistant. If the prover witnesses a congruency,
// they will be unable to find an authentication path in the
// tree with high probability.
let mut preimage = vec![]; let mut preimage = vec![];
preimage.extend(xl.into_bits(cs.namespace(|| "xl into bits"))?); preimage.extend(xl.into_bits_le(cs.namespace(|| "xl into bits"))?);
preimage.extend(xr.into_bits(cs.namespace(|| "xr into bits"))?); preimage.extend(xr.into_bits_le(cs.namespace(|| "xr into bits"))?);
cur = pedersen_hash::pedersen_hash( cur = pedersen_hash::pedersen_hash(
cs.namespace(|| "computation of pedersen hash"), cs.namespace(|| "computation of pedersen hash"),

View File

@ -88,7 +88,7 @@ impl<E: Engine> AllocatedNum<E> {
/// order, requiring that the representation /// order, requiring that the representation
/// strictly exists "in the field" (i.e., a /// strictly exists "in the field" (i.e., a
/// congruency is not allowed.) /// congruency is not allowed.)
pub fn into_bits_strict<CS>( pub fn into_bits_le_strict<CS>(
&self, &self,
mut cs: CS mut cs: CS
) -> Result<Vec<Boolean>, SynthesisError> ) -> Result<Vec<Boolean>, SynthesisError>
@ -220,7 +220,7 @@ impl<E: Engine> AllocatedNum<E> {
/// Convert the allocated number into its little-endian representation. /// Convert the allocated number into its little-endian representation.
/// Note that this does not strongly enforce that the commitment is /// Note that this does not strongly enforce that the commitment is
/// "in the field." /// "in the field."
pub fn into_bits<CS>( pub fn into_bits_le<CS>(
&self, &self,
mut cs: CS mut cs: CS
) -> Result<Vec<Boolean>, SynthesisError> ) -> Result<Vec<Boolean>, SynthesisError>
@ -565,7 +565,7 @@ mod test {
let mut cs = TestConstraintSystem::<Bls12>::new(); let mut cs = TestConstraintSystem::<Bls12>::new();
let n = AllocatedNum::alloc(&mut cs, || Ok(negone)).unwrap(); let n = AllocatedNum::alloc(&mut cs, || Ok(negone)).unwrap();
n.into_bits_strict(&mut cs).unwrap(); n.into_bits_le_strict(&mut cs).unwrap();
assert!(cs.is_satisfied()); assert!(cs.is_satisfied());
@ -587,9 +587,9 @@ mod test {
let n = AllocatedNum::alloc(&mut cs, || Ok(r)).unwrap(); let n = AllocatedNum::alloc(&mut cs, || Ok(r)).unwrap();
let bits = if i % 2 == 0 { let bits = if i % 2 == 0 {
n.into_bits(&mut cs).unwrap() n.into_bits_le(&mut cs).unwrap()
} else { } else {
n.into_bits_strict(&mut cs).unwrap() n.into_bits_le_strict(&mut cs).unwrap()
}; };
assert!(cs.is_satisfied()); assert!(cs.is_satisfied());