123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- void concatanate_index(char const * filename, char tmp[100], size_t index)
- {
- strcpy(tmp, filename);
- strcat(tmp, std::to_string(index).c_str());
- }
- int read_final_correction_word(bool party, DB_t& FCW_read, int i = 0)
- {
- if(!party)
- {
- char tmp[100];
- concatanate_index("../duoram-online/preprocflags/FCW0", tmp, i);
- int const in0 { open(tmp, O_RDONLY ) };
- size_t r = read(in0, &FCW_read, sizeof(FCW_read));
- if(r < 0) perror("Read error");
- }
-
- if(party)
- {
- char tmp[100];
- concatanate_index("../duoram-online/preprocflags/FCW1", tmp, i);
- int const in0 { open(tmp, O_RDONLY ) };
- size_t r = read(in0, &FCW_read, sizeof(FCW_read));
- if(r < 0) perror("Read error");
- }
- return 0;
- }
- int read_rand_indx(bool party, DB_t& R, int i = 0)
- {
- if(!party)
- {
- char tmp[100];
- concatanate_index("../duoram-online/preprocflags/R0", tmp, i);
- int const in0 { open(tmp, O_RDONLY ) };
- size_t r = read(in0, &R, sizeof(R));
- if(r < 0) perror("Read error");
- }
-
- if(party)
- {
- char tmp[100];
- concatanate_index("../duoram-online/preprocflags/R1", tmp, i);
- int const in0 { open(tmp, O_RDONLY ) };
- size_t r = read(in0, &R, sizeof(R));
- if(r < 0) perror("Read error");
- }
- return 0;
- }
- int read_flags_for_reading(bool party, size_t db_nitems, int i = 0)
- {
- if(!party)
- {
- char tmp[100];
- concatanate_index("../duoram-online/preprocflags/party0_read_flags_b", tmp, i);
- int const in0 { open(tmp, O_RDONLY ) };
- size_t r = read(in0, reading_b, db_nitems * sizeof(reading_b[0]));
- if(r < 0) perror("Read error");
-
- concatanate_index("../duoram-online/preprocflags/party0_read_flags_c", tmp, i);
- int const in1 { open( tmp, O_RDONLY ) };
- r = read(in1, reading_c, db_nitems * sizeof(reading_c[0]));
- if(r < 0) perror("Read error");
- concatanate_index("../duoram-online/preprocflags/party0_read_flags_d", tmp, i);
- int const in2 { open( tmp, O_RDONLY ) };
- r = read(in2, reading_d, db_nitems * sizeof(reading_d[0]));
- if(r < 0) perror("Read error");
- }
- if(party)
- {
- char tmp[100];
-
- concatanate_index("../duoram-online/preprocflags/party1_read_flags_b", tmp, i);
- int const in0 { open(tmp, O_RDONLY ) };
- size_t r = read(in0, reading_b, db_nitems * sizeof(reading_b[0]));
- if(r < 0) perror("Read error");
- concatanate_index("../duoram-online/preprocflags/party1_read_flags_c", tmp, i);
- int const in1 { open(tmp, O_RDONLY ) };
- r = read(in1, reading_c, db_nitems * sizeof(reading_c[0]));
- if(r < 0) perror("Read error");
-
- concatanate_index("../duoram-online/preprocflags/party1_read_flags_d", tmp, i);
- int const in2 { open(tmp, O_RDONLY ) };
- r = read(in2, reading_d, db_nitems * sizeof(reading_d[0]));
- if(r < 0) perror("Read error");
- }
-
- return 0;
- }
- int read_flags_for_writing(bool party, size_t db_nitems, int i = 0)
- {
- if(!party)
- {
- char tmp[100];
- concatanate_index("../duoram-online/preprocflags/party0_write_flags_b", tmp, i);
- int const in0_w { open(tmp, O_RDONLY ) };
- size_t r = read(in0_w, writing_b, db_nitems * sizeof(writing_b[0]));
- if(r < 0) perror("Read error");
- concatanate_index("../duoram-online/preprocflags/party0_write_flags_c", tmp,i);
- int const in1_w { open( tmp, O_RDONLY ) };
- r = read(in1_w, writing_c, db_nitems * sizeof(writing_c[0]));
- if(r < 0) perror("Read error");
-
- concatanate_index("../duoram-online/preprocflags/party0_write_flags_d", tmp,i);
- int const in2_w { open( tmp, O_RDONLY ) };
- r = read(in2_w, writing_d, db_nitems * sizeof(writing_d[0]));
- if(r < 0) perror("Read error");
- }
- if(party)
- {
- char tmp[100];
- concatanate_index("../duoram-online/preprocflags/party1_write_flags_b", tmp,i);
- int const in0_w { open( tmp, O_RDONLY ) };
- size_t r = read(in0_w, writing_b, db_nitems * sizeof(writing_b[0]));
- if(r < 0) perror("Read error");
- concatanate_index("../duoram-online/preprocflags/party1_write_flags_c", tmp, i);
- int const in1_w { open(tmp, O_RDONLY ) };
- r = read(in1_w, writing_c, db_nitems * sizeof(writing_c[0]));
- if(r < 0) perror("Read error");
- concatanate_index("../duoram-online/preprocflags/party1_write_flags_d", tmp, i);
- int const in2_w { open( tmp, O_RDONLY ) };
- r = read(in2_w, writing_d, db_nitems * sizeof(writing_d[0]));
- if(r < 0) perror("Read error");
- }
- return 0;
- }
- int read_flags_for_refreshing(size_t db_nitems, int i = 0)
- {
- char tmp[100];
- concatanate_index("../duoram-online/preprocflags/P2_party0_write_flags_c", tmp, i);
- int const in1_w { open(tmp, O_RDONLY ) };
- size_t r = read(in1_w, writing_c, db_nitems * sizeof(writing_c[0]));
- if(r < 0) perror("Read error");
-
- concatanate_index("../duoram-online/preprocflags/P2_party1_write_flags_d", tmp, i);
- int const in2_w { open(tmp, O_RDONLY ) };
- r = read(in2_w, writing_d, db_nitems * sizeof(writing_d[0]));
- if(r < 0) perror("Read error");
- concatanate_index("../duoram-online/preprocflags/P2_party0_write_c", tmp, i);
- int const in1_w_ { open(tmp, O_RDONLY ) };
- r = read(in1_w_, c, db_nitems * sizeof(c[0]));
- if(r < 0) perror("Read error");
-
- concatanate_index("../duoram-online/preprocflags/P2_party1_write_d", tmp, i);
- int const in2_w_ { open(tmp, O_RDONLY ) };
- r = read(in2_w_, d, db_nitems * sizeof(d[0]));
- if(r < 0) perror("Read error");
- return 0;
- }
- int read_flags_for_generating_cancellation_terms(size_t db_nitems, int i = 0)
- {
- char tmp[100];
- concatanate_index("../duoram-online/preprocflags/P2_party1_read_flags_d", tmp, i);
- int const in2 { open(tmp, O_RDONLY ) };
- size_t r = read(in2, reading_d, db_nitems * sizeof(reading_d[0]));
- if(r < 0) perror("Read error");
- concatanate_index("../duoram-online/preprocflags/P2_party0_read_flags_c", tmp, i);
- int const in2_ { open(tmp, O_RDONLY ) };
- r = read(in2_, reading_c, db_nitems * sizeof(reading_c[0]));
- if(r < 0) perror("Read error");
-
- return 0;
- }
- int read_flags_for_updating(bool party, size_t db_nitems, int i = 0)
- {
- char tmp[100];
- if(!party)
- {
- concatanate_index("../duoram-online/preprocflags/party0_write_b", tmp, i);
- int const in0_w_ { open(tmp, O_RDONLY ) };
- size_t r = read(in0_w_, b, db_nitems * sizeof(b[0]));
- if(r < 0) perror("Read error");
-
- concatanate_index("../duoram-online/preprocflags/party0_write_c", tmp, i);
- int const in1_w_ { open(tmp, O_RDONLY ) };
- r = read(in1_w_, c, db_nitems * sizeof(c[0]));
- if(r < 0) perror("Read error");
- concatanate_index("../duoram-online/preprocflags/party0_write_d", tmp, i);
- int const in2_w_ { open(tmp, O_RDONLY ) };
- r = read(in2_w_, d, db_nitems * sizeof(d[0]));
- if(r < 0) perror("Read error");
- }
- if(party)
- {
- concatanate_index("../duoram-online/preprocflags/party1_write_b", tmp, i);
- int const in0_w_ { open( tmp, O_RDONLY ) };
- size_t r = read(in0_w_, b, db_nitems * sizeof(b[0]));
- if(r < 0) perror("Read error");
-
- concatanate_index("../duoram-online/preprocflags/party1_write_c", tmp, i);
- int const in1_w_ { open(tmp, O_RDONLY ) };
- r = read(in1_w_, c, db_nitems * sizeof(c[0]));
- if(r < 0) perror("Read error");
- concatanate_index("../duoram-online/preprocflags/party1_write_d", tmp, i);
- int const in2_w_ { open(tmp, O_RDONLY ) };
- r = read(in2_w_, d, db_nitems * sizeof(d[0]));
- if(r < 0) perror("Read error");
- }
-
- return 0;
- }
|