wi11dey / Gates.jl

A fast circuit compiler that can seamlessly integrate with existing Julia code and can incrementally build up expressions and regenerate optimized circuits after substitutions and manipulations using standard Julia functions.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gates.jl

A fast circuit compiler that can seamlessly integrate with existing Julia code and can incrementally build up logic gate expressions and regenerate optimized circuits after substitutions and manipulations using standard Julia functions. A number of common logical transformations are also supported. To test, see SHA256.jl for SHA-2 implementation which can be compiled to a circuit and functionally encrypted or transformed to conjunctive normal form for obfuscation for simplification.

Additionally, interoperable with circuits in the widely-used Bristol format (see bristol.jl).

Transformations supported

  • Tseytin transformation to Conjunctive Normal Form
  • Intra-clause variable de-duplication
  • Dead variable removal
  • Circuit randomization

Example

using Gates
using CNFs

import SHA256: sha256

a = SymbolicInteger{64}(:a)
circuit = sha256([a])

@show cnfs = CNF.(circuit.bits)

@show simplify!.(cnfs)

@show substitue(circuit, a=0x010101)

About

A fast circuit compiler that can seamlessly integrate with existing Julia code and can incrementally build up expressions and regenerate optimized circuits after substitutions and manipulations using standard Julia functions.


Languages

Language:Julia 100.0%