obliv.hpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef __OBLIV_HPP__
  2. #define __OBLIV_HPP__
  3. #include <vector>
  4. // Routines for processing private data obliviously
  5. // Obliviously tally the number of messages in the given buffer destined
  6. // for each storage node. Each message is of size msg_size bytes.
  7. // There are num_msgs messages in the buffer. There are
  8. // num_storage_nodes storage nodes in total. The destination storage
  9. // node of each message is determined by looking at the top
  10. // DEST_STORAGE_NODE_BITS bits of the (little-endian) 32-bit word at the
  11. // beginning of the message; this will be a number between 0 and
  12. // num_storage_nodes-1, which is not necessarily the node number of the
  13. // storage node, which may be larger if, for example, there are a bunch
  14. // of routing or ingestion nodes that are not also storage nodes. The
  15. // return value is a vector of length num_storage_nodes containing the
  16. // tally.
  17. std::vector<uint32_t> obliv_tally_stg(const uint8_t *buf,
  18. uint32_t msg_size, uint32_t num_msgs, uint32_t num_storage_nodes);
  19. // Obliviously create padding messages destined for the various storage
  20. // nodes, using the (private) counts in the tally vector. The tally
  21. // vector may be modified by this function. tot_padding must be the sum
  22. // of the elements in tally, which need _not_ be private.
  23. void obliv_pad_stg(uint8_t *buf, uint32_t msg_size,
  24. std::vector<uint32_t> &tally, uint32_t tot_padding);
  25. // Obliviously determine the number of messages exceeding the maximum that can
  26. // be sent to a storage server.
  27. std::vector<uint32_t> obliv_excess_stg(std::vector<uint32_t> &tally,
  28. nodenum_t num_storage_nodes, uint32_t msgs_per_stg);
  29. // Obliviously determine the number of messages under the maximum that can
  30. // be sent to a storage server.
  31. std::vector<uint32_t> obliv_padding_stg(std::vector<uint32_t> &tally,
  32. nodenum_t num_storage_nodes, uint32_t msgs_per_stg);
  33. void obliv_excess_to_padding(uint8_t *buf, uint32_t msg_size, uint32_t num_msgs,
  34. std::vector<uint32_t> &excess, std::vector<uint32_t> &padding,
  35. std::vector<uint32_t> &tally, nodenum_t num_storage_nodes);
  36. #endif