cardano-protocol-0.2.0.0: Cardano Protocol: shared crypto and block-header definitions
Safe HaskellNone
LanguageHaskell2010

Cardano.Protocol.TPraos.BlockHeader

Synopsis

Documentation

newtype HashHeader Source #

Instances

Instances details
DecCBOR HashHeader 
Instance details

Defined in Cardano.Ledger.Hashes

EncCBOR HashHeader 
Instance details

Defined in Cardano.Ledger.Hashes

NFData HashHeader 
Instance details

Defined in Cardano.Ledger.Hashes

Methods

rnf ∷ HashHeader → () #

Generic HashHeader 
Instance details

Defined in Cardano.Ledger.Hashes

Associated Types

type Rep HashHeader 
Instance details

Defined in Cardano.Ledger.Hashes

type Rep HashHeader = D1 ('MetaData "HashHeader" "Cardano.Ledger.Hashes" "cardano-ledger-core-1.22.0.0-inplace" 'True) (C1 ('MetaCons "HashHeader" 'PrefixI 'True) (S1 ('MetaSel ('Just "unHashHeader") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Hash HASH EraIndependentBlockHeader))))
Show HashHeader 
Instance details

Defined in Cardano.Ledger.Hashes

Eq HashHeader 
Instance details

Defined in Cardano.Ledger.Hashes

Methods

(==) ∷ HashHeader → HashHeader → Bool #

(/=) ∷ HashHeader → HashHeader → Bool #

Ord HashHeader 
Instance details

Defined in Cardano.Ledger.Hashes

NoThunks HashHeader 
Instance details

Defined in Cardano.Ledger.Hashes

type Rep HashHeader 
Instance details

Defined in Cardano.Ledger.Hashes

type Rep HashHeader = D1 ('MetaData "HashHeader" "Cardano.Ledger.Hashes" "cardano-ledger-core-1.22.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
DecCBOR PrevHash Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

EncCBOR PrevHash Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

Generic PrevHash Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

Associated Types

type Rep PrevHash 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

type Rep PrevHash = D1 ('MetaData "PrevHash" "Cardano.Protocol.TPraos.BlockHeader" "cardano-protocol-0.2.0.0-inplace" 'False) (C1 ('MetaCons "GenesisHash" 'PrefixI 'False) (U1 ∷ Type → Type) :+: C1 ('MetaCons "BlockHash" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HashHeader)))

Methods

from ∷ PrevHash → Rep PrevHash x #

to ∷ Rep PrevHash x → PrevHash #

Show PrevHash Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

Methods

showsPrec ∷ Int → PrevHash → ShowS #

show ∷ PrevHash → String #

showList ∷ [PrevHash] → ShowS #

Eq PrevHash Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

Methods

(==) ∷ PrevHash → PrevHash → Bool #

(/=) ∷ PrevHash → PrevHash → Bool #

Ord PrevHash Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

NoThunks PrevHash Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

type Rep PrevHash Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

type Rep PrevHash = D1 ('MetaData "PrevHash" "Cardano.Protocol.TPraos.BlockHeader" "cardano-protocol-0.2.0.0-inplace" 'False) (C1 ('MetaCons "GenesisHash" 'PrefixI 'False) (U1 ∷ Type → Type) :+: C1 ('MetaCons "BlockHash" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HashHeader)))

newtype BHeader c Source #

Constructors

BHeaderConstr (MemoBytes (BHeaderRaw c)) 

Bundled Patterns

pattern BHeader ∷ Crypto c ⇒ BHBody c → SignedKES (KES c) (BHBody c) → BHeader c 

Instances

Instances details
Typeable c ⇒ ToCBOR (BHeader c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

Methods

toCBOR ∷ BHeader 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.BlockHeader

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

Defined in Cardano.Protocol.TPraos.BlockHeader

Methods

encCBOR ∷ BHeader c → Encoding Source #

SafeToHash (BHeader c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

Memoized (BHeader c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

Associated Types

type RawType (BHeader c) 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

Generic (BHeader c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

Associated Types

type Rep (BHeader c) 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

type Rep (BHeader c) = D1 ('MetaData "BHeader" "Cardano.Protocol.TPraos.BlockHeader" "cardano-protocol-0.2.0.0-inplace" 'True) (C1 ('MetaCons "BHeaderConstr" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (MemoBytes (BHeaderRaw c)))))

Methods

from ∷ BHeader c → Rep (BHeader c) x #

to ∷ Rep (BHeader c) x → BHeader c #

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

Defined in Cardano.Protocol.TPraos.BlockHeader

Methods

showsPrec ∷ Int → BHeader c → ShowS #

show ∷ BHeader c → String #

showList ∷ [BHeader c] → ShowS #

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

Defined in Cardano.Protocol.TPraos.BlockHeader

Methods

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

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

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

Defined in Cardano.Protocol.TPraos.BlockHeader

(Crypto c, Era era) ⇒ EraBlockHeader (BHeader c) era Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

(Crypto c, Era era) ⇒ TPraosEraBlockHeader (BHeader c) era Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

HashAnnotated (BHeader c) EraIndependentBlockHeader Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

type RawType (BHeader c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

type Rep (BHeader c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

type Rep (BHeader c) = D1 ('MetaData "BHeader" "Cardano.Protocol.TPraos.BlockHeader" "cardano-protocol-0.2.0.0-inplace" 'True) (C1 ('MetaCons "BHeaderConstr" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (MemoBytes (BHeaderRaw c)))))

data BHeaderRaw c Source #

Constructors

BHeaderRaw 

Fields

Instances

Instances details
Crypto c ⇒ DecCBOR (Annotator (BHeaderRaw c)) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

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

Defined in Cardano.Protocol.TPraos.BlockHeader

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

Defined in Cardano.Protocol.TPraos.BlockHeader

Generic (BHeaderRaw c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

Associated Types

type Rep (BHeaderRaw c) 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

type Rep (BHeaderRaw c) = D1 ('MetaData "BHeaderRaw" "Cardano.Protocol.TPraos.BlockHeader" "cardano-protocol-0.2.0.0-inplace" 'False) (C1 ('MetaCons "BHeaderRaw" 'PrefixI 'True) (S1 ('MetaSel ('Just "bhrBody") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (BHBody c)) :*: S1 ('MetaSel ('Just "bhrSignature") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (SignedKES (KES c) (BHBody c)))))

Methods

from ∷ BHeaderRaw c → Rep (BHeaderRaw c) x #

to ∷ Rep (BHeaderRaw c) x → BHeaderRaw c #

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

Defined in Cardano.Protocol.TPraos.BlockHeader

Methods

showsPrec ∷ Int → BHeaderRaw c → ShowS #

show ∷ BHeaderRaw c → String #

showList ∷ [BHeaderRaw c] → ShowS #

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

Defined in Cardano.Protocol.TPraos.BlockHeader

Methods

(==) ∷ BHeaderRaw c → BHeaderRaw c → Bool #

(/=) ∷ BHeaderRaw c → BHeaderRaw c → Bool #

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

Defined in Cardano.Protocol.TPraos.BlockHeader

type MemoHashIndex (BHeaderRaw c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

type Rep (BHeaderRaw c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

type Rep (BHeaderRaw c) = D1 ('MetaData "BHeaderRaw" "Cardano.Protocol.TPraos.BlockHeader" "cardano-protocol-0.2.0.0-inplace" 'False) (C1 ('MetaCons "BHeaderRaw" 'PrefixI 'True) (S1 ('MetaSel ('Just "bhrBody") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (BHBody c)) :*: S1 ('MetaSel ('Just "bhrSignature") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (SignedKES (KES c) (BHBody c)))))

data BHBody c Source #

Constructors

BHBody 

Fields

Instances

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

Defined in Cardano.Protocol.TPraos.BlockHeader

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

Defined in Cardano.Protocol.TPraos.BlockHeader

Methods

decCBOR ∷ Decoder s (BHBody c) Source #

dropCBOR ∷ Proxy (BHBody c) → Decoder s () Source #

label ∷ Proxy (BHBody c) → Text Source #

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

Defined in Cardano.Protocol.TPraos.BlockHeader

Methods

encCBOR ∷ BHBody c → Encoding Source #

Generic (BHBody c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

Associated Types

type Rep (BHBody c) 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

Methods

from ∷ BHBody c → Rep (BHBody c) x #

to ∷ Rep (BHBody c) x → BHBody c #

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

Defined in Cardano.Protocol.TPraos.BlockHeader

Methods

showsPrec ∷ Int → BHBody c → ShowS #

show ∷ BHBody c → String #

showList ∷ [BHBody c] → ShowS #

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

Defined in Cardano.Protocol.TPraos.BlockHeader

Methods

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

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

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

Defined in Cardano.Protocol.TPraos.BlockHeader

type Rep (BHBody c) Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

data LastAppliedBlock Source #

Constructors

LastAppliedBlock 

Instances

Instances details
DecCBOR LastAppliedBlock Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

EncCBOR LastAppliedBlock Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

NFData LastAppliedBlock Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

Methods

rnf ∷ LastAppliedBlock → () #

Generic LastAppliedBlock Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

Associated Types

type Rep LastAppliedBlock 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

type Rep LastAppliedBlock = D1 ('MetaData "LastAppliedBlock" "Cardano.Protocol.TPraos.BlockHeader" "cardano-protocol-0.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))))
Show LastAppliedBlock Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

Eq LastAppliedBlock Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

Ord LastAppliedBlock Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

NoThunks LastAppliedBlock Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

type Rep LastAppliedBlock Source # 
Instance details

Defined in Cardano.Protocol.TPraos.BlockHeader

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

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.

issuerIDfromBHBody ∷ BHBody 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 ∷ VRFAlgorithm v ⇒ OutputVRF v → Rational → ActiveSlotCoeff → Bool 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)

bhHash ∷ BHeader c → HashHeader Source #

Hash a given block header

hashHeaderToNonce ∷ HashHeader → Nonce Source #

HashHeader to Nonce

bhbody ∷ Crypto 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.

bnonce ∷ BHBody c → Nonce Source #

Retrieve the new nonce from the block header body.