|
@@ -1,15 +1,16 @@
|
|
|
#include "ot_blinds.h"
|
|
|
+#include <fcntl.h>
|
|
|
#include <cstdlib>
|
|
|
#include <iostream>
|
|
|
#include <ENCRYPTO_utils/connection.h>
|
|
|
#include <fstream>
|
|
|
#include <x86intrin.h> // SSE and AVX intrinsics
|
|
|
-const uint64_t n_OTS = 256;
|
|
|
+//const uint64_t n_OTS = 128;
|
|
|
|
|
|
ot_ext_prot test_prots[] = {IKNP};
|
|
|
snd_ot_flavor test_sflavor[] = {Snd_OT, Snd_C_OT, Snd_GC_OT, Snd_R_OT};
|
|
|
rec_ot_flavor test_rflavor[] = {Rec_OT, Rec_R_OT};
|
|
|
-uint64_t test_numots[] = {n_OTS, 3215, 100000};
|
|
|
+//uint64_t test_numots[] = {n_OTS, 3215, 100000};
|
|
|
uint64_t test_bitlen[] = {1, 3, 8, 191};
|
|
|
uint32_t test_nthreads[] = {1, 4};
|
|
|
field_type test_ftype[] = {P_FIELD, ECC_FIELD};
|
|
@@ -143,7 +144,7 @@ void run_test_sender(uint32_t numots, uint32_t bitlength, snd_ot_flavor stype, r
|
|
|
X[i] = new CBitVector();
|
|
|
// X[i]->Create(numots, bitlength, crypt);
|
|
|
X[i]->Create(numots, bitlength);
|
|
|
- X[i]->FillRand(n_OTS, crypt);
|
|
|
+ X[i]->FillRand(numots, crypt);
|
|
|
|
|
|
Y[i] = new CBitVector();
|
|
|
// X[i]->Create(numots, bitlength, crypt);
|
|
@@ -197,17 +198,33 @@ void run_test_sender(uint32_t numots, uint32_t bitlength, snd_ot_flavor stype, r
|
|
|
|
|
|
printf("\n\nLearnt Gamma0 = (X1 /cdot Y0) /oplus T------>>>>>> \n");
|
|
|
response.PrintHex();
|
|
|
- std::ofstream gammafile0, X0file, Y0file;
|
|
|
- gammafile0.open ("gamma0.txt", std::ios::out);
|
|
|
- X0file.open("X0.txt", std::ios::out);
|
|
|
- Y0file.open("Y0.txt", std::ios::out);
|
|
|
- for(size_t j = 0; j < n_OTS; ++j)
|
|
|
- {
|
|
|
- // std::cout << (int) response.GetBitNoMask(j);
|
|
|
- gammafile0 << (int) response.GetBitNoMask(j);
|
|
|
- X0file << (int) X0.GetBitNoMask(j);
|
|
|
- Y0file << (int) Y[0]->GetBitNoMask(j);
|
|
|
- }
|
|
|
+ // std::ofstream gammafile0, X0file, Y0file;
|
|
|
+ // gammafile0.open ("gamma0.txt", std::ios::out);
|
|
|
+ // X0file.open("X0.txt", std::ios::out);
|
|
|
+ // Y0file.open("Y0.txt", std::ios::out);
|
|
|
+
|
|
|
+ int fd = open("./y0", O_WRONLY, O_CREAT);
|
|
|
+ ssize_t bytes = write(fd, Y[0]->GetArr(), Y[0]->GetSize());
|
|
|
+ //std::cout << "bytes = " << bytes << std::endl;
|
|
|
+ close(fd);
|
|
|
+
|
|
|
+ int fd2 = open("./x0", O_WRONLY, O_CREAT);
|
|
|
+ ssize_t bytes2 = write(fd2, X0.GetArr(), X0.GetSize());
|
|
|
+ //std::cout << "bytes = " << bytes2 << std::endl;
|
|
|
+ close(fd2);
|
|
|
+
|
|
|
+ int fd3 = open("./gamma0", O_WRONLY, O_CREAT);
|
|
|
+ ssize_t bytes3 = write(fd3, response.GetArr(), response.GetSize());
|
|
|
+ //std::cout << "bytes = " << bytes3 << std::endl;
|
|
|
+ close(fd3);
|
|
|
+
|
|
|
+ // for(size_t j = 0; j < numots; ++j)
|
|
|
+ // {
|
|
|
+ // // std::cout << (int) response.GetBitNoMask(j);
|
|
|
+ // gammafile0 << (int) response.GetBitNoMask(j);
|
|
|
+ // X0file << (int) X0.GetBitNoMask(j);
|
|
|
+ // Y0file << (int) Y[0]->GetBitNoMask(j);
|
|
|
+ // }
|
|
|
|
|
|
for (uint32_t i = 0; i < nsndvals; i++)
|
|
|
{
|
|
@@ -238,7 +255,7 @@ void run_test_receiver(uint32_t numots, uint32_t bitlength, snd_ot_flavor stype,
|
|
|
{
|
|
|
X[i] = new CBitVector();
|
|
|
X[i]->Create(numots, bitlength);
|
|
|
- X[i]->FillRand(n_OTS, crypt);
|
|
|
+ X[i]->FillRand(numots, crypt);
|
|
|
|
|
|
Y[i] = new CBitVector();
|
|
|
Y[i]->Create(numots, bitlength);
|
|
@@ -293,10 +310,29 @@ void run_test_receiver(uint32_t numots, uint32_t bitlength, snd_ot_flavor stype,
|
|
|
std::ofstream gammafile1, X1file, Y1file;
|
|
|
|
|
|
|
|
|
+
|
|
|
+ int fd = open("./y1", O_WRONLY, O_CREAT);
|
|
|
+ ssize_t bytes = write(fd, Y[0]->GetArr(), Y[0]->GetSize());
|
|
|
+ std::cout << "bytes = " << bytes << std::endl;
|
|
|
+ close(fd);
|
|
|
+
|
|
|
+ int fd2 = open("./x1", O_WRONLY, O_CREAT);
|
|
|
+ ssize_t bytes2 = write(fd2, X1.GetArr(), X1.GetSize());
|
|
|
+ std::cout << "bytes = " << bytes2 << std::endl;
|
|
|
+ close(fd2);
|
|
|
+
|
|
|
+ int fd3 = open("./gamma1", O_WRONLY, O_CREAT);
|
|
|
+ ssize_t bytes3 = write(fd3, response.GetArr(), response.GetSize());
|
|
|
+ std::cout << "bytes = " << bytes3 << std::endl;
|
|
|
+ close(fd3);
|
|
|
+
|
|
|
+ std::cout << "X1: \n\n";
|
|
|
+ X1.PrintHex();
|
|
|
+
|
|
|
gammafile1.open ("gamma1.txt", std::ios::out);
|
|
|
X1file.open("X1.txt", std::ios::out);
|
|
|
Y1file.open("Y1.txt", std::ios::out);
|
|
|
- for(size_t j = 0; j < n_OTS; ++j)
|
|
|
+ for(size_t j = 0; j < numots; ++j)
|
|
|
{
|
|
|
// std::cout << (int) response.GetBitNoMask(j);
|
|
|
gammafile1 << (int) response.GetBitNoMask(j);
|
|
@@ -327,7 +363,10 @@ int main(int argc, char **argv)
|
|
|
// }
|
|
|
|
|
|
//Determines whether the program is executed in the sender or receiver role
|
|
|
- m_nPID = atoi(argv[3]);
|
|
|
+ m_nPID = atoi(argv[3]);
|
|
|
+ int64_t nblindbits = atoi(argv[4]);
|
|
|
+
|
|
|
+
|
|
|
std::cout << "Playing as role: " << m_nPID << std::endl;
|
|
|
assert(m_nPID >= 0 && m_nPID <= 1);
|
|
|
|
|
@@ -342,14 +381,15 @@ int main(int argc, char **argv)
|
|
|
|
|
|
// NOTE: This vector controls the settings used by the oblivious transfer.
|
|
|
test_options selected_options; // = {IKNP, 128, 1, Snd_C_OT, Rec_OT, 1, ECC_FIELD, false};
|
|
|
- selected_options.prot = IKNP;
|
|
|
- selected_options.numots = n_OTS; // Number of OTs performed using the extended COT.
|
|
|
- selected_options.bitlen = 1;
|
|
|
- selected_options.sflavor = Snd_OT; //Snd_C_OT;
|
|
|
- selected_options.rflavor = Rec_OT;
|
|
|
+ selected_options.prot = IKNP;
|
|
|
+ selected_options.numots = nblindbits; // Number of OTs performed using the extended COT.
|
|
|
+ selected_options.bitlen = 1;
|
|
|
+ selected_options.sflavor = Snd_OT; //Snd_C_OT;
|
|
|
+ selected_options.rflavor = Rec_OT;
|
|
|
selected_options.nthreads = 1; // Number of threads
|
|
|
- selected_options.ftype = P_FIELD; // Type of field to use for the base OT.
|
|
|
- selected_options.usemecr = false;
|
|
|
+ selected_options.ftype = P_FIELD; // Type of field to use for the base OT.
|
|
|
+ selected_options.usemecr = false;
|
|
|
+
|
|
|
// test_options selected_options = {IKNP, 128, 1, Snd_C_OT, Rec_OT, 1, P_FIELD, false}; // Alternative using P_FIELD
|
|
|
|
|
|
if (m_nPID == SERVER_ID) //Play as OT sender
|