You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

113 lines
2.5 KiB

  1. /* Copyright (c) 2014 Cryptography Research, Inc.
  2. * Released under the MIT License. See LICENSE.txt for license information.
  3. */
  4. #ifndef __P448_ALGO_H__
  5. #define __P448_ALGO_H__ 1
  6. #include "ec_point.h"
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. /*
  11. * Out = scalar * in, encoded in inverse square root
  12. * format.
  13. *
  14. * nbits is the number of bits in scalar.
  15. *
  16. * The scalar is to be presented in little-endian form,
  17. * meaning that scalar[0] contains the least significant
  18. * word of the scalar.
  19. *
  20. * If the point "in" is on the curve, the return
  21. * value will be set (to -1).
  22. *
  23. * If the point "in" is not on the curve, then the
  24. * output will be incorrect. If the scalar is even,
  25. * this condition will be detected by returning 0,
  26. * unless the output is the identity point (0; TODO).
  27. * If the scalar is odd, the value returned will be
  28. * set (to -1; TODO).
  29. *
  30. * The input and output points are always even.
  31. * Therefore on a cofactor-4 curve like Goldilocks,
  32. * it is sufficient for security to make the scalar
  33. * even. (TODO: detect when i/o has cofactor?)
  34. *
  35. * This function takes constant time, depending on
  36. * nbits but not on in or scalar.
  37. */
  38. mask_t
  39. p448_montgomery_ladder(
  40. struct p448_t *out,
  41. const struct p448_t *in,
  42. const uint64_t *scalar,
  43. int nbits,
  44. int n_extra_doubles
  45. );
  46. void
  47. edwards_scalar_multiply(
  48. struct tw_extensible_t *working,
  49. const uint64_t scalar[7]
  50. /* TODO? int nbits */
  51. );
  52. mask_t
  53. precompute_for_combs(
  54. struct tw_niels_t *out,
  55. const struct tw_extensible_t *const_base,
  56. int n,
  57. int t,
  58. int s
  59. );
  60. void
  61. edwards_comb(
  62. struct tw_extensible_t *working,
  63. const word_t scalar[7],
  64. const struct tw_niels_t *table,
  65. int n,
  66. int t,
  67. int s
  68. );
  69. /* TODO: void. int is just for diagnostic purposes. */
  70. int
  71. edwards_scalar_multiply_vt(
  72. struct tw_extensible_t *working,
  73. const uint64_t scalar[7]
  74. );
  75. void
  76. edwards_scalar_multiply_vt_pre(
  77. struct tw_extensible_t *working,
  78. const uint64_t scalar[7],
  79. const struct tw_niels_t *precmp,
  80. int table_bits
  81. );
  82. mask_t
  83. precompute_for_wnaf(
  84. struct tw_niels_t *out,
  85. const struct tw_extensible_t *const_base,
  86. int tbits
  87. ); /* TODO: attr don't ignore... */
  88. /* TODO: void. int is just for diagnostic purposes. */
  89. int
  90. edwards_combo_var_fixed_vt(
  91. struct tw_extensible_t *working,
  92. const uint64_t scalar_var[7],
  93. const uint64_t scalar_pre[7],
  94. const struct tw_niels_t *precmp,
  95. int table_bits_pre
  96. );
  97. #ifdef __cplusplus
  98. };
  99. #endif
  100. #endif /* __P448_ALGO_H__ */