A blockchain is a distributed public ledger that uses cryptography to ensure the record is practically immutable. The idea was created by an anonymous programmer that goes by the pseudonym Satoshi Nakamoto, and it's the underlying technology that makes peer-to-peer bitcoin transfers possible without the need for financial institutions to verify transactions. But blockchain technology has applications well beyond bitcoin. Anything that relies on access to a database can benefit from using blockchain technology.
What is a block?
A block is simply a collection of data. Theoretically, it can be any kind of data, but typically it includes transactional data.
For example, the block may contain data that says things like party A wants to send money to party B along with proof that party A has that money to send. That's primarily what's included in bitcoin's blockchain -- it's just a public ledger of transactions.
How data gets added to a block ?
When a person wants to add data to the public ledger, they must prove that they are authorized to add that data to a block. This is done through a system called public-key encryption.
Each person that's authorized to add data to the blockchain has both a private key and a public key. The private key must be kept secret from everyone else, but the public key is available to anyone with access to the blockchain.
The private key is used in combination with the data a person wants to add to create a digital signature. The computers on the blockchain network can then use a person's public key to verify the private key was used to sign the data. That public key cannot, however, be used to determine the private key.
This cryptography system ensures the data in each block is supposed to be there, which is very important. That's a responsibility typically held by financial institutions or trusted third parties, but blockchain technology eschews intermediaries in favor of a decentralized structure. As you'll see, any additions to the blockchain are very difficult to undo, so it's imperative each transaction is authorized.
Why is it called a chain?
Each block in the blockchain contains a reference to the block that immediately precedes it in the chain. This ensures that each block is ordered chronologically.
The reference data is generated by a cryptographic hash function, which takes all of the data in the previous block and maps it to a digest -- an alphanumeric string. If any of the data in the block changes, perhaps you want to add a few extra 0s to a number, the hash function will produce an entirely different digest.
By linking blocks together this way, it makes it practically impossible for a single person to change the data in the blockchain. Doing so would require that person to not only change the data in one block but also change it in every block that follows it.
What makes it so hard to make new blocks?
Each block also contains important information that allows the network of computers using the blockchain to verify the validity of the block -- such as a solution to a complex math problem called a proof-of-work. The proof-of-work requires a large amount of computing power to solve, but only a moderate amount is required to verify a solution.
A new block cannot be amended to the blockchain without solving the proof-of-work.
In many cryptocurrency blockchains like bitcoin and Ethereum, computers on the network are incentivized to produce proof-of-work and add blocks to the blockchain through a reward. Some blockchains rely entirely on transaction costs to incentivize people to spend money on computing resources like hardware and electricity to run it.
Thus, a person acting alone would need a large portion of the computing power on a network to even have a moderate chance of adding multiple blocks to a blockchain back-to-back.
Where is the blockchain stored ?
An important characteristic of most blockchains is that they're publicly distributed across the network. That's to say every computer on the network has a copy of the blockchain.
When a computer on the network solves the proof-of-work and adds a block to the blockchain, that new blockchain is immediately distributed to every other computer on the network. The other computers verify transactions in the block, as well as the proof-of-work solution.
There are instances when two computers solve the proof-of-work and try to add a block to the blockchain at the exact same time. And the blocks they add might not have the same data. Some computers get one copy of the chain while others get a different copy.
In this case, each computer keeps the first copy of the chain it received. The next computer to solve a proof-of-work will amend the new block to the copy it received and broadcast that new chain to the rest of the network, breaking the tie. The longest chain is always considered the only valid blockchain.
The rule that the longest chain is the only valid chain is another reason it's incredibly difficult to change a record. A person would not only have to solve the proof-of-work for the block they want to change, but they would also have to solve it for the next block before any other computer on the network solves it.