BTM2 Notes
BTM2 Notes
BTM2 Notes
The first cryptographic primitive that we need to understand is a cryptographic hash function.
A hash function is a mathematical function with the following three properties (general definition):
Hash functions are used to build data structures, such as hash tables.
Cryptographic hash functions require three additional properties:
1. Collision resistance
2. Hiding
3. Puzzle friendliness
. 1. Collision Resistance
• Definition: Collision resistance ensures that it is infeasible to find two distinct inputs that produce the same
hash output. In other words, for a hash function H, it should be hard to find any two values x and y such that
H(x)=H(y) and x!=y.
• Importance: Collision resistance prevents attackers from substituting one input for another without
detection, which is critical for maintaining data integrity and authenticity.
• How It Works:
• A collision can be found using methods like the Birthday Paradox. For a hash function with a 256-bit
output, it has been statistically shown that choosing just 2^130 + 1 random inputs yield a 99.8% chance of
finding a collision due to the birthday problem.
• Cryptographic hash functions are designed to minimize the feasibility of finding collisions, making them
secure against collision attacks.
Hiding:
Definition: The hiding property asserts that given the output of a hash function y=H(x), it should be
computationally infeasible to determine the original input x. This means that even
if an attacker knows the hash, they cannot reverse-engineer the input.
• Challenges: If the input set is small or predictable (e.g., "heads" or "tails"), an adversary may easily
compute possible hashes and determine the input.
• Solution: To enhance hiding, a secret value (nonce) r should be concatenated with the input x to form H(r
x). This ensures that even if x is predictable, the combination r x is not, ∥ ∥ providing a level of security.
• Key Concepts:
• Min-Entropy: This measures the unpredictability of the nonce. High min-entropy
means a wide distribution of possible nonce values, making it hard to guess.
• Commitment Schemes: These schemes utilize the hiding property to allow a user to commit to a value
while keeping it hidden until they decide to reveal it.
Puzzle Friendliness
2. Explain how a digital signature is created and verified. Why are digital signatures crucial for Bitcoin
transactions?
1. only you can make your signature, but anyone who sees it can verify that it’s valid.
2. signature to be tied to a particular document, so that the signature cannot be used to indicate your
agreement or endorsement of a different document.
How Digital Signatures Are Verified
Verification Process:
• The verifier takes the message, the public key, and the signature as input and calls the verify (pk,
message, sig) function.
• This function checks if the signature is valid for the given message under the public
key.
2. Outcome:
• The function returns a boolean value:
• True if the signature is valid. False if it is not.
Whereas a regular pointer retrieves the information, a hash pointer also allows you to verify that the
information hasn’t been changed.
• If an adversary modifies data anywhere in the blockchain, it will result in the hash pointer in the
following block becoming incorrect.
• By storing the head of the list, even if an adversary modifies all pointers to align with the modified
data, the head pointer will still be incorrect, allowing us to detect the tampering.
Another useful data structure built using hash pointers is a binary tree. A binary tree with hash pointers is
known as a Merkle tree, named after its inventor, Ralph Merkle.
• A sorted Merkle tree is created by taking the blocks at the bottom and sorting them using some
ordering function. This sorting can be based on alphabetical order, lexicographical order, numerical
order, or another agreed-upon ordering.
Features of Merkle Trees
• Data Storage: Merkle trees are efficient in storing a large amount of data. The root hash
summarizes all the data stored in the tree.
• Proof of Membership: To verify that a certain data block is a member of the Merkle tree:
1. Present the root hash.
2. Show the data block and the path from the data block to the root.
3. Only O(logn) items need to be shown if there are n nodes in the tree.
4. What is a Merkle tree, and how does it enable efficient verification of transactions in the Bitcoin
blockchain?
Another useful data structure built using hash pointers is a binary tree. A binary tree with hash pointers is
known as a Merkle tree, named after its inventor, Ralph Merkle.
• A sorted Merkle tree is created by taking the blocks at the bottom and sorting them using some
ordering function. This sorting can be based on alphabetical order, lexicographical order, numerical
order, or another agreed-upon ordering.
• It organizes and summarizes large sets
• of data into a binary tree format, where each leaf node contains a hash of the data, and each
non-leaf
• node contains a hash of its children.
Identities in Cryptocurrencies
1. Public Keys as Identities:
o In cryptocurrency systems, public keys are essentially treated as user identities.
o Users can create new identities by generating a fresh key pair (public and private keys). This
newly generated public key becomes the user’s new identity, while the private key allows
them to authorize actions.
o Hashing Public Keys: Public keys can be large, so often their hash is used as an identity to
keep data compact and private.
2. Decentralized Identity Management:
o Cryptocurrencies enable users to manage their own digital identities without needing a central
authority.
o Key features include:
§ Self-registration: Users can independently create their identities.
§ Multiple identities: Users can generate as many identities as needed.
§ Anonymity: Users can create temporary identities for privacy.
§ Control: There’s no single entity that controls or verifies these identities.
3. Bitcoin’s Implementation of Decentralized Identities:
o In Bitcoin, identities are represented as "addresses," which are essentially hashes of public
keys.
o Users can generate new addresses with ease, promoting flexibility and privacy.
4. Privacy Limitations:
o Despite providing a degree of anonymity, this system has privacy limits:
§ Behavioral patterns in transactions can sometimes reveal a user's identity.
§ For instance, repeated interactions with certain entities or transaction patterns might
make it possible for observers to infer the user's real-world identity.
This decentralized identity model balances user privacy with transparency, supporting the autonomous and
open nature of cryptocurrency networks.
6. Describe how a cryptographic hash function produces a 256-bit output and why this is a critical
feature in Bitcoin.
• Collision Resistance: A 256-bit output provides a large address space, making it extremely unlikely
for two distinct inputs to produce the same hash, a property known as collision resistance. This
ensures that each Bitcoin transaction has a unique hash, which is vital for tracking transactions and
preventing double-spending.
• Puzzle-Friendliness: The large output space of 256 bits makes it computationally challenging to
reverse-engineer the hash or predict an input, a feature used in Bitcoin’s Proof of Work (PoW).
Miners must find a nonce that, when hashed with block data, produces a hash below a specific target,
securing the network by making block creation resource-intensive.
• Efficiency and Security: A 256-bit hash provides an optimal balance between computational
efficiency and security strength, making it suitable for Bitcoin’s needs where both security and
performance are paramount.
7. What is the role of the elliptic curve digital signature algorithm (ECDSA) in Bitcoin.
The Elliptic Curve Digital Signature Algorithm (ECDSA) is a U.S. government standard that updates the
earlier DSA algorithm to use elliptic curves. Bitcoin uses ECDSA over the secp256k1 curve, providing
approximately 128 bits of security.
Key Points:
the Elliptic Curve Digital Signature Algorithm (ECDSA) plays a key role in Bitcoin by providing secure,
verifiable signatures for transactions:
1. Digital Signatures: ECDSA allows users to create digital signatures that are unique and tied to
specific transactions, ensuring that only the rightful owner of a Bitcoin address can authorize
spending from it.
2. Security: Bitcoin uses ECDSA over the secp256k1 elliptic curve, which offers strong security with
an estimated 128-bit security level. This prevents unauthorized spending and tampering with
transactions.
3. Verification: Anyone can use a public key to verify that a transaction's signature is valid, confirming
that the transaction was indeed signed by the owner of the private key without revealing the key
itself.
ECDSA thus ensures the integrity and authenticity of Bitcoin transactions, making it a core component of
Bitcoin's cryptographic foundation.
8. How does Bitcoin ensure that miners cannot simply fake transactions or signatures?Discuss the role
of cryptography.
Bitcoin employs a combination of cryptographic techniques and economic incentives to ensure that
miners cannot fake transactions or signatures. Here's how it works:
1. Digital Signatures
• Public-Private Key Pair: Every Bitcoin user has a pair of cryptographic keys: a private key (kept secret)
and a public key (shared with others).
• Signing Transactions: When a user wants to send Bitcoin, they create a transaction and sign it using their
private key. The digital signature proves that the transaction was created by the owner of the private key
without revealing the key itself.
• Verification: Other participants in the network can verify the authenticity of the transaction using the
public key. If the signature is valid, it confirms that the transaction was authorized by the owner of the
associated Bitcoin address.
1. Coin Creation:
• Goofy, the sole issuer of GoofyCoin, can create new coins whenever he wishes, and these newly
created coins belong to him.
• Process:
o Goofy generates a unique identifier for each coin, uniqueCoinID.
o He constructs the string “CreateCoin [uniqueCoinID]” and digitally signs it with his private
signing key.
o The resulting string and Goofy’s signature together form a coin.
• Verification: Anyone can use Goofy’s public key to verify the coin’s validity by checking his
signature, which confirms that Goofy indeed created the coin.
2.Coin Transactions:
o GoofyCoin holders can transfer their coins to others. However, this is done through cryptographic
operations rather than simply passing the coin data structure to a recipient.
o Security Limitation: GoofyCoin does not address the issue of double-spending. This means that a
single GoofyCoin could be spent multiple times by creating copies, leading to a major security flaw.
3.Limitations of GoofyCoin:
o While it mirrors basic transfer functionality found in cryptocurrencies like Bitcoin, GoofyCoin lacks
a mechanism to prevent double-spending, making it an insecure cryptocurrency.
Scrooge Coin aims to address the double-spending problem found in digital currencies. Double-spending
occurs when a digital asset is duplicated and used in multiple transactions. By maintaining an append-only
ledger, Scrooge Coin ensures each coin can be spent only once, with the transaction history permanently
recorded.
• The Scrooge Coin system uses an append-only ledger to log every transaction.
• Transactions in this ledger cannot be deleted or altered, meaning any coin's entire transaction history
is permanently stored.
• To implement this, Scrooge uses a blockchain, a sequence of blocks:
o Each block contains exactly one transaction and is digitally signed by Scrooge.
o Block Contents: Each block includes the transaction ID, transaction data, and a hash
pointer linking to the previous block.
o This hash pointer creates a chain effect: altering one block would invalidate the subsequent
blocks, ensuring data integrity.
• Only Signed Transactions Count: A transaction is only valid if it’s recorded in the blockchain and
signed by Scrooge.
• Transparency and Verification: Anyone can verify a transaction by checking Scrooge’s signature
on the block, confirming the transaction's authenticity.
• Double-Spending Protection: The public ledger shows every transaction, making it easy to check if
coins have already been used, preventing reuse.
• Centralization Risks: Since Scrooge controls the blockchain, he could refuse transactions, impose fees,
or abandon the system, causing reliance on a single issuer and raising concerns over decentralization.
Consensus in Bitcoin
Consensus refers to the agreement among participants in a blockchain network on the validity
of transactions and the current state of the blockchain. In Bitcoin, the primary consensus
mechanism used is Proof of Work (PoW), which ensures that all nodes in the network have
a synchronized and agreed-upon ledger of transactions.
Types of Consensus Mechanisms in Bitcoin:
1. Proof of Work (PoW):
o How it Works: Miners compete to solve complex mathematical puzzles. The first
miner to solve the puzzle gets to add a new block to the blockchain and is
rewarded with newly created bitcoins and transaction fees.
o Properties: PoW is decentralized, secure, and resistant to attacks like Sybil
attacks. It requires substantial computational power, which helps to prevent
fraudulent activities.
o Energy Consumption: One of the main criticisms of PoW is its high energy
consumption, as miners must use significant computational resources to solve
puzzles.
2. Alternative Consensus Mechanisms (not used in Bitcoin but important for context):
o Proof of Stake (PoS): Instead of competing to solve puzzles, validators are
chosen to create new blocks based on the number of coins they hold and are
willing to "stake" as collateral.
o Delegated Proof of Stake (DPoS): Coin holders elect a small number of
delegates to validate transactions and create new blocks on their behalf.
3. Other Consensus Types: While Bitcoin primarily uses PoW, various other consensus
mechanisms exist in the blockchain ecosystem, such as Byzantine Fault Tolerance
(BFT), Practical Byzantine Fault Tolerance (PBFT), and Proof of Authority (PoA). Each
has its own use cases and trade-offs.
Bootstrapping in Bitcoin
Bootstrapping in Bitcoin refers to the foundational mechanisms that establish and maintain the
network's security, value, and overall health, particularly in its early stages or when new nodes
join. Here’s a structured explanation that captures the essence of bootstrapping in Bitcoin:
1. Security of the Blockchain
• Genesis Block: The bootstrapping process begins with the genesis block, the first block
in the Bitcoin blockchain. Each subsequent block builds on this, creating an immutable
chain that verifies all transactions.
• Incentives for Miners: Miners secure the network by validating transactions and are
incentivized through block rewards (newly created bitcoins) and transaction fees. This
economic incentive encourages investment in mining infrastructure, enhancing network
security.
• Network Effect: As more participants join the network, the overall security increases.
A greater number of honest miners make it difficult for malicious actors to control the
network, promoting a robust and secure system.
2. Value of the Currency
• Scarcity and Supply: Bitcoin has a fixed supply cap of 21 million coins, creating
inherent scarcity. As demand for Bitcoin grows, its perceived value increases,
establishing it as a valuable digital currency.
• User Adoption: The value of Bitcoin is derived from its acceptance as a medium of
exchange and a store of value. User adoption is crucial; as more people use and accept
Bitcoin, its value strengthens, reinforcing its role in the economy.
3. Health of the Mining Ecosystem
• Rewards and Difficulty: The mining ecosystem's health is influenced by the balance
between block rewards and transaction fees. The block reward halves approximately
every four years, leading to an increased reliance on transaction fees as a miner
incentive.
• Infrastructure Development: The growth of mining pools, advancements in hardware,
and the establishment of efficient mining operations contribute to a healthy mining
ecosystem. A robust mining network is essential for ensuring both security and
decentralization.
Conclusion
In summary, bootstrapping in Bitcoin involves the establishment of a secure and valuable
network through a combination of initial trust, economic incentives for miners, user adoption,
and a healthy mining ecosystem. These factors work together to create a decentralized, secure,
and resilient system that continues to thrive in the evolving landscape of digital currencies.
17. How does Bitcoin prevent Sybil attacks in its decentralized network?
What is a Sybil Attack?
A Sybil attack is a security threat on a network where a single adversary creates multiple fake
identities (or nodes) to gain a disproportionately large influence over the network. This can
undermine the integrity and reliability of decentralized systems by allowing the attacker to
manipulate consensus processes, perform double-spending attacks, or disrupt communication
within the network. Since decentralized systems rely on the majority consensus to validate
transactions, an attacker with numerous nodes can potentially control the network’s decision-
making process, leading to malicious outcomes.
15.Explain the concept of a 51% attack. How could such an attack threaten Bitcoin’s
decentralization and security?
A 51% attack refers to a scenario in a blockchain network where a single entity or group of
entities gains control of more than 50% of the network’s computational power or hashing
power. In Bitcoin, where Proof of Work (PoW) is the consensus mechanism, miners compete
to solve complex cryptographic puzzles to add new blocks to the blockchain. If an attacker
were to control over half of the total mining power, they could potentially carry out the
following malicious activities:
1. Double-Spending
The attacker could reverse transactions that they created, allowing them to spend the same
bitcoins more than once. This is known as double-spending and undermines the integrity of
the blockchain, causing financial losses for those accepting these double-spent bitcoins.
2. Blocking Transactions
With a majority of the network's hashing power, the attacker could choose to prevent certain
transactions from being confirmed. By refusing to mine or validate specific transactions, they
could effectively censor users and prevent their transactions from reaching the blockchain.
3. Disrupting Consensus
In a 51% attack, the attacker could rewrite parts of the blockchain by selectively mining blocks
that favor their interests. They could even attempt to create a new chain that invalidates
previously confirmed blocks, known as a blockchain reorganization or a “reorg.” This
disrupts the network’s consensus and erodes trust in Bitcoin’s reliability.
Mitigation Strategies
To mitigate the risk of a 51% attack, various strategies can be employed:
• Increasing Hash Rate: Encouraging more miners to participate in the network can distribute hash power more
evenly and make it harder for any single entity to reach the 51% threshold.
--Implementing Different Consensus Mechanisms: Some newer cryptocurrencies use alternatives to PoW,
such as Proof of Stake (PoS), which may be less vulnerable to such attacks.
--Network Monitoring: Continuous monitoring for signs of abnormal mining behavior can help detect
potential attacks early.
• Community Awareness: Educating the community about the risks and encouraging best practices can help
safeguard against centralization efforts.
14. Explain the double-spending problem in digital currencies and how Bitcoin's
cryptographic techniques address this issue.
The double-spending problem in digital currencies refers to the risk that the same unit of
currency can be spent more than once. Unlike physical cash, where handing over a bill
physically prevents it from being spent again, digital currency, being purely data, can be
duplicated or replicated. This creates a unique challenge for digital currency systems, as they
must ensure that every unit of currency is spent only once to maintain integrity and prevent
inflation or fraud.
Q13. Discuss the mining process in Bitcoin and explain how miners are
incentivized to secure the network.
In blockchain technology:
• Mining: This process involves computers, known as miners, solving complex mathematical puzzles
to create new blocks and add them to the blockchain. As a reward for their efforts, miners receive
newly created cryptocurrency.
• Wallet: To use cryptocurrency, a digital wallet is required. This software program securely stores
your private keys, which are essential for accessing and managing your cryptocurrency funds.
• The creator of a transaction may set the output value lower than the input value.
o The difference is a transaction fee, which goes to the block creator who includes the
transaction in the block.
o This fee is voluntary but is expected to become mandatory as block rewards diminish.
Remaining Problems:
Or
Mining Process in Bitcoin and Miner Incentives
In Bitcoin, mining is the process by which new blocks are created and added to the blockchain. Here’s a
detailed breakdown of how it works and how miners are incentivized:
Mining Process
1. Creating New Blocks: Miners gather outstanding transactions and form them into a block. To add
this block to the blockchain, miners must solve a cryptographic puzzle, known as proof-of-work.
This puzzle involves finding a hash value that meets certain criteria, which requires substantial
computational power.
2. Proof-of-Work (PoW): Miners compete to solve the proof-of-work puzzle. This entails finding a
nonce (a random value) such that the hash of the block (including the nonce, previous block’s hash,
and transactions) is below a target threshold. The difficulty of this puzzle adjusts every 2,016 blocks
(about every two weeks) to ensure that a new block is added approximately every 10 minutes.
3. Broadcasting and Verification: Once a miner successfully solves the puzzle, they broadcast their
block to the network. Other nodes verify the block’s validity by checking the proof-of-work. If valid,
the block is added to the blockchain, and other nodes begin building on top of this block.
4. Consensus: The Bitcoin network operates on the principle that the longest chain (with the most
accumulated proof-of-work) is the valid blockchain. Miners are incentivized to add blocks to this
longest chain, as it maximizes the likelihood of their block reward being recognized.
Bitcoin miners are incentivized to secure the network through two main mechanisms:
1. Block Reward: When a miner successfully adds a new block to the blockchain, they receive a block
reward. This reward involves creating a special transaction within the block, which generates new
bitcoins (currently 12.5 BTC) and allows the miner to claim this reward. The block reward halves
roughly every four years, which gradually limits new bitcoin creation until the total supply cap of 21
million BTC is reached.
2. Transaction Fees: Miners also earn transaction fees from users. When creating a transaction, users
can opt to pay a fee, which miners receive for including that transaction in a block. This fee is
voluntary, acting like a “tip” to incentivize miners. However, as block rewards decrease, transaction
fees are expected to become a primary source of income for miners.
These incentives encourage miners to act honestly by aligning their rewards with network security and
consensus, thus ensuring they add valid transactions and blocks that extend the blockchain’s long-term
branch
To establish a secure, decentralized e-cash system like Bitcoin, achieving distributed consensus across nodes
is critical. Here’s how Bitcoin’s consensus mechanism functions in the face of challenges such as network
imperfections and potential malicious actors.
There are n nodes that each have an input value. Some of these nodes are faulty or malicious.
A distributed consensus protocol has the following two properties:
• It must terminate with all honest nodes in agreement on the value.
• The value must have been generated by an honest node.
Transaction Broadcasting and Pooling
When a user, like Alice, wants to send Bitcoin to another user, such as Bob, she broadcasts her transaction to
the network. Nodes then:
• Receive and Store Transactions: Each node adds Alice’s transaction to a pool of pending (or
outstanding) transactions.
• Maintain Ledgers: Each node has its own ledger, containing a sequence of blocks with transactions
that have already achieved consensus. Transactions not yet included in a block remain in the node’s
pool, leading to slight variations in each node's outstanding transaction pool due to network latency.
For these transactions, consensus has not yet happened, and so by definition, each node might have a slightly
different version of the outstanding transaction pool.
In practice, this occurs because the peer-to-peer network is not perfect, so some nodes may have heard about
a transaction that other nodes have not yet heard about.
1. Agreement Among Honest Nodes: All honest nodes in the network must reach consensus on a
single value.
2. Honest Value Generation: The agreed-upon value must originate from an honest node, even though
some nodes may be faulty or malicious.
1. Consensus in general is a hard problem, since nodes might crash or be outright malicious.
2. In the Bitcoin context, the network is highly imperfect. It’s a peer-to-peer system, and not all pairs of
nodes are connected to each other. There could be faults in the network because of poor Internet
connectivity, for example, and thus running a consensus protocol in which all nodes must participate
is not really possible.
Achieving consensus in a decentralized network like Bitcoin is complex due to several factors:
1. Network Imperfections:
• The Bitcoin network is a peer-to-peer system with nodes spread across the globe. This distribution can lead
to issues such as varying message propagation times and nodes not being connected to one another.
2. Node Failures:
• Nodes may crash or go offline, complicating the consensus process. The network must be resilient enough
to handle these failures without disrupting consensus.
3. Latency:
• There is inherent latency in the network, which affects how quickly transactions and blocks are
propagated. This latency can lead to inconsistencies in the order of transactions as observed by different
nodes.
In Bitcoin, achieving consensus is complicated by network latency and the lack of a global, shared time.
Nodes face two main obstacles:
1. Network Imperfections: Latency and node crashes can delay transaction propagation and impact
synchronization across nodes.
2. Malicious Actors: Some nodes may attempt to manipulate timestamps or disrupt consensus for an
advantage.
The absence of a global time standard means messages travel at varying speeds across this decentralized,
global network, complicating reliable timekeeping and order verification for transactions and blocks.
• Decentralization: Bitcoin operates on a peer-to-peer network, enabling anyone to run a node. This
lowers barriers to entry, allowing individuals to easily download the Bitcoin client and participate
without central authority approval.
• Node Distribution: The network consists of numerous nodes that maintain a copy of the blockchain,
ensuring no single entity controls the entire system.
Mining
• Open Participation: Mining is accessible to all, requiring substantial computational resources and
capital, which can lead to centralization. Many miners join pools to share resources and rewards.
• Concentration of Power: Increased competition can lead to resource concentration among those
with specialized hardware, raising concerns about centralization within mining.
Consensus Mechanism
• Transaction Propagation: User transactions are broadcasted and propagated throughout the
network. All nodes maintain a transaction ledger, ensuring transparency.
• Immutable Ledger: Once included in a block and added to the blockchain, transactions become
immutable, preventing alterations and double-spending.
• Incentives Against Malicious Behavior: Bitcoin’s design aligns miner incentives with network
security. The high cost of PoW discourages manipulation attempts, as attackers must invest
significantly in resources.
• Protection Against Double Spending: The append-only nature of the blockchain and consensus
requirements prevent double-spending. Valid transactions, once included in a block, cannot be
altered without network consensus.