Browse Source

tmp fix to make it work at the current arkworks version with the cherry-picks

cherry-pick
arnaucube 6 months ago
parent
commit
38821bbf14
4 changed files with 22 additions and 5 deletions
  1. +18
    -1
      src/fields/fp/mod.rs
  2. +1
    -1
      src/groups/curves/short_weierstrass/mod.rs
  3. +2
    -2
      src/groups/curves/twisted_edwards/mod.rs
  4. +1
    -1
      src/poly/evaluations/univariate/mod.rs

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

@ -129,13 +129,14 @@ impl AllocatedFp {
///
/// This does not create any constraints and only creates one linear
/// combination.
pub fn addmany<'a, I: Iterator<Item = &'a Self>>(iter: I) -> Self {
pub fn addmany<B: Borrow<Self>, I: Iterator<Item = B>>(iter: I) -> Self {
let mut cs = ConstraintSystemRef::None;
let mut has_value = true;
let mut value = F::zero();
let mut new_lc = lc!();
for variable in iter {
let variable = variable.borrow();
if !variable.cs.is_none() {
cs = cs.or(variable.cs.clone());
}
@ -1063,6 +1064,22 @@ impl<'a, F: PrimeField> Sum<&'a FpVar> for FpVar {
}
}
impl<'a, F: PrimeField> Sum<FpVar<F>> for FpVar<F> {
fn sum<I: Iterator<Item = FpVar<F>>>(iter: I) -> FpVar<F> {
let mut sum_constants = F::zero();
let sum_variables = FpVar::Var(AllocatedFp::<F>::addmany(iter.filter_map(|x| match x {
FpVar::Constant(c) => {
sum_constants += c;
None
},
FpVar::Var(v) => Some(v),
})));
let sum = sum_variables + sum_constants;
sum
}
}
#[cfg(test)]
mod test {
use crate::{

+ 1
- 1
src/groups/curves/short_weierstrass/mod.rs

@ -851,7 +851,7 @@ where
let (mut ge, iter) = if cofactor_weight < modulus_minus_1_weight {
let ge = Self::new_variable_omit_prime_order_check(
ark_relations::ns!(cs, "Witness without subgroup check with cofactor mul"),
|| f().map(|g| g.borrow().into_affine().mul_by_cofactor_inv().into()),
|| f().map(|g| g.into_affine().mul_by_cofactor_inv().into()),
mode,
)?;
(

+ 2
- 2
src/groups/curves/twisted_edwards/mod.rs

@ -337,7 +337,7 @@ where
.iter()
.zip(segment_powers.borrow())
{
let base_power = base_power.borrow();
let base_power = base_power;
let mut acc_power = *base_power;
let mut coords = vec![];
for _ in 0..4 {
@ -609,7 +609,7 @@ where
let (mut ge, iter) = if cofactor_weight < modulus_minus_1_weight {
let ge = Self::new_variable_omit_prime_order_check(
ark_relations::ns!(cs, "Witness without subgroup check with cofactor mul"),
|| f().map(|g| g.borrow().into_affine().mul_by_cofactor_inv().into()),
|| f().map(|g| g.into_affine().mul_by_cofactor_inv().into()),
mode,
)?;
(

+ 1
- 1
src/poly/evaluations/univariate/mod.rs

@ -166,7 +166,7 @@ impl EvaluationsVar {
.map(|(coeff, eval)| coeff * eval)
.sum::<FpVar<F>>();
Ok(interpolation)
Ok(interpolation.clone())
}
/// Generate interpolation constraints. We assume at compile time we know

Loading…
Cancel
Save