1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
use ark_ec::pairing::Pairing;
use ark_serialize::*;
use ark_std::vec::Vec;
#[derive(Clone, Debug, PartialEq, CanonicalSerialize, CanonicalDeserialize)]
pub struct Proof<E: Pairing> {
pub a: E::G1Affine,
pub b: E::G2Affine,
pub c: E::G1Affine,
}
impl<E: Pairing> Default for Proof<E> {
fn default() -> Self {
Self {
a: E::G1Affine::default(),
b: E::G2Affine::default(),
c: E::G1Affine::default(),
}
}
}
#[derive(Clone, Debug, PartialEq, CanonicalSerialize, CanonicalDeserialize)]
pub struct VerifyingKey<E: Pairing> {
pub alpha_g1: E::G1Affine,
pub beta_g2: E::G2Affine,
pub gamma_g2: E::G2Affine,
pub delta_g2: E::G2Affine,
pub gamma_abc_g1: Vec<E::G1Affine>,
}
impl<E: Pairing> Default for VerifyingKey<E> {
fn default() -> Self {
Self {
alpha_g1: E::G1Affine::default(),
beta_g2: E::G2Affine::default(),
gamma_g2: E::G2Affine::default(),
delta_g2: E::G2Affine::default(),
gamma_abc_g1: Vec::new(),
}
}
}
#[derive(Clone, Debug, PartialEq, CanonicalSerialize, CanonicalDeserialize)]
pub struct PreparedVerifyingKey<E: Pairing> {
pub vk: VerifyingKey<E>,
pub alpha_g1_beta_g2: E::TargetField,
pub gamma_g2_neg_pc: E::G2Prepared,
pub delta_g2_neg_pc: E::G2Prepared,
}
impl<E: Pairing> From<PreparedVerifyingKey<E>> for VerifyingKey<E> {
fn from(other: PreparedVerifyingKey<E>) -> Self {
other.vk
}
}
impl<E: Pairing> From<VerifyingKey<E>> for PreparedVerifyingKey<E> {
fn from(other: VerifyingKey<E>) -> Self {
crate::prepare_verifying_key(&other)
}
}
impl<E: Pairing> Default for PreparedVerifyingKey<E> {
fn default() -> Self {
Self {
vk: VerifyingKey::default(),
alpha_g1_beta_g2: E::TargetField::default(),
gamma_g2_neg_pc: E::G2Prepared::default(),
delta_g2_neg_pc: E::G2Prepared::default(),
}
}
}
#[derive(Clone, Debug, PartialEq, CanonicalSerialize, CanonicalDeserialize)]
pub struct ProvingKey<E: Pairing> {
pub vk: VerifyingKey<E>,
pub beta_g1: E::G1Affine,
pub delta_g1: E::G1Affine,
pub a_query: Vec<E::G1Affine>,
pub b_g1_query: Vec<E::G1Affine>,
pub b_g2_query: Vec<E::G2Affine>,
pub h_query: Vec<E::G1Affine>,
pub l_query: Vec<E::G1Affine>,
}