Basically, you take the input which is a block of transactions and create a digest of it (called a hash), which looks like a random number but isn’t. The important part of that digest is that you can’t change anything in that block without invalidating it entirely. The other important part is that the operation takes ***time*** and ***computational energy***, meaning it ***costs*** a tiny bit to do the math. Scale that up to making trillions of calculations to tweak the block enough to find a digest that is really really small, then it’s a valid hash. It’s hard to find that really small solution, but it’s really easy to verify (do the math a trillion times to find it, do the math once to check it).
So in practice, you’re rolling a random number and hoping to get a one in a trillion roll.
You own a magic box and people give you photocopies of their signed cheques. You take a bunch of signed cheques, and put them in the magic box. You also include a cheque that creates money to your account just in case you win.
The magic box has a keyboard. Every time you guess a number in the keyboard, the magic box spits out a random number. If the random number meets some criteria, you can tell the other magic box owners that you found a solution. The criteria is that it must be a very very small number, so you need to guess many times before you are able to get a solution that meets the criteria.
There are other magic box owners are out there receiving the same photocopies of cheques. If one magic box owner finds a solution, they tell everyone the number that they guessed. It is easy for other magic box owners to verify that the solution because it takes a second to type it in. Everyone acknowledges the signed cheques inside the box is now legit.
Everyone now works on a the next magic box. This time, the magic box will contain a copy of the previous magic box along with any newly signed cheques that haven’t been included. This keeps on going until you have a magic box inside a magic box inside a magic box etc.
In the real world everything is digital so it’s easy to have a chain where you remove a single signed cheque to undo a payment. But since the boxes are inside each other, if you change anything inside any box, it would affect the random output of the box, making it no longer satisfy the condition and become invalid.
To see how much money you have, simply ask around for the chain of boxes. Some people will give you the wrong chain, but it likely won’t be very long since they need to spend a lot of energy to guess a bunch of numbers to make a valid chain. It takes you far less time to verify than it takes for them to guess. Eventually you will find a chain that is very very long, which is likely the chain everyone agrees on because a lot of energy was used to create it.
To see how much money u have, simply add up the cheques sent to you minus the cheques you sent out.
The math problem is basically a twist on “Im thinking of a number between one and a billion” first person to guess it wins.
you need to know a few things:
1. there’s something called “hashing” that takes in inputs and outputs a seemingly random output (see this tool [https://emn178.github.io/online-tools/sha256.html](https://emn178.github.io/online-tools/sha256.html))
2. hashing will give the same output every time if the inputs are exactly the same (inputting “reddit” into SHA256 will always give “2e183f2a7a70de1c10044f4e370a221a792736cb074835afcde6a9df457d413b” as output)
3. changing even a single bit of the input will give an unpredictable, and completely different answer (inputting “Reddit” (capital R) gives “eb0050f72303bcdbbdc071e2a3bf810c903be8d05cdf09f7c3106f2b6f9878bf” which has nothing to do with the hash from “reddit” above)
4. These ‘outputs’ are usually formatted in hexadecimal (using characters 0123456789abcdef), but can be in binary or in decimal form and just represents a number (the output of ‘reddit’ being hashed from step2 in decimal form is “20849231319617073542494766561462311394317076535891665807670320877453132513595” and will be smaller than the max number representable in 256 bits)
5. the bitcoin network sets some threshold that the answer will be lower than (“im thinking of a number that added after the word “reddit”, its hashed value is a number lower than 10000000000000000000000000000000000000000000000000000000000000000000000000000″).
6. The first miner to find one wins, so you either get really lucky or are able to try hashing a bunch of times really fast.
“reddit1” hashes to “80992191607849107266945937912545788070534224368496577081050248192831763894397”
“reddit2” hashes to “91388177237288728016826958650204545595078502430216916238498236656504089532824”
“reddit3′ hashes to “5889602377724921096772519443223865920769791603544214551718898286268048025550” WINNER! (doesnt look like it cuz we dont write leading 0’s before decimals, but it’s actually 058896…etc)
“reddit4” hashes to “35390741966812078950407895123414739401095538395380331101523408047775363744221”
“reddit5” hashes to “115699904307572733452589137606698425027623415455401192282092685292621194302023” (almost! but try again cuz it’s not good enough)
“reddit6” hashes to “7026529653835210427635203474129647138418149896339361660188653916361750185586” WINNER!
“reddit7” hashes to “59415021918001391266558038051229429712161014466127143009275001879126847080756”
Because of these properties, you’re basically just guessing one input at a time and hashing it to find a valid output.
More reading: [https://en.wikipedia.org/wiki/Hashcash](https://en.wikipedia.org/wiki/Hashcash)
The maximum value of an unsigned 256-bit integer is 2 raised to the power 256 − 1, written in decimal as 115,792,089,237,316,195,423,570,985,008,687,907,853,269,984,665,640,564,039,457,584,007,913,129,639,935 or approximately as 1.1579 x 10 to the power 77.
I wrote a quick python program to find this, cuz why not.
import hashlib
given_constant = ‘reddit’
count = 0
minVal = 10000000000000000000000000000000000000000000000000000000000000000000000000000
while (count < 100):
count = count+1
string_to_hash = given_constant+str(count)
result = hashlib.sha256(string_to_hash.encode(‘utf-8’)).hexdigest()
if int(result,16) < minVal:
print( count, int(result, 16))
TLDR: I’m looking for a number that when you hash it with these other constants, you get a resulting hash output smaller than some target value. first to guess it wins.
Latest Answers