123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385 |
- /**
- * @brief The function writes the flag vectors into /preprocflags/ directory in duoram-online
- *
- * @param party
- * @param i
- * @param db_nitems
- * @param flags
- * @param outs_
- * @param final_correction_word
- */
- void write_evalfull_outs_into_a_file(bool party, size_t i, size_t db_nitems, int8_t * flags, int64_t * outs_, __m128i final_correction_word, int64_t additve_sharesR)
- {
- if(!party)
- {
- char const * p0_filename0;
- char tmp[100];
- p0_filename0 = "../duoram-online/preprocflags/party0_read_flags_b";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- int w0 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- int written = write(w0, flags, db_nitems * sizeof(flags[0]));
- if(written<0) perror("Write error");
- close(w0);
- p0_filename0 = "../duoram-online/preprocflags/party0_read_flags_c";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- int w1 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w1, flags, db_nitems * sizeof(flags[0]));
- if(written<0) perror("Write error");
- close(w1);
-
- p0_filename0 = "../duoram-online/preprocflags/party0_read_flags_d";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- int w2 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w2, flags, db_nitems * sizeof(flags[0]));
- if(written<0) perror("Write error");
- close(w2);
- p0_filename0 = "../duoram-online/preprocflags/party0_write_flags_b";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- int w4 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w4, flags, db_nitems * sizeof(flags[0]));
- if(written<0) perror("Write error");
- close(w4);
- p0_filename0 = "../duoram-online/preprocflags/party0_write_flags_c";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- int w5 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w5, flags, db_nitems * sizeof(flags[0]));
- if(written<0) perror("Write error");
- close(w5);
-
- p0_filename0 = "../duoram-online/preprocflags/party0_write_flags_d";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- int w6 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w6, flags, db_nitems * sizeof(flags[0]));
- if(written<0) perror("Write error");
- close(w6);
- p0_filename0 = "../duoram-online/preprocflags/party0_write_b";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- w4 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w4, outs_, db_nitems * sizeof(outs_[0]));
- if(written<0) perror("Write error");
- close(w4);
- p0_filename0 = "../duoram-online/preprocflags/party0_write_c";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- w5 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w5, outs_, db_nitems * sizeof(outs_[0]));
- if(written<0) perror("Write error");
- close(w5);
- p0_filename0 = "../duoram-online/preprocflags/party0_write_d";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- w6 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w6, outs_, db_nitems * sizeof(outs_[0]));
- if(written<0) perror("Write error");
- close(w6);
- }
- if(party)
- {
- char const * p0_filename0;
- char tmp[100];
- p0_filename0 = "../duoram-online/preprocflags/party1_read_flags_b";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- int w0 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- int written = write(w0, flags, db_nitems * sizeof(flags[0]));
- if(written<0) perror("Write error");
- close(w0);
- p0_filename0 = "../duoram-online/preprocflags/party1_read_flags_c";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- int w1 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w1, flags, db_nitems * sizeof(flags[0]));
- if(written<0) perror("Write error");
- close(w1);
- p0_filename0 = "../duoram-online/preprocflags/party1_read_flags_d";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- int w2 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w2,flags, db_nitems * sizeof(flags[0]));
- if(written<0) perror("Write error");
- close(w2);
- p0_filename0 = "../duoram-online/preprocflags/party1_write_flags_b";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- int w4 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w4,flags, db_nitems * sizeof(flags[0]));
- if(written<0) perror("Write error");
- close(w4);
- p0_filename0 = "../duoram-online/preprocflags/party1_write_flags_c";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- int w5 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w5, flags, db_nitems * sizeof(flags[0]));
- if(written<0) perror("Write error");
- close(w5);
-
- p0_filename0 = "../duoram-online/preprocflags/party1_write_flags_d";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- int w6 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w6, flags, db_nitems * sizeof(flags[0]));
- if(written<0) perror("Write error");
- close(w6);
- p0_filename0 = "../duoram-online/preprocflags/party1_write_b";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- w4 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w4, outs_, db_nitems * sizeof(outs_[0]));
- if(written<0) perror("Write error");
- close(w4);
- p0_filename0 = "../duoram-online/preprocflags/party1_write_c";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- w5 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w5, outs_, db_nitems * sizeof(outs_[0]));
- if(written<0) perror("Write error");
- close(w5);
-
- p0_filename0 = "../duoram-online/preprocflags/party1_write_d";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- w6 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w6, outs_, db_nitems * sizeof(outs_[0]));
- if(written<0) perror("Write error");
- close(w6);
- }
- if(party)
- {
- char const * p1_filename0;
- char tmp[100];
- p1_filename0 = "../duoram-online/preprocflags/FCW1";
- strcpy(tmp, p1_filename0);
- strcat(tmp, std::to_string(i).c_str());
-
- int w0 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- int written = write(w0, &final_correction_word[0], sizeof(uint64_t));
- if(written<0) perror("Write error");
- close(w0);
-
- p1_filename0 = "../duoram-online/preprocflags/R1";
- strcpy(tmp, p1_filename0);
- strcat(tmp, std::to_string(i).c_str());
-
- w0 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w0, &additve_sharesR, sizeof(int64_t));
- if(written<0) perror("Write error");
- close(w0);
- }
-
- if(!party)
- {
- char const * p0_filename0;
- char tmp[100];
- p0_filename0 = "../duoram-online/preprocflags/FCW0";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
-
- int w0 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- int written = write(w0, &final_correction_word[0], sizeof(uint64_t));
- if(written<0) perror("Write error");
- close(w0);
- p0_filename0 = "../duoram-online/preprocflags/R0";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
-
- w0 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w0, &additve_sharesR, sizeof(int64_t));
- if(written<0) perror("Write error");
- close(w0);
- }
-
- }
- void P2_write_evalfull_outs_into_a_file(bool party, size_t i, size_t db_nitems, int8_t * flags, int64_t * outs_)
- {
- if(!party)
- {
- char const * p0_filename0;
- char tmp[100];
- p0_filename0 = "../duoram-online/preprocflags/P2_party0_read_flags_b";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
-
- int w0 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- int written = write(w0, flags, db_nitems * sizeof(flags[0]));
- if(written<0) perror("Write error");
- close(w0);
- p0_filename0 = "../duoram-online/preprocflags/P2_party0_read_flags_c";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- int w1 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w1, flags, db_nitems * sizeof(flags[0]));
- if(written<0) perror("Write error");
- close(w1);
-
- p0_filename0 = "../duoram-online/preprocflags/P2_party0_read_flags_d";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- int w2 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w2, flags, db_nitems * sizeof(flags[0]));
- if(written<0) perror("Write error");
- close(w2);
- p0_filename0 = "../duoram-online/preprocflags/P2_party0_write_flags_b";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- int w4 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w4, flags, db_nitems * sizeof(flags[0]));
- if(written<0) perror("Write error");
- close(w4);
- p0_filename0 = "../duoram-online/preprocflags/P2_party0_write_flags_c";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- int w5 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w5, flags, db_nitems * sizeof(flags[0]));
- if(written<0) perror("Write error");
- close(w5);
-
- p0_filename0 = "../duoram-online/preprocflags/P2_party0_write_flags_d";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- int w6 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w6, flags, db_nitems * sizeof(flags[0]));
- if(written<0) perror("Write error");
- close(w6);
- p0_filename0 = "../duoram-online/preprocflags/P2_party0_write_b";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- w4 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w4, outs_, db_nitems * sizeof(outs_[0]));
- if(written<0) perror("Write error");
- close(w4);
- p0_filename0 = "../duoram-online/preprocflags/P2_party0_write_c";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- w5 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w5, outs_, db_nitems * sizeof(outs_[0]));
- if(written<0) perror("Write error");
- close(w5);
- p0_filename0 = "../duoram-online/preprocflags/P2_party0_write_d";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- w6 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w6, outs_, db_nitems * sizeof(outs_[0]));
- if(written<0) perror("Write error");
- close(w6);
- }
-
- if(party)
- {
- char const * p0_filename0;
- char tmp[100];
- p0_filename0 = "../duoram-online/preprocflags/P2_party1_read_flags_b";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
-
- int w0 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- int written = write(w0, flags, db_nitems * sizeof(flags[0]));
- if(written<0) perror("Write error");
- close(w0);
- p0_filename0 = "../duoram-online/preprocflags/P2_party1_read_flags_c";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- int w1 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w1, flags, db_nitems * sizeof(flags[0]));
- if(written<0) perror("Write error");
- close(w1);
- p0_filename0 = "../duoram-online/preprocflags/P2_party1_read_flags_d";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- int w2 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w2,flags, db_nitems * sizeof(flags[0]));
- if(written<0) perror("Write error");
- close(w2);
- p0_filename0 = "../duoram-online/preprocflags/P2_party1_write_flags_b";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- int w4 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w4,flags, db_nitems * sizeof(flags[0]));
- if(written<0) perror("Write error");
- close(w4);
- p0_filename0 = "../duoram-online/preprocflags/P2_party1_write_flags_c";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- int w5 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w5, flags, db_nitems * sizeof(flags[0]));
- if(written<0) perror("Write error");
- close(w5);
-
- p0_filename0 = "../duoram-online/preprocflags/P2_party1_write_flags_d";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- int w6 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w6, flags, db_nitems * sizeof(flags[0]));
- if(written<0) perror("Write error");
- close(w6);
- p0_filename0 = "../duoram-online/preprocflags/P2_party1_write_b";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- w4 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w4, outs_, db_nitems * sizeof(outs_[0]));
- if(written<0) perror("Write error");
- close(w4);
- //char const * p0_filename0;
- p0_filename0 = "../duoram-online/preprocflags/P2_party1_write_c";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- w5 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w5, outs_, db_nitems * sizeof(outs_[0]));
- if(written<0) perror("Write error");
- close(w5);
-
- p0_filename0 = "../duoram-online/preprocflags/P2_party1_write_d";
- strcpy(tmp, p0_filename0);
- strcat(tmp, std::to_string(i).c_str());
- w6 = open( tmp, O_WRONLY | O_APPEND | O_CREAT, S_IWRITE | S_IREAD);
- written = write(w6, outs_, db_nitems * sizeof(outs_[0]));
- if(written<0) perror("Write error");
- close(w6);
- }
- }
|