You are on page 1of 69

UNIT-I

UNIT-I

Introduction To Blockchain: Basics of Block chain, Block chain Components,


structure and operational aspects of Bitcoin block chain, and compare different
types of block chains, Basic crypto primitives: Hash, Signature, Hash chain to
Block chain, Cryptographic Hash Functions, Merkle Tree, Block chain
Architecture and Design, Conceptualization.

Bitcoin: Create Coin, Sending Payment, Double Spending, Transactions.

Basics of Blockchain

Basic Components of A Blockchain Network

Appearing on the 4.0 technology market in the past few years, Blockchain
technology is emerging with great developments in daily activities in many areas
of socio-economic life and gradually becoming a new trend in the global
technology and investment market. This technology has the potential to bring
efficiency not only in terms of information but also to help improve operating
systems in many organizations/enterprises. Vietnam is no exception to this trend.
Therefore, it is very necessary to learn about Blockchain, especially the young
generation in Vietnam.
Normally, a Blockchain platform are formed by 5 components, including:

• 1. Distributed Ledger
• 2. Peer-to-peer network – P2P
• 3. Consensus Mechanism
• 4. Cryptography
• 5. Virtual Machine

1. Distributed Ledger

Definition
An electronic ledger is essentially a database containing all transactions that are
constantly updated. It is composed of multiple blocks (each containing at least one
transaction) and these blocks are linked together into a chain using cryptography.
In other words, the following block will contain the cryptographic identifiers of the
previous block. So, if any block in the past has a problem, it will affect all the
blocks at the back of the chain.

Highlights

• A Ledger eliminate the central authority to process and validate transactions


• Data records are only stored in the ledger when the stakeholders reach a consensus
• All participants will be shared 1 copy of the ledger including all updated records
• A ledger provides a verifiable and trackable history of all information chronologically
stored on a particular data set.

2. Peer-to-peer network – P2P

Definition
A Peer-to-peer network (P2P) is a decentralized model to communicate between
many participants also known as peer nodes without any central servers or
dependence on any other nodes. A P2P network allows each party to act as both a
client and a server. This means that after the network is formed, all participants
own a copy of the ledger. From there it can be used to share and store files without
the help of an Intermediary.

Highlights
• On a Blockchain network, each node flexibly participates in the role of a client and a
server of other nodes to jointly provide and control data
• Decentralizing database and management rights eliminates the intermediary in
traditional models, which allows members to directly exchange information with each
other
• All records of data are copied by all nodes to ensure the continuity of the system
operation and limit single point failures (SPOF) and denial of service (DoS)
• Improving availability for both data and methods of validating helps the system to
avoid information loss or inability to verify.

Classification

• Unstructured P2P Network


• Structured P2P Network
• Hybrid P2P Network

3. Consensus Mechanism

Definition
The consensus mechanism prescribes sets of rules so that nodes participating in the
peer-to-peer network can work in sync and agree on which transactions are
legitimate and able to be added to the blockchain. The consensus mechanism is
used to determine the actual state of the blockchain.

Highlights

• Ensure the entire system is fault tolerant to achieve the desired agreement of a single
data value or a single network status
• Create a way for all participants to maintain the safety and security of the Blockchain
network.
• Prevent double-spending on the Blockchain for cryptocurrency transactions on the
Blockchain platform.

Classification
Each type of Blockchain will have a different consensus mechanism. Currently,
there are two types of consensus mechanisms most commonly used

• Proof-of-work (PoW): The PoW algorithm is operated by miners (nodes) working


together to solve a cryptographic problem to generate the next block. The first miner to
find the solution will reach consensus, be allowed to choose the block to be added to
the Blockchain network, and receive the corresponding award. However, these
problems are often complex and require miners to have high computing power.
• Proof-of-stake (PoS): To simplify the mining process, the term of PoS is used when
multiple tokens need to be verified. The PoS rule requires miners to prove their
ownership of % shares in order to perform the corresponding % of mining activity.
This saves more energy (electronics) and operating costs.

4. Cryptography

Definition
This component ensures the security, integrity and verification of the information
in the ledger or the information transmitted between the nodes. By building on a
foundation of mathematics (especially probability theory) along with knowledge of
game theory, cryptography has come up with encryption methods that are
impossible to break.

Classification
There are two main types of encryption methods:

• Symmetric Encryption: is a form of encryption to secure data, in which the encryption


and decryption of data use the same key. Since the key is used to decrypt the data, it
should be kept secret. Therefore, when using a symmetric key, the sender and receiver
need a mechanism to exchange keys before exchanging data

• Asymmetric Encryption: is a form of encryption to secure data, in which the encryption


and decryption of data uses two different keys. The key used to encrypt data is called a
public key, which can be shared widely and seen as a person’s identity. The key used
to decrypt data is called a private key, which is necessary for security to protect the
rights of the receiver.

Relevant Techniques

• Blockchain address: is represented as a long string of alphanumeric characters, which


is publicly shared so other users can send transactions. Each Blockchain address will
be generated from a public key. This public key is generated from a private key that
serves as a mechanism to prove ownership of the public key (or in other words, the
Blockchain address). When performing an interactive transaction with the Blockchain
network, the user will use the private key to sign a digital signature, proving that the
user is the owner of the valid Blockchain address in the transaction.
• Digital Signature: is an encrypted string of characters sent with the original data of the
transaction on the Blockchain platform. To create a digital signature, the user will use a
private key to encrypt (called digital signature) the data contained in the transaction
sent to the recipient. Remeber that the secret key used for this encryption is the secret
key that generates the sender’s Blockchain address. The digital signature will change if
the transaction data used for encryption changes, or in the case of the same data, but
using a different user’s private key.
• Hash function: is the process of converting an unlimited amount of input data and
creating a fixed length of output data. Hash functions are often used to protect the
integrity of data. Users can verify the validity of a transaction by comparing the hash
value of the transaction on the application with the hash value of the transaction on the
block explorer.

5. Virtual Machine
Definition
A virtual machine is a program that simulates a computer system. It has a CPU,
memory and virtual storage. Basically, a virtual machine works like a physical
computer, it can be used to store data, run application programs, and exist to jointly
operate a Blockchain network with other virtual machines.

Ethereum Virtual Machine (EVM)


The Ethereum virtual machine is used to ensure that transactions processed on
completely different environments and computer configurations will always create
the same results on the Ethereum platform. Essentially, an EVM is a machine that
processes smart contracts running on the Ethereum.

Nodes participating in the Ethereum system process transactions received through


the EVM. Any transaction that wants to change the status of network must go
through the process of the EVM. EVM is just a virtual machine but many copies
are made. Each node participating in the execution of the same transactions owns a
copy of the EVM to ensure the consistency of the computation.

Extension
It can be seen that the knowledge of Blockchain technology is extremely vast.
Therefore, to be able to effectively implement the necessary Blockchain
applications/solutions, organizations/enterprises in Vietnam need to have a deep
understanding of Blockchain technology and application potential to be able to
catch up with the most developing trends of the world technology market, get
closer to Blockchain technology projects and researches in Vietnam.

Types of Blockchain

The basic application of the blockchain is to perform transactions in a secure


network. That’s why people use blockchain and ledger technology in different
scenarios. One can set up multichain to prevent unauthorized access to sensitive
data. It is not available to the public, and can only be available to authorized
entities in the organization. It depends on the organization which type it requires to
choose for their work.

By using blockchain we can track orders and payments from end to end.
Advantage using blockchain :

It provides greater trust among users.

It provides greater security among data.

Reduce the cost of production.

Improve Speed.

Invocation and tokenization.

It provides immutable records.

Smart contracts

Disadvantages using blockchain :

Data modification is not possible.

It requires large storage for a large database.

The owner cannot access the private key again if they forget or lose it.

Real life application of blockchain :

Here is a list of real world problem where we can use blockchain :

In a secure and full-proof voting management system.

To supply chain management.

In healthcare management.

Real estate project.

NFT marketplace.

Avoid copyright and original content creation.

In the personal identity system


To make an immutable data backup.

Internet of Things

Permissionless Blockchain

It is also known as trustless or public blockchains, are available to everyone to


participate in the blockchains process that use to validate transactions and data.
These are used in the network where high transparency is required.

Characteristics:

Permissionless blockchain has no central authority.

The platform is completely open-source.

Full transparency of the transaction.

Heavy use of tokens.

Advantages:

