• Blockchain For Beginners: Taking The First Step

    Headre_blockchainforbeginners

    Blockchain is a revolutionary technology that is changing the way many transactions occur (not just financial). But it’s not a new technology. It’s been around for almost a decade now. What’s new is the hype it is creating recently.

    However, it is still an abstract concept for a majority of people.

    If someone comes up to you and asks you what blockchain is, will you be able to explain it in a simple, clear, and concise manner?

    Most people cannot.

    As per a report by HSBC, blockchain is the least understood of new technologies. In a survey of 12,000 people in 11 countries, 59% have never heard about blockchain technology, and among the people who have heard about it, 80% don’t understand what it is.

    These statistics may seem astonishing at first but given the confusion around blockchain technologies, they are not that surprising.

    There are several blockchain-related terms floating around, such as Bitcoin, ethereum, cryptocurrency, etc., which further complicate the understanding of blockchain as a separate entity.

    This blog post is aimed at educating you and expanding your knowledge about this technology.

    A brief history of blockchain technology

    briefhistory

    When Satoshi Nakamoto created Bitcoin in the year 2009, it served as a pivotal moment in the rise of digital currency.

    The creation of Bitcoin is considered revolutionary because it brought blockchain technology and smart contracts to the mainstream by being the first decentralized cryptocurrency ever.

    Stuart Haber and W. Scott Stornetta were the first ones to work on a cryptographically-secured chain of blocks in 1991, which continued throughout the mid-2000s.

    However, it was only in 2008 that the first blockchain was finally conceptualized by Satoshi Nakamoto, which later became the core component of Bitcoin.

    In his paper, Bitcoin: A Peer to Peer Electronic Cash System, Satoshi explained how he found a solution to the problem of double-spend issue for digital currency. He suggested the use of a distributed database, which combines cryptography, computer science and game theory.

    Double spend means that digital currency can be simultaneously spent in two places. Through Bitcoin, Satoshi introduced a method that allowed secure and direct transaction of values between two entities without them having to rely on a trusted middleman.

    Why blockchain came into picture?

    The initial interest surrounding blockchain was due to its ability to be anonymous, which formed the basis for cryptocurrencies such as Bitcoin; however, the highlighting point of the technology is the complete transparency provided by it.

    Why-blockchain-came-into-picture

    This feature has been found to have application in nearly every industry.

    Ethereum introduced blockchain as a decentralized platform that runs smart contracts.

    Ethereum’s blockchain enabled developers to create markets; move funds in accordance with instructions given long ago, such as a will or a futures contract; store registries of debts or promises, etc., without a middleman or counterparty risk.

    While Bitcoin is simply a cryptocurrency, Ethereum, on the other hand, is a ledger technology that is being used by companies for building new programs. It is one of the first alternative applications of blockchain technology outside of cryptocurrency.

    What blockchain is NOT

    Before we tell you what exactly a blockchain is, let’s debunk some popular myths surrounding the blockchain technology.

    What-blockchain-is-NOT

    Myth #1: Blockchain = Bitcoin

    The truth: Blockchain technology is often considered as a singular concept, a single blockchain; however, the fact is that that a blockchain is an umbrella term. If blockchain is a digital infrastructure, then Bitcoin is an application.
    The use-cases for blockchain are almost endless.

    Myth #2: Blockchain is 100% tamper-proof.

    The truth: Although it is largely impractical, there is still a scenario where a blockchain could be tampered with. It can happen if the network-computing power of more than 50% is controlled and all the previous transactions are re-written.

    Myth #3: Blockchain is 100% secure.

    The truth: Nothing is ever 100%. There are always some loopholes. Just because blockchain uses a cryptographically-secured digital ledger, it doesn’t make it 100% secure. The ethereum DAO hack is one such example, which ultimately led to the split of ethereum into ethereum and ethereum-classic.

    Moreover, the security of an overall blockchain system depends upon the adjacent applications. Now because these applications can be and have been hacked, it puts the security of the overall blockchain system under threat.

    Now that you know what blockchain is not, let’s find out what this technology is and why everyone is so curious about it.

    What blockchain is

    A blockchain is a digitized, decentralized, distributed database, commonly referred to as a distributed ledger that records all the information introduced in the blockchain network. The created database is then replicated and shared among all the participants in the network, providing them with the access to the information, resulting in a highly transparent environment.

    Blockchain can be visualized as an ordered list of blocks, where each block is identified by its cryptographic hash.
    each-block-is-identified-by-its-cryptographic-hash
    Each block is ordered in such a way that it refers to the previous block, leading to the creation of a chain of blocks. When a new block is created and added to the blockchain, all the information contained by the new block is available to every member of the network.

    One important aspect, which makes blockchain more secure over traditional methods, is that once a piece of information is introduced into a blockchain, it is extremely difficult to modify it because it requires the consensus of all the members involved.

    Now what makes a blockchain so revolutionary? The fact that every time a change is made to a blockchain by anybody, everyone on the chain is notified about the change, making it a good data structure for keeping track of records of anything of value.

    For example, in Bitcoin, the blockchain contains information about the transactions. Each block represents a transaction, which means that each block in a Bitcoin blockchain tells you who transacted which Bitcoins to whom. This can be checked at any point of time.

    Who owns what at any time is called the current ‘state’ of a blockchain.

    What-blockchain-is

    This ‘state’ keeps on updating with the addition of new blocks in the chain.

    Suppose that you have to validate if someone actually made a transaction. This can be validated by checking the state of the blockchain. If the transaction was made, the state will be updated. However, in order to view the state of a blockchain, the ledger should be available publicly. This brings us to the next concept of peer-to-peer networks.

    The role of peer-to-peer networks in blockchain

    A large number of computers download, synchronize, and make the current state of the blockchain available worldwide.

    These computers are called ‘nodes’.

    To ensure that a blockchain is secure and up-to-date, these computers work together in a peer-to-peer network.

    These nodes contain the complete and updated version of a blockchain. Whenever a new block is added to the blockchain, each node updates its blockchain.

    Advantages of using a peer-to-peer network:

    • The state of a blockchain can be checked at any time, using a blockchain explorer.
    • There is no dependency on one party to check the true state of a blockchain.
    • A blockchain’s security doesn’t depend on the security of one server.
    • In order to tamper with a blockchain, thousands of computers would have to be hacked at the same time.
    • A blockchain cannot be deleted unless deleted by all the concerned nodes.
    The-role-of-peer-to-peer-networks-in-blockchain

    However, this doesn’t ensure 100% security and assurance of everything to be true because the input itself can be incorrect or invalid, or there can be different versions of a blockchain, making it difficult to figure out which version is the true state.

    To take care of these ambiguities, consensus mechanism comes into play.

    Purpose of the consensus mechanism

    In a peer-to-peer network, the consensus mechanism allows nodes to work together without having to know or trust each other.

    How?

    All the nodes in a network agree upon a set of rules to ensure the network works as intended and stays in sync. These rules are set on the basis of:

    • how blocks are to be added to the chain,
    • when blocks are considered to be valid, and
    • how conflicts of truth are resolved.

    Adding blocks to the chain

    There are two widely-used ways of adding blocks to blockchains: Proof of work (PoW) and proof of stake (PoS).

    The first method is PoW, which is the more known out of the two.

    • In this process, transactions are collected in a block of information and submitted, every ten minutes (in case of Bitcoin), to the blockchain for verification. The miners on the network then attempt to find a “nonce” by solving a cryptographic puzzle.
    • The miner who finds a “nonce” broadcasts it to the network for all the other miners to check and update their records, and work on adding the next block.
    • The miner who solves the puzzle is also rewarded by the network in the form of a predefined amount of coins, along with the transaction costs of all the transactions contained in the block.
    • Bitcoin uses the PoW system.
    mining

    The second method, PoS, is also commonly used in distributed ledgers.

    • In a proof of stake system, users are required to show that they own a certain number of cryptocurrency units.
    • For validating transactions and creating blocks, forgers first put their own coins at ‘stake’.
    • Validating a fraudulent transaction costs them not only the coins at stake but also the right to participate as a forger in future.
    • Most of the times, validating the right transactions earns them transaction fee as a reward. However, sometimes new currency units are created by inflating the coin supply, and then the forgers are rewarded with new currency units rather than transaction fees.
    • Cryptocurrencies currently running the PoS system are BlackCoin, Lisk, Nxt, Peercoin, etc.

    The validity of blocks

    A miner solves the puzzle and mines a block, which is then checked for validity by all the nodes in the network.

    If it is valid, it is added to all the nodes’ copy of the chain.

    All the nodes in a network must reach a consensus on the validity for the network to synchronize and for the blockchain’s state to be updated.

    But on what basis is the validity ensured? A newly-mined block is added by the nodes only if it follows the rules stated by the consensus mechanism. The rules state that:

    • A block can only be as valid as the transactions contained within them and a transaction can only be valid when it has a digital signature from the owner of the cryptocurrency. For example, Bitcoin’s rules state that one can only send bitcoins that have been either received first from someone or from mining a block. The nodes run a software to ensure that a sender has enough bitcoins for making a transaction by checking the state of the network.

    This can be better explained with the help of an example. Suppose that you receive 2 bitcoins from Alex and you send them to Sara. You then send the same 2 Bitcoins to another user, Rob, too.

    Once the block with your first transaction is added to the chain, all the nodes in the network will update the blockchain to state that you no longer own those 2 Bitcoins. Now any newly-mined block containing your transaction to Rob will be rejected by the nodes.

    The nodes’ software will check that the block does not follow the rules and hence, the blockchain will not be updated for this block.

    How conflicts of truth are resolved

    A common conflict is when two or more miners end up creating blocks at approximately the same time. Since it takes time for blocks to be shared across the network, how to decide which block is legit?

    Let’s take an example: Suppose that all the nodes on a network have synchronized their blockchains, and they all are on block number 50. Now four miners across the world create ‘Block 51’ at roughly the same time. Each ‘Block 51’ will look slightly different: They will definitely contain a different payment address for the block reward; and they may contain a different set of transactions.

    Conflicts-of-truth1

    Let’s call them 51a, 51b, 51c.

    How to resolve this?

    We will use the longest chain rule.

    In the example above, let’s assume that you first see ‘Block 51’ and it is a valid block. You will start mining the next block on Block 51, let’s say, 52a:

    Conflicts-of-truth2

    However, you may see that someone else built on block 51b. Now you need to keep an eye on this chain. If you see that the chain is growing, then as per the “longest chain rule” you should consider this longer ‘b’ chain as the valid one (…50, 51b, 52b) and ignore the shorter chain that you initially built on (…50, 51a). Therefore, you won’t try to build 52a and instead try to build 53b:

    Conflicts-of-truth3

    The longest chain rule is used by the Bitcoin blockchain ecosystem to resolve such conflicts, which are quite common in the distributed networks.

    How does a blockchain work?

    Blockchain works on the concept of “Distributed Ledger Technology”.

    It works similar to a checking account at a bank. When you make a transaction at the bank, they update your ledger and subsequently, your balance.

    In blockchain, this process is followed with a fundamental difference: the ledger is not updated by only one entity; it is updated by all the participants in the global network. They synchronize a record and check it against each other.

    A blockchain is basically a digital record of all the transactions to have happened since the original block was created.

    This is what a block looks like:

    How-does-a-blockchain-work

    The Hash

    First comes the hash.

    A block header is the one that contains the information of all the previous blocks. At every stage, the block of information is hashed using the SHA-256 algorithm.

    The-Hash

    The purpose of hashing is to provide an immutable record and unique method of checking if any block in the chain has been tampered with.

    Let’s look at an example:

    If we hash the following three words: Bitcoin, bitcoin and bitco1n, the results will be is completely different, even though the changes.

    Bitcoin:

    b4056df6691f8dc72e56302ddad345d65fead3ead9299609a826e2344eb63aa4

    bitcoin:

    6b88c087247aa2f07ee1c5956b8e1a9f4c7f892a70e324f1bb3d161e05ca107b

    bitco1n:

    5f1c02fdfc98282785733b7a60b868d23c3b66c052b9b079f2f0887e11a96523

    If someone makes even a minor, single adjustment to any part of the blockchain, an error will be generated. This cryptography function ensures a very high level of integrity.

    Block Index

    The number of blocks since the beginning of a chain.

    Timestamp

    The time and date of the block and transactions.

    Transactions

    The amount of value being sent, the public key of the receiver and the address of the sender.

    Cryptographic Signature

    Cryptographic-Signature

    The sender signs their message with their private key, which can later be unencrypted with their public key. The trust is built on the assumption that only the sender holds their private key. As demonstrated in the image below:

    Proof of Work

    The final step in a transaction is its validation, which is done by miners through PoW or PoS system.

    Following is an illustration of a Bitcoin transaction’s life cycle:

    Proof-of-work

    Why do we need blockchain?

    We need blockchain because:

    Ordinary transactions are inefficient and lack transparency

    Why-do-we-need-blockchain1
    • Because each participant has their individual, separate ledger, it increases the possibility of human error or/and fraud.
    • Inefficiencies occur because of the reliance on intermediaries for validation.
    • Transactions can become a paper-laden process, which can result in delays and potential losses for all stakeholders.

    Blockchain reduces this complexity

    Why-do-we-need-blockchain2
    • Blockchain is a single, shared and tamper-proof ledger, in which, once transactions are recorded, they cannot be altered.
    • For a new transaction to be added to a network, it requires consensus from all the parties.
    • Blockchain technology eliminates/reduces the paper processes, resulting in fast transaction times, thereby, increasing efficiencies.

    Use Cases

    Blockchain is not a singular form and therefore, it can be configured in multiple ways for meeting the objectives and commercial requirements of a particular use case.

    Use-Cases

    Conclusion

    Although blockchain technology has been around for more than a decade now, it gained popularity only in recent years because of Bitcoin, which is a virtual currency used in real world business transactions. Because of Bitcoin, there is a major perception among most people that blockchain technology is only for banking and finance. However, this is not true and different industries are gradually recognizing the potential of blockchain technology in their business with the emergence of new and more practical use cases. It is undoubtedly one of the most talked-about technology these days and quite possibly the innovation of the era, which is here to stay and evolve.

    CTA_hireMagento-Developer
    Rishabh Sharma

    About the Author

    Rishabh Sharma is a Python Developer and has also worked on various projects involving Internet of Things. He finds a special inclination towards machine learning and data analytics. He loves reading inspirational books and also finds a keen interest in poetry.

    Comments

     
     


    get in touch

    Ready to discuss your requirements?

    Request Free Consultation