Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- newtype HashHeader = HashHeader {}
- data PrevHash
- data BHeader c where
- data BHBody c = BHBody {
- bheaderBlockNo ∷ !BlockNo
- bheaderSlotNo ∷ !SlotNo
- bheaderPrev ∷ !PrevHash
- bheaderVk ∷ !(VKey 'BlockIssuer)
- bheaderVrfVk ∷ !(VerKeyVRF (VRF c))
- bheaderEta ∷ !(CertifiedVRF (VRF c) Nonce)
- bheaderL ∷ !(CertifiedVRF (VRF c) Natural)
- bsize ∷ !Word32
- bhash ∷ !(Hash HASH EraIndependentBlockBody)
- bheaderOCert ∷ !(OCert c)
- bprotver ∷ !ProtVer
- data LastAppliedBlock = LastAppliedBlock {}
- data BoundedNatural
- assertBoundedNatural ∷ Natural → Natural → BoundedNatural
- lastAppliedHash ∷ WithOrigin LastAppliedBlock → PrevHash
- issuerIDfromBHBody ∷ BHBody c → KeyHash 'BlockIssuer
- checkLeaderValue ∷ ∀ v. VRFAlgorithm v ⇒ OutputVRF v → Rational → ActiveSlotCoeff → Bool
- checkLeaderNatValue ∷ BoundedNatural → Rational → ActiveSlotCoeff → Bool
- bhHash ∷ Crypto c ⇒ BHeader c → HashHeader
- hashHeaderToNonce ∷ HashHeader → Nonce
- prevHashToNonce ∷ PrevHash → Nonce
- bHeaderSize ∷ ∀ c. BHeader c → Int
- bhbody ∷ Crypto c ⇒ BHeader c → BHBody c
- hBbsize ∷ BHBody c → Word32
- seedEta ∷ Nonce
- seedL ∷ Nonce
- mkSeed ∷ Nonce → SlotNo → Nonce → Seed
- bnonce ∷ BHBody c → Nonce
- makeHeaderView ∷ BHeader c → BHeaderView
Documentation
newtype HashHeader Source #
The hash of a Block Header
Instances
The previous hash of a block
Instances
Generic PrevHash Source # | |
Show PrevHash Source # | |
DecCBOR PrevHash Source # | |
EncCBOR PrevHash Source # | |
Eq PrevHash Source # | |
Ord PrevHash Source # | |
Defined in Cardano.Protocol.TPraos.BHeader | |
NoThunks PrevHash Source # | |
type Rep PrevHash Source # | |
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) (U1 ∷ Type → Type) :+: C1 ('MetaCons "BlockHash" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HashHeader))) |
Instances
Generic (BHeader c) Source # | |
Crypto c ⇒ Show (BHeader c) Source # | |
Crypto c ⇒ ToCBOR (BHeader c) Source # | |
Crypto c ⇒ DecCBOR (Annotator (BHeader c)) Source # | |
Crypto c ⇒ EncCBOR (BHeader c) Source # | |
Crypto c ⇒ Eq (BHeader c) Source # | |
Crypto c ⇒ NoThunks (BHeader c) Source # | |
type Rep (BHeader c) Source # | |
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)))) |
BHBody | |
|
Instances
data LastAppliedBlock Source #
Instances
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.
∷ 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 ∷ ∀ 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.
∷ 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)
hashHeaderToNonce ∷ HashHeader → Nonce Source #
HashHeader to Nonce
bHeaderSize ∷ ∀ c. BHeader c → Int Source #
Construct a seed to use in the VRF computation.
makeHeaderView ∷ BHeader c → BHeaderView Source #