fix: filecoin message verification by type
This commit is contained in:
parent
e3931c23a2
commit
5a94f6d67a
@ -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 {
|
if msg.Type = ftypes.MessageTypeSecp256k1 {
|
||||||
logrus.Errorf("Couldn't verify transaction %v", err)
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
|
@ -15,11 +15,6 @@ import (
|
|||||||
|
|
||||||
var filecoinURL = "https://api.node.glif.io/"
|
var filecoinURL = "https://api.node.glif.io/"
|
||||||
|
|
||||||
const (
|
|
||||||
blsType = 0x1
|
|
||||||
secp256k1Type = 0x2
|
|
||||||
)
|
|
||||||
|
|
||||||
// client implements the `Client` interface.
|
// client implements the `Client` interface.
|
||||||
type LotusClient struct {
|
type LotusClient struct {
|
||||||
host string
|
host string
|
||||||
@ -86,9 +81,9 @@ func (c *LotusClient) GetTransaction(cid string) ([]byte, error) {
|
|||||||
|
|
||||||
switch msg.Message.From.Protocol() | msg.Message.To.Protocol() {
|
switch msg.Message.From.Protocol() | msg.Message.To.Protocol() {
|
||||||
case address.BLS:
|
case address.BLS:
|
||||||
msg.Type = blsType
|
msg.Type = ftypes.MessageTypeBLS
|
||||||
case address.SECP256K1:
|
case address.SECP256K1:
|
||||||
msg.Type = secp256k1Type
|
msg.Type = ftypes.MessageTypeSecp256k1
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("Address has unsupported protocol %v", err)
|
return nil, fmt.Errorf("Address has unsupported protocol %v", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user