/* * Proof.cpp * */ #include "Proof.h" #include "FHE/P2Data.h" #include "FHEOffline/EncCommit.h" #include "Math/Z2k.hpp" double Proof::dist = 0; bigint Proof::slack(int slack, int sec, int phim) { switch (slack) { case NONINTERACTIVE_SPDZ1_SLACK: cout << "Computing slack for non-interactive SPDZ1 proof" << endl; return NonInteractiveProof::slack(sec, phim); case INTERACTIVE_SPDZ1_SLACK: cout << "Computing slack for interactive SPDZ1 proof" << endl; return InteractiveProof::slack(sec, phim); case COVERT_SPDZ2_SLACK: cout << "No slack for covert SPDZ2 proof" << endl; return 0; case ACTIVE_SPDZ2_SLACK: cout << "Computing slack for active SPDZ2 proof" << endl; return EncCommit_::active_slack(phim); default: if (slack < 0) throw runtime_error("slack type unknown"); return bigint(1) << slack; } } void Proof::set_challenge(const octetStream& ciphertexts) { octetStream hash = ciphertexts.hash(); PRNG G; assert(hash.get_length() >= SEED_SIZE); G.SetSeed(hash.get_data()); set_challenge(G); } void Proof::set_challenge(PRNG& G) { unsigned int i; if (top_gear) { W.resize(V, vector(U)); for (i = 0; i < V; i++) for (unsigned j = 0; j < U; j++) W[i][j] = G.get_uint(2 * phim) - 1; } else { e.resize(sec); for (i = 0; i < sec; i++) { e[i] = G.get_bit(); } } } void Proof::generate_challenge(const Player& P) { GlobalPRNG G(P); set_challenge(G); } template class AbsoluteBoundChecker { T bound, neg_bound; public: AbsoluteBoundChecker(T bound) : bound(bound), neg_bound(-this->bound) {} bool outside(const T& value, double& dist) { (void)dist; #ifdef PRINT_MIN_DIST dist = max(dist, abs(value.get_d()) / bound.get_d()); #endif return value > bound || value < neg_bound; } }; bool Proof::check_bounds(T& z, X& t, int i) const { (void)i; unsigned int j,k; // Check Bound 1 and Bound 2 AbsoluteBoundChecker plain_checker(plain_check * n_proofs); AbsoluteBoundChecker rand_checker( rand_check * n_proofs); for (j=0; j 0) return OnlineOptions::singleton.comp_sec(); else return 0; }