feature: randomize compressor key-derivation moduli (#69) - #106
Merged
Merged
Conversation
The compressor derives its key stream with state = state * state % m on both the obfuscator (CompressorContext.Encrypt) and the injected runtime (Decrypt), using three fixed moduli (0x143fc089 / 0x444d56fb / 0x8a5cb7) that de4dot/AV pattern-match to fingerprint packed output. Each modulus is now chosen per pack from a curated set and injected into the runtime Decrypt via mutation keys (KeyI1/KeyI2/KeyI3), reusing the verified-injection helper from the feedback/LCG work so a runtime-source change that drops a placeholder fails the build. The round-trip is correct for any modulus (both sides share it), so the curated values are selected purely to preserve key-stream quality: each is prime and congruent to 3 mod 4 (squaring permutes the quadratic residues, so the stream cannot collapse), matches the original's bit-length, and mixes at least as well, validated by simulating the exact generator. The originals were not even prime. scripts/curate_primes.py regenerates the set deterministically (seed 69); ~15 bits of added per-pack identity. Validated by CompressorWithResx.Test (12/12).
This was referenced Sep 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Level 2 constant randomization — Compressor deriver (#69)
Removes the last fixed magic constants from the compressor packer: the three moduli of the key-derivation generator
state = state * state % m, used identically on the obfuscator side (CompressorContext.Encrypt) and in the injected runtimeDecrypt. de4dot/AV pattern-match these to fingerprint packed output.src[i]0x143fc089Mutation.KeyI1dst[i]derivation0x444d56fbMutation.KeyI20x8a5cb7Mutation.KeyI3How sync is preserved
One value per set is chosen per pack, stored on
CompressorContext, used byEncryptfor the main module and every embedded library, and injected into the runtimeDecryptvia the verifiedInjectStubKeyshelper (the mutation-placeholder + presence-check pattern from the feedback/LCG work). A runtime-source change that drops a placeholder throwsConfuserExceptioninstead of silently shipping a stub that can't decrypt. BothCompressorandCompressorCompatruntime variants are handled.Curated set (
scripts/curate_primes.py, seed 69)The round-trip is correct for any modulus (both sides share it), so the curated values are chosen purely to preserve key-stream quality. Each is:
(uint)truncation, same value ranges);ulonggenerator over thousands of random seeds.32 values per set → ~15 bits of added per-pack identity. The script regenerates the baked
CompressorPrimes.csdeterministically and is self-reproducible.Validation
CompressorWithResx.Test— 12/12 pass (compattrue/false× derivernormal/dynamic× resource modes). The test loads adesatellite assembly at runtime, resolved and decrypted through the exactResolve→Decryptpath these moduli drive; a broken constant-sync fails immediately.Remaining on #69 (follow-ups)
12/25/27(Constants) and anti-tamper rotation shifts5/3/7/11— need curated valid-triple/quad sets.0x3dbb2819still hardcoded (Normal/Anti done in feature: randomize anti-tamper feedback + CFG multiplier constants (#69 level 2) #98)..sh).Part of #69.