Skip to content

Commit f56bc90

Browse files
committed
Implement missing traits
1 parent 7bd8e8a commit f56bc90

5 files changed

Lines changed: 30 additions & 1 deletion

src/group_element_vs_paillier_encryption_in_range.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,15 @@ use crate::unknown_order::BigNumber;
8686
use generic_ec::{Curve, Point};
8787
use libpaillier::{Ciphertext, EncryptionKey, Nonce};
8888

89+
#[derive(Debug, Clone)]
8990
pub struct SecurityParams {
9091
/// l in paper, bit size of plaintext
9192
pub l: usize,
9293
/// Epsilon in paper, range extension and security parameter for x
9394
pub epsilon: usize,
9495
}
9596

97+
#[derive(Debug, Clone)]
9698
pub struct Data<C: Curve> {
9799
pub key0: EncryptionKey,
98100
pub c: Ciphertext,
@@ -101,18 +103,21 @@ pub struct Data<C: Curve> {
101103
pub g: Point<C>,
102104
}
103105

106+
#[derive(Clone)]
104107
pub struct PrivateData {
105108
pub x: BigNumber,
106109
pub nonce: Nonce,
107110
}
108111

112+
#[derive(Debug, Clone)]
109113
pub struct Commitment<C: Curve> {
110114
pub s: BigNumber,
111115
pub a: Ciphertext,
112116
pub y: Point<C>,
113117
pub d: BigNumber,
114118
}
115119

120+
#[derive(Clone)]
116121
pub struct PrivateCommitment {
117122
pub alpha: BigNumber,
118123
pub mu: BigNumber,
@@ -122,6 +127,7 @@ pub struct PrivateCommitment {
122127

123128
pub type Challenge = BigNumber;
124129

130+
#[derive(Debug, Clone)]
125131
pub struct Proof {
126132
pub z1: BigNumber,
127133
pub z2: BigNumber,

src/paillier_affine_operation_in_range.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ use libpaillier::{Ciphertext, EncryptionKey, Nonce};
139139

140140
pub use crate::common::InvalidProof;
141141

142+
#[derive(Debug, Clone)]
142143
pub struct SecurityParams {
143144
/// l in paper, bit size of x
144145
pub l_x: usize,
@@ -149,6 +150,7 @@ pub struct SecurityParams {
149150
}
150151

151152
/// Public data that both parties know
153+
#[derive(Debug, Clone)]
152154
pub struct Data<C: Curve> {
153155
/// N0 in paper, public key that C was encrypted on
154156
pub key0: EncryptionKey,
@@ -165,6 +167,7 @@ pub struct Data<C: Curve> {
165167
}
166168

167169
/// Private data of prover
170+
#[derive(Clone)]
168171
pub struct PrivateData {
169172
/// x or epsilon in paper, preimage of X
170173
pub x: BigNumber,
@@ -178,6 +181,7 @@ pub struct PrivateData {
178181

179182
// As described in cggmp21 at page 35
180183
/// Prover's first message, obtained by `commit`
184+
#[derive(Debug, Clone)]
181185
pub struct Commitment<C: Curve> {
182186
pub a: BigNumber,
183187
pub b_x: Point<C>,
@@ -190,6 +194,7 @@ pub struct Commitment<C: Curve> {
190194

191195
/// Prover's data accompanying the commitment. Kept as state between rounds in
192196
/// the interactive protocol.
197+
#[derive(Clone)]
193198
pub struct PrivateCommitment {
194199
pub alpha: BigNumber,
195200
pub beta: BigNumber,
@@ -206,6 +211,7 @@ pub struct PrivateCommitment {
206211
pub type Challenge = BigNumber;
207212

208213
/// The ZK proof. Computed by `prove`
214+
#[derive(Debug, Clone)]
209215
pub struct Proof {
210216
pub z1: BigNumber,
211217
pub z2: BigNumber,

src/paillier_blum_modulus.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,20 @@ pub enum InvalidProof {
7373
}
7474

7575
/// Public data that both parties know: the Paillier-Blum modulus
76+
#[derive(Debug, Clone)]
7677
pub struct Data {
7778
pub n: BigNumber,
7879
}
7980

8081
/// Private data of prover
82+
#[derive(Clone)]
8183
pub struct PrivateData {
8284
pub p: BigNumber,
8385
pub q: BigNumber,
8486
}
8587

8688
/// Prover's first message, obtained by `commit`
89+
#[derive(Debug, Clone)]
8790
pub struct Commitment {
8891
pub w: BigNumber,
8992
}
@@ -92,11 +95,12 @@ pub struct Commitment {
9295
/// `challenge`
9396
///
9497
/// Consists of `M` singular challenges
95-
#[derive(Debug, PartialEq, Eq)]
98+
#[derive(Debug, PartialEq, Eq, Clone)]
9699
pub struct Challenge<const M: usize> {
97100
pub ys: [BigNumber; M],
98101
}
99102

103+
#[derive(Debug, Clone)]
100104
pub struct ProofPoint {
101105
pub x: BigNumber,
102106
pub a: bool,
@@ -105,6 +109,7 @@ pub struct ProofPoint {
105109
}
106110

107111
/// The ZK proof. Computed by `prove`. Consists of M proofs for each challenge
112+
#[derive(Debug, Clone)]
108113
pub struct Proof<const M: usize> {
109114
pub points: [ProofPoint; M],
110115
}

src/paillier_decryption_modulo_q.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ use libpaillier::{Ciphertext, EncryptionKey, Nonce};
7575

7676
pub use crate::common::InvalidProof;
7777

78+
#[derive(Debug, Clone)]
7879
pub struct SecurityParams {
7980
/// l in paper, bit size of plaintext
8081
pub l: usize,
@@ -83,6 +84,7 @@ pub struct SecurityParams {
8384
}
8485

8586
/// Public data that both parties know
87+
#[derive(Debug, Clone)]
8688
pub struct Data {
8789
/// q in paper, modulo value such that `x = y mod q`
8890
pub q: BigNumber,
@@ -95,13 +97,15 @@ pub struct Data {
9597
}
9698

9799
/// Private data of prover
100+
#[derive(Clone)]
98101
pub struct PrivateData {
99102
/// y in paper, plaintext value of C
100103
pub y: BigNumber,
101104
/// rho in paper, nonce of encryption y -> C
102105
pub nonce: Nonce,
103106
}
104107

108+
#[derive(Debug, Clone)]
105109
/// Prover's first message, obtained by `commit`
106110
pub struct Commitment {
107111
pub s: BigNumber,
@@ -112,6 +116,7 @@ pub struct Commitment {
112116

113117
/// Prover's data accompanying the commitment. Kept as state between rounds in
114118
/// the interactive protocol.
119+
#[derive(Clone)]
115120
pub struct PrivateCommitment {
116121
pub alpha: BigNumber,
117122
pub mu: BigNumber,
@@ -124,6 +129,7 @@ pub struct PrivateCommitment {
124129
pub type Challenge = BigNumber;
125130

126131
/// The ZK proof. Computed by `prove`
132+
#[derive(Debug, Clone)]
127133
pub struct Proof {
128134
pub z1: BigNumber,
129135
pub z2: BigNumber,

src/paillier_encryption_in_range.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ use libpaillier::{Ciphertext, EncryptionKey, Nonce};
7676

7777
pub use crate::common::InvalidProof;
7878

79+
#[derive(Debug, Clone)]
7980
pub struct SecurityParams {
8081
/// l in paper, bit size of plaintext
8182
pub l: usize,
@@ -86,6 +87,7 @@ pub struct SecurityParams {
8687
}
8788

8889
/// Public data that both parties know
90+
#[derive(Debug, Clone)]
8991
pub struct Data {
9092
/// N0 in paper, public key that k -> K was encrypted on
9193
pub key: EncryptionKey,
@@ -94,6 +96,7 @@ pub struct Data {
9496
}
9597

9698
/// Private data of prover
99+
#[derive(Clone)]
97100
pub struct PrivateData {
98101
/// k in paper, plaintext of K
99102
pub plaintext: BigNumber,
@@ -103,6 +106,7 @@ pub struct PrivateData {
103106

104107
// As described in cggmp21 at page 33
105108
/// Prover's first message, obtained by `commit`
109+
#[derive(Debug, Clone)]
106110
pub struct Commitment {
107111
pub s: BigNumber,
108112
pub a: BigNumber,
@@ -111,6 +115,7 @@ pub struct Commitment {
111115

112116
/// Prover's data accompanying the commitment. Kept as state between rounds in
113117
/// the interactive protocol.
118+
#[derive(Clone)]
114119
pub struct PrivateCommitment {
115120
pub alpha: BigNumber,
116121
pub mu: BigNumber,
@@ -124,6 +129,7 @@ pub type Challenge = BigNumber;
124129

125130
// As described in cggmp21 at page 33
126131
/// The ZK proof. Computed by `prove`
132+
#[derive(Debug, Clone)]
127133
pub struct Proof {
128134
pub z1: BigNumber,
129135
pub z2: BigNumber,

0 commit comments

Comments
 (0)