Newer
Older
Silas Davis
committed
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
package account
import "github.com/tendermint/go-crypto"
// This allows us to control serialisation
type PublicKey struct {
crypto.PubKey `json:"unwrap"`
}
func PublicKeyFromPubKey(pubKey crypto.PubKey) PublicKey {
return PublicKey{PubKey: pubKey}
}
func PrivateKeyFromPrivKey(privKey crypto.PrivKey) PrivateKey {
return PrivateKey{PrivKey: privKey}
}
func (pk PublicKey) Address() Address {
return MustAddressFromBytes(pk.PubKey.Address())
}
func (pk PublicKey) MarshalJSON() ([]byte, error) {
return pk.PubKey.MarshalJSON()
}
func (pk *PublicKey) UnmarshalJSON(data []byte) error {
return pk.PubKey.UnmarshalJSON(data)
}
func (pk PublicKey) MarshalText() ([]byte, error) {
return pk.MarshalJSON()
}
func (pk *PublicKey) UnmarshalText(text []byte) error {
return pk.UnmarshalJSON(text)
}
type PrivateKey struct {
crypto.PrivKey
}
func (pk PrivateKey) PublicKey() PublicKey {
return PublicKeyFromPubKey(pk.PubKey())
}
func (pk PrivateKey) MarshalJSON() ([]byte, error) {
return pk.PrivKey.MarshalJSON()
}
func (pk *PrivateKey) UnmarshalJSON(data []byte) error {
return pk.PrivKey.UnmarshalJSON(data)
}
func (pk PrivateKey) MarshalText() ([]byte, error) {
return pk.MarshalJSON()
}
func (pk *PrivateKey) UnmarshalText(text []byte) error {
return pk.UnmarshalJSON(text)
}