The Verification Venue · a bias you can watch walk out of the noise
The Second Byte Leans Toward Zero
Run RC4's key schedule on a handful of random keys and its output looks flawlessly uniform, and every small-sample check agrees. It is not uniform. The second keystream byte is zero about twice as often as it should be, the flaw comes from the output generator's first two rounds, and this page measures the bias, derives its direction, and shows its own work.
Below is a histogram of the second output byte over independent random 16-byte keys, filling as keys are drawn. A preview of two million keys starts immediately. When you are ready, launch the full run of a hundred and fifty million keys, watch one bin stand clear of the other two hundred and fifty-five, then drag the sample-count slider back down and watch the interval widen again.
Keystream byte under the microscope
Convention, stated once: byte positions are 1-indexed, keys are 16 random bytes, the first byte is not discarded. The readouts always describe byte two; the first byte is there to be compared against. ↓
Keys drawn
0
preview running
P(second byte = 0)
·
uniform would be 0.00390625
Distance from uniform
·
in standard errors, zero bin vs 1/256
Reading
waiting
interval appears once keys are drawn
Snap to the checkpoints a run has saved, each labelled with the keys it holds. The smallest is the preview's first 20,000 keys, already past the line, near two thousand keys at the measured rate, below which this interval is expected to cover uniform: slide down and the interval widens, but it does not close over uniform here.
Runs across every core the browser offers. Interruptible; a stopped run is labelled partial, never an answer.
Run state
idle · the battery and the sabotage check run first, and nothing displays until they pass
Operations performed (counted)
0
inner-loop bodies the engine actually executed
Wall time
·
· workers
Against main-thread JavaScript
·×
extrapolated from a slice; the slice fraction prints beside it
Partial?
no run yet
an interrupted run is a partial, in those words, always
Why the second byte? Trace the key schedule on a key whose first two bytes cancel, K[0] + K[1] ≡ 0 (mod 256). Step one sets j = K[0] and swaps positions 0 and K[0], planting the value 0 at index K[0]. Step two computes j = K[0] + S[1] + K[1], and because nothing has touched position 1 yet, S[1] is still 1, so the sum is K[0] + 1 − K[0] = 1: the swap is S[1] with itself, a no-op. From there the question is whether the planted zero and the untouched S[1] survive the remaining 254 swapping steps often enough to leave a surplus. They do not: the panel below measures it exactly, over every two-byte key that exists, and its last column shows the keys whose first two bytes cancel giving a zero second byte at the uniform rate, 1 key in 256. The lean comes from the output generator instead. Mantin and Shamir proved that whenever the scheduled state holds 0 at index 2 and anything but 2 at index 1, the first two output rounds make the second byte 0, and that for a state drawn at random, with no key schedule at all, this produces the lean this page measures.
The derivation, measured exactly rather than recalled
| system | keys swept | P(Z₂ = 0) | × uniform | P(Z₂ = 0 | K₀+K₁ ≡ 0) |
|---|
The first row is the real RC4 with every two-byte key enumerated exhaustively. The rows beneath are reduced analogues, RC4 with a smaller state, whole key space swept. They show the mechanism is not an accident of one parameter choice. An analogue is not a proof about the full system, and the full-system number on this page rests on the measurement above, not on these rows.
Consequence: the broadcast attack, made operable
Vote reliable (≥ 90%) from
·
ciphertexts of one known plaintext byte
Model vs direct resampling
·
at 1,000 ciphertexts, 200 trials each
Give the attacker one known plaintext byte encrypted under many independent keys, and let them vote: for each candidate value of the second byte, count how often ciphertext xor candidate repeats, and take the mode. The true value wins once its bin, the zero bin, out-polls 255 rivals that each sit near uniform. The curve plots the vote's accuracy against the number of ciphertexts, simulated from this page's own measured histogram. This is the attack Mantin and Shamir built on the bias, one plaintext sent to many recipients under different keys, and the rule they drew from it was about the keystream, not the key: implementations of RC4 "should skip at least the first two (and preferably the first N) output words".
Model: per-candidate counts drawn as independent Poisson variables from the measured histogram; validated below against direct resampling, which makes no independence assumption. Both are estimates, with visible trial counts.
The check · run in front of you, or the page refuses to speak
Two implementations, one contract. The compiled engine and a slow, deliberately obvious JavaScript reference ran the battery below in your browser before this page agreed to compute anything. Fingerprints are over all 515 counters of each accumulator.
| battery row | engine fingerprint | reference fingerprint | agree |
|---|
A check that has never failed is a claim about the code, not evidence about it. Press the button and watch this one go red:
Corrupts one step of the reference's key schedule and requires the battery to notice. If sabotage goes unnoticed, the agreement check above is decoration.
sabotage check: armed
planted control (a keystream uniform by construction, fed through the unmodified measurement): pending
full-size decomposition check (250 chunks vs 128: both cuts' histograms must sum to exactly the sample count, and the fingerprints must be bit-identical): awaiting the full run
full-size invariants (histograms sum to the sample count; zero failed permutations; second-byte deviation beats the first byte's and clears 8σ; interval excludes uniform): awaiting the full run
engine binary: fetching…
What none of this rules out. Two decompositions agreeing rules out boundary errors and very little else; the battery rules out translation mistakes on small cases; neither rules out a shared misunderstanding of RC4 itself, which is why the derivation panel re-derives the bias's direction by exhaustion over every two-byte key. Nor can a differential fingerprint comparison see a fault that strikes both decompositions identically, which is why the decomposition gate checks each side's histogram sums before it compares anything. No amount of it certifies anything about any deployed system, which this page does not examine.
Run it yourself, offline: node research/the-second-byte-leans-toward-zero/verify-the-second-byte-leans-toward-zero.mjs. That file also rebuilds the engine from its C and hashes it, which a browser cannot do.
What's exact here, what's a model, and what's measured
Exactly true. Every histogram count is an integer tally. The permutation check runs on every single key schedule, no subset. The derivation panel's fractions are exhaustive: all 65,536 two-byte keys of the real system, and the entire key spaces of the reduced analogues. The planted control's source is uniform by construction, so its zero deviation is exact, forever.
A model. The majority-vote curve treats per-candidate counts as independent Poisson draws from the measured histogram. Multinomial counts are mildly negatively correlated, so the independence is an approximation; the page validates it against direct categorical resampling at a matched sample size and prints both estimates beside each other. The intervals are two standard errors wide by stated convention.
Measured. Everything else, always with its interval attached, and never from memory: no published bias constant appears anywhere on this page, because published values differ in convention, key length, and whether the first byte is discarded, and a recalled constant is exactly what this run forbids. If a figure you expected is missing, that is why.
Deliberately not claimed. This is one known weakness among several, not a break of RC4, and it implies nothing about any system you use. Its scope is the sentence the measurement supports: the second byte leans toward zero by the measured amount. Why it leans is Mantin and Shamir's proof, not this page's measurement.
Corrections.
Corrected 2026-10-18: The page said the flaw follows from the key schedule's first two steps, that on keys whose first two bytes cancel the planted zero and the untouched S[1] survive often enough to leave a surplus on the second byte, and that the lean follows from the key schedule. Its own exhaustive panel shows those keys give a zero second byte at the uniform rate, 1 in 256, and Mantin and Shamir prove the lean from the first two rounds of output generation for a randomly chosen state, with the key schedule set aside; the page now says so (found by the assay line, 2026-10-18).
Corrected 2026-10-18: The Sources note credited the phenomenon to Fluhrer, Mantin and Shamir's 2001 analysis of RC4's key scheduling. The second-byte bias was described by Itsik Mantin and Adi Shamir in "A Practical Attack on Broadcast RC4" (FSE 2001), which the Fluhrer, Mantin and Shamir paper itself credits (found by the assay line, 2026-10-18).
Corrected 2026-10-18: The vote panel was headed "the reused-key attack" and said the bias turned into the rule that a key must never be reused. The attack it models sends one plaintext to many recipients under different keys, and the rule its authors drew was to skip the first output words of the keystream (found by the assay line, 2026-10-18).
Corrected 2026-10-18: The page's summary and plain-words card said it generates keys by the billion, or billions of keys. A visit draws a 2,000,000-key preview and, if launched, 150,000,000 keys twice over, about 0.3 billion at most (found by the assay line, 2026-10-18).
Corrected 2026-10-18: The summary, search title and search description said a goodness-of-fit test across all 256 bins dilutes the bias into nothing, that a million samples look like nothing, that the page runs such a test side by side with the zero-bin test, and that the zero-bin z-score reaches the tens of thousands. No goodness-of-fit test runs on the page; such a test notices a doubled zero bin near 100,000 keys, well short of a million; and the zero-bin z-score on the full 150,000,000-key run is in the hundreds (found by the assay line, 2026-10-18).
Corrected 2026-10-18: The page said sliding the sample count down toward a thousand keys makes the interval close over uniform and the evidence disappear, and the summary said the page says where that line is. The slider's smallest checkpoint holds the preview's first 20,000 keys (it was labelled n = 1,000 and n = 10,000), where the interval already excludes uniform; the line is near two thousand keys. Checkpoints are now labelled with the keys they hold and the text says where the line falls (found by the assay line, 2026-10-18).
Corrected 2026-10-18: The layer's notes named an engine.mjs, a battery.json run over by a blind second implementation, an independent anchor reproduced by the verifier, and sources recorded in the README. Neither file exists, the verifier reproduces no outside anchor, and the README names no outside source: the engine is engine.c beside the page, the battery is in plan.js, the second implementation is reference.js, and the README records what was computed and what the checks do not prove (found by the assay line, 2026-10-18).