@trynullsec/s1-zk 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nullsec
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,85 +1,134 @@
1
1
  # Nullsec S1-ZK
2
2
 
3
- AI-native auditing for zero-knowledge circuits. Find underconstraints before they mint infinite money.
3
+ <p align="center">
4
+ <img src="https://raw.githubusercontent.com/trynullsec/nullsec-s1-zk/main/assets/nullsec-s1-zk-banner.png" width="100%" />
5
+ </p>
4
6
 
5
- ## What Nullsec S1-ZK Is
7
+ <p align="center">
8
+ <a href="https://www.npmjs.com/package/@trynullsec/s1-zk"><img src="https://img.shields.io/npm/v/@trynullsec/s1-zk?color=111827&label=npm" alt="npm version" /></a>
9
+ <img src="https://img.shields.io/badge/TypeScript-5.x-3178c6" alt="TypeScript" />
10
+ <img src="https://img.shields.io/badge/Circom-supported-16a34a" alt="Circom supported" />
11
+ <img src="https://img.shields.io/badge/Halo2-supported-7c3aed" alt="Halo2 supported" />
12
+ <img src="https://img.shields.io/badge/status-active-16a34a" alt="status active" />
13
+ <img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT license" />
14
+ </p>
6
15
 
7
- Nullsec S1-ZK is a production-grade static analysis foundation for ZK circuit auditing. It scans Circom circuits and Rust-based Halo2 circuits for high-impact soundness risks such as unsafe witness hints, missing constraints, missing range checks, missing booleanity checks, unbound inputs, unsafe assertions, component output binding mistakes, unconstrained advice assignments, and unbound Halo2 instance values.
16
+ **AI-native auditing for zero-knowledge circuits.**
8
17
 
9
- It detects high-signal underconstraint patterns, but it does not prove full circuit soundness and does not replace expert cryptographic audits.
18
+ Nullsec S1-ZK is an open-source security engine for zero-knowledge circuits.
10
19
 
11
- ## Why ZK Underconstraints Matter
20
+ It analyzes Circom and Halo2 circuits, builds constraint graphs, infers proof obligations, and generates exploit hypotheses for underconstraint risks.
12
21
 
13
- Most catastrophic ZK bugs are not ordinary application bugs. They are proof-system semantic failures where the circuit does not actually constrain what the protocol thinks it constrains. Nullsec S1-ZK is built around the question: what does this circuit claim to prove, and what does it actually constrain?
22
+ **Find underconstraints before they mint infinite money.**
14
23
 
15
- ## What v1 Detects
24
+ ```bash
25
+ npx @trynullsec/s1-zk scan ./circuits
26
+ ```
27
+
28
+ ## Why S1-ZK Exists
29
+
30
+ Catastrophic ZK bugs are often not ordinary application bugs. They are proof-system semantic failures: a witness can satisfy the constraint system while violating the protocol statement developers believe is being proven.
31
+
32
+ Nullsec S1-ZK is built around one question:
33
+
34
+ > What does this circuit claim to prove, and what does it actually constrain?
16
35
 
17
- v1 implements deterministic static analysis for Circom and best-effort static analysis for Halo2-style Rust circuits.
36
+ The tool is designed for ZK auditors, protocol engineers, security researchers, and crypto developers who need fast, deterministic signal on underconstraints, unsafe witness assignments, missing public bindings, selector mistakes, incomplete EC relations, and other soundness risks.
18
37
 
19
- Circom checks include:
38
+ ## Supported Frontends
20
39
 
21
- - Dangerous `<--` hint assignments.
22
- - Assigned but unconstrained signals.
23
- - Input signals that never bind into constraints.
24
- - Unconstrained outputs.
25
- - Missing booleanity checks.
26
- - Missing range checks and aliasing risks.
27
- - Unsafe `assert(...)` over signals.
28
- - Unsafe division and inverse patterns.
29
- - Unconstrained component outputs.
30
- - Unused signals and suspicious selectors.
40
+ ### Circom
31
41
 
32
- Halo2 checks include:
42
+ The Circom frontend parses `.circom` files and builds a signal/constraint graph for high-signal soundness checks:
33
43
 
