Blockchain Chapter1&2
Blockchain Chapter1&2
In the first-gen blockchain – specifically Bitcoin – was created which is a digital currency.
By empowering people with the technology to transact with one another (at a peer-to-peer level),
they don’t need to rely on centralized entities such as banks.
Bitcoin is the first real use case of blockchain technology and its main purpose is as a financial
application , any user can send Bill digital money and there is security in that transaction.
Blockchain and bitcoin both have strong privacy because the transaction is anonymous and they can
take peace in knowing that the system is secure in the technology and the trust lies in the algorithm
and not a centralized figure.
After Bitcoin’s success, it was time for the next generation of blockchain, which was brought
about by Ethereum. Second-generation blockchain technology does more than just document
transactions. Using self-executing agreements between two parties, called smart contracts,
transactions are faster and more secure than first-generation blockchain technology. Another
advantage of second-generation blockchain technology is that it acts more like a digital
ecosystem instead of a system only for transactions.
Even though Bitcoin and Ethereum are successful in their own ways, they will run into some
issues in the future. As crypto is more readily adopted, the issue of scalability in blockchains
becomes more prevalent. When too many people make transactions at a given time, fees can
skyrocket and transactions take longer. With third-generation blockchains like Cardano and
Polkadot, they automatically scale with demand, leading to lower fees overall. Another issue
that third-generation blockchains solve is interoperability, or the sharing of data across different
blockchains. While this is still being worked on, the idea is that multiple blockchains will be able
to interact with each other.
Types of blockchain
There are four different major types of blockchain namely, public blockchain, private
blockchain, hybrid blockchain, consortium or federated blockchain.
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.
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.
Consortium blockchain
A consortium blockchain is a semi decentralized type where more than one
organization manages a Blockchain network.
This is opposite to private blockchain where in which that is managed by only a single
organization but in consortium blockchain, more than one organization and banks
etc. It is also known as Federated Blockchain.
Consortium blockchain are typically used by government organizations and banks
etc..
Advantage of consortium blockchain
1.Consortium blockchains are more secure and have better scalability
2.Consortium offers better customizability and control over resources.
3.It is also more efficient compared to public blockchain networks.
Disadvantage of consortium blockchain
1.Consortium blockchain is less transparent.
2.Regulations and restrictions can have a more impact on network functionality.
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.
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 permission less systems are used.
• User access information via smart contracts
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
2.Security :
Blockchain technology is highly secured.The security method in the blockchain
is cryptography that ensures that hackers cannot change or tamper with the
data records
3.Transparency and trust
As blockchains are shared and everyone can see what is on the blockchain, this
allows the system to be transparent and as a result trust is established.
4.Highly secure
All transactions on a blockchain are cryptographically secured and provide
integrity.
5.Faster Processing: Blockchain technology speed of the transaction increased
to a very extent.
6. Low transaction cost : As there are no intermediaries in a transaction within
the blockchain network, the transaction cost are also lowered.
Limitations of blockchain
Challenges of blockchain
2. Data Layer:
The next layer after the hardware layer is the data layer where details of transactions are
stored. The transaction stored on a block ( the fundamental unit of a blockchain) has details
of the crypto sent, the public key of the receiver and the private key of the sender. Each
block which has data is connected to the previous block and the next block which is
generated. Only the genesis block, the first block of the network, is connected forwards and
not backward.
Within each block, there is another data structure referred to as the Merkle tree which is a
binary tree of hashes. Each block has a root hash which is a combination of all transaction
hashes in the block.
The Merkle tree is what prevents transactions from being mutated because if they are the
hash changes. Hashing produces a fixed-length string that is unique for any input meaning if
even a single character in a transaction changes, the hash is bound to change making the
transaction invalid. If the transaction is invalid, so is the block. If a block is invalid it is
rejected by other nodes and it is not part of the chain.
3.Network Layer
The network layer also known as a peer-to-peer layer .It is responsible for inter-node
communication and also called propagation layer.
Network layer takes care of block propagation, transactions and discover. Network layer
ensures that nodes can reveal each other and able to communicate synchronize and
propagate with each other to maintain valid current state of the blockchain network.
There are two kinds of node i.e. full node and light node. Full nodes guarantee that
validation and verification of transaction , enforcement of consensus rules and mining
whereas light nodes only keep the header of the blockchain and can send transaction.
4.consensus layer:
Consensus layer is responsible for validating the blocks, ordering the blocks and ensuring
everyone agrees on it.
Consensus layer create a definite set of agreements between nodes across the distributed
peer to peer network.
5.Application Layer
Application layer is divided into two sublayer i.e application layer and execution layer.
Application layer comprise of the application that are used by end users to interact with the
blockchain network. E.g smart contracts, chain code and dApps etc for these applications
blockchain network is the backend and they connect via APIs.
Execution layer is the sublayer which consist of chaincode ,smart contracts and underlying
rules.
Application send instructions to execution layer which ensure the deterministic nature of
the block chain and performs the execution of transactions.
Components of blockchain
The main components of any blockchain ecosystem are given below.
Node Application
Node Application specify that every computer ,connected to the internet, if its wants to
participate in. Node application not free from any restriction for example in case of
Bankchain as a block ecosystem only banks are allowed to participate.
The distributed ledger means the shared databases and contents accessible to the
participants of a particular blockchain ecosystem.
The shared ledger lists down the rules or guidelines that need to be followed ,for example if
we are running a bitcoin node application, then we have to follow by all the rules set down
in the program code of the bitcoin node application.
3.Consensus Algorithm
The consensus algorithm provides stability and security to the data in the blockchain. It is
represent the status of the network and how the nodes in the network arrive at an
agreement regarding what transactions to accept.
Also what protection used the blockchain from tampering is the fact that changing block can
be done only by making a new block from its predecessor and it also requires regenerating
all successors and redoing their contents.
It is to be noted that every block in the blockchain contains a hash of its predecessor block
thus having a chain of blocks with enormous amount work contained them.
2. Block is a data structure used for keeping a set of transactions which is distributed to all
nodes in the network.
4.Node is a user or computer within the blockchain architecture ( each has an independent
copy of the whole blockchain ledger)
5.Consensus is a set of rules and arrangements to carry out blockchain operations.
6.Miners are the specific nodes which perform the block verification process before adding
anything to the blockchain structure.
Cryptography
Cryptography in Blockchain is a type of internet security that is used to provide
security and helps users maintain data on the web providing credibility and data
security. Cryptography technologies make use of mathematical codes for storing
and transmitting data values in a more secure format. To clearly understand the
application of cryptography in blockchain.
• Encryption is the process of encrypting the plaintext so that the cipher text
can be produced plaintext is transformed into cipher text using the
encryption algorithm .
• Decryption is the reverse of the encryption process. In this the cipher text
is converted back to the plaintext (original) using a decryption algorithm.
2. Data integrity assures that information and programs are changed only in
a specified and authorized manner.
4. Authentication ensures to the receiver that the data received has been sent
only by an identified and verified sender.
Types of Cryptography
AES DES
3. Byte-Oriented. Bit-Oriented.
AES is more secure than the DES DES can be broken easily as it has known
cipher and is the de facto world vulnerabilities. 3DES(Triple DES) is a variation
6. standard. of DES which is secure than the usual DES.
Hashing
A hash function takes an input string (numbers, alphabets, media files) of any length and
transforms it into a fixed length. The fixed bit length can vary (like 32-bit or 64-bit or 128-bit
or 256-bit) depending on the hash function which is being used. The fixed-length output is
called a hash. This hash is also the cryptographic by product of a hash algorithm. The
following properties of cryptographic hashing makes the blockchain data structure
functionally powerful.
Bitcoin uses SHA- 256 hash function that produces a hash of size 256 bits(32 bytes).
The following properties of cryptographic hashing makes the blockchain data structure
functionally powerful:
1.Collision free :It is impossible to find two input texts input texts that produces the same
has value.
2.Easy to Generate : It is easy to generate a hash value for a particular input using hash
function.
3.Irreversible: It is impossible to generate original text from the hash value.
4.Commitment: It is not feasible to modify the original text without resulting a change in
hash value thus enabling data integrity.
Digital Signature
Digital signature is a digital code which include with an electronically transmitted document
with this digital code we can verify first of all whether the content of the document is
authenticated or not.
Digital signatures are used in blockchain where the transactions are digitally signed by
senders using their private key before broadcasting the transactions to the network. Digital
signatures in blockchain use public key cryptography which is also known as asymmetric
cryptography.
• The message has been created by a known sender. This is also known
as authentication.
• The sender cannot deny having sent the message. This is known as non-repudiation.
• The messages has not been altered during transmission. This is integrity.
In the first step the transaction to be transmitted is hashed. Once the data is hashed, she
uses her private key to encrypt the hash. This encrypted hash is the digital signature. This
digital signature is embedded with the actual transaction and transmitted.
All network participants receive the digital message with digital signature including John.
John uses Sarah's public key to decrypt the digital signature. This generates the hash value
of the document.
John applies the same hash algorithm on the received transaction as well. This result is the
hash value of the received data.
John then compares both hash values. If the hash values match, its a proof that the data is
not altered and that it is owned by Sarah.
Crptocurrency
Cryptocurrency is a digital payment system that doesn't rely on banks to verify transactions.
It’s a peer-to-peer system that can enable anyone anywhere to send and receive payments.
Instead of being physical money carried around and exchanged in the real world,
cryptocurrency payments exist purely as digital entries to an online database describing
specific transactions. When you transfer cryptocurrency funds, the transactions are
recorded in a public ledger. Cryptocurrency is stored in digital wallets.
Cryptocurrency received its name because it uses encryption to verify transactions. This
means advanced coding is involved in storing and transmitting cryptocurrency data between
wallets and to public ledgers. The aim of encryption is to provide security and safety.
It has since become the most well-known cryptocurrency in the world. Its
popularity has inspired the development of many other cryptocurrencies.
Digital Currency Ethereum
Smart Contract
The agreements simply the exchange of shares, money, any asset or property.
There are two used programming languages for writing ethereum smart
contract as a solidity and Serpent.
A smart contract is a set of lines of code that is uploaded and stored to check a
contract’s validity and containing a set of rules under which the parties who
share the smart contract agree to interact with each other.
Security: Blockchain transactions records are encrypted and that makes them very hard to
hack. Protects data and transaction from fraud. It is impossible to change or update the data
inside a block.
2.Copy Righted Content: Smart contracts can protect ownership rights such as music or
books.
1. Voting
Blockchain technology has the ability to make the voting process more easily accessible
while improving security. Hackers would be no match to blockchain technology, because
even if someone were to access the terminal, they wouldn’t be able to affect other nodes.
Each vote would be attributed to one ID, and with the ability to create a fake ID being
impossible, government officials could tally votes more efficiently and effectively.
3.Capital Markets
For capital markets, blockchain unlocks easier, cheaper, and faster access to capital. It reduces
the barriers to issuance and enables peer-to-peer trading, faster and more transparent
settlement and clearing, reduced costs, decreased counterparty risks, and streamlined auditing
and compliance.
5. Real Estate
Enterprise Ethereum enables the digitization of assets and financial instruments. This enhances
fractionalization of ownership, expanded access to global markets, increased liquidity, and
democratized access to real estate investment opportunities.
SHA-256 is a cryptographic hash function that belongs to the SHA-2 (Secure Hash Algorithm
2) family. It was developed by the National Security Agency (NSA) in the United States and is
widely used in various applications, particularly in blockchain technology. SHA-256 is
designed to take an input of any length and produce a fixed-size 256-bit output, regardless
of the input size.
SHA-256 plays a critical role in ensuring the security and immutability of blockchain
networks, particularly in proof-of-work (PoW) consensus algorithms. Here's how SHA-256
contributes to blockchain security.
The SHA 256 starts by converting the message to a binary number and get length 1.
The objective of this padding is to prepare the message before the hash computation
begins. The padding ensures that the padded message is a multiple 512 bits.
Now we are going to parse the padded message.After the message padding,we now need to
parse the message in to 512 bit blocks before the hash computation can begin.
To parse , we will take each set of 8 bits and convert the elements i.e each 4 set of 8 bits
into hexadecimal values.
The hashing algorithm will then perform the necessary computations that
include the iterations to create the hash. We now feed the initialize hash
values that we have prepared before into the algorithms.
For the hash function computation, the algorithm will grab the message
that was divided into chunks and put it through 64 rounds of operations.
The output obtained in each round is fed as an input of the next
computation round.
we can see the 64 rounds of operations that will be performed in the 512-
bit message. Once that all the iterations are completed, we can complete
the hashing process.
Immutable Ledger
A ledger in blockchain is a digital record-keeping system that contains a history of
all transactions that have taken place on the blockchain. The ledger is maintained
by a network of nodes and is updated in real-time as transactions occur. Each
transaction is verified and recorded by the nodes, and once recorded, the
transactions are immutable, meaning that they cannot be altered or deleted.
Immutable ledger resides in the concept of the hash. If hacker tries to alter
anything in the block its hash will change.
Now the hash will no long match the previous hash in the second block. So, the
hacker would have to change the next block and the block after that etc.ven if
they were able to pull that off the blockchain belongs to multiple computers.
With the distributed peer to peer network, anyone who wishes to participate in
the process of verifying and validating blocks can set up a bitcoin node.
Blockchain mining is used to secure and verify bitcoin transactions .Mining is the
process by which new bitcoin is added to the money supply. The process by which
new coin generation is called mining.Bitcoin mining is the process of creating new
bitcoin by solving a computational puzzle.
Miners receive two types of rewards for mining that is new coins created with
each new block, and transaction fees from all the transactions included in the
block.
Working of Mining:
Blockchain mining is a process used to validate new transaction. Mining is an
essential activity in the blockchain network.
It is the way the peer-to-peer network verifies transactions and reaches common
consensus without requiring a central authority.
The mining process starts when miners are trying to validate new transaction and
record them on the blockchain.
The solution found is called PoW .When a block is solved, all the transactions
contained in the candidate block are considered validated, and the new block is
confirmed .
This new block will be appended to the blockchain. The time taken to confirm a
new block is approximately 10 minutes for bitcoin,but for other coins it is much
faster. So, if we send or receive bitcoins, it will take approximately 10 minutes for
the transactions to be confirmed. Miners receive a reward when they solve the
complex mathematical problem. There are two types of rewards namely new
bitcoins and transaction fees.
When the hash initiates, the block has been successfully mined and is directed to
the bitcoin blockchain network and has turned in to the identifier for the block.
In many cases the hash is not suceesful,so we need to alter the block to some
extent and try again and again.
Nonce
• A nonce refers to a number or value that can only be used once. Nonces
are often used on authentication protocols and cryptographic hash
functions.
• In the context of blockchain technology, a nonce refers to a pseudo-
random number that is utilized as a counter during the process
of mining.
• Nonce is a 32-bit(4byte) random number which can be used one time.
Nonce is often used on cryptographic hash functions and authentication
protocols.
• The nonce in a bitcoin block is a 32-bit field whose value is adjusted by
miners so that the hash of the block will be less than or equal to the
current target of the network.
• In the miners test and discard millions of nonce per second until they
find that golden nonce which is valid. Once, the golden nonce is found,
they can complete the block and add it to the blockchain and there by
receive the block reward.
• In cryptography, nonce is a random number that can be used just once
in a cryptographic communication. There will be some constant
information, timestamp, hash values with difficulty and the nonce which
when passed through hash algorithm, SHA-256 will become a new block
therefore nonce plays important role.
Cryptographic puzzle
• The nonce is varied until the hash value becomes smaller than equal to
the target value. Adding new blocks to the blockchain (called mining)
requires solving a moderately difficult cryptographic puzzle. This feature
prevents malicious attack in blockchain.
• To complete each other, miners will create puzzle and who solves the
puzzle first is able to add the block of the transaction to the blockchain.
Consensus Protocol
Consensus protocols form the backbone of blockchain by helping all the
nodes in the network verify the transactions.
Blockchain functions work as in a decentralized manner and records large
volume transactions in real-time so there are so many issues or complexity
of what is the truth is.
The key is to get consensus one way or another ,or else malicious things like
double spending attack can occur. To handle this consensus algorithm comes
in.
Proof of Work(PoW)
The Proof of Stake consensus algorithm differs with the PoW mining consensus with
a mechanism where blocks are validated based on the stake of the network
participants.
Under proof-of-stake (POS), validators are chosen based on the number of staked coins
they have.
Proof of Stake (PoS) system may execute the algorithm in different ways,in
general, the blockchain is secured by a pseudo random election process that
considers a nodes allocation and the allocation determining the commitment
of the party to ensure the network.
The Ethereum blockchain which is the world’s largest blockchain network in
terms of developer activity has initiated to switch from PoW to PoS in an
attempt to increase the network scalability and reduce excessive electicity
wastage.