forked from bristolcrypto/SPDZ-2
-
Notifications
You must be signed in to change notification settings - Fork 282
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Semi-honest computation based on somewhat homomorphic encryption.
- Loading branch information
Showing
11 changed files
with
213 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* soho-party.cpp | ||
* | ||
*/ | ||
|
||
#include "Protocols/SohoShare.h" | ||
#include "Math/gfp.h" | ||
#include "Math/gf2n.h" | ||
#include "FHE/P2Data.h" | ||
#include "Tools/ezOptionParser.h" | ||
#include "GC/SemiSecret.h" | ||
#include "GC/SemiPrep.h" | ||
|
||
#include "Player-Online.hpp" | ||
#include "Protocols/HemiPrep.hpp" | ||
#include "Processor/Data_Files.hpp" | ||
#include "Processor/Instruction.hpp" | ||
#include "Processor/Machine.hpp" | ||
#include "Protocols/SohoPrep.hpp" | ||
#include "Protocols/SemiInput.hpp" | ||
#include "Protocols/MAC_Check_Base.hpp" | ||
#include "Protocols/MAC_Check.hpp" | ||
#include "Protocols/fake-stuff.hpp" | ||
#include "Protocols/SemiMC.hpp" | ||
#include "Protocols/Beaver.hpp" | ||
#include "GC/ShareSecret.hpp" | ||
#include "GC/SemiHonestRepPrep.h" | ||
|
||
int main(int argc, const char** argv) | ||
{ | ||
ez::ezOptionParser opt; | ||
spdz_main<SohoShare<gfp>, SohoShare<gf2n_short>>(argc, argv, opt); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* SohoPrep.h | ||
* | ||
*/ | ||
|
||
#ifndef PROTOCOLS_SOHOPREP_H_ | ||
#define PROTOCOLS_SOHOPREP_H_ | ||
|
||
template<class T> | ||
class SohoPrep : public SemiHonestRingPrep<T> | ||
{ | ||
typedef typename T::clear::FD FD; | ||
|
||
static PartSetup<FD>* setup; | ||
static Lock lock; | ||
|
||
public: | ||
static void basic_setup(Player& P); | ||
static void teardown(); | ||
|
||
SohoPrep(SubProcessor<T>* proc, DataPositions& usage) : | ||
BufferPrep<T>(usage), | ||
RingPrep<T>(proc, usage), SemiHonestRingPrep<T>(proc, usage) | ||
{ | ||
} | ||
|
||
void buffer_triples(); | ||
void buffer_inverses(); | ||
}; | ||
|
||
#endif /* PROTOCOLS_SOHOPREP_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* SohoPrep.cpp | ||
* | ||
*/ | ||
|
||
#include "SohoPrep.h" | ||
#include "FHEOffline/DataSetup.h" | ||
|
||
template<class T> | ||
PartSetup<typename SohoPrep<T>::FD>* SohoPrep<T>::setup = 0; | ||
|
||
template<class T> | ||
Lock SohoPrep<T>::lock; | ||
|
||
template<class T> | ||
void SohoPrep<T>::basic_setup(Player& P) | ||
{ | ||
assert(not setup); | ||
setup = new PartSetup<FD>; | ||
MachineBase machine; | ||
setup->secure_init(P, machine, T::clear::length(), 0); | ||
setup->covert_secrets_generation(P, machine, 1); | ||
} | ||
|
||
template<class T> | ||
void SohoPrep<T>::teardown() | ||
{ | ||
if (setup) | ||
delete setup; | ||
} | ||
|
||
template<class T> | ||
void SohoPrep<T>::buffer_triples() | ||
{ | ||
auto& proc = this->proc; | ||
assert(proc != 0); | ||
lock.lock(); | ||
if (not setup) | ||
{ | ||
PlainPlayer P(proc->P.N, T::clear::type_char()); | ||
basic_setup(P); | ||
} | ||
lock.unlock(); | ||
|
||
Plaintext_<FD> ai(setup->FieldD), bi(setup->FieldD); | ||
SeededPRNG G; | ||
ai.randomize(G); | ||
bi.randomize(G); | ||
Ciphertext Ca = setup->pk.encrypt(ai); | ||
Ciphertext Cb = setup->pk.encrypt(bi); | ||
octetStream os; | ||
Ca.pack(os); | ||
Cb.pack(os); | ||
|
||
for (int i = 1; i < proc->P.num_players(); i++) | ||
{ | ||
proc->P.pass_around(os); | ||
Ca.add<0>(os); | ||
Cb.add<0>(os); | ||
} | ||
|
||
Ciphertext Cc = Ca.mul(setup->pk, Cb); | ||
Plaintext_<FD> ci(setup->FieldD); | ||
SimpleDistDecrypt<FD> dd(proc->P, *setup); | ||
EncCommitBase_<FD> EC; | ||
dd.reshare(ci, Cc, EC); | ||
|
||
for (unsigned i = 0; i < ai.num_slots(); i++) | ||
this->triples.push_back({{ai.element(i), bi.element(i), | ||
ci.element(i)}}); | ||
} | ||
|
||
template<class T> | ||
void SohoPrep<T>::buffer_inverses() | ||
{ | ||
assert(this->proc != 0); | ||
::buffer_inverses(this->inverses, *this, this->proc->MC, this->proc->P); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* SohoShare.h | ||
* | ||
*/ | ||
|
||
#ifndef PROTOCOLS_SOHOSHARE_H_ | ||
#define PROTOCOLS_SOHOSHARE_H_ | ||
|
||
#include "SemiShare.h" | ||
|
||
template<class T> class SohoPrep; | ||
|
||
template<class T> | ||
class SohoShare : public SemiShare<T> | ||
{ | ||
typedef SohoShare This; | ||
typedef SemiShare<T> super; | ||
|
||
public: | ||
typedef SemiMC<This> MAC_Check; | ||
typedef DirectSemiMC<This> Direct_MC; | ||
typedef SemiInput<This> Input; | ||
typedef ::PrivateOutput<This> PrivateOutput; | ||
typedef SPDZ<This> Protocol; | ||
typedef SohoPrep<This> LivePrep; | ||
|
||
static const bool needs_ot = false; | ||
|
||
SohoShare() | ||
{ | ||
} | ||
|
||
template<class U> | ||
SohoShare(const U& other) : | ||
super(other) | ||
{ | ||
} | ||
}; | ||
|
||
#endif /* PROTOCOLS_SOHOSHARE_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
HERE=$(cd `dirname $0`; pwd) | ||
SPDZROOT=$HERE/.. | ||
|
||
. $HERE/run-common.sh | ||
|
||
run_player soho-party.x $* || exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters