mirror of
https://github.com/arnaucube/Nova.git
synced 2026-01-10 16:11:29 +01:00
Clippy formatting (#131)
* Clippy with Rust 1.67 * Clippy/Rustfmt with Rust 1.66.1
This commit is contained in:
@@ -12,7 +12,7 @@ keywords = ["zkSNARKs", "cryptography", "proofs"]
|
||||
|
||||
[dependencies]
|
||||
bellperson = { version = "0.24", default-features = false }
|
||||
ff = { version = "0.12.0", features = ["derive"]}
|
||||
ff = { version = "0.12.0", features = ["derive"] }
|
||||
merlin = "2.0.0"
|
||||
digest = "0.8.1"
|
||||
sha3 = "0.8.2"
|
||||
@@ -49,4 +49,4 @@ name = "compressed-snark"
|
||||
harness = false
|
||||
|
||||
[features]
|
||||
default = [ "bellperson/default", "neptune/default" ]
|
||||
default = []
|
||||
|
||||
@@ -38,7 +38,7 @@ fn bench_compressed_snark(c: &mut Criterion) {
|
||||
// number of constraints in the step circuit
|
||||
let num_cons = num_cons_in_augmented_circuit - num_cons_verifier_circuit_primary;
|
||||
|
||||
let mut group = c.benchmark_group(format!("CompressedSNARK-StepCircuitSize-{}", num_cons));
|
||||
let mut group = c.benchmark_group(format!("CompressedSNARK-StepCircuitSize-{num_cons}"));
|
||||
group.sample_size(num_samples);
|
||||
|
||||
// Produce public parameters
|
||||
@@ -143,7 +143,7 @@ where
|
||||
let mut x = z[0].clone();
|
||||
let mut y = x.clone();
|
||||
for i in 0..self.num_cons {
|
||||
y = x.square(cs.namespace(|| format!("x_sq_{}", i)))?;
|
||||
y = x.square(cs.namespace(|| format!("x_sq_{i}")))?;
|
||||
x = y.clone();
|
||||
}
|
||||
Ok(vec![y])
|
||||
|
||||
@@ -35,7 +35,7 @@ fn bench_recursive_snark(c: &mut Criterion) {
|
||||
// number of constraints in the step circuit
|
||||
let num_cons = num_cons_in_augmented_circuit - num_cons_verifier_circuit_primary;
|
||||
|
||||
let mut group = c.benchmark_group(format!("RecursiveSNARK-StepCircuitSize-{}", num_cons));
|
||||
let mut group = c.benchmark_group(format!("RecursiveSNARK-StepCircuitSize-{num_cons}"));
|
||||
group.sample_size(10);
|
||||
|
||||
// Produce public parameters
|
||||
@@ -144,7 +144,7 @@ where
|
||||
let mut x = z[0].clone();
|
||||
let mut y = x.clone();
|
||||
for i in 0..self.num_cons {
|
||||
y = x.square(cs.namespace(|| format!("x_sq_{}", i)))?;
|
||||
y = x.square(cs.namespace(|| format!("x_sq_{i}")))?;
|
||||
x = y.clone();
|
||||
}
|
||||
Ok(vec![y])
|
||||
|
||||
@@ -97,7 +97,7 @@ where
|
||||
for i in 0..self.seq.len() {
|
||||
// non deterministic advice
|
||||
let x_i_plus_1 =
|
||||
AllocatedNum::alloc(cs.namespace(|| format!("x_i_plus_1_iter_{}", i)), || {
|
||||
AllocatedNum::alloc(cs.namespace(|| format!("x_i_plus_1_iter_{i}")), || {
|
||||
Ok(self.seq[i].x_i_plus_1)
|
||||
})?;
|
||||
|
||||
@@ -106,12 +106,11 @@ where
|
||||
// (ii) y_i_plus_1 = x_i
|
||||
// (1) constraints for condition (i) are below
|
||||
// (2) constraints for condition (ii) is avoided because we just used x_i wherever y_i_plus_1 is used
|
||||
let x_i_plus_1_sq =
|
||||
x_i_plus_1.square(cs.namespace(|| format!("x_i_plus_1_sq_iter_{}", i)))?;
|
||||
let x_i_plus_1_sq = x_i_plus_1.square(cs.namespace(|| format!("x_i_plus_1_sq_iter_{i}")))?;
|
||||
let x_i_plus_1_quad =
|
||||
x_i_plus_1_sq.square(cs.namespace(|| format!("x_i_plus_1_quad_{}", i)))?;
|
||||
x_i_plus_1_sq.square(cs.namespace(|| format!("x_i_plus_1_quad_{i}")))?;
|
||||
cs.enforce(
|
||||
|| format!("x_i_plus_1_quad * x_i_plus_1 = x_i + y_i_iter_{}", i),
|
||||
|| format!("x_i_plus_1_quad * x_i_plus_1 = x_i + y_i_iter_{i}"),
|
||||
|lc| lc + x_i_plus_1_quad.get_variable(),
|
||||
|lc| lc + x_i_plus_1.get_variable(),
|
||||
|lc| lc + x_i.get_variable() + y_i.get_variable(),
|
||||
@@ -163,10 +162,7 @@ fn main() {
|
||||
|
||||
let circuit_secondary = TrivialTestCircuit::default();
|
||||
|
||||
println!(
|
||||
"Proving {} iterations of MinRoot per step",
|
||||
num_iters_per_step
|
||||
);
|
||||
println!("Proving {num_iters_per_step} iterations of MinRoot per step");
|
||||
|
||||
// produce public parameters
|
||||
let start = Instant::now();
|
||||
|
||||
@@ -185,7 +185,7 @@ pub fn synthesize_bits<F: PrimeField, CS: ConstraintSystem<F>>(
|
||||
.into_iter()
|
||||
.map(|i| {
|
||||
AllocatedBit::alloc(
|
||||
cs.namespace(|| format!("bit {}", i)),
|
||||
cs.namespace(|| format!("bit {i}")),
|
||||
Some(bits.as_ref().unwrap()[i as usize]),
|
||||
)
|
||||
})
|
||||
|
||||
@@ -122,13 +122,13 @@ where
|
||||
let mut result = Vec::new();
|
||||
|
||||
for input in &self.inputs {
|
||||
result.push(format!("INPUT {}", input));
|
||||
result.push(format!("INPUT {input}"));
|
||||
}
|
||||
for aux in &self.aux {
|
||||
result.push(format!("AUX {}", aux));
|
||||
result.push(format!("AUX {aux}"));
|
||||
}
|
||||
|
||||
for &(ref _a, ref _b, ref _c, ref name) in &self.constraints {
|
||||
for (_a, _b, _c, name) in &self.constraints {
|
||||
result.push(name.to_string());
|
||||
}
|
||||
|
||||
@@ -164,12 +164,12 @@ where
|
||||
if coeff != <G::Scalar>::one() && coeff != negone {
|
||||
for (i, x) in powers_of_two.iter().enumerate() {
|
||||
if x == &coeff {
|
||||
write!(s, "2^{} . ", i).unwrap();
|
||||
write!(s, "2^{i} . ").unwrap();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
write!(s, "{:?} . ", coeff).unwrap()
|
||||
write!(s, "{coeff:?} . ").unwrap()
|
||||
}
|
||||
|
||||
match var.0.get_unchecked() {
|
||||
@@ -188,10 +188,10 @@ where
|
||||
s.push(')');
|
||||
};
|
||||
|
||||
for &(ref a, ref b, ref c, ref name) in &self.constraints {
|
||||
for (a, b, c, name) in &self.constraints {
|
||||
s.push('\n');
|
||||
|
||||
write!(s, "{}: ", name).unwrap();
|
||||
write!(s, "{name}: ").unwrap();
|
||||
pp(&mut s, a);
|
||||
write!(s, " * ").unwrap();
|
||||
pp(&mut s, b);
|
||||
@@ -209,8 +209,7 @@ where
|
||||
fn set_named_obj(&mut self, path: String, to: NamedObject) {
|
||||
assert!(
|
||||
!self.named_objects.contains_key(&path),
|
||||
"tried to create object at existing path: {}",
|
||||
path
|
||||
"tried to create object at existing path: {path}"
|
||||
);
|
||||
|
||||
self.named_objects.insert(path, to);
|
||||
|
||||
@@ -43,7 +43,7 @@ where
|
||||
&self
|
||||
.a
|
||||
.iter()
|
||||
.map(|v| format!("Fr({:?})", v))
|
||||
.map(|v| format!("Fr({v:?})"))
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
.field(
|
||||
@@ -51,7 +51,7 @@ where
|
||||
&self
|
||||
.b
|
||||
.iter()
|
||||
.map(|v| format!("Fr({:?})", v))
|
||||
.map(|v| format!("Fr({v:?})"))
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
.field(
|
||||
@@ -59,7 +59,7 @@ where
|
||||
&self
|
||||
.c
|
||||
.iter()
|
||||
.map(|v| format!("Fr({:?})", v))
|
||||
.map(|v| format!("Fr({v:?})"))
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
.field("input_assignment", &self.input_assignment)
|
||||
|
||||
@@ -148,7 +148,7 @@ where
|
||||
// Allocate z0
|
||||
let z_0 = (0..arity)
|
||||
.map(|i| {
|
||||
AllocatedNum::alloc(cs.namespace(|| format!("z0_{}", i)), || {
|
||||
AllocatedNum::alloc(cs.namespace(|| format!("z0_{i}")), || {
|
||||
Ok(self.inputs.get()?.z0[i])
|
||||
})
|
||||
})
|
||||
@@ -158,7 +158,7 @@ where
|
||||
let zero = vec![G::Base::zero(); arity];
|
||||
let z_i = (0..arity)
|
||||
.map(|i| {
|
||||
AllocatedNum::alloc(cs.namespace(|| format!("zi_{}", i)), || {
|
||||
AllocatedNum::alloc(cs.namespace(|| format!("zi_{i}")), || {
|
||||
Ok(self.inputs.get()?.zi.as_ref().unwrap_or(&zero)[i])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -444,15 +444,15 @@ where
|
||||
|
||||
// perform the double-and-add loop to compute the scalar mul using incomplete addition law
|
||||
for (i, bit) in incomplete_bits.iter().enumerate().skip(1) {
|
||||
let temp = acc.add_incomplete(cs.namespace(|| format!("add {}", i)), &p)?;
|
||||
let temp = acc.add_incomplete(cs.namespace(|| format!("add {i}")), &p)?;
|
||||
acc = AllocatedPointNonInfinity::conditionally_select(
|
||||
cs.namespace(|| format!("acc_iteration_{}", i)),
|
||||
cs.namespace(|| format!("acc_iteration_{i}")),
|
||||
&temp,
|
||||
&acc,
|
||||
&Boolean::from(bit.clone()),
|
||||
)?;
|
||||
|
||||
p = p.double_incomplete(cs.namespace(|| format!("double {}", i)))?;
|
||||
p = p.double_incomplete(cs.namespace(|| format!("double {i}")))?;
|
||||
}
|
||||
|
||||
// convert back to AllocatedPoint
|
||||
@@ -500,15 +500,15 @@ where
|
||||
let mut p_complete = p.to_allocated_point(&self.is_infinity)?;
|
||||
|
||||
for (i, bit) in complete_bits.iter().enumerate() {
|
||||
let temp = acc.add(cs.namespace(|| format!("add_complete {}", i)), &p_complete)?;
|
||||
let temp = acc.add(cs.namespace(|| format!("add_complete {i}")), &p_complete)?;
|
||||
acc = AllocatedPoint::conditionally_select(
|
||||
cs.namespace(|| format!("acc_complete_iteration_{}", i)),
|
||||
cs.namespace(|| format!("acc_complete_iteration_{i}")),
|
||||
&temp,
|
||||
&acc,
|
||||
&Boolean::from(bit.clone()),
|
||||
)?;
|
||||
|
||||
p_complete = p_complete.double(cs.namespace(|| format!("double_complete {}", i)))?;
|
||||
p_complete = p_complete.double(cs.namespace(|| format!("double_complete {i}")))?;
|
||||
}
|
||||
|
||||
Ok(acc)
|
||||
@@ -961,7 +961,7 @@ mod tests {
|
||||
.to_le_bits()
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.map(|(i, bit)| AllocatedBit::alloc(cs.namespace(|| format!("bit {}", i)), Some(bit)))
|
||||
.map(|(i, bit)| AllocatedBit::alloc(cs.namespace(|| format!("bit {i}")), Some(bit)))
|
||||
.collect::<Result<Vec<AllocatedBit>, SynthesisError>>()
|
||||
.unwrap();
|
||||
let e = a.scalar_mul(cs.namespace(|| "Scalar Mul"), bits).unwrap();
|
||||
|
||||
@@ -52,10 +52,7 @@ pub fn nat_to_limbs<Scalar: PrimeField>(
|
||||
.collect(),
|
||||
)
|
||||
} else {
|
||||
eprintln!(
|
||||
"nat {} does not fit in {} limbs of width {}",
|
||||
nat, n_limbs, limb_width
|
||||
);
|
||||
eprintln!("nat {nat} does not fit in {n_limbs} limbs of width {limb_width}");
|
||||
Err(SynthesisError::Unsatisfiable)
|
||||
}
|
||||
}
|
||||
@@ -131,7 +128,7 @@ impl<Scalar: PrimeField> BigNat<Scalar> {
|
||||
let limbs = (0..n_limbs)
|
||||
.map(|limb_i| {
|
||||
cs.alloc(
|
||||
|| format!("limb {}", limb_i),
|
||||
|| format!("limb {limb_i}"),
|
||||
|| match values_cell {
|
||||
Ok(ref vs) => {
|
||||
if vs.len() != n_limbs {
|
||||
@@ -149,7 +146,7 @@ impl<Scalar: PrimeField> BigNat<Scalar> {
|
||||
// Hack b/c SynthesisError and io::Error don't implement Clone
|
||||
Err(ref e) => Err(SynthesisError::from(std::io::Error::new(
|
||||
std::io::ErrorKind::Other,
|
||||
format!("{}", e),
|
||||
format!("{e}"),
|
||||
))),
|
||||
},
|
||||
)
|
||||
@@ -189,7 +186,7 @@ impl<Scalar: PrimeField> BigNat<Scalar> {
|
||||
let limbs = (0..n_limbs)
|
||||
.map(|limb_i| {
|
||||
cs.alloc(
|
||||
|| format!("limb {}", limb_i),
|
||||
|| format!("limb {limb_i}"),
|
||||
|| match all_values_cell {
|
||||
Ok((ref vs, ref v)) => {
|
||||
if value.is_none() {
|
||||
@@ -201,7 +198,7 @@ impl<Scalar: PrimeField> BigNat<Scalar> {
|
||||
// Hack b/c SynthesisError and io::Error don't implement Clone
|
||||
Err(ref e) => Err(SynthesisError::from(std::io::Error::new(
|
||||
std::io::ErrorKind::Other,
|
||||
format!("{}", e),
|
||||
format!("{e}"),
|
||||
))),
|
||||
},
|
||||
)
|
||||
@@ -272,7 +269,7 @@ impl<Scalar: PrimeField> BigNat<Scalar> {
|
||||
(0..self.limbs.len()).map(|i| self.limb_values.as_ref().map(|vs| vs[i]));
|
||||
for (i, (limb, limb_value)) in self.limbs.iter().zip(limb_values_split).enumerate() {
|
||||
Num::new(limb_value, limb.clone())
|
||||
.fits_in_bits(cs.namespace(|| format!("{}", i)), self.params.limb_width)?;
|
||||
.fits_in_bits(cs.namespace(|| format!("{i}")), self.params.limb_width)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -291,7 +288,7 @@ impl<Scalar: PrimeField> BigNat<Scalar> {
|
||||
.enumerate()
|
||||
.map(|(i, (limb, limb_value))| {
|
||||
Num::new(limb_value, limb.clone()).decompose(
|
||||
cs.namespace(|| format!("subdecmop {}", i)),
|
||||
cs.namespace(|| format!("subdecmop {i}")),
|
||||
self.params.limb_width,
|
||||
)
|
||||
})
|
||||
@@ -370,7 +367,7 @@ impl<Scalar: PrimeField> BigNat<Scalar> {
|
||||
let mut carry_in = Num::new(Some(Scalar::zero()), LinearCombination::zero());
|
||||
|
||||
for i in 0..n {
|
||||
let carry = Num::alloc(cs.namespace(|| format!("carry value {}", i)), || {
|
||||
let carry = Num::alloc(cs.namespace(|| format!("carry value {i}")), || {
|
||||
Ok(
|
||||
nat_to_f(
|
||||
&((f_to_nat(&self.limb_values.grab()?[i])
|
||||
@@ -385,7 +382,7 @@ impl<Scalar: PrimeField> BigNat<Scalar> {
|
||||
accumulated_extra += max_word;
|
||||
|
||||
cs.enforce(
|
||||
|| format!("carry {}", i),
|
||||
|| format!("carry {i}"),
|
||||
|lc| lc,
|
||||
|lc| lc,
|
||||
|lc| {
|
||||
@@ -402,10 +399,10 @@ impl<Scalar: PrimeField> BigNat<Scalar> {
|
||||
accumulated_extra /= &target_base;
|
||||
|
||||
if i < n - 1 {
|
||||
carry.fits_in_bits(cs.namespace(|| format!("carry {} decomp", i)), carry_bits)?;
|
||||
carry.fits_in_bits(cs.namespace(|| format!("carry {i} decomp")), carry_bits)?;
|
||||
} else {
|
||||
cs.enforce(
|
||||
|| format!("carry {} is out", i),
|
||||
|| format!("carry {i} is out"),
|
||||
|lc| lc,
|
||||
|lc| lc,
|
||||
|lc| lc + &carry.num - (nat_to_f(&accumulated_extra).unwrap(), CS::one()),
|
||||
@@ -416,7 +413,7 @@ impl<Scalar: PrimeField> BigNat<Scalar> {
|
||||
|
||||
for (i, zero_limb) in self.limbs.iter().enumerate().skip(n) {
|
||||
cs.enforce(
|
||||
|| format!("zero self {}", i),
|
||||
|| format!("zero self {i}"),
|
||||
|lc| lc,
|
||||
|lc| lc,
|
||||
|lc| lc + zero_limb,
|
||||
@@ -424,7 +421,7 @@ impl<Scalar: PrimeField> BigNat<Scalar> {
|
||||
}
|
||||
for (i, zero_limb) in other.limbs.iter().enumerate().skip(n) {
|
||||
cs.enforce(
|
||||
|| format!("zero other {}", i),
|
||||
|| format!("zero other {i}"),
|
||||
|lc| lc,
|
||||
|lc| lc,
|
||||
|lc| lc + zero_limb,
|
||||
@@ -707,10 +704,7 @@ impl<Scalar: PrimeField> Polynomial<Scalar> {
|
||||
});
|
||||
let coefficients = (0..n_product_coeffs)
|
||||
.map(|i| {
|
||||
Ok(
|
||||
LinearCombination::zero()
|
||||
+ cs.alloc(|| format!("prod {}", i), || Ok(values.grab()?[i]))?,
|
||||
)
|
||||
Ok(LinearCombination::zero() + cs.alloc(|| format!("prod {i}"), || Ok(values.grab()?[i]))?)
|
||||
})
|
||||
.collect::<Result<Vec<LinearCombination<Scalar>>, SynthesisError>>()?;
|
||||
let product = Polynomial {
|
||||
@@ -722,7 +716,7 @@ impl<Scalar: PrimeField> Polynomial<Scalar> {
|
||||
for _ in 1..(n_product_coeffs + 1) {
|
||||
x.add_assign(&one);
|
||||
cs.enforce(
|
||||
|| format!("pointwise product @ {:?}", x),
|
||||
|| format!("pointwise product @ {x:?}"),
|
||||
|lc| {
|
||||
let mut i = Scalar::one();
|
||||
self.coefficients.iter().fold(lc, |lc, c| {
|
||||
@@ -807,7 +801,7 @@ mod tests {
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, x)| {
|
||||
Ok(LinearCombination::zero() + cs.alloc(|| format!("coeff_a {}", i), || Ok(*x))?)
|
||||
Ok(LinearCombination::zero() + cs.alloc(|| format!("coeff_a {i}"), || Ok(*x))?)
|
||||
})
|
||||
.collect::<Result<Vec<LinearCombination<Scalar>>, SynthesisError>>()?,
|
||||
values: Some(self.a),
|
||||
@@ -818,7 +812,7 @@ mod tests {
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, x)| {
|
||||
Ok(LinearCombination::zero() + cs.alloc(|| format!("coeff_b {}", i), || Ok(*x))?)
|
||||
Ok(LinearCombination::zero() + cs.alloc(|| format!("coeff_b {i}"), || Ok(*x))?)
|
||||
})
|
||||
.collect::<Result<Vec<LinearCombination<Scalar>>, SynthesisError>>()?,
|
||||
values: Some(self.b),
|
||||
|
||||
@@ -106,7 +106,7 @@ impl<Scalar: PrimeField> Num<Scalar> {
|
||||
let bits: Vec<Variable> = (1..n_bits)
|
||||
.map(|i| {
|
||||
cs.alloc(
|
||||
|| format!("bit {}", i),
|
||||
|| format!("bit {i}"),
|
||||
|| {
|
||||
let r = if *v.grab()?.get_bit(i).grab()? {
|
||||
Scalar::one()
|
||||
@@ -121,7 +121,7 @@ impl<Scalar: PrimeField> Num<Scalar> {
|
||||
|
||||
for (i, v) in bits.iter().enumerate() {
|
||||
cs.enforce(
|
||||
|| format!("{} is bit", i),
|
||||
|| format!("{i} is bit"),
|
||||
|lc| lc + *v,
|
||||
|lc| lc + CS::one() - *v,
|
||||
|lc| lc,
|
||||
@@ -191,7 +191,7 @@ impl<Scalar: PrimeField> Num<Scalar> {
|
||||
let allocations: Vec<Bit<Scalar>> = (0..n_bits)
|
||||
.map(|bit_i| {
|
||||
Bit::alloc(
|
||||
cs.namespace(|| format!("bit{}", bit_i)),
|
||||
cs.namespace(|| format!("bit{bit_i}")),
|
||||
values.as_ref().map(|vs| vs[bit_i]),
|
||||
)
|
||||
})
|
||||
@@ -257,5 +257,5 @@ pub fn f_to_nat<Scalar: PrimeField>(f: &Scalar) -> BigInt {
|
||||
/// Convert a natural number to a field element.
|
||||
/// Returns `None` if the number is too big for the field.
|
||||
pub fn nat_to_f<Scalar: PrimeField>(n: &BigInt) -> Option<Scalar> {
|
||||
Scalar::from_str_vartime(&format!("{}", n))
|
||||
Scalar::from_str_vartime(&format!("{n}"))
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ where
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, limb)| {
|
||||
limb.as_allocated_num(cs.namespace(|| format!("convert limb {} of X_r[0] to num", i)))
|
||||
limb.as_allocated_num(cs.namespace(|| format!("convert limb {i} of X_r[0] to num")))
|
||||
})
|
||||
.collect::<Result<Vec<AllocatedNum<G::Base>>, _>>()?;
|
||||
|
||||
@@ -241,7 +241,7 @@ where
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, limb)| {
|
||||
limb.as_allocated_num(cs.namespace(|| format!("convert limb {} of X_r[1] to num", i)))
|
||||
limb.as_allocated_num(cs.namespace(|| format!("convert limb {i} of X_r[1] to num")))
|
||||
})
|
||||
.collect::<Result<Vec<AllocatedNum<G::Base>>, _>>()?;
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ pub fn alloc_bignat_constant<F: PrimeField, CS: ConstraintSystem<F>>(
|
||||
#[allow(clippy::needless_range_loop)]
|
||||
for i in 0..n_limbs {
|
||||
cs.enforce(
|
||||
|| format!("check limb {}", i),
|
||||
|| format!("check limb {i}"),
|
||||
|lc| lc + &bignat.limbs[i],
|
||||
|lc| lc + CS::one(),
|
||||
|lc| lc + (limbs[i], CS::one()),
|
||||
@@ -222,7 +222,7 @@ pub fn conditionally_select_vec<F: PrimeField, CS: ConstraintSystem<F>>(
|
||||
.zip(b.iter())
|
||||
.enumerate()
|
||||
.map(|(i, (a, b))| {
|
||||
conditionally_select(cs.namespace(|| format!("select_{}", i)), a, b, condition)
|
||||
conditionally_select(cs.namespace(|| format!("select_{i}")), a, b, condition)
|
||||
})
|
||||
.collect::<Result<Vec<AllocatedNum<F>>, SynthesisError>>()
|
||||
}
|
||||
@@ -252,7 +252,7 @@ pub fn conditionally_select_bignat<F: PrimeField, CS: ConstraintSystem<F>>(
|
||||
// a * condition - b*condition = c - b
|
||||
for i in 0..c.limbs.len() {
|
||||
cs.enforce(
|
||||
|| format!("conditional select constraint {}", i),
|
||||
|| format!("conditional select constraint {i}"),
|
||||
|lc| lc + &a.limbs[i] - &b.limbs[i],
|
||||
|_| condition.lc(CS::one(), F::one()),
|
||||
|lc| lc + &c.limbs[i] - &b.limbs[i],
|
||||
|
||||
@@ -224,9 +224,9 @@ mod tests {
|
||||
let num = S::random(&mut csprng);
|
||||
ro.absorb(num);
|
||||
let num_gadget =
|
||||
AllocatedNum::alloc(cs.namespace(|| format!("data {}", i)), || Ok(num)).unwrap();
|
||||
AllocatedNum::alloc(cs.namespace(|| format!("data {i}")), || Ok(num)).unwrap();
|
||||
num_gadget
|
||||
.inputize(&mut cs.namespace(|| format!("input {}", i)))
|
||||
.inputize(&mut cs.namespace(|| format!("input {i}")))
|
||||
.unwrap();
|
||||
ro_gadget.absorb(num_gadget);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user