What does The Bit Budget of Tieban Shenshu conclude, in numbers, about “An Affine Cipher for Verse Numbers: Invertibility, Key Space and Known-Pair Attacks”?

Answer: Chapter 3 studies affine coding of verse numbers: with modulus 12,000 the invertible keys are worth only 25.195 bits, an average of 3.288 known pairs breaks the table, and no one-to-one code adds information.

Scope of the numbers: Its parameters are illustrative; all calculations are generated by its programs; it analyses structure and probability, makes no reading of any individual, and is not legal or financial advice. Chapter 5 shows that a verse carries at most 0.5307 bits of expected information and that at an illustrative scale 19.01 people are born each minute.

中文版

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: 12000, 25.195

modulus m phi(m) keys m*phi(m) key bits units share
12,0003,200 38,400,000 25.195 0.2667
17,0246,912 117,669,888 26.810 0.4060
120,00032,000 3,840,000,000 31.838 0.2667
an 8-digit decimal PIN, for comparison26.575 bits
m12000, a = 7, b = 1234: image size 12,000
a^-1 mod m5143; x = 1001 -> y = 8241 -> x = 1001
a6: gcd 6, image 2,000, bits lost 2.585
a15: gcd 15, image 800, bits lost 3.907
a16: gcd 16, image 750, bits lost 4.000
two keys (7,1234) then (11,5000) = one key (77, 6574): True
Show the full program
# Chapter 3. p31: Affine coding of verse numbers, y = (a*x + b) mod m.
# The map is a bijection exactly when gcd(a, m) = 1; then
# x = a^-1 * (y - b) mod m. The number of invertible keys is m * phi(m).
# A non-invertible a folds m inputs onto m / gcd(a, m) outputs and
# destroys log2 gcd(a, m) bits. Moduli: the two verse-bank readings of
# p11 and the 17024 "variation number" of the Huangji jingshi (Ch. 7).
# Keys a = 7, b = 1234 and a = 6 are arbitrary examples.
import math


def phi(m):
    r, n, p = m, m, 2
    while p * p <= n:
        if n % p == 0:
            while n % p == 0:
                n //= p
            r -= r // p
        p += 1
    if n > 1:
        r -= r // n
    return r


print("  modulus m   phi(m)    keys m*phi(m)   key bits  units share")
for m in (12000, 17024, 120000):
    f = phi(m)
    print("  {:>9,} {:>8,}  {:>15,}   {:8.3f}   {:9.4f}".format(
        m, f, m * f, math.log2(m * f), f / m))
print("  an 8-digit decimal PIN, for comparison: {:.3f} bits".format(
    math.log2(10 ** 8)))

m, a, b = 12000, 7, 1234
image = {(a * x + b) % m for x in range(m)}
inv = pow(a, -1, m)
x = 1001
y = (a * x + b) % m
print("  m = 12000, a = 7, b = 1234: image size {:,}".format(len(image)))
print("  a^-1 mod m = {}; x = {} -> y = {} -> x = {}".format(
    inv, x, y, inv * (y - b) % m))
for a2 in (6, 15, 16):
    g = math.gcd(a2, m)
    img = len({(a2 * x + b) % m for x in range(m)})
    print("  a = {:>2}: gcd {:>2}, image {:>5,}, bits lost {:.3f}".format(
        a2, g, img, math.log2(m / img)))
# stacking two affine keys gives one affine key: no extra secrecy
a1, b1, a3, b3 = 7, 1234, 11, 5000
comp = (a3 * a1 % m, (a3 * b1 + b3) % m)
ok = all((a3 * ((a1 * x + b1) % m) + b3) % m ==
         (comp[0] * x + comp[1]) % m for x in range(m))
print("  two keys (7,1234) then (11,5000) = one key {}: {}".format(
    comp, ok))

Single source and citation

Fan, Y. (2026). Tieban Shenshu Ke-Fen Decision Trees, Affine Coding of the Verse Bank and Entropy Lower Bounds on Elicitation (Version 1.0.0), Chapter 3: An Affine Cipher for Verse Numbers: Invertibility, Key Space and Known-Pair Attacks. 5D Library. DOI pending

DOI pending · monograph page goes live after publication · 5DL-B-157 · v1.0.0 · CC-BY-NC-ND-4.0

BibTeX
@book{fan2026157,
  author    = {Fan, Yafu},
  title     = {Tieban Shenshu Ke-Fen Decision Trees, Affine Coding of the Verse Bank and Entropy Lower Bounds on Elicitation},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  note      = {DOI pending}
}

Other chapter answers in this book