UNIT1ANS
UNIT1ANS
A)
2) Crypto currency and how it is different from digital
currency?
A)
Traditional Bookkeeping Method:
Distributed ledger technology has the potential to effectively improve these traditional methods
of bookkeeping by updating and modifying fundamental methods of how data is collected,
shared, and managed in the ledger. To understand this, traditionally paper-based and
conventional electronic ledgers were used to manage data that had a centralized point of
control. These types of system require high computing resource and labour to maintain ledgers
and also had many points of failure. Points of failure like:
However, DLT allows real-time sharing of data with transparency which gives trust that data
in the ledger is up to date and legitimate. Also Distributed Ledger Technology eliminates the
single point of failure which prevents data in the ledger from being manipulations and errors.
In DLT, there is no need for a central authority to validate transactions here different consensus
mechanisms are used to validate transactions which eventually makes this process very fast
and real-time. Similarly, DLT can reduce the cost of transactions because of this process.
It is abbreviated as ‘number only used once’ and it is a number which blockchain miners are
finding and on average, it takes almost 10 times to find out the correct nonce. A nonce is a 32-
bit number, having the maximum value as 2^ (32) total possible value, so the job of the bitcoins
miners is to find out the correct integer value which is a random integer between 0 and 2^(32),
so it becomes computationally expensive.
2. Difficulty Target: The difficulty target is a value set by the network that
determines how difficult it is to find a valid hash. Miners must find a hash
value that is below the target difficulty to create a valid block. As the difficulty
target represents a specific number of leading zeros in the block hash, miners
adjust their nonce values to produce hashes that meet this requirement.
Secure Hashing Algorithm: 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.
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.
Blockchain is the backbone technology of the digital cryptocurrency Bitcoin. The blockchain
is a distributed database of records of all transactions or digital events that have been executed
and shared among participating parties. Each transaction is verified by many participants of the
system. It contains every single record of each transaction. A blockchain is a digital data storage
concept. This information is presented in chunks. These blocks are linked together to make the
data unchangeable. When a data block is linked with the other blocks, the data in that block
can never be altered again.
Consider the following picture, which depicts a collection of transaction data blocks.
A hash is a mathematical function that transforms an arbitrary length input into a fixed-length
encrypted output. This consensus algorithm is a collection of rules that regulates the operation
of a blockchain network. Aside from cryptocurrency, the most prevalent application of hash
functions is password storage.
The cryptographic functions have the traditional functions along with some security traits,
making them difficult to predict and determine the underlying content of the text or the
transaction.
Putting in simple words, just take any length input string and then end up with a string of a
fixed length through some work every time the hashing process needs to be done. That work is
hashing. To understand it better, look at the diagram below:
Figure 4. Understanding the Block Hash.
Example: Let’s say, for example, there is a hashing algorithm that takes an input string and
generates an output hash value.
Note: Even the slightest change in the structure of anything could have a huge impact on the
output charset generated by the hashing block.
Output: rVuSuWYq3oE1z0ROjBPjunQ7SJbMSPTgnj7slb2Uvo9Td4Tgay
1. Property #1: The definiteness: This means that no matter how many times a given input is
parsed using a hash function, the result will always be the same. This is essential since it will
be hard to keep track of the input if different hashes are obtained every time.
2. Property #2: Easy yet Rapid Generation: The hash function should be able to rapidly
return the hash of input. If the procedure is not rapid enough, the system will be inefficient.
3. Property #3: Former Image Resistance: As seen in the example above, the generated hash
should have no pre or former image resistance, even a small change should be able to create a
different hash block, else it will be easy to decode the transactions, something which is not
wanted.
4. Property #4: Data Integrity Check: The most typical use of hash functions is data integrity
checking. It is used to compute checksums for data files. This program offers the user assurance
that the data is correct. The integrity check assists the user in detecting any modifications to
the original file. It does not, however, guarantee the originality of the work. Instead of changing
file data, the attacker can update the entire file, compute a new hash, and deliver it to the
recipient. This integrity testing program is only useful if the user is confident in the file’s
authenticity.
5. Property #5: Password Storage: Password storage is protected using hash functions.
Instead of saving passwords in clear text, most login procedures save password hash values to
a file. The Password file is made up of a table of pairs in the form (user ID, h(P)).
1. Distributed Ledger:
3. Cryptographic Security:
• Bitcoin uses the SHA-256 cryptographic hash function. This function takes an
input (in this case, the block data) and produces a fixed-size string of
characters. This hash acts as a unique digital fingerprint of the data. Even a
slight change in the input will produce a significantly different hash, which
helps in maintaining the immutability and security of the blockchain.
5. Transaction Verification:
• Each transaction is verified by multiple nodes within the network. Nodes use
digital signatures to validate the authenticity of the transactions, ensuring that
bitcoins are not spent more than once (preventing double-spending) and that
the sender has sufficient balance to make the transaction.
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:
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
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:
SHA-256 in Bitcoin
SHA-256 is a cryptographic algorithm that takes an input (or message) and produces
a fixed-size string of characters, which is typically a 64-character hexadecimal
number. Regardless of the size of the input, the output will always be 256 bits long.
2. Deterministic:
• For any given input, SHA-256 will always produce the same output. This
determinism ensures that the same transaction will always hash to the
same value, which is vital for verifying data integrity .
3. Collision Resistance:
• It is computationally infeasible to find two different inputs that produce
the same hash output. This property, known as collision resistance,
ensures that each transaction can be uniquely identified by its hash .
4. Avalanche Effect:
• A small change in the input drastically changes the output hash. This
means that even a tiny alteration in a transaction's data will result in a
completely different hash, making it easy to detect changes and
ensuring data integrity
Working of SHA-256
1. Input Processing:
• The input message is first padded to ensure its length is a multiple of 512 bits.
Padding involves appending a single '1' bit followed by a series of '0' bits, and
finally, appending the length of the original message as a 64-bit integer.
2. Message Scheduling:
• The padded message is divided into 512-bit blocks. Each block is further
divided into 16 words of 32 bits each. These words are then expanded into a
schedule array of 64 words using bitwise operations.
3. Initialization:
• SHA-256 uses eight 32-bit initial hash values, which are derived from the
fractional parts of the square roots of the first eight prime numbers.
4. Compression Function:
• After all blocks have been processed, the final hash value is obtained by
concatenating the eight 32-bit words. This results in a 256-bit hash value.
Role of SHA-256 in Bitcoin
1. Block Hashing:
• In Bitcoin, each block contains a header, which includes metadata such as the
timestamp, the Merkle root (a hash of all transactions in the block), and the
hash of the previous block’s header. The block header is hashed twice using
SHA-256 to produce a unique identifier for the block, known as the block
hash.
3. Transaction Integrity:
SHA-256 Hash:
f8c2b5af27b874b16d4c89ff7819d4e8c317e6d50a70c8c1c8c3e7885a226d1a
In this example, the input string "Hello, Bitcoin!" is processed by the SHA-256
algorithm to produce a unique 256-bit hash.
10) Note on i) distributed ledger ii) consensus iii)
reward (incentive) iv) miner
A)
Distributed Ledger
A distributed ledger is a decentralized database that is shared and synchronized
across multiple sites, institutions, or geographies. It allows transactions to have public
"witnesses," thereby making a cyberattack more difficult. Each participant on the
network can access the recordings shared across that network and own an identical
copy of it. This decentralization ensures that no single entity has control over the
entire database, promoting transparency and reducing the risk of data tampering .
Consensus
Consensus in a blockchain context refers to the fault-tolerant mechanism used to
achieve agreement on a single state of the network among distributed processes or
systems. This is essential for validating and verifying transactions without a central
authority. Several types of consensus mechanisms exist, including Proof of Work
(PoW), Proof of Stake (PoS), and others. These protocols ensure that all nodes in the
network agree on the validity of transactions and maintain the integrity of the
blockchain .
Reward (Incentive)
In blockchain networks, particularly those using consensus mechanisms like Proof of
Work (PoW), miners or validators are incentivized through rewards. These rewards
often come in the form of newly created cryptocurrency tokens. For instance, in
Bitcoin, miners receive a block reward for solving complex mathematical problems
and adding a new block to the blockchain. This incentive system encourages
participation and helps secure the network by ensuring a continuous effort to
validate and record transactions .
Miner
A miner in the context of blockchain is a participant who uses computational power
to solve complex cryptographic puzzles, which allows them to add new blocks to the
blockchain. This process is typically associated with the Proof of Work (PoW)
consensus mechanism. Miners compete to solve these puzzles, and the first to solve
it gets the right to add the block to the blockchain and receive a reward. Miners play
a crucial role in maintaining the blockchain by validating transactions and securing
the network against attacks .
11) Consensus algorithms
A)
Proof-of-work (PoW)
PoW is the most common consensus mechanism used by the most popular cryptocurrency like Litecoin
and Bitcoin. The PoW is known as mining and the participated nodes in the process are known as
miners. In this, miners solve complex and difficult mathematical problems and puzzles with the help of
high computation power and high processing time. The first miner who solves the puzzle to create a
block gets a reward with cryptocurrency.
PoW is required to solve a complex problem. The node that can solve the problem obtains the right to
add a new block into the blockchain.
Figure 1 shows the flowchart of the PoW consensus process. A miner computes the SHA256 of a block
header which contains a fixed value and a variable value (nonce). The fixed value is computed apriori
from the transaction information in all blocks. The miner obtains all rights to add a block to the
blockchain network, if the computed value is less than the target value. For computed value greater than
the target value, the value of nonce is changed, and the hash of the header is computed. The above
process continues until the header’s computed hash value is less than the target value. Solving the
problem is an intensive task. Nodes adjust the nonce value and compute the hash of the header until it
is less than the target value.
Figure: 1 Proof-of Work Consensus Protocol
Proof-of-Stake (PoS)
PoS is the second most common consensus mechanism alternative to PoW. It uses low energy, less
processing time, low cost, low computational power than PoW. In this consensus mechanism, it uses a
randomized method to choose who gets to create a next new block in the chain. Instead of miners,
validators are present in PoS. The users can stake their tokens to become a validator which means they
lock their money for a certain period to create a new block.
In PoW, nodes invest their resources and computation power in solving a complex problem. PoW
algorithm requires a high computation of power for mining, which leads to increased energy usage.
Moreover, the transaction rate of PoW is low. In PoS, nodes put a certain coin at stake to become a part
of the validation process. The more a node has a stake, the higher the chance of becoming a validator.
The validator is chosen pseudo-randomly and becomes a part of the consensus algorithm. A node having
the highest stake can monopolize the validation process.
Figure: 2 Proof-of Stake Consensus Protocol
• Tolerates Malicious Actors: BFT systems are designed to function correctly even
when some nodes in the system are compromised and behave arbitrarily or
maliciously.
• Consensus Mechanism: BFT consensus algorithms require more complex
mechanisms to ensure that all non-faulty nodes agree on the same state. Examples
include Practical Byzantine Fault Tolerance (PBFT) and Delegated Byzantine Fault
Tolerance (dBFT).
• Higher Overhead: Due to the need to handle malicious behavior, BFT systems often
have higher computational and communication overhead compared to simpler
consensus mechanisms like those used in CFT.
Crash Fault Tolerance (CFT)
Crash Fault Tolerance refers to the ability of a distributed system to handle failures
where nodes simply crash and stop functioning but do not act maliciously or send
incorrect data.
• Handles Non-Malicious Failures: CFT systems are designed to handle nodes that
fail by crashing but not those that exhibit arbitrary or malicious behavior.
• Simpler Consensus Mechanisms: CFT systems typically use simpler and less
resource-intensive consensus mechanisms such as Paxos or Raft.
• Lower Overhead: Because they only need to handle crash failures, CFT systems
generally have lower computational and communication overhead compared to BFT
systems.
Summary
• BFT is more robust as it can handle both crashes and malicious behavior but requires
more complex and resource-intensive consensus algorithms.
• CFT is simpler and more efficient but can only handle crashes and not malicious
behavior
1. Immutability:
• Once a block is added to the blockchain, it cannot be altered. This is crucial
for maintaining the integrity of the data stored within the blockchain.
2. Cryptography:
3. Consensus Protocols:
• Consensus mechanisms like Proof of Work (PoW) and Proof of Stake (PoS) are
used to validate transactions and add them to the blockchain. These protocols
ensure that all nodes in the network agree on the state of the blockchain,
preventing fraudulent activities.
4. Decentralization:
5. Secure Transactions:
1. Anonymity:
2. Data Encryption:
3. Permissioned Blockchains:
• In permissioned blockchains, access to the network is restricted to certain
verified participants. This ensures that only authorized individuals can
participate in the network, providing an additional layer of privacy and
security.
4. Selective Disclosure:
5. Privacy-Preserving Techniques:
Merkle tree also known as hash tree is a data structure used for data verification and
synchronization.
It is a tree data structure where each non-leaf node is a hash of its child nodes. All the leaf
nodes are at the same depth and are as far left as possible.
It maintains data integrity and uses hash functions for this purpose.
Hash Functions:
So before understanding how Merkle trees work, we need to understand how hash functions
work.
A hash function maps an input to a fixed output and this output is called hash. The output is
unique for every input and this enables fingerprinting of data. So, huge amounts of data can be
easily identified through their hash.
This is a binary Merkle tree, the top hash is a hash of the entire tree.
• This structure of the tree allows efficient mapping of huge data and small changes made
to the data can be easily identified.
• If we want to know where data change has occurred, then we can check if data is
consistent with root hash and we will not have to traverse the whole structure but only
a small part of the structure.
• The root hash is used as the fingerprint for the entire data.
Applications:
• Merkle trees are useful in distributed systems where same data should exist in multiple
places.
• Merkle trees can be used to check inconsistencies.
• Apache Cassandra uses Merkle trees to detect inconsistencies between replicas of entire
databases.
• It is used in bitcoin and blockchain.