Lotto Cup Draw

Draw method version 1 (view the source)

Lotto numbers The six main numbers, in any order. Not the bonus ball.
How can I trust this draw?

Why nobody can fix the draw

The Cup Secretary announces the teams, their ball numbers, the draw name and which Lotto draw will decide it before that Lotto draw is made. At that point nobody knows the numbers, the Cup Secretary included.

The same entries always give the same draw. Once the numbers are out, nobody can try again for a better one, and anyone can check the result.

Checking a draw with this page

Enter the details from the announcement and press Make the draw. A link in the announcement fills in everything except the Lotto numbers. You should get the published draw.

The fingerprint under the result checks your entries against the published draw. If only the first four characters match, the name is right and something else differs.

Checking a draw without this page

You don't have to trust this page. Any SHA-256 tool can check the draw, for example CyberChef, a free tool from GCHQ.

  1. Write out the seed: the draw name in lower case, the six Lotto numbers smallest first with spaces between, the number of teams and the number of byes. Separate the parts with a space, a vertical bar | and a space, for example sample draw | 3 11 24 38 45 57 | 8 | 0.
  2. Each ball's text is the seed followed by # and the ball number, for example sample draw | 3 11 24 38 45 57 | 8 | 0#1. Put each one into the SHA-256 tool exactly as written and note the code. In CyberChef, type it into Input and the code appears under Output.
  3. Sort the balls by their codes, smallest first, as in a dictionary with 0–9 before a–f. That order is the draw.

You don't need to do every ball. Show the working, under the result, lists each ball's text and code. Click a ball's text to open it in CyberChef, which works out the code itself, and compare the two. Check two or three balls.

Is the draw fair to every team?

A fair draw gives every ball the same chance of a bye and of choice of venue. The test makes 10,000 draws with the name, teams and byes above, each from random Lotto numbers, and counts how often each ball gets each. It uses the same method as the real draw.

How it works

What SHA-256 is

SHA-256 is a standard way of turning any piece of text into a 64-character code.

  • The same text always gives the same code, on any computer.
  • Change a single letter and the code comes out completely different, with no pattern to it.
  • Nobody can work backwards from a code, or find text that gives a code they want.

It secures websites and online banking, and every modern browser has it built in.

How the draw uses it

Everything that decides the draw goes into one line of text, the seed: the draw name, the Lotto numbers, the number of teams and the number of byes. Each ball's code is the SHA-256 of the seed with that ball's number on the end. The balls line up by code, smallest first, like tickets with random numbers on them. That line is the draw.

Any byes go to the first balls in the line. The rest pair off: first against second, third against fourth, and so on.

Why the Lotto?

Any result would do that is published at a set time, that nobody can know or influence beforehand, and that anyone can look up afterwards. The Lotto is convenient: everyone trusts it, it's drawn twice a week, and six numbers are hard to copy wrongly. A newspaper headline would also work, but a stray comma or a different edition would change the draw.

The method in detail

This is the complete method, precise enough to write your own version.

  1. The entries are:
    • a draw name made only of printable ASCII characters (codes 0x20 to 0x7E: letters, digits, spaces and standard punctuation), with at least one that isn't a space
    • six different whole numbers, each from 1 to 59
    • a number of teams N, where 2 ≤ N ≤ 128
    • a number of byes B, where 0 ≤ B ≤ N − 2 and N − B is even
    The balls are numbered 1 to N.
  2. The name is tidied by removing spaces from the start and end, replacing each run of spaces with a single space, and changing A–Z into a–z. Nothing else changes.
  3. The seed is four parts joined by the separator " | " (a space, a vertical bar and a space): the tidied name; the six numbers from smallest to largest with a single space between each; N; and B. All numbers are written in ordinary decimal with no leading zeros. For example, sample draw | 3 11 24 38 45 57 | 8 | 0.
  4. The text for ball i is the seed followed straight away by # and i, for example sample draw | 3 11 24 38 45 57 | 8 | 0#1. Its code is the SHA-256 of that text's UTF-8 bytes (the same as its ASCII bytes), written as 64 lower-case hex characters, 0–9 and a–f.
  5. The balls are sorted by their codes, smallest first. Every code is the same length, so alphabetical order gives the same result. Two identical codes are, in practice, impossible: less likely than one person winning the Lotto jackpot nine weeks running. If it happened, the lower ball would go first.
  6. The first B balls in that order get byes. The other N − B pair off in order, first against second, third against fourth and so on.
  7. The fingerprint is 12 upper-case hex characters: the first 4 of the SHA-256 of the tidied name, followed by the first 8 of the SHA-256 of the seed.

The whole method is in one short file, cup-draw.js.