{"id":13531749,"url":"https://github.com/filecoin-project/bellperson","last_synced_at":"2025-04-01T20:30:30.553Z","repository":{"id":37856346,"uuid":"176679636","full_name":"filecoin-project/bellperson","owner":"filecoin-project","description":"zk-SNARK library","archived":false,"fork":true,"pushed_at":"2023-12-15T14:59:22.000Z","size":4785,"stargazers_count":179,"open_issues_count":7,"forks_count":114,"subscribers_count":21,"default_branch":"master","last_synced_at":"2024-05-21T13:54:12.420Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"zkcrypto/bellman","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/filecoin-project.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null}},"created_at":"2019-03-20T07:36:18.000Z","updated_at":"2024-05-20T12:51:02.000Z","dependencies_parsed_at":"2023-02-10T16:31:30.740Z","dependency_job_id":null,"html_url":"https://github.com/filecoin-project/bellperson","commit_stats":null,"previous_names":["filecoin-project/bellman"],"tags_count":66,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filecoin-project%2Fbellperson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filecoin-project%2Fbellperson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filecoin-project%2Fbellperson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filecoin-project%2Fbellperson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/filecoin-project","download_url":"https://codeload.github.com/filecoin-project/bellperson/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246709921,"owners_count":20821296,"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":[],"created_at":"2024-08-01T07:01:05.326Z","updated_at":"2025-04-01T20:30:30.540Z","avatar_url":"https://github.com/filecoin-project.png","language":"Rust","funding_links":[],"categories":["Cryptography","Applications"],"sub_categories":["Zero Knowledge Proofs","Forums"],"readme":"# bellperson [![Crates.io](https://img.shields.io/crates/v/bellperson.svg)](https://crates.io/crates/bellperson)\n\n\u003e This is a fork of the great [bellman](https://github.com/zkcrypto/bellman) library.\n\n`bellman` is a crate for building zk-SNARK circuits. It provides circuit traits\nand primitive structures, as well as basic gadget implementations such as\nbooleans and number abstractions.\n\n## Backend\n\nThere is currently one backend available for the implementation of Bls12 381:\n- [`blstrs`](https://github.com/filecoin-project/blstrs) - optimized with hand tuned assembly, using [blst](https://github.com/supranational/blst)\n\n## GPU\n\nThis fork contains GPU parallel acceleration to the FFT and Multiexponentation algorithms in the groth16 prover codebase under the compilation features `cuda` and `opencl`.\n\n### Requirements\n- NVIDIA (Turing or newer) or \n- AMD GPU Graphics Driver (OpenCL)\n\n( For AMD devices we recommend [ROCm](https://www.amd.com/en/products/software/rocm.html) )\n\n### Environment variables\n\nThe gpu extension contains some env vars that may be set externally to this library.\n\n- `BELLMAN_NO_GPU`\n\n    Will disable the GPU feature from the library and force usage of the CPU.\n\n    ```rust\n    // Example\n    env::set_var(\"BELLMAN_NO_GPU\", \"1\");\n    ```\n\n- `BELLMAN_VERIFIER`\n\n    Chooses the device in which the batched verifier is going to run. Can be `cpu`, `gpu` or `auto`.\n\n    ```rust\n    Example\n    env::set_var(\"BELLMAN_VERIFIER\", \"gpu\");\n    ```\n\n- `RUST_GPU_TOOLS_CUSTOM_GPU`\n\n    Will allow for adding a GPU not in the tested list. This requires researching the name of the GPU device and the number of cores in the format `[\"name:cores\"]`.\n\n    ```rust\n    // Example\n    env::set_var(\"RUST_GPU_TOOLS_CUSTOM_GPU\", \"GeForce RTX 2080 Ti:4352, GeForce GTX 1060:1280\");\n    ```\n\n- `BELLMAN_CPU_UTILIZATION`\n\n    Can be set in the interval [0,1] to designate a proportion of the multiexponenation calculation to be moved to cpu in parallel to the GPU to keep all hardware occupied.\n\n    ```rust\n    // Example\n    env::set_var(\"BELLMAN_CPU_UTILIZATION\", \"0.5\");\n    ```\n\n- `RAYON_NUM_THREADS`\n\n    Restricts the number of threads used in the library to roughly that number (best effort). In the past this was done using `BELLMAN_NUM_CPUS` which is now deprecated. The default is set to the number of logical cores reported on the machine.\n\n    ```rust\n    // Example\n    env::set_var(\"RAYON_NUM_THREADS\", \"6\");\n    ```\n\n - `EC_GPU_NUM_THREADS`\n\n    Restricts the number of threads used by the FFT and multiexponentiation calculations. In the past this setting was shared with `RAYON_NUM_THREADS`, now they are separate settings that can be controlled independently. The default is set to the number of logical cores reported on the machine.\n\n    ```rust\n    // Example\n    env::set_var(\"EC_GPU_NUM_THREADS\", \"6\");\n    ```\n\n - `BELLMAN_GPU_FRAMEWORK`\n\n     Bellman can be compiled with both, OpenCL and CUDA support. When both are available, `BELLMAN_GPU_FRAMEWORK` can be used to set it to a specific one, either `cuda` or `opencl`.\n\n    ```rust\n    // Example\n    env::set_var(\"BELLMAN_GPU_FRAMEWORK\", \"opencl\");\n    ```\n\n - `BELLMAN_CUDA_NVCC_ARGS`\n\n     By default the CUDA kernel is compiled for several architectures, which may take a long time. `BELLMAN_CUDA_NVCC_ARGS` can be used to override those arguments. The input and output file will still be automatically set.\n\n    ```rust\n    // Example for compiling the kernel for only the Turing architecture\n    env::set_var(\"BELLMAN_CUDA_NVCC_ARGS\", \"--fatbin --gpu-architecture=sm_75 --generate-code=arch=compute_75,code=sm_75\");\n    ```\n\n - `BELLPERSON_GPUS_PER_LOCK`\n\n    Restricts the number of devices used by the FFT and multiexponentiation calculations.\n    - If it's not set, a single lock will be created, and each calculation uses all devices\n    - If BELLPERSON_GPUS_PER_LOCK = 0, no lock will be created, each calculation uses all devices, and each device can run multiple calculations. **WARNING**: this option can break things easily. Each kernel expects that it's run without anything else running on the GPU at the same time. If two kernels run at the same time, they might interfere with each other and lead to crashes or wrong results.\n    - If BELLPERSON_GPUS_PER_LOCK \u003e 0, create a lock for each device, each calculation uses BELLPERSON_GPUS_PER_LOCK (up to device number) devices\n\n    ```rust\n    // Example\n    env::set_var(\"BELLPERSON_GPUS_PER_LOCK\", \"0\");\n    env::set_var(\"BELLPERSON_GPUS_PER_LOCK\", \"1\");\n    ```\n\n#### Supported / Tested Cards\n\nDepending on the size of the proof being passed to the gpu for work, certain cards will not be able to allocate enough memory to either the FFT or Multiexp kernel. Below is a list of devices that work for small sets. In the future we will add the cutoff point at which a given card will not be able to allocate enough memory to utilize the GPU.\n\n| Device Name            | Cores | Comments       |\n|------------------------|-------|----------------|\n| Quadro RTX 6000        | 4608  |                |\n| TITAN RTX              | 4608  |                |\n| Tesla V100             | 5120  |                |\n| Tesla P100             | 3584  |                |\n| Tesla T4               | 2560  |                |\n| Quadro M5000           | 2048  |                |\n| GeForce RTX 3090       |10496  |                |\n| GeForce RTX 3080       | 8704  |                |\n| GeForce RTX 3070       | 5888  |                |\n| GeForce RTX 2080 Ti    | 4352  |                |\n| GeForce RTX 2080 SUPER | 3072  |                |\n| GeForce RTX 2080       | 2944  |                |\n| GeForce RTX 2070 SUPER | 2560  |                |\n| GeForce GTX 1080 Ti    | 3584  |                |\n| GeForce GTX 1080       | 2560  |                |\n| GeForce GTX 2060       | 1920  |                |\n| GeForce GTX 1660 Ti    | 1536  |                |\n| GeForce GTX 1060       | 1280  |                |\n| GeForce GTX 1650 SUPER | 1280  |                |\n| GeForce GTX 1650       |  896  |                |\n|                        |       |                |\n| gfx1010                | 2560  | AMD RX 5700 XT |\n| gfx906                 | 7400  | AMD RADEON VII |\n|------------------------|-------|----------------|\n\n### Running Tests\n\n```bash\nRUSTFLAGS=\"-C target-cpu=native\" cargo test --release --all\n```\n\nTo run using CUDA and OpenCL, you can use:\n\n```bash\nRUSTFLAGS=\"-C target-cpu=native\" cargo test --release --all --features cuda,opencl\n```\n\nTo run the multiexp_consistency test you can use:\n\n```bash\nRUST_LOG=info cargo test --features cuda,opencl -- --exact multiexp::gpu_multiexp_consistency --nocapture\n```\n\n### Considerations\n\nBellperson uses `rust-gpu-tools` as its CUDA/OpenCL backend, therefore you may see a\ndirectory named `~/.rust-gpu-tools` in your home folder, which contains the\ncompiled binaries of OpenCL kernels used in this repository.\n\n### Experimental\n\nThe instance aggregation provided by `groth16::aggregate::prove::aggregate_proofs_and_instances()` has not yet been\naudited so should be used with caution. It is not recommended to use instance aggregation in production until it has\nbeen audited.\n\n## License\n\nLicensed under either of\n\n- Apache License, Version 2.0, |[LICENSE-APACHE](LICENSE-APACHE) or\n   http://www.apache.org/licenses/LICENSE-2.0)\n- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally\nsubmitted for inclusion in the work by you, as defined in the Apache-2.0\nlicense, shall be dual licensed as above, without any additional terms or\nconditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffilecoin-project%2Fbellperson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffilecoin-project%2Fbellperson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffilecoin-project%2Fbellperson/lists"}