42 static void write_be(uint8_t* data, uint32_t x)
 
   52 static uint32_t 
read_be(
const uint8_t* data)
 
   54     return (((uint32_t)data[0]) << 24) |
 
   55            (((uint32_t)data[1]) << 16) |
 
   56            (((uint32_t)data[2]) << 8) |
 
   57            (((uint32_t)data[3]));
 
   68     hmac_sha512((
const uint8_t*)
"Bitcoin seed", 12, seed, seed_len, I);
 
   72         memset(I, 0, 
sizeof(I));
 
   78     memset(I, 0, 
sizeof(I));
 
   85     uint8_t data[1 + 32 + 4];
 
   87     uint8_t fingerprint[32];
 
   98     inout->
fingerprint = (fingerprint[0] << 24) + (fingerprint[1] << 16) + (fingerprint[2] << 8) + fingerprint[3];
 
  116     memset(data, 0, 
sizeof(data));
 
  117     memset(I, 0, 
sizeof(I));
 
  118     memset(fingerprint, 0, 
sizeof(fingerprint));
 
  120     return failed ? 
false : 
true;
 
  131     if (i & 0x80000000) { 
 
  141     inout->
fingerprint = (fingerprint[0] << 24) + (fingerprint[1] << 16) +
 
  142                          (fingerprint[2] << 8) + fingerprint[3];
 
  144     memset(fingerprint, 0, 
sizeof(fingerprint));
 
  170     memset(data, 0, 
sizeof(data));
 
  171     memset(I, 0, 
sizeof(I));
 
  172     memset(p, 0, 
sizeof(p));
 
  173     memset(z, 0, 
sizeof(z));
 
  187     uint8_t node_data[78];
 
  189     node_data[4] = node->
depth;
 
  218     uint8_t node_data[strlen(str)];
 
  226     uint32_t version = 
read_be(node_data);
 
  238     node->
depth = node_data[4];
 
  247     static char delim[] = 
"/";
 
  248     static char prime[] = 
"phH\'";
 
  249     static char digits[] = 
"0123456789";
 
  251     assert(
strlens(keypath) < 1024);
 
  252     char* pch, *kp = malloc(
strlens(keypath) + 1);
 
  262     memset(kp, 0, 
strlens(keypath) + 1);
 
  263     memcpy(kp, keypath, 
strlens(keypath));
 
  265     if (kp[0] != 
'm' || kp[1] != 
'/') {
 
  276     pch = strtok(kp + 2, delim);
 
  277     while (pch != NULL) {
 
  280         for (; i < 
strlens(pch); i++) {
 
  281             if (strchr(prime, pch[i])) {
 
  286             } 
else if (!strchr(digits, pch[i])) {
 
  291         idx = strtoull(pch, NULL, 10);
 
  292         if (idx > UINT32_MAX) {
 
  305         pch = strtok(NULL, delim);
 
btc_bool btc_hdnode_private_ckd(btc_hdnode *inout, uint32_t i)
 
uint8_t private_key[BTC_ECKEY_PKEY_LENGTH]
 
btc_bool btc_hd_generate_key(btc_hdnode *node, const char *keypath, const uint8_t *privkeymaster, const uint8_t *chaincode)
derive btc_hdnode including private key from master private key 
 
void ecc_get_pubkey(const uint8_t *private_key, uint8_t *public_key, size_t *in_outlen, btc_bool compressed)
get public key from given private key 
 
#define BTC_ECKEY_PKEY_LENGTH
 
uint32_t b58prefix_bip32_pubkey
 
void btc_hdnode_serialize_private(const btc_hdnode *node, const btc_chain *chain, char *str, int strsize)
 
#define BTC_ECKEY_COMPRESSED_LENGTH
 
uint32_t b58prefix_bip32_privkey
private key 
 
void sha256_Raw(const sha2_byte *data, size_t len, uint8_t digest[SHA256_DIGEST_LENGTH])
 
void btc_hdnode_fill_public_key(btc_hdnode *node)
 
int btc_base58_decode_check(const char *str, uint8_t *data, size_t datalen)
 
uint8_t chain_code[BTC_BIP32_CHAINCODE_SIZE]
 
btc_bool ecc_public_key_tweak_add(uint8_t *public_key_inout, const uint8_t *tweak)
ec mul tweak on given public key 
 
static uint32_t read_be(const uint8_t *data)
 
uint8_t public_key[BTC_ECKEY_COMPRESSED_LENGTH]
 
void ripemd160(const uint8_t *msg, uint32_t msg_len, uint8_t *hash)
 
static void write_be(uint8_t *data, uint32_t x)
 
btc_bool ecc_private_key_tweak_add(uint8_t *private_key, const uint8_t *tweak)
ec mul tweak on given private key 
 
static void btc_hdnode_serialize(const btc_hdnode *node, uint32_t version, char use_public, char *str, int strsize)
 
int btc_base58_encode_check(const uint8_t *data, int datalen, char *str, int strsize)
 
#define BTC_BIP32_CHAINCODE_SIZE
 
btc_bool btc_hdnode_from_seed(const uint8_t *seed, int seed_len, btc_hdnode *out)
 
#define btc_hdnode_private_ckd_prime(X, I)
 
void hmac_sha512(const uint8_t *key, const uint32_t keylen, const uint8_t *msg, const uint32_t msglen, uint8_t *hmac)
 
btc_bool ecc_verify_privatekey(const uint8_t *private_key)
verifies a given 32byte key 
 
void btc_hdnode_serialize_public(const btc_hdnode *node, const btc_chain *chain, char *str, int strsize)
 
btc_bool btc_hdnode_deserialize(const char *str, const btc_chain *chain, btc_hdnode *node)
 
btc_bool btc_hdnode_public_ckd(btc_hdnode *inout, uint32_t i)