@@ -15,39 +15,39 @@ b(e::ElGamalRow{<:Group, N}) where N = ntuple(n -> e[n].b, N)
15
15
struct Decryption{G <: Group , N} <: Proposition
16
16
g:: G
17
17
pk:: G
18
- cyphertexts :: Vector{ElGamalRow{G, N}}
18
+ ciphertexts :: Vector{ElGamalRow{G, N}}
19
19
plaintexts:: Vector{NTuple{N, G}}
20
20
end
21
21
22
22
proof_type (:: Type{Decryption} ) = ChaumPedersenProof
23
23
proof_type (:: Type{<:Decryption{G}} ) where G <: Group = ChaumPedersenProof{G}
24
24
25
- Base.:(== )(x:: T , y:: T ) where T <: Decryption = x. g == y. g && x. pk == y. pk && x. cyphertexts == y. cyphertexts && x. plaintexts == y. plaintexts
25
+ Base.:(== )(x:: T , y:: T ) where T <: Decryption = x. g == y. g && x. pk == y. pk && x. ciphertexts == y. ciphertexts && x. plaintexts == y. plaintexts
26
26
27
27
function Base. permute! (decr:: Decryption , perm:: AbstractVector{<:Integer} )
28
28
29
- permute! (decr. cyphertexts , perm)
29
+ permute! (decr. ciphertexts , perm)
30
30
permute! (decr. plaintexts, perm)
31
31
32
32
return
33
33
end
34
34
35
- verify (proposition:: Decryption , secret:: Integer ) = decrypt (proposition. g, proposition. cyphertexts , secret) == proposition
35
+ verify (proposition:: Decryption , secret:: Integer ) = decrypt (proposition. g, proposition. ciphertexts , secret) == proposition
36
36
37
- axinv (proposition:: Decryption ) = (mi ./ b (ei) for (ei, mi) in zip (proposition. cyphertexts , proposition. plaintexts))
37
+ axinv (proposition:: Decryption ) = (mi ./ b (ei) for (ei, mi) in zip (proposition. ciphertexts , proposition. plaintexts))
38
38
axinv (e:: Vector{<:ElGamalRow} , secret:: Integer ) = (a (ei) .^ (- secret) for ei in e)
39
39
40
- function decrypt (g:: G , cyphertexts :: Vector{<:ElGamalRow{G}} , secret:: Integer ; axinv = axinv (cyphertexts , secret)) where G <: Group
40
+ function decrypt (g:: G , ciphertexts :: Vector{<:ElGamalRow{G}} , secret:: Integer ; axinv = axinv (ciphertexts , secret)) where G <: Group
41
41
42
- plaintexts = [b (ci) .* axi for (ci, axi) in zip (cyphertexts , axinv)]
42
+ plaintexts = [b (ci) .* axi for (ci, axi) in zip (ciphertexts , axinv)]
43
43
pk = g^ secret
44
44
45
- return Decryption (g, pk, cyphertexts , plaintexts)
45
+ return Decryption (g, pk, ciphertexts , plaintexts)
46
46
end
47
47
48
48
function prove (proposition:: Decryption{G} , verifier:: Verifier , secret:: Integer ; axinv = axinv (proposition)) where G <: Group
49
49
50
- g_vec = [proposition. g, flatten (a (c) for c in proposition. cyphertexts )... ]
50
+ g_vec = [proposition. g, flatten (a (c) for c in proposition. ciphertexts )... ]
51
51
y_vec = [inv (proposition. pk), flatten (axinv)... ]
52
52
53
53
log_proposition = LogEquality (g_vec, y_vec)
@@ -57,9 +57,9 @@ function prove(proposition::Decryption{G}, verifier::Verifier, secret::Integer;
57
57
return log_proof
58
58
end
59
59
60
- function decrypt (g:: G , cyphertexts :: Vector{<:ElGamalRow{G}} , secret:: Integer , verifier:: Verifier ; axinv = axinv (cyphertexts , secret)) where G <: Group
60
+ function decrypt (g:: G , ciphertexts :: Vector{<:ElGamalRow{G}} , secret:: Integer , verifier:: Verifier ; axinv = axinv (ciphertexts , secret)) where G <: Group
61
61
62
- proposition = decrypt (g, cyphertexts , secret; axinv)
62
+ proposition = decrypt (g, ciphertexts , secret; axinv)
63
63
proof = prove (proposition, verifier, secret; axinv)
64
64
65
65
return Simulator (proposition, proof, verifier)
68
68
69
69
function verify (proposition:: Decryption , proof:: ChaumPedersenProof , verifier:: Verifier )
70
70
71
- g_vec = [proposition. g, flatten (a (c) for c in proposition. cyphertexts )... ]
71
+ g_vec = [proposition. g, flatten (a (c) for c in proposition. ciphertexts )... ]
72
72
y_vec = [inv (proposition. pk), flatten (axinv (proposition))... ]
73
73
74
74
log_proposition = LogEquality (g_vec, y_vec)
83
83
struct DecryptionInv{G <: Group , N} <: Proposition
84
84
g:: G
85
85
pk:: G
86
- cyphertexts :: Vector{ElGamalRow{G, N}}
86
+ ciphertexts :: Vector{ElGamalRow{G, N}}
87
87
trackers:: Vector{NTuple{N, G}}
88
88
end
89
89
90
90
proof_type (:: Type{DecryptionInv} ) = ChaumPedersenProof
91
91
proof_type (:: Type{<:DecryptionInv{G}} ) where G <: Group = ChaumPedersenProof{G}
92
92
93
- Base.:(== )(x:: T , y:: T ) where T <: DecryptionInv = x. g == y. g && x. pk == y. pk && x. cyphertexts == y. cyphertexts && x. trackers == y. trackers
93
+ Base.:(== )(x:: T , y:: T ) where T <: DecryptionInv = x. g == y. g && x. pk == y. pk && x. ciphertexts == y. ciphertexts && x. trackers == y. trackers
94
94
95
95
function Base. permute! (decr:: DecryptionInv , perm:: AbstractVector{<:Integer} )
96
96
97
- permute! (decr. cyphertexts , perm)
97
+ permute! (decr. ciphertexts , perm)
98
98
permute! (decr. trackers, perm)
99
99
100
100
return
101
101
end
102
102
103
- ax (proposition:: DecryptionInv ) = (ti .* b (ei) for (ei, ti) in zip (proposition. cyphertexts , proposition. trackers))
103
+ ax (proposition:: DecryptionInv ) = (ti .* b (ei) for (ei, ti) in zip (proposition. ciphertexts , proposition. trackers))
104
104
ax (e:: Vector{<:ElGamalRow} , secret:: Integer ) = (a (ei) .^ secret for ei in e)
105
105
106
- function decryptinv (g:: G , cyphertexts :: Vector{<:ElGamalRow{G}} , secret:: Integer ; ax = ax (cyphertexts , secret)) where G <: Group
106
+ function decryptinv (g:: G , ciphertexts :: Vector{<:ElGamalRow{G}} , secret:: Integer ; ax = ax (ciphertexts , secret)) where G <: Group
107
107
108
- trackers = [axi ./ b (ci) for (ci, axi) in zip (cyphertexts , ax)]
108
+ trackers = [axi ./ b (ci) for (ci, axi) in zip (ciphertexts , ax)]
109
109
pk = g^ secret
110
110
111
- return DecryptionInv (g, pk, cyphertexts , trackers)
111
+ return DecryptionInv (g, pk, ciphertexts , trackers)
112
112
end
113
113
114
114
# The same actually
115
115
function prove (proposition:: DecryptionInv{G} , verifier:: Verifier , secret:: Integer ; ax = ax (proposition)) where G <: Group
116
116
117
- g_vec = [proposition. g, flatten (a (c) for c in proposition. cyphertexts )... ]
117
+ g_vec = [proposition. g, flatten (a (c) for c in proposition. ciphertexts )... ]
118
118
y_vec = [proposition. pk, flatten (ax)... ]
119
119
120
120
log_proposition = LogEquality (g_vec, y_vec)
@@ -125,20 +125,20 @@ function prove(proposition::DecryptionInv{G}, verifier::Verifier, secret::Intege
125
125
end
126
126
127
127
128
- function decryptinv (g:: G , cyphertexts :: Vector{<:ElGamalRow{G}} , secret:: Integer , verifier:: Verifier ; ax = ax (cyphertexts , secret)) where G <: Group
128
+ function decryptinv (g:: G , ciphertexts :: Vector{<:ElGamalRow{G}} , secret:: Integer , verifier:: Verifier ; ax = ax (ciphertexts , secret)) where G <: Group
129
129
130
- proposition = decryptinv (g, cyphertexts , secret; ax)
130
+ proposition = decryptinv (g, ciphertexts , secret; ax)
131
131
132
132
proof = prove (proposition, verifier, secret; ax)
133
133
134
134
return Simulator (proposition, proof, verifier)
135
135
end
136
136
137
- verify (proposition:: DecryptionInv , secret:: Integer ) = decryptinv (proposition. g, proposition. cyphertexts , secret) == proposition
137
+ verify (proposition:: DecryptionInv , secret:: Integer ) = decryptinv (proposition. g, proposition. ciphertexts , secret) == proposition
138
138
139
139
function verify (proposition:: DecryptionInv , proof:: ChaumPedersenProof , verifier:: Verifier )
140
140
141
- g_vec = [proposition. g, flatten (a (c) for c in proposition. cyphertexts )... ]
141
+ g_vec = [proposition. g, flatten (a (c) for c in proposition. ciphertexts )... ]
142
142
y_vec = [proposition. pk, flatten (ax (proposition))... ]
143
143
144
144
log_proposition = LogEquality (g_vec, y_vec)
@@ -149,12 +149,12 @@ end
149
149
150
150
function Serializer. save (proposition:: Decryption , dir:: Path )
151
151
152
- (; g, pk, cyphertexts , plaintexts) = proposition
152
+ (; g, pk, ciphertexts , plaintexts) = proposition
153
153
154
154
pbkey_tree = Parser. marshal_publickey (pk, g)
155
155
write (joinpath (dir, " publicKey.bt" ), pbkey_tree)
156
156
157
- write (joinpath (dir, " Ciphertexts.bt" ), Tree (cyphertexts ))
157
+ write (joinpath (dir, " Ciphertexts.bt" ), Tree (ciphertexts ))
158
158
write (joinpath (dir, " Decryption.bt" ), Tree (plaintexts)) # Decryption could be renamed to Plaintexts
159
159
160
160
return
@@ -169,15 +169,15 @@ function Serializer.load(::Type{Decryption}, basedir::Path)
169
169
170
170
G = typeof (g)
171
171
172
- cyphertexts_tree = Parser. decode (read (joinpath (basedir, " Ciphertexts.bt" )))
172
+ ciphertexts_tree = Parser. decode (read (joinpath (basedir, " Ciphertexts.bt" )))
173
173
plaintexts_tree = Parser. decode (read (joinpath (basedir, " Decryption.bt" )))
174
174
175
175
N = 1 # ToDo: extract that from the tree
176
176
177
- cyphertexts = convert (Vector{ElGamalRow{G, N}}, cyphertexts_tree )
177
+ ciphertexts = convert (Vector{ElGamalRow{G, N}}, ciphertexts_tree )
178
178
plaintexts = convert (Vector{NTuple{N, G}}, plaintexts_tree)
179
179
180
- return Decryption (g, pk, cyphertexts , plaintexts)
180
+ return Decryption (g, pk, ciphertexts , plaintexts)
181
181
end
182
182
183
183
Serializer. load (:: Type{P} , :: Type{Decryption} , path:: Path ) where P <: ChaumPedersenProof = Serializer. load (P, path; prefix= " Decryption" )
@@ -186,12 +186,12 @@ Serializer.load(::Type{P}, ::Type{Decryption}, path::Path) where P <: ChaumPeder
186
186
187
187
function Serializer. save (proposition:: DecryptionInv , dir:: Path )
188
188
189
- (; g, pk, cyphertexts , trackers) = proposition
189
+ (; g, pk, ciphertexts , trackers) = proposition
190
190
191
191
pbkey_tree = Parser. marshal_publickey (pk, g)
192
192
write (joinpath (dir, " publicKey.bt" ), pbkey_tree)
193
193
194
- write (joinpath (dir, " Ciphertexts.bt" ), Tree (cyphertexts ))
194
+ write (joinpath (dir, " Ciphertexts.bt" ), Tree (ciphertexts ))
195
195
write (joinpath (dir, " DecryptionInv.bt" ), Tree (trackers)) # Decryption could be renamed to Plaintexts
196
196
197
197
return
@@ -206,15 +206,15 @@ function Serializer.load(::Type{DecryptionInv}, basedir::Path)
206
206
207
207
G = typeof (g)
208
208
209
- cyphertexts_tree = Parser. decode (read (joinpath (basedir, " Ciphertexts.bt" )))
209
+ ciphertexts_tree = Parser. decode (read (joinpath (basedir, " Ciphertexts.bt" )))
210
210
plaintexts_tree = Parser. decode (read (joinpath (basedir, " DecryptionInv.bt" )))
211
211
212
212
N = 1 # ToDo: extract that from the tree
213
213
214
- cyphertexts = convert (Vector{ElGamalRow{G, N}}, cyphertexts_tree )
214
+ ciphertexts = convert (Vector{ElGamalRow{G, N}}, ciphertexts_tree )
215
215
plaintexts = convert (Vector{NTuple{N, G}}, plaintexts_tree)
216
216
217
- return DecryptionInv (g, pk, cyphertexts , plaintexts)
217
+ return DecryptionInv (g, pk, ciphertexts , plaintexts)
218
218
end
219
219
220
220
Serializer. load (:: Type{P} , :: Type{DecryptionInv} , path:: Path ) where P <: ChaumPedersenProof = Serializer. load (P, path; prefix= " DecryptionInv" )
0 commit comments