0% found this document useful (0 votes)
25 views

Question Bank Answers

Uploaded by

ledasi2421
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Question Bank Answers

Uploaded by

ledasi2421
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 50

1.

List out the challenges associated with making resources accessible in a


distributed environment.

● Naming
● Access control
● Security
● Availability
● Performance
● Mutual exclusion of users, fairness
● Consistency in some cases

2. Why is Distribution required in BlockChain Technology?

● Sharing of information and services


● Possibility to add components improves
○ Availability
○ Reliability
○ fault tolerance
○ performance
○ scalability

3. List out the goals of Distributed Systems.

● Making resources accessible


● Distribution transparency
● Openness
● Scalability
● Security
● System design requirements

4. What do you mean by byzantine faults?

● Byzantine fault is the one where the faulty node exhibits malicious or
inconsistent behavior arbitrarily.
● difficult to handle since it can create confusion due to misleading information.
● This can be a result of an attack by adversaries, a software bug, or data
corruption.
● State machine replication protocols such as PBFT used to handle this fault.
5. List out the challenges in Distributed System Design.

● Coordination between nodes


● Fault tolerance
○ Even if some of the nodes become faulty or network links break,
the distributed system should tolerate
○ The Distributed System should continue to work flawlessly in
order to achieve the desired result.
○ Several algorithms and mechanisms have been proposed to
overcome these issues.
● Distributed systems are so challenging to design that a theorem known
as the CAP theorem has been proved and states that a distributed system
cannot have all much desired properties simultaneously.

6. What are peer to peer networks?

● Peers refer to the nodes or computers that perform the same tasks and
have the same power within a block chain network,
● is based on the decentralization concept, which lets network participants
conduct transactions without needing any middle- man, intermediaries
or central server.
● no administrator is required to maintain track of user transactions on the
network.
● the peers in the network cooperate to handle deals and manage the BTC
● no common P2P protocol for blockchains has been suggested.
● Instead, different cryptocurrencies have developed and adapted their
own peer-to- peer protocols.

7. How do peer to peer networks work?

● all nodes (peers) are connected to one another.


● A mesh network with a "flat" topology connects the network nodes and
there is no hierarchy.
● Each node on the network must serve as both a client and a server to
other nodes in a P2P network, making it distinct from a traditional
client-server setup.
● In a decentralized setup, each node acts as a server that can download
files and share them with other nodes.
● A node may perform both the sharing and receiving functions
concurrently, which accounts for the P2P network's speed, security and
efficiency.
8. Differentiate the different types of peer to peer networks.

● Structured peer-to-peer networks


○ nodes interact based on an organized structure, enabling nodes to
precisely search for files, even if the content is unavailable.
○ However, due to an organized system, some sort of centralization
exists in structured P2P networks.
○ structured peer-to-peer networks are challenging to set up,
although they provide simple data access.
● Unstructured peer-to-peer networks
○ There is no set structure for the nodes in this kind of network,
allowing network participants to join or leave the network as they
desire.
○ Also, due to a lack of definite structure, participants converse
with one another at random.
○ However, unstructured P2P networks require all nodes to remain
active to power a high number of transactions, mandating huge
CPU power to ensure that the network runs properly.
● Hybrid peer-to-peer networks
○ This type of P2P network mixes some P2P design aspects with
the traditional client- server approach.
○ For example, it makes it possible to locate a node using the
central server.
○ A distributed network application framework called the
client-server architecture assigns tasks to servers and clients in
the same system that connect via a computer network or the
Internet.

9. What are the benefits of Peer To Peer Block chain network?

● No single point of failure


● May withstand attacks reasonably well since they are decentralized.
● blockchains using P2P architecture cannot restrict network participants
from doing a transaction.
● cost-effective because they do not require a network operating system.
● network can readily accommodate an increase in load if
● many new peers join it at once.
● The loss of a single peer has little effect on the network as a whole.
10. Differentiate between name node and data node.

● NameNode :
○ aka master node
○ Manages all the slave nodes
○ Executes operations like opening,closing and renaming files
○ Stores metadata and requires high amount of ram
○ A single point of failure
● DataNode :
○ aka Slave Node
○ Does the actual work of reading,writing and processing the files
○ They also perform creation deletion and replication upon
instruction from the master node
○ Requires high memory as data is stored here

11. Illustrate how data is stored in HDFS with a suitable diagram.


12. Why do the blocks replicate in data nodes while storing?

Let's assume we don't replicate and only one yellow block is present on
datanode D1. Now if the data node D1 crashes we will lose the block and
which will make the overall data inconsistent and faulty. So we replicate the
blocks to achieve fault-tolerance.
Note: No two replicas of the same block are present on the same datanode.

13. Define the term BlockChain

Layman's definition: Blockchain is an ever-growing, secure, shared record


keeping system in which each user of the data holds a copy of the records,
which can only be updated if all parties involved in a transaction agree to
update.

Technical definition: Blockchain is a peer-to-peer, distributed ledger that is


cryptographically- secure, append-only, immutable (extremely hard to change),
and updateable only via consensus or agreement among peers.

14. What do you mean by the “Append-Only” feature in Blockchain?

● blockchain is append-only, which means that data can only be added to


the blockchain in time-ordered sequential order.
● blockchain is indeed immutable and cannot be changed

15. Explain the generic elements of a block chain with suitable diagrams.
1. Address
● Unique identifiers used in a transaction on the blockchain.
● They can be reused
● Good practice is for users to generate new address for each transaction to
prevent identification
2. Transaction
● fundamental unit of a blockchain.
● represents a transfer of value from one address to another.
● Each transaction includes details such as the sender’s address, recipient’s
address, amount, and digital signature, which authenticates and authorizes
the transfer.
3. Block
● composed of multiple transactions and some other elements such as the
previous block hash (hash pointer), timestamp, and nonce.
● Blocks are linked in chronological order to form the blockchain

4. Nodes
● performs various functions depending on the type of the blockchain used and
the role assigned to the node.
● 2 types of nodes -> full and light nodes
● Full nodes: store a complete copy of the Blockchain ledger
● Light nodes: only store the necessary data to verify transactions.

5. Smart Contract
● These programs run on top of the blockchain and encapsulate the business
logic to be executed when certain conditions are met.
● The smart contract feature is not available in all blockchains but is now
becoming a very desirable feature due to the flexibility.
● Enforceable and automatically executable

6. Virtual Machine
● is an extension of a transaction script
● allows Turing complete code to be run on a Blockchain
● Various blockchains use virtual machines to run programs, for example
Ethereum Virtual Machine (EVM) is used in Ethereum and Chain Virtual
Machine (CVM) used in chain core

7. State Machine
● can be viewed as a state transition mechanism.
● a state is modified from its initial form to the next and eventually to a final form
as a result of a transaction execution and validation process by nodes.
16. Compare and contrast the different types of blockchain. Also List out the
Benefits and limitations of block chain.

1. Public Blockchain
● They are open to the public, and anyone can participate as a node in the
decision-making process.
● Users may or may not be rewarded for their participation.
● These ledgers are not owned by anyone and are publicly open for anyone to
participate in.
● All users maintain a copy of the ledger on their local nodes
● Ex: Bitcoin and Ethereum

2. Private Blockchains
● open only to a consortium or group of individuals or organizations who have
decided to share the ledger among themselves.
● Ex: HydraChain and Quorum.

3. Semi-private Blockchains
● Part of the blockchain is private and part of it is public.
● The private part is controlled by a group of individuals, while the public part is
open for participation by anyone.
● The primary goal is to promote organizational collaboration to address
industry-specific challenges.
● This is still just a concept today, and no real world POCs are yet to be
developed.

4. Permissioned ledger
● is a blockchain where participants of the network are already known and
trusted.
● do not need to use a distributed consensus mechanism
● an agreement protocol is used to maintain a shared version of the truth about
the state of the records on the blockchain.
● There is also no requirement for a permissioned blockchain to be private as it
can be a public blockchain but with regulated access control.

5. Fully private and proprietary Blockchains


● restricted to specific, authorized participants, with a single organization
controlling access and data
● It ensures high privacy and security, making it suitable for internal, sensitive
business operations.
● Even in private blockchains, tokens are not really required, but they can be
used as means of transferring value or representing some real- world asset.

6. Tokenized blockchains
● These blockchains are standard blockchains that generate cryptocurrency as
a result of a consensus process via mining or initial distribution.
● Ex: Bitcoin and Ethereum
7. Tokenless blockchains
● designed in such a way that they do not have the basic unit for the transfer of
value
● However, they are still valuable in situations where there is no need to
transfer value between nodes and only the sharing of data among various
trusted parties is required.
● This is similar to full private blockchains, the only difference being that use of
tokens is not required

BENEFITS

● Decentralization
● Transparency and trust
● Immutability
● High availability
● Highly secure
● Simplification of current paradigms
● Faster dealings
● Cost saving

LIMITATIONS

● Scalability
● Adaptability
● Regulation
● Relatively immature technology
● Privacy

17. Differentiate between byzantine Fault Tolerance based consensus and


Leader Election based consensus algorithm.

1. Traditional Byzantine Fault Tolerance (BFT)-based:

● relies on a simple scheme of nodes that are publisher-signed messages.


● Eventually, when a certain number of messages are received, then an
agreement is reached.
● perform well when there are a limited number of nodes, but they do not scale
well.

2. Leader election-based consensus mechanisms:

● requires nodes to compete in a leader- election lottery, and the node that wins
proposes a final value.
● scale very well but perform very slowly.
● For example, the PoW used in Bitcoin falls into this category
● Proof-based, leader-election lottery based, or the Nakamoto consensus
whereby a leader is elected at random (using an algorithm) and proposes
a final value. This category is also referred to as the fully decentralized
or permissionless type of consensus mechanism. This type is well used
in the Bitcoin and Ethereum blockchain in the form of a PoW
mechanism. Scale very well but perform very slowly.
● BFT-based is a more traditional approach based on rounds of votes. This
class of consensus is also known as the consortium or permissioned
type of consensus mechanism. Perform well when there are a limited
number of nodes, but they do not scale well.

18. List and explain the different types of consensus mechanisms used in block
chain technology.

1. Proof of Work
● relies on proof that adequate computational resources have been spent
before proposing a value
● This scheme is used in Bitcoin, Litecoin, and other cryptocurrency
blockchains.
● only algorithm that has proven to be successful against any collusion attacks
like Sybil attack

2. Proof of Stake
● works on the idea that a node or user has an adequate stake in the system;
that is, the user has invested enough in the system so that any malicious
attempt by that user would outweigh the benefits of performing such an attack
on the network.
● Introduced by Peercoin and used in the Ethereum blockchain version called
Serenity.
● Coin Age -> criterion derived from the amount of time and number of coins
that have not been spent.
● chances of proposing and signing the next block increase with the coin age.

3. Delegated Proof of Stake


● Innovation over standard PoS
● Each node that has a stake in the system can delegate the validation of a
transaction to other nodes by voting.
● used in the BitShares blockchain.

4. Proof of Importance
● not only relies on how large a stake a user has in the system, but it also
monitors the usage and movement of tokens by the user in order to establish
a level of trust and importance.
● used in the NEM coin blockchain.
5. Proof of Capacity
● uses hard disk space as a resource to mine the blocks.
● Different from PoW, where CPU resources are used.
● also known as hard drive mining
● first introduced in the Burstcoin cryptocurrency.

6. Proof of Elapsed time


● uses a Trusted Execution Environment (TEE) to provide randomness and
safety in the leader election process via a guaranteed wait time.
● requires the Intel Software Guard Extensions (SGX) processor to provide the
security guarantee for it to be secure.

7. Proof of activity
● combination of PoS and PoW
● ensures that a stakeholder is selected in a pseudorandom but uniform
fashion.
● comparatively more energy-efficient mechanism as compared to PoW
● utilizes a new concept called Follow the Satoshi
● POW - first stage POS - other stages

