code
symbols and bits
A Reed–Solomon code adds check symbols to a message. Their pattern identifies both the location and value of a bounded number of damaged symbols. The result is one codeword with a fixed length.
A symbol here is one byte, while a bit is one of the eight positions inside that byte. One flipped bit damages one symbol. Eight flipped bits in that same byte still count as damage to one symbol because correction is measured by symbol positions.
The arithmetic takes place in GF(2^8), a field with 256 elements. Addition is exclusive-or and multiplication reduces by the primitive polynomial 0x11D. Every byte therefore acts as one field element.
code reading: —
parity
The layout is systematic. The first 223 symbols are the message and the final 32 symbols are parity. Reading the first region does not require separating message bytes from a mixed encoding.
The 32 parity bytes are computed from the complete sequence of 223 message bytes. They are chosen so that all 32 syndromes of the complete codeword are zero. A changed message byte or parity byte generally makes those checks nonzero.
A code with 32 parity symbols has minimum distance 33. It corrects 16 unknown symbol errors because each error contributes a location and a magnitude. Damage beyond that bound does not have a guaranteed unique correction.
code reading: —
the field
Parity symbols remain part of the same stored codeword and can be hit by a transfer. A hit in parity consumes correction capacity in the same way as a hit in the message region. The decoded message can remain unchanged while the decoder corrects that parity damage.
The same family of codes appears in compact discs, QR codes, and deep space links. Each use selects parameters suited to its channel. The common rule is that extra symbols provide a measurable distance between valid words.
The reader builds the codeword, counters, recent draws, and repair records from transactions. It starts from the fixed message rather than a stored second copy. The browser derives its decoded view from the replayed codeword.
code reading: —
the current word
The current word begins with the fixed message and its computed parity. Transfers alter individual bits during replay. Burns can restore the lowest damaged symbol.
Parity symbols can be hit like message symbols. Such a hit consumes the same correction capacity. Repairing it costs one symbol unit.
A fixed five-error vector tests the same decoder. It is separate from the live word. Its successful result checks the implementation.
code reading: —
export function gfMul(a: number, b: number): number { let r = 0; while (b) { if (b & 1) r ^= a; a <<= 1; if (a & 0x100) a ^= 0x11d; b >>= 1; } return r;}export function syndromes(cw: Uint8Array): number[] { const s: number[] = []; let root = 1; // alpha^0 for (let j = 0; j < 32; j++) { let acc = 0; for (let i = 0; i < 255; i++) acc = gfMul(acc, root) ^ cw[i]; s.push(acc); root = gfMul(root, 2); } return s;}