Skip to content

Commit e1b30c8

Browse files
committed
Merge Douglas's PR but keep going with RandomFunctions
1 parent 1af9e50 commit e1b30c8

2 files changed

Lines changed: 10 additions & 19 deletions

File tree

proof/prooffrog/UG-KEM-CCA.proof

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,13 @@ Game GameTableRandom(KEM K, NominalGroup NG, PRF H, PRG G) {
241241
NG.Exponent dk_T;
242242
K.Ciphertext kem_ct;
243243
K.Ciphertext ct_PQ;
244-
Map<BitString<H.in>, BitString<H.out>> T;
244+
RandomFunctions<BitString<H.in>, BitString<H.out>> RF;
245245
BitString<H.out> ss;
246246
[K.EncapsKey, NG.GroupElem] ek;
247247
[K.Ciphertext, NG.GroupElem] ct;
248248

249249
Void Initialize() {
250+
RF <- RandomFunctions<BitString<H.in>, BitString<H.out>>;
250251
BitString<K.Nseed> kem_seed <- BitString<K.Nseed>;
251252
[K.EncapsKey, K.DecapsKey] kem_keypair = K.DeriveKeyPair(kem_seed);
252253
ek_PQ = kem_keypair[0];
@@ -260,10 +261,7 @@ Game GameTableRandom(KEM K, NominalGroup NG, PRF H, PRG G) {
260261
NG.Exponent ske = NG.SampleExponent();
261262
NG.GroupElem ct_T = NG.Exp(NG.Generator(), ske);
262263
NG.GroupElem k2 = NG.Exp(ek_T, ske);
263-
if (!((NG.Encode(k2) || K.EncodeCiphertext(ct_PQ) || NG.Encode(ct_T) || K.EncodeEncapsKey(ek_PQ) || NG.Encode(ek_T)) in T)) {
264-
T[NG.Encode(k2) || K.EncodeCiphertext(ct_PQ) || NG.Encode(ct_T) || K.EncodeEncapsKey(ek_PQ) || NG.Encode(ek_T)] <- BitString<H.out>;
265-
}
266-
ss = T[NG.Encode(k2) || K.EncodeCiphertext(ct_PQ) || NG.Encode(ct_T) || K.EncodeEncapsKey(ek_PQ) || NG.Encode(ek_T)];
264+
ss = RF(NG.Encode(k2) || K.EncodeCiphertext(ct_PQ) || NG.Encode(ct_T) || K.EncodeEncapsKey(ek_PQ) || NG.Encode(ek_T));
267265
ek = [ek_PQ, ek_T];
268266
ct = [ct_PQ, ct_T];
269267
}
@@ -288,10 +286,7 @@ Game GameTableRandom(KEM K, NominalGroup NG, PRF H, PRG G) {
288286
}
289287
if (c1 == ct_PQ) {
290288
NG.GroupElem dec_k2 = NG.Exp(c2, dk_T);
291-
if (!((NG.Encode(dec_k2) || K.EncodeCiphertext(c1) || NG.Encode(c2) || K.EncodeEncapsKey(ek_PQ) || NG.Encode(ek_T)) in T)) {
292-
T[NG.Encode(dec_k2) || K.EncodeCiphertext(c1) || NG.Encode(c2) || K.EncodeEncapsKey(ek_PQ) || NG.Encode(ek_T)] <- BitString<H.out>;
293-
}
294-
return T[NG.Encode(dec_k2) || K.EncodeCiphertext(c1) || NG.Encode(c2) || K.EncodeEncapsKey(ek_PQ) || NG.Encode(ek_T)];
289+
return RF(NG.Encode(dec_k2) || K.EncodeCiphertext(c1) || NG.Encode(c2) || K.EncodeEncapsKey(ek_PQ) || NG.Encode(ek_T));
295290
}
296291
if (c1 == kem_ct) {
297292
return None;
@@ -320,12 +315,13 @@ Game GameFreshSS(KEM K, NominalGroup NG, PRF H, PRG G) {
320315
NG.Exponent dk_T;
321316
K.Ciphertext kem_ct;
322317
K.Ciphertext ct_PQ;
323-
Map<BitString<H.in>, BitString<H.out>> T;
318+
RandomFunctions<BitString<H.in>, BitString<H.out>> RF;
324319
BitString<H.out> ss;
325320
[K.EncapsKey, NG.GroupElem] ek;
326321
[K.Ciphertext, NG.GroupElem] ct;
327322

328323
Void Initialize() {
324+
RF <- RandomFunctions<BitString<H.in>, BitString<H.out>>;
329325
BitString<K.Nseed> kem_seed <- BitString<K.Nseed>;
330326
[K.EncapsKey, K.DecapsKey] kem_keypair = K.DeriveKeyPair(kem_seed);
331327
ek_PQ = kem_keypair[0];
@@ -364,10 +360,7 @@ Game GameFreshSS(KEM K, NominalGroup NG, PRF H, PRG G) {
364360
}
365361
if (c1 == ct_PQ) {
366362
NG.GroupElem dec_k2 = NG.Exp(c2, dk_T);
367-
if (!((NG.Encode(dec_k2) || K.EncodeCiphertext(c1) || NG.Encode(c2) || K.EncodeEncapsKey(ek_PQ) || NG.Encode(ek_T)) in T)) {
368-
T[NG.Encode(dec_k2) || K.EncodeCiphertext(c1) || NG.Encode(c2) || K.EncodeEncapsKey(ek_PQ) || NG.Encode(ek_T)] <- BitString<H.out>;
369-
}
370-
return T[NG.Encode(dec_k2) || K.EncodeCiphertext(c1) || NG.Encode(c2) || K.EncodeEncapsKey(ek_PQ) || NG.Encode(ek_T)];
363+
return RF(NG.Encode(dec_k2) || K.EncodeCiphertext(c1) || NG.Encode(c2) || K.EncodeEncapsKey(ek_PQ) || NG.Encode(ek_T));
371364
}
372365
if (c1 == kem_ct) {
373366
return None;

proof/prooffrog/games/PRF-Security.game

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,14 @@ Game Real(PRF F) {
1717
}
1818

1919
Game Random(PRF F) {
20-
Map<BitString<F.in>, BitString<F.out>> T;
20+
RandomFunctions<BitString<F.in>, BitString<F.out>> RF;
2121

2222
Void Initialize() {
23+
RF <- RandomFunctions<BitString<F.in>, BitString<F.out>>;
2324
}
2425

2526
BitString<F.out> Lookup(BitString<F.in> x) {
26-
if (!(x in T)) {
27-
T[x] <- BitString<F.out>;
28-
}
29-
return T[x];
27+
return RF(x);
3028
}
3129
}
3230

0 commit comments

Comments
 (0)