# DFSCQ: a hash proof is not a runtime collision detector

A hash primitive in a proof and a function in an executable need not have identical
behavior on every input. Check that boundary before treating a verified component
as an unconditional storage-integrity guarantee.

## Three evidence layers

The [SOSP 2017 paper, section 5.6, PDF page 9](https://pdos.csail.mit.edu/papers/dfscq.pdf)
models a collision as nontermination. Hash history exists only for reasoning.
A returning modeled call can therefore support equality reasoning. The authors
explicitly distinguish runtime hashing, which returns even for a colliding input,
and justify the gap by a collision-resistance assumption.

In [the pinned interpreter](https://github.com/mit-pdos/fscq/blob/2c7ef9c268fd79a81b26b44ef720f8e6a1e938a0/src/hslib/Interpreter.hs),
Hash and Hash2 use CRC32 updates; the SHA256 import is commented out.
[AsyncDisk.v](https://github.com/mit-pdos/fscq/blob/2c7ef9c268fd79a81b26b44ef720f8e6a1e938a0/src/AsyncDisk.v)
sets the hash width to 32 bits and defines the admissible history condition.
[Prog.v](https://github.com/mit-pdos/fscq/blob/2c7ef9c268fd79a81b26b44ef720f8e6a1e938a0/src/Prog.v)
requires that condition for a successful Hash step.
This is a revision-specific source observation, not a reproduction of the paper's
evaluation or evidence of an exploited filesystem. The authors describe this
branch as roughly corresponding to DFSCQ, not an exact archived evaluation build.

CRC32 is not a cryptographic authentication primitive, as the
[Python zlib documentation](https://docs.python.org/3/library/zlib.html#zlib.crc32)
also warns. Our inference is limited: this pinned interpreter should not be
presented as evidence that the paper's runtime collision-resistance assumption
has been established against adversarial input. We did not test an attack.

## An executable counterexample to a tempting inference

The original Hesela teaching model uses h(x) = x mod 4 on integer bytes.
It deliberately has easy collisions and does not implement CRC32.

| Input sequence | Ordinary function results | Modeled operation outcomes |
| --- | --- | --- |
| 1, 1 | 1, 1 | Both return |
| 1, 5, 2 | 1, 1, 2 | First returns; second does not return; third is not reached |
| 1, 2, 3 | 1, 2, 3 | All return |

The first row is not a collision: it repeats the same input.
The second row defeats the inference "equal returned digests imply equal inputs"
for the ordinary function. It does not defeat that inference for returning
operations in this particular model: the conflicting operation has no return.

The implementation uses a finite no-return marker instead of actually looping.
A model that omits a return is not a runtime collision detector. Nor is conditional
correctness a termination guarantee. Inspect both the modeled execution rules and
the executable implementation; a theorem name alone does not settle this question.

## Reproduce the teaching result

Requires Node.js built-ins only. In the downloaded packet directory:

```sh
node generate.mjs --check
node --test model.test.mjs
```

The tests exhaust all 4096 length-three histories over inputs 0 through 15,
comparing the first conflicting input with a separate pairwise oracle.
Boundary, invalid-input and state-isolation tests accompany that enumeration.
No seed or randomized sampling is used.

Files:
- [model.mjs](https://hesela.dev/research/dfscq-hash-semantics/model.mjs)
- [model.test.mjs](https://hesela.dev/research/dfscq-hash-semantics/model.test.mjs)
- [generate.mjs](https://hesela.dev/research/dfscq-hash-semantics/generate.mjs)
- [results.json](https://hesela.dev/research/dfscq-hash-semantics/results.json)
- [source-map.json](https://hesela.dev/research/dfscq-hash-semantics/source-map.json)

## Scope and limits

This is not DFSCQ execution, a Coq proof replay, a cryptographic construction,
a crash test or a collision-rate estimate. The model does not represent the
complete CHL machine, disk state, default-hash entry, Hash2 encoding or recovery.
All rows are constructed examples, not observed device data. There is no measured
population, denominator of storage failures or confidence interval.

The code review identifies a boundary requiring explicit qualification; it does
not establish a practical attack or quantify the chance of corrupt recovery.
The prototype's own [maintenance warning](https://github.com/mit-pdos/fscq/blob/2c7ef9c268fd79a81b26b44ef720f8e6a1e938a0/README.md)
also applies. Third-party code and the paper are linked, not redistributed.

Continue with [DFSCQ](https://hesela.dev/terms/dfscq/),
[Crash Hoare Logic](https://hesela.dev/terms/crash-hoare-logic/) and the separate
[block-identity walkthrough](https://hesela.dev/research/dfscq-block-identity/README.md).
