MCPcopy Create free account
hub / github.com/docknetwork/crypto / double

Method double

legogroth16/src/aggregation/commitment.rs:36–69  ·  view source on GitHub ↗

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>>,
    )

Source from the content-addressed store, hash-verified

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}

Callers 9

point_additionFunction · 0.80
initMethod · 0.80
newMethod · 0.80
g_offsetMethod · 0.80
verifyMethod · 0.80
checkFunction · 0.80
checkFunction · 0.80
newMethod · 0.80
newMethod · 0.80

Calls 5

mapMethod · 0.80
appendMethod · 0.80
cloneMethod · 0.80
into_iterMethod · 0.45
lenMethod · 0.45

Tested by 1

point_additionFunction · 0.64