34
- - Advice assignments that do not appear connected to gates, equality constraints, instance constraints, or lookups.
35
- - Instance/public values queried without an obvious public binding.
36
- - Selector discipline risks.
37
- - Unsafe inverse or division patterns.
38
- - Suspicious partial elliptic-curve operation assignments.
39
- - Copy-constraint usage without obvious `enable_equality`.
44
+ - Dangerous hint assignments with `<--`
45
+ - Assigned-but-unconstrained signals
46
+ - Unbound inputs
47
+ - Unconstrained outputs
48
+ - Missing booleanity checks
49
+ - Missing range checks
50
+ - Unsafe assertions
51
+ - Unsafe division or inverse patterns
52
+ - Alias and overflow risks
53
+ - Suspicious selectors
40
54
 
41
- ## Halo2 Constraint Graph
55
+ ### Halo2-Style Rust
42
56
 
43
- The Halo2 frontend builds a best-effort constraint graph from Rust source. It links `create_gate` expressions, advice/fixed/instance queries, selector-gated polynomials, `assign_region` assignments, selector enables, `constrain_equal`, `copy_advice`, lookups, and `constrain_instance` public bindings.
57
+ The Halo2 frontend scans Rust source for Halo2 patterns and builds a best-effort constraint graph over gates, regions, selectors, equality edges, and public bindings:
44
58
 
45
- This graph lets Nullsec S1-ZK distinguish advice values that are connected through gates, equality edges, lookups, or public instance exposure from values that are merely assigned in a region. It improves high-signal findings for Orchard-style EC gadgets and other Halo2 circuits, but it is still static source analysis, not formal verification or complete Halo2 synthesis.
59
+ - Assigned advice not constrained
60
+ - Instance value not bound
61
+ - Selector discipline risk
62
+ - Unsafe inverse/division
63
+ - Partial EC operation risk
64
+ - Missing `enable_equality` assumptions
65
+ - Gate extraction
66
+ - Assignment connectivity
67
+ - Equality/copy edges
68
+ - Public instance bindings
46
69
 
47
- ## Deep Relationship Analysis
70
+ ## Deep Analysis Mode
48
71
 
49
- Use `--deep` to enable proof obligation extraction, relation checking, taint/dataflow analysis, and deterministic exploit hypotheses.
72
+ `--deep` enables relationship-aware analysis beyond individual rule hits:
73
+
74
+ - Proof obligation extraction
75
+ - Relation checking
76
+ - Taint/witness flow analysis
77
+ - Exploit hypothesis generation
50
78
 
51
79
  ```bash
52
- nullsec-zk scan ./circuits --deep
80
+ npx @trynullsec/s1-zk scan ./circuits --deep
53
81
  ```
54
82
 
55
- Deep analysis infers likely obligations such as commitment binding, nullifier binding, Merkle path binding, selector booleanity, EC multiplication consistency, public input binding, and range constraints. It then checks whether parsed constraints, Halo2 graph edges, equality/copy edges, lookups, and public instance bindings appear to support those obligations.
83
+ Example deep-analysis output:
56
84
 
57
- This is relationship-aware static analysis. It helps auditors find gaps faster, but inferred obligations may be wrong or incomplete and are not formal proof obligations in the mathematical verification sense.
85
+ ```text
86
+ Proof obligations:
87
+ Total 68
88
+ Satisfied 59
89
+ Missing 9
90
+
91
+ Exploit hypothesis:
92
+ A malicious prover may choose EC point coordinates independently of the claimed scalar multiplication relation. If the verifier accepts those values as part of the EC output, the circuit may verify an invalid group operation.
93
+ ```
94
+
95
+ Deep mode is still static analysis. It infers likely proof obligations from naming, graph relationships, and source structure, then checks whether parsed constraints appear to support those obligations.
58
96
 
59
97
  ## Installation
60
98
 
99
+ Run without installing:
100
+
101
+ ```bash
102
+ npx @trynullsec/s1-zk scan ./circuits
103
+ ```
104
+
105
+ Install globally:
106
+
61
107
  ```bash
62
- npm install
63
- npm run build
64
- npm link
108
+ npm install -g @trynullsec/s1-zk
65
109
  ```
66
110
 
67
111
  ## Usage
68
112
 
