brew&drew Tupper's formula bitmaps

crypto
flag d4rk{0bV_DUHHH?}

d4rk{0bV_DUHHH?}

Summary

Two "twins", brew and drew, exchange messages using a "weird crypto-scheme"; we are given the log of the start of the conversation (logged_convo.txt) — six decimal integers of about 1750 bits each, alternating between brew: and drew:. There is no modulus, no exponent and no key, so it is not RSA or any recognisable public-key scheme.

Every integer is divisible by 17, and written in base 2^17 its digits form short zero-separated groups that are frequently palindromes ([255, 8, 8, 8, 255], [60, 66, 129, 66, 60], ...). That is the tell: those are not ciphertext values, they are pixel columns of a 17-pixel-tall bitmap, and a number that is a multiple of 17 and encodes a 17-row bitmap is a k value for Tupper's self-referential formula. Divide each integer by 17 and plot bit 17·x + y as pixel (x, y) and the conversation renders as text; the fifth message is the flag.

Solution / Exploit

Challenge text:

These two twins brew and drew are communicating, they talk less but when they do they use weird crypto-schemes, we tried to log the start of it.

logged_convo.txt is six integers (~1750 bits each), alternating brew: / drew: (reproduced from the source; e.g. message 0):

output
brew: 67161698341499273473130612306146733024555466385860729723346090404726176712549130561136564864203014586108687528049491278170399549234008024936662539474839813095021853123049009515318419284563761120399302300267076908609673368404248510243718305104348411717650704764669796106604722535632982630780869591798575223735053654595927489248364976283512057628272625018946470852738648372325263973159578148355292997476818596612498074652321259577914963043066083063026799152721673976252322137738314007095766723742331354672274472047108502281256960

1. What the numbers look like

The useful observations are all about the number 17:

  • Every integer is divisible by 17.
  • Pairwise GCDs are only 2^k · 17^m, so there are no shared primes to exploit (no hidden RSA structure).
  • The binary autocorrelation of each integer peaks at multiples of 17.
  • Written in base 2^17, the digits form short zero-separated groups that are often palindromes, such as [255, 8, 8, 8, 255] and [60, 66, 129, 66, 60].

That last point is what gives it away. 255, 8, 8, 8, 255 is not ciphertext — it is the letter H drawn as five pixel columns: a full bar, three columns with one middle pixel, and another full bar. 60, 66, 129, 66, 60 is an O. The palindromes are just letters that are left-right symmetric, and the repeated groups are repeated letters.

A number that is a multiple of 17 and encodes a bitmap 17 pixels tall is Tupper's formula.

2. Tupper's self-referential formula

output
1/2 < floor( mod( floor(y/17) · 2^(-17·floor(x) - mod(floor(y), 17)), 2 ) )

Plotted over 0 ≤ x < 106 and k ≤ y < k + 17, the formula draws a 106×17 bitmap. Stripped of the notation, it says:

pixel (x, y) is on when bit 17·x + y of k / 17 is set.

So k is the bitmap read column by column, multiplied by 17. Decoding is a division and a bit test.

3. Solve

python
1import re
2from PIL import Image
3
4ns = [int(x) for x in re.findall(r"\d{50,}", open("logged_convo.txt").read())]
5
6S = 8  # pixel scale
7im = Image.new("L", (106 * S, len(ns) * 19 * S), 255)
8for i, k in enumerate(ns):
9    assert k % 17 == 0
10    N = k // 17
11    for x in range(106):
12        for y in range(17):
13            if (N >> (17 * x + y)) & 1:
14                X, Y = 105 - x, i * 19 + 1 + y
15                im.paste(0, (X * S, Y * S, X * S + S, Y * S + S))
16im.save("out.png")

The 105 - x is the usual Tupper mirroring. Without it the text comes out reversed.

4. Output

Speaker Message
brew Hi! HOW ARE YOU?
drew I AM SCARED ☹
brew WHY???
drew Is This Safe?
brew d4rk{0bV_DUHHH?}
drew Ok! Thanks ☺

The 0 is a slashed zero in the bitmap, and the b has a full-height ascender, so neither is ambiguous once rendered.

Flag(s)

output
d4rk{0bV_DUHHH?}

Notes / Pitfalls

The sources record a substantial amount of time spent on a wrong approach before the "it's a picture" realisation. This section keeps that record, because the lesson is the point.

  • What went wrong first. A lot of effort went into treating the integers as ciphertext: factoring the cofactors, batch GCD, recurrences, XOR and affine byte transforms, and trying to deconvolve the base-2^17 digits against an unknown "kernel". The structure had already been found (17, base 2^17, palindromic digit groups), but it was read as algebra instead of as a picture.
  • The lesson. Print the bits as a grid before reaching for number theory. Palindromic digit groups in a fixed-width base are a strong hint that you are looking at glyph columns.
  • The structural characterisation was correct but incomplete. The deep-analysis notes (brewdrew_hz_NOTES.md) had already proven: v2(n) = 448, 686, 1093, 837, 161, 840; every n divisible by 17 (with X0, X2 divisible by 17^2); pairwise GCDs only 2^min(v2) · 17^(0..2); binary autocorrelation peaking at multiples of 17; and base-2^17 digits containing zero-separated palindromic words. It then concluded the message was a multiplicative convolution W' = M (*) K with an unknown kernel K, and stalled trying to deconvolve it — the flag was not recovered on that branch.
  • The dead ends, concretely. The notes list the failed attacks, all reproducible in the brewdrew_hz*.py scripts: gcd / shared-prime / batch-GCD; recurrences (x^2 mod N, x^e mod N, LCG, XOR shifts); byte/digit extraction in bases 2..1024 in both orders (no ASCII, no d4rk); interleave/spread extraction (bit strides 2..178), complement and bit/byte/nibble reversals; affine byte transforms per number (x·a⁻¹+b mod 256) and repeating-key XOR/ADD/SUB; base64 packing of 12-bit units and 12..17-bit re-packing; multiplicative kernels (2^k ± 1, repunits, B^t ± 1); and round-pair combinations (sum/diff/xor/and/or) of X0..X5.
  • cofactors.txt / wf.out / factorizations.json are all from those dead ends. They contain the per-message small-factor breakdowns (e.g. 0 brew v2=448 small={5: 1, 7: 1, 17: 2, 43: 1, 1801: 1}) and word-factor factorisations of the base-2^17 digit groups. None of it is needed for the solve; it is retained only as the trail of the wrong approach.
  • HANDOFF.md agrees. It records the flag d4rk{0bV_DUHHH?} (accepted) and states that the brew_pass*.py, brewdrew_*.py and related .out/.json/.txt files are from earlier dead-end attempts and are not needed for the solve.