From 302113ce658fe617d6b47fff76c32b77ee502f92 Mon Sep 17 00:00:00 2001 From: Sacha Servan-Schreiber <8027773+sachaservan@users.noreply.github.com> Date: Tue, 23 Jan 2024 13:03:23 +0100 Subject: [PATCH] Use the -f parameter in the SoftSpokenOT example --- frontend/ExampleTwoChooseOne.cpp | 31 +++++++------------ .../SoftSpokenOT/SoftSpokenMalOtExt.h | 13 ++++++++ .../SoftSpokenOT/SoftSpokenShOtExt.h | 11 +++++++ 3 files changed, 36 insertions(+), 19 deletions(-) diff --git a/frontend/ExampleTwoChooseOne.cpp b/frontend/ExampleTwoChooseOne.cpp index 4dc5527b..edce51c6 100644 --- a/frontend/ExampleTwoChooseOne.cpp +++ b/frontend/ExampleTwoChooseOne.cpp @@ -32,34 +32,29 @@ namespace osuCrypto #ifdef ENABLE_SOFTSPOKEN_OT // soft spoken takes an extra parameter as input what determines // the computation/communication trade-off. - template + template using is_SoftSpoken = typename std::conditional< - //std::is_same::value || - //std::is_same::value || - //std::is_same::value || - //std::is_same::value || - //std::is_same::value || - //std::is_same::value || - //std::is_same::value || - //std::is_same::value - false - , - std::true_type, std::false_type>::type; + std::is_same>::value || + std::is_same>::value || + std::is_same::value || + std::is_same::value, + std::true_type, + std::false_type>::type; #else - template + template using is_SoftSpoken = std::false_type; #endif template typename std::enable_if::value, T>::type - construct(CLP& cmd) + construct(const CLP& cmd) { return T(cmd.getOr("f", 2)); } template typename std::enable_if::value, T>::type - construct(CLP& cmd) + construct(const CLP& cmd) { return T{}; } @@ -79,10 +74,8 @@ namespace osuCrypto PRNG prng(sysRandomSeed()); - - OtExtSender sender; - OtExtRecver receiver; - + OtExtSender sender = construct(cmd); + OtExtRecver receiver = construct(cmd); #ifdef LIBOTE_HAS_BASE_OT // Now compute the base OTs, we need to set them on the first pair of extenders. diff --git a/libOTe/TwoChooseOne/SoftSpokenOT/SoftSpokenMalOtExt.h b/libOTe/TwoChooseOne/SoftSpokenOT/SoftSpokenMalOtExt.h index 3e7502ad..d7aaee37 100644 --- a/libOTe/TwoChooseOne/SoftSpokenOT/SoftSpokenMalOtExt.h +++ b/libOTe/TwoChooseOne/SoftSpokenOT/SoftSpokenMalOtExt.h @@ -153,6 +153,12 @@ namespace osuCrypto SoftSpokenMalOtSender() { init(); } + + SoftSpokenMalOtSender(u64 fieldBits) + { + init(fieldBits); + } + SoftSpokenMalOtSender(SoftSpokenMalOtSender&& o) = default; SoftSpokenMalOtSender& operator=(SoftSpokenMalOtSender&& o) = default; @@ -285,6 +291,13 @@ namespace osuCrypto { init(); } + + SoftSpokenMalOtReceiver(u64 fieldBits) + { + init(fieldBits); + } + + SoftSpokenMalOtReceiver(SoftSpokenMalOtReceiver&& o) :mBase(std::move(o.mBase)) ,mExtraV(std::move(o.mExtraV)) diff --git a/libOTe/TwoChooseOne/SoftSpokenOT/SoftSpokenShOtExt.h b/libOTe/TwoChooseOne/SoftSpokenOT/SoftSpokenShOtExt.h index 1e66876b..58adb3d8 100644 --- a/libOTe/TwoChooseOne/SoftSpokenOT/SoftSpokenShOtExt.h +++ b/libOTe/TwoChooseOne/SoftSpokenOT/SoftSpokenShOtExt.h @@ -101,6 +101,11 @@ namespace osuCrypto init(); } + SoftSpokenShOtSender(u64 fieldBits) + { + init(fieldBits); + } + SoftSpokenShOtSender(SoftSpokenShOtSender&& o) : mSubVole(std::move(o.mSubVole)) , mBlockIdx(std::exchange(o.mBlockIdx, 0)) @@ -281,6 +286,12 @@ namespace osuCrypto { init(); } + + SoftSpokenShOtReceiver(u64 fieldBits) + { + init(fieldBits); + } + SoftSpokenShOtReceiver(const SoftSpokenShOtReceiver&) = delete; SoftSpokenShOtReceiver(SoftSpokenShOtReceiver&& o) : mSubVole(std::move(o.mSubVole))