Coder Social home page Coder Social logo

rust-arith-circuit's Introduction

Rust Arithmetic Circuit Compiler

This project is an arithmetic circuit compiler written in Rust, for educational purposes only. It parses arithmetic expressions, builds a corresponding circuit, evaluates the circuit with given inputs, and generates Solidity smart contract code to verify the circuit.

Features

  • Parse arithmetic expressions.
  • Build arithmetic circuits from parsed expressions.
  • Evaluate circuits with given input values.
  • Generate Solidity smart contract code for circuit verification.

Dependencies

  • nom for parsing arithmetic expressions.

Getting Started

Prerequisites

  • Rust programming language and Cargo.

Installing

Clone the repository:

git clone https://github.com/luishsr/rust-arith-circuit.git
cd rust-arith-circuit

Building

To build the project, run:

cargo build

Running

To run the project, use:

cargo run

This will parse the expression x + y, evaluate it with x = 2 and y = 5, and generate the corresponding Solidity smart contract.

Example Output The expected output should be:

Result: 7

pragma solidity ^0.8.0;

contract ArithmeticCircuit {
    function verify(int256[] memory x, int256[] memory y) public pure returns (int256) {
        return x[0] + y[1];
    }
}

Project Structure

src/main.rs: Entry point of the application. src/circuit.rs: Contains the definition of the arithmetic circuit, parsing logic, evaluation, and Solidity code generation.

Usage

Modify the expression in main.rs to your desired arithmetic expression. Run the project to see the evaluated result and generated Solidity code.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.

License

This project is licensed under the MIT License - see the LICENSE file for details.

rust-arith-circuit's People

Contributors

luishsr avatar

Watchers

 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.