aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-08-13 14:02:23 +0800
committerGitHub <noreply@github.com>2018-08-13 14:02:23 +0800
commit39e2ea5eb982007a7438198f6d633fe580a3fd1f (patch)
treecd87fe44352df53d04ebfab71daf62ce57d46d28 /crypto
parentef8eef3e341777adc00b87c2b226bffbe337ebf6 (diff)
downloadtangerine-consensus-39e2ea5eb982007a7438198f6d633fe580a3fd1f.tar
tangerine-consensus-39e2ea5eb982007a7438198f6d633fe580a3fd1f.tar.gz
tangerine-consensus-39e2ea5eb982007a7438198f6d633fe580a3fd1f.tar.bz2
tangerine-consensus-39e2ea5eb982007a7438198f6d633fe580a3fd1f.tar.lz
tangerine-consensus-39e2ea5eb982007a7438198f6d633fe580a3fd1f.tar.xz
tangerine-consensus-39e2ea5eb982007a7438198f6d633fe580a3fd1f.tar.zst
tangerine-consensus-39e2ea5eb982007a7438198f6d633fe580a3fd1f.zip
core: ValidatorID.Hash is the hash of public key. (#49)
Diffstat (limited to 'crypto')
-rw-r--r--crypto/eth/eth.go5
-rw-r--r--crypto/interfaces.go3
2 files changed, 8 insertions, 0 deletions
diff --git a/crypto/eth/eth.go b/crypto/eth/eth.go
index edf50d3..975d8a8 100644
--- a/crypto/eth/eth.go
+++ b/crypto/eth/eth.go
@@ -104,6 +104,11 @@ func (pub PublicKey) Compress() []byte {
return pub.publicKey
}
+// Bytes returns the []byte representation of public key.
+func (pub PublicKey) Bytes() []byte {
+ return pub.Compress()
+}
+
// SigToPub returns the PublicKey that created the given signature.
func SigToPub(
hash common.Hash, signature crypto.Signature) (PublicKey, error) {
diff --git a/crypto/interfaces.go b/crypto/interfaces.go
index 015ff40..280082e 100644
--- a/crypto/interfaces.go
+++ b/crypto/interfaces.go
@@ -39,4 +39,7 @@ type PrivateKey interface {
type PublicKey interface {
// VerifySignature checks that the given public key created signature over hash.
VerifySignature(hash common.Hash, signature Signature) bool
+
+ // Bytes returns the []byte representation of public key.
+ Bytes() []byte
}