ledger_aegon_go

package module
v0.0.0-...-64b1053 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

README

ledger-aegon-go

Test


zondax_light zondax_dark

Please visit our website at zondax.ch


This project contains a Golang package to communicate with Aegon app for Ledger Nano S, S+ and X.

Documentation

Index

Constants

View Source
const (
	CLA     = 0x80
	CLA_ETH = 0xE0

	CHUNK_SIZE = 250
	HASH_LEN   = 32

	PAYLOAD_INIT = 0x00
	PAYLOAD_ADD  = 0x01
	PAYLOAD_LAST = 0x02

	FIRST_MESSAGE = 0x01
	LAST_MESSAGE  = 0x02
	NEXT_MESSAGE  = 0x03

	P1_ONLY_RETRIEVE          = 0x00
	P1_SHOW_ADDRESS_IN_DEVICE = 0x01

	INS_GET_VERSION             = 0x00
	INS_WALLET_ID               = 0x01
	INS_GET_ADDR                = 0x02
	INS_GET_EXTENDED_PUBLIC_KEY = 0x03
	INS_SIGN_HASH               = 0x04
	INS_SIGN                    = 0x05
	INS_SIGN_MSG                = 0x06

	HARDENED = 0x80000000
)

Variables

This section is empty.

Functions

func CheckVersion

func CheckVersion(ver VersionInfo, req VersionInfo) error

CheckVersion compares the current version with the required version

func ConcatMessageAndChangePath

func ConcatMessageAndChangePath(message []byte, path []string) []byte

func NewVersionRequiredError

func NewVersionRequiredError(req VersionInfo, ver VersionInfo) error

func RemoveDuplicates

func RemoveDuplicates(elements []string) []string

func SerializeChainID

func SerializeChainID(chainID string) ([]byte, error)

SerializeChainID serializes a chain ID into a byte slice

func SerializeHrp

func SerializeHrp(hrp string) ([]byte, error)

SerializeHrp serializes an HRP into a byte slice

func SerializePath

func SerializePath(path string) ([]byte, error)

func SerializePathSuffix

func SerializePathSuffix(path string) ([]byte, error)

func VerifySignature

func VerifySignature(pubkey, hash, signature []byte) bool

VerifySignature checks that the given public key created signature over hash. The public key should be in compressed (33 bytes) or uncompressed (65 bytes) format. The signature should have the 64 byte [R || S] format.

Types

type LedgerAegon

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

LedgerAegon represents a connection to the Aeg app in a Ledger device

func FindLedgerAegonApp

func FindLedgerAegonApp() (_ *LedgerAegon, rerr error)

FindLedgerAegonApp FindLedgerAegonUserApp finds a Aeg user app running in a ledger device

func (*LedgerAegon) CheckVersion

func (ledger *LedgerAegon) CheckVersion(ver VersionInfo) error

CheckVersion returns true if the App version is supported by this library

func (*LedgerAegon) Close

func (ledger *LedgerAegon) Close() error

Close closes a connection with the Aegon user app

func (*LedgerAegon) GetPubKey

func (ledger *LedgerAegon) GetPubKey(path string, show bool, hrp string, chainid string) (*ResponseAddr, error)

GetPubKey returns the pubkey and hash

func (*LedgerAegon) GetVersion

func (ledger *LedgerAegon) GetVersion() (*VersionInfo, error)

GetVersion returns the current version of the Aegon user app

func (*LedgerAegon) Sign

func (ledger *LedgerAegon) Sign(pathPrefix string, signingPaths []string, message []byte, changePaths []string) (*ResponseSign, error)

func (*LedgerAegon) SignHash

func (ledger *LedgerAegon) SignHash(pathPrefix string, signingPaths []string, hash []byte) (*ResponseSign, error)

func (*LedgerAegon) VerifyMultipleSignatures

func (ledger *LedgerAegon) VerifyMultipleSignatures(response ResponseSign, messageHash []byte, rootPath string, signingPaths []string, hrp string, chainID string) error

type LedgerError

type LedgerError int
const (
	U2FUnknown                  LedgerError = 1
	U2FBadRequest               LedgerError = 2
	U2FConfigurationUnsupported LedgerError = 3
	U2FDeviceIneligible         LedgerError = 4
	U2FTimeout                  LedgerError = 5
	Timeout                     LedgerError = 14
	NoErrors                    LedgerError = 0x9000
	DeviceIsBusy                LedgerError = 0x9001
	ErrorDerivingKeys           LedgerError = 0x6802
	ExecutionError              LedgerError = 0x6400
	WrongLength                 LedgerError = 0x6700
	EmptyBuffer                 LedgerError = 0x6982
	OutputBufferTooSmall        LedgerError = 0x6983
	DataIsInvalid               LedgerError = 0x6a80
	ConditionsNotSatisfied      LedgerError = 0x6985
	TransactionRejected         LedgerError = 0x6986
	BadKeyHandle                LedgerError = 0x6a81
	InvalidP1P2                 LedgerError = 0x6b00
	InstructionNotSupported     LedgerError = 0x6d00
	AppDoesNotSeemToBeOpen      LedgerError = 0x6e01
	UnknownError                LedgerError = 0x6f00
	SignVerifyError             LedgerError = 0x6f01
)

type ResponseAddr

type ResponseAddr struct {
	PublicKey []byte
	Hash      []byte
	Address   string
}

type ResponseSign

type ResponseSign struct {
	Hash      []byte
	Signature map[string][]byte
}

func SignAndCollect

func SignAndCollect(signingPaths []string, ledger *LedgerAegon) (*ResponseSign, error)

type VersionInfo

type VersionInfo struct {
	AppMode uint8
	Major   uint8
	Minor   uint8
	Patch   uint8
}

VersionInfo contains app version information

func (VersionInfo) String

func (c VersionInfo) String() string

type VersionRequiredError

type VersionRequiredError struct {
	Found    VersionInfo
	Required VersionInfo
}

func (VersionRequiredError) Error

func (e VersionRequiredError) Error() string

Jump to

Keyboard shortcuts

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