Line data Source code
1 : #ifndef HEADER_fd_src_flamenco_runtime_fd_pubkey_utils_h 2 : #define HEADER_fd_src_flamenco_runtime_fd_pubkey_utils_h 3 : 4 : #include "context/fd_exec_instr_ctx.h" 5 : 6 189 : #define MAX_SEEDS (16UL) 7 0 : #define MAX_SEED_LEN (32UL) 8 : 9 : /* TODO: firedancer pubkey errors don't map to agave's implementation */ 10 387 : #define FD_PUBKEY_SUCCESS (0) 11 : 12 : /* Custom error codes */ 13 0 : #define FD_PUBKEY_ERR_MAX_SEED_LEN_EXCEEDED (0U) 14 180 : #define FD_PUBKEY_ERR_INVALID_SEEDS (1U) 15 0 : #define FD_PUBKEY_ERR_ILLEGAL_OWNER (2U) 16 : 17 : FD_PROTOTYPES_BEGIN 18 : 19 : int 20 : fd_pubkey_create_with_seed( fd_exec_instr_ctx_t const * ctx, 21 : uchar const base [ static 32 ], 22 : char const * seed, 23 : ulong seed_sz, 24 : uchar const owner[ static 32 ], 25 : uchar out [ static 32 ] ); 26 : 27 : /* fd_pubkey_derive_pda mirrors the vm helper function fd_vm_derive_pda 28 : to derive a PDA not on a ed25519 point. 29 : TODO: Potentially replace with shared function in fd_vm_syscall_pda.c */ 30 : 31 : int 32 : fd_pubkey_derive_pda( fd_pubkey_t const * program_id, 33 : ulong seeds_cnt, 34 : uchar const * const * seeds, 35 : ulong const * seed_szs, 36 : uchar * bump_seed, 37 : fd_pubkey_t * out, 38 : uint * custom_err ); 39 : 40 : /* fd_pubkey_find_program_address mirrors the vm syscall function 41 : fd_vm_syscall_sol_try_find_program_address and creates a valid 42 : program derived address searching for a valid ed25519 curve point by 43 : iterating through 255 possible bump seeds. If any of the possible addresses 44 : are on the curve then we know that it is not a valid PDA. This also returns 45 : the bump seed along with the program derived address. 46 : TODO: Potentially replace with shared function in fd_vm_syscall_pda.c */ 47 : 48 : int 49 : fd_pubkey_find_program_address( fd_pubkey_t const * program_id, 50 : ulong seeds_cnt, 51 : uchar const * const * seeds, 52 : ulong const * seed_szs, 53 : fd_pubkey_t * out, 54 : uchar * out_bump_seed, 55 : uint * custom_err ); 56 : 57 : 58 : FD_PROTOTYPES_END 59 : 60 : #endif /* HEADER_fd_src_flamenco_runtime_fd_pubkey_utils_h */