This repository contains a basic implementation of the SAT attack described in this paper.
Python is required to run this SAT attack.
Install all dependencies using the package manager pip.
pip install -r requirements.txt
python3 sat_attack/run.py <LOCKED-FILE> <UNLOCKED-FILE>
A SAT attack is an oracle-guided attack on a logic locked circuit. Two copies of the locked circuit are used, each having different key inputs but the same priamry inputs. A SAT solver is used to determine a primary input such that the outputs of the two circuits will be different. This output is called a distinguishing I/O pair (DIP).
The DIP is then applied to the oracle to figure out what the output should be. This IO pair (DIP and oracle output) is then added as another clause to the SAT solver, ensuring that the output of the circuit given that input and a key MUST be the oracle output. This forces the SAT solver to never consider keys that are known to be incorrect.
The above process is done iteratively until a DIP can no longer be found. Then, a SAT solver is used again with all the DIPs found. Any key which satisfies all DIP/oracle output pairs is in the correct key class.
A description of the project structure and what each file contains is below.
benchmarks.py
: contains helper functions for reading in benchmark filescircuit.py
: class representing a single circuitcircuit_builder.py
: helper class to convert from a node tree to a z3 representation of a circuitcircuit_solver.py
: contains a helper function to solve for circuit outputs given inputsdip_finder.py
: class containing the SAT solver to find DIPsnode.py
: class representing an abstract node in the parsing processoracle_runner
: helper class to run DIPs on an oracleparser.py
: class to convert a stream of input tokens into a node treerun.py
: entry point for the applicationssat_attack.py
: class that runs the actually SAT attacksat_model.py
: contains a helper function to extract python literal values (True, False) from a z3 modeltoken_type.py
: enum to aid in the parser creating a node treetokenizer.py
: converts an input file to a stream of tokens, which are easier to deal with than text
- Evaluating the Security of Logic Encryption Algorithms
- Keynote: A Disquisition on Logic Locking
- Anti-SAT: Mitigating SAT Attack on Logic Locking
- Add automated tests
- Add more benchmarks and support features necessary
- Support multiple Verilog modules because Anti-SAT benchmarks uses them