MCPcopy Create free account
hub / github.com/arkworks-rs/poly-commit / open_multi_points

Method open_multi_points

poly-commit/src/streaming_kzg/space.rs:98–136  ·  view source on GitHub ↗

Evaluate a single polynomial at a set of points `points`, and provide an evaluation proof along with evaluations.

(
        &self,
        polynomial: &SF,
        points: &[E::ScalarField],
        max_msm_buffer: usize,
    )

Source from the content-addressed store, hash-verified

96
97 /// Evaluate a single polynomial at a set of points `points`, and provide an evaluation proof along with evaluations.
98 pub fn open_multi_points<SF>(
99 &self,
100 polynomial: &SF,
101 points: &[E::ScalarField],
102 max_msm_buffer: usize,
103 ) -> (Vec<E::ScalarField>, EvaluationProof<E>)
104 where
105 SF: Iterable,
106 SF::Item: Borrow<E::ScalarField>,
107 {
108 let zeros = vanishing_polynomial(points);
109 let mut quotient: ChunkedPippenger<E::G1> = ChunkedPippenger::new(max_msm_buffer);
110 let bases_init = self.powers_of_g.iter();
111 // TODO: change `skip` to `advance_by` once rust-lang/rust#7774 is fixed.
112 // See <https://github.com/rust-lang/rust/issues/77404>
113 let mut bases = bases_init.skip(self.powers_of_g.len() - polynomial.len() + zeros.degree());
114
115 let mut state = VecDeque::<E::ScalarField>::with_capacity(points.len());
116
117 let mut polynomial_iterator = polynomial.iter();
118
119 (0..points.len()).for_each(|_| {
120 state.push_back(*polynomial_iterator.next().unwrap().borrow());
121 });
122
123 for coefficient in polynomial_iterator {
124 let coefficient = coefficient.borrow();
125 let quotient_coefficient = state.pop_front().unwrap();
126 state.push_back(*coefficient);
127 (0..points.len()).for_each(|i| {
128 state[i] -= zeros.coeffs[zeros.degree() - i - 1] * quotient_coefficient;
129 });
130 let base = bases.next().unwrap();
131 quotient.add(base, quotient_coefficient.into_bigint());
132 }
133 let remainder = state.make_contiguous().to_vec();
134 let commitment = EvaluationProof(quotient.finalize().into_affine());
135 (remainder, commitment)
136 }
137
138 /// The commitment procedures, that takes as input a committer key and the streaming coefficients of polynomial, and produces the desired commitment.
139 pub fn commit<SF: ?Sized>(&self, polynomial: &SF) -> Commitment<E>

Callers

nothing calls this directly

Calls 7

vanishing_polynomialFunction · 0.85
EvaluationProofClass · 0.85
iterMethod · 0.80
lenMethod · 0.80
degreeMethod · 0.80
nextMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected