From 1f5cdacec4de861d557cbf6350fdaf5ea8fcaba2 Mon Sep 17 00:00:00 2001 From: Andrew Morris Date: Thu, 16 Jan 2025 15:15:59 +1100 Subject: [PATCH] remove trailing whitespace --- programs/test_mpc.cpp | 2 +- src/cpp/mpc/emp-agmpc/abitmp.h | 14 +++--- src/cpp/mpc/emp-agmpc/flexible_input_output.h | 10 ++--- src/cpp/mpc/emp-agmpc/fpremp.h | 24 +++++----- src/cpp/mpc/emp-agmpc/helper.h | 6 +-- src/cpp/mpc/emp-agmpc/mpc.h | 44 +++++++++---------- src/cpp/mpc/emp-tool/circuits/bit.hpp | 2 +- src/cpp/mpc/emp-tool/circuits/circuit_file.h | 6 +-- .../emp-tool/execution/circuit_execution.h | 2 +- .../emp-tool/execution/protocol_execution.h | 4 +- src/cpp/mpc/emp-tool/utils/ThreadPool.h | 10 ++--- src/cpp/mpc/emp-tool/utils/aes_opt.h | 6 +-- src/cpp/mpc/emp-tool/utils/block.h | 2 +- src/cpp/mpc/emp-tool/utils/crh.h | 6 +-- src/cpp/mpc/emp-tool/utils/f2k.h | 10 ++--- src/cpp/mpc/emp-tool/utils/mitccrh.h | 4 +- src/cpp/mpc/emp-tool/utils/prg.h | 2 +- src/cpp/mpc/emp-tool/utils/utils.hpp | 4 +- src/ts/appendWorker.ts | 16 +++---- src/ts/demo.ts | 4 +- src/ts/nodeSecure2PC.ts | 16 +++---- 21 files changed, 97 insertions(+), 97 deletions(-) diff --git a/programs/test_mpc.cpp b/programs/test_mpc.cpp index 34341df..7ff7255 100644 --- a/programs/test_mpc.cpp +++ b/programs/test_mpc.cpp @@ -14,7 +14,7 @@ int main(int argc, char** argv) { NetIOMP io(party, port); NetIOMP io2(party, port+2*(nP+1)*(nP+1)+1); NetIOMP *ios[2] = {&io, &io2}; - ThreadPool pool(4); + ThreadPool pool(4); BristolFormat cf(circuit_file_location.c_str()); CMPC* mpc = new CMPC(ios, &pool, party, &cf); diff --git a/src/cpp/mpc/emp-agmpc/abitmp.h b/src/cpp/mpc/emp-agmpc/abitmp.h index 805560e..bb03f69 100644 --- a/src/cpp/mpc/emp-agmpc/abitmp.h +++ b/src/cpp/mpc/emp-agmpc/abitmp.h @@ -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> 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) { diff --git a/src/cpp/mpc/emp-agmpc/flexible_input_output.h b/src/cpp/mpc/emp-agmpc/flexible_input_output.h index 56445fa..47f3846 100644 --- a/src/cpp/mpc/emp-agmpc/flexible_input_output.h +++ b/src/cpp/mpc/emp-agmpc/flexible_input_output.h @@ -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 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++){ diff --git a/src/cpp/mpc/emp-agmpc/fpremp.h b/src/cpp/mpc/emp-agmpc/fpremp.h index 65f9e77..95665ba 100644 --- a/src/cpp/mpc/emp-agmpc/fpremp.h +++ b/src/cpp/mpc/emp-agmpc/fpremp.h @@ -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(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"< * io, block * MAC[nP+1], block * KEY[nP+1], bool * r, } delete[] tmp; if(party == 1) - cerr<<"check_MAC pass!\n"< @@ -167,7 +167,7 @@ void check_correctness(NetIOMP* io, bool * r, int length, int party) { } delete[] tmp1; delete[] tmp2; - cerr<<"check_correctness pass!\n"<send_data(1, r, length*3); io->flush(1); diff --git a/src/cpp/mpc/emp-agmpc/mpc.h b/src/cpp/mpc/emp-agmpc/mpc.h index 5c961c7..7c833ca 100644 --- a/src/cpp/mpc/emp-agmpc/mpc.h +++ b/src/cpp/mpc/emp-agmpc/mpc.h @@ -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> 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> 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; diff --git a/src/cpp/mpc/emp-tool/circuits/bit.hpp b/src/cpp/mpc/emp-tool/circuits/bit.hpp index b274036..87c24b1 100644 --- a/src/cpp/mpc/emp-tool/circuits/bit.hpp +++ b/src/cpp/mpc/emp-tool/circuits/bit.hpp @@ -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{ diff --git a/src/cpp/mpc/emp-tool/circuits/circuit_file.h b/src/cpp/mpc/emp-tool/circuits/circuit_file.h index 6f954b0..8852711 100644 --- a/src/cpp/mpc/emp-tool/circuits/circuit_file.h +++ b/src/cpp/mpc/emp-tool/circuits/circuit_file.h @@ -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 gates; vector 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)); diff --git a/src/cpp/mpc/emp-tool/execution/circuit_execution.h b/src/cpp/mpc/emp-tool/execution/circuit_execution.h index 6c0a79b..4422c63 100644 --- a/src/cpp/mpc/emp-tool/execution/circuit_execution.h +++ b/src/cpp/mpc/emp-tool/execution/circuit_execution.h @@ -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 */ diff --git a/src/cpp/mpc/emp-tool/execution/protocol_execution.h b/src/cpp/mpc/emp-tool/execution/protocol_execution.h index 2e70656..9735820 100644 --- a/src/cpp/mpc/emp-tool/execution/protocol_execution.h +++ b/src/cpp/mpc/emp-tool/execution/protocol_execution.h @@ -1,11 +1,11 @@ #ifndef EMP_PROTOCOL_EXECUTION_H #define EMP_PROTOCOL_EXECUTION_H -#include +#include #include "emp-tool/utils/block.h" #include "emp-tool/utils/constants.h" namespace emp { -class ProtocolExecution { +class ProtocolExecution { public: int cur_party; #ifndef THREADING diff --git a/src/cpp/mpc/emp-tool/utils/ThreadPool.h b/src/cpp/mpc/emp-tool/utils/ThreadPool.h index c4833af..5eb70ad 100644 --- a/src/cpp/mpc/emp-tool/utils/ThreadPool.h +++ b/src/cpp/mpc/emp-tool/utils/ThreadPool.h @@ -39,7 +39,7 @@ class ThreadPool { public: ThreadPool(size_t); template - auto enqueue(F&& f, Args&&... args) + auto enqueue(F&& f, Args&&... args) -> std::future::type>; ~ThreadPool(); int size() const; @@ -48,13 +48,13 @@ private: std::vector< std::thread > workers; // the task queue std::queue< std::function > 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 -auto ThreadPool::enqueue(F&& f, Args&&... args) +auto ThreadPool::enqueue(F&& f, Args&&... args) -> std::future::type> { using return_type = typename std::result_of::type; @@ -96,7 +96,7 @@ auto ThreadPool::enqueue(F&& f, Args&&... args) auto task = std::make_shared< std::packaged_task >( std::bind(std::forward(f), std::forward(args)...) ); - + std::future res = task->get_future(); { std::unique_lock lock(queue_mutex); diff --git a/src/cpp/mpc/emp-tool/utils/aes_opt.h b/src/cpp/mpc/emp-tool/utils/aes_opt.h index b4489e3..42c98f6 100644 --- a/src/cpp/mpc/emp-tool/utils/aes_opt.h +++ b/src/cpp/mpc/emp-tool/utils/aes_opt.h @@ -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 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]); diff --git a/src/cpp/mpc/emp-tool/utils/block.h b/src/cpp/mpc/emp-tool/utils/block.h index 04c22cf..4781820 100644 --- a/src/cpp/mpc/emp-tool/utils/block.h +++ b/src/cpp/mpc/emp-tool/utils/block.h @@ -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; } diff --git a/src/cpp/mpc/emp-tool/utils/crh.h b/src/cpp/mpc/emp-tool/utils/crh.h index ebb947d..cca8ce3 100644 --- a/src/cpp/mpc/emp-tool/utils/crh.h +++ b/src/cpp/mpc/emp-tool/utils/crh.h @@ -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); diff --git a/src/cpp/mpc/emp-tool/utils/f2k.h b/src/cpp/mpc/emp-tool/utils/f2k.h index f73d9a1..62aa312 100644 --- a/src/cpp/mpc/emp-tool/utils/f2k.h +++ b/src/cpp/mpc/emp-tool/utils/f2k.h @@ -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 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) */ diff --git a/src/cpp/mpc/emp-tool/utils/mitccrh.h b/src/cpp/mpc/emp-tool/utils/mitccrh.h index 25350e1..782d18e 100644 --- a/src/cpp/mpc/emp-tool/utils/mitccrh.h +++ b/src/cpp/mpc/emp-tool/utils/mitccrh.h @@ -50,10 +50,10 @@ class MITCCRH { public: block tmp[K*H]; for(int i = 0; i < K*H; ++i) tmp[i] = blks[i]; - + ParaEnc(tmp, scheduled_key+key_used); key_used += K; - + for(int i = 0; i < K*H; ++i) blks[i] = blks[i] ^ tmp[i]; } diff --git a/src/cpp/mpc/emp-tool/utils/prg.h b/src/cpp/mpc/emp-tool/utils/prg.h index f979322..5a2bf19 100644 --- a/src/cpp/mpc/emp-tool/utils/prg.h +++ b/src/cpp/mpc/emp-tool/utils/prg.h @@ -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; } diff --git a/src/cpp/mpc/emp-tool/utils/utils.hpp b/src/cpp/mpc/emp-tool/utils/utils.hpp index aeace26..78fefce 100644 --- a/src/cpp/mpc/emp-tool/utils/utils.hpp +++ b/src/cpp/mpc/emp-tool/utils/utils.hpp @@ -1,5 +1,5 @@ template -void run_function(void *function, const Ts&... args) { +void run_function(void *function, const Ts&... args) { reinterpret_cast(function)(args...); } @@ -11,7 +11,7 @@ void inline delete_array_null(T * ptr){ } } -inline time_point clock_start() { +inline time_point clock_start() { return high_resolution_clock::now(); } diff --git a/src/ts/appendWorker.ts b/src/ts/appendWorker.ts index 90da384..14cea08 100644 --- a/src/ts/appendWorker.ts +++ b/src/ts/appendWorker.ts @@ -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')`); } diff --git a/src/ts/demo.ts b/src/ts/demo.ts index d8fe187..64047d7 100644 --- a/src/ts/demo.ts +++ b/src/ts/demo.ts @@ -63,7 +63,7 @@ windowAny.wsDemo = async function( input: number, ): Promise { 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. diff --git a/src/ts/nodeSecure2PC.ts b/src/ts/nodeSecure2PC.ts index 93194aa..138ce2d 100644 --- a/src/ts/nodeSecure2PC.ts +++ b/src/ts/nodeSecure2PC.ts @@ -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')`); }