
Dreaming BiBa
I am a great believer in the power of sleep, and how we can use it to solve technical problems. So, I had a dream a while ago, and I was at a fairground. As you may remember from our youth, a popular amusement is throwing balls into cans. In my dream,you win a prize if you could get two balls in the same can. My dream came from me thinking about BiBa — Bins and Balls — and which is a post-quantum crypto method for signing messages. When I woke up, and I had the answer on how BiBa relates to signing messages.
At the fairground
Let’s say you are at the fairground, and where there are five bins, and you randomly throw balls into the bins and win get two balls in the bin after three throws. Of course, the probability of the first throw will be:
P_0 = 0
on the second we now have a one-in-5 chance of getting it in the bin we hit the first time, so the chances of us not winning will be:
P_1 (Not win on second throw) = 4/5
Now, on the third throw, if we have not won, we will have two bins with balls out of 5 bins. So the bins could be:
1 1 0 0 0 1 0 1 0 0 1 0 0 1 0 1 0 0 0 1 0 1 1 0 0 0 1 0 1 0 0 1 0 0 1 0 1 0 1 0 0 1 0 0 1 You have three spaces that we could hit in each of the bins. You thus have two chances to hit a bin with a ball, and three chances to miss. The chance of you not winning is 3/5. The probability you will not win at this point is thus:
P(Not win on third throw) = 4/5 x 3/5 = 12/25 = 0.48
You now have a 52% of getting at least two balls in a bin on the third throw. Within hashing methods, this is known as a collision, and where we could group our hashes into a number of bins.
My dream
So let me explain my dream. It is all based on this classic paper [here]:

Basically the method involves us taking a hash of a value using a standard hashing method, such as with SHA-256. There will then be 2²⁵⁶ different hashing values. We aim to create a signature for a message, so Bob (the signer) selects a number of random values for his private key value and then publishes the hash of each of these (P_1, P_2, etc). He then sends these public keys to Alice. Now when Bob wants to sign a message, he will take one of his private key values, and then hashes it, and then determines the bin that it should be placed. In this case, we could use the (mod N) function on the hash, and where N is the number of bins. If we select 2¹⁰ there will be 1,024 bins. In this way there will be multiple mappings of the hash values to each of the bins:

Now when Bob takes a message, he takes the message and then adds a counter value (Ctr) on:
Message || Ctr
For each of these, he hashes and then maps to the bin. If he matches the bin for his private key value, he has found a match, otherwise, he will increment Ctr and try again. For Bob, it should not take too many tries before he finds one. When he does, he publishes the messages, and his private key value, along with the Ctr value. When Alice receives she checks that the private key value is mapped to one of this public keys, and then that the Ctr value maps to the same bin. If it does, the signature was produced by Bob.
Here is some code and where I have used 2¹⁰ bins, and the SHA-256 hash:
