0% found this document useful (0 votes)
17 views20 pages

Block Chain 2

Blockchain is a decentralized digital ledger technology that records transactions in linked blocks secured by cryptographic hashes. It can track both tangible and intangible assets, enhancing transparency and reducing costs by eliminating intermediaries. Blockchain can be categorized into public, private, and consortium chains, each with distinct access controls and use cases.

Uploaded by

aakashps214
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views20 pages

Block Chain 2

Blockchain is a decentralized digital ledger technology that records transactions in linked blocks secured by cryptographic hashes. It can track both tangible and intangible assets, enhancing transparency and reducing costs by eliminating intermediaries. Blockchain can be categorized into public, private, and consortium chains, each with distinct access controls and use cases.

Uploaded by

aakashps214
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

MODULE-5

Introduction about blockchain

 A blockchain is a digital transaction of records that’s arranged in chunks of data called


blocks.

 These blocks link with one another through a cryptographic validation known as a hashing
function.

 Linked together, these blocks form an unbroken chain—a blockchain.

 A blockchain is programmed to record not only financial transactions but virtually


everything of value.

 Another name for blockchain is distributed ledger.

Blockchain is interdisciplinary

HOW DOES BLOCKCHAIN WORK


 The blockchain network has no central authority —

 it is the very definition of a decentralized system.

 Since it is a shared and immutable ledger, the information in it is open for anyone and
everyone to see.

 Hence, anything that is built on the blockchain is by its very nature transparent

 everyone involved is accountable for their actions.

 Blockchain is a shared, immutable ledger that facilitates the process of recording


transactions and tracking assets in a business network. An asset can be tangible (a house,
car, cash, land) or intangible (intellectual property, patents, copyrights, branding).

 Virtually anything of value can be tracked and traded on a blockchain network, reducing risk
and cutting costs for all involved.

Why blockchain ?

 #. Bring Trust : To establish trust between ourselves, we depend on individual third parties
such as banks, land registries, government etc.

 #. Decentralization: Chances of error, mistakes and corruption can happen in centralized


control systems.

 #. Remove Middle Man : They always comes with somewhat risk and cost.

Some terms :

 The word “cryptocurrency” is derived from the encryption techniques which are used to
secure the network.

 Blockchains, which are organizational methods for ensuring the integrity of transactional
data, is an essential component of many cryptocurrencies.

 A cryptocurrency is a new form of digital asset based on a network that is distributed across
a large number of computers.

 This decentralized structure allows them to exist outside the control of governments and
central authorities.

BLOCKCHAIN

 Blockchain is a completely new distributed infrastructure and computing paradigm formed


by reorganizing mature technologies such as

• hash function,

• Merkle tree,

• Proof of work (PoW)


• combining cryptographic technologies such as public key encryption, digital signature and

 Blockchain technology is characterized by anti-counterfeiting, non-tampering

 and easy to implement smart contracts, and is known as a new technology that will lead to
social change

 In order to realize trusted transactions in distributed environment, blockchain technology


uses

 cryptographic technology to hide user information, while all transaction information is


verified and stored by distributed network.

Classification- According to different application scenarios and network admission


mechanism

 Blockchain technology can be divided into


 public chain,
 alliance chain
 private chain.

PUBLIC CHAIN

 In the public blockchain,

 data can be easily accessed, which provides an unprecedented opportunity for data
analysts to analyze various behaviors in the system by using transaction data, ie we
are having permission to read, write and participate within the blockchain.

 The public chain is usually also called Permissionless Blockchain.

 Anyone can participate in the maintenance and accessing to the data on the
blockchain,

 easy to deploy applications, and completely decentralized without being controlled


by any institution.

• Bitcoin, Ethereum etc., have no restrictions on the joining and exiting of nodes, are
typical public chains.

 At present, various public chains such as Bitcoin, Ethereum etc., have obtained a
large number of users and accumulated a large amount of transaction data.

 The public chain is a fully decentralized blockchain.

 It uses cryptography to ensure that transactions cannot be tampered with.

PRIVATE CHAIN

 Is a permissioned blockchain.

 Private chains, which are limited to enterprises, state agencies or individuals, cannot
completely solve the trust problem, but can improve auditability.

 It is often used for internal database management, auditing, government budget and
execution, or government industry statistics, etc.

 They need to be transparent to each other, but not to the public.

 The value of the private chain is mainly to provide a secure, traceable, non-
tamperable, automatic execution computing platform, which can prevent both
internal and external security attacks on data, which is difficult to achieve in
traditional systems.

 Public Blockchain : No access restriction every participant would able to read and
write.

 Private Blockchain : It is permissioned based in which network administrators


(owner) invite to selected member, It is read by all but only owner has the right to
making any changes in rules or other terms.

 Consortium /Alliance Blockchain : It is semi-decentralized system in which number


of organization controlling to it. Control of write, read and verify provided to group
of organization.

Public Vs Private Blockchain

• The order of magnitude of public is lesser that the private .

• Level of access granted to the participants

• Public is decentralized and private is more on a centralized way.

• Transaction per second is lesser in public compared to private .

• A public cannot compete with private in terms of scalability issues as its slower than
private .

• Public blockchains are trustless

• Public is more secured due to the decentralization .

Alliance chain / Consortium

 is a kind of blockchain that requires registration permission.

 This kind of blockchain is also called Permissioned Blockchain.

 The alliance chain is limited to the participation of alliance members, and the scale of
the alliance can be as large as between countries, or between different institutions
and enterprises.

 The number of nodes is much smaller compared to public blockchain, such as bitcoin
blockchain, since the nodes can join the network only when they are trusted.

 The read and write permissions and the permission to participate in accounting are
determined according to the rules of the alliance. The entire network is jointly
maintained by member institutions, and network access is generally accessed
through the gateway nodes of institutions, and the consensus process is controlled
by pre-selected nodes. Therefore, the alliance chain generally does not use the
proof-of-work mining mechanism, but mostly uses consensus algorithms such as
Proof of Stake (PoS), PBFT (Practical Byzantine Fault Tolerant), and RAFT.

 Compared with the maximum 3-20 transactions per second completed by the public
chain, the alliance chain can reach 1,000-10,000, the transaction speed is faster and
the transaction cost is greatly reduced.

BLOCKCHAIN ARCHITECTURE

 Blockchain is the underlying technology of Bitcoin.


 In 2008, a scholar named “Satoshi Nakamoto” proposed a digital currency called
Bitcoin.

 In the absence of any authoritative intermediaries, people who do not trust can pay
directly in Bitcoin.

 In October 2016, China Blockchain Technology and Application Development White


Paper published by the Ministry of Industry and Information Technology described
Blockchain Technology as a new application mode of computer technology, such as
distributed data storage, point-to-point transmission, and consensus mechanism and
encryption algorithm.

 Bitcoin ≠ blockchain

 Is an application of blockchain technology

 Is the underlying datastructure, which can be used for many things, including
cryptocurrencies.

Technical architecture of the blockchain


 Proposed a five-layer framework:-----PROPOSED BY MEMBERS YANG
• data layer,
• network layer,
• consensus layer,
• incentive layer,
• contract layer and
• application layer.
 Another proposal from the perspective of privacy protection: three-tier
framework
• network layer,
• transaction layer and
• application layer.
 From the perspective of facilitating data analysis, this paper proposed a
three-tier framework:
• application layer,
• contract layer,
• transaction layer.

3 tier architecture
Layers in blockchain

 The three-tier framework not only represents three types of block chain data, but
also represents three stages of block chain development.

 Bottom layer---transaction layer,

 Block chain development stage --- Block chain development stage 1.0,

 i.e programmable currency, represented by Bitcoin.

 Transaction means not only ---to change blockchain data,


Transaction is an important basic data in blockchain.

 Major task of blockchain 1.0--- Recording transactions to ensure the global


uniqueness and irreversible modification of blockchain data.

Middle layer

• The middle layer is the contract layer,

• Block chain development stage --- Block chain development stage .2.0,

