A stateless, mathematically self-limiting authorization system.
This document walks through the Musashi Protocol from first principles. It is written for three audiences simultaneously: a development team implementing the system, a physicist interested in the thermodynamic framing, and a general reader who wants to understand what the technology does and why it matters.
Each section deepens the previous one. Start anywhere; finish wherever the math gets interesting.
Part 0: The Warrior of Two Swords
In 1643, the Japanese swordsman Miyamoto Musashi wrote The Book of Five Rings (五輪書, Go Rin no Sho). Musashi was undefeated in over sixty duels — but his legacy is not his record. His legacy is his school: Niten Ichi-ryū (二天一流), "Two Heavens as One."
Musashi's insight was simple and radical: wield two swords simultaneously. Every other school taught the katana as a two-handed weapon. Musashi held the long sword (katana) in one hand and the short sword (wakizashi) in the other. Each sword had a distinct role:
- The katana delivers the decisive, irreversible strike. It is the killing blow. Once committed, there is no withdrawal.
- The wakizashi controls distance, deflects incoming attacks, and reads the opponent's stance. It is adaptive, reactive, and — unlike the katana — can disengage without consequence.
Neither sword alone constitutes a complete warrior. A katana without awareness is reckless. A wakizashi without killing power is purely defensive. The school is the discipline that wields both.
This protocol is named for that discipline.
The Two Hemispheres
The Musashi Protocol is a bipartite authorization token — a single credential composed of two fundamentally different halves:
| The Katana | The Wakizashi | |
|---|---|---|
| Hemisphere | Rigid | Fuzzy |
| Mechanism | Hash chain + Verifiable Delay Function | Cosine similarity (SAGE manifold) |
| Nature | Deterministic, irreversible, finite | Probabilistic, reversible, continuous |
| What it proves | "I possess the next secret in an ordered sequence" | "I am operating in the correct environment" |
| On use | Burns a link — permanently consumed | Measures similarity — no state consumed |
| Failure mode | Fatal: token dies when chain is exhausted | Recoverable: conditions may return to baseline |
The hash chain IS the katana — a one-way weapon that strikes once per link and cannot be taken back. When the chain is spent, the fight is over.
The SAGE manifold IS the wakizashi — a gate that reads environmental conditions and disengages the attack if the agent drifts too far from its trusted baseline. No links are burned on a SAGE rejection. When conditions return to normal, the stance resumes.
The Warrant IS the stance that holds them together.
Every section that follows maps back to this framing.
Part 1: The Problem
Modern authorization relies on centralized databases. A session token is an opaque string that means "look me up in the server's memory." This creates three structural vulnerabilities:
- Single point of failure. If the database goes down, every token becomes unverifiable. The entire system halts.
- Replay attacks. A stolen session token is valid until the server explicitly revokes it. The token itself carries no information about whether it has already been used. The server must remember every token it has ever seen.
- Revocation cost. Maintaining a revocation list (CRL, token blacklist) requires a database lookup on every single request. At scale, this lookup becomes the bottleneck.
The Musashi Protocol eliminates all three.
The token is not an opaque reference to server state — it is a self-contained cryptographic proof. It carries its own chain of secrets, its own time-delay proof, and its own environmental fingerprint. The server (Aegis) verifies pure mathematics. There is no database to consult, no revocation list to maintain, and no session state to replicate.
The token limits itself. Each use burns a cryptographic link. When the links run out, the token is dead — by construction, not by administrative action.
Part 2: The Hash Chain — Intuitive Model
The Matchbook Analogy
A book of matches. You tear one off each time you need a flame. Once torn, it's gone — you cannot re-attach it. When the book is empty, it's dead. No one needs to revoke it. No one needs to check a list. The physics of paper makes it self-limiting.
The hash chain is a cryptographic matchbook.
How It's Built
The chain is constructed by a component called Knox (the mint). Knox starts with a random secret and applies a one-way hash function (BLAKE3) repeatedly:
secret → H¹ → H² → H³ → H⁴ → H⁵ (anchor)
Each arrow is a BLAKE3 hash. H¹ = BLAKE3(secret). H² = BLAKE3(H¹). And so on. The final value — H⁵ in this example — is the anchor.
Knox publishes only the anchor. The entire chain of intermediate values (H¹ through H⁴) is kept secret and handed to the client as a stack of pre-images.
How It Burns
The client uses the chain in reverse order, peeling off one pre-image per use:
Use 1: The client reveals H⁴. Aegis hashes it: BLAKE3(H⁴) = H⁵. This matches the anchor. Accepted. The anchor advances to H⁴.
Use 2: The client reveals H³. Aegis hashes it: BLAKE3(H³) = H⁴. This matches the new anchor. Accepted. The anchor advances to H³.
Use 3: The client reveals H². And so on.
Exhaustion: When all pre-images have been consumed, no further operations are possible. The token is dead.
Why Replay Fails
Suppose an attacker intercepts H⁴ during Use 1. They wait, then try to replay it during Use 2.
The anchor has moved to H⁴. The attacker submits H⁴. Aegis computes BLAKE3(H⁴) = H⁵. But the anchor is H⁴, not H⁵. Rejected.
The replayed value always hashes to the old anchor, not the current one. The chain moves in one direction. There is no reverse gear.
This is the core mechanism: the verification function is BLAKE3(preimage) == current_anchor. The anchor advances forward on every use. A value that satisfied a previous anchor can never satisfy the current one — because hashing it again takes you one step further from where you need to be.
The Verification Function
In Rust, the entire verification is eight lines:
pub fn verify_and_burn(
current_anchor: &[u8; 32],
revealed_preimage: &[u8; 32],
) -> Result<[u8; 32], AuthError> {
let hash = blake3::hash(revealed_preimage);
if hash.as_bytes() == current_anchor {
Ok(*revealed_preimage)
} else {
Err(AuthError::ReplayOrInvalid)
}
}
One hash. One comparison. No database. No network call. The mathematics is the entire security model.
Part 3: The Physics — Why This Is Irreversible
This section is for the physicist in the room.
One-Way Functions and Thermodynamic Arrows
A cryptographic hash function maps an input of arbitrary length to a fixed-length output (256 bits for BLAKE3). The forward direction is fast — a modern CPU computes BLAKE3 in nanoseconds. The reverse direction — finding an input that produces a given output — requires brute-forcing 2²⁵⁶ possibilities.
To put 2²⁵⁶ in physical terms: if every atom in the observable universe (~10⁸⁰ ≈ 2²⁶⁶) were a computer, and each computed one hash per Planck time (~5.4 × 10⁻⁴⁴ seconds), the search would still take longer than the current age of the universe.
This is not a computational inconvenience. It is a physical impossibility — as fundamental as the second law of thermodynamics. The hash function defines a thermodynamic arrow: the chain moves from high entropy (many possible pre-images) to low entropy (one specific anchor) in the forward direction. Reversing it would require decreasing the entropy of a 256-bit system, which is forbidden by the same physics that forbids heat flowing from cold to hot spontaneously.
The Chain as Energy Dissipation
Each link in the chain is a unit of "cryptographic fuel." When the client reveals a pre-image, that fuel is burned — the information is now public, and the anchor advances past it. The burned link can never generate useful work again, just as dissipated heat cannot be recaptured without violating Carnot's limit.
The chain moves from N available pre-images to N-1, to N-2, until it reaches zero. This is monotonic, irreversible decay. The token's "temperature" (remaining uses) drops with each execution until it reaches absolute zero: death.
The VDF as a Physical Clock
The Verifiable Delay Function adds a second physical constraint. Before each use, the client must compute a sequence of T hash iterations:
state₀ → BLAKE3 → state₁ → BLAKE3 → state₂ → ... → stateₜ
Each step depends on the output of the previous step. This is inherently sequential — parallelism does not help. The minimum time to produce the proof is bounded by the speed of light through the silicon: T iterations × (single-hash latency).
The VDF converts computational cost into physical time. You cannot present a valid proof faster than the laws of physics allow the computation to complete. This is thermodynamic time-decay: the token ages in real, physical time, not wall-clock time that can be manipulated.
Part 4: The Bipartite Token — Two Hemispheres
The hash chain is powerful but blind. It verifies that the client possesses the correct secret — but it says nothing about who the client is or where they are operating. A stolen pre-image works just as well in an attacker's hands.
This is where the second hemisphere enters.
The SAGE Manifold
SAGE (Similarity-Assessed Governance Envelope) is a cosine similarity gate. At minting time, Knox captures an environmental or biometric fingerprint — a vector of floating-point values representing sensor readings, behavioral patterns, or any measurable context. This becomes the baseline.
On each execution, the client submits a fresh sample vector. Aegis computes the cosine similarity between the sample and the baseline:
$$\cos(\theta) = \frac{\mathbf{a} \cdot \mathbf{b}}{\|\mathbf{a}\| \, \|\mathbf{b}\|}$$
If the similarity is below the governance threshold Θ, the request is rejected. The client's environment has drifted too far from the conditions under which the token was issued.
The Cryptographic Clutch
Think of the hash chain as an engine and the SAGE manifold as a clutch.
- The engine (hash chain) burns fuel on every cycle. Each ignition is irreversible — the fuel is consumed.
- The clutch (SAGE) can disengage the engine from the wheels without consuming fuel. If conditions are wrong — the road is icy, the driver is unfamiliar — the clutch disconnects. No fuel is wasted. When conditions normalize, the clutch re-engages and the engine resumes.
A SAGE rejection does not advance the chain. No pre-image is burned. The token's "fuel level" is preserved. This is the critical distinction: the rigid hemisphere is irreversible (burning), while the fuzzy hemisphere is reversible (sensing).
Why Two Hemispheres?
| Attack | Hash Chain Alone | Hash Chain + SAGE |
|---|---|---|
| Stolen pre-image | Succeeds — attacker has the secret | Fails — attacker's environment differs |
| Environment drift (legitimate) | Burns a use on failure | Rejects without burning — preserves token life |
| Pre-image exhaustion | Token dies | Token dies (SAGE cannot prevent this) |
| Simultaneous pre-image theft + environment cloning | Succeeds | Succeeds (but vastly harder) |
The bipartite design means an attacker must compromise both the discrete secret (pre-image) and the continuous environment (sensor context). These are fundamentally different attack surfaces — one requires information theft, the other requires physical presence.
Part 5: The Full Protocol — From Mint to Death
The complete lifecycle of a Musashi token involves five stages and three independent verification gates.
Stage 1: WARD Challenge
Before Knox will mint anything, the client must solve a Proof-of-Work puzzle. This is the WARD gate — a computational toll that prevents mass-minting attacks.
The client receives a challenge (a random seed + a difficulty target) and must find a nonce such that:
Argon2id(seed || nonce) has `difficulty` leading zero bits
Argon2id is a memory-hard function: it requires significant RAM to evaluate, making it resistant to ASIC and GPU brute-forcing. The client proves it invested real computational resources before Knox allocates any cryptographic material.
Stage 2: Knox Mint
Knox generates the complete token:
- Creates a random secret and builds the hash chain (N links)
- Issues a VDF challenge (random seed + difficulty)
- Captures the environmental baseline (SAGE fingerprint)
- Packages everything into a
MintedPayload:
- The Warrant (public: anchor, VDF challenge, SAGE parameters)
- The pre-images (secret: the hash chain links, given only to the client)
Stage 3: VDF Solve
The client solves the VDF challenge by performing T sequential BLAKE3 iterations. This cannot be parallelized — each hash depends on the previous output. The proof is the final hash value.
This stage anchors the token in physical time. The client cannot pre-compute the proof (the challenge is not known until minting) and cannot accelerate it beyond hardware limits.
Stage 4: Aegis Verify — The Three Gates
Aegis is the execution boundary. It receives the client's request and runs three independent verification gates in sequence:
Gate 1 — VDF Gate: Verify that the submitted VDF proof matches the challenge in the Warrant. This confirms the client invested the required computation time.
Gate 2 — SAGE Gate: Compute the cosine similarity between the client's fresh environmental sample and the stored baseline. If the similarity falls below the governance threshold, reject. No chain state is modified on rejection.
Gate 3 — Chain Gate: Hash the submitted pre-image and compare it to the current anchor. If it matches, the anchor advances and the pre-image is burned. This is the irreversible step.
All three gates must pass. Any single failure aborts the entire operation.
Stage 5: CanonMDB Crystallize
On a successful pass through all three gates, Aegis writes a CrystallizedAct to the CanonMDB — an append-only, Merkle-linked ledger. Each act records:
- The token identity (genesis hash)
- The previous anchor and the revealed pre-image
- The SAGE similarity score at the moment of execution
- A BLAKE3 hash linking this act to the previous one
The CanonMDB provides tamper-evident "episodic memory" — a complete, verifiable record of every state transition the token has undergone. If any entry is altered, the Merkle chain breaks and the tampering is detectable.
Stage 6: Token Death
When the last pre-image is consumed, the chain is exhausted. There are no more secrets to reveal. The token is dead — not by revocation, not by expiration, but by mathematical necessity. The matchbook is empty.
Part 6: The Proof — What We Tested
The Musashi Protocol was subjected to a comprehensive adversarial test suite: 49 attacks across 7 distinct vectors. The goal was to break the math, not to find bugs — to demonstrate that the cryptographic primitives hold under hostile conditions.
Attack Vectors
| Vector | Target | Attacks | Result |
|---|---|---|---|
| V1: Hash Chain | Collision resistance, skip-link, reversal, ordering | 8 | All rejected |
| V2: VDF | Wrong difficulty, wrong seed, partial proof, zero proof | 6 | All rejected |
| V3: SAGE Manifold | Orthogonal injection, NaN, Inf, zero vector, near-threshold | 7 | All rejected |
| V4: CanonMDB | Field tampering, hash substitution, chain reordering | 6 | All detected |
| V5: WARD PoW | Wrong nonce, difficulty downgrade, ASIC simulation | 5 | All rejected |
| V6: Protocol Composition | Fuzzy pass without chain, chain pass without fuzzy | 6 | All rejected |
| V7: Network Concurrency | 500-concurrent double-spend, stale VDF, ghost token | 11 | All rejected |
Total: 49 attacks, 7 vectors, 0 weaknesses found.
For detailed methodology and results, see:
BUILDLOG.md — Entry 13(adversarial test suite)RESEARCH_PRIMER.md(mathematical foundations)core-primitives/tests/adversarial.rs(Rust integration tests)run_adversarial_stress.sh(network-level concurrency attacks)
Part 7: For the Engineer — Code Reference
The implementation lives in a Rust Cargo workspace. Here is a direct map from concepts to source files:
| Concept | File | Key Functions |
|---|---|---|
| Hash chain construction & verification | core-primitives/src/crypto.rs | generate_chain, verify_and_burn |
| VDF (sequential-hash, Core) | core-primitives/src/vdf.rs | solve, verify |
| VDF (RSW Time-Lock, MusashiSS) | core-primitives/src/vdf_ss.rs | generate_puzzle, solve, verify |
| SAGE manifold (cosine similarity) | core-primitives/src/fuzzy.rs | cosine_similarity |
| CanonMDB (Merkle-linked ledger) | core-primitives/src/canonmdb.rs | CrystallizedAct::new, verify |
| WARD PoW (BLAKE3) | core-primitives/src/ward.rs | generate_challenge, solve, verify |
| WARD PoW (Argon2id, ASIC-resistant) | core-primitives/src/ward_argon.rs | generate_challenge, solve, verify |
| Warrant (bipartite token) | core-primitives/src/warrant.rs | Warrant, MintedPayload |
| Knox (minting engine) | knox/src/main.rs | challenge, mint subcommands |
| Aegis (verification daemon) | aegis/src/main.rs | Axum HTTP handlers |
| Aegis shared state | aegis/src/state.rs | SharedState, TokenEntry |
Two Forks
The codebase ships two implementations:
- Musashi Core — sequential-hash VDF. Verification cost is O(T), matching the solver's cost. Simpler, but vulnerable to verification DDOS at high difficulty.
- MusashiSS — RSW Time-Lock puzzle. Verification cost is O(1) via the RSA trapdoor (knowledge of φ(N)). Production-grade, but requires trusting the key generator.
Both forks share the same hash chain, SAGE manifold, CanonMDB, and WARD modules. The only difference is the VDF implementation.
Further Reading
BUILDLOG.md— Chronological development log with all 13 entries and 3 cleared security minesRESEARCH_PRIMER.md— Formal cryptographic definitions, mathematical constructions, and bibliographySHORTSWORD.md— Design consideration for hiding SAGE parameters from the client (zero-knowledge environmental proof)README.md— Quick start, CLI reference, and project structure
Neither sword alone constitutes a complete warrior.
— Niten Ichi-ryū