@@ -68,7 +68,7 @@ int bip32_from_seed(bip32_key *key, const unsigned char *seed, size_t seed_len)
6868    return  retcode ;
6969}
7070
71- int  pubkey_from_privkey (unsigned char  *  out , const  unsigned char  *  privkey_in ) {
71+ int  bip32_pubkey_from_privkey (unsigned char  *  out , const  unsigned char  *  privkey_in ) {
7272    int  retcode  =  1 ;
7373    secp256k1_context *  ctx  =  NULL ;
7474    get_secp_ctx (& ctx );
@@ -89,11 +89,11 @@ int pubkey_from_privkey(unsigned char* out, const unsigned char* privkey_in) {
8989    return  retcode ;
9090}
9191
92- int  get_fingerprint (const  bip32_key *  key , uint32_t *  out ) {
92+ int  bip32_fingerprint (const  bip32_key *  key , uint32_t *  out ) {
9393    unsigned char   pubkey_bytes [BIP32_PUBKEY_SIZE ];
9494
9595    if  (key -> is_private ) {
96-         pubkey_from_privkey (pubkey_bytes , key -> key .privkey );
96+         bip32_pubkey_from_privkey (pubkey_bytes , key -> key .privkey );
9797    } else  {
9898        memcpy (pubkey_bytes , key -> key .pubkey , BIP32_PUBKEY_SIZE );
9999    }
@@ -114,7 +114,7 @@ int bip32_index_derive(bip32_key *target, const bip32_key *source, uint32_t inde
114114    int  retcode  =  1 ;
115115    const  size_t  hmac_msg_len  =  BIP32_PUBKEY_SIZE  +  sizeof (uint32_t );
116116    unsigned char   hmac_msg [hmac_msg_len ];
117-     unsigned char   output [SHA512_SIZE ];
117+     unsigned char   output [crypto_hash_sha512_BYTES ];
118118    bool  is_hardened  =  index  >= HARDENED_INDEX ;
119119
120120    if  (is_hardened  &&  !source -> is_private ) {
@@ -211,7 +211,7 @@ int bip32_index_derive(bip32_key *target, const bip32_key *source, uint32_t inde
211211        retcode  =  0 ; goto exit ;
212212    }
213213
214-     get_fingerprint (source , & target -> parent_fingerprint );
214+     bip32_fingerprint (source , & target -> parent_fingerprint );
215215
216216exit :
217217    secp256k1_context_destroy (ctx );
@@ -337,7 +337,7 @@ int bip32_deserialize(bip32_key *key, const char *str, const size_t str_len) {
337337    }
338338
339339    // Verify checksum 
340-     unsigned char   hash [SHA256_SIZE ];
340+     unsigned char   hash [crypto_hash_sha512_BYTES ];
341341    sha256_double (hash , data , 78 );
342342    if  (memcmp (hash , data  +  78 , 4 ) !=  0 ) {
343343        return  0 ;
@@ -421,7 +421,7 @@ int bip32_get_public(bip32_key *target, const bip32_key *source) {
421421    target -> is_testnet  =  source -> is_testnet ;
422422    target -> is_private  =  0 ;
423423
424-     pubkey_from_privkey (target -> key .pubkey , source -> key .privkey );
424+     bip32_pubkey_from_privkey (target -> key .pubkey , source -> key .privkey );
425425    return  1 ;
426426}
427427
0 commit comments