Skip to content

Commit

Permalink
mock ot and ci
Browse files Browse the repository at this point in the history
  • Loading branch information
ladnir committed Jun 12, 2024
1 parent 334da1b commit 549bf27
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 15 deletions.
22 changes: 9 additions & 13 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ jobs:

# Runs a set of commands using the runners shell

- name: build relic
run: python3 build.py --setup --relic --par=4 -DVERBOSE_FETCH=ON -DENABLE_BOOST=OFF -DENABLE_SODIUM=OFF -DENABLE_ASAN=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo
#- name: build relic
# run: python3 build.py -DENABLE_BOOST=OFF -DENABLE_SODIUM=OFF -DENABLE_ASAN=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo

- name: build bitpolymul
run: python3 build.py --setup --bitpolymul --par=4 -DVERBOSE_FETCH=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo
#- name: build bitpolymul
# run: python3 build.py --setup --bitpolymul --par=4 -DVERBOSE_FETCH=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo

- name: build libOTe
run: python3 build.py --par=4 -D ENABLE_ALL_OT=ON -DENABLE_CIRCUITS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo
run: python3 build.py --par=4 -D ENABLE_ALL_OT=ON -DENABLE_CIRCUITS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_ASAN=ON -DENABLE_MOCK_OT=true

- name: unit tests
run: ./out/build/linux/frontend/frontend_libOTe -u
Expand Down Expand Up @@ -74,7 +74,7 @@ jobs:
- name: install test
run: |
python3 build.py --setup --relic --bitpolymul --install --sudo -DCMAKE_BUILD_TYPE=RelWithDebInfo
python3 build.py --install --sudo -DCMAKE_BUILD_TYPE=RelWithDebInfo
python3 build.py --install --sudo -DCMAKE_BUILD_TYPE=RelWithDebInfo
cd libOTe_Tests/cmakeTests
cmake -S . -B out/ -DCMAKE_BUILD_TYPE=RelWithDebInfo
Expand Down Expand Up @@ -153,7 +153,7 @@ jobs:
# Runs a set of commands using the runners shell

- name: build libOTe
run: python3 build.py -DENABLE_BOOST=OFF -DVERBOSE_FETCH=ON -DENABLE_SSE=OFF -DENABLE_SODIUM=ON -DSODIUM_MONTGOMERY=OFF -D ENABLE_ALL_OT=ON
run: python3 build.py -DENABLE_BOOST=OFF -DVERBOSE_FETCH=ON -DENABLE_SSE=OFF -ENABLE_MOCK_OT=true -D ENABLE_ALL_OT=ON

- name: unit tests
run: ./out/build/osx/frontend/frontend_libOTe -u
Expand All @@ -179,7 +179,6 @@ jobs:
- name: install prefix test
run: |
python3 build.py --setup --sodium --install=~/install
python3 build.py --install=~/install
cd libOTe_Tests/cmakeTests
cmake -S . -B out/ -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=~/install
Expand All @@ -192,7 +191,6 @@ jobs:
- name: install test
run: |
python3 build.py --setup --sodium --install --sudo
python3 build.py --install --sudo
cd libOTe_Tests/cmakeTests
cmake -S . -B out/ -DCMAKE_BUILD_TYPE=Release
cmake --build out/
Expand All @@ -217,7 +215,7 @@ jobs:

# Runs a set of commands using the runners shell
- name: build libOTe
run: python3 build.py --par=1 -D ENABLE_ALL_OT=ON -DENABLE_RELIC=ON -G Ninja
run: python3 build.py --par=1 -D ENABLE_ALL_OT=ON -ENABLE_MOCK_OT=true -G Ninja


