Blockchain Unit-1 Notes

Introduction To Blockchain

  • The blockchain technology was described in 1991 by the research scientist Stuart Haber and W. Scott Stornetta. They develop a system using the concept of cryptographically secured chain of blocks to store the time-stamped documents. So that they could not be tampered.
  • In 2004, computer scientist and cryptographic activist Hal Finney introduced a system called Reusable Proof Of Work(RPoW) as a prototype for digital cash. It was a significant early step in the history of cryptocurrencies. The RPoW system worked by receiving a non-exchangeable or a non-fungible Hashcash based proof of work token in return, created an RSA-signed token that further could be transferred from person to person.
  • RPoW solved the double-spending problem by keeping the ownership of tokens registered on a trusted server. This server was designed to allow users throughout the world to verify its correctness and integrity in real-time.
  • Further, in 2008, Satoshi Nakamoto conceptualized the theory of distributed blockchains. It utilizes a peer-to-peer network for timestamping and verifying each exchange. It could be managed autonomously without requiring a central authority. These improvements were so beneficial that makes blockchains as the backbone of cryptocurrencies.

    1.1 Digital Trust

  • Digital Trust is a concept that refers to the level of confidence that customers, business partners and employees have in a company or organization's ability to maintain secure networks, systems and infrastructures, especially with regard to their sensitive data.
  • Digital trust is given to companies who have shown their users they can provide safety, privacy, security, reliability, and data ethics(principles) with their online programs or devices. When a person decides to use a company's product, they are confirming their digital trust in the business.

    1.2 Asset

  • An asset is anything of value or a resource of value that can be converted into cash. Individuals, companies, and governments own assets.
  • Digital assets can be defined as anything that exists in a digital format. The phrase ‘digital assets’ has historically referred to media formats that were traditionally physical items, such as photos, videos, and documents, that began to being created, stored, and shared in a digital environment.

    1.3 Transactions

  • A Blockchain transaction can be defined as a small unit of task that is stored in public records or blocks.
  • These blocked are executed, implemented & stored in blockchain only after the validation is done by all persons involved in blockchain network.

    How BlockChain Transaction Works?

  • Step 1: Some personal request a transaction. The transaction could be involved crypto currency, contracts, records or other information.
  • Step 2: The requested transaction is broadcasted to a P2P network with the help of nodes.
  • Step 3: The network of nodes validates the transaction the user’s status with help of known algorithms.
  • Step 4: After transaction is complete the new block is then added to the existing block chain.

    1.4 Distributed Ledger Technology

  • Distributed ledger technology (DLT) is a digital system for recording the transaction of assets in which the transactions and their details are recorded in multiple places at the same time.
  • In a distributed ledger, each node processes and verifies every item, thereby generating a record of each item and creating a consensus (agreement) on its veracity (accuracy). A distributed ledger can be used to record static data, such as a registry, and dynamic data, such as financial transactions.
  • It used to reduce operational inefficiencies on financial transaction.
  • It also provides security because of the immutable nature of ledgers.
  • Components of DLT:

  • A Data model that captures the current state of the ledger.
  • A language of transaction that changes the ledger states.
  • A protocol used to build consensus among participants around which transactions will be accepted and what in order by the ledger.

    Application of DLT

  • Finance
  • Music & entertainment
  • Diamond & precious assets
  • Artwork
  • Supply Chain of various Commodities
  • Online Voting
  • Insurance Contract
  • Advantages of DLT:

  • Secure because there is no third party intervention
  • DLT have the potential to speed transaction bez they remove the need for central authority or middleman
  • Reduce the cost of transaction
  • Handles records or transaction in transparent way.
  • It is immutable once recorded cannot be intervened
  • Data is distributed so it is tamper-proof
  • Disadvantages of DLT:

  • DLT is spread along with the nodes so makes it vulnerable to attack
  • Transaction cost is high bez of a larger network
  • Transaction speed is low bez of the operation of a large number of nodes.

    1.5 Types of network

    1. Public Blockchain

    These blockchains are completely open to following the idea of decentralization. They don’t have any restrictions, anyone having a computer and internet can participate in the network.

  • As the name is public this blockchain is open to the public, which means it is not owned by anyone.
  • Anyone having internet and a computer with good hardware can participate in this public blockchain.
  • All the computer in the network hold the copy of other nodes or block present in the network
  • In this public blockchain, we can also perform verification of transactions or records
  • Advantages:

  • Trustable: There are algorithms to detect no fraud. Participants need not worry about the other nodes in the network
  • Secure: This blockchain is large in size as it is open to the public. In a large size, there is greater distribution of records
  • Anonymous Nature: It is a secure platform to make your transaction properly at the same time, you are not required to reveal your name and identity in order to participate.
  • Decentralized: There is no single platform that maintains the network, instead every user has a copy of the ledger.
  • Disadvantages:

  • Processing: The rate of the transaction process is very slow, due to its large size. Verification of each node is a very time-consuming process.
  • Energy Consumption: Proof of work is high energy-consuming. It requires good computer hardware to participate in the network
  • Acceptance: No central authority is there so governments are facing the issue to implement the technology faster.
  • Use Cases: Public Blockchain is secured with proof of work or proof of stake they can be used to displace traditional financial systems. The more advanced side of this blockchain is the smart contract that enabled this blockchain to support decentralization. Examples of public blockchain are Bitcoin, Ethereum.

    2. Private Blockchain

    These blockchains are not as decentralized as the public blockchain only selected nodes can participate in the process, making it more secure than the others.

  • These are not as open as a public blockchain.
  • They are open to some authorized users only.
  • These blockchains are operated in a closed network.
  • In this few people are allowed to participate in a network within a company/organization.
  • Advantages:

  • Speed: The rate of the transaction is high, due to its small size. Verification of each node is less time-consuming.
  • Scalability: We can modify the scalability. The size of the network can be decided manually.
  • Privacy: It has increased the level of privacy for confidentiality reasons as the businesses required.
  • Balanced: It is more balanced as only some user has the access to the transaction which improves the performance of the network.
  • Disadvantages:

  • Security- The number of nodes in this type is limited so chances of manipulation are there. These blockchains are more vulnerable.
  • Centralized- Trust building is one of the main disadvantages due to its central nature. Organizations can use this for malpractices.
  • Count- Since there are few nodes if nodes go offline the entire system of blockchain can be endangered.
  • Use Cases:With proper security and maintenance, this blockchain is a great asset to secure information without exposing it to the public eye. Therefore companies use them for internal auditing, voting, and asset management. An example of private blockchains is Hyperledger, Corda.

    3. Consortium (Group) Blockchain (semi private blockchain)

    It is a creative approach that solves the needs of the organization. This blockchain validates the transaction and also initiates or receives transactions.

  • Also known as Federated Blockchain.
  • This is an innovative method to solve the organization’s needs.
  • Some part is public and some part is private.
  • In this type, more than one organization manages the blockchain.
  • Advantages:

  • Speed: A limited number of users make verification fast.
  • Authority: Multiple organizations can take part and make it decentralized at every level. Decentralized authority, makes it more secure.
  • Privacy: The information of the checked blocks is unknown to the public view. but any member belonging to the blockchain can access it.
  • Disadvantages:

  • Approval: Since one or more organizations are involved there can be differences in the vision of interest.
  • Transparency: It can be hacked if the organization becomes corrupt. Organizations may hide information from the users.
  • Vulnerability: If few nodes are getting compromised there is a greater chance of vulnerability in this blockchain
  • Use Cases: It has high potential in businesses, banks, and other payment processors. Food tracking of the organizations frequently collaborates with their sectors making it a federated solution ideal for their use. Examples of consortium Blockchain are Tendermint and Multichain.

    1.6 Components of blockchain or DLT

  • Node:
    Nodes are the participant user or computer within the blockchain.
  • Transaction:
    It is a smallest building block of a blockchain system.
  • Block:
    It is data structure used for keeping a set of transaction which is distributed to all nodes in the network.
  • Chain:
    It is a sequence of blocks in a specific order.
  • Miners:
    Special nodes which perform the block verification process.
  • Consensus:
    A set of rules & arrangement to carry out blockchain operation.

    1.7 Ledger

    A ledger is the principal book or computer file for recording and totaling economic transactions measured in terms of a monetary unit by account type, with debits and credits in separate columns and a beginning monetary balance and ending monetary balance for each account.
    Example: Revenue accounts, Expense accounts.

    1.7.1. Blocks

  • Blocks are records, which together form a blockchain. In the world of cryptocurrencies, blocks are like ledger pages while the whole record-keeping book is the blockchain. A block is a file that stores unalterable data related to the network.
  • Blocks hold all the records of valid cryptocurrency transactions. They are hashed and encoded into a hash tree or Merkle tree.
  • Every block has the cryptographic hash of the block that precedes it in the blockchain. A block, plus all the blocks before and after it, form a blockchain.
  • The first block in a blockchain is the Genesis(starting) Block. It is the only one with no data on the previous block because there is no block before it.

  • Block is divided into two sections -
    1)Block Header
    2)Block body

    Block header

    The head of the block is divided into six components:
    1. the version number of the software
    2. the hash of the previous block
    3. the root hash of the Merkle tree
    4. the time in seconds since 1970–01–01 T00: 00 UTC
    5. the goal of the current difficulty
    6. the nonce

    1.The version number of the software

    The software version number does not matter in most cases. However, a miner with a particular version number can signal which protocol decisions he supports.

    2.The hash of the previous block

    Because the hash of the previous block is contained in the hash of the new block, the blocks of the blockchain all build on each other. Without this component, there would be no connection and chronology between each block.

    3.The root hash of the Merkle tree

    All transactions contained in a block can be aggregated in a hash. This is the root hash of the Merkle tree.

    4.The time

    A timestamp in the block itself. The time is given in seconds since 1.1.1970.

    5.The goal of the current difficulty

    Every hash has a size in bits. The lower the goal in bits is, the harder it is to find a matching hash. A hash with many zeros at the beginning is smaller than a hash without zeros. Find out more about the difficulty of the proof of work.

    6.The Nonce

    The nonce is the variable incremented by the proof of work. In this way, the miner guesses a valid hash, a hash that is smaller than the target.

    The six components form the block header. The block header plays a fundamental role in Bitcoin because it connects all blocks together.

    Block Body

    • It contains all transactions that are confirmed with the block.
    • When a miner constructs a block, it validates the transactions. That is, he checks that the sender actually has enough money to spend. He can easily read this information from the blockchain.

    1.7.2. Blockchain

    A blockchain is a continuously growing list of records (blocks), which are linked & secured using cryptograph.

    1.8 PKI and Cryptography

    Cryptography is a method of protecting information and communications through the use of codes, so that only those for whom the information is intended can read and process it.
    cryptography is most often associated with scrambling plaintext (ordinary text, sometimes referred to as cleartext) into ciphertext (a process called encryption), then back again (known as decryption).

    Modern cryptography concerns itself with the following four objectives:

    • Confidentiality: The information cannot be understood by anyone for whom it was unintended.
    • Integrity: The information cannot be altered in storage or transit between sender and intended receiver without the alteration being detected.
    • Non-repudiation: The creator/sender of the information cannot deny (reject) at a later stage their intentions in the creation or transmission of the information.
    • Authentication: The sender and receiver can confirm each other's identity and the origin/destination of the information.

    PKI (or Public Key Infrastructure)

    It is the framework of encryption and cyber security that protects communications between the server (your website) and the client (the users).
    It works by using two different cryptographic keys:
    1) Public Key
    2) Private Key

    • The most distinct feature of Public Key Infrastructure (PKI) is that it uses a pair of keys to achieve the security service. The key pair consist of private key and public key.
    • PKI provides assurance of public key. It provides the identification of public keys and their distribution.
    • The purpose of a PKI is to facilitate the secure electronic transfer of information for a range of network activities such as e-commerce, internet banking and confidential email.
    • It is used to authenticate the communicating parties and to validate the information being transfer.

    Public key Infrastructure

      Certificate Authority

    • A Certificate Authority (CA) is used to authenticate the digital identities of the users, which can range from individuals to computer systems to servers.
    • Certificate Authorities prevent falsified entities and manage the life cycle of any given number of digital certificates within the system.
    • Registration Authority

    • Registration Authority (RA), which is authorized by the Certificate Authority to provide digital certificates to users on a case-by-case (item by item) basis.
    • All of the certificates that are requested, received, and revoked (cancel) by both the Certificate Authority and the Registration Authority are stored in an encrypted certificate database.
    • Validation authority

    • Validation authority (VA) is an entity that provides a service used to verify the validity of a digital certificate

    1.8.1. Private keys

    • A private key, also known as a secret key, is a variable in cryptography that is used with an algorithm to encrypt and decrypt data.
    • Secret keys should only be shared with the key's generator or parties authorized to decrypt the data.
    • Private keys play an important role in symmetric cryptography, asymmetric cryptography and cryptocurrencies.

    1.8.2. Public keys

    • Asymmetric cryptography also known as public key cryptography is components of blockchain technology.
    • This form of cryptography allows everyone to verify the integrity of transactions, protect funds from hackers and much more.
    • In this method we use two keys one for encryption & second for decryption.
    • a) User will use his/her friend’s public key to encrypt the message.
      b) The receiver will use a private key in order to decryption this message.
      c) The public key is used to encrypt plain text or to verify digital signature whereas private key is used to decrypt cipher text or to create digital signature.
      d) Message encrypted with the public key can only be decrypted using related private key pair.

      Working of public key:

      1) Public key uses asymmetric algorithms that converted messages into unreadable format
      2) A person who has a public key can encrypt the message intended for a specific receiver.
      3) The receiver with the private key can only decode the message, which is encrypted by the public key.
      4) The key is available via the public accessible directory.

    1.8.3. Hashing

    • Hashing refer to the process of generating a fixed size output from an input of variable size using the mathematical formulas known as hash functions.
    • A hash is basically like a fingerprint. It is unique for each block.
    • We can calculate hash of block by taking all of its contents & running it through a hash function. Each block point towards the previous block means that each block need a hash.
    • The hashing algorithm is deterministic that mean as long as your input not change your hashing algorithm will always produce same output (i.e. digest or hash)
    • It is one of the core elements of digital signature system. The process of hashing involves transforming data of any size into a fixed size output. This is done by an algorithm which we called hash function. The output generate by hash function is known as hash value or message digest.

    1.8.4. Digital Signature

    • It is a technique that binds a person/entity to the digital data.
    • This binding can be independently verified by receiver as well as any third party.
    • Digital signature is a cryptographic value that is calculated from the data and a secret key known only by the signer.

    Model of Digital Signature

    Workflow of encryption using Digital Signature

      The following points explain the entire process in detail −

    • The digital signature uses the scheme of public-private key pair.
    • The key pairs used for encryption/decryption and signing/verifying are different. The private key used for signing is referred to as the signature key and the public key as the verification key.
    • Signer feeds data to the hash function and generates hash of data.
    • Hash value and signature key are then fed to the signature algorithm which produces the digital signature on given hash. Signature is appended to the data and then both are sent to the verifier.
    • Verifier feeds the digital signature and the verification key into the verification algorithm. The verification algorithm gives some value as output.
    • Verifier also runs same hash function on received data to generate hash value.
    • For verification, this hash value and output of verification algorithm are compared. Based on the comparison result, verifier decides whether the digital signature is valid.
    • Since digital signature is created by ‘private’ key of signer and no one else can have this key; the signer cannot repudiate signing the data in future.

    How Digital Signature Work:

      Digital Signature System consists of three basic step: Hashing, Signing & verifying.

      Hashing:

    • The first step is to hash the message or digital data.
    • This is done by submitting data through a hashing algorithm so that a hash value is generated (i.e. message digest).
    • As mentioned, the messages can vary significantly in size, but when they are hashed, all their hash values have the same length.
    • This is the most basic property of a hash function.
    • Signing:

    • After the information is hashed, the sender of the message needs to sign it.
    • This is the moment where public-key cryptography comes into play.
    • There are several types of digital signature algorithms, each with its own particular mechanism.
    • But essentially, the hashed message will be signed with a private key, and the receiver of the message can then check its validity by using the corresponding public key (provided by the signer).
    • Verifying:

    • Let’s take an example to illustrate the whole process until the final step of verification. Imagine that Alice writes a message to Bob, hashes it, and then combines the hash value with her private key to generate a digital signature.
    • The signature will work as a unique digital fingerprint of that particular message.
    • When Bob receives the message, he can check the validity of the digital signature by using the public key provided by Alice.
    • This way, Bob can be sure that the signature was created by Alice because only she has the private key that corresponds to that public key (at least that’s what we expect).

    Importance or advantage of Digital Signature

    • Message authentication −
      When the verifier validates the digital signature using public key of a sender, he is assured that signature has been created only by sender who possess the corresponding secret private key and no one else.
    • Data Integrity − In case an attacker has access to the data and modifies it, the digital signature verification at receiver end fails. The hash of modified data and the output provided by the verification algorithm will not match. Hence, receiver can safely deny the message assuming that data integrity has been breached.
    • Non-repudiation − Since it is assumed that only the signer has the knowledge of the signature key, he can only create unique signature on a given data. Thus the receiver can present data and the digital signature to a third party as evidence if any dispute arises in the future.

    • Private key + public key = digital signature

    1.9. Consensus

    • Blockchain is distributed decentralized network that provides immunity, transparency, privacy & security.
    • There is no central authority present to validate & verify the transaction yet every transaction is completely secured & verified.
    • This is happen because of Consensus Protocol which is part of any block chain network.
    • It is mechanism is used to identify the unauthorized or fault tolerant. In this scenario every node is having a common agreement if all nodes share the common information then it proves that there is no any unauthorized node.
    • A consensus algorithm is procedure through which all peers(nodes) of the blockchain reach a common agreement about the present state of the distributed ledger.
    • In this way consensus algorithm achieve reliability in the blockcahin network and establish trust between unknown peers in distributed computing environment.
    • Objectives of a consensus mechanism:

      Agreement
    • Mechanism should bring about as much agreement from the group as possible.
    • Collaborative All the participant should aim to work together to achieve a result that puts the best interest of the group first.

    • Cooperative
    • All the participant shouldn’t put their own interest first and work as a team more than individuals.

    • Participatory
    • Every participants should actively participate in the overall process.

    1.9.1. Byzantine Fault

    • Byzantine Fault Tolerance (BFT) is a consensus approach that resists a system to get into the Byzantine Generals’ problem.
    • It also means the system should stay intact even if one of the nodes (or general) fails. In addition, BFT aims to reduce the effect of malicious byzantine nodes (or general) on the network.
    • The objective of a BFT mechanism is to safeguard against the system failures by employing collective decision making (both – correct and faulty nodes) which aims to reduce to influence of the faulty nodes.

    • Types of Byzantine failures:

      Fail-stop –

      In which the node fails & stop operating

      Arbitrary Node failures

      1) Failure to return result
      2) Respond with an incorrect result
      3) Respond with a different result to different parts of the system.

    1.9.2. Proof of Work

    • Proof of Work(PoW) is the original consensus algorithm in a blockchain network.
    • The algorithm is used to confirm the transaction and creates a new block to the chain.
    • In this algorithm, minors (a group of people) compete against each other to complete the transaction on the network.
    • The process of competing against each other is called mining.
    • As soon as miners successfully created a valid block, he gets rewarded plus transaction fee.
    • The most famous application of Proof of Work(PoW) is Bitcoin.
    • The puzzles are complex & it requires massive computational power to solve them.
    • The PoW consensus protocol can summarized as follows:

      1) New transaction is broadcast to the network
      2) Miners rush to compute a hash value that matches with that of the transaction
      3) The first one to solve the hash receives the reward
      4) A new block is created which incildes the recently concluded transaction.

      Blocks with PoW

      1.9.3. Poof of Stake

      • Proof of Stake (PoS) is a type of algorithm which aims to achieve distributed consensus in a Blockchain. It is alternatives of PoW.
      • In PoS system there’s no concept of miners, specialized hardware or massive energy consumption. All we need is a regular PC.
      • A stake is value/money we bet on a certain outcome. The process is called staking.A more particular meaning of stake will be defined later on.
      • In PoS the block producers are not miner but they act like validators. They get the opportunity to create block over which saves energy and reduced the time however for them to become a validator, they supposed to invest some stake (Money) except investing in expensive hardware to solve a complex puzzle.
      • After that all validator will start validating the block which they think can be added to the chain
      • Based on the actual block added in the blockchain all the validators get a reward proportionate to their bets their stake increase accordingly.

      • Proof of work Proof of stake
        Participating nodes are called miners Participating nodes are called validators
        Mining capacity depends on computational power Validating capacity depends on stake in the network
        Mining produce new coins. No new coins are formed.
        Miners receive block rewards Validators receive transaction fees
        Massive energy consumption Low to moderate energy consumption

      1.11 Cryptocurrency

      • A new form of digital asset based on a network that is distributed across a large number of computers.
      • This decentralized structure allows them to exist outside the control of governments and central authorities.
      • The word crypto currency is derived from the encryption techniques used to secure the network.
      • Cryptocurrencies are system that allow for the secure payment online which are denominated in terms of virtual “tokens” which are represented by ledger entries internal to the system.
      • Example: Bitcoin, Litecoin, Ethereum etc.

      1.12. Digital Token

      • It is a unit of cryptographic information that is used to facilitate a real world transaction.
      • The transaction can be anything from an online money transfer to subscribing to a service.
      • Bitcoin and Ethereum are two blockchain that offer digital tokens. We can use Bitcoin as digital money whereas Ethereum ETH token.
      • Two types of Digital Token:

      • Security Token:

        It used to offer securities to the investor which can be anything from a share in the company to dividends to assets.

      • Utility Token:

        They are form of internal points that the company offers for purchasing its services or products.

No comments:

Post a Comment