spir.hpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef __SPIR_HPP__
  2. #define __SPIR_HPP__
  3. #include <string>
  4. #include <stdint.h>
  5. using std::string;
  6. class SPIR {
  7. public:
  8. typedef uint64_t DBEntry; // The type of each DB entry (64 bits)
  9. static void init(uint32_t nthreads); // Call this once at startup
  10. };
  11. class SPIR_Client {
  12. public:
  13. // constructor
  14. SPIR_Client(uint8_t r, string &pub_params); // 2^r records in the database; pub_params will be _filled in_
  15. // preprocessing
  16. string preproc_PIRs(uint32_t num_pirs); // returns the string to send to the server
  17. void preproc_handle(const string &server_preproc);
  18. // SPIR query for index idx
  19. string query(size_t idx); // returns the string to send to the server
  20. // process the server's response to yield the server's db[(idx + rot)%N] + blind
  21. // where N=2^r, idx is provided by the client above, and
  22. // db, rot, and blind are provided by the server below
  23. SPIR::DBEntry process_reply(const string &server_reply);
  24. };
  25. class SPIR_Server {
  26. public:
  27. // constructor
  28. SPIR_Server(uint8_t r, const string &client_pub_params);
  29. // preprocessing
  30. string preproc_PIR(const string &client_preproc); // returns the string to reply to the client
  31. // SPIR query on the given database of N=2^r records, each of type DBEntry
  32. // rotate the database by rot, and blind each entry in the database additively with blind
  33. // returns the string to reply to the client
  34. string process_query(const string &client_query, const SPIR::DBEntry *db,
  35. size_t rot, SPIR::DBEntry blind);
  36. };
  37. #endif