MCPcopy Create free account
hub / github.com/data61/MP-SPDZ / first_phase

Function first_phase

Utils/he-example.cpp:25–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23}
24
25void first_phase(string filename, int n_mults, int circuit_sec)
26{
27 // specify number of multiplications (at most one) and function privacy parameter
28 // increase the latter to accommodate more operations
29 FHE_Params params(n_mults, circuit_sec);
30
31 // generate parameters for computation modulo a 32-bit prime
32 params.basic_generation_mod_prime(32);
33
34 // find computation modulus (depends on parameter generation)
35 cout << "computation modulo " << params.get_plaintext_modulus() << endl;
36
37 // generate key pair
38 FHE_KeyPair pair(params);
39 pair.generate();
40
41 Plaintext_mod_prime plaintext(params);
42
43 // set first two plaintext slots
44 plaintext.set_element(0, 4);
45 plaintext.set_element(1, -1);
46
47 // encrypt
48 Ciphertext ciphertext = pair.pk.encrypt(plaintext);
49
50 // store for second phase
51 octetStream os;
52 params.pack(os);
53 pair.pk.pack(os);
54 ciphertext.pack(os);
55 plaintext.pack(os);
56 pair.sk.pack(os);
57 ofstream out(filename);
58 os.output(out);
59}
60
61void second_phase(string filename)
62{

Callers 3

mainFunction · 0.85
_compute_prfs_outputsMethod · 0.85
_fill_keysMethod · 0.85

Calls 7

get_plaintext_modulusMethod · 0.80
encryptMethod · 0.60
generateMethod · 0.45
set_elementMethod · 0.45
packMethod · 0.45
outputMethod · 0.45

Tested by

no test coverage detected