# Z32 ciphertext-only unicity ## Inputs The assignment supplies the transcription `C9J|#Ok[AMf8?ORTGX6FDVj%HCELzPW9`, with case-sensitive characters naming handwritten glyphs. Of 32 positions, there are 29 distinct glyph types. Three of the 29 occur twice, at positions (1, 26), (2, 32), and (6, 14), and 26 of the 29 occur once. Each glyph decodes to one of 26 letters (A–Z). The base case uses printed order. The order variants assume 194 candidate permutations of the 32 positions, as stipulated in the assignment. The candidates themselves and the known mapping for the order-only variant were not supplied. ## Method and English redundancy Shannon's random-cipher model estimates the unicity distance as H(K)/D, where H(K) is key entropy in bits and D is language redundancy in bits per plaintext letter. The model treats trial decryptions like random draws from possible strings, of which roughly a fraction 2⁻ⁿᴰ are plausible at length n. Near the estimated distance, the expected number of spurious keys is of order one. A whole-symbol threshold here is the ceiling of that crossover, so it marks where the single-plaintext regime is expected to begin under the approximation. It gives neither a success probability nor a guarantee of one surviving plaintext at that length. Each ciphertext symbol contributes one plaintext letter in the assigned model. [Claude E. Shannon, *Communication Theory of Secrecy Systems* (1949), p. 660 and §14, pp. 690–693](https://kaf401.rloc.ru/Criptfiles/shannon1949.pdf#page=5) Use D = log₂(26) − h, with log₂(26) = 4.70044 bits per letter for uniformly random letters. Shannon reports about 2.3 bits per letter for statistics extending up to eight letters, and about 1 bit per letter for literary English using dependencies extending up to 100 letters. These supply a low redundancy of 2.40044 bits per letter and a high redundancy of 3.70044 bits per letter. They are two modeling choices. The high value tests how much the threshold falls with stronger language constraints. [Claude E. Shannon, *Prediction and Entropy of Printed English* (1951), p. 50 and §2, p. 51](https://languagelog.ldc.upenn.edu/myl/Shannon1950.pdf#page=1) ## Key counts and thresholds For the base case, choose one letter independently for each of the 29 observed glyph types. This gives 26²⁹ decoding maps, each with probability 1/26²⁹ under the uniform prior. Multiple glyphs can decode to the same letter, and an observed map may omit letters. Every map produces a different raw plaintext in printed order because every glyph in the map occurs. The handbook describes homophonic encryption using disjoint sets of encodings for letters, which gives unique decoding per glyph in the one-symbol case used here. For unknown order, count pairs of a map and an order. With 194 equally likely orders independent of the map, the pair adds log₂(194) = 7.5999 bits of key entropy. Distinct pairs can yield the same plaintext. [Menezes, van Oorschot and Vanstone, *Handbook of Applied Cryptography*, §1.5.2, pp. 17–18](https://cacr.uwaterloo.ca/hac/about/chap1.pdf) | Model | Number of keys or key pairs | Key entropy (bits per key draw) | Distance at high / low redundancy (symbols) | Whole-symbol threshold at high / low redundancy | Comparison with 32 symbols | |---|---:|---:|---:|---:|---| | Homophonic, printed order | 26²⁹ | 136.3128 | 36.84 / 56.79 | 37 / 57 | Below both thresholds | | Homophonic, unknown order | 194 × 26²⁹ | 143.9127 | 38.89 / 59.95 | 39 / 60 | Below both thresholds | | Simple one-to-one, conventional 26-symbol alphabet | 26! | 88.3820 | 23.88 / 36.82 | 24 / 37 | Between the reference thresholds. Z32 itself admits no such key. | | Fully known substitution, unknown order | 194 | 7.5999 | 2.05 / 3.17 | 3 / 4 | Above both formal thresholds | The one-to-one row describes a conventional cipher on two alphabets of 26 symbols, whose keys are permutations. A one-to-one map from the 29 observed glyph types into 26 letters has zero admissible keys. Consequently there is no key entropy or unicity distance for that variant on the supplied transcription, regardless of reading order. [*Handbook of Applied Cryptography*, §1.5.2, Definition 1.27, p. 17](https://cacr.uwaterloo.ca/hac/about/chap1.pdf#page=18) The order-only row uses the requested common denominator D. Every candidate order preserves the decoded letter counts, so the random-string comparison overstates the available constraints. Shannon's transposition adjustment compares against independently drawn letters at ordinary English frequencies. Using his single-letter entropy of 4.14 bits per letter gives adjusted redundancies of 1.84–3.14 bits per letter and a formal distance of 2.42–4.13 symbols, or 3–5 symbols after rounding up. This still puts the nominal crossover below 32 symbols. The 194 candidate orders are defined for the full block here. A few symbols of a partial block need not distinguish those orders, and different orders can produce identical full plaintexts by swapping equal letters. Both order-only calculations are scale estimates, with the actual distinctions depending on the mapping and permutations. [Shannon (1949), §15, pp. 693–694](https://kaf401.rloc.ru/Criptfiles/shannon1949.pdf#page=38) [Shannon (1951), §2, p. 51, eq. (3)](https://languagelog.ldc.upenn.edu/myl/Shannon1950.pdf#page=2) ## Reproduction Run this complete Python 3 script with no external packages. It checks the transcription counts and prints the key counts, entropy, distances, and ceilings in the table, then the adjusted order-only distances. ```python from collections import defaultdict from math import ceil, factorial, log2 ciphertext = "C9J|#Ok[AMf8?ORTGX6FDVj%HCELzPW9" positions = defaultdict(list) for index, glyph in enumerate(ciphertext, start=1): positions[glyph].append(index) repeats = [indices for indices in positions.values() if len(indices) > 1] singletons = sum(len(indices) == 1 for indices in positions.values()) assert len(ciphertext) == 32 and len(positions) == 29 assert repeats == [[1, 26], [2, 32], [6, 14]] and singletons == 26 print(len(ciphertext), len(positions), repeats, singletons) alphabet_size = 26 order_count = 194 homophonic_keys = alphabet_size ** len(positions) key_counts = { "homophonic": homophonic_keys, "homophonic plus order": homophonic_keys * order_count, "conventional one-to-one": factorial(alphabet_size), "one-to-one on supplied glyphs": 0, "order only": order_count, } english_entropy = (1.0, 2.3) # bits per letter, lower then higher uniform_entropy = log2(alphabet_size) redundancy = tuple(uniform_entropy - h for h in english_entropy) print(f"Uniform entropy: {uniform_entropy:.5f}") print("Redundancy (high / low):", *(f"{d:.5f}" for d in redundancy)) for model, count in key_counts.items(): if count == 0: print(model, count, "undefined") continue entropy = log2(count) distances = tuple(entropy / d for d in redundancy) print(model, count, f"{entropy:.4f}", *(f"{distance:.2f}" for distance in distances), *(ceil(distance) for distance in distances)) adjusted_redundancy = tuple(4.14 - h for h in english_entropy) adjusted_distances = tuple(log2(order_count) / d for d in adjusted_redundancy) print("Transposition redundancy:", *(f"{d:.2f}" for d in adjusted_redundancy)) print("Transposition distances:", *(f"{n:.2f}" for n in adjusted_distances), *(ceil(n) for n in adjusted_distances)) ``` ## Shows Under both English redundancy choices, 32 glyphs fall short of the estimated single-plaintext crossover for an unknown homophonic map, with or without uncertainty over order. A fully known map reduces the formal search to at most 194 plaintext permutations and puts 32 above the order-only benchmarks. The strict one-to-one model is excluded by the glyph count. ## Does not show The calculation neither certifies ambiguity for this particular cryptogram nor establishes a unique or authentic reading. Its estimate averages language constraints and does not score Z32 candidate plaintexts. For fixed order, every candidate plaintext obeys the three forced repeat pairs, so candidate strings differ structurally from the random-cipher model. Map, location, or message-format evidence could change the inference but lies outside this ciphertext-only calculation. ## Contestable assumptions - The transcription and glyph identities are exact. The model excludes nulls, errors, multiletter encodings, and context-dependent substitution. - The 29 observed glyphs define the counted part of the key. A larger cipher inventory could include unobserved glyphs representing letters absent from the observed map. Requiring the observed map itself to cover all 26 letters or imposing a homophone allocation would change the key count. - The counted maps and orders have uniform priors, independent of one another in the combined case. Glyph-selection frequencies within homophone sets could change relative likelihoods. - Ordinary printed English with spaces and punctuation omitted supplies a reasonable redundancy scale for the unknown message. A short instruction, coordinates spelled as text, or a restricted vocabulary could have different constraints. - The nominal calculation holds the counted key space fixed while varying text length and uses a constant redundancy per letter. Actual glyph coverage and language constraints vary with length. The order variants additionally depend on how their permutations are defined for other lengths.