8. Proof of Deposit
● Nodes that wish to participate in the network have to make a security deposit
before they can mine and propose blocks.
● This mechanism is used in the Tendermint blockchain.

9. Byzantine Fault Tolerance


● achieves state machine replication, which provides tolerance against
Byzantine nodes

19. Write a suitable scenario where the following consensus algorithms can be
used.

Proof of work
● When security is of utmost importance irrespective of time and
computer resources. An example given is Bitcoin.

Proof of stake
● A user wants to use a blockchain for quick transactions and lesser
computational resources are available

Delegated proof of stake


● participants vote to select a small group of trusted nodes to validate
transactions.
Proof of Lapsed time
● User is on a permissioned ledger where all the nodes have been
pre-authenticated and only a leader has to be elected to provide
consensus

Proof of deposit
● If the user enters the blockchain purely for transactions and needs them
to be done quickly

Proof of importance
● when reliability is important, but the system allows for unauthorized
users to also participate in the blockchain.

Federated byzantine consensus


● Ideal for networks that need to process high-speed transactions while
maintaining security through a group of trusted nodes

Proof of activity
● This consensus is suitable for networks that want both security and
energy efficiency.

Proof of capacity
● When a network wants to leverage hard drive storage instead of
computational power.

Proof of storage
● Suitable for decentralized storage networks where participants are
rewarded based on the amount of storage they contribute, such as
Filecoin.

20. “A distributed system cannot have consistency, availability, and partition


tolerance simultaneously” - Justify

● Consistency is a property which ensures that all nodes in a distributed


system have a single, current, and identical copy of the data.
● Availability means that data is available at each node and the nodes are
responding to requests.
● Partition tolerance ensures that if a group of nodes is unable to
communicate with other nodes due to network failures, the distributed
system continues to operate correctly.
● In blockchains, consistency is sacrificed in favor of availability and
partition tolerance.
● Consistency (C) on the blockchain is not achieved simultaneously with
Partition tolerance (P) and Availability (A), but it is achieved over time.
● This is called eventual consistency, where consistency is achieved as a
result of validation from multiple nodes over time

21. Illustrate the working model of the public-key cryptography signature


scheme with a suitable diagram.
22. Explain the working principle of the RSA digital signature algorithm with
a suitable diagram.

● provide a means of associating a message with an entity from which the message
has originated. Used to provide data origin authentication and non-repudiation

1. Calculate the hash value of the data packet:


● This will provide the data integrity guarantee as the hash can be computed at
the receiver's end again and matched with the original hash to check whether
the data has been modified in transit.
● message signing can work without hashing the data first, but is considered
insecure

2. Signs the hash value with the signer's private key:


● As only the signer has the private key, the authenticity of the signature and
the signed data is ensured.

● Authenticity -> digital signatures are verifiable by a receiving party.


● Unforgeability -> only the sender of the message can use the signing functionality
using the private key.
● Non Reusability -> digital signature cannot be separated from a message and used
again for another message.

If user wants to send an authenticated message to a receiver there are 2 ways:

1. Sign then encrypt


● the sender digitally signs the data using the private key
● appends the signature to the data
● then encrypts the data and the digital signature using the receiver's
public key

2. encrypt then sign


● the sender encrypts the data using the receiver's public key and then
digitally signs the encrypted data.
23. Explain the security properties of Message Authentication Codes.

1. Preimage resistance
● h(x) = y
● h is the hash function, x is the input, and y is the hash.
● The first security property requires that y cannot be reverse-computed to x.
● x is considered a preimage of y, hence the name preimage resistance
● This is also called a one-way property.

2. Second Preimage resistance


● m != x and h(m) = h(x)
● The second preimage resistance property requires that given x and h(x)
● it is almost impossible to find any other message m
● This property is also known as weak collision resistance.
● Focuses on the difficulty of finding a second input that matches the hash of a
specific given input.
● This property prevents an attacker from creating a different message with the
same hash as a specific given message.

3. Collision resistance
● h(x) != h(z)
● The collision resistance property requires that two different input messages
should not hash to the same output.
● This property is also known as strong collision resistance.
● Focuses on the difficulty of finding any two distinct inputs that produce the
same hash.
● This property ensures that it is difficult to find any two different messages that
hash to the same value, without specifying one of the messages beforehand.

24. List out the various types of security protocols

Various types of security protocols – authentication protocols, non-repudiation


protocols, and key management protocols.
25. Explain the working principle of SHA-256 algorithm with suitable
illustrations. (one round compression function)

● SHA-256 has the input message size < 264-bits. Block size is 512-bits, and it haFlis
a word size of 32-bits. The output is a 256-bit digest.

1. Preprocessing
● Padding of the message is used to adjust the length of a block to 512-bits if it
is smaller than the required block size of 512-bits
● Parsing the message into message blocks, which ensures that the message
and its padding is divided into equal blocks of 512-bits.
● Setting up the initial hash value, which consists of the eight 32-bit words
obtained by taking the first 32-bits of the fractional parts of the square roots of
the first eight prime numbers
● These initial values are randomly chosen to initialize the process, and they
provide a level of confidence that no backdoor exists in the algorithm.

2. Hash Computation
● Each message block is then processed in a sequence, and it requires 64
rounds to compute the full hash output.
● Each round uses slightly different constants to ensure that no two rounds are
the same.
● The message schedule is prepared.
● Eight working variables are initialized.
● The intermediate hash value is calculated.
● Finally, the message is processed, and the output hash is produced

● In the preceding diagram, a, b, c, d, e, f, g, and h are the registers. Maj and Ch are
applied bitwise.
● Σ0 and Σ1 perform bitwise rotation.
● Round constants are Wj and Kj, which are added, mod 232.
26.Give an appropriate scenario where the following wallets can be
used.
a. Non deterministic wallets
b. Brain Wallets
c. Mobile Wallets
d. Online Wallets
e. Hierarchical Deterministic Wallets
f. Paper Wallets

