Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subfield VOLE #127

Merged
merged 23 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@
"ENABLE_ALL_OT": true,
"ENABLE_SSE": true,
"ENABLE_AVX": true,
"ENABLE_BOOST": true,
"ENABLE_BITPOLYMUL": false,
"ENABLE_CIRCUITS": true,
"ENABLE_SIMPLESTOT": true,
"ENABLE_MRR": true,
"ENABLE_MR": true,
"ENABLE_SIMPLESTOT": true,
"ENABLE_RELIC": true,
"LIBOTE_STD_VER": "17",
"CMAKE_PREFIX_PATH": "${sourceDir}/../out/install",
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}"
Expand Down Expand Up @@ -43,23 +49,19 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"ENABLE_INSECURE_SILVER": false,
"ENABLE_LDPC": false,
"ENABLE_PPRF": true,
"ENABLE_SILENT_VOLE": true,
"LIBOTE_STD_VER": "17",
"ENABLE_ALL_OT": true,
"ENABLE_KKRT": "ON",
"ENABLE_IKNP": "ON",
"ENABLE_MR": "ON",
"ENABLE_SIMPLESTOT": "ON",
"ENABLE_RELIC": false,
"ENABLE_SODIUM": true,
"ENABLE_BOOST": false,
"ENABLE_BITPOLYMUL": true,
"ENABLE_BOOST": true,
"ENABLE_BITPOLYMUL": false,
"FETCH_AUTO": "ON",
"ENABLE_CIRCUITS": true,
"VERBOSE_FETCH": true,
"ENABLE_SSE": true,
"ENABLE_AVX": true,
"ENABLE_ASAN": true,
"ENABLE_ASAN": false,
"COPROTO_ENABLE_BOOST": true,
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
"CMAKE_PREFIX_PATH": "${sourceDir}/../out/install/${presetName}"
Expand All @@ -85,10 +87,10 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"LIBOTE_STD_VER": "17",
"ENABLE_ALL_OT": false,
"ENABLE_RELIC": false,
"ENABLE_ALL_OT": true,
"ENABLE_RELIC": true,
"ENABLE_SODIUM": false,
"ENABLE_BOOST": false,
"ENABLE_BOOST": true,
"ENABLE_OPENSSL": false,
"FETCH_AUTO": true,
"ENABLE_CIRCUITS": true,
Expand Down
19 changes: 6 additions & 13 deletions cmake/buildOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,8 @@ option(ENABLE_DELTA_IKNP "Build the IKNP Delta-OT-Ext protocol." OFF)
option(ENABLE_OOS "Build the OOS 1-oo-N OT-Ext protocol." OFF)
option(ENABLE_KKRT "Build the KKRT 1-oo-N OT-Ext protocol." OFF)

option(ENABLE_PPRF "Build the PPRF protocol." OFF)
option(ENABLE_SILENT_VOLE "Build the Silent Vole protocol." OFF)
#option(COPROTO_ENABLE_BOOST "Build with coproto boost support." OFF)
#option(COPROTO_ENABLE_OPENSSL "Build with coproto boost open ssl support." OFF)

option(ENABLE_INSECURE_SILVER "Build with silver codes." OFF)
option(ENABLE_LDPC "Build with ldpc functions." OFF)
Expand All @@ -105,21 +104,14 @@ if(ENABLE_INSECURE_SILVER)
endif()
option(NO_KOS_WARNING "Build with no kos security warning." OFF)

#option(FETCH_BITPOLYMUL "download and build bitpolymul" OFF))

EVAL(FETCH_BITPOLYMUL_IMPL
(DEFINED FETCH_BITPOLYMUL AND FETCH_BITPOLYMUL) OR
((NOT DEFINED FETCH_BITPOLYMUL) AND (FETCH_AUTO AND ENABLE_BITPOLYMUL)))


#option(FETCH_BITPOLYMUL "download and build bitpolymul" OFF))
EVAL(FETCH_BITPOLYMUL_IMPL
(DEFINED FETCH_BITPOLYMUL AND FETCH_BITPOLYMUL) OR
((NOT DEFINED FETCH_BITPOLYMUL) AND (FETCH_AUTO AND ENABLE_BITPOLYMUL)))




if(ENABLE_SILENT_VOLE OR ENABLE_SILENTOT OR ENABLE_SOFTSPOKEN_OT)
set(ENABLE_PPRF true)
endif()

option(VERBOSE_FETCH "Print build info for fetched libraries" ON)

Expand Down Expand Up @@ -159,7 +151,8 @@ message(STATUS "Option: ENABLE_KKRT = ${ENABLE_KKRT}\n\n")


