ledger

package module
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2023 License: BSD-3-Clause Imports: 12 Imported by: 0

README

ledger-sdk

Golang SDK for Using the Lux Ledger App

Example

device, err := Connect()
if err != nil {
  panic(err)
}

// Get version
version, commit, name, err := device.Version()
if err != nil {
  panic(err)
}
fmt.Printf("version: %s commit: %s name: %s\n", version, commit, name)

// Get Fuji Address
address, err := device.Address("fuji", 0, 0)
if err != nil {
  panic(err)
}
fmt.Printf("address: %s\n", address)

// Sign Hash
rawHash := hashing.ComputeHash256([]byte{0x1, 0x2, 0x3, 0x4})
suffixes := [][]uint32{{0, 1}, {0, 3}}
sigs, err := device.SignHash(rawHash, suffixes)
if err != nil {
  panic(err)
}

TODO

  • Add X-Chain Support (change indices)
  • Add C-Chain Support
  • Support Transaction Parsing (only sign hashes right now)

NOTE: THIS PROJECT IS ACTIVELY DEVELOPED AND MAY INCUR BREAKING CHANGES

Documentation

Index

Constants

View Source
const (
	CLA                   = 0x80
	INSVersion            = 0x00
	INSPromptPublicKey    = 0x02
	INSPromptExtPublicKey = 0x03
	INSSignHash           = 0x04
)
View Source
const (
	// PublicKeyCompressedLength is the byte count of a compressed public key
	PublicKeyCompressedLength = 33
)

Variables

View Source
var (
	ErrLedgerNotConnected       = errors.New("ledger is not connected")
	ErrAvalancheAppNotExecuting = errors.New("ledger is not executing avalanche app")
	ErrLedgerIsBlocked          = errors.New("ledger is blocked")
	ErrRejectedSignature        = errors.New("hash sign operation rejected by ledger user")
	ErrRejectedKeyProvide       = errors.New("public key provide operation rejected by ledger user")
)

Functions

func NewChild

func NewChild(key []byte, chainCode []byte, childIdx uint32) ([]byte, error)

Types

type Ledger

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

Ledger interface for the ledger wrapper

func New

func New() (Ledger, error)

New attempts to connect to a Ledger on the device over HID.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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