What is a hash and how does it work?


A hash is like making a Chicken McNugget out of a chicken. So, the credential is the chicken and the hash is the Chicken McNugget. You can always take the chicken and make an identical Chicken McNugget out of it, but you will never be able to take a Chicken McNugget and make a chicken out of it! So it stores much less information than the chicken, but is still a Chicken McNugget that was made from a chicken.

Take your bank account number – the IBAN in Europe, for example. It starts with DE in Germany and it’s followed by two numbers – let’s say 68. These first two numbers are a hash. After that you have a big long number.

So, if you change a single digit in the long number, the hash changes dramatically. It could change from 68 to 54 for example. And this is how the IBANs are made safe as you often make a mistake when you type in an IBAN. And every computer can check very easily if the long number – if it was hashed – gets the small number. The hash is the small number so it has much less information. If you take the long number, it will always produce the same hash. If you change it a little bit it will produce a completely different hash. 

But everyone can see if you just have the hash, the 68, that you can’t make the long number from that because it has much less information. What we store on the blockchain is just the short number. And if you send in your credential, we can always produce the same number again out of that and we can check if it is there. A mathematician would say it’s a one-way function, so it goes only in one direction, in the direction of a chicken to a Chicken McNugget. If you take the long number you will always get the same small number. If you take a different long number you will get another small number. If you only have the small number you have no chance of creating the long number with it. So if only the hash is put on the chain it’s impossible to reproduce your credential from it. It’s the number that represents your credential but has much less information in it.