All Projects → adria0 → za

adria0 / za

Licence: LGPL-2.1 license
An experimental rust zksnarks compiler with embeeded bellman-bn128 prover

Programming Languages

rust
11053 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to za

cloudwithchris.com
Cloud With Chris is my personal blogging, podcasting and vlogging platform where I talk about all things cloud. I also invite guests to talk about their experiences with the cloud and hear about lessons learned along their journey.
Stars: ✭ 23 (-41.03%)
Mutual labels:  learning-by-doing
powersoftau
Communal zk-SNARK MPC for Public Parameters
Stars: ✭ 16 (-58.97%)
Mutual labels:  zk-snarks
todo-cli
Minimal TODOs inside your terminal. Learning project for Rust.
Stars: ✭ 36 (-7.69%)
Mutual labels:  learning-by-doing
shortest-tutorial-ever
A list of the shortest tutorials ever.
Stars: ✭ 14 (-64.1%)
Mutual labels:  learning-by-doing
baseline
The Baseline Protocol is an open source initiative that combines advances in cryptography, messaging, and distributed ledger technology to enable confidential and complex coordination between enterprises while keeping data in systems of record. This repo serves as the main repo for the Baseline Protocol, containing core packages, examples, and r…
Stars: ✭ 565 (+1348.72%)
Mutual labels:  zk-snarks
Ruby Regexp
Learn Ruby Regexp step by step from beginner to advanced levels with plenty of examples and exercises
Stars: ✭ 79 (+102.56%)
Mutual labels:  learning-by-doing
workshops
workshops, study guides and learning materials for the Uno Platform
Stars: ✭ 86 (+120.51%)
Mutual labels:  learning-by-doing
ArvernOS
💾 A minimal, experimental and "toy" monolithic kernel to learn about OS development // Work In Progress
Stars: ✭ 313 (+702.56%)
Mutual labels:  learning-by-doing
r1cs
A Rust library for building R1CS gadgets
Stars: ✭ 75 (+92.31%)
Mutual labels:  zk-snarks
tutorials
Ably Tutorials in multiple languages
Stars: ✭ 35 (-10.26%)
Mutual labels:  learning-by-doing
awesome-by-example
😎 A curated list of example-based learning resources.
Stars: ✭ 97 (+148.72%)
Mutual labels:  learning-by-doing
go-examples
Collection of Go examples for beginner back end developers
Stars: ✭ 44 (+12.82%)
Mutual labels:  learning-by-doing
snak
Snak is a Hyperledger Burrow’s tools, which provides some facilities to compile, deploy and test smart contracts and send transactions to the Burrow. With Snack you can easily install and uninstall Burrow (currently only for Darwin and Ubuntu 16.04 amd64) and easily launch a Burrow test network.(Updated for Hyperledger Burrow v0.18.0)
Stars: ✭ 14 (-64.1%)
Mutual labels:  smartcontract
Coding-Ninjas-Full-Stack-Web-Development
It contains all the files I created during the MERN full stack web development course with coding ninjas
Stars: ✭ 108 (+176.92%)
Mutual labels:  learning-by-doing
TeachMePythonLikeIm5
Teach the Python programming language using a collection of super beginner friendly tutorials and challenges.
Stars: ✭ 23 (-41.03%)
Mutual labels:  learning-by-doing
tutorials
All of the code for my Medium articles
Stars: ✭ 130 (+233.33%)
Mutual labels:  learning-by-doing
ethsnarks
A toolkit for viable zk-SNARKS on Ethereum, Web, Mobile and Desktop
Stars: ✭ 224 (+474.36%)
Mutual labels:  zk-snarks
research
Shared learning of decentralized development.
Stars: ✭ 26 (-33.33%)
Mutual labels:  zk-snarks
how-to-build-your-own-uber-for-x-app
Code for my blog post on How to Build Your Own Uber-for-X App
Stars: ✭ 138 (+253.85%)
Mutual labels:  learning-by-doing
Zero-to-Hero-in-NLP
This repository contains A-Z techniques of Natural Language Processing to get started in NLP.
Stars: ✭ 60 (+53.85%)
Mutual labels:  learning-by-doing

Za!

An experimental port of the circom zk-SNARK compiler in Rust with embedded bellman-bn128 prover. I created it as a PoC port of the existing JavaScript compiler to Rust when I was working for iden3.

WARNING: This is a proof-of-concept prototype, and in particular has not received careful code review.

Building

Install rust

curl https://sh.rustup.rs -sSf | sh

Install additional dependencies, you may need to install the clang build-essentials and openssl-dev

Clone the repo

git clone https://github.com/adria0/za.git

Build

cargo build --release

The final binary will be in target/release/za

Usage

Generating trusted setup

za setup --circuit <circut.za> --pk <proving.key> --verifier <verifier.sol> --verifiertype <solidity|json>

  • circuit.za is an input file with the main component that specifies the circuit
  • proving.key is a generated output with the key required to generate proofs
  • verifier.sol is a generated output with the smartcontract to verify the generated proofs

if you want to do a test, create a file with name circuit.za with the following contents and run the za setup

template T() {
    signal private input p;
    signal private input q;
    signal output r;

    r <== p*q;
}
component main = T();

Generating a proof

za prove --input <input.json> --pk <proving.key> --proof <proof.json>

  • input.json is an input file with the required input signals to generate the full witness
  • proving.key is an input file with the key required to generate proofs
  • proof.json is the input required by the smartcontract to verify the proof

if you want to do a test, create a file with name input.json with the following contents and run the za prove

{ "p" : "2", "q": "3" , "r" : "6"}

then deploy the verifier.sol smartcontract and exec the verifyTx method with the contents of the proof.json

Testing a circuit

In order to test if a circuit is correct is possible to write an embedded test by using the #[test] tag before a template definition (see interop/circomlib/babyjub.circom), to execute the test, run:

  • za test --circuit <circuit.za>

this will run the tests found in the circuit and all the tests found in the included templates

Golang verification

you can verify the za! generated proofs generated with za! with the https://github.com/arnaucube/go-bellman-verifier tool (thanks @arnaucube)

JavaScript bindings

to compile the JavaScript bindings, go to the binding/js folder and run:

  • npm i
  • npm run install
  • npm test

check the test located in binding/js/test/test.js

Differences with circom

There are few differences between this implementation and the official circom:

  • Precedence of operators rust-like instead C-like:
    • DECNUMBER, HEXNUMBER, "(" exp ")"
    • Unary - !
    • **
    • * / \\ %
    • + -
    • << >>
    • &
    • ^
    • |
    • == != < > <= >=
    • &&
    • ||
  • Removed ++, -- and :?
  • Matrix access is only accessible with [x][y] (not with [x,y])
  • End statement semicolons are mandatory
  • Loops/conditionals statements must be inside blocks { }
  • Added dbg! function to trace variables, signals and components
  • Do now allow to use component signal outputs until all signal input are set
  • Signal input/outputs arrays should be evaluable with template parameters
  • Stamements tagged with #[w] are only evaluated in witness generation
  • #[test] tagged templates are used to verify embeeded tests
  • #[] expressions can be comment-scapped by using /*#[]#*/ to be compatible with circom circuits.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].