How Does Blockchain Work|Explained for Beginners
how does blockchain work a central part in every blockchain is the mining algorithm let's take bitcoins algorithm as an example it's called sha 256 short for secure hash algorithm 256 bits it takes an input which can be anything texts numbers or even a computer file of any length the output produced is called a hash and will be the same length every time 256 bits in machine code the same input will give the same output every time it's not random but if you make a small change to the input the
output will change completely it's also what's called a one-way function meaning that if you only have the output you can't calculate what the input was you can only guess what the input was and the odds of guessing that right is one in two to the power of 256 which is pretty much impossible in other words it's secure now that we know what the algorithm does let's demonstrate how a blockchain works with a simple example of a transaction here we have Alice involved along with their Bitcoin balance let's say Alice owes Bob two
Bitcoin for Alice to send Bob those two Bitcoin Alice broadcasts a message with the transaction that she wants to make to all the miners in the network in that broadcast alice gives the miners Bob's public address the amount of bitcoins you'd like to send along with a digital signature and her public key the signature is made with Alice's private key and the miners can then validate that Alice in fact is the owner of this Bitcoin and that she wants to make the transaction once the miners are sure that the transaction is valid they can
put it in a block along with many other transactions and attempt to mine the block this is done by putting the block through the sha-256 algorithm the output needs to start with a certain amount of zeros in order to be considered valid the amount of zeros needed depends on what's called the difficulty which changes depending on how much computing power there is on the network in order to produce an output hash with the desired amount of zeros in the beginning the miner adds what's called a nouns number into the block before running it
through the algorithm since a small change to the input completely changes the output the miner tries random nonces until they find a valid output hash once the block is mined that minor can broadcast that newly mined block to all the other miners they then check to make sure that the block is valid so that they can add it to their copy of the blockchain and the transaction is complete but in the block the miners also needs to include the output hash from the previous block so that all blocks are tied together hence
the name blockchain this is an important part because of the way Trust works in the system every miner has their own copy of the blockchain on their computer and everyone trusts whichever blockchain has the most computational work put into it the longest blockchain if a minor changes a transaction in a previous block the output hash for that block will change which leads to all the other hashes after it changing as well due to the blocks being linked with hashes the miner would then have to redo all of the work in order to make anyone accept his
blockchain as the right one so if a miner wanted to cheat he would need more than 50% of the network's computing power which is very unlikely the model of making computers who work in order to produce blocks is called proof of work there are also other models like proof of stake which does not require as much computing power and is meant to require less electricity while being able to scale to more users and that's the basics of how a blockchain works
No comments