{"id":24528031,"url":"https://github.com/erhant/arithmetic-circuits","last_synced_at":"2026-02-18T17:31:20.385Z","repository":{"id":270824989,"uuid":"909112232","full_name":"erhant/arithmetic-circuits","owner":"erhant","description":"Moda Palas Blackboard Cryptography II - Arithmetic Circuits \u0026 R1CS","archived":false,"fork":false,"pushed_at":"2025-01-03T22:39:11.000Z","size":375,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-10T17:46:30.530Z","etag":null,"topics":["circuits","cryptography","qap","r1cs","rust"],"latest_commit_sha":null,"homepage":"https://lu.ma/c6wrtj5b","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/erhant.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-12-27T19:00:26.000Z","updated_at":"2025-01-04T18:38:53.000Z","dependencies_parsed_at":"2025-01-03T23:02:24.893Z","dependency_job_id":null,"html_url":"https://github.com/erhant/arithmetic-circuits","commit_stats":null,"previous_names":["erhant/arithmetic-circuits"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/erhant/arithmetic-circuits","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erhant%2Farithmetic-circuits","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erhant%2Farithmetic-circuits/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erhant%2Farithmetic-circuits/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erhant%2Farithmetic-circuits/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erhant","download_url":"https://codeload.github.com/erhant/arithmetic-circuits/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erhant%2Farithmetic-circuits/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29587080,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T16:55:40.614Z","status":"ssl_error","status_checked_at":"2026-02-18T16:55:37.558Z","response_time":162,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["circuits","cryptography","qap","r1cs","rust"],"created_at":"2025-01-22T06:33:39.248Z","updated_at":"2026-02-18T17:31:20.341Z","avatar_url":"https://github.com/erhant.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ModaPalas Blackboard | Cryptography II: Arithmetic Circuits\n\n\u003ca href=\"./.github/workflows/test.yml\" target=\"_blank\"\u003e\n  \u003cimg alt=\"Workflow: Tests\" src=\"https://github.com/erhant/arithmetic-circuits/actions/workflows/tests.yml/badge.svg\"\u003e\n\u003c/a\u003e\n\nThis repository contains the material for the event [ModaPalas Blackboard | Cryptography II](https://lu.ma/c6wrtj5b?tk=dJKwGa) lecture \"Arithmetic Circuits\" by [erhant](https://github.com/erhant).\n\n## Lecture Notes\n\nWe have lecture notes as follows:\n\n1. [Introduction](./docs/1-intro.md)\n2. [Groups](./docs/2-groups.md)\n3. [Usage in Zero Knowledge Cryptography](./docs/3-usage.md)\n4. [Rank-1 Constraint Systems](./docs/4-r1cs.md)\n5. [Quadratic Arithmetic Programs](./docs/5-qap.md)\n6. [Designing Circuits](./docs/6-circuits.md)\n\nIf you have `mdbook` installed with Mermaid preprocessor, you can also open this in a book via:\n\n```sh\nmdbook serve --open\n```\n\n## Implementations\n\nWe also have some pieces of code:\n\n- [R1CS](./src/r1cs.rs): a simple implementation of Rank-1 Constraint System.\n- [QAP](./src/qap.rs): a simple implementation of Quadratic Arithmetic Program, connected to the R1CS implementation.\n- [Circuits](./src/circuits/mod.rs): a \"wire\" implementation and some circuit examples over it.\n\nYou can run some tests and see the results by running:\n\n```sh\ncargo test -- --show-output\n```\n\nWe have an example R1CS \u0026 QAP implementation that you can run, which shows you all the results:\n\n```rs\n// A interpolations:\n        A_0(x) = 51*x^2 + 41*x + 5\n        A_1(x) = x^2 + 93*x + 4\n        A_2(x) = 96*x^2 + 4*x + 94\n        A_3(x) = 49*x^2 + 47*x + 1\n// A evaluations:\n        A_0(1) = 0      A_0(2) = 0      A_0(3) = 5\n        A_1(1) = 1      A_1(2) = 0      A_1(3) = 1\n        A_2(1) = 0      A_2(2) = 1      A_2(3) = 0\n        A_3(1) = 0      A_3(2) = 0      A_3(3) = 1\n\n// B interpolations:\n        B_0(x) = 0\n        B_1(x) = 48*x^2 + 50*x\n        B_2(x) = 0\n        B_3(x) = 0\n// B evaluations:\n        B_0(1) = 0      B_0(2) = 0      B_0(3) = 0\n        B_1(1) = 1      B_1(2) = 1      B_1(3) = 0\n        B_2(1) = 0      B_2(2) = 0      B_2(3) = 0\n        B_3(1) = 0      B_3(2) = 0      B_3(3) = 0\n\n// C interpolations:\n        C_0(x) = 0\n        C_1(x) = 0\n        C_2(x) = 49*x^2 + 46*x + 3\n        C_3(x) = 96*x^2 + 4*x + 94\n// C evaluations:\n        C_0(1) = 0      C_0(2) = 0      C_0(3) = 0\n        C_1(1) = 0      C_1(2) = 0      C_1(3) = 0\n        C_2(1) = 1      C_2(2) = 0      C_2(3) = 0\n        C_3(1) = 0      C_3(2) = 1      C_3(3) = 0\n\n// P(x) built from QAP for a valid instance\nP(x) = 82*x^4 + 81*x^3 + 83*x^2 + 88*x + 54\nP(x) / T(x) = 82*x + 88\n```\n\nWe can also design circuits with the existing gates (see [this example](./tests/circuits_test.rs)) and then print a wire's lavel to see its gates, everything is composed of `+` and `*` only!\n\n```py\n# for equal wires a, b in a field of order 97\na == b is given by (1+(96*((a+(96*b))*0))): 1\n```\n\n## See Also\n\n- [Ying Tong Lai - Modern ZK Cryptography: Lecture 7 (MIT IAP 2023)](https://assets.super.so/9c1ce0ba-bad4-4680-8c65-3a46532bf44a/files/e11309fb-7356-42ad-9c78-565341abd80d.pdf)\n- [0xPARC - R1CS Explainer](https://learn.0xparc.org/materials/circom/additional-learning-resources/r1cs%20explainer/)\n- [Vitalik Buterin - QAP: Zero-to-Hero](https://medium.com/@VitalikButerin/quadratic-arithmetic-programs-from-zero-to-hero-f6d558cea649)\n- [RareSkills - R1CS](https://www.rareskills.io/post/rank-1-constraint-system)\n- [erhant - notes from ZKP MOOC Lecture 3: Programming ZKPs](https://crypto.erhant.me/zklearning/programming-zkps.html)\n- [Risen Crypto - R1CS and QAP](https://risencrypto.github.io/R1CSQAP/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferhant%2Farithmetic-circuits","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferhant%2Farithmetic-circuits","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferhant%2Farithmetic-circuits/lists"}