Everyone can participate only requirement is good hardware and internet.

Bring trust among users or entities.

It has a high level of transparency as it’s a larger network.

Broader decentralization of access to more participants.

Disadvantages:

Poor energy efficiency due to large network.


Lower performance scalability.

Less privacy as many of the things is visible.

Permissioned Blockchain

These are the closed network only a set of groups are allowed to validate
transactions or data in a given blockchain network. These are used in the network
where high privacy and security are required.

Characteristics:

A major feature is a transparency based on the objective of the organization.

Another feature is the lack of anatomy as only a limited number of users are
allowed.

It does not have a central authority.

Developed by private authority.

Advantages:

This blockchain tends to be faster as it has some nodes for validations.

They can offer customizability.

Strong Privacy as permission is needed for accessing transaction information.

As few nodes are involved performance and scalability are increased.

Disadvantages:
Not truly decentralized as it requires permission

Risk of corruption as only a few participants are involved.

Anytime owner and operator can change the rules as per their need.

Types of Blockchain

There are 4 types of blockchain:

Public Blockchain.

Private Blockchain.

Hybrid Blockchain.

Consortium Blockchain.

Types of Blockchain

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. Hybrid Blockchain

It is the mixed content of the private and public blockchain, where some part is
controlled by some organization and other makes are made visible as a public
blockchain.

It is a combination of both public and private blockchain.

Permission-based and permissionless systems are used.

User access information via smart contracts

Even a primary entity owns a hybrid blockchain it cannot alter the transaction

Advantages:

Ecosystem: Most advantageous thing about this blockchain is its hybrid nature. It
cannot be hacked as 51% of users don’t have access to the network

Cost: Transactions are cheap as only a few nodes verify the transaction. All the
nodes don’t carry the verification hence less computational cost.

Architecture: It is highly customizable and still maintains integrity, security, and


transparency.

Operations: It can choose the participants in the blockchain and decide which
transaction can be made public.
Disadvantages:

Efficiency: Not everyone is in the position to implement a hybrid Blockchain. The


organization also faces some difficulty in terms of efficiency in maintenance.

Transparency: There is a possibility that someone can hide information from the
user. If someone wants to get access through a hybrid blockchain it depends on the
organization whether they will give or not.

Ecosystem: Due to its closed ecosystem this blockchain lacks the incentives for
network participation.

Use Case: It provides a greater solution to the health care industry, government,
real estate, and financial companies. It provides a remedy where data is to be
accessed publicly but needs to be shielded privately. Examples of Hybrid
Blockchain are Ripple network and XRP token.

4. Consortium 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. The high speed makes
this more usable for organizations.
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.

Flexible: There is much divergence in the flexibility of the blockchain. Since it is


not a very large decision can be taken faster.

Disadvantages:

Approval: All the members approve the protocol making it less flexible. 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.

CRYPTOPRIMITIVES:

Blockchain Hash Function


A hash function is a mathematical function that takes an input string of any length
and converts it to a fixed-length output string. The fixed-length output is known
as the hash value. To be cryptographically secure and useful, a hash function
should have the following properties:
• Collision resistant: Give two messages m1 and m2, it is difficult to find a
hash value such that hash(k, m1) = hash(k, m2) where k is the key value.
• Preimage resistance: Given a hash value h, it is difficult to find a message m
such that h = hash(k, m).
• Second preimage resistance: Given a message m1, it is difficult to find
another message m2 such that hash(k, m1) = hash(k, m2).
• Large output space: The only way to find a hash collision is via a brute force
search, which requires checking as many inputs as the hash function has
possible outputs.
• Deterministic: A hash function must be deterministic, which means that for
any given input a hash function must always give the same result.
• Avalanche Effect: This means for a small change in the input, the output will
change significantly.
• Puzzle Friendliness: This means even if one gets to know the first 200 bytes,
one cannot guess or determine the next 56 bytes.
• Fixed-length Mapping: For any input of fixed length, the hash function will
always generate the output of the same length.

How do Hash Functions work?

The hash function takes the input of variable lengths and returns outputs of fixed
lengths. In cryptographic hash functions, the transactions are taken as inputs and
the hash algorithm gives an output of a fixed size.
The below diagram shows how hashes work.

Types of Cryptographic Hash Functions


There are several different classes of hash functions. Some of the popular classes
are:
1. RACE Integrity Primitives Evaluation Message Digest (RIPEMD): This set
includes RIPEMD, RIPEMD-128, RIPEMD-160, RIPEMD-256, RIPEMD-320.
• Out of these RIPEMD-160 is the most common.
• The original RIPEMD-128 is based on the design principles used in MD4.
• The RIPEMD-256 and 320 have fewer chances of the accidental collision but
do not have higher levels of security as compared to RIPEMD-128 and
RIPEMD-160.
2. Message-Digest Algorithm: This family comprises hash functions MD2,
MD4, MD5, and MD6.
• MD5 is the most widely used cryptographic hash function.
• It is used to generate a 128-bit digest from a 512-bit string broken down into
16 words composed of 32 bits each.
• Ronald Rivest designed this algorithm in 1991 to use for digital signature
verification.
• These are no longer considered cryptographically secure methods and should
not be used for cryptographic authentication.
3. BLAKE2: It was announced on December 21, 2012.BLAKE2 is a
cryptographic hash function based on BLAKE, designed with the aim to replace
MD5 and SHA-1 algorithms in applications requiring high performance in
software. It provides better security than SHA-2 and is similar to that of SHS-3. It
provides the following features:
• It provides immunity to length extensions.
• It removes the addition of constants to message words.
• It simplifies padding and reduces the number of rounds from 16 to 12.
4. BLAKE3: It was announced on January 9, 2020. BLAKE3 is a cryptographic
function based on Bao and BLAKE2. It is a few times faster than BLAKE2. This
algorithm provides many features like parallelism, XOF, KDF, etc.
5. Whirlpool: It is a cryptographic hash function, first described in 2000. It is a
modified version of the Advanced Encryption Standard (AES). Whirlpool
produces a hash of 512 bits.
6. Secure Hashing Algorithm: The family of SHA comprises four SHA
algorithms: SHA-0, SHA-1, SHA-2, and SHA-3.
• SHA-0 is a 160-bit hash function that was published by the National Institute
of Standards and Technology in 1993.
• SHA-1 was designed in 1995 to correct the weaknesses of SHA-0. In 2005, a
method was found to uncover collisions in the SHA-1 algorithm due to which
long-term employability became doubtful.
• SHA-2 has the following SHA variants, SHA-224, SHA-256, SHA-384, SHA-
512, SHA-512/224, and SHA-512/256. It is a stronger hash function and it still
follows the design of SHA-1.
• In 2012, the Keccak algorithm was chosen as the new SHA-3 standard.
• SHA-256 is the most famous of all cryptographic hash functions because it’s
used extensively in blockchain technology. The SHA-256 Hashing algorithm
was developed by the National Security Agency (NSA) in 2001.

Uses of Hash Functions in Blockchain

The blockchain has a number of different uses for hash functions. Some of the
most common uses of the hash function in blockchain are:
• Merkle Tree: This uses hash functions to make sure that it is infeasible to
find two Merkle trees with the same root hash. This helps to protect the
integrity of the block header by storing the root hash within the block header
and thus protecting the integrity of the transactions.
• Proof of Work Consensus: This algorithm defines a valid block as the one
whose block header has a hash value less than the threshold value.
• Digital signatures: Hash functions are the vital part of digital signatures that
ensures data integrity and are used for authentication for blockchain
transactions.
• The chain of blocks: Each block header in a block in the blockchain contains
the hash of the previous block header. This ensures that it is not possible to
change even a single block in a blockchain without being detected. As
modifying one block requires generating new versions of every following
block, thus increasing the difficulty.
Thus, it can be concluded hash functions are a vital part of the blockchain
technology used to protect the integrity and immutability of the data stored on the
blockchain.

Digital Signature

A digital signature is a mathematical scheme for presenting the authenticity of


digital messages or documents. A valid digital signature gives a recipient reason to
believe that the message was created by a claimed sender (authentication), that the
sender cannot deny having sent the message (non-repudiation), and that the
message was not altered in transit (integrity).

Digital signatures are often used to implement electronic signatures, a broader term
that refers to any electronic data that carries the intent of a signature, but not all
electronic signatures use digital signatures. Digital signatures employ asymmetric
cryptography. Asymmetric cryptography, also known as public key cryptography
(PKI), uses public and private keys to encrypt and decrypt data. The keys are
simply large numbers that have been paired together but are not identical
(asymmetric). One key in the pair can be shared with everyone; it is called
the public key. The other key in the pair is kept secret; it is called the private key.
Either of the keys can be used to encrypt a message; the opposite key from the one
used to encrypt the message is used for decryption.In many instances they provide a
layer of validation and security to messages sent through a non-secure channel.
Digital signatures are equivalent to traditional handwritten signatures in many
respects, but properly implemented digital signatures are more difficult to forge
than the handwritten type.

Let’s dive into this concept from blockchain perspective with the help of an
example:

Public key cryptography is a cryptographic system where you have 2 keys — public
key (Pu) and a private key(Pr). You give out your public key to the entire world
and keep the private key to yourself. e.g. Your Ethereum address is a public key and
your private key is stored either in your browser / mobile / hardware wallet.
Consider public key like an bank account number, for someone to send you money
(Ether), they just need to know your public (account) address. However, only you
can access the funds in your account because you are the only one who knows your
private key, say similar to your bank account password.

Public key cryptography has algorithms that let you encrypt, decrypt, sign and
verify messages using your pair of keys. Let’s explore how these steps flows with
an example

1. Signing the message with private key: To create a digital signature, signing
software (such as an email program) creates a one-way hash of the electronic
data to be signed. The private key is then used to encrypt the hash. The
encrypted hash — along with other information, such as the hashing algorithm
— is the digital signature. The reason for encrypting the hash instead of the
entire message or document is that a hash function can convert an arbitrary
input into a fixed length value, which is usually much shorter. This saves time
since hashing is much faster than signing.

2. Verifying the message with public key: This would involve two steps,
generate hash of the message and signature decryption. By using the signer’s
public key, the hash could be de-crypted. If this de-crypted hash matches a
second computed hash of the same data, it proves that the data hasn’t changed
since it was signed. If the two hashes don’t match, the data has either been
tampered with in some way (integrity) or the signature was created with a
private key that doesn’t correspond to the public key presented by the signer
(authentication)
(To develop basic understanding of how digital signatures work in cryptography, it
is highly recommended to learn more in detail — Cryptography & Digital
Signatures.)

Practical Applications:

• Digital Signatures are used in software programs, such as browsers, which need
to establish a secure connection over an insecure network like the internet.
Users and systems need to be certain that a public key is authentic, that it
belongs to the person or entity claimed and that it has not been tampered with
or replaced by a malicious third party.

• The United States Government Printing Office (GPO) publishes electronic


versions of the budget, public and private laws, and congressional bills with
digital signatures.
• Digital Signatures can reduce the time to close the contracts that require many
parties to validate and sign them. E.g. Mortgage Contracts require number of
parties to validate the contract & sign it at different stages of mortgage life
cycle. Parties involved — Buyer, Lender, Seller, Attorneys, Real Estate Agents,
Title Representatives, Closing Agents
With the immutable nature of blockchain, the contract validity can be trusted at
any point in time, so that all these parties can sign these contracts at their
convenience (no need to be present at the same time)

• Digital Signatures can be used for B2B communications & transactions, that
can validate the source & can be sent to only intended party without any
middlemen

Some Digital Signature algorithms

· RSA-based signature schemes, such as RSA-PSS

· DSA and its elliptic curve variant ECDSA

· Edwards-curve Digital Signature Algorithm and its Ed25519 variant.

· ElGamal signature scheme as the predecessor to DSA, and variants Schnorr


signature and Pointcheval–Stern signature algorithm

· Rabin signature algorithm

· Pairing-based schemes such as BLS


· Undeniable signatures

· Signatures with efficient protocols — are signature schemes that facilitate efficient
cryptographic protocols such as zero-knowledge proofs or secure computation.

Additional security precautions:

• Putting the private key on a smart card

• Using smart card readers with a separate keyboard

• Using digital signatures only with trusted applications

• Using a network attached hardware security module

• Digital signatures can also be applied in offline mode

How is Digital Signing used in Blockchain?

Digital signing in blockchain technology aims to authenticate transactions. That


means checking if the sender is authorized to make the transactions. The user has
to prove to the network that he’s authorized to spend his balance. The balance is
also verified by checking the transactions made to the account.

Each node in the network verifies the submitted transaction and then makes an
informed decision asking the whole network to add it. And that’s how the use of
digital signing network participants can authorize the transaction and account.
Blockchain Merkle Trees

A hash tree is also known as Merkle Tree. It is a tree in which each leaf node is
labeled with the hash value of a data block and each non-leaf node is labeled with
the hash value of its child nodes labels.
What is a Cryptographic Hash?

A cryptographic hash is a function that outputs a fixed-size digest for a variable-


length input. A hash function is an important cryptographic primitive and
extensively used in blockchain. For example, SHA-256 is a hash function in
which for any variable-bit length input, the output is always going to be a 256-bit
hash.

• From the above picture, it is clear that even the slightest change in an alphabet
in the input sentence can drastically change the hash obtained. Therefore
hashes can be used to verify integrity.
• Consider there is a text file with important data. Pass the contents of the text
file into a hash function and then store the hash in the phone. A hacker
manages to open the text file and changes the data.
• Now when you open the file again, you can compute the hash again and
compare this hash with the one stored previously on the phone.
• It will be clearly evident that the two hashes do not match and hence the file
has been tampered with.

What is Hash Pointer?

A regular pointer stores the memory address of data. With this pointer, the data
can be accessed easily. On the other hand, a hash pointer is a pointer to where
data is stored and with the pointer, the cryptographic hash of the data is also
stored. So a hash pointer points to the data and also allows us to verify the data. A
hash pointer can be used to build all kinds of data structures such as blockchain
and Merkle tree.

Blockchain Structure

The blockchain is a proficient combination of two hash-based data structures-


1. Linked list: This is the structure of the blockchain itself, which is a linked
list of hash pointers. A regular linked list consists of nodes. Each node has 2
parts- data and pointer. The pointer points to the next node. In the blockchain,
simply replace the regular pointer with a hash pointer.
2. Merkle tree: A Merkle tree is a binary tree formed by hash pointers, and
named after its creator, Ralph Merkle.
Blockchain as linked list with hash pointers

Block Structure

1. Block header: The header data contains metadata of the block, i.e information
about the block itself. The contents of the block header include-
• Hash of the previous block header.
• Hash of the current block.
• Timestamp.
• Cryptographic nonce.
• Merkle root.
2. Merkle tree: A Merkle tree is a binary tree formed by hash pointers, and
named after its creator, Ralph Merkle.
• As mentioned earlier, each block is supposed to hold a certain number of
transactions. Now the question arises, how to store these transactions within a
block? One approach can be to form a hash pointer-based linked list of
transactions and store this complete linked list in a block. However, when we
put this approach into perspective, it does not seem practical to store a huge
list of hundreds of transactions. What if there is a need to find whether a
particular transaction belongs to a block? Then we will have to traverse the
blocks one by one and within each block traverse the linked list of
transactions.
• This is a huge overhead and can reduce the efficiency of the blockchain. Now,
this is where the Merkle tree comes into the picture. Merkle tree is a per-block
tree of all the transactions that are included in the block. It allows us to have a
hash/digest of all transactions and provides proof of membership in a time-
efficient manner.
• So to recap, the blockchain is a hash-based linked list of blocks, where each
block consists of a header and transactions. The transactions are arranged in a
tree-like fashion, known as the Merkle tree.
Each block comprises of block header + Merkle tree

Merkle Tree Structure

Structure of Merkle tree


1. A blockchain can potentially have thousands of blocks with thousands of
transactions in each block. Therefore, memory space and computing power are
two main challenges.
2. It would be optimal to use as little data as possible for verifying transactions,
which can reduce CPU processing and provide better security, and this is exactly
what Merkle trees offer.
3. In a Merkle tree, transactions are grouped into pairs. The hash is computed for
each pair and this is stored in the parent node. Now the parent nodes are grouped
into pairs and their hash is stored one level up in the tree. This continues till the
root of the tree. The different types of nodes in a Merkle tree are:
• Root node: The root of the Merkle tree is known as the Merkle root and this
Merkle root is stored in the header of the block.
• Leaf node: The leaf nodes contain the hash values of transaction data. Each
transaction in the block has its data hashed and then this hash value (also
known as transaction ID) is stored in leaf nodes.
• Non-leaf node: The non-leaf nodes contain the hash value of their respective
children. These are also called intermediate nodes because they contain the
intermediate hash values and the hash process continues till the root of the
tree.
4. Bitcoin uses the SHA-256 hash function to hash transaction data continuously
till the Merkle root is obtained.
5. Further, a Merkle tree is binary in nature. This means that the number of leaf
nodes needs to be even for the Merkle tree to be constructed properly. In case
there is an odd number of leaf nodes, the tree duplicates the last hash and makes
the number of leaf nodes even.

How Do Merkle Trees Work?

• A Merkle tree is constructed from the leaf nodes level all the way up to the
Merkle root level by grouping nodes in pairs and calculating the hash of each
pair of nodes in that particular level. This hash value is propagated to the next
level. This is a bottom-to-up type of construction where the hash values are
flowing from down to up direction.
• Hence, by comparing the Merkle tree structure to a regular binary tree data
structure, one can observe that Merkle trees are actually inverted down.
Binary tree direction vs Merkle tree direction

Example: Consider a block having 4 transactions- T1, T2, T3, T4. These four
transactions have to be stored in the Merkle tree and this is done by the following
steps-
Step 1: The hash of each transaction is computed.
H1 = Hash(T1).
Step 2: The hashes computed are stored in leaf nodes of the Merkle tree.
Step 3: Now non-leaf nodes will be formed. In order to form these nodes, leaf
nodes will be paired together from left to right, and the hash of these pairs will be
calculated. Firstly hash of H1 and H2 will be computed to form H12. Similarly,
H34 is computed. Values H12 and H34 are parent nodes of H1, H2, and H3, H4
respectively. These are non-leaf nodes.
H12 = Hash(H1 + H2)
H34 = Hash(H3 + H4)
Step 4: Finally H1234 is computed by pairing H12 and H34. H1234 is the only
hash remaining. This means we have reached the root node and therefore H1234
is the Merkle root.
H1234 = Hash(H12 + H34)
Merkle tree works by hashing child nodes again and again till only one hash

remains.

Key Points:
• In order to check whether the transaction has tampered with the tree, there is
only a need to remember the root of the tree.
• One can access the transactions by traversing through the hash pointers and if
any content has been changed in the transaction, this will reflect on the hash
stored in the parent node, which in turn would affect the hash in the upper-
level node and so on until the root is reached.
• Hence the root of the Merkle tree has also changed. So Merkle root which is
stored in the block header makes transactions tamper-proof and validates the
integrity of data.
• With the help of the Merkle root, the Merkle tree helps in eliminating
duplicate or false transactions in a block.
• It generates a digital fingerprint of all transactions in a block and the Merkle
root in the header is further protected by the hash of the block header stored in
the next block.
Why Merkle Trees are Important For Blockchain?
• In a centralized network, data can be accessed from one single copy. This
means that nodes do not have to take the responsibility of storing their own
copies of data and data can be retrieved quickly.
• However, the situation is not so simple in a distributed system.
• Let us consider a scenario where blockchain does not have Merkle trees. In
this case, every node in the network will have to keep a record of every single
transaction that has occurred because there is no central copy of the
information.
• This means that a huge amount of information will have to be stored on every
node and every node will have its own copy of the ledger. If a node wants to
validate a past transaction, requests will have to be sent to all nodes,
requesting their copy of the ledger. Then the user will have to compare its own
copy with the copies obtained from several nodes.
• Any mismatch could compromise the security of the blockchain. Further on,
such verification requests will require huge amounts of data to be sent over the
network, and the computer performing this verification will need a lot of
processing power for comparing different versions of ledgers.
• Without the Merkle tree, the data itself has to be transferred all over the
network for verification.
• Merkle trees allow comparison and verification of transactions with viable
computational power and bandwidth. Only a small amount of information
needs to be sent, hence compensating for the huge volumes of ledger data that
had to be exchanged previously.
Merkle trees use a one-way hash function extensively and this hashing separates
the proof of data from data itself

Proof of Membership

A very interesting feature of the Merkle tree is that it provides proof of


membership.
Example: A miner wants to prove that a particular transaction belongs to a
Merkle tree Now the miner needs to present this transaction and all the nodes
which lie on the path between the transaction and the root. The rest of the tree can
be ignored because the hashes stored in the intermediate nodes are enough to
verify the hashes all the way up to the root.
Proof of membership: verifying the presence of transactions in blocks using the

Merkle tree.

If there are n nodes in the tree then only log(n) nodes need to be examined. Hence
even if there are a large number of nodes in the Merkle tree, proof of membership
can be computed in a relatively short time.

Merkle Proofs

A Merkle proof is used to decide:


1. If data belongs to a particular Merkle tree.
2. To prove data belongs to a set without the need to store the whole set.
3. To prove a certain data is included in a larger data set without revealing the
larger data set or its subsets.
Merkle proofs are established by hashing a hash’s corresponding hash together
and climbing up the tree until you obtain the root hash which is or can be
publicly known.
Consider the Merkle tree given below:
Let us say we need to prove that transaction ‘a’ is part of this Merkle tree.
Everyone in the network will be aware of the hash function used by all Merkle
trees.
1. H(a) = Ha as per the diagram.
2. The hash of Ha and Hb will be Hab, which will be stored in an upper-level
node.
3. Finally hash of Hab and Hcd will give Habcd. This is the Merkle root obtained
by us.
4. By comparing the obtained Merkle root and the Merkle root already available
within the block header, we can verify the presence of transaction ‘a’ in this
block.
From the above example, it is clear that in order to verify the presence of ‘a’, ‘a’
does not have to be revealed nor do ‘b’, ‘c’, ‘d’ have to be revealed, only their
hashes are sufficient. Therefore Merkle proof provides an efficient and simple
method of verifying inclusivity, and is synonymous with “proof of inclusion”.
A sorted Merkle tree is a tree where all the data blocks are ordered using an
ordering function. This ordering can be alphabetical, lexicographical, numerical,
etc.
Proof of Non-Membership:
• It is also possible to test non-membership in logarithmic time and space using
a sorted Merkle tree. That is, it is possible to show that a given transaction
does not belong in the Merkle tree.
• This can be done by displaying a path to the transaction that is immediately
before the transaction in question, as well as a path to the item that is
immediately following it.
• If these two elements in the tree are sequential, this proves that the item in
issue is not included or else it would have to go between the two things shown
if it was included, but there is no room between them because they are
sequential.
Coinbase Transaction:
A coinbase transaction is a unique Bitcoin transaction that is included in the
Merkle tree of every block in the blockchain. It is responsible for creating new
coins and also consists of a coinbase parameter that can be used by miners to
insert arbitrary data into the blockchain.

Simple Payment Verification(SPV)

• SPV makes it extremely easy for a client to verify whether a particular


transaction exists in a block and is valid without having to download the
entire blockchain. The users will only require a copy of the block headers of
the longest chain.
• This copy of headers is stored in the SPV wallet and this wallet uses the SPV
client to link a transaction to a Merkle branch in a block. SPV client
requests proof of inclusion(Merkle proof), in the form of a Merkle branch.
The fact that the transaction can be linked to a Merkle branch is proof that the
transaction exists.
• Now by assessing the blocks which are being mined on top of the transaction’s
block, the client can also conclude that majority of the nodes have built more
blocks on top of this chain by using consensus mechanisms like Proof of
Work, and hence this is the longest, valid blockchain.

Advantages of Merkle Tree

1. Efficient verification: Merkle trees offer efficient verification of integrity and


validity of data and significantly reduce the amount of memory required for
verification. The proof of verification does not require a huge amount of data
to be transmitted across the blockchain network. Enable trustless transfer of
cryptocurrency in the peer-to-peer, distributed system by the quick verification
of transactions.
2. No delay: There is no delay in the transfer of data across the network. Merkle
trees are extensively used in computations that maintain the functioning of
cryptocurrencies.
3. Less disk space: Merkle trees occupy less disk space when compared to other
data structures.
4. Unaltered transfer of data: Merkle root helps in making sure that the blocks
sent across the network are whole and unaltered.
5. Tampering Detection: Merkle tree gives an amazing advantage to miners to
check whether any transactions have been tampered with.
• Since the transactions are stored in a Merkle tree which stores the hash of
each node in the upper parent node, any changes in the details of the
transaction such as the amount to be debited or the address to whom the
payment must be made, then the change will propagate to the hashes in
upper levels and finally to the Merkle root.
• The miner can compare the Merkle root in the header with the Merkle root
stored in the data part of a block and can easily detect this tampering.
6. Time Complexity: Merkle tree is the best solution if a comparison is done
between the time complexity of searching a transaction in a block as a Merkle
tree and another block that has transactions arranged in a linked list, then-
• Merkle Tree search: O(logn), where n is the number of transactions in a
block.
• Linked List search: O(n), where n is the number of transactions in a
block.

Blockchain Structure
Blockchain is a Distributed Ledger Technology. It is a distributed and
decentralized database and it is secured ever as compared to other technologies.

What is Blockchain Architecture?

Blockchain is a technology where multiple parties involved in communication can


perform different transactions without third-party intervention. Verification and
validation of these transactions are carried out by special kinds of nodes.
Benefits of Blockchain:
• Itis safer than any other technology.
• To avoid possible legal issues, a trusted third party has to supervise the
transactions and validate the transactions.
• There’s no one central point of attack.
• Data cannot be changed or manipulated, it’s immutable.

1. Header: It is used to identify the particular block in the entire blockchain.


It handles all blocks in the blockchain. A block header is hashed
periodically by miners by changing the nonce value as part of normal
mining activity; also Three sets of block metadata are contained in the
block header.
2. Previous Block Address/ Hash: It is used to connect the i+1th block to
the ith block using the hash. In short, it is a reference to the hash of the
previous (parent) block in the chain.
3. Timestamp: It is a system verify the data into the block and assigns a time
or date of creation for digital documents. The timestamp is a string of
characters that uniquely identifies the document or event and indicates
when it was created.
4. Nonce: A nonce number which uses only once. It is a central part of the
proof of work in the block. It is compared to the live target if it is smaller
or equal to the current target. People who mine, test, and eliminate many
Nonce per second until they find that Valuable Nonce is valid.
5. Merkel Root: It is a type of data structure frame of different blocks of
data. A Merkle Tree stores all the transactions in a block by producing a
digital fingerprint of the entire transaction. It allows the users to verify
whether a transaction can be included in a block or not.

Key Characteristics of Blockchain Architecture

• Decentralization: In centralized transaction systems, each transaction needs


to be validated in the central trusted agency (e.g., the central bank),
naturally resulting in cost and the performance jam at the central servers.
In contrast to the centralized mode, a third party is not needed in the
blockchain. Consensus algorithms in blockchain are used to maintain data
stability in a decentralized network.
• Persistency: Transactions can be validated quickly and invalid transactions
would not be admitted by persons or miners who mining the crypto. It is
not possible to delete or roll back transactions once they are included in
the blockchain network. Invalid transactions do not carry forward further.
• Anonymity: Each user can interact with the blockchain with a generated
address, which does not disclose the real identity
of the miner. Note that blockchain cannot guarantee perfect privacy
preservation due to the permanent thing.
• Auditability: Blockchain stores data of users based on the Unspent
Transaction Output (UTXO) model. Every transaction has to refer to some
previous unspent transactions. Once the current transaction is recorded
into the blockchain, the position of those referred unspent transactions
switches from unspent to spent. Due to this process, the transactions can
be easily tracked and not harmed between transactions.
• Transparency: The transparency of blockchain is like cryptocurrency, in
bitcoin for tracking every transaction is done by the address. And for
security, it hides the person’s identity between and after the transaction.
All the transactions are made by the owner of the block associated with
the address, this process is transparent and there is no loss for anyone who
is involved in this transaction.
• Cryptography: The blockchain concept is fully based on security and for
that, all the blocks on the blockchain network want to be secure. And for
security, it implements cryptography and secures the data using the cipher
text and ciphers.
Types of Blockchain Architecture

1. Public Blockchain:

A public blockchain is a concept where anyone is free to join and take part in the
core activities of the blockchain network. Anyone can read, write, and audit the
ongoing activities on a public blockchain network, which helps to achieve the self-
determining, decentralized nature often authorized when blockchain is discussed.
Data on a public blockchain is secure as it is not possible to modify once they are
validated.
The public blockchain is fully decentralized, it has access and control over the
ledger, and its data is not restricted to persons, is always available and the central
authority manages all the blocks in the chain. There is publicly running all
operations. Due to no one handling it singly then there is no need to get permission
to access the public blockchain. Anyone can set his/her own node or block in the
network/ chain.
After a node or a block settled in the chain of the blocks, all the blocks are
connected like peer-to-peer connections. If someone tries to attack the block then it
forms a copy of that data and it is accessible only by the original author of the
block.
Advantages:
1. A public network operates on an actuate scheme that encourages new
persons to join and keep the network better.
2. There is no agreement in the public blockchain.
3. This means that a public blockchain network is immutable.
4. It has Rapid transactions.
Disadvantages:
1. Public blockchain can be costly in some manner.
2. The person need not give identity, that’s why there is a possibility of
corruption of the block if it is in under attack.
3. Processing speed is sometimes slow.
4. It has Integration issues.
2. Private Blockchain

Miners need permission to access a private blockchain. It works based on


permissions and controls, which give limit participation in the network. Only the
entities participating in a transaction will have knowledge about it and the other
stakeholders not able to access it.
By it works on the basis of permissions due to this it is also called a permission-
based blockchain. Private blockchains are not like public blockchains it is managed
by the entity that owns the network. A trusted person is in charge of the running of
the blockchain it will control who can access the private blockchain and also
controls the access rights of the private chain network. There may be a
possibility of some restrictions while accessing the network of the private
blockchain.
Advantages:
1. In a private blockchain, users join the network using the invitations and all
are verified.
2. Only permitted users/ persons can join the network.
3. Private Blockchain is partially immutable.
Disadvantages:
1. A private blockchain has trust issues, due to exclusive information being
difficult to access it.
2. As the number of participants increases, there is a possibility of an attack
on the registered users.

3. Consortium Blockchain
A consortium blockchain is a concept where it is permissioned by the government
and a group of organizations, not by one person like a private blockchain.
Consortium blockchains are more decentralized than private blockchains, due to
being more decentralized it increases the privacy and security of the blocks. Those
like private blockchains connected with government organizations’ blocks
network.
Consortium blockchains is lies between public and private blockchains. They are
designed by organizations and no one person outside of the organizations can gain
access. In Consortium blockchains all companies in between organizations
collaborate equally. They do not give access from outside of the organizations/
consortium network.
Advantages:
1. Consortium blockchain providers will always try to give the fastest output
as compared to public blockchains.
2. It is scalable.
3. A consortium blockchain is low transaction costs.
Disadvantages:
1. A consortium blockchain is unstable in relationships.
2. Consortium blockchain lacks an economic model.
3. It has flexibility issues.

Core Components of Blockchain Architecture

1. Node: Nodes are network participants and their devices permit them to
keep track of the distributed ledger and serve as communication hubs in
various network tasks. A block broadcasts all the network nodes when a
miner looks to add a new block in transactions to the blockchain.
2. Transactions: A transaction refers to a contract or agreement and
transfers of assets between parties. The asset is typically cash or property.
The network of computers in blockchain stores the transactional data as
copy with the storage typically referred to as a digital ledger.
3. Block: A block in a blockchain network is similar to a link in a chain. In
the field of cryptocurrency, blocks are like records that store transactions
like a record book, and those are encrypted into a hash tree. There are a
huge number of transactions occurring every day in the world. It is
important for the users to keep track of those transactions, and they do it
with the help of a block structure. The block structure of the blockchain is
mentioned in the very first diagram in this article.
4. Chain: Chain is the concept where all the blocks are connected with the
help of a chain in the whole blockchain structure in the world. And those
blocks are connected with the help of the previous block hash and it
indicates a chaining structure.
5. Miners: Blockchain mining is a process that validates every step in the
transactions while operating all cryptocurrencies. People involved in this
mining they called miners. Blockchain mining is a process to validate each
step in the transactions while operating cryptocurrencies.
6. Consensus: A consensus is a fault-tolerant mechanism that is used in
computer and blockchain systems to achieve the necessary agreement on a
single state of the network among distributed processes or multi-agent
systems, such as with cryptocurrencies. It is useful in record keeping and
other things.
There are different kinds of consensus mechanism algorithms, each of which
works on different principles:
• Proof of Work (PoW): Proof of Work required a stakeholder node to prove
that the work is done and submitted by them certifying them to receive the
right to add new transactions in the blockchain.
• Proof of Stake (PoS): The proof of Stake is also a common consensus
algorithm that evolved as a low-cost low-energy-consuming, low-energy-
consuming alternative for the PoW algorithm. For providing the
responsibilities the public ledger provides by the virtual currency token
like Bitcoin and Ethereum.
• Proof of Capacity (PoC): Proof of Capacity (PoC) allow sharing of
memory space of the nodes in the blockchain network.
• Proof of Elapsed Time (PoET): It encrypts the passage of time
cryptographically to reach an agreement without expending many
resources.

