coefficient_conversion_test.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "pir.hpp"
  2. #include "pir_client.hpp"
  3. #include "pir_server.hpp"
  4. #include <seal/seal.h>
  5. #include <chrono>
  6. #include <memory>
  7. #include <random>
  8. #include <cstdint>
  9. #include <cstddef>
  10. #include <bitset>
  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 = bytes_to_coeffs(logt, bytes + (i * ele_size), ele_size);
  23. for(int j = 0; j < ele_coeffs.size(); j++){
  24. cout << ele_coeffs[j] << endl;
  25. cout << std::bitset<logt>(ele_coeffs[j]) << endl;
  26. coeffs.push_back(ele_coeffs[j]);
  27. }
  28. }
  29. cout << "Num of Coeffs: " << coeffs.size() << endl;
  30. uint8_t output[ele_size * num_ele];
  31. coeffs_to_bytes(logt, coeffs, output, ele_size * num_ele, ele_size);
  32. cout << "Bytes: " << endl;
  33. for(int i = 0 ; i < ele_size * num_ele; i++){
  34. cout << (int)output[i] << endl;
  35. }
  36. return 0;
  37. }