packages feed

mfmts 1.0.0.1 → 1.1.0.0

raw patch · 27 files changed

+2492/−2079 lines, 27 filesdep +textdep ~basesystemsdep ~bytestringdep ~containersPVP ok

version bump matches the API change (PVP)

Dependencies added: text

Dependency ranges changed: basesystems, bytestring, containers

API changes (from Hackage documentation)

- MultiFormats.CID: getDataCodec :: CID -> MultiCodec
- MultiFormats.CID: getHashCodec :: CID -> MultiHash
- MultiFormats.CID: getHashDigest :: CID -> ByteString
- MultiFormats.CID: getVersion :: CID -> VersionEnum
- MultiFormats.CID: instance MultiFormats.CID.Extractor.Extractor MultiFormats.CID.CID
- MultiFormats.CID: newtype CID
- MultiFormats.CID.Errors: ExpectedHashCodec :: HashError
- MultiFormats.CID.Extractor: instance MultiFormats.CID.Extractor.Extractor MultiFormats.VarInt.VarInt
- MultiFormats.CID.Internal: CIDData :: VersionEnum -> MultiCodec -> MultiHash -> ByteString -> CIDData
- MultiFormats.CID.Internal: [cidDataCodec] :: CIDData -> MultiCodec
- MultiFormats.CID.Internal: [cidHashCodec] :: CIDData -> MultiHash
- MultiFormats.CID.Internal: [cidHashDigest] :: CIDData -> ByteString
- MultiFormats.CID.Internal: [cidVersion] :: CIDData -> VersionEnum
- MultiFormats.CID.Internal: data CIDData
- MultiFormats.CID.Internal: extractCIDv0 :: Extraction CIDData
- MultiFormats.CID.Internal: extractCIDv1 :: Extraction CIDData
- MultiFormats.CID.Internal: instance GHC.Classes.Eq MultiFormats.CID.Internal.CIDData
- MultiFormats.CID.Internal: mkCIDv0 :: ByteString -> CIDData
- MultiFormats.CID.Internal: serializeCIDv0 :: Serialization CIDData
- MultiFormats.CID.Internal: serializeCIDv1 :: Serialization CIDData
- MultiFormats.CID.Internal.CIDCodec: CIDCodec :: MultiCodec -> CIDCodec
- MultiFormats.CID.Internal.CIDCodec: instance GHC.Classes.Eq MultiFormats.CID.Internal.CIDCodec.CIDCodec
- MultiFormats.CID.Internal.CIDCodec: instance MultiFormats.CID.Extractor.Extractor MultiFormats.CID.Internal.CIDCodec.CIDCodec
- MultiFormats.CID.Internal.CIDCodec: newtype CIDCodec
- MultiFormats.CID.Internal.CIDDecoder: CIDDecoder :: ByteString -> CIDDecoder
- MultiFormats.CID.Internal.CIDDecoder: instance MultiFormats.CID.Parser.Parser MultiFormats.CID.Internal.CIDDecoder.CIDDecoder
- MultiFormats.CID.Internal.CIDDecoder: newtype CIDDecoder
- MultiFormats.CID.Internal.CIDHash: CIDHash :: MultiHash -> ByteString -> CIDHash
- MultiFormats.CID.Internal.CIDHash: data CIDHash
- MultiFormats.CID.Internal.CIDHash: instance GHC.Classes.Eq MultiFormats.CID.Internal.CIDHash.CIDHash
- MultiFormats.CID.Internal.CIDHash: instance MultiFormats.CID.Extractor.Extractor MultiFormats.CID.Internal.CIDHash.CIDHash
- MultiFormats.CID.Internal.CIDVersion: CIDVersion :: VersionEnum -> CIDVersion
- MultiFormats.CID.Internal.CIDVersion: CIDv0 :: VersionEnum
- MultiFormats.CID.Internal.CIDVersion: CIDv1 :: VersionEnum
- MultiFormats.CID.Internal.CIDVersion: cidv0Byte1st :: Word8
- MultiFormats.CID.Internal.CIDVersion: cidv0Bytes :: Int
- MultiFormats.CID.Internal.CIDVersion: cidv0HashLength :: Int
- MultiFormats.CID.Internal.CIDVersion: cidv1VarInt1st :: VarInt
- MultiFormats.CID.Internal.CIDVersion: data VersionEnum
- MultiFormats.CID.Internal.CIDVersion: extractVersion0 :: Extraction VersionEnum
- MultiFormats.CID.Internal.CIDVersion: extractVersion1 :: Extraction VersionEnum
- MultiFormats.CID.Internal.CIDVersion: instance GHC.Classes.Eq MultiFormats.CID.Internal.CIDVersion.CIDVersion
- MultiFormats.CID.Internal.CIDVersion: instance GHC.Classes.Eq MultiFormats.CID.Internal.CIDVersion.VersionEnum
- MultiFormats.CID.Internal.CIDVersion: instance GHC.Enum.Enum MultiFormats.CID.Internal.CIDVersion.VersionEnum
- MultiFormats.CID.Internal.CIDVersion: instance GHC.Show.Show MultiFormats.CID.Internal.CIDVersion.VersionEnum
- MultiFormats.CID.Internal.CIDVersion: instance MultiFormats.CID.Extractor.Extractor MultiFormats.CID.Internal.CIDVersion.CIDVersion
- MultiFormats.CID.Internal.CIDVersion: isCIDv0Str :: String -> Bool
- MultiFormats.CID.Internal.CIDVersion: newtype CIDVersion
- MultiFormats.MultiBase: data MultiBase
- MultiFormats.MultiBase: decodeCIDv0 :: Decoder
- MultiFormats.MultiBase: decodeFromPrefix :: Decoder
- MultiFormats.MultiBase: hasValidPrefix :: String -> Bool
- MultiFormats.MultiBase: instance Data.BaseSystem.BaseSystem MultiFormats.MultiBase.MultiBase
- MultiFormats.MultiBase: instance GHC.Classes.Eq MultiFormats.MultiBase.MultiBase
- MultiFormats.MultiBase: instance GHC.Classes.Ord MultiFormats.MultiBase.MultiBase
- MultiFormats.MultiBase: instance GHC.Show.Show MultiFormats.MultiBase.MultiBase
- MultiFormats.MultiBase: mkMultiBase :: (Show b, BaseSystem b) => b -> Char -> MultiBase
- MultiFormats.MultiBase: resolveMultiBase :: String -> Maybe MultiBase
- MultiFormats.MultiBase: resolvePrefix :: Char -> Maybe MultiBase
- MultiFormats.MultiBaseSystems: base10 :: MultiBase
- MultiFormats.MultiBaseSystems: base16lower :: MultiBase
- MultiFormats.MultiBaseSystems: base16upper :: MultiBase
- MultiFormats.MultiBaseSystems: base2 :: MultiBase
- MultiFormats.MultiBaseSystems: base32hexlower :: MultiBase
- MultiFormats.MultiBaseSystems: base32hexlowerNP :: MultiBase
- MultiFormats.MultiBaseSystems: base32hexupper :: MultiBase
- MultiFormats.MultiBaseSystems: base32hexupperNP :: MultiBase
- MultiFormats.MultiBaseSystems: base32lower :: MultiBase
- MultiFormats.MultiBaseSystems: base32lowerNP :: MultiBase
- MultiFormats.MultiBaseSystems: base32upper :: MultiBase
- MultiFormats.MultiBaseSystems: base32upperNP :: MultiBase
- MultiFormats.MultiBaseSystems: base58btc :: MultiBase
- MultiFormats.MultiBaseSystems: base64 :: MultiBase
- MultiFormats.MultiBaseSystems: base64NP :: MultiBase
- MultiFormats.MultiBaseSystems: base64url :: MultiBase
- MultiFormats.MultiBaseSystems: base64urlNP :: MultiBase
+ MultiFormats.CID: cidDataCodec :: CID -> MultiCodec
+ MultiFormats.CID: cidHashBuilder :: CID -> Builder
+ MultiFormats.CID: cidHashCodec :: CID -> MultiHash
+ MultiFormats.CID: cidVersion :: CID -> Version
+ MultiFormats.CID: data CID
+ MultiFormats.CID: instance Data.BaseSystem.BinaryTranscoder.BinaryTranscoder t => MultiFormats.CID.Extractor.Extractor MultiFormats.CID.CID t
+ MultiFormats.CID.Component.Codec: Codec :: MultiCodec -> Codec
+ MultiFormats.CID.Component.Codec: instance Data.BaseSystem.BinaryTranscoder.BinaryTranscoder t => MultiFormats.CID.Extractor.Extractor MultiFormats.CID.Component.Codec.Codec t
+ MultiFormats.CID.Component.Codec: instance GHC.Classes.Eq MultiFormats.CID.Component.Codec.Codec
+ MultiFormats.CID.Component.Codec: newtype Codec
+ MultiFormats.CID.Component.Decoder: Decoder :: b -> Decoder b
+ MultiFormats.CID.Component.Decoder: instance Data.BaseSystem.BinaryTranscoder.BinaryTranscoder b => MultiFormats.CID.Parser.Parser (MultiFormats.CID.Component.Decoder.Decoder b)
+ MultiFormats.CID.Component.Decoder: newtype Decoder b
+ MultiFormats.CID.Component.Hash: Hash :: MultiHash -> VarInt -> Builder -> Hash
+ MultiFormats.CID.Component.Hash: data Hash
+ MultiFormats.CID.Component.Hash: instance Data.BaseSystem.BinaryTranscoder.BinaryTranscoder t => MultiFormats.CID.Extractor.Extractor MultiFormats.CID.Component.Hash.Hash t
+ MultiFormats.CID.Component.Version: CIDv0 :: Version
+ MultiFormats.CID.Component.Version: CIDv1 :: Version
+ MultiFormats.CID.Component.Version: data Version
+ MultiFormats.CID.Component.Version: extractVersion0 :: BinaryTranscoder t => Extraction Version t
+ MultiFormats.CID.Component.Version: extractVersion1 :: BinaryTranscoder t => Extraction Version t
+ MultiFormats.CID.Component.Version: instance Data.BaseSystem.BinaryTranscoder.BinaryTranscoder t => MultiFormats.CID.Extractor.Extractor MultiFormats.CID.Component.Version.Version t
+ MultiFormats.CID.Component.Version: instance GHC.Classes.Eq MultiFormats.CID.Component.Version.Version
+ MultiFormats.CID.Component.Version: instance GHC.Enum.Enum MultiFormats.CID.Component.Version.Version
+ MultiFormats.CID.Component.Version: instance GHC.Show.Show MultiFormats.CID.Component.Version.Version
+ MultiFormats.CID.Component.Version: isStringCIDv0 :: String -> Bool
+ MultiFormats.CID.Component.Version: isTextCIDv0 :: Text -> Bool
+ MultiFormats.CID.Component.Version: v0EncodingLength :: Int
+ MultiFormats.CID.Component.Version: v0EncodingPrefix :: String
+ MultiFormats.CID.Component.Version: v0FirstByte :: Word8
+ MultiFormats.CID.Component.Version: v0HashBytes :: Int
+ MultiFormats.CID.Component.Version: v0SecondByte :: Word8
+ MultiFormats.CID.Component.Version: v0TotalBytes :: Int
+ MultiFormats.CID.Component.Version: v1FirstVarInt :: VarInt
+ MultiFormats.CID.Errors: UnknownHashCodec :: MultiCodec -> HashError
+ MultiFormats.CID.Extractor: instance Data.BaseSystem.BinaryTranscoder.BinaryTranscoder t => MultiFormats.CID.Extractor.Extractor MultiFormats.VarInt.VarInt t
+ MultiFormats.MultiBase: class BaseSystem a
+ MultiFormats.MultiBase: decoder :: BaseSystem a => a -> Text -> Maybe ByteStr
+ MultiFormats.MultiBase: encoder :: BaseSystem a => a -> ByteStr -> Text
+ MultiFormats.MultiBase: instance MultiFormats.MultiBase.BaseSystem (MultiFormats.MultiBase.DigitTranscoder.MultiBase MultiFormats.MultiBase.ByteStr)
+ MultiFormats.MultiBase: type ByteStr = ShortByteString
+ MultiFormats.MultiBase: type Decoder = Text -> Maybe ByteStr
+ MultiFormats.MultiBase: type Encoder = ByteStr -> Text
+ MultiFormats.MultiBase.DigitSystem: multibase10 :: BinaryTranscoder bxc => MultiBase bxc
+ MultiFormats.MultiBase.DigitSystem: multibase16lower :: BinaryTranscoder bxc => MultiBase bxc
+ MultiFormats.MultiBase.DigitSystem: multibase16upper :: BinaryTranscoder bxc => MultiBase bxc
+ MultiFormats.MultiBase.DigitSystem: multibase2 :: BinaryTranscoder bxc => MultiBase bxc
+ MultiFormats.MultiBase.DigitSystem: multibase32hexlower :: BinaryTranscoder bxc => MultiBase bxc
+ MultiFormats.MultiBase.DigitSystem: multibase32hexlowerNP :: BinaryTranscoder bxc => MultiBase bxc
+ MultiFormats.MultiBase.DigitSystem: multibase32hexupper :: BinaryTranscoder bxc => MultiBase bxc
+ MultiFormats.MultiBase.DigitSystem: multibase32hexupperNP :: BinaryTranscoder bxc => MultiBase bxc
+ MultiFormats.MultiBase.DigitSystem: multibase32lower :: BinaryTranscoder bxc => MultiBase bxc
+ MultiFormats.MultiBase.DigitSystem: multibase32lowerNP :: BinaryTranscoder bxc => MultiBase bxc
+ MultiFormats.MultiBase.DigitSystem: multibase32upper :: BinaryTranscoder bxc => MultiBase bxc
+ MultiFormats.MultiBase.DigitSystem: multibase32upperNP :: BinaryTranscoder bxc => MultiBase bxc
+ MultiFormats.MultiBase.DigitSystem: multibase58btc :: BinaryTranscoder bxc => MultiBase bxc
+ MultiFormats.MultiBase.DigitSystem: multibase64 :: BinaryTranscoder bxc => MultiBase bxc
+ MultiFormats.MultiBase.DigitSystem: multibase64NP :: BinaryTranscoder bxc => MultiBase bxc
+ MultiFormats.MultiBase.DigitSystem: multibase64url :: BinaryTranscoder bxc => MultiBase bxc
+ MultiFormats.MultiBase.DigitSystem: multibase64urlNP :: BinaryTranscoder bxc => MultiBase bxc
+ MultiFormats.MultiBase.DigitTranscoder: data MultiBase bxc
+ MultiFormats.MultiBase.DigitTranscoder: decodeCIDv0 :: BinaryTranscoder bxc => Text -> Maybe bxc
+ MultiFormats.MultiBase.DigitTranscoder: decodeFromPrefix :: BinaryTranscoder bxc => Text -> Maybe bxc
+ MultiFormats.MultiBase.DigitTranscoder: hasValidPrefix :: Text -> Bool
+ MultiFormats.MultiBase.DigitTranscoder: instance Data.BaseSystem.BinaryTranscoder.BinaryTranscoder bxc => Data.BaseSystem.DigitTranscoder.DigitTranscoder (MultiFormats.MultiBase.DigitTranscoder.MultiBase bxc) bxc
+ MultiFormats.MultiBase.DigitTranscoder: instance GHC.Classes.Eq (MultiFormats.MultiBase.DigitTranscoder.MultiBase bxc)
+ MultiFormats.MultiBase.DigitTranscoder: instance GHC.Classes.Ord (MultiFormats.MultiBase.DigitTranscoder.MultiBase bxc)
+ MultiFormats.MultiBase.DigitTranscoder: instance GHC.Show.Show (MultiFormats.MultiBase.DigitTranscoder.MultiBase bxc)
+ MultiFormats.MultiBase.DigitTranscoder: mkMultiBase :: (BinaryTranscoder bxc, DigitTranscoder dxc bxc, Show dxc) => Symbol -> dxc -> MultiBase bxc
+ MultiFormats.MultiBase.DigitTranscoder: resolvePrefix :: BinaryTranscoder bxc => Symbol -> Maybe (MultiBase bxc)
+ MultiFormats.MultiBase.DigitTranscoder: resolveTextPrefix :: BinaryTranscoder bxc => Text -> Maybe (MultiBase bxc)
+ MultiFormats.MultiBase.Lazy: class BaseSystem a
+ MultiFormats.MultiBase.Lazy: decoder :: BaseSystem a => a -> Text -> Maybe ByteStr
+ MultiFormats.MultiBase.Lazy: encoder :: BaseSystem a => a -> ByteStr -> Text
+ MultiFormats.MultiBase.Lazy: instance MultiFormats.MultiBase.Lazy.BaseSystem (MultiFormats.MultiBase.DigitTranscoder.MultiBase MultiFormats.MultiBase.Lazy.ByteStr)
+ MultiFormats.MultiBase.Lazy: type ByteStr = LazyByteString
+ MultiFormats.MultiBase.Lazy: type Decoder = Text -> Maybe ByteStr
+ MultiFormats.MultiBase.Lazy: type Encoder = ByteStr -> Text
+ MultiFormats.MultiBase.Strict: class BaseSystem a
+ MultiFormats.MultiBase.Strict: decoder :: BaseSystem a => a -> Text -> Maybe ByteStr
+ MultiFormats.MultiBase.Strict: encoder :: BaseSystem a => a -> ByteStr -> Text
+ MultiFormats.MultiBase.Strict: instance MultiFormats.MultiBase.Strict.BaseSystem (MultiFormats.MultiBase.DigitTranscoder.MultiBase MultiFormats.MultiBase.Strict.ByteStr)
+ MultiFormats.MultiBase.Strict: type ByteStr = ByteString
+ MultiFormats.MultiBase.Strict: type Decoder = Text -> Maybe ByteStr
+ MultiFormats.MultiBase.Strict: type Encoder = ByteStr -> Text
- MultiFormats.CID: CID :: CIDData -> CID
+ MultiFormats.CID: CID :: Version -> MultiCodec -> MultiHash -> VarInt -> Builder -> CID
- MultiFormats.CID.Extractor: class Extractor a
+ MultiFormats.CID.Extractor: class BinaryTranscoder t => Extractor a t
- MultiFormats.CID.Extractor: extractor :: Extractor a => Extraction a
+ MultiFormats.CID.Extractor: extractor :: Extractor a t => t -> Okay (a, t)
- MultiFormats.CID.Extractor: type Extraction a = ByteString -> Okay (a, ByteString)
+ MultiFormats.CID.Extractor: type Extraction a t = t -> Okay (a, t)
- MultiFormats.CID.Parser: parser :: Parser a => ParseMethod a
+ MultiFormats.CID.Parser: parser :: Parser a => Text -> Okay a
- MultiFormats.CID.Parser: type ParseMethod a = String -> Okay a
+ MultiFormats.CID.Parser: type ParseMethod a = Text -> Okay a
- MultiFormats.CID.Serializer: serializer :: Serializer a => Serialization a
+ MultiFormats.CID.Serializer: serializer :: Serializer a => a -> Okay Builder
- MultiFormats.CID.Serializer: type Serialization a = a -> Okay ByteString
+ MultiFormats.CID.Serializer: type Serialization a = a -> Okay Builder
- MultiFormats.VarInt: extractVarInt :: ByteString -> Okay (VarInt, ByteString)
+ MultiFormats.VarInt: extractVarInt :: BinaryTranscoder t => t -> Okay (VarInt, t)
- MultiFormats.VarInt: serializeVarInt :: VarInt -> Okay ByteString
+ MultiFormats.VarInt: serializeVarInt :: VarInt -> Okay Builder

Files

