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

Method combine_commitments

poly-commit/src/marlin/mod.rs:51–69  ·  view source on GitHub ↗

MSM for `commitments` and `coeffs`

(
        coeffs_and_comms: impl IntoIterator<Item = (E::ScalarField, &'a marlin_pc::Commitment<E>)>,
    )

Source from the content-addressed store, hash-verified

49{
50 /// MSM for `commitments` and `coeffs`
51 fn combine_commitments<'a>(
52 coeffs_and_comms: impl IntoIterator<Item = (E::ScalarField, &'a marlin_pc::Commitment<E>)>,
53 ) -> (E::G1, Option<E::G1>) {
54 let mut combined_comm = E::G1::zero();
55 let mut combined_shifted_comm = None;
56 for (coeff, comm) in coeffs_and_comms {
57 if coeff.is_one() {
58 combined_comm.add_assign(&comm.comm.0);
59 } else {
60 combined_comm += &comm.comm.0.mul(coeff);
61 }
62
63 if let Some(shifted_comm) = &comm.shifted_comm {
64 let cur = shifted_comm.0.mul(coeff);
65 combined_shifted_comm = Some(combined_shifted_comm.map_or(cur, |c| c + cur));
66 }
67 }
68 (combined_comm, combined_shifted_comm)
69 }
70
71 /// Normalize a list of commitments
72 fn normalize_commitments<'a>(

Callers

nothing calls this directly

Calls 2

is_oneMethod · 0.80
add_assignMethod · 0.45

Tested by

no test coverage detected