How Do We Flip A Billion Coins in a Fair Way and Writing Your Name in Crypto?

Prof Bill Buchanan OBE FRSE
Coinmonks
Published in
4 min readAug 1, 2018

--

So let’s say we have one billion people who are in a competition. We have a single toss of the coin, and if you match it, you continue. If not it does not match, then you are out of the competition. How many tosses will it take to get a winner (on average)?

It think it would only take … 30 rounds (I asked someone early and they said one trillion!).

So from one billion people, we would have 30 tosses of the coin, and we would (on average) have a winner. Do you agree with me?

Fast random numbers

So how are we going to build a computer that is going to create one billion random numbers quickly. Well, in 2016, Xoroshiro128+ came along, and has sub-nano-second times for each random number generated. We could thus generate one billion random numbers in less than a second. But how do we just to a bit flip? Well we just mask of the least significant bit.

So let’s take two seed values, and generate the first 10 random values and the first 50 tosses:

import sysval1=54253124354024L
val2=5395042653908L
def bin2chr(data):
result = ''

while data:
char = data & 0xff
result += chr(char)
data >>= 8

return result

--

--

Prof Bill Buchanan OBE FRSE
Coinmonks

Professor of Cryptography. Serial innovator. Believer in fairness, justice & freedom. Based in Edinburgh. Old World Breaker. New World Creator. Building trust.