Accumulate `commitments` and `values` according to the challenges produces by `challenge_gen`.
(
commitments: impl IntoIterator<Item = &'a LabeledCommitment<marlin_pc::Commitment<E>>>,
values: impl IntoIterator<Item = E::ScalarField>,
sponge: &mut impl CryptographicSpong
| 107 | |
| 108 | /// Accumulate `commitments` and `values` according to the challenges produces by `challenge_gen`. |
| 109 | fn accumulate_commitments_and_values<'a>( |
| 110 | commitments: impl IntoIterator<Item = &'a LabeledCommitment<marlin_pc::Commitment<E>>>, |
| 111 | values: impl IntoIterator<Item = E::ScalarField>, |
| 112 | sponge: &mut impl CryptographicSponge, |
| 113 | vk: Option<&marlin_pc::VerifierKey<E>>, |
| 114 | ) -> Result<(E::G1, E::ScalarField), Error> { |
| 115 | let acc_time = start_timer!(|| "Accumulating commitments and values"); |
| 116 | let mut combined_comm = E::G1::zero(); |
| 117 | let mut combined_value = E::ScalarField::zero(); |
| 118 | for (labeled_commitment, value) in commitments.into_iter().zip(values) { |
| 119 | let degree_bound = labeled_commitment.degree_bound(); |
| 120 | let commitment = labeled_commitment.commitment(); |
| 121 | assert_eq!(degree_bound.is_some(), commitment.shifted_comm.is_some()); |
| 122 | |
| 123 | let challenge_i = sponge.squeeze_field_elements_with_sizes(&[CHALLENGE_SIZE])[0]; |
| 124 | |
| 125 | combined_comm += &commitment.comm.0.mul(challenge_i); |
| 126 | combined_value += &(value * &challenge_i); |
| 127 | |
| 128 | if let Some(degree_bound) = degree_bound { |
| 129 | let challenge_i_1: E::ScalarField = |
| 130 | sponge.squeeze_field_elements_with_sizes(&[CHALLENGE_SIZE])[0]; |
| 131 | |
| 132 | let shifted_comm = commitment.shifted_comm.as_ref().unwrap().0.into_group(); |
| 133 | |
| 134 | let shift_power = vk |
| 135 | .unwrap() |
| 136 | .get_shift_power(degree_bound) |
| 137 | .ok_or(Error::UnsupportedDegreeBound(degree_bound))?; |
| 138 | |
| 139 | let mut adjusted_comm = shifted_comm - &shift_power.mul(value); |
| 140 | |
| 141 | adjusted_comm *= challenge_i_1; |
| 142 | combined_comm += &adjusted_comm; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | end_timer!(acc_time); |
| 147 | Ok((combined_comm, combined_value)) |
| 148 | } |
| 149 | |
| 150 | /// Combine and normalize a set of commitments |
| 151 | fn combine_and_normalize<'a, D: Clone + Ord + Sync>( |
nothing calls this directly
no test coverage detected