API reference › @evolu/common › local‑first/Storage › Fingerprint

type Fingerprint = Uint8Array & Brand<"Fingerprint">;

Defined in: packages/common/src/local-first/Storage.ts:302

A summary of a range of TimestampBytes for comparing ranges cheaply.

It is the XOR of the first fingerprintSize bytes of the SHA-256 hash of each timestamp in the range, or zeroFingerprint for an empty range.

XOR is linear, so fingerprints are not collision resistant: any 97 timestamps contain a nonempty subset whose fingerprints XOR to zero. Anyone who can write to a relay for an owner, which includes every collaborator of a SharedOwner, can store timestamps whose fingerprints XOR to the fingerprint of a chosen change. Two ranges that differ only by that change and those timestamps then compare equal, so sync skips them, and the change does not move between that relay and a peer. This was demonstrated end to end, and nothing reports it. Evolu.requestSync does not heal it, because the next round compares the same fingerprints. In protocol version 1, the only recovery is syncing through a relay that does not hold those timestamps. Binding the count or hashing the result changes every fingerprint, so it needs a new protocol version.

A write-key holder can also store a change under a timestamp another device has not used yet, such as a later one with the NodeId of that device's session, because relays accept timestamps from any time. A relay keeps the first change stored for a timestamp, so it does not store the device's change when it arrives, and peers that sync through that relay later get the stored one instead. A new fingerprint does not close this.