Fletcher checksums: when a short word swap stays invisible ======================================================== Result ------ A two-sum checksum can depend on order without detecting every reorder. In the zero-initialized, 8-bit-word Fletcher arithmetic used here, 00 00 00 55 and 55 00 00 00 both give (A,B) = (85,85). The fixed original reference therefore accepts both sequences. This is a constructed counterexample, not a measured corruption probability. Model and derivation -------------------- For w-bit input words use M=2^w-1, A=0 and B=0. At each word x: A=(A+x) mod M; B=(B+A) mod M. The model returns the ordered pair (A,B), not a packed integer or wire-format checksum. For n words, B=sum((n-i)*x[i]) mod M, using zero-based i. Swapping positions i and j leaves A unchanged. For j>i the change in B is (j-i)*(x[j]-x[i]) mod M. Thus a swap is invisible to these residues exactly when M divides distance*value_difference. For M=255, distance 3 and difference 85 give 255. The example has eight changed bits, not a single-bit error. For 16-bit words, 0000 0000 0000 5555 and 5555 0000 0000 0000 similarly give (21845,21845) modulo 65535, with sixteen changed bits. The examples also preserve the unnormalized end-around-carry sums. They do not rely on conflating the two zero representations: with zero initialization, the one-word inputs 00 and FF produce folded pairs (0,0) and (255,255), despite equal canonical residues. Code that packs or compares raw sums must retain that distinction. Complete finite check --------------------- model.py enumerates all 255*254 = 64,770 ordered distinct pairs of residues x,y in 0..254 for each distance. The 255 x=y pairs are excluded. Intermediate words are zero. It recomputes both messages, rather than counting only the modular predicate. Distance in words | Undetected swaps | Tested distinct pairs 1 | 0 | 64,770 2 | 0 | 64,770 3 | 510 | 64,770 5 | 1,020 | 64,770 15 | 3,570 | 64,770 The independent count is 255*(gcd(distance,255)-1). Every x has gcd(distance,255)-1 distinct y values with zero weighted difference. These are exhaustive counts in an explicitly selected finite set, not rates among device faults. No confidence interval or stochastic seed applies to this enumeration. Controls include shorter swaps, a different value difference, all 32 single-bit changes to the four-byte witness, and an independent weighted-sum calculation for all 65,536 two-byte inputs. Common prefix/suffix examples check that the collision is not an artifact of an empty surrounding message. Which Fletcher? --------------- RFC 1146 describes two accumulators but names the algorithm by word width; common Fletcher-16/Fletcher-32 names instead refer to the total result width. Its alternate TCP options are Historic under RFC 6247. Neither document specifies a modern storage format. HDF5 1.14.6's H5_checksum_fletcher32 uses zero initial sums, high-byte-first 16-bit input words and high-byte padding for an odd final byte. OpenZFS zfs-2.3.4's Fletcher-4 instead has four 64-bit accumulators over 32-bit words. The present two-sum model is not that algorithm. Research context and limits --------------------------- Koopman, Driscoll and Hall's March 2015 FAA report, DOT/FAA/TC-14/49, compares error-detection methods and explains its analytical and Monte Carlo methodology. Sections 2.4, 3.6 and 3.10.3 distinguish conditional error coverage from a blanket order-detection claim. Its communication/error models are not storage-fleet observations. This packet does not rerun the report's simulations or claim a new defect. The residue derivation above is directly checkable algebra. No HDF5 file, storage pool, disk or network was fault-injected here. Serialization, reference storage, metadata, authentication and reader verification policy lie outside this arithmetic model. For deployed data, specify those boundaries separately. Reproduce with Python 3.10+ -------------------------- Download these three files: https://hesela.dev/research/fletcher-order/model.py https://hesela.dev/research/fletcher-order/test_model.py https://hesela.dev/research/fletcher-order/results.json python3 -B model.py --check python3 -B -m unittest -v test_model.py python3 -B -O -m unittest -v test_model.py No third-party Python packages or network calls are required. --write intentionally regenerates results.json. The tests remain effective under Python -O because they use unittest assertions. Own code and text: MIT, see LICENSE.txt. Upstream sources are linked, not copied into this package. Sources (accessed 2026-11-23) ---------------------------- https://www.rfc-editor.org/rfc/rfc1146.html https://www.rfc-editor.org/rfc/rfc6247.html https://www.faa.gov/sites/faa.gov/files/aircraft/air_cert/design_approvals/air_software/TC-14-49.pdf https://raw.githubusercontent.com/HDFGroup/hdf5/hdf5_1.14.6/src/H5checksum.c https://github.com/openzfs/zfs/blob/34f96a15c73eab27dd6ad17bb5f1263bf26e37d7/module/zcommon/zfs_fletcher.c Related: https://hesela.dev/terms/fletcher-checksum/ Storage identity: https://hesela.com/analyses/checksums-identity-and-lost-writes/