Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- newtype HashHeader c = HashHeader {}
- data PrevHash c
- = GenesisHash
- | BlockHash !(HashHeader c)
- data BHeader c where
- data BHBody c = BHBody {
- bheaderBlockNo ∷ !BlockNo
- bheaderSlotNo ∷ !SlotNo
- bheaderPrev ∷ !(PrevHash c)
- bheaderVk ∷ !(VKey 'BlockIssuer c)
- bheaderVrfVk ∷ !(VerKeyVRF c)
- bheaderEta ∷ !(CertifiedVRF c Nonce)
- bheaderL ∷ !(CertifiedVRF c Natural)
- bsize ∷ !Word32
- bhash ∷ !(Hash c EraIndependentBlockBody)
- bheaderOCert ∷ !(OCert c)
- bprotver ∷ !ProtVer
- data LastAppliedBlock c = LastAppliedBlock {
- labBlockNo ∷ !BlockNo
- labSlotNo ∷ !SlotNo
- labHash ∷ !(HashHeader c)
- data BoundedNatural
- assertBoundedNatural ∷ Natural → Natural → BoundedNatural
- lastAppliedHash ∷ WithOrigin (LastAppliedBlock c) → PrevHash c
- issuerIDfromBHBody ∷ Crypto c ⇒ BHBody c → KeyHash 'BlockIssuer c
- checkLeaderValue ∷ ∀ v. VRFAlgorithm v ⇒ OutputVRF v → Rational → ActiveSlotCoeff → Bool
- checkLeaderNatValue ∷ BoundedNatural → Rational → ActiveSlotCoeff → Bool
- bhHash ∷ Crypto c ⇒ BHeader c → HashHeader c
- hashHeaderToNonce ∷ HashHeader c → Nonce
- prevHashToNonce ∷ PrevHash c → 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 ∷ Crypto c ⇒ BHeader c → BHeaderView c
Documentation
newtype HashHeader c Source #
The hash of a Block Header
Instances
The previous hash of a block
Instances
Generic (PrevHash c) Source # | |
Show (PrevHash c) Source # | |
Crypto c ⇒ DecCBOR (PrevHash c) Source # | |
Crypto c ⇒ EncCBOR (PrevHash c) Source # | |
Eq (PrevHash c) Source # | |
Ord (PrevHash c) Source # | |
Defined in Cardano.Protocol.TPraos.BHeader | |
Crypto c ⇒ NoThunks (PrevHash c) Source # | |
type Rep (PrevHash c) Source # | |
Defined in Cardano.Protocol.TPraos.BHeader type Rep (PrevHash c) = D1 ('MetaData "PrevHash" "Cardano.Protocol.TPraos.BHeader" "cardano-protocol-tpraos-1.3.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 c)))) |
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.3.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)))) |
BHBody | |
|
Instances
data LastAppliedBlock c Source #
LastAppliedBlock | |
|
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.
lastAppliedHash ∷ WithOrigin (LastAppliedBlock c) → PrevHash c Source #
issuerIDfromBHBody ∷ Crypto 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 → 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 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.
prevHashToNonce ∷ PrevHash c → Nonce Source #
bHeaderSize ∷ ∀ c. BHeader c → Int Source #
Construct a seed to use in the VRF computation.
makeHeaderView ∷ Crypto c ⇒ BHeader c → BHeaderView c Source #