|
|
@ -51,6 +51,30 @@ func (pub PublicKey) String() string { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// UnmarshalText loads the value from base64
|
|
|
|
|
|
|
|
func (key *PrivateKey) UnmarshalText(b []byte) error { |
|
|
|
|
|
|
|
v, err := PrivateKeyFromBase64(string(b)) |
|
|
|
|
|
|
|
switch { |
|
|
|
|
|
|
|
case err != nil: |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
*key = v |
|
|
|
|
|
|
|
return nil |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// UnmarshalText loads the value from base64
|
|
|
|
|
|
|
|
func (pub *PublicKey) UnmarshalText(b []byte) error { |
|
|
|
|
|
|
|
v, err := PublicKeyFromBase64(string(b)) |
|
|
|
|
|
|
|
switch { |
|
|
|
|
|
|
|
case err != nil: |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
*pub = v |
|
|
|
|
|
|
|
return nil |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// MarshalJSON encodes the key for JSON, omitting empty.
|
|
|
|
// MarshalJSON encodes the key for JSON, omitting empty.
|
|
|
|
func (key PrivateKey) MarshalJSON() ([]byte, error) { |
|
|
|
func (key PrivateKey) MarshalJSON() ([]byte, error) { |
|
|
|
return encodeKeyJSON(key.String()) |
|
|
|
return encodeKeyJSON(key.String()) |
|
|
|