1. Non Deterministic wallets


● These wallets contain randomly generated private keys and are also called
just a bunch of key wallets.
● The Bitcoin core client generates some keys when first started and generates
keys as and when required.
● Managing a large number of keys is very difficult and an error-prone process
can lead to theft and loss of coins.

2. Deterministic wallets
● In this type of wallet, keys are derived out of a seed value via hash functions.
This seed number is generated randomly and is commonly represented by
human-readable mnemonic code words.
● Mnemonic code words are defined in BIP 39, a Bitcoin improvement proposal
for mnemonic code for generating deterministic keys.
● Makes the Private key management easier

3. Hierarchical Deterministic wallets


● Hierarchical Deterministic (HD) wallets store keys in a tree structure derived
from a seed.
● The seed generates the parent key (master key), which is used to generate
child keys and, subsequently, grandchild keys.
● Key generation in HD wallets does not generate keys directly; instead, it
produces some information (private key generation information) that can be
used to generate a sequence of private keys.
● Very easy to maintain and are highly portable.
● Ex: Trezor, Jaxx, Electrum

4. Brain wallets
● The master private key can also be derived from the hash of passwords that
are memorized.
● The key idea is that this passphrase is used to derive the private key and if
used in HD wallets, this can result in a full HD wallet that is derived from a
single memorized password.
● This method is prone to password guessing and brute force attacks.
5. Paper wallets
● As the name implies, this is a paper-based wallet with the required key
material printed on it.
● It requires physical security to be stored.

6. Hardware wallets
● Another method is to use a tamper-resistant device to store keys. This
tamper-resistant device can be custom built
● or with the advent of NFC-enabled phones, this can also be a Secure
Element (SE) in NFC phones.
● Trezor and Ledger wallets (various types) are the most commonly used
Bitcoin hardware wallets

7. Online wallets
● Online wallets, as the name implies, are stored entirely online and are
provided as a service usually via the cloud.
● They provide a web interface to the users to manage their wallets and
perform various functions such as making and receiving payments.
● They are easy to use but imply that the user trusts the online wallet service
provider.

8. Mobile wallets
● Mobile wallets, as the name suggests, are installed on mobile devices.
● They can provide various methods to make payments, most notably the ability
to use smartphone cameras to scan QR codes quickly and make payments.
● Mobile wallets are available for the Android platform and iOS

27.Illustrate the following scenario using protocol messages with a


suitable diagram.
Alice wants to establish communication with bob. She needs to send a
transaction as a response to the getdata protocol message. Also she
wants to know the information about all of her peers.

1. Alice sends a version message to Bob, indicating her intent to establish


communication. This message typically includes her protocol version,
node ID, timestamp, and other details about her node.
2. Bob responds with a version message of his own, acknowledging Alice’s
request and establishing his end of the connection.
3. Bob sends a verack (version acknowledgment) message to Alice to
confirm he has received and validated her version message.
4. Alice responds with her own verack message, completing the handshake
and allowing them to communicate further.
5. Bob sends a getdata message to Alice, requesting a specific transaction or
data he needs from her.
6. Alice responds with a tx (transaction) message, providing the transaction
data Bob requested.
7. Alice wants to know information about her peers, so she sends a getaddr
message to Bob, requesting addresses of her peers.
8. Bob responds with an addr message, listing addresses of peers that Alice
can connect to
28.Explain the working principle of the mining algorithm with a suitable
diagram.

1. The previous hash block is retrieved from the bitcoin network.


2. Assemble a set of potential transactions broadcasted on the network into a block.
3. Compute the double hash of the block header with a nonce and the previous hash
using the SHA256 algorithm.
4. If the resultant hash is lower than the current difficulty level (target), then stop the
process.
5. If the resultant hash is greater than the current difficulty level (target), then repeat the
process by incrementing the nonce.

● As the hash rate of the bitcoin network increased, the total amount of 32-bit nonces
was exhausted too quickly.
● In order to address this issue, the extra nonce solution was implemented, whereby
the coinbase transaction is used as a source of extra nonce to provide a larger range
of nonces to be searched by the miners.

29.Write down the command to know the current network target


difficulty level to generate a hash.

bitcoin-cli getdifficulty
30.Represent a genesis block with a suitable diagram.

● This is the first block in the Bitcoin blockchain.


● Bitcoin provides protection against double spending by enforcing strict rules
on transaction verification and via mining.
● Transactions and blocks are added in the blockchain only after strict rule
checking explained earlier in the Transaction verification section and
successful PoW solution
● Each block contains one or more transactions, out of which the first
transaction is a coinbase transaction.

31.Draw a Merkle tree to achieve Merkle Root as HABCDEFGHIJKLMNOP.


32. “Alice wants to use her bitcoins to pay for some goods which Bob is
selling through the bitcoin network.” - How will double spending be
possible for the following scenario? Give Explanation to prevent the
double spending with suitable illustrations.

● Assume Alice wishes to pay Bob $1. If Alice and Bob pay with
actual currency, Alice will lose the $1 when the transaction is
completed.
● The dilemma becomes more difficult if Alice and Bob use digital
money.
● Digital money is in the form of a digital file that can be easily
copied. If Alice sends Bob a $1 digital file over email, for example,
Bob has no way of knowing if Alice has deleted her copy of the
file.
● If Alice still has the $1 digital file, she has the option of sending it
to Carol.
● Double spending is the term for this issue.
● If Alice sends money in digital format to Bob. Bob cannot know
for sure if Alice has deleted her copy of the file and she can choose
to send the same file to Carol.
● To avoid double spending, blockchain networks use a consensus
mechanism, like Proof of Work or Proof of Stake, which requires
all transactions to be validated by the majority of nodes before
being added to the blockchain.
● Additionally, each transaction includes unique cryptographic
signatures and references previous transaction outputs, ensuring
that each coin can only be spent once.

33. Write a Script to send 10BTC to the anonymous receiver using


