pBitcoin Mining in 4 Minutes Computerphile Seanampgt How do Bitcoin miners mine? Mikeampgt Theres no actual digging involved.
Think back to our article on hashing so a hash function takes a message of any length and returns a fixed length hash which hopefully looks quite random right so if you change even a little bit of your message the whole hash changes, so this is how Bitcoin mining works right in brief. So we have a block and at the top of the block is the hash of the previous block and a number right which were going to call our nonce this is a number were making up lets start at 1 and go up and then here weve got all the transactions so transactions one of which will give me some bitcoins because Im the miner. The way this works is I start with a random number here and then I hash this entire thing and I get a hash out the bottom here.
To mine successfully this hash needs to be very very small so lets say for example it has ten leading zeros as an example if I successfully pick a number where when I hash this entire thing including the number it has ten leading zeros Ive successfully mined that Bitcoin. Now thats quite unlikely youve got to think that each zero ampamp one has a roughly 50 chance of being a one so to get one leading zero its going to be about 50 of the time two leading zeros about 25 of the time and so on the more leading zeros we require the harder this process is. So it doesnt happen yeah the first time I pick a one I hash it and it doesnt work so what I do is I go to 2 and I hash it again and I get a totally different hash which maybe has a different number of leading zeroes and I go does this does this work? no, ok so 3, 4 5, 6, 7, 8, 9, 10 and so on and I just keep churning away with these random numbers in this nonce field here incorporating any transactions Ive received in the meantime until I get this kind of golden hash that Ive been looking for which is very very small so lets say 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 some numbers say 1 0 1 1 and something like that right now this is sha256 in the case of Bitcoin so its 256 bits long now as soon as Ive done that I go well brilliant Ive got some bitcoins i transmit this to the network and everyone sees this and goes cool and then they take this hash and they put it in the next block and start mining on that one as well with new random numbers so every time someone stumbles across a hash which is small enough thats when theyve mined the Bitcoin right and so thats how the difficulty of a network is changed you just change the threshold of number of zeros or size of your hash that you need to be below in order to be successful every couple of thousand blocks the network will look at how long it took and if like a bunch more miners have appeared so its actually starting to get a little bit too easy theyll theyll increase this difficulty such that hopefully a Bitcoin is mined roughly every ten minutes now of course this process is random so it might be less, might be more but on average. If a bunch of miners disappeared suddenly its taking 50 minutes to mine a Bitcoin Block? theyll just reduce this threshold so that you can mine that little bit more easily.
The number of bitcoins that a miner is awarded is halved every so often as well so I think is it at 12.5 at the moment so I will have sort of plus 12.5 for Mike in here as sort of my benefit of being the miner so this will only ever get actually put into the blockchain if Im the one that finds this hash otherwise unfortunately itll be someone elses name in here Seanampgt weve sat here and watched Beast churn through billions of password hashes How hard can it be to come up with this number? Mikeampgt As hard as they need it to be youve got to think that for all the miners on earth at least a lot of them have got dedicated hardware many trillions of hashes and theyre still only doing it every 10 minutes right its not easy to do and they can just keep making this more difficult until it takes about ten minutes. In some ways you cant make the problem more easy by buying more and more hardware because it will just make itself more difficult for you.
For now most of my contact with it is via a terminal and I ask it to do things it does them very, very fast. This particular server has four Titan X graphics cards in it a Titan X is one of the foremost graphics cards there are new.p