adding child key derivation for ecc keys
This commit is contained in:
parent
2808c02cc7
commit
d76a15ec89
2 changed files with 22 additions and 0 deletions
|
|
@ -46,6 +46,8 @@ namespace fc {
|
|||
public_key( const public_key_point_data& v );
|
||||
public_key( const compact_signature& c, const fc::sha256& digest, bool check_canonical = true );
|
||||
|
||||
public_key child( const fc::sha256& offset )const;
|
||||
|
||||
bool valid()const;
|
||||
/** Computes new pubkey = generator * offset + old pubkey ?! */
|
||||
// public_key mult( const fc::sha256& offset )const;
|
||||
|
|
@ -96,6 +98,8 @@ namespace fc {
|
|||
static private_key generate();
|
||||
static private_key regenerate( const fc::sha256& secret );
|
||||
|
||||
private_key child( const fc::sha256& offset )const;
|
||||
|
||||
/**
|
||||
* This method of generation enables creating a new private key in a deterministic manner relative to
|
||||
* an initial seed. A public_key created from the seed can be multiplied by the offset to calculate
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <fc/crypto/base58.hpp>
|
||||
#include <fc/crypto/elliptic.hpp>
|
||||
#include <fc/io/raw.hpp>
|
||||
|
||||
/* stuff common to all ecc implementations */
|
||||
|
||||
|
|
@ -9,6 +10,23 @@ namespace fc { namespace ecc {
|
|||
return public_key(data);
|
||||
}
|
||||
|
||||
public_key public_key::child( const fc::sha256& offset )const
|
||||
{
|
||||
fc::sha256::encoder enc;
|
||||
fc::raw::pack( enc, *this );
|
||||
fc::raw::pack( enc, offset );
|
||||
|
||||
return add( enc.result() );
|
||||
}
|
||||
|
||||
private_key private_key::child( const fc::sha256& offset )const
|
||||
{
|
||||
fc::sha256::encoder enc;
|
||||
fc::raw::pack( enc, get_public_key() );
|
||||
fc::raw::pack( enc, offset );
|
||||
return generate_from_seed( get_secret(), enc.result() );
|
||||
}
|
||||
|
||||
std::string public_key::to_base58( const public_key_data &key )
|
||||
{
|
||||
uint32_t check = (uint32_t)sha256::hash(key.data, sizeof(key))._hash[0];
|
||||
|
|
|
|||
Loading…
Reference in a new issue