# CQRC: Differential Testing Two Zero-Dependency QR Code Encoders at the Module-Matrix Level

Author: yxpil

Suggested arXiv categories: **cs.IT** (primary), cross-lists **cs.SE** and **cs.GR**.

## Abstract

QR Code encoders are usually validated by scanning a rendered image, a test that
lets the decoder's error correction absorb encoder mistakes and that samples few
of the possible inputs. This paper reports CQRC, a QR Code generator written twice
from scratch---in C# and in JavaScript---without third-party dependencies, and
evaluates it by taking the module matrix, not the image, as the conformance unit.
On a seeded corpus of 200 inputs spanning versions 1--40, all four
error-correction levels and five payload families, the two implementations produce
bit-identical matrices for 192 inputs (1,164,776 modules); the other eight expose a
C# defect. A third-party oracle (python-qrcode 8.2, invoked with an explicit mask)
agrees on 60/60 cases (585,988 modules), a 40x4 structural sweep passes in both
languages, and byte-mode capacity matches the published ISO table at all 44
checked points. We diagnose the eight failures exactly: the C# Reed--Solomon
encoder indexes a polynomial whose leading zero coefficients have been stripped, so
any block whose remainder starts with 0x00 throws (8/200 cases; the predictor has
accuracy 1.000, against 8.95 expected occurrences in 2,292 blocks). The JavaScript
port supplies the missing zero padding and is correct. A second defect, a PNG IDAT
stream without an Adler-32 checksum, is rejected by both CPython and Node zlib
despite valid chunk CRCs. We also measure the metadata trailer (20/20 recovered
from the code words; its "ISO/IEC 21570" label is a misattribution, since ISO 21570
is a food-analysis standard) and the geometric cost of styling: circular finders
change 16 of 49 cells per finder, and 0.5 module rounding removes 40% of a module's
area. No decoder was available, so we do not claim that styled symbols scan.

## Files

| Path | What it is |
|---|---|
| `main.tex` | The paper: 8 sections, 2 figures, 4 references. |
| `refs.bib` | Bibliography (ISO/IEC 18004, Reed--Solomon, python-qrcode, QR styling prior art). |
| `common.tex` | Copy of `../_shared/common.tex` (shared preamble). |
| `figures/capacity.pdf` | Capacity of the four EC levels against the published table. |
| `figures/finder.pdf` | Geometric cost of circular finder styling. |
| `scripts/measure_cqrc.py` | The measurement harness: seeded corpus, cross-language comparison, python-qrcode oracle, structural and capacity sweeps, defect diagnosis. |
| `scripts/js_harness.js` | Node harness that drives the JavaScript encoder and emits matrices and code words. |
| `scripts/make_figures.py` | Generates the two figures from the result JSON. |
| `scripts/results/*.json` | Raw measurement output. Every quantitative claim in the paper traces here. |
| `README.md` | This file. |

## Build

```bash
pdflatex main
bibtex main
pdflatex main
pdflatex main
```

or, with Tectonic:

```bash
tectonic -X compile main.tex --keep-logs
```

## Packaging for arXiv

```bash
tar czf cqrc-arxiv.tar.gz main.tex refs.bib common.tex figures/*.pdf
```

Full artifact tarball (adds the harness and result files):

```bash
tar czf cqrc-artifact.tar.gz main.tex refs.bib common.tex figures/*.pdf \
    scripts/measure_cqrc.py scripts/js_harness.js scripts/make_figures.py \
    scripts/results README.md
```

`common.tex` must stay byte-identical to the shared copy:

```bash
cmp common.tex ../_shared/common.tex && echo identical
```

## Submission steps

1. Start a new arXiv submission at <https://arxiv.org/submit>.
2. Choose **cs.IT** as the primary category; add **cs.SE** and **cs.GR** as cross-lists.
3. Paste the title and the abstract above; author `Daozhendong Yang` (or `yxpil`, but use one identity consistently across the paper, the arXiv account, and the README).
4. Upload `cqrc-arxiv.tar.gz`. arXiv detects `main.tex` and runs `pdflatex` + `bibtex`.
5. Inspect the auto-built PDF: 2 figures, no overfull boxes that push text into the margin.
6. Select a license and submit. A first cs.IT submission may require an endorsement.

## Reproduction

Requirements: .NET 8 SDK (for the C# library), Node 18+ (for the JavaScript port),
Python 3 with `python-qrcode` 8.2 and matplotlib, and the CQRC checkout at
`../../_repos/CQRC` (override with `CQRC_REPO`).

```bash
export CQRC_REPO=../../_repos/CQRC
python scripts/measure_cqrc.py --out scripts/results
python scripts/make_figures.py
```

The harness writes one JSON file per experiment: corpus, cross-language matrix
comparison, oracle agreement, structural sweep, capacity sweep, metadata
recovery, styling geometry, and the defect diagnosis. No package is installed
from the network during measurement.

### Provenance of the numbers

The two reported defects are properties of the repository at the measured
commit, not patches applied by this paper. The C# Reed--Solomon failure is
reproduced by the corpus and predicted from the code words; the missing
Adler-32 trailer is reproduced by feeding the emitted PNG to CPython's
`zlib.decompress`. Both are reported in Section 4 of the paper.

## What the paper does not claim

- It does not claim that the C# implementation is correct after the reported
  defect; the defect is left in place and diagnosed.
- It does not claim decodability of styled symbols. No barcode decoder was
  available on the measurement host, so styling is measured geometrically only.
- It does not claim that the 200-input corpus covers the input space. It is a
  seeded sample; the structural and capacity sweeps cover the fixed dimensions.
- It does not claim that the metadata trailer is a standard. It is an
  application-defined record, and the paper states that the project's
  "ISO/IEC 21570" label is a misattribution.
- It does not claim that the two implementations are independent in the sense
  of separate authors; they are two code bases written against the same
  specification, and the paper treats agreement as evidence of conformance,
  not of independent discovery.
- It does not report a performance comparison between the two languages.
