diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/authenticator.go | 2 | ||||
-rw-r--r-- | core/lattice.go | 2 | ||||
-rw-r--r-- | core/test/tcp-transport.go | 6 | ||||
-rw-r--r-- | core/types/node.go | 6 |
4 files changed, 10 insertions, 6 deletions
diff --git a/core/authenticator.go b/core/authenticator.go index 97b62d6..5415f96 100644 --- a/core/authenticator.go +++ b/core/authenticator.go @@ -123,7 +123,7 @@ func (au *Authenticator) VerifyBlock(b *types.Block) (err error) { if err != nil { return } - if !b.ProposerID.Equal(crypto.Keccak256Hash(pubKey.Bytes())) { + if !b.ProposerID.Equal(types.NewNodeID(pubKey)) { err = ErrIncorrectSignature return } diff --git a/core/lattice.go b/core/lattice.go index ca9d839..3ee0b94 100644 --- a/core/lattice.go +++ b/core/lattice.go @@ -109,7 +109,7 @@ func (s *Lattice) SanityCheck(b *types.Block) (err error) { if err != nil { return } - if !b.ProposerID.Equal(crypto.Keccak256Hash(pubKey.Bytes())) { + if !b.ProposerID.Equal(types.NewNodeID(pubKey)) { err = ErrIncorrectSignature return } diff --git a/core/test/tcp-transport.go b/core/test/tcp-transport.go index e1b73f0..64f915d 100644 --- a/core/test/tcp-transport.go +++ b/core/test/tcp-transport.go @@ -709,12 +709,16 @@ func NewTCPTransportServer( marshaller Marshaller, serverPort int) *TCPTransportServer { + prvKey, err := ecdsa.NewPrivateKey() + if err != nil { + panic(err) + } return &TCPTransportServer{ // NOTE: the assumption here is the node ID of peers // won't be zero. TCPTransport: *NewTCPTransport( TransportPeerServer, - ecdsa.NewPublicKeyFromByteSlice(nil), + prvKey.PublicKey(), nil, marshaller, serverPort), diff --git a/core/types/node.go b/core/types/node.go index 177e407..839c2bf 100644 --- a/core/types/node.go +++ b/core/types/node.go @@ -32,12 +32,12 @@ type NodeID struct { // NewNodeID returns a NodeID with Hash set to the hash value of // public key. func NewNodeID(pubKey crypto.PublicKey) NodeID { - return NodeID{Hash: crypto.Keccak256Hash(pubKey.Bytes())} + return NodeID{Hash: crypto.Keccak256Hash(pubKey.Bytes()[1:])} } // Equal checks if the hash representation is the same NodeID. -func (v NodeID) Equal(hash common.Hash) bool { - return v.Hash == hash +func (v NodeID) Equal(v2 NodeID) bool { + return v.Hash == v2.Hash } // NodeIDs implements sort.Interface for NodeID. |