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

Cardano.Chain.Common.CBOR

Description

CBOR encoding utilities needed for the Byron transaction format

Synopsis

CBOR in CBOR

These utilities are is used in the Byron-era chain encodings in cases where there are extensible parts of the encoding. In thse cases we have to be able to handle unknown extensions and thus decode values where we do not know the concrete type.

To solve this, the serialised representation uses nested CBOR-in-CBOR https://tools.ietf.org/html/rfc7049#section-2.4.4.1. The nesting means that the size is known without having to decode the body in those cases where we cannot decode the body.

The functions in this module handle the encoding and decoding for the cases of the known and unknown types.

encodeKnownCborDataItemEncCBOR a ⇒ a → Encoding Source #

This is an alias for encodeNestedCbor.

This function is used to handle the case of a known type, but compatible with the encoding used by encodeUnknownCborDataItem.

encodeUnknownCborDataItemLByteStringEncoding Source #

This is an alias for encodeNestedCborBytes, so all its details apply.

This function is used to handle the case of an unknown type, so it takes an opaque blob that is the representation of the value of the unknown type.

decodeKnownCborDataItemDecCBOR a ⇒ Decoder s a Source #

This is an alias for decodeNestedCbor.

This function is used to handle the case of a known type, but compatible with the encoding used by decodeUnknownCborDataItem.

decodeUnknownCborDataItemDecoder s ByteString Source #

This is an alias for decodeNestedCborBytes, so all its details apply.

This function is used to handle the case of an unknown type, so it returns an opaque blob that is the representation of the value of the unknown type.

Cyclic redundancy check

The Byron era address format includes a CRC to help resist accidental corruption. These functions deal with encoding and decoding the format that is used.

encodeCrcProtectedEncCBOR a ⇒ a → Encoding Source #

Encodes a value of type a, protecting it from accidental corruption by protecting it with a CRC.

encodedCrcProtectedSizeExpr ∷ ∀ a. EncCBOR a ⇒ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy a → Size Source #

decodeCrcProtected ∷ ∀ s a. DecCBOR a ⇒ Decoder s a Source #

Decodes a CBOR blob into a value of type a, checking the serialised CRC corresponds to the computed one