aboutsummaryrefslogtreecommitdiffstats
path: root/ethutil/key.go
blob: ec195f2136b1e4da39363103a4cac5aba040b5f7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package ethutil

type Key struct {
    PrivateKey []byte
    PublicKey  []byte
}

func NewKeyFromBytes(data []byte) *Key {
    val := NewValueFromBytes(data)
    return &Key{val.Get(0).Bytes(), val.Get(1).Bytes()}
}

func (k *Key) Address() []byte {
    return Sha3Bin(k.PublicKey[1:])[12:]
}

func (k *Key) RlpEncode() []byte {
    return EmptyValue().Append(k.PrivateKey).Append(k.PublicKey).Encode()
}