duoram-refresh.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * @brief This function is called by P2
  3. *
  4. * @param flags
  5. * @param standard_basis_vector
  6. * @param finalCW
  7. * @param party
  8. * @param db_nitems
  9. * @param rotate_by
  10. */
  11. void refresh_blinds(int8_t flags[], DB_t standard_basis_vector[], DB_t finalCW, bool party, size_t db_nitems, size_t rotate_by = 0)
  12. {
  13. DB_t tmp = 0;
  14. for(size_t j = 0; j < db_nitems; ++j)
  15. {
  16. tmp = (flags[(j + rotate_by) % db_nitems] != 0) ? finalCW : 0;
  17. if(party) updated_blinds[j] = blinds[j] - standard_basis_vector[(j + rotate_by) % db_nitems] - tmp;
  18. if(!party) updated_blinds[j] = blinds[j] - standard_basis_vector[(j + rotate_by) % db_nitems] + tmp;
  19. }
  20. }
  21. void refresh_blinded_vector_and_blinds(int8_t flags[], DB_t standard_basis_vector[], DB_t finalCW,int8_t flags0[], int8_t flags2[], DB_t b[], DB_t d[],
  22. bool party, size_t db_nitems, size_t rotate_by)
  23. {
  24. for(size_t j = 0; j < db_nitems; ++j)
  25. {
  26. updated_blinded_DB_recv[j] = blinded_DB_recv[j] - b[(j + rotate_by) % db_nitems] + d[(j + rotate_by) % db_nitems]
  27. - (flags0[(j + rotate_by) % db_nitems] * finalCW) + (flags2[(j + rotate_by) % db_nitems] * finalCW);
  28. blinds[j] = blinds[j] - standard_basis_vector[(j + rotate_by) % db_nitems] - (flags[(j + rotate_by) % db_nitems] * finalCW);
  29. }
  30. }
  31. void duoram_refresh (int8_t flags0[], int8_t flags1[], int8_t flags2[], DB_t b[], DB_t c[], DB_t d[], DB_t CW, bool party, size_t db_nitems, size_t rotate_by_ = 0)
  32. {
  33. refresh_blinded_vector_and_blinds(flags1, c, CW, flags0, flags2, b, d, party, db_nitems, rotate_by_);
  34. }