ge_448.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* ge_448.h
  2. *
  3. * Copyright (C) 2006-2022 wolfSSL Inc.
  4. *
  5. * This file is part of wolfSSL.
  6. *
  7. * wolfSSL is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * wolfSSL is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  20. */
  21. #ifndef WOLF_CRYPT_GE_448_H
  22. #define WOLF_CRYPT_GE_448_H
  23. #include <wolfssl/wolfcrypt/settings.h>
  24. #ifdef HAVE_ED448
  25. #include <wolfssl/wolfcrypt/fe_448.h>
  26. /*
  27. ge448 means group element.
  28. Here the group is the set of pairs (x,y) of field elements (see fe.h)
  29. satisfying -x^2 + y^2 = 1 + d x^2y^2
  30. where d = -39081.
  31. Representations:
  32. ge448_p2 (projective) : (X:Y:Z) satisfying x=X/Z, y=Y/Z
  33. ge448_precomp (affine): (x,y)
  34. */
  35. #ifdef ED448_SMALL
  36. typedef byte ge448;
  37. #define GE448_WORDS 56
  38. #elif defined(CURVED448_128BIT)
  39. typedef sword64 ge448;
  40. #define GE448_WORDS 8
  41. #else
  42. typedef sword32 ge448;
  43. #define GE448_WORDS 16
  44. #endif
  45. typedef struct {
  46. ge448 X[GE448_WORDS];
  47. ge448 Y[GE448_WORDS];
  48. ge448 Z[GE448_WORDS];
  49. } ge448_p2;
  50. WOLFSSL_LOCAL int ge448_compress_key(byte* out, const byte* xIn, const byte* yIn);
  51. WOLFSSL_LOCAL int ge448_from_bytes_negate_vartime(ge448_p2 *r, const byte *b);
  52. WOLFSSL_LOCAL int ge448_double_scalarmult_vartime(ge448_p2 *r, const byte *a,
  53. const ge448_p2 *A, const byte *b);
  54. WOLFSSL_LOCAL void ge448_scalarmult_base(ge448_p2* h, const byte* a);
  55. WOLFSSL_LOCAL void sc448_reduce(byte* b);
  56. WOLFSSL_LOCAL void sc448_muladd(byte* r, const byte* a, const byte* b, const byte* d);
  57. WOLFSSL_LOCAL void ge448_to_bytes(byte *s, const ge448_p2 *h);
  58. #ifndef ED448_SMALL
  59. typedef struct {
  60. ge448 x[GE448_WORDS];
  61. ge448 y[GE448_WORDS];
  62. } ge448_precomp;
  63. #endif /* !ED448_SMALL */
  64. #endif /* HAVE_ED448 */
  65. #endif /* WOLF_CRYPT_GE_448_H */