diff --git a/poly-commitment/src/commitment.rs b/poly-commitment/src/commitment.rs index 72e1f480a6..5807e0297d 100644 --- a/poly-commitment/src/commitment.rs +++ b/poly-commitment/src/commitment.rs @@ -608,14 +608,6 @@ pub fn combine_evaluations( acc } -pub fn inner_prod(xs: &[F], ys: &[F]) -> F { - let mut res = F::zero(); - for (&x, y) in xs.iter().zip(ys) { - res += &(x * y); - } - res -} - #[cfg(feature = "ocaml_types")] pub mod caml { // polynomial commitment diff --git a/poly-commitment/src/srs.rs b/poly-commitment/src/srs.rs index 2225f0667d..71fc350950 100644 --- a/poly-commitment/src/srs.rs +++ b/poly-commitment/src/srs.rs @@ -3,9 +3,8 @@ use crate::{ commitment::{ - b_poly, b_poly_coefficients, combine_commitments, inner_prod, shift_scalar, - squeeze_prechallenge, BatchEvaluationProof, BlindedCommitment, CommitmentCurve, EndoCurve, - Evaluation, + b_poly, b_poly_coefficients, combine_commitments, shift_scalar, squeeze_prechallenge, + BatchEvaluationProof, BlindedCommitment, CommitmentCurve, EndoCurve, Evaluation, }, error::CommitmentError, evaluation_proof::{combine_polys, Challenges, OpeningProof}, @@ -20,7 +19,10 @@ use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; use blake2::{Blake2b512, Digest}; use groupmap::GroupMap; use mina_poseidon::{sponge::ScalarChallenge, FqSponge}; -use o1_utils::{field_helpers::pows, math, ExtendedDensePolynomial}; +use o1_utils::{ + field_helpers::{inner_prod, pows}, + math, ExtendedDensePolynomial, +}; use rand::{CryptoRng, RngCore}; use rayon::prelude::*; use serde::{Deserialize, Serialize}; diff --git a/utils/src/field_helpers.rs b/utils/src/field_helpers.rs index c99d45e038..00f8827d06 100644 --- a/utils/src/field_helpers.rs +++ b/utils/src/field_helpers.rs @@ -229,3 +229,12 @@ pub fn product(xs: impl Iterator) -> F { } res } + +/// COmpute the inner product of two slices of field elements. +pub fn inner_prod(xs: &[F], ys: &[F]) -> F { + let mut res = F::zero(); + for (&x, y) in xs.iter().zip(ys) { + res += &(x * y); + } + res +}