forked from bristolcrypto/SPDZ-2
-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More honest-majority three-party computation (modulo prime and malici…
…ous binary).
- Loading branch information
Showing
160 changed files
with
3,763 additions
and
1,657 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ tags | |
.project | ||
.cproject | ||
.settings | ||
.pydevproject | ||
|
||
# VS Code IDE # | ||
############### | ||
|
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[submodule "SimpleOT"] | ||
path = SimpleOT | ||
url = https://github.com/pascholl/SimpleOT | ||
url = https://github.com/mkskeller/SimpleOT | ||
[submodule "mpir"] | ||
path = mpir | ||
url = git://github.com/wbhart/mpir.git |
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,66 @@ | ||
/* | ||
* MaliciousRepMC.h | ||
* | ||
*/ | ||
|
||
#ifndef AUTH_MALICIOUSREPMC_H_ | ||
#define AUTH_MALICIOUSREPMC_H_ | ||
|
||
#include "ReplicatedMC.h" | ||
#include "GC/MaliciousRepSecret.h" | ||
#include "GC/Machine.h" | ||
|
||
template<class T> | ||
class MaliciousRepMC : public ReplicatedMC<T> | ||
{ | ||
protected: | ||
typedef ReplicatedMC<T> super; | ||
|
||
public: | ||
virtual void POpen_Begin(vector<typename T::clear>& values, | ||
const vector<T>& S, const Player& P); | ||
virtual void POpen_End(vector<typename T::clear>& values, | ||
const vector<T>& S, const Player& P); | ||
|
||
virtual void Check(const Player& P); | ||
}; | ||
|
||
template<class T> | ||
class HashMaliciousRepMC : public MaliciousRepMC<T> | ||
{ | ||
crypto_generichash_state* hash_state; | ||
|
||
octetStream os; | ||
|
||
public: | ||
// emulate MAC_Check | ||
HashMaliciousRepMC(const typename T::value_type& _, int __ = 0, int ___ = 0) : HashMaliciousRepMC() | ||
{ (void)_; (void)__; (void)___; } | ||
|
||
// emulate Direct_MAC_Check | ||
HashMaliciousRepMC(const typename T::value_type& _, Names& ____, int __ = 0, int ___ = 0) : HashMaliciousRepMC() | ||
{ (void)_; (void)__; (void)___; (void)____; } | ||
|
||
HashMaliciousRepMC(); | ||
~HashMaliciousRepMC(); | ||
|
||
void POpen_End(vector<typename T::clear>& values,const vector<T>& S,const Player& P); | ||
|
||
void Check(const Player& P); | ||
}; | ||
|
||
template<class T> | ||
class CommMaliciousRepMC : public MaliciousRepMC<T> | ||
{ | ||
vector<octetStream> os; | ||
|
||
public: | ||
void POpen_Begin(vector<typename T::clear>& values, const vector<T>& S, | ||
const Player& P); | ||
void POpen_End(vector<typename T::clear>& values, const vector<T>& S, | ||
const Player& P); | ||
|
||
void Check(const Player& P); | ||
}; | ||
|
||
#endif /* AUTH_MALICIOUSREPMC_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,107 @@ | ||
/* | ||
* MaliciousRepMC.cpp | ||
* | ||
*/ | ||
|
||
#include "MaliciousRepMC.h" | ||
#include "GC/Machine.h" | ||
|
||
#include "ReplicatedMC.hpp" | ||
|
||
#include <stdlib.h> | ||
|
||
template<class T> | ||
void MaliciousRepMC<T>::POpen_Begin(vector<typename T::clear>& values, | ||
const vector<T>& S, const Player& P) | ||
{ | ||
super::POpen_Begin(values, S, P); | ||
} | ||
|
||
template<class T> | ||
void MaliciousRepMC<T>::POpen_End(vector<typename T::clear>& values, | ||
const vector<T>& S, const Player& P) | ||
{ | ||
(void)values, (void)S, (void)P; | ||
throw runtime_error("use subclass"); | ||
} | ||
|
||
template<class T> | ||
void MaliciousRepMC<T>::Check(const Player& P) | ||
{ | ||
(void)P; | ||
throw runtime_error("use subclass"); | ||
} | ||
|
||
template<class T> | ||
HashMaliciousRepMC<T>::HashMaliciousRepMC() | ||
{ | ||
// deal with alignment issues | ||
int error = posix_memalign((void**)&hash_state, 64, sizeof(crypto_generichash_state)); | ||
if (error) | ||
throw runtime_error(string("failed to allocate hash state: ") + strerror(error)); | ||
crypto_generichash_init(hash_state, 0, 0, crypto_generichash_BYTES); | ||
} | ||
|
||
template<class T> | ||
HashMaliciousRepMC<T>::~HashMaliciousRepMC() | ||
{ | ||
free(hash_state); | ||
} | ||
|
||
template<class T> | ||
void HashMaliciousRepMC<T>::POpen_End(vector<typename T::clear>& values, | ||
const vector<T>& S, const Player& P) | ||
{ | ||
ReplicatedMC<T>::POpen_End(values, S, P); | ||
os.reset_write_head(); | ||
for (auto& value : values) | ||
value.pack(os); | ||
crypto_generichash_update(hash_state, os.get_data(), os.get_length()); | ||
} | ||
|
||
template<class T> | ||
void HashMaliciousRepMC<T>::Check(const Player& P) | ||
{ | ||
unsigned char hash[crypto_generichash_BYTES]; | ||
crypto_generichash_final(hash_state, hash, sizeof hash); | ||
crypto_generichash_init(hash_state, 0, 0, crypto_generichash_BYTES); | ||
vector<octetStream> os(P.num_players()); | ||
os[P.my_num()].serialize(hash); | ||
P.Broadcast_Receive(os); | ||
for (int i = 0; i < P.num_players(); i++) | ||
if (os[i] != os[P.my_num()]) | ||
throw mac_fail(); | ||
} | ||
|
||
template<class T> | ||
void CommMaliciousRepMC<T>::POpen_Begin(vector<typename T::clear>& values, | ||
const vector<T>& S, const Player& P) | ||
{ | ||
assert(T::length == 2); | ||
(void)values; | ||
os.resize(2); | ||
for (auto& o : os) | ||
o.reset_write_head(); | ||
for (auto& x : S) | ||
for (int i = 0; i < 2; i++) | ||
x[i].pack(os[1 - i]); | ||
P.send_relative(os); | ||
} | ||
|
||
template<class T> | ||
void CommMaliciousRepMC<T>::POpen_End(vector<typename T::clear>& values, | ||
const vector<T>& S, const Player& P) | ||
{ | ||
P.receive_relative(os); | ||
if (os[0] != os[1]) | ||
throw mac_fail(); | ||
values.clear(); | ||
for (auto& x : S) | ||
values.push_back(os[0].template get<BitVec>() + x.sum()); | ||
} | ||
|
||
template<class T> | ||
void CommMaliciousRepMC<T>::Check(const Player& P) | ||
{ | ||
(void)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
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
Oops, something went wrong.