cardano-protocol-tpraos-0.1.0.0
Safe Haskell None
Language Haskell2010

Cardano.Protocol.TPraos.BHeader

Synopsis

Documentation

newtype HashHeader crypto Source #

The hash of a Block Header

Instances

Instances details
Eq ( HashHeader crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Ord ( HashHeader crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Show ( HashHeader crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Generic ( HashHeader crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Associated Types

type Rep ( HashHeader crypto) :: Type -> Type Source #

NFData ( HashHeader crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Methods

rnf :: HashHeader crypto -> () Source #

Crypto crypto => ToCBOR ( HashHeader crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Crypto crypto => FromCBOR ( HashHeader crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

NoThunks ( HashHeader crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

type Rep ( HashHeader crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

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

data PrevHash crypto Source #

The previous hash of a block

Instances

Instances details
Eq ( PrevHash crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Ord ( PrevHash crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Show ( PrevHash crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Generic ( PrevHash crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Associated Types

type Rep ( PrevHash crypto) :: Type -> Type Source #

Crypto crypto => ToCBOR ( PrevHash crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Crypto crypto => FromCBOR ( PrevHash crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Crypto crypto => NoThunks ( PrevHash crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

type Rep ( PrevHash crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

type Rep ( PrevHash crypto) = D1 (' MetaData "PrevHash" "Cardano.Protocol.TPraos.BHeader" "cardano-protocol-tpraos-0.1.0.0-La5Cvz4HrqgBuFHns9l3Vn" ' False ) ( C1 (' MetaCons "GenesisHash" ' PrefixI ' False ) ( U1 :: Type -> Type ) :+: C1 (' MetaCons "BlockHash" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ( HashHeader crypto))))

data BHeader crypto where Source #

Bundled Patterns

pattern BHeader :: Crypto crypto => BHBody crypto -> SignedKES crypto ( BHBody crypto) -> BHeader crypto

Instances

Instances details
Crypto crypto => Eq ( BHeader crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Crypto crypto => Show ( BHeader crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Generic ( BHeader crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Associated Types

type Rep ( BHeader crypto) :: Type -> Type Source #

Crypto crypto => ToCBOR ( BHeader crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Crypto crypto => FromCBOR ( Annotator ( BHeader crypto)) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Crypto crypto => NoThunks ( BHeader crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

type Rep ( BHeader crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

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

data BHBody crypto Source #

Constructors

BHBody

Fields

Instances

Instances details
Crypto crypto => Eq ( BHBody crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Crypto crypto => Show ( BHBody crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Generic ( BHBody crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Associated Types

type Rep ( BHBody crypto) :: Type -> Type Source #

Crypto crypto => ToCBOR ( BHBody crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Crypto crypto => FromCBOR ( BHBody crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Crypto crypto => SignableRepresentation ( BHBody crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Crypto crypto => NoThunks ( BHBody crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

type Rep ( BHBody crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

type Rep ( BHBody crypto) = D1 (' MetaData "BHBody" "Cardano.Protocol.TPraos.BHeader" "cardano-protocol-tpraos-0.1.0.0-La5Cvz4HrqgBuFHns9l3Vn" ' False ) ( C1 (' MetaCons "BHBody" ' PrefixI ' True ) ((( S1 (' MetaSel (' Just "bheaderBlockNo") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 BlockNo ) :*: S1 (' MetaSel (' Just "bheaderSlotNo") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 SlotNo )) :*: ( S1 (' MetaSel (' Just "bheaderPrev") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ( PrevHash crypto)) :*: ( S1 (' MetaSel (' Just "bheaderVk") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ( VKey ' BlockIssuer crypto)) :*: S1 (' MetaSel (' Just "bheaderVrfVk") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ( VerKeyVRF crypto))))) :*: (( S1 (' MetaSel (' Just "bheaderEta") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ( CertifiedVRF crypto Nonce )) :*: ( S1 (' MetaSel (' Just "bheaderL") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ( CertifiedVRF crypto Natural )) :*: S1 (' MetaSel (' Just "bsize") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 Natural ))) :*: ( S1 (' MetaSel (' Just "bhash") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ( Hash crypto EraIndependentBlockBody )) :*: ( S1 (' MetaSel (' Just "bheaderOCert") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ( OCert crypto)) :*: S1 (' MetaSel (' Just "bprotver") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ProtVer ))))))

data LastAppliedBlock crypto Source #

Instances

Instances details
Eq ( LastAppliedBlock crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Show ( LastAppliedBlock crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Generic ( LastAppliedBlock crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Associated Types

type Rep ( LastAppliedBlock crypto) :: Type -> Type Source #

NFData ( LastAppliedBlock crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Crypto crypto => ToCBOR ( LastAppliedBlock crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Crypto crypto => FromCBOR ( LastAppliedBlock crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

Crypto crypto => NoThunks ( LastAppliedBlock crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

type Rep ( LastAppliedBlock crypto) Source #
Instance details

Defined in Cardano.Protocol.TPraos.BHeader

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

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 :: Crypto crypto => BHBody crypto -> KeyHash ' BlockIssuer crypto 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 :: forall v. 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 :: Crypto crypto => BHeader crypto -> HashHeader crypto Source #

Hash a given block header

hashHeaderToNonce :: HashHeader crypto -> 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.

mkSeed Source #

Arguments

:: Nonce

Universal constant

-> SlotNo
-> Nonce

Epoch nonce

-> Seed

Construct a seed to use in the VRF computation.

bnonce :: BHBody crypto -> Nonce Source #

Retrieve the new nonce from the block header body.