cardano-protocol-tpraos-1.4.0.0: Cardano Protocol: Transitional Praos
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cardano.Protocol.TPraos.BHeader

Synopsis

Documentation

newtype HashHeader Source #

The hash of a Block Header

Instances

Instances details
Generic HashHeader Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Associated Types

type Rep HashHeaderTypeType Source #

Show HashHeader Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

DecCBOR HashHeader Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

EncCBOR HashHeader Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Methods

encCBORHashHeaderEncoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy HashHeaderSize Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [HashHeader] → Size Source #

NFData HashHeader Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Methods

rnfHashHeader → () Source #

Eq HashHeader Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Ord HashHeader Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

NoThunks HashHeader Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

type Rep HashHeader Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

type Rep HashHeader = D1 ('MetaData "HashHeader" "Cardano.Protocol.TPraos.BHeader" "cardano-protocol-tpraos-1.4.0.0-inplace" 'True) (C1 ('MetaCons "HashHeader" 'PrefixI 'True) (S1 ('MetaSel ('Just "unHashHeader") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Hash HASH EraIndependentBlockHeader))))

data PrevHash Source #

The previous hash of a block

Instances

Instances details
Generic PrevHash Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Associated Types

type Rep PrevHashTypeType Source #

Show PrevHash Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

DecCBOR PrevHash Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

EncCBOR PrevHash Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Methods

encCBORPrevHashEncoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy PrevHashSize Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [PrevHash] → Size Source #

Eq PrevHash Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Ord PrevHash Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

NoThunks PrevHash Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

type Rep PrevHash Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

type Rep PrevHash = D1 ('MetaData "PrevHash" "Cardano.Protocol.TPraos.BHeader" "cardano-protocol-tpraos-1.4.0.0-inplace" 'False) (C1 ('MetaCons "GenesisHash" 'PrefixI 'False) (U1TypeType) :+: C1 ('MetaCons "BlockHash" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HashHeader)))

data BHeader c where Source #

Bundled Patterns

pattern BHeaderCrypto c ⇒ BHBody c → SignedKES (KES c) (BHBody c) → BHeader c 

Instances

Instances details
Generic (BHeader c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Associated Types

type Rep (BHeader c) ∷ TypeType Source #

Methods

fromBHeader c → Rep (BHeader c) x Source #

toRep (BHeader c) x → BHeader c Source #

Crypto c ⇒ Show (BHeader c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Methods

showsPrecIntBHeader c → ShowS Source #

showBHeader c → String Source #

showList ∷ [BHeader c] → ShowS Source #

Crypto c ⇒ ToCBOR (BHeader c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Methods

toCBORBHeader c → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (BHeader c) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [BHeader c] → Size Source #

Crypto c ⇒ DecCBOR (Annotator (BHeader c)) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Crypto c ⇒ EncCBOR (BHeader c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Methods

encCBORBHeader c → Encoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy (BHeader c) → Size Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [BHeader c] → Size Source #

Crypto c ⇒ Eq (BHeader c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Methods

(==)BHeader c → BHeader c → Bool Source #

(/=)BHeader c → BHeader c → Bool Source #

Crypto c ⇒ NoThunks (BHeader c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

type Rep (BHeader c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

type Rep (BHeader c) = D1 ('MetaData "BHeader" "Cardano.Protocol.TPraos.BHeader" "cardano-protocol-tpraos-1.4.0.0-inplace" 'False) (C1 ('MetaCons "BHeader'" 'PrefixI 'True) (S1 ('MetaSel ('Just "bHeaderBody'") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (BHBody c)) :*: (S1 ('MetaSel ('Just "bHeaderSig'") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (SignedKES (KES c) (BHBody c))) :*: S1 ('MetaSel ('Just "bHeaderBytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))))

data BHBody c Source #

Constructors

BHBody 

Fields

Instances

Instances details
Generic (BHBody c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Associated Types

type Rep (BHBody c) ∷ TypeType Source #

Methods

fromBHBody c → Rep (BHBody c) x Source #

toRep (BHBody c) x → BHBody c Source #

Crypto c ⇒ Show (BHBody c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Methods

showsPrecIntBHBody c → ShowS Source #

showBHBody c → String Source #

showList ∷ [BHBody c] → ShowS Source #

Crypto c ⇒ SignableRepresentation (BHBody c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Crypto c ⇒ DecCBOR (BHBody c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Methods

decCBORDecoder s (BHBody c) Source #

dropCBORProxy (BHBody c) → Decoder s () Source #

labelProxy (BHBody c) → Text Source #

Crypto c ⇒ EncCBOR (BHBody c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Methods

encCBORBHBody c → Encoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy (BHBody c) → Size Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [BHBody c] → Size Source #

Crypto c ⇒ Eq (BHBody c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Methods

(==)BHBody c → BHBody c → Bool Source #

(/=)BHBody c → BHBody c → Bool Source #

Crypto c ⇒ NoThunks (BHBody c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

type Rep (BHBody c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

data LastAppliedBlock Source #

Constructors

LastAppliedBlock 

Instances

Instances details
Generic LastAppliedBlock Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Associated Types

type Rep LastAppliedBlockTypeType Source #

Show LastAppliedBlock Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

DecCBOR LastAppliedBlock Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

EncCBOR LastAppliedBlock Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

NFData LastAppliedBlock Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Methods

rnfLastAppliedBlock → () Source #

Eq LastAppliedBlock Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

NoThunks LastAppliedBlock Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

type Rep LastAppliedBlock Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

type Rep LastAppliedBlock = D1 ('MetaData "LastAppliedBlock" "Cardano.Protocol.TPraos.BHeader" "cardano-protocol-tpraos-1.4.0.0-inplace" 'False) (C1 ('MetaCons "LastAppliedBlock" 'PrefixI 'True) (S1 ('MetaSel ('Just "labBlockNo") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 BlockNo) :*: (S1 ('MetaSel ('Just "labSlotNo") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SlotNo) :*: S1 ('MetaSel ('Just "labHash") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HashHeader))))

data BoundedNatural Source #

Natural value with some additional bound. It must always be the base that 'bvValue <= bvMaxValue'. The creator is responsible for checking this value.

assertBoundedNatural Source #

Arguments

Natural

Maximum bound

Natural

Value

BoundedNatural 

Assert that a natural is bounded by a certain value. Throws an error when this is not the case.

issuerIDfromBHBodyBHBody c → KeyHash 'BlockIssuer Source #

Retrieve the issuer id (the hash of the cold key) from the body of the block header. This corresponds to either a genesis/core node or a stake pool.

checkLeaderValue ∷ ∀ v. VRFAlgorithm v ⇒ OutputVRF v → RationalActiveSlotCoeffBool Source #

Check that the certified VRF output, when used as a natural, is valid for being slot leader.

checkLeaderNatValue Source #

Arguments

BoundedNatural

Certified nat value

Rational

Stake proportion

ActiveSlotCoeff 
Bool 

Check that the certified input natural is valid for being slot leader. This means we check that

p < 1 - (1 - f)^σ

where p = certNat / certNatMax.

The calculation is done using the following optimization:

let q = 1 - p and c = ln(1 - f)

then p < 1 - (1 - f)^σ = 1 / (1 - p) < exp(-σ * c) = 1 / q < exp(-σ * c)

This can be efficiently be computed by taylorExpCmp which returns ABOVE in case the reference value `1 / (1 - p)` is above the exponential function at `-σ * c`, BELOW if it is below or MaxReached if it couldn't conclusively compute this within the given iteration bounds.

Note that 1 1 1 certNatMax --- = ----- = ---------------------------- = ---------------------- q 1 - p 1 - (certNat / certNatMax) (certNatMax - certNat)

bhHashCrypto c ⇒ BHeader c → HashHeader Source #

Hash a given block header

hashHeaderToNonceHashHeaderNonce Source #

HashHeader to Nonce

bHeaderSize ∷ ∀ c. BHeader c → Int Source #

bhbodyCrypto c ⇒ BHeader c → BHBody c Source #

mkSeed Source #

Arguments

Nonce

Universal constant

SlotNo 
Nonce

Epoch nonce

Seed 

Construct a seed to use in the VRF computation.

bnonceBHBody c → Nonce Source #

Retrieve the new nonce from the block header body.