Documentation ¶
Index ¶
- Constants
- func CheckVersion(ver VersionInfo, req VersionInfo) error
- func ConcatMessageAndChangePath(message []byte, path []string) []byte
- func NewVersionRequiredError(req VersionInfo, ver VersionInfo) error
- func RemoveDuplicates(elements []string) []string
- func SerializeChainID(chainID string) ([]byte, error)
- func SerializeHrp(hrp string) ([]byte, error)
- func SerializePath(path string) ([]byte, error)
- func SerializePathSuffix(path string) ([]byte, error)
- func VerifySignature(pubkey, hash, signature []byte) bool
- type LedgerAvalanche
- func (ledger *LedgerAvalanche) CheckVersion(ver VersionInfo) error
- func (ledger *LedgerAvalanche) Close() error
- func (ledger *LedgerAvalanche) GetExtPubKey(path string, show bool, hrp string, chainid string) ([]byte, []byte, error)
- func (ledger *LedgerAvalanche) GetPubKey(path string, show bool, hrp string, chainid string) (*ResponseAddr, error)
- func (ledger *LedgerAvalanche) GetVersion() (*VersionInfo, error)
- func (ledger *LedgerAvalanche) Sign(pathPrefix string, signingPaths []string, message []byte, changePaths []string) (*ResponseSign, error)
- func (ledger *LedgerAvalanche) SignHash(pathPrefix string, signingPaths []string, hash []byte) (*ResponseSign, error)
- func (ledger *LedgerAvalanche) VerifyMultipleSignatures(response ResponseSign, messageHash []byte, rootPath string, ...) error
- type LedgerError
- type ResponseAddr
- type ResponseSign
- type VersionInfo
- type VersionRequiredError
Constants ¶
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 NewVersionRequiredError ¶
func NewVersionRequiredError(req VersionInfo, ver VersionInfo) error
func RemoveDuplicates ¶
func SerializeChainID ¶
SerializeChainID serializes a chain ID into a byte slice
func SerializeHrp ¶
SerializeHrp serializes an HRP into a byte slice
func SerializePath ¶
func SerializePathSuffix ¶
func VerifySignature ¶
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 LedgerAvalanche ¶
type LedgerAvalanche struct {
// contains filtered or unexported fields
}
LedgerAvalanche represents a connection to the Avax app in a Ledger device
func FindLedgerAvalancheApp ¶
func FindLedgerAvalancheApp() (_ *LedgerAvalanche, rerr error)
FindLedgerAvalancheApp FindLedgerAvalancheUserApp finds a Avax user app running in a ledger device
func (*LedgerAvalanche) CheckVersion ¶
func (ledger *LedgerAvalanche) CheckVersion(ver VersionInfo) error
CheckVersion returns true if the App version is supported by this library
func (*LedgerAvalanche) Close ¶
func (ledger *LedgerAvalanche) Close() error
Close closes a connection with the Avalanche user app
func (*LedgerAvalanche) GetExtPubKey ¶
func (ledger *LedgerAvalanche) GetExtPubKey(path string, show bool, hrp string, chainid string) ([]byte, []byte, error)
GetExtPubKey returns the extended pubkey
func (*LedgerAvalanche) GetPubKey ¶
func (ledger *LedgerAvalanche) GetPubKey(path string, show bool, hrp string, chainid string) (*ResponseAddr, error)
GetPubKey returns the pubkey and hash
func (*LedgerAvalanche) GetVersion ¶
func (ledger *LedgerAvalanche) GetVersion() (*VersionInfo, error)
GetVersion returns the current version of the Avalanche user app
func (*LedgerAvalanche) Sign ¶
func (ledger *LedgerAvalanche) Sign(pathPrefix string, signingPaths []string, message []byte, changePaths []string) (*ResponseSign, error)
func (*LedgerAvalanche) SignHash ¶
func (ledger *LedgerAvalanche) SignHash(pathPrefix string, signingPaths []string, hash []byte) (*ResponseSign, error)
func (*LedgerAvalanche) VerifyMultipleSignatures ¶
func (ledger *LedgerAvalanche) 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 ResponseSign ¶
func SignAndCollect ¶
func SignAndCollect(signingPaths []string, ledger *LedgerAvalanche) (*ResponseSign, error)
type VersionInfo ¶
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