This toy nonce-reuse leak is not production exploit guidance.
The leak is about reuse
This toy leak appears because the same nonce gives the same keystream for two different plaintexts.
nonce reused = 1 \text{nonce reused}=1 nonce reused = 1
Toy nonce-reuse boundary The ciphertext XOR and plaintext XOR are recomputed from pinned bytes. Ciphertext A 48 bits / 6 bytes 0x7f7f54017a6a byte 0 byte 1 byte 2 byte 3 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 1 byte 4 byte 5 0 1 1 1 1 0 1 0 0 1 1 0 1 0 1 0 byte-0 0x7f byte-1 0x7f byte-2 0x54 byte-3 0x01 byte-4 0x7a byte-5 0x6a Ciphertext B 48 bits / 6 bytes 0x7f7f5401726a byte 0 byte 1 byte 2 byte 3 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 1 byte 4 byte 5 0 1 1 1 0 0 1 0 0 1 1 0 1 0 1 0 byte-0 0x7f byte-1 0x7f byte-2 0x54 byte-3 0x01 byte-4 0x72 byte-5 0x6a Ciphertext XOR 48 bits / 6 bytes 0x000000000800 byte 0 byte 1 byte 2 byte 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 byte 4 byte 5 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 byte-0 0x00 byte-1 0x00 byte-2 0x00 byte-3 0x00 byte-4 0x08 byte-5 0x00 Plaintext XOR 48 bits / 6 bytes 0x000000000800 byte 0 byte 1 byte 2 byte 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 byte 4 byte 5 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 byte-0 0x00 byte-1 0x00 byte-2 0x00 byte-3 0x00 byte-4 0x08 byte-5 0x00
It is not key recovery
The lesson shows a plaintext relationship and known-plaintext recovery, not recovery of the secret key.
key recovered = 0 \text{key recovered}=0 key recovered = 0
Toy nonce-reuse boundary The ciphertext XOR and plaintext XOR are recomputed from pinned bytes. Ciphertext A 48 bits / 6 bytes 0x7f7f54017a6a byte 0 byte 1 byte 2 byte 3 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 1 byte 4 byte 5 0 1 1 1 1 0 1 0 0 1 1 0 1 0 1 0 byte-0 0x7f byte-1 0x7f byte-2 0x54 byte-3 0x01 byte-4 0x7a byte-5 0x6a Ciphertext B 48 bits / 6 bytes 0x7f7f5401726a byte 0 byte 1 byte 2 byte 3 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 1 byte 4 byte 5 0 1 1 1 0 0 1 0 0 1 1 0 1 0 1 0 byte-0 0x7f byte-1 0x7f byte-2 0x54 byte-3 0x01 byte-4 0x72 byte-5 0x6a Ciphertext XOR 48 bits / 6 bytes 0x000000000800 byte 0 byte 1 byte 2 byte 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 byte 4 byte 5 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 byte-0 0x00 byte-1 0x00 byte-2 0x00 byte-3 0x00 byte-4 0x08 byte-5 0x00 Plaintext XOR 48 bits / 6 bytes 0x000000000800 byte 0 byte 1 byte 2 byte 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 byte 4 byte 5 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 byte-0 0x00 byte-1 0x00 byte-2 0x00 byte-3 0x00 byte-4 0x08 byte-5 0x00
What this does not model
NOTE: toy reused nonce and reused keystream illustration only; not AES-GCM, not ChaCha20-Poly1305, not nonce generation, not real stream-cipher internals, not traffic analysis, not key recovery, and not production exploit guidance.
toy only = 1 \text{toy only}=1 toy only = 1
Toy nonce-reuse boundary The ciphertext XOR and plaintext XOR are recomputed from pinned bytes. Ciphertext A 48 bits / 6 bytes 0x7f7f54017a6a byte 0 byte 1 byte 2 byte 3 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 1 byte 4 byte 5 0 1 1 1 1 0 1 0 0 1 1 0 1 0 1 0 byte-0 0x7f byte-1 0x7f byte-2 0x54 byte-3 0x01 byte-4 0x7a byte-5 0x6a Ciphertext B 48 bits / 6 bytes 0x7f7f5401726a byte 0 byte 1 byte 2 byte 3 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 1 byte 4 byte 5 0 1 1 1 0 0 1 0 0 1 1 0 1 0 1 0 byte-0 0x7f byte-1 0x7f byte-2 0x54 byte-3 0x01 byte-4 0x72 byte-5 0x6a Ciphertext XOR 48 bits / 6 bytes 0x000000000800 byte 0 byte 1 byte 2 byte 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 byte 4 byte 5 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 byte-0 0x00 byte-1 0x00 byte-2 0x00 byte-3 0x00 byte-4 0x08 byte-5 0x00 Plaintext XOR 48 bits / 6 bytes 0x000000000800 byte 0 byte 1 byte 2 byte 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 byte 4 byte 5 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 byte-0 0x00 byte-1 0x00 byte-2 0x00 byte-3 0x00 byte-4 0x08 byte-5 0x00
Summary
A reused nonce can turn two toy ciphertexts into the XOR of their plaintexts.
cipher XOR = 0 x 000000000800 \text{cipher XOR}=0x000000000800 cipher XOR = 0 x 000000000800
Toy nonce-reuse boundary The ciphertext XOR and plaintext XOR are recomputed from pinned bytes. Ciphertext A 48 bits / 6 bytes 0x7f7f54017a6a byte 0 byte 1 byte 2 byte 3 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 1 byte 4 byte 5 0 1 1 1 1 0 1 0 0 1 1 0 1 0 1 0 byte-0 0x7f byte-1 0x7f byte-2 0x54 byte-3 0x01 byte-4 0x7a byte-5 0x6a Ciphertext B 48 bits / 6 bytes 0x7f7f5401726a byte 0 byte 1 byte 2 byte 3 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 1 byte 4 byte 5 0 1 1 1 0 0 1 0 0 1 1 0 1 0 1 0 byte-0 0x7f byte-1 0x7f byte-2 0x54 byte-3 0x01 byte-4 0x72 byte-5 0x6a Ciphertext XOR 48 bits / 6 bytes 0x000000000800 byte 0 byte 1 byte 2 byte 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 byte 4 byte 5 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 byte-0 0x00 byte-1 0x00 byte-2 0x00 byte-3 0x00 byte-4 0x08 byte-5 0x00 Plaintext XOR 48 bits / 6 bytes 0x000000000800 byte 0 byte 1 byte 2 byte 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 byte 4 byte 5 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 byte-0 0x00 byte-1 0x00 byte-2 0x00 byte-3 0x00 byte-4 0x08 byte-5 0x00