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

Method commit_folding

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

The commitment procedures for our tensor check protocol. The algorithm takes advantage of the tree structure of folding polynomials in our protocol. Please refer to our paper for more details. The function takes as input a committer key and the tree structure of all the folding polynomials, and produces the desired commitment for each polynomial.

(
        &self,
        polynomials: &FoldedPolynomialTree<E::ScalarField, SF>,
        max_msm_buffer: usize,
    )

Source from the content-addressed store, hash-verified

163 /// The algorithm takes advantage of the tree structure of folding polynomials in our protocol. Please refer to our paper for more details.
164 /// The function takes as input a committer key and the tree structure of all the folding polynomials, and produces the desired commitment for each polynomial.
165 pub fn commit_folding<SF>(
166 &self,
167 polynomials: &FoldedPolynomialTree<E::ScalarField, SF>,
168 max_msm_buffer: usize,
169 ) -> Vec<Commitment<E>>
170 where
171 SF: Iterable,
172 SF::Item: Borrow<E::ScalarField>,
173 {
174 let n = polynomials.depth();
175 let mut pippengers: Vec<ChunkedPippenger<E::G1>> = Vec::new();
176 let mut folded_bases = Vec::new();
177 for i in 1..n + 1 {
178 let pippenger: ChunkedPippenger<<E as Pairing>::G1> =
179 ChunkedPippenger::with_size(max_msm_buffer / n);
180 let bases_init = self.powers_of_g.iter();
181
182 let delta = self.powers_of_g.len() - ceil_div(polynomials.len(), 1 << i);
183 // TODO: change `skip` to `advance_by` once rust-lang/rust#7774 is fixed.
184 // See <https://github.com/rust-lang/rust/issues/77404>
185 let bases = bases_init.skip(delta);
186 folded_bases.push(bases);
187 pippengers.push(pippenger);
188 }
189
190 for (i, coefficient) in polynomials.iter() {
191 let base = folded_bases[i - 1].next().unwrap();
192 pippengers[i - 1].add(base.borrow(), coefficient.into_bigint());
193 }
194
195 pippengers
196 .into_iter()
197 .map(|p| Commitment(p.finalize().into_affine()))
198 .collect::<Vec<_>>()
199 }
200
201 /// The commitment procedures for our tensor check protocol.
202 /// The algorithm takes advantage of the tree structure of folding polynomials in our protocol. Please refer to our paper for more details.

Callers

nothing calls this directly

Calls 8

ceil_divFunction · 0.85
depthMethod · 0.80
iterMethod · 0.80
lenMethod · 0.80
pushMethod · 0.80
CommitmentClass · 0.70
nextMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected