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

Method commit

poly-commit/src/marlin/marlin_pc/mod.rs:172–242  ·  view source on GitHub ↗

Outputs a commitment to `polynomial`.

(
        ck: &Self::CommitterKey,
        polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<E::ScalarField, P>>,
        rng: Option<&mut dyn RngCore>,
    )

Source from the content-addressed store, hash-verified

170
171 /// Outputs a commitment to `polynomial`.
172 fn commit<'a>(
173 ck: &Self::CommitterKey,
174 polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<E::ScalarField, P>>,
175 rng: Option<&mut dyn RngCore>,
176 ) -> Result<
177 (
178 Vec<LabeledCommitment<Self::Commitment>>,
179 Vec<Self::CommitmentState>,
180 ),
181 Self::Error,
182 >
183 where
184 P: 'a,
185 {
186 let rng = &mut crate::optional_rng::OptionalRng(rng);
187 let commit_time = start_timer!(|| "Committing to polynomials");
188
189 let mut commitments = Vec::new();
190 let mut states = Vec::new();
191
192 for p in polynomials {
193 let label = p.label();
194 let degree_bound = p.degree_bound();
195 let hiding_bound = p.hiding_bound();
196 let polynomial: &P = p.polynomial();
197
198 let enforced_degree_bounds: Option<&[usize]> = ck
199 .enforced_degree_bounds
200 .as_ref()
201 .map(|bounds| bounds.as_slice());
202 kzg10::KZG10::<E, P>::check_degrees_and_bounds(
203 ck.supported_degree(),
204 ck.max_degree,
205 enforced_degree_bounds,
206 &p,
207 )?;
208
209 let commit_time = start_timer!(|| format!(
210 "Polynomial {} of degree {}, degree bound {:?}, and hiding bound {:?}",
211 label,
212 polynomial.degree(),
213 degree_bound,
214 hiding_bound,
215 ));
216
217 let (comm, rand) =
218 kzg10::KZG10::commit(&ck.powers(), polynomial, hiding_bound, Some(rng))?;
219 let (shifted_comm, shifted_rand) = if let Some(degree_bound) = degree_bound {
220 let shifted_powers = ck
221 .shifted_powers(degree_bound)
222 .ok_or(Error::UnsupportedDegreeBound(degree_bound))?;
223 let (shifted_comm, shifted_rand) =
224 kzg10::KZG10::commit(&shifted_powers, &polynomial, hiding_bound, Some(rng))?;
225 (Some(shifted_comm), Some(shifted_rand))
226 } else {
227 (None, None)
228 };
229

Callers

nothing calls this directly

Calls 10

OptionalRngClass · 0.85
commitFunction · 0.85
labelMethod · 0.80
degree_boundMethod · 0.80
hiding_boundMethod · 0.80
polynomialMethod · 0.80
pushMethod · 0.80
supported_degreeMethod · 0.45
powersMethod · 0.45
shifted_powersMethod · 0.45

Tested by

no test coverage detected