content-addressable
Content addressing for Rust and Python: derive an address from data so anyone with the bytes and address can verify that they match.
The crate uses IPLD content identifiers (CIDs) with BLAKE3. The Python package binds the Rust core, so both languages produce the same identifier when a value encodes to the same canonical DAG-CBOR bytes.
Use the right identity
ContentId identifies canonical DAG-CBOR values. RawContentId identifies
bytes without interpreting them. Both use CIDv1 and a 32-byte BLAKE3 digest,
but their codecs differ and make them distinct identities even for the same
digest. Compare typed CIDs, never bare digests. Emit base32-lower CID text.
Before constructing a ContentId from untrusted bytes, check that they are
canonical DAG-CBOR.
ContentId::from_canonical_bytes assumes this without checking. Use checked
construction or checked decoding to validate canonicality; typed checked
decoding also catches fields the target type discards.
See identity and decoding for construction APIs, checked reads, presentation forms, foreign CIDs, and the Python tag-42 link limitation.
Installation
Rust (1.85 or later):
[dependencies]
content-addressable = "0.1.0"
Python:
pip install content-addressable
Import the Python package as content_addressable.
Rust quick start
Implement canonical_form to give your type the ContentAddressable trait
methods content_id, verify, and ensure_content_id:
use content_addressable::{canonical, ContentAddressable, ContentError};
use serde::Serialize;
#[derive(Serialize)]
struct Record {
name: String,
}
impl ContentAddressable for Record {
fn canonical_form(&self) -> Result<Vec<u8>, ContentError> {
canonical::to_canonical_dagcbor(self)
}
}
let record = Record { name: "alpha".into() };
let id = record.content_id()?; // a CIDv1 (DAG-CBOR + BLAKE3)
assert!(record.verify(&id)?); // self-certifying: re-derive and compare
println!("{id}"); // "bafyr4i…" — the canonical text form
# Ok::<(), ContentError>(())
verify returns Ok(false) on a mismatch. ensure_content_id returns
Err(ContentError::VerificationFailed).
Python quick start
Call content_id on a native Python value. Python exposes neither the Rust
ContentAddressable trait nor its verify method.
from content_addressable import (
ContentId, content_id,
to_canonical_dagcbor, from_canonical_dagcbor,
)
# A value's content id (CIDv1, DAG-CBOR + BLAKE3). Key order is irrelevant.
record = {"name": "alpha", "attrs": {}}
cid = content_id(record)
assert str(cid).startswith("b") # base32-lower multibase text
assert len(cid.digest_hex()) == 64 # 64-char bare-digest-hex
assert isinstance(to_canonical_dagcbor(record), bytes)
# Canonical bytes round-trip; equal values -> equal bytes -> equal ids.
raw = to_canonical_dagcbor(record)
assert content_id(record) == ContentId.from_canonical_bytes(raw)
assert from_canonical_dagcbor(raw) == record
assert content_id({"attrs": {}, "name": "alpha"}) == cid # order-independent
# Parse an id back from its text / binary forms.
assert ContentId.parse(str(cid)) == cid
assert ContentId.from_bytes(cid.to_bytes()) == cid
# Wrap an already-computed 32-byte BLAKE3 digest with NO re-hash.
assert ContentId.from_blake3_content_digest(cid.digest_bytes()) == cid
assert len(cid.digest_bytes()) == 32 # the raw BLAKE3 hash
ContentId supports equality and hashing for use as a dict key or set
member.
Stability and optional features
The core contracts are stable throughout 0.1.x, with
one documented exception in 0.1.2
for Rust trait-method name resolution. See the stability contract
for frozen bytes, APIs, and compatibility details.
All unstable-* features are off by default and may change:
unstable-store: verified storage operations and an in-memory backend.unstable-legacy: parsers for legacy identifier formats.unstable-migration: records of identity changes.
See experimental features for examples and storage guarantees.
Development
just install-hooks
just check # fmt + clippy + test + docs + leaf-deps
See RELEASING.md for tag-driven releases.
License
Metadata
Release files for content-addressable 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| content_addressable-0.1.3.tar.gz | 259.3 kB | With provenance | Details for content_addressable-0.1.3.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| content_addressable-0.1.3-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details for content_addressable-0.1.3-cp39-abi3-win_amd64.whl |
| content_addressable-0.1.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ x86-64 | Details for content_addressable-0.1.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
| content_addressable-0.1.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ ARM64 | Details for content_addressable-0.1.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
| content_addressable-0.1.3-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl | CPython 3.9 | abi3 | macOS 10.12+ x86-64, macOS 11.0+ ARM64, macOS 10.12+ universal2 (ARM64, x86-64) | Details for content_addressable-0.1.3-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl |
Total release size: 2.3 MB
Release files / content_addressable-0.1.3.tar.gz
| Download URL | content_addressable-0.1.3.tar.gz |
|---|---|
| Size | 259.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ca9bc367ea12f02f8c7b85c5f6d828c7b8020c5a59c414a250d147f1122bb500
|
|
BLAKE2b-256 checksum How to use checksums |
d528ff1ee3329fabc2810d237417749859cf5a751165b6cea58035a04af10be0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency logRelease files / content_addressable-0.1.3-cp39-abi3-win_amd64.whl
| Download URL | content_addressable-0.1.3-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 304.4 kB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
44b0cedc0ed03de9cd300e29ad6d40565af74c2faa0075bf15bb7259a5aea441
|
|
BLAKE2b-256 checksum How to use checksums |
0ed721f2d6b33ae251adbdc3bde3ee4045e2341c4ba783f76c608375e73942e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency logRelease files / content_addressable-0.1.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | content_addressable-0.1.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 464.8 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
b3754012137b086d0a10640c76f2b0b2352bd0a417ca161fabe1d43e19aa93f3
|
|
BLAKE2b-256 checksum How to use checksums |
73d7df0928c1bc10c489d49132b889f2b0090e5811f642961fc91709d9438640
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency logRelease files / content_addressable-0.1.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | content_addressable-0.1.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 444.2 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
f044619828c3bb22345b5aa6dcf68d423c4a3d408f5fe12e59c9eac3b96351b5
|
|
BLAKE2b-256 checksum How to use checksums |
dde789be67127448fece29a220b05fd29851494e55726c5b5229fce5fab478c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency logRelease files / content_addressable-0.1.3-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
| Download URL | content_addressable-0.1.3-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl |
|---|---|
| Size | 805.1 kB |
| Tags | CPython 3.9 abi3 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
3a2605e983606f9e8e5f9c50f7dc27744dc44b38828c14726ee452e0c92af56c
|
|
BLAKE2b-256 checksum How to use checksums |
5f106ae5656e2791fb46e440245c71822fad17998b5b62e215e293edaf20a198
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency logSecurity for content-addressable 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 5 files in this release have been uploaded with provenance metadata.
Attestation for content_addressable-0.1.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.