Skip to main content

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 Num2Bits without 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

  1. Basic Analysis: To analyze a Circom file and print the report to the console:

    circheck path/to/your/file.circom
    

    This will run the analysis and display the results directly in the terminal.

  2. 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

circheck-0.1.3.tar.gz (59.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

circheck-0.1.3-py3-none-any.whl (61.9 kB view details)

Uploaded Python 3

File details

Details for the file circheck-0.1.3.tar.gz.

File metadata

  • Download URL: circheck-0.1.3.tar.gz
  • Upload date:
  • Size: 59.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for circheck-0.1.3.tar.gz
Algorithm Hash digest
SHA256 39805a38886c4ff6f5ed3d201b0261c70f0a6e0f8afb6be404b2fd70ddf4b0fd
MD5 30216355d56d1c2a8259330fd9e4b27a
BLAKE2b-256 dc466d670382ea004f046a921c2502808bba13b7ee0ef06d34550226ac92a03a

See more details on using hashes here.

File details

Details for the file circheck-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: circheck-0.1.3-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

Hashes for circheck-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2aac0b777211ef900b033d10ba916e626b310e3c25b2d6edbce0f29cbe12d7ab
MD5 edc0e1388288e1a46c62950bdaf4b3c5
BLAKE2b-256 b79f5b911f11f68f7461b23fa8acba0b5c9c61e56f799e39979e11dd62b83a40

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page