API reference@evolu/commonlocal‑first/Timestamp › NodeId

const NodeId: regex("NodeId", /^[a-f0-9]{16}$/)(String);

Defined in: packages/common/src/local-first/Timestamp.ts:93

A NodeId uniquely identifies an owner's device. Generated once per device using cryptographic randomness.

Collision probability (birthday paradox):

  • 1,000 devices: ~0.00000000000271% (negligible).
  • 1M devices: ~0.00000271% (1 in 37M chance).
  • 135M devices: ~1% chance.
  • 4.29B devices: ~50% chance.

https://lemire.me/blog/2019/12/12/are-64-bit-random-identifiers-free-from-collision

What happens if different devices generate the same NodeId?

If devices with the same NodeId use different owners, no issues occur.

If devices with the same NodeId use the same owner, problems only arise when they generate CRDT messages with identical timestamps (same millis, counter, and NodeId). In this case, the protocol sync algorithm treats them as the same message: the first will be synced with the relay, while the affected message will not be delivered. The affected devices will see different data yet they will think they are synced. This is extremely rare and can be resolved by resetting one device to generate a new NodeId.