• i.e programmable finance, Ethereum is representative.

• Smart contract was proposed by Szabo in 1994, a digital protocol that uses
algorithms and procedures to compile contract terms, deploys on blockchain, and
can be automatically executed according to rules.

• The smart contract itself is also an important data type for Blockchain 2.0, which we
call contract data.

• The deployment and operation of smart contracts is not only inseparable from
transactions, but also generates new transaction data.

Top Layer

• The top layer is the application layer,


• Block chain development stage --- Block chain development stage .3.0,

• i.e programmable society, such as decentralized


application, decentralized autonomous organization.

• The application layer can be built on top of the contract layer to implement many
complex automation functions, or directly on the transaction layer (thus the contract
layer is represented by dotted lines).

• At present, because the blockchain technology is still in the early stage of


development, there is a lack of application data combined with actual scenarios.

• The operating environment of the blockchain is distributed, and its three-tier


framework is in a distributed environment.

• For example, the same smart contract is stored as a type of data on every node in a
distributed environment.

• When a transaction triggering contract operation is received, each node runs the
relevant contract based on the local blockchain data and stores the running results in
the local data.

• Finally, through the consensus mechanism, the local data is consistent with the
entire distributed network.

• In a distributed network environment of blockchain, there are usually a large number


of nodes.

• Core Components of Blockchain: How Does It Work

• These are the core blockchain architecture components:

• Node — user or computer within the blockchain

• Transaction — smallest building block of a blockchain system

• Block — a data structure used for keeping a set of transactions which is distributed
to all nodes in the network

• Chain — a sequence of blocks in a specific order

• Miners — specific nodes which perform the block verification process

• Consensus— a set of rules and arrangements to carry out blockchain operations

3. Blockchain data structure and data type

 In order to achieve data tampering, the blockchain is constructed into a chain


structure in units of blocks.

 The data structures on different blockchain platforms are slightly different, but
basically the same.

 Each block is identifiable by a hash, generated using the SHA 256 cryptographic hash
algorithm on the header of the block.

 Each block references a previous block, also known as the parent block, in the
“previous block hash” field, in the block header
Blockchain Hashing

Logically, the first block does not contain the pointer since this one is the first in a
chain. At the same time, there is potentially going to be a final block within the
blockchain database that has a pointer with no value.

Blockchain data structure

 Taking Bitcoin as an example, each block is composed of a

 block header

 block header stores a pre-block hash (PrevBlockHase) , random number (Nonce),


Merkle root (MerkleRoot), PoW etc

 block body

 and block body stores multiple transactions that occurred after the previous block;.

 The blockchain guarantees irreversible modification of data based on two hash


structures, Merkle tree and block list.
The Merkle tree

 First proposed by Ralph Merkle and was originally used to generate summaries of
digital certificate directories.

 Bitcoin uses the simplest binary Merkle tree.

 The list of transactions is stored as a Merkle tree. A Merkle tree is a tree data
structure in which every leaf node is the hash of a transaction and every non-leaf
node is the cryptographic hash of the child nodes.

 Each node in the tree is a hash value, and stores a SHA256 hash value of a
transaction data.

 The values of two leaf nodes are spliced / joined together, and then the values of the
parent node are obtained by hashing operation.

 Repeatedly calculate the hash value of the parent node until the root is generated,
that is, transaction merkle root.

 With the Merkle root, tampering of any transaction data in the block is detected,
ensuring the integrity of the transaction data.

 Without the involvement of other nodes in the tree, we can confirm whether a
transaction occurs based on the SPV (Simplified Payment Verification) only according
to the direct branch from the transaction node to the Merkle root path.
 Eg- only the nodes Hash34, Hash12, and Merkle roots in Figure 2 can be used to
verify that the transaction Tx4 is located in the block.

 In a block consisting of N transactions, at most 2log2 (N) hash operations can be


performed to verify the existence of the transaction.

 Without the need for full data participation, customers can verify the existence of a
transaction, making it ideal for building light clients or e-wallets.

 In Ethereum, the Merkle root is


