From d8ad6686808f87fa46ad864105debc096a5ff054 Mon Sep 17 00:00:00 2001 From: Marcel Keller Date: Tue, 9 Jun 2020 15:24:26 +1000 Subject: [PATCH] Use command-line modulus with HE-based protocols. --- FHEOffline/PairwiseSetup.cpp | 1 + Math/Setup.cpp | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/FHEOffline/PairwiseSetup.cpp b/FHEOffline/PairwiseSetup.cpp index 80563e227..1f6512eaf 100644 --- a/FHEOffline/PairwiseSetup.cpp +++ b/FHEOffline/PairwiseSetup.cpp @@ -62,6 +62,7 @@ void secure_init(T& setup, Player& P, MachineBase& machine, machine.drown_sec = sec; string filename = PREP_DIR + T::name() + "-" + to_string(plaintext_length) + "-" + to_string(sec) + "-" + + OnlineOptions::singleton.prime.get_str() + "-" + to_string(CowGearOptions::singleton.top_gear()) + "-P" + to_string(P.my_num()) + "-" + to_string(P.num_players()); try diff --git a/Math/Setup.cpp b/Math/Setup.cpp index a580d0963..4ef7d0968 100644 --- a/Math/Setup.cpp +++ b/Math/Setup.cpp @@ -69,6 +69,25 @@ void SPDZ_Data_Setup_Primes(bigint& p,int lgp,int& idx,int& m) void generate_prime(bigint& p, int lgp, int m) { + if (OnlineOptions::singleton.prime > 0) + { + p = OnlineOptions::singleton.prime; + if (!probPrime(p)) + { + cerr << p << " is not a prime" << endl; + exit(1); + } + else if (m != 1 and p % m != 1) + { + cerr << p + << " is not compatible with our encryption scheme, must be 1 modulo " + << m << endl; + exit(1); + } + else + return; + } + bigint u; int ex; ex = lgp - numBits(m);