keychain

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package keychain is a generated GoMock package.

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

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

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

type Ledger

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 MockLedger

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

MockLedger is a mock of Ledger interface.

func NewMockLedger

func NewMockLedger(ctrl *gomock.Controller) *MockLedger

NewMockLedger creates a new mock instance.

func (*MockLedger) Address

func (m *MockLedger) Address(arg0 string, arg1 uint32) (ids.ShortID, error)

Address mocks base method.

func (*MockLedger) Addresses

func (m *MockLedger) Addresses(arg0 []uint32) ([]ids.ShortID, error)

Addresses mocks base method.

func (*MockLedger) Disconnect

func (m *MockLedger) Disconnect() error

Disconnect mocks base method.

func (*MockLedger) EXPECT

func (m *MockLedger) EXPECT() *MockLedgerMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockLedger) Sign

func (m *MockLedger) Sign(arg0 []byte, arg1 []uint32) ([][]byte, error)

Sign mocks base method.

func (*MockLedger) SignHash

func (m *MockLedger) SignHash(arg0 []byte, arg1 []uint32) ([][]byte, error)

SignHash mocks base method.

func (*MockLedger) Version

func (m *MockLedger) Version() (*version.Semantic, error)

Version mocks base method.

type MockLedgerMockRecorder

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

MockLedgerMockRecorder is the mock recorder for MockLedger.

func (*MockLedgerMockRecorder) Address

func (mr *MockLedgerMockRecorder) Address(arg0, arg1 any) *gomock.Call

Address indicates an expected call of Address.

func (*MockLedgerMockRecorder) Addresses

func (mr *MockLedgerMockRecorder) Addresses(arg0 any) *gomock.Call

Addresses indicates an expected call of Addresses.

func (*MockLedgerMockRecorder) Disconnect

func (mr *MockLedgerMockRecorder) Disconnect() *gomock.Call

Disconnect indicates an expected call of Disconnect.

func (*MockLedgerMockRecorder) Sign

func (mr *MockLedgerMockRecorder) Sign(arg0, arg1 any) *gomock.Call

Sign indicates an expected call of Sign.

func (*MockLedgerMockRecorder) SignHash

func (mr *MockLedgerMockRecorder) SignHash(arg0, arg1 any) *gomock.Call

SignHash indicates an expected call of SignHash.

func (*MockLedgerMockRecorder) Version

func (mr *MockLedgerMockRecorder) Version() *gomock.Call

Version indicates an expected call of Version.

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

Jump to

Keyboard shortcuts

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