Stopping the same digital currency being spent twice

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Stopping the same digital currency being spent twice

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Why could double spending be a problem for digital money but not for a physical coin?
A A physical coin can be copied for free but digital money cannot
B A digital file can be copied, so the same money could be sent twice
2. What does double spending mean?
A Paying twice as much as the price of an item
B Spending the same digital currency more than once
3. How does blockchain check a payment before accepting it?
A It checks the shared ledger to see if the money has already been spent
B It asks the buyer to promise the money has not been spent
4. Ava spends her coin in a shop. She then tries to pay the same coin to a friend. What happens?
A The second payment is refused because the first is already in the ledger
B The second payment is accepted because it has a new time-stamp
5. Which statement about a ledger entry is correct?
A Once a payment is recorded it cannot be reused for another payment
B A recorded payment can be copied and used for as many payments as needed

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1double spending AThe shared ledger is searched to see if the money was already spent before a payment is accepted
2check ledger before accepting BThe ledger does check. Copying a file does not create new money, because only the ledger entry counts and it is already used.
3A digital file can be copied, but a ledger entry cannot be reused once the money is spent CTrying to spend the same digital currency twice, which blockchain prevents
4A second payment of the same money is refused because the ledger already shows it as spent DIF coin IN ledger THEN refuse payment
5Ava sends the same coin to Ben and to Cara, and both payments are accepted Ecoin spent = recorded in ledger
6Copy the coin file and spend the copy, because the ledger does not check it FBlockchain would not accept both payments. The first payment is already in the ledger, so the second one is refused.

Definitions

double spending

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
IF coin IN ______ THEN REFUSE payment ENDIF
2.
IF coin IN ledger THEN ______ payment ENDIF
3.
IF coin IN ledger THEN REFUSE payment ____ ACCEPT payment ENDIF
4.
IF coin ___ IN ledger THEN ACCEPT payment ENDIF
5.
coin ← 5 ADD coin TO ledger IF ____ IN ledger THEN REFUSE payment

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A coin ← "C7"
B IF coin IN ledger THEN
C OUTPUT "Accepted"
D ELSE
E ADD coin TO ledger
Question 2
A INPUT coin
B found ← SEARCH(wallet, coin)
C IF found = TRUE THEN
D OUTPUT "Refused"
Question 3
A payment ← "Ava pays Ben 5"
B IF payment NOT IN ledger THEN
C DELETE payment FROM ledger
D ELSE OUTPUT "Refused"
Question 4
A entry ← "C4 paid to Sam"
B ledger ← entry
C IF entry IN ledger THEN
D OUTPUT "Already spent"
Question 5
A FOR each block IN chain
B IF coin NOT IN block THEN
C spent ← TRUE
D NEXT block

Answer Key

Stopping the same digital currency being spent twice
Section A: Quick Questions
Q1
B — A digital file can be copied, so the same money could be sent twice
Q2
B — Spending the same digital currency more than once
Q3
A — It checks the shared ledger to see if the money has already been spent
Q4
A — The second payment is refused because the first is already in the ledger
Q5
A — Once a payment is recorded it cannot be reused for another payment
Section B: Match the Pairs
Q1
double spending → Trying to spend the same digital currency twice, which blockchain prevents
Q2
check ledger before accepting → The shared ledger is searched to see if the money was already spent before a payment is accepted
Q3
A digital file can be copied, but a ledger entry cannot be reused once the money is spent → coin spent = recorded in ledger
Q4
A second payment of the same money is refused because the ledger already shows it as spent → IF coin IN ledger THEN refuse payment
Q5
Ava sends the same coin to Ben and to Cara, and both payments are accepted → Blockchain would not accept both payments. The first payment is already in the ledger, so the second one is refused.
Q6
Copy the coin file and spend the copy, because the ledger does not check it → The ledger does check. Copying a file does not create new money, because only the ledger entry counts and it is already used.
Section C: Definitions
Q1
double spending — Spending the same digital currency twice. Blockchain stops it: each spent payment is already in the shared ledger, so a second payment of the same money is refused.
Section D: Fill in the Blanks
Q1
IF coin IN ledger THEN REFUSE payment ENDIF
Q2
IF coin IN ledger THEN REFUSE payment ENDIF
Q3
IF coin IN ledger THEN REFUSE payment ELSE ACCEPT payment ENDIF
Q4
IF coin NOT IN ledger THEN ACCEPT payment ENDIF
Q5
coin ← 5 ADD coin TO ledger IF coin IN ledger THEN REFUSE payment
Section E: Spot the Error
Q1
C — If the coin is already in the ledger it has been spent, so the second payment must be refused. The line should output "Refused".
Q2
B — The check must use the shared ledger, which records every spent payment. A wallet does not show whether the coin was already spent. It should be SEARCH(ledger, coin).
Q3
C — An accepted payment must be added to the ledger so that a later attempt to spend the same money is refused. Deleting it would allow double spending. It should be ADD payment TO ledger.
Q4
B — This overwrites the whole ledger and wipes out all earlier records. A ledger entry is added to the end of the ledger, so it should be APPEND entry TO ledger.
Q5
B — The coin should be marked as spent when it IS found in a block. NOT IN would mark it as spent when it is missing. It should be IF coin IN block THEN.