Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- type Header = AHeader ()
- data AHeader a = AHeader {
- aHeaderProtocolMagicId ∷ !(Annotated ProtocolMagicId a)
- aHeaderPrevHash ∷ !(Annotated HeaderHash a)
- aHeaderSlot ∷ !(Annotated SlotNumber a)
- aHeaderDifficulty ∷ !(Annotated ChainDifficulty a)
- headerProtocolVersion ∷ !ProtocolVersion
- headerSoftwareVersion ∷ !SoftwareVersion
- aHeaderProof ∷ !(Annotated Proof a)
- headerGenesisKey ∷ !VerificationKey
- headerSignature ∷ !(ABlockSignature a)
- headerAnnotation ∷ !a
- headerExtraAnnotation ∷ !a
- mkHeader ∷ ProtocolMagicId → Either GenesisHash Header → EpochSlots → SlotNumber → SigningKey → Certificate → Body → ProtocolVersion → SoftwareVersion → Header
- mkHeaderExplicit ∷ ProtocolMagicId → HeaderHash → ChainDifficulty → EpochSlots → SlotNumber → SigningKey → Certificate → Body → ProtocolVersion → SoftwareVersion → Header
- headerProtocolMagicId ∷ AHeader a → ProtocolMagicId
- headerPrevHash ∷ AHeader a → HeaderHash
- headerProof ∷ AHeader a → Proof
- headerSlot ∷ AHeader a → SlotNumber
- headerIssuer ∷ AHeader a → VerificationKey
- headerLength ∷ AHeader ByteString → Natural
- headerDifficulty ∷ AHeader a → ChainDifficulty
- headerToSign ∷ EpochSlots → AHeader a → ToSign
- encCBORHeader ∷ EpochSlots → Header → Encoding
- encCBORHeaderSize ∷ Proxy EpochSlots → Proxy (AHeader a) → Size
- encCBORHeaderToHash ∷ EpochSlots → Header → Encoding
- decCBORAHeader ∷ EpochSlots → Decoder s (AHeader ByteSpan)
- decCBORHeader ∷ EpochSlots → Decoder s Header
- decCBORHeaderToHash ∷ EpochSlots → Decoder s (Maybe Header)
- wrapHeaderBytes ∷ ByteString → ByteString
- encCBORBlockVersions ∷ ProtocolVersion → SoftwareVersion → Encoding
- encCBORBlockVersionsSize ∷ Proxy ProtocolVersion → Proxy SoftwareVersion → Size
- renderHeader ∷ EpochSlots → Header → Builder
- data ABoundaryHeader a = UnsafeABoundaryHeader {}
- mkABoundaryHeader ∷ Either GenesisHash HeaderHash → Word64 → ChainDifficulty → a → ABoundaryHeader a
- encCBORABoundaryHeader ∷ ProtocolMagicId → ABoundaryHeader a → Encoding
- encCBORABoundaryHeaderSize ∷ Proxy ProtocolMagicId → Proxy (ABoundaryHeader a) → Size
- decCBORABoundaryHeader ∷ Decoder s (ABoundaryHeader ByteSpan)
- boundaryHeaderHashAnnotated ∷ ABoundaryHeader ByteString → HeaderHash
- wrapBoundaryBytes ∷ ByteString → ByteString
- type HeaderHash = Hash Header
- headerHashF ∷ Format r (HeaderHash → r)
- hashHeader ∷ EpochSlots → Header → HeaderHash
- headerHashAnnotated ∷ AHeader ByteString → HeaderHash
- genesisHeaderHash ∷ GenesisHash → HeaderHash
- type BlockSignature = ABlockSignature ()
- data ABlockSignature a = ABlockSignature {
- delegationCertificate ∷ !(ACertificate a)
- signature ∷ !(Signature ToSign)
- data ToSign = ToSign {}
- recoverSignedBytes ∷ EpochSlots → AHeader ByteString → Annotated ToSign ByteString
Header
AHeader | |
|
Instances
Header Constructors
∷ ProtocolMagicId | |
→ Either GenesisHash Header | |
→ EpochSlots | Number of slots per epoch. This is needed to convert the slot number to
the legacy format used in |
→ SlotNumber | |
→ SigningKey | The |
→ Certificate | A certificate of delegation from a genesis key to the |
→ Body | |
→ ProtocolVersion | |
→ SoftwareVersion | |
→ Header |
Smart constructor for Header
∷ ProtocolMagicId | |
→ HeaderHash | Parent |
→ ChainDifficulty | |
→ EpochSlots | See |
→ SlotNumber | |
→ SigningKey | The |
→ Certificate | A certificate of delegation from a genesis key to the |
→ Body | |
→ ProtocolVersion | |
→ SoftwareVersion | |
→ Header |
Make a Header
for a given slot, with a given body, parent hash,
and difficulty. This takes care of some signing and consensus data.
Header Accessors
headerPrevHash ∷ AHeader a → HeaderHash Source #
headerProof ∷ AHeader a → Proof Source #
headerSlot ∷ AHeader a → SlotNumber Source #
headerToSign ∷ EpochSlots → AHeader a → ToSign Source #
Header Binary Serialization
encCBORHeader ∷ EpochSlots → Header → Encoding Source #
Encode a header, without taking in to account deprecated epoch boundary blocks.
encCBORHeaderSize ∷ Proxy EpochSlots → Proxy (AHeader a) → Size Source #
encCBORHeaderToHash ∷ EpochSlots → Header → Encoding Source #
Encode a Header
accounting for deprecated epoch boundary blocks
This encoding is only used when hashing the header for backwards compatibility, but should not be used when serializing a header within a block
decCBORAHeader ∷ EpochSlots → Decoder s (AHeader ByteSpan) Source #
decCBORHeader ∷ EpochSlots → Decoder s Header Source #
decCBORHeaderToHash ∷ EpochSlots → Decoder s (Maybe Header) Source #
wrapHeaderBytes ∷ ByteString → ByteString Source #
These bytes must be prepended when hashing raw boundary header data
In the Byron release, hashes were taken over a data type that was never directly serialized to the blockchain, so these magic bytes cannot be determined from the raw header data.
These bytes are from `encodeListLen 2 <> encCBOR (1 :: Word8)`
Header Formatting
renderHeader ∷ EpochSlots → Header → Builder Source #
Boundary Header
data ABoundaryHeader a Source #
Instances
mkABoundaryHeader ∷ Either GenesisHash HeaderHash → Word64 → ChainDifficulty → a → ABoundaryHeader a Source #
Smart constructor for ABoundaryHeader
Makes sure that the hash is forced.
encCBORABoundaryHeader ∷ ProtocolMagicId → ABoundaryHeader a → Encoding Source #
Encode from a boundary header with any annotation. This does not
necessarily invert decCBORBoundaryHeader
, because that decoder drops
information that this encoder replaces, such as the body proof (assumes
the body is empty) and the extra header data (sets it to empty map).
boundaryHeaderHashAnnotated ∷ ABoundaryHeader ByteString → HeaderHash Source #
Compute the hash of a boundary block header from its annotation.
It uses wrapBoundaryBytes
, for the hash must be computed on the header
bytes tagged with the CBOR list length and tag discriminator, which is
the encoding chosen by cardano-sl.
wrapBoundaryBytes ∷ ByteString → ByteString Source #
These bytes must be prepended when hashing raw boundary header data
In the Byron release, hashes were taken over a data type that was never directly serialized to the blockchain, so these magic bytes cannot be determined from the raw header data.
HeaderHash
headerHashF ∷ Format r (HeaderHash → r) Source #
Specialized formatter for HeaderHash
hashHeader ∷ EpochSlots → Header → HeaderHash Source #
Hash the serialised representation of a Header
For backwards compatibility we have to take the hash of the header
serialised with encCBORHeaderToHash
genesisHeaderHash ∷ GenesisHash → HeaderHash Source #
Extract the genesis hash and cast it into a header hash.
BlockSignature
type BlockSignature = ABlockSignature () Source #
data ABlockSignature a Source #
Signature of the Block
We use a heavyweight delegation scheme, so the signature has two parts:
- A delegation certificate from a genesis key to the block signer
- The actual signature over
ToSign
Instances
ToSign
Data to be signed in Block
ToSign | |
|
Instances
recoverSignedBytes ∷ EpochSlots → AHeader ByteString → Annotated ToSign ByteString Source #
Produces the ByteString that was signed in the block