Blockchain Architecture Vs Database

Below are some of the differences between blockchain architecture and database:

Blockchain
Parameter Architecture Database
s

Control Blockchain is The database is Centralized.


Blockchain
Parameter Architecture Database
s

decentralized because
there is no single point
of failure and there is
no central authority to
control the blockchain.

Blockchain has only an The database has Create, Read, Update,


Operations Insert operation. and Delete operations.

The database is not fully robust


Strength It is robust technology. technology.

Blockchain is
immutable technology
and we cannot change The database is a fully mutable
it back or we cannot go technology, The data can be edited in the
Mutability back. database.

Anyone with the right


proof of work can
write on the In the database reading and writing can do
Rights blockchain. so.

Speed It is slow in speed. It is faster as compared to blockchain.


Blockchain Nodes

In simple terms, every participant in a blockchain network is a node. Being a


decentralized network where a central authority is absent, there is great value for
blockchain nodes. There exist several types of blockchain nodes, and each of them
requires specific hardware configurations to get hosted or connected. Basically,
there are two types of nodes: full nodes and lightweight nodes. These types
comprise a constellation of a variety of nodes that are grouped under them.
Full nodes act as a server in a decentralized network. Their main tasks include
maintaining the consensus between other nodes and verifying the transactions.
They also store a copy of the blockchain, thus being able to securely enable custom
functions such as instant send and private transactions. When making decisions for
the future of a network, full nodes are the ones that vote on proposals.
Pruned Full Nodes: The specific characteristic here is that these nodes begin to
download blocks from the beginning, and once they reach the set limit, the oldest
ones are deleted, retaining only their headers and chain placement.
Archival Full Nodes: These are what most people refer to when they talk about
full nodes. These nodes envision a server that hosts the full Blockchain in its
database.
Compared to full nodes, Master nodes themselves cannot add blocks to the
blockchain. Their only purpose is to keep a record of transactions and validate
them. Whether Mining or Staking nodes, they’re the ones who write blocks on the
blockchain.
Lightweight or Simple Payment Verification (SPV) nodes, on the other hand, are
used in day-to-day cryptocurrency operations. These nodes communicate with the
blockchain while relying on full nodes to provide them with the necessary sets of
information. They do not store a copy of the blockchain but only query the current
status for the last block. Also, they broadcast transactions to other nodes in the
network for processing.

Blockchain Consensus

In the previous section, we got to know about the consensus. What does this term
mean? The set of rules by which a blockchain network operates and validates the
information of blocks is known as ‘consensus’.

Since cryptocurrencies operate on a decentralized P2P network, it won’t be wrong


to assume that complications are bound to arise when a decision needs to be taken.
This is where consensus comes in handy. While consensus must be achieved by a
certain type of node, in P2P networks any user can become a full node and thus
gain supremacy over others.

When at least 51% of nodes agree on something, the decision is validated on behalf
of the whole of the blockchain. This 51% rule may result in threats even. The most
common threat to a blockchain is the 51% attack, where more than half of the
nodes are concentrated in one entity. This paves the way for the entity to change
consensus rules as it sees fit, which could lead to a monopoly.
Blockchain Proof of Work

A popular consensus mechanism for blockchains, Proof of Work is a requirement


through which expensive computations, also called mining, can be performed in
order to facilitate transactions on the blockchain. Although it might be hard for
nodes to generate a valid block, it is quite easy for the network to validate the
block’s authenticity. This is achieved through hash functions. Since hashes are
quite sensitive to changes and even minute modifications will result in a
completely different hash output, they can be used to validate and secure blocks.

For a block to be confirmed as valid, miners are required to generate two hashes: a
hash of all the transactions in the block and one proving that they have expended
the energy required to generate the block by solving a special cryptographic puzzle
with a pre-set level of difficulty. The difficulty of solving the puzzle can be
automatically adjusted in Proof of Work systems to create a consistent time period
for blocks that are to be added to the blockchain.
In summary, a miner creates a block of valid transactions. Further, the miner runs a
Proof of Work algorithm on it to find a valid hash. When a valid block is
generated, the block is added to the blockchain, and the miner receives network
fees and the newly created cryptocurrency.

Blockchain Protocols

As blockchains are being rolled out at an exponential rate for everything from
cross-border financial transactions to supply chain management, the lack of
scalability has remained a constant issue since the genesis of blockchains. As more
computers join the P2P network, the efficiency of the whole blockchain ecosystem
typically deteriorates.

Through the process of sharding, a way of partitioning, blockchain miners can


maintain a consistent throughput throughout the network.
Blockchain protocols, however, demand constant attention for their efficient
functioning.
Each party maintains its own copy of
the information, and all nodes must
BLOCKCHAIN validate updates collectively.

The information could represent


PROTOCOL
transactions, contracts, assets,
identities, or practically anything else
CHARACTERISTICS that can be described in digital form.

Entries are permanent, transparent, and


searchable, which makes it possible for
community members to view
transaction histories in their entirety.

Each update is a new block added to


the end of a chain. A protocol manages
how new edits or entries are initiated,
validated, recorded, and distributed.

Cryptology replaces third-party


intermediaries as the keeper of trust,
with all blockchain participants running
complex algorithms to certify the
integrity of the whole.

Major blockchain protocols are listed below:

• Bitcoin: The first Blockchains application, Bitcoin enables users to perform


non-reversible transactions trustlessly. This protocol includes technologies
such as hash, digital signature, public-key cryptography, P2P networking,
Proof of Work, and Proof of Work mining.
• Ethereum: Known for smart contracts, Ethereum features a native
cryptocurrency, namely Ether, and an Ethereum wallet. This protocol allows
users to create decentralized applications and democratic autonomous
organizations.
• Ripple: Ripple Blockchain supports tokens that are used to represent fiat, other
cryptocurrencies, commodities, or other value units such as mobile minutes
and frequent flyer miles.
• Hyperledger: Developed by the Linux Foundation in
2015, Hyperledger supports Python, endorsement policies for transactions, and
confidential channels for private information sharing.
• Openchain: A scalable and secure blockchain protocol, Openchain is suitable
for organizations that wish to issue and manage their digital assets.
• IOTA: Known for its blockless distribution ledger ‘Tangle’, IOTA enables
infinitesimally small payments without charging extra fees.
• Lisk: A relatively new blockchain protocol, Lisk allows the development of
decentralized applications in pure JavaScript.
• BigchainDB: This open-source system starts with a big data distributed
database and then adds blockchain characteristics to the network including
decentralized control and digital asset transfers.

So, hope this is good enough to understand how Blockchain works. Now, check
out the best tutorial to learn Blockchain by Intellipaat and earn your certification
with a Blockchain course. Further check the most frequently asked Blockchain
interview questions and answers.
Bit Coin Structure

What is bitcoin?

Simply put, bitcoin is a digital currency. No bills to print or coins to mint. It's
decentralized -- there's no government, institution (like a bank) or other authority
that controls it. Owners are anonymous; instead of using names, tax IDs or social
security numbers, bitcoin connects buyers and sellers through encryption keys.
And it isn't issued from the top down like traditional currency; rather, bitcoin is
"mined" by powerful computers connected to the internet.

How does one 'mine' bitcoin?

A person (or group, or company) mines bitcoin by doing a combination of


advanced math and record-keeping. Here's how it works. When someone sends a
bitcoin to someone else, the network records that transaction, and all the other
transactions made over a certain period of time, in a "block." Computers running
special software -- the "miners" -- inscribe these transactions in a gigantic digital
ledger. These blocks are known, collectively, as the "blockchain," an eternal,
openly accessible record of all the transactions that have ever been made.

Using specialized software and increasingly powerful (and energy-intensive)


