coefficient_conversion_test.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "pir.hpp"
  2. #include "pir_client.hpp"
  3. #include "pir_server.hpp"
  4. #include <bitset>
  5. #include <chrono>
  6. #include <cstddef>
  7. #include <cstdint>
  8. #include <memory>
  9. #include <random>
  10. #include <seal/seal.h>
  11. using namespace std::chrono;
  12. using namespace std;
  13. using namespace seal;
  14. int main(int argc, char *argv[]) {
  15. const uint32_t logt = 16;
  16. const uint32_t ele_size = 3;
  17. const uint32_t num_ele = 3;
  18. uint8_t bytes[ele_size * num_ele] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
  19. vector<uint64_t> coeffs;
  20. cout << "Coeffs: " << endl;
  21. for (int i = 0; i < num_ele; i++) {
  22. vector<uint64_t> ele_coeffs =
  23. bytes_to_coeffs(logt, bytes + (i * ele_size), ele_size);
  24. for (int j = 0; j < ele_coeffs.size(); j++) {
  25. cout << ele_coeffs[j] << endl;
  26. cout << std::bitset<logt>(ele_coeffs[j]) << endl;
  27. coeffs.push_back(ele_coeffs[j]);
  28. }
  29. }
  30. cout << "Num of Coeffs: " << coeffs.size() << endl;
  31. uint8_t output[ele_size * num_ele];
  32. coeffs_to_bytes(logt, coeffs, output, ele_size * num_ele, ele_size);
  33. cout << "Bytes: " << endl;
  34. for (int i = 0; i < ele_size * num_ele; i++) {
  35. cout << (int)output[i] << endl;
  36. }
  37. return 0;
  38. }