KEMBAR78
Blockchain tutorial | DOCX
Blockchain
A blockchainisa constantlygrowingledgerwhichkeepsapermanentrecordof all the transactions
that have takenplace ina secure,chronological,andimmutable way.
Let's breakdown the definition,
 Ledger:It isa file thatis constantly growing.
 Permanent:Itmeansonce the transactiongoesinside ablockchain,youcanput upit
permanentlyinthe ledger.
 Secure:Blockchainplacedinformationinasecure way.Itusesveryadvancedcryptography
to make sure that the informationislockedinside the blockchain.
 Chronological:Chronological meanseverytransactionhappensafterthe previousone.
 Immutable:Itmeansasyou buildall the transactionontothe blockchain,thisledgercan
neverbe changed.
A blockchainisa chainof blockswhichcontaininformation.Eachblockrecordsall of the recent
transactions,andonce completedgoesintothe blockchainasapermanentdatabase.Eachtime a
blockgetscompleted,anewblockisgenerated.
Need of Blockchain
o Time reduction: In the financial industry, blockchain can allow the quicker
settlement of trades. It does not take a lengthy process for verification,
settlement, and clearance. It is because of a single version of agreed-upon data
available between all stakeholders.
o Unchangeable transactions: Blockchain register transactions in a chronological
order which certifies the unalterability of all operations, means when a new block
is added to the chain of ledgers, it cannot be removed or modified.
o Reliability: Blockchain certifies and verifies the identities of each interested
parties. This removes double records, reducing rates and accelerates
transactions.
o Security: Blockchain uses very advanced cryptography to make sure that the
information is locked inside the blockchain. It uses Distributed Ledger Technology
where each party holds a copy of the original chain, so the system remains
operative, even the large number of other nodes fall.
o Collaboration: It allows each party to transact directly with each other without
requiring a third-party intermediary.
o Decentralized: It is decentralized because there is no central authority
supervising anything. There are standards rules on how every node exchanges
the blockchain information. This method ensures that all transactions are
validated, and all valid transactions are added one by one.
History of Blockchain
The blockchain technology was described in 1991 by the research scientist Stuart
Haber and W. Scott Stornetta.
They wanted to introduce a computationally practical solution for time-stamping digital
documents so that they could not be backdated or tampered. They develop a system
using the concept of cryptographically secured chain of blocks to store the time-
stamped documents.
In 1992, Merkle Trees were incorporated into the design, Merkle Trees are used to
create a 'secured chain of blocks.' It stored a series of data records, and each data
records connected to the one before it. The newest record in this chain contains the
history of the entire chain.
In 2004, computer scientist and cryptographic activist Hal Finney introduced a system
called Reusable Proof Of Work(RPoW) as a prototype for digital cash.
RPoW solved the double-spending problem by keeping the ownership of tokens
registered on a trusted server.
in 2008, Satoshi Nakamoto conceptualized the theory of distributed blockchains.
He improves the design in a unique way to add blocks to the initial chain without
requiring them to be signed by trusted parties. The modified trees would contain a
secure history of data exchanges. It utilizes a peer-to-peer network for timestamping
and verifying each exchange.
The evolution of blockchains has been steady and promising. The words block and chain
were used separately in Satoshi Nakamoto's original paper but were eventually
popularized as a single word, the Blockchain, by 2016. In recent time, the file size of
cryptocurrency blockchain containing records of all transactions occurred on the network
has grown from 20 GB to 100 GB.
Problem With Centralized System :
“the concentration of control of an activity or organization under a single authority.”
Distributed Database: There is no Central Server or System which keeps the data of
Blockchain. The data is distributed over Millions of Computers around the world which are
connected with the Blockchain. This system allows Notarization of Data as it is present on
every Node and is publicly verifiable.
Distributed ledger technology (DLT).
A blockchain is a database but it differs from a traditional database in that the information
stored on it is not centralized in one location.
a record of the ledger is held by all of the participants in the chain that can verify the
provenance of all of the data that is entered. Think of it as a database without an
administrator.
A distributed ledger is a type of database that is consensually shared, replicated, and
synchronized among the members of a decentralized network. All the information on this
ledger is securely and accurately stored using cryptography. This information can be
accessed by using keys and cryptographic signatures. The distributed ledger allows
transactions to have public witnesses, which makes cyberattack more difficult. It records the
transactions such as the exchange of assets or data, among the participants in the network.
All the participants in the network govern and agreed-upon consensus on the updates to
the records in the ledger. There is no central authority, or third-party mediators such
as a financial institution or government agencies are involved. Every record in the
distributed ledger has a timestamp and unique cryptographic signature. It makes the
ledger an auditable, and immutable history of all transactions in the network.
Further, if any alterations made to the ledger, they are reflected and copied to all
participants in seconds or minutes. In other words, when any modifications or updates
happen in the ledger, each node constructs the new transaction, and then the
nodes vote by consensus algorithm on which copy is correct. Once a consensus
algorithm has been determined, all the other nodes update themselves with the new and
correct copy of the ledger.
A network of nodes: A node is a computer connected to the Blockchain Network. Node
gets connected with Blockchain using the client. Client helps in validating and propagates
transaction on to the Blockchain. When a computer connects to the Blockchain, a copy of
the Blockchain data gets downloaded into the system and the node comes in sync with the
latest block of data on Blockchain. The Node connected to the Blockchain which helps in the
execution of a Transaction in return for an incentive is called Miners.
Properties or characteristics or Building trust with Blockchain:
Blockchain builts trust through the following five attributes:
 Distributed: The distributed ledger is shared and updated with every incoming
transaction among the nodes connected to the Blockchain. All this is done in
real-time as there is no central server controlling the data.
 Secure: There is no unauthorized access to Blockchain made possible through
Permissions and Cryptography.
 Transparent: Because every node or participant in Blockchain has a copy of
the Blockchain data, they have access to all transaction data. They themselves
can verify the identities without the need for mediators.
 Consensus-based: All relevant network participants must agree that a
transaction is valid. This is achieved through the use of consensus algorithms.
 Flexible: Smart Contracts which are executed based on certain conditions can
be written into the platform. Blockchain Network can evolve in pace with
business processes.
Benefits of Blockchain Technology:
 Time-saving: No central Authority verification needed for settlements making
the process faster and cheaper.
 Cost-saving: A Blockchain network reduces expenses in several ways. No
need for third-party verification. Participants can share assets directly.
Intermediaries are reduced. Transaction efforts are minimized as every
participant has a copy of shared ledger.
 Tighter security: No one can temper with Blockchain Data as it shared among
millions of Participant. The system is safe against cybercrimes and Fraud.
Consensus –
Consensus is a process of ensuring that all the different users in a blockchain come
to an agreement regarding the current state of blockchain. There are several
consensus mechanisms that are used by different blockchains to achieve
consensus. For example, Bitcoin uses Proof-of-Work while Ethereum is moving from
Proof-of-Work to Proof-of-Stake algorithm.
Smart Contracts –
Forget smart contract and blockchain for a moment. Think about contracts in
general. These contain some conditions which need to be fulfilled in order for some
transaction (eg; money exchange) to occur. For example, if you are selling me a
laptop, a contract will contain that I will be responsible to pay you only if the laptop
works properly. Similarly, smart contracts are pre-requisite conditions which need to
be fulfilled for transactions to happen in a blockchain.
What is inside a blockchain?
A blockchain is a chain of blocks connected to each other. A block consists of four
parts:
 Previous Hash
 The timestamp
 Nonce
 Merkle tree root
 Each block contains a cryptographic hash of the data of the previous block.
 The nonce is calculated by the miners by solving a cryptographic puzzle to propose
the next block in the chain. It is known as proof of work.
 The blockchain is said to be immutable because of its cryptographic properties. But
this does not mean that changing the data is impossible. It means that it is extremely
hard to change the data and any change can be easily detected.
 A merkle tree is a binary tree with hash pointers. A merkle tree is a structure that
allows for efficient and secure verification of content in a large body of data.
 The advantage of using merkle trees is that proving membership requires O(logn)
steps. Also, in a sorted merkle tree, non-membership can also be proved in O(logn)
steps. The first block is known as the genesis block.
Types of Blockchain
There are different types of blockchains possible in the ecosystem.
1. Public –
A public blockchain is also known as permission-less blockchain.
 Here, everyone can be a part of this blockchain and can participate by running
as a node, by mining a block or by making transactions in the blockchain.
Bitcoin and Litecoin are examples of public blockchains.
 Public blockchains like Bitcoin and Ethereum
 They allow anyone to participate as users, miners, developers, or
community members. All transactions that take place on public blockchains
are fully transparent, meaning that anyone can examine the transaction
details.
 Public blockchains are designed to be fully decentralized,
2. Private
A private blockchain is also known as permissioned blockchain.
 Here, there are restrictions on the participation as only selected individuals or
member of an organisation can be a part of the blockchain.
 Multichain and Hyperledger projects (Fabric, Sawtooth) are examples of
private blockchain.
 participants need consent(permission) to join the networks
 Transactions are private and are only available to ecosystem participants
that have been given permission to join the network
 Private blockchains are more centralized than public blockchains
3. Consortium –
A consortium blockchain are said to be partially-decentralised or semi-
decentralised.
 consortium blockchains are governed by a group rather than a single
entity.
 the member organisations has the authority to participate by running as a full
node, by mining etc.
 R3 and EWF (Energy Web Foundation) are examples of consortium
blockchain.
 Participants in consortium blockchains could include anyone from central
banks, to governments, to supply chains.
What is the difference between blockchain and
cryptocurrency?
A relatable way of framing this relationship is to compare it to an application on your
phone (e.g. Uber or Whatsapp), and the platform on which that application is running
(IOS or Android). Blockchain is the platform and cryptocurrency is an application that
runs on the blockchain platform. The confusion stems in part from the fact that the
platform (blockchain) and cryptocurrency (Bitcoin) launched at the same time.
Blockchain Hash Function
 A hash function takes an input string (numbers, alphabets, media files) of any
length and transforms it into a fixed length.
 The fixed bit length can vary (like 32-bit or 64-bit or 128-bit or 256-bit)
depending on the hash function which is being used.
 The fixed-length output is called a hash. This hash is also the cryptographic
byproduct of a hash algorithm. We can understand it from the following diagram.
 Hash Functions: Map any sized data to a fixed size; Example H(x) = x % n,
where x and n are integers and % is the modular (remainder after division
by n) operations. x can be of any arbitrary length, but H(x) is within the
range [0,n-1].
 X is called the message and H(X) is called the message digest
 A small change in the data results in a significant change in the output – called
the avalanche effect
The hash algorithm has certain unique properties:
 It produces a unique output (or hash).
 It is a one-way function.
Cryptographically Secured:
• One way, given a x, we can compute H(x), but given a H(x), no deterministic
algorithm can compute x
• For two different x1 and x2, H(x1) and H(x2) should be different
Hash function algorithm Examples: MD5, SHA256(secured hashfunction algorithm)
PROPERTIES:
Collision-Free
– If two messages are different, then there digest also differs(M1 not equal to M1 then
H(M1) not equal to H(M2) )
Hash functions are one-way, given a 𝑥, it is easy to find 𝐻(𝑥), however, given a 𝐻(𝑥), no
deterministic algorithm can find 𝑥
It is difficult to find 𝑥 and 𝑦, such that 𝑥 ≠ 𝑦; however 𝐻 (𝑥) = 𝐻(𝑦)
Note the phase difficult to find, collision is not impossible
Try with random input and find collisioin – but, it take time
Hiding
– Hide the original message; remember about the avalanche effect
Given a 𝐻(𝑥), it is “computationally difficult” to find 𝑥
The difficulty depends on the size of the message digests
Hiding helps to commit a value and then check it later
1. Computing the message digest and store it in a digest store – commit
2. To check whether a message has been committed, match the message digest at the
digest store.
PUZZLE FRIENDLY
If X and Y , find out K such that Y=H(X||K) used to solve the mining puzzle in bitcoin POW
HASHCHAIN
the repeated application of a cryptographic hash function to a given data asset.
This type of hash cryptography can be extremely useful in some specific security setups. By
providing a successive chain, hash chains make it harder for a snooping hacker to hijack a
data asset through applying a single input.
HashChain Technology Inc. (TSXV:KASH, OTCQB:HSSHF) is a blockchain technology company
dedicated to blockchain-related business and services, including mining various
cryptocurrencies through proprietary technology, a blockchain tax software solution and
masternode Hosting services.
Markel tree :
It is a mathematical data structure composed of hashes of different blocks of data, and
which serves as a summary of all the transactions in a block.
It also allows for efficient and secure verification of content in a large body of data. It
also helps to verify the consistency and content of the data.
Both Bitcoin and Ethereum use Merkle Trees structure.
How do Merkle trees work?
 A Merkle tree stores all the transactions in a block by producing a digital
fingerprint of the entire set of transactions. It allows the user to verify whether a
transaction can be included in a block or not.
 Merkle trees are created by repeatedly calculating hashing pairs of nodes until there
is only one hash left. This hash is called the Merkle Root, or the Root Hash. The
Merkle Trees are constructed in a bottom-up approach.
 Every leaf node is a hash of transactional data, and the non-leaf node is a hash of
its previous hashes.
 Merkle trees are in a binary tree, so it requires an even number of leaf nodes. If
there is an odd number of transactions, the last hash will be duplicated once to
create an even number of leaf nodes.
Merkle Root is stored in the block header. The block header is the part of the bitcoin
block which gets hash in the process of mining. It contains the hash of the last block, a
Nonce, and the Root Hash of all the transactions in the current block in a Merkle Tree.
Merkle trees have three benefits:
o It provides a means to maintain the integrity and validity of data.
o It helps in saving the memory or disk space as the proofs, computationally easy
and fast.
o Their proofs and management require tiny amounts of information to be
transmitted across networks.
BITCOIN
A bitcoin is a type of digital assets which can be bought, sold, and transfer between the
two parties securely over the internet.
We can also use bitcoin to buy products and services as well as make payments and
exchange values electronically.
How Bitcoin Works?
When you send an email to another person, you just type an email address and can
communicate directly to that person. It is the same thing when you send an instant
message. This type of communication between two parties is commonly known as Peer-
to-Peer communication.
Whenever you want to transfer money to someone over the internet, you need to use a
service of third-party such as banks, a credit card, a PayPal, or some other type of
money transfer services. The double-spend problem provides a challenge to determine
whether a transaction is real or not. How you can send a bitcoin to someone over the
internet without needing a bank or some other institution to certify the transfer took
place.
Key Concepts of Bitcoin
There are four key concepts that you need to aware in Bitcoin. These are:
o Disintermediated : i.e. don’t need third party to make transection over the
internet for verification purpose ( peer to peer )
o Distributed : i.e. bitcoin n/w run over the n/w of thousands of computer instead
of having one centralized comp. which handle workload
o Decentralized : i.e. there is no central control, no central repository of data and
no management in the middle
o Trustless : i.e. bcs no need to have a third-party, such as a bank to certify and
bring trust to the entire process of transactions.
DIGITAL SIGNATURE :
A digital signature is a mathematical technique used to validate the authenticity and integrity
of a message, software or digital document.
Digital signature are electronic signatures, which assures that the message was sent by a
particular sender. While performing digital transactions authenticity and integrity should be
assured, otherwise the data can be altered or someone can also act as if he was the sender
and expect a reply.
signing Algorithms:
To create a digital signature,
signing algorithms like email programs create a one-way hash of the electronic data which is
to be signed.
signing algorithms like email programs create a one-way hash of the electronic data which is
to be signed.
This encrypted hash along with other information like the hashing algorithm is the digital
signature.
This digital signature is appended with the data and sent to the verifier.
This saves time as now instead of signing a long message a shorter hash value has to be
signed and moreover hashing is much faster than signing.
Signature Verification Algorithms :
Verifier receives Digital Signature along with the data. It then uses Verification algorithm to
process on the digital signature and the public key (verification key) and generates some
value.
It also applies the same hash function on the received data and generates a hash value.
Then the hash value and the output of the verification algorithm are compared. If they both
are equal, then the digital signature is valid else it is invalid.
The steps followed in creating digital signature are :
1. Message digest is computed by applying hash function on the message and then
message digest is encrypted using private key of sender to form the digital signature.
digital signature = encryption (private key of sender, message digest)
2. Digital signature is then transmitted with the message.
message + digital signature is transmitted
3. Receiver decrypts the digital signature using the public key of sender
4. The receiver now has the message digest.
5. And check validity as above given
What Is a Consensus Mechanism?
A consensus mechanism is a fault-tolerant mechanism that is used in computer and
blockchain systems to achieve the necessary agreement on a single data value or a single
state of the network among distributed processes or multi-agent systems, such as with
cryptocurrencies.
There are different kinds of consensus mechanism algorithms which work on different principles.
proof of work (POW)
proof of stake (POS)
Proof of Capacity (POC)
Ethereumis a Blockchain network that introduced a built-in Turing-complete programming
language which can be used for creating various decentralized applications(also called
Dapps). The ethereum network is fueled by its own cryptocurrency called ‘ether’. The
ethereum network is currently famous for allowing the implementation of smart contracts.
Smart contracts can be thought of as ‘cryptographic bank lockers’ which contain certain
values. These cryptographic lockers can only be unlocked when certain conditions are met.
The smart contracts are created mainly using a programming language called solidity.
Solidity is an Object Oriented Programming language which is comparatively easy to learn.
Ethereum has two types of accounts: Externally owned account (EOA), and
Contract account. These are explained as following below.
 Externally owned account (EOA):
Externally owned accounts are controlled by private keys. Each EOA has a
public-private key pair. The users can send messages by creating and signing
transactions.
 Contract Account:
Contract accounts are controlled by contract codes. These codes are stored
with the account. Each contract account has an ether balance associated with
it. The contract code of these accounts get activated every time a transaction
from an EOA or a message from another contract is received by it. When the
contract code activates, it allows to read/write the message to the local storage,
send messages and create contracts.
Blockchain tutorial

Blockchain tutorial

  • 1.
    Blockchain A blockchainisa constantlygrowingledgerwhichkeepsapermanentrecordofall the transactions that have takenplace ina secure,chronological,andimmutable way. Let's breakdown the definition,  Ledger:It isa file thatis constantly growing.  Permanent:Itmeansonce the transactiongoesinside ablockchain,youcanput upit permanentlyinthe ledger.  Secure:Blockchainplacedinformationinasecure way.Itusesveryadvancedcryptography to make sure that the informationislockedinside the blockchain.  Chronological:Chronological meanseverytransactionhappensafterthe previousone.  Immutable:Itmeansasyou buildall the transactionontothe blockchain,thisledgercan neverbe changed. A blockchainisa chainof blockswhichcontaininformation.Eachblockrecordsall of the recent transactions,andonce completedgoesintothe blockchainasapermanentdatabase.Eachtime a blockgetscompleted,anewblockisgenerated. Need of Blockchain
  • 2.
    o Time reduction:In the financial industry, blockchain can allow the quicker settlement of trades. It does not take a lengthy process for verification, settlement, and clearance. It is because of a single version of agreed-upon data available between all stakeholders. o Unchangeable transactions: Blockchain register transactions in a chronological order which certifies the unalterability of all operations, means when a new block is added to the chain of ledgers, it cannot be removed or modified. o Reliability: Blockchain certifies and verifies the identities of each interested parties. This removes double records, reducing rates and accelerates transactions. o Security: Blockchain uses very advanced cryptography to make sure that the information is locked inside the blockchain. It uses Distributed Ledger Technology where each party holds a copy of the original chain, so the system remains operative, even the large number of other nodes fall. o Collaboration: It allows each party to transact directly with each other without requiring a third-party intermediary. o Decentralized: It is decentralized because there is no central authority supervising anything. There are standards rules on how every node exchanges the blockchain information. This method ensures that all transactions are validated, and all valid transactions are added one by one. History of Blockchain The blockchain technology was described in 1991 by the research scientist Stuart Haber and W. Scott Stornetta. They wanted to introduce a computationally practical solution for time-stamping digital documents so that they could not be backdated or tampered. They develop a system using the concept of cryptographically secured chain of blocks to store the time- stamped documents. In 1992, Merkle Trees were incorporated into the design, Merkle Trees are used to create a 'secured chain of blocks.' It stored a series of data records, and each data records connected to the one before it. The newest record in this chain contains the history of the entire chain.
  • 3.
    In 2004, computerscientist and cryptographic activist Hal Finney introduced a system called Reusable Proof Of Work(RPoW) as a prototype for digital cash. RPoW solved the double-spending problem by keeping the ownership of tokens registered on a trusted server. in 2008, Satoshi Nakamoto conceptualized the theory of distributed blockchains. He improves the design in a unique way to add blocks to the initial chain without requiring them to be signed by trusted parties. The modified trees would contain a secure history of data exchanges. It utilizes a peer-to-peer network for timestamping and verifying each exchange. The evolution of blockchains has been steady and promising. The words block and chain were used separately in Satoshi Nakamoto's original paper but were eventually popularized as a single word, the Blockchain, by 2016. In recent time, the file size of cryptocurrency blockchain containing records of all transactions occurred on the network has grown from 20 GB to 100 GB. Problem With Centralized System : “the concentration of control of an activity or organization under a single authority.”
  • 4.
    Distributed Database: Thereis no Central Server or System which keeps the data of Blockchain. The data is distributed over Millions of Computers around the world which are connected with the Blockchain. This system allows Notarization of Data as it is present on every Node and is publicly verifiable. Distributed ledger technology (DLT). A blockchain is a database but it differs from a traditional database in that the information stored on it is not centralized in one location. a record of the ledger is held by all of the participants in the chain that can verify the provenance of all of the data that is entered. Think of it as a database without an administrator. A distributed ledger is a type of database that is consensually shared, replicated, and synchronized among the members of a decentralized network. All the information on this ledger is securely and accurately stored using cryptography. This information can be accessed by using keys and cryptographic signatures. The distributed ledger allows transactions to have public witnesses, which makes cyberattack more difficult. It records the transactions such as the exchange of assets or data, among the participants in the network. All the participants in the network govern and agreed-upon consensus on the updates to the records in the ledger. There is no central authority, or third-party mediators such as a financial institution or government agencies are involved. Every record in the distributed ledger has a timestamp and unique cryptographic signature. It makes the ledger an auditable, and immutable history of all transactions in the network. Further, if any alterations made to the ledger, they are reflected and copied to all participants in seconds or minutes. In other words, when any modifications or updates happen in the ledger, each node constructs the new transaction, and then the nodes vote by consensus algorithm on which copy is correct. Once a consensus algorithm has been determined, all the other nodes update themselves with the new and correct copy of the ledger. A network of nodes: A node is a computer connected to the Blockchain Network. Node gets connected with Blockchain using the client. Client helps in validating and propagates
  • 5.
    transaction on tothe Blockchain. When a computer connects to the Blockchain, a copy of the Blockchain data gets downloaded into the system and the node comes in sync with the latest block of data on Blockchain. The Node connected to the Blockchain which helps in the execution of a Transaction in return for an incentive is called Miners. Properties or characteristics or Building trust with Blockchain: Blockchain builts trust through the following five attributes:  Distributed: The distributed ledger is shared and updated with every incoming transaction among the nodes connected to the Blockchain. All this is done in real-time as there is no central server controlling the data.  Secure: There is no unauthorized access to Blockchain made possible through Permissions and Cryptography.  Transparent: Because every node or participant in Blockchain has a copy of the Blockchain data, they have access to all transaction data. They themselves can verify the identities without the need for mediators.  Consensus-based: All relevant network participants must agree that a transaction is valid. This is achieved through the use of consensus algorithms.  Flexible: Smart Contracts which are executed based on certain conditions can be written into the platform. Blockchain Network can evolve in pace with business processes. Benefits of Blockchain Technology:  Time-saving: No central Authority verification needed for settlements making the process faster and cheaper.
  • 6.
     Cost-saving: ABlockchain network reduces expenses in several ways. No need for third-party verification. Participants can share assets directly. Intermediaries are reduced. Transaction efforts are minimized as every participant has a copy of shared ledger.  Tighter security: No one can temper with Blockchain Data as it shared among millions of Participant. The system is safe against cybercrimes and Fraud.
  • 7.
    Consensus – Consensus isa process of ensuring that all the different users in a blockchain come to an agreement regarding the current state of blockchain. There are several consensus mechanisms that are used by different blockchains to achieve consensus. For example, Bitcoin uses Proof-of-Work while Ethereum is moving from Proof-of-Work to Proof-of-Stake algorithm. Smart Contracts – Forget smart contract and blockchain for a moment. Think about contracts in general. These contain some conditions which need to be fulfilled in order for some transaction (eg; money exchange) to occur. For example, if you are selling me a laptop, a contract will contain that I will be responsible to pay you only if the laptop works properly. Similarly, smart contracts are pre-requisite conditions which need to be fulfilled for transactions to happen in a blockchain. What is inside a blockchain? A blockchain is a chain of blocks connected to each other. A block consists of four parts:  Previous Hash  The timestamp  Nonce  Merkle tree root  Each block contains a cryptographic hash of the data of the previous block.
  • 8.
     The nonceis calculated by the miners by solving a cryptographic puzzle to propose the next block in the chain. It is known as proof of work.  The blockchain is said to be immutable because of its cryptographic properties. But this does not mean that changing the data is impossible. It means that it is extremely hard to change the data and any change can be easily detected.  A merkle tree is a binary tree with hash pointers. A merkle tree is a structure that allows for efficient and secure verification of content in a large body of data.  The advantage of using merkle trees is that proving membership requires O(logn) steps. Also, in a sorted merkle tree, non-membership can also be proved in O(logn) steps. The first block is known as the genesis block. Types of Blockchain There are different types of blockchains possible in the ecosystem. 1. Public – A public blockchain is also known as permission-less blockchain.  Here, everyone can be a part of this blockchain and can participate by running as a node, by mining a block or by making transactions in the blockchain. Bitcoin and Litecoin are examples of public blockchains.  Public blockchains like Bitcoin and Ethereum  They allow anyone to participate as users, miners, developers, or community members. All transactions that take place on public blockchains are fully transparent, meaning that anyone can examine the transaction details.  Public blockchains are designed to be fully decentralized, 2. Private A private blockchain is also known as permissioned blockchain.  Here, there are restrictions on the participation as only selected individuals or member of an organisation can be a part of the blockchain.  Multichain and Hyperledger projects (Fabric, Sawtooth) are examples of private blockchain.  participants need consent(permission) to join the networks  Transactions are private and are only available to ecosystem participants that have been given permission to join the network  Private blockchains are more centralized than public blockchains 3. Consortium – A consortium blockchain are said to be partially-decentralised or semi- decentralised.  consortium blockchains are governed by a group rather than a single entity.  the member organisations has the authority to participate by running as a full node, by mining etc.  R3 and EWF (Energy Web Foundation) are examples of consortium blockchain.  Participants in consortium blockchains could include anyone from central banks, to governments, to supply chains.
  • 9.
    What is thedifference between blockchain and cryptocurrency? A relatable way of framing this relationship is to compare it to an application on your phone (e.g. Uber or Whatsapp), and the platform on which that application is running (IOS or Android). Blockchain is the platform and cryptocurrency is an application that runs on the blockchain platform. The confusion stems in part from the fact that the platform (blockchain) and cryptocurrency (Bitcoin) launched at the same time. Blockchain Hash Function  A hash function takes an input string (numbers, alphabets, media files) of any length and transforms it into a fixed length.  The fixed bit length can vary (like 32-bit or 64-bit or 128-bit or 256-bit) depending on the hash function which is being used.  The fixed-length output is called a hash. This hash is also the cryptographic byproduct of a hash algorithm. We can understand it from the following diagram.  Hash Functions: Map any sized data to a fixed size; Example H(x) = x % n, where x and n are integers and % is the modular (remainder after division by n) operations. x can be of any arbitrary length, but H(x) is within the range [0,n-1].  X is called the message and H(X) is called the message digest  A small change in the data results in a significant change in the output – called the avalanche effect The hash algorithm has certain unique properties:  It produces a unique output (or hash).  It is a one-way function. Cryptographically Secured: • One way, given a x, we can compute H(x), but given a H(x), no deterministic algorithm can compute x • For two different x1 and x2, H(x1) and H(x2) should be different Hash function algorithm Examples: MD5, SHA256(secured hashfunction algorithm)
  • 10.
    PROPERTIES: Collision-Free – If twomessages are different, then there digest also differs(M1 not equal to M1 then H(M1) not equal to H(M2) ) Hash functions are one-way, given a 𝑥, it is easy to find 𝐻(𝑥), however, given a 𝐻(𝑥), no deterministic algorithm can find 𝑥 It is difficult to find 𝑥 and 𝑦, such that 𝑥 ≠ 𝑦; however 𝐻 (𝑥) = 𝐻(𝑦) Note the phase difficult to find, collision is not impossible Try with random input and find collisioin – but, it take time Hiding – Hide the original message; remember about the avalanche effect Given a 𝐻(𝑥), it is “computationally difficult” to find 𝑥 The difficulty depends on the size of the message digests Hiding helps to commit a value and then check it later 1. Computing the message digest and store it in a digest store – commit 2. To check whether a message has been committed, match the message digest at the digest store.
  • 11.
    PUZZLE FRIENDLY If Xand Y , find out K such that Y=H(X||K) used to solve the mining puzzle in bitcoin POW HASHCHAIN the repeated application of a cryptographic hash function to a given data asset. This type of hash cryptography can be extremely useful in some specific security setups. By providing a successive chain, hash chains make it harder for a snooping hacker to hijack a data asset through applying a single input. HashChain Technology Inc. (TSXV:KASH, OTCQB:HSSHF) is a blockchain technology company dedicated to blockchain-related business and services, including mining various cryptocurrencies through proprietary technology, a blockchain tax software solution and masternode Hosting services.
  • 12.
    Markel tree : Itis a mathematical data structure composed of hashes of different blocks of data, and which serves as a summary of all the transactions in a block. It also allows for efficient and secure verification of content in a large body of data. It also helps to verify the consistency and content of the data. Both Bitcoin and Ethereum use Merkle Trees structure. How do Merkle trees work?  A Merkle tree stores all the transactions in a block by producing a digital fingerprint of the entire set of transactions. It allows the user to verify whether a transaction can be included in a block or not.  Merkle trees are created by repeatedly calculating hashing pairs of nodes until there is only one hash left. This hash is called the Merkle Root, or the Root Hash. The Merkle Trees are constructed in a bottom-up approach.  Every leaf node is a hash of transactional data, and the non-leaf node is a hash of its previous hashes.  Merkle trees are in a binary tree, so it requires an even number of leaf nodes. If there is an odd number of transactions, the last hash will be duplicated once to create an even number of leaf nodes. Merkle Root is stored in the block header. The block header is the part of the bitcoin block which gets hash in the process of mining. It contains the hash of the last block, a Nonce, and the Root Hash of all the transactions in the current block in a Merkle Tree. Merkle trees have three benefits:
  • 13.
    o It providesa means to maintain the integrity and validity of data. o It helps in saving the memory or disk space as the proofs, computationally easy and fast. o Their proofs and management require tiny amounts of information to be transmitted across networks. BITCOIN A bitcoin is a type of digital assets which can be bought, sold, and transfer between the two parties securely over the internet. We can also use bitcoin to buy products and services as well as make payments and exchange values electronically. How Bitcoin Works? When you send an email to another person, you just type an email address and can communicate directly to that person. It is the same thing when you send an instant message. This type of communication between two parties is commonly known as Peer- to-Peer communication. Whenever you want to transfer money to someone over the internet, you need to use a service of third-party such as banks, a credit card, a PayPal, or some other type of money transfer services. The double-spend problem provides a challenge to determine whether a transaction is real or not. How you can send a bitcoin to someone over the internet without needing a bank or some other institution to certify the transfer took place. Key Concepts of Bitcoin There are four key concepts that you need to aware in Bitcoin. These are: o Disintermediated : i.e. don’t need third party to make transection over the internet for verification purpose ( peer to peer ) o Distributed : i.e. bitcoin n/w run over the n/w of thousands of computer instead of having one centralized comp. which handle workload o Decentralized : i.e. there is no central control, no central repository of data and no management in the middle o Trustless : i.e. bcs no need to have a third-party, such as a bank to certify and bring trust to the entire process of transactions.
  • 14.
    DIGITAL SIGNATURE : Adigital signature is a mathematical technique used to validate the authenticity and integrity of a message, software or digital document. Digital signature are electronic signatures, which assures that the message was sent by a particular sender. While performing digital transactions authenticity and integrity should be assured, otherwise the data can be altered or someone can also act as if he was the sender and expect a reply. signing Algorithms: To create a digital signature, signing algorithms like email programs create a one-way hash of the electronic data which is to be signed. signing algorithms like email programs create a one-way hash of the electronic data which is to be signed. This encrypted hash along with other information like the hashing algorithm is the digital signature. This digital signature is appended with the data and sent to the verifier. This saves time as now instead of signing a long message a shorter hash value has to be signed and moreover hashing is much faster than signing. Signature Verification Algorithms : Verifier receives Digital Signature along with the data. It then uses Verification algorithm to process on the digital signature and the public key (verification key) and generates some value. It also applies the same hash function on the received data and generates a hash value. Then the hash value and the output of the verification algorithm are compared. If they both are equal, then the digital signature is valid else it is invalid. The steps followed in creating digital signature are :
  • 15.
    1. Message digestis computed by applying hash function on the message and then message digest is encrypted using private key of sender to form the digital signature. digital signature = encryption (private key of sender, message digest) 2. Digital signature is then transmitted with the message. message + digital signature is transmitted 3. Receiver decrypts the digital signature using the public key of sender 4. The receiver now has the message digest. 5. And check validity as above given What Is a Consensus Mechanism? A consensus mechanism is a fault-tolerant mechanism that is used in computer and blockchain systems to achieve the necessary agreement on a single data value or a single state of the network among distributed processes or multi-agent systems, such as with cryptocurrencies. There are different kinds of consensus mechanism algorithms which work on different principles. proof of work (POW) proof of stake (POS) Proof of Capacity (POC) Ethereumis a Blockchain network that introduced a built-in Turing-complete programming language which can be used for creating various decentralized applications(also called Dapps). The ethereum network is fueled by its own cryptocurrency called ‘ether’. The ethereum network is currently famous for allowing the implementation of smart contracts. Smart contracts can be thought of as ‘cryptographic bank lockers’ which contain certain values. These cryptographic lockers can only be unlocked when certain conditions are met. The smart contracts are created mainly using a programming language called solidity. Solidity is an Object Oriented Programming language which is comparatively easy to learn. Ethereum has two types of accounts: Externally owned account (EOA), and Contract account. These are explained as following below.
  • 16.
     Externally ownedaccount (EOA): Externally owned accounts are controlled by private keys. Each EOA has a public-private key pair. The users can send messages by creating and signing transactions.  Contract Account: Contract accounts are controlled by contract codes. These codes are stored with the account. Each contract account has an ether balance associated with it. The contract code of these accounts get activated every time a transaction from an EOA or a message from another contract is received by it. When the contract code activates, it allows to read/write the message to the local storage, send messages and create contracts.