From f4b5ad2da930b081dedc09bd30ac901f4518218f Mon Sep 17 00:00:00 2001 From: Marcel Keller Date: Thu, 4 Apr 2024 12:38:29 +1100 Subject: [PATCH] Random bit generation in Rep4. --- GC/Rep4Prep.cpp | 33 +++++++++++++++++++++++++++++++++ GC/Rep4Prep.h | 28 ++++++++++++++++++++++++++++ GC/Rep4Secret.h | 4 +++- Machines/Rep4.hpp | 1 + Machines/rep4-ring-party.cpp | 1 + Makefile | 7 ++++--- Protocols/Rep4.hpp | 1 + 7 files changed, 71 insertions(+), 4 deletions(-) create mode 100644 GC/Rep4Prep.cpp create mode 100644 GC/Rep4Prep.h diff --git a/GC/Rep4Prep.cpp b/GC/Rep4Prep.cpp new file mode 100644 index 00000000..242be342 --- /dev/null +++ b/GC/Rep4Prep.cpp @@ -0,0 +1,33 @@ +/* + * Rep4Prep.cpp + * + */ + +#include "Rep4Prep.h" + +#include "Protocols/Rep4.hpp" +#include "Protocols/Rep4Input.hpp" +#include "Protocols/ReplicatedPrep.hpp" + +namespace GC +{ + +Rep4Prep::Rep4Prep(DataPositions& usage, int) : + BufferPrep(usage) +{ +} + +void Rep4Prep::set_protocol(Rep4Secret::Protocol& protocol) +{ + this->P = &protocol.P; +} + +void Rep4Prep::buffer_bits() +{ + assert(P); + Rep4 proto(*P); + for (int i = 0; i < OnlineOptions::singleton.batch_size; i++) + this->bits.push_back(proto.get_random() & 1); +} + +} /* namespace GC */ diff --git a/GC/Rep4Prep.h b/GC/Rep4Prep.h new file mode 100644 index 00000000..9d03cb00 --- /dev/null +++ b/GC/Rep4Prep.h @@ -0,0 +1,28 @@ +/* + * Rep4Prep.h + * + */ + +#ifndef GC_REP4PREP_H_ +#define GC_REP4PREP_H_ + +#include "Rep4Secret.h" +#include "PersonalPrep.h" +#include "Protocols/ReplicatedPrep.h" + +namespace GC +{ + +class Rep4Prep : public BufferPrep +{ +public: + Rep4Prep(DataPositions& usage, int _ = -1); + + void set_protocol(Rep4Secret::Protocol& protocol); + + void buffer_bits(); +}; + +} /* namespace GC */ + +#endif /* GC_REP4PREP_H_ */ diff --git a/GC/Rep4Secret.h b/GC/Rep4Secret.h index f464c82c..f81be6bd 100644 --- a/GC/Rep4Secret.h +++ b/GC/Rep4Secret.h @@ -13,13 +13,15 @@ namespace GC { +class Rep4Prep; + class Rep4Secret : public RepSecretBase { typedef RepSecretBase super; typedef Rep4Secret This; public: - typedef DummyLivePrep LivePrep; + typedef Rep4Prep LivePrep; typedef Rep4 Protocol; typedef Rep4MC MC; typedef MC MAC_Check; diff --git a/Machines/Rep4.hpp b/Machines/Rep4.hpp index 83ad1cff..0156433e 100644 --- a/Machines/Rep4.hpp +++ b/Machines/Rep4.hpp @@ -7,6 +7,7 @@ #define MACHINES_REP4_HPP_ #include "GC/Rep4Secret.h" +#include "GC/Rep4Prep.h" #include "Protocols/Rep4Share2k.h" #include "Protocols/Rep4Prep.h" #include "Protocols/Rep4.hpp" diff --git a/Machines/rep4-ring-party.cpp b/Machines/rep4-ring-party.cpp index a224f1ca..51fac657 100644 --- a/Machines/rep4-ring-party.cpp +++ b/Machines/rep4-ring-party.cpp @@ -10,6 +10,7 @@ #include "Math/gf2n.h" #include "Tools/ezOptionParser.h" #include "GC/Rep4Secret.h" +#include "GC/Rep4Prep.h" #include "Processor/RingOptions.h" #include "Processor/RingMachine.hpp" diff --git a/Makefile b/Makefile index 50a63452..9be2d322 100644 --- a/Makefile +++ b/Makefile @@ -247,17 +247,18 @@ mama-party.x: $(TINIER) ps-rep-ring-party.x: Protocols/MalRepRingOptions.o malicious-rep-ring-party.x: Protocols/MalRepRingOptions.o sy-rep-ring-party.x: Protocols/MalRepRingOptions.o -rep4-ring-party.x: GC/Rep4Secret.o +rep4-ring-party.x: GC/Rep4Secret.o GC/Rep4Prep.o no-party.x: Protocols/ShareInterface.o semi-ecdsa-party.x: $(OT) $(LIBSIMPLEOT) $(GC_SEMI) mascot-ecdsa-party.x: $(OT) $(LIBSIMPLEOT) +rep4-ecdsa-party.x: GC/Rep4Prep.o fake-spdz-ecdsa-party.x: $(OT) $(LIBSIMPLEOT) emulate.x: GC/FakeSecret.o semi-bmr-party.x: $(GC_SEMI) $(OT) real-bmr-party.x: $(OT) paper-example.x: $(VM) $(OT) $(FHEOFFLINE) -binary-example.x: $(VM) $(OT) GC/PostSacriBin.o $(GC_SEMI) GC/AtlasSecret.o -mixed-example.x: $(VM) $(OT) GC/PostSacriBin.o $(GC_SEMI) GC/AtlasSecret.o Machines/Tinier.o +binary-example.x: $(VM) $(OT) GC/PostSacriBin.o $(GC_SEMI) GC/AtlasSecret.o GC/Rep4Prep.o +mixed-example.x: $(VM) $(OT) GC/PostSacriBin.o $(GC_SEMI) GC/AtlasSecret.o GC/Rep4Prep.o Machines/Tinier.o l2h-example.x: $(VM) $(OT) Machines/Tinier.o he-example.x: $(FHEOFFLINE) mascot-offline.x: $(VM) $(TINIER) diff --git a/Protocols/Rep4.hpp b/Protocols/Rep4.hpp index 941fabcc..45d42ab4 100644 --- a/Protocols/Rep4.hpp +++ b/Protocols/Rep4.hpp @@ -4,6 +4,7 @@ */ #include "Rep4.h" +#include "GC/square64.h" #include "Processor/TruncPrTuple.h" template