poseidon.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #pragma once
  2. /**
  3. * @brief Solana poseidon system call
  4. **/
  5. #include <sol/types.h>
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. /**
  10. * Length of a Poseidon hash result
  11. */
  12. #define POSEIDON_RESULT_LENGTH 32
  13. /**
  14. * Configuration using the Barreto–Naehrig curve with an embedding degree of
  15. * 12, defined over a 254-bit prime field.
  16. *
  17. * Configuration Details:
  18. * - S-Box: x^5
  19. * - Width: 2 <= t <= 13
  20. * - Inputs: 1 <= n <= 12
  21. * - Full rounds: 8
  22. * - Partial rounds: Depending on width: [56, 57, 56, 60, 60, 63, 64, 63,
  23. * 60, 66, 60, 65]
  24. */
  25. #define POSEIDON_PARAMETERS_BN254_X5 0
  26. /**
  27. * Big-endian inputs and output
  28. */
  29. #define POSEIDON_ENDIANNESS_BIG_ENDIAN 0
  30. /**
  31. * Little-endian inputs and output
  32. */
  33. #define POSEIDON_ENDIANNESS_LITTLE_ENDIAN 1
  34. /**
  35. * Poseidon
  36. *
  37. * @param parameters Configuration parameters for the hash function
  38. * @param endianness Endianness of inputs and result
  39. * @param bytes Array of byte arrays
  40. * @param bytes_len Number of byte arrays
  41. * @param result 32 byte array to hold the result
  42. */
  43. /* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE platform-tools-sdk/sbf/c/inc/sol/inc/poseidon.inc AND RUN `cargo run --bin gen-headers` */
  44. #ifndef SOL_SBFV2
  45. uint64_t sol_poseidon(
  46. const uint64_t parameters,
  47. const uint64_t endianness,
  48. const SolBytes *bytes,
  49. const uint64_t bytes_len,
  50. uint8_t *result
  51. );
  52. #else
  53. typedef uint64_t(*sol_poseidon_pointer_type)(
  54. const uint64_t parameters,
  55. const uint64_t endianness,
  56. const SolBytes *bytes,
  57. const uint64_t bytes_len,
  58. uint8_t *result
  59. );
  60. static uint64_t sol_poseidon(
  61. const uint64_t parameters arg1,
  62. const uint64_t endianness arg2,
  63. const SolBytes *bytes arg3,
  64. const uint64_t bytes_len arg4,
  65. uint8_t *result
  66. arg5) {
  67. sol_poseidon_pointer_type sol_poseidon_pointer = (sol_poseidon_pointer_type) 3298065441;
  68. return sol_poseidon_pointer(arg1, arg2, arg3, arg4, arg5);
  69. }
  70. #endif
  71. #ifdef __cplusplus
  72. }
  73. #endif
  74. /**@}*/