BF-JWT-Policy
Authors: Ahmad Ali Parr, Jessica L. Williams (SNAPKITTYWEST)
RIP Black Hat. Cipher. Quantum Hacker.
Every great system must be destroyed to stand strong.
BF256 (Brainfuck as a cryptographic primitive) was attacked, broken via linear algebra in O(nΒ³), and replaced with the correct architecture.
The Architecture
JWT signature: HS256/ES256 (standard, secure)
β
SPARK-verified Brainfuck VM (bf_vm/)
β
BF program = authorization POLICY (not a key)
β
GNATprove: 100% proved, 0 checks failed
Critical distinction:
| Wrong | Right |
|---|---|
| BF as crypto key | BF as policy program |
| BF256 signature | Standard HS256/ES256 signature |
| Secret = initial tape | Secret = HMAC key |
| Broken in O(nΒ³) | SPARK-verified correct |
Why BF256 Was Broken
BF + and - operations are affine transformations over β€/256β€. With 2 known (message, signature) pairs:
sigβ = Affine(secret_tape, hash(mβ))
sigβ = Affine(secret_tape, hash(mβ))
Solve for secret_tape via linear algebra. O(nΒ³) where n = tape size (typically < 100 cells). Total break.
Ahmad found this himself. Documented it. Built the correct thing.
What's Correct
The Brainfuck VM is Turing-complete, minimal, and formally verifiable. Used as a policy evaluation engine β not a crypto primitive β it's:
- Memory safe β no buffer overflows (SPARK proved)
- Terminating β step counter decreasing invariant (SPARK proved)
- Deterministic β same input β same output (SPARK proved)
- Non-interfering β secret inputs don't leak to public outputs (SPARK proved)
GNATprove Results
Summary: 100% proved, 0 checks failed, 0 checks unproved
All overflow checks, index checks, termination, and postconditions proved.
Quick Start
# Prove SPARK
cd bf_vm && gnatprove -P bf_vm.gpr --level=2 --report=all
# Build Rust (compiles Ada + FFI)
cd ../bf_jwt_policy && cargo build --release
# Run demo
cargo run --example jwt_policy_demo
Expected:
β
Authorized! Context: PolicyContext { role: Admin, ... }
β User denied: Access denied by policy
License
Tri-license β AGPL-3.0 | BSL 1.1 β MIT | MIT
Copyright (C) 2026 Ahmad Ali Parr, Jessica L. Williams / SNAPKITTYWEST
πΌ Commercial License
Snapkitty code is free and open under AGPL-3.0 for open-source use. Building a commercial product or service? A proprietary commercial license from Snapkitty Collective LLC lets you ship this code without the AGPL's source-sharing and network-use obligations.