Dev.to Security 🔐 Cybersecurity 👁 1 📖 3 min read

ISO/IEC 18004 Static Vector SVG QR Codes: GF(256) Reed-Solomon Error Correction, Mask Scoring & Zero Link Rot

\ Canonical Engineering Monograph: https://nandai.org/blog/static-iso-18004-svg-qr-codes-vs-dynamic-redirect-saas · Local SVG Studio: nandai.org/qr-generator/wifi-network-qr-code Many hosted QR platforms default to e

\

Canonical Engineering Monograph: https://nandai.org/blog/static-iso-18004-svg-qr-codes-vs-dynamic-redirect-saas · Local SVG Studio: nandai.org/qr-generator/wifi-network-qr-code

Many hosted QR platforms default to encoding an intermediate short-link (https://vendor.example/r/a9x) rather than the user's actual destination URL, Wi-Fi payload, or vCard. Once a trial expires or a redirect domain sunsets, every printed packaging sleeve, technical manual, and restaurant menu stops resolving.

A static ISO/IEC 18004 QR code writes the raw UTF-8 byte sequence directly into the binary module matrix. There is no external lookup table, no tracking hop, and zero server dependency after print.

1. Byte-Mode Framing & Reed-Solomon Parity Over GF(256)

In Byte Mode (0100), the payload stream prefixes a 4-bit mode indicator, an 8-bit or 16-bit character count indicator (depending on QR Version 1..40), the UTF-8 payload bytes (for example WIFI:T:WPA;S:LabNet;P:Passphrase;;), a 4-bit terminator (0000), and alternating pad bytes (0xEC, 0x11) to fill the version's data codeword capacity.

Error-correction codewords are generated using Reed-Solomon polynomial division over the finite field GF(256) defined by irreducible primitive polynomial:

P(x) = x^8 + x^4 + x^3 + x^2 + 1   (0x11D)

Using generator polynomial G(x) = prod_{i=0}^{n-1} (x - alpha^i) where alpha = 2 is the primitive element of GF(256):

const GF_EXP = new Uint8Array(512);
const GF_LOG = new Uint8Array(256);

(function initGaloisTables() {
  let x = 1;
  for (let i = 0; i < 255; i++) {
    GF_EXP[i] = x;
    GF_LOG[x] = i;
    x <<= 1;
    if (x & 0x100) x ^= 0x11d; // Modulo x^8 + x^4 + x^3 + x^2 + 1
  }
  for (let i = 255; i < 512; i++) GF_EXP[i] = GF_EXP[i - 255];
})();

export function gfMul(a: number, b: number): number {
  if (a === 0 || b === 0) return 0;
  return GF_EXP[GF_LOG[a] + GF_LOG[b]];
}

Dividing the shifted message polynomial M(x) * x^n by G(x) yields the n parity remainder bytes appended after the data codewords. The four ISO/IEC 18004 error-correction tiers govern physical scuff tolerance:

ECC Level Recoverable Codeword Loss Recommended Print Application
Level L Up to 7% Clean high-contrast screens and indoor signage
Level M Up to 15% Standard paper flyers, manuals, and business cards
Level Q Up to 25% Shipping labels, workshop tags, and packaging
Level H Up to 30% Outdoor decals, harsh surfaces, or center-badge overlays

2. Deterministic 8-Mask Penalty Evaluation

Raw data bits often produce dense dark clusters or accidental 1:1:3:1:1 finder-pattern echoes that confuse optical decoders. After placing fixed function modules (three 7x7 finder patterns, timing strips, alignment patterns, and format info), ISO/IEC 18004 applies each of 8 boolean mask functions (r, c) -> bool exclusively to data/ECC modules and sums four penalty criteria:

  • N1 (Adjacent Same-Color Runs): 5+ consecutive dark or light modules along any row or column (3 + (runLen - 5) penalty points).
  • N2 (2x2 Solid Blocks): +3 penalty for every uniform 2x2 block of equal color.
  • N3 (Finder-Like Sequences): +40 penalty for 10111010000 or 00001011101 along rows or columns.
  • N4 (Dark-to-Light Imbalance): Penalizes deviation from 50% dark module density in 5% increments (10 * floor(|pctDark - 50| / 5)).

The encoder commits the mask index (0..7) yielding the minimum aggregate penalty score and writes the 15-bit BCH (15, 5) protected format string around the finder patterns.

3. Single-Path Vector .SVG Geometry & Quiet-Zone Rules

Raster .png QR exports sampled at low resolution suffer from anti-aliased edge bleed when scaled inside print layouts. Emitting a single combined SVG <path> over exact integer grid coordinates keeps every module edge binary-sharp from 18 mm hardware labels up to 600 DPI trade-show banners:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 33 33" shape-rendering="crispEdges">
  <rect width="33" height="33" fill="#ffffff"/>
  <path d="M4 4h7v1h-7z ..." fill="#000000"/>
</svg>

Two physical constraints determine reliable camera focus under uneven lighting:

  1. Strict 4-Module Quiet Zone: Maintain at least 4 modules of uninterrupted light margin on all four edges (viewBox width = matrixSize + 8).
  2. Dark-on-Light Contrast (>= 4:1): Standard camera pipelines expect dark modules on a light background; inverted light-on-dark codes fail on older embedded barcode scanners.

Read the full reference specification at nandai.org/blog/static-iso-18004-svg-qr-codes-vs-dynamic-redirect-saas, or generate permanent zero-upload Wi-Fi, vCard, and URL vector .SVG codes locally at nandai.org/qr-generator/wifi-network-qr-code and nandai.org/qr-generator.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.