mirror of
https://github.com/status-im/status-keycard-go.git
synced 2025-01-31 00:28:40 +00:00
41 lines
716 B
Go
41 lines
716 B
Go
package main
|
|
|
|
import (
|
|
"encoding/hex"
|
|
"encoding/json"
|
|
"fmt"
|
|
)
|
|
|
|
type hexString []byte
|
|
|
|
// MarshalJSON serializes hexString to hex
|
|
func (s hexString) MarshalJSON() ([]byte, error) {
|
|
bytes, err := json.Marshal(fmt.Sprintf("%x", string(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 := hex.DecodeString(x)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
*s = hexString([]byte(str))
|
|
return nil
|
|
}
|
|
|
|
type openSecureChannelParams struct {
|
|
Index int `json:"index"`
|
|
Key hexString `json:"key"`
|
|
}
|
|
|
|
type verifyPinParams struct {
|
|
Pin string `json:"pin"`
|
|
}
|