Chapter 15 of 22 Part III: Cybersecurity and Privacy

The Invisible Journey of Money

Each project below is tailored to a specific algorithm and scientific question from Chapter 15, with concrete inputs, verifiable numerical outputs, boundary cases, and links to the related lab and pioneer.

Project 1 of 3 · v1-c15-p01 Foundational · ~25 min

Miniature Issuing-Bank Authorization Engine

Lab activity: A. The miniature issuing bank · Related code: block-01.js, block-04.js · Pioneer: View profile

Real-World Problem: When you tap a card, the issuing bank must decide Approve or Decline in under a second.
Scientific Question: What exact checks occur during authorization before settlement ever moves money between banks?

Objective: Implement an integer-cent issuing bank checking account status, daily limit, available balance, and fictional EMV cryptogram.

Hypothesis to Test: Holding authorized funds as "pending" immediately prevents spending the same balance twice before settlement.

Step-by-Step Implementation

  1. Store all balances and transaction amounts strictly as integer cents.
  2. Verify card active flag, fictional one-time cryptogram, daily limit, and available >= amount.
  3. Move approved amounts into pending holds (authorization) separate from settled balance.
  4. Run a batch settlement step to finalize pending holds into posted ledger entries.
Concrete Input: Balance = 5000 cents ($50.00), purchase = 1999 cents ($19.99), second purchase = 3500 cents ($35.00).
Expected Output: Purchase 1: APPROVED (available = 3001 cents); Purchase 2: DECLINED (insufficient available funds).

Test Cases: Valid $19.99 -> approved; $35.00 on $30.01 left -> declined; Frozen card -> declined.

Boundary Condition: Zero or negative purchase amounts must be rejected immediately.

Common Mistake to Avoid: Using JavaScript floating-point dollars (0.1 + 0.2 !== 0.3) instead of integer cents.

Interpreting Results: Separating authorization holds from clearing/settlement explains why card statements show "Pending" charges.

Show Hint, Extension Challenge & Reflection

Hint: Review the worked example and equation in Chapter 15 before testing the boundary case: Zero or negative purchase amounts must be rejected immediately.

Extension Challenge: Add a partial refund workflow that credits back 500 cents while preserving double-entry balance.

Reflection Question: How did Roland Moreno and Helmut Gröttrup's smart-card chip designs make dynamic payment cryptograms possible?

Project 2 of 3 · v1-c15-p02 Intermediate · ~25 min

Idempotency Key & Double-Entry Ledger

Lab activity: B. One purchase, one record · Related code: block-02.js, block-05.js · Pioneer: View profile

Real-World Problem: If a café payment terminal loses Wi-Fi mid-checkout and retries the request, the customer must not be billed twice.
Scientific Question: How do idempotency keys and double-entry invariants guarantee "one purchase, one record"?

Objective: Build a double-entry ledger with idempotency-key deduplication and verify that sum(debits) === sum(credits).

Hypothesis to Test: Submitting the same idempotency key three times executes the debit/credit pair exactly once and returns the cached receipt.

Step-by-Step Implementation

  1. Maintain a Map of processed idempotency keys to stored transaction receipts.
  2. On incoming request, return the stored receipt immediately if the key already exists.
  3. For new keys, append both a debit entry and an equal credit entry atomically.
  4. Assert sum(debits) === sum(credits) after every operation.
Concrete Input: 3 retries of { key: "tx-901", from: "Customer", to: "Bookstore", cents: 1500 }.
Expected Output: Customer debited 1500 cents ONCE; Bookstore credited 1500 cents ONCE; ledger invariant = 0.

Test Cases: 3 identical keys -> 1 ledger entry; Same key with different amount -> rejected as conflict.

Boundary Condition: Reusing an old idempotency key with a different dollar amount must raise a 409-style conflict error.

Common Mistake to Avoid: Checking idempotency only in the browser UI instead of on the ledger processor.

Interpreting Results: Idempotency makes unreliable networks safe for financial transactions.

Show Hint, Extension Challenge & Reflection

Hint: Review the worked example and equation in Chapter 15 before testing the boundary case: Reusing an old idempotency key with a different dollar amount must raise a 409-style conflict error.

Extension Challenge: Add a ledger audit function that detects any unbalanced single-sided tampering.

Reflection Question: Why did John Shepherd-Barron's ATM and modern digital banking rely on strict transaction atomicity?

Project 3 of 3 · v1-c15-p03 Intermediate · ~25 min

Rule-Based Fraud Review Desk Simulator

Lab activity: C. The review desk · Related code: block-03.js, block-04.js, block-05.js · Pioneer: View profile

Real-World Problem: Banks flag unusual spending patterns while trying not to block legitimate travelers.
Scientific Question: How do transparent risk-scoring rules balance catching fictional fraud against annoying false declines?

Objective: Score fictional transactions using velocity, impossible-travel, and amount-anomaly rules and inspect false-positive rates.

Hypothesis to Test: Combining multiple weak signals (new country + high velocity + unusual hour) lowers false positives compared to a single rigid rule.

Step-by-Step Implementation

  1. Define 3 explainable risk rules (rapid burst, impossible travel speed, amount > 5× average).
  2. Score every transaction in the fictional review queue and log which rules fired.
  3. Adjust the review threshold and count false declines vs. missed anomalies.
  4. Explain why every declined customer needs a clear human-readable reason.
Concrete Input: 10 fictional transactions including 1 impossible-travel pair (City A and City B 3,000 km apart in 5 minutes).
Expected Output: Impossible-travel pair scored 95/100 (HOLD FOR REVIEW); normal bookstore purchase scored 10/100 (APPROVE).

Test Cases: 3,000 km in 5 min -> flagged; Normal $12 purchase -> approved.

Boundary Condition: Card-not-present online purchases can legitimately originate from another city (e.g., ordering a gift).

Common Mistake to Avoid: Hard-blocking transactions without giving users a verification path.

Interpreting Results: Risk scoring is a statistical threshold problem closely related to Chapter 19's FAR/FRR trade-off.

Show Hint, Extension Challenge & Reflection

Hint: Review the worked example and equation in Chapter 15 before testing the boundary case: Card-not-present online purchases can legitimately originate from another city (e.g., ordering a gift).

Extension Challenge: Add a "travel notice" flag that suppresses the foreign-location penalty for verified trips.

Reflection Question: How did David Chaum's blind-signature research raise important questions about privacy in digital payments?