You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
py-multicodec is a basic implementation that provides core prefix operations but lacks:
Many newer codecs present in go-multicodec
Advanced features like code enumeration, reserved range support
Type-safe codec constants
Integration with serialization frameworks
Feature Comparison Table
Feature
py-multicodec
go-multicodec
rust-multicodec
js-multiformats
Core Operations
Add prefix
✅ add_prefix()
✅ Via constants
✅ add()
✅ Via codec interface
Remove prefix
✅ remove_prefix()
❌
✅ remove()
✅ Via codec interface
Get codec from bytes
✅ get_codec()
❌
✅ get()
✅ Via codec interface
Get prefix bytes
✅ get_prefix()
❌
❌
❌
Extract prefix integer
✅ extract_prefix()
❌
❌
❌
Check if codec exists
✅ is_codec()
✅ Via Set()
❌
❌
Codec Management
Codec constants
❌
✅ Type-safe constants
❌
❌
List all codecs
❌
✅ KnownCodes()
❌
❌
Codec name → code
✅ Via NAME_TABLE
✅ Via Set()
❌
❌
Code → codec name
✅ Via CODE_TABLE
✅ Via String()
❌
❌
Reserved range support
❌
✅ ReservedStart/End
❌
❌
Serialization
Encode objects
❌
❌
✅ JSON only
✅ Via codec interface
Decode objects
❌
❌
✅ JSON only
✅ Via codec interface
Type Safety
Type-safe codec types
❌
✅ Code type
✅ Enum
✅ TypeScript types
Flag.Value interface
❌
✅
❌
❌
Codec Count
Total codecs
~370
~600+
1 (JSON only)
2 (raw, json)
Auto-update mechanism
✅ update-table.py
✅ go generate
❌
❌
API Comparison
py-multicodec API
frommulticodecimportadd_prefix, remove_prefix, get_codec, get_prefix, is_codec, extract_prefix# Add prefixprefixed=add_prefix('sha2-256', data)
# Remove prefixdata=remove_prefix(prefixed)
# Get codec namecodec=get_codec(prefixed)
# Get prefix bytesprefix_bytes=get_prefix('sha2-256')
# Extract prefix integerprefix_int=extract_prefix(prefixed)
# Check if codec existsexists=is_codec('sha2-256')
go-multicodec API
import"github.com/multiformats/go-multicodec"// Type-safe constantscode:=multicodec.Sha2_256name:=code.String() // "sha2-256"// Set from stringvarcode multicodec.Codecode.Set("sha2-256")
// Set from numbercode:=multicodec.Code(0x12)
// List all known codecsallCodes:=multicodec.KnownCodes()
// Reserved rangeifcode>=multicodec.ReservedStart&&code<=multicodec.ReservedEnd {
// Internal use code
}
rust-multicodec API
use rust_multicodec::{codec, encode, decode};// Encode with JSON codeclet encoded = encode(codec::CodecType::JSON,&object)?;// Decodelet result:DecodeResult<T> = decode(encoded.as_ref())?;
# Update from official multicodec table
curl -X GET https://raw.githubusercontent.com/multiformats/multicodec/master/table.csv | python tools/update-table.py
This will regenerate multicodec/constants.py with the latest codecs from the official table.
Conclusion
py-multicodec provides the core functionality for multicodec operations but is missing:
~230+ codecs present in go-multicodec
Advanced features like codec enumeration, reserved ranges, type safety
Integration features like serialization, CLI support
The codebase is well-structured and can be easily updated. The main gap is the outdated codec table, which can be fixed by running the update script.
Last Updated: Based on codebase analysis as of current date Comparison Sources:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
py-multicodec Comparison Analysis
This document provides a comprehensive comparison between
py-multicodecand other multicodec implementations:go-multicodec(Go)rust-multicodec(Rust)js-multiformats(JavaScript/TypeScript - multicodec portion)Executive Summary
py-multicodec is a basic implementation that provides core prefix operations but lacks:
Feature Comparison Table
add_prefix()add()remove_prefix()remove()get_codec()get()get_prefix()extract_prefix()is_codec()Set()KnownCodes()NAME_TABLESet()CODE_TABLEString()ReservedStart/EndCodetypeupdate-table.pygo generateAPI Comparison
py-multicodec API
go-multicodec API
rust-multicodec API
js-multiformats API
Missing Codecs in py-multicodec
Based on comparison with go-multicodec (which appears to be the most comprehensive), the following codecs are missing in py-multicodec:
CID & Versioning
cidv1(0x01) - PRESENTcidv2(0x02) - PRESENTcidv3(0x03) - PRESENTMultiformat Extensions
varsig(0x34) - Variable signature formatdnslink(0xe8) - DNS link formatHash Functions
sha2-384(0x20) - SHA-384sha2-224(0x1013) - SHA-224sha2-512-224(0x1014) - SHA-512/224sha2-512-256(0x1015) - SHA-512/256murmur3-x64-128(0x1022) - Murmur3 x64 128-bitmurmur3-x64-64(0x22) - Murmur3 x64 64-bit (Note: py hasmurmur3-128andmurmur3-32)Encryption & Cipher
aes-128(0xa0)aes-192(0xa1)aes-256(0xa2)chacha-128(0xa3)chacha-256(0xa4)aes-gcm-256(0x2000)chacha20-poly1305(0xa000)Network & Transport
ipcidr(0x2b) - IP CIDR maskwebrtc-direct(0x0118)webrtc(0x0119)sni(0x01c1) - Server Name Indicationnoise(0x01c6) - Noise protocolshs(0x01c8) - Secure Handshakequic-v1(0x01cd)webtransport(0x01d1)certhash(0x01d2)http-path(0x01e1)memorytransport(0x0309)Blockchain & Cryptocurrency
caip-50(0xca) - Chain Agnostic Improvement Proposal 50streamid(0xce) - Stream IDlbry(0x8c) - LBRY protocoleth-receipt-log-trie(0x99)eth-receipt-log(0x9a)beeson(0xfc)Checksums
crc32(0x0132)crc64-ecma(0x0164)crc64-nvme(0x0165)Serialization & Formats
car(0x0202) - Content Addressed Archivecar-index-sorted(0x0400)car-multihash-index-sorted(0x0401)x509-certificate(0x0210)IPLD & Data Structures
ipns-record(0x0300)libp2p-relay-rsvp(0x0302)blake3-hashseq(0x80)Cryptographic Keys & Signatures
sr25519-pub(0xef) - Sr25519 public keyrsa-pub(0x1205) - RSA public keysm2-pub(0x1206) - SM2 public keyvlad(0x1207)provenance-log(0x1208)provenance-log-entry(0x1209)provenance-log-script(0x120a)mlkem-512-pub(0x120b) - ML-KEM 512 public keymlkem-768-pub(0x120c) - ML-KEM 768 public keymlkem-1024-pub(0x120d) - ML-KEM 1024 public keymultisig(0x1239)multikey(0x123a)nonce(0x123b)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)Post-Quantum Cryptography
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)Hash Functions (Extended)
xxh-32(0xb3e1) - XXH32 hashxxh-64(0xb3e2) - XXH64 hashxxh3-64(0xb3e3) - XXH3 64-bitxxh3-128(0xb3e4) - XXH3 128-bitsha256a(0x7012) - SHA256a variantMerkle Trees & Data Structures
fr32-sha256-trunc254-padbintree(0x1011)rdfc-1(0xb403)ssz(0xb501) - Simple Serializessz-sha2-256-bmt(0xb502)sha2-256-chunked(0xb510)Formats & Protocols
json-jcs(0xb601) - JSON Canonicalization Schemebittorrent-pieces-root(0xb702)iscc(0xcc01) - International Standard Content Codeswhid-1-snp(0x01f0) - Software Heritage IDmultidid(0x0d1d) - Multi-DIDTransport Protocols
transport-bitswap(0x0900)transport-graphsync-filecoinv1(0x0910)transport-ipfs-gateway-http(0x0920)transport-filecoin-piece-http(0x0930)Signatures & Authentication
nonstandard-sig(0xd000)bcrypt-pbkdf(0xd00d)es256k(0xd0e7)bls12_381-g1-sig(0xd0ea)bls12_381-g2-sig(0xd0eb)eddsa(0xd0ed)eip-191(0xd191)jwk_jcs-pub(0xeb71)ed2k(0xed00)Filecoin
fil-commitment-unsealed(0xf101) - PRESENTfil-commitment-sealed(0xf102) - PRESENTShelter Protocol
shelter-contract-manifest(0x511020)shelter-contract-text(0x511021)shelter-contract-data(0x511022)shelter-file-manifest(0x511023)shelter-file-chunk(0x511024)Other Protocols
plaintextv2(0x708021)arweave-ns(0xb28a10)subspace-ns(0xb2f590)kumandra-ns(0xb4b510)JWT & Signatures
es256(0xd00000) - ECDSA P-256es384(0xd00001) - ECDSA P-384es512(0xd00002) - ECDSA P-521rs256(0xd00005) - RSA SHA-256es256k-msig(0xd00080)bls12_381-g1-msig(0xd00081)bls12_381-g2-msig(0xd00082)eddsa-msig(0xd00083)bls12_381-g1-share-msig(0xd00084)bls12_381-g2-share-msig(0xd00085)lamport-msig(0xd00086)lamport-share-msig(0xd00087)es256-msig(0xd00088)es384-msig(0xd00089)es521-msig(0xd0008a)rs256-msig(0xd0008b)scion(0xd00e00)ML-KEM Private Keys
mlkem-512-priv(0x130d)mlkem-768-priv(0x130e)mlkem-1024-priv(0x130f)jwk_jcs-priv(0x130e)Missing Features in py-multicodec
1. Codec Enumeration
KnownCodes()equivalent to list all supported codecsCODECS.keys()directly (but not part of public API)2. Reserved Range Support
ReservedStartandReservedEndconstants3. Type-Safe Codec Constants
multicodec.Sha2_256)4. Flag.Value Interface
flag.Valueinterface5. Serialization Integration
6. Codec Metadata
7. Error Types
ValueErrorfor all errorsUnknownCodecError,InvalidPrefixError, etc.8. Validation
validate_codec()function9. Codec Registry
10. Performance Optimizations
Codec Count Summary
Note: The actual count varies as the multicodec table is updated. Both py-multicodec and go-multicodec can be updated from the official table.
Recommendations
High Priority
update-table.pyto sync with latest multicodec tableKnownCodes()equivalent - Expose list of all codecsMedium Priority
Low Priority
Update Process
To update py-multicodec with missing codecs:
This will regenerate
multicodec/constants.pywith the latest codecs from the official table.Conclusion
py-multicodec provides the core functionality for multicodec operations but is missing:
The codebase is well-structured and can be easily updated. The main gap is the outdated codec table, which can be fixed by running the update script.
Last Updated: Based on codebase analysis as of current date
Comparison Sources:
/home/luca/Informatica/Learning/PNL_Launchpad_Curriculum/Libp2p/py-multicodec/home/luca/PNL_Launchpad_Curriculum/Libp2p/go-multicodec/home/luca/PNL_Launchpad_Curriculum/Libp2p/rust-multicodec/home/luca/PNL_Launchpad_Curriculum/Libp2p/js-multiformatsBeta Was this translation helpful? Give feedback.
All reactions