{"id":17540533,"url":"https://github.com/filip26/copper-multicodec","last_synced_at":"2026-03-09T23:36:42.217Z","repository":{"id":174757438,"uuid":"627161934","full_name":"filip26/copper-multicodec","owner":"filip26","description":"Multicodec \u0026 Multihash — encoder/decoder for self-describing data formats","archived":false,"fork":false,"pushed_at":"2026-02-23T23:26:06.000Z","size":575,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-24T05:49:26.816Z","etag":null,"topics":["multicodec","multiformats","multihash","self-describing","self-descriptive","varint"],"latest_commit_sha":null,"homepage":"https://apicatalog.com","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/filip26.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["filip26"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://wise.com/share/filipk558","https://paypal.me/FilipKolarik"]}},"created_at":"2023-04-12T23:01:57.000Z","updated_at":"2026-02-23T23:26:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"7a28ae57-e664-4b31-983a-159f7b5782f6","html_url":"https://github.com/filip26/copper-multicodec","commit_stats":{"total_commits":187,"total_committers":2,"mean_commits":93.5,"dds":"0.33689839572192515","last_synced_commit":"73b0b82fd3207bab58ece452913e79854169485f"},"previous_names":["filip26/copper-multicodec"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/filip26/copper-multicodec","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filip26%2Fcopper-multicodec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filip26%2Fcopper-multicodec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filip26%2Fcopper-multicodec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filip26%2Fcopper-multicodec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/filip26","download_url":"https://codeload.github.com/filip26/copper-multicodec/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filip26%2Fcopper-multicodec/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30316772,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T20:05:46.299Z","status":"ssl_error","status_checked_at":"2026-03-09T19:57:04.425Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["multicodec","multiformats","multihash","self-describing","self-descriptive","varint"],"created_at":"2024-10-20T22:24:11.836Z","updated_at":"2026-03-09T23:36:42.209Z","avatar_url":"https://github.com/filip26.png","language":"Java","funding_links":["https://github.com/sponsors/filip26","https://wise.com/share/filipk558","https://paypal.me/FilipKolarik"],"categories":[],"sub_categories":[],"readme":"# Copper Multicodec\n\nA multicodec is a **self-describing** format: encoded data always begins\nwith a varint code that unambiguously identifies its format and intended\npurpose.  \n\nThis design eliminates guesswork, ensures interoperability between systems,\nand makes it possible to introduce new formats without breaking existing\nimplementations.  \n\nThe multicodec identifier tells applications how the data is meant to be\ninterpreted and processed.  \n\nEach multicodec is tagged to reflect its purpose - for example, hash functions (e.g., `sha2-256`), cryptography keys (e.g., `ed25519-pub`), and other identifiers used across the multiformats ecosystem.\n\nCopper Multicodec is a Java library implementing \n[Multicodec](https://github.com/multiformats/multicodec) and \n[Multihash](https://github.com/multiformats/multihash), enabling efficient\nencoding and decoding of self-describing data formats.\n\n[![Java 8 CI](https://github.com/filip26/copper-multicodec/actions/workflows/java8-build.yml/badge.svg?branch=main)](https://github.com/filip26/copper-multicodec/actions/workflows/java8-build.yml)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=filip26_copper-multicodec\u0026metric=alert_status)](https://sonarcloud.io/summary/new_code?id=filip26_copper-multicodec)\n[![javadoc](https://javadoc.io/badge2/com.apicatalog/copper-multicodec/javadoc.svg)](https://javadoc.io/doc/com.apicatalog/copper-multicodec)\n[![Maven Central](https://img.shields.io/maven-central/v/com.apicatalog/copper-multicodec.svg?label=Maven%20Central)](https://mvnrepository.com/artifact/com.apicatalog/copper-multicodec)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\n## ✨ Features\n\n- Static codec registry with predefined codecs for efficient access  \n- Direct static access to codecs without runtime lookups  \n- Support for custom codecs through extension  \n- Multihash compatibility  \n- Unsigned VarInt (UVarInt) encoding and decoding  \n- Zero third-party dependencies for a lightweight, self-contained implementation\n\n## 💡 Examples\n\n```java\n/* encode an input as P-521 public key */\nbyte[] encoded = KeyCodec.P521_PUBLIC_KEY.encode(input);\n\n/* encode an input as an identity */\nbyte[] encoded = MultihashCodec.IDENTITY.encode(input);\n\n/* get decoder instance initialized with all supported codecs */\nvar decoder = MulticodecDecoder.getInstance();\n\n/* get custom decoder initialized with codecs tagged as key and hash */\nvar decoder = MulticodecDecoder.getInstance(Tag.Key, Tag.Hash);\n\n/* get custom decoder initialized with custom codec set  */\nvar decoder = MulticodecDecoder.getInstance(codecs...);\n\n/* decode */\nbyte[] decoded = decoder.decode(encoded);\n\n/* or check if encoding is supported  */\nbyte[] decoded = decoder.getCodec(encoded)\n                        .map(codec -\u003e codec.decode(encoded))\n                        .orElseThrow(() -\u003e new IllegalArgumentException(\"Unsupported codec.\"));\n\n/* or directly when only one codec is supported */\nbyte[] decoded = KeyCodec.P521_PUBLIC_KEY.decode(encoded);\n\n/* check if byte array is encoded with a codec */\nif (KeyCodec.P521_PUBLIC_KEY.isEncoded(encoded)) {\n  ...\n}\n\n/* create a custom codec */\nvar codec = Multicodec.of(name, tag, code);\n\n/* get registry instance initialized with all supported codecs */\nvar registry = MulticodecRegistry.getInstance();\n\n/* get custom registry initialized with codecs tagged as key and hash */\nvar registry = MulticodecRegistry.getInstance(Tag.Key, Tag.Hash);\n\n/* get custom registry initialized with custom codec set  */\nvar registry = MulticodecRegistry.getInstance(codecs...);\n\n/* get codec */\nbyte[] encoded = registry.getCodec(code)\n                         .map(codec -\u003e codec.encode(input))\n                         .orElseThrow(() -\u003e new IllegalArgumentException(\"Unsupported codec.\"));\n```\n\n### Multihash\n\n```java\n/* get multihash decoder initialized with all multihash codecs */\nvar decoder = MulticodecDecoder.getInstance(Tag.Multihash);\n\n/* decode; digest size is checked and removed */\nbyte[] decoded = decoder.decode(encoded);\n\n/* or check if supported  */\nbyte[] decoded = decoder.getCodec(encoded)\n                        .map(codec -\u003e codec.decode(encoded))\n                        .orElseThrow(() -\u003e new IllegalArgumentException(\"Unsupported multihash.\"));\n\n/* or directly */\nbyte[] decoded = MultihashCodec.SHA2_384.decode(encoded);\n\n/* \n\n/* check if byte array is encoded with multihash codec */\nif (MultihashCodec.SHA2_384.isEncoded(encoded)) {\n  var digestLength = MultihashCodec.SHA2_384.digestLength(encoded);\n  ...\n}\n\n/* determine digest index  */\nvar index = decoder.getCodec(encoded)\n                    .map(Multihash.class::cast)\n                    .mapToInt(codec -\u003e encoded.length - codec.digestLength(encoded))\n                    .orElseThrow(() -\u003e new IllegalArgumentException(\"Unsupported multihash.\"));\n\n```\n\n## 📦 Installation\n\n### Maven\n\nTo include Copper Multicodec in your project, add the following dependency to your `pom.xml`:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.apicatalog\u003c/groupId\u003e\n    \u003cartifactId\u003ecopper-multicodec\u003c/artifactId\u003e\n    \u003cversion\u003e2.4.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## 🛠️ LD-CLI\n\n[LD-CLI](https://github.com/filip26/ld-cli) is a command-line utility for\nworking with multiformats including multibase, multicodec, and multihash,\nas well as JSON-LD and related specifications.\n\nIt provides encoding, decoding, detection, analysis, and format conversion\nfeatures, making it useful for inspecting identifiers, testing content\naddressing, and integrating multiformats into development workflows.\n\n### Example\n\nDetect and analyze a multibase + multicodec value\n```bash\n\u003e ld-cli multicodec --analyze --multibase \u003c\u003c\u003c 'z6MkmM42vxfqZQsv4ehtTjFFxQ4sQKS2w6WR7emozFAn5cxu'\n\nMultibase:  name=base58btc, prefix=z, length=58 chars\nMulticodec: name=ed25519-pub, code=237, varint=[0xED,0x01], tag=Key, status=Draft\nLength:     32 bytes\n```\n\n## 🤝 Contributing\n\nContributions are welcome! Please submit a pull request.\n\n### Building\n\nFork and clone the repository, then build with Maven:\n\n```bash\n\u003e cd copper-multicodec\n\u003e mvn clean package\n```\n\n## 📚 Resources\n- [Codecs Registry](https://github.com/multiformats/multicodec/blob/master/table.csv)\n- [Multicodec](https://github.com/multiformats/multicodec)\n- [Multihash](https://github.com/multiformats/multihash)\n- [unsigned-varint](https://github.com/multiformats/unsigned-varint)\n- [Copper Multibase](https://github.com/filip26/copper-multibase)\n\n## 💼 Commercial Support\n\nCommercial support and consulting are available.  \nFor inquiries, please contact: filip26@gmail.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffilip26%2Fcopper-multicodec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffilip26%2Fcopper-multicodec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffilip26%2Fcopper-multicodec/lists"}