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.
Weikeng Chen w.k@berkeley.edu
Thu, 12 Nov 2020 01:18:43 -0800
1 files changed,
2 insertions(+),
1 deletions(-)
jump to
M
src/fields/fp/mod.rs
→
src/fields/fp/mod.rs
@@ -876,7 +876,8 @@ #[tracing::instrument(target = "r1cs")]
fn to_non_unique_bits_le(&self) -> Result<Vec<Boolean<F>>, SynthesisError> { use ark_ff::BitIteratorLE; 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) .collect::<Vec<_>>()), Self::Var(v) => v.to_non_unique_bits_le(),