Blockchain Unit 1
Blockchain Unit 1
UNIT-I
What is blockchain?
A decentralized that enables multiple authoritative domains, who do not trust each other, to
cooperate, coordinate and collaborate in a rational decision making process
3. Consortium Blockchain
In Consortium Blockchain, some nodes control the consensus process, and some other
nodes may be allowed to participate in the transactions. Consortium Blockchain is like a
hybrid of Public and Private Blockchain.
It is public because the Blockchain is being shared by different nodes, and it is private
because the nodes that can access the Blockchain is restricted. Hence, it is partly public
and partly private.
The following table provides a detailed comparison among these three blockchain systems:
Consortium
Property Public blockchain Private blockchain
blockchain
Public or
Read permission Public Public or restricted
restricted
Efficiency (use of
Low High High
resources)
Needs
Consensus process Permissionless Needs permission
permission
server keeps all the required information in one place so that it is easy to update, due to the server
being a centralized database controlled by a number of administrators with permissions.
In the case of the distributed network of blockchain architecture, each participant within the
network maintains, approves, and updates new entries. The system is controlled not only by
separate individuals, but by everyone within the blockchain network. Each member ensures that
all records and procedures are in order, which results in data validity and security. Thus, parties
that do not necessarily trust each other are able to reach a common consensus.
different kinds of transactions arranged into a P2P network. This network consists of many
computers, but in a way that the data cannot be altered without the consensus of the whole network
(each separate computer).
Properties of Blockchain
It’s a condition when one digital token is spent multiple times because the token generally consists
of a digital file that can easily be cloned. It simply leads to inflation and organizations must bear a
huge loss. One of the primary aims of Blockchain technology is to eliminate this approach up to
the possible extent.
Hash function:
Hash functions are extremely useful and appear in almost all information security
applications.
A hash function is a mathematical function that converts a numerical input value into another
compressed numerical value. The input to the hash function is of arbitrary length but output
is always of fixed length.
Values returned by a hash function are called message digest or simply hash values. The
following picture illustrated hash function.
Hashing functions have a few properties that make them desirable for creating proof of work,
a key concept in the Bitcoin network specifically:
Hash functions turn an arbitrarily-large piece of data into a fixed-length hash output
They are one-to-one: the same input will always provide the same hash output
They are one-way functions: it's impossible to "work backwards", and reconstruct the input
given a hash output.
The core hash algorithm used in blockchain technology is the SHA256. The purpose of using a
hash is because the output is not ‘encryption’ i.e it cannot be decrypted back to the original text. It
is a ‘one-way’ cryptographic function, and is a fixed size for any size of source text. To get a better
understanding, let us look at an example below:
If you look at the first example, we are feeding the input as “Hello World” and getting an output
as “a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e”. However, by
just adding an “!” at the end, the output completely changes to
“7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069”. If we change “H”
to “h” and “W” to “w”, then the output value changes to
“7509e5bda0c762d2bac7f90d758b5b2263fa01ccbc542ab5e3df163be08e6ca9”.
The complexity of this algorithm is as even the slightest change in the input can cause a
massive change in the output. (Avalanche Effect)
Digital Signature: (ensure the identity of user and prevent the non-repudiation attack)
This cryptographic technique helps the user by creating a set of keys referred as Public key and
Private key. Here the Public key is shared with others whereas the Private key is kept as a secret
by the user. To understand the roles of these keys, Let us look at the example below to get a better
understanding:
If Chandler sends some bitcoins to Joey, that transaction will have three pieces of information:
1. He takes all the un-encrypted data like transaction amount and public keys of both Joey
and Chandler, and feeds it to a hash algorithm to get a hash value which we shall call Hash1
2. He takes the digital signature and decrypts it using chandler’s public key to get a hash value
which we will call as Hash2
If both Hash1 and Hash2 are the same then it means that this a valid transaction
Public and enterprise Blockchain are secure by design and are the continuously growing
ledger on which all decentralized crypto currency and applications are built.
Miners use high end computers to solve mathematical equations to verify transactions on
the blockchain.
Mining computers collect hundreds of pending transactions — also called a block — and
turn them into a mathematical puzzle. The miner who finds the solution first gets rewarded.
Blockchain Architecture
Logically, a blockchain is a chain of blocks which contain specific information (database),
but in a secure and genuine way that is grouped together in a network (peer-to-peer). In
other words, blockchain is a combination of computers linked to each other instead of a
central server, meaning that the whole network is decentralized.
To make it even simpler, the blockchain concept can be compared to work done with
Google Docs. You may recall the days of tossing over doc. documents and waiting for
other participants to make necessary edits. These days, with the help of Google Docs, it is
possible to work on the same document simultaneously.
The blockchain technique allows digital information to be distributed, rather than copied.
This distributed ledger provides transparency, trust, and data security.
Blockchain architecture is being used very broadly in the financial industry. However,
these days, this technology is employed not only for cryptocurrencies, but also for record
keeping, digital notary, and smart contracts.
The structure of blockchain technology is represented by a list of blocks with transactions in a
particular order. These lists can be stored as a flat file (txt. format) or in the form of a simple
database. Two vital data structures used in blockchain include:
Pointers - variables that keep information about the location of another variable.
Specifically, this is pointing to the position of another variable.
Linked lists - a sequence of blocks where each block has specific data and links to the
following block with the help of a pointer.
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.
Basically, the following blockchain sequence diagram is a connected list of records:
Blockchain architecture can serve the following purposes for organizations and enterprises:
Cost reduction - lots of money is spent on sustaining centrally held databases (e.g.
banks, governmental institutions) by keeping data current secure from cyber crimes and
other corrupt intentions.
History of data - within a blockchain structure, it is possible to check the history of
any transaction at any moment in time. This is a ever-growing archive, while a
centralized database is more of a snapshot of information at a specific point.
Data validity & security - once entered, the data is hard to tamper with due to the
blockchain’s nature. It takes time to proceed with record validation, since the process
occurs in each independent network rather than via compound processing power. This
means that the system sacrifices performance speed, but instead guarantees high data
security and validity.
Components of Blocks
Blocks are data structures whose purpose is to bundle sets of transactions and be distributed to all
nodes in the network. Blocks are created by miners (discussed in more detail below).
Blocks contain a block header, which is the metadata that helps verify the validity of a
block.
previous block header hash - the reference this block's parent block
merkle root hash - a cryptographic hash of all of the transactions included in this block
nBits - the current difficulty that was used to create this block
nonce ("number used once") - a random value that the creator of a block is allowed to manipulate
however they so choose
These 6 fields constitute the block header. The rest of a block contains transactions that the miner
has chosen to include in the block that they created.
Users create transactions and submit them to the network, where they sit in a pool waiting to be
included in a block.
A hash is like a fingerprint (long record consisting of some digits and letters). Each block
hash is generated with the help of a cryptographic hash algorithm (SHA 256).
Consequently, this helps to identify each block in a blockchain structure easily. The
moment a block is created, it automatically attaches a hash, while any changes made in a
block affect the change of a hash too. Simply stated, hashes help to detect any changes in
blocks.
The final element within the block is the hash from a previous block. This creates a chain
of blocks and is the main element behind blockchain architecture’s security. As an
example, block 45 points to block 46. The very first block in a chain is a bit special - all
confirmed and validated blocks are derived from the genesis block.
Any corrupt attempts provoke the blocks to change. All the following blocks then carry
incorrect information and render the whole blockchain system invalid.
On the other hand, in theory, it could be possible to adjust all the blocks with the help of
strong computer processors. However, there is a solution that eliminates this possibility
called proof-of-work. This allows a user to slow down the process of creation of new
blocks.
In Bitcoin blockchain architecture, it takes around 10 minutes to determine the necessary
proof-of-work and add a new block to the chain. This work is done by miners - special
nodes within the Bitcoin blockchain structure. Miners get to keep the transaction fees from
the block that they verified as a reward.
Each new user (node) joining the peer-to-peer network of blockchain receives a full copy
of the system. Once a new block is created, it is sent to each node within the blockchain
system. Then, each node verifies the block and checks whether the information stated there
is correct. If everything is alright, the block is added to the local blockchain in each node.
All the nodes inside a blockchain architecture create a consensus protocol. A consensus
system is a set of network rules, and if everyone abides by them, they become self-enforced
inside the blockchain.
For example, the Bitcoin blockchain has a consensus rule stating that a transaction amount must
be cut in half after every 200,000 blocks. This means that if a block produces a verification reward
of 10 BTC, this value must be halved after every 200,000 blocks.
As well, there can only be 4 million BTC left to be mined, since there is a maximum of 21 million
BTC laid down in the Bitcoin blockchain system by the protocol. Once the miners unlock this
many, the supply of Bitcoins ends unless the protocol is changed.
To recap, this makes blockchain technology immutable and cryptographically secure by
eliminating any third-parties. It is impossible to tamper with the blockchain system; as it
would be necessary to tamper with all of its blocks, recalculate the proof-of-work for each
block, and also control more than 50% of all the nodes in a peer-to-peer network.
Mining process
”Mining is the mechanism that allows the blockchain to be created securely and in a
decentralized manner. It provides the basis for the cryptocurrency system and enables a
peer-to-peer network without a central authority.
Miners validate new transactions and record them on the global ledger ( blockchain ). On
average, a block ( the structure containing transations ) is mined every 10 minutes.
Miners compete to solve a difficult mathematical problem based on a cryptographic hash
algorithm. The solution found is called the Proof-Of-Work. This proof proves that a
miner did spend a lot of time and resources to solve the problem. When a block is
'solved', the transactions contained are considered confirmed, and the bitcoin concerned
in the transactions can be spend.