Back to the blog
Technology7 min read

Verifiable lotteries: why HMAC-SHA256 beats drawing names from a hat

How a cryptographically verifiable lottery works, how it differs from a manual draw and why it is the safest way to fix the order of choice in a partition.

by Equipo Lex Partis

The order in which each party picks its assets determines which assets they will end up with. Fixing that order in a demonstrably neutral way is therefore critical. A manual draw — pulling a piece of paper from a bag — works, but its evidentiary value depends entirely on who was present and how the moment was documented. A cryptographically verifiable lottery solves the problem by turning neutrality into something that can be checked mathematically after the fact.

The problem with a manual draw

A manual draw before a notary or court clerk is legally valid, but it leaves a poor trail. If months later one party claims the draw was unfair, the only defence is testimonial: those present must remember and declare what happened. Memory is fragile and witnesses are not always available. A verifiable lottery, by contrast, leaves a mathematical trail that any third party can recheck years later.

What HMAC-SHA256 is

HMAC-SHA256 is a cryptographic function that combines a seed (a random number) with a message (the input data of the lottery) and produces a deterministic 256-bit hash. Two key properties: given the same seed and message, the result is always the same (reproducible); and it is computationally impossible to predict the result without knowing the seed, or to alter it without that being noticed.

How a verifiable lottery is articulated

  1. Before the lottery, the set of parties (with their identifier) and the date-time of the draw are fixed. That data forms the message.
  2. A random 256-bit seed is generated and its hash (commitment) is published to all parties.
  3. At the moment of the draw, the original seed is published. Any party can verify it matches the previous commitment.
  4. HMAC-SHA256(seed, message) is computed. The result is a 256-bit hash.
  5. That hash is used as the deterministic input of a shuffling algorithm (Fisher-Yates, for example) producing the definitive order of the parties.
  6. Everything is published: seed, message, hash and resulting order. Any third party can recompute and verify.

Reproducibility: the real evidentiary value

The key difference is this: if two years later a party challenges the lottery, it is enough to take the same published data (seed, message), apply the same algorithm and check whether the result matches. If it does, the lottery is indisputable. If not, manipulation is demonstrable. There is no need to call witnesses or reconstruct the moment: verification is mathematical.

Real-world applicability

This technique is standard in applications where verifiability is critical: lotteries, academic allocations, administrative draws. Carrying it over to the partition setting is natural and, in our view, should become standard practice when the procedure is managed digitally. The additional effort to implement it well is minimal; the evidentiary robustness it adds is enormous.

Want to apply this on your next case?

Lex Partis structures inventory, preferences, draw and adjudication with the traceability that legal professionals expect.