What does Zero-Touch Sites, Payment Anti-Fraud and Cashflow Queues conclude, in numbers, about “Transfer Receipts: Deduplication, Image Hashes and Release-Then-Audit”?
Answer: Chapter 1 shows that checking only 4 trailing digits gives an even chance of a collision by 119 orders and, after 5,000 orders, wrongly refuses 0.3935 of honest receipts; a perceptual hash recognises re-saved copies but matches honest receipts from the same app; release-then-audit deters only when the person caught loses a stake, and with a stake of 200 auditing 0.485 of orders suffices.
Scope of the numbers: Marked boxes separate evidence, 16 runnable Python programs, historical sources and hypotheses.
Data table
The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it. standard-library Python onlyprinted values that match the answer: 0.3935, 119, 5000
| (1) P(some shared tail) among n orders | |
| k n | 50 n=100 n=500 n=5000 n for 0.5 |
| 4 | 0.1155 0.3914 1.0000 1.0000 119 |
| 6 | 0.0012 0.0049 0.1173 1.0000 1178 |
| 8 | 0.0000 0.0000 0.0012 0.1175 11775 |
| honest receipt flagged after M | 5,000 orders: |
| k | 4: 0.3935 |
| k | 6: 0.0050 |
| k | 8: 0.0000 |
| (2) P(Hamming distance <= d) for a 64-bit perceptual hash | |
| d unrelated same app re-saved copy | |
| 4 | 3.68e-14 0.0280 0.9569 |
| 6 | 4.51e-12 0.1365 0.9970 |
| 10 | 9.98e-09 0.6374 1.0000 |
| Reading: four-digit tails collide by the time a shop has | |
| taken 119 orders, and after 5,000 orders four honest | |
| receipts in ten would be refused. A perceptual hash finds | |
| re-saved copies but also matches honest receipts from the | |
| same app; neither replaces the full reference number. |
Show the full program
# Chapter 1. [p01] Last-k-digit receipt checks and hash look-alikes.
# (1) A manual-payment site accepts a bank-transfer screenshot and
# stores only the last k digits of its reference number to stop reuse.
# If tails are uniform, among n honest orders the chance of at least
# one shared tail is 1 - prod_{i<n} (1 - i / 10^k) (birthday problem).
# After M accepted orders, a new honest receipt is wrongly flagged as
# "reused" with chance 1 - (1 - 10^-k)^M.
# (2) A 64-bit perceptual hash flags two images as the same receipt if
# they differ in at most d bits. For unrelated images, bits differ
# with chance 0.5; for two honest receipts made by the same banking
# app (same layout, different numbers) they differ with chance 0.15;
# a re-saved copy of one receipt differs with chance 0.03 per bit.
import math
def birthday(n, k):
p = 1.0
for i in range(n):
p *= 1 - i / 10 ** k
return 1 - p
def first_n(k, target=0.5):
n, p = 1, 1.0
while 1 - p < target:
p *= 1 - n / 10 ** k
n += 1
return n
def tail(d, q, bits=64):
return sum(math.comb(bits, i) * q ** i * (1 - q) ** (bits - i)
for i in range(d + 1))
if __name__ == "__main__":
print(" (1) P(some shared tail) among n orders")
print(" k n=50 n=100 n=500 n=5000 n for 0.5")
for k in (4, 6, 8):
row = [birthday(n, k) for n in (50, 100, 500, 5000)]
print(" {} {:11.4f} {:8.4f} {:8.4f} {:8.4f} {:10d}".format(
k, *row, first_n(k)))
print(" honest receipt flagged after M = 5,000 orders:")
for k in (4, 6, 8):
print(" k={}: {:.4f}".format(k, 1 - (1 - 10 ** -k) ** 5000))
print(" (2) P(Hamming distance <= d) for a 64-bit perceptual hash")
print(" d unrelated same app re-saved copy")
for d in (4, 6, 10):
print(" {:2d} {:11.2e} {:10.4f} {:15.4f}".format(
d, tail(d, 0.5), tail(d, 0.15), tail(d, 0.03)))
print("\nReading: four-digit tails collide by the time a shop has")
print("taken 119 orders, and after 5,000 orders four honest")
print("receipts in ten would be refused. A perceptual hash finds")
print("re-saved copies but also matches honest receipts from the")
print("same app; neither replaces the full reference number.")Single source and citation
Fan, Y. (2026). Zero-Touch Multi-Site Fault Tolerance, Payment Anti-Fraud State Machines and Passive Cashflow Queuing (Version 1.0.0), Chapter 1: Transfer Receipts: Deduplication, Image Hashes and Release-Then-Audit. 5D Library. https://doi.org/10.5281/zenodo.24090201
DOI: 10.5281/zenodo.24090201 · Read the monograph · 5DL-B-075 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026075,
author = {Fan, Yafu},
title = {Zero-Touch Multi-Site Fault Tolerance, Payment Anti-Fraud State Machines and Passive Cashflow Queuing},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
doi = {10.5281/zenodo.24090201},
url = {https://doi.org/10.5281/zenodo.24090201}
}Other chapter answers in this book
- Chapter 2 · Self-Referral and "Invite Friends to Unlock"
- Chapter 3 · The Order State Machine: Exhaustive Checking and the Idempotency Window
- Chapter 4 · Thirty Sites on One Kernel: Queues and Tail Latency
- Chapter 5 · Availability: Shared Kernels, Standby Nodes and Blue-Green Draining
- Chapter 6 · Allocating Traffic, Promoting Domains and Holding Cash
- Chapter 7 · Matched Tallies, Banknote Seals and Liu Yan's Canal
- Chapter 8 · A Nine-Flag Audit and a Pre-Registered Experiment