Struct hdwallet::extended_key::ExtendedPrivKey
source · pub struct ExtendedPrivKey {
pub private_key: SecretKey,
pub chain_code: Vec<u8>,
}
Expand description
ExtendedPrivKey is used for child key derivation. See secp256k1 crate documentation for SecretKey signatures usage.
Examples
use hdwallet::{ExtendedPrivKey, KeyIndex};
use rand;
let mut rng = rand::thread_rng();
let master_key = ExtendedPrivKey::random(&mut rng).unwrap();
let hardened_key_index = KeyIndex::hardened_from_normalize_index(0).unwrap();
let hardended_child_priv_key = master_key.derive_private_key(hardened_key_index).unwrap();
let normal_key_index = KeyIndex::Normal(0);
let noamal_child_priv_key = master_key.derive_private_key(normal_key_index).unwrap();
Fields§
§private_key: SecretKey
§chain_code: Vec<u8>
Implementations§
source§impl ExtendedPrivKey
impl ExtendedPrivKey
sourcepub fn random<R: RngCore + CryptoRng>(
rng: &mut R
) -> Result<ExtendedPrivKey, Error>
pub fn random<R: RngCore + CryptoRng>( rng: &mut R ) -> Result<ExtendedPrivKey, Error>
Generate an ExtendedPrivKey, use 256 size random seed.
sourcepub fn random_with_seed_size<R: RngCore + CryptoRng>(
rng: &mut R,
seed_size: KeySeed
) -> Result<ExtendedPrivKey, Error>
pub fn random_with_seed_size<R: RngCore + CryptoRng>( rng: &mut R, seed_size: KeySeed ) -> Result<ExtendedPrivKey, Error>
Generate an ExtendedPrivKey which use 128 or 256 or 512 bits random seed.
sourcepub fn with_seed(seed: &[u8]) -> Result<ExtendedPrivKey, Error>
pub fn with_seed(seed: &[u8]) -> Result<ExtendedPrivKey, Error>
Generate an ExtendedPrivKey from seed
sourcepub fn derive_private_key(
&self,
key_index: KeyIndex
) -> Result<ExtendedPrivKey, Error>
pub fn derive_private_key( &self, key_index: KeyIndex ) -> Result<ExtendedPrivKey, Error>
Derive a child key from ExtendedPrivKey.
Trait Implementations§
source§impl Clone for ExtendedPrivKey
impl Clone for ExtendedPrivKey
source§fn clone(&self) -> ExtendedPrivKey
fn clone(&self) -> ExtendedPrivKey
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ExtendedPrivKey
impl Debug for ExtendedPrivKey
source§impl Deserialize<&[u8], Error> for ExtendedPrivKey
impl Deserialize<&[u8], Error> for ExtendedPrivKey
source§impl PartialEq<ExtendedPrivKey> for ExtendedPrivKey
impl PartialEq<ExtendedPrivKey> for ExtendedPrivKey
source§fn eq(&self, other: &ExtendedPrivKey) -> bool
fn eq(&self, other: &ExtendedPrivKey) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.