nano

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: Apache-2.0, Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NameLedgerEd25519 = "ledger-ed25519"
	TypeLedgerEd25519 = 0x10

	// Timeout is the number of seconds to wait for a response from the ledger
	// if eg. waiting for user confirmation on button push
	Timeout = 20
)

nolint

View Source
const (
	App       = 0x80
	Init      = 0x00
	Update    = 0x01
	Digest    = 0x02
	MaxChunk  = 253
	KeyLength = 32
	SigLength = 64
)

Variables

This section is empty.

Functions

func NewPrivKeyLedgerEd25519

func NewPrivKeyLedgerEd25519() (crypto.PrivKey, error)

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

func PubKeyLedgerEd25519FromBytes

func PubKeyLedgerEd25519FromBytes(key [32]byte) crypto.PubKey

PubKeyLedgerEd25519FromBytes creates a PubKey from the raw bytes

Types

type MockPrivKeyLedgerEd25519

type MockPrivKeyLedgerEd25519 struct {
	Msg []byte
	Pub [KeyLength]byte
	Sig [SigLength]byte
}

MockPrivKeyLedgerEd25519 behaves as the ledger, but stores a pre-packaged call-response for use in test cases

func NewMockKey

func NewMockKey(msg, pubkey, sig string) (pk MockPrivKeyLedgerEd25519)

NewMockKey returns

func (MockPrivKeyLedgerEd25519) AssertIsPrivKeyInner

func (pk MockPrivKeyLedgerEd25519) AssertIsPrivKeyInner()

AssertIsPrivKeyInner fulfils PrivKey Interface

func (MockPrivKeyLedgerEd25519) Bytes

func (pk MockPrivKeyLedgerEd25519) Bytes() []byte

Bytes fulfils PrivKey Interface - not supported

func (MockPrivKeyLedgerEd25519) Equals

func (pk MockPrivKeyLedgerEd25519) Equals(other crypto.PrivKey) bool

Equals compares that two Mocks have the same data

func (MockPrivKeyLedgerEd25519) PubKey

PubKey returns a real PubKeyLedgerEd25519, that will verify this signature

func (MockPrivKeyLedgerEd25519) Sign

Sign returns a real SignatureLedger, if the msg matches what we expect

func (MockPrivKeyLedgerEd25519) Wrap

Wrap fulfils interface for PrivKey struct

type PrivKeyLedgerEd25519

type PrivKeyLedgerEd25519 struct {
	// PubKey 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 crypto.PubKey
}

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

func (*PrivKeyLedgerEd25519) AssertIsPrivKeyInner

func (pk *PrivKeyLedgerEd25519) AssertIsPrivKeyInner()

AssertIsPrivKeyInner fulfils PrivKey Interface

func (*PrivKeyLedgerEd25519) Bytes

func (pk *PrivKeyLedgerEd25519) Bytes() []byte

Bytes fulfils PrivKey Interface - but it stores the cached pubkey so we can verify the same key when we reconnect to a ledger

func (*PrivKeyLedgerEd25519) Equals

func (pk *PrivKeyLedgerEd25519) Equals(other crypto.PrivKey) bool

Equals fulfils PrivKey Interface - makes sure both keys refer to the same

func (*PrivKeyLedgerEd25519) PubKey

func (pk *PrivKeyLedgerEd25519) PubKey() crypto.PubKey

PubKey returns the stored PubKey TODO: query the ledger if not there, once it is not volatile

func (*PrivKeyLedgerEd25519) Sign

func (pk *PrivKeyLedgerEd25519) Sign(msg []byte) crypto.Signature

Sign calls the ledger and stores the PubKey for future use

XXX/TODO: panics if there is an error communicating with the ledger.

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

func (*PrivKeyLedgerEd25519) ValidateKey

func (pk *PrivKeyLedgerEd25519) ValidateKey() error

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

func (*PrivKeyLedgerEd25519) Wrap

func (pk *PrivKeyLedgerEd25519) Wrap() crypto.PrivKey

Wrap fulfils interface for PrivKey struct

type PubKeyLedgerEd25519

type PubKeyLedgerEd25519 struct {
	crypto.PubKeyEd25519
}

PubKeyLedgerEd25519 works like a normal Ed25519 except a hash before the verify bytes

func (PubKeyLedgerEd25519) Bytes

func (pk PubKeyLedgerEd25519) Bytes() []byte

Bytes fulfils pk Interface - no data, just type info

func (PubKeyLedgerEd25519) Equals

func (pk PubKeyLedgerEd25519) Equals(other crypto.PubKey) bool

Equals implements PubKey interface

func (PubKeyLedgerEd25519) VerifyBytes

func (pk PubKeyLedgerEd25519) VerifyBytes(msg []byte, sig crypto.Signature) bool

VerifyBytes uses the normal Ed25519 algorithm but a sha512 hash beforehand

func (PubKeyLedgerEd25519) Wrap

func (pk PubKeyLedgerEd25519) Wrap() crypto.PubKey

Wrap fulfils interface for PubKey struct

Jump to

Keyboard shortcuts

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