hardware, miners convert these blocks into sequences of code, known as a "hash."
This is more dramatic than it sounds; producing a hash requires serious
computational power, and thousands of miners compete simultaneously to do it. It's
like a multitude of chefs feverishly racing to prepare a new, extremely complicated
dish -- and only the first one to serve up a perfect version of it ends up getting paid.

When a new hash is generated, it's placed at the end of the blockchain, which is
then publicly updated and propagated. For their trouble, the miner currently gets
12.5 bitcoins, which, in February 2018, was worth roughly $100,000. Note that the
amount of awarded bitcoins decreases over time.

What determines the value of a bitcoin?

Ultimately, the value of a bitcoin is determined by what people will pay for it. In
this way, there's a similarity to how stocks are priced.

The protocol established by Satoshi Nakamoto dictates that only 21 million


bitcoins can ever be mined -- almost 19 million have been mined so far -- so there
is a limited supply, like with gold and other precious metals, but no real intrinsic
value. (There are numerous mathematical and economic theories about why
Nakamoto chose the number 21 million.) This makes bitcoin different from stocks,
which usually have some relationship to a company's actual or potential earnings.

Without a government or central authority at the helm controlling supply, "value"


is totally open to interpretation. This process of "price discovery," the primary
driver of volatility in bitcoin's price, also invites speculation (don't mortgage your
house to buy bitcoin) and manipulation (hence the well-documented talk of tulips
and bubbles).

Bitcoin has made Satoshi Nakamoto a billionaire many times over, at least on
paper. It's minted plenty of millionaires among the technological pioneers,
investors and early bitcoin miners. The Winklevoss twins, who parlayed a $65
million Facebook payout into a venture capital fund that made early investments in
bitcoin, are now well-known billionaires, according to Fortune.

Sending and Receiving a Payment


1. Open your wallet app.
2. Click on Send Payment or similar button.
3. Enter the amount you want to send.
4. Enter the QR code or wallet address of the recipient.
5. Click Send or a similar button.

How and Where to Pay Using Bitcoin in 3 Easy Steps?

Bitcoin has been the hottest thing in the world of finance for the last several years.
If you still don’t know how to use this digital currency and want to find out who
accepts Bitcoin these days, you are on the right page. In this short article, we are
going to give you some basic advice on how to start using Bitcoin in no time.

1. Choose Your Bitcoin Wallet

Before being able to pay with Bitcoin, you must find a wallet where you can store
your digital currency. This will serve as your Bitcoin bank account through which
you can store, pay, and receive money. There are many free crypto wallets on the
web, and they all work well on both desktop and mobile devices. Just make an
account using your personal details, and you’re good to go.

2. Buy Bitcoin

After your wallet is set up, comes the time for you to buy some bitcoins. You can
do this through one of the many cryptocurrency exchange services. Do your
research and get the best possible price for bitcoin at the moment.You can buy
bitcoins using your credit card or a bank account. Just provide the exchange
service with your bitcoin wallet address and the transaction will be completed in
minutes.

3. Start Paying with Bitcoin

If an online merchant has the option of Bitcoin payments, you just need to copy
their Bitcoin address and paste it into a designated field on your wallet. Type in the
right amount of bitcoins into the payment box and click ‘send’. Just make sure that
you always type in the exact amount as displayed in the payment window. The
transaction should be completed in a couple of seconds.You’ll be happy to know
that Bitcoin is accepted by most of the top stores and services online. If you need a
list of some of the best companies that are Bitcoin-friendly today,
Bitcoin Transaction
Double Spending

There are two types of examples of double spending in BTC.

➢ The first case is making duplicates of the same bitcoin and sending it to
multiple users.
➢ The second case is performing the transaction and reversing the already sent
transaction after getting the service.

You go to Restaurants and order a cappuccino worth $5. You pay in cash. The
service provider at Restaurants instantly confirmed that you have paid, and you
received your coffee in exchange for the money. Now is it possible to spend the
same $5 somewhere else to make another purchase? The answer is NO. But what if
the answer is YES? It means the same person can use the same cash more than one
times. This type of problem is known as Double Spending Problem.

In a physical currency, the double-spending problem can never arise. But in digital
cash-like bitcoin, the double-spending problem can arise. Hence, bitcoin
transactions have a possibility of being copied and rebroadcasted. It opens up the
possibility that the same BTC could be spent twice by its owner.

How Bitcoin handles the Double Spending Problem?

Bitcoin handles the double-spending problem by implementing a confirmation


mechanism and maintaining a universal ledger called blockchain.

Let us suppose you have 1 BTC and try to spend it twice. You made the 1 BTC
transaction to Alice. Again, you sign and send the same 1 BTC transaction to Bob.
Both transactions go into the pool of unconfirmed transactions where many
unconfirmed transactions are stored already. The unconfirmed transactions are
transactions which do not pick by anyone. Now, whichever transaction first got
confirmations and was verified by miners, will be valid. Another transaction which
could not get enough confirmations will be pulled out from the network. In this
example, transaction T1 is valid, and Alice will receive the bitcoin.

What happened if both the transactions are taken simultaneously by the miners?

Suppose two different miners will pick both transactions at the same time and start
creating a block. Now, when the block is confirmed, both Alice and Bob will wait
for confirmation on their transaction. Whichever transaction first got confirmations
will be validated first, and another transaction will be pulled out from the network.

Now suppose if both Alice and Bob received the first confirmation at the same
time, then there is a race will be started between Alice and Bob. So, whichever
transaction gets the maximum number of confirmations from the network will be
included in the blockchain, and the other one will be discarded.

Bitcoin: Fundamental Technical Structure


The Bitcoin network is a decentralized, trustless, peer-to-peer network designed to
securely send monetary value from one party to another in the form of bitcoin. This
article provides an overview of Bitcoin’s technical structure including the
blockchain, nodes, miners, and proof of work mining. If you’d like to read up on
other aspects of Bitcoin, be sure to check out our other articles, including Bitcoin:
Origins and Cultural Significance and Bitcoin: Network Security.

Contents

The Blockchain Ledger

Peer-to-Peer Network Nodes

Proof-of-Work Mining: Bitcoin’s Consensus Mechanism

Anatomy of a Block

Bitcoin Halving

Bitcoin Forks

The Blockchain Ledger

The Bitcoin network maintains a distributed public ledger that records the
ownership of all bitcoin, the native digital asset token of the network. New
transactions are grouped together into “blocks” and added sequentially to the
network’s ongoing chain of blocks — hence the term “blockchain.” The Bitcoin
blockchain contains every block since inception, stretching all the way back to the
first block known as the “Genesis Block.”

Identical copies of the blockchain are hosted on computers around the world that
run the Bitcoin software. These computers are called "nodes." This design ensures
that no single entity is in control of the blockchain or protocol that governs it.
Bitcoin's distributed nature makes it decentralized and resistant to being controlled
(or shut down) by any government or central authority. Theoretically, all nodes
that maintain a complete copy of the blockchain — known as "full nodes" —
would need to be destroyed in order to erase the Bitcoin blockchain. No small task
as there are even full nodes floating above the earth in space!

Nodes known as “miners” serve the purpose of validating Bitcoin transactions and
securing the blockchain ledger. In the traditional banking system, when you send
money from your bank account to another bank account, the banks act as trusted
intermediaries, deducting funds from one account and adding them to another.
With Bitcoin, centralized intermediaries are replaced by a trustless network of
miners. We’ll explain how this works shortly.

Peer-to-Peer Network Nodes

Nodes are a major part of blockchain-based protocols and the cornerstone of


decentralization, security, and transparency. There are several types of nodes on
the Bitcoin network. When a user connects to the Bitcoin network to send or
receive bitcoin, her computer acts as a node. Most nodes are known as light nodes,
which typically only download the more recent blockchain data needed to process
and verify new transactions. This minimal approach keeps light nodes running
quickly and efficiently without requiring too much computational or storage
resources.

In contrast, full nodes contain an entire copy of the blockchain in real time. They
download every block of transactions that has ever happened on the network since
the Genesis Block — not just the most recent ones. As long as the full blockchain
exists on at least one full node, there will be a record of all bitcoin and bitcoin
transactions throughout history.

Finally, there are the nodes called miners who write blocks of new transactions to
the blockchain and, in doing so, mint new bitcoin.

Proof-of-Work Mining: Bitcoin’s Consensus Mechanism

Miners compete to solve a computationally-intensive, proof of work puzzle. The


