{"id":13511344,"url":"https://github.com/adria0/za","last_synced_at":"2025-03-30T20:33:01.390Z","repository":{"id":50791573,"uuid":"232611919","full_name":"adria0/za","owner":"adria0","description":"An experimental rust zksnarks compiler with embeeded bellman-bn128 prover","archived":true,"fork":false,"pushed_at":"2021-05-29T09:15:38.000Z","size":20001,"stargazers_count":42,"open_issues_count":7,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-01T13:34:40.592Z","etag":null,"topics":["cryptography","ethereum","learning-by-doing","rust","smartcontract","zk-snarks"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adria0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-08T16:53:12.000Z","updated_at":"2024-09-24T16:14:41.000Z","dependencies_parsed_at":"2022-08-30T08:31:03.761Z","dependency_job_id":null,"html_url":"https://github.com/adria0/za","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adria0%2Fza","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adria0%2Fza/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adria0%2Fza/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adria0%2Fza/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adria0","download_url":"https://codeload.github.com/adria0/za/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246379366,"owners_count":20767694,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cryptography","ethereum","learning-by-doing","rust","smartcontract","zk-snarks"],"created_at":"2024-08-01T03:00:47.887Z","updated_at":"2025-03-30T20:33:00.531Z","avatar_url":"https://github.com/adria0.png","language":"Rust","funding_links":[],"categories":["Cryptography"],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eZa!\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/adria0/za/actions?query=workflow%3ARust\"\u003e\u003cimg src=\"https://github.com/adria0/za/workflows/Rust/badge.svg\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/adria0/za/actions?query=workflow%3AClippy\"\u003e\u003cimg src=\"https://github.com/adria0/za/workflows/Clippy/badge.svg\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/adria0/za/actions?query=workflow%3ARustfmt\"\u003e\u003cimg src=\"https://github.com/adria0/za/workflows/Rustfmt/badge.svg\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/adria0/za/actions?query=workflow%3AAudit\"\u003e\u003cimg src=\"https://github.com/adria0/za/workflows/Audit/badge.svg\"\u003e\u003c/a\u003e\n    \u003cimg src=\"https://img.shields.io/badge/License-LGPLv2.1-blue.svg\"\u003e\n\u003c/p\u003e\n\nAn 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.\n\n**WARNING**: This is a proof-of-concept prototype, and in particular has not received careful code review.\n\n[circom]: https://github.com/iden3/circom\n\n### Building \n\nInstall rust\n\n`curl https://sh.rustup.rs -sSf | sh`\n\nInstall additional dependencies, you may need to install the `clang` `build-essentials` and `openssl-dev`\n\nClone the repo\n\n`git clone https://github.com/adria0/za.git`\n\nBuild\n\n`cargo build --release`\n\nThe final binary will be in `target/release/za`\n\n### Usage\n\n#### Generating trusted setup\n\n`za setup --circuit \u003ccircut.za\u003e --pk \u003cproving.key\u003e --verifier \u003cverifier.sol\u003e --verifiertype \u003csolidity|json\u003e`\n\n- `circuit.za` is an input file with the `main` component that specifies the circuit\n- `proving.key` is a generated output with the key required to generate proofs\n- `verifier.sol` is a generated output with the smartcontract to verify the generated proofs\n\n_if you want to do a test, create a file with name `circuit.za` with the following contents and run the `za setup`_\n\n```\ntemplate T() {\n    signal private input p;\n    signal private input q;\n    signal output r;\n\n    r \u003c== p*q;\n}\ncomponent main = T();\n```\n\n#### Generating a proof\n\n`za prove --input \u003cinput.json\u003e --pk \u003cproving.key\u003e --proof \u003cproof.json\u003e`\n\n- `input.json` is an input file with the required input signals to generate the full witness\n- `proving.key` is an input file with the key required to generate proofs\n- `proof.json` is the input required by the smartcontract to verify the proof\n\n_if you want to do a test, create a file with name `input.json` with the following contents and run the `za prove`_\n\n```\n{ \"p\" : \"2\", \"q\": \"3\" , \"r\" : \"6\"}\n```\n\n_then deploy the `verifier.sol` smartcontract and exec the `verifyTx` method with the contents of the `proof.json`_\n\n\n#### Testing a circuit\n\nIn 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:\n\n- `za test --circuit \u003ccircuit.za\u003e`\n\nthis will run the tests found in the circuit and all the tests found in the included templates\n\n### Golang verification\n\nyou can verify the za! generated proofs generated with za! with the https://github.com/arnaucube/go-bellman-verifier tool (thanks @arnaucube)\n\n### JavaScript bindings\n\nto compile the JavaScript bindings, go to the `binding/js` folder and run:\n\n- `npm i`\n- `npm run install`\n- `npm test`\n\ncheck the test located in `binding/js/test/test.js`\n\n### Differences with circom\n\nThere are few differences between this implementation and the official circom:\n\n- Precedence of operators rust-like instead C-like:\n  - `DECNUMBER`, `HEXNUMBER`, `\"(\" exp \")\"`\n  - Unary `-` `!`\n  - `**`      \n  - `*` `/` `\\\\` `%`\n  - `+` `-`     \n  - `\u003c\u003c` `\u003e\u003e`  \n  - `\u0026` \n  - `^` \n  - `|` \n  - `==` `!=` `\u003c` `\u003e` `\u003c=` `\u003e=`\n  - `\u0026\u0026`\n  - `||`\n- Removed `++`, `--` and `:?`\n- Matrix access is only accessible with `[x][y]` (not with `[x,y]`) \n- End statement semicolons are mandatory\n- Loops/conditionals statements must be inside blocks `{ }`\n- Added `dbg!` function to trace variables, signals and components\n- Do now allow to use component `signal output`s until all `signal input` are set  \n- Signal input/outputs arrays should be evaluable with template parameters\n- Stamements tagged with `#[w]` are only evaluated in witness generation\n- `#[test]` tagged templates are used to verify embeeded tests\n- `#[]` expressions can be comment-scapped by using `/*#[]#*/` to be compatible with circom circuits. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadria0%2Fza","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadria0%2Fza","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadria0%2Fza/lists"}