{"id":23225935,"url":"https://github.com/arkworks-rs/r1cs-tutorial","last_synced_at":"2025-08-19T13:32:07.869Z","repository":{"id":40363206,"uuid":"360261790","full_name":"arkworks-rs/r1cs-tutorial","owner":"arkworks-rs","description":"Tutorial for writing constraints in the `arkworks` framework","archived":false,"fork":false,"pushed_at":"2024-06-21T16:06:02.000Z","size":116,"stargazers_count":245,"open_issues_count":5,"forks_count":89,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-08-12T07:07:05.035Z","etag":null,"topics":["cryptography","r1cs","rollup","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arkworks-rs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null}},"created_at":"2021-04-21T18:02:47.000Z","updated_at":"2025-08-01T11:49:25.000Z","dependencies_parsed_at":"2022-08-09T18:12:04.736Z","dependency_job_id":null,"html_url":"https://github.com/arkworks-rs/r1cs-tutorial","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"arkworks-rs/template","purl":"pkg:github/arkworks-rs/r1cs-tutorial","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arkworks-rs%2Fr1cs-tutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arkworks-rs%2Fr1cs-tutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arkworks-rs%2Fr1cs-tutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arkworks-rs%2Fr1cs-tutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arkworks-rs","download_url":"https://codeload.github.com/arkworks-rs/r1cs-tutorial/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arkworks-rs%2Fr1cs-tutorial/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271161606,"owners_count":24709735,"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","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","r1cs","rollup","rust"],"created_at":"2024-12-19T00:02:23.269Z","updated_at":"2025-08-19T13:32:07.537Z","avatar_url":"https://github.com/arkworks-rs.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eIntroduction to SNARK Development with `arkworks`\u003c/h1\u003e\n\nIn this tutorial, we will learn how to write applications for use with state-of-the-art zkSNARKs using the [`arkworks`](https://arkworks.rs) ecosystem of SNARK libraries.\n\n## Prerequisites\n\nBecause the `arkworks` ecosystem uses the Rust programming language, this tutorial assumes some familiarity with the basics of Rust. We also assume basic familiarity with zkSNARK concepts, and in particular with the following terminology:\n\n* Public input/instance: a publicly known object that the verifier can check a zkSNARK proof against. For example, in a proof of membership in a Merkle tree, the Merkle tree root would be a public input.\n* Private input/witness: an object that is known only to the prover, for either efficiency or privacy reasons. In the Merkle tree example, the Merkle tree authentication path would be a private input.\n* Circuit: an encoding of a computation in a way that can be proven using a zkSNARK.\n* Gadget: subcircuits corresponding to useful computations that can be used to build up the full circuit. In the Merkle tree example, a hash function gadget would be used repeatedly.\n\n## Instructions\n\n1. Ensure that you have the latest version of Rust installed (1.51 at the time of writing).  If you do not already have Rust installed, you can do so via [`rustup`](https://rustup.rs/). Linux users, please note that `arkworks` relies on Rust 1.51, which might be more recent than the Rust version provided by your distribution's package repositories; hence, even if you have installed Rust via your package manager, please install the latest Rust via `rustup`.\n\n2. Clone this repository via `git clone https://github.com/arkworks-rs/r1cs-tutorial.git`\n\n3. (Optional) While Rust works out of the box with your text editor of choice, using [Visual Studio Code](https://code.visualstudio.com/) along with the [`rust-analyzer`](https://marketplace.visualstudio.com/items?itemName=matklad.rust-analyzer) plugin makes Rust development easier.  \n\n4. (Optional) Join the Telegram channel for [this tutorial](https://t.me/joinchat/4HzYWAYHVfpiODZh) and for the [`arkworks` ecosystem](https://t.me/joinchat/QaIYxIqLScnonTJ4) to ask questions interactively.\n\n5. Proceed to the exercises below.\n\n## Exercises\n\nIn this tutorial, we will construct a SNARK-based rollup for a simple payments system. In the course of doing so, you will learn how to use `arkworks` libraries for writing constraint systems, how to debug these circuits for both correctness and performance, and finally how to plug these circuits into zkSNARKs.\n\nFirst, checkout the `main` branch in the repository.\n\n### Exercise 1: Merkle Tree Example\n\nWe'll design a simple circuit for checking a Merkle tree membership path for a given leaf.\nOpen [`merkle-tree-example/README.md`](./merkle-tree-example/README.md).\n\n### Exercise 2: Validating a single transaction\n\nWe'll design a circuit for validating a single transaction in a simple account-based payment system.\nOpen [`simple-payments/README.md`](./simple-payments/README.md) to first learn more about the payment system, and then open [`rollup/README.md`](./rollup/README.md) for the instructions for this exercise.\n\n### Exercise 3: Writing a rollup circuit\n\nWe'll design a circuit for a rollup for batch verification of transactions in the foregoing payment system.\nOpen [`rollup/README.md`](./rollup/README.md) for the instructions for this exercise.\n\n## Solutions\n\nIf you get stuck on one of the above exercises, or if you wish to compare your solution with ours, check out the [`solutions`](https://github.com/arkworks-rs/r1cs-tutorial/tree/solutions) branch on this repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farkworks-rs%2Fr1cs-tutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farkworks-rs%2Fr1cs-tutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farkworks-rs%2Fr1cs-tutorial/lists"}