message(STATUS "other \n=======================================================")
message(STATUS "Option: NO_KOS_WARNING = ${NO_KOS_WARNING}\n\n")
message(STATUS "Option: NO_KOS_WARNING = ${NO_KOS_WARNING}")
message(STATUS "Option: ENABLE_PPRF = ${ENABLE_PPRF}\n\n")

#############################################
# Config Checks #
Expand Down
1 change: 1 addition & 0 deletions cmake/buildOptions.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ set(ENABLE_KKRT @ENABLE_KKRT@)
set(ENABLE_SILENT_VOLE @ENABLE_SILENT_VOLE@)
set(NO_SILVER_WARNING @NO_SILVER_WARNING@)

set(ENABLE_PPRF @ENABLE_PPRF@)

set(libOTe_boost_FOUND ${ENABLE_BOOST})
set(libOTe_relic_FOUND ${ENABLE_RELIC})
Expand Down
2 changes: 1 addition & 1 deletion cryptoTools
154 changes: 154 additions & 0 deletions frontend/ExampleBase.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@

#include "libOTe/Base/SimplestOT.h"
#include "libOTe/Base/McRosRoyTwist.h"
#include "libOTe/Base/McRosRoy.h"
#include "libOTe/Tools/Popf/EKEPopf.h"
#include "libOTe/Tools/Popf/MRPopf.h"
#include "libOTe/Tools/Popf/FeistelPopf.h"
#include "libOTe/Tools/Popf/FeistelMulPopf.h"
#include "libOTe/Tools/Popf/FeistelRistPopf.h"
#include "libOTe/Tools/Popf/FeistelMulRistPopf.h"
#include "libOTe/Base/MasnyRindal.h"
#include "libOTe/Base/MasnyRindalKyber.h"

#include "cryptoTools/Common/BitVector.h"
#include "cryptoTools/Common/CLP.h"
#include "util.h"
#include "coproto/Socket/AsioSocket.h"
#include "cryptoTools/Common/Timer.h"

