Skip to main content

ChaCha20-Blake3

Standard IETF ChaCha20-Poly1305 style construct with a cryptographically strong BLAKE3 hash instead, preventing key holders from crafting different messages that correspond to same tag or ciphertext.

The implementation follows standard practices, not the vastly modified KERKOUR ChaCha20-BLAKE3 implementation. Therefore we keep 12 byte nonce and 16 byte default tag length, so this remains a full drop-in replacement for ChaCha20-Poly1305, whereas they use 32 bytes for each, staged key/nonce derivation and a completely different authentication format.

Draft version 0.1.0: Implementation is still likely to change. Do not use in production.

Features

  • Boxes: encrypt/decrypt and encrypt_into/decrypt_into — one-shot AEAD with appended random nonce, associated data, and MAC.
  • Detached nonces: the standard AEAD construct using a provided nonce and does not attach it to the ciphertext; as opposed to random nonce attached in boxes
  • Detached tags: tag — compute the BLAKE3 authentication tag separately, for use with external signature schemes over the tag.
  • Channels: Sender/Receiver — ordered message encryption/decryption over a shared key using an incrementing counter nonce.
  • CSPRNG: random(n) / random(buf) — fast ChaCha20-based random bytes, thread-safe, seeded from OS randomness.

Wire format: ciphertext mac [nonce]. The MAC is a keyed BLAKE3 over the associated data and ciphertext; the key stream is IETF ChaCha20.

Usage

import chab3

key = chab3.random(32)

ct = chab3.encrypt(b"hello", key, ad=b"metadata")
msg = chab3.decrypt(ct, key, ad=b"metadata")

s, r = chab3.Sender(key), chab3.Receiver(key)
assert r.decrypt(s.encrypt(b"in order")) == b"in order"

Using existing output buffer, in-place operation:

buf = bytearray(100)
out = chab3.encrypt_into(buf, b"attack at dawn", key)  # out is a sliced memoryview into buf
msg = chab3.decrypt_into(buf, out, key)  # memoryview into buf now showing b"hello"

Tampered ciphertext raises chab3.WireError; caller misuse (wrong buffer or key sizes) raises TypeError.

Metadata

Release files for chab3 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for chab3 0.1.0
File Size Uploaded Provenance Actions
chab3-0.1.0.tar.gz 90.2 kB Without provenance Details for chab3-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for chab3 0.1.0
File Interpreter ABI Platform Actions
chab3-0.1.0-py3-none-any.whl Python 3 none any Details for chab3-0.1.0-py3-none-any.whl

Total release size: 94.6 kB

Release files / chab3-0.1.0.tar.gz

Download URL chab3-0.1.0.tar.gz
Size 90.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d0f5642e5359082d7058422d5d6a1427ea999f59aa211f71ec1b530ad3afa396
BLAKE2b-256 checksum
How to use checksums
9b05d4d5b741d4790f656ccaae94233851b8b6183313fbf34f68ce911c16801b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / chab3-0.1.0-py3-none-any.whl

Download URL chab3-0.1.0-py3-none-any.whl
Size 4.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
165f11bc53b62ac03f4630529cb2b5c0d96f568e34e27341dd2e2be33ab92fc2
BLAKE2b-256 checksum
How to use checksums
32e45065763267309f19dbf5c521031566807fcc8838c877f66e319f273c77b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for chab3 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page