forked from data61/MP-SPDZ
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ShamirMachine.hpp
101 lines (92 loc) · 2.74 KB
/
ShamirMachine.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* ShamirMachine.cpp
*
*/
#include <Machines/ShamirMachine.h>
#include "Protocols/ShamirShare.h"
#include "Protocols/MaliciousShamirShare.h"
#include "Math/gfp.h"
#include "Math/gf2n.h"
#include "GC/VectorProtocol.h"
#include "GC/CcdPrep.h"
#include "GC/TinyMC.h"
#include "GC/MaliciousCcdSecret.h"
#include "GC/VectorInput.h"
#include "Processor/FieldMachine.hpp"
#include "Processor/Data_Files.hpp"
#include "Processor/Instruction.hpp"
#include "Processor/Machine.hpp"
#include "Protocols/ShamirInput.hpp"
#include "Protocols/Shamir.hpp"
#include "Protocols/ShamirMC.hpp"
#include "Protocols/MaliciousShamirMC.hpp"
#include "Protocols/MaliciousShamirPO.hpp"
#include "Protocols/MAC_Check_Base.hpp"
#include "Protocols/Beaver.hpp"
#include "Protocols/Spdz2kPrep.hpp"
#include "Protocols/ReplicatedPrep.hpp"
#include "Protocols/MalRepRingPrep.hpp"
#include "GC/ShareSecret.hpp"
#include "GC/VectorProtocol.hpp"
#include "GC/Secret.hpp"
#include "GC/CcdPrep.hpp"
#include "Math/gfp.hpp"
ShamirOptions ShamirOptions::singleton;
ShamirOptions& ShamirOptions::s()
{
return singleton;
}
ShamirOptions::ShamirOptions(int nparties, int threshold) :
nparties(nparties), threshold(threshold)
{
}
ShamirOptions::ShamirOptions(ez::ezOptionParser& opt, int argc, const char** argv)
{
opt.add(
"3", // Default.
0, // Required?
1, // Number of args expected.
0, // Delimiter if expecting multiple args.
"Number of players", // Help description.
"-N", // Flag token.
"--nparties" // Flag token.
);
opt.add(
"", // Default.
0, // Required?
1, // Number of args expected.
0, // Delimiter if expecting multiple args.
"Number of corrupted parties (default: just below half)", // Help description.
"-T", // Flag token.
"--threshold" // Flag token.
);
opt.parse(argc, argv);
opt.get("-N")->getInt(nparties);
set_threshold(opt);
opt.resetArgs();
}
void ShamirOptions::set_threshold(ez::ezOptionParser& opt)
{
if (opt.isSet("-T"))
opt.get("-T")->getInt(threshold);
else
threshold = (nparties - 1) / 2;
#ifdef VERBOSE
cerr << "Using threshold " << threshold << " out of " << nparties << endl;
#endif
if (2 * threshold >= nparties)
throw runtime_error("threshold too high");
if (threshold < 1)
{
cerr << "Threshold has to be positive" << endl;
exit(1);
}
}
template<template<class U> class T>
ShamirMachineSpec<T>::ShamirMachineSpec(int argc, const char** argv)
{
auto& opts = ShamirOptions::singleton;
ez::ezOptionParser opt;
opts = {opt, argc, argv};
HonestMajorityFieldMachine<T>(argc, argv, opt, opts.nparties);
}