fix: filecoin message verification by type

This commit is contained in:
bahadylbekov 2020-12-02 17:18:45 +03:00
parent e3931c23a2
commit 5a94f6d67a
2 changed files with 10 additions and 9 deletions

View File

@ -174,8 +174,14 @@ func (ppp *PrePreparePool) IsValidPrePrepare(prePrepare *types2.Message) bool {
}
}
if err = sigs.Verify(msg.Signature, msg.Message.From.Bytes(), msg.Message.Cid().Bytes()); err != nil {
logrus.Errorf("Couldn't verify transaction %v", err)
if msg.Type = ftypes.MessageTypeSecp256k1 {
if err = sigs.Verify(msg.Signature, msg.Message.From.Bytes(), msg.Message.Cid().Bytes()); err != nil {
logrus.Errorf("Couldn't verify transaction %v", err)
}
return true
} else {
// TODO: BLS Signature verification
return true
}
}
/////////////////////////////////

View File

@ -15,11 +15,6 @@ import (
var filecoinURL = "https://api.node.glif.io/"
const (
blsType = 0x1
secp256k1Type = 0x2
)
// client implements the `Client` interface.
type LotusClient struct {
host string
@ -86,9 +81,9 @@ func (c *LotusClient) GetTransaction(cid string) ([]byte, error) {
switch msg.Message.From.Protocol() | msg.Message.To.Protocol() {
case address.BLS:
msg.Type = blsType
msg.Type = ftypes.MessageTypeBLS
case address.SECP256K1:
msg.Type = secp256k1Type
msg.Type = ftypes.MessageTypeSecp256k1
default:
return nil, fmt.Errorf("Address has unsupported protocol %v", err)
}