Skip to content

Library to replace expressions by their MBA equivalents in compile-time.

License

Notifications You must be signed in to change notification settings

estr3llas/ocamba

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ocamba

ocamba is a library to replace expressions (+, -, ^, &, |) by their MBA (Mixed-Boolean Arithmetics) equivalents. All of ocamba's work is done in compile time, via PPX.

ocamba's MBAs are Linear, not Polynomial.

Installation

To use ocamba, you must add it as a dependency in your project's dune file and register it as a preprocessor for the relevant executables or libraries.

(executable
 (name main)
  (preprocess (pps ocamba))
)

; Optionally you can see the transformed code after invoking "dune build", use:
; (flags :standard -source)

Usage

Usage is exemplified within this project's main.ml.

The extension's structure follows:

[%mba ({N}, {E})]

Where {N} controls the recursion depth of the transformations, and {E} is the expression to be transformed.

Example

An example of a transformed expression is:

let normal_add = x + y

let obfuscated_add =
  ((((((lnot x) land y) + (x land (lnot y))) + (2 * (x land y))) lor
      ((((lnot x) land y) + (x land (lnot y))) + (2 * (x land y))))
     + ((((lnot x) land y) + (x land (lnot y))) + (2 * (x land y))))
    -
    ((lnot ((((lnot x) land y) + (x land (lnot y))) + (2 * (x land y)))) land
       ((((lnot x) land y) + (x land (lnot y))) + (2 * (x land y))))

About

Library to replace expressions by their MBA equivalents in compile-time.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published