Skip to main content

kubo-compatible IPFS CID computation for Aleph Cloud, backed by the aleph-cid Rust crate

Project description

aleph-cid (Python)

kubo-compatible IPFS CID computation for Aleph Cloud, backed by the aleph-cid Rust crate. Computes the exact CIDs that kubo would assign, without running an IPFS node: streaming file hashing (CIDv0 and CIDv1), UnixFS folder DAGs (plain and HAMT-sharded directories), and CARv1 packing.

All hashing releases the GIL, so it can run on worker threads without blocking the interpreter.

Install

pip install aleph-cid

Prebuilt abi3 wheels cover CPython 3.10+ on Linux (x86_64, aarch64), macOS, and Windows.

Usage

import aleph_cid

# One-shot CIDv0 (kubo `ipfs add` default)
aleph_cid.compute_cid(b"hello\n")

# Streaming, for large files
hasher = aleph_cid.CidHasher.for_ipfs_v1_raw_leaves()
with open("video.mp4", "rb") as f:
    while chunk := f.read(1 << 20):
        hasher.update(chunk)
cid = hasher.finalize()

# Verify data against an existing CID of any supported flavor
hasher = aleph_cid.CidHasher.for_expected(cid)
hasher.update(data)
assert hasher.finalize() == cid

# Folder root CID, matching kubo `/api/v0/add?wrap-with-directory=true`
root = aleph_cid.hash_folder("./site", cid_version=1)

# Pack a folder into a CARv1 file (for `/api/v0/ipfs/add_car` uploads)
root = aleph_cid.write_folder_car("./site", "site.car")
assert aleph_cid.read_carv1_root("site.car") == root

Compatibility

CIDs match kubo defaults: sha2-256, 256 KiB chunks, balanced DAGs with 174 links per node, dag-pb leaves for CIDv0 and raw leaves for CIDv1, directories HAMT-sharded above 256 KiB of link data. Golden tests pin the output against real kubo.

Development

Built with maturin:

cd crates/aleph-cid-python
python -m venv .venv && . .venv/bin/activate
pip install maturin pytest
maturin develop
pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aleph_cid-0.1.0.tar.gz (43.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

aleph_cid-0.1.0-cp310-abi3-win_amd64.whl (273.0 kB view details)

Uploaded CPython 3.10+Windows x86-64

aleph_cid-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (420.4 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

aleph_cid-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (411.7 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

aleph_cid-0.1.0-cp310-abi3-macosx_11_0_arm64.whl (366.2 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

aleph_cid-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl (376.2 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file aleph_cid-0.1.0.tar.gz.

File metadata

  • Download URL: aleph_cid-0.1.0.tar.gz
  • Upload date:
  • Size: 43.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for aleph_cid-0.1.0.tar.gz
Algorithm Hash digest
SHA256 eb0d09993d0b1be952476d37733d3dbdc84e0a3ec4b0e6724b88094f3af8392c
MD5 72aeff4d11fa3bc81f573d25dfcef466
BLAKE2b-256 ec70379acea18f6f7c47416da3f378258cdc54ff7c7a3e29e5b25377c6260d58

See more details on using hashes here.

Provenance

The following attestation bundles were made for aleph_cid-0.1.0.tar.gz:

Publisher: release-aleph-cid.yml on aleph-im/aleph-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aleph_cid-0.1.0-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: aleph_cid-0.1.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 273.0 kB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for aleph_cid-0.1.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 d272b9aeb27f48cbc418f6d1de4b290f1f315c512b08d8d00992e913a711a336
MD5 1a4d8c22df8a2b83b12288d16a41f44e
BLAKE2b-256 5581abfd7a06b97f74efe58832b242a8e7449a41f4c9a7060d39297991268caa

See more details on using hashes here.

Provenance

The following attestation bundles were made for aleph_cid-0.1.0-cp310-abi3-win_amd64.whl:

Publisher: release-aleph-cid.yml on aleph-im/aleph-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aleph_cid-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for aleph_cid-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d76c797bae94937f9887f9c6da02b1cd25295908daa82fbed15284db3209c66d
MD5 64f9713373201a9bddc94b6ebf926ff3
BLAKE2b-256 607168347f03ddcb5806b241ee74367ad96db96866581278a091be00aef379fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for aleph_cid-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release-aleph-cid.yml on aleph-im/aleph-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aleph_cid-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for aleph_cid-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5319cb11317ac2b6ff7d41ece9ee0679653aab1035a5c4a3a0ec02dddf6cf28b
MD5 08f378e4f41e71ce0b59b22d26c005ca
BLAKE2b-256 47a7b675a113cf20a13d5a4dd6b4f29db6e8e6f34861fd0f7d4633bb8c7bc50d

See more details on using hashes here.

Provenance

The following attestation bundles were made for aleph_cid-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release-aleph-cid.yml on aleph-im/aleph-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aleph_cid-0.1.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for aleph_cid-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d4a5e6b5e4b8308fe69e48d9abfd58a025af859aff1d17f986fd44504f267288
MD5 7fb69db1f080dd3fff364d77749d958c
BLAKE2b-256 396ca8e96cd891f664f6c095e17fa1bd0ec4f41c42086910471193b1a8125133

See more details on using hashes here.

Provenance

The following attestation bundles were made for aleph_cid-0.1.0-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release-aleph-cid.yml on aleph-im/aleph-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aleph_cid-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for aleph_cid-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8022fe25c40cbe30320f06cb16c946cfb6f58a436c8a7e529fcb4255dae21a0f
MD5 bfcc0f443590eea04abf232742751ecb
BLAKE2b-256 b187403dd50631dcc7e72b05886070faa80da4c7e2d120628c7be93bfbe0ff8c

See more details on using hashes here.

Provenance

The following attestation bundles were made for aleph_cid-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: release-aleph-cid.yml on aleph-im/aleph-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page