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),
|
GasPrice: types.NewInt(0),
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned, err := msg.Serialize()
|
sig, err := cg.w.Sign(context.TODO(), cg.banker, msg.Cid().Bytes())
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
sig, err := cg.w.Sign(context.TODO(), cg.banker, unsigned)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package chain
|
package chain
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
pubsub "github.com/libp2p/go-libp2p-pubsub"
|
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 {
|
func (mp *MessagePool) addLocked(m *types.SignedMessage) error {
|
||||||
data, err := m.Message.Serialize()
|
log.Debugf("mpooladd: %s %s", m.Message.From, m.Message.Nonce)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Debugf("mpooladd: %d %s", m.Message.Nonce, base64.StdEncoding.EncodeToString(data))
|
if err := m.Signature.Verify(m.Message.From, m.Message.Cid().Bytes()); err != nil {
|
||||||
|
|
||||||
if err := m.Signature.Verify(m.Message.From, data); err != nil {
|
|
||||||
log.Warnf("mpooladd signature verification failed: %s", err)
|
log.Warnf("mpooladd signature verification failed: %s", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ func (s *Signature) Verify(addr address.Address, msg []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if addr != maybeaddr {
|
if addr != maybeaddr {
|
||||||
|
panic("stop here")
|
||||||
return fmt.Errorf("signature did not match")
|
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)
|
copy(sig[:], s.Data)
|
||||||
|
|
||||||
if !bls.Verify(sig, digests, pubkeys) {
|
if !bls.Verify(sig, digests, pubkeys) {
|
||||||
|
panic("stop here")
|
||||||
return fmt.Errorf("bls signature failed to verify")
|
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) {
|
func (a *WalletAPI) WalletSignMessage(ctx context.Context, k address.Address, msg *types.Message) (*types.SignedMessage, error) {
|
||||||
msgbytes, err := msg.Serialize()
|
mcid := msg.Cid()
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
sig, err := a.WalletSign(ctx, k, msgbytes)
|
sig, err := a.WalletSign(ctx, k, mcid.Bytes())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("failed to sign message: %w", err)
|
return nil, xerrors.Errorf("failed to sign message: %w", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user