| 81 | |
| 82 | template <class FD> |
| 83 | void covert_generation(Plaintext_<FD>& mess, vector<Ciphertext>& C, |
| 84 | const vector<const FHE_PK*>& pks, const Player* P, int num_runs, condition cond) |
| 85 | { |
| 86 | CODE_LOCATION |
| 87 | const FHE_Params& params=(*pks[0]).get_params(); |
| 88 | |
| 89 | /* Commit to the seeds */ |
| 90 | vector< vector<octetStream> > seeds(num_runs, vector<octetStream>((*P).num_players())); |
| 91 | vector< vector<octetStream> > Comm_seeds(num_runs, vector<octetStream>((*P).num_players())); |
| 92 | vector<octetStream> Open_seeds(num_runs); |
| 93 | |
| 94 | vector<PRNG> G(num_runs); |
| 95 | Commit_To_Seeds(G,seeds,Comm_seeds,Open_seeds,*P,num_runs); |
| 96 | |
| 97 | // Generate the messages and ciphertexts |
| 98 | vector< Plaintext_<FD> > m(num_runs,mess.get_field()); |
| 99 | vector<Ciphertext> c(num_runs,params); |
| 100 | Random_Coins rc(params); |
| 101 | for (int i=0; i<num_runs; i++) |
| 102 | { m[i].randomize(G[i],cond); |
| 103 | rc.generate(G[i]); |
| 104 | (*pks[P->my_num()]).encrypt(c[i],m[i],rc); |
| 105 | //cout << "xxxxxxxxxxxxxxxxxxxxx" << endl; |
| 106 | //cout << i << "\t" << (*P).socket(P.my_num()) << endl; |
| 107 | //cout << i << "\t" << m[i] << endl; |
| 108 | //cout << i << "\t" << rc << endl; |
| 109 | //cout << i << "\t" << c[i] << endl; |
| 110 | } |
| 111 | |
| 112 | // Broadcast and receive ciphertexts |
| 113 | vector< vector<octetStream> > ctx(num_runs, vector<octetStream> ((*P).num_players())); |
| 114 | for (int i=0; i<num_runs; i++) |
| 115 | { c[i].pack(ctx[i][(*P).my_num()]); |
| 116 | (*P).Broadcast_Receive(ctx[i]); |
| 117 | } |
| 118 | |
| 119 | // Compute and commit to the challenge value |
| 120 | vector<unsigned int> e((*P).num_players()); |
| 121 | vector<octetStream> Comm_e((*P).num_players()); |
| 122 | vector<octetStream> Open_e((*P).num_players()); |
| 123 | Commit_To_Challenge(e,Comm_e,Open_e,*P,num_runs); |
| 124 | |
| 125 | // Open challenge |
| 126 | int challenge=Open_Challenge(e,Open_e,Comm_e,*P,num_runs); |
| 127 | |
| 128 | // Open seeds, but not the challenge run |
| 129 | Open(seeds,Comm_seeds,Open_seeds,*P,num_runs,challenge); |
| 130 | |
| 131 | // Now check all the prior executions |
| 132 | Plaintext_<FD> mm(mess.get_field()); |
| 133 | Ciphertext cc(params); |
| 134 | octetStream occ; |
| 135 | for (int i=0; i<num_runs; i++) |
| 136 | { if (i!=challenge) |
| 137 | { for (int j=0; j<(*P).num_players(); j++) |
| 138 | { if (j!=(*P).my_num()) |
| 139 | { PRNG G; |
| 140 | G.SetSeed(seeds[i][j].get_data()); |
no test coverage detected