Opening the world
Five districts await
Explore money, cryptography, ledgers, consensus, and digital cash. Read the exact midterm study answers in the guide while the 3D engine loads.
Checking WebGL and loading the engine…
On a phone, use Fullscreen and rotate to landscape for more room to drive. The text guide works in portrait view.
Accessible text companion
Midterm study guide
Q1–Q10 from my CS646 midterm study notes and model answers, including full answers and separate technical notes. Q10 is an optional CS746 extension. This guide remains available if the 3D world cannot run in your browser.
Q1Q1. Historically money is defined by three functions. What are the three functions?moneyWeek 1
Recall promptWithout looking, name the three historical functions in order and explain each using cow → money → corn, stored value, and a common measure of wealth.
Write this for full credit
Write these three functions, in this order. This is the answer. Do not substitute the later trio (money, payments system, monetary policy).
1. Medium of exchange — people accept it for goods instead of bartering. Example: cow → money → corn.
2. Store of value — it keeps value in a form everyone recognizes, so holding it means you hold something of value.
3. Unit of account — it is the common measure for prices and wealth (“How rich are you?”).
Historically, all three must be true or it is not money.
One extra line if you have room: today the definition is looser — a token for debiting and crediting accounts. That is context, not one of the three functions.
Walkthrough
- State the historical test
Historically, money is defined by three functions. All three must be present for the historical definition.
- Medium of exchange
Money is accepted for goods and services, avoiding direct barter. The course example is cow → money → corn.
- Store of value
A person can retain money as a commonly recognized form of value.
- Unit of account
Money gives a common measure for prices and wealth: “How rich are you?”
- Separate the later context
The Internet-age token-for-debiting-and-crediting definition is a contrast, not one of the historical three. Money, a payments system, and monetary policy are distinct parts of a monetary system.
Full model answer
Historically, money is defined by three functions (Deck 01, slide 3):
1. A medium of exchange. Money is accepted in exchange for goods and services, so trade no longer needs bartering: a farmer with a cow who needs corn can turn the cow into money and the money into corn.
2. A store of value. Money keeps its value in a commonly recognized form, so holding it shows you possess something of value.
3. A unit of account. Money is the common measure for pricing things and comparing wealth ("How rich are you?").
In the historical definition, all three conditions must be met for something to be considered money.
Context (one or two lines is enough): in the Internet age the definition is relaxed. Money becomes an object or token for debiting/crediting accounts in a payments system, so not all three characteristics are required. Money is also only one part of a monetary system, which needs all three of: money, a payments system (protocols for debiting/crediting accounts, i.e., record keeping), and monetary policy (protocols for controlling the supply of money). The course reuses this frame for Bitcoin (week 5, slide 63): its payments system uses a distributed public ledger, and its monetary policy fixes the total at about 21M BTC.Q2Q2. One-way hashing: 1) What are the two most important properties of a one-way hash function/algorithm? 2) A good one-way hash algorithm is considered to behave like a random function. Explain what it means.cryptoWeek 2
Recall promptDefine one-wayness and collision resistance, then explain how a deterministic hash can still behave like a random function.
Write this for full credit
The two properties to name:
1. One-wayness — given the output, you cannot feasibly find an input that hashes to it.
2. Collision resistance — you cannot feasibly find two different inputs with the same output.
“Behaves like a random function” means three things: the same input always gives the same output; the outputs look random if you never see the inputs; a tiny input change (even 1 byte) makes a completely different output.
Also say: any-length input, short fixed-length output (SHA-256 is 256 bits), and each output is about equally likely (about 1 in 2^256).
Walkthrough
- Define the transformation
A one-way hash maps an input of any length, even an empty string, to a short fixed-length output; the course uses SHA-256 and a 256-bit example.
- Explain one-wayness
Given a particular hash output, finding an input that produces it is computationally infeasible.
- Explain collision resistance
Finding two distinct inputs with the same output is computationally infeasible. The course distinguishes matching a given document from finding any colliding pair, illustrated by the $1,000 versus $10,000 promises.
- Explain random-function behavior
The function is deterministic for the same input, yet outputs appear random and uncorrelated even when inputs differ by one byte.
- Connect to probability and proof of work
For a 256-bit output, the course approximates Prob{SHA256(X) = Y} as 1/2^256 and Prob{SHA256(X) < T} as T/2^256; proof of work uses this threshold behavior.
Full model answer
A one-way hash algorithm hashes an input document of any length (even an empty string) into a condensed, short output of fixed length, say 256 bits (32 bytes). SHA-256 (SHA-2 family, still secure) is the example the course uses; Bitcoin hashes block headers with double SHA-256.
1) The two most important properties
- One-wayness: given an output, it is infeasible for anyone to find an input document that is hashed to that specific output. (In theory you could search; in practice it would take an infeasible amount of time.)
- Collision resistance: it is infeasible for anyone to find two or more different input documents that are hashed to the same output. A good hash resists both types of collision: Type 1, where the attacker has one input document and looks for a different one with the same output, and Type 2, where the attacker may choose any pair. Example from the slides: nobody should be able to find "I, Bob, will pay Alice $1,000." and "I, Bob, will pay Alice $10,000." with the same output. Collisions must exist (only 2^256 outputs but unlimited inputs), yet nobody can find one; the brute-force birthday attack needs about 1.25 · 2^(t/2) hashes for a t-bit output, about 2^128 for 256 bits.
Slide analogy: a confetti shredder that keeps only 20 random pieces and burns off the rest. You cannot rebuild the newspaper from the 20 pieces (one-way), and you cannot find two newspapers shredded to the same 20 pieces (collision-resistant).
2) "Behaves like a random function" (a random oracle)
- The hash is deterministic: the same input always produces the same output.
- Its outputs look random: to every practical algorithm that does not see the inputs X1 and X2, the outputs Y1 = H(X1) and Y2 = H(X2) cannot be told apart from truly random values.
- The outputs are totally uncorrelated even when the inputs are correlated: change a single byte or character of the input and the output is completely different.
- Therefore every possible output value is hit with almost equal probability: Prob{SHA256(X) = Y} ≈ 1/2^256, and for a threshold T, Prob{SHA256(X) < T} ≈ T/2^256. Proof of work depends on exactly this (week 5, slide 23).Q3Q3. Draw a diagram to explain the concept of digital signature.cryptoWeek 2
Recall promptDraw Alice → insecure network → Bob. Put KS only into S, KP into V, and label what travels and the Yes/No output.
Write this for full credit
Draw this and label these parts:
1. Alice signs with her secret key KS. KS goes only into the signing box S.
2. She signs the document, or Hash(m). The document and the signature travel together over an insecure network.
3. Bob verifies with Alice’s public key KP, taken from a public directory. KP goes into the verification box V.
4. V outputs Yes or No.
Name one scheme if asked, for example RSA: signature s = m^d mod N, check m = s^e mod N.
Walkthrough
- Place the parties and keys
Alice owns secret signing key KS; her corresponding public key KP is available to Bob through a public key directory.
- Sign the document
Alice feeds the document, in practice Hash(m), and KS into signing algorithm S, producing a signature.
- Send across the network
The document and its signature travel together over an insecure network; the secret key does not travel.
- Verify with the public key
Bob gives KP, the document, and signature to V. V returns Yes if valid or No if invalid.
- Explain the guarantee
A changed document fails verification; the course names unforgeability, undeniability, universal verifiability, and document-specific signatures. A signature is distinct from encryption.
Full model answer
Draw this (Deck 02 slide 25, repeated in Deck 04 slide 7):
SIGNING BY ALICE VERIFICATION BY BOB
Alice's public key KP
document m --> Hash(m) --> [ S ] --> signature (public key directory)
^ |
Alice's secret key KS -+ v
document m + signature --> ( insecure network ) --> [ V ] --> Yes / No
Explain the parts:
1. Key pair. Alice generates a matching pair of keys: a secret signing key KS that only she holds, and a public key KP that she registers in a public key directory so anyone can look it up.
2. Signing (S). Alice feeds the document (in practice its 1-way hash, Hash(m)) and her secret key KS into the signing algorithm S. S outputs the signature, which is sent together with the document over an insecure network.
3. Verification (V). Bob fetches Alice's public key KP from the directory and feeds KP, the document, and the signature into the verification algorithm V. V outputs Yes (valid, it was Alice) or No.
4. Example: RSA. Alice signs s = m^d mod N with her secret d. Bob uses Alice's public key (e, N), computes m = s^e mod N, and accepts iff m is in the right format. ECDSA and Schnorr (used in Bitcoin) have the same shape: the secret key is used in S, the public key in V, and Hash(m) is what gets signed.
5. Properties: unforgeable, undeniable by the signatory, universally verifiable, and different from document to document. If Bob changes "I, Alice, will pay Bob $1000." to "$1000000.", the old signature is no longer valid.
A signature is not encryption: Bitcoin does not use encryption directly, but it does use public key digital signatures. In Bitcoin, an account number is the hash of a public key, and spending means showing a valid signature made with the matching secret key.Q4Q4. Explain the concept of blockchain in Bitcoin. List at least 3 key elements/fields contained in a block.consensusWeek 5
Recall promptExplain the ledger and draw two linked blocks. Name at least three block fields, then reconstruct all six header fields and what follows the header.
Write this for full credit
Blockchain = Bitcoin’s public ledger of transactions, copied by everyone. No names and no stored account balances.
A block is built about every 10 minutes from the validated transactions of the last 10 minutes.
Blocks link by a one-way hash: each block stores the hash of the previous block’s header, back to the genesis block. Change one transaction and every later link breaks.
Name at least 3 header fields. The full header is 80 bytes: version, hash of previous block, Merkle root, time, target (difficulty), nonce. The transactions themselves follow the header; the first is the coinbase.
Walkthrough
- Define the ledger
Bitcoin’s public ledger records transactions. The course describes the ledger as copied by participants, with no names or explicit account-balance records.
- Assemble a block
Miners validate and collect transactions from roughly the preceding ten minutes; the first transaction is the coinbase. A Merkle root summarizes the ordered list.
- Name the header fields
The 80-byte header contains version (4 B), previous-header hash (32 B), Merkle root (32 B), time (4 B), target (4 B), and nonce (4 B). A transaction count and ordered transaction list follow the header.
- Link blocks by hash
Each new header stores the hash of its predecessor’s header, tracing back toward the genesis block. Mining searches for a header hash under the target.
- Explain tamper evidence
Changing an old transaction changes its Merkle root and header hash, so subsequent links no longer match without redoing their proof of work.
Full model answer
Concept. Bitcoin is a *combined public ledger*: one electronic record of the transactions of all users across the "global village". Only transactions are recorded; there are no names and no balances. The blockchain is how that ledger is kept. Roughly every 10 minutes, the transactions of the last 10 minutes are validated by miners, bundled together with a Merkle hash tree into a block, and the block is irreversibly tied to the previous one by a 1-way hash chain: each block stores the hash of the header of the previous block, so the chain runs back to the genesis block and grows in one direction. Once a block is added, everyone has a copy, and changing an old transaction would change its Merkle root, its block's header hash and every block after it, which anyone can detect. That is what makes the record immutable. Fields in a block (Deck 05 slide 10). A block is an 80-byte block header followed by the list of transactions: | Field | Bytes | What it is | |---|---|---| | Version | 4 | Version number, defines how the block is validated | | Hash of previous block | 32 | Double-SHA-256 hash of the header of the previous block (the chain link) | | Merkle root | 32 | Merkle hash root of all TXs included in this block | | Time | 4 | UNIX epoch time | | Target threshold | 4 | Level of difficulty for proof of work | | Nonce | 4 | Varied by miners so that the hash of this header is below the target threshold | | # of TXs | 1-9 | Number of TXs in this block | | Ordered list of TXs | variable | First TX is the coinbase; the rest are collected mostly during the last 10 minutes | A block can be identified by its height number or by the hash of its header (e.g., block #150,000).
Technical notes
The course calls the chain irreversible. Bitcoin can briefly fork and discard a stale block; replacing older history becomes increasingly costly as work accumulates. Treat finality as increasing confidence, not literal impossibility.
Bitcoin Developer Guide — Block Chain ↗
Q5Q5. Explain the concept of a transaction in Bitcoin. List at least 2 key data fields contained in a transaction.ledgerWeek 4
Recall promptTrace one UTXO into a transaction. Name the previous TXID/index and unlocking data on the input, then value/scriptPubKey on the output.
Write this for full credit
A transaction spends earlier unspent outputs (inputs) and creates new outputs. The ledger records transfers, not balances.
Write at least these two fields:
1. Input: the previous transaction’s id, the output index, and the unlocking data (signature + sender’s public key).
2. Output: the amount (value) and the locking script (hash of the receiver’s public key).
The transaction is identified by its own hash (double SHA-256). Outputs cannot add up to more than the inputs; the difference is the fee.
Walkthrough
- Describe a transaction
A Bitcoin transaction spends earlier unspent outputs as inputs and creates new outputs; the public ledger records these transfers rather than explicit balances.
- Identify the inputs
Each input identifies a prior transaction output by TXID and output index n, and supplies unlocking material such as a signature and public key in the course’s P2PKH example.
- Identify the outputs
Each output states a value in satoshis and a scriptPubKey; in the course’s P2PKH example it contains a hash of the receiver’s public key.
- Name the remaining data
The course also lists version, input/output counts, script lengths, sequence, and lock_time. It identifies a TX by TXID = Double_SHA256(Transaction).
- Check validity and fee
The cited lecture checks that inputs are unspent, signatures match, and output value does not exceed input value; the difference is the fee.
Full model answer
Concept. A transaction (TX) moves bitcoin from one account to another and is what the public ledger records: only transactions are recorded, never balances or names. An "account" is just the hash of a public key (Account # = Hash(Kp)), created on the fly when a payment is received. A TX spends earlier unspent transaction outputs (UTXOs) as its inputs and creates new outputs for future TXs to spend, so money moves along a chain of transactions. A TX is identified by its hash value, TXID = Double_SHA256(Transaction) (32 bytes). Key information in a TX (Deck 04 slide 17): - "From" account: the hash of the unspent TX being spent + the sender's public key. - "To" account: the hash of the receiver's public key + the amount. - Sender's signature: proves the sender has the money (holds the matching secret key) and assures the TX's integrity. - When: set when the TX is "tied" to the blockchain (the block it ends up in). Data fields of a regular TX (max 10,000 bytes, slide 28): Version; Input count; for each input the TXID of the UTXO being spent and its index n, ScriptSigLen and the ScriptSig (signature script, typically signature + public key), Sequence; Output count; for each output the Value (amount in satoshis), scriptPubKeyLen and the scriptPubKey (public key script, usually with the hash of the receiver's public key); Lock_time. What the miner checks: every input really is a UTXO and every signature is valid (the "most important two events" in the notes), and the sum of the outputs ≤ the sum of the inputs; the difference is collected by the miner as the transaction fee.
Technical notes
The account-as-public-key-hash and signature-in-ScriptSig description is a P2PKH teaching example. Bitcoin outputs are spending-condition scripts; P2SH and other script forms also exist. Label this exhibit as the course P2PKH model.
Bitcoin Developer Guide — Transactions ↗The course cites a blanket 10,000-byte transaction maximum. Current Bitcoin Core standardness policy instead defines a maximum standard transaction weight; do not present 10,000 bytes as a current universal transaction-size rule.
Bitcoin Core policy.h — MAX_STANDARD_TX_WEIGHT ↗
Q6Q6. Describe how transactions of past 10 minutes are bundled together and then tied to the Bitcoin blockchain, using a technique called “Merkel hash tree”.consensusWeek 5
Recall promptStarting at TX0 coinbase, draw leaves, pairwise hashes, an odd-leaf duplicate, one root, and the root’s slot in the block header.
Write this for full credit
Write this sequence:
1. Take the validated transactions from about the last 10 minutes. TX0 is the coinbase. Keep the order fixed.
2. Hash each transaction (the leaves).
3. Hash them in pairs. If one is left over, pair it with itself.
4. Repeat until one value remains: the Merkle root.
5. Put that root in the 80-byte block header. Mining hashes the header; the next block stores that header hash, so the transactions cannot be changed later.
Walkthrough
- Collect and order transactions
Miners gather and validate transactions, mostly from the preceding ten minutes. TX0 is the coinbase, and order affects the resulting root.
- Hash each leaf
Hash every transaction separately, for example H01 = Hash(TX0) and H02 = Hash(TX1).
- Pair and hash upward
Pair neighboring hashes and hash each pair; when a level has an odd count, duplicate the final hash for that level.
- Reach the single root
Repeat the pairing until one Merkle root remains. Changing a transaction or its order changes the root.
- Put the root in the header
Store the 32-byte root in the 80-byte block header with the previous hash and mining fields. Proof of work hashes the header; the next block references that header hash.
- Prove inclusion economically
A verifier can check one transaction using only the hashes along its Merkle path rather than revealing or rehashing every transaction.
Full model answer
(The slides spell it Merkle hash tree.)
1. Collect. Miners collect the unconfirmed TXs broadcast mostly during the last 10 minutes and validate them (inputs are UTXOs, signatures valid, right format). The first TX, TX0, is the miner's coinbase. The order is then fixed: a different order would give a different root.
2. Hash each TX. Every TX is individually hashed first: H01 = Hash(TX0), H02 = Hash(TX1), and so on.
3. Pair and merge-hash. The hash values are pair-wise merge-hashed: H11 = Hash(H01, H02), H12 = Hash(H03, H04), ... When a level has an odd number of values, the last hash value is paired with itself, so the number of TXs does not need to be a power of 2.
4. Repeat to the root. Repeat level by level until a single hash value is produced: the Merkle hash root.
5. Tie it to the blockchain. The 32-byte Merkle root goes into the 80-byte block header, next to the version, the hash of the previous block, the time, the target threshold and the nonce. The miner then solves the proof-of-work puzzle SHA256²(block header) < T by varying the 4-byte nonce (if every nonce fails, change the coinbase field, recompute the Merkle root and repeat). The winning header's hash becomes the "hash of previous block" in the next block, so the last 10 minutes of TXs are bundled together and irreversibly tied to the chain.
H_root --> stored in the block header (Merkle root)
/ \
H11 H12
/ \ / \
H01 H02 H03 H04
| | | |
TX0 TX1 TX2 TX3
(coinbase)
Why a Merkle tree? Any change to a TX (a flipped bit, deleted bytes, or a new order) gives a new root that differs from the stored one, so tampering is detected. And a single TX's inclusion can be proved with only that TX and the hashes along its path (to prove TX3 in the slide's 5-TX tree you need only TX3, H03, H11 and H22), which also protects privacy because the other TXs stay hidden behind their hash values.Technical notes
A Merkle path lets a verifier check inclusion with sibling hashes; it does not make included transactions private from full nodes, which retain the block transaction data.
Bitcoin Developer Guide — Block Chain ↗
Q7Q7. Bitcoin transaction graph: 1) Alice has two unspent transactions, one worth 60BTC and the other 40BTC and wishes to pay Bob 50BTC and Cathy 40BTC. Alice is willing to pay Bitcoin miners a generous transaction fee worth 0.5BTC, with the balance being paid back to herself as a change. 2) Upon receiving the 40BTC from Alice, Cathy transfers the full amount to her friend Dana without paying a transaction fee. Draw a diagram to illustrate the above scenario. Make sure to indicate public keys or receiving addresses and their matching digital signatures.ledgerWeek 4
Recall promptDraw 60 + 40 BTC into TX200, label every matching key/signature, distribute 50 + 40 + 9.5, compute the 0.5 fee, then send Cathy’s 40 to Dana at zero fee.
Write this for full credit
Draw two transactions. The numbers to write:
Alice spends 60 BTC and 40 BTC (100 in). She pays Bob 50, Cathy 40, and a 0.5 fee. Her change is 9.5 BTC (100 − 50 − 40 − 0.5).
Label each input with the previous transaction, Alice’s public key, and Alice’s signature. Label each output with the receiver’s public-key hash and the amount (Bob 50, Cathy 40, Alice change 9.5). The 0.5 fee is not an output; the miner keeps it.
Second transaction: Cathy sends all 40 BTC to Dana and pays no fee. Label Cathy’s key and signature on the input, and Dana’s key hash on the output.
Course rule to state: if the fee (tip) is 0, a miner will never pick up the transaction.
Walkthrough
- Show Alice’s starting UTXOs
Two unspent outputs belong to Alice: 60 BTC locked to Hash(PK1) and 40 BTC locked to Hash(PK2). Together they supply 100 BTC.
- Unlock both inputs
TX200 references each earlier TXID plus output index. For each input, show Alice’s public key and signature made by the matching secret key; the key hashes to the UTXO’s receiving address.
- Allocate Alice’s outputs
Create outputs of 50 BTC to Hash(Bob PK), 40 BTC to Hash(Cathy PK), and 9.5 BTC change to a fresh Hash(Alice PK3).
- Balance the fee
Outputs total 99.5 BTC, so 100 − 99.5 = 0.5 BTC is the miner fee; the fee is a difference, not its own output.
- Trace Cathy to Dana
TX300 spends Cathy’s 40 BTC output #1 from TX200 with Cathy’s public key and signature, then creates a 40 BTC output to Hash(Dana PK).
- Explain zero-fee status
TX300 has 40 BTC input and 40 BTC output, hence a zero fee. The course notes say a zero-tip transaction will not be picked up by a miner; distinguish this relay/miner expectation from the value-balance rule that permits equality.
Full model answer
Draw this (same style as Deck 04 slides 20-23):
TX100 (unspent): [ Hash of Alice's PK1 | 60 BTC ] --+
TX120 (unspent): [ Hash of Alice's PK2 | 40 BTC ] --+
v
TX200 inputs : (Hash of TX100, Alice's signature1, Alice's public key PK1)
(Hash of TX120, Alice's signature2, Alice's public key PK2) total in = 100 BTC
outputs: #0 Hash of Bob's public key 50 BTC
#1 Hash of Cathy's public key 40 BTC ----+
#2 Hash of Alice's public key3 9.5 BTC | (change)
| total out = 99.5 BTC
fee to the miner = 100 - 99.5 = 0.5 BTC
v
TX300 input : (Hash of TX200 + index 1, Cathy's signature, Cathy's public key) total in = 40 BTC
output : #0 Hash of Dana's public key 40 BTC total out = 40 BTC, fee = 0
Explain the diagram:
- Accounts are hashes of public keys (Account # = Hash(Kp)). Alice's two UTXOs are locked to the hashes of her public keys PK1 (60 BTC in TX100) and PK2 (40 BTC in TX120).
- TX200, Alice pays. A UTXO must be spent in full, so Alice uses both (60 + 40 = 100 BTC) as two inputs. Each input names the UTXO being spent (hash of the earlier TX plus its output index) and carries Alice's public key and her signature made with the matching secret key. The matching the question asks for: the public key in each input must hash to the account recorded in the UTXO it spends, and the signature must verify under that public key.
- Outputs: 50 BTC to the hash of Bob's public key, 40 BTC to the hash of Cathy's public key, and the change 100 − 50 − 40 − 0.5 = 9.5 BTC back to a new key of Alice's (hash of Alice's public key3). Outputs total 99.5 ≤ inputs 100; the missing 0.5 BTC is not an output. The miner collects it as the transaction fee.
- Accept rule: Bob and Cathy accept if (1) TX100 and TX120 are in the database of unspent TXs and (2) Alice's signatures are both valid.
- TX300, Cathy pays Dana. Cathy spends output #1 of TX200 (40 BTC) with her public key and her signature and pays 40 BTC to the hash of Dana's public key. Inputs = outputs = 40 BTC, so the fee is 0.
- Zero-fee rule from the lecture: the format only requires outputs ≤ inputs, so a zero fee is allowed by the format. But the fee is the miner's tip, and the week 4 notes record: *"If the tip is 0, the transaction will never be picked up by the miner."* So TX300 would sit unconfirmed in the mempool. TXs waiting there can be "replaced", e.g. to increase the fee so they are confirmed faster, and newly confirmed TXs are recommended not to be spent until 5+ new blocks are extended (about 1 hour).Technical notes
The lecture says a zero-tip transaction will never be picked up. Zero fee satisfies the arithmetic balance rule, while relay and miner selection depend on fee-rate policy and other choices. Present “never” as the course note, not a consensus-law guarantee.
Bitcoin Core init.cpp — minrelaytxfee and blockmintxfee ↗
Q8Q8. OP_RETURN is a Bitcoin opcode/command that allows one to record a short message, such as “Congrats, Alice and Bob. All life’s best to the two of you.” in the Bitcoin blockchain. In addition to OP_RETURN, there is another method to store data in the blockchain permanently. It takes advantage of the fact that the Bitcoin network does not discern the validity of a certain field in a transaction output. 1) Explain how this second method works. 2) How to record a relatively large message, such as a digital photo, in the blockchain? 3) How can one intentionally make any amount of bitcoin un-spendable, that is how to “burn” bitcoin? Note: Acts described in this question are considered unethical. You are strongly advised AGAINST doing it!ledgerWeek 4
Recall promptExplain why a P2PKH key-hash field can resemble arbitrary 20-byte data, how many chunks could encode a photo, and why an output without a known key is effectively unspendable.
Write this for full credit
Three parts. Keep them separate:
1. OP_RETURN — an output that carries a short message, often with 0 BTC.
2. The other method — write the data into the output field that is supposed to hold the hash of the receiver’s public key (a fake address). Miners cannot tell a fake hash from a real one, because hashes look random. Once mined, the data stays in every copy of the chain.
3. A large file such as a photo — split it into many 20-byte chunks across many outputs and transactions, in order, then reassemble.
Burning bitcoin — pay to an output whose key hash has no known key. Nobody can ever produce the signature to spend it.
Add the warning: the course says these acts are unethical.
Walkthrough
- Recognize the OP_RETURN baseline
The course shows a short message in an OP_RETURN output, often 0 BTC in its coinbase examples. The sample paper asks for a different data-carrying method.
- Place bytes in a key-hash field
In the course’s P2PKH output model, scriptPubKey contains a 20-byte receiver public-key hash. The answer infers replacing those bytes with message data, producing a fake receiving address.
- Explain the delayed check
Random-looking hash bytes do not reveal whether a matching public key exists; the key/signature condition is tested when the output is later spent. Once mined, the output bytes are committed by the Merkle tree and chain.
- Scale a photo across outputs
In the course answer, split a file into ordered 20-byte chunks across many outputs and transactions, then reconstruct it by reading those fields. Its stated 10,000-byte transaction limit is a course-era simplification.
- Explain the proposed burn
The course describes paying bitcoin to an output for which no one knows a matching key, making the funds effectively unspendable. This is distinct from a provably unspendable OP_RETURN script.
- State the ethics warning
The sample paper explicitly calls these acts unethical and advises against them. This room is an offline explanation, with no live transaction construction or broadcast.
Full model answer
Background. OP_RETURN puts a short message into a TX output. The slides show it in coinbase TXs, used "to add a combination of a random number for mining, proof of ownership, a message": the OP_RETURN outputs carry 0.00000000 BTC, and coinbase messages such as "Mined by …" are readable in block explorers.
> Source note: the slides and notes show OP_RETURN, the output format and the one-way hash, but they do not spell out the fake-address method or burning step by step. The answer below puts together facts that are on the slides.
1) The second method: hide data in the receiver's public-key hash.
- Every output holds an amount and the hash of the receiver's public key in its scriptPubKey (e.g. OP_DUP OP_HASH160 <20-byte PubKey hash> OP_EQUALVERIFY OP_CHECKSIG).
- Bitcoin accounts are created on the fly and are just hash values ("= a random number!"). A good hash output cannot be told apart from a truly random value, so nobody, miners included, can tell whether the 20 bytes in an output are the hash of a real public key or 20 bytes of someone's message.
- Miners validate what the rules require: inputs are UTXOs, signatures are valid, the format is right, and outputs ≤ inputs. The output's public-key hash only has to be "proved" when someone later tries to spend it.
- So: cut the message into 20-byte pieces and write each piece where a receiver's public-key hash would go, in outputs that each pay a tiny amount. Once the TX is mined, those bytes are hashed into the Merkle root, protected by the chain, and copied to every node: stored permanently.
2) A large message, such as a digital photo.
- Split the file into many 20-byte chunks and use many outputs (a TX can have n outputs), each carrying one chunk as a fake address.
- A TX is limited to 10,000 bytes, so a photo needs many TXs. Number them or chain them (each TX spends the previous one's change) so the chunks can be put back in order and the photo rebuilt by reading the outputs.
- Lighter alternative: store only the photo's 1-way hash (for example with OP_RETURN). That proves the photo existed without putting the photo itself on the chain.
3) Burning bitcoin.
- To spend an output you must present a public key whose hash matches the output, plus a valid signature made with the matching secret signing key.
- So send the coins to an output whose "public-key hash" did not come from any real key: a fake address as in (1), or an obviously made-up value. Because the hash is one-way, nobody can find a public key, let alone its secret key, that hashes to that value.
- The coins stay forever as a UTXO nobody can spend: they are burned. (Coins whose secret keys are lost are effectively burned too; about 20% of all bitcoin is considered lost.)
Ethics (printed on the paper). These acts are considered unethical, and you are strongly advised AGAINST doing them. The data can never be removed from the immutable blockchain, every full node has to store it, and the fake outputs sit forever in the UTXO database that miners maintain.Technical notes
The fake 20-byte receiver-hash explanation applies to the P2PKH output pattern used in the course; Bitcoin also has other output script types. The lecture sources do not themselves specify the whole fake-address procedure, so this answer is a synthesis.
Bitcoin Developer Guide — Transactions ↗The course’s 10,000-byte transaction limit is not a current universal cap; Bitcoin Core standardness policy uses transaction weight. Keep the number inside the course answer only.
Bitcoin Core policy.h — MAX_STANDARD_TX_WEIGHT ↗A fake key hash is effectively unspendable when no matching key is known, but it is not a proof that no key could exist. OP_RETURN scripts are provably unspendable and are treated differently from ordinary unspent outputs. The course’s “about 20% lost” figure is unverified here and should not become a current statistic.
Bitcoin Developer Guide — Transactions, Null Data ↗
Q9Q9. Describe RSA blind signature, including public and secret parameters, blinding operation, unblinding operation, and verification algorithm.cashWeek 3
Recall promptWrite public and secret RSA parameters, then derive BLIND Y, SIGN S_Y, UNBLIND S_x, and VERIFY S_x^e for the $10 coin.
Write this for full credit
Use the course’s notation. Write four operations:
Public: (e, N), N = p·q. Secret: d, with e·d = 1 mod φ(N).
1. Blind: Y = r^e · x mod N. Alice keeps x (the coin) and r (the blinder) secret.
2. Sign: the bank computes S_Y = Y^d mod N without seeing x.
3. Unblind: S_x = S_Y / r mod N, which equals x^d mod N.
4. Verify: S_x^e mod N = x, using only the public (e, N).
Why it matters: the bank cannot link the signed coin back to Alice.
Walkthrough
- Set up RSA keys and actors
The bank chooses primes p and q, N = p·q, and exponents e and d satisfying e·d ≡ 1 (mod φ(N)); (e,N) is public and d is secret. Alice is the customer and a shop later verifies.
- Choose a coin and blinder
Alice chooses coin identifier x and invertible randomizer r from Z*_N. The bank will not see x during blind signing.
- Blind before sending
Alice computes Y = r^e·x mod N, or r^e·H(x) mod N in the course’s hash version, and sends Y to the bank.
- Have the bank sign blindly
The bank signs S_Y = Y^d mod N and, in the $10 example, debits Alice’s account by $10 without seeing the unblinded coin.
- Unblind the signature
Alice computes S_x = S_Y/r mod N, meaning multiplication by the modular inverse of r. Since r^(e·d) ≡ r, this yields x^d mod N (or H(x)^d).
- Verify and explain unlinkability
The shop checks S_x^e mod N = x (or H(x)) using (e,N). The bank saw Y at withdrawal and cannot link the unblinded coin presented later to that withdrawal. The course’s $10 denomination uses e = 23 and d8.
Full model answer
Setting. Chaum's 3-party model: a customer (Alice), the bank, and a shop. The bank signs a coin blindly, without seeing its contents, like stamping a seal on a sealed envelope. The shop can later verify the bank's signature, but the bank cannot link the coin back to Alice. Public and secret parameters (the bank's RSA key, Deck 03 slide 6): - Choose two large primes p, q (each at least 300 digits) and compute **N = p * q**. - Find e and d such that **e * d = 1 (mod φ(N))**, where φ(N) = (p − 1)(q − 1). - Public: (e, N), the bank's public verification key, published in the public key directory. - Secret: d, the bank's matching secret signing key (kept together with N). p, q and φ(N) also stay secret. - For denominations the bank uses one modulus N and different public exponents e = 3, 5, 7, 11, …, 41 (consecutive odd primes) for 1¢, 5¢, …, $1000, each with its own secret d1 … d12. For example, $10 uses e = 23 and d8. Customer's secret values: x and r, picked at random from Z*_N (numbers in Z_N relatively prime to N). x is the coin identifier; r is the randomizer, or blinder. Blinding operation (customer → bank): Y = r^e · x mod N (hash version: Y = r^e · H(x) mod N). The bank sees only Y, which looks random because of r. Signing (bank → customer): S_Y = Y^d mod N. The bank also moves $10 from Alice's account to its own pool. Unblinding operation (customer): S_x = S_Y / r mod N = x^d mod N (hash version: H(x)^d mod N). Why it works: S_Y = (r^e · x)^d = r^(e·d) · x^d = r · x^d mod N, because e·d = 1 mod φ(N). Dividing by r leaves x^d mod N, the bank's ordinary RSA signature on x. Verification algorithm (anyone, e.g. the shop): fetch the bank's public key (e, N), compute S_x^e mod N and accept iff it equals x (in the hash version, H(x)), i.e. the result is in the right format. The customer can also check the bank's reply: Y = S_Y^e mod N. Worked flow for a $10 coin (slide 12): (1) Y = r^23 · H(x) mod N; (2a) S_Y = Y^(d8) mod N and (2b) the bank reduces Alice's balance by $10; (3) Alice verifies Y = S_Y^23 mod N; (4) she unblinds C_$10 = S_Y / r mod N = H(x)^(d8) mod N. Result: the bank sees (Y, S_Y) at withdrawal and C_$10 at deposit but cannot link them, which gives anonymity and untraceability for Alice. (Cut and choose, where the bank opens half of 2k raw coins, forces Alice to build coins in the correct format.)
Q10Q10. ECDSA: 1) Describe elliptic curve based digital signature algorithm (ECDSA), including public and secret parameters, signing algorithm and verification algorithm. 2) One of the root causes of Bitcoin transaction malleability lies in the fact that ECDSA itself is malleable. Explain how it occurs.cryptoWeek 2Optional CS746 extension
Recall promptWithout the panels, write key generation, signing, verification, and why the mirrored signature (r,n−s) retains the same x coordinate.
Write this for full credit
Label this CS 746 only. It is not on the CS 646 paper.
Keys: private d; public Q = d·G on the curve (secp256k1).
Sign: pick random k; r comes from the x-coordinate of k·G; s = (Hash(m) + d·r) / k mod n. The signature is (r, s).
Verify: rebuild the point from (r, s) and the public key; accept if its x-coordinate matches r.
Malleability: (r, n − s) also verifies, because r uses only the x-coordinate and the mirrored point has the same x. Both signatures are valid, and they produce different transaction ids.
Walkthrough
- Mark the course boundary and parameters
This is CS 746-only optional practice for a CS 646 student. ECDSA uses public curve parameters (E,G,p,n) on secp256k1 plus a one-way hash.
- Derive the key pair
Alice chooses private scalar d in the source’s interval [2,n−2] and publishes Q = dG.
- Sign with a fresh k
Choose k, compute kG = (x1,y1), set r = x1 mod n, then s = (Hash(m)+d·r)/k mod n. Retry if r or s is zero; signature σ = (r,s).
- Verify algebraically
Check r,s are in range; w=s^−1 mod n; u1=Hash(m)·w and u2=r·w; compute u1G+u2Q and accept iff its x coordinate mod n equals r.
- Show the malleable twin
Replacing s by n−s negates the verification point’s y coordinate but preserves x. Thus both (r,s) and (r,n−s) verify for the same message.
- Connect to the legacy TXID example
In the course’s legacy scriptSig example, changing the encoded signature changes the transaction hash/TXID while the payment remains valid. The source names a coordinate-committing remedy and EC-Schnorr; modern SegWit nuance is recorded separately.
Full model answer
CS 746 only. CS 646 students do not answer this question (it is worth 0 (N/A) for CS 646). 1) ECDSA *Public, system-wide parameters (E, G, p, n)*, used by all parties in Bitcoin (curve secp256k1): - E: the elliptic curve y^2 = x^3 + 7 mod p over GF(p) (a Koblitz curve); - G: a base point; p: a prime number; n: the size (order) of the additive group of points on E (a prime); - a 1-way hash, Hash. *Key pair:* Alice selects, uniformly at random, an integer d from [2, n − 2] as her private signing key and computes her public key Q = dG (published with (E, G, p, n)). *Signing m:* 1. Select a random integer k in [2, n − 2]. 2. Compute kG = (x1, y1) and r = x1 (mod n). If r = 0, go back to step 1. 3. Compute s = (Hash(m) + d · r) / k (mod n). 4. If s = 0, go back to step 1. Otherwise the signature is σ = (r, s). *Verifying σ = (r, s) on m:* 1. Obtain an authentic copy of Alice's public key (E, G, p, n, Q). 2. Check that r and s are non-zero integers smaller than n. 3. Compute w = s^(−1) (mod n). 4. Compute u1 = Hash(m) · w (mod n) and u2 = r · w (mod n). 5. Compute u1G + u2Q = (x1, y1). 6. Accept the signature only if x1 (mod n) = r. 2) Why ECDSA is malleable, and how that causes transaction malleability - If (r, s) is a valid signature on m, then (r, −s mod n) and (r, n − s) are valid signatures on m too: a "digital twin" that anyone can compute without the private key. - Reason: r depends only on the x coordinate of kG = (x1, y1). Changing kG to −kG flips only the sign of the y coordinate and leaves r unchanged. With −s, w = s^(−1) changes sign, so u1 and u2 both change sign: (−u1)G + (−u2)Q = −(u1G + u2Q), the same point with its y negated. Its x coordinate is the same, so the check x1 (mod n) = r still passes. - In Bitcoin, the signature sits in each input's scriptSig, and the TXID is Double_SHA256 of the whole TX, signatures included. The signature itself does not cover the signature script fields (SIGHASH_ALL signs all fields except the signature scripts). So a third party can swap s for n − s: the TX stays valid and pays the same people, but its TXID changes. That is transaction malleability. - Remedy on the slide: make r a function of both coordinates, e.g. r = Hash(x1, y1). EC-Schnorr, adopted by Bitcoin (Taproot), is free of signature malleability.
Technical notes
The TXID-changing scriptSig example describes legacy transaction structure. Segregated Witness moves signature data outside the transaction hash used as txid for its witness-spending path, mitigating this third-party malleability vector.
BIP 141 — Segregated Witness ↗The algebraic ECDSA pair (r,s) and (r,n−s) is real, but the course’s r = Hash(x,y) remedy is a lecture illustration. Deployed BIP 340 Schnorr signatures have a non-malleability rationale; keep protocol history separate from the mathematical demonstration.
BIP 340 — Schnorr Signatures for secp256k1 ↗