Papers
Topics
Authors
Recent
Search
2000 character limit reached

Equality Expansion in MBA Obfuscation

Updated 4 July 2026
  • Equality Expansion is a method in MBA obfuscation that leverages algebraic identities to transform simple expressions into syntactically complex, semantically equivalent formulas.
  • It employs an e-graph to manage the exhaustive application of rewrite rules, ensuring multiple equivalent variants coexist without the need for external equivalence checks.
  • Control mechanisms like node-count and time limits are integrated to prevent combinatorial explosion while maximizing MBA alternation and complexity for robust obfuscation.

Equality Expansion denotes, in the Mixed Boolean–Arithmetic (MBA) obfuscation setting, an adaptation of the Equality Saturation technique: rather than saturating an expression with all possible “simplifying” rewrites, it exhaustively applies valid algebraic identities to drive expression size up. In Scrambler, Equality Expansion is the mechanism that takes a simple integer or bit-vector expression and systematically grows an enormous—but semantically identical—MBA formula, with equivalence guaranteed by construction (Lee et al., 4 Mar 2026).

1. Definition and problem setting

In MBA obfuscation, the objective is to replace a “transparent” formula such as f(x,y)=x+yf(x,y)=x+y with an algebraically equivalent, yet syntactically complex, expression involving bitwise operators such as AND, OR, XOR, and NOT together with arithmetic operators such as ++, -, ×\times, and shifts. Equality Expansion begins with an initial expression e0e_0 in an e-graph, together with a set RR of semantically correct rewrite rules of the form LHSRHS\mathrm{LHS} \leftrightarrow \mathrm{RHS}, where the right-hand side is typically more verbose than the left-hand side. At each iteration, patterns matching LHS\mathrm{LHS} are found in the e-graph, and the corresponding RHS\mathrm{RHS} is added into the same equivalence class, thereby enlarging the set of equivalent expressions. The process stops when a user-specified termination condition is met, such as AST-size reaching a threshold, an e-graph node-count limit, or a wall-clock timeout; an alternate expression is then extracted from the same equivalence class, typically one of maximal complexity according to a cost metric (Lee et al., 4 Mar 2026).

This formulation differs from the standard use of Equality Saturation in compiler optimization. The rewrite system is not organized around simplification or canonicalization; it is biased toward expansion. The practical consequence is that the e-graph functions as a repository of semantically interchangeable MBA variants, from which highly complex expressions can be selected without separately proving equivalence after generation.

2. Algebraic identities and expansion rules

The algebraic substrate of Equality Expansion is a trusted set of identities drawn from Boolean algebra, arithmetic, and bitwise–arithmetic mixing. Among the core identities are distributive and dual-distributive laws, De Morgan’s laws, and several standard MBA encodings. Representative formulas include

x(yz)=(xy)(xz),x \land (y \mid z) = (x \land y) \mid (x \land z),

++0

++1

For bitwise–arithmetic mixing, Scrambler uses identities such as

++2

with the side relation

++3

together with

++4

++5

++6

and

++7

Each identity can be used “forward” or “backward,” but the rule-set is explicitly biased toward the expansion direction (Lee et al., 4 Mar 2026).

A concrete rule used for growing an addition node is:

e0e_07

The importance of these rules is not merely that they increase size. They also increase operator heterogeneity, degree, and nesting depth, allowing construction of non-linear MBA expressions that interleave Boolean and arithmetic structure in ways that are difficult to read syntactically while remaining algebraically exact.

3. Realization in an e-graph

Equality Expansion is implemented over an e-graph. In this representation, an e-graph is a forest of e-classes; each e-class is a set of e-nodes; and an e-node is an operator together with pointers to child e-classes. A union-find structure maintains the disjointness of different e-classes and merges them when equal expressions are learned. The main loop initializes an e-graph with the input expression ++8, repeatedly pattern-matches rewrite left-hand sides, constructs the corresponding right-hand sides inside the e-graph, checks a termination condition, and then rebuilds the e-graph to reestablish invariants and hashcons. After expansion, a root e-class contains all variants of ++9, and extraction chooses a “largest” expression according to a cost function, typically by dynamic programming over the e-graph (Lee et al., 4 Mar 2026).

This implementation matters because it separates generation from commitment. Rewrites do not force a single derivation path; instead, many equivalent subexpressions coexist compactly inside the same structure. That property is what makes exhaustive expansion operationally feasible: repeated rule applications accumulate alternatives without discarding earlier forms, and extraction is deferred until the search space has been sufficiently enlarged.

4. Semantic guarantees and equivalence by construction

The central semantic claim of Equality Expansion is that every step preserves semantics by construction. Every rewrite rule in -0 is a proven algebraic identity. When a match -1 is applied, the system does not delete or overwrite the left-hand side; it only adds the right-hand side under the same e-class. Thus every newly introduced e-node is asserted equal to its parent expression, and the union-find invariants guarantee that no contradictory merges occur. Formally, if -2 and -3, then after applying a rewrite with -4 one has -5; by induction, every added expression remains in the same equivalence class (Lee et al., 4 Mar 2026).

A recurrent misconception is that solver-free generation weakens correctness guarantees. The construction used here supports the opposite conclusion. Because rules are drawn from a trusted identity set and because new expressions are inserted only into the same equivalence class as the matched term, there is no need for an external solver such as Z3 to re-verify equivalence. The soundness burden is shifted from post hoc checking to the design of the rewrite system itself.

5. Growth, extraction, and complexity control

Unbridled expansion can blow up space and time, so Equality Expansion is paired with explicit control mechanisms. Scrambler uses a node-count limit, for example stopping once the e-graph reaches -6 nodes; the paper used -7 as default. It also uses a time bound, with -8 set to -9 in experiments, and can impose per-rule depth or “fuel” restrictions to avoid re-applying the same rule ad infinitum in a local region. An optional target AST-size can be set for extraction, for example at least ×\times0 nodes. During extraction, subexpressions whose local cost is below a threshold may be pruned so that the final formula is as “twisted” as possible (Lee et al., 4 Mar 2026).

The extraction objective is itself expansion-aware. The selected cost function rewards depth, number of operators, and related structural indicators of complexity. This means that Equality Expansion is not only a saturation procedure but also a search-and-selection procedure over a very large equivalence class. A plausible implication is that practical effectiveness depends as much on extraction policy as on rewrite coverage: the e-graph can contain many large candidates, but the returned expression is determined by the chosen notion of maximal complexity.

6. Relation to earlier MBA obfuscators

The paper contrasts Scrambler’s Equality Expansion with traditional obfuscators such as MBA-Obfuscator, NeuReduce, and Loki. Those tools are described as relying on manually constructed truth tables or matrix representations, limiting operator sets; supporting only linear or at best low-degree polynomial MBA forms; requiring costly SMT checks to guarantee equivalence; and being constrained to shallow expansions by generation time or combinatorial explosion. Scrambler instead supports arbitrary bitwise and arithmetic operators so long as identities exist, easily generates non-linear, high-degree MBA expressions by repeatedly applying distribution, De Morgan, and related laws, and avoids external solvers entirely because equivalence is baked in (Lee et al., 4 Mar 2026).

The reported quantitative difference is large. Scrambler is said to scale to tens of thousands of AST nodes, with an average AST size of approximately ×\times1 versus approximately ×\times2 for MBA-Obfuscator. Qualitatively, the generated expressions are reported to achieve far higher MBA alternation and Shannon entropy while still guaranteeing correctness. These comparisons identify Equality Expansion not simply as an implementation detail, but as the mechanism enabling both the growth regime and the proof discipline of the tool.

7. Canonical running example

A standard illustration starts from

×\times3

First, apply the OR/AND identity: ×\times4 Next, expand OR using

×\times5

so that

×\times6

Then replace Boolean negation by arithmetic negation: ×\times7 yielding Boolean subterms such as

×\times8

Finally, optional doubling rewrites such as ×\times9 can be applied. One possible resulting MBA expression is

e0e_00

The procedure can continue by distributing AND over OR or vice versa, re-encoding OR in terms of e0e_01 and e0e_02, and nesting De Morgan expansions. After four rewrite steps, the expression grows from e0e_03 AST nodes to over e0e_04; Scrambler would then continue matching any of its e0e_05 expansion rules until it reaches a node limit such as e0e_06 or times out (Lee et al., 4 Mar 2026).

This example captures the general character of Equality Expansion. The method does not search for a single clever identity. It accumulates a dense space of algebraically exact variants and then extracts one whose syntactic form is substantially more complex than the source while remaining semantically interchangeable with it.

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Equality Expansion.