kyber512r3_poly.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #pragma once
  2. #include <stdint.h>
  3. #include "kyber512r3_params.h"
  4. /*
  5. * Elements of R_q = Z_q[X]/(X^n + 1). Represents polynomial
  6. * coeffs[0] + X*coeffs[1] + X^2*xoeffs[2] + ... + X^{n-1}*coeffs[n-1]
  7. */
  8. #define poly S2N_KYBER_512_R3_NAMESPACE(poly)
  9. typedef struct {
  10. int16_t coeffs[S2N_KYBER_512_R3_N];
  11. } poly;
  12. #define poly_compress S2N_KYBER_512_R3_NAMESPACE(poly_compress)
  13. void poly_compress(uint8_t r[S2N_KYBER_512_R3_POLYCOMPRESSEDBYTES], poly *a);
  14. #define poly_decompress S2N_KYBER_512_R3_NAMESPACE(poly_decompress)
  15. void poly_decompress(poly *r, const uint8_t a[S2N_KYBER_512_R3_POLYCOMPRESSEDBYTES]);
  16. #define poly_tobytes S2N_KYBER_512_R3_NAMESPACE(poly_tobytes)
  17. void poly_tobytes(uint8_t r[S2N_KYBER_512_R3_POLYBYTES], poly *a);
  18. #define poly_frombytes S2N_KYBER_512_R3_NAMESPACE(poly_frombytes)
  19. void poly_frombytes(poly *r, const uint8_t a[S2N_KYBER_512_R3_POLYBYTES]);
  20. #define poly_frommsg S2N_KYBER_512_R3_NAMESPACE(poly_frommsg)
  21. void poly_frommsg(poly *r, const uint8_t msg[S2N_KYBER_512_R3_INDCPA_MSGBYTES]);
  22. #define poly_tomsg S2N_KYBER_512_R3_NAMESPACE(poly_tomsg)
  23. void poly_tomsg(uint8_t msg[S2N_KYBER_512_R3_INDCPA_MSGBYTES], poly *r);
  24. #define poly_getnoise_eta1 S2N_KYBER_512_R3_NAMESPACE(poly_getnoise_eta1)
  25. void poly_getnoise_eta1(poly *r, const uint8_t seed[S2N_KYBER_512_R3_SYMBYTES], uint8_t nonce);
  26. #define poly_getnoise_eta2 S2N_KYBER_512_R3_NAMESPACE(poly_getnoise_eta2)
  27. void poly_getnoise_eta2(poly *r, const uint8_t seed[S2N_KYBER_512_R3_SYMBYTES], uint8_t nonce);
  28. #define poly_ntt S2N_KYBER_512_R3_NAMESPACE(poly_ntt)
  29. void poly_ntt(poly *r);
  30. #define poly_invntt_tomont S2N_KYBER_512_R3_NAMESPACE(poly_invntt_tomont)
  31. void poly_invntt_tomont(poly *r);
  32. #define poly_basemul_montgomery S2N_KYBER_512_R3_NAMESPACE(poly_basemul_montgomery)
  33. void poly_basemul_montgomery(poly *r, const poly *a, const poly *b);
  34. #define poly_tomont S2N_KYBER_512_R3_NAMESPACE(poly_tomont)
  35. void poly_tomont(poly *r);
  36. #define poly_reduce S2N_KYBER_512_R3_NAMESPACE(poly_reduce)
  37. void poly_reduce(poly *r);
  38. #define poly_csubq S2N_KYBER_512_R3_NAMESPACE(poly_csubq)
  39. void poly_csubq(poly *r);
  40. #define poly_add S2N_KYBER_512_R3_NAMESPACE(poly_add)
  41. void poly_add(poly *r, const poly *a, const poly *b);
  42. #define poly_sub S2N_KYBER_512_R3_NAMESPACE(poly_sub)
  43. void poly_sub(poly *r, const poly *a, const poly *b);