From c84599e7e09b88b9db96ad1e46a0e2a9af26a452 Mon Sep 17 00:00:00 2001 From: Cassandra Heart Date: Mon, 12 Aug 2024 01:01:26 -0500 Subject: [PATCH] push out signature validation to the edge, punish only --- go-libp2p-blossomsub/pubsub.go | 2 +- go-libp2p-blossomsub/sign.go | 2 -- go-libp2p-blossomsub/validation.go | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/go-libp2p-blossomsub/pubsub.go b/go-libp2p-blossomsub/pubsub.go index c7af86f..e1f90d3 100644 --- a/go-libp2p-blossomsub/pubsub.go +++ b/go-libp2p-blossomsub/pubsub.go @@ -266,7 +266,7 @@ func NewPubSub(ctx context.Context, h host.Host, rt PubSubRouter, opts ...Option peerOutboundQueueSize: 32, signID: h.ID(), signKey: nil, - signPolicy: StrictSign, + signPolicy: LaxSign, incoming: make(chan *RPC, 32), newPeers: make(chan struct{}, 1), newPeersPend: make(map[peer.ID]struct{}), diff --git a/go-libp2p-blossomsub/sign.go b/go-libp2p-blossomsub/sign.go index 6142487..4da5f36 100644 --- a/go-libp2p-blossomsub/sign.go +++ b/go-libp2p-blossomsub/sign.go @@ -27,10 +27,8 @@ const ( // StrictNoSign does not produce signatures and drops and penalises incoming messages that carry one StrictNoSign = msgVerification // LaxSign produces signatures and validates incoming signatures iff one is present - // Deprecated: it is recommend to either strictly enable, or strictly disable, signatures. LaxSign = msgSigning // LaxNoSign does not produce signatures and validates incoming signatures iff one is present - // Deprecated: it is recommend to either strictly enable, or strictly disable, signatures. LaxNoSign = 0 ) diff --git a/go-libp2p-blossomsub/validation.go b/go-libp2p-blossomsub/validation.go index 045532c..bfcd49e 100644 --- a/go-libp2p-blossomsub/validation.go +++ b/go-libp2p-blossomsub/validation.go @@ -297,7 +297,7 @@ func (v *validation) validateWorker() { func (v *validation) validate(vals []*validatorImpl, src peer.ID, msg *Message, synchronous bool) error { // If signature verification is enabled, but signing is disabled, // the Signature is required to be nil upon receiving the message in PubSub.pushMsg. - if msg.Signature != nil { + if msg.Signature != nil && v.p.signPolicy&msgVerification != 0 { if !v.validateSignature(msg) { log.Debugf("message signature validation failed; dropping message from %s", src) v.tracer.RejectMessage(msg, RejectInvalidSignature)