Documentation ¶
Overview ¶
Package bip32 provides ...
Package bip32 provides ...
Index ¶
- Constants
- Variables
- func EntropyFromMnemonic(mnemonic string) ([]byte, error)
- func GetWordList() []string
- func IsMnemonicValid(mnemonic string) bool
- func MnemonicToByteArray(mnemonic string, raw ...bool) ([]byte, error)
- func NewEntropy(bitSize int) ([]byte, error)
- func NewMnemonic(entropy []byte) (string, error)
- func NewSeed(mnemonic string, password string) []byte
- func NewSeedWithErrorChecking(mnemonic string, password string) ([]byte, error)
- func SetWordList(list []string)
- type ExtendedKey
- func (key *ExtendedKey) Address() (*ec.AddressPubKeyHash, error)
- func (key *ExtendedKey) B58Serialize() string
- func (key *ExtendedKey) Child(i uint32) (*ExtendedKey, error)
- func (key *ExtendedKey) DerivePath(pathStr string) (*ExtendedKey, error)
- func (key *ExtendedKey) ECPrivKey() (*ec.PrivateKey, error)
- func (key *ExtendedKey) HardenedChild(i uint32) (*ExtendedKey, error)
- func (key *ExtendedKey) Neuter() *ExtendedKey
- func (key *ExtendedKey) Serialize() ([]byte, error)
Constants ¶
const ( //HardenedKeyStart hardended key starts. HardenedKeyStart uint32 = 0x80000000 // 2^31 )
Variables ¶
var ( // ErrInvalidSeedLen seed Len error ErrInvalidSeedLen = errors.New("seed lenght must be between 128 and 512 bits") // ErrUnusableSeed describes an error in which the provided seed is not // usable due to the derived key falling outside of the valid range for // secp256k1 private keys. This error indicates the caller must choose // another seed. ErrUnusableSeed = errors.New("unusable seed") // ErrKeyByteSize error extended key bytes ErrKeyByteSize = errors.New("error extended key bytes") //ErrDeriveBeyondMaxDepth max 255 indices ErrDeriveBeyondMaxDepth = errors.New("cannot derive a key with more than 255 indices in its path") // ErrDeriveHardFromPublic cannot derive a hardened key from a public key ErrDeriveHardFromPublic = errors.New("cannot derive a hardened key from a public key") //ErrInvalidChild child index invalid ErrInvalidChild = errors.New("the extended key at this index is invalid") // ErrNotPrivExtKey not Private Key ErrNotPrivExtKey = errors.New("cant't create private keys from public extended key") )
var ( // ErrInvalidMnemonic is returned when trying to use a malformed mnemonic. ErrInvalidMnemonic = errors.New("Invalid mnenomic") // ErrEntropyLengthInvalid is returned when trying to use an entropy set with // an invalid size. ErrEntropyLengthInvalid = errors.New("Entropy length must be [128, 256] and a multiple of 32") // ErrValidatedSeedLengthMismatch is returned when a validated seed is not the // same size as the given seed. This should never happen is present only as a // sanity assertion. ErrValidatedSeedLengthMismatch = errors.New("Seed length does not match validated seed length") // ErrChecksumIncorrect is returned when entropy has the incorrect checksum. ErrChecksumIncorrect = errors.New("Checksum incorrect") )
var ErrKeyPathFormat = errors.New("Wallet Path Error")
var ErrParentKey = errors.New("Key must master")
Functions ¶
func EntropyFromMnemonic ¶
EntropyFromMnemonic takes a mnemonic generated by this library, and returns the input entropy used to generate the given mnemonic. An error is returned if the given mnemonic is invalid.
func GetWordList ¶
func GetWordList() []string
GetWordList gets the list of words to use for mnemonics.
func IsMnemonicValid ¶
IsMnemonicValid attempts to verify that the provided mnemonic is valid. Validity is determined by both the number of words being appropriate, and that all the words in the mnemonic are present in the word list.
func MnemonicToByteArray ¶
MnemonicToByteArray takes a mnemonic string and turns it into a byte array suitable for creating another mnemonic. An error is returned if the mnemonic is invalid.
func NewEntropy ¶
NewEntropy will create random entropy bytes so long as the requested size bitSize is an appropriate size.
bitSize has to be a multiple 32 and be within the inclusive range of {128, 256}
func NewMnemonic ¶
NewMnemonic will return a string consisting of the mnemonic words for the given entropy. If the provide entropy is invalid, an error will be returned.
func NewSeed ¶
NewSeed creates a hashed seed output given a provided string and password. No checking is performed to validate that the string provided is a valid mnemonic.
func NewSeedWithErrorChecking ¶
NewSeedWithErrorChecking creates a hashed seed output given the mnemonic string and a password. An error is returned if the mnemonic is not convertible to a byte array.
func SetWordList ¶
func SetWordList(list []string)
SetWordList sets the list of words to use for mnemonics. Currently the list that is set is used package-wide.
Types ¶
type ExtendedKey ¶
type ExtendedKey struct { DerivationPath string // contains filtered or unexported fields }
ExtendedKey private/public key data
func NewMasterKey ¶
func NewMasterKey(seed []byte, params *chaincfg.Params) (*ExtendedKey, error)
NewMasterKey create a new master key data from seed
func (*ExtendedKey) Address ¶
func (key *ExtendedKey) Address() (*ec.AddressPubKeyHash, error)
Address return pay-to-pubkey-has (P2PKH) address
func (*ExtendedKey) B58Serialize ¶
func (key *ExtendedKey) B58Serialize() string
func (*ExtendedKey) Child ¶
func (key *ExtendedKey) Child(i uint32) (*ExtendedKey, error)
Child create extended child key https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#child-key-derivation-ckd-functions
func (*ExtendedKey) DerivePath ¶
func (key *ExtendedKey) DerivePath(pathStr string) (*ExtendedKey, error)
DerivePath return key by path : m/0'/1/2' etc...
func (*ExtendedKey) ECPrivKey ¶
func (key *ExtendedKey) ECPrivKey() (*ec.PrivateKey, error)
func (*ExtendedKey) HardenedChild ¶
func (key *ExtendedKey) HardenedChild(i uint32) (*ExtendedKey, error)
HardenedChild derivation hardened child
func (*ExtendedKey) Neuter ¶
func (key *ExtendedKey) Neuter() *ExtendedKey
Neuter https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#private-parent-key--public-child-key
func (*ExtendedKey) Serialize ¶
func (key *ExtendedKey) Serialize() ([]byte, error)