{"id":26825095,"url":"https://github.com/chancehudson/rust-witness","last_synced_at":"2025-04-28T14:05:48.395Z","repository":{"id":246439809,"uuid":"820791310","full_name":"chancehudson/rust-witness","owner":"chancehudson","description":"Generate circom witnesses natively in Rust","archived":false,"fork":false,"pushed_at":"2025-04-02T01:01:43.000Z","size":311,"stargazers_count":9,"open_issues_count":5,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-28T14:05:43.011Z","etag":null,"topics":["circom","rust","witness","zk"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chancehudson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2024-06-27T07:28:19.000Z","updated_at":"2025-04-02T01:01:46.000Z","dependencies_parsed_at":"2024-06-28T00:47:24.873Z","dependency_job_id":"a9b094aa-10cc-43f7-a10d-8a6fd16db619","html_url":"https://github.com/chancehudson/rust-witness","commit_stats":null,"previous_names":["vimwitch/rust-witness","chancehudson/rust-witness"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chancehudson%2Frust-witness","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chancehudson%2Frust-witness/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chancehudson%2Frust-witness/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chancehudson%2Frust-witness/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chancehudson","download_url":"https://codeload.github.com/chancehudson/rust-witness/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251326836,"owners_count":21571634,"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":["circom","rust","witness","zk"],"created_at":"2025-03-30T10:19:12.086Z","updated_at":"2025-04-28T14:05:48.371Z","avatar_url":"https://github.com/chancehudson.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rust-witness\n\nA crate to natively generate circom witnesses in Rust. This crate transpiles the wasm witness generator to C then provides macros to easily invoke the C functions.\n\n## Usage\n\n1. Add `rust-witness` as a dependency and a build dependency. Add `paste` as a dependency.\n2. Write a `build.rs` that looks like the following:\n```rust\nuse rust_witness::transpile::transpile_wasm;\n\nfn main() {\n    // This function will recursively search the target directory\n    // for any files with the `wasm` extension and compile\n    // them to C and link them\n    transpile_wasm(\"my/path/to/wasm/\");\n}\n```\n3. Compute a witness like the following:\n```rust\nuse rust_witness::witness;\n\n// Use this macro to generate a function that can be\n// used to build a witness for the target circuit\n//\nwitness!(circuitname);\n// The name should be the name of the wasm file all lowercase\n// with all special characters removed\n//\n// e.g. \n// multiplier2 -\u003e multiplier2\n// keccak_256_256_main -\u003e keccak256256main\n// aadhaar-verifier -\u003e aadhaarverifier\n// \n\nfn build_proof() {\n    let inputs: HashMap\u003cString, Vec\u003cBigInt\u003e\u003e;\n    // The generated function will be the name of the circuit\n    // followed by _witness\n    let witness = circuitname_witness(inputs);\n}\n```\n\n\n## Setup\n\nClone the repo then run the following command in the repo directory:\n\n```sh\ncargo test\n```\n\n## Speeding up builds\n\nBy default this package will build `w2c2` from source if the binary is not in your `$PATH`. This can be slow when developing and rebuilding frequently. To install `w2c2` to your cargo bin run the following:\n\n```sh\nsh ./install_w2c2.sh\n```\n\n`transpile_wasm` will automatically use the `w2c2` in your `$PATH` if possible.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchancehudson%2Frust-witness","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchancehudson%2Frust-witness","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchancehudson%2Frust-witness/lists"}