Recover keyed delta masks and source-dependent decode boundaries
Browse files- docs/ASSET_PIPELINE_TODO.md +2 -0
- docs/FINDINGS.md +6 -0
- docs/PROVISIONAL_TODO.md +2 -0
- docs/RESEARCH_LEDGER.md +4 -0
- docs/REVERSE_ENGINEERING_TODO.md +5 -0
- docs/research/MESSAGE_DELTA.md +2 -0
- docs/research/MESSAGE_DELTA_KEY.md +56 -0
- docs/research/README.md +2 -0
- docs/research/message-delta-key.json +0 -0
- scripts/analyze_message_delta_key.py +100 -0
- scripts/test_message_delta_key.py +81 -0
docs/ASSET_PIPELINE_TODO.md
CHANGED
|
@@ -236,3 +236,5 @@ Research progress: [message strings and data reads](research/MESSAGE_STRINGS.md)
|
|
| 236 |
Research progress: [numeric message codecs](research/MESSAGE_NUMERIC.md) adds raw float and finite angle contracts (RE-381–383). RE-384 retains compressed/delta/caller/numeric-control/packet/runtime/platform validation; broad codec conversion milestones remain open.
|
| 237 |
|
| 238 |
Research progress: [scalar message deltas](research/MESSAGE_DELTA.md) adds integer/finite-float and modeled-tree compressed contracts (RE-385–387). RE-388 retains keyed/higher-level/caller/actual-packet/runtime/platform work; broad network conversion remains open.
|
|
|
|
|
|
|
|
|
| 236 |
Research progress: [numeric message codecs](research/MESSAGE_NUMERIC.md) adds raw float and finite angle contracts (RE-381–383). RE-384 retains compressed/delta/caller/numeric-control/packet/runtime/platform validation; broad codec conversion milestones remain open.
|
| 237 |
|
| 238 |
Research progress: [scalar message deltas](research/MESSAGE_DELTA.md) adds integer/finite-float and modeled-tree compressed contracts (RE-385–387). RE-388 retains keyed/higher-level/caller/actual-packet/runtime/platform work; broad network conversion remains open.
|
| 239 |
+
|
| 240 |
+
Research progress: [keyed message deltas](research/MESSAGE_DELTA_KEY.md) adds integer mask/XOR and finite float compressed contracts (RE-389–391). RE-392 retains caller/index/runtime/higher-level/packet/platform work; broad networking conversion remains open.
|
docs/FINDINGS.md
CHANGED
|
@@ -438,3 +438,9 @@ Bounded qagame paths recover bomb-plant/inactivity correction requests, direct f
|
|
| 438 |
**F-149 — Observed finite float delta:** finite numeric equality controls payload omission, including opposite signed zeros; unchanged reads retain baseline bits. Changed payloads forward raw 32-bit words. Nonfinite/control-state/caller/runtime behavior remains open. [DELTA-002](research/MESSAGE_DELTA.md).
|
| 439 |
|
| 440 |
**F-150 — Observed compressed scalar delta composition:** native wrapper/bit/Huffman instruction slices agree with independent flag/remainder/modeled-codeword packing and cursor/accounting checks. Seed trees remain model-derived; actual packet/overflow/EOF/full-native-training/platform contracts remain open. [DELTA-003](research/MESSAGE_DELTA.md).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 438 |
**F-149 — Observed finite float delta:** finite numeric equality controls payload omission, including opposite signed zeros; unchanged reads retain baseline bits. Changed payloads forward raw 32-bit words. Nonfinite/control-state/caller/runtime behavior remains open. [DELTA-002](research/MESSAGE_DELTA.md).
|
| 439 |
|
| 440 |
**F-150 — Observed compressed scalar delta composition:** native wrapper/bit/Huffman instruction slices agree with independent flag/remainder/modeled-codeword packing and cursor/accounting checks. Seed trees remain model-derived; actual packet/overflow/EOF/full-native-training/platform contracts remain open. [DELTA-003](research/MESSAGE_DELTA.md).
|
| 441 |
+
|
| 442 |
+
**F-151 — Observed keyed integer mask indexing:** writer compares before full-word XOR; reader directly indexes a 32-word kbitmask by width. Sampled widths below 32 retain one extra key bit; width 32 reads the adjacent entityStateFields low word, differing between the Linux images. Caller width/key/narrowing/legal-index/runtime effects remain open. [KEY-001](research/MESSAGE_DELTA_KEY.md).
|
| 443 |
+
|
| 444 |
+
**F-152 — Observed keyed finite float delta:** numeric equality omits payload and preserves baseline bits; changed words XOR the full key before/after 32-bit transport, without the integer mask table. Nonfinite/control-state/caller/platform behavior remains open. [KEY-002](research/MESSAGE_DELTA_KEY.md).
|
| 445 |
+
|
| 446 |
+
**F-153 — Observed keyed compressed composition:** independent modeled-codeword packing agrees with native wrapper/bit/Huffman slices and paired bytes/cursors. Integer width-32 decode returns can differ for identical bytes due to actual adjacent file words; legal game-level reachability remains unverified. Native training/packet/overflow/EOF/runtime/platform contracts remain open. [KEY-003](research/MESSAGE_DELTA_KEY.md).
|
docs/PROVISIONAL_TODO.md
CHANGED
|
@@ -548,3 +548,5 @@ Research progress: [message strings and data reads](research/MESSAGE_STRINGS.md)
|
|
| 548 |
Research progress: [numeric message codecs](research/MESSAGE_NUMERIC.md) completes bounded RE-381–383. RE-384 leaves delta/snapshot/angle callers and complete compressed/numeric-control/runtime/platform contracts open.
|
| 549 |
|
| 550 |
Research progress: [scalar message deltas](research/MESSAGE_DELTA.md) completes bounded RE-385–387. RE-388 leaves keyed/usercmd/entity/player/snapshot and complete caller/overflow/EOF/floating/runtime/platform contracts open.
|
|
|
|
|
|
|
|
|
| 548 |
Research progress: [numeric message codecs](research/MESSAGE_NUMERIC.md) completes bounded RE-381–383. RE-384 leaves delta/snapshot/angle callers and complete compressed/numeric-control/runtime/platform contracts open.
|
| 549 |
|
| 550 |
Research progress: [scalar message deltas](research/MESSAGE_DELTA.md) completes bounded RE-385–387. RE-388 leaves keyed/usercmd/entity/player/snapshot and complete caller/overflow/EOF/floating/runtime/platform contracts open.
|
| 551 |
+
|
| 552 |
+
Research progress: [keyed message deltas](research/MESSAGE_DELTA_KEY.md) completes bounded RE-389–391. RE-392 leaves keyed caller/narrowing/index reachability, higher-level codecs and actual runtime/packet/platform contracts open.
|
docs/RESEARCH_LEDGER.md
CHANGED
|
@@ -249,3 +249,7 @@ Completed bounded RE-381–383 with `analyze_message_numeric.py`: fourteen verif
|
|
| 249 |
## 2026-10-11 — Scalar deltas and modeled-tree compressed composition
|
| 250 |
|
| 251 |
Completed bounded RE-385–387 with `analyze_message_delta.py`: 22 verified graphs across the Linux ELF64 engines, 296 compressed scalar delta streams and 48 supplied-reader control probes. DELTA-001–003/F-148–150 distinguish full-word integer equality/baseline retention from changed-width masking, finite float equality (including opposite signed zeros) from raw word equality, and local nonzero flag dispatch from legal one-bit decoder output. Changed float payloads retain raw words; unchanged reads retain baseline bits. Native delta/bit/raw/Huffman instruction slices compose exact bytes against MODEL-DERIVED seeded trees, with independent flag/remainder/codeword packing, decoded value, cursor, oldsize/range diagnostic and canary oracles. Source/disassembly identities and codebook/initialization report hashes are retained and verified. Frame saves/restores/PUSH/POP are omitted; stopped helper/tail boundaries, disjoint virtual frames and caller-register restoration are explicit. No original process or native callee executes, and finite comparison rejection does not specify native nonfinite behavior. Eight tests verify integer/float requests and equality, independent packing, changed signed tails, cursor/accounting/diagnostics/canaries, supplied nonzero flags, dependency hashes/paired outcomes and finite comparison model boundaries. All 382 tests pass; new and preceding reports regenerate byte-identically, with storage/link/whitespace checks passing. RE-384 remains open; RE-388 tracks keyed masks/XOR/table bounds, usercmd/entity/player/snapshot/caller contracts, remaining widths/aliases, compressed capacity/overflow/reset/truncation/EOF/padding/nonfinite control behavior, native seeded codewords and actual packet/runtime/all-platform/renderer conformance.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
## 2026-10-11 — Scalar deltas and modeled-tree compressed composition
|
| 250 |
|
| 251 |
Completed bounded RE-385–387 with `analyze_message_delta.py`: 22 verified graphs across the Linux ELF64 engines, 296 compressed scalar delta streams and 48 supplied-reader control probes. DELTA-001–003/F-148–150 distinguish full-word integer equality/baseline retention from changed-width masking, finite float equality (including opposite signed zeros) from raw word equality, and local nonzero flag dispatch from legal one-bit decoder output. Changed float payloads retain raw words; unchanged reads retain baseline bits. Native delta/bit/raw/Huffman instruction slices compose exact bytes against MODEL-DERIVED seeded trees, with independent flag/remainder/codeword packing, decoded value, cursor, oldsize/range diagnostic and canary oracles. Source/disassembly identities and codebook/initialization report hashes are retained and verified. Frame saves/restores/PUSH/POP are omitted; stopped helper/tail boundaries, disjoint virtual frames and caller-register restoration are explicit. No original process or native callee executes, and finite comparison rejection does not specify native nonfinite behavior. Eight tests verify integer/float requests and equality, independent packing, changed signed tails, cursor/accounting/diagnostics/canaries, supplied nonzero flags, dependency hashes/paired outcomes and finite comparison model boundaries. All 382 tests pass; new and preceding reports regenerate byte-identically, with storage/link/whitespace checks passing. RE-384 remains open; RE-388 tracks keyed masks/XOR/table bounds, usercmd/entity/player/snapshot/caller contracts, remaining widths/aliases, compressed capacity/overflow/reset/truncation/EOF/padding/nonfinite control behavior, native seeded codewords and actual packet/runtime/all-platform/renderer conformance.
|
| 252 |
+
|
| 253 |
+
## 2026-10-11 — Keyed deltas, direct mask indexing and adjacent data
|
| 254 |
+
|
| 255 |
+
Completed bounded RE-389–391 with `analyze_message_delta_key.py`: 22 verified graphs across the Linux ELF64 engines, two symbol/file-backed 32-word mask tables plus adjacent entityStateFields words, 288 compressed keyed streams and 48 supplied-reader control probes. KEY-001–003/F-151–153 distinguish comparison before XOR from keyed payload encoding, direct width indexing from an inferred width-minus-one mask, extra returned key bits from caller-visible effects, and width-32 adjacent file reads from a valid mask entry. Identical encoded width-32 integer streams can return different words between images because the adjacent low words differ; legal caller/index/narrowing/runtime reachability remains unverified. Finite keyed float payloads XOR the complete word and recover changed values; numeric equality/signed zeros retain baseline bits without using the integer mask table. Independent flag/remainder/modeled-codeword packing, exact decode formula, cursor/accounting/XOR-range diagnostic and canary oracles validate the sampled instruction compositions. Source/disassembly and dependency identities/hashes are retained; compressed trees remain MODEL-DERIVED. Frame saves/restores/PUSH/POP are omitted, stopped helper/tail boundaries and caller-register restoration are explicit, and no original process or native callee executes. Eight tests verify table/symbol/adjacent file bytes, keyed decisions/requests, float behavior, independent packing/cursors, integer decode masks, supplied flags, accounting/diagnostics/dependencies and paired payloads with source-specific width-32 results. All 390 tests pass; new and preceding reports regenerate byte-identically, with storage/link/whitespace checks passing. RE-388 remains open; RE-392 tracks caller widths/keys/narrowing/index reachability/runtime adjacent effects, usercmd/entity/player/snapshot codecs, remaining scalar/overflow/EOF/nonfinite controls, native seeded codewords and actual packet/runtime/all-platform/renderer contracts before Rust mask compatibility decisions.
|
docs/REVERSE_ENGINEERING_TODO.md
CHANGED
|
@@ -467,3 +467,8 @@ Purpose: turn the supplied installation into an evidence-backed specification of
|
|
| 467 |
- [x] RE-386 Recover finite float delta comparisons, signed-zero baseline retention and raw changed payloads ([DELTA-002](research/MESSAGE_DELTA.md)).
|
| 468 |
- [x] RE-387 Compose bounded scalar delta compressed writes/reads against modeled trees with independent payload/cursor/accounting oracles ([DELTA-003](research/MESSAGE_DELTA.md)).
|
| 469 |
- [ ] RE-388 Recover keyed integer/float delta masks/XOR/table bounds, usercmd/entity/player/snapshot codecs and callers; validate remaining widths/value aliases, compressed capacity/overflow/reset/truncation/EOF/padding/nonfinite-control contracts, native seeded codewords and actual packet/runtime/all-platform/renderer conformance.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 467 |
- [x] RE-386 Recover finite float delta comparisons, signed-zero baseline retention and raw changed payloads ([DELTA-002](research/MESSAGE_DELTA.md)).
|
| 468 |
- [x] RE-387 Compose bounded scalar delta compressed writes/reads against modeled trees with independent payload/cursor/accounting oracles ([DELTA-003](research/MESSAGE_DELTA.md)).
|
| 469 |
- [ ] RE-388 Recover keyed integer/float delta masks/XOR/table bounds, usercmd/entity/player/snapshot codecs and callers; validate remaining widths/value aliases, compressed capacity/overflow/reset/truncation/EOF/padding/nonfinite-control contracts, native seeded codewords and actual packet/runtime/all-platform/renderer conformance.
|
| 470 |
+
|
| 471 |
+
- [x] RE-389 Recover keyed integer XOR/direct-index masks, symbol-backed array bounds and sampled adjacent width-32 reads ([KEY-001](research/MESSAGE_DELTA_KEY.md)).
|
| 472 |
+
- [x] RE-390 Recover keyed finite float comparisons, baseline retention and full-word XOR payloads ([KEY-002](research/MESSAGE_DELTA_KEY.md)).
|
| 473 |
+
- [x] RE-391 Compose modeled-tree keyed streams with independent packing/cursors and source-dependent integer width-32 return checks ([KEY-003](research/MESSAGE_DELTA_KEY.md)).
|
| 474 |
+
- [ ] RE-392 Recover keyed callers/widths/keys/narrowing and zero/negative/out-of-range mask-index reachability, runtime adjacent-data effects, usercmd/entity/player/snapshot codecs, remaining scalar/overflow/EOF/nonfinite/control-state behavior, native seeded codewords and actual packet/runtime/all-platform/renderer contracts; resolve caller evidence before Rust mask compatibility decisions.
|
docs/research/MESSAGE_DELTA.md
CHANGED
|
@@ -37,3 +37,5 @@ Twenty-four additional reader probes per engine supply flag words 0/1/2/0xffffff
|
|
| 37 |
Eight independent tests verify integer full-word/request behavior, finite float comparisons/signed-zero retention, independent flag/remainder/codeword packing, changed integer masking/signed tails, cursor/accounting/diagnostic/canary effects, nonzero supplied reader flags, report dependencies/paired results and the finite comparison model boundary. No evaluator extension was needed.
|
| 38 |
|
| 39 |
RE-388: recover integer/float keyed delta masks/XOR/table bounds, usercmd/entity/player/snapshot codecs and actual callers; validate remaining scalar widths/value aliases, compressed capacity/overflow/reset/truncation/EOF/padding, nonfinite floating control behavior, native seeded codewords and actual packet/runtime/all-platform/renderer contracts.
|
|
|
|
|
|
|
|
|
| 37 |
Eight independent tests verify integer full-word/request behavior, finite float comparisons/signed-zero retention, independent flag/remainder/codeword packing, changed integer masking/signed tails, cursor/accounting/diagnostic/canary effects, nonzero supplied reader flags, report dependencies/paired results and the finite comparison model boundary. No evaluator extension was needed.
|
| 38 |
|
| 39 |
RE-388: recover integer/float keyed delta masks/XOR/table bounds, usercmd/entity/player/snapshot codecs and actual callers; validate remaining scalar widths/value aliases, compressed capacity/overflow/reset/truncation/EOF/padding, nonfinite floating control behavior, native seeded codewords and actual packet/runtime/all-platform/renderer contracts.
|
| 40 |
+
|
| 41 |
+
Follow-up: [keyed message deltas](MESSAGE_DELTA_KEY.md) recovers bounded integer mask/XOR, finite float XOR and modeled-tree streams. Broader RE-388 remains open; RE-392 tracks caller/index/narrowing and complete packet/platform contracts.
|
docs/research/MESSAGE_DELTA_KEY.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Keyed delta masks, XOR and compressed compositions
|
| 2 |
+
|
| 3 |
+
Reproduce with `python3 scripts/analyze_message_delta_key.py`; validate with `python3 scripts/test_message_delta_key.py`. [message-delta-key.json](message-delta-key.json) retains 22 source/disassembly-hash-verified graphs across the Linux ELF64 engines, symbol-backed mask-table bytes and adjacent data, 288 compressed keyed streams and 48 supplied-reader control probes. It hashes and checks native identities for the [modeled codebook](HUFFMAN_CODEBOOK.md) and [initialization report](HUFFMAN_INITIALIZATION.md).
|
| 4 |
+
|
| 5 |
+
All results are synthetic native instruction compositions; original processes and native callees never execute. Compressed trees remain MODEL-DERIVED. Frame saves/restores/PUSH/POP are omitted; helper CALL/tail boundaries stop and compose with explicit caller-register restoration and disjoint virtual frames. Supplied flag/payload probes do not decode actual bits/cursors. Float comparisons cover finite inputs only. Legal caller widths/keys/truncation, full native training, runtime/all-platform and actual packet conformance remain open.
|
| 6 |
+
|
| 7 |
+
## KEY-001 — Integer XOR and direct mask-table indexing (RE-389)
|
| 8 |
+
|
| 9 |
+
MSG_WriteDeltaKey compares complete baseline/new words before XOR. Equal words request only a zero flag of width one, regardless of the key. Changed words request a one flag, then forward `(new_word XOR key_word)` with the supplied width. The underlying writer masks/range-checks that XOR word; the delta wrapper does not validate the width or key locally.
|
| 10 |
+
|
| 11 |
+
MSG_ReadDeltaKey requests width one, returning the full baseline when the flag is zero. For nonzero flags it reads the supplied payload width, indexes the file-backed kbitmask array directly by that signed width, masks the key with the indexed word, then XORs that masked key into the read result. It does not locally clamp the index or add a scalar-wrapper post-read EOF check.
|
| 12 |
+
|
| 13 |
+
Both ELF symbol tables identify kbitmask as 128 bytes: exactly 32 little-endian words. Independent extraction/hash checks recover entry i as `(1 << (i+1)) - 1` for i zero through 31. Thus the directly selected mask is one bit wider than the requested payload width for sampled positive widths below 32:
|
| 14 |
+
|
| 15 |
+
| Supplied width | Indexed mask |
|
| 16 |
+
| --- | --- |
|
| 17 |
+
| 1 | 0x00000003 |
|
| 18 |
+
| 7 | 0x000000ff |
|
| 19 |
+
| 8 | 0x000001ff |
|
| 20 |
+
| 16 | 0x0001ffff |
|
| 21 |
+
| 31 | 0xffffffff |
|
| 22 |
+
|
| 23 |
+
For sampled changed positive widths W below 32, the composed returned word is `(new_word & ((1 << W)-1)) | (key_word & (1 << W))`. The extra returned bit comes from the key. This is a local return-word contract, not a proof of a game-level discrepancy: callers may restrict keys/widths or truncate to narrower fields. Those callers must be recovered before choosing Rust compatibility behavior.
|
| 24 |
+
|
| 25 |
+
Width 32 indexes immediately beyond the symbol-backed array. The next ELF symbol is entityStateFields, starting exactly at kbitmask +128. The synthetic composition supplies its actual file-backed first four bytes, not an invented 33rd mask entry:
|
| 26 |
+
|
| 27 |
+
| Image | Adjacent low word |
|
| 28 |
+
| --- | --- |
|
| 29 |
+
| Linux dedicated ELF64 | 0x004b8135 |
|
| 30 |
+
| Linux client ELF64 | 0x0056fcb4 |
|
| 31 |
+
|
| 32 |
+
For these supplied width-32 states the returned word is `(new XOR key) XOR (key & adjacent_word)`, and can differ between images for identical encoded bytes. The report retains array and neighboring symbol bounds, addresses, offsets and exact bytes. It does not establish that a width-32 integer-key call is legal/reachable, or that runtime relocation/lifetime/platform behavior matches file-backed memory. Negative/zero/out-of-range indexes and their callers remain open.
|
| 33 |
+
|
| 34 |
+
## KEY-002 — Keyed finite float delta (RE-390)
|
| 35 |
+
|
| 36 |
+
MSG_WriteDeltaKeyFloat uses finite scalar comparison to decide whether to emit a payload. Equal numeric values request only a zero flag; opposite signed zeros therefore retain the baseline's bits. Changed values request a one flag and then the raw new scalar word XOR the full key with width thirty-two.
|
| 37 |
+
|
| 38 |
+
The float reader returns baseline bits for a zero flag. For any supplied nonzero flag it reads thirty-two bits, XORs the full key into the raw word and returns that scalar payload through moves. It does not use kbitmask. Encoded XOR words can look nonfinite, but the sampled arithmetic comparison happens on finite inputs before XOR; payload handling is integer/raw-bit transport.
|
| 39 |
+
|
| 40 |
+
Forty-eight finite float streams per engine cover eight baseline/new pairs, keys zero/0x80000100/0xffffffff and initial bit positions zero/seven. Changed values recover the complete new word; unchanged values retain the baseline, including signed-zero cases. Native NaN/unordered/exception/MXCSR/FTZ/DAZ and caller sentinel behavior remain unmodeled.
|
| 41 |
+
|
| 42 |
+
## KEY-003 — Compressed keyed streams and paired-image differences (RE-391)
|
| 43 |
+
|
| 44 |
+
Each image also has 96 integer streams across widths 1/7/8/9/16/24/31/32, four baseline/new pairs and the same three keys, with initial bit zero. Every stream composes key-delta requests with WriteBits/raw-bit/transmit/send instructions, then resets the supplied read cursor and composes ReadBits/raw-bit/receive and key-delta instructions against the exact output bytes. The modeled tree determines Huffman symbols/code lengths; they are not supplied separately at helper boundaries.
|
| 45 |
+
|
| 46 |
+
Independent packing verifies the change bit, XOR payload's raw remainder and modeled Huffman byte codes. Payload bytes/cursors agree between native images. Decoded integer results match independently extracted direct-index masks, including the width-32 adjacent-word difference. Keyed float results recover the expected raw word without that table effect.
|
| 47 |
+
|
| 48 |
+
Oldsize counts one flag bit plus the requested payload width when changed. Range diagnostics inspect the signed XOR payload before width masking; they do not stop the sampled writes. Message overflow stays zero in explicitly oversized 256-byte, zero-initialized buffers with canaries. Size/readcount retain `(bit >> 3) + 1` for the sampled nonnegative cursors. Near-capacity expansion, dirty prefixes, padding, truncation/EOF and full networking recovery remain open.
|
| 49 |
+
|
| 50 |
+
Twenty-four reader control probes per engine supply flags 0/1/2/0xffffffff, three keys, baseline 0x1234 and a raw payload word. Zero retains baseline; other words trigger integer width thirteen or float width thirty-two payload requests. Integer return XOR uses the direct table entry; float uses the full key. These supplied noncanonical flags are boundary probes, not legal one-bit decoder outputs.
|
| 51 |
+
|
| 52 |
+
## Validation and next work
|
| 53 |
+
|
| 54 |
+
Eight independent tests verify symbol/file-backed table and adjacent bytes, integer decision/request XOR, finite float/signed-zero behavior, independent compressed packing/cursors, exact integer decode masks, supplied flags, accounting/XOR diagnostics/dependency hashes, and paired payloads with explicitly source-dependent width-32 results. No evaluator extension was needed.
|
| 55 |
+
|
| 56 |
+
RE-392: recover keyed delta caller widths/keys and narrowing, mask-index zero/negative/out-of-range reachability, runtime adjacent-data effects, usercmd/entity/player/snapshot codecs, remaining scalar/overflow/EOF/nonfinite/control-state behavior, native trained codewords and actual packet/runtime/all-platform/renderer contracts. Resolve caller evidence before normalizing or preserving the observed mask behavior in Rust.
|
docs/research/README.md
CHANGED
|
@@ -149,3 +149,5 @@ The extension collector adds five focused tests for native tail calls, command-r
|
|
| 149 |
[Raw float transport and finite angle codecs](MESSAGE_NUMERIC.md) adds RE-381–383: raw float OOB/EOF behavior, finite angle encoding and signed angle16 reads. Reproduce with `python3 scripts/analyze_message_numeric.py`; check with `python3 scripts/test_message_numeric.py`. Delta/caller/control-state/compressed and actual packet/runtime/platform contracts remain open.
|
| 150 |
|
| 151 |
[Scalar delta flags and compressed compositions](MESSAGE_DELTA.md) adds RE-385–387: integer changes, finite float equality/signed zeros and modeled-tree byte/cursor composition. Reproduce with `python3 scripts/analyze_message_delta.py`; check with `python3 scripts/test_message_delta.py`. Keyed/higher-level/overflow/EOF/nonfinite and actual packet/runtime/platform contracts remain open.
|
|
|
|
|
|
|
|
|
| 149 |
[Raw float transport and finite angle codecs](MESSAGE_NUMERIC.md) adds RE-381–383: raw float OOB/EOF behavior, finite angle encoding and signed angle16 reads. Reproduce with `python3 scripts/analyze_message_numeric.py`; check with `python3 scripts/test_message_numeric.py`. Delta/caller/control-state/compressed and actual packet/runtime/platform contracts remain open.
|
| 150 |
|
| 151 |
[Scalar delta flags and compressed compositions](MESSAGE_DELTA.md) adds RE-385–387: integer changes, finite float equality/signed zeros and modeled-tree byte/cursor composition. Reproduce with `python3 scripts/analyze_message_delta.py`; check with `python3 scripts/test_message_delta.py`. Keyed/higher-level/overflow/EOF/nonfinite and actual packet/runtime/platform contracts remain open.
|
| 152 |
+
|
| 153 |
+
[Keyed delta masks, XOR and compressed compositions](MESSAGE_DELTA_KEY.md) adds RE-389–391: actual integer table/bounds/adjacent reads, finite float XOR and modeled-tree payload/cursor checks. Reproduce with `python3 scripts/analyze_message_delta_key.py`; check with `python3 scripts/test_message_delta_key.py`. Caller/narrowing/index/higher-level and actual packet/runtime/platform contracts remain open.
|
docs/research/message-delta-key.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
scripts/analyze_message_delta_key.py
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Keyed delta masks/XOR and modeled-tree compressed compositions."""
|
| 3 |
+
import gzip
|
| 4 |
+
import hashlib
|
| 5 |
+
import itertools
|
| 6 |
+
import json
|
| 7 |
+
import re
|
| 8 |
+
import struct
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
from analyze_bsp_loading import read_address
|
| 11 |
+
from analyze_native import elf
|
| 12 |
+
from analyze_bsp_references import global_address, trace_fields
|
| 13 |
+
from analyze_collision_composition import get_word, put_word
|
| 14 |
+
from analyze_engine_control import control_flow
|
| 15 |
+
from analyze_message_byte_codec import MSG, DATA, install_tree
|
| 16 |
+
from analyze_message_numeric import frame_graph
|
| 17 |
+
from analyze_message_widths import reader, run, writer
|
| 18 |
+
from analyze_message_wrappers import WRAPPER_STACK
|
| 19 |
+
from analyze_qvm import write_json
|
| 20 |
+
from analyze_vm_extensions import native_functions, verified
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
INTEGER_PAIRS=[(0,0),(0,1),(1,0),(0x1234,0x1234),(0x1234,0xffffffff),(0xffffffff,0)]
|
| 24 |
+
FLOAT_PAIRS=[(0,0),(0,0x80000000),(0x80000000,0),(0x3f800000,0x3f800000),(0x3f800000,0x3fc00000),(0xbf800000,0x3f800000),(0x3f800000,0),(0x7f7fffff,0x7f7fffff)]
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def write_delta(graphs,m,kind,baseline,value,width,key):
|
| 28 |
+
name='MSG_WriteDeltaKeyFloat' if kind=='float' else 'MSG_WriteDeltaKey';g,omitted=frame_graph(graphs[name]);rows=g['instructions'];calls={x['address']:i for i,x in enumerate(rows) if x['opcode']=='callq'};tails={x['address'] for x in rows if x['opcode']=='jmp' and '<MSG_WriteBits>' in x['operands']};ends={x['address'] for x in rows if x['opcode']=='retq'}
|
| 29 |
+
regs={'%rdi':MSG,'%rsi':key,'%rdx':baseline,'%rcx':value,'%r8':width&0xffffffff,'%xmm0':baseline,'%xmm1':value,'%rsp':WRAPPER_STACK};pc=rows[0]['address'];requests=[];trace=[]
|
| 30 |
+
while True:
|
| 31 |
+
t=run(g,pc,list(calls)+list(tails)+list(ends),m,regs);m=t['memory'];regs=t['registers'];trace+=t['trace']
|
| 32 |
+
if t['stop'] in ends:break
|
| 33 |
+
request=[regs[k] for k in ['rdi','rsi','rdx']];requests.append(request)
|
| 34 |
+
if request[0]!=MSG:raise ValueError('delta writer pointer')
|
| 35 |
+
word_width=request[2];signed_width=word_width if word_width<2**31 else word_width-2**32
|
| 36 |
+
m,_,error,child=writer(graphs,m,signed_width,request[1]);trace+=child
|
| 37 |
+
if error:raise ValueError('delta writer fixture error')
|
| 38 |
+
if t['stop'] in tails:break
|
| 39 |
+
pc=rows[calls[t['stop']]+1]['address']
|
| 40 |
+
if len(requests)>2:raise ValueError('delta writer bound')
|
| 41 |
+
return m,requests,trace,omitted
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def read_delta(graphs,m,kind,baseline,width,key,supplied=None):
|
| 45 |
+
name='MSG_ReadDeltaKeyFloat' if kind=='float' else 'MSG_ReadDeltaKey';g,omitted=frame_graph(graphs[name]);rows=g['instructions'];calls={x['address']:i for i,x in enumerate(rows) if x['opcode']=='callq'};tails={x['address'] for x in rows if x['opcode']=='jmp' and '<MSG_ReadBits>' in x['operands']};ends={x['address'] for x in rows if x['opcode']=='retq'}
|
| 46 |
+
regs={'%rdi':MSG,'%rsi':key,'%rdx':baseline,'%rcx':width&0xffffffff,'%xmm0':baseline,'%rsp':WRAPPER_STACK};pc=rows[0]['address'];requests=[];trace=[]
|
| 47 |
+
while True:
|
| 48 |
+
t=run(g,pc,list(calls)+list(tails)+list(ends),m,regs);m=t['memory'];regs=t['registers'];trace+=t['trace']
|
| 49 |
+
if t['stop'] in ends:break
|
| 50 |
+
request=[regs[k] for k in ['rdi','rsi']];requests.append(request)
|
| 51 |
+
if request[0]!=MSG:raise ValueError('delta reader pointer')
|
| 52 |
+
word_width=request[1];signed_width=word_width if word_width<2**31 else word_width-2**32
|
| 53 |
+
if supplied is None:
|
| 54 |
+
m,value,error,child=reader(graphs,m,signed_width);trace+=child
|
| 55 |
+
if error:raise ValueError('delta reader fixture error')
|
| 56 |
+
else:value=supplied[len(requests)-1]
|
| 57 |
+
regs['rax']=value
|
| 58 |
+
if t['stop'] in tails:break
|
| 59 |
+
pc=rows[calls[t['stop']]+1]['address']
|
| 60 |
+
if len(requests)>2:raise ValueError('delta reader bound')
|
| 61 |
+
return m,regs['xmm0' if kind=='float' else 'rax']&0xffffffff,requests,trace,omitted
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
def main():
|
| 65 |
+
cp=Path('docs/research/huffman-codebook.json');ip=Path('docs/research/huffman-initialization.json');code=json.loads(cp.read_text());initial=json.loads(ip.read_text())
|
| 66 |
+
out={'native':{},'codebook_report_sha256':hashlib.sha256(cp.read_bytes()).hexdigest(),'initialization_report_sha256':hashlib.sha256(ip.read_bytes()).hexdigest(),'limitations':'Synthetic Linux ELF64 instruction compositions only; original processes/native callees never execute. Compressed tree is MODEL-DERIVED, not complete native training/runtime capture. Save/restore/PUSH/POP omitted; disjoint virtual frames and caller-register restoration explicit. Float writer comparisons are finite only; signed zeros compare equal. Separate supplied-reader flag/return probes do not compose actual bits or cursor effects. Ample zero-initialized buffers, sampled integer widths and pairs only. Integer mask table has 32 symbol-backed words; sampled width32 reads a file-backed adjacent entityStateFields word, not a valid mask entry. No legal-index/overflow/truncation/usercmd/entity/player/snapshot/real-packet/all-platform conformance.'}
|
| 67 |
+
for label in ['linux--Quake3-UrT-Ded.x86_64','linux--Quake3-UrT.x86_64']:
|
| 68 |
+
r=json.loads(Path(f'docs/research/native/{label}.json').read_text());data=verified((Path('.cache/UrbanTerror43')/r['source']['path']).read_bytes(),r['source']['sha256']);meta,symbols=elf(data);a=r['artifacts']['disassembly.txt'];fs=native_functions(verified(gzip.open(a['path'],'rb').read(),a['uncompressed_sha256']).decode());names=['MSG_WriteDeltaKey','MSG_ReadDeltaKey','MSG_WriteDeltaKeyFloat','MSG_ReadDeltaKeyFloat','MSG_WriteBits','MSG_ReadBits','Huff_putBit','Huff_getBit','Huff_offsetTransmit','Huff_offsetReceive','send'];graphs={n:control_flow(fs[n]) for n in names}
|
| 69 |
+
if code['native'][label]['source']!=r['source'] or code['native'][label]['disassembly_sha256']!=a['uncompressed_sha256']:raise ValueError('codebook provenance')
|
| 70 |
+
if initial['native'][label]['source']!=r['source'] or initial['native'][label]['disassembly_sha256']!=a['uncompressed_sha256']:raise ValueError('initialization provenance')
|
| 71 |
+
mask_instruction=next(x for x in graphs['MSG_ReadDeltaKey']['instructions'] if x['opcode']=='andl' and '(,%rax,4)' in x['operands'])
|
| 72 |
+
mask_address=int(re.search(r'(0x[0-9a-f]+)\(',mask_instruction['operands'])[1],16);raw,offset=read_address(data,meta['sections'],mask_address,132)
|
| 73 |
+
mask_symbol=next(x for x in symbols if x['name']=='kbitmask' and x['address']==mask_address);adjacent=next(x for x in symbols if x['name']=='entityStateFields' and x['address']==mask_address+128)
|
| 74 |
+
if mask_symbol['bytes']!=128:raise ValueError('mask symbol size')
|
| 75 |
+
mask_words=list(struct.unpack('<33I',raw));mask_report={'address':mask_address,'file_offset':offset,'symbol':mask_symbol,'table_words':mask_words[:32],'table_sha256':hashlib.sha256(raw[:128]).hexdigest(),'adjacent_word':mask_words[32],'adjacent_symbol':adjacent,'adjacent_bytes_hex':raw[128:].hex()}
|
| 76 |
+
template={mask_address+i:v for i,v in enumerate(raw)};base=initial['native'][label]['entry_request']['huff_init_pointer'];state=code['model_derived_seed_training']['final_state'];install_tree(template,state,base);root=install_tree(template,state,base+0xc830)
|
| 77 |
+
for x in graphs['MSG_ReadBits']['instructions']:
|
| 78 |
+
if x['opcode']=='movq' and '(%rip)' in x['operands']:put_word(template,global_address(x),root,8)
|
| 79 |
+
g=graphs['MSG_WriteBits'];old=global_address(next(x for x in g['instructions'] if x['opcode']=='addl' and '(%rip)' in x['operands']));over=global_address(next(x for x in g['instructions'] if x['opcode']=='addl' and '$0x1,' in x['operands'] and '(%rip)' in x['operands']))
|
| 80 |
+
streams=[]
|
| 81 |
+
fixtures=[('integer',w,b,v,0,key) for w,(b,v),key in itertools.product([1,7,8,9,16,24,31,32],[(0,0),(0,1),(0x1234,0x1234),(0x1234,0xffffffff)],[0,0x80000100,0xffffffff])]+[('float',32,b,v,bit,key) for (b,v),bit,key in itertools.product(FLOAT_PAIRS,[0,7],[0,0x80000100,0xffffffff])]
|
| 82 |
+
for kind,width,baseline,value,bit,key in fixtures:
|
| 83 |
+
m=dict(template)
|
| 84 |
+
for i in range(256):m[DATA+i]=0
|
| 85 |
+
m[DATA-1]=m[DATA+256]=0x7b
|
| 86 |
+
for offset,v in [(4,0),(8,0),(16,DATA),(24,256),(28,bit//8+1),(32,0),(36,bit)]:put_word(m,MSG+offset,v,8 if offset==16 else 4)
|
| 87 |
+
put_word(m,old,0);put_word(m,over,0)
|
| 88 |
+
m,wrequests,trace,womitted=write_delta(graphs,m,kind,baseline,value,width,key);write_bit=get_word(m,MSG+36);size=get_word(m,MSG+28);payload=bytes(m[DATA+i] for i in range(size)).hex();account=get_word(m,old);counter=get_word(m,over)
|
| 89 |
+
put_word(m,MSG+36,bit);put_word(m,MSG+32,0);m,result,rrequests,child,romitted=read_delta(graphs,m,kind,baseline,width,key);trace+=child
|
| 90 |
+
streams.append({'kind':kind,'key_word':key,'width':width,'baseline_word':baseline,'value_word':value,'initial_bit':bit,'write_requests':wrequests,'read_requests':rrequests,'payload_hex':payload,'write_bit':write_bit,'write_size':size,'read_bit':get_word(m,MSG+36),'read_count':get_word(m,MSG+32),'result_word':result,'oldsize_word':account,'range_counter':counter,'overflow_flag':get_word(m,MSG+4),'canaries':[m[DATA-1],m[DATA+256]],'writer_omitted':womitted,'reader_omitted':romitted,**trace_fields({'trace':trace},False)})
|
| 91 |
+
probes=[]
|
| 92 |
+
for kind,flag,key in itertools.product(['integer','float'],[0,1,2,0xffffffff],[0,0x80000100,0xffffffff]):
|
| 93 |
+
baseline=0x1234;payload=0x8196a5ff
|
| 94 |
+
_,result,requests,trace,omitted=read_delta(graphs,template,kind,baseline,13,key,[flag,payload]);probes.append({'kind':kind,'key_word':key,'supplied_flag_word':flag,'baseline_word':baseline,'supplied_payload_word':payload,'width':13,'result_word':result,'requests':requests,'omitted':omitted,**trace_fields({'trace':trace},False)})
|
| 95 |
+
out['native'][label]={'source':r['source'],'disassembly_sha256':a['uncompressed_sha256'],'graphs':graphs,'mask_table':mask_report,'compressed_streams':streams,'supplied_reader_probes':probes}
|
| 96 |
+
write_json(Path('docs/research/message-delta-key.json'),out)
|
| 97 |
+
print('Recovered keyed delta mask/XOR boundaries and modeled-tree streams')
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
if __name__=='__main__':main()
|
scripts/test_message_delta_key.py
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Independent keyed masks/XOR, payload packing and source-boundary oracles."""
|
| 3 |
+
import hashlib
|
| 4 |
+
import json
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
import struct
|
| 7 |
+
import unittest
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def f32(word):return struct.unpack('<f',struct.pack('<I',word))[0]
|
| 11 |
+
def changed(p):return f32(p['baseline_word'])!=f32(p['value_word']) if p['kind']=='float' else p['baseline_word']!=p['value_word']
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
class MessageDeltaKeyTests(unittest.TestCase):
|
| 15 |
+
@classmethod
|
| 16 |
+
def setUpClass(cls):
|
| 17 |
+
cls.r=json.loads(Path('docs/research/message-delta-key.json').read_text());cls.words={x['symbol']:x['bits'] for x in json.loads(Path('docs/research/huffman-codebook.json').read_text())['model_derived_seed_training']['codebook']}
|
| 18 |
+
|
| 19 |
+
def test_symbol_backed_mask_table_and_adjacent_file_word(self):
|
| 20 |
+
for n in self.r['native'].values():
|
| 21 |
+
p=n['mask_table'];expected=[(1<<(i+1))-1 for i in range(32)];self.assertEqual(p['table_words'],expected);self.assertEqual(p['symbol']['bytes'],128);self.assertEqual(p['symbol']['name'],'kbitmask');self.assertEqual(p['symbol']['address'],p['address']);self.assertEqual(p['adjacent_symbol']['name'],'entityStateFields');self.assertEqual(p['adjacent_symbol']['address'],p['address']+128)
|
| 22 |
+
raw=struct.pack('<32I',*expected);self.assertEqual(p['table_sha256'],hashlib.sha256(raw).hexdigest());self.assertEqual(p['adjacent_bytes_hex'],p['adjacent_word'].to_bytes(4,'little').hex())
|
| 23 |
+
data=(Path('.cache/UrbanTerror43')/n['source']['path']).read_bytes();self.assertEqual(data[p['file_offset']:p['file_offset']+132],raw+bytes.fromhex(p['adjacent_bytes_hex']))
|
| 24 |
+
|
| 25 |
+
def test_integer_keyed_requests_compare_before_xor(self):
|
| 26 |
+
for n in self.r['native'].values():
|
| 27 |
+
rows=[p for p in n['compressed_streams'] if p['kind']=='integer'];self.assertEqual(len(rows),96)
|
| 28 |
+
for p in rows:
|
| 29 |
+
c=changed(p);self.assertEqual(p['write_requests'],[[0x90000,int(c),1]]+([[0x90000,p['value_word']^p['key_word'],p['width']]] if c else []));self.assertEqual(p['read_requests'],[[0x90000,1]]+([[0x90000,p['width']]] if c else []))
|
| 30 |
+
|
| 31 |
+
def test_float_full_word_xor_and_signed_zero_baseline(self):
|
| 32 |
+
for n in self.r['native'].values():
|
| 33 |
+
rows=[p for p in n['compressed_streams'] if p['kind']=='float'];self.assertEqual(len(rows),48)
|
| 34 |
+
for p in rows:
|
| 35 |
+
c=changed(p);self.assertEqual(p['write_requests'],[[0x90000,int(c),1]]+([[0x90000,p['value_word']^p['key_word'],32]] if c else []));self.assertEqual(p['result_word'],p['value_word'] if c else p['baseline_word'])
|
| 36 |
+
if {p['baseline_word'],p['value_word']}=={0,0x80000000}:self.assertEqual(len(p['write_requests']),1)
|
| 37 |
+
|
| 38 |
+
def test_independent_flag_raw_remainder_codeword_bytes_and_cursors(self):
|
| 39 |
+
for n in self.r['native'].values():
|
| 40 |
+
self.assertEqual(len(n['compressed_streams']),144)
|
| 41 |
+
for p in n['compressed_streams']:
|
| 42 |
+
c=changed(p);bits=[int(c)]
|
| 43 |
+
if c:
|
| 44 |
+
width=p['width'];rem=width%8;word=(p['value_word']^p['key_word'])&((1<<width)-1);bits += [(word>>i)&1 for i in range(rem)]
|
| 45 |
+
for i in range(width//8):bits+=self.words[(word>>(rem+8*i))&255]
|
| 46 |
+
final=p['initial_bit']+len(bits);payload=bytearray(final//8+1)
|
| 47 |
+
for i,bit in enumerate(bits):pos=p['initial_bit']+i;payload[pos//8]|=bit<<(pos%8)
|
| 48 |
+
self.assertEqual(p['payload_hex'],payload.hex());self.assertEqual(p['write_bit'],final);self.assertEqual(p['read_bit'],final);self.assertEqual(p['write_size'],final//8+1);self.assertEqual(p['read_count'],final//8+1)
|
| 49 |
+
|
| 50 |
+
def test_integer_decoder_direct_index_extra_key_bit_and_adjacent_word(self):
|
| 51 |
+
for n in self.r['native'].values():
|
| 52 |
+
masks=n['mask_table']['table_words']+[n['mask_table']['adjacent_word']]
|
| 53 |
+
for p in n['compressed_streams']:
|
| 54 |
+
if p['kind']!='integer':continue
|
| 55 |
+
expected=p['baseline_word']
|
| 56 |
+
if changed(p):expected=((p['value_word']^p['key_word'])&((1<<p['width'])-1))^(p['key_word']&masks[p['width']])
|
| 57 |
+
self.assertEqual(p['result_word'],expected)
|
| 58 |
+
if changed(p) and p['width']<32:self.assertEqual(p['result_word'],(p['value_word']&((1<<p['width'])-1))|(p['key_word']&(1<<p['width'])))
|
| 59 |
+
|
| 60 |
+
def test_supplied_nonzero_flags_key_effects(self):
|
| 61 |
+
for n in self.r['native'].values():
|
| 62 |
+
self.assertEqual(len(n['supplied_reader_probes']),24)
|
| 63 |
+
for p in n['supplied_reader_probes']:
|
| 64 |
+
c=p['supplied_flag_word']!=0;mask=0xffffffff if p['kind']=='float' else n['mask_table']['table_words'][13];expected=p['supplied_payload_word']^(p['key_word']&mask) if c else p['baseline_word'];self.assertEqual(p['result_word'],expected);width=32 if p['kind']=='float' else 13;self.assertEqual(p['requests'],[[0x90000,1]]+([[0x90000,width]] if c else []))
|
| 65 |
+
|
| 66 |
+
def test_requested_accounting_xored_range_diagnostic_and_dependencies(self):
|
| 67 |
+
for key,name in [('codebook_report_sha256','huffman-codebook.json'),('initialization_report_sha256','huffman-initialization.json')]:self.assertEqual(self.r[key],hashlib.sha256((Path('docs/research')/name).read_bytes()).hexdigest())
|
| 68 |
+
for n in self.r['native'].values():
|
| 69 |
+
for p in n['compressed_streams']:
|
| 70 |
+
word=p['value_word']^p['key_word'];value=word if word<2**31 else word-2**32;overflow=changed(p) and p['width']!=32 and (value<0 or value>(1<<p['width'])-1)
|
| 71 |
+
self.assertEqual(p['range_counter'],int(overflow));self.assertEqual(p['oldsize_word'],1+(p['width'] if changed(p) else 0));self.assertEqual(p['overflow_flag'],0);self.assertEqual(p['canaries'],[0x7b]*2)
|
| 72 |
+
|
| 73 |
+
def test_paired_payloads_and_source_specific_width32_decode(self):
|
| 74 |
+
a,b=self.r['native'].values();self.assertEqual(a['mask_table']['table_words'],b['mask_table']['table_words']);self.assertNotEqual(a['mask_table']['adjacent_word'],b['mask_table']['adjacent_word'])
|
| 75 |
+
def clean(rows):return [{k:v for k,v in p.items() if k not in ['trace','trace_sha256','writer_omitted','reader_omitted','omitted'] and not(k=='result_word' and p['kind']=='integer' and p['width']==32)} for p in rows]
|
| 76 |
+
self.assertEqual(clean(a['compressed_streams']),clean(b['compressed_streams']));self.assertEqual(clean(a['supplied_reader_probes']),clean(b['supplied_reader_probes']))
|
| 77 |
+
differences=[(x,y) for x,y in zip(a['compressed_streams'],b['compressed_streams']) if x['result_word']!=y['result_word']];self.assertTrue(differences)
|
| 78 |
+
for x,y in differences:self.assertEqual(x['kind'],'integer');self.assertEqual(x['width'],32);self.assertEqual(x['payload_hex'],y['payload_hex'])
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
if __name__=='__main__':unittest.main()
|