From a43e8f6439b7581f5ce45fb91371d52501ab921e Mon Sep 17 00:00:00 2001 From: xiaojiqing Date: Mon, 15 Jun 2026 23:09:23 -0700 Subject: [PATCH] feat: add PrimalLPNParameter for ferret --- emp-ot/emp-ot/ferret/constants.h | 1 + emp-zk/emp-zk/emp-zk-bool/emp-zk-bool.h | 6 +++--- emp-zk/emp-zk/emp-zk-bool/ostriple.h | 13 +++++++++---- emp-zk/emp-zk/emp-zk-bool/zk_prover.h | 4 ++-- emp-zk/emp-zk/emp-zk-bool/zk_verifier.h | 4 ++-- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/emp-ot/emp-ot/ferret/constants.h b/emp-ot/emp-ot/ferret/constants.h index c661bda..1cc3a20 100644 --- a/emp-ot/emp-ot/ferret/constants.h +++ b/emp-ot/emp-ot/ferret/constants.h @@ -25,6 +25,7 @@ class PrimalLPNParameter { public: const static PrimalLPNParameter ferret_b13 = PrimalLPNParameter(10485760, 1280, 452000, 13, 470016, 918, 32768, 9); const static PrimalLPNParameter ferret_b12 = PrimalLPNParameter(10268672, 2507, 238000, 12, 268800, 1050, 17384, 8); const static PrimalLPNParameter ferret_b11 = PrimalLPNParameter(10180608, 4971, 124000, 11, 178944, 699, 17384, 8); +const static PrimalLPNParameter ferret_b10 = PrimalLPNParameter(1024*2048, 2048, 65536, 10, 86272, 337, 16384, 8); }//namespace #endif //EMP_FERRET_CONSTANTS_H__ diff --git a/emp-zk/emp-zk/emp-zk-bool/emp-zk-bool.h b/emp-zk/emp-zk/emp-zk-bool/emp-zk-bool.h index 1e6cb1d..b58ea08 100644 --- a/emp-zk/emp-zk/emp-zk-bool/emp-zk-bool.h +++ b/emp-zk/emp-zk/emp-zk-bool/emp-zk-bool.h @@ -9,16 +9,16 @@ namespace emp { template -inline void setup_zk_bool(IO** ios, int threads, int party, void * state = nullptr) { +inline void setup_zk_bool(IO** ios, int threads, int party, void * state = nullptr, const PrimalLPNParameter* lpn_param = &ferret_b10) { CheatRecord::reset(); if(party == ALICE) { ZKBoolCircExecPrv * t = new ZKBoolCircExecPrv(); CircuitExecution::circ_exec = t; - ProtocolExecution::prot_exec = new ZKProver(ios, threads, t, state); + ProtocolExecution::prot_exec = new ZKProver(ios, threads, t, state, lpn_param); } else { ZKBoolCircExecVer * t = new ZKBoolCircExecVer(); CircuitExecution::circ_exec = t; - ProtocolExecution::prot_exec = new ZKVerifier(ios, threads, t, state); + ProtocolExecution::prot_exec = new ZKVerifier(ios, threads, t, state, lpn_param); } } diff --git a/emp-zk/emp-zk/emp-zk-bool/ostriple.h b/emp-zk/emp-zk/emp-zk-bool/ostriple.h index b5d5472..643e40a 100644 --- a/emp-zk/emp-zk/emp-zk-bool/ostriple.h +++ b/emp-zk/emp-zk/emp-zk-bool/ostriple.h @@ -32,14 +32,19 @@ class OSTriple { ThreadPool *pool = nullptr; void * ferret_state = nullptr; - OSTriple (int party, int threads, IO **ios, void * state = nullptr) { + OSTriple (int party, int threads, IO **ios, void * state = nullptr, const PrimalLPNParameter* lpn_param = nullptr) { this->party = party; this->threads = threads; this->ferret_state = state; // initiate Iterative COT with regular noise and security against malicious adv - if(ferret_state == nullptr) - // ferret = new FerretCOT(3-party, threads, ios, true); - ferret = new FerretCOT(3-party, threads, ios, true, true, PrimalLPNParameter(1024*2048, 2048, 65536, 10, 86272, 337, 16384, 8)); + if(ferret_state == nullptr) { + if (lpn_param == nullptr) { + ferret = new FerretCOT(3-party, threads, ios, true, true, ferret_b10); + } + else { + ferret = new FerretCOT(3-party, threads, ios, true, true, *lpn_param); + } + } else { ferret = new FerretCOT(3-party, threads, ios, true, false); ferret->disassemble_state(ferret_state, 10400000); diff --git a/emp-zk/emp-zk/emp-zk-bool/zk_prover.h b/emp-zk/emp-zk/emp-zk-bool/zk_prover.h index 86d5a0f..b111908 100644 --- a/emp-zk/emp-zk/emp-zk-bool/zk_prover.h +++ b/emp-zk/emp-zk/emp-zk-bool/zk_prover.h @@ -35,10 +35,10 @@ class ZKProver: public ProtocolExecution { OSTriple *ostriple = nullptr; PolyProof *polyproof = nullptr; ZKBoolCircExecPrv *gen = nullptr; - ZKProver(IO** ios, int threads, ZKBoolCircExecPrv *t, void * state): ProtocolExecution(ALICE) { + ZKProver(IO** ios, int threads, ZKBoolCircExecPrv *t, void * state, const PrimalLPNParameter* lpn_param = &ferret_b10): ProtocolExecution(ALICE) { this->io = ios[0]; this->gen = t; - ostriple = new OSTriple(ALICE, threads, ios, state); + ostriple = new OSTriple(ALICE, threads, ios, state, lpn_param); polyproof = new PolyProof(ALICE, ios[0], ostriple->ferret); t->template set_ostriple(ostriple); t->polyproof = this->polyproof; diff --git a/emp-zk/emp-zk/emp-zk-bool/zk_verifier.h b/emp-zk/emp-zk/emp-zk-bool/zk_verifier.h index e06b1cb..3a3e52d 100644 --- a/emp-zk/emp-zk/emp-zk-bool/zk_verifier.h +++ b/emp-zk/emp-zk/emp-zk-bool/zk_verifier.h @@ -46,9 +46,9 @@ class ZKVerifier: public ProtocolExecution { OSTriple* ostriple = nullptr; PolyProof *polyproof = nullptr; ZKBoolCircExecVer *eva = nullptr; - ZKVerifier(IO **ios, int threads, ZKBoolCircExecVer *t, void * state): ProtocolExecution(BOB) { + ZKVerifier(IO **ios, int threads, ZKBoolCircExecVer *t, void * state, const PrimalLPNParameter* lpn_param = &ferret_b10): ProtocolExecution(BOB) { this->io = ios[0]; - ostriple = new OSTriple(BOB, threads, ios, state); + ostriple = new OSTriple(BOB, threads, ios, state, lpn_param); polyproof = new PolyProof(BOB, ios[0], ostriple->ferret); polyproof->delta = ostriple->delta; t->template set_ostriple(ostriple);