0% found this document useful (0 votes)
6 views16 pages

Mod3 BCT

An account-based ledger tracks balances associated with accounts, but it faces drawbacks like validation complexity and efficiency issues. Bitcoin overcomes these limitations with a transaction-based ledger that references previous outputs, allowing for efficient validation and immutability. Bitcoin's scripting language, Script, enables secure transaction verification through a stack-based execution model.

Uploaded by

roka21cs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views16 pages

Mod3 BCT

An account-based ledger tracks balances associated with accounts, but it faces drawbacks like validation complexity and efficiency issues. Bitcoin overcomes these limitations with a transaction-based ledger that references previous outputs, allowing for efficient validation and immutability. Bitcoin's scripting language, Script, enables secure transaction verification through a stack-based execution model.

Uploaded by

roka21cs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Q1 What is an account-based ledger? What are the drawbacks of this?

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.

Drawbacks of Account-Based Ledgers:

1. Validation Complexity: To verify if a transaction is valid (e.g., Alice has 15 coins to


send), the system needs to maintain and check historical account balances.

2. Efficiency Issues: Tracking balances requires additional data structures and constant
updates, making the system less efficient.

3. Increased Overhead: This model demands continuous synchronization to ensure the


ledger's consistency across all nodes.

Transaction-Based Ledger (Used in Bitcoin):

Bitcoin addresses these issues by adopting a transaction-based ledger where:

• Transactions reference previous transaction outputs (not account balances).

• 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.

Advantages of Transaction-Based Ledger:

1. Efficient Validation: Validating a transaction requires checking only its specific inputs
(previous unspent outputs) rather than the entire account history.

2. Immutability: Once a transaction is included in the blockchain, it cannot be altered,


ensuring consistency.

3. Simplified Data Management: No need to maintain account balances separately; the


ledger inherently tracks unspent outputs.

By using this model, Bitcoin reduces the computational and storage burden and ensures a
secure, decentralized, and efficient system.

Q2 Explain execution of Bitcoin script

Execution of Bitcoin Script

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).

How Execution Works

1. Combining Scripts:

o The scriptSig and scriptPubKey are concatenated and executed together.

o Example:

▪ scriptPubKey: Specifies the conditions under which the output can be


spent (e.g., "This output can be spent by a signature matching public key
hash X").

▪ scriptSig: Provides data (e.g., signature and public key) to satisfy the
conditions.

2. Stack-Based Execution:

o A stack is used for computation.

o Instructions in the script are processed sequentially.

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.

o Run Opcodes: Instructions from the scriptPubKey are executed.

▪ Example Opcodes:

▪ OP_DUP: Duplicates the top item on the stack.

▪ OP_HASH160: Computes the hash of the top stack item.

▪ OP_EQUALVERIFY: Verifies if the top two items on the stack are


equal.

▪ OP_CHECKSIG: Checks if the signature is valid for the given


public key and transaction.

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

Suppose we want to spend an output locked by a Pay-to-PubKeyHash (P2PKH) script. Here's


how it works:

scriptPubKey (Output Script):

OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG

• OP_DUP: Duplicates the public key.

• OP_HASH160: Hashes the duplicated public key.

• OP_EQUALVERIFY: Verifies the hash matches the provided <pubKeyHash>.

• OP_CHECKSIG: Verifies the signature is valid for the public key.

scriptSig (Input Script):

<signature> <pubKey>

• signature: Proves ownership of the private key.

• pubKey: Provides the public key for verification.

Execution Process:

1. Push <signature> and <pubKey> from scriptSig onto the stack.

2. Execute scriptPubKey:

o OP_DUP: Duplicates the <pubKey>.

o OP_HASH160: Hashes the duplicated <pubKey> and pushes the result.

o Compare the hash with <pubKeyHash> using OP_EQUALVERIFY. If they match,


continue.

o Use OP_CHECKSIG to verify the <signature> matches the <pubKey> for the
transaction.

If all conditions are satisfied, the transaction is valid.


Key Features of Bitcoin Script:

1. Cryptographic Operations: Built-in support for hash functions and signature


verification.

2. Deterministic: No loops or recursion; each instruction runs exactly once.

3. Security: Scripts fail if any error occurs during execution, preventing invalid transactions
from being included in the blockchain.

4. Customizability: Supports features like multisignatures, time locks, and more


advanced spending conditions.

Bitcoin’s scripting language is simple but powerful enough to support a wide range of financial
transactions while maintaining security and efficiency.

Q3 With a neat diagram explain bitcoin blockchain

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.

2. Merkle Tree of Transactions: Ensures efficient transaction verification within each


block.

Components of the Bitcoin Blockchain

1. Hash Chain of Blocks


• Each block contains:

o prev: The hash of the previous block (providing the link between blocks).

o trans: The hash of all transactions in the current block.

• The hash of the previous block ensures that any alteration in a past block invalidates all
subsequent blocks, maintaining the chain's integrity.

2. Merkle Tree of Transactions

• A Merkle tree organizes transactions within a block.

• Each leaf node represents a hash of an individual transaction.

• 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).

How the Blockchain Works

1. Block Structure:

o Each block contains:

▪ Header:

▪ Hash of the previous block.

▪ Merkle root.

▪ Timestamp.

▪ Difficulty target.

▪ Nonce (used in proof-of-work).

▪ Transactions: Details of all transactions included in the block.

2. Mining and Proof-of-Work:

o Miners solve a computational puzzle (proof-of-work) to add a new block.

o This involves finding a hash value below a certain threshold by adjusting the
nonce.

3. Verification:

o To verify a block, nodes check:

▪ The validity of transactions.

▪ The integrity of the Merkle root.

▪ The proof-of-work for the block.

4. Consensus:
o The blockchain uses a decentralized consensus mechanism where the longest
chain (with the most computational work) is considered valid.

Importance of the Diagram

• The diagram illustrates:

o Hash Chain: Ensuring the immutability of the blockchain through links between
blocks.

o Merkle Tree: Ensuring transaction integrity and enabling efficient validation.

This combination makes the Bitcoin blockchain secure, tamper-resistant, and efficient for
verifying transactions in a decentralized manner.

Q4 Explain the simplest way of storing Bitcoins

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:

1. Software Wallet (Hot Wallet)

• What it is: A software application installed on your mobile phone, computer, or


accessed via a web browser.

• 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:

o Easy to set up and use.

o Free and widely accessible.

o Convenient for frequent transactions.

• Drawbacks:

o Vulnerable to hacking if the device is compromised.

o Requires an internet connection.

2. Hardware Wallet (Cold Wallet)

• What it is: A physical device designed to store Bitcoin securely offline.


• How it works:

o Purchase a hardware wallet like Ledger Nano S or Trezor.

o Connect the wallet to your computer or phone to send/receive Bitcoin.

o The private key remains offline, even during transactions.

• Advantages:

o Extremely secure against hacking.

o Immune to viruses or malware.

• Drawbacks:

o Costs money to buy the device.

o Slightly less convenient for frequent use.

3. Paper Wallet

• What it is: A printed document containing your public and private keys.

• How it works:

o Use a Bitcoin paper wallet generator to create a pair of keys.

o Print the keys on paper and store them securely (e.g., in a safe).

• Advantages:

o No digital exposure; immune to hacking.

o Simple and cost-effective.

• Drawbacks:

o Susceptible to physical damage or loss (fire, water, theft).

o Less user-friendly for sending/receiving Bitcoin.

4. Exchange Wallet (Simplest but Risky)

• What it is: Storing your Bitcoin directly on a cryptocurrency exchange like Coinbase,
Binance, or Kraken.

• How it works:

o Create an account on the exchange.

o Deposit Bitcoin into your account.

• Advantages:

o Very user-friendly for beginners.


o Allows easy trading and conversion to other currencies.

• Drawbacks:

o You don't control the private keys (not your keys, not your coins).

o High risk if the exchange gets hacked or shuts down.

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 and Cold Storage in Bitcoin

Hot Storage

• Definition: Hot storage refers to wallets that are connected to the internet and allow
quick and easy access to Bitcoin.

• Examples:

o Mobile wallets (e.g., Trust Wallet, Electrum)

o Web wallets (e.g., exchanges like Binance, Coinbase)

o Desktop wallets

• Advantages:

o Convenient for frequent transactions.

o Easy to set up and use.

• Drawbacks:

o Vulnerable to hacking, phishing attacks, and malware due to internet exposure.

o Less secure for large amounts of Bitcoin.

Cold Storage

• Definition: Cold storage refers to wallets that are completely offline and not connected
to the internet, providing enhanced security.

• Examples:

o Hardware wallets (e.g., Ledger, Trezor)

o Paper wallets
o Air-gapped computers

• Advantages:

o Immune to online hacking and malware attacks.

o Ideal for long-term storage of large amounts of Bitcoin.

• Drawbacks:

o Less convenient for frequent transactions.

o Requires careful handling to avoid physical damage or loss.

Schema of a Hierarchical Deterministic (HD) Wallet

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.

o Allows segregation of accounts or purposes, e.g., one branch for savings,


another for transactions.

4. Path Derivation:

o Keys are derived using a specific BIP-32 path, such as m / purpose' / coin_type' /
account' / change / address_index.

Schema (Structure) of an HD Wallet:

1. Root Key:
o Generated from the seed phrase.

o Example: m

2. Purpose:

o Defines the wallet type (e.g., BIP-44 for multi-account wallets).

o Example: m/44'

3. Coin Type:

o Specifies the cryptocurrency (e.g., Bitcoin is 0).

o Example: m/44'/0'

4. Account:

o Allows for multiple accounts within the same wallet.

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:

o Sequentially generated addresses.

o Example: m/44'/0'/0'/0/0, m/44'/0'/0'/0/1, etc.

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:

o Allows generating new addresses for each transaction, enhancing privacy.

3. Flexibility:

o Enables managing multiple accounts and purposes within a single wallet.

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

• Definition: Proof of Liabilities is a mechanism used by exchanges or custodians to


demonstrate that they hold sufficient reserves to cover all customer deposits.

• 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.

3. The root hash is published, which represents a cryptographic commitment to all


user balances.

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:

1. The user requests their path of inclusion, which contains:

▪ The hash of their balance.

▪ 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.

Steps in the Diagram

1. Each leaf node represents a user's account and balance.

o For example, user1 acct, user2 acct, etc.

o Each account's balance is hashed.

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.

4. The exchange publishes the Merkle root for public verification.

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.

Payment Process in Bitcoin: 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.

1. User Initiates Payment

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 A QR code for easy scanning

• Input Details: The user scans the QR code or manually enters:


o The merchant's Bitcoin address.

o The amount to be paid in Bitcoin (or its equivalent in fiat currency, as converted
by the wallet or payment service).

o Optional transaction fee (higher fees may speed up transaction confirmation).

2. Transaction Broadcast

Once the user confirms the payment:

• Wallet Action: The user's wallet constructs the transaction, which includes:

o Input(s): Reference to previous unspent outputs (UTXOs) owned by the user.

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).

3. Bitcoin Network Validation

• Mining Nodes:

o Nodes in the network validate the transaction by verifying:

▪ The digital signature matches the user's public key.

▪ The inputs are unspent (preventing double-spending).

o Once validated, miners include the transaction in a block.

• Confirmation: The transaction is confirmed when it is included in a block. Additional


blocks built on top of this block further strengthen the confirmation.

4. Merchant Receives Payment

• Immediate Notification:

o Merchants can use payment gateways (e.g., BitPay, Coinbase Commerce) to


monitor the Bitcoin network for the transaction.

o Upon detection, the merchant may treat the payment as "pending" or


"complete" depending on the number of confirmations received.

o Common practice: Wait for 1-6 confirmations for higher security.

• Funds Access:
o Once the transaction is confirmed, the Bitcoin is credited to the merchant's
wallet.

5. Optional Role of Payment Services

Payment services or gateways (e.g., BitPay) simplify the process for merchants:

• Conversion to Fiat:

o Services can automatically convert Bitcoin payments to fiat currency, reducing


volatility risks for merchants.

• Invoicing and Management:

o They provide tools for invoicing, order tracking, and payment reconciliation.

• Enhanced User Experience:

o Offer streamlined interfaces, reducing technical barriers for merchants and


users.

Diagram of the Process

1. User (Payer):

o Scans QR code or enters the merchant's address.

o Confirms the transaction.

o Wallet signs and broadcasts it to the Bitcoin network.

2. Bitcoin Network:

o Validates and propagates the transaction.

o Miners confirm it by including it in a block.

3. Merchant (Payee):

o Monitors the network for the transaction.

o Receives the payment once confirmed.

o (Optional) Uses a payment service for fiat conversion or invoicing.

Advantages of Bitcoin Payment Process

1. Global Access: No intermediaries or banking restrictions.

2. Transparency: Transactions are recorded on the blockchain.

3. Security: Digital signatures and blockchain immutability ensure secure payments.


4. Low Fees: Typically lower than traditional payment methods, especially for cross-border
payments.

By following this process, Bitcoin enables seamless, secure, and decentralized payments
between users and merchants.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy