LCOV - code coverage report
Current view: top level - flamenco/runtime - fd_pubkey_utils.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 6 6 100.0 %
Date: 2024-11-13 11:58:15 Functions: 0 0 -

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

Generated by: LCOV version 1.14