Commit to given messages using the parameters and the given blinding as a Pedersen commitment. `indexed_messages_sorted_by_index` must produce items sorted by unique indices, otherwise, an error will be returned. Eg. if given messages `m_i`, `m_j`, and `m_k` in the iterator, the commitment converts messages to scalars and multiplies them by the parameter curve points: `params.g * blinding + params
(
&self,
indexed_messages_sorted_by_index: MI,
blinding: &'a G::ScalarField,
)
| 90 | /// `params.g * blinding + params.g_vec_i * m_i + params.g_vec_j * m_j + params.g_vec_k * m_k` |
| 91 | /// Computes using multi-scalar multiplication |
| 92 | pub fn commit_to_messages<'a, MI>( |
| 93 | &self, |
| 94 | indexed_messages_sorted_by_index: MI, |
| 95 | blinding: &'a G::ScalarField, |
| 96 | ) -> Result<G, KVACError> |
| 97 | where |
| 98 | MI: IntoIterator<Item = (usize, &'a G::ScalarField)>, |
| 99 | { |
| 100 | let (bases, scalars): (Vec<_>, Vec<_>) = process_results( |
| 101 | pair_valid_items_with_slice::<_, _, _, KVACError, _>( |
| 102 | indexed_messages_sorted_by_index, |
| 103 | CheckLeft(seq_pairs_satisfy(|a, b| a < b)), |
| 104 | &self.g_vec, |
| 105 | ), |
| 106 | |iter| iter.chain(once((&self.g, blinding))).unzip(), |
| 107 | )?; |
| 108 | |
| 109 | Ok(G::Group::msm_unchecked(&bases, &scalars).into_affine()) |
| 110 | } |
| 111 | |
| 112 | /// Compute `b = A*{e+x}` |
| 113 | /// `indexed_messages_sorted_by_index` must produce items sorted by unique indices, otherwise, |