int main(int argc, char** argv) { string* addr = new string("127.0.0.1"); uint16_t port = 7766; //Determines whether the program is executed in the sender or receiver role m_nPID = atoi(argv[1]); //the number of OTs that are performed. Has to be initialized to a certain minimum size due to uint64_t numOTs = 1000000; //bitlength of the values that are transferred - NOTE that when bitlength is not 1 or a multiple of 8, the endianness has to be observed uint32_t bitlength = 8; uint32_t runs = 1; //Use elliptic curve cryptography in the base-OTs m_eFType = ECC_FIELD; //The symmetric security parameter (80, 112, 128) uint32_t m_nSecParam = 128; //Number of threads that will be used in OT extension m_nNumOTThreads = 1; //Specifies which OT flavor should be used snd_ot_flavor stype = Snd_OT; rec_ot_flavor rtype = Rec_OT; m_nBaseOTs = 190; m_nChecks = 380; m_bUseMinEntCorAssumption = false; m_eProt = IKNP; read_test_options(&argc, &argv, &m_nPID, &numOTs, &bitlength, &m_nSecParam, addr, &port, &m_eProt, &stype, &rtype, &m_nNumOTThreads, &m_nBaseOTs, &m_nChecks, &m_bUseMinEntCorAssumption, &runs); /*int32_t read_test_options(int32_t* argcp, char*** argvp, uint32_t* role, uint64_t* numots, uint32_t* bitlen, uint32_t* secparam, string* address, uint16_t* port, ot_ext_prot* protocol, snd_ot_flavor* sndflav, rec_ot_flavor* rcvflav, uint32_t* nthreads, uint32_t* nbaseots, uint32_t* nchecks, bool* usemecr, uint32_t* runs) {*/ crypto *crypt = new crypto(m_nSecParam, (uint8_t*) m_cConstSeed[m_nPID]); if(m_nPID == SERVER_ID) //Play as OT sender { InitOTSender(addr->c_str(), port, crypt); CBitVector delta, X1, X2; //The masking function with which the values that are sent in the last communication step are processed m_fMaskFct = new XORMasking(bitlength, delta); //creates delta as an array with "numOTs" entries of "bitlength" bit-values and fills delta with random values delta.Create(numOTs, bitlength, crypt); //Create X1 and X2 as two arrays with "numOTs" entries of "bitlength" bit-values and resets them to 0 X1.Create(numOTs, bitlength, crypt); X2.Create(numOTs, bitlength, crypt); #ifndef BATCH cout << getProt(m_eProt) << " Sender performing " << numOTs << " " << getSndFlavor(stype) << " / " << getRecFlavor(rtype) << " extensions on " << bitlength << " bit elements with " << m_nNumOTThreads << " threads, " << getFieldType(m_eFType) << " and" << (m_bUseMinEntCorAssumption ? "": " no" ) << " min-ent-corr-robustness " << runs << " times" << endl; #endif for(uint32_t i = 0; i < runs; i++) { ObliviouslySend(X1, X2, numOTs, bitlength, stype, rtype, crypt); } } else //Play as OT receiver { InitOTReceiver(addr->c_str(), port, crypt); CBitVector choices, response; //The masking function with which the values that are sent in the last communication step are processed m_fMaskFct = new XORMasking(bitlength); //Create the bitvector choices as a bitvector with numOTs entries choices.Create(numOTs, crypt); //Pre-generate the respose vector for the results response.Create(numOTs, bitlength); response.Reset(); /* * The inputs of the receiver in G_OT, C_OT and R_OT are the same. The only difference is the version * variable that has to match the version of the sender. */ #ifndef BATCH cout << getProt(m_eProt) << " Receiver performing " << numOTs << " " << getSndFlavor(stype) << " / " << getRecFlavor(rtype) << " extensions on " << bitlength << " bit elements with " << m_nNumOTThreads << " threads, " << getFieldType(m_eFType) << " and" << (m_bUseMinEntCorAssumption ? "": " no" ) << " min-ent-corr-robustness " << runs << " times" << endl; #endif for(uint32_t i = 0; i < runs; i++) { ObliviouslyReceive(choices, response, numOTs, bitlength, stype, rtype, crypt); } } //Cleanup(); delete crypt; return 1; }
int main(int argc, char **argv) { const char *addr = "127.0.0.1"; int port = 7766; if (argc != 2) { cout << "Please call with 0 if acting as server or 1 if acting as client" << endl; return 0; } // Determines whether the program is executed in the sender or receiver role m_nPID = atoi(argv[1]); cout << "Playing as role: " << m_nPID << endl; assert(m_nPID >= 0 && m_nPID <= 1); // The symmetric security parameter (80, 112, 128) uint32_t m_nSecParam = 128; crypto *crypt = new crypto(m_nSecParam, (uint8_t *)m_cConstSeed[m_nPID]); uint32_t m_nBaseOTs = 190; uint32_t m_nChecks = 380; ot_ext_prot lastprot = PROT_LAST; field_type lastfield = FIELD_LAST; if (m_nPID == SERVER_ID) // Play as OT sender { InitSender(addr, port); OTExtSnd *sender = NULL; for (uint32_t i = 0; i < m_nTests; i++) { if (lastprot != tests[i].prot || lastfield != tests[i].ftype) { // if(sender) delete sender; sender = InitOTExtSnd(tests[i].prot, m_nBaseOTs, m_nChecks, tests[i].usemecr, tests[i].ftype, crypt); lastprot = tests[i].prot; lastfield = tests[i].ftype; } cout << "Test " << i << ": " << getProt(tests[i].prot) << " Sender " << tests[i].numots << " " << getSndFlavor(tests[i].sflavor) << " / " << getRecFlavor(tests[i].rflavor) << " on " << tests[i].bitlen << " bits with " << tests[i].nthreads << " threads, " << getFieldType(tests[i].ftype) << " and" << (tests[i].usemecr ? "" : " no") << " MECR" << endl; run_test_sender(tests[i].numots, tests[i].bitlen, tests[i].sflavor, tests[i].rflavor, tests[i].nthreads, crypt, sender); } delete sender; } else // Play as OT receiver { InitReceiver(addr, port); OTExtRec *receiver = NULL; for (uint32_t i = 0; i < m_nTests; i++) { if (lastprot != tests[i].prot || lastfield != tests[i].ftype) { // if(receiver) delete receiver; receiver = InitOTExtRec(tests[i].prot, m_nBaseOTs, m_nChecks, tests[i].usemecr, tests[i].ftype, crypt); lastprot = tests[i].prot; lastfield = tests[i].ftype; } cout << "Test " << i << ": " << getProt(tests[i].prot) << " Receiver " << tests[i].numots << " " << getSndFlavor(tests[i].sflavor) << " / " << getRecFlavor(tests[i].rflavor) << " on " << tests[i].bitlen << " bits with " << tests[i].nthreads << " threads, " << getFieldType(tests[i].ftype) << " and" << (tests[i].usemecr ? "" : " no") << " MECR" << endl; run_test_receiver(tests[i].numots, tests[i].bitlen, tests[i].sflavor, tests[i].rflavor, tests[i].nthreads, crypt, receiver); } delete receiver; } Cleanup(); delete crypt; return 1; }