-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
88 lines (68 loc) · 2.31 KB
/
main.cpp
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
#include "zeroknowledge.h"
#include "protocol.h"
void PrintProtocolTimings(const clock_t begin, const clock_t end){
double elapsed_secs = double(end - begin)/CLOCKS_PER_SEC;
cout << "\n";
cout << "Decryption Protocol:"<< "\n";
cout << "Soundness: 2^-" << lambda << "\n";
cout << "Ciphertexts: " << tau << "\n";
cout << "\n";
cout << "Proof time: " <<elapsed_secs << " sec\n";
cout << "Time / ctx: " <<elapsed_secs/(lambda*tau) << " sec\n";
cout << "\n";
}
void PrintZKPTimings(const clock_t begin, const clock_t end){
double elapsed_secs = double(end - begin)/CLOCKS_PER_SEC;
cout << "\n";
cout << "Zero-Knowledge Protocol:"<< "\n";
cout << "Soundness: (2/3)^-" << mu << "\n";
cout << "Number of proofs: " << 2*lambda << "\n";
cout << "\n";
cout << "Proof time: " <<elapsed_secs << " sec\n";
cout << "Time / proof: " <<elapsed_secs/(2*lambda*mu) << " sec\n";
cout << "\n";
}
int main()
{
// Define variables
EncKey encKey;
ComKey comKey;
Statement stmt;
string hash;
Vec<CommitMessage> comMsg;
BinaryChallenge binaryChlg;
Vec<Response> resp;
Mat<ProofMessage> proofMessage;
Vec<TernaryChallenge> ternaryChlg;
Mat<Proof> zkProof;
clock_t begin, end;
// Initialize keys, message and response
InitializeDecryption(encKey,comKey,comMsg,resp);
// Sample tau messages and ciphertexts
CreateStatement(stmt,encKey);
begin = clock();
// Create the commit message
CreateCommitMessage(comMsg,hash,encKey,comKey,stmt);
// Create lambda binary challenges
CreateChallenge(binaryChlg);
// Create the response message
CreateResponseMessage(resp,comMsg,binaryChlg);
end = clock();
// Print parameters and timings
PrintProtocolTimings(begin,end);
// Verify the decryption proof
VerifyResponseMessage(stmt,hash,binaryChlg,resp,encKey.PKa,comKey);
// Initialize proofMessage, ternaryChlg and zkProof
InitializeZKProof(proofMessage,ternaryChlg,zkProof);
begin = clock();
CreateZKProofMessage(proofMessage, comKey.PK, comMsg, binaryChlg);
// Create mu ternary challenges
CreateTernaryChallenge(ternaryChlg);
// Create the proof message
CreateZKProof(zkProof, proofMessage, ternaryChlg);
end = clock();
// Print parameters and timings
PrintZKPTimings(begin,end);
// Verify the shortness proof
VerifyZKProof(zkProof, ternaryChlg, comKey.PK, resp);
}