The cipher below decrypts the stream of every type-01 file and every nested item in the 25 files read; the plain text it gives matches an independent implementation byte for byte.
Key: ring and seed
The key is the file's own 8192-byte ring (layout) and a 16-bit seed. The cipher keeps a state s that starts
as the seed. For each byte of the cipher text:
s = T1[(s >> 8) & 0x7ff] ^ T2[s & 0xff]
plain = cipher ^ ring[s & 0x1fff]
The state is updated before the byte is used, so the first plain byte uses the state after one step. Decryption and encryption are the same operation.
The tables
T1 has 2048 entries and T2 has 256. Both are linear over GF(2): entry i is the XOR of the basis words whose
position matches a set bit of i.
| Table | Basis words, bit 0 first |
|---|---|
| T1 (11 words) | 0001bc86 0003790d 0006f21b 000de436 001bc86d 003790db 006f21b6 00de436d 01bc86da 03790db5 06f21b6a |
| T2 (8 words) | 05e436d5 062c5b7e 01bc8028 03790051 06f200a2 00003790 00006f21 0000de43 |
The state therefore has up to 27 bits. The seed is the two bytes after 74 02 in the seed block; the seeds
of the files read lie between 0x49e8 and 0x4a02.
Nested encryption
Inside the plain text, a literal or OCTET STRING whose content starts 02 hh ll 73 is encrypted again. The same ring is used, with
the seed hhll and the bytes after the first four as cipher text. Its plain text is again a program, which can hold
further encrypted items. Byte i of a cipher text is byte i of its plain text, so every nested item has an exact offset in the file.
Sources
- The constants and the update rule were read from the running reference reader of the OpenMG package and checked against the module files (owner ruling QC088, 2026-12-03).