1 #ifndef LIBWALLY_INTERNAL_H 2 #define LIBWALLY_INTERNAL_H 3 4 #include <include/wally_core.h> 5 #include "secp256k1/include/secp256k1.h" 6 #include "secp256k1/include/secp256k1_recovery.h" 7 #include "secp256k1/include/secp256k1_ecdsa_s2c.h" 8 #include <config.h> 9 #if defined(HAVE_MEMSET_S) 10 #define __STDC_WANT_LIB_EXT1__ 1 11 #endif 12 #include <string.h> 13 14 /* Fetch an internal secp context */ 15 const secp256k1_context *secp_ctx(void); 16 #define secp256k1_context_destroy(c) _do_not_destroy_shared_ctx_pointers(c) 17 18 /* secp pub/priv key functions */ 19 #define pubkey_create secp256k1_ec_pubkey_create 20 #define pubkey_tweak_add secp256k1_ec_pubkey_tweak_add 21 22 int privkey_tweak_add(unsigned char *seckey, const unsigned char *tweak); 23 int pubkey_combine(secp256k1_pubkey *pubnonce, const secp256k1_pubkey *const *pubnonces, size_t n); 24 int pubkey_negate(secp256k1_pubkey *pubkey); 25 int pubkey_parse(secp256k1_pubkey *pubkey, const unsigned char *input, size_t inputlen); 26 int pubkey_serialize(unsigned char *output, size_t *outputlen, const secp256k1_pubkey *pubkey, unsigned int flags); 27 int seckey_verify(const unsigned char *seckey); 28 29 #define PUBKEY_COMPRESSED SECP256K1_EC_COMPRESSED 30 #define PUBKEY_UNCOMPRESSED SECP256K1_EC_UNCOMPRESSED 31 32 33 void wally_clear(void *p, size_t len); 34 void wally_clear_2(void *p, size_t len, void *p2, size_t len2); 35 void wally_clear_3(void *p, size_t len, void *p2, size_t len2, 36 void *p3, size_t len3); 37 void wally_clear_4(void *p, size_t len, void *p2, size_t len2, 38 void *p3, size_t len3, void *p4, size_t len4); 39 40 void clear_and_free(void *p, size_t len); 41 42 /* Fetch our internal operations function pointers */ 43 const struct wally_operations *wally_ops(void); 44 45 void *wally_malloc(size_t size); 46 void *wally_calloc(size_t size); 47 void wally_free(void *ptr); 48 char *wally_strdup(const char *str); 49 50 #define malloc(size) __use_wally_malloc_internally__ 51 #define calloc(size) __use_wally_calloc_internally__ 52 #define free(ptr) __use_wally_free_internally__ 53 #ifdef strdup 54 #undef strdup 55 #endif 56 #define strdup(ptr) __use_wally_strdup_internally__ 57 58 /* Validity checking for input parameters */ 59 #define BYTES_VALID(p, len) ((p != NULL) == (len != 0)) 60 #define BYTES_INVALID(p, len) (!BYTES_VALID(p, len)) 61 #define BYTES_INVALID_N(p, len, siz) ((p != NULL) != (len == siz)) 62 63 #endif /* LIBWALLY_INTERNAL_H */ 64