Skip to main content

CLSC-256-AEAD v8 — research build 0.9.0

Experimental authenticated encryption for a two-party channel, pure Python, zero runtime dependencies:

  • SpongeARX512 - 512-bit ARX permutation used as a duplex sponge (rate 256 / capacity 256 bits). The research build includes an explicit inverse for its 4-word round function and full 512-bit permutation, with algebraic notes and inverse-property regression tests.
  • BLAKE2b key schedule, per-message keys, 128-bit key commitment and a 256-bit outer MAC.
  • Module-LWE KEM (rank 2, q=3329, n=256) with Fujisaki-Okamoto transform and implicit rejection for a post-quantum ratchet. ML-KEM-512-like parameters; not FIPS 203.
  • One chain per direction, skipped-message keys (reordering / loss), replay protection.

Status: research code. No formal proof, no third-party review. Do not use it as the only protection of anything that matters. For production use ChaCha20-Poly1305 / AES-GCM (+ ML-KEM-768).

Install & use

pip install clsc256
import os
from clsc256 import CLSC256Session, SessionRole

root = os.urandom(32)                      # shared secret from your key exchange
alice = CLSC256Session(root, SessionRole.INITIATOR)
bob   = CLSC256Session(root, SessionRole.RESPONDER)

pkt = alice.encrypt(b"hello", aad=b"session:42")
assert bob.decrypt(pkt, aad=b"session:42") == b"hello"

# optional post-quantum ratchet: exchange KEM public keys over an AUTHENTICATED channel
alice.set_peer_kem_public_key(bob.local_kem_public_key)
bob.set_peer_kem_public_key(alice.local_kem_public_key)

Rules: one session object per endpoint, opposite roles on the two sides; packets that carry a PQ ratchet step (flags == 1) must not be lost (reliable transport or retransmit). Ordinary packets may be lost or reordered (up to MAX_SKIP = 64).

What the audit found and what v8 does about it

Problem (found by attacking v4 / v7) Fix in v8
v4: one forged packet permanently desynchronised the session Ratchet state changes only after full authentication
v4: no direction separation (reflection) Separate chain per direction
v4/v7: RNG failure or cloned state leaked "equal prefix" of messages Hedged synthetic nonce bound to the message
v7: PQ ratchet never worked (sender and receiver derived different keys) One shared derivation function; tested over many epochs
v7: a lost packet killed the session (skipped keys used the wrong nonce) Message keys derive from chain + seq only; delayed packets decrypt
v7: a forged packet could erase a stored key of a delayed message Key is deleted only after successful decryption
v7: KEM accepted modified ciphertexts (no FO) FO transform with implicit rejection
v7: simultaneous PQ steps desynchronised both sides Previous KEM secret key kept; packets name their target key
v7: outer MAC did not frame AAD length Lengths of AAD and header are MAC'd
v7: S-box/MDS layer with linearly dependent masks, no security gain Removed; the sponge keystream is XORed directly
README claims that were wrong (256-bit collision margin, "dynamic S-box", sqrt constants, ML-KEM) Corrected below

Mathematical verification added in research build 0.9.0

docs/PERMUTATION_SPEC.md gives the state space, round equations, inverse equations, and a construction-level argument that each round is bijective. SpongeARX512.unpermute() is the executable inverse. The test suite checks the inverse over multiple round counts and checks the Module-LWE negacyclic polynomial multiplication against a simple reference implementation.

Run the reproducible bit-diffusion experiment with:

PYTHONPATH=src python audit/permutation_analysis.py

This experiment measures avalanche propagation for selected round counts. It is a diagnostic, not a cryptanalytic attack and not evidence of pseudorandomness or security.

Honest limits

  • Sponge generic security is about 2^128 (capacity 256 bits), not 2^256.
  • Round constants are digits of pi; rotations are the BLAKE2b ones. The round function is proven bijective by construction, but there is no differential/linear/rotational or other serious cryptanalysis of the permutation. Avalanche measurements are not a security proof.
  • Pure Python: ~300 KB/s, not constant-time, zeroize is best-effort.
  • Symmetric root key must come from your own authenticated key exchange. KEM public keys must be authenticated too, otherwise the first PQ epoch adds no protection.
  • Forward secrecy: old chain keys are erased. If the root key leaks, recorded traffic is readable (the PQ ratchet only protects against later state compromise).
  • A truncated stream (dropped final packets) is not detected; add your own end-of-stream message.
  • A lost PQ-step packet stalls the receiver until it is retransmitted (it then recovers).

Reproduce the audit

pip install -e .[audit]
python -m unittest discover tests
PYTHONPATH=src python audit/permutation_analysis.py
cd audit && PYTHONPATH=../src python audit_v8.py

audit_v8.py reports median end-to-end throughput against the AES-GCM and ChaCha20-Poly1305 APIs. This is explicitly a diagnostic comparison, not a like-for-like protocol benchmark: CLSC includes session state, key derivation, padding, and its sponge, while the standard cases use library AEAD calls with a counter nonce. Do not interpret the numbers as a security ranking.

License: MIT.

Metadata

Release files for clsc256 0.9.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 clsc256 0.9.0
File Size Uploaded Provenance Actions
clsc256-0.9.0.tar.gz 17.6 kB Without provenance Details for clsc256-0.9.0.tar.gz

Built distribution (wheel)

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

Total release size: 30.8 kB

Release files / clsc256-0.9.0.tar.gz

Download URL clsc256-0.9.0.tar.gz
Size 17.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2b64d18a3b032a7fc27348c19f7bf5624c13d7f39eefde099b967b5bfd98a7c7
BLAKE2b-256 checksum
How to use checksums
5099a7aa56585402b8e674ddd2736365e74740a8b0977d75f8ea8012e3361a81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.5

Release files / clsc256-0.9.0-py3-none-any.whl

Download URL clsc256-0.9.0-py3-none-any.whl
Size 13.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6e38f11793c1a5b89f4d039abf9688c87762f28076fc1bbd70db1dbf058db93e
BLAKE2b-256 checksum
How to use checksums
f948179fbadb2b2c723e2c32e7610d7c6275cadb352ffd2bb27b38529a7d8af8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.5

Security for clsc256 0.9.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.9.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