关于「一个指纹的盲区:总哈希只能回答「变没变」」,《默克尔树与书稿存证》给出的定量结论是什么?
结论:第一章在九个文件的示意书稿上做单字节改动,凭总哈希猜改了哪个文件,命中率 0.1133,与瞎猜的 0.1111 无异。
数据口径:书中的书稿、时间戳、盐值与参数均为示意,全部计算由书中程序生成;哈希与时间戳只证明某段内容不晚于某时已经存在且未被改动,不等于著作权登记或权属证明,举证效力以法院与当地法规为准;本书不构成个人化法律建议。 第一章在九个文件的示意书稿上做单字节改动,凭总哈希猜改了哪个文件,命中率 0.1133,与瞎猜的 0.1111 无异。
对照数据表
下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 0.1111, 0.1133
| file mean bits sd bits (of 256 output bits, 300 edits each) | |
| 0 | 128.09 7.93 |
| 1 | 128.15 8.42 |
| 2 | 127.96 8.53 |
| 3 | 127.95 7.93 |
| 4 | 127.83 7.58 |
| 5 | 128.11 7.83 |
| 6 | 127.70 8.03 |
| 7 | 127.69 8.16 |
| 8 | 127.47 8.17 |
| grand mean distance | 127.88 bits |
| spread of file means | 0.68 bits |
| guess-the-file accuracy | 0.1133 (test edits 2700) |
| chance level 1/9 | 0.1111 |
| standard error at chance | 0.0060 |
| bits needed to name the file | 3.1699 |
查看完整验算程序
# Chapter 1. p11: one digest of the whole book says "changed", not where.
# Model: a demo manuscript of 9 files (preface + 8 chapters) is hashed
# as one SHA-256 digest. We change one byte in a random file at a random
# offset and measure the Hamming distance between old and new digests.
# If the digest carried any trace of WHERE the edit happened, the mean
# distance would differ by file and a classifier could guess the file.
# Training and test edits use different fixed seeds. Texts are synthetic
# (illustrative texts, not a real manuscript).
import hashlib
import math
import random
NFILE = 9
def file_text(i, ver=1):
# illustrative manuscript: about 5 KB of fixed text per file
line = "B-295 demo manuscript, file %02d, version %d. " % (i, ver)
return (line * 120).encode("ascii")
def book_digest(files):
h = hashlib.sha256()
for f in files:
h.update(f)
return h.digest()
def hamming(a, b):
return bin(int.from_bytes(a, "big") ^ int.from_bytes(b, "big")).count(
"1")
def edits(offset, per_file):
rng = random.Random(20261113 + offset)
base = [file_text(i) for i in range(NFILE)]
d0 = book_digest(base)
out = []
for i in range(NFILE):
for _ in range(per_file):
f = bytearray(base[i])
pos = rng.randrange(len(f))
f[pos] = (f[pos] + 1 + rng.randrange(255)) % 256
files = base[:i] + [bytes(f)] + base[i + 1:]
out.append((i, hamming(d0, book_digest(files))))
return out
train = edits(0, 300)
test = edits(1, 300)
means = []
print("file mean bits sd bits (of 256 output bits, 300 edits each)")
for i in range(NFILE):
xs = [d for f, d in train if f == i]
m = math.fsum(xs) / len(xs)
sd = math.sqrt(math.fsum((x - m) ** 2 for x in xs) / (len(xs) - 1))
means.append(m)
print("%4d %9.2f %7.2f" % (i, m, sd))
hits = 0
for f, d in test:
guess = min(range(NFILE), key=lambda j: (abs(d - means[j]), j))
if guess == f:
hits += 1
grand = math.fsum(d for _, d in train) / len(train)
print("grand mean distance %.2f bits" % grand)
print("spread of file means %.2f bits" % (max(means) - min(means)))
print("guess-the-file accuracy %.4f (test edits %d)"
% (hits / len(test), len(test)))
print("chance level 1/9 %.4f" % (1 / NFILE))
print("standard error at chance %.4f"
% math.sqrt((1 / NFILE) * (1 - 1 / NFILE) / len(test)))
print("bits needed to name the file %.4f" % math.log2(NFILE))唯一数据源与引用
范雅福(Fan, Y.). (2026). 《默克尔树哈希链与可信时间戳、专著版本防篡改与优先权举证最小证明母典》第 1 章「一个指纹的盲区:总哈希只能回答「变没变」」(版本 1.0.0). 5D Library. DOI 待发布
DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 5DL-B-295 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026295,
author = {Fan, Yafu},
title = {Merkle Hash Trees and Trusted Timestamps: Tamper-Evidence for Monograph Versions and Minimal Proofs of Priority},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}