calculated using the Merkle Patricia
tree because the transaction data in
the block does not change much, but
the status data often changes and the
number is large.
 When building a new block, the
Block list

 The hash value of the block header is obtained by performing a SHA256 hash
operation on the metadata such as the Prev-BlockHash, the Nonce, and the Merkle
root in the block header.

 PrevBlockHash stores hash value of the previous block.

 All blocks are linked together in the order of generation with PrevBlockHash as a
hash pointer, forming a block list.

 The block header contains the transaction Merkle root, so you can verify whether
the block header and transaction data have been tampered with by Hash operation.

 The block header also contains the previous block hash value PrevBlockHash, so it is
also possible to verify whether all blocks from the previous block of the block to the
creation block have been tampered with by block hashing.

 Relying on the PrevBlockHash, all blocks are interlocked, and any block is tampered
with, causing a chain change of all the block hash pointers.
 When a block and all previous blocks are downloaded from an untrusted node, block
hashing can be used to verify whether each block has been modified.

Data model

 Transaction model

 Account-based model

 Data type

 Transaction data model :

 A transaction in the blockchain is usually a transfer, and Figure shows the data
structure of the transaction in Bitcoin.

 Each transaction includes multiple transaction inputs and multiple transaction


outputs, indicating that one transaction can merge the bitcoins in the previous
plurality of accounts and transfer them to another plurality of accounts.

 TRANSACTION INPUT

 Each transaction input is mainly composed OF

1. the hash value of the last transaction (PrevTxHash),


2. the output index (Index) and
3. the input script (ScriptSig).

 The input of a transaction

1. corresponds to the output of the previous transaction,


2. PrevTxHash saves the hash of the previous transaction output

 Index

indicates that this transaction input corresponds to which transaction output in the
transaction history.

 The script (ScriptSig)

contains the signature of the Bitcoin holder on the current transaction

 TRANSACTION OUTPUT

 Each transaction output

1. includes the transfer amount (Value)


2. script script-PubKey containing the recipient's public key hash (script-PubKey).

 In the transaction-based model, all transactions depend on the hash pointer of the
previous transaction to form a list of transactions as nodes.

 Each transaction can be traced back to the first transaction in the trading chain
Coinbase (ie bitcoin from mining).

 Transaction-based model can effectively prevent counterfeiting, double-flower


attacks against digital currency.

(2) Account-based model.

 The transaction-based model makes it easy to verify transactions, but it cannot


quickly query user balances.
 To support more types of industry applications, blockchain platforms such as
Ethereum and Hyperledger Fabric use an account-based model to easily query the
transaction balances or trading status data.

 Smart contracts are also better suited to build on an account-based model that is
easier to handle complex business logic for state data.

 The accounts under Ethereum are divided into two types:

 External account (Externally Owned Account) and

 Contract account (Contract Account).

 The external account is used to record the Ethereum balance,

 the contract account is used to store the smart contract.

 When a transaction occurs, it will trigger a change in account status.[figure]

 External accounts and contract accounts are represented by the same data structure
in Ethereum, which contains four attributes:

1. Balance,
2. Nonce,
3. CodeHash and
4. StorageRoot.

 Balance records the Ethereum balance of the account.

 Nonce counts the number of transactions initiated by the account to prevent replay
attacks.

 CodeHash is the hash value of the contract code when the account is applied to a
smart contract.

 StorageRoot is the MerklePatricia root of contract status data

 Ethereum's transactions include seven attributes:

 To - saves the recipient's account address

 Value -Value is the amount of ethernic currency transferred.

 Nonce-Nonce counts the number of transactions initiated by the transaction

 gasPrice- GasPrice is the unit price of the Ether of Gas at the time of the transaction
 gasLimit- gasLimit is the maximum amount of Gas allowed to execute this transaction

 Data - Data is the message data when the smart contract is invoked

 transaction signature.-is the initiator's ECDSA signature of the transaction.

 Elliptic Curve Digital Signature Algorithm (ECDSA) offers a variant of the Digital
Signature Algorithm (DSA) which uses elliptic curve cryptography.

