5D Library › 零人工多站点容错架构、支付防欺诈状态机与被动现金流排队论 · English
第七章 飞钱合券、交子印押与刘晏漕运
为什么在这里读这些史料
本书的三个问题——凭证如何防伪与防重复兑付、流通中的凭证总量如何封顶、物资的流转如何通过缩短在途时间而增加——在唐宋的财政与金融中都有先例:唐代的飞钱、北宋的交子,以及唐代刘晏对漕运的整顿。本章没有取得可以逐字核对的原始文献版本,因此不引用古籍原文,只引用英文维基百科相关条目的文字(已逐字核对),并把它们所据的研究著作列出;凡条目未载之事,本章一律不作断言。
唐代飞钱:合券取钱
原典
英文维基百科「Flying cash」条目(所据研究为 Yang 1952)
the merchants would entrust their money to the representative offices of their local governments
When the tallies were matched at a local office, they could withdraw their money.
in the year 804, merchants were using flying cash
据该条目,唐代商人把钱交给其本地政府的驻外代表机构,取得凭证;凭证与官府所存的另一半在当地机构相合,即可取钱。条目又记,至迟在 804 年商人已在使用飞钱,朝廷起初禁止,后于 812 年正式接纳。
这正是第一章的问题:凭证要能证明「这笔钱确实存过、且只取一次」。合券的安全来自两半必须相合:伪造者看不到官府的另一半,只能盲猜。
推导
# Chapter 7. [p14] Tallies, seals, caps and canals, recomputed.
# (1) Flying cash: a merchant's tally half is redeemed only when it
# matches the office's half. If a match checks k independent marks of
# b possible forms each, a blind forger matches with chance b^-k.
# (2) Jiaozi were stamped with several seals. If a forger copies any one
# seal convincingly with chance q, all n seals pass with chance q^n.
# (3) The official issue was capped at 1,255,340 strings of cash and
# notes were exchanged after a two-year term: if exchanges were spread
# evenly, the issue office turned over cap / 2 a year.
# (4) Little's law for a supply line: stock in transit = throughput x
# transit time. Throughput T and the transit times are parameters; a
# shorter passage carries the same flow with less grain on the road.
if __name__ == "__main__":
print(" (1) blind forgery of a tally: b^-k")
print(" k b=4 b=10 b=60")
for k in (1, 2, 3, 4, 6):
print(" {} {:10.2e} {:10.2e} {:10.2e}".format(
k, 4.0 ** -k, 10.0 ** -k, 60.0 ** -k))
print(" (2) all n seals pass: q^n")
print(" n q=0.5 q=0.3 q=0.1")
for n in (1, 2, 3, 5):
print(" {} {:9.4f} {:8.4f} {:8.4f}".format(
n, 0.5 ** n, 0.3 ** n, 0.1 ** n))
cap = 1255340
print(" (3) cap {:,d}; even exchange over 2 years: {:,d} a year"
.format(cap, cap // 2))
print(" (4) grain in transit for throughput T = 100 units a day")
for days in (60, 40, 30):
print(" transit {:2d} days -> {:,d} units on the road".format(
days, 100 * days))
print("\nReading: matching four marks of ten forms leaves a blind")
print("forger one chance in ten thousand - the full reference")
print("number of Chapter 1, not its last digits. Several seals")
print("multiply a forger's difficulty as several independent")
print("checks do. A cap and a term bound what is outstanding, as a")
print("limit on provisional orders and a key's lifetime do.")
# (1) blind forgery of a tally: b^-k
# k b=4 b=10 b=60
# 1 2.50e-01 1.00e-01 1.67e-02
# 2 6.25e-02 1.00e-02 2.78e-04
# 3 1.56e-02 1.00e-03 4.63e-06
# 4 3.91e-03 1.00e-04 7.72e-08
# 6 2.44e-04 1.00e-06 2.14e-11
# (2) all n seals pass: q^n
# n q=0.5 q=0.3 q=0.1
# 1 0.5000 0.3000 0.1000
# 2 0.2500 0.0900 0.0100
# 3 0.1250 0.0270 0.0010
# 5 0.0312 0.0024 0.0000
# (3) cap 1,255,340; even exchange over 2 years: 627,670 a year
# (4) grain in transit for throughput T = 100 units a day
# transit 60 days -> 6,000 units on the road
# transit 40 days -> 4,000 units on the road
# transit 30 days -> 3,000 units on the road
#
# Reading: matching four marks of ten forms leaves a blind
# forger one chance in ten thousand - the full reference
# number of Chapter 1, not its last digits. Several seals
# multiply a forger's difficulty as several independent
# checks do. A cap and a term bound what is outstanding, as a
# limit on provisional orders and a key's lifetime do.若合券时核对 处相互独立的记号、每处有 种可能,盲目伪造者相合的概率是 :4 处、每处 10 种时只有 1.00e-04,即万分之一。这与第一章的结论相同:要核对的是完整的流水号,而不是末几位。
北宋交子:多重印押与发行上限
原典
英文维基百科「Jiaozi (currency)」条目
To combat counterfeiting, jiaozi were stamped with multiple banknote seals.
据该条目,交子最早由四川的商人私下发行,1023 年朝廷设立交子务,改为官办;条目记载官办交子的发行额以 1,255,340 缗为限,并以两年为期兑换新旧。
交子的防伪靠多重印押:若伪造者仿造任何一枚印押成功的概率为 , 枚印押全部通过的概率是 ; 时,两枚印押把通过率从 0.3000 降到 0.0900,三枚降到 0.0270。这与第二章用设备与支付账户两种独立信号识别团伙是同一个道理:独立的检查相乘。发行上限与两年兑换期则对应第三章的设计:限制在途的「临时放行」订单总量,并给幂等键设定有效期。若兑换平均分布在两年内,每年要兑换 627,670 缗。
刘晏:疏浚汴河
原典
英文维基百科「Liu Yan」条目(唐代官员,715 或 716—780)
the food supplies for the Chang’an regions became plentiful
据该条目,刘晏于 758 年主持盐铁事务,此后亲自察看旧日的漕运路线,开始疏浚汴河的淤塞,此后长安一带的粮食供应变得充足。条目没有记载具体的运量与航程,本章也不作推断。
程序第四项只用利特尔定律说明其中的道理:在途库存 = 流量 × 在途时间 (Little 1961)。若每天运 100 个单位,在途 60 天就有 6,000 个单位压在路上;在途时间缩短到 30 天,同样的流量只需 3,000 个单位在途。第四章的排队与第六章的现金储备是同一个定律:缩短在途时间(处理时间、回款延迟),就减少了需要垫付的库存与现金。
假说 · 尚未验证
作者的诠释(尚未验证): 飞钱的合券、交子的多重印押与发行上限,分别对应现代数字凭证的完整校验、多因子核验与在途总量控制;这些机制在一千多年前就已被用来解决同样的问题。什么会证明这一诠释不当:若对原始文献的研究表明,飞钱与交子的贬值或失败主要不是因为防伪与总量控制的失效,而是别的原因(例如财政滥发),那么这一类比只在形式上成立。
小结
飞钱的合券是一种完整凭证的核对:4 处、每处 10 种记号就让盲目伪造只剩万分之一的机会。交子的多重印押让独立的检查相乘,发行上限与两年兑换期限制了在途的凭证总量。刘晏疏浚汴河之后长安粮食充足;利特尔定律说明,缩短在途时间就减少了压在路上的物资。本章所引均为英文维基百科条目的文字,未引古籍原文。
参考文献
Fan, Y. (2026). Zero-Touch Multi-Site Fault Tolerance, Payment Anti-Fraud State Machines and Passive Cashflow Queuing: Receipt-Hash Deduplication, Self-Referral Blocking, Host-Header Routing and Availability Bounds [零人工多站点容错架构、支付防欺诈状态机与被动现金流排队论] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.24090201 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).