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

Method batch_open

poly-commit/src/lib.rs:269–358  ·  view source on GitHub ↗

Open several polynomials at one or more points each (possibly different for each polynomial). Each entry in the in the query set of points contains the label of the polynomial which should be queried at that point. Behaviour is undefined if `query_set` contains the entries with the same point label but different actual points. The opening challenges are independent for each batch of polynomials.

(
        ck: &Self::CommitterKey,
        labeled_polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<F, P>>,
        commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitm

Source from the content-addressed store, hash-verified

267 ///
268 /// The opening challenges are independent for each batch of polynomials.
269 fn batch_open<'a>(
270 ck: &Self::CommitterKey,
271 labeled_polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<F, P>>,
272 commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
273 query_set: &QuerySet<P::Point>,
274 sponge: &mut impl CryptographicSponge,
275 states: impl IntoIterator<Item = &'a Self::CommitmentState>,
276 rng: Option<&mut dyn RngCore>,
277 ) -> Result<Self::BatchProof, Self::Error>
278 where
279 P: 'a,
280 Self::CommitmentState: 'a,
281 Self::Commitment: 'a,
282 {
283 // The default implementation achieves proceeds by rearranging the queries in
284 // order to gather (i.e. batch) all polynomials that should be queried at
285 // the same point, then opening their commitments simultaneously with a
286 // single call to `open` (per point)
287 let rng = &mut optional_rng::OptionalRng(rng);
288 let poly_st_comm: BTreeMap<_, _> = labeled_polynomials
289 .into_iter()
290 .zip(states)
291 .zip(commitments.into_iter())
292 .map(|((poly, st), comm)| (poly.label(), (poly, st, comm)))
293 .collect();
294
295 let open_time = start_timer!(|| format!(
296 "Opening {} polynomials at query set of size {}",
297 poly_st_comm.len(),
298 query_set.len(),
299 ));
300
301 let mut query_to_labels_map = BTreeMap::new();
302
303 // `label` is the label of the polynomial the query refers to
304 // `point_label` is the label of the point being queried
305 // `point` is the actual point
306 for (label, (point_label, point)) in query_set.iter() {
307 // For each point label in `query_set`, we define an entry in
308 // `query_to_labels_map` containing a pair whose first element is
309 // the actual point and the second one is the set of labels of the
310 // polynomials being queried at that point
311 let labels = query_to_labels_map
312 .entry(point_label)
313 .or_insert((point, BTreeSet::new()));
314 labels.1.insert(label);
315 }
316
317 let mut proofs = Vec::new();
318 for (_point_label, (point, labels)) in query_to_labels_map.into_iter() {
319 let mut query_polys: Vec<&'a LabeledPolynomial<_, _>> = Vec::new();
320 let mut query_states: Vec<&'a Self::CommitmentState> = Vec::new();
321 let mut query_comms: Vec<&'a LabeledCommitment<Self::Commitment>> = Vec::new();
322
323 // Constructing matching vectors with the polynomial, commitment
324 // randomness and actual commitment for each polynomial being
325 // queried at `point`
326 for label in labels {

Callers

nothing calls this directly

Implementers 6

mod.rspoly-commit/src/marlin/marlin_pst13_pc
mod.rspoly-commit/src/marlin/marlin_pc/mod.r
mod.rspoly-commit/src/linear_codes/mod.rs
mod.rspoly-commit/src/ipa_pc/mod.rs
mod.rspoly-commit/src/sonic_pc/mod.rs
mod.rspoly-commit/src/hyrax/mod.rs

Calls 7

OptionalRngClass · 0.85
openFunction · 0.85
labelMethod · 0.80
iterMethod · 0.80
entryMethod · 0.80
insertMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected