A blockchain is a distributed and a decentralized digital ledger that can be used to record transactions and other data across numerous computers in a decentralized peer-to-peer network. We can also define a blockchain as a distributed encrypted database like a spreadsheet that is duplicated thousands of times across a network of computers. This network is designed to regularly update this spreadsheet. It is a subset of distributed ledger technologies.
Centralized Network vs Decentralized Network
Each node is a computer(desktop, laptop, handphone, mining rig etc) that is connected to the network
A blockchain comprises a chronological chain of blocks. A block refers to a set of transactions that are bundled together and appended to the blockchain. Every node in the network stores a copy of the distributed ledgers, or a chain of blocks, as shown in the figure below.
A block in the blockchain primarily consists of four pieces of metadata, as follows:
On the Bitcoin blockchain network, the miner nodes bundle unconfirmed and valid transactions into a block. Each block contains a given number of transactions. In the Bitcoin network, every miner must solve a cryptographic puzzle to propose the next block. This process is known as 'proof of work'. Proof-of-work is a mechanism that existed before the first blockchain was created. It prevents abuses by requiring a certain amount of computing work. That amount of work is key to prevent spamming and tampering. Spamming is no longer worth it if it requires a lot of computing power.
Timestamping is an important feature of blockchain technology. Each block is timestamped, with each new block referring to the previous block using the cryptographic hash. Combined with cryptographic hashes, this timestamped chain of blocks provides an immutable record of all transactions in the blockchain, as shown in the figure below:
A hash or hash value is the result of a hash function. A hash function takes an input of any length, perform some algorithmic transformation, and produces an alphanumeric value of a predetermined length. The input could be a spreadsheet file, a music file, video file, image file, financial statement, invoice, contract etc.
A hash value comprises a 256 bits(64 characters) random letters and numbers , as follows: “4373c7fb1437035365d9228c77eca2cfd240523e274163e78c1eba11effd8b38”.
A hash has the following properties
Hashes are used to represent the current state of the blockchain. The input is the entire state of the blockchain. It means all the transactions that have taken place so far and the resulting output hash represents the current state of the blockchain. The hash is used to agree between all parties that the state is the same.
Hash is for validation purpose. Data on the blockchain is “hashed” in each block. Each block is linked with the previous bock via the hash value. If someone tampers with a block, everyone will know the block is corrupted. Therefore. It preserves the integrity and immutability of the blockchain.
Digital signatures, like real signatures, are a way to prove that somebody is who they say they are, except that we use cryptography or math, which is more secure than handwritten signatures that can be easily forged. A digital signature is a way to prove that a message originates from a specific person and no one else, like a hacker.
Digital signatures are used today all over the Internet. Whenever you visit a website, you are using SSL, which uses digital signatures to establish trust between you and the server. This means that when you visit Facebook.com, your browser can check the digital signature that came with the web page to verify that it indeed originated from Facebook and not some hacker.
Generating a key pair is analogous to creating an account on the blockchain, but without having to actually register anywhere. Besides that, every transaction that is executed on the blockchain is digitally signed by the sender using their private key. This signature ensures that only the owner of the account can move money out of the account.
To sum it all together, blockchain could not exist without hashing and digital signatures. Hashing provides a way for everyone on the blockchain to agree on the current world state, while digital signatures provide a way to ensure that all transactions are only made by the rightful owners. We rely on these two properties to ensure that the blockchain has not been corrupted or compromised.