“winning” miner is rewarded with a set number of bitcoin (plus network
transaction fees) called the “block reward.” One miner wins the block reward
roughly every 10 minutes, regardless of the amount of processing power that
miners collectively bring to bear on the network. More processing power only
increases a miner's chances of winning; it does not speed up the competition.
Miners can’t accelerate or otherwise alter Bitcoin’s deterministic supply schedule.

The puzzle requires a miner to create a new block by taking all of the network’s
new and unconfirmed transactions, as well as information from the previous block
(i.e., its “block header”), and “hash” them using the SHA-256 algorithm. Hashing
is a process whereby a specific input (in this case, recent transaction data and the
block header) is entered into an algorithm to generate a specific output. A Miner
must take this input and guess a number called a “nonce” that when entered
together into SHA-256, will generate an output that satisfies the output threshold
set by the Bitcoin protocol. Mining boils down to guessing nonces as quickly as
possible. If a miner hits the specified output threshold, she will broadcast her new
block (which includes her nonce) to other miners on the network so that they can
hash it themselves and verify her solution. If a majority of miners — 51% or more
— reach consensus on her solution, she will be allowed to add her new block to the
blockchain and receive the block reward. And then the race begins all over again.
Here’s the important part: if any of the transaction data is altered by even the
smallest amount (say a “satoshi,” which is 0.00000001 BTC), the hash output will
change. As a result, a majority of miners will fail to reach consensus around any
nonce that solves the puzzle using tampered transaction data. This prevents a
dishonest miner from winning and encourages miners to act scrupulously with their
precious computational resources.

Bitcoin mining is an elegant design that serves the dual purpose of validating
transactions and minting new bitcoin. But there’s more...because mining requires
computer processing power (i.e, energy), there is a real cost to minting bitcoin,
which gives it digital scarcity. This mimics real world gold production inasmuch as
they both require energy to mine. But unlike Bitcoin, gold mining does not serve to
validate (and process) transactions. Bitcoin mining does both, and that’s a beautiful
thing.

Anatomy of a Block

Each Bitcoin block is limited in size to one megabyte of data. For “Segregated
Witness” (SegWit) blocks, transaction data is limited to one megabyte, whereas
signature data (aka witness) is segregated and limited to three megabytes. This
keeps the block size at one megabyte while increasing block space for transaction
data.

A block contains the following information:

A Block header:

Version number
Hash of the previous block header

Hash of the root of Merkle tree of all the transactions in the current block

Timestamp

Difficulty target of the current block (meaning how difficult the target hash will be
to find)

Nonce

Data for each transaction:

Version number

Flag (only for SegWit transactions)

Transaction inputs

Transaction outputs

Witnesses (only for SegWit transactions)


Lock time

Bitcoin Halving

Bitcoin has a deterministic supply schedule that caps the total supply of bitcoin at
21 million bitcoin (or BTC). As discussed above, new bitcoin are minted when a
miner wins the block reward. The block reward amount is “halved” every 210,000
blocks, which happens approximately every four years. Bitcoin’s halving schedule
is as follows:

2009 to 2012: block reward = 50 BTC

2012 to 2016: block reward = 25 BTC

2016 to 2020: block reward = 12.5 BTC

2020 to 2024: block reward = 6.25 BTC

The next halving will occur in early 2024, when the block reward halves to 3.125
BTC. As the block reward continues to halve, it will eventually approach zero —
approximately in the year 2140. In other words, after 2140, no new bitcoin will
ever be minted and the block reward will consist solely of transaction fees charged
by miners when bitcoin is sent on the network.

The fixed and predetermined supply schedule of bitcoin gives it “hard money,”
store of value properties and is why many people consider it “digital gold” or “gold
2.0.”
Bitcoin Forks

A fork occurs when an existing blockchain splits into two different blockchains.
This happens when an update is made to a protocol that not all of the nodes adopt.
There are two types of forks that blockchains can experience; a soft fork, whereby
old nodes and new nodes are able to read both blockchains (compatible); and a
hard fork, whereby old nodes cannot read the new blockchain and vice versa
(incompatible). Hard forks result in two separate blockchains with distinct native
digital asset tokens that are separate and apart from each other.

When updates are made to the Bitcoin protocol, individual nodes must determine if
they will upgrade and accept the new changes or not. If a constituent of nodes
within the network refuses to adopt the changes, then a hard fork results. Bitcoin
has experienced several forks of both kinds, including the Bitcoin Cash hard fork
that occurred at block 661,647, the last common block between Bitcoin and
Bitcoin Cash. The Bitcoin Cash fork emanated from a disagreement in the Bitcoin
community around block size. Bitcoin Cash adopted a block size of eight
megabytes to increase transaction throughput, whereas Bitcoin kept a block size of
one megabyte to foster greater node participation and ensure decentralization.
CREATE A CRYPTOCURRENCY :

• Crypto currencies are digital currencies that work just like their traditional counterparts: People
use them to make purchases or to receive funds from sales of goods or services.

• The difference between crypto currencies and traditional ones is that, in order for crypto
currencies to work, an online network must facilitate and verify all transactions.

• Determine the use for your crypto currency.

• Select a block chain platform.

• Prepare the nodes.

• Choose a block chain architecture.

• Establish APIs.
• Create a suitable interface.

• Understand the legal considerations.

Determine the Use for Your Crypto currency

• The first step in creating a crypto currency is obvious but essential: Developers (the term used
for crypto currency creators) must find a compelling use for their proposed digital currency.
Traditional and crypto currencies can serve many purposes:

• Transfer of money

• Alternative wealth storage

• Smart contract support

• Data verification

• Smart asset management

• Select a Block chain Platform : All crypto currencies are anchored by a block chain platform. This
ensures that every transaction is recorded and distributed across the block chain, creating a
system of accountability. This approach makes it impossible for outside parties to hack, trick, or
change the digital ledger.

• Platforms vary depending on the consensus mechanism used. At its core, a block chain is a kind
of digital ledger that permanently lists every crypto currency transaction. However: not all
transactions are considered. Some, for example, might be fraudulent. Therefore, a screening
process is required. In the world of blockchains, that’s what a consensus mechanism provides.

Prepare the Nodes : Once you’ve selected a blockchain, the nodes that work in the blockchain must be
created. Nodes are, usually, fast computers that connect to a blockchain network to verify and process
transactions. Nodes keep the currency running while recording and sharing the data that eventually gets
added to the digital ledger.

There are four key considerations when setting up nodes:

1. Determining who has access to nodes. Some ledgers are publicly accessible; others remain
private.

2. Determining where nodes are hosted. A cloud network can host a node, but local nodes may be
preferred in order to provide on-premise support for computers that act as nodes.

3. Choosing which operating system is ideal. An open-source operating system like Ubuntu or
Fedora is usually preferred, as developers can reconfigure the OS to their cryptocurrencies’
unique needs.
4. Deciding what hardware is required. Components like processors, RAM, GPUs, and hard drives
are important considerations because nodes require faster hardware so that they can process
more transactions in less time.

Choose a Block chain Architecture

When it comes to sharing data, block chains don’t all operate the same way. Digital architecture is a lot
like building architecture: It must not only consider design but also how everything fits together to work
best. Consider these three prominent block chain architecture formats :

1. Centralized — One central node on the block chain receives information from multiple other
nodes.

2. Decentralized — Nodes on the block chain share data together.

3. Establish APIs

4. The application programming interface (or API) is an interface linking to a blockchain node or a
client network. For example, an API can interface between the currency exchange and an
application that collects data about that currency. APIs can work for many purposes in the world
of cryptocurrencies, but the most common include trading currencies, providing data security,
and obtaining currency analysis.

5. Developers may find many blockchain API solutions, including Bitcore, Factom, and Infura
Ethereum APIs.

6. Create a Suitable Interface

7. Developers who wish to make it easy for others to interact with their cryptocurrency must
consider the user interface (UI) and user experience (UX). The easier the UI and UX, the more
likely it is that consumers and miners will be able to easily configure their settings and manage
their investments. Interfaces require a server and database to work, plus someone should be
ready to program a website or program that allows someone to review and configure data.

8.

9. 7. Understand the Legal Considerations

10. Considering the legal aspects of creating a new currency prior to beginning is both wise and
necessary. Developers must:
11. Set up a legal entity, such as an LLC or Corporation.
12. Acquire a license from their local governments.
13. Register with certified groups that are devoted to stopping money laundering and other harmful
activities, such as the Financial Crimes Enforcement Network in the United States.

You might also like