mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-23 07:58:09 +00:00
bip32: serialization returns nu. of written bytes
This commit is contained in:
parent
db1b638cdf
commit
00413c0b6e
14
bip32.c
14
bip32.c
@ -438,7 +438,7 @@ int hdnode_sign_digest(HDNode *node, const uint8_t *digest, uint8_t *sig, uint8_
|
||||
}
|
||||
|
||||
|
||||
void hdnode_serialize(const HDNode *node, uint32_t fingerprint, uint32_t version, char use_public, char *str, int strsize)
|
||||
int hdnode_serialize(const HDNode *node, uint32_t fingerprint, uint32_t version, char use_public, char *str, int strsize)
|
||||
{
|
||||
uint8_t node_data[78];
|
||||
write_be(node_data, version);
|
||||
@ -452,19 +452,19 @@ void hdnode_serialize(const HDNode *node, uint32_t fingerprint, uint32_t version
|
||||
node_data[45] = 0;
|
||||
memcpy(node_data + 46, node->private_key, 32);
|
||||
}
|
||||
base58_encode_check(node_data, sizeof(node_data), str, strsize);
|
||||
|
||||
int ret = base58_encode_check(node_data, sizeof(node_data), str, strsize);
|
||||
MEMSET_BZERO(node_data, sizeof(node_data));
|
||||
return ret;
|
||||
}
|
||||
|
||||
void hdnode_serialize_public(const HDNode *node, uint32_t fingerprint, char *str, int strsize)
|
||||
int hdnode_serialize_public(const HDNode *node, uint32_t fingerprint, char *str, int strsize)
|
||||
{
|
||||
hdnode_serialize(node, fingerprint, 0x0488B21E, 1, str, strsize);
|
||||
return hdnode_serialize(node, fingerprint, 0x0488B21E, 1, str, strsize);
|
||||
}
|
||||
|
||||
void hdnode_serialize_private(const HDNode *node, uint32_t fingerprint, char *str, int strsize)
|
||||
int hdnode_serialize_private(const HDNode *node, uint32_t fingerprint, char *str, int strsize)
|
||||
{
|
||||
hdnode_serialize(node, fingerprint, 0x0488ADE4, 0, str, strsize);
|
||||
return hdnode_serialize(node, fingerprint, 0x0488ADE4, 0, str, strsize);
|
||||
}
|
||||
|
||||
// check for validity of curve point in case of public data not performed
|
||||
|
6
bip32.h
6
bip32.h
@ -74,14 +74,14 @@ int hdnode_get_ethereum_pubkeyhash(const HDNode *node, uint8_t *pubkeyhash);
|
||||
int hdnode_sign(HDNode *node, const uint8_t *msg, uint32_t msg_len, uint8_t *sig, uint8_t *pby);
|
||||
int hdnode_sign_digest(HDNode *node, const uint8_t *digest, uint8_t *sig, uint8_t *pby);
|
||||
|
||||
void hdnode_serialize_public(const HDNode *node, uint32_t fingerprint, char *str, int strsize);
|
||||
int hdnode_serialize_public(const HDNode *node, uint32_t fingerprint, char *str, int strsize);
|
||||
|
||||
void hdnode_serialize_private(const HDNode *node, uint32_t fingerprint, char *str, int strsize);
|
||||
int hdnode_serialize_private(const HDNode *node, uint32_t fingerprint, char *str, int strsize);
|
||||
|
||||
int hdnode_deserialize(const char *str, HDNode *node);
|
||||
|
||||
// Private
|
||||
void hdnode_serialize(const HDNode *node, uint32_t fingerprint, uint32_t version, char use_public, char *str, int strsize);
|
||||
int hdnode_serialize(const HDNode *node, uint32_t fingerprint, uint32_t version, char use_public, char *str, int strsize);
|
||||
|
||||
void hdnode_get_address_raw(HDNode *node, uint8_t version, uint8_t *addr_raw);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user