#!/usr/bin/env python3 """Rebuild the target file finding #767 names, from the served bytes of the version chain. Finding #767 (review #373 of return #1321) prescribes: "Target = v2 + #1099 row + #1350 census row + #1321 row directly after #1099's row: sha256 4ce085c485c1c3db4b4a4170a1dc992e1b58ddbc81642af5cc4ab4af49dfd07d (= v4 + 38 lines, 0 removed)." That is a verifiable claim, so this script does not paraphrase it: it starts from v4, adds the two blocks v3 deleted (which are #796's 36 lines, present in v2), adds #1099's row (present in v3) and #1321's row (present in v5), and then reports whether the result's sha256 IS 4ce085c4... Measured version chain (line counts, all sha-verified against the store): v1 61601140 (81,231 B, 347 lines) v2 47c10f0a (84,088 B, 383 lines) = v1 + #796's 36 lines v3 bc763992 (84,898 B, 348 lines) = v2 - 36 lines + #1099's row v4 6778292c (82,024 B, 348 lines) = v3 + #1350 census row - #1099's row v5 3408f5f6 (83,372 B, 348 lines) = v4 + #1321 row - #1350 census row <-- SERVED """ import hashlib import os import sys sys.stdout.reconfigure(encoding="utf-8", errors="replace") HERE = os.path.dirname(os.path.abspath(__file__)) os.chdir(HERE) SHA_V2 = "47c10f0a5d7c78a982708270b4aecc5b6eb97d6dfd2b47cbce69f78c74aa15cb" SHA_V3 = "bc7639925683d96a41b5f7ee2ce3b471bb209f7d6c03c6a90d3297d5a453a841" SHA_V4 = "6778292c1b085c7f12b08020d4f8ea530b4756489e032e0cf10909cd990580e9" TARGET = "4ce085c485c1c3db4b4a4170a1dc992e1b58ddbc81642af5cc4ab4af49dfd07d" ANCHOR_KEEP = "broken and any negative that day is void." # end of v2's calibration paragraph ANCHOR_SEC5 = "## 5. What is still open" def lines(p): with open(p, encoding="utf-8") as fh: return fh.read().split("\n") v2 = lines("files/" + SHA_V2) v3 = lines("files/" + SHA_V3) v4 = lines("files/" + SHA_V4) v5 = lines("doc/SEARCH-CONVENTIONS.md") # --- the two blocks v3 deleted (v2 lines 175-204 and 294-299, 1-indexed) ------------- block1 = v2[174:204] # 30 lines: blank + "A channel can fail..." + endpoint table block2 = v2[293:299] # 6 lines: blank, blank, the 4-line "Void negatives" quote assert block1[1].startswith("**A channel can fail on EVERY query"), block1[1][:60] assert any("Void negatives" in l for l in block2), block2 print("block1 = %d lines, block2 = %d lines (total %d = #796's 36)" % (len(block1), len(block2), len(block1) + len(block2))) # --- the two rows ---------------------------------------------------------------- row_1099 = v3[116] # "the smooth/rough split of the global factor identity, ..." row_1321 = v5[116] # "the sign of a truncated alternating subset-sum sieve weight, ..." assert "smooth/rough split" in row_1099, row_1099[:80] assert "truncated alternating subset-sum" in row_1321, row_1321[:80] print("row_1099 len=%d ; row_1321 len=%d" % (len(row_1099), len(row_1321))) out = list(v4) # block1 goes back directly after the calibration paragraph it followed in v2 i = [k for k, l in enumerate(out) if l.startswith(ANCHOR_KEEP)] assert len(i) == 1, i out[i[0] + 1:i[0] + 1] = block1 # #1099's row then #1321's row, directly after the last table row of v4 ("mu(n/s) ..."), # which is the position #1099's row occupied in v3 and #1321's row occupies in v5 LAST_ROW = "| mu(n/s) restricted to s dividing n" j = [k for k, l in enumerate(out) if l.startswith(LAST_ROW)] assert len(j) == 1, ("last table row not unique", len(j)) assert out[j[0] + 1].strip() == "", "expected v4's table to end right after %r" % LAST_ROW out[j[0] + 1:j[0] + 1] = [row_1099, row_1321] # block2 goes back just before the section 5 heading k = [m for m, l in enumerate(out) if l.startswith(ANCHOR_SEC5)] assert len(k) == 1, k out[k[0]:k[0]] = block2 text = "\n".join(out) blob = text.encode("utf-8") got = hashlib.sha256(blob).hexdigest() print() print("rebuilt: %d lines, %d bytes, sha256 %s" % (len(out), len(blob), got)) print("target : %s" % TARGET) print("verdict: %s" % ("MATCHES finding #767's stated sha" if got == TARGET else "DOES NOT MATCH (order or whitespace differs from the reviewer's)")) if got == TARGET: with open("out/target-4ce085c4.md", "wb") as fh: fh.write(blob) print("wrote out/target-4ce085c4.md")