Static analysis tool to detect ZKP vulnerabilities in Circom circuits.
Project description
Circheck
Circheck is a static analysis tool for Circom source code, designed to detect security vulnerabilities in Zero-Knowledge Proof (ZKP) circuits written in the Circom language. This tool helps developers and users ensure the security and integrity of their ZKP projects by analyzing the source code and identifying potential issues during circuit design.
Features
Circheck detects a variety of potential issues in Circom circuits, including:
- Unconstrained Output Signals: Detects output signals that are not constrained by any constraints.
- Unconstrained Component Inputs: Identifies input signals to components that are not constrained and may accept unchecked values.
- Data Flow Constraint Discrepancy: Finds signals that depend on others via dataflow but lack corresponding constraint dependencies.
- Unused Component Outputs: Warns when outputs of components are not used or checked in the circuit.
- Unused Signals: Identifies signals that are declared but never used in any computation or constraint.
- Type Mismatch: Detects potential type mismatches, such as signals flowing into templates like
Num2Bitswithout proper range checks. - Assignment Misuse: Finds assignment misuse, where a variable is assigned using the wrong operator.
- Divide by Zero: Warns of potential divide-by-zero issues in the circuit.
- Non-deterministic Data Flow: Flags conditional assignments depending on signals, which may lead to non-deterministic data flows.
Installation
To install Circheck, you can clone the repository and install the required dependencies:
git clone https://github.com/dangduongminhnhat/Circheck.git
cd Circheck
pip install -r requirements.txt
or you can install Circheck via pip, use the following command:
pip install circheck
Usage
Circheck is a static analysis tool designed to detect ZKP vulnerabilities in Circom circuits. You can use it via the command line interface (CLI) to analyze Circom code and generate reports.
Command Line Arguments
input: Required - The path to the Circom file you want to analyze.--json: Optional - If specified, the tool will output a JSON report to the given file. The output file must end with.json.
Example Usage
-
Basic Analysis: To analyze a Circom file and print the report to the console:
circheck path/to/your/file.circomThis will run the analysis and display the results directly in the terminal.
-
Generate JSON Report: To analyze the Circom file and save the report in a JSON file:
circheck path/to/your/file.circom --json path/to/output/report.json
This will run the analysis and save the results in the specified JSON file.
Example Output:
When you run the tool, you'll see progress information printed to the terminal, such as:
PS C:\Users\GAMING\Desktop\Capstone_Project> circheck .\demo.circom --json .\result.json
[Info] Generating AST for: .\demo.circom
[Success] AST generated successfully.
[Success] Type checking passed.
[Info] Creating CDG: SingleAssignment0, in .\demo.circom
[Info] Building conditional dependency edges of SingleAssignment0...
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████| 5/5 [00:00<?, ?it/s]
[Info] Building condition constraint edges of SingleAssignment0...
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████| 5/5 [00:00<?, ?it/s]
[Success] CDG created successfully.
[Info] Starting the analysis process of graph SingleAssignment0.
[Info] Detecting unconstrainted output...
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<?, ?it/s]
[Info] Detecting unconstrained component input...
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████| 5/5 [00:00<?, ?it/s]
[Info] Detecting data flow constraint discrepancy...
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████| 3/3 [00:00<?, ?it/s]
[Info] Detecting unused component output...
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████| 5/5 [00:00<?, ?it/s]
[Info] Detecting type mismatch...
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████| 5/5 [00:00<?, ?it/s]
[Info] Detecting assignment misuse...
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████| 7/7 [00:00<?, ?it/s]
[Info] Detecting unused signals...
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████| 7/7 [00:00<?, ?it/s]
[Info] Detecting nondeterministic data flow...
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████| 7/7 [00:00<?, ?it/s]
[Success] Detection completed successfully.
[Timeit] Analysis completed in 0.30 s
If there are any warnings or issues detected, they will be printed like this:
[Warning] In .\demo.circom:4:4
Signal 'out' depends on 'a' via dataflow, but there is no corresponding constraint dependency.
[Warning] In .\demo.circom:5:4
Variable out is assigned using <-- instead of <==.
âš Total warnings: 2
Example JSON Output:
If you specify a JSON output file, the results will also be saved to the file. For example:
[Success] Saved report to path/to/output/report.json
The JSON file will contain detailed information about the analysis, including detected vulnerabilities. A sample JSON output might look like this:
{
"SingleAssignment0": {
"data flow constraint discrepancy": {
".\\demo.circom:4:4": [
"Signal 'out' depends on 'a' via dataflow, but there is no corresponding constraint dependency."
]
},
"assignment missue": {
".\\demo.circom:5:4": [
"Variable out is assigned using <-- instead of <==."
]
}
}
}
License
Licensed under the MIT License © 2025 Dang Duong Minh Nhat.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file circheck-0.2.0.tar.gz.
File metadata
- Download URL: circheck-0.2.0.tar.gz
- Upload date:
- Size: 59.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b0e921e808b0f921365d90e0b7183202a2c68934ad4fdad730545f1d9ae08de
|
|
| MD5 |
86e18b7623cdcdc2ea797be8a4a77583
|
|
| BLAKE2b-256 |
672cb05ccff6835c7c0e5238f07d487efb9898ecc059b3e11db52635199a4352
|
File details
Details for the file circheck-0.2.0-py3-none-any.whl.
File metadata
- Download URL: circheck-0.2.0-py3-none-any.whl
- Upload date:
- Size: 61.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ef3dd6ca5e1a2b6c15baa14bc082a9ababfcf306335c5e608bcaa0b626805bd
|
|
| MD5 |
d37a22d941c5594897bf4c395745066b
|
|
| BLAKE2b-256 |
7e7c9acb6dbca7ee2404fd2b659e68146dbdf1c3c44bc8f66ffc0e84e7703ed0
|