chacha

The ChaCha20 stream cipher (docs.ppad.tech/chacha).
git clone git://git.ppad.tech/chacha.git
Log | Files | Refs | README | LICENSE

commit 9adca9651d3098b8fa2ce48f663c5ac6105dc90e
parent 77d52db9f9b824f3c4b2ffcfb863e097da7debf4
Author: Jared Tobin <jared@jtobin.io>
Date:   Sat, 21 Jun 2025 14:27:46 +0400

release: v0.2.0

Diffstat:
MCHANGELOG | 5+++++
MREADME.md | 11+++++------
Mflake.lock | 8++++----
Mlib/Crypto/Cipher/ChaCha20.hs | 2+-
Mppad-chacha.cabal | 2+-
5 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG @@ -1,5 +1,10 @@ # Changelog +- 0.2.0 (2025-06-21) + * Both the ChaCha block function and stream cipher are now total, + returning values of 'Left InvalidKey' or 'Left InvalidNonce' when + supplied with the corresponding bad inputs. + - 0.1.0 (2025-03-09) * Initial release, supporting the chacha20 stream cipher and block function. diff --git a/README.md b/README.md @@ -40,16 +40,15 @@ The aim is best-in-class performance for pure, highly-auditable Haskell code. Current benchmark figures on the simple "sunscreen input" from RFC8439 -on my mid-2020 MacBook Air look like (use `cabal bench` to run the +on an M4 Silicon MacBook Air look like (use `cabal bench` to run the benchmark suite): ``` benchmarking ppad-chacha/cipher - time 1.554 μs (1.510 μs .. 1.596 μs) - 0.995 R² (0.994 R² .. 0.997 R²) - mean 1.541 μs (1.511 μs .. 1.579 μs) - std dev 115.1 ns (95.95 ns .. 139.7 ns) - variance introduced by outliers: 81% (severely inflated) + time 770.2 ns (769.9 ns .. 770.5 ns) + 1.000 R² (1.000 R² .. 1.000 R²) + mean 770.2 ns (770.0 ns .. 770.5 ns) + std dev 794.7 ps (653.0 ps .. 999.5 ps) ``` ## Security diff --git a/flake.lock b/flake.lock @@ -51,11 +51,11 @@ ] }, "locked": { - "lastModified": 1740802922, - "narHash": "sha256-j+sxOWxnsMgX3GHyf7Z44lvAiBkrl/p0lD0eYli6Lgo=", + "lastModified": 1741625558, + "narHash": "sha256-ZBDXRD5fsVqA5bGrAlcnhiu67Eo50q0M9614nR3NBwY=", "ref": "master", - "rev": "043c845ae7f280ddbfdb5568ea453c9943e49cf2", - "revCount": 21, + "rev": "fb63457f2e894eda28250dfe65d0fcd1d195ac2f", + "revCount": 24, "type": "git", "url": "git://git.ppad.tech/base16.git" }, diff --git a/lib/Crypto/Cipher/ChaCha20.hs b/lib/Crypto/Cipher/ChaCha20.hs @@ -332,7 +332,7 @@ serialize (ChaCha m) = do -- >>> cip -- "\192*c\248A\204\211n\130y8\197\146k\245\178Y\197=\180_\223\138\146:^\206\&0\v[\201" -- >>> cipher key 1 non cip --- "but you can share the plaintext" +-- Right "but you can share the plaintext" cipher :: BS.ByteString -- ^ 256-bit key -> Word32 -- ^ 32-bit counter diff --git a/ppad-chacha.cabal b/ppad-chacha.cabal @@ -1,6 +1,6 @@ cabal-version: 3.0 name: ppad-chacha -version: 0.1.0 +version: 0.2.0 synopsis: A pure ChaCha20 stream cipher license: MIT license-file: LICENSE