#include "Verifier.h" template Verifier::Verifier(const Proof& proof) : P(proof) { #ifdef LESS_ALLOC_MORE_MEM z.resize(proof.phim); z.allocate_slots(bigint(1) << proof.B_plain_length); t.resize(3, proof.phim); t.allocate_slots(bigint(1) << proof.B_rand_length); #endif } template bool Check_Decoding(const Plaintext& AE,bool Diag) { // // Now check decoding z[i] // if (!AE.to_type(0)) // { cout << "Fail Check 4 " << endl; // return false; // } if (Diag && !AE.is_diagonal()) { cout << "Fail Check 5 " << endl; return false; } return true; } template bool Check_Decoding(const vector& AE, bool Diag) { (void)AE; if (Diag) throw not_implemented(); return true; } template void Verifier::Stage_2(const vector& e, AddableVector& c,octetStream& ciphertexts, octetStream& cleartexts, const FHE_PK& pk,bool Diag,bool binary) { unsigned int i,k,V=P.V; c.unpack(ciphertexts, pk); if (c.size() != P.sec) throw length_error("number of received ciphertexts incorrect"); // Now check the encryptions are correct int ee; Ciphertext d1(pk.get_params()), d2(pk.get_params()); Random_Coins rc(pk.get_params()); ciphertexts.get(V); if (V != P.V) throw length_error("number of received commitments incorrect"); cleartexts.get(V); if (V != P.V) throw length_error("number of received cleartexts incorrect"); for (i=0; i= (int) P.sec) { ee=0; } else { ee=e[jj]; } if (ee!=0) { add(d1,d1,c.at(jj)); } } rc.assign(t[0], t[1], t[2]); pk.encrypt(d2,z,rc); if (!(d1 == d2)) { cout << "Fail Check 6 " << i << endl; throw runtime_error("ciphertexts don't match"); } } // Now check decoding z[i] for (i=0; i void Verifier::NIZKPoK(AddableVector& c, octetStream& ciphertexts, octetStream& cleartexts, const FHE_PK& pk,bool Diag, bool binary) { vector e(P.sec); P.get_challenge(e, ciphertexts); Stage_2(e,c,ciphertexts,cleartexts,pk,Diag,binary); } template class Verifier; template class Verifier;