Browse Source

Make ToBitsGadget for FpVar's output constant-length (#12)

This is related to a Zexe issue https://github.com/scipr-lab/zexe/issues/289

Basically, ToBitsGadget for FpVar may produce shorter output for a constant value, which is undesired for a few reasons.
master
Weikeng Chen 4 years ago
committed by GitHub
parent
commit
8dca325042
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions
  1. +2
    -1
      src/fields/fp/mod.rs

+ 2
- 1
src/fields/fp/mod.rs

@ -876,7 +876,8 @@ impl ToBitsGadget for FpVar {
fn to_non_unique_bits_le(&self) -> Result<Vec<Boolean<F>>, SynthesisError> { fn to_non_unique_bits_le(&self) -> Result<Vec<Boolean<F>>, SynthesisError> {
use ark_ff::BitIteratorLE; use ark_ff::BitIteratorLE;
match self { match self {
Self::Constant(c) => Ok(BitIteratorLE::without_trailing_zeros(&c.into_repr())
Self::Constant(c) => Ok(BitIteratorLE::new(&c.into_repr())
.take((F::Params::MODULUS_BITS) as usize)
.map(Boolean::constant) .map(Boolean::constant)
.collect::<Vec<_>>()), .collect::<Vec<_>>()),
Self::Var(v) => v.to_non_unique_bits_le(), Self::Var(v) => v.to_non_unique_bits_le(),

Loading…
Cancel
Save