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.
 
 
 
 
 

80 lines
1.8 KiB

  1. /* Copyright (c) 2015 Cryptography Research, Inc.
  2. * Released under the MIT License. See LICENSE.txt for license information.
  3. */
  4. /**
  5. * @file decaf.h
  6. * @author Mike Hamburg
  7. * @brief Decaf high-level functions.
  8. */
  9. #ifndef __DECAF_H__
  10. #define __DECAF_H__ 1
  11. #include <stdint.h>
  12. typedef uint64_t decaf_word_t, decaf_bool_t;
  13. #define DECAF_LIMBS (512/8/sizeof(decaf_word_t))
  14. #define DECAF_SER_BYTES 56
  15. typedef struct decaf_point_s {
  16. decaf_word_t x[DECAF_LIMBS],y[DECAF_LIMBS],z[DECAF_LIMBS],t[DECAF_LIMBS];
  17. } decaf_point_t[1];
  18. static const decaf_bool_t DECAF_SUCCESS = -(decaf_bool_t)1, DECAF_FAILURE = 0;
  19. const decaf_point_t decaf_identity_point;
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. #define API_VIS __attribute__((visibility("default")))
  24. #define WARN_UNUSED __attribute__((warn_unused_result))
  25. #define NONNULL2 __attribute__((nonnull(1,2)))
  26. #define NONNULL3 __attribute__((nonnull(1,2,3)))
  27. void decaf_encode (
  28. uint8_t ser[DECAF_SER_BYTES],
  29. const decaf_point_t pt
  30. ) API_VIS NONNULL2;
  31. decaf_bool_t decaf_decode (
  32. decaf_point_t pt,
  33. const uint8_t ser[DECAF_SER_BYTES],
  34. decaf_bool_t allow_identity
  35. ) API_VIS WARN_UNUSED NONNULL2;
  36. void decaf_add (
  37. decaf_point_t a,
  38. const decaf_point_t b,
  39. const decaf_point_t c
  40. ) API_VIS NONNULL3;
  41. decaf_bool_t decaf_eq (
  42. const decaf_point_t a,
  43. const decaf_point_t b
  44. ) API_VIS WARN_UNUSED NONNULL2;
  45. void decaf_sub (
  46. decaf_point_t a,
  47. const decaf_point_t b,
  48. const decaf_point_t c
  49. ) API_VIS NONNULL3;
  50. void decaf_add_sub (
  51. decaf_point_t a,
  52. const decaf_point_t b,
  53. const decaf_point_t c,
  54. decaf_bool_t do_sub
  55. ) API_VIS NONNULL3;
  56. #undef API_VIS
  57. #undef WARN_UNUSED
  58. #undef NONNULL2
  59. #undef NONNULL3
  60. #ifdef __cplusplus
  61. }; /* extern "C" */
  62. #endif
  63. #endif /* __DECAF_H__ */