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

Function second_phase

Utils/he-example.cpp:61–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61void second_phase(string filename)
62{
63 // read from file
64 ifstream in(filename);
65 octetStream os;
66 os.input(in);
67 FHE_Params params;
68 FHE_PK pk(params);
69 FHE_SK sk(params);
70 Plaintext_mod_prime plaintext(params);
71 Ciphertext ciphertext(params);
72
73 // parameter must be set correctly first
74 params.unpack(os);
75 pk.unpack(os);
76 ciphertext.unpack(os);
77 plaintext.unpack(os);
78
79 if (params.n_mults() == 0)
80 // public-private multiplication is always available
81 ciphertext *= plaintext;
82 else
83 // private-private multiplication only with matching parameters
84 ciphertext = ciphertext.mul(pk, ciphertext);
85
86 // re-randomize for circuit privacy
87 ciphertext.rerandomize(pk);
88
89 // read secret key and decrypt
90 sk.unpack(os);
91 plaintext = sk.decrypt(ciphertext);
92
93 cout << "should be 16: " << plaintext.element(0) << endl;
94 cout << "should be 1: " << plaintext.element(1) << endl;
95 assert(plaintext.element(0) == 16);
96 assert(plaintext.element(1) == 1);
97}

Callers 3

mainFunction · 0.85
garbleMethod · 0.85
_check_evaluateMethod · 0.85

Calls 7

rerandomizeMethod · 0.80
elementMethod · 0.80
inputMethod · 0.45
unpackMethod · 0.45
n_multsMethod · 0.45
mulMethod · 0.45
decryptMethod · 0.45

Tested by

no test coverage detected