Skip to content
Adventures and Amusings of a Mathematician
Go back

The Math Behind Rand Protocol: A Friendly Walkthrough

The original Rand Protocol whitepaper is dense. It assumes you already know what a Merkle tree, a STARK, a quorum certificate, and the Module-LWE problem are. If you don’t, the formal definitions can feel like a wall.

This post walks through the same mathematics in a friendlier way. The audience I have in mind is a beginner-level mathematician — someone comfortable with proofs, modular arithmetic, and basic probability, but who has not yet spent a year reading IACR papers. Where the whitepaper writes a definition, I explain the intuition first, then the symbols. Where the whitepaper writes a proof, I sketch the idea before the algebra.

The protocol itself is what you’d get if you tried to design a privacy-preserving blockchain that can survive both a Byzantine adversary today and a quantum computer ten years from now. That sounds ambitious, and it is — but the building blocks are by now standard, and the mathematics is more accessible than the literature suggests.

What Rand Is, in One Paragraph

Rand combines two ideas. First, Byzantine Fault Tolerant consensus (specifically HotStuff): a small set of validators agree on the next block in 2–6 seconds with deterministic finality, tolerating up to one third of them being malicious. Second, GPU-driven zero-knowledge proving: anyone with a GPU can earn tokens by generating STARK proofs that authorize private transactions. The first gives speed and decentralized agreement; the second gives privacy and a permissionless entry point. The protocol runs on the Solana Virtual Machine (SVM), uses a dual-token economy (ATLAS for public gas and validator stake, SHRUGG for private gas and prover rewards), and chooses cryptographic primitives that remain secure under quantum attack.

The Cryptographic Building Blocks

Before any consensus or privacy logic, we need three primitives. Each can be defined in one or two lines, so let’s get them out of the way.

Hash Functions

A hash function H:{0,1}∗→{0,1}λH : \{0,1\}^* \to \{0,1\}^\lambda takes any-length input and produces a fixed-length output of λ\lambda bits. We say HH is collision-resistant if no efficient adversary can find two distinct inputs x≠x′x \neq x' with H(x)=H(x′)H(x) = H(x') except with negligible probability.

“Negligible” has a precise meaning here: it’s a function ϵ(λ)\epsilon(\lambda) that shrinks faster than any inverse polynomial as λ\lambda grows. For practical purposes, ϵ(2128)≈0\epsilon(2^{128}) \approx 0 — small enough that you’d need more energy than the sun emits to brute-force.

Rand uses SHA-3 and BLAKE3 as its hash functions. Both give 128 bits of post-quantum collision resistance, which I’ll explain below.

Digital Signatures

A signature scheme is a triple Σ=(KeyGen,Sign,Verify)\Sigma = (\mathsf{KeyGen}, \mathsf{Sign}, \mathsf{Verify}):

The security property is existential unforgeability under chosen-message attack (EUF-CMA): an adversary who can request signatures on any messages of their choosing still cannot produce a valid signature on a new message. This is the cryptographic version of “even if you watch me sign a thousand documents, you can’t forge my signature on a thousand-and-first.”

Rand uses CRYSTALS-Dilithium, a NIST-standardized lattice-based signature scheme. Public keys are 1,312 bytes; signatures are 2,420 bytes. That’s larger than ECDSA, but the trade-off is that lattice problems remain hard for quantum computers.

Commitment Schemes

A commitment lets you “lock in” a value without revealing it, and later “open” it to prove what you committed to. Two properties matter:

Rand uses Pedersen commitments:

Comm(v;r)=v⋅G+r⋅H\mathsf{Comm}(v; r) = v \cdot G + r \cdot H

where G,HG, H are independent generators of an elliptic-curve group of prime order qq. Hiding follows from rr being uniformly random; binding follows from the discrete log between GG and HH being unknown.

Zero-Knowledge Proofs

This is the magical primitive. A zero-knowledge proof system for a relation RR lets a prover convince a verifier that they know a witness ww for a statement xx (i.e., (x,w)∈R(x, w) \in R), without revealing anything about ww.

Three properties define it:

Rand uses STARKs (Scalable Transparent Arguments of Knowledge). The two adjectives matter: scalable means proof verification is logarithmic in the size of the computation; transparent means there is no trusted setup ceremony. Proof size is O(log⁡2n)O(\log^2 n) for a computation of size nn, and verification takes O(log⁡2n)O(\log^2 n) time. Concretely, a private-transfer proof is 50–200 KB and verifies in 2–5 ms.

Byzantine Fault Tolerance

Finally, the consensus primitive. A protocol is Byzantine fault tolerant if it maintains safety (no two honest nodes disagree) and liveness (the protocol keeps making progress) even when up to ff of nn nodes behave arbitrarily — including lying, colluding, or going silent.

The classical Lamport–Shostak–Pease result says you need

n≥3f+1n \geq 3f + 1

That is: to tolerate ff Byzantine nodes you need at least 3f+13f + 1 total nodes. Equivalently, fewer than one third can be malicious.

The Dual-Token Architecture

Most privacy-preserving blockchains pay for gas in the same token they hold. Rand splits the gas token in two, and there is a real mathematical reason for this.

Why Two Tokens

Suppose Alice has a public identity tied to address AA, and she wants to make a private transaction txpriv\text{tx}_{\text{priv}}. If she pays gas for txpriv\text{tx}_{\text{priv}} from AA, an observer can chain the inferences:

txpriv←gas paymentA←ownershipAlice\text{tx}_{\text{priv}} \xleftarrow{\text{gas payment}} A \xleftarrow{\text{ownership}} \text{Alice}

The privacy of the transaction body is irrelevant — the gas payment alone deanonymizes the sender. This is a gas payment privacy leak, and it’s a theorem, not just a pitfall: in any single-token system where private transactions pay gas in the public token, an adversary can correlate private transactions with public identities through gas patterns.

Rand fixes this by giving private transactions their own gas token, SHRUGG, which can itself be held in shielded form and spent for gas inside the zero-knowledge circuit. The relation the prover must satisfy looks like:

Rprivate gas={Valid private transfer proof∧ Gas note nullifier valid∧ Gas amount≥required feeR_{\text{private gas}} = \begin{cases} \text{Valid private transfer proof} \\ \land \ \text{Gas note nullifier valid} \\ \land \ \text{Gas amount} \geq \text{required fee}\end{cases}

So the gas payment itself is part of the zero-knowledge proof. The chain of inferences above is broken at the first arrow.

The Two Roles

The diversification matters for the stablecoin: ATLAS price reflects validator demand and public-transaction throughput, while SHRUGG price reflects proof-generation demand. Their correlation is low, which makes the basket more stable than either alone.

Resource Accounting

Public and private transactions consume different resources:

ResourcePublic txPrivate tx
SVM computationHighLow
State storageVariableFixed (one commitment)
BandwidthLowHigh (50–200 KB proofs)
GPU provingNoneHigh (3–10 seconds)
VerificationSignature onlySTARK verification

Two gas tokens let you price these accurately without one transaction type subsidizing the other.

Consensus: HotStuff BFT

Rand uses HotStuff, a BFT protocol with linear message complexity (most BFT protocols are O(n2)O(n^2)). The protocol proceeds in views, each with a designated leader.

Quorum Certificates

A Quorum Certificate (QC) for block BB at view vv is a set of signatures from at least 2f+12f + 1 validators on the tuple

(B.hash,v,type)(B.\text{hash}, v, \text{type})

where type∈{prepare,precommit,commit}\text{type} \in \{\text{prepare}, \text{precommit}, \text{commit}\}. A QC is the protocol’s way of saying “a supermajority of validators agreed to this.” Each block goes through three QC stages — prepare, pre-commit, commit — before being finalized.

Why Three Phases

The three-phase structure exists to handle the case where a leader is replaced mid-flight without the network ever committing to two conflicting blocks. Two-phase BFT (like the original PBFT) needs a more complex view-change subprotocol; HotStuff’s third phase eliminates that complexity at the cost of one extra round of voting.

Leader Selection

Leaders are picked deterministically using a stake-weighted Verifiable Random Function (VRF):

Leader(v)=Vactive[i],i=VRF(epoch seed,v) mod ∣Vactive∣\text{Leader}(v) = V_{\text{active}}[i], \quad i = \mathsf{VRF}(\text{epoch seed}, v) \bmod |V_{\text{active}}|

A VRF is essentially a signature scheme whose output is also a uniform-looking random string — anyone can verify the leader was chosen correctly, but no one can predict or grind the next leader without breaking the VRF. This blocks grinding attacks, where an adversary tries many candidate seeds to bias future leader selection.

Safety Theorem

Here is the proof I think is worth seeing in full because the algebra is clean.

Theorem (Safety). If fewer than f<n/3f < n/3 validators are Byzantine, no two honest validators commit to conflicting blocks.

Proof. Suppose for contradiction that honest validators V1,V2V_1, V_2 commit to conflicting blocks B,B′B, B' at the same height. Each commit required a commit-QC, so

∣SB∣≥2f+1,∣SB′∣≥2f+1|S_B| \geq 2f + 1, \qquad |S_{B'}| \geq 2f + 1

where SBS_B is the signing set for BB. With n=3f+1n = 3f + 1 total validators, inclusion–exclusion gives

∣SB∩SB′∣≥(2f+1)+(2f+1)−(3f+1)=f+1.|S_B \cap S_{B'}| \geq (2f+1) + (2f+1) - (3f+1) = f + 1.

So at least f+1f+1 validators signed both blocks. By assumption, at most ff are Byzantine, so at least one honest validator signed both — but the protocol forbids honest validators from doing that. Contradiction. ■\blacksquare

The whole argument is a counting bound on intersection sizes. This is what’s beautiful about BFT proofs: the security reduces to elementary combinatorics applied to overlapping quorums.

Slashing

Byzantine behavior is also discouraged economically:

ViolationSlashJail
Double-signing33%Permanent
Extended downtime (>24h)1%7 days
Invalid block proposal50%Permanent
Provable censorship10%30 days

This is what eliminates the nothing-at-stake problem — in PoS without slashing, a rational validator might sign every fork “just in case,” because there’s no cost. With 33% slashing for double-signing, that strategy has expected return −0.33⋅S-0.33 \cdot S and is dominated.

Privacy: STARKs Over Note Commitments

Rand’s privacy system uses a UTXO-style “note” model, where each unit of private value is a record committed into a Merkle tree.

Notes, Commitments, Nullifiers

A private note is a tuple

note=(v,asset,ρ,r,pkowner)\text{note} = (v, \text{asset}, \rho, r, \text{pk}_{\text{owner}})

where vv is the value, asset\text{asset} is the asset identifier, ρ\rho is a unique nullifier seed, rr is randomness, and pkowner\text{pk}_{\text{owner}} is the owner’s public key. Notes are stored only as their commitments:

cm=H(H(pkowner) ∥ v ∥ asset ∥ ρ ∥ r)\text{cm} = H(H(\text{pk}_{\text{owner}}) \,\|\, v \,\|\, \text{asset} \,\|\, \rho \,\|\, r)

To spend a note, the owner publishes its nullifier:

nf=H(sk ∥ ρ)\text{nf} = H(\text{sk} \,\|\, \rho)

Two properties are doing all the work here. First, the nullifier is deterministic in the secret key and seed, so any attempt to spend the same note twice produces the same nf\text{nf}, which validators can detect. Second, the nullifier is unlinkable to the commitment: given nf\text{nf}, you cannot tell which cm\text{cm} it spent without knowing sk\text{sk}.

The Transfer Circuit

To make a private transfer, the sender produces a STARK proof for the relation:

The relation RtransferR_{\text{transfer}} that the prover must satisfy is the conjunction of five conditions. Letting {noteiin}\{\text{note}^{\text{in}}_i\} be the input notes and {notejout}\{\text{note}^{\text{out}}_j\} the output notes:

  1. Membership. Every input commitment is in the Merkle tree: for all ii, MerkleVerify(rt,cmiin,pathi)=1\mathsf{MerkleVerify}(\text{rt}, \text{cm}^{\text{in}}_i, \text{path}_i) = 1.
  2. Nullifier correctness. Each nullifier is correctly derived from the secret key and the note’s seed: nfi=H(sk∥ρi)\text{nf}_i = H(\text{sk} \Vert \rho_i).
  3. Commitment correctness. Each output commitment is correctly formed: cmj=Commit(notejout)\text{cm}_j = \mathsf{Commit}(\text{note}^{\text{out}}_j).
  4. Value conservation. Total value in equals total value out: ∑iviin=∑jvjout\sum_i v^{\text{in}}_i = \sum_j v^{\text{out}}_j. No minting, no burning.
  5. Asset preservation. All input and output notes share the same asset type.

The verifier sees only the public inputs — the Merkle root rt\text{rt}, the nullifiers {nfi}\{\text{nf}_i\}, the new commitments {cmj}\{\text{cm}_j\}, and the asset identifier — and is convinced that all five conditions hold without learning which notes were spent, who the parties are, or how much changed hands.

Why STARKs

Rand’s STARK uses the Goldilocks field Fp\mathbb{F}_p with p=264−232+1p = 2^{64} - 2^{32} + 1 (chosen for fast arithmetic on 64-bit CPUs and GPUs), BLAKE3 as the hash, blowup factor 8, and 30 FRI queries. This gives 100+ bits of soundness, ~120 KB proofs, and 2–5 ms verification.

The key reason for STARKs over SNARKs is post-quantum security: STARK soundness rests only on the collision resistance of a hash function, while many SNARKs use elliptic-curve pairings that fall to Shor’s algorithm.

Recipient Notification

To inform the recipient of a new note, the sender attaches an encrypted output:

enc note=Encpkrecipient(note)\text{enc note} = \mathsf{Enc}_{\text{pk}_{\text{recipient}}}(\text{note})

using CRYSTALS-Kyber for post-quantum key encapsulation. The recipient scans new commitments, tries to decrypt each attached ciphertext with their secret key, and recovers any notes addressed to them.

Supply Auditability

A privacy chain must answer an awkward question: how do we know nobody is silently minting tokens inside the shielded pool?

For ATLAS (the public token), supply is just an arithmetic sum:

SATLAS(h)=Sinitial+∑i=0hBlockReward(i)+∑i=0hStakingRewards(i)−∑i=0hBurned(i)S_{\text{ATLAS}}(h) = S_{\text{initial}} + \sum_{i=0}^{h} \text{BlockReward}(i) + \sum_{i=0}^{h} \text{StakingRewards}(i) - \sum_{i=0}^{h} \text{Burned}(i)

with Sinitial=500,000,000S_{\text{initial}} = 500{,}000{,}000 ATLAS at genesis. Every block header carries the running total and the delta, both of which are verifiable from public data.

SHRUGG is similar in shape:

SSHRUGG(h)=Sinitial+∑i=0hProvingRewards(i)+∑i=0hDemandBonus(i)−∑i=0hBurned(i)S_{\text{SHRUGG}}(h) = S_{\text{initial}} + \sum_{i=0}^{h} \text{ProvingRewards}(i) + \sum_{i=0}^{h} \text{DemandBonus}(i) - \sum_{i=0}^{h} \text{Burned}(i)

with Sinitial=200,000,000S_{\text{initial}} = 200{,}000{,}000 SHRUGG. Demand bonuses are deterministic from on-chain proof activity:

multiplier(epoch)=max⁡ ⁣(0.5, min⁡ ⁣(2.0, 1+proofsepoch−targettarget))\text{multiplier}(\text{epoch}) = \max\!\left(0.5,\ \min\!\left(2.0,\ 1 + \frac{\text{proofs}_{\text{epoch}} - \text{target}}{\text{target}}\right)\right)

so when proof demand exceeds target, prover rewards inflate (capped at 2×2\times), and when demand collapses, rewards deflate (floored at 0.5×0.5\times).

The hard part is auditing the shielded pool, where individual balances are hidden by design. Rand handles this with a zero-knowledge supply proof:

Rsupply audit={every committed note appears in the root∑(note values)=shielded balanceall note values≥0R_{\text{supply audit}} = \begin{cases} \text{every committed note appears in the root} \\ \sum (\text{note values}) = \text{shielded balance} \\ \text{all note values} \geq 0 \end{cases}

Anyone can verify the aggregate shielded supply equals the publicly claimed shielded balance, even though no individual note value is revealed.

Post-Quantum Security

The most distinctive feature of Rand is its commitment to remaining secure when quantum computers arrive. Two algorithms threaten classical cryptography:

Resistance to Shor

Rand uses no primitive that Shor’s algorithm can attack:

The hard problem under all of this is Module-LWE (Module Learning With Errors). Informally, given a random matrix A\mathbf{A} over the polynomial ring Rq=Zq[X]/(Xn+1)R_q = \mathbb{Z}_q[X]/(X^n+1) and a vector b=As+e\mathbf{b} = \mathbf{A}\mathbf{s} + \mathbf{e} where s,e\mathbf{s}, \mathbf{e} are small, distinguish b\mathbf{b} from uniform. No efficient algorithm — classical or quantum — is known.

Grover’s Impact

Grover halves bit-security against unstructured search. So:

For Rand, that means SHA-3-256 and BLAKE3-256 give 128 bits of quantum preimage security and roughly 85 bits of quantum collision security — which is the dominant term in the STARK soundness bound:

ϵSTARK≤ϵFRI+ϵcollision+qH⋅2−λ\epsilon_{\text{STARK}} \leq \epsilon_{\text{FRI}} + \epsilon_{\text{collision}} + q_H \cdot 2^{-\lambda}

This is acceptable for current parameters; if more quantum collision resistance is needed later, the system can move to 384- or 512-bit hashes at the cost of larger proofs.

Attack Resistance

Many famous blockchain attacks have closed-form bounds in this framework. Three are worth highlighting.

The 51% Attack Becomes a 67% Attack

In Nakamoto consensus, an adversary with 51% of hashpower can rewrite history. Under BFT consensus, the threshold is higher:

Theorem. An adversary needs more than 2/32/3 of stake to violate safety in BFT consensus.

This follows immediately from the safety proof above: signing two conflicting blocks requires f+1f + 1 honest signatures, so the adversary must control more than 2f2f of 3f+13f+1 stake — i.e., more than 2/32/3.

Eclipse Attacks

In an eclipse attack, an adversary surrounds a victim node with malicious peers. With kk outbound connections to diverse subnets, the eclipse probability is bounded by

Pr⁡[Eclipse]≤(mN)k\Pr[\text{Eclipse}] \leq \left(\frac{m}{N}\right)^k

where mm is the number of adversary-controlled nodes and NN is total network size. For m/N=0.1m/N = 0.1 and k=8k = 8, this is 10−810^{-8} — small enough to ignore.

Sybil Attacks

The classic Sybil attack — creating many fake identities — is neutralized by stake-weighted voting:

Power(k identities with stake S/k)=k⋅Sk=S\text{Power}(k \text{ identities with stake } S/k) = k \cdot \frac{S}{k} = S

Splitting SS across kk identities gives the same total power as one identity with SS, so there is no Sybil benefit.

Concrete Parameters

The whitepaper recommends these parameters for 128-bit security:

ComponentParameterSecurity level
Hash functionSHA-3-256128-bit classical, 85-bit Q
SignaturesDilithium2128-bit quantum
Key encapsulationKyber768192-bit quantum
Symmetric encryptionAES-256-GCM128-bit quantum
STARK fieldGoldilocks p=264−232+1p = 2^{64}-2^{32}+1—
FRI queries30Soundness 2−1002^{-100}
Validatorsn=100n = 100BFT f<33f < 33
Minimum stake100,000 ATLASEconomic security
Block time2 seconds—
Finality3 rounds (~6 seconds)Deterministic
Merkle tree depth322322^{32} notes
Nullifier size256 bits128-bit collision resistance

Economic Security

With n=100n = 100 validators and a minimum stake of 100,000 ATLAS at $1 each, the cost to mount a safety-violating attack is bounded below by

AttackCost≥n3⋅Smin⁡⋅PATLAS+SlashingLoss≈33⋅100,000⋅1+0.33⋅33⋅100,000≈$4.4M\text{AttackCost} \geq \frac{n}{3} \cdot S_{\min} \cdot P_{\text{ATLAS}} + \text{SlashingLoss} \approx 33 \cdot 100{,}000 \cdot 1 + 0.33 \cdot 33 \cdot 100{,}000 \approx \$4.4\text{M}

That’s the floor. In practice, validator stake will scale up well beyond the minimum, and ATLAS market cap will move the floor with it.

Closing Thoughts

What I find appealing about the Rand design is that almost every choice has a mathematical justification rather than a heuristic one. The two-token gas split is forced by a privacy-leakage theorem. The 67% threshold is forced by the BFT safety proof. The choice of STARKs over SNARKs is forced by post-quantum requirements. The choice of Module-LWE is forced by Shor-resistance. The slashing fractions are calibrated against expected attack rewards.

There is no part of the protocol that requires you to take anything on faith. Every property is provable from a small list of standard cryptographic assumptions: collision resistance of the hash, Module-LWE/SIS hardness, and a partially synchronous network with f<n/3f < n/3 Byzantine validators. If those assumptions hold, everything else follows.

The mathematics is, in the end, not exotic. It is mostly counting — counting overlapping quorums, counting collision queries, counting the cost of a Sybil identity. What is exotic is how much you can build on top of those counts if you are careful.

For readers who want the unabridged version, the formal whitepaper has the full statement of every theorem and a complete bibliography. This post was written to be the on-ramp.


Share this post on:

Previous Post
Cold War 2.0: Why It Probably Ends Without a Hot War — and Who Gets Rich on the Way
Next Post
What a Real GPU Compute Market Means for Everyone (Part 2)