Blockchain
Blockchain is a digital ledger that has the main function of storing digital information. Unlike a standard database, the data in a blockchain is stored in chunks of digital information that are secure by cryptography, called blocks, which can range in size. Whenever the storage of one block is filled with data (primarily transaction data), the block is sealed, timestamped, and broadcasted to a network of nodes.
The information stored in a blockchain is immutable, meaning no one can change the content of the past blocks. A blockchain can be either centralized (where a central source of control governs the network) or decentralized (where the network relies on peer-to-peer communication and distributed consensus to govern the network).
Are blockchains public or private?
Blockchains can either be public (open, permissionless) or private (permissioned). In a permissionless environment, anyone can freely join the network as a node, making it a trustless environment.
What are some consensus mechanisms?
Different consensus mechanisms can secure each permissionless, open, and trustless blockchain: proof of work and proof of stake are the most common, but there are many others. Proof of work is considered to be highly secure and decentralized, while proof of stake is more scalable.
Let's take Proof of Work (PoW) as an example first:
User A sends to User B 1000 CKB. The transaction is sent to the network and waits ”in line” to be introduced in a block (equal to being validated). This process is made possible by miners. Miners are the actors that secure the network by solving complicated equations that derive from specific algorithms by using specific (ASICS) or nonspecific (GPUs) hardware.
So, how does it all work?
Miners compete with each other to get to the result of the equation first. The result of the equation is the hashkey of the block, which works like a safe lock for the block that will store the transaction data (solving this equation is called ”finding a block”). Solving the equation requires a lot of energy for the hardware to work, hence the name ”miners.” For the work done on securing the network, the miners get a reward in the form of mined cryptocurrency. If they are part of a pool (which is a conglomerate of miners that all use their machines in order to solve the SAME equation), then the pool gets the reward and is distributed fairly to all miners by the hash power they provided. After the miners send the sealed, timestamped block to the network, the second actors come into play: Nodes.
What are nodes?
Nodes are copies of the blockchain that are being held on computers/hardware around the world. It keeps the entire information (all the blocks with all the respective data - remember, it is immutable - ), and the vast majority of nodes will share the EXACT SAME blockchain data. Whenever the miners broadcast a new block, the nodes check its validity, and the integrity of the previous known state of the blockchain and then CROSS-REFERENCE with ALL the other nodes so they will all have the same blocks added to the blockchain. Once confirmed, they will update their state accordingly (the nodes will agree on the new block being added, and the change of the blockchain state). This ensures that a bad actor will not be able to change the state of the blockchain. Their node would be the only one that does not match the copy of every other node, so the majority of nodes will not agree upon their transaction. Of course, all these steps are perfectly transparent in a decentralized blockchain and you can verify at any given point any address, amount, transaction, or miner address that validated the block and so on. This shows how TRANSPARENT and TRUSTLESS a decentralized Proof of Work blockchain could be.
Let’s talk Proof-of-Stake (POS):
The second most used consensus mechanism is Proof of Stake (PoS), which eliminates the need for mining, and replaces miners with stakers. Each user can stake a portion or all their funds and basically ”vouch'' for the network's security. The blocks are distributed randomly, with the highest chances of getting a block to the staker that stakes the most money.
What is a 51% attack?
A 51% attack (which happens when either 51% of all miners decide to broadcast faulty blocks, or when 51% of all the stakers decide to do the same in a PoS consensus) is much easier to obtain in a Proof of Stake environment. Given that PoW requires hardware, facilities, and a competent energy grid - not only a lot of money. Luckily, they are extremely rare events in both categories.
How do you interact with a blockchain?
You will need a wallet to interact with the blockchain to be able to hold and transact with crypto. Wallets are made of 2 components: a private key and a public address.
What is a private key?
The private key, as the name suggests, MUST remain unknown to anybody. The funds on a blockchain are stored on the blockchain itself, not on your wallet, and to transact with them, you need proof that you own them: this is the private key. A private key is a large number in cryptography to encrypt or decrypt data, sort of like a password.
What is a public address?
The public address is linked to the private key and can be shared freely to receive funds from other people. A good comparison for the private key is the PIN number of your card, which must not be shared with anyone but is absolutely necessary in order to take money out of an ATM, and the IBAN for the public address, which can be freely shared to anyone in order to receive money.