How Does The Bitcoin Network Work?

Marcus Gustafsson
A free video tutorial from Marcus Gustafsson
Computer Technology Fanatic & Cryptocurrency Investor
4.4 instructor rating • 1 course • 6,524 students

Learn more from the full course

Full Cryptocurrency Course: Bitcoin, Ethereum & Blockchain

Learn All About Bitcoin, Ethereum & The Blockchain Technology That Makes Cryptocurrency Work! Let's Start Investing!

02:01:29 of on-demand video • Updated December 2017

  • How to Buy, Sell, Send, Receive, Exchange & Store cryptocurrencies
  • What Blockchain is & how it works on the inside
  • What Bitcoin & Ethereum is and what they are used for
  • What cryptocurrency & cryptography is
  • Protecting your cryptocurrency investment
  • The history of bitcoin & cryptocurrencies
English [Auto] In this video we're going to take a look at how the miners use that shot 2:56 algorithm to secure the network. Let's show this with an example of a transaction. Here we have Alice Bob and me here is a minor and he's copy off the block chain. Let's say Alice has 20 bitcoins. Bob has 50 and I have 10. If Bob wants to send me 20 Bitcoins he will first broadcast a message out to the miners saying that he wants to do that for the miners to consider Bob's transaction valid. They must first make sure that Bob has 20 bitcoins or more in his account to do this. They check the block chain for all previous transactions to see if Bob at some point has received this amount of bitcoins and that he hasn't already spent them. Then the miners also must make sure that it's really Bob who wants to send these bitcoins and not someone else. The only way for Bob to prove to the miners that it's really him is with the private key. But remember what I said earlier about that you should never show your private key to anyone. This includes the miners. So how can Bob prove that it's really him. The answer is with a digital signature a digital signature might sound insecure and someone could just copy the signature right. Well no they can't. That's because unlike a handwritten signature for a check this digital signature is always different for every transaction. The signature depends on what the message says the message being what transaction you want to make and the private key. The miners then use this signature along with the message and your public key to make sure that the signature is correct. Once the miners are sure that Bob does in fact have those 20 bitcoins and that it's really him who wants to send them the miners and Bob's transactions to their meme pool which is short for memory pool this is where all the transactions lie and wait to be added to a block. Once Bob's transaction has moved up a bit in the queue of transactions the miner will put Bob's transaction along with a lot of other ones in a block. The miner then has to mine the block or confirm the block. This is done with a shot 256 algorithm. The miners takes all the transactions in the block and adds a number to it's called a nouns. The miner then takes the whole block including the nouns and puts it through the shot 256 algorithm. The hashed that is produced has to start with a certain amount of Ciro's in order to be considered valid. The amount of zeros needed depends on what's called the difficulty. The more zeroes needed the harder it is to find a valid hash. Remember that I said even the slightest change to the input completely changes the output and that the only way to figure out the inputs is to guess that's exactly what the miners are doing here. They are guessing for possible noun's numbers that could produce a hash that starts with a certain amount of zeros when combined with the transactions of that block. But here there is not just one right answer. Since the rules for the hash is just that it has to start with a certain amount of zeros. We're not looking for one specific hash. So it will not take years to find it. Instead it takes on average 10 minutes to find the nouns number that works. And that's the job of the difficulty adjustment to adjust the amount of zeroes needed in the beginning of the hash in order to be considered valid. The difficulty adjusts every 2056 blocks which is about every two weeks. The goal of the difficult adjustment is to adjust the difficulty so that every block takes 10 minutes to mine. Now why is this difficult adjustment needed. It's needed since the amount of minors and their computer power changes. If a lot of minors stopped mining it would take a long time for the miners that are left to find the hash that works. And that would slow down transaction times. The difficulty also just in order to make it harder if more people start mining. Why does it do that as well. Have you ever up until this point wondered why people choose to mine it's because they get rewarded for finding the Hirsch's for these blocks. As of right now the block reward is twelve point five Bitcoins which is a lot of money. The block award is cut in half every 210000 blocks which is about every four years if every block takes 10 minutes to mine. These Bitcoins are created by the system every time a block is mine. This is how Bitcoins come into existence. The max supply of bitcoins that will ever exist is 21 million and it has been calculated that all Bitcoins will be in existence around the year 2014. The miners can choose to mine alone and get the whole twelve point five Bitcoins if they find the hash works or they can mine in what's called a pool which just means that a group of miners mine together and share the profits depending on who has the most computing power in bitcoins. Early days people mined with their PCs. Nowadays there is special hardware design from mining Bitcoin called a sink which is short for application specific integrated circuits and it's much faster. Something to note is that different crypto currencies use different mining algorithms than shot 2:56. So the hardware used is also different. And some crypto currencies don't even have mining. You can also be a part of securing the network without needing a bunch of expensive basic minders. You could mine with your PC either in a pool or on your own with what's called a full node which is a program that validates transactions and blocks. You can do this by downloading Bitcoin core. Keep in mind that it contains the whole block chain which takes up a lot of memory and that it is not very profitable to mine it with the PC anymore. If you would like to become a full node sometime in the future I will leave the links to where you can read more about how it's done as well as the download link in this video material. Now the reason we need that difficulty to increase is because if it didn't just a few minor it could get a hold of a very big portion of the total bitcoins in existence. And if just a few people had bitcoin it would not be worth anything. It needs to be widespread. Another reason for why we need the difficult to increase is that there is a fee that you have to pay to the minor when making that transaction. If all the Bitcoins were to have been distributed to quickly and all that to a small group of people when all the Bitcoins have been created the only money left to gain from mining is the fees. And since old Bitcoins have been distributed too quickly there would not be enough users so that the miners would earn enough fees to keep on mining. One final thing we should discuss before moving forward is what's stopping a miner from changing transactions in a block on his copy of the block chain in his favor. Well the idea is that everyone trusts whichever copy of the block chain that has the most computational work put into it the longest block chain. Remember that I said that the miners are looking for a noun's number that together with the transactions output a hash that starts with a certain amount of zeros when put into the shot 256 algorithm. Well the block has to contain one more thing. The hash of the previous block. The reason for this is that if a minor would change the transaction in the block it would not only change to hash out put that block completely. It would also change all the blocks that come after it's making them all invalid. Since even the slight change to the input completely changes the output so now that the minor estranges the transaction in his favor he would need to redo all of the work in that block and the once off to do it in order to make them valid. And since everyone trusts the longest chain no one would trust his copy of the block chain unless he was able to make it the longest one which would require that he had more than 50 percent of the whole network's computer power which is very unlikely. This is what's called a 51 percent attack. Well what if the attacker decided to only change the transaction in the current block so that he only needed to find the valid hash for that block. Wouldn't that be much easier for him. Yes. And this is the reason why most exchange Web sites require six confirmations before Bitcoins are sent or received. What I mean by six confirmations is that not only does the block that your transaction is in need to be confirmed but also five blocks after that. This helps because in order to make an exchange except that's fraudulent. BLOCK The miner needs to yet again outpace the rest of the network's computing power for five more blocks in order to make his change. The longest one and make the exchanges see it as valid this whole model of making computers work in order to confirm transactions is called p o w short for proof of work. There are also other models used by other currencies like POS. Proof of stake. The point of trying to make new models is so that we don't need tons of energy to keep the system running like we do now with bitcoin. I don't want to confuse you. This early on but I feel obligated to mention one more thing that might seem strange Nowadays people are working on what's called a lightning network and they recently made it work. It's a way to transact and save cheaper and faster way. But their transactions are not recorded on the block chain right away. We will not be talking about this anymore since this is still pretty experimental and not something that's close to being mainstream yet. If you want to know more just google for more information on the lightning network. Please do not get scared if you think this is complicated. You do not need to know exactly how everything works in the background in order to use bitcoin or other crypto currencies. Now that we know how the bitcoin network works and how it is kept secure we can move on to talk about what Bitcoin really is and what purpose it has.