Mod3 BCT
Mod3 BCT
How can it be
overcomed through transaction based ledger used by bitcoin?
An account-based ledger is a financial system where balances are associated with accounts,
and transactions update these balances. Each account has a current balance, and every
transaction modifies the involved account balances. A transaction like "Alice sends 15 coins to
Bob" would decrease Alice's balance and increase Bob's balance in the ledger.
2. Efficiency Issues: Tracking balances requires additional data structures and constant
updates, making the system less efficient.
• Each transaction consumes specific outputs from previous transactions and creates
new outputs.
• Transactions are uniquely identified, and their validity is verified using cryptographic
signatures and hash pointers.
1. Efficient Validation: Validating a transaction requires checking only its specific inputs
(previous unspent outputs) rather than the entire account history.
By using this model, Bitcoin reduces the computational and storage burden and ensures a
secure, decentralized, and efficient system.
Bitcoin uses a stack-based scripting language called Script, which is designed to verify
transactions. It is not Turing complete and is intentionally kept simple to avoid infinite loops or
excessive computational demands.
Bitcoin scripts are used in two places:
1. scriptPubKey: The output script in the transaction being spent (locked to certain
conditions).
2. scriptSig: The input script in the transaction spending the output (provides proof to
satisfy conditions in the scriptPubKey).
1. Combining Scripts:
o Example:
▪ scriptSig: Provides data (e.g., signature and public key) to satisfy the
conditions.
2. Stack-Based Execution:
o Data elements (like signatures) are pushed onto the stack, and operations (like
cryptographic checks) pop data off the stack, process it, and push the result
back.
3. Execution Steps:
o Push Data: Data from the scriptSig (e.g., a public key and signature) is pushed
onto the stack.
▪ Example Opcodes:
4. Validation Outcome:
o If the script executes without errors and leaves true on the stack, the transaction
is considered valid.
o If an error occurs or the stack does not contain true, the transaction is invalid.
Example Script Execution
<signature> <pubKey>
Execution Process:
2. Execute scriptPubKey:
o Use OP_CHECKSIG to verify the <signature> matches the <pubKey> for the
transaction.
3. Security: Scripts fail if any error occurs during execution, preventing invalid transactions
from being included in the blockchain.
Bitcoin’s scripting language is simple but powerful enough to support a wide range of financial
transactions while maintaining security and efficiency.
The Bitcoin blockchain is a data structure that serves as a decentralized public ledger for
recording transactions. It relies on two types of hash structures:
1. Hash Chain of Blocks: Links blocks together chronologically, ensuring the integrity and
immutability of the blockchain.
o prev: The hash of the previous block (providing the link between blocks).
• The hash of the previous block ensures that any alteration in a past block invalidates all
subsequent blocks, maintaining the chain's integrity.
• Pairs of hashes are recursively combined until a single hash (the Merkle root) is
generated, which is stored in the block header.
• The Merkle tree allows efficient transaction verification without requiring all transactions
to be downloaded (used in Simplified Payment Verification, SPV).
1. Block Structure:
▪ Header:
▪ Merkle root.
▪ Timestamp.
▪ Difficulty target.
o This involves finding a hash value below a certain threshold by adjusting the
nonce.
3. Verification:
4. Consensus:
o The blockchain uses a decentralized consensus mechanism where the longest
chain (with the most computational work) is considered valid.
o Hash Chain: Ensuring the immutability of the blockchain through links between
blocks.
This combination makes the Bitcoin blockchain secure, tamper-resistant, and efficient for
verifying transactions in a decentralized manner.
The simplest way to store Bitcoins is by using a Bitcoin wallet. A Bitcoin wallet is a digital tool
that allows you to store and manage your private keys, which are essential for accessing and
managing your Bitcoin. Here are the simplest methods:
• How it works:
o You install a Bitcoin wallet app like Trust Wallet, Exodus, or Electrum.
o The wallet generates a public key (your Bitcoin address) and a corresponding
private key.
o You can store, send, and receive Bitcoin using this wallet.
• Advantages:
• Drawbacks:
• Advantages:
• Drawbacks:
3. Paper Wallet
• What it is: A printed document containing your public and private keys.
• How it works:
o Print the keys on paper and store them securely (e.g., in a safe).
• Advantages:
• Drawbacks:
• What it is: Storing your Bitcoin directly on a cryptocurrency exchange like Coinbase,
Binance, or Kraken.
• How it works:
• Advantages:
• Drawbacks:
o You don't control the private keys (not your keys, not your coins).
Recommendation
For beginners, a software wallet is the simplest way to start. As you accumulate more Bitcoin
or prioritize security, consider upgrading to a hardware wallet. Always back up your wallet and
keep your private keys or recovery phrases safe and secure!
Q5 Define hot and cold storage in Bitcoin. Explain schema of hierarchical deterministic wallet
Hot Storage
• Definition: Hot storage refers to wallets that are connected to the internet and allow
quick and easy access to Bitcoin.
• Examples:
o Desktop wallets
• Advantages:
• Drawbacks:
Cold Storage
• Definition: Cold storage refers to wallets that are completely offline and not connected
to the internet, providing enhanced security.
• Examples:
o Paper wallets
o Air-gapped computers
• Advantages:
• Drawbacks:
What is an HD Wallet?
• An HD wallet is a type of Bitcoin wallet that generates a tree-like structure of keys and
addresses from a single seed phrase (a mnemonic phrase). This allows users to create
an unlimited number of public-private key pairs deterministically.
Features of HD Wallets:
1. Seed Phrase:
o A human-readable 12-24 word mnemonic phrase that serves as the root of the
wallet.
o From this seed, all private and public keys can be regenerated.
2. Master Keys:
o Master Private Key (m): The root key from which all child private keys are
derived.
o Master Public Key (M): Derived from the master private key; used to generate
child public keys without exposing private keys.
3. Key Hierarchy:
o The wallet organizes keys in a tree structure where each node can generate child
keys.
4. Path Derivation:
o Keys are derived using a specific BIP-32 path, such as m / purpose' / coin_type' /
account' / change / address_index.
1. Root Key:
o Generated from the seed phrase.
o Example: m
2. Purpose:
o Example: m/44'
3. Coin Type:
o Example: m/44'/0'
4. Account:
o Example: m/44'/0'/0'
5. Change:
o Defines whether the address is for receiving payments (0) or change from a
transaction (1).
o Example: m/44'/0'/0'/0
6. Address Index:
Benefits of HD Wallets:
1. Backup Once:
o The entire wallet can be restored using the seed phrase, regardless of how many
addresses have been generated.
2. Privacy:
3. Flexibility:
In summary, hot storage is for active use, while cold storage is for long-term security. HD
wallets simplify the management of Bitcoin by deriving all addresses and keys from a single
seed, ensuring security and ease of recovery.
Q6 With a neat diagram explain proof-of-liabilities and proof-of-inclusion in merkle tree.
Proof of Liabilities and Proof of Inclusion in a Merkle Tree
Proof of Liabilities
• How it Works:
1. The exchange generates a Merkle tree where each leaf node represents a user's
account balance.
2. The balances are hashed, and these hashes are propagated upwards in the
Merkle tree, creating a root hash.
4. Any user can verify their balance's inclusion in this tree using the root hash and
intermediate hashes.
Proof of Inclusion
• Definition: Proof of Inclusion ensures that a particular user’s account (and balance) is
included in the Merkle tree without exposing other users’ data.
• How it Works:
▪ Sibling hashes along the path to the root of the Merkle tree.
2. Using these hashes and the root hash, the user can independently verify their
balance's inclusion in the tree.
2. Hashes of neighboring leaf nodes are combined and hashed again to form parent
nodes.
3. This process continues until a single Merkle root is created at the top of the tree.
Key Benefits
• Transparency: Users can verify that their balances are included without revealing other
users' balances.
• Security: Since only hashes are shared, sensitive data remains protected.
• Auditability: External auditors or users can verify the exchange’s claim of liabilities.
This combination of Proof of Liabilities and Proof of Inclusion enhances trust in exchanges
while maintaining user privacy.
Q7 Explain payment process in Bitcoin, by considering user, merchant and payment service.
Bitcoin payments involve three key entities: the user (payer), the merchant (payee), and
optionally a payment service that facilitates the transaction for better usability or integration.
The user initiates the payment process by using a Bitcoin wallet. The steps are as follows:
• Address Generation: The merchant provides their Bitcoin address (a public key) to
receive the payment. This can be displayed as:
o A text string
o The amount to be paid in Bitcoin (or its equivalent in fiat currency, as converted
by the wallet or payment service).
2. Transaction Broadcast
• Wallet Action: The user's wallet constructs the transaction, which includes:
o Output(s): The amount to be sent to the merchant and any change to be returned
to the user.
o Digital Signature: Generated using the user's private key, proving ownership of
the funds.
• Broadcast to Network: The wallet broadcasts the signed transaction to the Bitcoin
network (a decentralized peer-to-peer network).
• Mining Nodes:
• Immediate Notification:
• Funds Access:
o Once the transaction is confirmed, the Bitcoin is credited to the merchant's
wallet.
Payment services or gateways (e.g., BitPay) simplify the process for merchants:
• Conversion to Fiat:
o They provide tools for invoicing, order tracking, and payment reconciliation.
1. User (Payer):
2. Bitcoin Network:
3. Merchant (Payee):
By following this process, Bitcoin enables seamless, secure, and decentralized payments
between users and merchants.