An invertible Bloom lookup table is a compact set-difference sketch, not an ordinary membership filter. Each ID touches several deterministic cells; a cell stores a signed count, the XOR of IDs, and the XOR of their checksums. Insert IDs from the left replica with plus one and IDs from the right with minus one. Shared IDs cancel in every cell. A cell with count plus or minus one and a matching checksum can reveal one candidate ID. Peeling removes that candidate's contribution from every cell, exposing more pure cells. The decoder returns two exact difference sets only when all residual cells become zero; otherwise it returns failure. This model accepts distinct unsigned 64-bit integer IDs and requires both replicas to use identical cell counts, probe counts, and hash rules. A checksum match is a probabilistic guard, not a cryptographic proof.
Invertible Bloom tables: peel differences between replica ID sets
Operational case
The left replica has incident IDs 19, 29, 47, and 61; the right has 19, 47, and 83. Peeling returns left-only IDs 29 and 61 and right-only ID 83. Shared IDs 19 and 47 cancel without being listed. If the number of differing IDs overwhelms the chosen cells, a nonzero residual can remain and the decoder returns no answer, rather than a partial list presented as complete. An empty set difference decodes to two empty sets. Repeating an ID within a replica violates the set model, because a count of two would no longer mean a single distinct record.
Working Python program
import hashlib
class ReplicaDifferenceTable:
def __init__(self, cells=47, probes=3):
if cells < probes or probes < 2:
raise ValueError("need at least one cell per probe")
self.cells = cells
self.probes = probes
self.counts = [0] * cells
self.keys = [0] * cells
self.checks = [0] * cells
def _digest(self, key, salt):
data = key.to_bytes(8, "little") + salt.to_bytes(2, "little")
return int.from_bytes(hashlib.blake2b(data, digest_size=8).digest(), "little")
def _positions(self, key):
positions = []
salt = 0
while len(positions) < self.probes:
slot = self._digest(key, salt) % self.cells
if slot not in positions:
positions.append(slot)
salt += 1
return positions
def adjust(self, key, sign):
if not isinstance(key, int) or not 0 <= key < 2**64 or sign not in (-1, 1):
raise ValueError("key must be an unsigned 64-bit ID and sign must be +1 or -1")
fingerprint = self._digest(key, 65535)
for slot in self._positions(key):
self.counts[slot] += sign
self.keys[slot] ^= key
self.checks[slot] ^= fingerprint
def decode(self):
counts, keys, checks = self.counts[:], self.keys[:], self.checks[:]
left_only, right_only = set(), set()
while True:
pure = next((slot for slot, count in enumerate(counts)
if abs(count) == 1 and checks[slot] == self._digest(keys[slot], 65535)
and slot in self._positions(keys[slot])), None)
if pure is None:
break
key, sign = keys[pure], counts[pure]
(left_only if sign == 1 else right_only).add(key)
fingerprint = self._digest(key, 65535)
for slot in self._positions(key):
counts[slot] -= sign
keys[slot] ^= key
checks[slot] ^= fingerprint
if any(count or key or check for count, key, check in zip(counts, keys, checks)):
return None
return left_only, right_only
if __name__ == "__main__":
left = {19, 29, 47, 61}
right = {19, 47, 83}
table = ReplicaDifferenceTable()
for incident_id in left:
table.adjust(incident_id, 1)
for incident_id in right:
table.adjust(incident_id, -1)
result = table.decode()
print(tuple(sorted(side) for side in result) if result is not None else None)Output
([29, 61], [83])Time, space, and tradeoff
With K probes and M cells, each adjustment computes K positions and checks for duplicates among at most K chosen slots; this direct version costs O(K squared) hashing and O(M) table space. Peeling rescans all M cells to find each pure candidate and can remove at most D recovered IDs, so worst-case decoding is O(DM plus DK squared); a queue of newly pure cells would be faster. It copies all cell arrays before decoding, retaining the source sketch. Success depends on load and hash placement, with no guaranteed decode threshold here. A Merkle tree gives a different comparison protocol; an ordinary Bloom filter can test possible membership but cannot list both sides' missing IDs.
Common Mistakes
- Do not return a partial peel as a complete replica diff.
- Do not insert duplicate IDs when the contract is set reconciliation.
- Do not use different hash parameters for the two replicas.
- Do not treat a checksum as a proof against deliberate collisions.
Connected lessons
- Hashing
- Data Structures
- Counting Bloom filters: delete only a known insertion
- Merkle trees: verify an indexed scan record
- Cuckoo filters: relocate compact fingerprints safely
- Run-length bitmaps: union, intersect, and subtract alert spans
- Bloom filters: reject absent keys without claiming exact membership
- Scalable Bloom filters: grow without discarding old members
- Projects
- Quizzes
Compare the operation boundary with Double-array tries: static incident-code transitions with BASE and CHECK, Hopscotch hashing: keep each shipment near its home bucket, De Bruijn graphs: compact non-branching k-mer routes into unitigs, then complete the audit project and decision quiz.