P2PKH and P2SH in the Bitcoin Network.
34. Calculate a Network Difficulty of a block chain network for the
given scenario. Previous network target of the block chain is 500 and
time taken to add a new block in the current block chain is 20
minutes.

Target = Previous target * Time/2016 * 10 minutes


35. Assume that a node is proposing a new transaction in the block
chain network. Maximum Size of the block chain is 500 bytes. Output
value of the proposed transaction is 1000 BTC. nLock time of the
proposed transaction contains 15 bits. Number of Signature
operation required is 3 and the proposed transaction receives 15
confirmations after the successful execution of PoW. Size of the
proposed block is 250 bytes. Verify whether the given transaction is
valid or not. Justify your answer.

36.Define the term “Bit Coin”

Bitcoin is a peer to peer electronic cash, a digital money that can be


transferred between people or computers without any trusted
middleman(such as a bank or government), and whose issuance is not
under the control of any single party on which everyone trusts.

37. Illustrate the process of node discovery protocol in the bitcoin


network with suitable examples.
How does peer discovery work in a peer to peer network?
38.Compare and contrast Full node and SPV nodes in the Bitcoin
network.

1. Full Nodes: are implementations of Bitcoin core clients performing the


wallet, miner, full blockchain storage, and network routing functions.
However, it is not necessary to perform all these functions.

2. Simple Payment Verification (SPV) nodes or lightweight clients


perform only wallet and network routing functionality. The latest version
of Bitcoin protocol is 70015 and was introduced with Bitcoin core client
0.13.2

39. Assume that you are asked to establish a peer to peer connection
among non standard nodes in the bitcoin network. Identify suitable
protocol to do so and justify your answer.

● stratum protocol - compute hashes to submit their solutions to the


mining pool.
● Mining Nodes: Perform mining functions only.
● Stratum is also a line-based protocol that makes use of plain TCP
sockets and human-readable JSON-RPC to operate and
communicate between nodes.
● Stratum is commonly used to connect to mining pools
40.Identify the type of wallet used in the following scenarios and explain
the steps to be followed to make the payment.

Mr.X uses a wallet which stores randomly generated private keys for
making payments in the bitcoin network. -> Non Deterministic wallet
Mr.X uses a wallet in which keys are derived out of a seed value via
hash functions. -> Deterministic wallet
Mr.X uses a wallet which stores private keys in a tree structure
derived from a seed. -> Hierarchical Deterministic wallets
Mr.X uses a wallet in which master private key can also be derived
from the hash of passwords that are memorized -> Brain wallets
Mr.X uses a wallet which uses a tamper-resistant device to store keys.
-> Hardware wallets
Mr.X uses a wallet which provides various methods to make
payments, most notably the ability to use smartphone cameras to
scan QR codes quickly and make payments. -> Mobile wallets

41. Compare and contrast Hard Fork and Soft Fork in the Bitcoin
network.
HARD FORK

● A hard fork is a significant alteration of a blockchain's algorithms and code,which


results in either a completely new version of the blockchain or blockchain splitting
into two separate networks.
● Hard forks are often used to launch new crypto-projects.

SOFT FORK

● A soft fork is a minor change of a blockchain protocol that results in two parallel
versions of the protocol, meaning that all blockchain nodes operate on the same
network, but some of them under the old rules and some under the new ones.
● A soft fork is an improvement of the blockchain's performance, with the old and new
protocols functioning harmoniously in the same network.
42. Discuss briefly about the elements of the Ethereum block chain.

1. Keys and addresses


● used in Ethereum blockchain mainly to represent ownership and
transfer of Ether.
● Keys are used in pairs of private and public type.
● The private key is generated randomly and is kept secret whereas
a public key is derived from the private key.
● Addresses are derived from the public keys which are a 20-bytes
code used to identify accounts.
2. Accounts
● Accounts are one of the main building blocks of the Ethereum
blockchain.
● Operations performed between and on the accounts, represent
state transitions.
● Ethereum, being a transaction driven state machine, the state is
created or updated as a result of the interaction between accounts
and transaction execution.
3. Transactions and messages
● A transaction in Ethereum is a digitally signed data packet using
a private key that contains the instructions that, when completed,
either result in a message call or contract creation.
● Transactions can be divided into two types based on the output
they produce:
○ Message call transactions: This transaction simply
produces a message call that is used to pass messages from
one contract account to another.
○ Contract creation transactions: As the name suggests,
these transactions result in the creation of a new contract
account.
4. Ether cryptocurrency/tokens
● As an incentive to the miners, Ethereum also rewards its own
native currency called Ether, abbreviated as ETH.
● After the DAO hack, a hard fork was proposed in order to
mitigate the issue; therefore, there are now two Ethereum
blockchains: one is called Ethereum Classic, and its currency is
represented by ETC, whereas the hard-forked version is ETH
● ETH, is the currently the most active and official Ethereum
blockchain.
5. The EVM
● EVM is a simple stack-based execution machine that runs
bytecode instructions to transform the system state from one state
to another.
● EVM is a Turing-complete machine but is limited by the amount
of gas that is required to run any instruction.
● EVM is an entirely isolated and sandboxed runtime environment.
● The code that runs on the EVM does not have access to any
external resources, such as a network or filesystem.
● EVM is big-endian by design, and it uses 256-bit wide words.
6. Smart contracts
● Smart contracts are self-executing code stored on the blockchain.
● They run on the EVM and execute automatically when certain
conditions are met, enabling decentralized applications (DApps)
by automating processes without intermediaries.

43. List out the steps involved in Ethereum state transition functions.

1. Confirm the transaction validity by checking the syntax, signature


