Skip to content

Bitcoin Dojo: weeks 3–7 exercises, graded against real Bitcoin data - #3

Merged
code-orange-dev merged 1 commit into
mainfrom
dojo-weeks-3-7
Sep 26, 2026
Merged

code-orange-dev merged 1 commit into
mainfrom
dojo-weeks-3-7

Conversation

@code-orange-dev

Copy link
Copy Markdown
Owner

Weeks 3–7 of the Dojo were empty folders. Weeks 1–2 were there but broken: week 2 imported a week_01_solution module that doesn't exist, and week 1 crashed on its first unimplemented method.

New: weeks 3–7 (Programming Bitcoin ch. 4–13)

Each week has exercises/ (stubs with hints and discussion questions), solutions/, and a check.py grader that reports ✓ / ✗ / not implemented yet, like the Privacy Track's SP lab.

Week Graded against
3 Keys & addresses BIP173's example key (key 1 → bc1qw508d6…), the book's ch. 4 answers, WIF of key 1
4 Serialisation Reproduce real mainnet txids byte for byte, including block 170 (Satoshi → Hal Finney)
5 Script & ECDSA Verify the real signature on a 2013 P2PKH transaction with your own sighash, ECDSA and Script interpreter, plus 2-of-3 multisig and the OP_CHECKMULTISIG off-by-one
6 SegWit A real block 800,000 P2WPKH tx: txid vs wtxid, weight (561) and vsize, BIP143 sighash verifying the real signature, nLockTime, and a CLTV script
7 Capstone Verify your own signet transaction with your own code, then continue into the Privacy Track

Expected values come from outside the repo (BIPs, the book, the blockchain), and the reference solutions pass all of them. Real tx data is in data/transactions.json with its source.

Fixes to weeks 1–2

  • Week 2 now uses the participant's week 1 FieldElement if it works, and falls back to the reference otherwise
  • Added FieldElement.__rmul__ as a provided method. Without it, 3 * x**2 in point doubling over F_p raised a TypeError, so week 2 could never pass even with perfect answers
  • Real checks with the book's values ((170,142), 2G = (36,111), order 21) replace "uncomment and look"
  • Fixed Exercise 2 printing the wrong curve equation

CI

.github/workflows/dojo.yml runs every reference solution on Python 3.8 and 3.12 and makes sure unfinished stubs never crash. It only triggers on bitcoin-dojo/**.

Note: the week 7 capstone and README point at the Privacy Track's Silent Payments lab, which lands with #2.

🤖 Generated with Claude Code

- Weeks 3-6 get exercise files, reference solutions and a check.py each:
  keys/addresses (BIP173 + Programming Bitcoin answers), tx parsing
  (reproduce real mainnet txids incl. block 170), Script + ECDSA (verify
  a real 2013 signature), SegWit (real txid, weight, BIP143 signature)
- Week 7 capstone: verify your own signet transaction with your code
- Fix week 2 importing a module that didn't exist; add FieldElement
  __rmul__ (point doubling over F_p was impossible without it); fix the
  mislabeled curve; week 1/2 checks report 'not implemented' instead of
  crashing; week 1/2 reference solutions
- lib/dojo.py shared helpers; data/transactions.json real tx data
- CI: all solutions pass on Python 3.8 and 3.12; stubs never crash

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@code-orange-dev
code-orange-dev merged commit 504c42a into main Sep 26, 2026
2 checks passed
@code-orange-dev
code-orange-dev deleted the dojo-weeks-3-7 branch September 26, 2026 06:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant