Proof of Work
The Bitcoin blockchain is secure from hackers because of a mechanism referred to as Proof-of-Work.
Unlike a traditional database that is housed in a central location with someone ensuring its security, the Bitcoin blockchain is distributed around the world in over 15,000 locations.
As a distributed ledger, it is self-governing.
Each location is a node. A node is essentially a large bank of computers. They validate the blockchain and compete to acquire bitcoin. The operation is referred to as bitcoin mining.
The data in the existing blockchain and the new data that is added to it (in a block) is validated by everyone in the network.
Here's how proof of work ensures consensus. (This is a bit complicated, but if I could grasp it, so can you.) Every bitcoin transaction contains essential data – the two parties' digital wallet addresses, the transaction date and time, and other information that a sender adds. About 500 transactions, or 1 MB of data, is in each block. The blocks are sequentially "chained" together.
All blockchain data is public and the miners continually access new transactions. They take the transactions and convert it into a string of alphanumeric characters known as a "hash." The hash is always 64 characters regardless how much data is fed into the SHA256 hash calculator. The hash for a new block is created by taking the raw data from the first transaction and converting it into a hash. The raw data from the second transaction is added to the first hash to create a new hash. This process continues until there is a hash of all 500 transactions. Let me show you how it works. Imagine each paragraph of this article contains data from a bitcoin transaction. 1) Paragraph 1 "The Bitcoin blockchain is secure from hackers because of a mechanism referred to as Proof-of-Work." becomes this hash:
c70de0ff57dd8b63106b5a996a82117242ccd6f93316ceddefdbbbc181796104 2) Paragraph 2 "Unlike a traditional database that is housed in a central location with someone ensuring its security, the Bitcoin blockchain is distributed around the world in over 15,000 locations" is added to
"c70de0ff57dd8b63106b5a996a82117242ccd6f93316ceddefdbbbc181796104" and it becomes this new hash: 23c5adc507b44fd4b353d834f5089133f8e2d57b0fe4b667980ec86f5de79b92 This is repeated for all 500 bitcoin transactions – the requisite amount for a new block in the blockchain.
While the miners are doing this, they are also competing with each other in a contest that is essentially a lottery. They are trying to find a hash that matches a previously created hash for the current block.
The competing computers spit out randomly generated hashes until the winning hash is found. This requires massive computing power.
The winning computer gets the honor to "seal off" the new block of transactions with the block hash and assign the next block number. (As of this moment, 727,518 bitcoin blocks have been mined. A new block is mined about every ten minutes.)
The miner is rewarded with 6.25 BTC (about $250,000).
Proof of Stake
Since there is no central authority ensuring the integrity of a blockchain, a consensus mechanism is used to check the existing data and add new data.
The Bitcoin blockchain uses the proof-of-work mechanism. Proof-of-work sets up a competition among Bitcoin miners to solve a mathematical problem that requires using a massive amount of computing power. This has a significant environmental impact.
An alternative consensus mechanism is proof-of-stake. "Validators" will offer their coins as collateral for the opportunity to validate blocks on a blockchain. This is referred to as "staking." It only uses a small fraction of energy compared to the proof-of-work mechanism. The Ethereum blockchain is moving from proof-of-work to proof-of-stake. When it does, a validator will need to "stake" 32 ETH (about $110,000 at today's price). Validators are selected at random to validate the block. When enough validators verify the block is accurate, the block is closed.