-
Notifications
You must be signed in to change notification settings - Fork 5
/
types.go
67 lines (56 loc) · 1.43 KB
/
types.go
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
package statuskeycardgo
import (
"encoding/json"
)
type hexString []byte
// MarshalJSON serializes hexString to hex
func (s hexString) MarshalJSON() ([]byte, error) {
bytes, err := json.Marshal(btox(s))
return bytes, err
}
// UnmarshalJSON deserializes hexString to hex
func (s *hexString) UnmarshalJSON(data []byte) error {
var x string
err := json.Unmarshal(data, &x)
if err != nil {
return err
}
str, err := xtob(x)
if err != nil {
return err
}
*s = hexString([]byte(str))
return nil
}
type Signature struct {
R hexString `json:"r"`
S hexString `json:"s"`
V byte `json:"v"`
}
type ApplicationInfo struct {
Initialized bool `json:"initialized"`
InstanceUID hexString `json:"instanceUID"`
Version int `json:"version"`
AvailableSlots int `json:"availableSlots"`
// KeyUID is the sha256 of of the master public key on the card.
// It's empty if the card doesn't contain any key.
KeyUID hexString `json:"keyUID"`
}
type PairingInfo struct {
Key hexString `json:"key"`
Index int `json:"index"`
}
type KeyPair struct {
Address string `json:"address"`
PublicKey hexString `json:"publicKey"`
PrivateKey hexString `json:"privateKey,omitempty"`
}
type Wallet struct {
Path string `json:"path"`
Address string `json:"address,omitempty"`
PublicKey hexString `json:"publicKey"`
}
type Metadata struct {
Name string `json:"name"`
Wallets []Wallet `json:"wallets"`
}