keychain

package
v1.11.11-rc.2 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: BSD-3-Clause Imports: 5 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidIndicesLength    = errors.New("number of indices should be greater than 0")
	ErrInvalidNumAddrsToDerive = errors.New("number of addresses to derive should be greater than 0")
	ErrInvalidNumAddrsDerived  = errors.New("incorrect number of ledger derived addresses")
	ErrInvalidNumSignatures    = errors.New("incorrect number of signatures")
)

Functions

This section is empty.

Types

type Keychain

type Keychain interface {
	// The returned Signer can provide a signature for [addr]
	Get(addr ids.ShortID) (Signer, bool)
	// Returns the set of addresses for which the accessor keeps an associated
	// signer
	Addresses() set.Set[ids.ShortID]
}

Keychain maintains a set of addresses together with their corresponding signers

func NewLedgerKeychain

func NewLedgerKeychain(l Ledger, numToDerive int) (Keychain, error)

NewLedgerKeychain creates a new Ledger with [numToDerive] addresses.

func NewLedgerKeychainFromIndices added in v1.9.3

func NewLedgerKeychainFromIndices(l Ledger, indices []uint32) (Keychain, error)

NewLedgerKeychainFromIndices creates a new Ledger with addresses taken from the given [indices].

type Ledger added in v1.9.6

type Ledger interface {
	Version() (v *version.Semantic, err error)
	Address(displayHRP string, addressIndex uint32) (ids.ShortID, error)
	Addresses(addressIndices []uint32) ([]ids.ShortID, error)
	SignHash(hash []byte, addressIndices []uint32) ([][]byte, error)
	Sign(unsignedTxBytes []byte, addressIndices []uint32) ([][]byte, error)
	Disconnect() error
}

Ledger interface for the ledger wrapper

type Signer

type Signer interface {
	SignHash([]byte) ([]byte, error)
	Sign([]byte) ([]byte, error)
	Address() ids.ShortID
}

Signer implements functions for a keychain to return its main address and to sign a hash

Directories

Path Synopsis
Package keychainmock is a generated GoMock package.
Package keychainmock is a generated GoMock package.

Jump to

Keyboard shortcuts

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