ledger

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPrivKeySecp256k1

func NewPrivKeySecp256k1(path hd.BIP44Params, hrp string) (types.LedgerPrivKey, string, error)

NewPrivKeySecp256k1 will generate a new key and store the public key for later use. The request will require user confirmation and will show account and index in the device

func NewPrivKeySecp256k1Unsafe

func NewPrivKeySecp256k1Unsafe(path hd.BIP44Params) (types.LedgerPrivKeyAminoJSON, error)

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

This function is marked as unsafe as it will retrieve a pubkey without user verification. It can only be used to verify a pubkey but never to create new accounts/keys. In that case, please refer to NewPrivKeySecp256k1

func RegisterAmino

func RegisterAmino(cdc *codec.LegacyAmino)

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

func SetAppName

func SetAppName(appName string)

Set the Ledger app name to use a different app name

func SetCreatePubkey

func SetCreatePubkey(fn createPubkeyFn)

Set the createPubkey function to use a different public key

func SetDiscoverLedger

func SetDiscoverLedger(fn discoverLedgerFn)

Set the discoverLedger function to use a different Ledger derivation

func SetSkipDERConversion

func SetSkipDERConversion()

Set the DER Conversion requirement to true (false by default)

func ShowAddress

func ShowAddress(path hd.BIP44Params, expectedPubKey types.PubKey, accountAddressPrefix string) error

ShowAddress triggers a ledger device to show the corresponding address.

Types

type Options

type Options struct {
	// contains filtered or unexported fields
}

Options hosts customization options to account for differences in Ledger signing and usage across chains.

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 types.PubKey
	Path         hd.BIP44Params
}

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 types.LedgerPrivKey) 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() types.PubKey

PubKey returns the cached public key.

func (PrivKeyLedgerSecp256k1) Sign

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

Sign returns a secp256k1 signature for the corresponding message using SIGN_MODE_TEXTUAL.

func (PrivKeyLedgerSecp256k1) SignLedgerAminoJSON

func (pkl PrivKeyLedgerSecp256k1) SignLedgerAminoJSON(message []byte) ([]byte, error)

SignLedgerAminoJSON returns a secp256k1 signature for the corresponding message using SIGN_MODE_LEGACY_AMINO_JSON.

func (PrivKeyLedgerSecp256k1) Type

func (pkl PrivKeyLedgerSecp256k1) Type() string

func (PrivKeyLedgerSecp256k1) ValidateKey

func (pkl PrivKeyLedgerSecp256k1) ValidateKey() error

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

type SECP256K1

type SECP256K1 interface {
	Close() error
	// Returns an uncompressed pubkey
	GetPublicKeySECP256K1([]uint32) ([]byte, error)
	// Returns a compressed pubkey and bech32 address (requires user confirmation)
	GetAddressPubKeySECP256K1([]uint32, string) ([]byte, string, error)
	// Signs a message (requires user confirmation)
	// The last byte denotes the SIGN_MODE to be used by Ledger: 0 for
	// LEGACY_AMINO_JSON, 1 for TEXTUAL. It corresponds to the P2 value
	// in https://github.com/cosmos/ledger-cosmos/blob/main/docs/APDUSPEC.md
	SignSECP256K1([]uint32, []byte, byte) ([]byte, error)
}

SECP256K1 reflects an interface a Ledger API must implement for SECP256K1

Jump to

Keyboard shortcuts

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