crypto

package
v0.25.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPrivKeyLedgerSecp256k1

func NewPrivKeyLedgerSecp256k1(path DerivationPath) (tmcrypto.PrivKey, error)

NewPrivKeyLedgerSecp256k1 will generate a new key and store the public key for later use.

CONTRACT: The ledger device, ledgerDevice, must be loaded and set prior to any creation of a PrivKeyLedgerSecp256k1.

func RegisterAmino

func RegisterAmino(cdc *amino.Codec)

RegisterAmino registers all go-crypto related types in the given (amino) codec.

Types

type DerivationPath

type DerivationPath []uint32

DerivationPath represents a Ledger derivation path.

type LedgerSECP256K1

type LedgerSECP256K1 interface {
	GetPublicKeySECP256K1([]uint32) ([]byte, error)
	SignSECP256K1([]uint32, []byte) ([]byte, error)
}

LedgerSECP256K1 reflects an interface a Ledger API must implement for the SECP256K1 scheme.

type PrivKeyLedgerSecp256k1

type PrivKeyLedgerSecp256k1 struct {
	// CachedPubKey should be private, but we want to encode it via
	// go-amino so we can view the address later, even without having the
	// ledger attached.
	CachedPubKey tmcrypto.PubKey
	Path         DerivationPath
	// contains filtered or unexported fields
}

PrivKeyLedgerSecp256k1 implements PrivKey, calling the ledger nano we cache the PubKey from the first call to use it later.

func (*PrivKeyLedgerSecp256k1) AssertIsPrivKeyInner

func (pkl *PrivKeyLedgerSecp256k1) AssertIsPrivKeyInner()

AssertIsPrivKeyInner implements the PrivKey interface. It performs a no-op.

func (PrivKeyLedgerSecp256k1) Bytes

func (pkl PrivKeyLedgerSecp256k1) Bytes() []byte

Bytes implements the PrivKey interface. It stores the cached public key so we can verify the same key when we reconnect to a ledger.

func (PrivKeyLedgerSecp256k1) Equals

func (pkl PrivKeyLedgerSecp256k1) Equals(other tmcrypto.PrivKey) bool

Equals implements the PrivKey interface. It makes sure two private keys refer to the same public key.

func (PrivKeyLedgerSecp256k1) PubKey

func (pkl PrivKeyLedgerSecp256k1) PubKey() tmcrypto.PubKey

PubKey returns the cached public key.

func (PrivKeyLedgerSecp256k1) Sign

func (pkl PrivKeyLedgerSecp256k1) Sign(msg []byte) ([]byte, error)

Sign calls the ledger and stores the PubKey for future use.

Communication is checked on NewPrivKeyLedger and PrivKeyFromBytes, returning an error, so this should only trigger if the private key is held in memory for a while before use.

func (PrivKeyLedgerSecp256k1) ValidateKey

func (pkl PrivKeyLedgerSecp256k1) ValidateKey() error

ValidateKey allows us to verify the sanity of a public key after loading it from disk.

Directories

Path Synopsis
hd
Package hd provides basic functionality Hierarchical Deterministic Wallets.
Package hd provides basic functionality Hierarchical Deterministic Wallets.

Jump to

Keyboard shortcuts

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