x25519.h 664 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include <stdint.h>
  2. #include <vector>
  3. #define KEYSIZE 32
  4. typedef uint8_t key25519[KEYSIZE];
  5. typedef uint64_t fe25519[5];
  6. struct ge25519
  7. {
  8. fe25519 X;
  9. fe25519 Y;
  10. fe25519 Z;
  11. fe25519 T;
  12. };
  13. class keys_block
  14. {
  15. public:
  16. keys_block(int size);
  17. void calculate_public_keys(const uint8_t random_bytes[KEYSIZE]);
  18. void get_public_key(key25519 public_key, int index) const;
  19. void get_private_key(key25519 private_key, int index) const;
  20. private:
  21. int key_bits[256];
  22. std::vector<ge25519> points;
  23. std::vector<fe25519> temp_z;
  24. std::vector<ge25519> state;
  25. };
  26. class base_powers
  27. {
  28. public:
  29. base_powers();
  30. const ge25519& get(int index);
  31. private:
  32. ge25519 data[255];
  33. };