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.
 
 
 
 
 

118 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. void
  53. edwards_scalar_multiply_vlook(
  54. struct tw_extensible_t *working,
  55. const uint64_t scalar[7]
  56. /* TODO? int nbits */
  57. );
  58. mask_t
  59. precompute_for_combs(
  60. struct tw_niels_t *out,
  61. const struct tw_extensible_t *const_base,
  62. int n,
  63. int t,
  64. int s
  65. );
  66. void
  67. edwards_comb(
  68. struct tw_extensible_t *working,
  69. const word_t scalar[7],
  70. const struct tw_niels_t *table,
  71. int n,
  72. int t,
  73. int s
  74. );
  75. void
  76. edwards_scalar_multiply_vt(
  77. struct tw_extensible_t *working,
  78. const uint64_t scalar[7]
  79. );
  80. void
  81. edwards_scalar_multiply_vt_pre(
  82. struct tw_extensible_t *working,
  83. const uint64_t scalar[7],
  84. const struct tw_niels_t *precmp,
  85. int table_bits
  86. );
  87. mask_t
  88. precompute_for_wnaf(
  89. struct tw_niels_t *out,
  90. const struct tw_extensible_t *const_base,
  91. int tbits
  92. ); /* TODO: attr don't ignore... */
  93. void
  94. edwards_combo_var_fixed_vt(
  95. struct tw_extensible_t *working,
  96. const uint64_t scalar_var[7],
  97. const uint64_t scalar_pre[7],
  98. const struct tw_niels_t *precmp,
  99. int table_bits_pre
  100. );
  101. #ifdef __cplusplus
  102. };
  103. #endif
  104. #endif /* __P448_ALGO_H__ */