|
@@ -272,14 +272,46 @@ void write_evalfull_outs_into_a_file(bool party, size_t i, size_t db_nitems, in
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void compute_CW(tcp::socket& sout, tcp::socket& sin, __m128i L, __m128i R, uint8_t bit, __m128i & CW)
|
|
|
+
|
|
|
+struct cw_construction
|
|
|
{
|
|
|
+ __m128i rand_b, gamma_b;
|
|
|
+ uint8_t bit_b;
|
|
|
+};
|
|
|
+
|
|
|
+struct BlindsCW
|
|
|
+{
|
|
|
+ __m128i blinded_message;
|
|
|
+ uint8_t blinded_bit;
|
|
|
+};
|
|
|
|
|
|
- struct cw_construction
|
|
|
- {
|
|
|
- __m128i rand_b, gamma_b;
|
|
|
- uint8_t bit_b;
|
|
|
- };
|
|
|
+
|
|
|
+void compute_CW_bits(tcp::socket& sout, __m128i L, __m128i R, uint8_t bit, uint8_t &cwt_L, uint8_t &cwt_R)
|
|
|
+{
|
|
|
+ uint8_t advice_L = get_lsb(L) ^ bit;
|
|
|
+ uint8_t advice_R = get_lsb(R) ^ bit;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ uint8_t advice[2];
|
|
|
+ uint8_t cwts[2];
|
|
|
+
|
|
|
+ advice[0] = advice_L;
|
|
|
+ advice[1] = advice_R;
|
|
|
+
|
|
|
+ boost::asio::write(sout, boost::asio::buffer(&advice, sizeof(advice)));
|
|
|
+ boost::asio::read(sout, boost::asio::buffer(&cwts, sizeof(cwts)));
|
|
|
+
|
|
|
+ cwt_L = cwts[0];
|
|
|
+ cwt_R = cwts[1];
|
|
|
+
|
|
|
+ cwt_L = cwt_L ^ advice_L ^ 1;
|
|
|
+ cwt_R = cwt_R ^ advice_R;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void compute_CW(tcp::socket& sout, tcp::socket& sin, __m128i L, __m128i R, uint8_t bit, __m128i & CW)
|
|
|
+{
|
|
|
|
|
|
|
|
|
cw_construction computecw;
|
|
@@ -290,8 +322,6 @@ void compute_CW(tcp::socket& sout, tcp::socket& sin, __m128i L, __m128i R, uint8
|
|
|
__m128i gamma_b = computecw.gamma_b;
|
|
|
uint8_t bit_b = computecw.bit_b;
|
|
|
|
|
|
-
|
|
|
-
|
|
|
#ifdef DEBUG
|
|
|
__m128i rand_b2, gamma_b2;
|
|
|
uint8_t bit_b2;
|
|
@@ -312,22 +342,11 @@ void compute_CW(tcp::socket& sout, tcp::socket& sin, __m128i L, __m128i R, uint8
|
|
|
__m128i blinded_L = L ^ R ^ rand_b;
|
|
|
__m128i blinded_L_read;
|
|
|
|
|
|
-
|
|
|
- struct BlindsCW
|
|
|
- {
|
|
|
- __m128i blinded_message;
|
|
|
- uint8_t blinded_bit;
|
|
|
- };
|
|
|
-
|
|
|
BlindsCW blinds_sent, blinds_recv;
|
|
|
-
|
|
|
blinds_sent.blinded_bit = blinded_bit;
|
|
|
blinds_sent.blinded_message = blinded_L;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- boost::asio::write(sout, boost::asio::buffer(&blinds_sent, sizeof(blinds_sent)));
|
|
|
- boost::asio::read(sout, boost::asio::buffer(&blinds_recv, sizeof(blinds_recv)));
|
|
|
+ boost::asio::write(sout, boost::asio::buffer(&blinds_sent, sizeof(BlindsCW)));
|
|
|
+ boost::asio::read(sout, boost::asio::buffer(&blinds_recv, sizeof(BlindsCW)));
|
|
|
|
|
|
blinded_bit_read = blinds_recv.blinded_bit;
|
|
|
blinded_L_read = blinds_recv.blinded_message;
|
|
@@ -452,7 +471,7 @@ inline void create_dpfs( size_t db_nitems,
|
|
|
|
|
|
|
|
|
dpfP2 dpf_instance;
|
|
|
- dpf_instance.root = root;
|
|
|
+ dpf_instance.root = root;
|
|
|
for (size_t layer = 0; layer < depth; ++layer)
|
|
|
{
|
|
|
#ifdef VERBOSE
|
|
@@ -486,29 +505,14 @@ inline void create_dpfs( size_t db_nitems,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // Computes the correction word using OSWAP
|
|
|
compute_CW(socketsPb[socket_no], socketsP2[socket_no], L, R, target_share[layer], CW[layer]);
|
|
|
|
|
|
- uint8_t advice_L = get_lsb(L) ^ target_share[layer];
|
|
|
- uint8_t advice_R = get_lsb(R) ^ target_share[layer];
|
|
|
-
|
|
|
uint8_t cwt_L, cwt_R;
|
|
|
-
|
|
|
- uint8_t advice[2];
|
|
|
- uint8_t cwts[2];
|
|
|
-
|
|
|
- advice[0] = advice_L;
|
|
|
- advice[1] = advice_R;
|
|
|
-
|
|
|
- boost::asio::write(socketsPb[socket_no+1], boost::asio::buffer(&advice, sizeof(advice)));
|
|
|
- boost::asio::read(socketsPb[socket_no+1], boost::asio::buffer(&cwts, sizeof(cwts)));
|
|
|
+ // Computes the correction word bits
|
|
|
+ compute_CW_bits(socketsPb[socket_no+1], L, R, target_share[layer], cwt_L, cwt_R);
|
|
|
|
|
|
- cwt_L = cwts[0];
|
|
|
- cwt_R = cwts[1];
|
|
|
-
|
|
|
- cwt_L = cwt_L ^ advice_L ^ 1;
|
|
|
- cwt_R = cwt_R ^ advice_R;
|
|
|
-
|
|
|
- #ifdef DEBUG
|
|
|
+ #ifdef DEBUG
|
|
|
if(ind == 0)
|
|
|
{
|
|
|
std::cout << "CW reconstruction = " << CW[layer][0] << " " << CW[layer][1] << std::endl;
|
|
@@ -522,8 +526,6 @@ inline void create_dpfs( size_t db_nitems,
|
|
|
dpf_instance.cwt_L[layer] = cwt_L;
|
|
|
dpf_instance.cwt_R[layer] = cwt_R;
|
|
|
|
|
|
-
|
|
|
-
|
|
|
for(size_t j = 0; j < nodes_in_prev_layer; ++j)
|
|
|
{
|
|
|
t[curlayer][2*j] = get_lsb(s[curlayer][2*j]) ^ (cwt_L & t[1-curlayer][j]);
|
|
@@ -533,26 +535,28 @@ inline void create_dpfs( size_t db_nitems,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- boost::asio::write(socketsP2[socket_no+1], boost::asio::buffer(&dpf_instance, sizeof(dpfP2)));
|
|
|
+ boost::asio::write(socketsP2[socket_no+1], boost::asio::buffer(&dpf_instance, sizeof(dpfP2)));
|
|
|
|
|
|
__m128i Gamma = _mm_setzero_si128();
|
|
|
|
|
|
for (size_t i = 0; i < to + 1; ++i)
|
|
|
{
|
|
|
- Gamma[0] += output[i][0];
|
|
|
+ Gamma[0] += output[i][0]; // the correction word for duoram update
|
|
|
Gamma[1] += output[i][1]; // the correction word for share conversion
|
|
|
}
|
|
|
|
|
|
if(party)
|
|
|
{
|
|
|
- Gamma[0] = -Gamma[0];
|
|
|
+ Gamma[0] = -Gamma[0]; // the correction word for duoram update
|
|
|
Gamma[1] = -Gamma[1]; // the correction word for share conversion
|
|
|
}
|
|
|
|
|
|
- // boost::asio::write(socketsPb[socket_no + 3], boost::asio::buffer(&Gamma, sizeof(Gamma)));
|
|
|
- // boost::asio::read(socketsPb[socket_no + 3], boost::asio::buffer(&final_correction_word, sizeof(final_correction_word)));
|
|
|
+ #ifdef DEBUG
|
|
|
+ boost::asio::write(socketsPb[socket_no + 3], boost::asio::buffer(&Gamma, sizeof(Gamma)));
|
|
|
+ boost::asio::read(socketsPb[socket_no + 3], boost::asio::buffer(&final_correction_word, sizeof(final_correction_word)));
|
|
|
+ #endif
|
|
|
|
|
|
- final_correction_word = Gamma; // final_correction_word + Gamma;
|
|
|
+ final_correction_word = Gamma;
|
|
|
|
|
|
} // dpf::__evalinterval
|
|
|
|
|
@@ -606,6 +610,7 @@ inline void evaluate_dpfs( size_t db_nitems, dpfP2 dpfinstance, const AES_KEY&
|
|
|
std::cout << "t[curlayer][0] " << (int) t[curlayer][0] << std::endl;
|
|
|
}
|
|
|
#endif
|
|
|
+
|
|
|
for (size_t layer = 0; layer < depth; ++layer)
|
|
|
{
|
|
|
#ifdef VERBOSE
|
|
@@ -618,13 +623,10 @@ inline void evaluate_dpfs( size_t db_nitems, dpfP2 dpfinstance, const AES_KEY&
|
|
|
auto nextbit = (from_node >> (nbits-layer-1)) & 1;
|
|
|
size_t nodes_in_prev_layer = std::ceil(static_cast<double>(nodes_in_interval) / (1ULL << (depth-layer)));
|
|
|
size_t nodes_in_cur_layer = std::ceil(static_cast<double>(nodes_in_interval) / (1ULL << (depth-layer-1)));
|
|
|
-
|
|
|
-
|
|
|
|
|
|
for (i = nextbit, j = nextbit; j < nodes_in_prev_layer-1; ++j, i+=2)
|
|
|
{
|
|
|
traverse(prgkey, s[1-curlayer][j], &s[curlayer][i]);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
if (nodes_in_prev_layer > j)
|
|
@@ -632,7 +634,6 @@ inline void evaluate_dpfs( size_t db_nitems, dpfP2 dpfinstance, const AES_KEY&
|
|
|
if (i < nodes_in_cur_layer - 1)
|
|
|
{
|
|
|
traverse(prgkey, s[1-curlayer][j], &s[curlayer][i]);
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -658,13 +659,13 @@ inline void evaluate_dpfs( size_t db_nitems, dpfP2 dpfinstance, const AES_KEY&
|
|
|
|
|
|
for (size_t i = 0; i < to + 1; ++i)
|
|
|
{
|
|
|
- Gamma[0] += output[i][0];
|
|
|
+ Gamma[0] += output[i][0]; // the correction word for duoram update
|
|
|
Gamma[1] += output[i][1]; // the correction word for share conversion
|
|
|
}
|
|
|
|
|
|
if(party)
|
|
|
{
|
|
|
- Gamma[0] = -Gamma[0];
|
|
|
+ Gamma[0] = -Gamma[0]; // the correction word for duoram update
|
|
|
Gamma[1] = -Gamma[1]; // the correction word for share conversion
|
|
|
}
|
|
|
|