validity, and nonce.
2. The transaction fee is calculated, and the sending address is resolved
using the signature. Furthermore, the sender's account balance is
checked and subtracted accordingly, and nonce is incremented. An error
is returned if the account balance is not enough.
3. Provide enough Ether (gas price) to cover the cost of the transaction.
This is charged per byte incrementally proportional to the size of the
transaction.
In this step, the actual transfer of value occurs. The flow is from the
sender's account to the receiver's account. The account is created
automatically if the destination account specified in the transaction does
not exist yet. Moreover, if the destination account is a contract, then the
contract code is executed. This also depends on the amount of gas
available.
If enough gas is available, then the contract code will be executed fully;
otherwise, it will run up to the point where it runs out of gas.
4. In cases of transaction failure due to insufficient account balance or gas,
all state changes are rolled back except for fee payment, which is paid to
the miners.
5. Finally, the remainder (if any) of the fee is sent back to the sender as
change and fees are paid to the miners accordingly. At this point, the
function returns the resulting state which is also stored on the
blockchain.

44. Compare and Contrast the properties of Externally Owned Accounts and
Contract Accounts.

Externally Owned Accounts Contract Accounts.

EOAs has ether balance CAs have Ether balance.

They are capable of sending They can get triggered and execute
transactions code in response to a transaction or a
message from other contracts.

They have no associated code They have associated code that is


kept in memory/storage on the
blockchain.

They are controlled by private keys CAs can maintain their permanent
state and can call other contracts.

Accounts contain a key-value store CAs contain a key-value store.

They are associated with a human They are not intrinsically associated
user with any user or actor on the
blockchain.
45. What are the different types of transactions in Ethereum Blockchain?

Message call transactions: This transaction simply produces a message call


that is used to pass messages from one contract account to another.

Contract creation transactions: As the name suggests, these transactions


result in the creation of a new contract account.

46. List out the essential parameters that are required when creating an
account.

● Sender
● Original transactor (transaction originator)
● Available gas
● Gas price
● Endowment, which is the amount of ether allocated
● A byte array of an arbitrary length
● Initialization EVM code
● Current depth of the message call/contract-creation stack (current depth
means the number of items that are already there in the stack)

47. Compare and Contrast Decentralized Autonomous Organizations and


Decentralized Autonomous Societies.

● Decentralized Autonomous Organization (DAO) is also a computer


program that runs at top of a blockchain and embedded within it are
governance and business logic rules.
● The main difference, however, is that DAOs are autonomous, which
means that they are fully automated and contain artificially-intelligent
logic
● The Ethereum blockchain led the way with the initial introduction of
DAOs. In a DAO, the code is considered the governing entity rather
than people or paper contracts.
● However, a human curator maintains this code and acts as a proposal
evaluator for the community.
● DAOs are capable of hiring external contractors if enough input is
received from the token holders (participants).
● Decentralized Autonomous Societies (DASs) are a concept whereby
an entire society can function on a blockchain with the help of multiple,
complex smart contracts and a combination of DAOs and Decentralized
Applications (DApps) running autonomously.
● Many services that a government commonly offers can be delivered via
blockchains, such as government identity card systems, passports, and
records of deeds, marriages, and births.

48. List out the operations performed by DAPPS.

● Establishment of consensus by a DApp can be achieved using consensus


algorithms such as PoW and PoS.
● So far, only PoW has been found to be incredibly resistant to 51%
attacks, as is evident from Bitcoin.
● Furthermore, a DApp can distribute tokens (coins) via mining,
fundraising, and development.

49. Define the term “Smart Contract”.

● A smart contract is a secure and unstoppable computer program


representing an agreement that is automatically executable and
enforceable.
50. “Smart contracts are inherently required to be deterministic.” – Comment
on this statement.

● This property will allow a smart contract to be run by any node on a


network and achieve the same result.
● If the result differs even slightly between nodes, then consensus cannot
be achieved, and a whole paradigm of distributed consensus on
blockchain can fail.
● Moreover, it is also desirable that the contract language itself is
deterministic, thus ensuring integrity and stability of the smart contracts.
● Deterministic in the sense that there are no non-deterministic functions
used in the language, which can produce different results on various
nodes.
● A deterministic feature ensures that smart contracts always produce the
same output for a specific input.
● In other words, programs, when executed, produce a reliable and
accurate business logic that is entirely in line with the requirements
programmed in the high-level code.

51. List out the properties of smart contracts.

● Automatically executable
● Enforceable
● Semantically sound
● Secure and unstoppable

52. Compare and Contrast Bitcoin and Ethereum Block chain.

Bitcoin Ethereum

Bitcoin runs on the SHA-256 Ethereum runs on the Keccak-256


hash algorithm. hash algorithm.

Assets of Bitcoin is BTC Assets of Ethereum is Ether.

The Proof-of-Work (PoW) is the The Proof-of-Stake is the


consensus mechanism used by the consensus mechanism used by
Bitcoin network. Ethereum.

Energy consumption is very high. Energy consumption is very low


as compared to bitcoin

Structure of bitcoin is simple and Structure of Ethereum is complex


robust. and feature rich

Generally, bitcoin transactions are Generally, bitcoin transactions are


only for keeping notes. only for keeping notes.
Ethereum transactions may
contain some executable code.

The block time of bitcoin is 10 The block time of Ethereum is 14


minutes. to 15 seconds.
53. Write a syntax to define a function in solidity language.

function <name of the function> (<parameters>) <visibility specifier> returns


(<return data type> <name of the variable>)
{
<function body>
}

54. Write a structure for input parameters and output parameters of a


function in solidity language.

contract myContract -> input parameters


{
function checkValues(uint x, uint y)
{
}
}

contract myContract -> output parameters


{
function getValue() returns (uint z)
{
z=x+y;
}
}
55. Illustrate the issues in solidity language using suitable examples. (Solidity
programs)
56. List out the various functionalities performed by iterators in Ethereum
Virtual Machine.

The iterator performs various functions that are used to set the next state of the
machine and eventually the world state. The functions include;

● It fetches the next instruction from a byte array where the machine code is stored in
the execution environment.
● It adds/removes (PUSH/POP) items from the stack accordingly.
● Gas is reduced according to the gas cost of the instructions/opcodes.
● It increments the Program Counter (PC).

57. Describe the implementation of chain code in hyperledger fabric.

● Chaincode is usually written in Golang or Java.


