starkshield 1.0.0
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/README.md +101 -0
- package/bin/circom +0 -0
- package/bin/cli.js +36 -0
- package/bin/index.js +13 -0
- package/circomlib/.vscode/launch.json +63 -0
- package/circomlib/README.md +18 -0
- package/circomlib/circuits/README.md +830 -0
- package/circomlib/circuits/aliascheck.circom +33 -0
- package/circomlib/circuits/babyjub.circom +107 -0
- package/circomlib/circuits/binsub.circom +74 -0
- package/circomlib/circuits/binsum.circom +101 -0
- package/circomlib/circuits/bitify.circom +106 -0
- package/circomlib/circuits/comparators.circom +141 -0
- package/circomlib/circuits/compconstant.circom +74 -0
- package/circomlib/circuits/eddsa.circom +139 -0
- package/circomlib/circuits/eddsamimc.circom +124 -0
- package/circomlib/circuits/eddsamimcsponge.circom +124 -0
- package/circomlib/circuits/eddsaposeidon.circom +123 -0
- package/circomlib/circuits/escalarmul.circom +166 -0
- package/circomlib/circuits/escalarmulany.circom +197 -0
- package/circomlib/circuits/escalarmulfix.circom +299 -0
- package/circomlib/circuits/escalarmulw4table.circom +52 -0
- package/circomlib/circuits/gates.circom +96 -0
- package/circomlib/circuits/mimc.circom +156 -0
- package/circomlib/circuits/mimcsponge.circom +293 -0
- package/circomlib/circuits/montgomery.circom +142 -0
- package/circomlib/circuits/multiplexer.circom +115 -0
- package/circomlib/circuits/mux1.circom +48 -0
- package/circomlib/circuits/mux2.circom +63 -0
- package/circomlib/circuits/mux3.circom +75 -0
- package/circomlib/circuits/mux4.circom +119 -0
- package/circomlib/circuits/pedersen.circom +257 -0
- package/circomlib/circuits/pedersen_old.circom +68 -0
- package/circomlib/circuits/pointbits.circom +164 -0
- package/circomlib/circuits/poseidon.circom +208 -0
- package/circomlib/circuits/poseidon_constants.circom +24959 -0
- package/circomlib/circuits/poseidon_constants_old.circom +252 -0
- package/circomlib/circuits/poseidon_old.circom +97 -0
- package/circomlib/circuits/sha256/ch.circom +47 -0
- package/circomlib/circuits/sha256/constants.circom +53 -0
- package/circomlib/circuits/sha256/main.circom +35 -0
- package/circomlib/circuits/sha256/maj.circom +45 -0
- package/circomlib/circuits/sha256/rotate.circom +28 -0
- package/circomlib/circuits/sha256/sha256.circom +81 -0
- package/circomlib/circuits/sha256/sha256_2.circom +91 -0
- package/circomlib/circuits/sha256/sha256compression.circom +166 -0
- package/circomlib/circuits/sha256/sha256compression_function.circom +112 -0
- package/circomlib/circuits/sha256/shift.circom +33 -0
- package/circomlib/circuits/sha256/sigma.circom +77 -0
- package/circomlib/circuits/sha256/sigmaplus.circom +50 -0
- package/circomlib/circuits/sha256/t1.circom +58 -0
- package/circomlib/circuits/sha256/t2.circom +51 -0
- package/circomlib/circuits/sha256/xor3.circom +45 -0
- package/circomlib/circuits/sign.circom +36 -0
- package/circomlib/circuits/smt/smthash_mimc.circom +58 -0
- package/circomlib/circuits/smt/smthash_poseidon.circom +57 -0
- package/circomlib/circuits/smt/smtlevins.circom +103 -0
- package/circomlib/circuits/smt/smtprocessor.circom +261 -0
- package/circomlib/circuits/smt/smtprocessorlevel.circom +95 -0
- package/circomlib/circuits/smt/smtprocessorsm.circom +165 -0
- package/circomlib/circuits/smt/smtverifier.circom +138 -0
- package/circomlib/circuits/smt/smtverifierlevel.circom +71 -0
- package/circomlib/circuits/smt/smtverifiersm.circom +106 -0
- package/circomlib/circuits/switcher.circom +42 -0
- package/circomlib/doc/root_transfer.monopic +0 -0
- package/circomlib/doc/smt_diagram_0.monopic +0 -0
- package/circomlib/doc/smt_diagram_1.monopic +0 -0
- package/circomlib/doc/smt_hash.monopic +0 -0
- package/circomlib/doc/smt_levins.monopic +0 -0
- package/circomlib/doc/smt_sm.monopic +0 -0
- package/circomlib/doc/smt_verifier_sm.monopic +0 -0
- package/circomlib/doc/voting.monopic +0 -0
- package/circomlib/doc/window.monopic +0 -0
- package/circomlib/doc/window_chain.monopic +0 -0
- package/circomlib/index.js +2 -0
- package/circomlib/package.json +33 -0
- package/circomlib/test/aliascheck.js +77 -0
- package/circomlib/test/babyjub.js +118 -0
- package/circomlib/test/binsub.js +52 -0
- package/circomlib/test/binsum.js +38 -0
- package/circomlib/test/circuits/aliascheck_test.circom +4 -0
- package/circomlib/test/circuits/babyadd_tester.circom +4 -0
- package/circomlib/test/circuits/babycheck_test.circom +4 -0
- package/circomlib/test/circuits/babypbk_test.circom +4 -0
- package/circomlib/test/circuits/binsub_test.circom +33 -0
- package/circomlib/test/circuits/constants_test.circom +20 -0
- package/circomlib/test/circuits/eddsa_test.circom +5 -0
- package/circomlib/test/circuits/eddsamimc_test.circom +5 -0
- package/circomlib/test/circuits/eddsaposeidon_test.circom +5 -0
- package/circomlib/test/circuits/edwards2montgomery.circom +5 -0
- package/circomlib/test/circuits/escalarmul_min_test.circom +27 -0
- package/circomlib/test/circuits/escalarmul_test.circom +33 -0
- package/circomlib/test/circuits/escalarmul_test_min.circom +28 -0
- package/circomlib/test/circuits/escalarmulany_test.circom +30 -0
- package/circomlib/test/circuits/escalarmulfix_test.circom +31 -0
- package/circomlib/test/circuits/escalarmulw4table.circom +20 -0
- package/circomlib/test/circuits/escalarmulw4table_test.circom +19 -0
- package/circomlib/test/circuits/escalarmulw4table_test3.circom +19 -0
- package/circomlib/test/circuits/greatereqthan.circom +5 -0
- package/circomlib/test/circuits/greaterthan.circom +5 -0
- package/circomlib/test/circuits/isequal.circom +5 -0
- package/circomlib/test/circuits/iszero.circom +5 -0
- package/circomlib/test/circuits/lesseqthan.circom +5 -0
- package/circomlib/test/circuits/lessthan.circom +5 -0
- package/circomlib/test/circuits/mimc_sponge_hash_test.circom +5 -0
- package/circomlib/test/circuits/mimc_sponge_test.circom +5 -0
- package/circomlib/test/circuits/mimc_test.circom +5 -0
- package/circomlib/test/circuits/montgomery2edwards.circom +5 -0
- package/circomlib/test/circuits/montgomeryadd.circom +5 -0
- package/circomlib/test/circuits/montgomerydouble.circom +5 -0
- package/circomlib/test/circuits/mux1_1.circom +33 -0
- package/circomlib/test/circuits/mux2_1.circom +37 -0
- package/circomlib/test/circuits/mux3_1.circom +41 -0
- package/circomlib/test/circuits/mux4_1.circom +56 -0
- package/circomlib/test/circuits/pedersen2_test.circom +34 -0
- package/circomlib/test/circuits/pedersen_test.circom +31 -0
- package/circomlib/test/circuits/pointbits_loopback.circom +25 -0
- package/circomlib/test/circuits/poseidon3_test.circom +5 -0
- package/circomlib/test/circuits/poseidon6_test.circom +5 -0
- package/circomlib/test/circuits/poseidonex_test.circom +5 -0
- package/circomlib/test/circuits/sha256_2_test.circom +17 -0
- package/circomlib/test/circuits/sha256_test448.circom +5 -0
- package/circomlib/test/circuits/sha256_test512.circom +5 -0
- package/circomlib/test/circuits/sign_test.circom +5 -0
- package/circomlib/test/circuits/smtprocessor10_test.circom +5 -0
- package/circomlib/test/circuits/smtverifier10_test.circom +5 -0
- package/circomlib/test/circuits/sum_test.circom +33 -0
- package/circomlib/test/comparators.js +187 -0
- package/circomlib/test/eddsa.js +75 -0
- package/circomlib/test/eddsamimc.js +102 -0
- package/circomlib/test/eddsaposeidon.js +103 -0
- package/circomlib/test/escalarmul.js +121 -0
- package/circomlib/test/escalarmulany.js +51 -0
- package/circomlib/test/escalarmulfix.js +95 -0
- package/circomlib/test/helpers/printsignal.js +22 -0
- package/circomlib/test/helpers/sha256.js +178 -0
- package/circomlib/test/mimccircuit.js +27 -0
- package/circomlib/test/mimcspongecircuit.js +47 -0
- package/circomlib/test/montgomery.js +101 -0
- package/circomlib/test/multiplexer.js +101 -0
- package/circomlib/test/pedersen.js +83 -0
- package/circomlib/test/pedersen2.js +56 -0
- package/circomlib/test/point2bits.js +30 -0
- package/circomlib/test/poseidoncircuit.js +80 -0
- package/circomlib/test/sha256.js +118 -0
- package/circomlib/test/sign.js +82 -0
- package/circomlib/test/smtprocessor.js +219 -0
- package/circomlib/test/smtverifier.js +141 -0
- package/lib/compile.js +82 -0
- package/lib/deploy.js +391 -0
- package/lib/test.js +47 -0
- package/lib/verify.js +153 -0
- package/package.json +43 -0
- package/pot12_0000.ptau +0 -0
- package/pot12_0001.ptau +0 -0
- package/ptau/pot12_final.ptau +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# starkshield
|
|
2
|
+
|
|
3
|
+
**Write Circom. Compile. Deploy. Verify — all in just one click, Powered by Starknet**
|
|
4
|
+
|
|
5
|
+
A zero-setup toolkit to build, deploy, and verify ZK circuits using Circom — with **no Web3 knowledge required**.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## ✨ Features
|
|
10
|
+
|
|
11
|
+
- 🧠 Write simple Circom circuits
|
|
12
|
+
- 🛠 Compile to `.r1cs`, `.wasm`, `.zkey`, and Solidity verifier
|
|
13
|
+
- 🚀 Deploy verifier to **Starknet** with one command
|
|
14
|
+
- ✅ Verify proofs using a single JavaScript function
|
|
15
|
+
- 🧪 No Web3 scripting, no ABI handling — fully abstracted
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 📦 Installation
|
|
20
|
+
|
|
21
|
+
Install in your project:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install starkshield
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
⚡ Usage
|
|
28
|
+
|
|
29
|
+
### ✅ Compile Circom circuit
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npx starkshield compile <path-to-your-circom-file>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
This command:
|
|
36
|
+
|
|
37
|
+
- Compiles your .circom file
|
|
38
|
+
- Runs Groth16 trusted setup
|
|
39
|
+
- Outputs .r1cs, .wasm, circuit_final.zkey, and verifier.sol
|
|
40
|
+
- All files are saved in a folder named after your circuit (e.g., ./yourCircuit/)
|
|
41
|
+
|
|
42
|
+
### ✅ Test Compiled Circom Circuit
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npx starkshield test <path-to-generated-folder> <path-to-input.json>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
This command:
|
|
49
|
+
|
|
50
|
+
- Tests the zk System produced by the compile command
|
|
51
|
+
- Uses inputs provided by the developer from input.json provided
|
|
52
|
+
- produces proof.json and public.json
|
|
53
|
+
- proof.json contains the smart contract parameters, which will be used to verify it onchain
|
|
54
|
+
- public.json contains human verifiable outputs and proofs
|
|
55
|
+
|
|
56
|
+
### ✅ Deploy Compiled Circom Circuit
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npx starkshield deploy <path-to-generated-folder> <PRIVATE_KEY_OF_WALLET>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
This command:
|
|
63
|
+
|
|
64
|
+
- Compiles verifier.sol generated during compilation using solc
|
|
65
|
+
- Deploys the compiled binary to Starknet, taking fees from the provided wallet's private key
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
### ✅ Verify ZK Proof Programmatically
|
|
69
|
+
|
|
70
|
+
You can verify a proof directly using a single function call.
|
|
71
|
+
|
|
72
|
+
```js
|
|
73
|
+
const { verifyProof } = require("starkshield");
|
|
74
|
+
|
|
75
|
+
const result = await verifyProof({
|
|
76
|
+
input: {
|
|
77
|
+
// Your circuit input goes here
|
|
78
|
+
},
|
|
79
|
+
"<relative-path-to-generated-folder>",
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
console.log(result ? "✅ Valid proof" : "❌ Invalid proof");
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
- You pass input (in the form of json) & Relative path to the generated folder, which was generated during compilation process
|
|
86
|
+
- Automatically generates the proof and public signals
|
|
87
|
+
- Formats the calldata for the Solidity verifier
|
|
88
|
+
- Calls the deployed verifier contract on Starknet and returns the result
|
|
89
|
+
|
|
90
|
+
# You don’t need to manually use snarkjs or interact with web3 directly — the SDK abstracts it all for you.
|
|
91
|
+
|
|
92
|
+
## 🛠 Commands Overview
|
|
93
|
+
|
|
94
|
+
| Command | Description |
|
|
95
|
+
|----------------------------------------------|--------------------------------------------------|
|
|
96
|
+
| `npx starkshield compile <path-to-circuit>` | Compiles the `.circom` file and runs Groth16 setup |
|
|
97
|
+
| `npx starkshield test <output-folder> <path-to-input.json>` | Tests the Circom logic locally using ZK Proofs |
|
|
98
|
+
| `npx starkshield deploy <output-folder> <private-key>` | Deploys the verifier contract to Starknet |
|
|
99
|
+
| `verifyProof(input,"<relative-path-to-output-folder>")` *(programmatic only)* | Generates proof and verifies it on-chain using deployed contract |
|
|
100
|
+
|
|
101
|
+
|
package/bin/circom
ADDED
|
Binary file
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { program } = require('commander');
|
|
4
|
+
const { compileCircuit } = require('../lib/compile');
|
|
5
|
+
const { testCircuit } = require('../lib/test');
|
|
6
|
+
const { deployVerifier } = require('../lib/deploy');
|
|
7
|
+
// const { verifyProof } = require('../lib/verify');
|
|
8
|
+
|
|
9
|
+
program
|
|
10
|
+
.command('compile <circomFilePath>')
|
|
11
|
+
.description('Compile a circom circuit')
|
|
12
|
+
.action((circomFilePath) => {
|
|
13
|
+
compileCircuit(circomFilePath);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
program
|
|
17
|
+
.command('test <folder> <inputJson>')
|
|
18
|
+
.description('Test the circuit with input.json and generate proof/public.json')
|
|
19
|
+
.action((folder, inputJson) => {
|
|
20
|
+
testCircuit(folder, inputJson);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
program
|
|
24
|
+
.command('deploy <folder> <privateKey> <accountAddress>')
|
|
25
|
+
.description('Deploy verifier.sol in folder to Starknet using provided private key and account address')
|
|
26
|
+
.action((folder, privateKey, accountAddress) => {
|
|
27
|
+
deployVerifier(folder, privateKey, accountAddress);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
program.parse(process.argv);
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
module.exports = {
|
|
35
|
+
// verifyProof
|
|
36
|
+
};
|
package/bin/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const { compileCircuit } = require('../lib/compile');
|
|
2
|
+
const { testCircuit } = require('../lib/test');
|
|
3
|
+
// const { deployVerifier } = require('../lib/deploy');
|
|
4
|
+
// const { verifyProof } = require('../lib/verify');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
// verifyProof,
|
|
10
|
+
compileCircuit,
|
|
11
|
+
testCircuit,
|
|
12
|
+
// deployVerifier
|
|
13
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Use IntelliSense to learn about possible attributes.
|
|
3
|
+
// Hover to view descriptions of existing attributes.
|
|
4
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
+
"version": "0.2.0",
|
|
6
|
+
"configurations": [
|
|
7
|
+
{
|
|
8
|
+
"type": "pwa-node",
|
|
9
|
+
"request": "launch",
|
|
10
|
+
"name": "Launch Program",
|
|
11
|
+
"skipFiles": [
|
|
12
|
+
"<node_internals>/**"
|
|
13
|
+
],
|
|
14
|
+
"program": "${workspaceFolder}/calcoptimizedposeidonconsts/test_poseidon.js",
|
|
15
|
+
"cwd": "${workspaceFolder}/calcoptimizedposeidonconsts"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"type": "pwa-node",
|
|
19
|
+
"request": "launch",
|
|
20
|
+
"name": "Tests",
|
|
21
|
+
"skipFiles": [
|
|
22
|
+
"<node_internals>/**"
|
|
23
|
+
],
|
|
24
|
+
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
|
|
25
|
+
"cwd": "${workspaceFolder}",
|
|
26
|
+
"args": ["test/smtverifier.js"]
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"type": "pwa-node",
|
|
30
|
+
"request": "launch",
|
|
31
|
+
"name": "Test Poseidon",
|
|
32
|
+
"skipFiles": [
|
|
33
|
+
"<node_internals>/**"
|
|
34
|
+
],
|
|
35
|
+
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
|
|
36
|
+
"cwd": "${workspaceFolder}",
|
|
37
|
+
"args": ["test/poseidoncircuit.js"]
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"type": "pwa-node",
|
|
41
|
+
"request": "launch",
|
|
42
|
+
"name": "Test binsum",
|
|
43
|
+
"skipFiles": [
|
|
44
|
+
"<node_internals>/**"
|
|
45
|
+
],
|
|
46
|
+
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
|
|
47
|
+
"cwd": "${workspaceFolder}",
|
|
48
|
+
"args": ["test/binsum.js"]
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"type": "pwa-node",
|
|
52
|
+
"request": "launch",
|
|
53
|
+
"name": "Test babyjub",
|
|
54
|
+
"skipFiles": [
|
|
55
|
+
"<node_internals>/**"
|
|
56
|
+
],
|
|
57
|
+
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
|
|
58
|
+
"cwd": "${workspaceFolder}",
|
|
59
|
+
"args": ["test/babyjub.js"]
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
]
|
|
63
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# CircomLib
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
- This repository contains a library of circuit templates.
|
|
6
|
+
- All files are copyrighted under 2018 0KIMS association and part of the free software [circom](https://github.com/iden3/circom) (Zero Knowledge Circuit Compiler).
|
|
7
|
+
- You can read more about the circom language in [the circom documentation webpage](https://docs.circom.io/).
|
|
8
|
+
|
|
9
|
+
## Organisation
|
|
10
|
+
|
|
11
|
+
This respository contains 5 folders:
|
|
12
|
+
- `circuits`: it contains the implementation of different cryptographic primitives in circom language.
|
|
13
|
+
- `calcpedersenbases`: set of functions in JavaScript used to find a set of points in [Baby Jubjub](https://github.com/barryWhiteHat/baby_jubjub) elliptic curve that serve as basis for the [Pedersen Hash](https://github.com/zcash/zcash/issues/2234).
|
|
14
|
+
- `doc`: it contains some circuit schemes in ASCII (must be opened with Monodraw, an ASCII art editor for Mac).
|
|
15
|
+
- `src`: it contains similar implementation of circuits in JavaScript.
|
|
16
|
+
- `test`: tests.
|
|
17
|
+
|
|
18
|
+
A description of the specific circuit templates for the `circuit` folder will be soon updated.
|