Contract data

 Introduced in the year 1995,

 cryptographer Szabo first proposed the concept of smart contract.

 He pointed out that "smart contracts stimulate contract execution by using protocols
and user interfaces".

 Smart contract is

 a commercial contract; self-executing contracts containing the terms and conditions


of an agreement among peers.

 The terms and conditions of the agreement are written into code.

 written in a programming language that automatically enforces the terms of the


contract when the predetermined conditions are met,

 Thus ,achieving the goal of "code is the law."

 The existing smart contract works like the If-Then statement of other computer
programs.

 The smart contract executes on the Ethereum blockchain's decentralized platform.

 The agreements facilitate the exchange of money, shares, property, or any asset.

 Because blockchain data has important features such as non-tampering and


complete credibility, building smart contracts based on blockchain data has natural
advantages.

 There are two widely-used programming languages for writing Ethereum smart
contracts – Solidity and Serpent

 The life cycle of smart contract includes three stages:

 contract generation,

 contract publication and

 contract execution.

 Contract generation mainly includes four aspects:

1. multi-party negotiation,
2. contract specification,
3. contract verification, and
4. contract code.

 The specific implementation process is as follows:


1. The contract participants negotiate with each other;
2. the parties clarify their respective rights and obligations,
3. jointly determine the contract text,
4. write the program, test the program, and finally obtain the standard contract code.

 Contract release is similar to transaction release.

 Steps for contract release

1. The signed contract is distributed to each node through P2P, and each node will
temporarily store the received contract in memory and wait for consensus.
2. Each node will package the new temporary contract into a contract set,
3. calculate the hash value of the set,
4. Assemble the hash value of the contract set into a block and spread to other nodes
of the whole network.
5. The node that receives the block will compare the Hash value stored in the block
with the Hash value of the contract set saved by itself.
6. Through multiple rounds of transmission and comparison, all nodes will eventually
reach a consensus on the newly issued contracts, and the agreed contracts will be
distributed to all nodes in the network in block form.

 Smart contract structure

 Each of the blocks contains the following information:

 Root Hash of the Current Block,

 Root Hash of the Previous Block,

 TimeStamp,

 contract data, and

 other descriptive information.

 The execution of smart contracts is based on the "event-triggered" mechanism.

 The smart contract on the blockchain contains transaction processing and saving
mechanisms and a complete state machine for accepting and processing various
smart contracts.

 The smart contract periodically traverses the state machine and trigger conditions of
each contract, pushing the contract that meets the trigger condition to the queue to
be verified.

 The contract to be verified will spread to each node, just like a normal transaction.

 The node will first verify the signature to ensure the legitimacy of the contract.

 The validated contract will be successfully executed after reaching a consensus.

 Finally, all nodes will reach a consensus on the contract.

 The processing of the entire contract is automatically completed by the smart


contract system built into the bottom of the blockchain, which is open and
transparent and cannot be tampered with.

 Smart contract system can actively or passively accept, store, process and send data,
and call smart contract, so as to control and manage digital objects in the chain.
 The smart contract technology platforms that have emerged, such as Ethereum and
Hyperledger, have Turing's complete development scripting language, enabling the
blockchain to support smarter contract applications for financial and social systems

Problems to be solved in blockchain data analysis

Based on relevant literature analysis, the focus of blockchain data analysis can be
summarized into seven aspects:

 entity identification,

 privacy risk analysis

 network portrait,

 network visualization,

 transaction pattern recognition,

 market effect analysis,

 illegal behaviour detection and analysis

 Figure shows the relationship between


these seven questions.
 Solid arrows indicate that the previous
(1) Entity identification
 In Bit coin transactions, users are anonymous.
 transaction involves multiple users, and one user may participate in multiple
transactions at the same time.
 A natural question is: can you identify users from transaction records, or which
addresses belong to the same user?
 Since it is not possible to confirm that a user is identified, it is generally considered in
the literature that an entity is identified.
 An entity may be a user or an organization, and a user or an organization may also