● Chaincode can be public , confidential, or access controlled.
● These code files serve as a smart contract that users can interact with via
APIs.
● Users can call functions in the chaincode that result in a state change,
and consequently updates the ledger.
● There are also functions that are only used to query the ledger and do
not result in any state change.
● Chaincode implementation is performed by first creating the chaincode
shim interface in the code.
● Shim provides APIs for accessing state variables and transaction context
of chain code
58. List and explain the Requirements and Design goals of hyper ledger fabric.

1. Privacy and Confidentiality


● Traditional blockchains are permissionless so it is of utmost importance that in
the permissioned model like Hyperledger Fabric, transactions on the network
are visible to only those who are allowed to view it.
● It is expected that users will be able to choose appropriate modules according
to their business requirements.
● If a business blockchain needs to be run only between already trusted parties
and performs very basic business operations, then perhaps there is no need
to have advanced cryptographic support for confidentiality and privacy.
● users should be able to remove that functionality or module or replace that
with a more appropriate module that suits their needs.
● The blockchain should be able to handle sophisticated cryptographic
algorithms without compromising performance.

2. Scalability
● allow reasonable transaction throughput, which will be sufficient for all
business requirements and also a large number of users.

3. Deterministic Transactions
● This is a core requirement as if transactions do not produce the same result
every time they are executed regardless of who and where the transaction is
executed, then achieving consensus is impossible.

4. Identity
● To provide privacy and confidentiality services, a flexible PKI model that can
be used to handle the access control functionality is also required.
● The strength and type of cryptographic mechanisms is also expected to vary
according to the needs and requirements of the users
● In certain scenarios, it might be required for a user to hide their identity, and
as such, the Hyperledger is expected to provide this functionality.

5. Auditability
● It is expected that an immutable audit trail of all identities, related operations,
and any changes is kept.

6. Interoperability
● Currently, there are many blockchain platforms available, but they cannot
communicate with each other
● It is important that they are able to communicate with each other.
● There should be a common set of standards that all blockchains can follow in
order to allow communication between different ledgers.

7. Portability
● concerned with the ability to run across multiple platforms and environments
without the need to change anything at code level.
● It is envisaged to be portable, not only at infrastructure level but also at code,
libraries, and API levels, so that it can support uniform development across
various implementations of Hyperledger.

8. Rich data queries


● The blockchain network should allow rich queries to be run on the network.
● used to query the current state of the ledger using traditional query
languages, which will allow for wider adoption and ease of use.

59. Differentiate “Solo” and “Kafka” Ordering Schemes.

SOLO: This is a basic ordering service intended to be used for development


and testing purposes.
Kafka: This is an implementation of Apache Kafka, which provides ordering
service.

60. Assume the following scenario. Mr.X wants to discover the list of peers
participating in his peer to peer network and transfer 100 ether to his
immediate peer using hyperledger fabric. Explain the different kind of
message communication he is supposed to use in order to complete the
given scenario.

There are four main types of messages in Hyperledger Fabric: discovery,


transaction, synchronization, and consensus.

Discovery messages are exchanged between nodes when starting up in order to


discover other peers on the network.
Transaction messages are used to deploy, invoke, and query transactions, and
consensus messages are exchanged during consensus.
Synchronization messages are passed between nodes to synchronize and keep
the blockchain updated on all nodes.
61. Explain the various components of the fabric with reference architecture.

1. Peers
● Peers participate in maintaining the state of the distributed ledger.
They also hold a local copy of the distributed ledger.
● Peers communicate via gossip protocol.
● There are three types of peers
● Endorsing peers
○ simulate the transaction execution and generate a
read-write set.
○ Endorses execute and endorse transactions.
○ It should be noted that an endorser is also a committer too.
● Committing peers
○ receives transaction endorsed by endorsers, verify them
and then update the ledger with the read-write set.
○ verifies the read-write set generated by the endorsers along
with transaction validation.
● Submitters
○ has not been implemented yet. It is on the development
roadmap and will be implemented.

2. Orderer nodes
● receive transactions from endorsers along with read-write sets,
arrange them in a sequence, and send those to committing peers.
● Committing peers then perform validation and commit to the
ledger.
● All peers make use of certificates issued by membership services.

3. Clients
● software that makes use of APIs to interact with the Hyperledger
Fabric and propose transactions.

4. Channels
● allow the flow of confidential transactions between different
parties on the network.
● They allow using the same blockchain network but with separate
blockchains.
● Channels allow only members of the channel to view the
transaction related to them, all other members of the network will
not be able to view the transactions.
5. World State Database
● World state reflects all committed transaction on the blockchain.
● key-value store which is updated as a result of transactions and
chaincode execution.
● either LevelDB or CouchDB is used.
● LevelDB is a key-value store whereas CouchDB stores data as
JSON objects which allows rich queries to run against the
database

6. Transactions
● divided into two types: deployment transactions and invocation
transactions.
● The former is used to deploy new chaincode to the ledger, and the
latter is used to call functions from the smart contract.
● Transactions can be either public or confidential.
● Public transactions are open and available to all participants
whilst confidential transactions are visible only in a channel open
to its participants.

7. Membership Service Provider (MSP)


● MSP is a modular component that is used to manage identities on
the blockchain network.
● This provider is used to authenticate clients who want to join the
blockchain network.
● Certificate Authority: is used in MSP to provide identity
verification and binding service.

8. Smart contracts
● In Hyperledger Fabric the same concept of smart contracts is
implemented but they are called chain code instead of smart
contracts.
● They contain conditions and parameters to execute transactions
and update the ledger Chaincode is usually written in Golang and
Java.
62. Describe the membership services offered by hyper ledger fabric

These services are used to provide access control capability for the users of the
fabric network

It performs the following functions


1. User identity verification
2. User registration
3. Assign appropriate permissions to the users depending on their roles

● They make use of Certificate authority in order to support identity management and
authorization operations
● This CA can be internal which is a default interface in Hyperledger Fabric or
organization can opt to use an external CA
● Fabric CA issues enrollment certificates (E-Certs), which are produced by enrollment
certificate authority (E-CA).
● Once peers are issued with an identity, they are allowed to join the blockchain
network.
● There are also temporary certificates issued called TCerts, which are used for
one-time transactions.
● All peers and applications are identified using certificate authority.
● Authentication service is provided by the certificate authority.

63. Explain the Consensus services offered by hyper ledger fabric.

● A consensus service is responsible for providing the interface to the


consensus mechanism.
● This serves as a module that is pluggable and receives the transaction from
other Hyperledger entities and executes them under criteria according to the
type of mechanism chosen.
● Consensus in Hyperledger V1 is implemented as a peer called orderer, which
is responsible for ordering the transactions in sequence into a block.
● Orderer does not hold smart contracts or ledgers.
● Two types of ordering service
○ SOLO: This is a basic ordering service intended to be used for
development and testing purposes.
○ Kafka: This is an implementation of Apache Kafka, which provides
ordering service.
● Currently Kafka only provides crash fault tolerance but does not provide
byzantine fault tolerance.
64. Explain the various components of the hyper ledger with reference
architecture.

1. Consensus Layer
● responsible for facilitating the agreement process between the participants on
the blockchain network.
● The consensus is required to make sure that the order and state of
transactions is validated and agreed

2. Smart Contract Layer


● responsible for implementing business logic as per the requirements of the
users
● Transaction are processed based on the logic defined in the smart contracts

3. Communication Layer
● responsible for message transmission and exchange between the nodes on
the blockchain network.

4. Security and Crypto Layer


● responsible for providing a capability to allow various cryptographic
algorithms or modules to provide privacy, confidentiality and non-repudiations
services

5. Data Stores
● provides an ability to use different data stores for storing state of the ledger.
● This means that data stores are also pluggable and allows usage of any
database backend.
6. Policy Services
● provide the ability to manage different policies required for the blockchain
network.
● includes endorsement policy and consensus policy.

7. API’s and SDK’s


● allows clients and applications to interact with the blockchain
● SDK is used to provide mechanisms to deploy and execute chaincode, query
blocks and monitor events on the blockchain.

65. Differentiate between Legacy wallet and HD Wallet

Legacy Wallet:

● Uses a single private key for the wallet address.


● Less secure, as loss of the key results in loss of funds.
● Not hierarchical.

HD Wallet (Hierarchical Deterministic Wallet):

● Generates a tree of keys from a single seed.


● More secure as it supports multiple addresses without needing to backup each key.
● Can generate and manage multiple accounts from a single seed​

66. Differentiate between Bitcoin Mannet and Testnet.

Bitcoin Mainnet:

● The actual Bitcoin network where real transactions occur.


● All transactions have real monetary value.
● Strict consensus rules.

Bitcoin Testnet:

● A testing environment where developers can experiment with Bitcoin applications.


● Transactions have no real value.
● More lenient consensus rules​

67. Write a simple code to create a legacy wallet.


68. Discuss the data flow of a transaction request in a hyperledger fabric.

69. Recommend a common template to write contract class functions using


solidity.
70. Summarize the fundamental requirements of the smart contract s in
hyperledger fabric.
71. Write a simple smart contract to demonstrate an electronic voting system
where adding a candidate and printing the number of votes received
should be addressed by separate functions.
72. Write a simple smart contract using Solidity to demonstrate a banking
application with the following functions:
Set manager - Join as client - Deposit - Withdraw - Send interest - Get balance
73. List the requirements that need to be considered when Hyperledger Fabric
is used to develop enterprise applications.

74. Draw and explain the components of the Fabric application stack.

The Fabric application stack has five layers:

75. Prerequisite software: the base layer needed to run the software, for example,
Docker.
76. Fabric and Fabric samples: the Fabric executables to run a Fabric network along
with sample code.
77. Contract APIs: to develop smart contracts executed on a Fabric Network.
78. Application APIs: to develop your blockchain application.
79. The Application: your blockchain application will utilize the Application SDKs to
call smart contracts running on a Fabric network
(if required in detail)

Fabric Application Stack is a well-structured framework used to develop, deploy, and manage
blockchain applications on the Hyperledger Fabric platform. It consists of five layers, each building on
the previous one, from setting up infrastructure to creating and running a complete blockchain
application.
1. Prerequisite Software (Base Layer) - This layer provides the foundational software needed to run
the components of a Hyperledger Fabric network. It ensures the proper environment setup, using
virtualization tools and dependency managers to prepare the system for Fabric deployment. Tools
include -

● Docker - Fabric components like peer nodes, orders and CA run in isolated Docker
containers

● Kubernetes - large-scale networks opt for Kubernetes to orchestrate fabric containers across
multiple nodes

● Helm - automate deployment of Fabric

● Node.js and npm/yarn - develop application and smart contract interface

● Go: compile and execute smart contracts

2. Fabric and Fabric Samples - core fabric network layer - This layer consists of the essential
binaries and sample projects that form the backbone of any Hyperledger Fabric network. It enables
the deployment of blockchain networks and serves as a sandbox for testing configurations. Fabric
components include peers, orderers and CA. Fabric Samples are example projects to help developers
get familiar with Fabric architecture and functionality

3. Contract APIs (Smart Contract Development Layer) - The smart contract layer, also called the
chaincode layer, defines the logic for business transactions. These contracts run on peer nodes and
enforce the rules for updating the ledger. Contract operations include - installation, deployment,
state management.

4. Application APIs (Development Layer for Blockchain Applications) - This layer provides SDKs
and APIs that developers use to create blockchain-based applications. It allows external applications
to interact with the Fabric network by calling smart contracts and querying the ledger. Key API
functions include - transaction submission, query operations, identity and authentication, event
listeners

5. The Application (Blockchain Application Layer) - This is the top-most layer where your
blockchain solution is deployed and operated. The application is responsible for delivering value to
end-users by leveraging the underlying Fabric network.
80. Write a chain code for asset transfer from one client to another client
using JavaScript.

81. Draw a reference architecture to deploy a chain code in IBM Cloud.

You might also like