Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
A NetworkComponent
that handles authentication of sent and received messages.
This "middleware" uses HydraKey
keys for signing own messages and verifying
others', providing Authenticated
messages to consumers.
Synopsis
- data Signed msg = Signed {}
- data Authenticated msg = Authenticated {}
- withAuthentication :: (SignableRepresentation inbound, ToJSON inbound, SignableRepresentation outbound) => Tracer m AuthLog -> SigningKey HydraKey -> [Party] -> NetworkComponent m (Signed inbound) (Signed outbound) a -> NetworkComponent m (Authenticated inbound) outbound a
- mkAuthLog :: (ToJSON msg, Show signature) => msg -> signature -> Party -> AuthLog
- data AuthLog = MessageDropped {}
Documentation
Represents a signed message over the network. Becomes valid once its receivers verify it against its other peers verification keys. Messages are signed and turned into authenticated messages before broadcasting them to other peers.
Instances
(Arbitrary msg, SignableRepresentation msg) => Arbitrary (Signed msg) Source # | |
FromJSON msg => FromJSON (Signed msg) Source # | |
Defined in Hydra.Network.Authenticate parseJSON :: Value -> Parser (Signed msg) parseJSONList :: Value -> Parser [Signed msg] omittedField :: Maybe (Signed msg) | |
ToJSON msg => ToJSON (Signed msg) Source # | |
Defined in Hydra.Network.Authenticate toEncoding :: Signed msg -> Encoding toJSONList :: [Signed msg] -> Value toEncodingList :: [Signed msg] -> Encoding | |
Generic (Signed msg) Source # | |
Show msg => Show (Signed msg) Source # | |
FromCBOR msg => FromCBOR (Signed msg) Source # | |
ToCBOR msg => ToCBOR (Signed msg) Source # | |
Defined in Hydra.Network.Authenticate toCBOR :: Signed msg -> Encoding encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy (Signed msg) -> Size encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [Signed msg] -> Size | |
Eq msg => Eq (Signed msg) Source # | |
type Rep (Signed msg) Source # | |
Defined in Hydra.Network.Authenticate type Rep (Signed msg) = D1 ('MetaData "Signed" "Hydra.Network.Authenticate" "hydra-node-0.19.0-6Z4E5vp1s1XJuLOmmEVMTw" 'False) (C1 ('MetaCons "Signed" 'PrefixI 'True) (S1 ('MetaSel ('Just "payload") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 msg) :*: (S1 ('MetaSel ('Just "signature") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Signature msg)) :*: S1 ('MetaSel ('Just "party") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Party)))) |
data Authenticated msg Source #
Instances
withAuthentication :: (SignableRepresentation inbound, ToJSON inbound, SignableRepresentation outbound) => Tracer m AuthLog -> SigningKey HydraKey -> [Party] -> NetworkComponent m (Signed inbound) (Signed outbound) a -> NetworkComponent m (Authenticated inbound) outbound a Source #
Middleware used to sign messages before broadcasting them to other peers and verify signed messages upon receiving. Only verified messages are pushed downstream to the internal network for the node to consume and process. Non-verified messages get discarded.
mkAuthLog :: (ToJSON msg, Show signature) => msg -> signature -> Party -> AuthLog Source #
Smart constructor for MessageDropped
Instances
Arbitrary AuthLog Source # | |
FromJSON AuthLog Source # | |
Defined in Hydra.Network.Authenticate parseJSON :: Value -> Parser AuthLog parseJSONList :: Value -> Parser [AuthLog] | |
ToJSON AuthLog Source # | |
Defined in Hydra.Network.Authenticate toEncoding :: AuthLog -> Encoding toJSONList :: [AuthLog] -> Value toEncodingList :: [AuthLog] -> Encoding | |
Generic AuthLog Source # | |
Show AuthLog Source # | |
Eq AuthLog Source # | |
type Rep AuthLog Source # | |
Defined in Hydra.Network.Authenticate type Rep AuthLog = D1 ('MetaData "AuthLog" "Hydra.Network.Authenticate" "hydra-node-0.19.0-6Z4E5vp1s1XJuLOmmEVMTw" 'False) (C1 ('MetaCons "MessageDropped" 'PrefixI 'True) (S1 ('MetaSel ('Just "message") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: (S1 ('MetaSel ('Just "signature") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "party") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Party)))) |