- name: unit test
Expand All @@ -234,8 +232,6 @@ jobs:
- name: hint test
run: |
python3 build.py --setup
python3 build.py
cd libOTe_Tests/cmakeTests
cmake -S . -B out/ -D LIBOTE_HINT=../..
cmake --build out/ --config Release
Expand All @@ -245,7 +241,7 @@ jobs:
- name: install prefix test
run: |
python3 build.py --relic --bitpolymul --install=~/install
python3 build.py --install=~/install
cd libOTe_Tests/cmakeTests
cmake -S . -B out/ -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=~/install
cmake --build out/ --config Release
Expand Down
3 changes: 2 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"ENABLE_GMP": false,
"ENABLE_ALL_OT": true,
"ENABLE_RELIC": false,
"ENABLE_SODIUM": true,
"ENABLE_SODIUM": false,
"ENABLE_BOOST": false,
"ENABLE_OPENSSL": false,
"FETCH_AUTO": true,
Expand All @@ -104,6 +104,7 @@
"VERBOSE_FETCH": true,
"ENABLE_PIC": false,
"ENABLE_ASAN": false,
"ENABLE_MOCK_OT": true,
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}"
},
"vendor": {
Expand Down
6 changes: 6 additions & 0 deletions cmake/buildOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ else()
option(ENABLE_BITPOLYMUL "Build with bit poly mul inegration" TRUE)
endif()

option(ENABLE_MOCK_OT "Build the insecure mock base OT" OFF)

option(ENABLE_SIMPLESTOT "Build the SimplestOT base OT" OFF)
option(ENABLE_SIMPLESTOT_ASM "Build the assembly based SimplestOT library" OFF)
option(ENABLE_MRR "Build the McQuoidRosulekRoy 20 PopfOT base OT using Ristretto KA" OFF)
Expand Down Expand Up @@ -173,6 +175,10 @@ message(STATUS "Option: ENABLE_PPRF = ${ENABLE_PPRF}\n\n")
# Config Checks #
#############################################

if(ENABLE_MOCK_OT)
message("\n\nWarning: the libary is being build with insecure mock base OTs. ENABLE_MOCK_OT=${ENABLE_MOCK_OT}\n\n")
endif()

if(NOT UNIX OR APPLE OR MSVC)
#if(ENABLE_SIMPLESTOT_ASM)
# message(FATAL_ERROR "ENABLE_SIMPLESTOT_ASM only supported on Linux")
Expand Down
3 changes: 3 additions & 0 deletions libOTe/Base/BaseOT.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "McRosRoy.h"
#include "libOTe/Tools/Popf/EKEPopf.h"
#include "libOTe/Tools/Popf/FeistelMulRistPopf.h"
#include "MockOt.h"

namespace osuCrypto
{
Expand All @@ -29,6 +30,8 @@ namespace osuCrypto
using DefaultBaseOT = MasnyRindalKyber;
#elif defined ENABLE_SIMPLESTOT
using DefaultBaseOT = SimplestOT;
#elif defined ENABLE_MOCK_OT
using DefaultBaseOT = INSECURE_MOCK_OT;
#else
#undef LIBOTE_HAS_BASE_OT
#endif
Expand Down
85 changes: 85 additions & 0 deletions libOTe/Base/MockOt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#pragma once
// © 2024 Peter Rindal.
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

#include "libOTe/config.h"
#ifdef ENABLE_MOCK_OT

#include "libOTe/TwoChooseOne/OTExtInterface.h"
#include <cryptoTools/Common/Defines.h>
#include <cryptoTools/Crypto/PRNG.h>
#include <cryptoTools/Common/BitVector.h>
namespace osuCrypto
{

class INSECURE_MOCK_OT : public OtReceiver, public OtSender
{
public:

task<> receive(
const BitVector& choices,
span<block> messages,
PRNG& prng,
Socket& chl,
u64 numThreads)
{
return receive(choices, messages, prng, chl);
}

task<> send(
span<std::array<block, 2>> messages,
PRNG& prng,
Socket& chl,
u64 numThreads)
{
return send(messages, prng, chl);
}

task<> receive(
const BitVector& choices,
span<block> messages,
PRNG& prng,
Socket& chl) override
{
struct Warning
{

~Warning()
{
std::cout << "warning, INSECURE_MOCK_OT was used. The program is insecure." << LOCATION << std::endl;
}
};
static Warning w;

block seed = prng.get();
co_await chl.send(seed);

std::vector<std::array<block, 2>> all(messages.size());

PRNG sPrng(seed);
sPrng.get(all.data(), all.size());

for (u64 i = 0; i < all.size(); ++i)
{
messages[i] = all[i][choices[i]];
}
}

task<> send(
span<std::array<block, 2>> messages,
PRNG& prng,
Socket& chl) override
{
block seed;
co_await chl.recv(seed);
PRNG sPrng(seed);
sPrng.get(messages.data(), messages.size());
}
};

}
#endif
2 changes: 2 additions & 0 deletions libOTe/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
// build the library with Masney Rindal Kyber Base OT enabled
#cmakedefine ENABLE_MR_KYBER @ENABLE_MR_KYBER@

// build the library with mocked Base OT enabled
#cmakedefine ENABLE_MOCK_OT @ENABLE_MOCK_OT@


// build the library with Keller Orse Scholl OT-Ext enabled
Expand Down
2 changes: 1 addition & 1 deletion libOTe_Tests/Vole_Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ void Vole_Silent_Rounds_test(const oc::CLP& cmd)
auto p0 = recv.silentReceive(c, z0, prng, chls[0]);
auto p1 = send.silentSend(x, z1, prng, chls[1]);
#if (defined ENABLE_MRR_TWIST && defined ENABLE_SSE) || \
defined ENABLE_MR || defined ENABLE_MRR
defined ENABLE_MR || defined ENABLE_MRR || defined ENABLE_MOCK_OT
u64 expRound = 3;
#else
u64 expRound = 5;
Expand Down

0 comments on commit 549bf27

Please sign in to comment.