cardano-ledger-byron-1.0.1.0: The blockchain layer of Cardano during the Byron era
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cardano.Chain.Block.Header

Synopsis

Header

data AHeader a Source #

Constructors

AHeader 

Fields

Instances

Instances details
Functor AHeader Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Methods

fmap ∷ (a → b) → AHeader a → AHeader b Source #

(<$) ∷ a → AHeader b → AHeader a Source #

ToJSON a ⇒ ToJSON (AHeader a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Generic (AHeader a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Associated Types

type Rep (AHeader a) ∷ TypeType Source #

Methods

fromAHeader a → Rep (AHeader a) x Source #

toRep (AHeader a) x → AHeader a Source #

Show a ⇒ Show (AHeader a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Methods

showsPrecIntAHeader a → ShowS Source #

showAHeader a → String Source #

showList ∷ [AHeader a] → ShowS Source #

Decoded (AHeader ByteString) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Associated Types

type BaseType (AHeader ByteString) Source #

NFData a ⇒ NFData (AHeader a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Methods

rnfAHeader a → () Source #

Buildable (WithEpochSlots Header) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Eq a ⇒ Eq (AHeader a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Methods

(==)AHeader a → AHeader a → Bool Source #

(/=)AHeader a → AHeader a → Bool Source #

NoThunks a ⇒ NoThunks (AHeader a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

type Rep (AHeader a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

type Rep (AHeader a) = D1 ('MetaData "AHeader" "Cardano.Chain.Block.Header" "cardano-ledger-byron-1.0.1.0-inplace" 'False) (C1 ('MetaCons "AHeader" 'PrefixI 'True) (((S1 ('MetaSel ('Just "aHeaderProtocolMagicId") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Annotated ProtocolMagicId a)) :*: S1 ('MetaSel ('Just "aHeaderPrevHash") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Annotated HeaderHash a))) :*: (S1 ('MetaSel ('Just "aHeaderSlot") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Annotated SlotNumber a)) :*: (S1 ('MetaSel ('Just "aHeaderDifficulty") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Annotated ChainDifficulty a)) :*: S1 ('MetaSel ('Just "headerProtocolVersion") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ProtocolVersion)))) :*: ((S1 ('MetaSel ('Just "headerSoftwareVersion") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SoftwareVersion) :*: (S1 ('MetaSel ('Just "aHeaderProof") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Annotated Proof a)) :*: S1 ('MetaSel ('Just "headerGenesisKey") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 VerificationKey))) :*: (S1 ('MetaSel ('Just "headerSignature") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (ABlockSignature a)) :*: (S1 ('MetaSel ('Just "headerAnnotation") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Just "headerExtraAnnotation") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a))))))
type BaseType (AHeader ByteString) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Header Constructors

mkHeader Source #

Arguments

ProtocolMagicId 
Either GenesisHash Header 
EpochSlots

Number of slots per epoch. This is needed to convert the slot number to the legacy format used in ToSign, where a slot is identified by the epoch to which it belongs and the offset within that epoch (counted in number of slots).

SlotNumber 
SigningKey

The SigningKey used for signing the block

Certificate

A certificate of delegation from a genesis key to the SigningKey

Body 
ProtocolVersion 
SoftwareVersion 
Header 

Smart constructor for Header

mkHeaderExplicit Source #

Arguments

ProtocolMagicId 
HeaderHash

Parent

ChainDifficulty 
EpochSlots

See mkHeader.

SlotNumber 
SigningKey

The SigningKey used for signing the block

Certificate

A certificate of delegation from a genesis key to the SigningKey

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

Header Binary Serialization

encCBORHeaderEpochSlotsHeaderEncoding Source #

Encode a header, without taking in to account deprecated epoch boundary blocks.

encCBORHeaderToHashEpochSlotsHeaderEncoding 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

wrapHeaderBytesByteStringByteString 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

Boundary Header

data ABoundaryHeader a Source #

Instances

Instances details
Functor ABoundaryHeader Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Methods

fmap ∷ (a → b) → ABoundaryHeader a → ABoundaryHeader b Source #

(<$) ∷ a → ABoundaryHeader b → ABoundaryHeader a Source #

ToJSON a ⇒ ToJSON (ABoundaryHeader a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Generic (ABoundaryHeader a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Associated Types

type Rep (ABoundaryHeader a) ∷ TypeType Source #

Show a ⇒ Show (ABoundaryHeader a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Decoded (ABoundaryHeader ByteString) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Associated Types

type BaseType (ABoundaryHeader ByteString) Source #

Eq a ⇒ Eq (ABoundaryHeader a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

NoThunks a ⇒ NoThunks (ABoundaryHeader a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

type Rep (ABoundaryHeader a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

type Rep (ABoundaryHeader a) = D1 ('MetaData "ABoundaryHeader" "Cardano.Chain.Block.Header" "cardano-ledger-byron-1.0.1.0-inplace" 'False) (C1 ('MetaCons "UnsafeABoundaryHeader" 'PrefixI 'True) ((S1 ('MetaSel ('Just "boundaryPrevHash") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Either GenesisHash HeaderHash)) :*: S1 ('MetaSel ('Just "boundaryEpoch") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64)) :*: (S1 ('MetaSel ('Just "boundaryDifficulty") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ChainDifficulty) :*: S1 ('MetaSel ('Just "boundaryHeaderAnnotation") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a))))
type BaseType (ABoundaryHeader ByteString) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

mkABoundaryHeaderEither GenesisHash HeaderHashWord64ChainDifficulty → a → ABoundaryHeader a Source #

Smart constructor for ABoundaryHeader

Makes sure that the hash is forced.

encCBORABoundaryHeaderProtocolMagicIdABoundaryHeader 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).

boundaryHeaderHashAnnotatedABoundaryHeader ByteStringHeaderHash 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.

wrapBoundaryBytesByteStringByteString 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

type HeaderHash = Hash Header Source #

Hash of block header

headerHashFFormat r (HeaderHash → r) Source #

Specialized formatter for HeaderHash

hashHeaderEpochSlotsHeaderHeaderHash Source #

Hash the serialised representation of a Header

For backwards compatibility we have to take the hash of the header serialised with encCBORHeaderToHash

genesisHeaderHashGenesisHashHeaderHash Source #

Extract the genesis hash and cast it into a header hash.

BlockSignature

data ABlockSignature a Source #

Signature of the Block

We use a heavyweight delegation scheme, so the signature has two parts:

  1. A delegation certificate from a genesis key to the block signer
  2. The actual signature over ToSign

Instances

Instances details
Functor ABlockSignature Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Methods

fmap ∷ (a → b) → ABlockSignature a → ABlockSignature b Source #

(<$) ∷ a → ABlockSignature b → ABlockSignature a Source #

FromCBOR BlockSignature Source # 
Instance details

Defined in Cardano.Chain.Block.Header

ToCBOR BlockSignature Source # 
Instance details

Defined in Cardano.Chain.Block.Header

DecCBOR BlockSignature Source # 
Instance details

Defined in Cardano.Chain.Block.Header

EncCBOR BlockSignature Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Buildable BlockSignature Source # 
Instance details

Defined in Cardano.Chain.Block.Header

ToJSON a ⇒ ToJSON (ABlockSignature a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Generic (ABlockSignature a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Associated Types

type Rep (ABlockSignature a) ∷ TypeType Source #

Show a ⇒ Show (ABlockSignature a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

FromCBOR (ABlockSignature ByteSpan) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

DecCBOR (ABlockSignature ByteSpan) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

NFData a ⇒ NFData (ABlockSignature a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Methods

rnfABlockSignature a → () Source #

Eq a ⇒ Eq (ABlockSignature a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

NoThunks a ⇒ NoThunks (ABlockSignature a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

type Rep (ABlockSignature a) Source # 
Instance details

Defined in Cardano.Chain.Block.Header

type Rep (ABlockSignature a) = D1 ('MetaData "ABlockSignature" "Cardano.Chain.Block.Header" "cardano-ledger-byron-1.0.1.0-inplace" 'False) (C1 ('MetaCons "ABlockSignature" 'PrefixI 'True) (S1 ('MetaSel ('Just "delegationCertificate") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (ACertificate a)) :*: S1 ('MetaSel ('Just "signature") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Signature ToSign))))

ToSign

data ToSign Source #

Data to be signed in Block

Instances

Instances details
Generic ToSign Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Associated Types

type Rep ToSignTypeType Source #

Methods

fromToSignRep ToSign x Source #

toRep ToSign x → ToSign Source #

Show ToSign Source # 
Instance details

Defined in Cardano.Chain.Block.Header

FromCBOR ToSign Source # 
Instance details

Defined in Cardano.Chain.Block.Header

ToCBOR ToSign Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Methods

toCBORToSignEncoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy ToSignSize Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [ToSign] → Size Source #

DecCBOR ToSign Source # 
Instance details

Defined in Cardano.Chain.Block.Header

EncCBOR ToSign Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Methods

encCBORToSignEncoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy ToSignSize Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [ToSign] → Size Source #

Eq ToSign Source # 
Instance details

Defined in Cardano.Chain.Block.Header

Methods

(==)ToSignToSignBool Source #

(/=)ToSignToSignBool Source #

type Rep ToSign Source # 
Instance details

Defined in Cardano.Chain.Block.Header

recoverSignedBytesEpochSlotsAHeader ByteStringAnnotated ToSign ByteString Source #

Produces the ByteString that was signed in the block