-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.go
More file actions
113 lines (95 loc) · 3.07 KB
/
Copy pathtypes.go
File metadata and controls
113 lines (95 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*******************************************************************************
* (c) 2018 - 2022 ZondaX AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
********************************************************************************/
package ledger_avalanche_go
import (
"fmt"
ledger_go "github.com/zondax/ledger-go"
)
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
)
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
)
// LedgerAvalanche represents a connection to the Avax app in a Ledger device
type LedgerAvalanche struct {
api ledger_go.LedgerDevice
version VersionInfo
}
// VersionInfo contains app version information
type VersionInfo struct {
AppMode uint8
Major uint8
Minor uint8
Patch uint8
}
func (c VersionInfo) String() string {
return fmt.Sprintf("%d.%d.%d", c.Major, c.Minor, c.Patch)
}
type VersionRequiredError struct {
Found VersionInfo
Required VersionInfo
}
type ResponseSign struct {
Hash []byte
Signature map[string][]byte
}
type ResponseAddr struct {
PublicKey []byte
Hash []byte
Address string
}