Documentation ¶
Index ¶
- Constants
- Variables
- type Ed25519
- type ExtendedKey
- func Ed25519Child(k *ExtendedKey, i uint32) (*ExtendedKey, error)
- func Ed25519Child64(k *ExtendedKey, i uint64) (*ExtendedKey, error)
- func MasterKeyForSliceEncryption(seedBytes []byte, nonce uint32) (*ExtendedKey, error)
- func MasterKeyFromMnemonic(mnemonic []string, passphrase string) (*ExtendedKey, error)
- func MasterKeyFromPassphrase(passphrase string) (*ExtendedKey, []string, error)
- func MasterKeyGenerate(seedBytes []byte, masterKey []byte) *ExtendedKey
- func NewExtendedKey(key, chainCode, parentFP []byte, depth uint8, childNum uint32, isPrivate bool) *ExtendedKey
- type Secp256K1
Constants ¶
const ( // RecommendedSeedLen is the recommended length in bytes for a seed // to a master node. RecommendedSeedLen = 32 // 256 bits // HardenedKeyStart is the index at which a hardened key starts. Each // extended key has 2^31 normal child keys and 2^31 hardened child keys. // Thus the range for normal child keys is [0, 2^31 - 1] and the range // for hardened child keys is [2^31, 2^32 - 1]. HardenedKeyStart = 0x80000000 // 2^31 // MinSeedBytes is the minimum number of bytes allowed for a seed to // a master node. MinSeedBytes = 16 // 128 bits // MaxSeedBytes is the maximum number of bytes allowed for a seed to // a master node. MaxSeedBytes = 64 // 512 bits )
Variables ¶
var ( ErrNonHardenedChild = errors.New("ed25519 does not support non hardened children") ErrPublicParentDerivation = errors.New("derivation from public parent not supported") )
var ( // ErrDeriveHardFromPublic describes an error in which the caller // attempted to derive a hardened extended key from a public key. ErrDeriveHardFromPublic = errors.New("cannot derive a hardened key " + "from a public key") // ErrDeriveBeyondMaxDepth describes an error in which the caller // has attempted to derive more than 255 keys from a root key. ErrDeriveBeyondMaxDepth = errors.New("cannot derive a key with more than " + "255 indices in its path") // ErrNotPrivExtKey describes an error in which the caller attempted // to extract a private key from a public extended key. ErrNotPrivExtKey = errors.New("unable to create private keys from a " + "public extended key") // ErrInvalidChild describes an error in which the child at a specific // index is invalid due to the derived key falling outside of the valid // range for secp256k1 private keys. This error indicates the caller // should simply ignore the invalid child extended key at this index and // increment to the next index. ErrInvalidChild = errors.New("the extended key at this index is invalid") // 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") // ErrInvalidSeedLen describes an error in which the provided seed or // seed length is not in the allowed range. ErrInvalidSeedLen = fmt.Errorf("seed length must be between %d and %d "+ "bits", MinSeedBytes*8, MaxSeedBytes*8) // ErrBadChecksum describes an error in which the checksum encoded with // a serialized extended key does not match the calculated value. ErrBadChecksum = errors.New("bad extended key checksum") // ErrInvalidKeyLen describes an error in which the provided serialized // key is not the expected length. ErrInvalidKeyLen = errors.New("the provided serialized extended key " + "length is invalid") )
var ED25519CurvePhrase = []byte("ed25519 seed")
var Secp256k1CurvePhrase = []byte("Bitcoin seed")
Secp256k1CurvePhrase is the master key used along with a random seed used to generate the master node in the hierarchical tree.
Functions ¶
This section is empty.
Types ¶
type Ed25519 ¶
type Ed25519 struct{}
func (*Ed25519) Child ¶
func (e *Ed25519) Child(k ExtendedKey, i uint32) (*ExtendedKey, error)
type ExtendedKey ¶
type ExtendedKey struct {
// contains filtered or unexported fields
}
ExtendedKey houses all the information needed to support a hierarchical deterministic extended key. See the package overview documentation for more details on how to use extended keys.
func Ed25519Child ¶
func Ed25519Child(k *ExtendedKey, i uint32) (*ExtendedKey, error)
func Ed25519Child64 ¶
func Ed25519Child64(k *ExtendedKey, i uint64) (*ExtendedKey, error)
func MasterKeyForSliceEncryption ¶
func MasterKeyForSliceEncryption(seedBytes []byte, nonce uint32) (*ExtendedKey, error)
func MasterKeyFromMnemonic ¶
func MasterKeyFromMnemonic(mnemonic []string, passphrase string) (*ExtendedKey, error)
func MasterKeyFromPassphrase ¶
func MasterKeyFromPassphrase(passphrase string) (*ExtendedKey, []string, error)
func MasterKeyGenerate ¶
func MasterKeyGenerate(seedBytes []byte, masterKey []byte) *ExtendedKey
func NewExtendedKey ¶
func NewExtendedKey(key, chainCode, parentFP []byte, depth uint8, childNum uint32, isPrivate bool) *ExtendedKey
NewExtendedKey returns a new instance of an extended key with the given fields. No error checking is performed here as it's only intended to be a convenience method used to create a populated struct. This function should only by used by applications that need to create custom ExtendedKeys. All other applications should just use NewMaster, Child, or Neuter.
func (ExtendedKey) Depth ¶
func (e ExtendedKey) Depth() uint8
func (ExtendedKey) PrivateKey ¶
func (e ExtendedKey) PrivateKey() []byte
func (ExtendedKey) PublicKey ¶
func (e ExtendedKey) PublicKey() []byte
type Secp256K1 ¶
type Secp256K1 struct{}
func (*Secp256K1) Child ¶
func (s *Secp256K1) Child(k ExtendedKey, i uint32) (*ExtendedKey, error)