69
113
  ```bash
70
- nullsec-zk scan ./examples
71
- nullsec-zk scan ./examples/halo2
72
- nullsec-zk scan ./benchmarks/historical/orchard-inspired --deep
73
- nullsec-zk scan ./examples --format json
74
- nullsec-zk scan ./examples --format sarif
75
- nullsec-zk scan ./examples --report markdown
76
- nullsec-zk scan ./examples --out report.json
77
- nullsec-zk scan ./examples --fail-on HIGH
114
+ nullsec-zk scan ./circuits
115
+ nullsec-zk scan ./circuits --deep
116
+ nullsec-zk scan ./circuits --format json
117
+ nullsec-zk scan ./circuits --report markdown
78
118
  nullsec-zk rules
79
- nullsec-zk explain NS-ZK-001
119
+ nullsec-zk explain NS-H2-005
120
+ nullsec-zk init
80
121
  ```
81
122
 
82
- ## Example Terminal Output
123
+ The same commands work through `npx`:
124
+
125
+ ```bash
126
+ npx @trynullsec/s1-zk scan ./circuits --deep
127
+ npx @trynullsec/s1-zk rules
128
+ npx @trynullsec/s1-zk explain NS-H2-005
129
+ ```
130
+
131
+ ## Example Output
83
132
 
84
133
  ```text
85
134
  Nullsec S1-ZK
@@ -90,73 +139,122 @@ Frontend: Mixed
90
139
  Files scanned: 24
91
140
  Rules executed: 18
92
141
  Issues found: 33
142
+
143
+ Severity summary:
144
+ CRITICAL 2
145
+ HIGH 12
146
+ MEDIUM 15
147
+ LOW 4
148
+ INFO 0
93
149
  ```
94
150
 
95
- ## JSON Output
151
+ ## Rule Coverage
152
+
153
+ Rules are documented in [`RULES.md`](./RULES.md). The current rule families include:
154
+
155
+ - `NS-ZK-*` rules for Circom underconstraints, unsafe hints, missing booleanity/range checks, unsafe assertions, component-output binding, and selector risks.
156
+ - `NS-H2-*` rules for Halo2 advice connectivity, public instance binding, selector discipline, inverse safety, EC operation completeness, and equality assumptions.
96
157
 
97
- JSON output includes the tool name, version, target, files scanned, rules executed, severity counts, issues, and parser warnings.
158
+ List rules locally:
98
159
 
99
160
  ```bash
100
- nullsec-zk scan ./examples --format json
161
+ nullsec-zk rules
101
162
  ```
102
163
 
103
- ## Markdown Reports
164
+ Explain a rule:
104
165
 
105
166
  ```bash
106
- nullsec-zk scan ./examples --report markdown
167
+ nullsec-zk explain NS-H2-005
107
168
  ```
108
169
 
109
- By default this writes `nullsec-zk-report.md`. Use `--out` to choose another path.
170
+ ## Orchard-Inspired Benchmark
110
171
 
111
- ## SARIF / CI Usage
172
+ The repository includes synthetic Orchard-inspired Halo2 benchmarks under:
112
173
 
113
- ```bash
114
- nullsec-zk scan ./circuits --format sarif --out nullsec-zk.sarif --fail-on HIGH
174
+ ```text
175
+ benchmarks/historical/orchard-inspired
115
176
  ```
116
177
 
117
- The SARIF renderer is structured for GitHub code scanning compatibility.
178
+ These examples are not copied from Zcash source. They are synthetic benchmark cases modeling the class of partial elliptic-curve underconstraint issues discussed publicly after the Orchard vulnerability disclosure.
118
179
 
119
- ## Rule List
180
+ Nullsec S1-ZK does not claim to have found the real Zcash bug, and it does not prove Zcash or Orchard security. The benchmark exists to research the same family of underconstraint risk in a small, auditable fixture.
120
181
 
121
- Run:
182
+ Run it with deep analysis:
122
183
 
123
184
  ```bash
124
- nullsec-zk rules
185
+ npx @trynullsec/s1-zk scan ./benchmarks/historical/orchard-inspired --deep
125
186
  ```
126
187
 
127
- Detailed rule documentation is in `RULES.md`.
188
+ ## Reports
189
+
190
+ Nullsec S1-ZK supports:
191
+
192
+ - Terminal output
193
+ - JSON output
194
+ - Markdown reports
195
+ - SARIF for code-scanning workflows
196
+
197
+ Examples:
198
+
199
+ ```bash
200
+ nullsec-zk scan ./circuits --format json
201
+ nullsec-zk scan ./circuits --report markdown
202
+ nullsec-zk scan ./circuits --format sarif --out nullsec-zk.sarif
203
+ ```
128
204
 
129
205
  ## Configuration
130
206
 
131
- Create a config:
207
+ Create a config file:
132
208
 
133
209
  ```bash
