libp2p-hs-0.1.0.0: Haskell implementation of the libp2p networking stack
Safe HaskellNone
LanguageGHC2021

LibP2P.Protocol.GossipSub.Validation

Description

Inbound pubsub message validation (specspubsubREADME.md).

Under StrictSign the consuming side must enforce that from, seqno and signature are present, that the signature verifies against the author's public key, and that the key matches the from peer ID. Messages that fail are dropped without propagation. Under StrictNoSign the signing fields must be absent.

The signed bytes are "libp2p-pubsub:" <> protobuf(msg without signature and key), symmetric with the signing path in LibP2P.Protocol.GossipSub.Router.

Synopsis

Documentation

data ValidationError Source #

Why an inbound message was rejected.

Constructors

MissingField String

A field required by StrictSign is absent

UnexpectedField String

A signing field is present under StrictNoSign

MalformedKey String

The key field (or inlined key) failed to decode

KeyPeerIdMismatch

The public key does not derive the from peer ID

BadSignature

Signature verification failed

validateMessage :: SignaturePolicy -> PubSubMessage -> Either ValidationError () Source #

Validate an inbound message against the configured signature policy.

signaturePrefix :: ByteString Source #

Domain separation prefix for pubsub message signatures.

marshalForSigning :: PubSubMessage -> ByteString Source #

Marshal a message for signature computation. Per the libp2p spec, the signed data excludes both signature and key fields.

signingBytes :: PubSubMessage -> ByteString Source #

The exact bytes covered by a message signature.