Welcome to Hidden Order
Hidden shortcuts and a bit of background theory.

Welcome to Hidden Order. This is the first post here, so a word about what you will find. I write about privacy, cryptography and whatever else sparks my curiosity. I like taking clever ideas apart until they look obvious, then putting them back together. Wherever I can, I would rather show than tell: posts like this one come with small machines to play with and code you can run, right here in the page. No background in cryptography is assumed. If you can work out a remainder, you can follow along.
It felt right to begin with the idea this blog is named after. And that idea begins with a time capsule.
In 1999, Ron Rivest gave a time capsule a mathematical lock.
The capsule commemorated the history of MIT’s Laboratory for Computer Science and was meant to stay closed for roughly thirty-five years. Opening it meant solving a puzzle: start with a number, square it, keep the remainder after dividing by another number, and repeat. Then repeat again. About eighty trillion times.1

The instructions were public. There was no hidden algorithm to discover. The difficulty was meant to be the journey itself: every step depended on the answer to the one before, so a thousand computers would be no faster than one.
In 2019, the puzzle was solved twice. Bernard Fabrot’s software computation took three years and three months; a separate team using FPGAs finished in about two months.2 Nobody had found a way around the mathematics. A prediction about computation had simply turned out to be a prediction about future computers.
But there was a shortcut, and Rivest had known it all along. It came from knowing how many elements were in a mathematical group.
In the rest of this post we will follow that one number through time-lock puzzles, elliptic curves and proofs of delay. A quick note on the interactive parts before we start. The panels can be clicked and dragged as much as you like. The Python cells are live: press Run to try one, or Edit to change it and see what breaks. They share one session, like a notebook, so they work best run in order. Python downloads the first time you press Run (about 13 MB), and nothing you type leaves your browser.
A modest secret
“How many things are there?” sounds like an oddly modest secret on which to build cryptography. We are used to hiding passwords, keys and messages. The size of a mathematical collection feels like something that ought to be printed on the box.
Sometimes it is. Sometimes the box works perfectly well without anyone being able to count what is inside.
Everything in this post rests on one structure, so it is worth stating precisely.
Notice what the rules don’t ask for:
need not equal . Every group in this post happens to behave that way, but plenty of groups don’t.Our first example is the numbers 1 to 6, combined by multiplying and then keeping the remainder after dividing by 7. Here is how it passes each test:
| Rule | Checking it for 1 to 6, multiplied modulo 7 |
|---|---|
| Closure | , still between 1 and 6. A product is never 0, because 7 is prime and can’t divide the product of two smaller numbers. |
| Associativity | and . Ordinary multiplication is associative, and taking remainders doesn’t change that. |
| Identity | . |
| Inverses | , , and all leave remainder 1, so every element has a partner that undoes it. |
So it is a group, and its order is 6.
Now watch a single element move. Start at 1 and keep multiplying by 3, and you get 3, 2, 6, 4, 5, and then 1 again. Six steps and you are home. Multiply by 2 instead, and you get 2, 4, 1: home after three.
So there are really two orders here. The group has six elements; the element 3 has order six, and the element 2 has order three. The size of the whole world and the length of one element’s cycle can differ.
Why seven, and why does every example below use a prime? Because a prime is what makes rules 1 and 4 hold. Modulo a prime, every remainder from 1 to
has an inverse, exactly as we just checked for 7. With a composite modulus both rules break. Modulo 6, , which falls outside the set, so closure fails. And multiplying by 2 only ever gives 0, 2 or 4, never 1, so 2 has no inverse: it shares a factor with 6. The repair is to keep only the remainders that share no factor with the modulus, which modulo 6 leaves just 1 and 5. A prime is simply the case where nothing has to be thrown away, so the group is all of 1 to and its order is exactly . We will meet a composite modulus soon enough: it is where the secret lives.Try it. Change the base, change the modulus, and watch where each walk closes:
Play with it for a minute and you will notice that the length of a cycle always divides the size of the group. That isn’t a coincidence of small numbers; it is Lagrange’s theorem, and everything that follows leans on it.
If you prefer to see it as code, here is the same walk:
def order(g, p):
"""Smallest k >= 1 with g**k ≡ 1 (mod p)."""
x, k = g % p, 1
while x != 1:
x, k = x * g % p, k + 1
return k
print([order(g, 7) for g in range(1, 7)]) # every answer divides 6
print(order(2, 1_000_003)) # a bigger primeKnowing the cycle gives you a shortcut. If someone asks where you will be after a million complete laps and four more steps, you do not walk the million laps. You count four steps. In symbols: if
has order , write the exponent as , with the remainder. Each of the full laps multiplies by and changes nothing, soAnd because every element’s order divides the group’s, knowing the order of the whole group is enough to cut any exponent down to size. Give the exponent below a ridiculous value and notice that the answer arrives just as fast:
Now imagine you can multiply elements and test whether two are equal, but you have no efficient way to learn the cycle length. You can always take the next step. You just can’t skip ahead.
The lock and its key
That is precisely the situation Rivest engineered. He chose two large secret primes,
and , and published only their product . The numbers modulo that share no factor with it form a group, and its order isEasy to compute if you know
and ; nobody knows how to compute it efficiently if you don’t.3 The puzzle asks for , which the solver reaches by squaring over and over:The stored values never grow past
, but the exponent doubles at every step. The creator doesn’t walk at all. Knowing , they reduce the exponent first, to , and compute directly. Two quick exponentiations, whose cost grows only with the logarithm of .Here is a toy version you can race. Drag
up and watch what happens to each side:Same answer, wildly different journeys. In code, the difference is a single line:
import time
p, q = 7919, 7907 # the creator's secret
N, phi = p * q, (p - 1) * (q - 1) # N is public; phi is not
def solve_slowly(x, T):
for _ in range(T):
x = x * x % N
return x
def solve_with_trapdoor(x, T):
return pow(x, pow(2, T, phi), N)
T = 300_000
t0 = time.perf_counter(); slow = solve_slowly(5, T); t1 = time.perf_counter()
fast = solve_with_trapdoor(5, T); t2 = time.perf_counter()
print(f"same answer: {slow == fast}")
print(f"slow: {1000*(t1-t0):.0f} ms trapdoor: {1000*(t2-t1):.3f} ms")It is worth pausing on why hiding the order is the same as hiding the factors. Since
, anyone who learns also learns , and two numbers whose sum and product you know are the roots of a quadratic. Three lines suffice:from math import isqrt
N, phi = 62615533, 62599708 # pretend we were only told these two numbers
s = N - phi + 1 # = p + q
d = isqrt(s * s - 4 * N) # = p - q
print("p, q =", (s + d) // 2, (s - d) // 2)If this setup looks familiar, it should. Rivest and Shamir are also the R and S of RSA, and RSA rests on the same hidden order.4 An RSA public key is a modulus
and an exponent . The private key is another exponent , chosen so that . To encrypt a message you raise it to the power . To decrypt you raise the result to the power . Because is a whole number of laps plus one, you land back on :Anyone can encrypt, because
and are public. Finding takes , and so, in effect, the factors. RSA uses the hidden order to undo an exponent; the time-lock uses it to skip one. Here is RSA on the same toy modulus (far too small to be safe, of course):N, phi = 7919 * 7907, 7918 * 7906
e = 65537 # the usual public exponent
d = pow(e, -1, phi) # the private key: impossible without phi
m = 42_424_242 # a message, as a number below N
c = pow(m, e, N) # anyone can do this
print("ciphertext:", c)
print("decrypted: ", pow(c, d, N))There is a tempting leap here: if we hide the order, surely the solver must perform every squaring.
That leap is an assumption.
Even “the order is hidden” needs care. Anyone who knows a multiple of an element’s order can reduce exponents just as well. And a careless starting value can sit in a tiny cycle of its own. My favourite example is
.Remainders wrap around, so
sits one step below , and itself counts as 0. In other words, behaves exactly like . And squared is 1. You can check it without any wrapping-around intuition at all:Once the chain reaches 1 it can never leave, because
. So the first squaring gives 1, and so does every squaring after it. Compare that with a healthy start, and then with a third value that looks perfectly innocent but hides a short cycle:The middle preset is the dramatic one, but the third is the more instructive. It never reaches 1. It simply has a small order, 37, so its chain repeats every 36 squarings, and a solver who notices the repeat can skip the walk entirely. That is the shortcut from the cycle explorer turned against the puzzle. A good starting value needs a large order, not just a large size.
The same check in code:
N = 62615533
x = N - 1 # this is -1 (mod N)
print(x * x % N) # squaring once already gives 1 ...
print(pow(x, 2 ** 1000, N)) # ... so every later answer is 1The order of
is two, so an eighty-trillion-step puzzle would be over after one. Security comes from choosing the instance well, not merely from leaving a blank where the order should have been written.When the order is public
Elliptic-curve cryptography makes an instructive contrast, because it usually publishes its group orders.
Points on a curve over a finite field form a group under a geometric kind of addition, with a special identity point
. A chosen point generates a subgroup of order , so . The hard problem is to take and and recover . This is the elliptic-curve discrete logarithm problem. Knowing tells an attacker the range to search. On its own, it doesn’t tell them where is.6But the order is far more than a range limit. Its shape matters.
Suppose
factors entirely into small primes. Then the Pohlig–Hellman algorithm can project the problem into each small piece, solve each piece separately, and stitch the answers back together with the Chinese remainder theorem.6 An impressive-looking total conceals a pile of easy problems. Type in a few orders and see how much the shape changes the cost:To make that concrete, here is a complete Pohlig–Hellman attack. It uses the multiplicative group modulo a prime rather than a curve, to keep the code short, but the idea is identical. The group has more than six trillion elements, far too many to search one by one. Yet the secret falls out in milliseconds, because its order is a product of small primes:
from math import prod
import random
def dlog_brute(g, h, n, p):
"""Find x in [0, n) with g**x ≡ h (mod p) by trying every candidate."""
acc = 1
for x in range(n):
if acc == h:
return x
acc = acc * g % p
raise ValueError("no solution")
def crt(residues, moduli):
"""Chinese remainder theorem for pairwise-coprime moduli."""
M = prod(moduli)
return sum(r * (M // m) * pow(M // m, -1, m) for r, m in zip(residues, moduli)) % M
def pohlig_hellman(g, h, p, factors):
"""Solve g**x ≡ h (mod p), where p - 1 = product of q**e over `factors`."""
n = p - 1
residues, moduli = [], []
for q, e in factors:
qe = q ** e
g_i = pow(g, n // qe, p) # generates the subgroup of order q**e
h_i = pow(h, n // qe, p) # h, projected into that subgroup
residues.append(dlog_brute(g_i, h_i, qe, p))
moduli.append(qe)
return crt(residues, moduli)
p = 6_278_415_343_201 # p - 1 is smooth:
factors = [(2, 5), (3, 3), (5, 2), (7, 1), (11, 1), (13, 1), (17, 1), (19, 1), (29, 1), (31, 1)]
g = 61 # a generator of the whole group
secret = random.randrange(p - 1)
h = pow(g, secret, p)
found = pohlig_hellman(g, h, p, factors)
print(f"secret = {secret}\nfound = {found}\nmatch: {found == secret}")
print("largest subproblem:", max(q ** e for q, e in factors), "candidates, out of", f"{p - 1:,}")This is why cryptographic systems work in a subgroup of large prime order: there is nothing to split. A large prime order, however, is not the end of the story.
Same group, different face
Here is the part I find genuinely fascinating. Every cyclic group of a given order is, abstractly, the same group. The integers modulo
under ordinary addition are one such group, and in that representation the “discrete logarithm” is just division:n = 1_000_003 # a prime, so every nonzero a generates
a, d = 271_828, 314_159 # generator and secret
h = d * a % n # the additive version of "h = g^d"
print("recovered:", h * pow(a, -1, n) % n) # one division: instantThe multiplicative group modulo a prime is cyclic too, yet there nobody knows a fast way to answer the same question. The two groups are isomorphic; the map between them is easy to compute in one direction and, as far as anyone knows, hard to reverse. An attack is often exactly that missing efficient map: a way of carrying a hard problem to a place where it becomes easy.

Elliptic curves have two famous bridges of this kind.
The first appears when a curve over the prime field
has exactly points:Such a curve is called anomalous. At first glance it looks ideal: a large prime-order group, with nothing for Pohlig–Hellman to split. But Smart’s attack lifts the curve into the
-adic numbers and applies a formal logarithm, which turns the hard relation into an additive one, the easy representation from the cell above:7Recovering
becomes a division. Nothing got smaller; the secret simply became readable in another representation. That is a deeper failure than “the key was too short”, because making larger doesn’t repair it.The second bridge is a pairing. If the subgroup has prime order
, its embedding degree is the smallest with . A suitable pairing carries the curve problem into the multiplicative group of the larger field , keeping the secret exponent intact:8When
is small, that field is small enough for specialised finite-field algorithms, and the MOV attack solves the transferred problem far faster than the original. This doesn’t make every such curve unusable. Pairing-based cryptography chooses small embedding degrees on purpose and sizes its parameters so that both sides resist attack.9 The bridge just has to be counted.For elliptic curves, then, we want to prevent an efficient passage into an easier problem. For time-lock puzzles, we want to withhold the period that lets someone skip the journey. Both come down to knowing which shortcuts the mathematics permits.
Proving you waited
There is still an awkward question about long computations: why should everyone else have to repeat yours to check it?
Suppose you return after hours of squaring and announce a result. If verifying it also takes hours, trusting you becomes expensive for everyone. A verifiable delay function, or VDF, fixes that: evaluating it takes sequential work, its output is unique, and it comes with a proof that anyone can check quickly. The modern definition was formalised by Boneh, Bonneau, Bünz and Fisch in 2018.10

One elegant construction, due to Wesolowski, needs nothing more than division with remainder.11 The prover claims
. A prime is chosen, either by the verifier or by hashing the statement, and we writeThe prover sends one extra value,
. The verifier computes , which is cheap because is small, and checksIt works because the exponents add up:
. The verifier does a few dozen multiplications and never walks the chain. Here it is as a machine. Try an honest prover first, then tamper with the answer, then let a prover who knows the trapdoor have a go:That last button is the one to sit with. And here is the whole protocol in Python, with the challenge derived from a hash so nobody gets to choose it. The prover computes
in the same pass as , doing the long division of by one bit at a time:import hashlib
p, q = 7919, 7907
N, phi = p * q, (p - 1) * (q - 1)
def is_prime(m):
return m > 1 and all(m % d for d in range(2, int(m ** 0.5) + 1))
def challenge(x, T, y):
"""A 24-bit prime derived from the statement: no one can choose it."""
seed = int.from_bytes(hashlib.sha256(f"{x}|{T}|{y}".encode()).digest()[:3], "big") | 1 << 23
while not is_prime(seed):
seed += 1
return seed
def prove(x, T):
y = x
for _ in range(T): # the delay: T sequential squarings
y = y * y % N
l = challenge(x, T, y)
pi, r = 1, 1
for _ in range(T): # pi = x ** (2**T // l), via long division
b, r = divmod(2 * r, l)
pi = pi * pi * pow(x, b, N) % N
return y, pi
def verify(x, T, y, pi):
l = challenge(x, T, y)
s = pow(2, T, l)
return pow(pi, l, N) * pow(x, s, N) % N == y
y, pi = prove(3, 100_000)
print("honest proof accepted: ", verify(3, 100_000, y, pi))
print("tampered answer accepted:", verify(3, 100_000, (y + 1) % N, pi))So what, exactly, has the verifier checked?
The proof establishes that the answer is right. The conclusion that obtaining it required a delay rests on something else entirely: the sequentiality assumption, the setup, and what the prover happened to know. Someone holding
can produce the same answer, and a perfectly valid proof, almost instantly.5 If you’d like to see that for yourself, try writing acheat(x, T) that makes verify return True for a trillion squarings without doing them. My version is below, if you want to compare.
One way to cheat
Reduce every exponent modulo
. Since and shares no factor with , we have .def cheat(x, T):
y = pow(x, pow(2, T, phi), N)
l = challenge(x, T, y)
s = pow(2, T, l)
q_mod = (pow(2, T, phi) - s) * pow(l, -1, phi) % phi
return y, pow(x, q_mod, N)
y, pi = cheat(3, 10 ** 12) # a trillion squarings, skipped
print(verify(3, 10 ** 12, y, pi)) # TrueA verifier has checked a mathematical relationship. It has not watched a processor execute each instruction. (Pietrzak’s alternative VDF reaches the same asymmetry with different machinery, recursively halving the claim.12)
Who could know the shortcut?
That makes setup part of the story. For a puzzle creator, knowing the factors is useful: it makes preparation quick. For a public VDF meant to delay everyone, anyone who kept those factors defeats the purpose. You need a setup that convincingly forgets them.5
Imaginary quadratic class groups offer another route: suitable public parameters define a group whose order nobody learns along the way.13 The arithmetic is heavier, but nobody has to generate a secret and then promise to forget it. That doesn’t make the system assumption-free. Order-finding algorithms, parameter sizes and low-order elements still matter, and recent work has revised security estimates on exactly those grounds.14
The input needs the same care. If a result is supposed to show work that started recently, the challenge must prevent useful advance computation; a fixed public input lets someone begin long before you start watching.
And even with all of that handled, the clock sits outside the equation. Sequential work defeats one strategy: spreading dependent steps across an army of machines. It does not stop a faster machine, better arithmetic or custom hardware, and the puzzle makes no progress while nobody computes it. The original time-lock paper said as much in 1996.3 Chia’s timelords, which evaluate VDFs in production, treat hardware speed as a live concern.15 The MIT capsule is the cleanest illustration of all: one task, two implementations, and two very different calendars.
There are other ways to send a message into the future. drand’s timelock encryption ties decryption to a future round of a threshold randomness beacon, trading computational work for trust in a distributed network.16 Same promise (“you can read this later”), different foundation. That is the habit worth keeping: whenever a system offers a guarantee, ask what mathematical statement sits underneath it, what assumptions connect that statement to the promise, and who might know something that changes the calculation.
Thank you for reading the first one. There is more to come.
Footnotes
-
MIT CSAIL, Time-Lock Crypto Puzzle, and Time Capsule of Innovations. ↩
-
Ronald L. Rivest, LCS35 Time-Lock Crypto Puzzle, retrospective presentation, 15 May 2019. ↩
-
Ronald L. Rivest, Adi Shamir and David A. Wagner, Time-lock Puzzles and Timed-release Crypto, 1996. ↩ ↩2
-
Ronald L. Rivest, Adi Shamir and Leonard Adleman, A Method for Obtaining Digital Signatures and Public-Key Cryptosystems, Communications of the ACM 21(2), 1978. ↩
-
Dan Boneh, Benedikt Bünz and Ben Fisch, A Survey of Two Verifiable Delay Functions, 2018. ↩ ↩2 ↩3
-
David McGrew, Kevin Igoe and Margaret Salter, RFC 6090: Fundamental Elliptic Curve Cryptography Algorithms, 2011. ↩ ↩2
-
Nigel P. Smart, The Discrete Logarithm Problem on Elliptic Curves of Trace One, 1997; Journal of Cryptology, 1999. The relation shown is schematic. ↩
-
Travis Scholl, Isolated Elliptic Curves and the MOV Attack, §2.4. ↩
-
David Jao, Elliptic Curves in Cryptography, course notes. ↩
-
Dan Boneh, Joseph Bonneau, Benedikt Bünz and Ben Fisch, Verifiable Delay Functions, CRYPTO 2018. ↩
-
Benjamin Wesolowski, Efficient Verifiable Delay Functions, Journal of Cryptology, 2020. ↩
-
Krzysztof Pietrzak, Simple Verifiable Delay Functions, ITCS 2019. ↩
-
Aron van Baarsen, Imaginary Quadratic Class Groups and a Survey of Time-Lock Cryptographic Applications, 2022. ↩
-
Samuel Dobson, Steven Galbraith and Benjamin Smith, Trustless Unknown-Order Groups, 2022. ↩
-
drand, Timelock Encryption. ↩
Responses
No responses yet. You could be the first.
Comments couldn’t be loaded right now.