Commits to 2 vector, 1 of group G1 elements and 1 of group G2 elements.
(
vkey: impl Into<PreparedVKey<E>>,
wkey: &WKey<E>,
a: &[E::G1Affine],
b: impl IntoIterator<Item = impl Into<E::G2Prepared>>,
)
| 34 | |
| 35 | /// Commits to 2 vector, 1 of group G1 elements and 1 of group G2 elements. |
| 36 | pub fn double( |
| 37 | vkey: impl Into<PreparedVKey<E>>, |
| 38 | wkey: &WKey<E>, |
| 39 | a: &[E::G1Affine], |
| 40 | b: impl IntoIterator<Item = impl Into<E::G2Prepared>>, |
| 41 | ) -> Result<Self, AggregationError> { |
| 42 | let vkey = vkey.into(); |
| 43 | let PreparedVKey { |
| 44 | a: mut v_a, |
| 45 | b: mut v_b, |
| 46 | } = vkey; |
| 47 | let b_prep: Vec<E::G2Prepared> = b.into_iter().map(|b| b.into()).collect::<Vec<_>>(); |
| 48 | let b_len = b_prep.len(); |
| 49 | v_a.truncate(a.len()); |
| 50 | v_a.append(&mut b_prep.clone()); |
| 51 | v_b.truncate(a.len()); |
| 52 | v_b.append(&mut b_prep.clone()); |
| 53 | Ok(Self { |
| 54 | t: E::multi_pairing( |
| 55 | cfg_iter!(a) |
| 56 | .map(|e| E::G1Prepared::from(*e)) |
| 57 | .chain(cfg_iter!(wkey.a[0..b_len]).map(|e| E::G1Prepared::from(*e))) |
| 58 | .collect::<Vec<_>>(), |
| 59 | v_a, |
| 60 | ), |
| 61 | u: E::multi_pairing( |
| 62 | cfg_iter!(a) |
| 63 | .map(|e| E::G1Prepared::from(*e)) |
| 64 | .chain(cfg_iter!(wkey.b[0..b_len]).map(|e| E::G1Prepared::from(*e))) |
| 65 | .collect::<Vec<_>>(), |
| 66 | v_b, |
| 67 | ), |
| 68 | }) |
| 69 | } |
| 70 | } |