134
210
  nullsec-zk init
135
211
  ```
136
212
 
137
- Example:
213
+ Example `.nullsec-zk.json`:
138
214
 
139
215
  ```json
140
216
  {
141
217
  "rules": {
142
- "NS-ZK-006": "off",
143
- "NS-ZK-005": "high"
218
+ "NS-ZK-006": "off"
144
219
  },
145
- "ignore": ["node_modules", "circomlib"],
146
- "failOn": "HIGH",
147
- "format": "terminal",
148
- "field": "BN254"
220
+ "ignore": ["node_modules", "target"],
221
+ "failOn": "HIGH"
149
222
  }
150
223
  ```
151
224
 
152
225
  ## Limitations
153
226
 
154
- Static analysis is approximate. The Circom and Halo2 frontends are best-effort source analyzers, and `--deep` infers likely proof obligations from naming and graph relationships. Nullsec S1-ZK does not compile circuits, generate witnesses, or perform formal verification. See `LIMITATIONS.md`.
227
+ Nullsec S1-ZK is a static analysis tool:
228
+
229
+ - Parsing is best-effort.
230
+ - It is not formal verification.
231
+ - It does not prove full circuit soundness.
232
+ - It does not replace expert ZK or cryptographic audits.
233
+ - Macro-heavy Rust/Halo2 code can be missed.
234
+ - Deep analysis infers likely proof obligations and can be wrong.
235
+
236
+ See [`LIMITATIONS.md`](./LIMITATIONS.md) for more detail.
155
237
 
156
238
  ## Roadmap
157
239
 
158
- Future work includes deeper Halo2 analysis, Noir, gnark, Plonky2, R1CS extraction, witness counterexample generation, spec-to-circuit comparison, LLM-assisted exploit reasoning, CI integrations, and hosted reporting. See `ROADMAP.md`.
240
+ - Real Rust AST parsing via `syn`
241
+ - Noir frontend
242
+ - gnark frontend
243
+ - Plonky2 frontend
244
+ - R1CS extraction
245
+ - Circuit graph visualization
246
+ - GitHub Action
247
+ - Hosted dashboard
248
+ - Witness counterexample generation
249
+ - Spec-to-circuit comparison
250
+ - Historical ZK bug benchmark suite
159
251
 
160
252
  ## Security Philosophy
161
253
 
162
- Nullsec S1-ZK treats ZK circuit bugs as proof semantics failures. It is designed to surface places where witness values, public claims, outputs, selectors, and integer domains are not bound by constraints in the way a protocol likely intends.
254
+ Nullsec S1-ZK treats ZK circuit bugs as proof semantics failures. It prioritizes cases where witness values, public claims, outputs, selectors, integer domains, and EC intermediates are not bound by constraints in the way the protocol likely intends.
255
+
256
+ The goal is not to replace human auditors. The goal is to give auditors sharper graph-aware evidence faster.
257
+
258
+ ## License
259
+
260
+ MIT
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trynullsec/s1-zk",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Nullsec S1-ZK: AI-native auditing for zero-knowledge circuits.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -17,12 +17,25 @@
17
17
  },
18
18
  "keywords": [
19
19
  "zk",
20
+ "zero-knowledge",
20
21
  "circom",
22
+ "halo2",
21
23
  "security",
22
24
  "static-analysis",
23
- "auditing"
25
+ "circuits",
26
+ "audit",
27
+ "cryptography",
28
+ "proof-systems"
24
29
  ],
25
- "license": "UNLICENSED",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/trynullsec/nullsec-s1-zk.git"
33
+ },
34
+ "bugs": {
35
+ "url": "https://github.com/trynullsec/nullsec-s1-zk/issues"
36
+ },
37
+ "homepage": "https://github.com/trynullsec/nullsec-s1-zk#readme",
38
+ "license": "MIT",
26
39
  "dependencies": {
27
40
  "chalk": "^5.6.2",
28
41
  "commander": "^14.0.2",
@@ -37,9 +50,11 @@
37
50
  "files": [
38
51
  "dist",
39
52
  "README.md",
53
+ "LICENSE",
40
54
  "RULES.md",
41
55
  "LIMITATIONS.md",
42
56
  "ROADMAP.md",
57
+ "assets",
43
58
  "examples",
44
59
  "benchmarks"
45
60
  ]