control multiple entities at the same time.
Heuristic methods are often used to identify potential entities, which can be divided
into two main types:
 common input method --that all input addresses belong to the same entity in a
transaction.
 change address method. ---the change address represents an entity.
 The change address definition is a plurality of output addresses of a transaction,
(2) Privacy protection

 Blockchain privacy protection can be divided into


 identity privacy protection
 transaction privacy protection.
 Identity privacy protection requires that user's identity information, physical
address, IP address are not related to user's public key, address and other public
information on the blockchain.
 Any unauthorized node can neither obtain any information about the user's identity
by relying on the data disclosed in the blockchain, nor can it track and analyse user
transactions and identity information through measures such as network monitoring
and traffic analysis.

(3) Network portrait

 In the face of massive transaction data, researchers hope to analyse


 How many users are involved in the transaction?
 What are the characteristics of these users?
 Does this huge payment network have the characteristics of a general complex
network?
 Bitcoin as an "asset", how is it distributed among users?
 Do you meet the general laws of economics, etc.?
 And from the point of view of complex network, the characteristics of Bitcoin
network are analysed.

(4) Network visualization

 With the prevalence of blockchain technology, the transaction data stored in the
blockchain increases rapidly.
 Therefore, in the face of a large and rapidly growing trading network, it is an
important research direction to study its visualization tools.
 For example,
a. the bitcoin trading network's visualization system, BitConeView, can be used to track
bitcoin transactions in real time and intuitively.
b. Especially, the system defines the concept of "purity" so as to find out the mixed
currency transactions conveniently and monitor the potential money laundering
banks in the Bitcoin network in real time.

5. Market Effect Analysis

 The prices of encrypted currencies such as Bitcoin are highly volatile.


 From the perspective of finance. this extremely high volatility has attracted
economists to discuss whether bitcoin is a currency or not
 On the other hand, from the perspective of data analysis, researchers hope to
explain the driving factors behind this extreme volatility.
 It is generally believed that the influencing factors include:
 miner behaviour;
 cryptographic currency system settings;
 user participation;
 policy;
 number of potential users and market sentiment;
 competition or alternative relationship with other cryptocurrencies and traditional
assets.
(6) Illegal behaviour detection.

 Unlike traditional bank payment systems, Bitcoin is an anonymous, non-centralized


payment system.
 Anonymous features lead to many illegal activities in bitcoin transactions, such as
money laundering, fraudulent gambling, and the sale of contraband.
 These illegal acts of exposure are only a small part, and a large number of illegal acts
are not known.
 Measures to Identify illegal behaviours based on transaction patterns and blockchain
data analysis techniques helps to promote the healthy development of blockchain
technology and can also provide reference for the supervision and legislation of the
blockchain industry.

(7) Transaction pattern recognition

 Unlike traditional payment systems such as Banks, bitcoin is an anonymous,


decentralized payment system.
 An important question is the human payment behaviour in the context of anonymity
 It is a valuable question whether specific patterns can be identified from blockchain
transaction records to detect related illicit activity.

Types of blockchain network

#. Public + Permissionless Blockchains. Ex: Bitcoin, Ethereum, Litecoin


#. Private + Permissioned Blockchains. Ex: Multichain, Monax #. Consortium
Blockchains . Ex: R3, EWF, Corda
Use case

#. Voting & Governance

#. Supply Chain management.

#. Subsidy distribution/ Crowdfunding.

#. Real time money transfer.

#. Audit Logs

#. Sharing Economy.

Important questions

 What is meant by Block Chaining?

 With neat diagram explain blockchain data structure

 What are the types of blockchain based on the classification according to different
application scenarios and network admission mechanism

 Hint- Public, Private and Alliance

 What is Contract Data ?

 Hint- definition of smart contract. Elaborate according to marks

 Explain the Data models in Blockchain

 Hint- transaction data model and account based data model. Explain with diagram

 Explain with block diagram the Smart contract structure

 Explain the Blockchain architecture in detail.

 Hint- 3 layer- application,contract, transaction

 Explain the problems to be solved in Blockchain Data Analysis.

You might also like