Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
CBOR encoding utilities needed for the Byron transaction format
Synopsis
- encodeKnownCborDataItem ∷ EncCBOR a ⇒ a → Encoding
- encodeUnknownCborDataItem ∷ LByteString → Encoding
- knownCborDataItemSizeExpr ∷ Size → Size
- unknownCborDataItemSizeExpr ∷ Size → Size
- decodeKnownCborDataItem ∷ DecCBOR a ⇒ Decoder s a
- decodeUnknownCborDataItem ∷ Decoder s ByteString
- encodeCrcProtected ∷ EncCBOR a ⇒ a → Encoding
- encodedCrcProtectedSizeExpr ∷ ∀ a. EncCBOR a ⇒ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy a → Size
- decodeCrcProtected ∷ ∀ s a. DecCBOR a ⇒ Decoder s a
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.
encodeKnownCborDataItem ∷ EncCBOR 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
.
encodeUnknownCborDataItem ∷ LByteString → Encoding 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.
decodeKnownCborDataItem ∷ DecCBOR 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
.
decodeUnknownCborDataItem ∷ Decoder 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.
encodeCrcProtected ∷ EncCBOR 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