Full MD5 computed entirely from copy+jump primitives, executed by the
“pythonic runner” vm_programs/CopyJumpMachine.py.
| File | Role |
|---|---|
vm_programs/md5_gen.py |
generator: emits program_md5.prg.txt |
vm_programs/program_md5.prg.txt |
generated MD5 program (375,758 lines) |
vm_programs/md5_reference.py |
expected digests via hashlib |
vm_programs/md5_check.py |
runs the program in the VM and diffs vs hashlib |
vm_programs/md5.md |
design notes (memory layout, primitives, round structure) |
Every MD5 operation is lowered to bit-level copy+jump code:
j <bit> <label>).sum = a⊕b⊕cin, carry = (a&b) | ((a⊕b)&cin)), 5 adds per round.mod 16 arithmetic at runtime).The standard MD5 structure is followed: per round compute F/G/H/I(B,C,D),
then F += A + K[i] + M[g], B += leftrotate(F, s[i]), rotate registers
A=D, D=C, C=B, and finally add the initial constants back
(a0 += A, b0 += B, c0 += C, d0 += D). Bits are LSB-first throughout.
python3 vm_programs/md5_check.py → PASS against hashlib:
b"" → d41d8cd98f00b204e9800998ecf8427eb"abc" → 900150983cd24fb0d6963f7d28e17f72b"hello" → 5d41402abc4b2a76b9719d911017c592b"The quick brown fox jumps over the lazy dog" → 9e107d9d372bb6826bd81d3542a419d6Also verified through the CLI entry point
(python3 vm_programs/CopyJumpMachine.py vm_programs/program_md5.prg.txt),
which emits the 16 digest bytes LSB-first.
python3 vm_programs/md5_reference.py # expected digests
python3 vm_programs/md5_gen.py # (re)generate the program
python3 vm_programs/md5_check.py # run in VM + diff vs hashlib
python3 vm_programs/CopyJumpMachine.py vm_programs/program_md5.prg.txt
Change the embedded message by editing MESSAGE at the top of
md5_gen.py, then re-running the generator.
len(message) < 56 bytes). Multi-block MD5
would need a block loop and running-state chaining across blocks.1024+31 for INIT_D, plus scratch bits at 8000..8003)..cj numeric export is intentionally not generated (the Python runner
executes the textual format directly).resm_bbjj.md.All five stages are complete and verified.
CopyJumpMachine.py — no export)| Stage | File | Result |
|---|---|---|
| 1. XOR gate | vm_programs/program_xor_gate.prg.txt |
✅ 4/4 truth-table cases pass |
| 2. Reference xorshift32 | vm_programs/xorshift32_reference.py |
✅ outputs match expected |
| 3. Countdown loop-count | vm_programs/program_countdown.prg.txt |
✅ counts 10 → 1, terminates |
| 4. One number from seed | vm_programs/program_xorshift32_step.prg.txt |
✅ 0x87985AA5 |
| 5. N numbers in loop | vm_programs/program_xorshift32_loop.prg.txt |
✅ all 10 match reference |
Plus the generator: vm_programs/xorshift32_gen.py (emits stages 4 & 5).
00→byte:0, 01→byte:1, 10→byte:1, 11→byte:0.byte: 10, 9, 8, …, 1.0x87985AA5 (matches reference step 1).xorshift32_reference.py → all 10 values OK (0x87985AA5 … 0x3AB14B11).# XOR gate (type/pass two bits)
printf '1\n0\n' | python3 vm_programs/CopyJumpMachine.py vm_programs/program_xor_gate.prg.txt
# Reference PRNG (play with seed/n)
python3 vm_programs/xorshift32_reference.py 0x12345678 10
python3 vm_programs/xorshift32_reference.py 1 5
# Countdown
python3 vm_programs/CopyJumpMachine.py vm_programs/program_countdown.prg.txt
# One number / N numbers
python3 vm_programs/CopyJumpMachine.py vm_programs/program_xorshift32_step.prg.txt
python3 vm_programs/CopyJumpMachine.py vm_programs/program_xorshift32_loop.prg.txt
xorshift32_gen.py): edit SEED and N at the top, then re-run python3 vm_programs/xorshift32_gen.py to regenerate stages 4 & 5. The emitted .prg.txt headers echo the chosen values (e.g. # SEED = 0x12345678, # N = 10).program_countdown.prg.txt): # === EMBEDDED CONSTANT: N = 10 === with a commented bit-map for editing.# x[0] = seed bit 0 = 0).<<13, >>17, <<5 as index arithmetic over the bit arrays (out-of-range source = constant 0), so no actual shift instructions.a=0 → dst=b; a=1,b=0 → 1; a=1,b=1 → 0), reused 61× per xorshift step (the other 35 bits are plain copies where the shift moved a bit out).Everything is non-interactive (no in reads) so it’s deterministic and directly diffable against the Python reference.
vm_programs/program_xor_gate.prg.txtvm_programs/xorshift32_reference.pyvm_programs/program_countdown.prg.txtvm_programs/program_xorshift32_step.prg.txtvm_programs/program_xorshift32_loop.prg.txtvm_programs/xorshift32_gen.py.cj numeric export (via exporter.py) later.