ODD 24-CSE3N4031-BCT-Module 3 Notes-Latest
ODD 24-CSE3N4031-BCT-Module 3 Notes-Latest
BITCOIN BLOCKCHAIN
A bitcoin, at its core, is a fungible token representing value. The token is digital (or
virtual), and your public key is used to assign it to you. Ownership is transferred when
transactions are made to another person's public key. You use your wallet, the mobile
application, to send or receive Bitcoin.
Choose your wallet
Free Bitcoin wallets are available for all major operating systems and devices to serve
a variety of your needs. For example, you can install an app on your mobile device for
everyday use or a wallet only for online payments on your computer. In any case,
choosing a wallet is easy and can be done in minutes.
Get Bitcoin
You can get Bitcoin by accepting it as a payment for goods and services. There are also
several ways you can buy Bitcoin.
Spend Bitcoin
There are a growing number of services and merchants accepting Bitcoin all over the
world. Use Bitcoin to pay them and rate your experience to help them gain more
visibility.
Bitcoin Blockchain Structure
Bitcoin Blockchain Operations
It includes Mining and Network Consensus.
Mining
The algorithm that miners use to reach consensus is called the proof-of-
work protocol, which requires the miner to provide the necessary computational work
to solve a puzzle and claim the right to add a new block to the chain, broadcast their
validation work for consensus based on consensus status add the new block.
Consensus
Give the working of PoW (Proof of Work Consensus)
Bitcoin transaction means sending bitcoin from one person to another in the secured
blockchain network. These messages are digitally signed using cryptography and
verified by the miners in the blockchain network.
The transaction input is the Bitcoin address from which the money was sent, and
the transaction output is the Bitcoin address to which the money was sent.
The time taken for transaction confirmation mainly depends on two factors:
• Transaction fees: If the user pays minimal transaction fees, then the time
taken to confirm that particular user transaction would take longer vice versa.
The mining process needs significant technology and effort. Therefore,
transaction fees are essential.
• Network load: Every transaction gets stored temporarily in the memory pool
till the miners confirm it. When the transaction activities reach a certain high
threshold, the memory pool gets jammed, thereby slowing the confirmation
time of the transaction even more. Due to this, all the subsequent transactions
become susceptible to delay.
A Bitcoin transaction moves the value of some Bitcoin from one address to another.
A transaction changes the state of the agreed-correct blockchain.
This constant movement of coins constitutes the data within any blockchain
architecture, while how transactions are handled and verified varies by
implementation.
Format of a Transaction
Transactions contain one or more inputs and one or more outputs.
The miner is the person who solves mathematical puzzles (also called proof of work)
to validate the transaction. Anyone with mining hardware and high processing power
can take part in this. Numerous miners simultaneously take part in solving the
complex mathematical puzzle; the one who solves it wins 12.5 bitcoins as a reward.
The miner verifies the transactions (after solving the puzzle) and then adds the block
to the blockchain when it is confirmed.
Note: Also, mention the difficulty level and its purpose, which were discussed in
earlier modules.
• Bitcoin Network
One of the core components of the Bitcoin system is the peer-to-peer network that
it runs on. While peer-to-peer, or P2P, networks existed before Bitcoin,
understanding what is happening on the Bitcoin P2P network is fundamental to
understanding Bitcoin.
When a new node boots up, it must discover other Bitcoin nodes on the network to
participate. To start this process, a new node must find at least one existing node on
the network and connect to it.
To connect to a known peer, nodes establish a TCP connection, usually to port 8333
(the port generally known as the one used by bitcoin), or an alternative port if one is
provided. Upon establishing a connection, the node will start a "handshake" (see the
initial handshake between peers) by transmitting a version message.
Once one or more connections are established, the new node will send an addr
message containing its IP address to its neighbors. The neighbors will, in turn,
forward the addr message to their neighbors, ensuring that the newly connected
node becomes well known and better connected. Additionally, the newly attached
node can send getaddr to the neighbors, asking them to return a list of other peers'
IP addresses. That way, a node can find peers to connect to and advertise its
existence on the network for other nodes to find it. Address propagation and
discovery shows the address discovery protocol.
A node must connect to a few different peers to establish diverse paths into the
Bitcoin network. Paths are not persistent - nodes come and go - and so the node must
continue to discover new nodes as it loses old connections and assists other nodes
when they bootstrap.
Nodes will periodically send a message to maintain the connection. If a node has not
communicated on a connection for more than 90 minutes, it is assumed to be
disconnected and a new peer will be sought. Thus, the network dynamically adjusts
to transient nodes and network problems and can organically grow and shrink as
needed without any central control.
• Bitcoin Scripts
Bitcoin Script serves as the scripting language behind Bitcoin transactions, allowing
users to define the conditions under which funds can be spent.
It locks the funds until certain conditions are met. Check whether the balance is
correct or not. Further, it ensures that the same funds cannot be spent twice. The
output is considered as UTXO – Unspent Transaction Output.
An unlocking script (ScriptSig) must be provided for every input you want to spend
in a transaction:
It checks (Input is drawn from previous outputs) that the transaction initiator has
the necessary permissions to spend the bitcoins.
Every node will then combine and run these two scripts for each input in each
transaction they receive to make sure they validate.
If a full script (unlocking + locking) is valid, the output is "unlocked" and can be spent.
Pay-to-Script-Hash (P2SH)
• Sends bitcoins to a script hash, enabling more complex transactions.
• ScriptPubKey: OP_HASH160 <ScriptHash> OP_EQUAL
• Usage: Multisig, escrow, and other complex transaction types.
• Bitcoin Wallets
A Bitcoin wallet is used to store the value of virtual money. The difference is that a
Bitcoin wallet stores a collection of private keys instead of a collection of bills and
cards. Typically, a wallet is encrypted with a strong password to protect it from
unauthorized access.
Unlike the Bitcoin network, a Bitcoin wallet is controlled only by its owner (it's not
distributed and shared like the blockchain).
It's essential to keep your Bitcoin wallet safe by either setting a strong password or
OTPs. This is required to keep it out of reach of malicious individuals.
Types of Wallets
There are many different Bitcoin wallets to choose from.
There are two broad types of wallets: soft wallets and hard wallets.
Desktop wallets fall into two main categories known as "full nodes" and "light"
clients. Full nodes host a full copy of the blockchain (about 31 GB as of January
2015), while light clients provide only Bitcoin storage capabilities while depending on
an external source to read the blockchain.
• Mobile Wallets
The software that powers a wallet is stored on your Mobile. Mobile wallets are
simply Bitcoin wallets designed for a mobile device. This means they can quickly scan
QR codes, easily navigate with a touch screen, and are accessible while moving.
Mobile wallets are almost always "light" clients in that they do not store a full copy
of the blockchain.
• Paper Wallets
Paper wallets are a way to embody bitcoins in a physical medium such as paper or
metal. Like a printed banknote, if a paper wallet is lost or destroyed, the Bitcoin stored
on it is gone forever. This brings the physical aspect to Bitcoins.
MetaMask
What is MetaMask?
Public blockchains like Ethereum are the next evolution of Internet databases, and
MetaMask is the next evolution of the browser.
MetaMask is a web browser extension and mobile app that allows you to manage your
Ethereum private keys. By doing so, it serves as a wallet for Ether and other tokens and
will enable you to interact with decentralized applications or apps. Unlike some
wallets, MetaMask keeps no information on you: not your email address, not your
password, and not your Secret Recovery Phrase or other private keys. You retain all
power over your crypto-identity.
For Mobile
Android
1. Open the Play Store and search for "MetaMask". The official MetaMask app
looks like the screenshot below. Be VERY CAREFUL that you don't install a fake
MetaMask app! Look for the one with 10M+ downloads.
2. Tap 'Install' and wait for the process to finish.
3. Once installed, open the app and follow the prompts to create your wallet.
4. Back up your Secret Recovery Phrase somewhere safe and offline!
Signifying just how important crypto regulation is at the federal level, in March 2022,
US President Joe Biden announced a “whole-of-government” approach to regulating
crypto assets in a vast executive order. This will force all federal agencies and
departments to consider how they protect consumers and ensure financial stability
and national security while addressing climate risks. Why was this announcement so
pivotal? The President’s statement states, “The United States must maintain
technological leadership in this rapidly growing space, supporting innovation while
mitigating the risks for consumers, businesses, the broader financial system, and the
climate. And, it must play a leading role in international engagement and global
governance of digital assets consistent with democratic values and US global
competitiveness”. As such, this statement shows the world that the US is preparing to
become a world leader in crypto.
China
Australia
Question Bank
1. What is the primary difference between SHA-1 and SHA-256? Evaluate the
strengths and weaknesses of SHA-256.
3. What is the term for a Bitcoin wallet that stores private keys offline for
enhanced security? What term describes generating a Bitcoin wallet's address
from a public key?
4. Explain the use of SHA-256 in digital certificates and SSL/TLS protocols. What
operation in Bitcoin Script verifies a digital signature?
10. Distinguish among the roles and responsibilities of different types of nodes
in the Bitcoin network.
11. Describe the basic structure of a Bitcoin script and explain the significance
of the stack-based execution model. How does a Bitcoin script validate a
transaction's spending conditions? Provide an overview of the process involved.
12. Discuss in detail the types of consensus without identity. What is a hash
pointer? How is it different from a regular pointer?
13. Suppose there is a sudden increase in the number of miners joining the
Bitcoin network due to a rise in the price of Bitcoin. With this influx of new
miners, the network's total computational power (hash rate) significantly
increases significantly. Describe how the Proof of Work consensus model
handles this situation to ensure that blocks are added approximately every 10
minutes.
17. Brief Zero Knowledge Proof. Why are heavy nodes considered essential in
the Bitcoin network?
18. What is a crucial feature of Bitcoin Script that helps ensure transaction
validity and security?
20. Explain why hash pointers are considered more secure than traditional
pointers in data structures.