libbtc
bitcoinclibrary
|
#include "btc/bip32.h"
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <inttypes.h>
#include "btc/base58.h"
#include "btc/ecc.h"
#include "ripemd160.h"
#include "sha2.h"
#include "utils.h"
Go to the source code of this file.
Functions | |
static void | write_be (uint8_t *data, uint32_t x) |
static uint32_t | read_be (const uint8_t *data) |
btc_bool | btc_hdnode_from_seed (const uint8_t *seed, int seed_len, btc_hdnode *out) |
btc_bool | btc_hdnode_public_ckd (btc_hdnode *inout, uint32_t i) |
btc_bool | btc_hdnode_private_ckd (btc_hdnode *inout, uint32_t i) |
void | btc_hdnode_fill_public_key (btc_hdnode *node) |
static void | btc_hdnode_serialize (const btc_hdnode *node, uint32_t version, char use_public, char *str, int strsize) |
void | btc_hdnode_serialize_public (const btc_hdnode *node, const btc_chain *chain, char *str, int strsize) |
void | btc_hdnode_serialize_private (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_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 More... | |
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
Definition at line 245 of file bip32.c.
References BTC_BIP32_CHAINCODE_SIZE, BTC_ECKEY_PKEY_LENGTH, btc_hdnode_fill_public_key(), btc_hdnode_private_ckd(), btc_hdnode_private_ckd_prime, btc_hdnode::chain_code, btc_hdnode::child_num, btc_hdnode::depth, btc_hdnode::fingerprint, btc_hdnode::private_key, and strlens.
btc_bool btc_hdnode_deserialize | ( | const char * | str, |
const btc_chain * | chain, | ||
btc_hdnode * | node | ||
) |
Definition at line 216 of file bip32.c.
References btc_chain::b58prefix_bip32_privkey, btc_chain::b58prefix_bip32_pubkey, btc_base58_decode_check(), BTC_BIP32_CHAINCODE_SIZE, BTC_ECKEY_COMPRESSED_LENGTH, BTC_ECKEY_PKEY_LENGTH, btc_hdnode_fill_public_key(), btc_hdnode::chain_code, btc_hdnode::child_num, btc_hdnode::depth, btc_hdnode::fingerprint, btc_hdnode::private_key, btc_hdnode::public_key, and read_be().
void btc_hdnode_fill_public_key | ( | btc_hdnode * | node | ) |
Definition at line 178 of file bip32.c.
References BTC_ECKEY_COMPRESSED_LENGTH, ecc_get_pubkey(), btc_hdnode::private_key, and btc_hdnode::public_key.
Referenced by btc_hd_generate_key(), btc_hdnode_deserialize(), btc_hdnode_from_seed(), and btc_hdnode_private_ckd().
btc_bool btc_hdnode_from_seed | ( | const uint8_t * | seed, |
int | seed_len, | ||
btc_hdnode * | out | ||
) |
Definition at line 61 of file bip32.c.
References BTC_BIP32_CHAINCODE_SIZE, BTC_ECKEY_PKEY_LENGTH, btc_hdnode_fill_public_key(), btc_hdnode::chain_code, btc_hdnode::child_num, btc_hdnode::depth, ecc_verify_privatekey(), btc_hdnode::fingerprint, hmac_sha512(), and btc_hdnode::private_key.
btc_bool btc_hdnode_private_ckd | ( | btc_hdnode * | inout, |
uint32_t | i | ||
) |
Definition at line 124 of file bip32.c.
References BTC_BIP32_CHAINCODE_SIZE, BTC_ECKEY_COMPRESSED_LENGTH, BTC_ECKEY_PKEY_LENGTH, btc_hdnode_fill_public_key(), btc_hdnode::chain_code, btc_hdnode::child_num, btc_hdnode::depth, ecc_private_key_tweak_add(), ecc_verify_privatekey(), btc_hdnode::fingerprint, hmac_sha512(), btc_hdnode::private_key, btc_hdnode::public_key, ripemd160(), sha256_Raw(), and write_be().
Referenced by btc_hd_generate_key().
btc_bool btc_hdnode_public_ckd | ( | btc_hdnode * | inout, |
uint32_t | i | ||
) |
Definition at line 83 of file bip32.c.
References BTC_BIP32_CHAINCODE_SIZE, BTC_ECKEY_COMPRESSED_LENGTH, btc_hdnode::chain_code, btc_hdnode::child_num, btc_hdnode::depth, ecc_public_key_tweak_add(), btc_hdnode::fingerprint, hmac_sha512(), btc_hdnode::private_key, btc_hdnode::public_key, ripemd160(), sha256_Raw(), and write_be().
|
static |
Definition at line 185 of file bip32.c.
References btc_base58_encode_check(), BTC_BIP32_CHAINCODE_SIZE, BTC_ECKEY_COMPRESSED_LENGTH, BTC_ECKEY_PKEY_LENGTH, btc_hdnode::chain_code, btc_hdnode::child_num, btc_hdnode::depth, btc_hdnode::fingerprint, btc_hdnode::private_key, btc_hdnode::public_key, and write_be().
Referenced by btc_hdnode_serialize_private(), and btc_hdnode_serialize_public().
void btc_hdnode_serialize_private | ( | const btc_hdnode * | node, |
const btc_chain * | chain, | ||
char * | str, | ||
int | strsize | ||
) |
Definition at line 209 of file bip32.c.
References btc_chain::b58prefix_bip32_privkey, and btc_hdnode_serialize().
void btc_hdnode_serialize_public | ( | const btc_hdnode * | node, |
const btc_chain * | chain, | ||
char * | str, | ||
int | strsize | ||
) |
Definition at line 203 of file bip32.c.
References btc_chain::b58prefix_bip32_pubkey, and btc_hdnode_serialize().
|
static |
Definition at line 52 of file bip32.c.
Referenced by btc_hdnode_deserialize().
|
static |
Copyright (c) 2013-2014 Tomas Dzetkulic Copyright (c) 2013-2014 Pavol Rusnak Copyright (c) 2015 Douglas J. Bakkumk
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Definition at line 42 of file bip32.c.
Referenced by btc_hdnode_private_ckd(), btc_hdnode_public_ckd(), and btc_hdnode_serialize().