68 lines
1.4 KiB
Go
Raw Normal View History

package statuskeycardgo
2021-09-13 13:09:23 +02:00
import (
"encoding/json"
)
type hexString []byte
// MarshalJSON serializes hexString to hex
func (s hexString) MarshalJSON() ([]byte, error) {
2021-10-27 08:46:00 +03:00
bytes, err := json.Marshal(btox(s))
2021-09-13 13:09:23 +02:00
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
}
2021-10-27 08:46:00 +03:00
str, err := xtob(x)
2021-09-13 13:09:23 +02:00
if err != nil {
return err
}
*s = hexString([]byte(str))
return nil
}
2021-09-14 18:31:02 +02:00
type Signature struct {
2021-10-27 08:46:00 +03:00
R hexString `json:"r"`
S hexString `json:"s"`
V byte `json:"v"`
2021-09-14 18:31:02 +02:00
}
2021-09-28 11:26:45 +02:00
type ApplicationInfo struct {
2021-10-18 14:50:56 +03:00
Initialized bool `json:"initialized"`
InstanceUID hexString `json:"instanceUID"`
Version int `json:"version"`
AvailableSlots int `json:"availableSlots"`
2021-09-28 11:26:45 +02:00
// KeyUID is the sha256 of of the master public key on the card.
// It's empty if the card doesn't contain any key.
2021-10-18 14:50:56 +03:00
KeyUID hexString `json:"keyUID"`
2021-09-28 11:26:45 +02:00
}
2021-09-14 18:31:02 +02:00
type PairingInfo struct {
Key hexString `json:"key"`
Index int `json:"index"`
}
2021-10-21 08:48:51 +03:00
type KeyPair struct {
Address string `json:"address"`
PublicKey hexString `json:"publicKey"`
2021-10-21 09:09:20 +03:00
PrivateKey hexString `json:"privateKey,omitempty"`
2021-10-21 08:48:51 +03:00
}
2022-08-04 11:21:23 +02:00
type Wallet struct {
2022-12-30 08:03:21 +01:00
Path string `json:"path"`
Address string `json:"address,omitempty"`
PublicKey hexString `json:"publicKey"`
2022-08-04 11:21:23 +02:00
}
type Metadata struct {
Name string `json:"name"`
Wallets []Wallet `json:"wallets"`
}