secp256k1.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #pragma once
  2. /**
  3. * @brief Solana secp256k1 system call
  4. */
  5. #include <sol/types.h>
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. /** Length of a secp256k1 recover input hash */
  10. #define SECP256K1_RECOVER_HASH_LENGTH 32
  11. /** Length of a secp256k1 input signature */
  12. #define SECP256K1_RECOVER_SIGNATURE_LENGTH 64
  13. /** Length of a secp256k1 recover result */
  14. #define SECP256K1_RECOVER_RESULT_LENGTH 64
  15. /** The hash provided to a sol_secp256k1_recover is invalid */
  16. #define SECP256K1_RECOVER_ERROR_INVALID_HASH 1
  17. /** The recovery_id provided to a sol_secp256k1_recover is invalid */
  18. #define SECP256K1_RECOVER_ERROR_INVALID_RECOVERY_ID 2
  19. /** The signature provided to a sol_secp256k1_recover is invalid */
  20. #define SECP256K1_RECOVER_ERROR_INVALID_SIGNATURE 3
  21. /**
  22. * Recover public key from a signed message.
  23. *
  24. * @param hash Hashed message
  25. * @param recovery_id Tag used for public key recovery from signatures. Can be 0 or 1
  26. * @param signature An ECDSA signature
  27. * @param result 64 byte array to hold the result. A recovered public key
  28. * @return 0 if executed successfully
  29. */
  30. /* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE platform-tools-sdk/sbf/c/inc/sol/inc/secp256k1.inc AND RUN `cargo run --bin gen-headers` */
  31. #ifndef SOL_SBFV2
  32. uint64_t sol_secp256k1_recover(const uint8_t *, uint64_t, const uint8_t *, uint8_t *);
  33. #else
  34. typedef uint64_t(*sol_secp256k1_recover_pointer_type)(const uint8_t *, uint64_t, const uint8_t *, uint8_t *);
  35. static uint64_t sol_secp256k1_recover(const uint8_t * arg1, uint64_t arg2, const uint8_t * arg3, uint8_t * arg4) {
  36. sol_secp256k1_recover_pointer_type sol_secp256k1_recover_pointer = (sol_secp256k1_recover_pointer_type) 400819024;
  37. return sol_secp256k1_recover_pointer(arg1, arg2, arg3, arg4);
  38. }
  39. #endif
  40. #ifdef __cplusplus
  41. }
  42. #endif
  43. /**@}*/