Appendix D: Solutions for Chapter 6
This page collects solutions and editorial notes for the exercises in Chapter 6: Digital signatures reconsidered. Compute and derivation exercises have worked solutions; open-ended exercises have an editorial note describing what a strong answer addresses.
The fuller versions of these routines are in the signature_attacks package under solutions/ch06-signature-attacks. From a clone of the companion repository, pytest tests/ch06 runs its suite. Appendix C has the setup.
Exercise 1
Section titled “Exercise 1”The textbook RSA signature on is , so , because raising to the -th power is multiplicative on . Nothing here needs the group to be cyclic, and for a two-prime modulus it is not: , which for the chapter’s modulus is not cyclic because . The combined signature is therefore a valid textbook-RSA signature on the message without ever asking the signer for it: the multiplicative homomorphism is the forgery.
The full-domain-hash variant FDH-RSA replaces with in both signing and verification, so accepts iff . Multiplying the two signatures still works as arithmetic: , because RSA exponentiation is multiplicative whatever is fed into it. What the product is not is a forgery. It verifies only against a message whose hash satisfies , and producing such an means inverting the random oracle at a value the attacker chose, which succeeds only with negligible probability. The obvious candidate fails for the separate reason that is not multiplicative.
# The 64-bit modulus from the chapter's opening snippet.p, q = 3184935163, 3199286161n = p * qe = 65537d = pow(e, -1, (p - 1) * (q - 1))
m1, m2 = 0x1111222233334444, 0x5555666677778888s1, s2 = pow(m1, d, n), pow(m2, d, n)combined = (s1 * s2) % nexpected = pow((m1 * m2) % n, d, n)print(combined == expected, combined)# ==> True 2687895047109345874Exercise 2
Section titled “Exercise 2”The recovery uses the same identities derived in Appendix D, Chapter 4: and , all modulo the group order. The block below keeps the chapter’s group and changes what the exercise asks you to change: private key instead of , nonce instead of . As in the chapter, is derived from rather than chosen, since a nonce the signer picks is what fixes .
Two conditions are worth checking rather than assuming, because a real signer enforces both. FIPS 186-5 rejects a signature with or , so a pair that includes one is not a pair an attacker could ever observe. A randomized signer then draws a fresh nonce; a deterministic one outputs failure (National Institute of Standards and Technology, 2023). And the recovery needs , which for a fixed holds exactly when .
When , the differences and are both zero. The recovery formula becomes , which is undefined. The two signatures collapse to the same equation, so two equations in two unknowns degenerate to one, and and cannot be solved independently.
p, n, g = 23, 11, 4 # the chapter's group: order-11 subgroup of (Z/23)^*d, k = 4, 8 # a different private key and nonce, as the exercise asksr = pow(g, k, p) % n # r follows from k; the signer does not choose itz1, z2 = 1, 2
# signing: s = k^{-1} (z + r d) mod ns1 = (pow(k, -1, n) * (z1 + r * d)) % ns2 = (pow(k, -1, n) * (z2 + r * d)) % n
# a conforming signer never emits a signature with r = 0 or s = 0assert r != 0 and s1 != 0 and s2 != 0assert s1 != s2
# recoveryk_rec = ((z1 - z2) * pow(s1 - s2, -1, n)) % nd_rec = ((s1 * k_rec - z1) * pow(r, -1, n)) % nprint(r, s1, s2, k_rec, d_rec)# ==> 9 6 2 8 4Exercise 3
Section titled “Exercise 3”A reference statement to compare against your own version:
The challenger samples a keypair and gives to the adversary. The adversary makes any number of queries to a signing oracle that returns for adversary-chosen messages , with the queried set recorded by the challenger. The adversary then outputs a forgery , and the challenger declares the adversary the winner if and only if and . The adversary’s advantage as a function of the security parameter , and the scheme is EUF-CMA secure if every probabilistic polynomial-time adversary’s advantage is negligible in .
A complete answer also names the original paper (Goldwasser et al., 1988) and says which of the chapter’s four notions it is stating: the key-only or EUF-KMA weakenings, plain EUF-CMA, or the stronger sEUF-CMA. The last of those counts a second valid signature on an already-queried message as a win. The two standards this book builds are specified against different notions: FIPS 204 designs ML-DSA for SUF-CMA, its name for sEUF-CMA, while FIPS 205 states SLH-DSA’s security categories with respect to EUF-CMA (National Institute of Standards and Technology, 2024a, 2024b).
Exercise 4
Section titled “Exercise 4”A stateful hash-based scheme tracks an index of which one-time keypairs have been consumed. If two machines hold a copy of the secret state and sign independently, both will eventually use the same one-time index. That produces two signatures under the same one-time key on different messages, which reveals additional secret material at every position where the two signed digests differ. What that buys an attacker is a much larger set of forgeable messages, not the whole one-time secret and not unrestricted signing: Chapter 14 works out which Lamport positions become supplyable after two signatures, and Chapter 15 does the same for WOTS+ chain positions. It is already a break, because the scheme’s security condition is one signature per key, and a forgeable set an attacker can search through is far inside the work the parameters promise. Coordination is the only safe way to share state: a shared sequence number, an atomic counter, or enforcement inside a hardware security module (HSM). Any backup that does not preserve the coordination invariant is a forgery vector.
The NIST stateful standard is XMSS / LMS (NIST SP 800-208). The way that standard contains the risk is to move the state inside the hardware. It requires key generation and signature generation to happen in cryptographic modules that never export secret keying material, validated to FIPS 140-2 or FIPS 140-3 Level 3 or higher physical security (Cooper et al., 2020). The NIST stateless standard is SLH-DSA (FIPS 205), which removes the state requirement at the cost of a larger signature (National Institute of Standards and Technology, 2024b).
Exercise 5
Section titled “Exercise 5”The EUF-CMA win condition is unchanged in the deployment setting: an adversary that produces such that and was never queried to the signing oracle wins the game. In the recorded-key scenario the adversary makes zero oracle queries: it reads from the public ledger at year and waits. At year Shor’s algorithm (Shor, 1994) recovers the secret scalar from in polynomial time, after which the adversary signs any of its choice and the forgery is unconditional. The win condition is satisfied trivially because the queried set contains no message at all.
The key-exposure window length is
At and the window is ten years. Part VII picks this up: Chapter 36 sets a quantum threat model for public ledgers using Mosca’s inequality, and Chapter 37 works through signature migration for Bitcoin and Ethereum, whose Layer-1 (L1) keys are the ones exposed this way.
# Key-exposure window for a Schnorr-on-secp256k1 public key first published at Y_first,# evaluated at a stated CRQC arrival year Y_CRQC.Y_first = 2021 # BIP-341 puts the output key in the P2TR scriptPubKeyY_CRQC = 2031 # CNSSP 15 CNSA 2.0 mandatory-use milestone (Chapter 1)exposure_years = Y_CRQC - Y_firstprint(exposure_years)# ==> 10