Git Product home page Git Product logo

sat_attack's Introduction

A Poor Person's SAT Attack

This repository contains a basic implementation of the SAT attack described in this paper.

Installation

Python is required to run this SAT attack.

Install all dependencies using the package manager pip.

pip install -r requirements.txt

Usage

python3 sat_attack/run.py <LOCKED-FILE> <UNLOCKED-FILE>

Description

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.

Project Structure

A description of the project structure and what each file contains is below.

  • benchmarks.py: contains helper functions for reading in benchmark files
  • circuit.py: class representing a single circuit
  • circuit_builder.py: helper class to convert from a node tree to a z3 representation of a circuit
  • circuit_solver.py: contains a helper function to solve for circuit outputs given inputs
  • dip_finder.py: class containing the SAT solver to find DIPs
  • node.py: class representing an abstract node in the parsing process
  • oracle_runner: helper class to run DIPs on an oracle
  • parser.py: class to convert a stream of input tokens into a node tree
  • run.py: entry point for the applications
  • sat_attack.py: class that runs the actually SAT attack
  • sat_model.py: contains a helper function to extract python literal values (True, False) from a z3 model
  • token_type.py: enum to aid in the parser creating a node tree
  • tokenizer.py: converts an input file to a stream of tokens, which are easier to deal with than text

Relevant Papers

Future Improvements

  • Add automated tests
  • Add more benchmarks and support features necessary
  • Support multiple Verilog modules because Anti-SAT benchmarks uses them

sat_attack's People

Contributors

lnestor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

sat_attack's Issues

Error in running the sat solver

VirtualBox:~/sat_attack$ python3 sat_attack/run.py /home/vamsi/sat_attack/benchmarks/sample/sample_locked.v /home/vamsi/sat_attack/benchmarks/sample/sample_unlocked.v
Traceback (most recent call last):
File "sat_attack/run.py", line 4, in
import sat_attack
File "/home/vamsi/sat_attack/sat_attack/sat_attack.py", line 1, in
import z3
ModuleNotFoundError: No module named 'z3'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.