+ CHANGELOG.md view
@@ -0,0 +1,113 @@+[`mfmts`](http://hackage-content.haskell.org/package/mfmts) change log:+=======================================================================++Major release 1.1+-----------------++### Cabal+- Upgrade major versions for `text` and `containers` versions.+- Add `tested-with` line for GHC 9.6.7.+- Remove the `Dev` flag.++### Builds / CI+- Use `ghcup` to install the correct Haskell tooling instead of outdated+`cabal-install` package in all CI scripts.+- Combine documentation generation and packaging into a single script that+uploads everything to a candidate hackage page.+- Add script for running the `ipfshs` unit testing package for mfmts.++### `MultiFormats.CID` module changes+- The data struct `CIDData` and the newtype `CID` have been flattened into a+single `CID` data struct.+- With `CIDData` being removed, the module `MultiFormats.CID.Internal` has also+been removed and merged with the main `MultiFormats.CID` module.+- The getter functions for `CID` (`getDataCodec`, `getHashCodec`,+`getHashDigest`, and `getVersion`) have been replaced with data member+functions: `cidDataCodec`, `cidHashCodec`, `cidHashDigest`, and `cidVersion`.+- The hash digest stored with the `CID` as `cidHashDigest` has had its type+changed from `Data.ByteString` to `Data.ByteString.Builder`.+- Since the hash digest is now a `Builder`, its byte length is now stored as a+data member, `cidHashSize`, rather than from bytestring `length` on the old+`ByteString` type.+- Like the hash digest the `serializier` now outputs `CID` data as bytestring+`Builder`.+- The `extractor` method for `CID` now works on `BinaryTranscoder` data so that+it can support `ByteString`, `LazyByteString`, and `ShortByteString`+generically.+- The `parser` method has been upgraded to work with `Text` instead of `String`+inputs.+- The `Show` instance has been improved and written to show with newlines.++### `MultiFormats.CID.Internal` moves to `MultiFormats.CID.Component`+With this release, the CID internal submodule has been reorganized into+components of the CID metadata processing. So it is implemented in parts+implementing type-classes from `MultiFormats.CID.Parser`,+`MultiFormats.CID.Serializer` and `MultiFormats.CID.Extractor`.++### `MultiFormats.CID.Serializer` type-class changes+This update changes the type signature of the `serializier` method from+`a -> Okay ByteString` to `a -> Okay Builder`. The bytestring `Builder` type+supports *O(1)* concatination, so this should provide a significant performance+increase.++### `MultiFormats.CID.Extractor` type-class changes+This module also has a method type change; `extractor` previously had a+signature of `ByteString -> Okay (a, ByteString)`, and now has changed to+`(BinaryTranscoder t) => t -> Okay (a, t)` where `a` is the type being extracted+from the transcoder data.++### `MultiFormats.CID.Parser` type-class changes+The parsing method has been upgraded to work on `Text` data rather than `String`+inputs, and this should provide a performance increase in some areas. So, the+`parser` method has changed from `String -> Okay a` to `Text -> Okay a`, where+`a` is some data to be parsed from input.++### `MultiFormats.MultiCodec` module changes+- The `Show` instance has been improved.+- The moudle has been regenerated against multicodec commit+[`45c88b89ab909c0fac7c86dafe43ad72d1e8e8a9`](+https://github.com/multiformats/multicodec/commit/45c88b89ab909c0fac7c86dafe43ad72d1e8e8a9+).++### `MultiFormats.MultiHash` module changes+- Hash function performance issues were addressed; internally+`multiHashFunction` now uses the `Foreign.Marshal.Array` module to copy directly+from the pointer directly into a malloc'd buffer rather than from using `pack`+and `unpack`.+- The `Show` instance has been improved++### `MultiFormats.VarInt` module changes+- The function `extractVarInt` now has the signature+`(BinaryTranscoder t) => t -> Okay (VarInt, t)` to support the changes to the+`extractor` method in the CID module.+- The `serializeVarInt` function also changed to `VarInt -> Okay Builder` to+support the changes to the CID `serializer`.++Major release 1.0+-----------------++## Version 1.0.0.1 (04-01-2026)++This version aims to fix the issues with the hackage page and provide CI via+sourcehut builds.++- Set correct PVP bounds for cabal dependencies.+- Update `crypton` to ^>= 1.1, removing deprecated dependencies.+- Added CI/CD for builds.sr.ht:+  * Add `.builds/nudge-parents.yml` to automatically update this submodule in+  other sourcehut repositories.+  * Add `.builds/upload-candidate-docs.yml` to generate and upload documentation+  to Hackage.+  * Add `.builds/upload-candidate-package.yml` to generate and upload a package+  candidate to Hackage.++## Version 1.0.0.0 (03-12-2026)++Introducing this package to Hackage! This release introduces the basic structure+for the project and provides the following libraries:++- `mfmts-varint` for processing variable length integer inputs.+- `mfmts-multicodec` for providing a lookup method for codec values/names.+- `mfmts-multibase` for converting data to/from multibase encodings.+- `mfmts-multihash` for identifing hash functions from multicodecs.+- `mfmts-cid` for encoding/decoding multiformat content idenitifiers.
− CHANGE_LOG.md
@@ -1,28 +0,0 @@-[`mfmts`](http://hackage-content.haskell.org/package/mfmts) change log:-=======================================================================--## Version 1.0.0.1 (04-01-2026)--This version aims to fix the issues with the hackage page and provide CI via-sourcehut builds.--- Set correct PVP bounds for cabal dependencies.-- Update `crypton` to ^>= 1.1, removing deprecated dependencies.-- Added CI/CD for builds.sr.ht:-  * Add `.builds/nudge-parents.yml` to automatically update this submodule in-  other sourcehut repositories.-  * Add `.builds/upload-candidate-docs.yml` to generate and upload documentation-  to Hackage.-  * Add `.builds/upload-candidate-package.yml` to generate and upload a package-  candidate to Hackage.--## Version 1.0.0.0 (03-12-2026)--Introducing this package to Hackage! This release introduces the basic structure-for the project and provides the following libraries:--- `mfmts-varint` for processing variable length integer inputs.-- `mfmts-multicodec` for providing a lookup method for codec values/names.-- `mfmts-multibase` for converting data to/from multibase encodings.-- `mfmts-multihash` for identifing hash functions from multicodecs.-- `mfmts-cid` for encoding/decoding multiformat content idenitifiers.
README.md view
@@ -1,82 +1,184 @@-mfmts-=====+mfmts [![hackage.haskell.org](+https://img.shields.io/badge/hackage%2Ehaskell%2Eorg-5C5181?logo=haskell)](+https://hackage.haskell.org/package/mfmts)[![builds.sr.ht status](+https://builds.sr.ht/~z0/mfmts/commits/main/mfmts-testing.yml.svg)](+https://builds.sr.ht/~z0/mfmts/commits/main/mfmts-testing.yml?)+--------------------------------------------------------------- -This project contains my implementation of the [multiformats specifiation](-https://github.com/multiformats/multiformats) split across several individual-libraries.+This project implements the specifications described by Protocol Lab's+[multiformats](https://github.com/multiformats/multiformats) written in Haskell. -`mfmts-multibase` - Multibase BaseSystems encoding + decoding--------------------------------------------------------------+`cid` - Content identitiers for hashed data+------------------------------------------- -Implements encoders and decoders for numeric basesytems and mutliformats-specification for multibase prefix encoded strings.+Provides functionality for the multiformats CID binary format. These modules+provide parsing CIDs from multibase prefixed digit strings, extracting CID data+from byte strings and serializing CIDs stored in memory into its binary format. -#### *References:*-- Multibase GitHub - [https://github.com/multiformats/multibase](-https://github.com/multiformats/multibase)+CID GitHub README example in GHCI:+```haskell+λ> {-# LANGUAGE OverloadedStrings #-}+λ> import MultiFormats.CID (CID)+λ> import MultiFormats.CID.Parser qualified as CID+λ> import MultiFormats.CID.Errors qualified as CID+λ> CID.parser "zb2rhe5P4gXftAwvA4eXQ5HJwsER2owDyS9sKaQRRVQPn93bA" :: CID.Okay CID+Right CIDv1 {+    DataCodec=MultiCodec(0x55, "raw"),+    HashCodec=MultiHash(0x12, "sha2-256"),+    HashDigest=[base58btc]("8S6sXBSX8wVLcT88GnuZpbvmaxetTmPri26tufEByBKS"),+    HashSize=32+}+``` -`mfmts-varints` - Unsigned VarInts-----------------------------------+- CID specification - [https://github.com/multiformats/cid](+https://github.com/multiformats/cid)+- CID example from README - [+https://github.com/multiformats/cid#variant---human-readable-form](+https://github.com/multiformats/cid#variant---human-readable-form)+- Official IPFS Golang implementation - [https://github.com/ipfs/go-cid](+https://github.com/ipfs/go-cid) -Provides parsing and serialization for multiformats unsigned binary varints.+`multibase` - Multibase prefix data transcoding+----------------------------------------------- -#### *References:*-- Varint GitHub - [https://github.com/multiformats/unsigned-varint](-https://github.com/multiformats/unsigned-varint)+Implements encoders and decoders for numeric basesytems identitified by a+specified prefix symbol. It implements transcoders from the [basesystems](+https://git.sr.ht/~z0/basesystems) library, allowing for different types of+bytestring data to be specified as type parameters. -`mfmts-multicodec` - Magic Number specifications-------------------------------------------------+Multibase GitHub README example in GHCI:+```haskell+λ> {-# LANGUAGE OverloadedStrings #-}+λ> import MultiFormats.MultiBase.DigitTranscoder (decodeFromPrefix)+λ> import Data.ByteString.Short (ShortByteString)+λ> type Str = ShortByteString+λ> -- uppercase hexadecimal+λ> decodeFromPrefix "F4D756C74696261736520697320617765736F6D6521205C6F2F" :: Maybe Str+Just "Multibase is awesome! \\o/"+λ> -- base32 no padding+λ> decodeFromPrefix "BJV2WY5DJMJQXGZJANFZSAYLXMVZW63LFEEQFY3ZP" :: Maybe Str+Just "Multibase is awesome! \\o/"+λ> -- bitcoin base58+λ> decodeFromPrefix "zYAjKoNbau5KiqmHPmSxYCvn66dA1vLmwbt" :: Maybe Str+Just "Multibase is awesome! \\o/"+λ> -- base64 with padding+λ> decodeFromPrefix "MTXVsdGliYXNlIGlzIGF3ZXNvbWUhIFxvLw==" :: Maybe Str+Just "Multibase is awesome! \\o/"+``` +- Multibase specification - [https://github.com/multiformats/multibase](+https://github.com/multiformats/multibase)+- Multibase example - [+https://github.com/multiformats/multibase#multibase-by-example](+https://github.com/multiformats/multibase#multibase-by-example)++`multicodec` - Magic number specifications+------------------------------------------+ Provides lookup table and query functions for codecs defined from multiformats multicodec. These are magic numbers that represent certain data encoded within-CIDs, mulithash and other related projects. This module uses a python script-to generate haskell code from the freshest `table.csv` on multicodec's GitHub.+CIDs, mulithash and other related projects. This module has code which+is generated by a python script in the [ipfshs](https://todo.sr.ht/~z0/ipfshs)+repo, and is automatically generated from CSV. -#### *References:*-- Multicodec GitHub - [https://github.com/multiformats/multicodec](+Example of looking up codecs:+```haskell+λ> import MultiFormats.MultiCodec qualified as MC+λ> -- Resolving from codec values:+λ> MC.resolveCodecName $ MC.MultiCodec 0x1+Just "cidv1"+λ> -- Resolving from names:+λ> MC.resolveCodecValue "cidv1"+Just MultiCodec(0x1, "cidv1")+λ> MC.resolveCodecValue "cidv0"+Nothing+```++- Multicodec specification - [https://github.com/multiformats/multicodec]( https://github.com/multiformats/multicodec)-- Multicodec Table CSV - [+- Multicodec value table - [ https://github.com/multiformats/multicodec/blob/master/table.csv]( https://github.com/multiformats/multicodec/blob/master/table.csv) -`mfmts-multihash` - Multicodec hash function identifiers---------------------------------------------------------+`multihash` - Multicodec hash function identifiers+-------------------------------------------------- -Provides a lookup table for hash functions in the `mfmts-codec` table and-validates they have an implementation backend. This module is also used to-verify the Multihash's Multicodec as part of decoding ContentIDs.+Multihashes are a type of multicodec for identifying hash functions. This+code provides a lookup table for hash functions from the multicodec module, and+a way to get hash digests from specific functions over bytestrings, and to+verify multicodec values as valid multihash codecs. -#### *References:*-- Multihash GitHub - [-https://github.com/multiformats/multihash](-https://github.com/multiformats/multihash)-- Go implementation - [-https://github.com/multiformats/go-multihash/blob/master/multihash.go](-https://github.com/multiformats/go-multihash/blob/master/multihash.go)+Example of looking up hash functions and applying them:+```haskell+λ> import MultiFormats.MultiCodec qualified as MC+λ> import MultiFormats.MultiHash qualified as MH+λ> -- Here's an example of how we can verify names and codec values as valid+λ> -- hash functions.+λ> MH.resolveHashCodec $ MC.MultiCodec 0x12+Just MultiHash(0x12, "sha2-256")+λ> MH.resolveHashName "sha2-256"+Just MultiHash(0x12, "sha2-256")+λ> -- Building a function call that hashes the string "Hello World!" using the+λ> -- sha2-256 algorithm, then outputs the digest as hexadecimal:+λ> import Data.BaseSystem.Lazy (encoder)+λ> import Data.BaseSystem.DigitSystem (base16lower)+λ> import Data.ByteString.Builder qualified as Builder+λ> import Data.Maybe (fromJust)+λ> let sha256 = MH.multiHashFunction $ fromJust (MH.resolveHashName "sha2-256")+λ> let input = Builder.string8 "Hello World!"+λ> encoder base16lower $ sha256 input+"7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069"+``` -`mfmts-cid` - CID/ContentID----------------------------+- Multihash specification - [https://github.com/multiformats/multihash](+https://github.com/multiformats/multihash)+- Multiformat's Golang implementation - [+https://github.com/multiformats/go-multihash](+https://github.com/multiformats/go-multihash) -Provides Parsing (from String), Extracting (from ByteString) and Serialization-(to ByteString) for ContentIDs/CIDs.+`varint` - Unsigned variable length integers+-------------------------------------------- -#### *References:*-- CID GitHub - [https://github.com/multiformats/cid](-https://github.com/multiformats/cid)-- Go implementation - [https://github.com/ipfs/go-cid](-https://github.com/ipfs/go-cid)+Provides parsing and serialization for multiformats unsigned binary varints,+with the special caveat from multiformats that requires them always to be+minimally encoded, so this project also verifies that the varint inputs comply+with the rules of the multiformats specifiation. -Unit testing-------------+Varint GitHub README example in GHCI using `packValue` from the [basesystems](+https://git.sr.ht/~z0/basesystems) library to transfer constants into+bytestrings. We can then use `extractVarInt` to get the varint representation+from the bytes:+```haskell+λ> import Data.BaseSystem.BinaryTranscoder (packValue)+λ> import Data.ByteString.Short (ShortByteString)+λ> import MultiFormats.VarInt (VarInt, extractVarInt)+λ> import MultiFormats.VarInt.Errors qualified as VarInt+λ> -- Make alias so we don't get type warnings+λ> let packInteger x = packValue (x :: Integer)+λ> -- 7-bit values fit into 1 byte:+λ> extractVarInt (packInteger 0x01) :: VarInt.Okay (VarInt, ShortByteString)+Right (1,"")+λ> extractVarInt (packInteger 0x7f) :: VarInt.Okay (VarInt, ShortByteString)+Right (127,"")+λ> -- 8-bit and larger values have their MSB set until a zero MSB byte is found:+λ> extractVarInt (packInteger 0x8001) :: VarInt.Okay (VarInt, ShortByteString)+Right (128,"")+λ> extractVarInt (packInteger 0xff01) :: VarInt.Okay (VarInt, ShortByteString)+Right (255,"")+λ> extractVarInt (packInteger 0xac02) :: VarInt.Okay (VarInt, ShortByteString)+Right (300,"")+λ> extractVarInt (packInteger 0x808001) :: VarInt.Okay (VarInt, ShortByteString)+Right (16384,"")+``` -Some modules in this directory have unit tests that are generated within the-python folder as JSON formats. Code for unit tests sets are found at the [main-ipfshs repo](https://git.sr.ht/~z0/ipfshs).+- Varint specification - [https://github.com/multiformats/unsigned-varint](+https://github.com/multiformats/unsigned-varint) -Reporting bugs---------------+Development+----------- -Bugs can be reported to the ipfshs [ticket tracker](+Unit tests are provided on the main [ipfshs repo](https://git.sr.ht/~z0/ipfshs),+and bugs can be reported on [ipfshs ticket tracker]( https://todo.sr.ht/~z0/ipfshs).  Licensing@@ -86,5 +188,5 @@ [AGPLv3](https://www.gnu.org/licenses/agpl-3.0.en.html) license. See [LICENSE.txt](LICENSE.txt). -Copyright (C) 2026 Zoey McBride-<[zoeymcbride@mailbox.org](mailto:zoeymcbride@mailbox.org)>+Copyright © 2026 Zoey McBride | [zoeymcbride@mailbox.org](+mailto:zoeymcbride@mailbox.org)
cid/MultiFormats/CID.hs view
@@ -9,92 +9,170 @@ -- See: https://github.com/multiformats/cid module MultiFormats.CID   ( CID (CID),-    getDataCodec,-    getHashCodec,-    getHashDigest,-    getVersion,+    cidVersion,+    cidDataCodec,+    cidHashCodec,+    cidHashBuilder,   ) where -import Data.BaseSystem (encoder)-import Data.BaseSystems (base58btc)-import Data.Bifunctor (first)-import Data.ByteString (ByteString)-import Data.ByteString qualified as Bytes+import Data.BaseSystem.BinaryTranscoder (BinaryTranscoder)+import Data.BaseSystem.BinaryTranscoder qualified as BXC+import Data.BaseSystem.DigitSystem (base58btc)+import Data.BaseSystem.Lazy (encoder)+import Data.ByteString.Builder (Builder)+import Data.ByteString.Builder qualified as Builder+import Data.ByteString.Short (ShortByteString)+import Data.List (intercalate)+import Data.Maybe (fromJust)+import Data.Text qualified as Text+import MultiFormats.CID.Component.Codec qualified as CID+import MultiFormats.CID.Component.Decoder qualified as CID+import MultiFormats.CID.Component.Hash qualified as CID+import MultiFormats.CID.Component.Version (Version (CIDv0, CIDv1))+import MultiFormats.CID.Component.Version qualified as CID import MultiFormats.CID.Errors import MultiFormats.CID.Extractor-import MultiFormats.CID.Internal-import MultiFormats.CID.Internal.CIDDecoder-import MultiFormats.CID.Internal.CIDVersion import MultiFormats.CID.Parser import MultiFormats.CID.Serializer-import MultiFormats.MultiCodec (MultiCodec)-import MultiFormats.MultiHash (MultiHash)-import Text.Printf (printf)+import MultiFormats.MultiCodec (MultiCodec, resolveCodecValue)+import MultiFormats.MultiHash (MultiHash, resolveHashName)+import MultiFormats.VarInt (VarInt) --- | Wraps CIDData to implement multi-version Parser, Extractor & Serializer.-newtype CID = CID CIDData deriving (Eq)+-- | Defines the data-type for CID data.+data CID = CID+  { -- | Specifies the version (CIDv0 or CIDv1) of this CID.+    cidVersion :: CID.Version,+    -- | Describes the content type of the hashed data.+    cidDataCodec :: MultiCodec,+    -- | Contains the hash functoin used.+    cidHashCodec :: MultiHash,+    -- | Stores the # of bytes used to store the HashDigest+    cidHashSize :: VarInt,+    -- | Stores the hash function's output.+    cidHashBuilder :: Builder+  } --- | Repl/Unit test friendly Show.+instance Eq CID where+  (CID v1 c1 h1 s1 d1) == (CID v2 c2 h2 s2 d2) =+    -- Check that none of the comparable values mismatch+    not (v1 /= v2 || c1 /= c2 || h1 /= h2 || s1 /= s2)+      -- And then check equality on the executed builder+      && Builder.toLazyByteString d1 == Builder.toLazyByteString d2+ instance Show CID where-  show cid =-    let version = getVersion cid-        datacodec = getDataCodec cid-        hashcodec = getHashCodec cid-        hashdigest = getHashDigest cid-     in printf-          "%s(DataCodec=%s, HashCodec=%s, HashDigest[%s]=%s)"-          (show version)-          (show datacodec)-          (show hashcodec)-          (show showbase)-          (encoder showbase hashdigest)+  show (CID version datacodec hashcodec hashsize hashbuilder) =+    let hashdigest = Builder.toLazyByteString hashbuilder+        basestring = show showbase+        hashstring = Text.unpack (encoder showbase hashdigest)+     in show version+          ++ (" {\n" ++ showtab)+          ++ intercalate+            (",\n" ++ showtab)+            [ "DataCodec=" ++ show datacodec,+              "HashCodec=" ++ show hashcodec,+              "HashDigest=[" ++ basestring ++ "](" ++ quote hashstring ++ ")",+              "HashSize=" ++ show hashsize+            ]+          ++ "\n}"     where       -- Sets the base implementation to show the hash digest with.       showbase = base58btc+      -- Sets the # of spaces to show for tab+      showtab = replicate 4 ' '+      -- Puts a String in double quotes.+      quote str = "\"" ++ str ++ "\""  -- | Parses a CIDv1 from a MultiBase encoded string OR a CIDv0 from a base58btc -- encoded string. Fails when there is extra bytes past the CID. instance Parser CID where   parser cidstr = do-    -- Decode to bytes based on the String's encoding.-    CIDDecoder cidbytes <- parser cidstr+    -- Decode to bytes based on the String's encoding. Use SBS as BXC because+    -- the bytestring is discarded after this function.+    CID.Decoder cidbytes <- parser cidstr :: Okay (CID.Decoder ShortByteString)     -- Extracts the CID's data from bytes.     (cid, trailing) <- extractor cidbytes     -- Fail if there is any leftovers.-    if Bytes.length trailing > 0+    if BXC.lengthBytes trailing > 0       then Left (InvalidData TrailingBytes)       else Right cid  -- | Extracts a CID from a ByteString. Allows trailing bytes.-instance Extractor CID where+instance (BinaryTranscoder t) => Extractor CID t where   extractor bytes = do     -- First, extract the version from bytes-    (CIDVersion version, rest) <- extractor bytes+    (version, rest) <- extractor bytes     -- Apply the constructor if the CID was successfully extracted from bytes-    first CID <$> case version of+    case version of       CIDv0 -> extractCIDv0 rest       CIDv1 -> extractCIDv1 rest +-- | Applies the extraction after version# for CIDv0 was extracted.+extractCIDv0 :: (BinaryTranscoder t) => Extraction CID t+extractCIDv0 ondata+  -- Fail if there isn't enough bytes+  | totalbytes < CID.v0HashBytes = Left (InvalidHash IncorrectLength)+  -- Create the CIDv0 from data+  | otherwise = Right (mkCIDv0 ciddata, rest)+  where+    totalbytes = BXC.lengthBytes ondata+    (ciddata, rest) = BXC.splitAtByte CID.v0HashBytes ondata++-- | Applies the extraction after version# for CIDv1 was extracted.+extractCIDv1 :: (BinaryTranscoder t) => Extraction CID t+extractCIDv1 oncodec = do+  -- Extract the 1st MultiCodec from the bytes.+  (CID.Codec multicodec, onhash) <- extractor oncodec+  -- Extract the 2nd MultiCodec and get CIDHash+  (CID.Hash multihash hashsize hashdigest, stop) <- extractor onhash+  -- Get the length of the hash data after the hash codec+  -- TODO: verifiy hash length against crypton library+  return (CID CIDv1 multicodec multihash hashsize hashdigest, stop)+ -- | Serializes a CID from representation. instance Serializer CID where-  serializer (CID ciddata) =+  serializer ciddata =     case cidVersion ciddata of       CIDv0 -> serializeCIDv0 ciddata       CIDv1 -> serializeCIDv1 ciddata --- | Gets VersionEnum from a CID.-getVersion :: CID -> VersionEnum-getVersion (CID ciddata) = cidVersion ciddata---- | Gets data-type MultiCodec from a CID.-getDataCodec :: CID -> MultiCodec-getDataCodec (CID ciddata) = cidDataCodec ciddata+-- | Serializes CIDv0 by adding the Codec Byte to its digest+serializeCIDv0 :: Serialization CID+serializeCIDv0 (CID CIDv1 _ _ _ _) = error "serializeCIDv0: input has CIDv1!"+serializeCIDv0 (CID CIDv0 _ _ _ cidhash) =+  -- Concat the Builders for the bytes data into a single Builder+  let cid1st = Builder.word8 CID.v0FirstByte+      cid2nd = Builder.word8 CID.v0SecondByte+   in return $ mconcat [cid1st, cid2nd, cidhash] --- | Gets MultiHash codec from a CID.-getHashCodec :: CID -> MultiHash-getHashCodec (CID ciddata) = cidHashCodec ciddata+-- | Serializes CIDv1 into VarInts of its components.+serializeCIDv1 :: Serialization CID+serializeCIDv1 (CID CIDv0 _ _ _ _) = error "serializeCIDv1: input has CIDv0!"+serializeCIDv1 (CID CIDv1 datacodec hashcodec hashlength hashbuilder) = do+  -- Get the Builder from each serializer sequenced from Just values+  builders <-+    sequence+      [ serializer CID.v1FirstVarInt,+        serializer datacodec,+        serializer hashcodec,+        serializer hashlength,+        pure hashbuilder+      ]+  -- Concat the list into one large Builder+  return $ mconcat builders --- | Gets the hash digest from a CID.-getHashDigest :: CID -> ByteString-getHashDigest (CID ciddata) = cidHashDigest ciddata+-- | Provides the contructor for CIDv0s, see:+-- https://github.com/multiformats/cid?tab=readme-ov-file#cidv0+mkCIDv0 :: (BinaryTranscoder t) => t -> CID+mkCIDv0 digest =+  CID+    { cidVersion = CIDv0,+      cidDataCodec = codec "dag-pb",+      cidHashCodec = hash "sha2-256",+      cidHashSize = varlength digest,+      cidHashBuilder = BXC.serializeValue digest+    }+  where+    codec str = fromJust $ resolveCodecValue str+    hash str = fromJust $ resolveHashName str+    varlength = fromIntegral . BXC.lengthBytes
+ cid/MultiFormats/CID/Component/Codec.hs view
@@ -0,0 +1,19 @@+-- | Module      : MultiFormats.CID.Component.Codec+--   Description : Implements extracting codecs from CIDs.+--   Copyright   : Zoey McBride (c) 2026+--   License     : AGPL-3.0-or-later+--   Maintainer  : zoeymcbride@mailbox.org+--   Stability   : experimental+module MultiFormats.CID.Component.Codec (Codec (Codec)) where++import Data.BaseSystem.BinaryTranscoder (BinaryTranscoder)+import Data.Bifunctor (first)+import MultiFormats.CID.Extractor (Extractor (extractor))+import MultiFormats.MultiCodec (MultiCodec (MultiCodec))++-- | Represents a MultiCodec value embedded within CID data.+newtype Codec = Codec MultiCodec deriving (Eq)++-- | Extracts the MultiCodec from VarInt in bytes and wraps in Codec.+instance (BinaryTranscoder t) => Extractor Codec t where+  extractor bytes = first (Codec . MultiCodec) <$> extractor bytes
+ cid/MultiFormats/CID/Component/Decoder.hs view
@@ -0,0 +1,31 @@+-- | Module      : MultiFormats.CID.Component.Decoder+--   Description : Parses CID bytes from a multibase encoded string+--   Copyright   : Zoey McBride (c) 2026+--   License     : AGPL-3.0-or-later+--   Maintainer  : zoeymcbride@mailbox.org+--   Stability   : experimental+module MultiFormats.CID.Component.Decoder (Decoder (Decoder)) where++import Data.BaseSystem.BinaryTranscoder (BinaryTranscoder)+import Data.Text qualified as Text+import MultiFormats.CID.Component.Version (isTextCIDv0)+import MultiFormats.CID.Errors+import MultiFormats.CID.Parser+import MultiFormats.MultiBase.DigitTranscoder (hasValidPrefix)+import MultiFormats.MultiBase.DigitTranscoder qualified as DXC++-- | Implements decoding CID from String's base encoding.+newtype Decoder b = Decoder b++-- | Decodes a CID to bytes.+instance (BinaryTranscoder b) => Parser (Decoder b) where+  parser str =+    let choosedecoder+          | Text.null str = Left (InvalidData EmptyCID)+          | isTextCIDv0 str = Right DXC.decodeCIDv0+          | hasValidPrefix str = Right DXC.decodeFromPrefix+          | otherwise = Left (InvalidEncoding UnknownBasePrefix)+     in choosedecoder >>= \decoder ->+          case decoder str of+            Nothing -> Left (InvalidEncoding ImproperDigit)+            Just bytes -> Right (Decoder bytes)
+ cid/MultiFormats/CID/Component/Hash.hs view
@@ -0,0 +1,49 @@+-- | Module      : MultiFormats.CID.Component.Hash+--   Description : Implements extraction and verification of multihash CID data+--   Copyright   : Zoey McBride (c) 2026+--   License     : AGPL-3.0-or-later+--   Maintainer  : zoeymcbride@mailbox.org+--   Stability   : experimental+module MultiFormats.CID.Component.Hash (Hash (Hash)) where++import Data.BaseSystem.BinaryTranscoder (BinaryTranscoder)+import Data.BaseSystem.BinaryTranscoder qualified as BXC+import Data.ByteString.Builder (Builder)+import MultiFormats.CID.Component.Codec qualified as CID+import MultiFormats.CID.Errors+import MultiFormats.CID.Extractor (Extractor (extractor))+import MultiFormats.MultiHash (MultiHash, resolveHashCodec)+import MultiFormats.VarInt (VarInt)++data Hash = Hash+  { -- | Stores the MultiCodec for the hash function used.+    cidHashCodec :: MultiHash,+    -- | Stores the length in bytes of the hash builder.+    cidHashLength :: VarInt,+    -- | Stores the hash function's output.+    cidHashDigest :: Builder+  }++-- | Extracts the MultiHash codec and hash digest via a varint size following+-- the MultiHash codec.+instance (BinaryTranscoder t) => Extractor Hash t where+  extractor bytes = do+    -- Get the CodecCode from the first varint+    (CID.Codec codec, onsize) <- extractor bytes+    -- Get the digest size from the first varint, make CID.Error if on Left+    (usize :: VarInt, ondigest) <- extractor onsize+    -- When codec is a valid hash and the given size is available in the bytes,+    -- take #size elements from bytes and construct the Hash+    case resolveHashCodec codec of+      Nothing -> Left (InvalidHash $ UnknownHashCodec codec)+      Just hash+        | isize < BXC.lengthBytes ondigest -> Left (InvalidHash IncorrectLength)+        | otherwise -> Right $ extractHashDigest hash ondigest+        where+          -- Gets the varint size as generic integral type+          isize = fromIntegral usize+          -- Extracts the hash data from the bytes+          extractHashDigest multihash rest =+            let (hashdata, final) = BXC.splitAtByte isize rest+                hashbuilder = BXC.serializeValue hashdata+             in (Hash multihash usize hashbuilder, final)
+ cid/MultiFormats/CID/Component/Version.hs view
@@ -0,0 +1,121 @@+-- | Module      : MultiFormats.CID.Component.Version+--   Description : Implements extraction versioning from CID data.+--   Copyright   : Zoey McBride (c) 2026+--   License     : AGPL-3.0-or-later+--   Maintainer  : zoeymcbride@mailbox.org+--   Stability   : experimental+module MultiFormats.CID.Component.Version+  ( Version (CIDv0, CIDv1),++    -- * Extractions+    extractVersion0,+    extractVersion1,++    -- * Helper functions+    isTextCIDv0,+    isStringCIDv0,++    -- * Constants+    v0EncodingPrefix,+    v0EncodingLength,+    v0TotalBytes,+    v0HashBytes,+    v0FirstByte,+    v0SecondByte,+    v1FirstVarInt,+  )+where++import Data.BaseSystem.BinaryTranscoder (BinaryTranscoder)+import Data.BaseSystem.BinaryTranscoder qualified as BXC+import Data.Text (Text)+import Data.Text qualified as Text+import Data.Word (Word8)+import MultiFormats.CID.Errors+import MultiFormats.CID.Extractor (Extraction, Extractor (extractor))+import MultiFormats.VarInt (VarInt)++-- | Implements available CID versions.+data Version = CIDv0 | CIDv1 deriving (Show, Eq, Enum)++-- | Extracts and validates the CID versioning information from bytes.+instance (BinaryTranscoder t) => Extractor Version t where+  extractor cidbytes =+    case BXC.uncons cidbytes of+      Nothing -> Left (InvalidData EmptyCID)+      Just (magic, _)+        -- Only CIDv0 will start with 0x12, and it must be followed w/ a+        -- special byte; if it doesn't have both, the encoding is invalid.+        | magic == v0FirstByte -> extractVersion0 cidbytes+        -- Without the magic bytes, CIDvX > CIDv0 is done in VarInts, so we get+        -- the Version information from the first varint (0x1 for CIDv1).+        | otherwise -> extractVersion1 cidbytes++-- | Performs extraction for CIDv1.+extractVersion1 :: (BinaryTranscoder t) => Extraction Version t+extractVersion1 bytes =+  extractor bytes >>= \(varint1, rest) ->+    if invalidCIDv1 varint1+      then Left (InvalidEncoding ExpectedCIDv1)+      else Right (CIDv1, rest)+  where+    invalidCIDv1 v1 = v1 /= v1FirstVarInt++-- | Performs extraction for CIDv0.+extractVersion0 :: (BinaryTranscoder t) => Extraction Version t+extractVersion0 ciddata =+  let (lead, rest) = BXC.splitAtByte 2 ciddata+      total = BXC.lengthBytes ciddata+   in case BXC.unpackBytes lead of+        [b1, b2]+          | invalidCIDv0 b1 b2 total -> Left (InvalidEncoding MalformedCIDv0)+          | otherwise -> Right (CIDv0, rest)+        _Not2 -> Left (InvalidEncoding MalformedCIDv0)+  where+    -- Checks the conditions where a CIDv0 is invalidated.+    {-# INLINE invalidCIDv0 #-}+    invalidCIDv0 b1 b2 total =+      b1 /= v0FirstByte || b2 /= v0SecondByte || total /= v0TotalBytes++-- | This prefixes a CIDv0 instead of a multibase prefix.+v0EncodingPrefix :: String+v0EncodingPrefix = "Qm"++-- | The length of a CIDv0 string, base58 encoded.+v0EncodingLength :: Int+v0EncodingLength = 46++-- | Required length in bytes of all CIDv0 encodings.+v0TotalBytes :: Int+v0TotalBytes = 34++-- | Length of hash digest in CIDv0, ie the length without its versioning+-- information, since those are the only items in CIDv0.+v0HashBytes :: Int+v0HashBytes = v0TotalBytes - 2++-- | Required first byte of all CIDv0 encodings.+v0FirstByte :: Word8+v0FirstByte = 0x12++-- | Required second byte of all CIDv0 encodings.+v0SecondByte :: Word8+v0SecondByte = 0x20++-- | Required first VarInt of all CIDv1 encodings.+v1FirstVarInt :: VarInt+v1FirstVarInt = 1++-- | /O(1)/ Checks if Text qualifes for CIDv0 decoding.+isTextCIDv0 :: Text -> Bool+isTextCIDv0 text =+  let start = Text.unpack $ Text.take 2 text+      len = Text.length text+   in start == v0EncodingPrefix && len == v0EncodingLength++-- | /O(n)/ Checks if a String qualifes for CIDv0 decoding.+isStringCIDv0 :: String -> Bool+isStringCIDv0 str =+  let start = take 2 str+      len = length str+   in start == v0EncodingPrefix && len == v0EncodingLength
cid/MultiFormats/CID/Errors.hs view
@@ -13,12 +13,13 @@   ) where +import MultiFormats.MultiCodec (MultiCodec (..)) import MultiFormats.VarInt.Errors qualified as VarInt  -- | Functor for wrapping CID processing function's return values. type Okay t = Either Error t --- | Sums up everything that can go wrong in the CID modules.+-- | Everything that can go wrong in the CID modules. data Error   = InvalidData DataError   | InvalidEncoding EncodingError@@ -50,8 +51,9 @@  -- | Errors with the CID's MultiHash. data HashError-  = -- | If the given hash codec isn't for a hash function.-    ExpectedHashCodec+  = -- | If the given hash codec isn't known as a hash function (isn't+    -- provided here, or isn't a hash codec value or is a invalid multicodec)+    UnknownHashCodec MultiCodec   | -- | If the encoded hash length doesn't match the digest size.     IncorrectLength   deriving (Eq, Show)
cid/MultiFormats/CID/Extractor.hs view
@@ -14,18 +14,18 @@   ) where +import Data.BaseSystem.BinaryTranscoder (BinaryTranscoder) import Data.Bifunctor (Bifunctor (first))-import Data.ByteString (ByteString) import MultiFormats.CID.Errors import MultiFormats.VarInt (VarInt, extractVarInt) --- | Extracts `a` from ByteString.-type Extraction a = ByteString -> Okay (a, ByteString)+-- | Alias for `extractor` method. Extracts `a` from ByteString.+type Extraction a t = t -> Okay (a, t)  -- | Generic function signature for extracting CID components.-class Extractor a where-  extractor :: Extraction a+class (BinaryTranscoder t) => Extractor a t where+  extractor :: t -> Okay (a, t)  -- | Extractor for VarInts in CID data. Converts VarInt.Error to CID.Error.-instance Extractor VarInt where+instance (BinaryTranscoder t) => Extractor VarInt t where   extractor = first InvalidVarInt . extractVarInt
− cid/MultiFormats/CID/Internal.hs
@@ -1,107 +0,0 @@--- | Module      : MultiFormats.CID.Internal---   Description : Internal implementation for CID---   Copyright   : Zoey McBride (c) 2026---   License     : AGPL-3.0-or-later---   Maintainer  : zoeymcbride@mailbox.org---   Stability   : experimental------ This file provides implemtations for serialization and extraction for--- versioned CID data (when we know ahead-of-time to be CIDv0 or CIDv1).-module MultiFormats.CID.Internal-  ( CIDData (CIDData, cidVersion, cidDataCodec, cidHashCodec, cidHashDigest),--    -- * Extraction over CIDVersion-    extractCIDv1,-    extractCIDv0,--    -- * Serialization over CIDVersion-    serializeCIDv1,-    serializeCIDv0,--    -- * Constructs CIDv0 from ByteString-    mkCIDv0,-  )-where--import Data.Bifunctor (first)-import Data.ByteString (ByteString)-import Data.ByteString qualified as Bytes-import Data.Maybe (fromJust)-import MultiFormats.CID.Errors-import MultiFormats.CID.Extractor-import MultiFormats.CID.Internal.CIDCodec-import MultiFormats.CID.Internal.CIDHash-import MultiFormats.CID.Internal.CIDVersion-import MultiFormats.CID.Serializer-import MultiFormats.MultiCodec (MultiCodec, resolveCodecValue)-import MultiFormats.MultiHash (MultiHash, resolveHashName)-import MultiFormats.VarInt (VarInt)---- | Define the CID as a constructor of CIDData-data CIDData = CIDData-  { -- | Specifies the version (CIDv0 or CIDv1) of this CID.-    cidVersion :: VersionEnum,-    -- | Describes the content type of the hashed data.-    cidDataCodec :: MultiCodec,-    -- | Contains the hash functoin used.-    cidHashCodec :: MultiHash,-    -- | Stores the hash function's output.-    cidHashDigest :: ByteString-  }-  deriving (Eq)---- | Applies the extraction after version# for CIDv0 was extracted.-extractCIDv0 :: Extraction CIDData-extractCIDv0 ondata = first mkCIDv0 <$> splitDigestCIDv0 ondata-  where-    -- Get the hash digest from ByteString if there is enough bytes.-    splitDigestCIDv0 digest-      | Bytes.length digest < hashlen = Left (InvalidHash IncorrectLength)-      | otherwise = Right (Bytes.splitAt hashlen digest)-      where-        hashlen = cidv0HashLength---- | Applies the extraction after version# for CIDv1 was extracted.-extractCIDv1 :: Extraction CIDData-extractCIDv1 oncodec = do-  -- Extract the 1st MultiCodec from the bytes.-  (CIDCodec multicodec, onhash) <- extractor oncodec-  -- Extract the 2nd MultiCodec and get CIDHash-  (CIDHash multihash hashdigest, stop) <- extractor onhash-  -- return the CIDv1 data with the trailing bytes.-  return (CIDData CIDv1 multicodec multihash hashdigest, stop)---- | Serializes CIDv0 by adding the Codec Byte to its digest-serializeCIDv0 :: Serialization CIDData-serializeCIDv0 ciddata =-  return $ Bytes.cons cidv0Byte1st (cidHashDigest ciddata)---- | Serializes CIDv1 into VarInts of its components.-serializeCIDv1 :: Serialization CIDData-serializeCIDv1 ciddata =-  let digest = cidHashDigest ciddata-      digestlength = Bytes.length digest-   in Bytes.concat-        <$> sequence-          [ serializer cidv1VarInt1st,-            serializer (cidDataCodec ciddata),-            serializer (cidHashCodec ciddata),-            serializer (fromIntegral digestlength :: VarInt),-            pure digest-          ]---- | Provides the contructor for CIDv0s, see:--- https://github.com/multiformats/cid?tab=readme-ov-file#cidv0-mkCIDv0 :: ByteString -> CIDData-mkCIDv0 digest =-  CIDData-    { cidVersion = CIDv0,-      cidDataCodec = codec "dag-pb",-      cidHashCodec = hash "sha2-256",-      cidHashDigest = digest-    }-  where-    -- Forces a resolve from MultiCodec-    codec str = fromJust $ resolveCodecValue str-    -- Forces a resolve from MultiHash-    hash str = fromJust $ resolveHashName str
− cid/MultiFormats/CID/Internal/CIDCodec.hs
@@ -1,18 +0,0 @@--- | Module      : MultiFormats.CID.Internal.CIDCodec---   Description : Implements extracting codecs from CIDs.---   Copyright   : Zoey McBride (c) 2026---   License     : AGPL-3.0-or-later---   Maintainer  : zoeymcbride@mailbox.org---   Stability   : experimental-module MultiFormats.CID.Internal.CIDCodec (CIDCodec (CIDCodec)) where--import Data.Bifunctor (first)-import MultiFormats.CID.Extractor (Extractor (extractor))-import MultiFormats.MultiCodec (MultiCodec (MultiCodec))---- | Represents a MultiCodec value embedded within CID data.-newtype CIDCodec = CIDCodec MultiCodec deriving (Eq)---- | Extracts the MultiCodec from VarInt in bytes and wraps in CIDCodec.-instance Extractor CIDCodec where-  extractor bytes = first (CIDCodec . MultiCodec) <$> extractor bytes
− cid/MultiFormats/CID/Internal/CIDDecoder.hs
@@ -1,29 +0,0 @@--- | Module      : MultiFormats.CID.Internal.CIDDecoder---   Description : Parses CID bytes from a multibase encoded string---   Copyright   : Zoey McBride (c) 2026---   License     : AGPL-3.0-or-later---   Maintainer  : zoeymcbride@mailbox.org---   Stability   : experimental-module MultiFormats.CID.Internal.CIDDecoder (CIDDecoder (CIDDecoder)) where--import Data.ByteString (ByteString)-import MultiFormats.CID.Errors-import MultiFormats.CID.Internal.CIDVersion (isCIDv0Str)-import MultiFormats.CID.Parser-import MultiFormats.MultiBase (decodeCIDv0, decodeFromPrefix, hasValidPrefix)---- | Implements decoding CID from String's base encoding.-newtype CIDDecoder = CIDDecoder ByteString---- | Decodes a CID to bytes.-instance Parser CIDDecoder where-  parser str =-    let choosedecoder-          | null str = Left (InvalidData EmptyCID)-          | isCIDv0Str str = Right decodeCIDv0-          | hasValidPrefix str = Right decodeFromPrefix-          | otherwise = Left (InvalidEncoding UnknownBasePrefix)-     in choosedecoder >>= \decoder ->-          case decoder str of-            Nothing -> Left (InvalidEncoding ImproperDigit)-            Just bytes -> Right (CIDDecoder bytes)
− cid/MultiFormats/CID/Internal/CIDHash.hs
@@ -1,42 +0,0 @@--- | Module      : MultiFormats.CID.Internal.CIDHash---   Description : Implements extraction and verification of multihash CID data---   Copyright   : Zoey McBride (c) 2026---   License     : AGPL-3.0-or-later---   Maintainer  : zoeymcbride@mailbox.org---   Stability   : experimental-module MultiFormats.CID.Internal.CIDHash (CIDHash (CIDHash)) where--import Data.Bifunctor (first)-import Data.ByteString (ByteString)-import Data.ByteString qualified as Bytes-import MultiFormats.CID.Errors-import MultiFormats.CID.Extractor (Extractor (extractor))-import MultiFormats.CID.Internal.CIDCodec (CIDCodec (CIDCodec))-import MultiFormats.MultiHash (MultiHash, resolveHashCodec)-import MultiFormats.VarInt (VarInt)--data CIDHash = CIDHash-  { -- | Stores the MultiCodec for the hash function used.-    cidHashCodec :: MultiHash,-    -- | Stores the hash function's output.-    cidHashDigest :: ByteString-  }-  deriving (Eq)---- | Extracts the MultiHash codec and hash digest via a varint size following--- the MultiHash codec.-instance Extractor CIDHash where-  extractor bytes = do-    -- Get the CodecCode from the first varint-    (CIDCodec codec, onsize) <- extractor bytes-    -- Get the digest size from the first varint, make CID.Error if on Left-    (usize :: VarInt, rest) <- extractor onsize-    -- When codec is a valid hash and the given size is available in the bytes,-    -- take #size elements from bytes and construct the CIDHash-    case resolveHashCodec codec of-      Nothing -> Left (InvalidHash ExpectedHashCodec)-      Just hash-        | isize > Bytes.length rest -> Left (InvalidHash IncorrectLength)-        | otherwise -> Right (first (CIDHash hash) $ Bytes.splitAt isize rest)-        where-          isize = fromIntegral usize
− cid/MultiFormats/CID/Internal/CIDVersion.hs
@@ -1,108 +0,0 @@--- | Module      : MultiFormats.CID.Internal.CIDVersion---   Description : Implements extraction versioning from CID data.---   Copyright   : Zoey McBride (c) 2026---   License     : AGPL-3.0-or-later---   Maintainer  : zoeymcbride@mailbox.org---   Stability   : experimental-module MultiFormats.CID.Internal.CIDVersion-  ( VersionEnum (CIDv0, CIDv1),-    CIDVersion (CIDVersion),--    -- * Extractions-    extractVersion0,-    extractVersion1,--    -- * Helper functions-    isCIDv0Str,--    -- * Constants-    cidv0Bytes,-    cidv0HashLength,-    cidv0Byte1st,-    cidv1VarInt1st,-  )-where--import Data.Bifunctor (Bifunctor (first))-import Data.ByteString qualified as Bytes-import Data.Word (Word8)-import MultiFormats.CID.Errors-import MultiFormats.CID.Extractor (Extraction, Extractor (extractor))-import MultiFormats.VarInt (VarInt)---- | Implements available CID versions.-data VersionEnum = CIDv0 | CIDv1 deriving (Show, Eq, Enum)---- | Wraps Version type to implement Extractor.-newtype CIDVersion = CIDVersion VersionEnum deriving (Eq)---- | Extracts and validates the CID versioning information from bytes.-instance Extractor CIDVersion where-  extractor cidbytes =-    case Bytes.uncons cidbytes of-      Nothing -> Left (InvalidData EmptyCID)-      -- Only CIDv0 will start with 0x12, and it must be followed w/ a-      -- special byte; if it doesn't have both, the encoding is invalid.-      Just (0x12, _) -> first CIDVersion <$> extractVersion0 cidbytes-      -- Without the magic bytes, CIDvX > CIDv0 is done in VarInts, so we get-      -- the Version information from the first varint (0x1 for CIDv1).-      Just _VarInt -> first CIDVersion <$> extractVersion1 cidbytes---- | Performs extraction for CIDv1.-extractVersion1 :: Extraction VersionEnum-extractVersion1 bytes =-  extractor bytes >>= \(varint1, rest) ->-    if invalidCIDv1 varint1-      then Left (InvalidEncoding ExpectedCIDv1)-      else Right (CIDv1, rest)-  where-    invalidCIDv1 v1 = v1 /= cidv1VarInt1st---- | Performs extraction for CIDv0.-extractVersion0 :: Extraction VersionEnum-extractVersion0 bytes =-  let (lead, rest) = Bytes.splitAt 2 bytes-   in case Bytes.unpack lead of-        [b1, b2]-          | invalidCIDv0 b1 b2 -> Left (InvalidEncoding MalformedCIDv0)-          | otherwise -> Right (CIDv0, rest)-        _Not2 -> Left (InvalidEncoding MalformedCIDv0)-  where-    invalidCIDv0 b1 b2 =-      b1 /= cidv0Byte1st-        || b2 /= cidv0Byte2nd-        || Bytes.length bytes /= cidv0Bytes---- | This prefixes a CIDv0 instead of a multibase prefix.-cidv0StringPrefix :: String-cidv0StringPrefix = "Qm"---- | The length of a CIDv0 string, base58 encoded.-cidv0StringLength :: Int-cidv0StringLength = 46---- | Required length in bytes of all CIDv0 encodings.-cidv0Bytes :: Int-cidv0Bytes = 34---- | Length of hash digest in CIDv0, ie the length without its versioning--- information, since those are the only items in CIDv0.-cidv0HashLength :: Int-cidv0HashLength = cidv0Bytes - 2---- | Required first byte of all CIDv0 encodings.-cidv0Byte1st :: Word8-cidv0Byte1st = 0x12---- | Required second byte of all CIDv0 encodings.-cidv0Byte2nd :: Word8-cidv0Byte2nd = 0x20---- | Required first VarInt of all CIDv1 encodings.-cidv1VarInt1st :: VarInt-cidv1VarInt1st = 1---- | Checks if a string meets CIDv0 criteria.-isCIDv0Str :: String -> Bool-isCIDv0Str str =-  take 2 str == cidv0StringPrefix && length str == cidv0StringLength
cid/MultiFormats/CID/Parser.hs view
@@ -10,11 +10,12 @@ -- the function signature Parsing some type a from String. module MultiFormats.CID.Parser (Parser (parser), ParseMethod) where +import Data.Text (Text) import MultiFormats.CID.Errors (Okay) --- | Function signature for parsing a String into some `a`.-type ParseMethod a = String -> Okay a+-- | Alias for function signature for parsing a String into some `a`.+type ParseMethod a = Text -> Okay a  -- | Generic function signature for parsing CID components from Strings. class Parser a where-  parser :: ParseMethod a+  parser :: Text -> Okay a
cid/MultiFormats/CID/Serializer.hs view
@@ -15,18 +15,18 @@ where  import Data.Bifunctor (Bifunctor (first))-import Data.ByteString (ByteString)+import Data.ByteString.Builder (Builder) import MultiFormats.CID.Errors import MultiFormats.MultiCodec (MultiCodec, multiCodecValue) import MultiFormats.MultiHash (MultiHash, multiHashCodec) import MultiFormats.VarInt (VarInt, serializeVarInt)  -- | Represents a function that implements serialization.-type Serialization a = a -> Okay ByteString+type Serialization a = a -> Okay Builder  -- | Generic function signature for serializing CID components. class Serializer a where-  serializer :: Serialization a+  serializer :: a -> Okay Builder  -- | Serializer for VarInts in CID data. Converts VarInt.Error to CID.Error. instance Serializer VarInt where
mfmts.cabal view
@@ -1,5 +1,5 @@ cabal-version: 3.0-version:       1.0.0.1+version:       1.1.0.0 name:          mfmts build-type:    Simple author:        Zoey McBride@@ -13,7 +13,8 @@     systems. extra-doc-files:     README.md-    CHANGE_LOG.md+    CHANGELOG.md+ source-repository head {     type: git     location: https://git.sr.ht/~z0/mfmts@@ -26,57 +27,43 @@     Manual: True } --- | Sets flag for developer build toggle-flag Dev {-    Description: Developer build options-    Default: False-    Manual: True+-- | Configures the Haskell toolchain for the library clause+common HaskellConfig {+    default-language: GHC2021+    default-extensions: StrictData+    hs-source-dirs: cid varint multihash multibase multicodec }  -- | These dependency versions are known to be compatable with mfmts common DefaultVersions {     build-depends:         base >= 4.18 && < 5,-        basesystems ^>= 1.0,+        basesystems ^>= 1.1,+        text >= 2.1 && < 2.2,         array ^>= 0.5,-        bytestring ^>= 0.11,-        containers ^>= 0.6,+        bytestring ^>= 0.12,+        containers >= 0.7 && < 0.8,         crypton ^>= 1.1,         ram >= 0.20.1 && < 0.23 } --- | DefaultBuild: strict compilation + optimize for executable speed-common DefaultBuild {+-- | BuildUser: strict compilation + optimize for executable speed+common BuildUser {     import: DefaultVersions     ghc-options: -Wall -Wextra -Wno-unused-top-binds } --- | CIBuild: strict compilation + optimize for compile time-common CIBuild {+-- | BuildCI: strict compilation + optimize for compile time+common BuildCI {     import: DefaultVersions     ghc-options: -Wall -Wextra -Werror -Wno-unused-top-binds } --- | Configures the Dev flag-common DevBuild {-   import: DefaultVersions-   ghc-options: -Wall -Wextra -Wno-unused-top-binds-}-- -- | Configures mfmts library {-    default-language: GHC2021-    default-extensions: StrictData-    if flag(Dev) {-        import: DevBuild-    }-    elif flag(CI) {-        import: CIBuild-    }-    else {-        import: DefaultBuild-    }+    import: HaskellConfig+    if flag(CI) { import: BuildCI }+    else { import: BuildUser }     exposed-modules:         -- * Unsigned binary varints         MultiFormats.VarInt,@@ -84,8 +71,14 @@         -- * Multicodecs for identifying data in CID         MultiFormats.MultiCodec,         -- * Multibase for labeling identifying basesystems via prefix+        -- for ShortByteString, LazyByteString, and strict ByteString         MultiFormats.MultiBase,-        MultiFormats.MultiBaseSystems,+        MultiFormats.MultiBase.Lazy,+        MultiFormats.MultiBase.Strict,+        -- * Data.BaseSystem.DigitSystems with prefix identifiers for MultiBase+        MultiFormats.MultiBase.DigitSystem,+        -- * Instance of Data.BaseSystem.DigitTranscoder for MultiBase+        MultiFormats.MultiBase.DigitTranscoder,         -- * Associates various hash functions with their Mutlicodec identifier         MultiFormats.MultiHash,         -- * CID definitions@@ -96,15 +89,8 @@         MultiFormats.CID.Extractor,         MultiFormats.CID.Parser,         -- * Implements Extractors, Serializers, and Parsers for CID components-        MultiFormats.CID.Internal,-        MultiFormats.CID.Internal.CIDCodec,-        MultiFormats.CID.Internal.CIDDecoder,-        MultiFormats.CID.Internal.CIDHash,-        MultiFormats.CID.Internal.CIDVersion,-    hs-source-dirs:-        cid-        varint-        multihash-        multibase-        multicodec+        MultiFormats.CID.Component.Codec,+        MultiFormats.CID.Component.Decoder,+        MultiFormats.CID.Component.Hash,+        MultiFormats.CID.Component.Version, }
multibase/MultiFormats/MultiBase.hs view
@@ -1,108 +1,37 @@ -- | Module      : MultiFormats.MultiBase---   Description : Functions for working with multibase data.+--   Description : Multibase encoders and decoders for ShortByteString --   Copyright   : Zoey McBride (c) 2026 --   License     : AGPL-3.0-or-later --   Maintainer  : zoeymcbride@mailbox.org --   Stability   : experimental module MultiFormats.MultiBase-  ( MultiBase (prefixChar, baseEncoder, baseDecoder),-    mkMultiBase,--    -- * Decoders-    decodeFromPrefix,-    decodeCIDv0,--    -- * Query functions for MultiBase information-    hasValidPrefix,-    resolvePrefix,-    resolveMultiBase,+  ( BaseSystem (encoder, decoder),+    Encoder,+    Decoder,+    ByteStr,   ) where -import Data.BaseSystem (BaseSystem, Decoder, Encoder)-import Data.BaseSystem qualified as Bases-import Data.BaseSystems qualified as Bases-import Data.Function (on)-import Data.List (uncons)-import Data.Map.Strict qualified as Map-import Data.Maybe (isJust)-import Text.Printf (printf)--data MultiBase = MultiBase-  { prefixChar :: Char,-    baseEncoder :: Encoder,-    baseDecoder :: Decoder,-    baseName :: String-  }--instance Eq MultiBase where-  (==) = (==) `on` prefixChar--instance Ord MultiBase where-  compare = compare `on` prefixChar--instance Show MultiBase where-  show mb = printf "multi%s('%c')" (baseName mb) (prefixChar mb)---- | Implements encoder/decoder for multibase systems when the prefix is known--- ahead of time.-instance BaseSystem MultiBase where-  encoder mb bytes = prefixChar mb : baseEncoder mb bytes-  decoder _ = decodeFromPrefix---- | Constructs a Multibase from a BaseSystem.-mkMultiBase :: (Show b, BaseSystem b) => b -> Char -> MultiBase-mkMultiBase bs prefix =-  MultiBase-    { prefixChar = prefix,-      baseEncoder = Bases.encoder bs,-      baseDecoder = Bases.decoder bs,-      baseName = show bs-    }+import Data.BaseSystem.DigitTranscoder qualified as DXC+import Data.ByteString.Short (ShortByteString)+import Data.Text (Text)+import MultiFormats.MultiBase.DigitTranscoder (MultiBase) --- | Resolves a MultiBase system from a Char.-resolvePrefix :: Char -> Maybe MultiBase-resolvePrefix prefix = Map.lookup prefix prefixTable <*> pure prefix-  where-    -- https://github.com/multiformats/multibase/blob/master/multibase.csv-    prefixTable =-      Map.fromList-        [ ('0', mkMultiBase Bases.base2),-          ('9', mkMultiBase Bases.base10),-          ('f', mkMultiBase Bases.base16lower),-          ('F', mkMultiBase Bases.base16upper),-          ('b', mkMultiBase Bases.base32lowerNP),-          ('B', mkMultiBase Bases.base32upperNP),-          ('c', mkMultiBase Bases.base32lower),-          ('C', mkMultiBase Bases.base32upper),-          ('v', mkMultiBase Bases.base32hexlowerNP),-          ('V', mkMultiBase Bases.base32hexupperNP),-          ('t', mkMultiBase Bases.base32hexlower),-          ('T', mkMultiBase Bases.base32hexupper),-          ('z', mkMultiBase Bases.base58btc),-          ('m', mkMultiBase Bases.base64NP),-          ('M', mkMultiBase Bases.base64),-          ('u', mkMultiBase Bases.base64urlNP),-          ('U', mkMultiBase Bases.base64url)-        ]+-- | Sets the bytestring type to use in this file.+type ByteStr = ShortByteString --- | Resolves a MultiBase system from the first Char in a String.-resolveMultiBase :: String -> Maybe MultiBase-resolveMultiBase str = uncons str >>= \(ch, _) -> resolvePrefix ch+-- | Alias for curried encoder method.+type Encoder = ByteStr -> Text --- | Checks if a given char is an implemented MultiBase prefix.-hasValidPrefix :: String -> Bool-hasValidPrefix [] = False-hasValidPrefix (prefix : _) = isJust $ resolvePrefix prefix+-- | Alias for curried decoder method.+type Decoder = Text -> Maybe ByteStr --- | Provides decoder for MultiBase strings with any implemented prefix--- character.-decodeFromPrefix :: Decoder-decodeFromPrefix str =-  uncons str >>= \(prefix, rest) -> do-    decode <- baseDecoder <$> resolvePrefix prefix-    decode rest+-- | Configures the BaseSystem for this file's ByteType.+class BaseSystem a where+  encoder :: a -> ByteStr -> Text+  decoder :: a -> Text -> Maybe ByteStr --- | Decodes for CIDv0 from base58btc w/o MultiBase prefix.-decodeCIDv0 :: Decoder-decodeCIDv0 = Bases.decoder Bases.base58btc+-- | Demotes the DigitTranscoder for MultiBase to BaseSystem transcoders.+instance BaseSystem (MultiBase ByteStr) where+  encoder = DXC.digitEncoder+  decoder = DXC.digitDecoder
+ multibase/MultiFormats/MultiBase/DigitSystem.hs view
@@ -0,0 +1,102 @@+-- | Module      : MultiFormats.MultiBase.DigitSystem+--   Description : Parameters to set multibase encoder/decoder basesystem+--   Copyright   : Zoey McBride (c) 2026+--   License     : AGPL-3.0-or-later+--   Maintainer  : zoeymcbride@mailbox.org+--   Stability   : experimental+module MultiFormats.MultiBase.DigitSystem+  ( multibase2,+    multibase10,+    multibase16lower,+    multibase16upper,+    multibase32lower,+    multibase32lowerNP,+    multibase32upper,+    multibase32upperNP,+    multibase32hexlower,+    multibase32hexlowerNP,+    multibase32hexupper,+    multibase32hexupperNP,+    multibase58btc,+    multibase64,+    multibase64NP,+    multibase64url,+    multibase64urlNP,+  )+where++import Data.BaseSystem.BinaryTranscoder (BinaryTranscoder)+import Data.Maybe (fromJust)+import MultiFormats.MultiBase.DigitTranscoder (MultiBase, resolvePrefix)++-- | Creates the multibase from Char, and crashes if Char is an invalid prefix.+mk :: (BinaryTranscoder bxc) => Char -> MultiBase bxc+mk = fromJust . resolvePrefix++-- | Binary has prefix "0".+multibase2 :: (BinaryTranscoder bxc) => MultiBase bxc+multibase2 = mk '0'++-- | Decimal has prefix "9".+multibase10 :: (BinaryTranscoder bxc) => MultiBase bxc+multibase10 = mk '9'++-- | Hex-lower has prefix "f".+multibase16lower :: (BinaryTranscoder bxc) => MultiBase bxc+multibase16lower = mk 'f'++-- | Hex-upper has prefix "F".+multibase16upper :: (BinaryTranscoder bxc) => MultiBase bxc+multibase16upper = mk 'F'++-- | base32lower (no pad) has prefix "b".+multibase32lowerNP :: (BinaryTranscoder bxc) => MultiBase bxc+multibase32lowerNP = mk 'b'++-- | base32uppper (no pad) has prefix "B".+multibase32upperNP :: (BinaryTranscoder bxc) => MultiBase bxc+multibase32upperNP = mk 'B'++-- | base32lower (with pad) has prefix "c".+multibase32lower :: (BinaryTranscoder bxc) => MultiBase bxc+multibase32lower = mk 'c'++-- | base32upper (with pad) has prefix "C".+multibase32upper :: (BinaryTranscoder bxc) => MultiBase bxc+multibase32upper = mk 'C'++-- | Hex-base32lower (no pad) has prefix "v".+multibase32hexlowerNP :: (BinaryTranscoder bxc) => MultiBase bxc+multibase32hexlowerNP = mk 'v'++-- | Hex-base32upper (no pad) has prefix "V".+multibase32hexupperNP :: (BinaryTranscoder bxc) => MultiBase bxc+multibase32hexupperNP = mk 'V'++-- | Hex-base32lower (with pad) has prefix "t".+multibase32hexlower :: (BinaryTranscoder bxc) => MultiBase bxc+multibase32hexlower = mk 't'++-- | Hex-base32upper (with pad) has prefix "T".+multibase32hexupper :: (BinaryTranscoder bxc) => MultiBase bxc+multibase32hexupper = mk 'T'++-- | Bitcoin base58 has prefix "z".+multibase58btc :: (BinaryTranscoder bxc) => MultiBase bxc+multibase58btc = mk 'z'++-- | base64 (no pad) has prefix "m".+multibase64NP :: (BinaryTranscoder bxc) => MultiBase bxc+multibase64NP = mk 'm'++-- | base64 (with pad) has prefix "M".+multibase64 :: (BinaryTranscoder bxc) => MultiBase bxc+multibase64 = mk 'M'++-- | base64url (no pad) has prefix "u".+multibase64urlNP :: (BinaryTranscoder bxc) => MultiBase bxc+multibase64urlNP = mk 'u'++-- | base64url (with pad) has prefix "U".+multibase64url :: (BinaryTranscoder bxc) => MultiBase bxc+multibase64url = mk 'U'
+ multibase/MultiFormats/MultiBase/DigitTranscoder.hs view
@@ -0,0 +1,147 @@+-- | Module      : MultiFormats.MultiBase.DigitTranscoder+--   Description : Implements Data.BaseSystem.DigitTranscoder for MultiBase+--   Copyright   : Zoey McBride (c) 2026+--   License     : AGPL-3.0-or-later+--   Maintainer  : zoeymcbride@mailbox.org+--   Stability   : experimental+module MultiFormats.MultiBase.DigitTranscoder+  ( -- * Methods on MultiBase systems.+    MultiBase (multibasePrefix),+    mkMultiBase,++    -- * Decoders+    decodeFromPrefix,+    decodeCIDv0,++    -- * Query functions for MultiBase information+    hasValidPrefix,+    resolvePrefix,+    resolveTextPrefix,+  )+where++import Data.BaseSystem.Alphabet qualified as Alpha+import Data.BaseSystem.BinaryTranscoder (BinaryTranscoder)+import Data.BaseSystem.DigitSystem qualified as Digits+import Data.BaseSystem.DigitTranscoder (DigitTranscoder (..))+import Data.ByteString (ByteString)+import Data.Char (ord)+import Data.Function (on)+import Data.IntMap.Lazy (IntMap)+import Data.IntMap.Lazy qualified as IntMap+import Data.Maybe (fromMaybe)+import Data.Text (Text)+import Data.Text qualified as Text++-- | Stores a multibase basesystem's prefix and its implementations for+-- digitDecoder/digitEncoder from Data.BaseSystem.DigitTranscoder.+data MultiBase bxc = MultiBase+  { -- | The name of the basesystem for displaying in show (prepends "multi").+    multibaseName :: String,+    -- | The basesystem's idenitifying symbol.+    multibasePrefix :: Alpha.Symbol,+    -- | Encodes the binary transcoder to Text.+    multibaseEncoder :: bxc -> Text,+    -- | Decodes the binary transcoder from Text.+    multibaseDecoder :: Text -> Maybe bxc+  }++-- | Implements equality for multibase on prefixes.+instance Eq (MultiBase bxc) where+  (==) = (==) `on` multibasePrefix++-- | Implements ordering for multibase on prefixes.+instance Ord (MultiBase bxc) where+  compare = compare `on` multibasePrefix++-- | Prepends multi to the basesystem name.+instance Show (MultiBase bxc) where+  show mb = "multi" ++ multibaseName mb++-- | Implements a DigitTranscoder for all MulitBases parameterized by+-- BinaryTranscoder.+instance (BinaryTranscoder bxc) => DigitTranscoder (MultiBase bxc) bxc where+  -- digitEncoder: Use the encoder provided in the MultiBase data.+  digitEncoder = multibaseEncoder++  -- digitDecoder: Ignore the argument and try to decode from text prefix.+  digitDecoder _ = decodeFromPrefix++-- | Provides decoder for MultiBase strings with any implemented prefix+-- character.+decodeFromPrefix :: (BinaryTranscoder bxc) => Text -> Maybe bxc+decodeFromPrefix text = do+  (prefix, rest) <- Text.uncons text+  decode <- multibaseDecoder <$> resolvePrefix prefix+  decode rest++-- | Decodes for CIDv0 from base58btc w/o MultiBase prefix.+decodeCIDv0 :: (BinaryTranscoder bxc) => Text -> Maybe bxc+decodeCIDv0 = digitDecoder Digits.base58btc++-- | Checks if the Text has a valid prefix character.+hasValidPrefix :: Text -> Bool+hasValidPrefix text =+  fromMaybe False $ do+    (ch, _) <- Text.uncons text+    return $ ord ch `IntMap.member` lookupTable+  where+    -- Sets the table to lookup, they all share the same keys, but since it's+    -- a generic type the compiler doesn't know which table to look in, so+    -- we set it here.+    lookupTable = prefixSymbolTable :: IntMap (MultiBase ByteString)++-- | Resolves a MultiBase system from the first Symbol in a String.+resolveTextPrefix :: (BinaryTranscoder bxc) => Text -> Maybe (MultiBase bxc)+resolveTextPrefix text = Text.uncons text >>= \(ch, _) -> resolvePrefix ch++-- | Resolves a MultiBase system from a basesystem prefix Symbol.+resolvePrefix :: (BinaryTranscoder bxc) => Alpha.Symbol -> Maybe (MultiBase bxc)+resolvePrefix prefix = ord prefix `IntMap.lookup` prefixSymbolTable++-- | Creates the lookup table between prefix symbols and multibase systems.+-- Lazy IntMaps get better performance than Lazy Maps for Ints, so we convert+-- the Chars to get the boost.+-- Multibase table:+-- https://github.com/multiformats/multibase/blob/master/multibase.csv+-- Data.Map on IntMap performance:+-- https://hackage-content.haskell.org/package/containers-0.8/docs/Data-Map.html+prefixSymbolTable :: (BinaryTranscoder bxc) => IntMap (MultiBase bxc)+prefixSymbolTable =+  IntMap.fromList+    [ mk '0' Digits.base2,+      mk '9' Digits.base10,+      mk 'f' Digits.base16lower,+      mk 'F' Digits.base16upper,+      mk 'b' Digits.base32lowerNP,+      mk 'B' Digits.base32upperNP,+      mk 'c' Digits.base32lower,+      mk 'C' Digits.base32upper,+      mk 'v' Digits.base32hexlowerNP,+      mk 'V' Digits.base32hexupperNP,+      mk 't' Digits.base32hexlower,+      mk 'T' Digits.base32hexupper,+      mk 'z' Digits.base58btc,+      mk 'm' Digits.base64NP,+      mk 'M' Digits.base64,+      mk 'u' Digits.base64urlNP,+      mk 'U' Digits.base64url+    ]+  where+    -- Creates a lookup table entry from prefix.+    mk prefix digits = (ord prefix, mkMultiBase prefix digits)++-- | Creates a multibase system from a prefix and digit transcoder+-- implementation.+mkMultiBase ::+  (BinaryTranscoder bxc, DigitTranscoder dxc bxc, Show dxc) =>+  Alpha.Symbol ->+  dxc ->+  MultiBase bxc+mkMultiBase prefix digits =+  MultiBase+    { multibaseName = show digits,+      multibasePrefix = prefix,+      multibaseEncoder = digitEncoder digits,+      multibaseDecoder = digitDecoder digits+    }
+ multibase/MultiFormats/MultiBase/Lazy.hs view
@@ -0,0 +1,37 @@+-- | Module      : MultiFormats.MultiBase.Lazy+--   Description : Multibase encoders and decoders for LazyByteString+--   Copyright   : Zoey McBride (c) 2026+--   License     : AGPL-3.0-or-later+--   Maintainer  : zoeymcbride@mailbox.org+--   Stability   : experimental+module MultiFormats.MultiBase.Lazy+  ( BaseSystem (encoder, decoder),+    Encoder,+    Decoder,+    ByteStr,+  )+where++import Data.BaseSystem.DigitTranscoder qualified as DXC+import Data.ByteString.Lazy (LazyByteString)+import Data.Text (Text)+import MultiFormats.MultiBase.DigitTranscoder (MultiBase)++-- | Sets the bytestring type to use in this file.+type ByteStr = LazyByteString++-- | Alias for curried encoder method.+type Encoder = ByteStr -> Text++-- | Alias for curried decoder method.+type Decoder = Text -> Maybe ByteStr++-- | Configures the BaseSystem for this file's ByteType.+class BaseSystem a where+  encoder :: a -> ByteStr -> Text+  decoder :: a -> Text -> Maybe ByteStr++-- | Demotes the DigitTranscoder for MultiBase to BaseSystem transcoders.+instance BaseSystem (MultiBase ByteStr) where+  encoder = DXC.digitEncoder+  decoder = DXC.digitDecoder
+ multibase/MultiFormats/MultiBase/Strict.hs view
@@ -0,0 +1,37 @@+-- | Module      : MultiFormats.MultiBase.Strict+--   Description : Multibase encoders and decoders for strict ByteString+--   Copyright   : Zoey McBride (c) 2026+--   License     : AGPL-3.0-or-later+--   Maintainer  : zoeymcbride@mailbox.org+--   Stability   : experimental+module MultiFormats.MultiBase.Strict+  ( BaseSystem (encoder, decoder),+    Encoder,+    Decoder,+    ByteStr,+  )+where++import Data.BaseSystem.DigitTranscoder qualified as DXC+import Data.ByteString (ByteString)+import Data.Text (Text)+import MultiFormats.MultiBase.DigitTranscoder (MultiBase)++-- | Sets the bytestring type to use in this file.+type ByteStr = ByteString++-- | Alias for curried encoder method.+type Encoder = ByteStr -> Text++-- | Alias for curried decoder method.+type Decoder = Text -> Maybe ByteStr++-- | Configures the BaseSystem for this file's ByteType.+class BaseSystem a where+  encoder :: a -> ByteStr -> Text+  decoder :: a -> Text -> Maybe ByteStr++-- | Demotes the DigitTranscoder for MultiBase to BaseSystem transcoders.+instance BaseSystem (MultiBase ByteStr) where+  encoder = DXC.digitEncoder+  decoder = DXC.digitDecoder
− multibase/MultiFormats/MultiBaseSystems.hs
@@ -1,102 +0,0 @@--- | Module      : MultiFormats.MultiBaseSystems---   Description : Provides default instances of multibase---   Copyright   : Zoey McBride (c) 2026---   License     : AGPL-3.0-or-later---   Maintainer  : zoeymcbride@mailbox.org---   Stability   : experimental-module MultiFormats.MultiBaseSystems-  ( base2,-    base10,-    base16lower,-    base16upper,-    base32lower,-    base32lowerNP,-    base32upper,-    base32upperNP,-    base32hexlower,-    base32hexlowerNP,-    base32hexupper,-    base32hexupperNP,-    base58btc,-    base64,-    base64NP,-    base64url,-    base64urlNP,-  )-where--import Data.Maybe (fromJust)-import MultiFormats.MultiBase---- | Unwraps Maybe from multibaseSystems lookup for implementing MultiBase from--- Char.-multibasePrefix :: Char -> MultiBase-multibasePrefix = fromJust . resolvePrefix---- | Binary has prefix '0'.-base2 :: MultiBase-base2 = multibasePrefix '0'---- | Decimal has prefix '9'.-base10 :: MultiBase-base10 = multibasePrefix '9'---- | Hex-lower has prefix 'f'.-base16lower :: MultiBase-base16lower = multibasePrefix 'f'---- | Hex-upper has prefix 'F'.-base16upper :: MultiBase-base16upper = multibasePrefix 'F'---- | base32lower (no pad) has prefix 'b'.-base32lowerNP :: MultiBase-base32lowerNP = multibasePrefix 'b'---- | base32uppper (no pad) has prefix 'B'.-base32upperNP :: MultiBase-base32upperNP = multibasePrefix 'B'---- | base32lower (with pad) has prefix 'c'.-base32lower :: MultiBase-base32lower = multibasePrefix 'c'---- | base32upper (with pad) has prefix 'C'.-base32upper :: MultiBase-base32upper = multibasePrefix 'C'---- | Hex-base32lower (no pad) has prefix 'v'.-base32hexlowerNP :: MultiBase-base32hexlowerNP = multibasePrefix 'v'---- | Hex-base32upper (no pad) has prefix 'V'.-base32hexupperNP :: MultiBase-base32hexupperNP = multibasePrefix 'V'---- | Hex-base32lower (with pad) has prefix 't'.-base32hexlower :: MultiBase-base32hexlower = multibasePrefix 't'---- | Hex-base32upper (with pad) has prefix 'T'.-base32hexupper :: MultiBase-base32hexupper = multibasePrefix 'T'---- | Bitcoin base58 has prefix 'z'.-base58btc :: MultiBase-base58btc = multibasePrefix 'z'---- | base64 (no pad) has prefix 'm'.-base64NP :: MultiBase-base64NP = multibasePrefix 'm'---- | base64 (with pad) has prefix 'M'.-base64 :: MultiBase-base64 = multibasePrefix 'M'---- | base64url (no pad) has prefix 'u'.-base64urlNP :: MultiBase-base64urlNP = multibasePrefix 'u'---- | base64url (with pad) has prefix 'U'.-base64url :: MultiBase-base64url = multibasePrefix 'U'
multicodec/MultiFormats/MultiCodec.hs view
@@ -5,1299 +5,1328 @@ --   Maintainer  : zoeymcbride@mailbox.org --   Stability   : experimental module MultiFormats.MultiCodec-  ( MultiCodec(MultiCodec, multiCodecValue),-    resolveCodecValue,-    resolveCodecName,-    gitCommitHash,-    gitCommitDate,-  )-where---- !!! WARNING: !!!--- This file is generated! Don't edit it. Instead, use the scripts provided in--- the python folder at the root of the git repository. The current file was--- generated on: 2026-03-27 16:23:19.941647+00:00--import Data.Map (Map)-import Data.Map qualified as LazyMap-import Data.Maybe (fromMaybe)-import MultiFormats.VarInt (VarInt)---- | Represents MultiCodec code.-newtype MultiCodec = MultiCodec {multiCodecValue :: VarInt} deriving (Eq, Ord)--instance Show MultiCodec where-  show codec = fromMaybe "<invalid codec>" $ resolveCodecName codec---- | Resolves MultiCodec code from its string name.-resolveCodecValue :: String -> Maybe MultiCodec-resolveCodecValue name = MultiCodec <$> LazyMap.lookup name nameToCodec---- | Resolves MultiCodec name from its numeric code.-resolveCodecName :: MultiCodec -> Maybe String-resolveCodecName (MultiCodec codec) = LazyMap.lookup codec codecToName---- | The git hash for table.csv used to generate this file.-gitCommitHash :: String-gitCommitHash = "c89cc366970fa6c03294e430421a42f31efff616"---- | This is the date the table.csv was commited.-gitCommitDate :: String-gitCommitDate = "2026-03-06 02:56:38 +0100"--nameToCodec :: Map String VarInt-nameToCodec =-  LazyMap.fromList [-        ("identity", 0x00),-        ("cidv1", 0x01),-        ("cidv2", 0x02),-        ("cidv3", 0x03),-        ("ip4", 0x04),-        ("tcp", 0x06),-        ("sha1", 0x11),-        ("sha2-256", 0x12),-        ("sha2-512", 0x13),-        ("sha3-512", 0x14),-        ("sha3-384", 0x15),-        ("sha3-256", 0x16),-        ("sha3-224", 0x17),-        ("shake-128", 0x18),-        ("shake-256", 0x19),-        ("keccak-224", 0x1a),-        ("keccak-256", 0x1b),-        ("keccak-384", 0x1c),-        ("keccak-512", 0x1d),-        ("blake3", 0x1e),-        ("sha2-384", 0x20),-        ("dccp", 0x21),-        ("murmur3-x64-64", 0x22),-        ("murmur3-32", 0x23),-        ("ip6", 0x29),-        ("ip6zone", 0x2a),-        ("ipcidr", 0x2b),-        ("path", 0x2f),-        ("multicodec", 0x30),-        ("multihash", 0x31),-        ("multiaddr", 0x32),-        ("multibase", 0x33),-        ("varsig", 0x34),-        ("dns", 0x35),-        ("dns4", 0x36),-        ("dns6", 0x37),-        ("dnsaddr", 0x38),-        ("protobuf", 0x50),-        ("cbor", 0x51),-        ("raw", 0x55),-        ("dbl-sha2-256", 0x56),-        ("rlp", 0x60),-        ("bencode", 0x63),-        ("dag-pb", 0x70),-        ("dag-cbor", 0x71),-        ("libp2p-key", 0x72),-        ("git-raw", 0x78),-        ("torrent-info", 0x7b),-        ("torrent-file", 0x7c),-        ("blake3-hashseq", 0x80),-        ("leofcoin-block", 0x81),-        ("leofcoin-tx", 0x82),-        ("leofcoin-pr", 0x83),-        ("sctp", 0x84),-        ("dag-jose", 0x85),-        ("dag-cose", 0x86),-        ("lbry", 0x8c),-        ("eth-block", 0x90),-        ("eth-block-list", 0x91),-        ("eth-tx-trie", 0x92),-        ("eth-tx", 0x93),-        ("eth-tx-receipt-trie", 0x94),-        ("eth-tx-receipt", 0x95),-        ("eth-state-trie", 0x96),-        ("eth-account-snapshot", 0x97),-        ("eth-storage-trie", 0x98),-        ("eth-receipt-log-trie", 0x99),-        ("eth-receipt-log", 0x9a),-        ("aes-128", 0xa0),-        ("aes-192", 0xa1),-        ("aes-256", 0xa2),-        ("chacha-128", 0xa3),-        ("chacha-256", 0xa4),-        ("bitcoin-block", 0xb0),-        ("bitcoin-tx", 0xb1),-        ("bitcoin-witness-commitment", 0xb2),-        ("zcash-block", 0xc0),-        ("zcash-tx", 0xc1),-        ("caip-50", 0xca),-        ("streamid", 0xce),-        ("stellar-block", 0xd0),-        ("stellar-tx", 0xd1),-        ("md4", 0xd4),-        ("md5", 0xd5),-        ("decred-block", 0xe0),-        ("decred-tx", 0xe1),-        ("ipld", 0xe2),-        ("ipfs", 0xe3),-        ("swarm", 0xe4),-        ("ipns", 0xe5),-        ("zeronet", 0xe6),-        ("secp256k1-pub", 0xe7),-        ("dnslink", 0xe8),-        ("bls12_381-g1-pub", 0xea),-        ("bls12_381-g2-pub", 0xeb),-        ("x25519-pub", 0xec),-        ("ed25519-pub", 0xed),-        ("bls12_381-g1g2-pub", 0xee),-        ("sr25519-pub", 0xef),-        ("dash-block", 0xf0),-        ("dash-tx", 0xf1),-        ("swarm-manifest", 0xfa),-        ("swarm-feed", 0xfb),-        ("beeson", 0xfc),-        ("udp", 0x0111),-        ("webrtc-direct", 0x0118),-        ("webrtc", 0x0119),-        ("p2p-circuit", 0x0122),-        ("dag-json", 0x0129),-        ("udt", 0x012d),-        ("utp", 0x012e),-        ("crc32", 0x0132),-        ("crc64-ecma", 0x0164),-        ("crc64-nvme", 0x0165),-        ("unix", 0x0190),-        ("thread", 0x0196),-        ("p2p", 0x01a5),-        ("https", 0x01bb),-        ("onion", 0x01bc),-        ("onion3", 0x01bd),-        ("garlic64", 0x01be),-        ("garlic32", 0x01bf),-        ("tls", 0x01c0),-        ("sni", 0x01c1),-        ("noise", 0x01c6),-        ("shs", 0x01c8),-        ("quic", 0x01cc),-        ("quic-v1", 0x01cd),-        ("webtransport", 0x01d1),-        ("certhash", 0x01d2),-        ("ws", 0x01dd),-        ("wss", 0x01de),-        ("p2p-websocket-star", 0x01df),-        ("http", 0x01e0),-        ("http-path", 0x01e1),-        ("swhid-1-snp", 0x01f0),-        ("json", 0x0200),-        ("messagepack", 0x0201),-        ("car", 0x0202),-        ("x509-certificate", 0x0210),-        ("ipns-record", 0x0300),-        ("libp2p-peer-record", 0x0301),-        ("libp2p-relay-rsvp", 0x0302),-        ("memorytransport", 0x0309),-        ("car-index-sorted", 0x0400),-        ("car-multihash-index-sorted", 0x0401),-        ("transport-bitswap", 0x0900),-        ("transport-graphsync-filecoinv1", 0x0910),-        ("transport-ipfs-gateway-http", 0x0920),-        ("transport-filecoin-piece-http", 0x0930),-        ("multidid", 0x0d1d),-        ("fr32-sha256-trunc254-padbintree", 0x1011),-        ("sha2-256-trunc254-padded", 0x1012),-        ("sha2-224", 0x1013),-        ("sha2-512-224", 0x1014),-        ("sha2-512-256", 0x1015),-        ("murmur3-x64-128", 0x1022),-        ("ripemd-128", 0x1052),-        ("ripemd-160", 0x1053),-        ("ripemd-256", 0x1054),-        ("ripemd-320", 0x1055),-        ("x11", 0x1100),-        ("p256-pub", 0x1200),-        ("p384-pub", 0x1201),-        ("p521-pub", 0x1202),-        ("ed448-pub", 0x1203),-        ("x448-pub", 0x1204),-        ("rsa-pub", 0x1205),-        ("sm2-pub", 0x1206),-        ("vlad", 0x1207),-        ("provenance-log", 0x1208),-        ("provenance-log-entry", 0x1209),-        ("provenance-log-script", 0x120a),-        ("mlkem-512-pub", 0x120b),-        ("mlkem-768-pub", 0x120c),-        ("mlkem-1024-pub", 0x120d),-        ("mldsa-44-pub", 0x1210),-        ("mldsa-65-pub", 0x1211),-        ("mldsa-87-pub", 0x1212),-        ("slhdsa-sha2-128s-pub", 0x1220),-        ("slhdsa-shake-128s-pub", 0x1221),-        ("slhdsa-sha2-128f-pub", 0x1222),-        ("slhdsa-shake-128f-pub", 0x1223),-        ("slhdsa-sha2-192s-pub", 0x1224),-        ("slhdsa-shake-192s-pub", 0x1225),-        ("slhdsa-sha2-192f-pub", 0x1226),-        ("slhdsa-shake-192f-pub", 0x1227),-        ("slhdsa-sha2-256s-pub", 0x1228),-        ("slhdsa-shake-256s-pub", 0x1229),-        ("slhdsa-sha2-256f-pub", 0x122a),-        ("slhdsa-shake-256f-pub", 0x122b),-        ("multisig", 0x1239),-        ("multikey", 0x123a),-        ("nonce", 0x123b),-        ("ed25519-priv", 0x1300),-        ("secp256k1-priv", 0x1301),-        ("x25519-priv", 0x1302),-        ("sr25519-priv", 0x1303),-        ("rsa-priv", 0x1305),-        ("p256-priv", 0x1306),-        ("p384-priv", 0x1307),-        ("p521-priv", 0x1308),-        ("bls12_381-g1-priv", 0x1309),-        ("bls12_381-g2-priv", 0x130a),-        ("bls12_381-g1g2-priv", 0x130b),-        ("bls12_381-g1-pub-share", 0x130c),-        ("bls12_381-g2-pub-share", 0x130d),-        ("bls12_381-g1-priv-share", 0x130e),-        ("bls12_381-g2-priv-share", 0x130f),-        ("sm2-priv", 0x1310),-        ("ed448-priv", 0x1311),-        ("x448-priv", 0x1312),-        ("mlkem-512-priv", 0x1313),-        ("mlkem-768-priv", 0x1314),-        ("mlkem-1024-priv", 0x1315),-        ("jwk_jcs-priv", 0x1316),-        ("lamport-sha3-512-pub", 0x1a14),-        ("lamport-sha3-384-pub", 0x1a15),-        ("lamport-sha3-256-pub", 0x1a16),-        ("lamport-sha3-512-priv", 0x1a24),-        ("lamport-sha3-384-priv", 0x1a25),-        ("lamport-sha3-256-priv", 0x1a26),-        ("lamport-sha3-512-priv-share", 0x1a34),-        ("lamport-sha3-384-priv-share", 0x1a35),-        ("lamport-sha3-256-priv-share", 0x1a36),-        ("lamport-sha3-512-sig", 0x1a44),-        ("lamport-sha3-384-sig", 0x1a45),-        ("lamport-sha3-256-sig", 0x1a46),-        ("lamport-sha3-512-sig-share", 0x1a54),-        ("lamport-sha3-384-sig-share", 0x1a55),-        ("lamport-sha3-256-sig-share", 0x1a56),-        ("kt-128", 0x1d01),-        ("kt-256", 0x1d02),-        ("aes-gcm-256", 0x2000),-        ("silverpine", 0x3f42),-        ("sm3-256", 0x534d),-        ("sha256a", 0x7012),-        ("chacha20-poly1305", 0xa000),-        ("blake2b-8", 0xb201),-        ("blake2b-16", 0xb202),-        ("blake2b-24", 0xb203),-        ("blake2b-32", 0xb204),-        ("blake2b-40", 0xb205),-        ("blake2b-48", 0xb206),-        ("blake2b-56", 0xb207),-        ("blake2b-64", 0xb208),-        ("blake2b-72", 0xb209),-        ("blake2b-80", 0xb20a),-        ("blake2b-88", 0xb20b),-        ("blake2b-96", 0xb20c),-        ("blake2b-104", 0xb20d),-        ("blake2b-112", 0xb20e),-        ("blake2b-120", 0xb20f),-        ("blake2b-128", 0xb210),-        ("blake2b-136", 0xb211),-        ("blake2b-144", 0xb212),-        ("blake2b-152", 0xb213),-        ("blake2b-160", 0xb214),-        ("blake2b-168", 0xb215),-        ("blake2b-176", 0xb216),-        ("blake2b-184", 0xb217),-        ("blake2b-192", 0xb218),-        ("blake2b-200", 0xb219),-        ("blake2b-208", 0xb21a),-        ("blake2b-216", 0xb21b),-        ("blake2b-224", 0xb21c),-        ("blake2b-232", 0xb21d),-        ("blake2b-240", 0xb21e),-        ("blake2b-248", 0xb21f),-        ("blake2b-256", 0xb220),-        ("blake2b-264", 0xb221),-        ("blake2b-272", 0xb222),-        ("blake2b-280", 0xb223),-        ("blake2b-288", 0xb224),-        ("blake2b-296", 0xb225),-        ("blake2b-304", 0xb226),-        ("blake2b-312", 0xb227),-        ("blake2b-320", 0xb228),-        ("blake2b-328", 0xb229),-        ("blake2b-336", 0xb22a),-        ("blake2b-344", 0xb22b),-        ("blake2b-352", 0xb22c),-        ("blake2b-360", 0xb22d),-        ("blake2b-368", 0xb22e),-        ("blake2b-376", 0xb22f),-        ("blake2b-384", 0xb230),-        ("blake2b-392", 0xb231),-        ("blake2b-400", 0xb232),-        ("blake2b-408", 0xb233),-        ("blake2b-416", 0xb234),-        ("blake2b-424", 0xb235),-        ("blake2b-432", 0xb236),-        ("blake2b-440", 0xb237),-        ("blake2b-448", 0xb238),-        ("blake2b-456", 0xb239),-        ("blake2b-464", 0xb23a),-        ("blake2b-472", 0xb23b),-        ("blake2b-480", 0xb23c),-        ("blake2b-488", 0xb23d),-        ("blake2b-496", 0xb23e),-        ("blake2b-504", 0xb23f),-        ("blake2b-512", 0xb240),-        ("blake2s-8", 0xb241),-        ("blake2s-16", 0xb242),-        ("blake2s-24", 0xb243),-        ("blake2s-32", 0xb244),-        ("blake2s-40", 0xb245),-        ("blake2s-48", 0xb246),-        ("blake2s-56", 0xb247),-        ("blake2s-64", 0xb248),-        ("blake2s-72", 0xb249),-        ("blake2s-80", 0xb24a),-        ("blake2s-88", 0xb24b),-        ("blake2s-96", 0xb24c),-        ("blake2s-104", 0xb24d),-        ("blake2s-112", 0xb24e),-        ("blake2s-120", 0xb24f),-        ("blake2s-128", 0xb250),-        ("blake2s-136", 0xb251),-        ("blake2s-144", 0xb252),-        ("blake2s-152", 0xb253),-        ("blake2s-160", 0xb254),-        ("blake2s-168", 0xb255),-        ("blake2s-176", 0xb256),-        ("blake2s-184", 0xb257),-        ("blake2s-192", 0xb258),-        ("blake2s-200", 0xb259),-        ("blake2s-208", 0xb25a),-        ("blake2s-216", 0xb25b),-        ("blake2s-224", 0xb25c),-        ("blake2s-232", 0xb25d),-        ("blake2s-240", 0xb25e),-        ("blake2s-248", 0xb25f),-        ("blake2s-256", 0xb260),-        ("skein256-8", 0xb301),-        ("skein256-16", 0xb302),-        ("skein256-24", 0xb303),-        ("skein256-32", 0xb304),-        ("skein256-40", 0xb305),-        ("skein256-48", 0xb306),-        ("skein256-56", 0xb307),-        ("skein256-64", 0xb308),-        ("skein256-72", 0xb309),-        ("skein256-80", 0xb30a),-        ("skein256-88", 0xb30b),-        ("skein256-96", 0xb30c),-        ("skein256-104", 0xb30d),-        ("skein256-112", 0xb30e),-        ("skein256-120", 0xb30f),-        ("skein256-128", 0xb310),-        ("skein256-136", 0xb311),-        ("skein256-144", 0xb312),-        ("skein256-152", 0xb313),-        ("skein256-160", 0xb314),-        ("skein256-168", 0xb315),-        ("skein256-176", 0xb316),-        ("skein256-184", 0xb317),-        ("skein256-192", 0xb318),-        ("skein256-200", 0xb319),-        ("skein256-208", 0xb31a),-        ("skein256-216", 0xb31b),-        ("skein256-224", 0xb31c),-        ("skein256-232", 0xb31d),-        ("skein256-240", 0xb31e),-        ("skein256-248", 0xb31f),-        ("skein256-256", 0xb320),-        ("skein512-8", 0xb321),-        ("skein512-16", 0xb322),-        ("skein512-24", 0xb323),-        ("skein512-32", 0xb324),-        ("skein512-40", 0xb325),-        ("skein512-48", 0xb326),-        ("skein512-56", 0xb327),-        ("skein512-64", 0xb328),-        ("skein512-72", 0xb329),-        ("skein512-80", 0xb32a),-        ("skein512-88", 0xb32b),-        ("skein512-96", 0xb32c),-        ("skein512-104", 0xb32d),-        ("skein512-112", 0xb32e),-        ("skein512-120", 0xb32f),-        ("skein512-128", 0xb330),-        ("skein512-136", 0xb331),-        ("skein512-144", 0xb332),-        ("skein512-152", 0xb333),-        ("skein512-160", 0xb334),-        ("skein512-168", 0xb335),-        ("skein512-176", 0xb336),-        ("skein512-184", 0xb337),-        ("skein512-192", 0xb338),-        ("skein512-200", 0xb339),-        ("skein512-208", 0xb33a),-        ("skein512-216", 0xb33b),-        ("skein512-224", 0xb33c),-        ("skein512-232", 0xb33d),-        ("skein512-240", 0xb33e),-        ("skein512-248", 0xb33f),-        ("skein512-256", 0xb340),-        ("skein512-264", 0xb341),-        ("skein512-272", 0xb342),-        ("skein512-280", 0xb343),-        ("skein512-288", 0xb344),-        ("skein512-296", 0xb345),-        ("skein512-304", 0xb346),-        ("skein512-312", 0xb347),-        ("skein512-320", 0xb348),-        ("skein512-328", 0xb349),-        ("skein512-336", 0xb34a),-        ("skein512-344", 0xb34b),-        ("skein512-352", 0xb34c),-        ("skein512-360", 0xb34d),-        ("skein512-368", 0xb34e),-        ("skein512-376", 0xb34f),-        ("skein512-384", 0xb350),-        ("skein512-392", 0xb351),-        ("skein512-400", 0xb352),-        ("skein512-408", 0xb353),-        ("skein512-416", 0xb354),-        ("skein512-424", 0xb355),-        ("skein512-432", 0xb356),-        ("skein512-440", 0xb357),-        ("skein512-448", 0xb358),-        ("skein512-456", 0xb359),-        ("skein512-464", 0xb35a),-        ("skein512-472", 0xb35b),-        ("skein512-480", 0xb35c),-        ("skein512-488", 0xb35d),-        ("skein512-496", 0xb35e),-        ("skein512-504", 0xb35f),-        ("skein512-512", 0xb360),-        ("skein1024-8", 0xb361),-        ("skein1024-16", 0xb362),-        ("skein1024-24", 0xb363),-        ("skein1024-32", 0xb364),-        ("skein1024-40", 0xb365),-        ("skein1024-48", 0xb366),-        ("skein1024-56", 0xb367),-        ("skein1024-64", 0xb368),-        ("skein1024-72", 0xb369),-        ("skein1024-80", 0xb36a),-        ("skein1024-88", 0xb36b),-        ("skein1024-96", 0xb36c),-        ("skein1024-104", 0xb36d),-        ("skein1024-112", 0xb36e),-        ("skein1024-120", 0xb36f),-        ("skein1024-128", 0xb370),-        ("skein1024-136", 0xb371),-        ("skein1024-144", 0xb372),-        ("skein1024-152", 0xb373),-        ("skein1024-160", 0xb374),-        ("skein1024-168", 0xb375),-        ("skein1024-176", 0xb376),-        ("skein1024-184", 0xb377),-        ("skein1024-192", 0xb378),-        ("skein1024-200", 0xb379),-        ("skein1024-208", 0xb37a),-        ("skein1024-216", 0xb37b),-        ("skein1024-224", 0xb37c),-        ("skein1024-232", 0xb37d),-        ("skein1024-240", 0xb37e),-        ("skein1024-248", 0xb37f),-        ("skein1024-256", 0xb380),-        ("skein1024-264", 0xb381),-        ("skein1024-272", 0xb382),-        ("skein1024-280", 0xb383),-        ("skein1024-288", 0xb384),-        ("skein1024-296", 0xb385),-        ("skein1024-304", 0xb386),-        ("skein1024-312", 0xb387),-        ("skein1024-320", 0xb388),-        ("skein1024-328", 0xb389),-        ("skein1024-336", 0xb38a),-        ("skein1024-344", 0xb38b),-        ("skein1024-352", 0xb38c),-        ("skein1024-360", 0xb38d),-        ("skein1024-368", 0xb38e),-        ("skein1024-376", 0xb38f),-        ("skein1024-384", 0xb390),-        ("skein1024-392", 0xb391),-        ("skein1024-400", 0xb392),-        ("skein1024-408", 0xb393),-        ("skein1024-416", 0xb394),-        ("skein1024-424", 0xb395),-        ("skein1024-432", 0xb396),-        ("skein1024-440", 0xb397),-        ("skein1024-448", 0xb398),-        ("skein1024-456", 0xb399),-        ("skein1024-464", 0xb39a),-        ("skein1024-472", 0xb39b),-        ("skein1024-480", 0xb39c),-        ("skein1024-488", 0xb39d),-        ("skein1024-496", 0xb39e),-        ("skein1024-504", 0xb39f),-        ("skein1024-512", 0xb3a0),-        ("skein1024-520", 0xb3a1),-        ("skein1024-528", 0xb3a2),-        ("skein1024-536", 0xb3a3),-        ("skein1024-544", 0xb3a4),-        ("skein1024-552", 0xb3a5),-        ("skein1024-560", 0xb3a6),-        ("skein1024-568", 0xb3a7),-        ("skein1024-576", 0xb3a8),-        ("skein1024-584", 0xb3a9),-        ("skein1024-592", 0xb3aa),-        ("skein1024-600", 0xb3ab),-        ("skein1024-608", 0xb3ac),-        ("skein1024-616", 0xb3ad),-        ("skein1024-624", 0xb3ae),-        ("skein1024-632", 0xb3af),-        ("skein1024-640", 0xb3b0),-        ("skein1024-648", 0xb3b1),-        ("skein1024-656", 0xb3b2),-        ("skein1024-664", 0xb3b3),-        ("skein1024-672", 0xb3b4),-        ("skein1024-680", 0xb3b5),-        ("skein1024-688", 0xb3b6),-        ("skein1024-696", 0xb3b7),-        ("skein1024-704", 0xb3b8),-        ("skein1024-712", 0xb3b9),-        ("skein1024-720", 0xb3ba),-        ("skein1024-728", 0xb3bb),-        ("skein1024-736", 0xb3bc),-        ("skein1024-744", 0xb3bd),-        ("skein1024-752", 0xb3be),-        ("skein1024-760", 0xb3bf),-        ("skein1024-768", 0xb3c0),-        ("skein1024-776", 0xb3c1),-        ("skein1024-784", 0xb3c2),-        ("skein1024-792", 0xb3c3),-        ("skein1024-800", 0xb3c4),-        ("skein1024-808", 0xb3c5),-        ("skein1024-816", 0xb3c6),-        ("skein1024-824", 0xb3c7),-        ("skein1024-832", 0xb3c8),-        ("skein1024-840", 0xb3c9),-        ("skein1024-848", 0xb3ca),-        ("skein1024-856", 0xb3cb),-        ("skein1024-864", 0xb3cc),-        ("skein1024-872", 0xb3cd),-        ("skein1024-880", 0xb3ce),-        ("skein1024-888", 0xb3cf),-        ("skein1024-896", 0xb3d0),-        ("skein1024-904", 0xb3d1),-        ("skein1024-912", 0xb3d2),-        ("skein1024-920", 0xb3d3),-        ("skein1024-928", 0xb3d4),-        ("skein1024-936", 0xb3d5),-        ("skein1024-944", 0xb3d6),-        ("skein1024-952", 0xb3d7),-        ("skein1024-960", 0xb3d8),-        ("skein1024-968", 0xb3d9),-        ("skein1024-976", 0xb3da),-        ("skein1024-984", 0xb3db),-        ("skein1024-992", 0xb3dc),-        ("skein1024-1000", 0xb3dd),-        ("skein1024-1008", 0xb3de),-        ("skein1024-1016", 0xb3df),-        ("skein1024-1024", 0xb3e0),-        ("xxh-32", 0xb3e1),-        ("xxh-64", 0xb3e2),-        ("xxh3-64", 0xb3e3),-        ("xxh3-128", 0xb3e4),-        ("poseidon-bls12_381-a2-fc1", 0xb401),-        ("poseidon-bls12_381-a2-fc1-sc", 0xb402),-        ("rdfc-1", 0xb403),-        ("ssz", 0xb501),-        ("ssz-sha2-256-bmt", 0xb502),-        ("sha2-256-chunked", 0xb510),-        ("json-jcs", 0xb601),-        ("bittorrent-pieces-root", 0xb702),-        ("iscc", 0xcc01),-        ("zeroxcert-imprint-256", 0xce11),-        ("bcrypt-pbkdf", 0xd00d),-        ("es256k", 0xd0e7),-        ("bls12_381-g1-sig", 0xd0ea),-        ("bls12_381-g2-sig", 0xd0eb),-        ("eddsa", 0xd0ed),-        ("eip-191", 0xd191),-        ("jwk_jcs-pub", 0xeb51),-        ("ed2k", 0xed20),-        ("fil-commitment-unsealed", 0xf101),-        ("fil-commitment-sealed", 0xf102),-        ("shelter-contract-manifest", 0x511e00),-        ("shelter-contract-text", 0x511e01),-        ("shelter-contract-data", 0x511e02),-        ("shelter-file-manifest", 0x511e03),-        ("shelter-file-chunk", 0x511e04),-        ("plaintextv2", 0x706c61),-        ("holochain-adr-v0", 0x807124),-        ("holochain-adr-v1", 0x817124),-        ("holochain-key-v0", 0x947124),-        ("holochain-key-v1", 0x957124),-        ("holochain-sig-v0", 0xa27124),-        ("holochain-sig-v1", 0xa37124),-        ("skynet-ns", 0xb19910),-        ("arweave-ns", 0xb29910),-        ("subspace-ns", 0xb39910),-        ("kumandra-ns", 0xb49910),-        ("massa", 0xb59910),-        ("massa-mainnet", 0xb59911),-        ("massa-buildnet", 0xb59912),-        ("massa-deweb", 0xb59913),-        ("massa-gossip", 0xb59914),-        ("massa-mns", 0xb59915),-        ("massa-sc", 0xb59916),-        ("massa-gossip-id", 0xb59917),-        ("es256", 0xd01200),-        ("es384", 0xd01201),-        ("es512", 0xd01202),-        ("rs256", 0xd01205),-        ("es256k-msig", 0xd01300),-        ("bls12_381-g1-msig", 0xd01301),-        ("bls12_381-g2-msig", 0xd01302),-        ("eddsa-msig", 0xd01303),-        ("bls12_381-g1-share-msig", 0xd01304),-        ("bls12_381-g2-share-msig", 0xd01305),-        ("lamport-msig", 0xd01306),-        ("lamport-share-msig", 0xd01307),-        ("es256-msig", 0xd01308),-        ("es384-msig", 0xd01309),-        ("es521-msig", 0xd0130a),-        ("rs256-msig", 0xd0130b),-        ("scion", 0xd02000)-  ]--codecToName :: Map VarInt String-codecToName =-  LazyMap.fromList [-        (0x00, "identity"),-        (0x01, "cidv1"),-        (0x02, "cidv2"),-        (0x03, "cidv3"),-        (0x04, "ip4"),-        (0x06, "tcp"),-        (0x11, "sha1"),-        (0x12, "sha2-256"),-        (0x13, "sha2-512"),-        (0x14, "sha3-512"),-        (0x15, "sha3-384"),-        (0x16, "sha3-256"),-        (0x17, "sha3-224"),-        (0x18, "shake-128"),-        (0x19, "shake-256"),-        (0x1a, "keccak-224"),-        (0x1b, "keccak-256"),-        (0x1c, "keccak-384"),-        (0x1d, "keccak-512"),-        (0x1e, "blake3"),-        (0x20, "sha2-384"),-        (0x21, "dccp"),-        (0x22, "murmur3-x64-64"),-        (0x23, "murmur3-32"),-        (0x29, "ip6"),-        (0x2a, "ip6zone"),-        (0x2b, "ipcidr"),-        (0x2f, "path"),-        (0x30, "multicodec"),-        (0x31, "multihash"),-        (0x32, "multiaddr"),-        (0x33, "multibase"),-        (0x34, "varsig"),-        (0x35, "dns"),-        (0x36, "dns4"),-        (0x37, "dns6"),-        (0x38, "dnsaddr"),-        (0x50, "protobuf"),-        (0x51, "cbor"),-        (0x55, "raw"),-        (0x56, "dbl-sha2-256"),-        (0x60, "rlp"),-        (0x63, "bencode"),-        (0x70, "dag-pb"),-        (0x71, "dag-cbor"),-        (0x72, "libp2p-key"),-        (0x78, "git-raw"),-        (0x7b, "torrent-info"),-        (0x7c, "torrent-file"),-        (0x80, "blake3-hashseq"),-        (0x81, "leofcoin-block"),-        (0x82, "leofcoin-tx"),-        (0x83, "leofcoin-pr"),-        (0x84, "sctp"),-        (0x85, "dag-jose"),-        (0x86, "dag-cose"),-        (0x8c, "lbry"),-        (0x90, "eth-block"),-        (0x91, "eth-block-list"),-        (0x92, "eth-tx-trie"),-        (0x93, "eth-tx"),-        (0x94, "eth-tx-receipt-trie"),-        (0x95, "eth-tx-receipt"),-        (0x96, "eth-state-trie"),-        (0x97, "eth-account-snapshot"),-        (0x98, "eth-storage-trie"),-        (0x99, "eth-receipt-log-trie"),-        (0x9a, "eth-receipt-log"),-        (0xa0, "aes-128"),-        (0xa1, "aes-192"),-        (0xa2, "aes-256"),-        (0xa3, "chacha-128"),-        (0xa4, "chacha-256"),-        (0xb0, "bitcoin-block"),-        (0xb1, "bitcoin-tx"),-        (0xb2, "bitcoin-witness-commitment"),-        (0xc0, "zcash-block"),-        (0xc1, "zcash-tx"),-        (0xca, "caip-50"),-        (0xce, "streamid"),-        (0xd0, "stellar-block"),-        (0xd1, "stellar-tx"),-        (0xd4, "md4"),-        (0xd5, "md5"),-        (0xe0, "decred-block"),-        (0xe1, "decred-tx"),-        (0xe2, "ipld"),-        (0xe3, "ipfs"),-        (0xe4, "swarm"),-        (0xe5, "ipns"),-        (0xe6, "zeronet"),-        (0xe7, "secp256k1-pub"),-        (0xe8, "dnslink"),-        (0xea, "bls12_381-g1-pub"),-        (0xeb, "bls12_381-g2-pub"),-        (0xec, "x25519-pub"),-        (0xed, "ed25519-pub"),-        (0xee, "bls12_381-g1g2-pub"),-        (0xef, "sr25519-pub"),-        (0xf0, "dash-block"),-        (0xf1, "dash-tx"),-        (0xfa, "swarm-manifest"),-        (0xfb, "swarm-feed"),-        (0xfc, "beeson"),-        (0x0111, "udp"),-        (0x0118, "webrtc-direct"),-        (0x0119, "webrtc"),-        (0x0122, "p2p-circuit"),-        (0x0129, "dag-json"),-        (0x012d, "udt"),-        (0x012e, "utp"),-        (0x0132, "crc32"),-        (0x0164, "crc64-ecma"),-        (0x0165, "crc64-nvme"),-        (0x0190, "unix"),-        (0x0196, "thread"),-        (0x01a5, "p2p"),-        (0x01bb, "https"),-        (0x01bc, "onion"),-        (0x01bd, "onion3"),-        (0x01be, "garlic64"),-        (0x01bf, "garlic32"),-        (0x01c0, "tls"),-        (0x01c1, "sni"),-        (0x01c6, "noise"),-        (0x01c8, "shs"),-        (0x01cc, "quic"),-        (0x01cd, "quic-v1"),-        (0x01d1, "webtransport"),-        (0x01d2, "certhash"),-        (0x01dd, "ws"),-        (0x01de, "wss"),-        (0x01df, "p2p-websocket-star"),-        (0x01e0, "http"),-        (0x01e1, "http-path"),-        (0x01f0, "swhid-1-snp"),-        (0x0200, "json"),-        (0x0201, "messagepack"),-        (0x0202, "car"),-        (0x0210, "x509-certificate"),-        (0x0300, "ipns-record"),-        (0x0301, "libp2p-peer-record"),-        (0x0302, "libp2p-relay-rsvp"),-        (0x0309, "memorytransport"),-        (0x0400, "car-index-sorted"),-        (0x0401, "car-multihash-index-sorted"),-        (0x0900, "transport-bitswap"),-        (0x0910, "transport-graphsync-filecoinv1"),-        (0x0920, "transport-ipfs-gateway-http"),-        (0x0930, "transport-filecoin-piece-http"),-        (0x0d1d, "multidid"),-        (0x1011, "fr32-sha256-trunc254-padbintree"),-        (0x1012, "sha2-256-trunc254-padded"),-        (0x1013, "sha2-224"),-        (0x1014, "sha2-512-224"),-        (0x1015, "sha2-512-256"),-        (0x1022, "murmur3-x64-128"),-        (0x1052, "ripemd-128"),-        (0x1053, "ripemd-160"),-        (0x1054, "ripemd-256"),-        (0x1055, "ripemd-320"),-        (0x1100, "x11"),-        (0x1200, "p256-pub"),-        (0x1201, "p384-pub"),-        (0x1202, "p521-pub"),-        (0x1203, "ed448-pub"),-        (0x1204, "x448-pub"),-        (0x1205, "rsa-pub"),-        (0x1206, "sm2-pub"),-        (0x1207, "vlad"),-        (0x1208, "provenance-log"),-        (0x1209, "provenance-log-entry"),-        (0x120a, "provenance-log-script"),-        (0x120b, "mlkem-512-pub"),-        (0x120c, "mlkem-768-pub"),-        (0x120d, "mlkem-1024-pub"),-        (0x1210, "mldsa-44-pub"),-        (0x1211, "mldsa-65-pub"),-        (0x1212, "mldsa-87-pub"),-        (0x1220, "slhdsa-sha2-128s-pub"),-        (0x1221, "slhdsa-shake-128s-pub"),-        (0x1222, "slhdsa-sha2-128f-pub"),-        (0x1223, "slhdsa-shake-128f-pub"),-        (0x1224, "slhdsa-sha2-192s-pub"),-        (0x1225, "slhdsa-shake-192s-pub"),-        (0x1226, "slhdsa-sha2-192f-pub"),-        (0x1227, "slhdsa-shake-192f-pub"),-        (0x1228, "slhdsa-sha2-256s-pub"),-        (0x1229, "slhdsa-shake-256s-pub"),-        (0x122a, "slhdsa-sha2-256f-pub"),-        (0x122b, "slhdsa-shake-256f-pub"),-        (0x1239, "multisig"),-        (0x123a, "multikey"),-        (0x123b, "nonce"),-        (0x1300, "ed25519-priv"),-        (0x1301, "secp256k1-priv"),-        (0x1302, "x25519-priv"),-        (0x1303, "sr25519-priv"),-        (0x1305, "rsa-priv"),-        (0x1306, "p256-priv"),-        (0x1307, "p384-priv"),-        (0x1308, "p521-priv"),-        (0x1309, "bls12_381-g1-priv"),-        (0x130a, "bls12_381-g2-priv"),-        (0x130b, "bls12_381-g1g2-priv"),-        (0x130c, "bls12_381-g1-pub-share"),-        (0x130d, "bls12_381-g2-pub-share"),-        (0x130e, "bls12_381-g1-priv-share"),-        (0x130f, "bls12_381-g2-priv-share"),-        (0x1310, "sm2-priv"),-        (0x1311, "ed448-priv"),-        (0x1312, "x448-priv"),-        (0x1313, "mlkem-512-priv"),-        (0x1314, "mlkem-768-priv"),-        (0x1315, "mlkem-1024-priv"),-        (0x1316, "jwk_jcs-priv"),-        (0x1a14, "lamport-sha3-512-pub"),-        (0x1a15, "lamport-sha3-384-pub"),-        (0x1a16, "lamport-sha3-256-pub"),-        (0x1a24, "lamport-sha3-512-priv"),-        (0x1a25, "lamport-sha3-384-priv"),-        (0x1a26, "lamport-sha3-256-priv"),-        (0x1a34, "lamport-sha3-512-priv-share"),-        (0x1a35, "lamport-sha3-384-priv-share"),-        (0x1a36, "lamport-sha3-256-priv-share"),-        (0x1a44, "lamport-sha3-512-sig"),-        (0x1a45, "lamport-sha3-384-sig"),-        (0x1a46, "lamport-sha3-256-sig"),-        (0x1a54, "lamport-sha3-512-sig-share"),-        (0x1a55, "lamport-sha3-384-sig-share"),-        (0x1a56, "lamport-sha3-256-sig-share"),-        (0x1d01, "kt-128"),-        (0x1d02, "kt-256"),-        (0x2000, "aes-gcm-256"),-        (0x3f42, "silverpine"),-        (0x534d, "sm3-256"),-        (0x7012, "sha256a"),-        (0xa000, "chacha20-poly1305"),-        (0xb201, "blake2b-8"),-        (0xb202, "blake2b-16"),-        (0xb203, "blake2b-24"),-        (0xb204, "blake2b-32"),-        (0xb205, "blake2b-40"),-        (0xb206, "blake2b-48"),-        (0xb207, "blake2b-56"),-        (0xb208, "blake2b-64"),-        (0xb209, "blake2b-72"),-        (0xb20a, "blake2b-80"),-        (0xb20b, "blake2b-88"),-        (0xb20c, "blake2b-96"),-        (0xb20d, "blake2b-104"),-        (0xb20e, "blake2b-112"),-        (0xb20f, "blake2b-120"),-        (0xb210, "blake2b-128"),-        (0xb211, "blake2b-136"),-        (0xb212, "blake2b-144"),-        (0xb213, "blake2b-152"),-        (0xb214, "blake2b-160"),-        (0xb215, "blake2b-168"),-        (0xb216, "blake2b-176"),-        (0xb217, "blake2b-184"),-        (0xb218, "blake2b-192"),-        (0xb219, "blake2b-200"),-        (0xb21a, "blake2b-208"),-        (0xb21b, "blake2b-216"),-        (0xb21c, "blake2b-224"),-        (0xb21d, "blake2b-232"),-        (0xb21e, "blake2b-240"),-        (0xb21f, "blake2b-248"),-        (0xb220, "blake2b-256"),-        (0xb221, "blake2b-264"),-        (0xb222, "blake2b-272"),-        (0xb223, "blake2b-280"),-        (0xb224, "blake2b-288"),-        (0xb225, "blake2b-296"),-        (0xb226, "blake2b-304"),-        (0xb227, "blake2b-312"),-        (0xb228, "blake2b-320"),-        (0xb229, "blake2b-328"),-        (0xb22a, "blake2b-336"),-        (0xb22b, "blake2b-344"),-        (0xb22c, "blake2b-352"),-        (0xb22d, "blake2b-360"),-        (0xb22e, "blake2b-368"),-        (0xb22f, "blake2b-376"),-        (0xb230, "blake2b-384"),-        (0xb231, "blake2b-392"),-        (0xb232, "blake2b-400"),-        (0xb233, "blake2b-408"),-        (0xb234, "blake2b-416"),-        (0xb235, "blake2b-424"),-        (0xb236, "blake2b-432"),-        (0xb237, "blake2b-440"),-        (0xb238, "blake2b-448"),-        (0xb239, "blake2b-456"),-        (0xb23a, "blake2b-464"),-        (0xb23b, "blake2b-472"),-        (0xb23c, "blake2b-480"),-        (0xb23d, "blake2b-488"),-        (0xb23e, "blake2b-496"),-        (0xb23f, "blake2b-504"),-        (0xb240, "blake2b-512"),-        (0xb241, "blake2s-8"),-        (0xb242, "blake2s-16"),-        (0xb243, "blake2s-24"),-        (0xb244, "blake2s-32"),-        (0xb245, "blake2s-40"),-        (0xb246, "blake2s-48"),-        (0xb247, "blake2s-56"),-        (0xb248, "blake2s-64"),-        (0xb249, "blake2s-72"),-        (0xb24a, "blake2s-80"),-        (0xb24b, "blake2s-88"),-        (0xb24c, "blake2s-96"),-        (0xb24d, "blake2s-104"),-        (0xb24e, "blake2s-112"),-        (0xb24f, "blake2s-120"),-        (0xb250, "blake2s-128"),-        (0xb251, "blake2s-136"),-        (0xb252, "blake2s-144"),-        (0xb253, "blake2s-152"),-        (0xb254, "blake2s-160"),-        (0xb255, "blake2s-168"),-        (0xb256, "blake2s-176"),-        (0xb257, "blake2s-184"),-        (0xb258, "blake2s-192"),-        (0xb259, "blake2s-200"),-        (0xb25a, "blake2s-208"),-        (0xb25b, "blake2s-216"),-        (0xb25c, "blake2s-224"),-        (0xb25d, "blake2s-232"),-        (0xb25e, "blake2s-240"),-        (0xb25f, "blake2s-248"),-        (0xb260, "blake2s-256"),-        (0xb301, "skein256-8"),-        (0xb302, "skein256-16"),-        (0xb303, "skein256-24"),-        (0xb304, "skein256-32"),-        (0xb305, "skein256-40"),-        (0xb306, "skein256-48"),-        (0xb307, "skein256-56"),-        (0xb308, "skein256-64"),-        (0xb309, "skein256-72"),-        (0xb30a, "skein256-80"),-        (0xb30b, "skein256-88"),-        (0xb30c, "skein256-96"),-        (0xb30d, "skein256-104"),-        (0xb30e, "skein256-112"),-        (0xb30f, "skein256-120"),-        (0xb310, "skein256-128"),-        (0xb311, "skein256-136"),-        (0xb312, "skein256-144"),-        (0xb313, "skein256-152"),-        (0xb314, "skein256-160"),-        (0xb315, "skein256-168"),-        (0xb316, "skein256-176"),-        (0xb317, "skein256-184"),-        (0xb318, "skein256-192"),-        (0xb319, "skein256-200"),-        (0xb31a, "skein256-208"),-        (0xb31b, "skein256-216"),-        (0xb31c, "skein256-224"),-        (0xb31d, "skein256-232"),-        (0xb31e, "skein256-240"),-        (0xb31f, "skein256-248"),-        (0xb320, "skein256-256"),-        (0xb321, "skein512-8"),-        (0xb322, "skein512-16"),-        (0xb323, "skein512-24"),-        (0xb324, "skein512-32"),-        (0xb325, "skein512-40"),-        (0xb326, "skein512-48"),-        (0xb327, "skein512-56"),-        (0xb328, "skein512-64"),-        (0xb329, "skein512-72"),-        (0xb32a, "skein512-80"),-        (0xb32b, "skein512-88"),-        (0xb32c, "skein512-96"),-        (0xb32d, "skein512-104"),-        (0xb32e, "skein512-112"),-        (0xb32f, "skein512-120"),-        (0xb330, "skein512-128"),-        (0xb331, "skein512-136"),-        (0xb332, "skein512-144"),-        (0xb333, "skein512-152"),-        (0xb334, "skein512-160"),-        (0xb335, "skein512-168"),-        (0xb336, "skein512-176"),-        (0xb337, "skein512-184"),-        (0xb338, "skein512-192"),-        (0xb339, "skein512-200"),-        (0xb33a, "skein512-208"),-        (0xb33b, "skein512-216"),-        (0xb33c, "skein512-224"),-        (0xb33d, "skein512-232"),-        (0xb33e, "skein512-240"),-        (0xb33f, "skein512-248"),-        (0xb340, "skein512-256"),-        (0xb341, "skein512-264"),-        (0xb342, "skein512-272"),-        (0xb343, "skein512-280"),-        (0xb344, "skein512-288"),-        (0xb345, "skein512-296"),-        (0xb346, "skein512-304"),-        (0xb347, "skein512-312"),-        (0xb348, "skein512-320"),-        (0xb349, "skein512-328"),-        (0xb34a, "skein512-336"),-        (0xb34b, "skein512-344"),-        (0xb34c, "skein512-352"),-        (0xb34d, "skein512-360"),-        (0xb34e, "skein512-368"),-        (0xb34f, "skein512-376"),-        (0xb350, "skein512-384"),-        (0xb351, "skein512-392"),-        (0xb352, "skein512-400"),-        (0xb353, "skein512-408"),-        (0xb354, "skein512-416"),-        (0xb355, "skein512-424"),-        (0xb356, "skein512-432"),-        (0xb357, "skein512-440"),-        (0xb358, "skein512-448"),-        (0xb359, "skein512-456"),-        (0xb35a, "skein512-464"),-        (0xb35b, "skein512-472"),-        (0xb35c, "skein512-480"),-        (0xb35d, "skein512-488"),-        (0xb35e, "skein512-496"),-        (0xb35f, "skein512-504"),-        (0xb360, "skein512-512"),-        (0xb361, "skein1024-8"),-        (0xb362, "skein1024-16"),-        (0xb363, "skein1024-24"),-        (0xb364, "skein1024-32"),-        (0xb365, "skein1024-40"),-        (0xb366, "skein1024-48"),-        (0xb367, "skein1024-56"),-        (0xb368, "skein1024-64"),-        (0xb369, "skein1024-72"),-        (0xb36a, "skein1024-80"),-        (0xb36b, "skein1024-88"),-        (0xb36c, "skein1024-96"),-        (0xb36d, "skein1024-104"),-        (0xb36e, "skein1024-112"),-        (0xb36f, "skein1024-120"),-        (0xb370, "skein1024-128"),-        (0xb371, "skein1024-136"),-        (0xb372, "skein1024-144"),-        (0xb373, "skein1024-152"),-        (0xb374, "skein1024-160"),-        (0xb375, "skein1024-168"),-        (0xb376, "skein1024-176"),-        (0xb377, "skein1024-184"),-        (0xb378, "skein1024-192"),-        (0xb379, "skein1024-200"),-        (0xb37a, "skein1024-208"),-        (0xb37b, "skein1024-216"),-        (0xb37c, "skein1024-224"),-        (0xb37d, "skein1024-232"),-        (0xb37e, "skein1024-240"),-        (0xb37f, "skein1024-248"),-        (0xb380, "skein1024-256"),-        (0xb381, "skein1024-264"),-        (0xb382, "skein1024-272"),-        (0xb383, "skein1024-280"),-        (0xb384, "skein1024-288"),-        (0xb385, "skein1024-296"),-        (0xb386, "skein1024-304"),-        (0xb387, "skein1024-312"),-        (0xb388, "skein1024-320"),-        (0xb389, "skein1024-328"),-        (0xb38a, "skein1024-336"),-        (0xb38b, "skein1024-344"),-        (0xb38c, "skein1024-352"),-        (0xb38d, "skein1024-360"),-        (0xb38e, "skein1024-368"),-        (0xb38f, "skein1024-376"),-        (0xb390, "skein1024-384"),-        (0xb391, "skein1024-392"),-        (0xb392, "skein1024-400"),-        (0xb393, "skein1024-408"),-        (0xb394, "skein1024-416"),-        (0xb395, "skein1024-424"),-        (0xb396, "skein1024-432"),-        (0xb397, "skein1024-440"),-        (0xb398, "skein1024-448"),-        (0xb399, "skein1024-456"),-        (0xb39a, "skein1024-464"),-        (0xb39b, "skein1024-472"),-        (0xb39c, "skein1024-480"),-        (0xb39d, "skein1024-488"),-        (0xb39e, "skein1024-496"),-        (0xb39f, "skein1024-504"),-        (0xb3a0, "skein1024-512"),-        (0xb3a1, "skein1024-520"),-        (0xb3a2, "skein1024-528"),-        (0xb3a3, "skein1024-536"),-        (0xb3a4, "skein1024-544"),-        (0xb3a5, "skein1024-552"),-        (0xb3a6, "skein1024-560"),-        (0xb3a7, "skein1024-568"),-        (0xb3a8, "skein1024-576"),-        (0xb3a9, "skein1024-584"),-        (0xb3aa, "skein1024-592"),-        (0xb3ab, "skein1024-600"),-        (0xb3ac, "skein1024-608"),-        (0xb3ad, "skein1024-616"),-        (0xb3ae, "skein1024-624"),-        (0xb3af, "skein1024-632"),-        (0xb3b0, "skein1024-640"),-        (0xb3b1, "skein1024-648"),-        (0xb3b2, "skein1024-656"),-        (0xb3b3, "skein1024-664"),-        (0xb3b4, "skein1024-672"),-        (0xb3b5, "skein1024-680"),-        (0xb3b6, "skein1024-688"),-        (0xb3b7, "skein1024-696"),-        (0xb3b8, "skein1024-704"),-        (0xb3b9, "skein1024-712"),-        (0xb3ba, "skein1024-720"),-        (0xb3bb, "skein1024-728"),-        (0xb3bc, "skein1024-736"),-        (0xb3bd, "skein1024-744"),-        (0xb3be, "skein1024-752"),-        (0xb3bf, "skein1024-760"),-        (0xb3c0, "skein1024-768"),-        (0xb3c1, "skein1024-776"),-        (0xb3c2, "skein1024-784"),-        (0xb3c3, "skein1024-792"),-        (0xb3c4, "skein1024-800"),-        (0xb3c5, "skein1024-808"),-        (0xb3c6, "skein1024-816"),-        (0xb3c7, "skein1024-824"),-        (0xb3c8, "skein1024-832"),-        (0xb3c9, "skein1024-840"),-        (0xb3ca, "skein1024-848"),-        (0xb3cb, "skein1024-856"),-        (0xb3cc, "skein1024-864"),-        (0xb3cd, "skein1024-872"),-        (0xb3ce, "skein1024-880"),-        (0xb3cf, "skein1024-888"),-        (0xb3d0, "skein1024-896"),-        (0xb3d1, "skein1024-904"),-        (0xb3d2, "skein1024-912"),-        (0xb3d3, "skein1024-920"),-        (0xb3d4, "skein1024-928"),-        (0xb3d5, "skein1024-936"),-        (0xb3d6, "skein1024-944"),-        (0xb3d7, "skein1024-952"),-        (0xb3d8, "skein1024-960"),-        (0xb3d9, "skein1024-968"),-        (0xb3da, "skein1024-976"),-        (0xb3db, "skein1024-984"),-        (0xb3dc, "skein1024-992"),-        (0xb3dd, "skein1024-1000"),-        (0xb3de, "skein1024-1008"),-        (0xb3df, "skein1024-1016"),-        (0xb3e0, "skein1024-1024"),-        (0xb3e1, "xxh-32"),-        (0xb3e2, "xxh-64"),-        (0xb3e3, "xxh3-64"),-        (0xb3e4, "xxh3-128"),-        (0xb401, "poseidon-bls12_381-a2-fc1"),-        (0xb402, "poseidon-bls12_381-a2-fc1-sc"),-        (0xb403, "rdfc-1"),-        (0xb501, "ssz"),-        (0xb502, "ssz-sha2-256-bmt"),-        (0xb510, "sha2-256-chunked"),-        (0xb601, "json-jcs"),-        (0xb702, "bittorrent-pieces-root"),-        (0xcc01, "iscc"),-        (0xce11, "zeroxcert-imprint-256"),-        (0xd00d, "bcrypt-pbkdf"),-        (0xd0e7, "es256k"),-        (0xd0ea, "bls12_381-g1-sig"),-        (0xd0eb, "bls12_381-g2-sig"),-        (0xd0ed, "eddsa"),-        (0xd191, "eip-191"),-        (0xeb51, "jwk_jcs-pub"),-        (0xed20, "ed2k"),-        (0xf101, "fil-commitment-unsealed"),-        (0xf102, "fil-commitment-sealed"),-        (0x511e00, "shelter-contract-manifest"),-        (0x511e01, "shelter-contract-text"),-        (0x511e02, "shelter-contract-data"),-        (0x511e03, "shelter-file-manifest"),-        (0x511e04, "shelter-file-chunk"),-        (0x706c61, "plaintextv2"),-        (0x807124, "holochain-adr-v0"),-        (0x817124, "holochain-adr-v1"),-        (0x947124, "holochain-key-v0"),-        (0x957124, "holochain-key-v1"),-        (0xa27124, "holochain-sig-v0"),-        (0xa37124, "holochain-sig-v1"),-        (0xb19910, "skynet-ns"),-        (0xb29910, "arweave-ns"),-        (0xb39910, "subspace-ns"),-        (0xb49910, "kumandra-ns"),-        (0xb59910, "massa"),-        (0xb59911, "massa-mainnet"),-        (0xb59912, "massa-buildnet"),-        (0xb59913, "massa-deweb"),-        (0xb59914, "massa-gossip"),-        (0xb59915, "massa-mns"),-        (0xb59916, "massa-sc"),-        (0xb59917, "massa-gossip-id"),-        (0xd01200, "es256"),-        (0xd01201, "es384"),-        (0xd01202, "es512"),-        (0xd01205, "rs256"),-        (0xd01300, "es256k-msig"),-        (0xd01301, "bls12_381-g1-msig"),-        (0xd01302, "bls12_381-g2-msig"),-        (0xd01303, "eddsa-msig"),-        (0xd01304, "bls12_381-g1-share-msig"),-        (0xd01305, "bls12_381-g2-share-msig"),-        (0xd01306, "lamport-msig"),-        (0xd01307, "lamport-share-msig"),-        (0xd01308, "es256-msig"),-        (0xd01309, "es384-msig"),-        (0xd0130a, "es521-msig"),-        (0xd0130b, "rs256-msig"),-        (0xd02000, "scion")-  ]-+  ( MultiCodec (MultiCodec, multiCodecValue),+    resolveCodecValue,+    resolveCodecName,+    gitCommitHash,+    gitCommitDate,+  )+where++-- !!! WARNING: !!!+-- This file is generated! Don't edit it. Instead, use the scripts provided in+-- the python folder at the root of the git repository. The current file was+-- generated on: 2026-05-18 21:27:03.095413+00:00++import Data.BaseSystem (encoder)+import Data.BaseSystem.BinaryTranscoder (packValue)+import Data.BaseSystem.DigitSystem (base16lower)+import Data.Map (Map)+import Data.Map qualified as LazyMap+import Data.Maybe (fromMaybe)+import Data.Text qualified as Text+import MultiFormats.VarInt (VarInt)++-- | Represents MultiCodec code.+newtype MultiCodec = MultiCodec {multiCodecValue :: VarInt} deriving (Eq, Ord)++instance Show MultiCodec where+  show codec@(MultiCodec value) =+    let name = fromMaybe "<invalid codec>" $ resolveCodecName codec+        hexstring = "0x" ++ Text.unpack (encoder base16lower $ packValue value)+     in "MultiCodec(" ++ hexstring ++ ", " ++ quote name ++ ")"+    where+      -- Puts a String in double quotes.+      quote str = "\"" ++ str ++ "\""++-- | Resolves MultiCodec code from its string name.+resolveCodecValue :: String -> Maybe MultiCodec+resolveCodecValue name = MultiCodec <$> LazyMap.lookup name nameToCodec++-- | Resolves MultiCodec name from its numeric code.+resolveCodecName :: MultiCodec -> Maybe String+resolveCodecName (MultiCodec codec) = LazyMap.lookup codec codecToName++-- | The git hash for table.csv used to generate this file.+gitCommitHash :: String+gitCommitHash = "45c88b89ab909c0fac7c86dafe43ad72d1e8e8a9"++-- | This is the date the table.csv was commited.+gitCommitDate :: String+gitCommitDate = "2026-04-17 09:53:49 +0200"++nameToCodec :: Map String VarInt+nameToCodec =+  LazyMap.fromList+    [ ("identity", 0x00),+      ("cidv1", 0x01),+      ("cidv2", 0x02),+      ("cidv3", 0x03),+      ("ip4", 0x04),+      ("tcp", 0x06),+      ("sha1", 0x11),+      ("sha2-256", 0x12),+      ("sha2-512", 0x13),+      ("sha3-512", 0x14),+      ("sha3-384", 0x15),+      ("sha3-256", 0x16),+      ("sha3-224", 0x17),+      ("shake-128", 0x18),+      ("shake-256", 0x19),+      ("keccak-224", 0x1a),+      ("keccak-256", 0x1b),+      ("keccak-384", 0x1c),+      ("keccak-512", 0x1d),+      ("blake3", 0x1e),+      ("sha2-384", 0x20),+      ("dccp", 0x21),+      ("murmur3-x64-64", 0x22),+      ("murmur3-32", 0x23),+      ("ip6", 0x29),+      ("ip6zone", 0x2a),+      ("ipcidr", 0x2b),+      ("path", 0x2f),+      ("multicodec", 0x30),+      ("multihash", 0x31),+      ("multiaddr", 0x32),+      ("multibase", 0x33),+      ("varsig", 0x34),+      ("dns", 0x35),+      ("dns4", 0x36),+      ("dns6", 0x37),+      ("dnsaddr", 0x38),+      ("protobuf", 0x50),+      ("cbor", 0x51),+      ("raw", 0x55),+      ("dbl-sha2-256", 0x56),+      ("rlp", 0x60),+      ("bencode", 0x63),+      ("dag-pb", 0x70),+      ("dag-cbor", 0x71),+      ("libp2p-key", 0x72),+      ("git-raw", 0x78),+      ("torrent-info", 0x7b),+      ("torrent-file", 0x7c),+      ("blake3-hashseq", 0x80),+      ("leofcoin-block", 0x81),+      ("leofcoin-tx", 0x82),+      ("leofcoin-pr", 0x83),+      ("sctp", 0x84),+      ("dag-jose", 0x85),+      ("dag-cose", 0x86),+      ("lbry", 0x8c),+      ("eth-block", 0x90),+      ("eth-block-list", 0x91),+      ("eth-tx-trie", 0x92),+      ("eth-tx", 0x93),+      ("eth-tx-receipt-trie", 0x94),+      ("eth-tx-receipt", 0x95),+      ("eth-state-trie", 0x96),+      ("eth-account-snapshot", 0x97),+      ("eth-storage-trie", 0x98),+      ("eth-receipt-log-trie", 0x99),+      ("eth-receipt-log", 0x9a),+      ("aes-128", 0xa0),+      ("aes-192", 0xa1),+      ("aes-256", 0xa2),+      ("chacha-128", 0xa3),+      ("chacha-256", 0xa4),+      ("bitcoin-block", 0xb0),+      ("bitcoin-tx", 0xb1),+      ("bitcoin-witness-commitment", 0xb2),+      ("zcash-block", 0xc0),+      ("zcash-tx", 0xc1),+      ("caip-50", 0xca),+      ("streamid", 0xce),+      ("stellar-block", 0xd0),+      ("stellar-tx", 0xd1),+      ("md4", 0xd4),+      ("md5", 0xd5),+      ("decred-block", 0xe0),+      ("decred-tx", 0xe1),+      ("ipld", 0xe2),+      ("ipfs", 0xe3),+      ("swarm", 0xe4),+      ("ipns", 0xe5),+      ("zeronet", 0xe6),+      ("secp256k1-pub", 0xe7),+      ("dnslink", 0xe8),+      ("bls12_381-g1-pub", 0xea),+      ("bls12_381-g2-pub", 0xeb),+      ("x25519-pub", 0xec),+      ("ed25519-pub", 0xed),+      ("bls12_381-g1g2-pub", 0xee),+      ("sr25519-pub", 0xef),+      ("dash-block", 0xf0),+      ("dash-tx", 0xf1),+      ("swarm-manifest", 0xfa),+      ("swarm-feed", 0xfb),+      ("beeson", 0xfc),+      ("udp", 0x0111),+      ("webrtc-direct", 0x0118),+      ("webrtc", 0x0119),+      ("p2p-circuit", 0x0122),+      ("dag-json", 0x0129),+      ("udt", 0x012d),+      ("utp", 0x012e),+      ("crc32", 0x0132),+      ("crc64-ecma", 0x0164),+      ("crc64-nvme", 0x0165),+      ("unix", 0x0190),+      ("thread", 0x0196),+      ("p2p", 0x01a5),+      ("https", 0x01bb),+      ("onion", 0x01bc),+      ("onion3", 0x01bd),+      ("garlic64", 0x01be),+      ("garlic32", 0x01bf),+      ("tls", 0x01c0),+      ("sni", 0x01c1),+      ("noise", 0x01c6),+      ("shs", 0x01c8),+      ("quic", 0x01cc),+      ("quic-v1", 0x01cd),+      ("webtransport", 0x01d1),+      ("certhash", 0x01d2),+      ("ws", 0x01dd),+      ("wss", 0x01de),+      ("p2p-websocket-star", 0x01df),+      ("http", 0x01e0),+      ("http-path", 0x01e1),+      ("swhid-1-snp", 0x01f0),+      ("json", 0x0200),+      ("messagepack", 0x0201),+      ("car", 0x0202),+      ("x509-certificate", 0x0210),+      ("ipns-record", 0x0300),+      ("libp2p-peer-record", 0x0301),+      ("libp2p-relay-rsvp", 0x0302),+      ("memorytransport", 0x0309),+      ("car-index-sorted", 0x0400),+      ("car-multihash-index-sorted", 0x0401),+      ("transport-bitswap", 0x0900),+      ("transport-graphsync-filecoinv1", 0x0910),+      ("transport-ipfs-gateway-http", 0x0920),+      ("transport-filecoin-piece-http", 0x0930),+      ("multidid", 0x0d1d),+      ("fr32-sha256-trunc254-padbintree", 0x1011),+      ("sha2-256-trunc254-padded", 0x1012),+      ("sha2-224", 0x1013),+      ("sha2-512-224", 0x1014),+      ("sha2-512-256", 0x1015),+      ("murmur3-x64-128", 0x1022),+      ("ripemd-128", 0x1052),+      ("ripemd-160", 0x1053),+      ("ripemd-256", 0x1054),+      ("ripemd-320", 0x1055),+      ("x11", 0x1100),+      ("p256-pub", 0x1200),+      ("p384-pub", 0x1201),+      ("p521-pub", 0x1202),+      ("ed448-pub", 0x1203),+      ("x448-pub", 0x1204),+      ("rsa-pub", 0x1205),+      ("sm2-pub", 0x1206),+      ("vlad", 0x1207),+      ("provenance-log", 0x1208),+      ("provenance-log-entry", 0x1209),+      ("provenance-log-script", 0x120a),+      ("mlkem-512-pub", 0x120b),+      ("mlkem-768-pub", 0x120c),+      ("mlkem-1024-pub", 0x120d),+      ("mldsa-44-pub", 0x1210),+      ("mldsa-65-pub", 0x1211),+      ("mldsa-87-pub", 0x1212),+      ("slhdsa-sha2-128s-pub", 0x1220),+      ("slhdsa-shake-128s-pub", 0x1221),+      ("slhdsa-sha2-128f-pub", 0x1222),+      ("slhdsa-shake-128f-pub", 0x1223),+      ("slhdsa-sha2-192s-pub", 0x1224),+      ("slhdsa-shake-192s-pub", 0x1225),+      ("slhdsa-sha2-192f-pub", 0x1226),+      ("slhdsa-shake-192f-pub", 0x1227),+      ("slhdsa-sha2-256s-pub", 0x1228),+      ("slhdsa-shake-256s-pub", 0x1229),+      ("slhdsa-sha2-256f-pub", 0x122a),+      ("slhdsa-shake-256f-pub", 0x122b),+      ("multisig", 0x1239),+      ("multikey", 0x123a),+      ("nonce", 0x123b),+      ("ed25519-priv", 0x1300),+      ("secp256k1-priv", 0x1301),+      ("x25519-priv", 0x1302),+      ("sr25519-priv", 0x1303),+      ("rsa-priv", 0x1305),+      ("p256-priv", 0x1306),+      ("p384-priv", 0x1307),+      ("p521-priv", 0x1308),+      ("bls12_381-g1-priv", 0x1309),+      ("bls12_381-g2-priv", 0x130a),+      ("bls12_381-g1g2-priv", 0x130b),+      ("bls12_381-g1-pub-share", 0x130c),+      ("bls12_381-g2-pub-share", 0x130d),+      ("bls12_381-g1-priv-share", 0x130e),+      ("bls12_381-g2-priv-share", 0x130f),+      ("sm2-priv", 0x1310),+      ("ed448-priv", 0x1311),+      ("x448-priv", 0x1312),+      ("mlkem-512-priv", 0x1313),+      ("mlkem-768-priv", 0x1314),+      ("mlkem-1024-priv", 0x1315),+      ("jwk_jcs-priv", 0x1316),+      ("mldsa-44-priv", 0x1317),+      ("mldsa-65-priv", 0x1318),+      ("mldsa-87-priv", 0x1319),+      ("mldsa-44-priv-seed", 0x131a),+      ("mldsa-65-priv-seed", 0x131b),+      ("mldsa-87-priv-seed", 0x131c),+      ("bip340-pub", 0x1340),+      ("bip340-priv", 0x1341),+      ("lamport-sha3-512-pub", 0x1a14),+      ("lamport-sha3-384-pub", 0x1a15),+      ("lamport-sha3-256-pub", 0x1a16),+      ("lamport-sha3-512-priv", 0x1a24),+      ("lamport-sha3-384-priv", 0x1a25),+      ("lamport-sha3-256-priv", 0x1a26),+      ("lamport-sha3-512-priv-share", 0x1a34),+      ("lamport-sha3-384-priv-share", 0x1a35),+      ("lamport-sha3-256-priv-share", 0x1a36),+      ("lamport-sha3-512-sig", 0x1a44),+      ("lamport-sha3-384-sig", 0x1a45),+      ("lamport-sha3-256-sig", 0x1a46),+      ("lamport-sha3-512-sig-share", 0x1a54),+      ("lamport-sha3-384-sig-share", 0x1a55),+      ("lamport-sha3-256-sig-share", 0x1a56),+      ("kt-128", 0x1d01),+      ("kt-256", 0x1d02),+      ("aes-gcm-256", 0x2000),+      ("silverpine", 0x3f42),+      ("sm3-256", 0x534d),+      ("sha256a", 0x7012),+      ("chacha20-poly1305", 0xa000),+      ("blake2b-8", 0xb201),+      ("blake2b-16", 0xb202),+      ("blake2b-24", 0xb203),+      ("blake2b-32", 0xb204),+      ("blake2b-40", 0xb205),+      ("blake2b-48", 0xb206),+      ("blake2b-56", 0xb207),+      ("blake2b-64", 0xb208),+      ("blake2b-72", 0xb209),+      ("blake2b-80", 0xb20a),+      ("blake2b-88", 0xb20b),+      ("blake2b-96", 0xb20c),+      ("blake2b-104", 0xb20d),+      ("blake2b-112", 0xb20e),+      ("blake2b-120", 0xb20f),+      ("blake2b-128", 0xb210),+      ("blake2b-136", 0xb211),+      ("blake2b-144", 0xb212),+      ("blake2b-152", 0xb213),+      ("blake2b-160", 0xb214),+      ("blake2b-168", 0xb215),+      ("blake2b-176", 0xb216),+      ("blake2b-184", 0xb217),+      ("blake2b-192", 0xb218),+      ("blake2b-200", 0xb219),+      ("blake2b-208", 0xb21a),+      ("blake2b-216", 0xb21b),+      ("blake2b-224", 0xb21c),+      ("blake2b-232", 0xb21d),+      ("blake2b-240", 0xb21e),+      ("blake2b-248", 0xb21f),+      ("blake2b-256", 0xb220),+      ("blake2b-264", 0xb221),+      ("blake2b-272", 0xb222),+      ("blake2b-280", 0xb223),+      ("blake2b-288", 0xb224),+      ("blake2b-296", 0xb225),+      ("blake2b-304", 0xb226),+      ("blake2b-312", 0xb227),+      ("blake2b-320", 0xb228),+      ("blake2b-328", 0xb229),+      ("blake2b-336", 0xb22a),+      ("blake2b-344", 0xb22b),+      ("blake2b-352", 0xb22c),+      ("blake2b-360", 0xb22d),+      ("blake2b-368", 0xb22e),+      ("blake2b-376", 0xb22f),+      ("blake2b-384", 0xb230),+      ("blake2b-392", 0xb231),+      ("blake2b-400", 0xb232),+      ("blake2b-408", 0xb233),+      ("blake2b-416", 0xb234),+      ("blake2b-424", 0xb235),+      ("blake2b-432", 0xb236),+      ("blake2b-440", 0xb237),+      ("blake2b-448", 0xb238),+      ("blake2b-456", 0xb239),+      ("blake2b-464", 0xb23a),+      ("blake2b-472", 0xb23b),+      ("blake2b-480", 0xb23c),+      ("blake2b-488", 0xb23d),+      ("blake2b-496", 0xb23e),+      ("blake2b-504", 0xb23f),+      ("blake2b-512", 0xb240),+      ("blake2s-8", 0xb241),+      ("blake2s-16", 0xb242),+      ("blake2s-24", 0xb243),+      ("blake2s-32", 0xb244),+      ("blake2s-40", 0xb245),+      ("blake2s-48", 0xb246),+      ("blake2s-56", 0xb247),+      ("blake2s-64", 0xb248),+      ("blake2s-72", 0xb249),+      ("blake2s-80", 0xb24a),+      ("blake2s-88", 0xb24b),+      ("blake2s-96", 0xb24c),+      ("blake2s-104", 0xb24d),+      ("blake2s-112", 0xb24e),+      ("blake2s-120", 0xb24f),+      ("blake2s-128", 0xb250),+      ("blake2s-136", 0xb251),+      ("blake2s-144", 0xb252),+      ("blake2s-152", 0xb253),+      ("blake2s-160", 0xb254),+      ("blake2s-168", 0xb255),+      ("blake2s-176", 0xb256),+      ("blake2s-184", 0xb257),+      ("blake2s-192", 0xb258),+      ("blake2s-200", 0xb259),+      ("blake2s-208", 0xb25a),+      ("blake2s-216", 0xb25b),+      ("blake2s-224", 0xb25c),+      ("blake2s-232", 0xb25d),+      ("blake2s-240", 0xb25e),+      ("blake2s-248", 0xb25f),+      ("blake2s-256", 0xb260),+      ("skein256-8", 0xb301),+      ("skein256-16", 0xb302),+      ("skein256-24", 0xb303),+      ("skein256-32", 0xb304),+      ("skein256-40", 0xb305),+      ("skein256-48", 0xb306),+      ("skein256-56", 0xb307),+      ("skein256-64", 0xb308),+      ("skein256-72", 0xb309),+      ("skein256-80", 0xb30a),+      ("skein256-88", 0xb30b),+      ("skein256-96", 0xb30c),+      ("skein256-104", 0xb30d),+      ("skein256-112", 0xb30e),+      ("skein256-120", 0xb30f),+      ("skein256-128", 0xb310),+      ("skein256-136", 0xb311),+      ("skein256-144", 0xb312),+      ("skein256-152", 0xb313),+      ("skein256-160", 0xb314),+      ("skein256-168", 0xb315),+      ("skein256-176", 0xb316),+      ("skein256-184", 0xb317),+      ("skein256-192", 0xb318),+      ("skein256-200", 0xb319),+      ("skein256-208", 0xb31a),+      ("skein256-216", 0xb31b),+      ("skein256-224", 0xb31c),+      ("skein256-232", 0xb31d),+      ("skein256-240", 0xb31e),+      ("skein256-248", 0xb31f),+      ("skein256-256", 0xb320),+      ("skein512-8", 0xb321),+      ("skein512-16", 0xb322),+      ("skein512-24", 0xb323),+      ("skein512-32", 0xb324),+      ("skein512-40", 0xb325),+      ("skein512-48", 0xb326),+      ("skein512-56", 0xb327),+      ("skein512-64", 0xb328),+      ("skein512-72", 0xb329),+      ("skein512-80", 0xb32a),+      ("skein512-88", 0xb32b),+      ("skein512-96", 0xb32c),+      ("skein512-104", 0xb32d),+      ("skein512-112", 0xb32e),+      ("skein512-120", 0xb32f),+      ("skein512-128", 0xb330),+      ("skein512-136", 0xb331),+      ("skein512-144", 0xb332),+      ("skein512-152", 0xb333),+      ("skein512-160", 0xb334),+      ("skein512-168", 0xb335),+      ("skein512-176", 0xb336),+      ("skein512-184", 0xb337),+      ("skein512-192", 0xb338),+      ("skein512-200", 0xb339),+      ("skein512-208", 0xb33a),+      ("skein512-216", 0xb33b),+      ("skein512-224", 0xb33c),+      ("skein512-232", 0xb33d),+      ("skein512-240", 0xb33e),+      ("skein512-248", 0xb33f),+      ("skein512-256", 0xb340),+      ("skein512-264", 0xb341),+      ("skein512-272", 0xb342),+      ("skein512-280", 0xb343),+      ("skein512-288", 0xb344),+      ("skein512-296", 0xb345),+      ("skein512-304", 0xb346),+      ("skein512-312", 0xb347),+      ("skein512-320", 0xb348),+      ("skein512-328", 0xb349),+      ("skein512-336", 0xb34a),+      ("skein512-344", 0xb34b),+      ("skein512-352", 0xb34c),+      ("skein512-360", 0xb34d),+      ("skein512-368", 0xb34e),+      ("skein512-376", 0xb34f),+      ("skein512-384", 0xb350),+      ("skein512-392", 0xb351),+      ("skein512-400", 0xb352),+      ("skein512-408", 0xb353),+      ("skein512-416", 0xb354),+      ("skein512-424", 0xb355),+      ("skein512-432", 0xb356),+      ("skein512-440", 0xb357),+      ("skein512-448", 0xb358),+      ("skein512-456", 0xb359),+      ("skein512-464", 0xb35a),+      ("skein512-472", 0xb35b),+      ("skein512-480", 0xb35c),+      ("skein512-488", 0xb35d),+      ("skein512-496", 0xb35e),+      ("skein512-504", 0xb35f),+      ("skein512-512", 0xb360),+      ("skein1024-8", 0xb361),+      ("skein1024-16", 0xb362),+      ("skein1024-24", 0xb363),+      ("skein1024-32", 0xb364),+      ("skein1024-40", 0xb365),+      ("skein1024-48", 0xb366),+      ("skein1024-56", 0xb367),+      ("skein1024-64", 0xb368),+      ("skein1024-72", 0xb369),+      ("skein1024-80", 0xb36a),+      ("skein1024-88", 0xb36b),+      ("skein1024-96", 0xb36c),+      ("skein1024-104", 0xb36d),+      ("skein1024-112", 0xb36e),+      ("skein1024-120", 0xb36f),+      ("skein1024-128", 0xb370),+      ("skein1024-136", 0xb371),+      ("skein1024-144", 0xb372),+      ("skein1024-152", 0xb373),+      ("skein1024-160", 0xb374),+      ("skein1024-168", 0xb375),+      ("skein1024-176", 0xb376),+      ("skein1024-184", 0xb377),+      ("skein1024-192", 0xb378),+      ("skein1024-200", 0xb379),+      ("skein1024-208", 0xb37a),+      ("skein1024-216", 0xb37b),+      ("skein1024-224", 0xb37c),+      ("skein1024-232", 0xb37d),+      ("skein1024-240", 0xb37e),+      ("skein1024-248", 0xb37f),+      ("skein1024-256", 0xb380),+      ("skein1024-264", 0xb381),+      ("skein1024-272", 0xb382),+      ("skein1024-280", 0xb383),+      ("skein1024-288", 0xb384),+      ("skein1024-296", 0xb385),+      ("skein1024-304", 0xb386),+      ("skein1024-312", 0xb387),+      ("skein1024-320", 0xb388),+      ("skein1024-328", 0xb389),+      ("skein1024-336", 0xb38a),+      ("skein1024-344", 0xb38b),+      ("skein1024-352", 0xb38c),+      ("skein1024-360", 0xb38d),+      ("skein1024-368", 0xb38e),+      ("skein1024-376", 0xb38f),+      ("skein1024-384", 0xb390),+      ("skein1024-392", 0xb391),+      ("skein1024-400", 0xb392),+      ("skein1024-408", 0xb393),+      ("skein1024-416", 0xb394),+      ("skein1024-424", 0xb395),+      ("skein1024-432", 0xb396),+      ("skein1024-440", 0xb397),+      ("skein1024-448", 0xb398),+      ("skein1024-456", 0xb399),+      ("skein1024-464", 0xb39a),+      ("skein1024-472", 0xb39b),+      ("skein1024-480", 0xb39c),+      ("skein1024-488", 0xb39d),+      ("skein1024-496", 0xb39e),+      ("skein1024-504", 0xb39f),+      ("skein1024-512", 0xb3a0),+      ("skein1024-520", 0xb3a1),+      ("skein1024-528", 0xb3a2),+      ("skein1024-536", 0xb3a3),+      ("skein1024-544", 0xb3a4),+      ("skein1024-552", 0xb3a5),+      ("skein1024-560", 0xb3a6),+      ("skein1024-568", 0xb3a7),+      ("skein1024-576", 0xb3a8),+      ("skein1024-584", 0xb3a9),+      ("skein1024-592", 0xb3aa),+      ("skein1024-600", 0xb3ab),+      ("skein1024-608", 0xb3ac),+      ("skein1024-616", 0xb3ad),+      ("skein1024-624", 0xb3ae),+      ("skein1024-632", 0xb3af),+      ("skein1024-640", 0xb3b0),+      ("skein1024-648", 0xb3b1),+      ("skein1024-656", 0xb3b2),+      ("skein1024-664", 0xb3b3),+      ("skein1024-672", 0xb3b4),+      ("skein1024-680", 0xb3b5),+      ("skein1024-688", 0xb3b6),+      ("skein1024-696", 0xb3b7),+      ("skein1024-704", 0xb3b8),+      ("skein1024-712", 0xb3b9),+      ("skein1024-720", 0xb3ba),+      ("skein1024-728", 0xb3bb),+      ("skein1024-736", 0xb3bc),+      ("skein1024-744", 0xb3bd),+      ("skein1024-752", 0xb3be),+      ("skein1024-760", 0xb3bf),+      ("skein1024-768", 0xb3c0),+      ("skein1024-776", 0xb3c1),+      ("skein1024-784", 0xb3c2),+      ("skein1024-792", 0xb3c3),+      ("skein1024-800", 0xb3c4),+      ("skein1024-808", 0xb3c5),+      ("skein1024-816", 0xb3c6),+      ("skein1024-824", 0xb3c7),+      ("skein1024-832", 0xb3c8),+      ("skein1024-840", 0xb3c9),+      ("skein1024-848", 0xb3ca),+      ("skein1024-856", 0xb3cb),+      ("skein1024-864", 0xb3cc),+      ("skein1024-872", 0xb3cd),+      ("skein1024-880", 0xb3ce),+      ("skein1024-888", 0xb3cf),+      ("skein1024-896", 0xb3d0),+      ("skein1024-904", 0xb3d1),+      ("skein1024-912", 0xb3d2),+      ("skein1024-920", 0xb3d3),+      ("skein1024-928", 0xb3d4),+      ("skein1024-936", 0xb3d5),+      ("skein1024-944", 0xb3d6),+      ("skein1024-952", 0xb3d7),+      ("skein1024-960", 0xb3d8),+      ("skein1024-968", 0xb3d9),+      ("skein1024-976", 0xb3da),+      ("skein1024-984", 0xb3db),+      ("skein1024-992", 0xb3dc),+      ("skein1024-1000", 0xb3dd),+      ("skein1024-1008", 0xb3de),+      ("skein1024-1016", 0xb3df),+      ("skein1024-1024", 0xb3e0),+      ("xxh-32", 0xb3e1),+      ("xxh-64", 0xb3e2),+      ("xxh3-64", 0xb3e3),+      ("xxh3-128", 0xb3e4),+      ("poseidon-bls12_381-a2-fc1", 0xb401),+      ("poseidon-bls12_381-a2-fc1-sc", 0xb402),+      ("rdfc-1", 0xb403),+      ("ssz", 0xb501),+      ("ssz-sha2-256-bmt", 0xb502),+      ("sha2-256-chunked", 0xb510),+      ("json-jcs", 0xb601),+      ("bittorrent-pieces-root", 0xb702),+      ("iscc", 0xcc01),+      ("zeroxcert-imprint-256", 0xce11),+      ("bcrypt-pbkdf", 0xd00d),+      ("es256k", 0xd0e7),+      ("bls12_381-g1-sig", 0xd0ea),+      ("bls12_381-g2-sig", 0xd0eb),+      ("eddsa", 0xd0ed),+      ("eip-191", 0xd191),+      ("jwk_jcs-pub", 0xeb51),+      ("ed2k", 0xed20),+      ("fil-commitment-unsealed", 0xf101),+      ("fil-commitment-sealed", 0xf102),+      ("shelter-contract-manifest", 0x511e00),+      ("shelter-contract-text", 0x511e01),+      ("shelter-contract-data", 0x511e02),+      ("shelter-file-manifest", 0x511e03),+      ("shelter-file-chunk", 0x511e04),+      ("plaintextv2", 0x706c61),+      ("holochain-adr-v0", 0x807124),+      ("holochain-adr-v1", 0x817124),+      ("holochain-key-v0", 0x947124),+      ("holochain-key-v1", 0x957124),+      ("holochain-sig-v0", 0xa27124),+      ("holochain-sig-v1", 0xa37124),+      ("skynet-ns", 0xb19910),+      ("arweave-ns", 0xb29910),+      ("subspace-ns", 0xb39910),+      ("kumandra-ns", 0xb49910),+      ("massa", 0xb59910),+      ("massa-mainnet", 0xb59911),+      ("massa-buildnet", 0xb59912),+      ("massa-deweb", 0xb59913),+      ("massa-gossip", 0xb59914),+      ("massa-mns", 0xb59915),+      ("massa-sc", 0xb59916),+      ("massa-gossip-id", 0xb59917),+      ("adnl", 0xb69910),+      ("es256", 0xd01200),+      ("es384", 0xd01201),+      ("es512", 0xd01202),+      ("rs256", 0xd01205),+      ("bip340", 0xd01206),+      ("es256k-msig", 0xd01300),+      ("bls12_381-g1-msig", 0xd01301),+      ("bls12_381-g2-msig", 0xd01302),+      ("eddsa-msig", 0xd01303),+      ("bls12_381-g1-share-msig", 0xd01304),+      ("bls12_381-g2-share-msig", 0xd01305),+      ("lamport-msig", 0xd01306),+      ("lamport-share-msig", 0xd01307),+      ("es256-msig", 0xd01308),+      ("es384-msig", 0xd01309),+      ("es521-msig", 0xd0130a),+      ("rs256-msig", 0xd0130b),+      ("scion", 0xd02000)+    ]++codecToName :: Map VarInt String+codecToName =+  LazyMap.fromList+    [ (0x00, "identity"),+      (0x01, "cidv1"),+      (0x02, "cidv2"),+      (0x03, "cidv3"),+      (0x04, "ip4"),+      (0x06, "tcp"),+      (0x11, "sha1"),+      (0x12, "sha2-256"),+      (0x13, "sha2-512"),+      (0x14, "sha3-512"),+      (0x15, "sha3-384"),+      (0x16, "sha3-256"),+      (0x17, "sha3-224"),+      (0x18, "shake-128"),+      (0x19, "shake-256"),+      (0x1a, "keccak-224"),+      (0x1b, "keccak-256"),+      (0x1c, "keccak-384"),+      (0x1d, "keccak-512"),+      (0x1e, "blake3"),+      (0x20, "sha2-384"),+      (0x21, "dccp"),+      (0x22, "murmur3-x64-64"),+      (0x23, "murmur3-32"),+      (0x29, "ip6"),+      (0x2a, "ip6zone"),+      (0x2b, "ipcidr"),+      (0x2f, "path"),+      (0x30, "multicodec"),+      (0x31, "multihash"),+      (0x32, "multiaddr"),+      (0x33, "multibase"),+      (0x34, "varsig"),+      (0x35, "dns"),+      (0x36, "dns4"),+      (0x37, "dns6"),+      (0x38, "dnsaddr"),+      (0x50, "protobuf"),+      (0x51, "cbor"),+      (0x55, "raw"),+      (0x56, "dbl-sha2-256"),+      (0x60, "rlp"),+      (0x63, "bencode"),+      (0x70, "dag-pb"),+      (0x71, "dag-cbor"),+      (0x72, "libp2p-key"),+      (0x78, "git-raw"),+      (0x7b, "torrent-info"),+      (0x7c, "torrent-file"),+      (0x80, "blake3-hashseq"),+      (0x81, "leofcoin-block"),+      (0x82, "leofcoin-tx"),+      (0x83, "leofcoin-pr"),+      (0x84, "sctp"),+      (0x85, "dag-jose"),+      (0x86, "dag-cose"),+      (0x8c, "lbry"),+      (0x90, "eth-block"),+      (0x91, "eth-block-list"),+      (0x92, "eth-tx-trie"),+      (0x93, "eth-tx"),+      (0x94, "eth-tx-receipt-trie"),+      (0x95, "eth-tx-receipt"),+      (0x96, "eth-state-trie"),+      (0x97, "eth-account-snapshot"),+      (0x98, "eth-storage-trie"),+      (0x99, "eth-receipt-log-trie"),+      (0x9a, "eth-receipt-log"),+      (0xa0, "aes-128"),+      (0xa1, "aes-192"),+      (0xa2, "aes-256"),+      (0xa3, "chacha-128"),+      (0xa4, "chacha-256"),+      (0xb0, "bitcoin-block"),+      (0xb1, "bitcoin-tx"),+      (0xb2, "bitcoin-witness-commitment"),+      (0xc0, "zcash-block"),+      (0xc1, "zcash-tx"),+      (0xca, "caip-50"),+      (0xce, "streamid"),+      (0xd0, "stellar-block"),+      (0xd1, "stellar-tx"),+      (0xd4, "md4"),+      (0xd5, "md5"),+      (0xe0, "decred-block"),+      (0xe1, "decred-tx"),+      (0xe2, "ipld"),+      (0xe3, "ipfs"),+      (0xe4, "swarm"),+      (0xe5, "ipns"),+      (0xe6, "zeronet"),+      (0xe7, "secp256k1-pub"),+      (0xe8, "dnslink"),+      (0xea, "bls12_381-g1-pub"),+      (0xeb, "bls12_381-g2-pub"),+      (0xec, "x25519-pub"),+      (0xed, "ed25519-pub"),+      (0xee, "bls12_381-g1g2-pub"),+      (0xef, "sr25519-pub"),+      (0xf0, "dash-block"),+      (0xf1, "dash-tx"),+      (0xfa, "swarm-manifest"),+      (0xfb, "swarm-feed"),+      (0xfc, "beeson"),+      (0x0111, "udp"),+      (0x0118, "webrtc-direct"),+      (0x0119, "webrtc"),+      (0x0122, "p2p-circuit"),+      (0x0129, "dag-json"),+      (0x012d, "udt"),+      (0x012e, "utp"),+      (0x0132, "crc32"),+      (0x0164, "crc64-ecma"),+      (0x0165, "crc64-nvme"),+      (0x0190, "unix"),+      (0x0196, "thread"),+      (0x01a5, "p2p"),+      (0x01bb, "https"),+      (0x01bc, "onion"),+      (0x01bd, "onion3"),+      (0x01be, "garlic64"),+      (0x01bf, "garlic32"),+      (0x01c0, "tls"),+      (0x01c1, "sni"),+      (0x01c6, "noise"),+      (0x01c8, "shs"),+      (0x01cc, "quic"),+      (0x01cd, "quic-v1"),+      (0x01d1, "webtransport"),+      (0x01d2, "certhash"),+      (0x01dd, "ws"),+      (0x01de, "wss"),+      (0x01df, "p2p-websocket-star"),+      (0x01e0, "http"),+      (0x01e1, "http-path"),+      (0x01f0, "swhid-1-snp"),+      (0x0200, "json"),+      (0x0201, "messagepack"),+      (0x0202, "car"),+      (0x0210, "x509-certificate"),+      (0x0300, "ipns-record"),+      (0x0301, "libp2p-peer-record"),+      (0x0302, "libp2p-relay-rsvp"),+      (0x0309, "memorytransport"),+      (0x0400, "car-index-sorted"),+      (0x0401, "car-multihash-index-sorted"),+      (0x0900, "transport-bitswap"),+      (0x0910, "transport-graphsync-filecoinv1"),+      (0x0920, "transport-ipfs-gateway-http"),+      (0x0930, "transport-filecoin-piece-http"),+      (0x0d1d, "multidid"),+      (0x1011, "fr32-sha256-trunc254-padbintree"),+      (0x1012, "sha2-256-trunc254-padded"),+      (0x1013, "sha2-224"),+      (0x1014, "sha2-512-224"),+      (0x1015, "sha2-512-256"),+      (0x1022, "murmur3-x64-128"),+      (0x1052, "ripemd-128"),+      (0x1053, "ripemd-160"),+      (0x1054, "ripemd-256"),+      (0x1055, "ripemd-320"),+      (0x1100, "x11"),+      (0x1200, "p256-pub"),+      (0x1201, "p384-pub"),+      (0x1202, "p521-pub"),+      (0x1203, "ed448-pub"),+      (0x1204, "x448-pub"),+      (0x1205, "rsa-pub"),+      (0x1206, "sm2-pub"),+      (0x1207, "vlad"),+      (0x1208, "provenance-log"),+      (0x1209, "provenance-log-entry"),+      (0x120a, "provenance-log-script"),+      (0x120b, "mlkem-512-pub"),+      (0x120c, "mlkem-768-pub"),+      (0x120d, "mlkem-1024-pub"),+      (0x1210, "mldsa-44-pub"),+      (0x1211, "mldsa-65-pub"),+      (0x1212, "mldsa-87-pub"),+      (0x1220, "slhdsa-sha2-128s-pub"),+      (0x1221, "slhdsa-shake-128s-pub"),+      (0x1222, "slhdsa-sha2-128f-pub"),+      (0x1223, "slhdsa-shake-128f-pub"),+      (0x1224, "slhdsa-sha2-192s-pub"),+      (0x1225, "slhdsa-shake-192s-pub"),+      (0x1226, "slhdsa-sha2-192f-pub"),+      (0x1227, "slhdsa-shake-192f-pub"),+      (0x1228, "slhdsa-sha2-256s-pub"),+      (0x1229, "slhdsa-shake-256s-pub"),+      (0x122a, "slhdsa-sha2-256f-pub"),+      (0x122b, "slhdsa-shake-256f-pub"),+      (0x1239, "multisig"),+      (0x123a, "multikey"),+      (0x123b, "nonce"),+      (0x1300, "ed25519-priv"),+      (0x1301, "secp256k1-priv"),+      (0x1302, "x25519-priv"),+      (0x1303, "sr25519-priv"),+      (0x1305, "rsa-priv"),+      (0x1306, "p256-priv"),+      (0x1307, "p384-priv"),+      (0x1308, "p521-priv"),+      (0x1309, "bls12_381-g1-priv"),+      (0x130a, "bls12_381-g2-priv"),+      (0x130b, "bls12_381-g1g2-priv"),+      (0x130c, "bls12_381-g1-pub-share"),+      (0x130d, "bls12_381-g2-pub-share"),+      (0x130e, "bls12_381-g1-priv-share"),+      (0x130f, "bls12_381-g2-priv-share"),+      (0x1310, "sm2-priv"),+      (0x1311, "ed448-priv"),+      (0x1312, "x448-priv"),+      (0x1313, "mlkem-512-priv"),+      (0x1314, "mlkem-768-priv"),+      (0x1315, "mlkem-1024-priv"),+      (0x1316, "jwk_jcs-priv"),+      (0x1317, "mldsa-44-priv"),+      (0x1318, "mldsa-65-priv"),+      (0x1319, "mldsa-87-priv"),+      (0x131a, "mldsa-44-priv-seed"),+      (0x131b, "mldsa-65-priv-seed"),+      (0x131c, "mldsa-87-priv-seed"),+      (0x1340, "bip340-pub"),+      (0x1341, "bip340-priv"),+      (0x1a14, "lamport-sha3-512-pub"),+      (0x1a15, "lamport-sha3-384-pub"),+      (0x1a16, "lamport-sha3-256-pub"),+      (0x1a24, "lamport-sha3-512-priv"),+      (0x1a25, "lamport-sha3-384-priv"),+      (0x1a26, "lamport-sha3-256-priv"),+      (0x1a34, "lamport-sha3-512-priv-share"),+      (0x1a35, "lamport-sha3-384-priv-share"),+      (0x1a36, "lamport-sha3-256-priv-share"),+      (0x1a44, "lamport-sha3-512-sig"),+      (0x1a45, "lamport-sha3-384-sig"),+      (0x1a46, "lamport-sha3-256-sig"),+      (0x1a54, "lamport-sha3-512-sig-share"),+      (0x1a55, "lamport-sha3-384-sig-share"),+      (0x1a56, "lamport-sha3-256-sig-share"),+      (0x1d01, "kt-128"),+      (0x1d02, "kt-256"),+      (0x2000, "aes-gcm-256"),+      (0x3f42, "silverpine"),+      (0x534d, "sm3-256"),+      (0x7012, "sha256a"),+      (0xa000, "chacha20-poly1305"),+      (0xb201, "blake2b-8"),+      (0xb202, "blake2b-16"),+      (0xb203, "blake2b-24"),+      (0xb204, "blake2b-32"),+      (0xb205, "blake2b-40"),+      (0xb206, "blake2b-48"),+      (0xb207, "blake2b-56"),+      (0xb208, "blake2b-64"),+      (0xb209, "blake2b-72"),+      (0xb20a, "blake2b-80"),+      (0xb20b, "blake2b-88"),+      (0xb20c, "blake2b-96"),+      (0xb20d, "blake2b-104"),+      (0xb20e, "blake2b-112"),+      (0xb20f, "blake2b-120"),+      (0xb210, "blake2b-128"),+      (0xb211, "blake2b-136"),+      (0xb212, "blake2b-144"),+      (0xb213, "blake2b-152"),+      (0xb214, "blake2b-160"),+      (0xb215, "blake2b-168"),+      (0xb216, "blake2b-176"),+      (0xb217, "blake2b-184"),+      (0xb218, "blake2b-192"),+      (0xb219, "blake2b-200"),+      (0xb21a, "blake2b-208"),+      (0xb21b, "blake2b-216"),+      (0xb21c, "blake2b-224"),+      (0xb21d, "blake2b-232"),+      (0xb21e, "blake2b-240"),+      (0xb21f, "blake2b-248"),+      (0xb220, "blake2b-256"),+      (0xb221, "blake2b-264"),+      (0xb222, "blake2b-272"),+      (0xb223, "blake2b-280"),+      (0xb224, "blake2b-288"),+      (0xb225, "blake2b-296"),+      (0xb226, "blake2b-304"),+      (0xb227, "blake2b-312"),+      (0xb228, "blake2b-320"),+      (0xb229, "blake2b-328"),+      (0xb22a, "blake2b-336"),+      (0xb22b, "blake2b-344"),+      (0xb22c, "blake2b-352"),+      (0xb22d, "blake2b-360"),+      (0xb22e, "blake2b-368"),+      (0xb22f, "blake2b-376"),+      (0xb230, "blake2b-384"),+      (0xb231, "blake2b-392"),+      (0xb232, "blake2b-400"),+      (0xb233, "blake2b-408"),+      (0xb234, "blake2b-416"),+      (0xb235, "blake2b-424"),+      (0xb236, "blake2b-432"),+      (0xb237, "blake2b-440"),+      (0xb238, "blake2b-448"),+      (0xb239, "blake2b-456"),+      (0xb23a, "blake2b-464"),+      (0xb23b, "blake2b-472"),+      (0xb23c, "blake2b-480"),+      (0xb23d, "blake2b-488"),+      (0xb23e, "blake2b-496"),+      (0xb23f, "blake2b-504"),+      (0xb240, "blake2b-512"),+      (0xb241, "blake2s-8"),+      (0xb242, "blake2s-16"),+      (0xb243, "blake2s-24"),+      (0xb244, "blake2s-32"),+      (0xb245, "blake2s-40"),+      (0xb246, "blake2s-48"),+      (0xb247, "blake2s-56"),+      (0xb248, "blake2s-64"),+      (0xb249, "blake2s-72"),+      (0xb24a, "blake2s-80"),+      (0xb24b, "blake2s-88"),+      (0xb24c, "blake2s-96"),+      (0xb24d, "blake2s-104"),+      (0xb24e, "blake2s-112"),+      (0xb24f, "blake2s-120"),+      (0xb250, "blake2s-128"),+      (0xb251, "blake2s-136"),+      (0xb252, "blake2s-144"),+      (0xb253, "blake2s-152"),+      (0xb254, "blake2s-160"),+      (0xb255, "blake2s-168"),+      (0xb256, "blake2s-176"),+      (0xb257, "blake2s-184"),+      (0xb258, "blake2s-192"),+      (0xb259, "blake2s-200"),+      (0xb25a, "blake2s-208"),+      (0xb25b, "blake2s-216"),+      (0xb25c, "blake2s-224"),+      (0xb25d, "blake2s-232"),+      (0xb25e, "blake2s-240"),+      (0xb25f, "blake2s-248"),+      (0xb260, "blake2s-256"),+      (0xb301, "skein256-8"),+      (0xb302, "skein256-16"),+      (0xb303, "skein256-24"),+      (0xb304, "skein256-32"),+      (0xb305, "skein256-40"),+      (0xb306, "skein256-48"),+      (0xb307, "skein256-56"),+      (0xb308, "skein256-64"),+      (0xb309, "skein256-72"),+      (0xb30a, "skein256-80"),+      (0xb30b, "skein256-88"),+      (0xb30c, "skein256-96"),+      (0xb30d, "skein256-104"),+      (0xb30e, "skein256-112"),+      (0xb30f, "skein256-120"),+      (0xb310, "skein256-128"),+      (0xb311, "skein256-136"),+      (0xb312, "skein256-144"),+      (0xb313, "skein256-152"),+      (0xb314, "skein256-160"),+      (0xb315, "skein256-168"),+      (0xb316, "skein256-176"),+      (0xb317, "skein256-184"),+      (0xb318, "skein256-192"),+      (0xb319, "skein256-200"),+      (0xb31a, "skein256-208"),+      (0xb31b, "skein256-216"),+      (0xb31c, "skein256-224"),+      (0xb31d, "skein256-232"),+      (0xb31e, "skein256-240"),+      (0xb31f, "skein256-248"),+      (0xb320, "skein256-256"),+      (0xb321, "skein512-8"),+      (0xb322, "skein512-16"),+      (0xb323, "skein512-24"),+      (0xb324, "skein512-32"),+      (0xb325, "skein512-40"),+      (0xb326, "skein512-48"),+      (0xb327, "skein512-56"),+      (0xb328, "skein512-64"),+      (0xb329, "skein512-72"),+      (0xb32a, "skein512-80"),+      (0xb32b, "skein512-88"),+      (0xb32c, "skein512-96"),+      (0xb32d, "skein512-104"),+      (0xb32e, "skein512-112"),+      (0xb32f, "skein512-120"),+      (0xb330, "skein512-128"),+      (0xb331, "skein512-136"),+      (0xb332, "skein512-144"),+      (0xb333, "skein512-152"),+      (0xb334, "skein512-160"),+      (0xb335, "skein512-168"),+      (0xb336, "skein512-176"),+      (0xb337, "skein512-184"),+      (0xb338, "skein512-192"),+      (0xb339, "skein512-200"),+      (0xb33a, "skein512-208"),+      (0xb33b, "skein512-216"),+      (0xb33c, "skein512-224"),+      (0xb33d, "skein512-232"),+      (0xb33e, "skein512-240"),+      (0xb33f, "skein512-248"),+      (0xb340, "skein512-256"),+      (0xb341, "skein512-264"),+      (0xb342, "skein512-272"),+      (0xb343, "skein512-280"),+      (0xb344, "skein512-288"),+      (0xb345, "skein512-296"),+      (0xb346, "skein512-304"),+      (0xb347, "skein512-312"),+      (0xb348, "skein512-320"),+      (0xb349, "skein512-328"),+      (0xb34a, "skein512-336"),+      (0xb34b, "skein512-344"),+      (0xb34c, "skein512-352"),+      (0xb34d, "skein512-360"),+      (0xb34e, "skein512-368"),+      (0xb34f, "skein512-376"),+      (0xb350, "skein512-384"),+      (0xb351, "skein512-392"),+      (0xb352, "skein512-400"),+      (0xb353, "skein512-408"),+      (0xb354, "skein512-416"),+      (0xb355, "skein512-424"),+      (0xb356, "skein512-432"),+      (0xb357, "skein512-440"),+      (0xb358, "skein512-448"),+      (0xb359, "skein512-456"),+      (0xb35a, "skein512-464"),+      (0xb35b, "skein512-472"),+      (0xb35c, "skein512-480"),+      (0xb35d, "skein512-488"),+      (0xb35e, "skein512-496"),+      (0xb35f, "skein512-504"),+      (0xb360, "skein512-512"),+      (0xb361, "skein1024-8"),+      (0xb362, "skein1024-16"),+      (0xb363, "skein1024-24"),+      (0xb364, "skein1024-32"),+      (0xb365, "skein1024-40"),+      (0xb366, "skein1024-48"),+      (0xb367, "skein1024-56"),+      (0xb368, "skein1024-64"),+      (0xb369, "skein1024-72"),+      (0xb36a, "skein1024-80"),+      (0xb36b, "skein1024-88"),+      (0xb36c, "skein1024-96"),+      (0xb36d, "skein1024-104"),+      (0xb36e, "skein1024-112"),+      (0xb36f, "skein1024-120"),+      (0xb370, "skein1024-128"),+      (0xb371, "skein1024-136"),+      (0xb372, "skein1024-144"),+      (0xb373, "skein1024-152"),+      (0xb374, "skein1024-160"),+      (0xb375, "skein1024-168"),+      (0xb376, "skein1024-176"),+      (0xb377, "skein1024-184"),+      (0xb378, "skein1024-192"),+      (0xb379, "skein1024-200"),+      (0xb37a, "skein1024-208"),+      (0xb37b, "skein1024-216"),+      (0xb37c, "skein1024-224"),+      (0xb37d, "skein1024-232"),+      (0xb37e, "skein1024-240"),+      (0xb37f, "skein1024-248"),+      (0xb380, "skein1024-256"),+      (0xb381, "skein1024-264"),+      (0xb382, "skein1024-272"),+      (0xb383, "skein1024-280"),+      (0xb384, "skein1024-288"),+      (0xb385, "skein1024-296"),+      (0xb386, "skein1024-304"),+      (0xb387, "skein1024-312"),+      (0xb388, "skein1024-320"),+      (0xb389, "skein1024-328"),+      (0xb38a, "skein1024-336"),+      (0xb38b, "skein1024-344"),+      (0xb38c, "skein1024-352"),+      (0xb38d, "skein1024-360"),+      (0xb38e, "skein1024-368"),+      (0xb38f, "skein1024-376"),+      (0xb390, "skein1024-384"),+      (0xb391, "skein1024-392"),+      (0xb392, "skein1024-400"),+      (0xb393, "skein1024-408"),+      (0xb394, "skein1024-416"),+      (0xb395, "skein1024-424"),+      (0xb396, "skein1024-432"),+      (0xb397, "skein1024-440"),+      (0xb398, "skein1024-448"),+      (0xb399, "skein1024-456"),+      (0xb39a, "skein1024-464"),+      (0xb39b, "skein1024-472"),+      (0xb39c, "skein1024-480"),+      (0xb39d, "skein1024-488"),+      (0xb39e, "skein1024-496"),+      (0xb39f, "skein1024-504"),+      (0xb3a0, "skein1024-512"),+      (0xb3a1, "skein1024-520"),+      (0xb3a2, "skein1024-528"),+      (0xb3a3, "skein1024-536"),+      (0xb3a4, "skein1024-544"),+      (0xb3a5, "skein1024-552"),+      (0xb3a6, "skein1024-560"),+      (0xb3a7, "skein1024-568"),+      (0xb3a8, "skein1024-576"),+      (0xb3a9, "skein1024-584"),+      (0xb3aa, "skein1024-592"),+      (0xb3ab, "skein1024-600"),+      (0xb3ac, "skein1024-608"),+      (0xb3ad, "skein1024-616"),+      (0xb3ae, "skein1024-624"),+      (0xb3af, "skein1024-632"),+      (0xb3b0, "skein1024-640"),+      (0xb3b1, "skein1024-648"),+      (0xb3b2, "skein1024-656"),+      (0xb3b3, "skein1024-664"),+      (0xb3b4, "skein1024-672"),+      (0xb3b5, "skein1024-680"),+      (0xb3b6, "skein1024-688"),+      (0xb3b7, "skein1024-696"),+      (0xb3b8, "skein1024-704"),+      (0xb3b9, "skein1024-712"),+      (0xb3ba, "skein1024-720"),+      (0xb3bb, "skein1024-728"),+      (0xb3bc, "skein1024-736"),+      (0xb3bd, "skein1024-744"),+      (0xb3be, "skein1024-752"),+      (0xb3bf, "skein1024-760"),+      (0xb3c0, "skein1024-768"),+      (0xb3c1, "skein1024-776"),+      (0xb3c2, "skein1024-784"),+      (0xb3c3, "skein1024-792"),+      (0xb3c4, "skein1024-800"),+      (0xb3c5, "skein1024-808"),+      (0xb3c6, "skein1024-816"),+      (0xb3c7, "skein1024-824"),+      (0xb3c8, "skein1024-832"),+      (0xb3c9, "skein1024-840"),+      (0xb3ca, "skein1024-848"),+      (0xb3cb, "skein1024-856"),+      (0xb3cc, "skein1024-864"),+      (0xb3cd, "skein1024-872"),+      (0xb3ce, "skein1024-880"),+      (0xb3cf, "skein1024-888"),+      (0xb3d0, "skein1024-896"),+      (0xb3d1, "skein1024-904"),+      (0xb3d2, "skein1024-912"),+      (0xb3d3, "skein1024-920"),+      (0xb3d4, "skein1024-928"),+      (0xb3d5, "skein1024-936"),+      (0xb3d6, "skein1024-944"),+      (0xb3d7, "skein1024-952"),+      (0xb3d8, "skein1024-960"),+      (0xb3d9, "skein1024-968"),+      (0xb3da, "skein1024-976"),+      (0xb3db, "skein1024-984"),+      (0xb3dc, "skein1024-992"),+      (0xb3dd, "skein1024-1000"),+      (0xb3de, "skein1024-1008"),+      (0xb3df, "skein1024-1016"),+      (0xb3e0, "skein1024-1024"),+      (0xb3e1, "xxh-32"),+      (0xb3e2, "xxh-64"),+      (0xb3e3, "xxh3-64"),+      (0xb3e4, "xxh3-128"),+      (0xb401, "poseidon-bls12_381-a2-fc1"),+      (0xb402, "poseidon-bls12_381-a2-fc1-sc"),+      (0xb403, "rdfc-1"),+      (0xb501, "ssz"),+      (0xb502, "ssz-sha2-256-bmt"),+      (0xb510, "sha2-256-chunked"),+      (0xb601, "json-jcs"),+      (0xb702, "bittorrent-pieces-root"),+      (0xcc01, "iscc"),+      (0xce11, "zeroxcert-imprint-256"),+      (0xd00d, "bcrypt-pbkdf"),+      (0xd0e7, "es256k"),+      (0xd0ea, "bls12_381-g1-sig"),+      (0xd0eb, "bls12_381-g2-sig"),+      (0xd0ed, "eddsa"),+      (0xd191, "eip-191"),+      (0xeb51, "jwk_jcs-pub"),+      (0xed20, "ed2k"),+      (0xf101, "fil-commitment-unsealed"),+      (0xf102, "fil-commitment-sealed"),+      (0x511e00, "shelter-contract-manifest"),+      (0x511e01, "shelter-contract-text"),+      (0x511e02, "shelter-contract-data"),+      (0x511e03, "shelter-file-manifest"),+      (0x511e04, "shelter-file-chunk"),+      (0x706c61, "plaintextv2"),+      (0x807124, "holochain-adr-v0"),+      (0x817124, "holochain-adr-v1"),+      (0x947124, "holochain-key-v0"),+      (0x957124, "holochain-key-v1"),+      (0xa27124, "holochain-sig-v0"),+      (0xa37124, "holochain-sig-v1"),+      (0xb19910, "skynet-ns"),+      (0xb29910, "arweave-ns"),+      (0xb39910, "subspace-ns"),+      (0xb49910, "kumandra-ns"),+      (0xb59910, "massa"),+      (0xb59911, "massa-mainnet"),+      (0xb59912, "massa-buildnet"),+      (0xb59913, "massa-deweb"),+      (0xb59914, "massa-gossip"),+      (0xb59915, "massa-mns"),+      (0xb59916, "massa-sc"),+      (0xb59917, "massa-gossip-id"),+      (0xb69910, "adnl"),+      (0xd01200, "es256"),+      (0xd01201, "es384"),+      (0xd01202, "es512"),+      (0xd01205, "rs256"),+      (0xd01206, "bip340"),+      (0xd01300, "es256k-msig"),+      (0xd01301, "bls12_381-g1-msig"),+      (0xd01302, "bls12_381-g2-msig"),+      (0xd01303, "eddsa-msig"),+      (0xd01304, "bls12_381-g1-share-msig"),+      (0xd01305, "bls12_381-g2-share-msig"),+      (0xd01306, "lamport-msig"),+      (0xd01307, "lamport-share-msig"),+      (0xd01308, "es256-msig"),+      (0xd01309, "es384-msig"),+      (0xd0130a, "es521-msig"),+      (0xd0130b, "rs256-msig"),+      (0xd02000, "scion")+    ]
multihash/MultiFormats/MultiHash.hs view
@@ -17,21 +17,31 @@  import Control.Monad (join) import Crypto.Hash (HashAlgorithm)-import Crypto.Hash qualified as HF+import Crypto.Hash qualified as Hash import Crypto.Hash.Algorithms qualified as Algo+import Data.BaseSystem (encoder)+import Data.BaseSystem.BinaryTranscoder (packValue)+import Data.BaseSystem.DigitSystem (base16lower) import Data.ByteArray qualified as Memory-import Data.ByteString (ByteString)-import Data.ByteString qualified as Bytes+import Data.ByteString.Builder (Builder)+import Data.ByteString.Builder qualified as Builder+import Data.ByteString.Internal (ByteString (BS))+import Data.ByteString.Lazy (LazyByteString)+import Data.ByteString.Lazy qualified as LBS import Data.Function (on) import Data.Map (Map) import Data.Map qualified as LazyMap import Data.Maybe (fromMaybe, mapMaybe)+import Data.Text qualified as Text+import Foreign.ForeignPtr (newForeignPtr)+import Foreign.Marshal.Alloc (finalizerFree)+import Foreign.Marshal.Array (copyArray, mallocArray)+import GHC.IO (unsafePerformIO) import MultiFormats.MultiCodec (MultiCodec (..)) import MultiFormats.MultiCodec qualified as MC-import Text.Printf (printf)  -- | Alias for the type of function signture we want from a hash function.-type HashFunction = ByteString -> ByteString+type HashFunction = Builder -> LazyByteString  -- | Forms the MultiHash implementaton. data MultiHash = MultiHash@@ -42,11 +52,13 @@   }  instance Show MultiHash where-  show =-    printf "MultiHash(%s)"-      . fromMaybe "<invalid codec>"-      . MC.resolveCodecName-      . multiHashCodec+  show (MultiHash codec@(MultiCodec value) _) =+    let name = fromMaybe "<invalid codec>" $ MC.resolveCodecName codec+        hexstring = "0x" ++ Text.unpack (encoder base16lower $ packValue value)+     in "MultiHash(" ++ hexstring ++ ", " ++ quote name ++ ")"+    where+      -- Puts a String in double quotes.+      quote str = "\"" ++ str ++ "\""  instance Eq MultiHash where   (==) = (==) `on` multiHashCodec@@ -63,14 +75,33 @@ resolveHashName :: String -> Maybe MultiHash resolveHashName name = resolveHashCodec =<< MC.resolveCodecValue name --- Provides an implementation for the given HashAlgorithm.-hashImpl :: (HashAlgorithm a) => a -> Maybe HashFunction-hashImpl algo =-  -- This code is really slow. It copies each byte from Memory to-  -- a new ByteString. I wonder if I can take the pointer from Memory and-  -- assign it to a ByteString for O(1) conversion. Or if we can convince the-  -- compiler that that's all that needs done.-  return $ Bytes.pack . Memory.unpack . HF.hashWith algo+-- | Runs the hash function and copies the result into a new buffer.+hashBytesCopy :: (HashAlgorithm a) => a -> HashFunction+hashBytesCopy algo builder =+  -- This was done as a pure function with pack/unpack, but we're going to use+  -- IO to improve the performance of the copy, which needs to happen to+  -- instantiate a new bytestring type from Crypto.Hash function results.+  unsafePerformIO $+    -- In order to work with the data produced by the hash via Memory, we have+    -- pass an IO transformation on the pointer to the data. The data at the+    -- pointer gets GC'd after this, so we can't copy by referenece and have to+    -- malloc to retain the data (and not double free and crash) unfortunately.+    Memory.withByteArray digest $ \srcptr -> do+      -- Copy the array into newly allocated space+      destptr <- mallocArray len+      copyArray destptr srcptr len+      -- Associate the finalizer with free for the pointer to be used in the GC+      hashptr <- newForeignPtr finalizerFree destptr+      -- Construct the bytestring from the pointer, then O(1) convert to lazy+      return $ LBS.fromStrict (BS hashptr len)+  where+    -- Loads the entire input into memory. hashWith only accepts instances of+    -- ByteArrayAccess, but LazyByteString doesn't implement this.+    access = LBS.toStrict (Builder.toLazyByteString builder)+    -- Runs the hash algorithm on the accessed data.+    digest = Hash.hashWith algo access+    -- Gets the length (in bytes) of the pointed to memory.+    len = Memory.length digest  -- | Resolves all the String names from MultiCodec table and assigns an -- implementation of the hash function if it exists@@ -78,28 +109,36 @@ hashFunctionTable =   -- We want a lazy map so we can skip evaluting hash functions that never get   -- looked up, but we have to evaluate all the hash codecs that exist.-  LazyMap.fromList $-    -- This should leave the hfuncs unevaluted in the Map.-    mapMaybe-      (\(name, hfunc) -> (,hfunc) <$> MC.resolveCodecValue name)-      [ ("identity", Just id),-        ("sha1", hashImpl Algo.SHA1),-        ("sha2-256", hashImpl Algo.SHA256),-        ("sha2-512", hashImpl Algo.SHA512),-        ("sha3-256", hashImpl Algo.SHA3_256),-        ("sha3-512", hashImpl Algo.SHA3_512),-        ("sha3-224", hashImpl Algo.SHA3_224),-        ("sha3-384", hashImpl Algo.SHA3_384),-        ("sha3-512", hashImpl Algo.SHA3_512),-        ("keccak-224", hashImpl Algo.Keccak_224),-        ("keccak-256", hashImpl Algo.Keccak_256),-        ("keccak-384", hashImpl Algo.Keccak_384),-        ("keccak-512", hashImpl Algo.Keccak_512),-        ("blake3", Nothing),-        -- Shake has HashAlgorithms in Algo, but idk how to use them-        ("shake-128", Nothing),-        ("shake-256", Nothing),-        ("md5", hashImpl Algo.MD5),-        -- This can be implemented w/ composition-        ("dbl-sha2-256", Nothing)-      ]+  LazyMap.fromList . mapMaybe pairEntries $+    [ ("identity", Just Builder.toLazyByteString),+      ("sha1", hashSingle Algo.SHA1),+      ("sha2-256", hashSingle Algo.SHA256),+      ("sha2-512", hashSingle Algo.SHA512),+      ("sha3-256", hashSingle Algo.SHA3_256),+      ("sha3-512", hashSingle Algo.SHA3_512),+      ("sha3-224", hashSingle Algo.SHA3_224),+      ("sha3-384", hashSingle Algo.SHA3_384),+      ("sha3-512", hashSingle Algo.SHA3_512),+      ("keccak-224", hashSingle Algo.Keccak_224),+      ("keccak-256", hashSingle Algo.Keccak_256),+      ("keccak-384", hashSingle Algo.Keccak_384),+      ("keccak-512", hashSingle Algo.Keccak_512),+      ("md5", hashSingle Algo.MD5),+      ("dbl-sha2-256", hashDouble Algo.SHA256),+      -- These have HashAlgorithms in Algo, but idk how to use them+      ("blake3", Nothing),+      ("shake-128", Nothing),+      ("shake-256", Nothing)+    ]+  where+    -- Applies the hash algorithm once+    hashSingle algo = Just $ hashBytesCopy algo+    -- Applies the hash algorithm twice+    hashDouble algo = do+      hash <- hashSingle algo+      return $ hash . Builder.lazyByteString . hash+    -- Returns a map entry if the multicodec exists+    pairEntries (name, hfunc) =+      case MC.resolveCodecValue name of+        Just multicodec -> Just (multicodec, hfunc)+        Nothing -> Nothing
varint/MultiFormats/VarInt.hs view
@@ -15,32 +15,36 @@   ) where +import Data.BaseSystem.BinaryTranscoder (BinaryTranscoder)+import Data.BaseSystem.BinaryTranscoder qualified as BXC import Data.Bits ((.&.), (.<<.), (.>>.), (.|.))-import Data.ByteString (ByteString)-import Data.ByteString qualified as Bytes-import Data.Word (Word64, Word8)+import Data.ByteString.Builder (Builder)+import Data.ByteString.Builder qualified as Builder+import Data.ByteString.Short qualified as SBS+import Data.Word (Word16, Word64, Word8) import MultiFormats.VarInt.Errors (Error (..), Okay)  -- | VarInt spec uses unsigned 64 bit integers. type VarInt = Word64 --- | Byte with MSB=1.+-- | Byte with most significant bit (MSB) set to 1. msb1 :: Word8 msb1 = 1 .<<. 7 --- | Byte with LSB=1.+-- | Byte with least significant bit (LSB) set to 1. lsb1 :: Word8 lsb1 = 1 --- | The value w/ MSB=1 and LSB=1.+-- | The value with MSB=1 and LSB=1. msb1lsb1 :: Word8 msb1lsb1 = msb1 .|. lsb1 --- | The value that extracts all bits but the MSB.-masklower :: Word8-masklower = msb1 - 1+-- | The value that extracts all bits but the MSB in a bitwise AND.+mask7lsbs :: Word8+mask7lsbs = msb1 - 1 --- | The maximum value the spec allows (2^63-1).+-- | The maximum value the spec allows is 2^63-1, so a 64-bit integer with bit+-- missing to account for the final byte's terminating MSB bit. maxVarInt :: VarInt maxVarInt = (1 .<<. 63) - 1 @@ -50,74 +54,95 @@  -- | Splits ByteString into it's first occurring VarInt and the remaining -- ByteString after.-spanVarInt :: ByteString -> Maybe (ByteString, ByteString)-spanVarInt bytes =+spanVarInt :: (BinaryTranscoder t) => t -> Okay (t, t)+spanVarInt bxc =   -- Collect the bytes with MSB=1.-  case Bytes.span isMSB1 bytes of+  case BXC.spanBytes isMSB1 bxc of     -- The varint is the leading bytes with the MSB=1 and a final terminating     -- byte with MSB=0.     (msb1s, msb0s)       -- Verify if a final byte exists.-      | Bytes.null msb0s -> Nothing-      -- The loop invariant ensures msb + 1 has MSB=0. Add the last byte with-      -- splitAt since it is (a lot) more efficent than append.-      | otherwise -> Just (Bytes.splitAt (Bytes.length msb1s + 1) bytes)+      | BXC.null msb0s -> Left MissingTermination+      -- The loop invariant ensures &msb1s + 1 has MSB=0, so compute this offset+      -- and split the data there.+      | otherwise ->+          let nulloffset = BXC.lengthBytes msb1s + 1+           in Right (BXC.splitAtByte nulloffset bxc)   where+    -- Checks if the most-significant bit (MSB) is set to 1     isMSB1 byte = (byte .&. msb1) /= 0  -- | Concats the lower 7 bits from bytes into single int value.-buildVarInt :: ByteString -> VarInt-buildVarInt = Bytes.foldr (\byte int -> advance int .|. lower byte) 0+buildVarInt :: (BinaryTranscoder t) => t -> VarInt+buildVarInt = foldr build 0 . BXC.unpackBytes   where-    advance int = int .<<. 7-    lower byte = fromIntegral $ byte .&. masklower+    -- Shifts the accumulator 7 bits (1 byte minus MSB value) and ORs the+    -- current byte into place, and remove the MSB set bit.+    build byte acc = acc .<<. 7 .|. fromIntegral (byte .&. mask7lsbs)  -- | Checks edge case where input is invalid from not being a minimal encoding -- of varints, (ie, we can fit 2 bytes of 7 bits into 1 byte of 7 bits). The -- only case of this is when a final 0x8100 should be a 0x79... I think!-nonMinimal :: ByteString -> Bool-nonMinimal bytes = Bytes.unpack (Bytes.takeEnd 2 bytes) == [msb1lsb1, 0]+{-# INLINE nonMinimal #-}+nonMinimal :: (BinaryTranscoder bxc) => bxc -> Bool+nonMinimal vardata = last16bits == invalidsuffix+  where+    -- Puts the last two bytes of the transcoder into a Word16.+    last16bits = fromIntegral $ BXC.unpackValue (BXC.takeBytesEnd 2 vardata)+    -- This value is the same to the value from bytes 0x7F, so it's not minimal+    invalidsuffix = (fromIntegral msb1lsb1 :: Word16) .<<. 8  -- | Checks if a VarInt encoded ByteString overflows a Word64.-aboveCapacity :: ByteString -> Bool-aboveCapacity varbytes =-  let wholelen = Bytes.length varbytes+{-# INLINE aboveCapacity #-}+aboveCapacity :: (BinaryTranscoder t) => t -> Bool+aboveCapacity vardata =+  let wholelen = BXC.lengthBytes vardata    in not (1 <= wholelen && wholelen <= bytesCapacity)  -- | Extracts the first minimally encoded varint from a ByteString.-extractVarInt :: ByteString -> Okay (VarInt, ByteString)+extractVarInt :: (BinaryTranscoder t) => t -> Okay (VarInt, t) extractVarInt bytes-  | Bytes.null bytes = Left EmptyBytes+  | BXC.null bytes = Left EmptyBytes   | otherwise =       case spanVarInt bytes of-        Nothing -> Left MissingTermination-        Just (varbytes, rest)+        Left err -> Left err+        Right (varbytes, rest)           | aboveCapacity varbytes -> Left BytesOverflow           | nonMinimal varbytes -> Left NotMinimal           | otherwise -> Right (buildVarInt varbytes, rest) --- | Puts a parsed VarInt (Word64, without MSB indicators) into a ByteString--- with MSB indicators, and a max size of 9 bytes.-serializeVarInt :: VarInt -> Okay ByteString+-- | Puts a parsed VarInt (Word64 value) into a Builder of ShortByteString with+-- MSB bits set, and a max size of 9 bytes.+serializeVarInt :: VarInt -> Okay Builder serializeVarInt varint   | varint > maxVarInt = Left AboveMaxValue   | otherwise =       Right-        . zeroReplaceNull-        . Bytes.unfoldr setMSBs-        . Bytes.dropWhileEnd (== 0)-        $ Bytes.pack [varintGroup i varint | i <- [1 .. bytesCapacity]]+        -- Put the ShortByteString into a ByteString Builder.+        . Builder.shortByteString+        -- Set the continuation bits in the bytes.+        . SBS.unfoldr setMSBs+        -- Replace empty bytestrings with a single zero byte.+        . replaceNull0+        -- Drop bytes until a minimal value is found.+        . SBS.dropWhileEnd (== 0)+        -- Pack the bytes from varint 7-bit groups.+        $ SBS.pack [var7sAt bytepos | bytepos <- [1 .. bytesCapacity]]   where-    -- Extracts Nth group of 7 bits from VarInt.-    varintGroup n var = fromIntegral (var .>>. (7 * (n - 1))) .&. masklower+    -- Extracts 1-indexed groups of 7 bits from varint starting from the LSB.+    {-# INLINEABLE var7sAt #-}+    var7sAt idx = fromIntegral (varint .>>. (7 * (idx - 1))) .&. mask7lsbs     -- Sets MSB=1 for leading bytes in unfoldr.-    setMSBs bytes =-      Bytes.uncons bytes >>= \(byte, rest) ->-        if Bytes.null rest-          then Just (byte, mempty)-          else Just (byte .|. msb1, rest)+    {-# INLINEABLE setMSBs #-}+    setMSBs bytes = do+      (top, rest) <- SBS.uncons bytes+      Just $+        if SBS.null rest+          then (top, SBS.empty)+          else (top .|. msb1, rest)     -- Replaces a null ByteString with a single zero.-    zeroReplaceNull bytes =-      if Bytes.null bytes-        then Bytes.singleton 0+    {-# INLINEABLE replaceNull0 #-}+    replaceNull0 bytes =+      if SBS.null bytes+        then SBS.singleton 0         else bytes