mirror of
https://github.com/arnaucube/ark-r1cs-std.git
synced 2026-01-17 03:01:29 +01:00
tmp fix to make it work at the current arkworks version with the cherry-picks
This commit is contained in:
@@ -129,13 +129,14 @@ impl<F: PrimeField> AllocatedFp<F> {
|
|||||||
///
|
///
|
||||||
/// This does not create any constraints and only creates one linear
|
/// This does not create any constraints and only creates one linear
|
||||||
/// combination.
|
/// 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 cs = ConstraintSystemRef::None;
|
||||||
let mut has_value = true;
|
let mut has_value = true;
|
||||||
let mut value = F::zero();
|
let mut value = F::zero();
|
||||||
let mut new_lc = lc!();
|
let mut new_lc = lc!();
|
||||||
|
|
||||||
for variable in iter {
|
for variable in iter {
|
||||||
|
let variable = variable.borrow();
|
||||||
if !variable.cs.is_none() {
|
if !variable.cs.is_none() {
|
||||||
cs = cs.or(variable.cs.clone());
|
cs = cs.or(variable.cs.clone());
|
||||||
}
|
}
|
||||||
@@ -1063,6 +1064,22 @@ impl<'a, F: PrimeField> Sum<&'a FpVar<F>> for FpVar<F> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|||||||
@@ -851,7 +851,7 @@ where
|
|||||||
let (mut ge, iter) = if cofactor_weight < modulus_minus_1_weight {
|
let (mut ge, iter) = if cofactor_weight < modulus_minus_1_weight {
|
||||||
let ge = Self::new_variable_omit_prime_order_check(
|
let ge = Self::new_variable_omit_prime_order_check(
|
||||||
ark_relations::ns!(cs, "Witness without subgroup check with cofactor mul"),
|
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,
|
mode,
|
||||||
)?;
|
)?;
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -337,7 +337,7 @@ where
|
|||||||
.iter()
|
.iter()
|
||||||
.zip(segment_powers.borrow())
|
.zip(segment_powers.borrow())
|
||||||
{
|
{
|
||||||
let base_power = base_power.borrow();
|
let base_power = base_power;
|
||||||
let mut acc_power = *base_power;
|
let mut acc_power = *base_power;
|
||||||
let mut coords = vec![];
|
let mut coords = vec![];
|
||||||
for _ in 0..4 {
|
for _ in 0..4 {
|
||||||
@@ -609,7 +609,7 @@ where
|
|||||||
let (mut ge, iter) = if cofactor_weight < modulus_minus_1_weight {
|
let (mut ge, iter) = if cofactor_weight < modulus_minus_1_weight {
|
||||||
let ge = Self::new_variable_omit_prime_order_check(
|
let ge = Self::new_variable_omit_prime_order_check(
|
||||||
ark_relations::ns!(cs, "Witness without subgroup check with cofactor mul"),
|
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,
|
mode,
|
||||||
)?;
|
)?;
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ impl<F: PrimeField> EvaluationsVar<F> {
|
|||||||
.map(|(coeff, eval)| coeff * eval)
|
.map(|(coeff, eval)| coeff * eval)
|
||||||
.sum::<FpVar<F>>();
|
.sum::<FpVar<F>>();
|
||||||
|
|
||||||
Ok(interpolation)
|
Ok(interpolation.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generate interpolation constraints. We assume at compile time we know
|
/// Generate interpolation constraints. We assume at compile time we know
|
||||||
|
|||||||
Reference in New Issue
Block a user