questions that can pop-up during an interview or a blockchain conversation - expand and see multiple answers
Coins/tokens are used to implement changes between states. When somebody does a transaction, this is a change of state, and coins are moved from one address to another. Apart from that, transactions can contain additional data, and a change of state is used to mutate data—the only way to do this in an immutable-by-definition blockchain. Technically, a blockchain doesn’t need coins for its essential operations, but without them, some other way needs to be introduced to manage states of the chain and to verify transactions.
Increased Capacity: Blockchain increases the capacity of the whole network because there are a lot of computers working together which in total offers a high power than a few of the devices where the things are centralized.
Better Security: Blockchain provides secure network by the connection of several computers called nodes which confirm the transaction on the network. There is not even a single chance of shutting down the system making Blockchain a secure system for keeping records.
Trustless exchange: Using blockchain, two parties can make an exchange without the oversight or intermediation of a third party, sharply reducing or even eliminating counterparty risk.
Durability, reliability, and longevity: Blockchain does not have a central point of failure due to the decentralized network thus better able to withstand malicious attacks.
Transparency and immutability: Blockchain technology makes transactional histories more transparent. It stores all the transactions over a distributed network which are transparent; viewable for public. Also, Blockchain is immutable (can’t be altered) for transactions because of multiple records’ storage in a single block over the peer-to-peer network.
Security: Blockchain provides unparalleled security
Immutability: Data once are written cannot be changed or altered.
Fast: Blockchain offers quick transactions
Decentralized: Any centralized authority or entity do not control it
Fault-tolerant: Blockchain networks are fault-tolerant.
Low transaction fees: No need for the third party makes it cheaper and more effective
Minting: Provides coin minting by various methods.
Blockchain is a chain of blocks made up of digital pieces of information or can be defined as the growing list of records linked via cryptography. Each block on the chain contains a cryptographic hash of the previous block, a timestamp, and transaction data.
Blockchain is an open, distributed, decentralized, public ledger that can record transactions between two parties efficiently and in a verifiable and permanent way.
Blockchain is the backbone of the world famous cryptocurrency– Bitcoin, a peer to peer electronic cash system and a decentralized network that allows users to make transactions directly without an intermediary to manage the exchange of funds.
Blockchain is the fastest growing and the most trusted crypto company helping millions across the globe gives a comfortable and safe way to access cryptocurrencies.
Miners are the people who own the systems that are nodes of the distributed environment of blockchain. Essentially, miners do nothing but own the system, and the system does the work for them. They verify the transaction and compete to find the right nonce for the new block. A nonce, a number only used once, is the number miners are racing to find. The miner who wins the race gets rewarded with the cryptocurrency.
Blockchain mining is a process by which transactions of a blockchain are verified without involving any third-party. Every time a transaction is sent from a Bitcoin wallet, it is sent to the transaction pool. Miners then pick hundreds of transactions and combine them to form a block with other overheads like Merkel Root, SHA-256 Hash, Nonce, etc.
All blockchain protocols rely on digital, decentralized, and distributed ledger models where the trust comes from the network itself. The designing principles of a blockchain include:
- Network integrity
- Distributed power
- Value as an incentive
Blockchain incorporates all of the above-mentioned principles by design. You wouldn’t need to emphasize improving the privacy or security of the blockchain, as it would have these properties innately. The trust protocol depends on the mass collaboration of people. This collaboration comes from the individual interest derived by the incentives that blockchain offers to the miners.
Just like the traditional contracts that we use in our daily lives (from purchasing a car to selling a property), smart contracts are a digital contract in the form of a computer program that is stored inside a blockchain. In the distributed environment of blockchain, smart contracts make sure that the participants comply with the agreed-upon terms and conditions.
Though it’s not a very ethical example, consider a betting website that allows the fans to place a bet on the football match. It requires people to fund their bets beforehand.
People tend to bet through a betting website because they do not know each other, and they do not trust each other. Thus, the website works as an intermediary and ensures that the people get their money if they win the bet. The trust that people put in the betting website is owing to the fact that the website charges service fees. Therefore, win or lose, the website always wins. But iff the website isn’t well established, those who manage the website may run away at any time. So, this threat always remains.
Blockchain & Smart Contract
Blockchain enables people to place a bet without an intermediary. People do not trust each other! Do not worry. They don’t need to. They will trust the Blockchain Protocol. This is where the smart contract comes into action. Once the bet is funded, the smart contract will automatically release the funds to the right person as soon as the conditions get fulfilled. So, if a person placed a bet in favor of team X, then the blockchain network will verify the outcome of that match from various sources and release the amount immediately.
Why do we trust smart contracts?
For starters, because the funds aren’t stored in one single place. They are distributed over the network and cannot be manipulated by anyone. Moreover, they are immutable in the sense that an agreed-upon can never be changed. There are no chances of anyone tampering with your smart contract. Since the smart contract is distributed, it will be verified by everyone involved in the network. So, a single-sided attempt of releasing the funds will be labeled as invalid and will be discarded.
The term smart contract is used to describe computer code that can facilitate the exchange of items such as money, content, property, or anything of value. When such smart contracts run on the blockchain platform, they become like a self-operating computer program that executes automatically when desired conditions are met. Since these run on the blockchain, they run exactly as programmed, without any chance of censorship, downtime, deception, or third-party interception.
Hashing is the process of taking an input of arbitrary length and converting it into a hash (a modified, outputted value) of a unique and fixed length. Hash functions are used to generate the encrypted output. This process plays a vital role in maintaining the integrity of transactions and confidentiality of data in the blockchain environment.
A hashing algorithm is selected based on a certain number of features. The most important one is that a hashing function must either be collision-free, or allow for an extremely low probability of collision. Theoretically, it is rather impossible for a hashing algorithm to be absolutely collision-free. However, practically speaking, this is generally achieved by using a very large number of bits in the hash value. This is done in order to make sure that no one can derive the secret items from the hash value, and also to make sure that one hash value uniquely reprints a single data set. SHA-3, SHA-256, and Keccak-256 are some of the hashing algorithms used for this purpose.
The probability of generating a single hash value for two different transactions for a 256-bit code would be 2^256 (which is an extremely low chance).
Some of the popular consensus algorithms are:
- PBFT (Practical Byzantine Fault Tolerance)
- Delegated proof-of-stake
- Proof-of-elapsed time
Now, the possible reasons why we need consensus mechanism more than “proof-of-work” are”
- Different business needs
- Different use cases
- Cryptography/Strength of Algorithm
- Regulation requirements
It’s a condition when one digital token is spent multiple times because the token generally consists of a digital file that can easily be cloned. It simply leads to inflation and organizations must bear a huge loss. One of the primary aims of Blockchain technology is to eliminate this approach up to the possible extent.
Blockchain prevents double spending by confirming a transaction by multiple parties before the actual transaction is written to the ledger. It’s no exaggeration to say that the entirety of bitcoin’s system of Blockchain, mining, proof of work, difficulty etc, exist to produce this history of transactions that is computationally impractical to modify.
Blockchain is considered incorruptible. Any ill-intentioned individual acting alone is powerless. “To take over the network, an attacker would have to control more than 50 percent of its total computing power,” Augier explains. “We hope that’s a theoretical scenario, but we can’t be sure. Should it happen, the individual would take every precaution to avoid being noticed.” Not to mention the energy required to power the computers needed for the blockchain system to work.
Banks and accounting systems use ledgers to track and timestamp transactions. The difference is that the blockchain is completely decentralized and an open source. This means that people do not have to rely on or trust the central bank to keep track of the transactions. The peer-to-peer blockchain technology can keep track of all the transactions without the fear of having them erased or lost.
Furthermore, the blockchain, because of its open-source nature, is more versatile and programmable than central banking ledgers. If programmers need new functionality on the blockchain, they can simply innovate on top of already existing software through consensus. This is difficult for central banks because of all of their regulations and central points of failure.
In simple terms, updating a cryptocurrency protocol or code is called forking. Fork implies that a Blockchain splits into two branches. It can happen when the participants of the network cannot come to an agreement with regards to the consensus algorithm and new rules to validate transactions.
There are three types of forking:
- Hard forks
- Soft forks
- Accidental forks
- A Blockchain distributed ledger is highly transparent as compared to a traditional ledger.
- Blockchain distributed ledgers are irreversible. Information registered on a distributed ledger cannot be modified whereas on a traditional ledger it is reversible.
- A distributed ledger is more secure. It uses cryptography and every transaction is hashed and recorded whereas in traditional ledger security can be compromised.
- In a distributed ledger, there is no central authority. It is a distributed system and the participants hold the authority to maintain the sanity of the network and are responsible for validating the transactions.
- Traditional ledgers are based on the concept of centralized control, which controls all transactions.
- In a distributed ledger, identities are unknown and hidden whereas in traditional ledger identities of all participants have to be known before the transactions happen.
- In a distributed ledger, there is no single point of failure as the data is distributed and information is shared across multiple nodes. If one node fails, the other nodes carry the same copy of the information. In comparison, traditional ledgers have a single point of failure. If a single system crashes, the entire network comes to a standstill.
- In a distributed ledger, data modification or change cannot be done but for a traditional ledger, it is possible.
- In a distributed ledger, validation is done by the participants in the network while in a traditional ledger, validation is done by a centralized authority.
- The copy of the ledger is shared amongst participants in a distributed ledger while in a traditional ledger, a single copy is maintained in a centralized location. It is not shared amongst the participants.
Blockchain is a decentralized technology of immutable records called blocks, which are secured using cryptography. Hyperledger is a platform or an organization that allows people to build private Blockchain.
Using Blockchain you can build public and private Blockchain whereas with Hyperledger you can only build private Blockchains.
Blockchain is divided into public, private, and consortium Blockchains and Hyperledger is a private Blockchain technology with access to Blockchain data and is limited to predefined users, configurations, and programming.
Blockchain can be used in multiple fields such as business, government, healthcare, etc. while Hyperledger is primarily used for enterprise-based solutions. Wherever we talk about public Blockchain, it refers to the usage of Blockchain on the internet, and Hyperledger-based Blockchain solutions are solutions meant for usage on the intranet, within an organization.
RSA (Rivest-Shamir-Adelman) algorithm is the first algorithm that is used for signing data and encryption. It is most widely used for securing sensitive data. It is also known as an asymmetric cryptographic algorithm which works on two different keys, namely public and private keys. The public key can be shared with anyone and the private key must be kept secret.
RSA is a cryptographic asymmetry algorithm that provides a state of data security for applications to use. It offers public-key encryption. RSA stands (for its developers’ name as Rivest-Shamir-Adleman) is one of the first public key cryptosystems which gives encryption key to everyone and keeps its decryption key as private. It is widely used for secure data transmission and hence applicable for several use cases including Blockchain.
RSA provides a state of the security algorithm for applications to use. It stands for Rivers, Shamir, and Adelman. They are the developer of this algorithm. RSA offers public-key encryption and hence is applicable in a variety of use-cases including blockchain. It is also the first encryption that is widely used for signing data and encryption. It works by using both private and public keys.
- On-chain transactions: These transactions are available on the blockchain and are visible to all the nodes on the blockchain network. It includes authentication and validation of a transaction by a defined number of participants.
- Off-chain transactions: These transactions deal with the values outside the blockchain and can be carried out using the various number of methods.
An off-chain transaction is the movement of value outside of the blockchain. While an on-chain transaction – usually referred to as simply ‘a transaction’ – modifies the blockchain and depends on the blockchain to determine its validity an off-chain transaction relies on other methods to record and validate the transaction.
A Coinbase transaction is a unique type of bitcoin transaction that is created by miners. It is the first transaction in the new block. The miners use it to collect the block reward of their work. Any transaction fees collected by the miners are also sent in this transaction.
A 51% attack or double-spend attack refers to an individual or group of miners on a blockchain who try to control more than 50% of the network’s mining hash rate or computing power. These attackers try to prevent the new transactions from gaining confirmations and enable them to halt payments between some or all the users. They are also capable of reversing transactions that are completed while they are in control of the network; it means they could double-spend coins.
In Blockchain, a 51% attack refers to a vulnerability where an individual or group of people controls the majority of the mining power (hash rate). This allows attackers to prevent new transactions from being confirmed. Further, they can double-spend the coins. In a 51% attack, smaller cryptocurrencies are being attacked.
51% Attack refers to a situation where a group of miners who hold more than 50% of the Network Hash Rate could manipulate with the New transactions (Stopping the transactions to proceed or gaining conformations) or able to reverse the transactions that were recently confirmed and kind of doing Double spend. It is Highly unlikely to be able to do that today but it is possible.
- Node - User/computer within the blockchain architecture.
- Transaction - It is the smallest building block of the blockchain system.
- Block - It is used for maintaining a set of transactions that are distributed to all the nodes in the network.
- Chain - Sequence of blocks.
- Miners - Specific nodes which perform a block verification process before adding to the blockchain structure.
- Consensus protocol - Set of rules to carry out blockchain operations.
1. Node application: Every computer that is part of a blockchain ecosystem must install and run an application. For example, in the Bitcoin network, every computer must install and run the Bitcoin wallet application.
2. Shared ledger: the Shared ledger is the data structure (Blockchain) that is distributed across all the nodes of a blockchain network. The shared ledger can be managed and viewed through the node application that runs on every computer in the network.
3. Consensus algorithm: Consensus algorithm is an algorithm implemented as part of the node application which provides the rules on how the blockchain network arrives at a single view of the shared ledger.
4. Virtual machine: Virtual machine is a logical part of the node application. The virtual machine understands a wide range of instructions, manages the state of digital contracts and enforces the terms of the contract.
There are many key features of blockchain. They include the following.
- Blockchain as a data structure: Blockchain can act as a data structure and store different types of data, including identity information, insurance, medical, and so on.
- Immutability: The data, once stored in the blockchain, is immutable. This gives the blockchain tamper detection property as well.
- Data protection: As the owner of the data is the source peer itself, data protection is completely dependent on the source. The absence of third-party actors also means that it is secure and offers the best data protection.
- Decentralized ledger technology: Decentralized ledger technology is the most important feature of a blockchain. It can be used by a private organization or public in a variety of use-cases.
- Better user anonymity: Users are relatively hidden compared to other traditional networks.
- Double spending: Blockchain solves double-spending problems using consensus algorithms and distributed ledger technology.
In reality, a trapdoor function is a function that is easy to compute in one direction but difficult to compute in the opposite direction unless the user has access to special information.
The trapdoor function is crucial when developing public-key encryptions and you can use it blockchains to create addresses and private keys for the users.
The most common types of ledgers that can be used in blockchain include:
- Centralized networks.
- Decentralized networks.
- Distributed networks.
Broadly speaking, there are four different types of blockchains.
Public Blockchain: Public blockchains are open-source and allow anyone to participate as developers, miners, and users. Furthermore, these are fully transparent allowing anyone to examine all recorded transactional information.
Private or Permissioned Blockchain: As the name suggests, permissioned blockchains impose certain privacy rules. For example, users require consent before participating in a network. Furthermore, all transactions remain private to the outside and only available to people inside the ecosystem.
Consortium Blockchain: Consortium Blockchain can be considered as a subcategory of the private blockchain. Furthermore, it comes with the same merits of a private blockchain but with the added clause that these are governed by a group rather than a single entity.
Hybrid Blockchain: Hybrid blockchains offer the perfect blend between privacy and transparency, by utilizing aspects of both private and public blockchain. Furthermore, this is most popular among businesses as they can control what data they want to make public, and what data they want to keep private.
There are three different types of Blockchain - Public, Private, and Consortium Blockchain.
Public Blockchain ledgers are visible to all the users on the internet and any user can verify and add a block of transactions to the Blockchain. Examples, Bitcoin, and Ethereum.
Private Blockchain ledgers are visible to users on the internet but only specific users in the organization can verify and add transactions. It’s a permissioned blockchain, although the information is available publicly, the controllers of the information are within the organization and are predetermined. Example, Blockstack.
In Consortium Blockchain, the consensus process is controlled by only specific nodes. However, ledgers are visible to all participants in the consortium Blockchain. Example, Ripple.
Blockchain has been categorized into public, private, and consortium blockchains. The primary point of distinction between these blockchains is the freedom of joining the network, verifying the transaction, initiate the transaction and availability of the ledgers for a review.
Public Blockchain allows public access. Anyone can join the network, verify the transaction, and initiate a new transaction. The ledgers are available for public view and anyone can track the blockchain to the genesis blockchain. Bitcoin is an example of a public blockchain.
Private Blockchain restricts the public from joining the network by creating certain entry criteria and to make sure that only authorized people can initiate and verify the transaction. Although the ledgers are available for everyone with internet access, people controlling the flow of information on the blockchain are pre-determined. This is usually employed within a single organization.
Consortium Blockchain is a hybrid of public and private blockchains. A Public blockchain is considered to be the least trustful while the private blockchain is considered to be highly trusted owing to the limited number of people involved. The consortium blockchain is implemented for a wider group of participants having predefined nodes. You may consider employing it for transactions between multiple organizations.
Public blockchain is made as open-source and non-permission based such that anyone can join for reading/writing/auditing the blockchain without any permission. Any user can download the code and start running the node on our device. Anyone can review anything on a public blockchain as it is made as transparent. Example: Bitcoin, Ethereum, Dash, etc.
Private blockchain is permission based and the private property of any individual or company. The private organizations use it to store sensitive information making available for their certain peoples only. Anyone who is authorized can access it and can participate in transaction and validation. Example: locks tax, multi-chain, etc.
Consortium/ federated blockchain is semi-decentralized and like a hybrid of the public and private blockchain. A group of individuals or consortium controls it. As public it can be shared by different nodes and as private only restricted nodes can access it.
Altering a single block requires a new signature for every other block that comes after it all the way to the end of the chain. This is considered to be near impossible. Why?
Let’s say a corrupt miner has altered a block of transactions and is now trying to calculate new signatures for the subsequent blocks in order to have the rest of the network accept his change. The problem for him is, the rest of the network is also calculating new signatures for new blocks. The corrupt miner will have to calculate new signatures for these blocks too as they are being added to the end of the chain. After all, he needs to keep all of the blocks linked, including the new ones constantly being added. Unless the miner has more computational power than the rest of the network combined, he will never catch up with the rest of the network finding signatures.
Millions of users are mining on the blockchain, and therefore it can be assumed that a single bad actor or entity on the network will never have more computational power than the rest of the network combined, meaning the network will never accept any changes on the blockchain, making the blockchain immutable.
Mining difficulty is the degree that determines how hard it is for miners in terms of hashing power (and thus also time) to find an eligible hash aka signature for their block (a block of transactions needs an eligible hash to be verified and added to the blockchain). On the Bitcoin blockchain, miners try to find an eligible hash by hashing random numbers.
A block of transactions will only be accepted by the rest of the network if it has a signature (hash) that meets certain requirements (in example of Bitcoin, the signature needs to start with a certain number of zeroes). In order to find this signature, miners are spending computational power (hashing power) to perform a set of pre-determined operations on random numbers untill they find a number that leads to an output number that meets the requirements.
Finding an output that starts with only one zero is much easier (generally more common) than finding an output number that starts with five consecutive zeroes (this is pretty rare so it would take much more time to find a number that leads to such output).
For example block 100 (back in 2009) only required a signature that started with eight consecutive zeroes, whereas the last recent block (block 542865) needed a signature that started with at least 18 consecutive zeroes.
Merkle trees are a fundamental part of blockchain technology. A merkle tree is a structure that allows for efficient and secure verification of content in a large body of data.
A Merkle tree summarizes all the transactions in a block by producing a digital fingerprint of the entire set of transactions, thereby enabling a user to verify whether or not a transaction is included in a block.
Merkle trees are created by repeatedly hashing pairs of nodes until there is only one hash left (this hash is called the Root Hash, or the Merkle Root). They are constructed from the bottom up, from hashes of individual transactions (known as Transaction IDs). Hashing is usually conducted using the SHA-2 cryptographic hash function, though other functions can also be used.
Merkle Tree is used to verify the transaction in the quickest time and less space complexity.
When a transaction occurs in a BlockChain the first step is to hash each transaction in the memory pool using SHA256.These hashes are then placed into a Merkle Tree (hash tree).The hashes of transactions are grouped into two and then concatenated result is hashed again until the tree is formed.
Hash at the top of the tree is called the Merkle root.The Merkle Root of this hash tree is placed into the block’s header along with the hash of the previous block and a random number called a nonce.The block’s header is then hashed with SHA256 producing an output that will serve as the block’s identifier.
A Merkle Tree is a data structure similar to a binary tree and is used to contain the cryptographic hashes of each block in a blockchain. Here the leaf node presents a hash of a block of transactional data whereas the non-leaf node represents a hash of the containing leaf node.
The advantage of using the Merkle Tree structure allows users to simply download the chain of block headers, instead of downloading every single transaction and block. As such, this makes verifying the existence of a particular block inside a blockchain extremely easy and convenient.
Merkle tree plays a major role in the blockchain technology. It describes a mathematical data structure that is composed of various blocks of data. It also summarizes all the transactions in a block by providing a digital fingerprint of the entire set of transactions.
It allows efficient and secure verification of content across a large body of data. Merkle tree is also known as a Hash tree and mostly used by Ethereum and Bitcoin.
The importance of a Merkle tree in the blockchain is that if anyone wants to verify the specific transaction in a block, they can download the chain of block headers instead of downloading every transaction and every block.
Merkel Tree is a data structure that is used for verifying a block. It is in the form of a binary tree containing cryptographic hashes of each block. A Merkle tree is structured similarly to a binary tree where each leaf node is a hash of a block of transactional data and each non-leaf node is a hash of its leaf node. The Merkel root or hash root is the final hash root of all the transaction hashes. It encompasses all the transactions that are underlying all the non-leaf nodes.
Merkle Tree also known as ‘hash tree’ is a data structure in cryptography in which each leaf node is a hash of a block of data, and each non-leaf node is a hash of its child nodes.
The benefit of using the Merkle Tree in blockchain is that instead of downloading every transaction and every block, a “light client” can only download the chain of block headers.
Also, if someone needs to verify the existence of a specific transaction in a block, then he doesn’t have to download the entire block. Downloading a set of a branch of this tree which contains this transaction is enough. We check the hashes which are just going up the branch (relevant to my transaction). If these hashes check out good, then we know that this particular transaction exist in this block.
Merkle trees are a data structure that is used in cryptography. It is also known as the hash tree. Technically, in the tree, every leaf node is designated with the hash of the data block. The non-leaf node on the other hand stores the cryptographic hash of the child nodes. Hash trees are incredibly efficient in terms of performance and can be used to verify large data structures.
For example, it is not required to transfer the whole block to verify a block.
Using a Merkle tree can significantly reduce the amount of data that a trusted authority has to maintain for verification purposes. It separates the validation of the data from the data itself.
Merkle trees have three major benefits:
- They provide a means to prove the integrity and validity of data
- They require little memory or disk space as the proofs are computationally easy and fast
- Their proofs and management only require tiny amounts of information to be transmitted across networks.
The ability to prove that a log is complete and consistent is essential to blockchain technology and the general ledger concept. Merkle trees help verify that later versions of a log include everything from an earlier version and that all data is recorded and presented in chronological order.
When a miner attempts to add a new block of transactions to the blockchain, it broadcasts the block to all the nodes on the network. Based on the block’s legitimacy (validity of signature and transactions), nodes can accept or reject the block. When a node accepts a new block of transactions, it saves and stores it on top of the rest of the blocks it already has stored. In short, here is what nodes do:
- Nodes check if a block of transactions is valid and accept or reject it.
- Nodes save and store blocks of transactions (storing blockchain transaction history).
- Nodes broadcast and spread this transaction history to other nodes that may need to synchronize with the blockchain (need to be updated on transaction history).
A blockchain exists out of blocks of data. These blocks of data are stored on nodes (compare it to small servers). Nodes can be any kind of device (mostly computers, laptops or even bigger servers). Nodes form the infrastructure of a blockchain.
All nodes on a blockchain are connected to each other and they constantly exchange the latest blockchain data with each other so all nodes stay up to date. They store, spread and preserve the blockchain data, so theoretically a blockchain exists on nodes.
A full node is basically a device (like a computer) that contains a full copy of the transaction history of the blockchain.
Basically the blockchain data structure is explained as a back-linked record of blocks of transactions, which is ordered. It can be saved as a file or in a plain database. Each block can be recognized by a hash, created utilizing the SHA256 cryptographic hash algorithm on the header of the block. Each block mentions a former block, also identified as the parent block, in the “previous block hash” field, in the block header.