mirror of
https://github.com/privacy-scaling-explorations/emp-wasm.git
synced 2026-01-10 18:47:53 -05:00
remove trailing whitespace
This commit is contained in:
@@ -14,7 +14,7 @@ int main(int argc, char** argv) {
|
||||
NetIOMP<nP> io(party, port);
|
||||
NetIOMP<nP> io2(party, port+2*(nP+1)*(nP+1)+1);
|
||||
NetIOMP<nP> *ios[2] = {&io, &io2};
|
||||
ThreadPool pool(4);
|
||||
ThreadPool pool(4);
|
||||
BristolFormat cf(circuit_file_location.c_str());
|
||||
|
||||
CMPC<nP>* mpc = new CMPC<nP>(ios, &pool, party, &cf);
|
||||
|
||||
@@ -65,7 +65,7 @@ class ABitMP { public:
|
||||
|
||||
if(party == 1)
|
||||
Delta = abit1[2]->Delta;
|
||||
else
|
||||
else
|
||||
Delta = abit1[1]->Delta;
|
||||
}
|
||||
~ABitMP() {
|
||||
@@ -130,7 +130,7 @@ class ABitMP { public:
|
||||
tMs[i] = new block[ssp];
|
||||
tbs[i] = new bool[ssp];
|
||||
}
|
||||
|
||||
|
||||
const int chk = 1;
|
||||
const int SIZE = 1024*2;
|
||||
block (* tMAC)[4] = new block[SIZE/chk][4];
|
||||
@@ -168,7 +168,7 @@ class ABitMP { public:
|
||||
}
|
||||
delete[] tmp;
|
||||
vector<future<bool>> res;
|
||||
//TODO: they should not need to send MACs.
|
||||
//TODO: they should not need to send MACs.
|
||||
for(int i = 1; i <= nP; ++i) for(int j = 1; j<= nP; ++j) if( (i < j) and (i == party or j == party) ) {
|
||||
int party2 = i + j - party;
|
||||
res.push_back(pool->enqueue([this, Ms, bs, party2]()->bool {
|
||||
@@ -214,13 +214,13 @@ class ABitMP { public:
|
||||
char (*dgst)[Hash::DIGEST_SIZE] = new char[nP+1][Hash::DIGEST_SIZE];
|
||||
char (*dgst0)[Hash::DIGEST_SIZE] = new char[ssp*(nP+1)][Hash::DIGEST_SIZE];
|
||||
char (*dgst1)[Hash::DIGEST_SIZE] = new char[ssp*(nP+1)][Hash::DIGEST_SIZE];
|
||||
|
||||
|
||||
|
||||
|
||||
for(int i = 0; i < ssp; ++i) {
|
||||
Ks[0][i] = zero_block;
|
||||
for(int j = 1; j <= nP; ++j) if(j != party)
|
||||
Ks[0][i] = Ks[0][i] ^ KEY[j][length-3*ssp+i];
|
||||
|
||||
|
||||
Ks[1][i] = Ks[0][i] ^ Delta;
|
||||
Hash::hash_once(dgst0[party*ssp+i], &Ks[0][i], sizeof(block));
|
||||
Hash::hash_once(dgst1[party*ssp+i], &Ks[1][i], sizeof(block));
|
||||
@@ -308,7 +308,7 @@ class ABitMP { public:
|
||||
}));
|
||||
}
|
||||
if(joinNcleanCheat(res2)) error("commitments 2\n");
|
||||
|
||||
|
||||
bool cheat = false;
|
||||
block *tmp_block = new block[ssp];
|
||||
for(int i = 1; i <= nP; ++i) if (i != party) {
|
||||
|
||||
@@ -257,9 +257,9 @@ public:
|
||||
}
|
||||
authenticated_bitshares_new_circuit.emplace_back(new_entry);
|
||||
}
|
||||
|
||||
|
||||
//print_block(Delta);
|
||||
|
||||
|
||||
/*
|
||||
cout << "Debug the authenticated input" << endl;
|
||||
for(int i = 0; i < 10; i++){
|
||||
@@ -596,7 +596,7 @@ public:
|
||||
assert(party_assignment[pos] == party || party_assignment[pos] == 0);
|
||||
return plaintext_results[pos];
|
||||
}
|
||||
|
||||
|
||||
AuthBitShare<nP> get_authenticated_bitshare(int pos) {
|
||||
assert(party_assignment[pos] == -1);
|
||||
return authenticated_share_results[pos];
|
||||
@@ -779,9 +779,9 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//print_block(Delta);
|
||||
|
||||
|
||||
/*
|
||||
cout << "Debug the authenticated output" << endl;
|
||||
for(int i = 0; i < 10; i++){
|
||||
|
||||
@@ -98,7 +98,7 @@ class FpreMP { public:
|
||||
joinNclean(res);
|
||||
for(int k = 0; k < length*bucket_size; ++k) {
|
||||
s[0][k] = (tr[3*k] and tr[3*k+1]);
|
||||
for(int i = 1; i <= nP; ++i)
|
||||
for(int i = 1; i <= nP; ++i)
|
||||
if (i != party) {
|
||||
s[0][k] = (s[0][k] != s[i][k]);
|
||||
}
|
||||
@@ -128,7 +128,7 @@ class FpreMP { public:
|
||||
joinNclean(res);
|
||||
#ifdef __debug
|
||||
check_MAC(io, tMAC, tKEY, tr, Delta, length*bucket_size*3, party);
|
||||
#endif
|
||||
#endif
|
||||
auto ret = abit->check(tMAC, tKEY, tr, length*bucket_size*3 + 3*ssp);
|
||||
ret.get();
|
||||
//check compute phi
|
||||
@@ -227,8 +227,8 @@ class FpreMP { public:
|
||||
xorBlocks_arr(X[1], X[1], X[i], ssp);
|
||||
for(int i = 0; i < ssp; ++i)X[2][i] = zero_block;
|
||||
if(!cmpBlock(X[1], X[2], ssp)) error("AND check");
|
||||
|
||||
//land -> and
|
||||
|
||||
//land -> and
|
||||
block S = sampleRandom<nP>(io, &prg, pool, party);
|
||||
|
||||
int * ind = new int[length*bucket_size];
|
||||
@@ -248,7 +248,7 @@ class FpreMP { public:
|
||||
location[index] = tmp;
|
||||
}
|
||||
delete[] ind;
|
||||
|
||||
|
||||
for(int i = 0; i < length; ++i) {
|
||||
for(int j = 0; j < bucket_size-1; ++j)
|
||||
d[party][(bucket_size-1)*i+j] = tr[3*location[i*bucket_size]+1] != tr[3*location[i*bucket_size+1+j]+1];
|
||||
@@ -284,9 +284,9 @@ class FpreMP { public:
|
||||
for(int i = 2; i <= nP; ++i)
|
||||
for(int j = 0; j < (bucket_size-1)*length; ++j)
|
||||
d[1][j] = d[1][j]!=d[i][j];
|
||||
|
||||
|
||||
for(int i = 0; i < length; ++i) {
|
||||
for(int j = 1; j <= nP; ++j)if (j!= party) {
|
||||
for(int j = 1; j <= nP; ++j)if (j!= party) {
|
||||
for(int k = 1; k < bucket_size; ++k)
|
||||
if(d[1][(bucket_size-1)*i+k-1]) {
|
||||
MAC[j][3*i+2] = MAC[j][3*i+2] ^ tMAC[j][3*location[i*bucket_size+k]];
|
||||
@@ -298,12 +298,12 @@ class FpreMP { public:
|
||||
r[3*i+2] = r[3*i+2] != tr[3*location[i*bucket_size+k]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef __debug
|
||||
check_MAC(io, MAC, KEY, r, Delta, length*3, party);
|
||||
check_correctness(io, r, length, party);
|
||||
#endif
|
||||
|
||||
|
||||
// ret.get();
|
||||
delete[] tr;
|
||||
delete[] phi;
|
||||
@@ -360,7 +360,7 @@ class FpreMP { public:
|
||||
uint8_t res = LSB(bH);
|
||||
tmp >>= (r[3*i+1]*2+r[3*i]);
|
||||
return (tmp&0x1) != (res&0x1);
|
||||
}
|
||||
}
|
||||
|
||||
void check_MAC_phi(block * MAC[nP+1], block * KEY[nP+1], block * phi, bool * r, int length) {
|
||||
block * tmp = new block[length];
|
||||
@@ -383,7 +383,7 @@ class FpreMP { public:
|
||||
delete[] tmp;
|
||||
delete[] tD;
|
||||
if(party == 1)
|
||||
cerr<<"check_MAC_phi pass!\n"<<flush;
|
||||
cerr<<"check_MAC_phi pass!\n"<<flush;
|
||||
}
|
||||
|
||||
|
||||
@@ -400,7 +400,7 @@ class FpreMP { public:
|
||||
for(int i = 0; i < l; ++i)
|
||||
if(!cmpBlock(&z, &tmp1[i], 1))
|
||||
error("check sum zero failed!");
|
||||
cerr<<"check zero sum pass!\n"<<flush;
|
||||
cerr<<"check zero sum pass!\n"<<flush;
|
||||
delete[] tmp1;
|
||||
delete[] tmp2;
|
||||
} else {
|
||||
|
||||
@@ -16,7 +16,7 @@ const static block inProdTableBlock[] = {zero_block, all_one_block};
|
||||
|
||||
block inProd(bool * b, block * blk, int length) {
|
||||
block res = zero_block;
|
||||
for(int i = 0; i < length; ++i)
|
||||
for(int i = 0; i < length; ++i)
|
||||
// if(b[i])
|
||||
// res = res ^ blk[i];
|
||||
res = res ^ (inProdTableBlock[b[i]] & blk[i]);
|
||||
@@ -147,7 +147,7 @@ void check_MAC(NetIOMP<nP> * io, block * MAC[nP+1], block * KEY[nP+1], bool * r,
|
||||
}
|
||||
delete[] tmp;
|
||||
if(party == 1)
|
||||
cerr<<"check_MAC pass!\n"<<flush;
|
||||
cerr<<"check_MAC pass!\n"<<flush;
|
||||
}
|
||||
|
||||
template<int nP>
|
||||
@@ -167,7 +167,7 @@ void check_correctness(NetIOMP<nP>* io, bool * r, int length, int party) {
|
||||
}
|
||||
delete[] tmp1;
|
||||
delete[] tmp2;
|
||||
cerr<<"check_correctness pass!\n"<<flush;
|
||||
cerr<<"check_correctness pass!\n"<<flush;
|
||||
} else {
|
||||
io->send_data(1, r, length*3);
|
||||
io->flush(1);
|
||||
|
||||
@@ -35,7 +35,7 @@ class CMPC { public:
|
||||
int party, total_pre, ssp;
|
||||
ThreadPool * pool;
|
||||
block Delta;
|
||||
|
||||
|
||||
block (*GTM)[4][nP+1];
|
||||
block (*GTK)[4][nP+1];
|
||||
bool (*GTv)[4];
|
||||
@@ -180,7 +180,7 @@ class CMPC { public:
|
||||
for(int i = 0; i < cf->num_gate; ++i) {
|
||||
if (cf->gates[4*i+3] == AND_GATE) {
|
||||
x[party][ands] = value[cf->gates[4*i]] != ANDS_value[3*ands];
|
||||
y[party][ands] = value[cf->gates[4*i+1]] != ANDS_value[3*ands+1];
|
||||
y[party][ands] = value[cf->gates[4*i+1]] != ANDS_value[3*ands+1];
|
||||
ands++;
|
||||
}
|
||||
}
|
||||
@@ -252,7 +252,7 @@ class CMPC { public:
|
||||
block H[4][nP+1];
|
||||
block K[4][nP+1], M[4][nP+1];
|
||||
bool r[4];
|
||||
if(party != 1) {
|
||||
if(party != 1) {
|
||||
for(int i = 0; i < cf->num_gate; ++i) if(cf->gates[4*i+3] == AND_GATE) {
|
||||
r[0] = sigma_value[ands] != value[cf->gates[4*i+2]];
|
||||
r[1] = r[0] != value[cf->gates[4*i]];
|
||||
@@ -279,7 +279,7 @@ class CMPC { public:
|
||||
H[j][party] = H[j][party] ^ K[j][k];
|
||||
}
|
||||
H[j][party] = H[j][party] ^ labels[cf->gates[4*i+2]];
|
||||
if(r[j])
|
||||
if(r[j])
|
||||
H[j][party] = H[j][party] ^ Delta;
|
||||
}
|
||||
for(int j = 0; j < 4; ++j)
|
||||
@@ -359,7 +359,7 @@ class CMPC { public:
|
||||
joinNclean(res);
|
||||
for(int i = 2; i <= nP; ++i) delete[] tmp[i];
|
||||
}
|
||||
|
||||
|
||||
if(party!= 1) {
|
||||
for(int i = 0; i < num_in; ++i) {
|
||||
block tmp = labels[i];
|
||||
@@ -376,8 +376,8 @@ class CMPC { public:
|
||||
}));
|
||||
}
|
||||
joinNclean(res);
|
||||
|
||||
int ands = 0;
|
||||
|
||||
int ands = 0;
|
||||
for(int i = 0; i < cf->num_gate; ++i) {
|
||||
if (cf->gates[4*i+3] == XOR_GATE) {
|
||||
for(int j = 2; j<= nP; ++j)
|
||||
@@ -394,7 +394,7 @@ class CMPC { public:
|
||||
xorBlocks_arr(H, H, GT[ands][j][index], nP+1);
|
||||
for(int k = 2; k <= nP; ++k)
|
||||
eval_labels[k][cf->gates[4*i+2]] = H[k] ^ eval_labels[k][cf->gates[4*i+2]];
|
||||
|
||||
|
||||
block t0 = GTK[ands][index][j] ^ Delta;
|
||||
|
||||
if(cmpBlock(&H[1], >K[ands][index][j], 1))
|
||||
@@ -406,7 +406,7 @@ class CMPC { public:
|
||||
}
|
||||
ands++;
|
||||
} else {
|
||||
mask_input[cf->gates[4*i+2]] = not mask_input[cf->gates[4*i]];
|
||||
mask_input[cf->gates[4*i+2]] = not mask_input[cf->gates[4*i]];
|
||||
for(int j = 2; j <= nP; ++j)
|
||||
eval_labels[j][cf->gates[4*i+2]] = eval_labels[j][cf->gates[4*i]];
|
||||
}
|
||||
@@ -418,7 +418,7 @@ class CMPC { public:
|
||||
} else {
|
||||
vector<future<void>> res;
|
||||
bool * tmp[nP+1];
|
||||
for(int i = 2; i <= nP; ++i)
|
||||
for(int i = 2; i <= nP; ++i)
|
||||
tmp[i] = new bool[cf->n3];
|
||||
for(int i = 2; i <= nP; ++i) {
|
||||
int party2 = i;
|
||||
@@ -444,11 +444,11 @@ class CMPC { public:
|
||||
T[1] = sigma(a ^ Delta);
|
||||
T[2] = sigma(sigma(b));
|
||||
T[3] = sigma(sigma(b ^ Delta));
|
||||
|
||||
H[0][0] = T[0] ^ T[2];
|
||||
H[1][0] = T[0] ^ T[3];
|
||||
H[2][0] = T[1] ^ T[2];
|
||||
H[3][0] = T[1] ^ T[3];
|
||||
|
||||
H[0][0] = T[0] ^ T[2];
|
||||
H[1][0] = T[0] ^ T[3];
|
||||
H[2][0] = T[1] ^ T[2];
|
||||
H[3][0] = T[1] ^ T[3];
|
||||
for(int j = 0; j < 4; ++j) for(int i = 1; i <= nP; ++i) {
|
||||
H[j][i] = H[j][0] ^ makeBlock(4*idx+j, i);
|
||||
}
|
||||
@@ -500,7 +500,7 @@ class CMPC { public:
|
||||
emp::Hash::hash_once(dig2, tmp, (end[party]-start[party])*sizeof(block));
|
||||
io->recv_data(party2, dig, Hash::DIGEST_SIZE);
|
||||
delete[] tmp;
|
||||
return strncmp(dig, dig2, Hash::DIGEST_SIZE) != 0;
|
||||
return strncmp(dig, dig2, Hash::DIGEST_SIZE) != 0;
|
||||
}));
|
||||
}
|
||||
if(joinNcleanCheat(res)) error("cheat!");
|
||||
@@ -532,7 +532,7 @@ class CMPC { public:
|
||||
}
|
||||
joinNclean(res);
|
||||
}
|
||||
|
||||
|
||||
if(party!= 1) {
|
||||
for(int i = 0; i < num_in; ++i) {
|
||||
block tmp = labels[i];
|
||||
@@ -549,8 +549,8 @@ class CMPC { public:
|
||||
}));
|
||||
}
|
||||
joinNclean(res);
|
||||
|
||||
int ands = 0;
|
||||
|
||||
int ands = 0;
|
||||
for(int i = 0; i < cf->num_gate; ++i) {
|
||||
if (cf->gates[4*i+3] == XOR_GATE) {
|
||||
for(int j = 2; j<= nP; ++j)
|
||||
@@ -567,7 +567,7 @@ class CMPC { public:
|
||||
xorBlocks_arr(H, H, GT[ands][j][index], nP+1);
|
||||
for(int k = 2; k <= nP; ++k)
|
||||
eval_labels[k][cf->gates[4*i+2]] = H[k] ^ eval_labels[k][cf->gates[4*i+2]];
|
||||
|
||||
|
||||
block t0 = GTK[ands][index][j] ^ Delta;
|
||||
|
||||
if(cmpBlock(&H[1], >K[ands][index][j], 1))
|
||||
@@ -579,7 +579,7 @@ class CMPC { public:
|
||||
}
|
||||
ands++;
|
||||
} else {
|
||||
mask_input[cf->gates[4*i+2]] = not mask_input[cf->gates[4*i]];
|
||||
mask_input[cf->gates[4*i+2]] = not mask_input[cf->gates[4*i]];
|
||||
for(int j = 2; j <= nP; ++j)
|
||||
eval_labels[j][cf->gates[4*i+2]] = eval_labels[j][cf->gates[4*i]];
|
||||
}
|
||||
@@ -591,7 +591,7 @@ class CMPC { public:
|
||||
} else {
|
||||
vector<future<void>> res;
|
||||
bool * tmp[nP+1];
|
||||
for(int i = 2; i <= nP; ++i)
|
||||
for(int i = 2; i <= nP; ++i)
|
||||
tmp[i] = new bool[cf->n3];
|
||||
for(int i = 2; i <= nP; ++i) {
|
||||
int party2 = i;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
inline Bit::Bit(bool b, int party) {
|
||||
if (party == PUBLIC)
|
||||
bit = CircuitExecution::circ_exec->public_label(b);
|
||||
else ProtocolExecution::prot_exec->feed(&bit, party, &b, 1);
|
||||
else ProtocolExecution::prot_exec->feed(&bit, party, &b, 1);
|
||||
}
|
||||
|
||||
inline Bit Bit::select(const Bit & select, const Bit & new_v) const{
|
||||
|
||||
@@ -121,7 +121,7 @@ class BristolFormat { public:
|
||||
else if (gates[4*i+3] == XOR_GATE) {
|
||||
wires[gates[4*i+2]] = CircuitExecution::circ_exec->xor_gate(wires[gates[4*i]], wires[gates[4*i+1]]);
|
||||
}
|
||||
else
|
||||
else
|
||||
wires[gates[4*i+2]] = CircuitExecution::circ_exec->not_gate(wires[gates[4*i]]);
|
||||
}
|
||||
memcpy(out, wires.data()+(num_wire-n3), n3*sizeof(block));
|
||||
@@ -129,7 +129,7 @@ class BristolFormat { public:
|
||||
};
|
||||
|
||||
class BristolFashion { public:
|
||||
int num_gate = 0, num_wire = 0,
|
||||
int num_gate = 0, num_wire = 0,
|
||||
num_input = 0, num_output = 0;
|
||||
vector<int> gates;
|
||||
vector<block> wires;
|
||||
@@ -192,7 +192,7 @@ class BristolFashion { public:
|
||||
else if (gates[4*i+3] == XOR_GATE) {
|
||||
wires[gates[4*i+2]] = CircuitExecution::circ_exec->xor_gate(wires[gates[4*i]], wires[gates[4*i+1]]);
|
||||
}
|
||||
else
|
||||
else
|
||||
wires[gates[4*i+2]] = CircuitExecution::circ_exec->not_gate(wires[gates[4*i]]);
|
||||
}
|
||||
memcpy(out, wires.data()+(num_wire-num_output), num_output*sizeof(block));
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
namespace emp {
|
||||
|
||||
/* Circuit Pipelining
|
||||
/* Circuit Pipelining
|
||||
* [REF] Implementation of "Faster Secure Two-Party Computation Using Garbled Circuit"
|
||||
* https://www.usenix.org/legacy/event/sec11/tech/full_papers/Huang.pdf
|
||||
*/
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#ifndef EMP_PROTOCOL_EXECUTION_H
|
||||
#define EMP_PROTOCOL_EXECUTION_H
|
||||
#include <pthread.h>
|
||||
#include <pthread.h>
|
||||
#include "emp-tool/utils/block.h"
|
||||
#include "emp-tool/utils/constants.h"
|
||||
|
||||
namespace emp {
|
||||
class ProtocolExecution {
|
||||
class ProtocolExecution {
|
||||
public:
|
||||
int cur_party;
|
||||
#ifndef THREADING
|
||||
|
||||
@@ -39,7 +39,7 @@ class ThreadPool {
|
||||
public:
|
||||
ThreadPool(size_t);
|
||||
template<class F, class... Args>
|
||||
auto enqueue(F&& f, Args&&... args)
|
||||
auto enqueue(F&& f, Args&&... args)
|
||||
-> std::future<typename std::result_of<F(Args...)>::type>;
|
||||
~ThreadPool();
|
||||
int size() const;
|
||||
@@ -48,13 +48,13 @@ private:
|
||||
std::vector< std::thread > workers;
|
||||
// the task queue
|
||||
std::queue< std::function<void()> > tasks;
|
||||
|
||||
|
||||
// synchronization
|
||||
std::mutex queue_mutex;
|
||||
std::condition_variable condition;
|
||||
bool stop;
|
||||
};
|
||||
|
||||
|
||||
int inline ThreadPool::size() const {
|
||||
return workers.size();
|
||||
}
|
||||
@@ -88,7 +88,7 @@ inline ThreadPool::ThreadPool(size_t threads)
|
||||
|
||||
// add new work item to the pool
|
||||
template<class F, class... Args>
|
||||
auto ThreadPool::enqueue(F&& f, Args&&... args)
|
||||
auto ThreadPool::enqueue(F&& f, Args&&... args)
|
||||
-> std::future<typename std::result_of<F(Args...)>::type>
|
||||
{
|
||||
using return_type = typename std::result_of<F(Args...)>::type;
|
||||
@@ -96,7 +96,7 @@ auto ThreadPool::enqueue(F&& f, Args&&... args)
|
||||
auto task = std::make_shared< std::packaged_task<return_type()> >(
|
||||
std::bind(std::forward<F>(f), std::forward<Args>(args)...)
|
||||
);
|
||||
|
||||
|
||||
std::future<return_type> res = task->get_future();
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(queue_mutex);
|
||||
|
||||
@@ -70,7 +70,7 @@ static inline void ParaEnc(block *blks, AES_KEY *keys) {
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned int r = 1; r < 10; ++r) {
|
||||
for (unsigned int r = 1; r < 10; ++r) {
|
||||
blks = first;
|
||||
for(size_t i = 0; i < numKeys; ++i) {
|
||||
block K = keys[i].rd_key[r];
|
||||
@@ -95,7 +95,7 @@ template<int numKeys, int numEncs>
|
||||
static inline void ParaEnc(block *_blks, AES_KEY *keys) {
|
||||
uint8x16_t * first = (uint8x16_t*)(_blks);
|
||||
|
||||
for (unsigned int r = 0; r < 9; ++r) {
|
||||
for (unsigned int r = 0; r < 9; ++r) {
|
||||
auto blks = first;
|
||||
for(size_t i = 0; i < numKeys; ++i) {
|
||||
uint8x16_t K = vreinterpretq_u8_m128i(keys[i].rd_key[r]);
|
||||
@@ -103,7 +103,7 @@ static inline void ParaEnc(block *_blks, AES_KEY *keys) {
|
||||
*blks = vaesmcq_u8(vaeseq_u8(*blks, K));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
auto blks = first;
|
||||
for(size_t i = 0; i < numKeys; ++i) {
|
||||
uint8x16_t K = vreinterpretq_u8_m128i(keys[i].rd_key[9]);
|
||||
|
||||
@@ -84,7 +84,7 @@ inline void xorBlocks_arr(block* res, const block* x, const block* y, int nblock
|
||||
|
||||
inline void xorBlocks_arr(block* res, const block* x, block y, int nblocks) {
|
||||
const block * dest = nblocks+x;
|
||||
for (; x != dest;)
|
||||
for (; x != dest;)
|
||||
*(res++) = *(x++) ^ y;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
namespace emp {
|
||||
|
||||
/*
|
||||
/*
|
||||
* By default, CRH use zero_block as the AES key.
|
||||
* Here we model f(x) = AES_{00..0}(x) as a random permutation (and thus in the RPM model)
|
||||
*/
|
||||
@@ -14,7 +14,7 @@ class CRH: public PRP { public:
|
||||
}
|
||||
|
||||
block H(block in) {
|
||||
block t = in;
|
||||
block t = in;
|
||||
permute_block(&t, 1);
|
||||
return t ^ in;
|
||||
}
|
||||
@@ -44,7 +44,7 @@ class CRH: public PRP { public:
|
||||
if(scratch == nullptr) {
|
||||
del = true;
|
||||
scratch = new block[n];
|
||||
}
|
||||
}
|
||||
for(int i = 0; i < n; ++i)
|
||||
scratch[i] = in[i];
|
||||
permute_block(scratch, n);
|
||||
|
||||
@@ -91,11 +91,11 @@ __attribute__((target("sse2")))
|
||||
inline block reduce(__m128i tmp3, __m128i tmp6) {//3 is low, 6 is high
|
||||
__m128i tmp7, tmp8, tmp9, tmp10, tmp11, tmp12;
|
||||
__m128i XMMMASK = _mm_setr_epi32(0xffffffff, 0x0, 0x0, 0x0);
|
||||
tmp7 = _mm_srli_epi32(tmp6, 31);
|
||||
tmp8 = _mm_srli_epi32(tmp6, 30);
|
||||
tmp7 = _mm_srli_epi32(tmp6, 31);
|
||||
tmp8 = _mm_srli_epi32(tmp6, 30);
|
||||
tmp9 = _mm_srli_epi32(tmp6, 25);
|
||||
|
||||
tmp7 = _mm_xor_si128(tmp7, tmp8);
|
||||
tmp7 = _mm_xor_si128(tmp7, tmp8);
|
||||
tmp7 = _mm_xor_si128(tmp7, tmp9);
|
||||
|
||||
tmp8 = _mm_shuffle_epi32(tmp7, 147);
|
||||
@@ -108,7 +108,7 @@ inline block reduce(__m128i tmp3, __m128i tmp6) {//3 is low, 6 is high
|
||||
tmp10 = _mm_slli_epi32(tmp6, 1);
|
||||
tmp3 = _mm_xor_si128(tmp3, tmp10);
|
||||
tmp11 = _mm_slli_epi32(tmp6, 2);
|
||||
tmp3 = _mm_xor_si128(tmp3, tmp11);
|
||||
tmp3 = _mm_xor_si128(tmp3, tmp11);
|
||||
tmp12 = _mm_slli_epi32(tmp6, 7);
|
||||
tmp3 = _mm_xor_si128(tmp3, tmp12);
|
||||
return _mm_xor_si128(tmp3, tmp6);
|
||||
@@ -202,7 +202,7 @@ inline void uni_hash_coeff_gen(block* coeff, block seed, int sz) {
|
||||
/* coefficients of almost universal hash function */
|
||||
template<int N>
|
||||
inline void uni_hash_coeff_gen(block* coeff, block seed) {
|
||||
uni_hash_coeff_gen(coeff, seed, N);
|
||||
uni_hash_coeff_gen(coeff, seed, N);
|
||||
}
|
||||
|
||||
/* packing in Galois field (v[i] * X^i for v of size 128) */
|
||||
|
||||
@@ -50,10 +50,10 @@ class MITCCRH { public:
|
||||
block tmp[K*H];
|
||||
for(int i = 0; i < K*H; ++i)
|
||||
tmp[i] = blks[i];
|
||||
|
||||
|
||||
ParaEnc<K,H>(tmp, scheduled_key+key_used);
|
||||
key_used += K;
|
||||
|
||||
|
||||
for(int i = 0; i < K*H; ++i)
|
||||
blks[i] = blks[i] ^ tmp[i];
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ class PRG { public:
|
||||
return 0xFFFFFFFFFFFFFFFFULL;
|
||||
}
|
||||
result_type operator()() {
|
||||
if(ptr == 32) {
|
||||
if(ptr == 32) {
|
||||
random_block((block*)buffer, 16);
|
||||
ptr = 0;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
template<class... Ts>
|
||||
void run_function(void *function, const Ts&... args) {
|
||||
void run_function(void *function, const Ts&... args) {
|
||||
reinterpret_cast<void(*)(Ts...)>(function)(args...);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ void inline delete_array_null(T * ptr){
|
||||
}
|
||||
}
|
||||
|
||||
inline time_point<high_resolution_clock> clock_start() {
|
||||
inline time_point<high_resolution_clock> clock_start() {
|
||||
return high_resolution_clock::now();
|
||||
}
|
||||
|
||||
|
||||
@@ -38,13 +38,13 @@ async function secure2PC(
|
||||
|
||||
running = true;
|
||||
|
||||
const emp: {
|
||||
circuit?: string;
|
||||
input?: Uint8Array;
|
||||
io?: IO;
|
||||
handleOutput?: (value: Uint8Array) => void
|
||||
const emp: {
|
||||
circuit?: string;
|
||||
input?: Uint8Array;
|
||||
io?: IO;
|
||||
handleOutput?: (value: Uint8Array) => void
|
||||
} = {};
|
||||
|
||||
|
||||
module.emp = emp;
|
||||
|
||||
emp.circuit = circuit;
|
||||
@@ -80,11 +80,11 @@ function partyToIndex(party: 'alice' | 'bob'): number {
|
||||
if (party === 'alice') {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if (party === 'bob') {
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
throw new Error(`Invalid party ${party} (must be 'alice' or 'bob')`);
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ windowAny.wsDemo = async function(
|
||||
input: number,
|
||||
): Promise<number> {
|
||||
const io = await makeWebSocketIO('ws://localhost:8175/demo');
|
||||
|
||||
|
||||
const bits = await secure2PC(
|
||||
party,
|
||||
add32BitCircuit,
|
||||
@@ -287,7 +287,7 @@ function makeConsoleSend(): (data: Uint8Array) => void {
|
||||
|
||||
/**
|
||||
* Decodes a Base64-encoded string into a Uint8Array.
|
||||
*
|
||||
*
|
||||
* @param base64Str - The Base64-encoded string to decode and process.
|
||||
* @throws {TypeError} If the input is not a string.
|
||||
* @throws {Error} If Base64 decoding fails.
|
||||
|
||||
@@ -21,13 +21,13 @@ export default async function nodeSecure2PC(
|
||||
|
||||
let module = await ((await import('../../build/jslib.js')).default());
|
||||
|
||||
const emp: {
|
||||
circuit?: string;
|
||||
input?: Uint8Array;
|
||||
io?: IO;
|
||||
handleOutput?: (value: Uint8Array) => void
|
||||
const emp: {
|
||||
circuit?: string;
|
||||
input?: Uint8Array;
|
||||
io?: IO;
|
||||
handleOutput?: (value: Uint8Array) => void
|
||||
} = {};
|
||||
|
||||
|
||||
module.emp = emp;
|
||||
|
||||
emp.circuit = circuit;
|
||||
@@ -59,10 +59,10 @@ function partyToIndex(party: 'alice' | 'bob'): number {
|
||||
if (party === 'alice') {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if (party === 'bob') {
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
throw new Error(`Invalid party ${party} (must be 'alice' or 'bob')`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user