namespace osuCrypto
{

template<typename BaseOT>
void baseOT_example_from_ot(Role role, int totalOTs, int numThreads, std::string ip, std::string tag, const CLP&, BaseOT ot)
{
#ifdef COPROTO_ENABLE_BOOST
PRNG prng(sysRandomSeed());

if (totalOTs == 0)
totalOTs = 128;

if (numThreads > 1)
std::cout << "multi threading for the base OT example is not implemented.\n" << std::flush;

Timer t;
Timer::timeUnit s;
if (role == Role::Receiver)
{
auto sock = cp::asioConnect(ip, false);
BaseOT recv = ot;

AlignedVector<block> msg(totalOTs);
BitVector choice(totalOTs);
choice.randomize(prng);


s = t.setTimePoint("base OT start");

coproto::sync_wait(recv.receive(choice, msg, prng, sock));

// make sure all messages are sent.
cp::sync_wait(sock.flush());
}
else
{
auto sock = cp::asioConnect(ip, true);

BaseOT send = ot;

AlignedVector<std::array<block, 2>> msg(totalOTs);

s = t.setTimePoint("base OT start");

coproto::sync_wait(send.send(msg, prng, sock));


// make sure all messages are sent.
cp::sync_wait(sock.flush());
}



auto e = t.setTimePoint("base OT end");
auto milli = std::chrono::duration_cast<std::chrono::milliseconds>(e - s).count();

std::cout << tag << (role == Role::Receiver ? " (receiver)" : " (sender)")
<< " n=" << totalOTs << " " << milli << " ms" << std::endl;
#endif
}

template<typename BaseOT>
void baseOT_example(Role role, int totalOTs, int numThreads, std::string ip, std::string tag, const CLP& clp)
{
return baseOT_example_from_ot(role, totalOTs, numThreads, ip, tag, clp, BaseOT());
}

bool baseOT_examples(const CLP& cmd)
{
bool flagSet = false;

#ifdef ENABLE_SIMPLESTOT
flagSet |= runIf(baseOT_example<SimplestOT>, cmd, simple);
#endif

#ifdef ENABLE_SIMPLESTOT_ASM
flagSet |= runIf(baseOT_example<AsmSimplestOT>, cmd, simpleasm);
#endif

#ifdef ENABLE_MRR_TWIST
#ifdef ENABLE_SSE
flagSet |= runIf([&](Role role, int totalOTs, int numThreads, std::string ip, std::string tag, const CLP& clp) {
DomainSepEKEPopf factory;
const char* domain = "EKE POPF OT example";
factory.Update(domain, std::strlen(domain));
baseOT_example_from_ot(role, totalOTs, numThreads, ip, tag, clp, McRosRoyTwist(factory));
}, cmd, moellerpopf, { "eke" });
#endif

flagSet |= runIf([&](Role role, int totalOTs, int numThreads, std::string ip, std::string tag, const CLP& clp) {
DomainSepMRPopf factory;
const char* domain = "MR POPF OT example";
factory.Update(domain, std::strlen(domain));
baseOT_example_from_ot(role, totalOTs, numThreads, ip, tag, clp, McRosRoyTwistMR(factory));
}, cmd, moellerpopf, { "mrPopf" });

flagSet |= runIf([&](Role role, int totalOTs, int numThreads, std::string ip, std::string tag, const CLP& clp) {
DomainSepFeistelPopf factory;
const char* domain = "Feistel POPF OT example";
factory.Update(domain, std::strlen(domain));
baseOT_example_from_ot(role, totalOTs, numThreads, ip, tag, clp, McRosRoyTwistFeistel(factory));
}, cmd, moellerpopf, { "feistel" });

flagSet |= runIf([&](Role role, int totalOTs, int numThreads, std::string ip, std::string tag, const CLP& clp) {
DomainSepFeistelMulPopf factory;
const char* domain = "Feistel With Multiplication POPF OT example";
factory.Update(domain, std::strlen(domain));
baseOT_example_from_ot(role, totalOTs, numThreads, ip, tag, clp, McRosRoyTwistMul(factory));
}, cmd, moellerpopf, { "feistelMul" });
#endif

#ifdef ENABLE_MRR
flagSet |= runIf([&](Role role, int totalOTs, int numThreads, std::string ip, std::string tag, const CLP& clp) {
DomainSepFeistelRistPopf factory;
const char* domain = "Feistel POPF OT example (Risretto)";
factory.Update(domain, std::strlen(domain));
baseOT_example_from_ot(role, totalOTs, numThreads, ip, tag, clp, McRosRoy(factory));
}, cmd, ristrettopopf, { "feistel" });

flagSet |= runIf([&](Role role, int totalOTs, int numThreads, std::string ip, std::string tag, const CLP& clp) {
DomainSepFeistelMulRistPopf factory;
const char* domain = "Feistel With Multiplication POPF OT example (Risretto)";
factory.Update(domain, std::strlen(domain));
baseOT_example_from_ot(role, totalOTs, numThreads, ip, tag, clp, McRosRoyMul(factory));
}, cmd, ristrettopopf, { "feistelMul" });
#endif

#ifdef ENABLE_MR
flagSet |= runIf(baseOT_example<MasnyRindal>, cmd, mr);
#endif

return flagSet;
}

}
59 changes: 1 addition & 58 deletions frontend/ExampleBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,65 +14,8 @@

#include "cryptoTools/Common/BitVector.h"
#include "cryptoTools/Common/CLP.h"
#include "util.h"
#include "coproto/Socket/AsioSocket.h"

namespace osuCrypto
{

template<typename BaseOT>
void baseOT_example_from_ot(Role role, int totalOTs, int numThreads, std::string ip, std::string tag, CLP&, BaseOT ot)
{
#ifdef COPROTO_ENABLE_BOOST
PRNG prng(sysRandomSeed());

if (totalOTs == 0)
totalOTs = 128;

if (numThreads > 1)
std::cout << "multi threading for the base OT example is not implemented.\n" << std::flush;

Timer t;
Timer::timeUnit s;
if (role == Role::Receiver)
{
auto sock = cp::asioConnect(ip, false);
BaseOT recv = ot;

AlignedVector<block> msg(totalOTs);
BitVector choice(totalOTs);
choice.randomize(prng);


s = t.setTimePoint("base OT start");

coproto::sync_wait(recv.receive(choice, msg, prng, sock));

}
else
{
auto sock = cp::asioConnect(ip, true);

BaseOT send = ot;

AlignedVector<std::array<block, 2>> msg(totalOTs);

s = t.setTimePoint("base OT start");

coproto::sync_wait(send.send(msg, prng, sock));
}

auto e = t.setTimePoint("base OT end");
auto milli = std::chrono::duration_cast<std::chrono::milliseconds>(e - s).count();

std::cout << tag << (role == Role::Receiver ? " (receiver)" : " (sender)")
<< " n=" << totalOTs << " " << milli << " ms" << std::endl;
#endif
}

template<typename BaseOT>
void baseOT_example(Role role, int totalOTs, int numThreads, std::string ip, std::string tag, CLP& clp)
{
return baseOT_example_from_ot(role, totalOTs, numThreads, ip, tag, clp, BaseOT());
}
bool baseOT_examples(const CLP& clp);
}
Loading
Loading