Skip to content

Commit

Permalink
feat(debug feature): debug, strack tracing and witness generation
Browse files Browse the repository at this point in the history
BREAKING CHANGE: this release contain the mvp version ( init, compile and debug feat. )
  • Loading branch information
sleepyqadir committed Oct 3, 2022
1 parent a4c33fb commit 0a877ec
Show file tree
Hide file tree
Showing 32 changed files with 949 additions and 575 deletions.
96 changes: 91 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,37 @@
<p align="center" >
<img src="https://xord.notion.site/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F283b98b7-fdae-4e5a-acaf-248242084e4a%2FICON.png?table=block&id=5306223c-a4f7-45d1-9f54-b9a5f4004cd6&spaceId=49976899-64a1-40fd-a3e6-c2ad82ad7aa1&width=250&userId=&cache=v2" alt="shield" width="200" height="200">
</p>
The shield is a development framework for circom developers but we plan it for other languages such as CAIRO, SNARKYJS, etc.

The shield is a development framework for circom developers, but we plan it for other languages such as CAIRO, SNARKYJS, etc.

The core reason is to provide libraries, plugins, and testing tools to ensure code quality and security.

Circomlib (which is the most popular library to build circom circuits) has over 1800 weekly downloads.

## Pre-Requisite


You have to setup the environment before using it and install the following to get started with shield cli.

#### Windows

- [rust](https://www.rust-lang.org/tools/install)
- [circom](https://docs.circom.io/getting-started/installation/)
- [nodejs](https://nodejs.org/en/download/)

In future versions we'll provide a script to setup the environment with a single command execution.
In future versions, we will provide a script to setup the environment with single command execution.

#### Linux/Mac

- [nodejs](https://nodejs.org/en/download/)


## Installation

Install shield globally with npm:

```bash

$ npm i -g @xorddotcom/shield
```

Expand All @@ -30,8 +42,10 @@ $ npm i -g @xorddotcom/shield
### Getting Started

To create a sample project, run
In future versions, we will provide a script to setup the environment with single command execution.

```bash

$ shield init
```

Expand All @@ -48,6 +62,7 @@ create a JavaScript, TypeScript project, or an empty shield.config.js
### Compiling your circuits

```bash

$ shield compile
```

Expand All @@ -61,6 +76,7 @@ Options:
-c, --circuit <value> specific circuit to compile
-h, --help display help for command


```

### Basic configuration
Expand Down Expand Up @@ -90,6 +106,10 @@ module.exports = {
circuit: "demo.circom",
// (optional) Output path for zkey file, inferred from `name` if unspecified
zkey: "demo.zkey",
// (optional) Input path for input signal data, inferred from `name` if unspecified
input: "input.json",
// // (optional) Output path for witness file, inferred from `name` if unspecified
witness: "demo.json",
},
],
},
Expand All @@ -107,9 +127,7 @@ Your project structure should look like this:
│ └── demo.circom
└── shield.config.js


```

Now, you can use shield compile to compile the circuits and output demo_Verifier.sol, demo.zkey,demo.wasm and Verifier contract interface files into their respective directories:

```javascript
Expand All @@ -127,6 +145,9 @@ Now, you can use shield compile to compile the circuits and output demo_Verifier
│ └── verification_key.json
├── circuits
│ ├── demo.circom
│ ├── input.json
│ ├── demo.wtns
│ ├── demo.json
│ └── powersOfTau28_hez_final_10.ptau
├── contracts
│ ├── demo_Verifier.sol
Expand All @@ -137,12 +158,77 @@ Now, you can use shield compile to compile the circuits and output demo_Verifier

```

### Debugging your circuits

Debug feature allows you to display the circom circuits logs, input/output signals logs, and the passed/failed Constraints along with signals calculations.

To debug with an error stack trace and generate a witness JSON/Wtns file, run:

```bash

$ shield debug
```


```bash

Usage: shield debug [options]

debug (display input/output signals, circuit logs, and passed/failed constraints ) and generate a witness file of the circuit

Options:
-c, --circuit <value> specific circuit to debug
-h, --help display help for command

```

#### Example debug logs

```
Input Signals:
┌───────────┬────────┐
│ (Signals) │ Values │
├───────────┼────────┤
│ c │ '4' │
│ a │ '2' │
│ b │ '2' │
└───────────┴────────┘
No ouput signal found:
Constraint no 1: passed
Currently, we are only providing the initialization and compiling feature in this CLI but we're working iteratively and working on other features as well that we have in our roadmap such as debugging with error stack trace.
=> ((-1)*signal2) * (1*signal3) = ((-1)*signal1)
=> ((-1)*2) * (1*2) = ((-1)*4)
Related signals:
signal2: main.a, value: 2
signal3: main.b, value: 2
signal1: main.c, value: 4
```

## Contribution
For making a contribution refer to [CONTRIBUTION.md](https://github.com/xorddotcom/SHIELD/blob/main/CONTRIBUTION.md) file.

## License

[MIT](https://choosealicense.com/licenses/mit/)

## Donate

[![Buy Us A Coffee](https://srv-cdn.himpfen.io/badges/buymeacoffee/buymeacoffee-flat.svg)](https://cryptip.me/0xf1f7dfb65C47445ACA50319512373A50C396fCdF) &nbsp;


**Ethereum :** `0xf1f7dfb65C47445ACA50319512373A50C396fCdF` <br />
**Optimism :** `0xf1f7dfb65C47445ACA50319512373A50C396fCdF` <br />
**Polygon :** `0xf1f7dfb65C47445ACA50319512373A50C396fCdF` <br />
**Zksync :** `0xf1f7dfb65C47445ACA50319512373A50C396fCdF` <br />
**Arbitrum :** `0xf1f7dfb65C47445ACA50319512373A50C396fCdF` <br />
Loading

0 comments on commit 0a877ec

Please sign in to comment.