duoram-write.h 1.0 KB

123456789101112131415161718192021222324
  1. void write_into_the_database(DB_t DB[], DB_t updated_DB[], int8_t flags[], DB_t b[], DB_t final_CW, bool party, size_t db_nitems, size_t rotate_by = 0)
  2. {
  3. for(size_t j = 0; j < db_nitems; ++j)
  4. {
  5. const size_t ind = (j + rotate_by) % db_nitems;
  6. DB_t tmp = (flags[ind] * final_CW);
  7. DB[j] = DB[j] + b[ind] + tmp;
  8. updated_DB[j] = DB[j];
  9. }
  10. }
  11. auto DuoramUpdate( bool party, size_t db_nitems, size_t rotate_by_,
  12. DB_t DB[], DB_t updated_DB[], int8_t writing_b[], DB_t b[], DB_t final_CW, DB_t message,
  13. int8_t writing_c[], int8_t writing_d[], DB_t c[], DB_t d[])
  14. {
  15. read_flags_for_updating(party, db_nitems);
  16. write_into_the_database(DB, updated_DB, writing_b, b, final_CW, party, db_nitems, - rotate_by_);
  17. #ifdef ThreeParty
  18. if(!party) duoram_refresh(writing_b, writing_c, writing_d, b, c, d, final_CW, party, db_nitems, -rotate_by_);
  19. if( party) duoram_refresh(writing_b, writing_d, writing_c, b, d, c, final_CW, party, db_nitems, -rotate_by_);
  20. #endif
  21. }