OSDN Git Service
(root)
/
bytom
/
vapor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
delete the key index (#335)
[bytom/vapor.git]
/
protocol
/
bbft.go
diff --git
a/protocol/bbft.go
b/protocol/bbft.go
index
11dc0db
..
a6a6deb
100644
(file)
--- a/
protocol/bbft.go
+++ b/
protocol/bbft.go
@@
-7,6
+7,7
@@
import (
log "github.com/sirupsen/logrus"
"github.com/vapor/config"
log "github.com/sirupsen/logrus"
"github.com/vapor/config"
+ "github.com/vapor/crypto/ed25519/chainkd"
"github.com/vapor/errors"
"github.com/vapor/event"
"github.com/vapor/protocol/bc"
"github.com/vapor/errors"
"github.com/vapor/event"
"github.com/vapor/protocol/bc"
@@
-132,6
+133,7
@@
func (c *Chain) validateSign(block *types.Block) error {
cachekey := signCacheKey(blockHash.String(), pubKey)
if signature, ok := c.signatureCache.Get(cachekey); ok {
block.Set(node.Order, signature.([]byte))
cachekey := signCacheKey(blockHash.String(), pubKey)
if signature, ok := c.signatureCache.Get(cachekey); ok {
block.Set(node.Order, signature.([]byte))
+ c.eventDispatcher.Post(event.BlockSignatureEvent{BlockHash: blockHash, Signature: signature.([]byte), XPub: node.XPub[:]})
c.signatureCache.Remove(cachekey)
} else {
continue
c.signatureCache.Remove(cachekey)
} else {
continue
@@
-165,6
+167,12
@@
func (c *Chain) ProcessBlockSignature(signature, xPub []byte, blockHash *bc.Hash
// save the signature if the block is not exist
if blockHeader == nil {
// save the signature if the block is not exist
if blockHeader == nil {
+ var xPubKey chainkd.XPub
+ copy(xPubKey[:], xPub[:])
+ if !xPubKey.Verify(blockHash.Bytes(), signature) {
+ return errInvalidSignature
+ }
+
cacheKey := signCacheKey(blockHash.String(), xpubStr)
c.signatureCache.Add(cacheKey, signature)
return nil
cacheKey := signCacheKey(blockHash.String(), xpubStr)
c.signatureCache.Add(cacheKey, signature)
return nil