ledger

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0, UNKNOWN, UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Overview

Package ledger contains the internals for package crypto/keys/ledger, primarily existing so that the Discover function can be mocked elsewhere.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DiscoverFn

type DiscoverFn func() (SECP256K1, error)

DiscoverFn defines a Ledger discovery function that returns a connected device or an error upon failure. Its allows a method to avoid CGO dependencies when Ledger support is potentially not enabled.

var Discover DiscoverFn = DiscoverDefault

Discover defines a function to be invoked at runtime for discovering a connected Ledger device.

type MockLedger

type MockLedger struct{}

MockLedger is an interface that can be used to create mock [Ledger]. Embed it in another type, and implement the method you want to mock:

type MyMock struct { MockLedger }
func (MyMock) SignSECP256K1(d1, d2 []byte, d3 byte) ([]byte, error) { ... }

func (MockLedger) Close

func (MockLedger) Close() error

func (MockLedger) GetAddressPubKeySECP256K1

func (MockLedger) GetAddressPubKeySECP256K1(data []uint32, str string) ([]byte, string, error)

func (MockLedger) GetPublicKeySECP256K1

func (MockLedger) GetPublicKeySECP256K1(data []uint32) ([]byte, error)

func (MockLedger) SignSECP256K1

func (MockLedger) SignSECP256K1(d1 []uint32, d2 []byte, d3 byte) ([]byte, error)

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)
	SignSECP256K1([]uint32, []byte, byte) ([]byte, error)
}

SECP256K1 reflects an interface a Ledger API must implement for SECP256K1

func DiscoverDefault

func DiscoverDefault() (SECP256K1, error)

DiscoverDefault is the default function for Discover.

func DiscoverMock

func DiscoverMock() (SECP256K1, error)

DiscoverMock can be used as a mock DiscoverFn.

Jump to

Keyboard shortcuts

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