compute signatures over msg cids instead of raw bytes
This commit is contained in:
parent
49e8b5d334
commit
68c1170250
@ -336,12 +336,7 @@ func (cg *ChainGen) getRandomMessages() ([]*types.SignedMessage, error) {
|
||||
GasPrice: types.NewInt(0),
|
||||
}
|
||||
|
||||
unsigned, err := msg.Serialize()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sig, err := cg.w.Sign(context.TODO(), cg.banker, unsigned)
|
||||
sig, err := cg.w.Sign(context.TODO(), cg.banker, msg.Cid().Bytes())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package chain
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"sync"
|
||||
|
||||
pubsub "github.com/libp2p/go-libp2p-pubsub"
|
||||
@ -82,14 +81,9 @@ func (mp *MessagePool) Add(m *types.SignedMessage) error {
|
||||
}
|
||||
|
||||
func (mp *MessagePool) addLocked(m *types.SignedMessage) error {
|
||||
data, err := m.Message.Serialize()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Debugf("mpooladd: %s %s", m.Message.From, m.Message.Nonce)
|
||||
|
||||
log.Debugf("mpooladd: %d %s", m.Message.Nonce, base64.StdEncoding.EncodeToString(data))
|
||||
|
||||
if err := m.Signature.Verify(m.Message.From, data); err != nil {
|
||||
if err := m.Signature.Verify(m.Message.From, m.Message.Cid().Bytes()); err != nil {
|
||||
log.Warnf("mpooladd signature verification failed: %s", err)
|
||||
return err
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ func (s *Signature) Verify(addr address.Address, msg []byte) error {
|
||||
}
|
||||
|
||||
if addr != maybeaddr {
|
||||
panic("stop here")
|
||||
return fmt.Errorf("signature did not match")
|
||||
}
|
||||
|
||||
@ -45,6 +46,7 @@ func (s *Signature) Verify(addr address.Address, msg []byte) error {
|
||||
copy(sig[:], s.Data)
|
||||
|
||||
if !bls.Verify(sig, digests, pubkeys) {
|
||||
panic("stop here")
|
||||
return fmt.Errorf("bls signature failed to verify")
|
||||
}
|
||||
|
||||
|
@ -40,12 +40,9 @@ func (a *WalletAPI) WalletSign(ctx context.Context, k address.Address, msg []byt
|
||||
}
|
||||
|
||||
func (a *WalletAPI) WalletSignMessage(ctx context.Context, k address.Address, msg *types.Message) (*types.SignedMessage, error) {
|
||||
msgbytes, err := msg.Serialize()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mcid := msg.Cid()
|
||||
|
||||
sig, err := a.WalletSign(ctx, k, msgbytes)
|
||||
sig, err := a.WalletSign(ctx, k, mcid.Bytes())
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("failed to sign message: %w", err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user