mirror of
https://github.com/data61/MP-SPDZ.git
synced 2026-01-09 13:37:58 -05:00
Fake preprocessing for any threshold with Shamir secret sharing.
This commit is contained in:
@@ -17,8 +17,10 @@ public:
|
||||
int nparties;
|
||||
int threshold;
|
||||
|
||||
ShamirOptions();
|
||||
ShamirOptions(int nparties = 3, int threshold = 1);
|
||||
ShamirOptions(ez::ezOptionParser& opt, int argc, const char** argv);
|
||||
|
||||
void set_threshold(ez::ezOptionParser& opt);
|
||||
};
|
||||
|
||||
class ShamirMachine : public ShamirOptions
|
||||
|
||||
@@ -39,8 +39,8 @@ ShamirOptions& ShamirOptions::s()
|
||||
return singleton;
|
||||
}
|
||||
|
||||
ShamirOptions::ShamirOptions() :
|
||||
nparties(3), threshold(1)
|
||||
ShamirOptions::ShamirOptions(int nparties, int threshold) :
|
||||
nparties(nparties), threshold(threshold)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -66,6 +66,12 @@ ShamirOptions::ShamirOptions(ez::ezOptionParser& opt, int argc, const char** arg
|
||||
);
|
||||
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
|
||||
@@ -80,7 +86,6 @@ ShamirOptions::ShamirOptions(ez::ezOptionParser& opt, int argc, const char** arg
|
||||
cerr << "Threshold has to be positive" << endl;
|
||||
exit(1);
|
||||
}
|
||||
opt.resetArgs();
|
||||
}
|
||||
|
||||
template<template<class U> class T>
|
||||
|
||||
@@ -50,7 +50,11 @@ public:
|
||||
|
||||
static string type_short()
|
||||
{
|
||||
return "S" + string(1, clear::type_char());
|
||||
auto res = "S" + string(1, clear::type_char());
|
||||
auto opts = ShamirOptions::singleton;
|
||||
if (opts.threshold != (opts.nparties - 1) / 2)
|
||||
res += "T" + to_string(opts.threshold);
|
||||
return res;
|
||||
}
|
||||
static string type_string()
|
||||
{
|
||||
|
||||
@@ -187,7 +187,7 @@ void make_share(ShamirShare<T>* Sa, const V& a, int N,
|
||||
{
|
||||
auto& share = Sa[i];
|
||||
share = a;
|
||||
for (int j = 0; j < (N - 1) / 2; j++)
|
||||
for (int j = 0; j < ShamirOptions::singleton.threshold; j++)
|
||||
share += vandermonde[i][j] * randomness[j];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "Math/Z2k.hpp"
|
||||
#include "Math/gfp.hpp"
|
||||
#include "GC/Secret.hpp"
|
||||
#include "Machines/ShamirMachine.hpp"
|
||||
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
@@ -615,6 +616,16 @@ int main(int argc, const char** argv)
|
||||
"-s", // Flag token.
|
||||
"--special" // Flag token.
|
||||
);
|
||||
opt.add(
|
||||
"", // Default.
|
||||
0, // Required?
|
||||
1, // Number of args expected.
|
||||
0, // Delimiter if expecting multiple args.
|
||||
"Number of corrupted parties for Shamir secret sharing "
|
||||
"(default: just below half)", // Help description.
|
||||
"-T", // Flag token.
|
||||
"--threshold" // Flag token.
|
||||
);
|
||||
opt.parse(argc, argv);
|
||||
|
||||
int lgp;
|
||||
@@ -680,6 +691,12 @@ int FakeParams::generate()
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (nplayers > 2)
|
||||
{
|
||||
ShamirOptions::singleton.nparties = nplayers;
|
||||
ShamirOptions::singleton.set_threshold(opt);
|
||||
}
|
||||
|
||||
int ntrip2=0, ntripp=0, nbits2=0,nbitsp=0,nsqr2=0,nsqrp=0,ninp2=0,ninpp=0,ninv=0, nbittrip=0, nbitgf2ntrip=0;
|
||||
vector<int> list_options;
|
||||
int lg2, lgp;
|
||||
|
||||
Reference in New Issue
Block a user