hydra-node-0.20.0: The Hydra node
Safe HaskellSafe-Inferred
LanguageGHC2021

Hydra.Network.Authenticate

Description

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

Documentation

data Signed msg Source #

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.

Constructors

Signed 

Fields

Instances

Instances details
(Arbitrary msg, SignableRepresentation msg) => Arbitrary (Signed msg) Source # 
Instance details

Defined in Hydra.Network.Authenticate

Methods

arbitrary :: Gen (Signed msg)

shrink :: Signed msg -> [Signed msg]

FromJSON msg => FromJSON (Signed msg) Source # 
Instance details

Defined in Hydra.Network.Authenticate

Methods

parseJSON :: Value -> Parser (Signed msg)

parseJSONList :: Value -> Parser [Signed msg]

omittedField :: Maybe (Signed msg)

ToJSON msg => ToJSON (Signed msg) Source # 
Instance details

Defined in Hydra.Network.Authenticate

Methods

toJSON :: Signed msg -> Value

toEncoding :: Signed msg -> Encoding

toJSONList :: [Signed msg] -> Value

toEncodingList :: [Signed msg] -> Encoding

omitField :: Signed msg -> Bool

Generic (Signed msg) Source # 
Instance details

Defined in Hydra.Network.Authenticate

Associated Types

type Rep (Signed msg) :: Type -> Type Source #

Methods

from :: Signed msg -> Rep (Signed msg) x Source #

to :: Rep (Signed msg) x -> Signed msg Source #

Show msg => Show (Signed msg) Source # 
Instance details

Defined in Hydra.Network.Authenticate

Methods

showsPrec :: Int -> Signed msg -> ShowS Source #

show :: Signed msg -> String Source #

showList :: [Signed msg] -> ShowS Source #

FromCBOR msg => FromCBOR (Signed msg) Source # 
Instance details

Defined in Hydra.Network.Authenticate

Methods

fromCBOR :: Decoder s (Signed msg)

label :: Proxy (Signed msg) -> Text

ToCBOR msg => ToCBOR (Signed msg) Source # 
Instance details

Defined in Hydra.Network.Authenticate

Methods

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 # 
Instance details

Defined in Hydra.Network.Authenticate

Methods

(==) :: Signed msg -> Signed msg -> Bool Source #

(/=) :: Signed msg -> Signed msg -> Bool Source #

type Rep (Signed msg) Source # 
Instance details

Defined in Hydra.Network.Authenticate

type Rep (Signed msg) = D1 ('MetaData "Signed" "Hydra.Network.Authenticate" "hydra-node-0.20.0-GJlHI5giGamBfggh7PdYBV" '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 #

Constructors

Authenticated 

Fields

Instances

Instances details
FromJSON msg => FromJSON (Authenticated msg) Source # 
Instance details

Defined in Hydra.Network.Authenticate

Methods

parseJSON :: Value -> Parser (Authenticated msg)

parseJSONList :: Value -> Parser [Authenticated msg]

omittedField :: Maybe (Authenticated msg)

ToJSON msg => ToJSON (Authenticated msg) Source # 
Instance details

Defined in Hydra.Network.Authenticate

Methods

toJSON :: Authenticated msg -> Value

toEncoding :: Authenticated msg -> Encoding

toJSONList :: [Authenticated msg] -> Value

toEncodingList :: [Authenticated msg] -> Encoding

omitField :: Authenticated msg -> Bool

Generic (Authenticated msg) Source # 
Instance details

Defined in Hydra.Network.Authenticate

Associated Types

type Rep (Authenticated msg) :: Type -> Type Source #

Methods

from :: Authenticated msg -> Rep (Authenticated msg) x Source #

to :: Rep (Authenticated msg) x -> Authenticated msg Source #

Show msg => Show (Authenticated msg) Source # 
Instance details

Defined in Hydra.Network.Authenticate

Eq msg => Eq (Authenticated msg) Source # 
Instance details

Defined in Hydra.Network.Authenticate

type Rep (Authenticated msg) Source # 
Instance details

Defined in Hydra.Network.Authenticate

type Rep (Authenticated msg) = D1 ('MetaData "Authenticated" "Hydra.Network.Authenticate" "hydra-node-0.20.0-GJlHI5giGamBfggh7PdYBV" 'False) (C1 ('MetaCons "Authenticated" 'PrefixI 'True) (S1 ('MetaSel ('Just "payload") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 msg) :*: S1 ('MetaSel ('Just "party") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Party)))

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

data AuthLog Source #

Constructors

MessageDropped 

Fields

Instances

Instances details
Arbitrary AuthLog Source # 
Instance details

Defined in Hydra.Network.Authenticate

Methods

arbitrary :: Gen AuthLog

shrink :: AuthLog -> [AuthLog]

FromJSON AuthLog Source # 
Instance details

Defined in Hydra.Network.Authenticate

Methods

parseJSON :: Value -> Parser AuthLog

parseJSONList :: Value -> Parser [AuthLog]

omittedField :: Maybe AuthLog

ToJSON AuthLog Source # 
Instance details

Defined in Hydra.Network.Authenticate

Methods

toJSON :: AuthLog -> Value

toEncoding :: AuthLog -> Encoding

toJSONList :: [AuthLog] -> Value

toEncodingList :: [AuthLog] -> Encoding

omitField :: AuthLog -> Bool

Generic AuthLog Source # 
Instance details

Defined in Hydra.Network.Authenticate

Associated Types

type Rep AuthLog :: Type -> Type Source #

Show AuthLog Source # 
Instance details

Defined in Hydra.Network.Authenticate

Eq AuthLog Source # 
Instance details

Defined in Hydra.Network.Authenticate

type Rep AuthLog Source # 
Instance details

Defined in Hydra.Network.Authenticate

type Rep AuthLog = D1 ('MetaData "AuthLog" "Hydra.Network.Authenticate" "hydra-node-0.20.0-GJlHI5giGamBfggh7PdYBV" '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))))