Code Monkey home page Code Monkey logo

sage-synth's Introduction

circuit-synthesis

This repo contains three different arithmetic circuit compilers, which are used to compile low multiplicative degree arithmetic circuits for use in 5Gen-C. These tools can also be used to generate circuits for garbled circuits. Anyone who needs to muck about with arithmetic circuits in Haskell might find these tools useful as well.

  • circuit-synthesis: a Haskell DSL for constructing and optimizing arithmetic circuits.
  • scripts/c2v: a shell script that transforms Cryptol into arithmetic circuits using yosys.
  • scripts/c2a: a shell script that transforms Cryptol into arithmetic circuits using abc.

circuit-synthesis

circuit-synthesis is our name for the Haskell DSL in this repo. cxs is the name of it in executable form (see app/Main.hs). It is very good at producing low multiplicative degree circuits. It has optimizers for reducing the degree, and tools for building, translating, composing circuits. The main tool is the Builder monad. See src/Examples for example (-ish, see below) circuits.

Building: build.sh compiles a binary named cxs in the current directory. This requires a recent version of cabal and ghc. cxs is good for getting information about large circuits, producing the circuits from Examples, optimizing existing cirucits, and so on.

c2v and c2a are very similar programs, which have slightly different pipelines. Both generate arithmetic circuits from Cryptol programs. c2v goes through yosys which allows it to tell how expensive different gates are. This is generally useful, since it allows flexibility in what kind of optimization we wish to do.

Dependencies:

Usage: give c2v a Cryptol file, which function to turn into a circuit, and it will print an arithmetic circuit to stdout. For example, to create a circuit for one round of AES:

    % ./scripts/c2v cryptol/AES.cry aes1r > aes1r.c2v.acirc

c2v can use liberty files to produce circuits with minimal numbers of AND gates, which is useful for garbled circuits. See ctv -h for details.

c2a is the cousin of c2v. It is generally worse, but sometimes surprisingly better, which is why we keep it.

Dependencies:

Usage:

    % ./scripts/c2a cryptol/AES.cry aes1r > aes1r.c2a.acirc

Disclaimer

This is research code. I'd love to document it someday (maybe today). So expect mysterious stuff, especially in the examples. They're not really good teaching examples, They are from us trying to get low multiplicative degree PRFs for 5Gen-C.

That said, I'm pretty excited about how useful this library has been for people besides me. If you need help, or have constructive suggestions to improve it, I'd be happy to talk.

License

MIT

sage-synth's People

Contributors

spaceships avatar amaloz avatar dagit avatar dmwit avatar

Watchers

James Cloos avatar

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.