Required preprocessing for semi-honest protocols.

This commit is contained in:
Marcel Keller
2023-03-15 12:46:07 +11:00
parent f3d5cc4241
commit 1a73c741c0
10 changed files with 76 additions and 5 deletions

View File

@@ -12,6 +12,7 @@
#include "ShiftableTripleBuffer.h"
template<class T> class Beaver;
template<class T> class SubProcessor;
namespace GC
{
@@ -29,6 +30,7 @@ class SemiPrep : public BufferPrep<SemiSecret>, ShiftableTripleBuffer<SemiSecret
public:
SemiPrep(DataPositions& usage, bool = true);
SemiPrep(void*, DataPositions& usage) : SemiPrep(usage) {}
~SemiPrep();
void set_protocol(SemiSecret::Protocol& protocol);

19
Machines/hemi-offline.cpp Normal file
View File

@@ -0,0 +1,19 @@
#include "GC/TinierSecret.h"
#include "GC/Semi.h"
#include "GC/SemiPrep.h"
#include "Protocols/HemiShare.h"
#include "Semi.hpp"
#include "Math/gfp.hpp"
#include "Processor/FieldMachine.hpp"
#include "Processor/OfflineMachine.hpp"
#include "Protocols/MascotPrep.hpp"
#include "Protocols/HemiPrep.hpp"
int main(int argc, const char** argv)
{
ez::ezOptionParser opt;
DishonestMajorityFieldMachine<HemiShare, HemiShare, gf2n_short,
OfflineMachine<DishonestMajorityMachine>>(argc, argv, opt);
}

17
Machines/semi-offline.cpp Normal file
View File

@@ -0,0 +1,17 @@
#include "GC/TinierSecret.h"
#include "GC/Semi.h"
#include "GC/SemiPrep.h"
#include "Semi.hpp"
#include "Math/gfp.hpp"
#include "Processor/FieldMachine.hpp"
#include "Processor/OfflineMachine.hpp"
#include "Protocols/MascotPrep.hpp"
int main(int argc, const char** argv)
{
ez::ezOptionParser opt;
DishonestMajorityFieldMachine<SemiShare, SemiShare, gf2n,
OfflineMachine<DishonestMajorityMachine>>(argc, argv, opt);
}

View File

@@ -0,0 +1,21 @@
#include "GC/TinierSecret.h"
#include "GC/Semi.h"
#include "GC/SemiPrep.h"
#include "Protocols/Semi2kShare.h"
#include "Protocols/SemiPrep2k.h"
#include "Math/gf2n.h"
#include "Semi.hpp"
#include "Math/gfp.hpp"
#include "Processor/RingMachine.hpp"
#include "Processor/OfflineMachine.hpp"
#include "Protocols/MascotPrep.hpp"
#include "Protocols/RepRingOnlyEdabitPrep.hpp"
int main(int argc, const char** argv)
{
ez::ezOptionParser opt;
DishonestMajorityRingMachine<Semi2kShare, SemiShare,
OfflineMachine<DishonestMajorityMachine>>(argc, argv, opt);
}

View File

@@ -261,6 +261,9 @@ l2h-example.x: $(VM) $(OT) Machines/Tinier.o
he-example.x: $(FHEOFFLINE)
mascot-offline.x: $(VM) $(TINIER)
cowgear-offline.x: $(TINIER) $(FHEOFFLINE)
semi-offline.x: $(GC_SEMI) $(OT)
semi2k-offline.x: $(GC_SEMI) $(OT)
hemi-offline.x: $(GC_SEMI) $(FHEOFFLINE) $(OT)
static/rep-bmr-party.x: $(BMR)
static/mal-rep-bmr-party.x: $(BMR)
static/shamir-bmr-party.x: $(BMR)

View File

@@ -160,6 +160,12 @@ string BaseMachine::memory_filename(const string& type_short, int my_number)
string BaseMachine::get_domain(string progname)
{
if (singleton)
{
assert(s().progname == progname);
return s().domain;
}
assert(not singleton);
BaseMachine machine;
singleton = 0;

View File

@@ -166,7 +166,9 @@ void OfflineMachine<W>::generate()
{
ofstream out(filename, ios::binary);
file_signature<T>().output(out);
for (int i = 0; i < buffered_total(total, batch); i++)
auto& opts = OnlineOptions::singleton;
opts.batch_size = DIV_CEIL(opts.batch_size, batch) * batch;
for (int i = 0; i < buffered_total(total, batch) / batch; i++)
preprocessing.template get_edabitvec<0>(true, n_bits).output(n_bits,
out);
}

View File

@@ -39,7 +39,8 @@ public:
ez::ezOptionParser& opt);
};
template<template<int K> class T, template<class V> class U>
template<template<int K> class T, template<class V> class U,
class W = DishonestMajorityMachine>
class DishonestMajorityRingMachine
{
public:
@@ -49,7 +50,7 @@ public:
OnlineOptions& online_opts = OnlineOptions::singleton;
online_opts = {opt, argc, argv, T<64>(), live_prep_default};
RingMachine<T, U, DishonestMajorityMachine>(argc, argv, opt, online_opts);
RingMachine<T, U, W>(argc, argv, opt, online_opts);
}
};

View File

@@ -42,7 +42,7 @@ RingMachine<U, V, W>::RingMachine(int argc, const char** argv,
ez::ezOptionParser& opt, OnlineOptions& online_opts, int nplayers)
{
RingOptions opts(opt, argc, argv);
W machine(argc, argv, opt, online_opts, nplayers);
W machine(argc, argv, opt, online_opts, gf2n(), nplayers);
int R = opts.ring_size_from_opts_or_schedule(online_opts.progname);
switch (R)
{

View File

@@ -1088,7 +1088,7 @@ the actual computation. First, compile the binary:
`make <protocol>-offline.x`
At the time of writing the supported protocols are `mascot`,
`cowgear`, and `mal-shamir`.
`cowgear`, mal-shamir`, `semi`, `semi2k`, and `hemi`.
If you have not done so already, then compile your high-level program: