Skip to main content

Crate rumba_core

Crate rumba_core 

Source
Expand description

Simplification of Mixed Boolean-Arithmetic (MBA) expressions.

MBA expressions interleave bitwise operators (&, |, ^, ~) with arithmetic ones (+, -, *) to obscure an otherwise simple value. They are a common code-obfuscation primitive; rumba-core recovers the underlying expression.

§Overview

Simplification is best-effort: it returns a simplify::SolveError or leaves the input untouched rather than aborting the process.

§Example

use rumba_core::expr::{Expr, VarId};
use rumba_core::simplify::simplify_mba;

let x = Expr::Var(VarId(0));
let y = Expr::Var(VarId(1));

// (x ^ y) + 2*(x & y) is an MBA encoding of x + y.
let mba = (x.clone() ^ y.clone()) + 2u64 * (x.clone() & y.clone());

let simplified = simplify_mba(mba, 64).expect("simplification failed");

// The result is semantically equal to x + y.
assert!(simplified.sem_equal(&(x + y), 64, 1000).is_ok());

§Features

  • parse — string parsing of expressions via [parser].
  • jit — JIT-compiled evaluation for faster semantic checks.

The solver’s contract is best-effort: it must degrade to a SolveError (or leave the input alone) rather than abort the process. Forbid silent unwrap() and panic! in library code so every fallible spot is either handled or an explicit, message-carrying expect(). Tests may still unwrap freely.

Modules§

expr
The expr::Expr expression tree and its building blocks.
lang
A lower-level typed representation of MBA expressions used during solving.
simplify
MBA simplification entry points.