Coder Social home page Coder Social logo

ognjenkurtic / maci Goto Github PK

View Code? Open in Web Editor NEW

This project forked from 0x3327/maci

0.0 1.0 0.0 37.82 MB

Minimal anti collusion infrastructure

Home Page: https://privacy-scaling-explorations.github.io/maci/

License: Other

Shell 11.62% JavaScript 3.89% TypeScript 66.51% Dockerfile 0.23% Solidity 17.75%

maci's Introduction

Minimal Anti-Collusion Infrastructure

CI License Telegram

Please refer to the original ethresear.ch post for a high-level view.

Documentation for developers and integrators can be found here: https://privacy-scaling-explorations.github.io/maci/

We welcome contributions to this project. Please join our Telegram group to discuss.

Packages

Below you can find a list of the packages included in this repository.

package npm tests
maci-circuits NPM Package Actions Status
maci-cli NPM Package Actions Status
maci-common NPM Package Actions Status
maci-contracts NPM Package Actions Status
maci-core NPM Package Actions Status
maci-crypto NPM Package Actions Status
maci-domainobjs NPM Package Actions Status
maci-integrationTests NPM Package Actions Status
maci-server NPM Package Actions Status

Local Development and testing

Requirements

You should have Node 16 (or 14) installed. Use nvm to install it and manage versions.

You also need a Ubuntu/Debian Linux machine on an Intel CPU.

Get started

Install dependencies: sudo apt-get install build-essential libgmp-dev libssl-dev libsodium-dev git nlohmann-json3-dev nasm g++ libgcc-s1

If you are missing the correct version of glibc see circuits/scripts/installGlibc.sh

Clone this repository, install NodeJS dependencies, and build the source code:

git clone [email protected]:privacy-scaling-explorations/maci.git
cd maci
npm install
npm run bootstrap
npm run build

For development purposes, you can generate the proving and verifying keys for the zk-SNARK circuits, along with their Solidity verifier contracts as such.

Navigate to the rapidsnark repo to install the necessary tooling.

Build the zk-SNARKs and generate their proving and verifying keys:

cd circuits
npm run build-test-circuits

This can take around 10 to 15 minutes, depending on the specs of your machine. Once ready, the following will appear on screen: Launched JSON-RPC server at port 9001

Note that if you change the circuits and recompile them, you should also update and recompile the verifier contracts in contracts/contracts with their new versions, or the tests will fail:

cd contracts
npm run compileSol

Avoid using npx hardhat compile and instead use the provided command as artifacts are copied into their relevant directories.

Local development

This repository is organised as Lerna submodules. Each submodule contains its own unit tests.

  • audit: Documentation surrounding the audit performed on v1
  • crypto: low-level cryptographic operations.
  • circuits: zk-SNARK circuits.
  • contracts: Solidity contracts and deployment code.
  • domainobjs: Classes which represent high-level domain objects particular to this project.
  • core: Business logic functions for message processing, vote tallying, and circuit input generation through MaciState, a state machine abstraction.
  • cli: A command-line interface with which one can deploy and interact with an instance of MACI.
  • integrationTests: Integration tests which use the command-line interface to perform end-to-end tests.

Compiling Circom

Prior to using the generated zkey files for corresponding circuits, it is now required to compile circom locally. To get started the follow the instructions here and be sure that the installation directory matches the value in the circom field inside circuits/circomHelperConfig.json.

For example:

{
    "circom": "../$RELATIVE_PATH_TO_CIRCOM"
}

Testing

Unit tests

The following submodules contain unit tests: core, crypto, circuits, contracts, and domainobjs.

Except for the contracts submodule, run unit tests as such (the following example is for crypto):

cd crypto
npm run test

For contracts and integrationTests, run the tests one by one. This prevents incorrect nonce errors.

First, start a Hardhat instance in a separate terminal:

cd contracts
npm run hardhat

In another terminal you can run:

cd contracts
npm run test

Or run tests individual as such:

cd contracts
npm run test-accQueue
npx jest AccQueue

Where both test commands run AccQueue.test.ts

Alternatively you can run all unit tests as follows, but you should stop your Hardhat instance first as this will start its own instance before running the tests:

cd contracts
./scripts/runTestsInCi.sh

Or run all integration tests (this also starts its own Hardhat instance):

cd integrationTests
./scripts/runTestsInCi.sh

You can ignore the Hardhat errors which this script emits as you should already have Hardhat running in a separate terminal. Otherwise, you will have to exit Ganache using the kill command.

Docker

Run docker build -t maci . to build all stages.

To run a specific build step docker build --target circuits -t maci . Note: a cached version of builder job must be on your system prior as it relies on existing artifacts

CI pipeline

CI pipeline ensures that we have automated tests that constantly validate. For more information about pipeline workflows, see https://github.com/privacy-scaling-explorations/maci/wiki/MACI-CI-pipeline.

maci's People

Contributors

amit0617 avatar aspiers avatar barrywhitehat avatar baumstern avatar brendanww avatar chaosma avatar chihchengliang avatar corydickson avatar ctrlc03 avatar daodesigner avatar dependabot[bot] avatar dvlprsh avatar exfinen avatar galrogozinski avatar hmrtn avatar johnson86tw avatar kendricktan avatar kobigurk avatar ksaitor avatar luker501 avatar maxgrok avatar mhchia avatar pettinarip avatar shakeib98 avatar shawnharmsen avatar weijiekoh avatar xuhcc 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.