bech32

Pure Haskell bech32, bech32m encoding/decoding (docs.ppad.tech/bech32).
git clone git://git.ppad.tech/bech32.git
Log | Files | Refs | README | LICENSE

commit 55f351f4c17608f6c384cddc4112418f1409674a
parent 95c41c2a1064d3b433bfe6d0087a2f4776b00c23
Author: Jared Tobin <jared@jtobin.io>
Date:   Sun, 28 Dec 2025 12:18:07 -0330

release: v0.2.4

Diffstat:
MCHANGELOG | 3+++
MREADME.md | 21+++++++++++----------
Mbench/Reference/Bech32.hs | 1-
Mflake.lock | 20++++++++++----------
Mflake.nix | 4++--
Mppad-bech32.cabal | 4++--
Mtest/Reference/Bech32.hs | 1-
7 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG @@ -1,5 +1,8 @@ # Changelog +- 0.2.4 (2025-12-28) + * Adds an 'llvm' build flag and tests with GHC 9.10.3. + - 0.2.3 (2025-06-21) * Minor performance improvements and internal housekeeping. diff --git a/README.md b/README.md @@ -49,18 +49,19 @@ Current benchmark figures on a M4 Silicon MacBook Air look like (use `cabal bench` to run the benchmark suite): ``` - benchmarking benchmarks/ppad-bech32/bech32 encode/120b - time 462.7 ns (460.8 ns .. 465.5 ns) - 1.000 R² (1.000 R² .. 1.000 R²) - mean 465.5 ns (464.3 ns .. 466.6 ns) - std dev 3.955 ns (3.485 ns .. 4.602 ns) + benchmarking benchmarks/ppad-bech32/bech32 decode/120b + time 501.7 ns (497.7 ns .. 505.6 ns) + 0.999 R² (0.999 R² .. 1.000 R²) + mean 494.4 ns (491.6 ns .. 498.0 ns) + std dev 10.81 ns (8.895 ns .. 12.98 ns) + variance introduced by outliers: 28% (moderately inflated) benchmarking benchmarks/ppad-bech32/bech32 decode/120b - time 499.4 ns (497.5 ns .. 502.3 ns) - 1.000 R² (1.000 R² .. 1.000 R²) - mean 508.0 ns (505.2 ns .. 510.8 ns) - std dev 9.101 ns (7.828 ns .. 11.23 ns) - variance introduced by outliers: 21% (moderately inflated) + time 501.7 ns (497.7 ns .. 505.6 ns) + 0.999 R² (0.999 R² .. 1.000 R²) + mean 494.4 ns (491.6 ns .. 498.0 ns) + std dev 10.81 ns (8.895 ns .. 12.98 ns) + variance introduced by outliers: 28% (moderately inflated) ``` You should compile with the 'llvm' flag for maximum performance. diff --git a/bench/Reference/Bech32.hs b/bench/Reference/Bech32.hs @@ -20,7 +20,6 @@ import Data.Bits (Bits, unsafeShiftL, unsafeShiftR, (.&.), (.|.), xor, testBit) import qualified Data.ByteString as BS import qualified Data.ByteString.Char8 as BSC import Data.Char (toLower, toUpper) -import Data.Foldable (foldl') import Data.Functor.Identity (Identity, runIdentity) import Data.Ix (Ix(..)) import Data.Word (Word8) diff --git a/flake.lock b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "owner": "numtide", "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "type": "github" }, "original": { @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1725910328, - "narHash": "sha256-n9pCtzGZ0httmTwMuEbi5E78UQ4ZbQMr1pzi5N0LAG8=", + "lastModified": 1766840161, + "narHash": "sha256-Ss/LHpJJsng8vz1Pe33RSGIWUOcqM1fjrehjUkdrWio=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5775c2583f1801df7b790bf7f7d710a19bac66f4", + "rev": "3edc4a30ed3903fdf6f90c837f961fa6b49582d1", "type": "github" }, "original": { @@ -40,11 +40,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1737297101, - "narHash": "sha256-EnXnq+JLflbWt+DvaGGnY2gfAqsGNOm5vPgHh3hkfwQ=", + "lastModified": 1766932084, + "narHash": "sha256-GvVsbTfW+B7IQ9K/QP2xcXJAm1lhBin1jYZWNjOzT+o=", "ref": "master", - "rev": "f29823875250bc99b3891f7373535ccde9a29a44", - "revCount": 1, + "rev": "353e61763b959b960a55321a85423501e3e9ed7a", + "revCount": 2, "type": "git", "url": "git://git.ppad.tech/nixpkgs.git" }, diff --git a/flake.nix b/flake.nix @@ -18,9 +18,9 @@ pkgs = import nixpkgs { inherit system; }; hlib = pkgs.haskell.lib; - llvm = pkgs.llvmPackages_15.llvm; + llvm = pkgs.llvmPackages_19.llvm; - hpkgs = pkgs.haskell.packages.ghc981.extend (new: old: { + hpkgs = pkgs.haskell.packages.ghc910.extend (new: old: { ${lib} = old.callCabal2nixWithOptions lib ./. "--enable-profiling" {}; }); diff --git a/ppad-bech32.cabal b/ppad-bech32.cabal @@ -1,6 +1,6 @@ cabal-version: 3.0 name: ppad-bech32 -version: 0.2.3 +version: 0.2.4 synopsis: bech32 and bech32m encoding/decoding, per BIPs 173 & 350. license: MIT license-file: LICENSE @@ -8,7 +8,7 @@ author: Jared Tobin maintainer: jared@ppad.tech category: Cryptography build-type: Simple -tested-with: GHC == 9.8.1 +tested-with: GHC == 9.10.3 extra-doc-files: CHANGELOG description: bech32 and bech32m encoding/decoding on strict bytestrings, per BIPs diff --git a/test/Reference/Bech32.hs b/test/Reference/Bech32.hs @@ -20,7 +20,6 @@ import Data.Bits (Bits, unsafeShiftL, unsafeShiftR, (.&.), (.|.), xor, testBit) import qualified Data.ByteString as BS import qualified Data.ByteString.Char8 as BSC import Data.Char (toLower, toUpper) -import Data.Foldable (foldl') import Data.Functor.Identity (Identity, runIdentity) import Data.Ix (Ix(..)) import Data.Word (Word8)