chainkd

package
v0.0.0-...-ff6bfbe Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBadKeyStr = errors.New("bad key string")

ErrBadKeyStr is produced when an error is encountered parsing an XPub or XPrv.

Functions

func NewXKeys

func NewXKeys(r io.Reader) (xprv XPrv, xpub XPub, err error)

NewXKeys produces a new keypair from a source of random bytes.

func XPubKeys

func XPubKeys(xpubs []XPub) []ed25519.PublicKey

XPubKeys extracts the ed25519.PublicKey from each XPub.

Types

type XPrv

type XPrv [64]byte

XPrv is an extended private key from which child keys may be derived.

func NewXPrv

func NewXPrv(r io.Reader) (xprv XPrv, err error)

NewXPrv takes a source of random bytes and produces a new XPrv. If r is nil, crypto/rand.Reader is used.

func (XPrv) Bytes

func (xprv XPrv) Bytes() []byte

Bytes produces xprv as a byte slice.

func (XPrv) Child

func (xprv XPrv) Child(sel []byte, hardened bool) (res XPrv)

Child produces the child of xprv with the given selector.

func (XPrv) Derive

func (xprv XPrv) Derive(path [][]byte) XPrv

Derive produces the descendant of the XPrv at the given path. It's equivalent to repeated calls of xprv.Child with the elements of path.

func (XPrv) MarshalText

func (xprv XPrv) MarshalText() ([]byte, error)

MarshalText satisfies the encoding.TextMarshaler interface.

func (XPrv) Sign

func (xprv XPrv) Sign(msg []byte) []byte

Sign produces a chainkd signature of msg using xprv.

func (XPrv) String

func (xprv XPrv) String() string

func (*XPrv) UnmarshalText

func (xprv *XPrv) UnmarshalText(inp []byte) error

UnmarshalText satisfies the encoding.TextUnmarshaler interface.

func (XPrv) XPub

func (xprv XPrv) XPub() XPub

XPub produces the XPub corresponding to xprv.

type XPub

type XPub [64]byte

XPub is an extended public key from which child keys may be derived.

func DeriveXPubs

func DeriveXPubs(xpubs []XPub, path [][]byte) []XPub

DeriveXPubs calls Derive on each XPub, all with the same path.

func (XPub) Bytes

func (xpub XPub) Bytes() []byte

Bytes produces xpub as a byte slice.

func (XPub) Child

func (xpub XPub) Child(sel []byte) (res XPub)

Child produces the child of xpub with the given selector.

func (XPub) Derive

func (xpub XPub) Derive(path [][]byte) XPub

Derive produces the descendant of the XPub at the given path. It's equivalent to repeated calls of xpub.Child with the elements of path.

func (XPub) MarshalText

func (xpub XPub) MarshalText() ([]byte, error)

MarshalText satisfies the encoding.TextMarshaler interface.

func (XPub) PublicKey

func (xpub XPub) PublicKey() ed25519.PublicKey

PublicKey extracts the ed25519 public key from an xpub.

func (XPub) String

func (xpub XPub) String() string

String produces a hex-encoded copy of xpub.

func (*XPub) UnmarshalText

func (xpub *XPub) UnmarshalText(inp []byte) error

UnmarshalText satisfies the encoding.TextUnmarshaler interface.

func (XPub) Verify

func (xpub XPub) Verify(msg []byte, sig []byte) bool

Verify verifies that sig is a proper signature of msg using xpub's corresponding XPrv.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL