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

Cardano.Protocol.TPraos.BHeader

Synopsis

Documentation

newtype HashHeader c Source #

The hash of a Block Header

Instances

Instances details
Generic (HashHeader c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Associated Types

type Rep (HashHeader c) ∷ TypeType Source #

Methods

fromHashHeader c → Rep (HashHeader c) x Source #

toRep (HashHeader c) x → HashHeader c Source #

Show (HashHeader c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

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

Defined in Cardano.Protocol.TPraos.BHeader

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

Defined in Cardano.Protocol.TPraos.BHeader

Methods

encCBORHashHeader c → Encoding Source #

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

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

NFData (HashHeader c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Methods

rnfHashHeader c → () Source #

Eq (HashHeader c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Methods

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

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

Ord (HashHeader c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

NoThunks (HashHeader c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

type Rep (HashHeader c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

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

data PrevHash c Source #

The previous hash of a block

Constructors

GenesisHash 
BlockHash !(HashHeader c) 

Instances

Instances details
Generic (PrevHash c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Associated Types

type Rep (PrevHash c) ∷ TypeType Source #

Methods

fromPrevHash c → Rep (PrevHash c) x Source #

toRep (PrevHash c) x → PrevHash c Source #

Show (PrevHash c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

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

Defined in Cardano.Protocol.TPraos.BHeader

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

Defined in Cardano.Protocol.TPraos.BHeader

Methods

encCBORPrevHash c → Encoding Source #

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

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

Eq (PrevHash c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Methods

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

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

Ord (PrevHash c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Methods

comparePrevHash c → PrevHash c → Ordering Source #

(<)PrevHash c → PrevHash c → Bool Source #

(<=)PrevHash c → PrevHash c → Bool Source #

(>)PrevHash c → PrevHash c → Bool Source #

(>=)PrevHash c → PrevHash c → Bool Source #

maxPrevHash c → PrevHash c → PrevHash c Source #

minPrevHash c → PrevHash c → PrevHash c Source #

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

Defined in Cardano.Protocol.TPraos.BHeader

type Rep (PrevHash c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

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

data BHeader c where Source #

Bundled Patterns

pattern BHeaderCrypto c ⇒ BHBody c → SignedKES 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.2.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 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 c Source #

Constructors

LastAppliedBlock 

Fields

Instances

Instances details
Generic (LastAppliedBlock c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Associated Types

type Rep (LastAppliedBlock c) ∷ TypeType Source #

Show (LastAppliedBlock c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

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

Defined in Cardano.Protocol.TPraos.BHeader

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

Defined in Cardano.Protocol.TPraos.BHeader

NFData (LastAppliedBlock c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Methods

rnfLastAppliedBlock c → () Source #

Eq (LastAppliedBlock c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

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

Defined in Cardano.Protocol.TPraos.BHeader

type Rep (LastAppliedBlock c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

type Rep (LastAppliedBlock c) = D1 ('MetaData "LastAppliedBlock" "Cardano.Protocol.TPraos.BHeader" "cardano-protocol-tpraos-1.2.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 c)))))

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.

issuerIDfromBHBodyCrypto c ⇒ BHBody c → KeyHash 'BlockIssuer c 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 c Source #

Hash a given block header

hashHeaderToNonceHashHeader c → Nonce Source #

HashHeader to Nonce What is going on here? This is here because the surrounding code is parametrized in the hash algorithm used, but the nonce is hard-coded to Blake2b_256. We require the nonce to have the right length (the size of a Blake2b_256 hash), so if the hash size differs, we pad or remove bytes accordingly.

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.