├── .circleci └── config.yml ├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── src ├── compiler.mjs ├── index.mjs ├── r1csCompiler.mjs ├── r1csParser.mjs ├── r1csStark.mjs └── witnessBuilder.mjs └── test ├── bits.r1cs ├── epochKeyLite_main.r1cs ├── example.circom ├── example.r1cs ├── example1.asm ├── example1.test.mjs ├── exampleR1cs.test.mjs ├── operators.test.mjs └── r1csParser.test.mjs /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | 3 | workflows: 4 | test: 5 | jobs: 6 | - test-node: 7 | context: 8 | - org-global 9 | matrix: 10 | parameters: 11 | node-version: ["16", "18", "20"] 12 | 13 | orbs: 14 | node: circleci/node@5.1.0 15 | 16 | jobs: 17 | test-node: 18 | resource_class: medium 19 | parameters: 20 | node-version: 21 | type: string 22 | machine: 23 | image: ubuntu-2204:2022.04.1 24 | steps: 25 | - checkout 26 | - node/install: 27 | node-version: << parameters.node-version >> 28 | - run: 29 | name: Fetch rstark wasm 30 | command: | 31 | cd .. 32 | wget https://github.com/vimwitch/rstark/releases/download/alpha-1-goldilocks/rstark.tar.gz 33 | tar -xzf rstark.tar.gz 34 | mkdir rstark 35 | mv pkg rstark 36 | - run: 37 | name: Install Packages 38 | command: npm i 39 | - run: 40 | name: Test 41 | command: npm run test 42 | 43 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | *.tmp 4 | *.swp 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # circom-stark [![CircleCI](https://img.shields.io/circleci/build/github/vimwitch/circom-stark/main)](https://app.circleci.com/pipelines/github/vimwitch/circom-stark) 2 | 3 | A binding to make R1CS proofs using [rstark](https://github.com/vimwitch/rstark). 4 | 5 | ## About 6 | 7 | R1CS proofs are based on sets of constraints of the form `A*B - C = 0` where `A`, `B`, and `C` are scalar sums. We can take such a system and reduce it to a single constraint using a random linear combination. This reduces to a STARK proof with trace length 1 and 1 constraint. The proof speed is limited by the total number of variables (aka signals) in the R1CS. 8 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "circom-stark", 3 | "version": "0.0.1", 4 | "lockfileVersion": 2, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "circom-stark", 9 | "version": "0.0.1", 10 | "license": "MIT", 11 | "dependencies": { 12 | "rstark": "../rstark/pkg", 13 | "starkstark": "vimwitch/starkstark#main" 14 | }, 15 | "devDependencies": { 16 | "ava": "^5.3.1", 17 | "r1csfile": "^0.0.47" 18 | } 19 | }, 20 | "../rstark/pkg": { 21 | "name": "rstark", 22 | "version": "0.1.0" 23 | }, 24 | "node_modules/@iden3/bigarray": { 25 | "version": "0.0.2", 26 | "dev": true, 27 | "license": "GPL-3.0" 28 | }, 29 | "node_modules/@iden3/binfileutils": { 30 | "version": "0.0.11", 31 | "dev": true, 32 | "license": "GPL-3.0", 33 | "dependencies": { 34 | "fastfile": "0.0.20", 35 | "ffjavascript": "^0.2.48" 36 | } 37 | }, 38 | "node_modules/@noble/hashes": { 39 | "version": "1.3.2", 40 | "license": "MIT", 41 | "engines": { 42 | "node": ">= 16" 43 | }, 44 | "funding": { 45 | "url": "https://paulmillr.com/funding/" 46 | } 47 | }, 48 | "node_modules/@nodelib/fs.scandir": { 49 | "version": "2.1.5", 50 | "dev": true, 51 | "license": "MIT", 52 | "dependencies": { 53 | "@nodelib/fs.stat": "2.0.5", 54 | "run-parallel": "^1.1.9" 55 | }, 56 | "engines": { 57 | "node": ">= 8" 58 | } 59 | }, 60 | "node_modules/@nodelib/fs.stat": { 61 | "version": "2.0.5", 62 | "dev": true, 63 | "license": "MIT", 64 | "engines": { 65 | "node": ">= 8" 66 | } 67 | }, 68 | "node_modules/@nodelib/fs.walk": { 69 | "version": "1.2.8", 70 | "dev": true, 71 | "license": "MIT", 72 | "dependencies": { 73 | "@nodelib/fs.scandir": "2.1.5", 74 | "fastq": "^1.6.0" 75 | }, 76 | "engines": { 77 | "node": ">= 8" 78 | } 79 | }, 80 | "node_modules/acorn": { 81 | "version": "8.10.0", 82 | "dev": true, 83 | "license": "MIT", 84 | "bin": { 85 | "acorn": "bin/acorn" 86 | }, 87 | "engines": { 88 | "node": ">=0.4.0" 89 | } 90 | }, 91 | "node_modules/acorn-walk": { 92 | "version": "8.2.0", 93 | "dev": true, 94 | "license": "MIT", 95 | "engines": { 96 | "node": ">=0.4.0" 97 | } 98 | }, 99 | "node_modules/aggregate-error": { 100 | "version": "4.0.1", 101 | "dev": true, 102 | "license": "MIT", 103 | "dependencies": { 104 | "clean-stack": "^4.0.0", 105 | "indent-string": "^5.0.0" 106 | }, 107 | "engines": { 108 | "node": ">=12" 109 | }, 110 | "funding": { 111 | "url": "https://github.com/sponsors/sindresorhus" 112 | } 113 | }, 114 | "node_modules/ansi-regex": { 115 | "version": "6.0.1", 116 | "dev": true, 117 | "license": "MIT", 118 | "engines": { 119 | "node": ">=12" 120 | }, 121 | "funding": { 122 | "url": "https://github.com/chalk/ansi-regex?sponsor=1" 123 | } 124 | }, 125 | "node_modules/ansi-styles": { 126 | "version": "6.2.1", 127 | "dev": true, 128 | "license": "MIT", 129 | "engines": { 130 | "node": ">=12" 131 | }, 132 | "funding": { 133 | "url": "https://github.com/chalk/ansi-styles?sponsor=1" 134 | } 135 | }, 136 | "node_modules/anymatch": { 137 | "version": "3.1.3", 138 | "dev": true, 139 | "license": "ISC", 140 | "dependencies": { 141 | "normalize-path": "^3.0.0", 142 | "picomatch": "^2.0.4" 143 | }, 144 | "engines": { 145 | "node": ">= 8" 146 | } 147 | }, 148 | "node_modules/argparse": { 149 | "version": "1.0.10", 150 | "dev": true, 151 | "license": "MIT", 152 | "dependencies": { 153 | "sprintf-js": "~1.0.2" 154 | } 155 | }, 156 | "node_modules/array-find-index": { 157 | "version": "1.0.2", 158 | "dev": true, 159 | "license": "MIT", 160 | "engines": { 161 | "node": ">=0.10.0" 162 | } 163 | }, 164 | "node_modules/arrgv": { 165 | "version": "1.0.2", 166 | "dev": true, 167 | "license": "MIT", 168 | "engines": { 169 | "node": ">=8.0.0" 170 | } 171 | }, 172 | "node_modules/arrify": { 173 | "version": "3.0.0", 174 | "dev": true, 175 | "license": "MIT", 176 | "engines": { 177 | "node": ">=12" 178 | }, 179 | "funding": { 180 | "url": "https://github.com/sponsors/sindresorhus" 181 | } 182 | }, 183 | "node_modules/ava": { 184 | "version": "5.3.1", 185 | "dev": true, 186 | "license": "MIT", 187 | "dependencies": { 188 | "acorn": "^8.8.2", 189 | "acorn-walk": "^8.2.0", 190 | "ansi-styles": "^6.2.1", 191 | "arrgv": "^1.0.2", 192 | "arrify": "^3.0.0", 193 | "callsites": "^4.0.0", 194 | "cbor": "^8.1.0", 195 | "chalk": "^5.2.0", 196 | "chokidar": "^3.5.3", 197 | "chunkd": "^2.0.1", 198 | "ci-info": "^3.8.0", 199 | "ci-parallel-vars": "^1.0.1", 200 | "clean-yaml-object": "^0.1.0", 201 | "cli-truncate": "^3.1.0", 202 | "code-excerpt": "^4.0.0", 203 | "common-path-prefix": "^3.0.0", 204 | "concordance": "^5.0.4", 205 | "currently-unhandled": "^0.4.1", 206 | "debug": "^4.3.4", 207 | "emittery": "^1.0.1", 208 | "figures": "^5.0.0", 209 | "globby": "^13.1.4", 210 | "ignore-by-default": "^2.1.0", 211 | "indent-string": "^5.0.0", 212 | "is-error": "^2.2.2", 213 | "is-plain-object": "^5.0.0", 214 | "is-promise": "^4.0.0", 215 | "matcher": "^5.0.0", 216 | "mem": "^9.0.2", 217 | "ms": "^2.1.3", 218 | "p-event": "^5.0.1", 219 | "p-map": "^5.5.0", 220 | "picomatch": "^2.3.1", 221 | "pkg-conf": "^4.0.0", 222 | "plur": "^5.1.0", 223 | "pretty-ms": "^8.0.0", 224 | "resolve-cwd": "^3.0.0", 225 | "stack-utils": "^2.0.6", 226 | "strip-ansi": "^7.0.1", 227 | "supertap": "^3.0.1", 228 | "temp-dir": "^3.0.0", 229 | "write-file-atomic": "^5.0.1", 230 | "yargs": "^17.7.2" 231 | }, 232 | "bin": { 233 | "ava": "entrypoints/cli.mjs" 234 | }, 235 | "engines": { 236 | "node": ">=14.19 <15 || >=16.15 <17 || >=18" 237 | }, 238 | "peerDependencies": { 239 | "@ava/typescript": "*" 240 | }, 241 | "peerDependenciesMeta": { 242 | "@ava/typescript": { 243 | "optional": true 244 | } 245 | } 246 | }, 247 | "node_modules/binary-extensions": { 248 | "version": "2.2.0", 249 | "dev": true, 250 | "license": "MIT", 251 | "engines": { 252 | "node": ">=8" 253 | } 254 | }, 255 | "node_modules/blueimp-md5": { 256 | "version": "2.19.0", 257 | "dev": true, 258 | "license": "MIT" 259 | }, 260 | "node_modules/braces": { 261 | "version": "3.0.2", 262 | "dev": true, 263 | "license": "MIT", 264 | "dependencies": { 265 | "fill-range": "^7.0.1" 266 | }, 267 | "engines": { 268 | "node": ">=8" 269 | } 270 | }, 271 | "node_modules/callsites": { 272 | "version": "4.1.0", 273 | "dev": true, 274 | "license": "MIT", 275 | "engines": { 276 | "node": ">=12.20" 277 | }, 278 | "funding": { 279 | "url": "https://github.com/sponsors/sindresorhus" 280 | } 281 | }, 282 | "node_modules/cbor": { 283 | "version": "8.1.0", 284 | "dev": true, 285 | "license": "MIT", 286 | "dependencies": { 287 | "nofilter": "^3.1.0" 288 | }, 289 | "engines": { 290 | "node": ">=12.19" 291 | } 292 | }, 293 | "node_modules/chalk": { 294 | "version": "5.3.0", 295 | "dev": true, 296 | "license": "MIT", 297 | "engines": { 298 | "node": "^12.17.0 || ^14.13 || >=16.0.0" 299 | }, 300 | "funding": { 301 | "url": "https://github.com/chalk/chalk?sponsor=1" 302 | } 303 | }, 304 | "node_modules/chokidar": { 305 | "version": "3.5.3", 306 | "dev": true, 307 | "funding": [ 308 | { 309 | "type": "individual", 310 | "url": "https://paulmillr.com/funding/" 311 | } 312 | ], 313 | "license": "MIT", 314 | "dependencies": { 315 | "anymatch": "~3.1.2", 316 | "braces": "~3.0.2", 317 | "glob-parent": "~5.1.2", 318 | "is-binary-path": "~2.1.0", 319 | "is-glob": "~4.0.1", 320 | "normalize-path": "~3.0.0", 321 | "readdirp": "~3.6.0" 322 | }, 323 | "engines": { 324 | "node": ">= 8.10.0" 325 | }, 326 | "optionalDependencies": { 327 | "fsevents": "~2.3.2" 328 | } 329 | }, 330 | "node_modules/chunkd": { 331 | "version": "2.0.1", 332 | "dev": true, 333 | "license": "MIT" 334 | }, 335 | "node_modules/ci-info": { 336 | "version": "3.8.0", 337 | "dev": true, 338 | "funding": [ 339 | { 340 | "type": "github", 341 | "url": "https://github.com/sponsors/sibiraj-s" 342 | } 343 | ], 344 | "license": "MIT", 345 | "engines": { 346 | "node": ">=8" 347 | } 348 | }, 349 | "node_modules/ci-parallel-vars": { 350 | "version": "1.0.1", 351 | "dev": true, 352 | "license": "MIT" 353 | }, 354 | "node_modules/clean-stack": { 355 | "version": "4.2.0", 356 | "dev": true, 357 | "license": "MIT", 358 | "dependencies": { 359 | "escape-string-regexp": "5.0.0" 360 | }, 361 | "engines": { 362 | "node": ">=12" 363 | }, 364 | "funding": { 365 | "url": "https://github.com/sponsors/sindresorhus" 366 | } 367 | }, 368 | "node_modules/clean-yaml-object": { 369 | "version": "0.1.0", 370 | "dev": true, 371 | "license": "MIT", 372 | "engines": { 373 | "node": ">=0.10.0" 374 | } 375 | }, 376 | "node_modules/cli-truncate": { 377 | "version": "3.1.0", 378 | "dev": true, 379 | "license": "MIT", 380 | "dependencies": { 381 | "slice-ansi": "^5.0.0", 382 | "string-width": "^5.0.0" 383 | }, 384 | "engines": { 385 | "node": "^12.20.0 || ^14.13.1 || >=16.0.0" 386 | }, 387 | "funding": { 388 | "url": "https://github.com/sponsors/sindresorhus" 389 | } 390 | }, 391 | "node_modules/cliui": { 392 | "version": "8.0.1", 393 | "dev": true, 394 | "license": "ISC", 395 | "dependencies": { 396 | "string-width": "^4.2.0", 397 | "strip-ansi": "^6.0.1", 398 | "wrap-ansi": "^7.0.0" 399 | }, 400 | "engines": { 401 | "node": ">=12" 402 | } 403 | }, 404 | "node_modules/cliui/node_modules/ansi-regex": { 405 | "version": "5.0.1", 406 | "dev": true, 407 | "license": "MIT", 408 | "engines": { 409 | "node": ">=8" 410 | } 411 | }, 412 | "node_modules/cliui/node_modules/emoji-regex": { 413 | "version": "8.0.0", 414 | "dev": true, 415 | "license": "MIT" 416 | }, 417 | "node_modules/cliui/node_modules/is-fullwidth-code-point": { 418 | "version": "3.0.0", 419 | "dev": true, 420 | "license": "MIT", 421 | "engines": { 422 | "node": ">=8" 423 | } 424 | }, 425 | "node_modules/cliui/node_modules/string-width": { 426 | "version": "4.2.3", 427 | "dev": true, 428 | "license": "MIT", 429 | "dependencies": { 430 | "emoji-regex": "^8.0.0", 431 | "is-fullwidth-code-point": "^3.0.0", 432 | "strip-ansi": "^6.0.1" 433 | }, 434 | "engines": { 435 | "node": ">=8" 436 | } 437 | }, 438 | "node_modules/cliui/node_modules/strip-ansi": { 439 | "version": "6.0.1", 440 | "dev": true, 441 | "license": "MIT", 442 | "dependencies": { 443 | "ansi-regex": "^5.0.1" 444 | }, 445 | "engines": { 446 | "node": ">=8" 447 | } 448 | }, 449 | "node_modules/code-excerpt": { 450 | "version": "4.0.0", 451 | "dev": true, 452 | "license": "MIT", 453 | "dependencies": { 454 | "convert-to-spaces": "^2.0.1" 455 | }, 456 | "engines": { 457 | "node": "^12.20.0 || ^14.13.1 || >=16.0.0" 458 | } 459 | }, 460 | "node_modules/color-convert": { 461 | "version": "2.0.1", 462 | "dev": true, 463 | "license": "MIT", 464 | "dependencies": { 465 | "color-name": "~1.1.4" 466 | }, 467 | "engines": { 468 | "node": ">=7.0.0" 469 | } 470 | }, 471 | "node_modules/color-name": { 472 | "version": "1.1.4", 473 | "dev": true, 474 | "license": "MIT" 475 | }, 476 | "node_modules/common-path-prefix": { 477 | "version": "3.0.0", 478 | "dev": true, 479 | "license": "ISC" 480 | }, 481 | "node_modules/concordance": { 482 | "version": "5.0.4", 483 | "dev": true, 484 | "license": "ISC", 485 | "dependencies": { 486 | "date-time": "^3.1.0", 487 | "esutils": "^2.0.3", 488 | "fast-diff": "^1.2.0", 489 | "js-string-escape": "^1.0.1", 490 | "lodash": "^4.17.15", 491 | "md5-hex": "^3.0.1", 492 | "semver": "^7.3.2", 493 | "well-known-symbols": "^2.0.0" 494 | }, 495 | "engines": { 496 | "node": ">=10.18.0 <11 || >=12.14.0 <13 || >=14" 497 | } 498 | }, 499 | "node_modules/convert-to-spaces": { 500 | "version": "2.0.1", 501 | "dev": true, 502 | "license": "MIT", 503 | "engines": { 504 | "node": "^12.20.0 || ^14.13.1 || >=16.0.0" 505 | } 506 | }, 507 | "node_modules/currently-unhandled": { 508 | "version": "0.4.1", 509 | "dev": true, 510 | "license": "MIT", 511 | "dependencies": { 512 | "array-find-index": "^1.0.1" 513 | }, 514 | "engines": { 515 | "node": ">=0.10.0" 516 | } 517 | }, 518 | "node_modules/date-time": { 519 | "version": "3.1.0", 520 | "dev": true, 521 | "license": "MIT", 522 | "dependencies": { 523 | "time-zone": "^1.0.0" 524 | }, 525 | "engines": { 526 | "node": ">=6" 527 | } 528 | }, 529 | "node_modules/debug": { 530 | "version": "4.3.4", 531 | "dev": true, 532 | "license": "MIT", 533 | "dependencies": { 534 | "ms": "2.1.2" 535 | }, 536 | "engines": { 537 | "node": ">=6.0" 538 | }, 539 | "peerDependenciesMeta": { 540 | "supports-color": { 541 | "optional": true 542 | } 543 | } 544 | }, 545 | "node_modules/debug/node_modules/ms": { 546 | "version": "2.1.2", 547 | "dev": true, 548 | "license": "MIT" 549 | }, 550 | "node_modules/dir-glob": { 551 | "version": "3.0.1", 552 | "dev": true, 553 | "license": "MIT", 554 | "dependencies": { 555 | "path-type": "^4.0.0" 556 | }, 557 | "engines": { 558 | "node": ">=8" 559 | } 560 | }, 561 | "node_modules/eastasianwidth": { 562 | "version": "0.2.0", 563 | "dev": true, 564 | "license": "MIT" 565 | }, 566 | "node_modules/emittery": { 567 | "version": "1.0.1", 568 | "dev": true, 569 | "license": "MIT", 570 | "engines": { 571 | "node": ">=14.16" 572 | }, 573 | "funding": { 574 | "url": "https://github.com/sindresorhus/emittery?sponsor=1" 575 | } 576 | }, 577 | "node_modules/emoji-regex": { 578 | "version": "9.2.2", 579 | "dev": true, 580 | "license": "MIT" 581 | }, 582 | "node_modules/escalade": { 583 | "version": "3.1.1", 584 | "dev": true, 585 | "license": "MIT", 586 | "engines": { 587 | "node": ">=6" 588 | } 589 | }, 590 | "node_modules/escape-string-regexp": { 591 | "version": "5.0.0", 592 | "dev": true, 593 | "license": "MIT", 594 | "engines": { 595 | "node": ">=12" 596 | }, 597 | "funding": { 598 | "url": "https://github.com/sponsors/sindresorhus" 599 | } 600 | }, 601 | "node_modules/esprima": { 602 | "version": "4.0.1", 603 | "dev": true, 604 | "license": "BSD-2-Clause", 605 | "bin": { 606 | "esparse": "bin/esparse.js", 607 | "esvalidate": "bin/esvalidate.js" 608 | }, 609 | "engines": { 610 | "node": ">=4" 611 | } 612 | }, 613 | "node_modules/esutils": { 614 | "version": "2.0.3", 615 | "dev": true, 616 | "license": "BSD-2-Clause", 617 | "engines": { 618 | "node": ">=0.10.0" 619 | } 620 | }, 621 | "node_modules/fast-diff": { 622 | "version": "1.3.0", 623 | "dev": true, 624 | "license": "Apache-2.0" 625 | }, 626 | "node_modules/fast-glob": { 627 | "version": "3.3.1", 628 | "dev": true, 629 | "license": "MIT", 630 | "dependencies": { 631 | "@nodelib/fs.stat": "^2.0.2", 632 | "@nodelib/fs.walk": "^1.2.3", 633 | "glob-parent": "^5.1.2", 634 | "merge2": "^1.3.0", 635 | "micromatch": "^4.0.4" 636 | }, 637 | "engines": { 638 | "node": ">=8.6.0" 639 | } 640 | }, 641 | "node_modules/fastfile": { 642 | "version": "0.0.20", 643 | "dev": true, 644 | "license": "GPL-3.0" 645 | }, 646 | "node_modules/fastq": { 647 | "version": "1.15.0", 648 | "dev": true, 649 | "license": "ISC", 650 | "dependencies": { 651 | "reusify": "^1.0.4" 652 | } 653 | }, 654 | "node_modules/ffjavascript": { 655 | "version": "0.2.60", 656 | "dev": true, 657 | "license": "GPL-3.0", 658 | "dependencies": { 659 | "wasmbuilder": "0.0.16", 660 | "wasmcurves": "0.2.2", 661 | "web-worker": "^1.2.0" 662 | } 663 | }, 664 | "node_modules/figures": { 665 | "version": "5.0.0", 666 | "dev": true, 667 | "license": "MIT", 668 | "dependencies": { 669 | "escape-string-regexp": "^5.0.0", 670 | "is-unicode-supported": "^1.2.0" 671 | }, 672 | "engines": { 673 | "node": ">=14" 674 | }, 675 | "funding": { 676 | "url": "https://github.com/sponsors/sindresorhus" 677 | } 678 | }, 679 | "node_modules/fill-range": { 680 | "version": "7.0.1", 681 | "dev": true, 682 | "license": "MIT", 683 | "dependencies": { 684 | "to-regex-range": "^5.0.1" 685 | }, 686 | "engines": { 687 | "node": ">=8" 688 | } 689 | }, 690 | "node_modules/find-up": { 691 | "version": "6.3.0", 692 | "dev": true, 693 | "license": "MIT", 694 | "dependencies": { 695 | "locate-path": "^7.1.0", 696 | "path-exists": "^5.0.0" 697 | }, 698 | "engines": { 699 | "node": "^12.20.0 || ^14.13.1 || >=16.0.0" 700 | }, 701 | "funding": { 702 | "url": "https://github.com/sponsors/sindresorhus" 703 | } 704 | }, 705 | "node_modules/fsevents": { 706 | "version": "2.3.3", 707 | "dev": true, 708 | "license": "MIT", 709 | "optional": true, 710 | "os": [ 711 | "darwin" 712 | ], 713 | "engines": { 714 | "node": "^8.16.0 || ^10.6.0 || >=11.0.0" 715 | } 716 | }, 717 | "node_modules/get-caller-file": { 718 | "version": "2.0.5", 719 | "dev": true, 720 | "license": "ISC", 721 | "engines": { 722 | "node": "6.* || 8.* || >= 10.*" 723 | } 724 | }, 725 | "node_modules/glob-parent": { 726 | "version": "5.1.2", 727 | "dev": true, 728 | "license": "ISC", 729 | "dependencies": { 730 | "is-glob": "^4.0.1" 731 | }, 732 | "engines": { 733 | "node": ">= 6" 734 | } 735 | }, 736 | "node_modules/globby": { 737 | "version": "13.2.2", 738 | "dev": true, 739 | "license": "MIT", 740 | "dependencies": { 741 | "dir-glob": "^3.0.1", 742 | "fast-glob": "^3.3.0", 743 | "ignore": "^5.2.4", 744 | "merge2": "^1.4.1", 745 | "slash": "^4.0.0" 746 | }, 747 | "engines": { 748 | "node": "^12.20.0 || ^14.13.1 || >=16.0.0" 749 | }, 750 | "funding": { 751 | "url": "https://github.com/sponsors/sindresorhus" 752 | } 753 | }, 754 | "node_modules/ignore": { 755 | "version": "5.2.4", 756 | "dev": true, 757 | "license": "MIT", 758 | "engines": { 759 | "node": ">= 4" 760 | } 761 | }, 762 | "node_modules/ignore-by-default": { 763 | "version": "2.1.0", 764 | "dev": true, 765 | "license": "ISC", 766 | "engines": { 767 | "node": ">=10 <11 || >=12 <13 || >=14" 768 | } 769 | }, 770 | "node_modules/imurmurhash": { 771 | "version": "0.1.4", 772 | "dev": true, 773 | "license": "MIT", 774 | "engines": { 775 | "node": ">=0.8.19" 776 | } 777 | }, 778 | "node_modules/indent-string": { 779 | "version": "5.0.0", 780 | "dev": true, 781 | "license": "MIT", 782 | "engines": { 783 | "node": ">=12" 784 | }, 785 | "funding": { 786 | "url": "https://github.com/sponsors/sindresorhus" 787 | } 788 | }, 789 | "node_modules/irregular-plurals": { 790 | "version": "3.5.0", 791 | "dev": true, 792 | "license": "MIT", 793 | "engines": { 794 | "node": ">=8" 795 | } 796 | }, 797 | "node_modules/is-binary-path": { 798 | "version": "2.1.0", 799 | "dev": true, 800 | "license": "MIT", 801 | "dependencies": { 802 | "binary-extensions": "^2.0.0" 803 | }, 804 | "engines": { 805 | "node": ">=8" 806 | } 807 | }, 808 | "node_modules/is-error": { 809 | "version": "2.2.2", 810 | "dev": true, 811 | "license": "MIT" 812 | }, 813 | "node_modules/is-extglob": { 814 | "version": "2.1.1", 815 | "dev": true, 816 | "license": "MIT", 817 | "engines": { 818 | "node": ">=0.10.0" 819 | } 820 | }, 821 | "node_modules/is-fullwidth-code-point": { 822 | "version": "4.0.0", 823 | "dev": true, 824 | "license": "MIT", 825 | "engines": { 826 | "node": ">=12" 827 | }, 828 | "funding": { 829 | "url": "https://github.com/sponsors/sindresorhus" 830 | } 831 | }, 832 | "node_modules/is-glob": { 833 | "version": "4.0.3", 834 | "dev": true, 835 | "license": "MIT", 836 | "dependencies": { 837 | "is-extglob": "^2.1.1" 838 | }, 839 | "engines": { 840 | "node": ">=0.10.0" 841 | } 842 | }, 843 | "node_modules/is-number": { 844 | "version": "7.0.0", 845 | "dev": true, 846 | "license": "MIT", 847 | "engines": { 848 | "node": ">=0.12.0" 849 | } 850 | }, 851 | "node_modules/is-plain-object": { 852 | "version": "5.0.0", 853 | "dev": true, 854 | "license": "MIT", 855 | "engines": { 856 | "node": ">=0.10.0" 857 | } 858 | }, 859 | "node_modules/is-promise": { 860 | "version": "4.0.0", 861 | "dev": true, 862 | "license": "MIT" 863 | }, 864 | "node_modules/is-unicode-supported": { 865 | "version": "1.3.0", 866 | "dev": true, 867 | "license": "MIT", 868 | "engines": { 869 | "node": ">=12" 870 | }, 871 | "funding": { 872 | "url": "https://github.com/sponsors/sindresorhus" 873 | } 874 | }, 875 | "node_modules/js-string-escape": { 876 | "version": "1.0.1", 877 | "dev": true, 878 | "license": "MIT", 879 | "engines": { 880 | "node": ">= 0.8" 881 | } 882 | }, 883 | "node_modules/js-yaml": { 884 | "version": "3.14.1", 885 | "dev": true, 886 | "license": "MIT", 887 | "dependencies": { 888 | "argparse": "^1.0.7", 889 | "esprima": "^4.0.0" 890 | }, 891 | "bin": { 892 | "js-yaml": "bin/js-yaml.js" 893 | } 894 | }, 895 | "node_modules/load-json-file": { 896 | "version": "7.0.1", 897 | "dev": true, 898 | "license": "MIT", 899 | "engines": { 900 | "node": "^12.20.0 || ^14.13.1 || >=16.0.0" 901 | }, 902 | "funding": { 903 | "url": "https://github.com/sponsors/sindresorhus" 904 | } 905 | }, 906 | "node_modules/locate-path": { 907 | "version": "7.2.0", 908 | "dev": true, 909 | "license": "MIT", 910 | "dependencies": { 911 | "p-locate": "^6.0.0" 912 | }, 913 | "engines": { 914 | "node": "^12.20.0 || ^14.13.1 || >=16.0.0" 915 | }, 916 | "funding": { 917 | "url": "https://github.com/sponsors/sindresorhus" 918 | } 919 | }, 920 | "node_modules/lodash": { 921 | "version": "4.17.21", 922 | "dev": true, 923 | "license": "MIT" 924 | }, 925 | "node_modules/lru-cache": { 926 | "version": "6.0.0", 927 | "dev": true, 928 | "license": "ISC", 929 | "dependencies": { 930 | "yallist": "^4.0.0" 931 | }, 932 | "engines": { 933 | "node": ">=10" 934 | } 935 | }, 936 | "node_modules/map-age-cleaner": { 937 | "version": "0.1.3", 938 | "dev": true, 939 | "license": "MIT", 940 | "dependencies": { 941 | "p-defer": "^1.0.0" 942 | }, 943 | "engines": { 944 | "node": ">=6" 945 | } 946 | }, 947 | "node_modules/matcher": { 948 | "version": "5.0.0", 949 | "dev": true, 950 | "license": "MIT", 951 | "dependencies": { 952 | "escape-string-regexp": "^5.0.0" 953 | }, 954 | "engines": { 955 | "node": "^12.20.0 || ^14.13.1 || >=16.0.0" 956 | }, 957 | "funding": { 958 | "url": "https://github.com/sponsors/sindresorhus" 959 | } 960 | }, 961 | "node_modules/md5-hex": { 962 | "version": "3.0.1", 963 | "dev": true, 964 | "license": "MIT", 965 | "dependencies": { 966 | "blueimp-md5": "^2.10.0" 967 | }, 968 | "engines": { 969 | "node": ">=8" 970 | } 971 | }, 972 | "node_modules/mem": { 973 | "version": "9.0.2", 974 | "dev": true, 975 | "license": "MIT", 976 | "dependencies": { 977 | "map-age-cleaner": "^0.1.3", 978 | "mimic-fn": "^4.0.0" 979 | }, 980 | "engines": { 981 | "node": ">=12.20" 982 | }, 983 | "funding": { 984 | "url": "https://github.com/sindresorhus/mem?sponsor=1" 985 | } 986 | }, 987 | "node_modules/merge2": { 988 | "version": "1.4.1", 989 | "dev": true, 990 | "license": "MIT", 991 | "engines": { 992 | "node": ">= 8" 993 | } 994 | }, 995 | "node_modules/micromatch": { 996 | "version": "4.0.5", 997 | "dev": true, 998 | "license": "MIT", 999 | "dependencies": { 1000 | "braces": "^3.0.2", 1001 | "picomatch": "^2.3.1" 1002 | }, 1003 | "engines": { 1004 | "node": ">=8.6" 1005 | } 1006 | }, 1007 | "node_modules/mimic-fn": { 1008 | "version": "4.0.0", 1009 | "dev": true, 1010 | "license": "MIT", 1011 | "engines": { 1012 | "node": ">=12" 1013 | }, 1014 | "funding": { 1015 | "url": "https://github.com/sponsors/sindresorhus" 1016 | } 1017 | }, 1018 | "node_modules/ms": { 1019 | "version": "2.1.3", 1020 | "dev": true, 1021 | "license": "MIT" 1022 | }, 1023 | "node_modules/nofilter": { 1024 | "version": "3.1.0", 1025 | "dev": true, 1026 | "license": "MIT", 1027 | "engines": { 1028 | "node": ">=12.19" 1029 | } 1030 | }, 1031 | "node_modules/normalize-path": { 1032 | "version": "3.0.0", 1033 | "dev": true, 1034 | "license": "MIT", 1035 | "engines": { 1036 | "node": ">=0.10.0" 1037 | } 1038 | }, 1039 | "node_modules/p-defer": { 1040 | "version": "1.0.0", 1041 | "dev": true, 1042 | "license": "MIT", 1043 | "engines": { 1044 | "node": ">=4" 1045 | } 1046 | }, 1047 | "node_modules/p-event": { 1048 | "version": "5.0.1", 1049 | "dev": true, 1050 | "license": "MIT", 1051 | "dependencies": { 1052 | "p-timeout": "^5.0.2" 1053 | }, 1054 | "engines": { 1055 | "node": "^12.20.0 || ^14.13.1 || >=16.0.0" 1056 | }, 1057 | "funding": { 1058 | "url": "https://github.com/sponsors/sindresorhus" 1059 | } 1060 | }, 1061 | "node_modules/p-limit": { 1062 | "version": "4.0.0", 1063 | "dev": true, 1064 | "license": "MIT", 1065 | "dependencies": { 1066 | "yocto-queue": "^1.0.0" 1067 | }, 1068 | "engines": { 1069 | "node": "^12.20.0 || ^14.13.1 || >=16.0.0" 1070 | }, 1071 | "funding": { 1072 | "url": "https://github.com/sponsors/sindresorhus" 1073 | } 1074 | }, 1075 | "node_modules/p-locate": { 1076 | "version": "6.0.0", 1077 | "dev": true, 1078 | "license": "MIT", 1079 | "dependencies": { 1080 | "p-limit": "^4.0.0" 1081 | }, 1082 | "engines": { 1083 | "node": "^12.20.0 || ^14.13.1 || >=16.0.0" 1084 | }, 1085 | "funding": { 1086 | "url": "https://github.com/sponsors/sindresorhus" 1087 | } 1088 | }, 1089 | "node_modules/p-map": { 1090 | "version": "5.5.0", 1091 | "dev": true, 1092 | "license": "MIT", 1093 | "dependencies": { 1094 | "aggregate-error": "^4.0.0" 1095 | }, 1096 | "engines": { 1097 | "node": ">=12" 1098 | }, 1099 | "funding": { 1100 | "url": "https://github.com/sponsors/sindresorhus" 1101 | } 1102 | }, 1103 | "node_modules/p-timeout": { 1104 | "version": "5.1.0", 1105 | "dev": true, 1106 | "license": "MIT", 1107 | "engines": { 1108 | "node": ">=12" 1109 | }, 1110 | "funding": { 1111 | "url": "https://github.com/sponsors/sindresorhus" 1112 | } 1113 | }, 1114 | "node_modules/parse-ms": { 1115 | "version": "3.0.0", 1116 | "dev": true, 1117 | "license": "MIT", 1118 | "engines": { 1119 | "node": ">=12" 1120 | }, 1121 | "funding": { 1122 | "url": "https://github.com/sponsors/sindresorhus" 1123 | } 1124 | }, 1125 | "node_modules/path-exists": { 1126 | "version": "5.0.0", 1127 | "dev": true, 1128 | "license": "MIT", 1129 | "engines": { 1130 | "node": "^12.20.0 || ^14.13.1 || >=16.0.0" 1131 | } 1132 | }, 1133 | "node_modules/path-type": { 1134 | "version": "4.0.0", 1135 | "dev": true, 1136 | "license": "MIT", 1137 | "engines": { 1138 | "node": ">=8" 1139 | } 1140 | }, 1141 | "node_modules/picomatch": { 1142 | "version": "2.3.1", 1143 | "dev": true, 1144 | "license": "MIT", 1145 | "engines": { 1146 | "node": ">=8.6" 1147 | }, 1148 | "funding": { 1149 | "url": "https://github.com/sponsors/jonschlinkert" 1150 | } 1151 | }, 1152 | "node_modules/pkg-conf": { 1153 | "version": "4.0.0", 1154 | "dev": true, 1155 | "license": "MIT", 1156 | "dependencies": { 1157 | "find-up": "^6.0.0", 1158 | "load-json-file": "^7.0.0" 1159 | }, 1160 | "engines": { 1161 | "node": "^12.20.0 || ^14.13.1 || >=16.0.0" 1162 | }, 1163 | "funding": { 1164 | "url": "https://github.com/sponsors/sindresorhus" 1165 | } 1166 | }, 1167 | "node_modules/plur": { 1168 | "version": "5.1.0", 1169 | "dev": true, 1170 | "license": "MIT", 1171 | "dependencies": { 1172 | "irregular-plurals": "^3.3.0" 1173 | }, 1174 | "engines": { 1175 | "node": "^12.20.0 || ^14.13.1 || >=16.0.0" 1176 | }, 1177 | "funding": { 1178 | "url": "https://github.com/sponsors/sindresorhus" 1179 | } 1180 | }, 1181 | "node_modules/pretty-ms": { 1182 | "version": "8.0.0", 1183 | "dev": true, 1184 | "license": "MIT", 1185 | "dependencies": { 1186 | "parse-ms": "^3.0.0" 1187 | }, 1188 | "engines": { 1189 | "node": ">=14.16" 1190 | }, 1191 | "funding": { 1192 | "url": "https://github.com/sponsors/sindresorhus" 1193 | } 1194 | }, 1195 | "node_modules/queue-microtask": { 1196 | "version": "1.2.3", 1197 | "dev": true, 1198 | "funding": [ 1199 | { 1200 | "type": "github", 1201 | "url": "https://github.com/sponsors/feross" 1202 | }, 1203 | { 1204 | "type": "patreon", 1205 | "url": "https://www.patreon.com/feross" 1206 | }, 1207 | { 1208 | "type": "consulting", 1209 | "url": "https://feross.org/support" 1210 | } 1211 | ], 1212 | "license": "MIT" 1213 | }, 1214 | "node_modules/r1csfile": { 1215 | "version": "0.0.47", 1216 | "dev": true, 1217 | "license": "GPL-3.0", 1218 | "dependencies": { 1219 | "@iden3/bigarray": "0.0.2", 1220 | "@iden3/binfileutils": "0.0.11", 1221 | "fastfile": "0.0.20", 1222 | "ffjavascript": "0.2.60" 1223 | } 1224 | }, 1225 | "node_modules/randomf": { 1226 | "version": "0.0.3", 1227 | "license": "MIT" 1228 | }, 1229 | "node_modules/readdirp": { 1230 | "version": "3.6.0", 1231 | "dev": true, 1232 | "license": "MIT", 1233 | "dependencies": { 1234 | "picomatch": "^2.2.1" 1235 | }, 1236 | "engines": { 1237 | "node": ">=8.10.0" 1238 | } 1239 | }, 1240 | "node_modules/require-directory": { 1241 | "version": "2.1.1", 1242 | "dev": true, 1243 | "license": "MIT", 1244 | "engines": { 1245 | "node": ">=0.10.0" 1246 | } 1247 | }, 1248 | "node_modules/resolve-cwd": { 1249 | "version": "3.0.0", 1250 | "dev": true, 1251 | "license": "MIT", 1252 | "dependencies": { 1253 | "resolve-from": "^5.0.0" 1254 | }, 1255 | "engines": { 1256 | "node": ">=8" 1257 | } 1258 | }, 1259 | "node_modules/resolve-from": { 1260 | "version": "5.0.0", 1261 | "dev": true, 1262 | "license": "MIT", 1263 | "engines": { 1264 | "node": ">=8" 1265 | } 1266 | }, 1267 | "node_modules/reusify": { 1268 | "version": "1.0.4", 1269 | "dev": true, 1270 | "license": "MIT", 1271 | "engines": { 1272 | "iojs": ">=1.0.0", 1273 | "node": ">=0.10.0" 1274 | } 1275 | }, 1276 | "node_modules/rstark": { 1277 | "resolved": "../rstark/pkg", 1278 | "link": true 1279 | }, 1280 | "node_modules/run-parallel": { 1281 | "version": "1.2.0", 1282 | "dev": true, 1283 | "funding": [ 1284 | { 1285 | "type": "github", 1286 | "url": "https://github.com/sponsors/feross" 1287 | }, 1288 | { 1289 | "type": "patreon", 1290 | "url": "https://www.patreon.com/feross" 1291 | }, 1292 | { 1293 | "type": "consulting", 1294 | "url": "https://feross.org/support" 1295 | } 1296 | ], 1297 | "license": "MIT", 1298 | "dependencies": { 1299 | "queue-microtask": "^1.2.2" 1300 | } 1301 | }, 1302 | "node_modules/semver": { 1303 | "version": "7.5.4", 1304 | "dev": true, 1305 | "license": "ISC", 1306 | "dependencies": { 1307 | "lru-cache": "^6.0.0" 1308 | }, 1309 | "bin": { 1310 | "semver": "bin/semver.js" 1311 | }, 1312 | "engines": { 1313 | "node": ">=10" 1314 | } 1315 | }, 1316 | "node_modules/serialize-error": { 1317 | "version": "7.0.1", 1318 | "dev": true, 1319 | "license": "MIT", 1320 | "dependencies": { 1321 | "type-fest": "^0.13.1" 1322 | }, 1323 | "engines": { 1324 | "node": ">=10" 1325 | }, 1326 | "funding": { 1327 | "url": "https://github.com/sponsors/sindresorhus" 1328 | } 1329 | }, 1330 | "node_modules/signal-exit": { 1331 | "version": "4.1.0", 1332 | "dev": true, 1333 | "license": "ISC", 1334 | "engines": { 1335 | "node": ">=14" 1336 | }, 1337 | "funding": { 1338 | "url": "https://github.com/sponsors/isaacs" 1339 | } 1340 | }, 1341 | "node_modules/slash": { 1342 | "version": "4.0.0", 1343 | "dev": true, 1344 | "license": "MIT", 1345 | "engines": { 1346 | "node": ">=12" 1347 | }, 1348 | "funding": { 1349 | "url": "https://github.com/sponsors/sindresorhus" 1350 | } 1351 | }, 1352 | "node_modules/slice-ansi": { 1353 | "version": "5.0.0", 1354 | "dev": true, 1355 | "license": "MIT", 1356 | "dependencies": { 1357 | "ansi-styles": "^6.0.0", 1358 | "is-fullwidth-code-point": "^4.0.0" 1359 | }, 1360 | "engines": { 1361 | "node": ">=12" 1362 | }, 1363 | "funding": { 1364 | "url": "https://github.com/chalk/slice-ansi?sponsor=1" 1365 | } 1366 | }, 1367 | "node_modules/sprintf-js": { 1368 | "version": "1.0.3", 1369 | "dev": true, 1370 | "license": "BSD-3-Clause" 1371 | }, 1372 | "node_modules/stack-utils": { 1373 | "version": "2.0.6", 1374 | "dev": true, 1375 | "license": "MIT", 1376 | "dependencies": { 1377 | "escape-string-regexp": "^2.0.0" 1378 | }, 1379 | "engines": { 1380 | "node": ">=10" 1381 | } 1382 | }, 1383 | "node_modules/stack-utils/node_modules/escape-string-regexp": { 1384 | "version": "2.0.0", 1385 | "dev": true, 1386 | "license": "MIT", 1387 | "engines": { 1388 | "node": ">=8" 1389 | } 1390 | }, 1391 | "node_modules/starkstark": { 1392 | "version": "0.0.0", 1393 | "resolved": "git+ssh://git@github.com/vimwitch/starkstark.git#683bf06ef15882a67f86a26a33efedc5055df885", 1394 | "license": "ISC", 1395 | "dependencies": { 1396 | "@noble/hashes": "^1.3.1", 1397 | "randomf": "^0.0.3" 1398 | } 1399 | }, 1400 | "node_modules/string-width": { 1401 | "version": "5.1.2", 1402 | "dev": true, 1403 | "license": "MIT", 1404 | "dependencies": { 1405 | "eastasianwidth": "^0.2.0", 1406 | "emoji-regex": "^9.2.2", 1407 | "strip-ansi": "^7.0.1" 1408 | }, 1409 | "engines": { 1410 | "node": ">=12" 1411 | }, 1412 | "funding": { 1413 | "url": "https://github.com/sponsors/sindresorhus" 1414 | } 1415 | }, 1416 | "node_modules/strip-ansi": { 1417 | "version": "7.1.0", 1418 | "dev": true, 1419 | "license": "MIT", 1420 | "dependencies": { 1421 | "ansi-regex": "^6.0.1" 1422 | }, 1423 | "engines": { 1424 | "node": ">=12" 1425 | }, 1426 | "funding": { 1427 | "url": "https://github.com/chalk/strip-ansi?sponsor=1" 1428 | } 1429 | }, 1430 | "node_modules/supertap": { 1431 | "version": "3.0.1", 1432 | "dev": true, 1433 | "license": "MIT", 1434 | "dependencies": { 1435 | "indent-string": "^5.0.0", 1436 | "js-yaml": "^3.14.1", 1437 | "serialize-error": "^7.0.1", 1438 | "strip-ansi": "^7.0.1" 1439 | }, 1440 | "engines": { 1441 | "node": "^12.20.0 || ^14.13.1 || >=16.0.0" 1442 | } 1443 | }, 1444 | "node_modules/temp-dir": { 1445 | "version": "3.0.0", 1446 | "dev": true, 1447 | "license": "MIT", 1448 | "engines": { 1449 | "node": ">=14.16" 1450 | } 1451 | }, 1452 | "node_modules/time-zone": { 1453 | "version": "1.0.0", 1454 | "dev": true, 1455 | "license": "MIT", 1456 | "engines": { 1457 | "node": ">=4" 1458 | } 1459 | }, 1460 | "node_modules/to-regex-range": { 1461 | "version": "5.0.1", 1462 | "dev": true, 1463 | "license": "MIT", 1464 | "dependencies": { 1465 | "is-number": "^7.0.0" 1466 | }, 1467 | "engines": { 1468 | "node": ">=8.0" 1469 | } 1470 | }, 1471 | "node_modules/type-fest": { 1472 | "version": "0.13.1", 1473 | "dev": true, 1474 | "license": "(MIT OR CC0-1.0)", 1475 | "engines": { 1476 | "node": ">=10" 1477 | }, 1478 | "funding": { 1479 | "url": "https://github.com/sponsors/sindresorhus" 1480 | } 1481 | }, 1482 | "node_modules/wasmbuilder": { 1483 | "version": "0.0.16", 1484 | "dev": true, 1485 | "license": "GPL-3.0" 1486 | }, 1487 | "node_modules/wasmcurves": { 1488 | "version": "0.2.2", 1489 | "dev": true, 1490 | "license": "GPL-3.0", 1491 | "dependencies": { 1492 | "wasmbuilder": "0.0.16" 1493 | } 1494 | }, 1495 | "node_modules/web-worker": { 1496 | "version": "1.2.0", 1497 | "dev": true, 1498 | "license": "Apache-2.0" 1499 | }, 1500 | "node_modules/well-known-symbols": { 1501 | "version": "2.0.0", 1502 | "dev": true, 1503 | "license": "ISC", 1504 | "engines": { 1505 | "node": ">=6" 1506 | } 1507 | }, 1508 | "node_modules/wrap-ansi": { 1509 | "version": "7.0.0", 1510 | "dev": true, 1511 | "license": "MIT", 1512 | "dependencies": { 1513 | "ansi-styles": "^4.0.0", 1514 | "string-width": "^4.1.0", 1515 | "strip-ansi": "^6.0.0" 1516 | }, 1517 | "engines": { 1518 | "node": ">=10" 1519 | }, 1520 | "funding": { 1521 | "url": "https://github.com/chalk/wrap-ansi?sponsor=1" 1522 | } 1523 | }, 1524 | "node_modules/wrap-ansi/node_modules/ansi-regex": { 1525 | "version": "5.0.1", 1526 | "dev": true, 1527 | "license": "MIT", 1528 | "engines": { 1529 | "node": ">=8" 1530 | } 1531 | }, 1532 | "node_modules/wrap-ansi/node_modules/ansi-styles": { 1533 | "version": "4.3.0", 1534 | "dev": true, 1535 | "license": "MIT", 1536 | "dependencies": { 1537 | "color-convert": "^2.0.1" 1538 | }, 1539 | "engines": { 1540 | "node": ">=8" 1541 | }, 1542 | "funding": { 1543 | "url": "https://github.com/chalk/ansi-styles?sponsor=1" 1544 | } 1545 | }, 1546 | "node_modules/wrap-ansi/node_modules/emoji-regex": { 1547 | "version": "8.0.0", 1548 | "dev": true, 1549 | "license": "MIT" 1550 | }, 1551 | "node_modules/wrap-ansi/node_modules/is-fullwidth-code-point": { 1552 | "version": "3.0.0", 1553 | "dev": true, 1554 | "license": "MIT", 1555 | "engines": { 1556 | "node": ">=8" 1557 | } 1558 | }, 1559 | "node_modules/wrap-ansi/node_modules/string-width": { 1560 | "version": "4.2.3", 1561 | "dev": true, 1562 | "license": "MIT", 1563 | "dependencies": { 1564 | "emoji-regex": "^8.0.0", 1565 | "is-fullwidth-code-point": "^3.0.0", 1566 | "strip-ansi": "^6.0.1" 1567 | }, 1568 | "engines": { 1569 | "node": ">=8" 1570 | } 1571 | }, 1572 | "node_modules/wrap-ansi/node_modules/strip-ansi": { 1573 | "version": "6.0.1", 1574 | "dev": true, 1575 | "license": "MIT", 1576 | "dependencies": { 1577 | "ansi-regex": "^5.0.1" 1578 | }, 1579 | "engines": { 1580 | "node": ">=8" 1581 | } 1582 | }, 1583 | "node_modules/write-file-atomic": { 1584 | "version": "5.0.1", 1585 | "dev": true, 1586 | "license": "ISC", 1587 | "dependencies": { 1588 | "imurmurhash": "^0.1.4", 1589 | "signal-exit": "^4.0.1" 1590 | }, 1591 | "engines": { 1592 | "node": "^14.17.0 || ^16.13.0 || >=18.0.0" 1593 | } 1594 | }, 1595 | "node_modules/y18n": { 1596 | "version": "5.0.8", 1597 | "dev": true, 1598 | "license": "ISC", 1599 | "engines": { 1600 | "node": ">=10" 1601 | } 1602 | }, 1603 | "node_modules/yallist": { 1604 | "version": "4.0.0", 1605 | "dev": true, 1606 | "license": "ISC" 1607 | }, 1608 | "node_modules/yargs": { 1609 | "version": "17.7.2", 1610 | "dev": true, 1611 | "license": "MIT", 1612 | "dependencies": { 1613 | "cliui": "^8.0.1", 1614 | "escalade": "^3.1.1", 1615 | "get-caller-file": "^2.0.5", 1616 | "require-directory": "^2.1.1", 1617 | "string-width": "^4.2.3", 1618 | "y18n": "^5.0.5", 1619 | "yargs-parser": "^21.1.1" 1620 | }, 1621 | "engines": { 1622 | "node": ">=12" 1623 | } 1624 | }, 1625 | "node_modules/yargs-parser": { 1626 | "version": "21.1.1", 1627 | "dev": true, 1628 | "license": "ISC", 1629 | "engines": { 1630 | "node": ">=12" 1631 | } 1632 | }, 1633 | "node_modules/yargs/node_modules/ansi-regex": { 1634 | "version": "5.0.1", 1635 | "dev": true, 1636 | "license": "MIT", 1637 | "engines": { 1638 | "node": ">=8" 1639 | } 1640 | }, 1641 | "node_modules/yargs/node_modules/emoji-regex": { 1642 | "version": "8.0.0", 1643 | "dev": true, 1644 | "license": "MIT" 1645 | }, 1646 | "node_modules/yargs/node_modules/is-fullwidth-code-point": { 1647 | "version": "3.0.0", 1648 | "dev": true, 1649 | "license": "MIT", 1650 | "engines": { 1651 | "node": ">=8" 1652 | } 1653 | }, 1654 | "node_modules/yargs/node_modules/string-width": { 1655 | "version": "4.2.3", 1656 | "dev": true, 1657 | "license": "MIT", 1658 | "dependencies": { 1659 | "emoji-regex": "^8.0.0", 1660 | "is-fullwidth-code-point": "^3.0.0", 1661 | "strip-ansi": "^6.0.1" 1662 | }, 1663 | "engines": { 1664 | "node": ">=8" 1665 | } 1666 | }, 1667 | "node_modules/yargs/node_modules/strip-ansi": { 1668 | "version": "6.0.1", 1669 | "dev": true, 1670 | "license": "MIT", 1671 | "dependencies": { 1672 | "ansi-regex": "^5.0.1" 1673 | }, 1674 | "engines": { 1675 | "node": ">=8" 1676 | } 1677 | }, 1678 | "node_modules/yocto-queue": { 1679 | "version": "1.0.0", 1680 | "dev": true, 1681 | "license": "MIT", 1682 | "engines": { 1683 | "node": ">=12.20" 1684 | }, 1685 | "funding": { 1686 | "url": "https://github.com/sponsors/sindresorhus" 1687 | } 1688 | } 1689 | }, 1690 | "dependencies": { 1691 | "@iden3/bigarray": { 1692 | "version": "0.0.2", 1693 | "dev": true 1694 | }, 1695 | "@iden3/binfileutils": { 1696 | "version": "0.0.11", 1697 | "dev": true, 1698 | "requires": { 1699 | "fastfile": "0.0.20", 1700 | "ffjavascript": "^0.2.48" 1701 | } 1702 | }, 1703 | "@noble/hashes": { 1704 | "version": "1.3.2" 1705 | }, 1706 | "@nodelib/fs.scandir": { 1707 | "version": "2.1.5", 1708 | "dev": true, 1709 | "requires": { 1710 | "@nodelib/fs.stat": "2.0.5", 1711 | "run-parallel": "^1.1.9" 1712 | } 1713 | }, 1714 | "@nodelib/fs.stat": { 1715 | "version": "2.0.5", 1716 | "dev": true 1717 | }, 1718 | "@nodelib/fs.walk": { 1719 | "version": "1.2.8", 1720 | "dev": true, 1721 | "requires": { 1722 | "@nodelib/fs.scandir": "2.1.5", 1723 | "fastq": "^1.6.0" 1724 | } 1725 | }, 1726 | "acorn": { 1727 | "version": "8.10.0", 1728 | "dev": true 1729 | }, 1730 | "acorn-walk": { 1731 | "version": "8.2.0", 1732 | "dev": true 1733 | }, 1734 | "aggregate-error": { 1735 | "version": "4.0.1", 1736 | "dev": true, 1737 | "requires": { 1738 | "clean-stack": "^4.0.0", 1739 | "indent-string": "^5.0.0" 1740 | } 1741 | }, 1742 | "ansi-regex": { 1743 | "version": "6.0.1", 1744 | "dev": true 1745 | }, 1746 | "ansi-styles": { 1747 | "version": "6.2.1", 1748 | "dev": true 1749 | }, 1750 | "anymatch": { 1751 | "version": "3.1.3", 1752 | "dev": true, 1753 | "requires": { 1754 | "normalize-path": "^3.0.0", 1755 | "picomatch": "^2.0.4" 1756 | } 1757 | }, 1758 | "argparse": { 1759 | "version": "1.0.10", 1760 | "dev": true, 1761 | "requires": { 1762 | "sprintf-js": "~1.0.2" 1763 | } 1764 | }, 1765 | "array-find-index": { 1766 | "version": "1.0.2", 1767 | "dev": true 1768 | }, 1769 | "arrgv": { 1770 | "version": "1.0.2", 1771 | "dev": true 1772 | }, 1773 | "arrify": { 1774 | "version": "3.0.0", 1775 | "dev": true 1776 | }, 1777 | "ava": { 1778 | "version": "5.3.1", 1779 | "dev": true, 1780 | "requires": { 1781 | "acorn": "^8.8.2", 1782 | "acorn-walk": "^8.2.0", 1783 | "ansi-styles": "^6.2.1", 1784 | "arrgv": "^1.0.2", 1785 | "arrify": "^3.0.0", 1786 | "callsites": "^4.0.0", 1787 | "cbor": "^8.1.0", 1788 | "chalk": "^5.2.0", 1789 | "chokidar": "^3.5.3", 1790 | "chunkd": "^2.0.1", 1791 | "ci-info": "^3.8.0", 1792 | "ci-parallel-vars": "^1.0.1", 1793 | "clean-yaml-object": "^0.1.0", 1794 | "cli-truncate": "^3.1.0", 1795 | "code-excerpt": "^4.0.0", 1796 | "common-path-prefix": "^3.0.0", 1797 | "concordance": "^5.0.4", 1798 | "currently-unhandled": "^0.4.1", 1799 | "debug": "^4.3.4", 1800 | "emittery": "^1.0.1", 1801 | "figures": "^5.0.0", 1802 | "globby": "^13.1.4", 1803 | "ignore-by-default": "^2.1.0", 1804 | "indent-string": "^5.0.0", 1805 | "is-error": "^2.2.2", 1806 | "is-plain-object": "^5.0.0", 1807 | "is-promise": "^4.0.0", 1808 | "matcher": "^5.0.0", 1809 | "mem": "^9.0.2", 1810 | "ms": "^2.1.3", 1811 | "p-event": "^5.0.1", 1812 | "p-map": "^5.5.0", 1813 | "picomatch": "^2.3.1", 1814 | "pkg-conf": "^4.0.0", 1815 | "plur": "^5.1.0", 1816 | "pretty-ms": "^8.0.0", 1817 | "resolve-cwd": "^3.0.0", 1818 | "stack-utils": "^2.0.6", 1819 | "strip-ansi": "^7.0.1", 1820 | "supertap": "^3.0.1", 1821 | "temp-dir": "^3.0.0", 1822 | "write-file-atomic": "^5.0.1", 1823 | "yargs": "^17.7.2" 1824 | } 1825 | }, 1826 | "binary-extensions": { 1827 | "version": "2.2.0", 1828 | "dev": true 1829 | }, 1830 | "blueimp-md5": { 1831 | "version": "2.19.0", 1832 | "dev": true 1833 | }, 1834 | "braces": { 1835 | "version": "3.0.2", 1836 | "dev": true, 1837 | "requires": { 1838 | "fill-range": "^7.0.1" 1839 | } 1840 | }, 1841 | "callsites": { 1842 | "version": "4.1.0", 1843 | "dev": true 1844 | }, 1845 | "cbor": { 1846 | "version": "8.1.0", 1847 | "dev": true, 1848 | "requires": { 1849 | "nofilter": "^3.1.0" 1850 | } 1851 | }, 1852 | "chalk": { 1853 | "version": "5.3.0", 1854 | "dev": true 1855 | }, 1856 | "chokidar": { 1857 | "version": "3.5.3", 1858 | "dev": true, 1859 | "requires": { 1860 | "anymatch": "~3.1.2", 1861 | "braces": "~3.0.2", 1862 | "fsevents": "~2.3.2", 1863 | "glob-parent": "~5.1.2", 1864 | "is-binary-path": "~2.1.0", 1865 | "is-glob": "~4.0.1", 1866 | "normalize-path": "~3.0.0", 1867 | "readdirp": "~3.6.0" 1868 | } 1869 | }, 1870 | "chunkd": { 1871 | "version": "2.0.1", 1872 | "dev": true 1873 | }, 1874 | "ci-info": { 1875 | "version": "3.8.0", 1876 | "dev": true 1877 | }, 1878 | "ci-parallel-vars": { 1879 | "version": "1.0.1", 1880 | "dev": true 1881 | }, 1882 | "clean-stack": { 1883 | "version": "4.2.0", 1884 | "dev": true, 1885 | "requires": { 1886 | "escape-string-regexp": "5.0.0" 1887 | } 1888 | }, 1889 | "clean-yaml-object": { 1890 | "version": "0.1.0", 1891 | "dev": true 1892 | }, 1893 | "cli-truncate": { 1894 | "version": "3.1.0", 1895 | "dev": true, 1896 | "requires": { 1897 | "slice-ansi": "^5.0.0", 1898 | "string-width": "^5.0.0" 1899 | } 1900 | }, 1901 | "cliui": { 1902 | "version": "8.0.1", 1903 | "dev": true, 1904 | "requires": { 1905 | "string-width": "^4.2.0", 1906 | "strip-ansi": "^6.0.1", 1907 | "wrap-ansi": "^7.0.0" 1908 | }, 1909 | "dependencies": { 1910 | "ansi-regex": { 1911 | "version": "5.0.1", 1912 | "dev": true 1913 | }, 1914 | "emoji-regex": { 1915 | "version": "8.0.0", 1916 | "dev": true 1917 | }, 1918 | "is-fullwidth-code-point": { 1919 | "version": "3.0.0", 1920 | "dev": true 1921 | }, 1922 | "string-width": { 1923 | "version": "4.2.3", 1924 | "dev": true, 1925 | "requires": { 1926 | "emoji-regex": "^8.0.0", 1927 | "is-fullwidth-code-point": "^3.0.0", 1928 | "strip-ansi": "^6.0.1" 1929 | } 1930 | }, 1931 | "strip-ansi": { 1932 | "version": "6.0.1", 1933 | "dev": true, 1934 | "requires": { 1935 | "ansi-regex": "^5.0.1" 1936 | } 1937 | } 1938 | } 1939 | }, 1940 | "code-excerpt": { 1941 | "version": "4.0.0", 1942 | "dev": true, 1943 | "requires": { 1944 | "convert-to-spaces": "^2.0.1" 1945 | } 1946 | }, 1947 | "color-convert": { 1948 | "version": "2.0.1", 1949 | "dev": true, 1950 | "requires": { 1951 | "color-name": "~1.1.4" 1952 | } 1953 | }, 1954 | "color-name": { 1955 | "version": "1.1.4", 1956 | "dev": true 1957 | }, 1958 | "common-path-prefix": { 1959 | "version": "3.0.0", 1960 | "dev": true 1961 | }, 1962 | "concordance": { 1963 | "version": "5.0.4", 1964 | "dev": true, 1965 | "requires": { 1966 | "date-time": "^3.1.0", 1967 | "esutils": "^2.0.3", 1968 | "fast-diff": "^1.2.0", 1969 | "js-string-escape": "^1.0.1", 1970 | "lodash": "^4.17.15", 1971 | "md5-hex": "^3.0.1", 1972 | "semver": "^7.3.2", 1973 | "well-known-symbols": "^2.0.0" 1974 | } 1975 | }, 1976 | "convert-to-spaces": { 1977 | "version": "2.0.1", 1978 | "dev": true 1979 | }, 1980 | "currently-unhandled": { 1981 | "version": "0.4.1", 1982 | "dev": true, 1983 | "requires": { 1984 | "array-find-index": "^1.0.1" 1985 | } 1986 | }, 1987 | "date-time": { 1988 | "version": "3.1.0", 1989 | "dev": true, 1990 | "requires": { 1991 | "time-zone": "^1.0.0" 1992 | } 1993 | }, 1994 | "debug": { 1995 | "version": "4.3.4", 1996 | "dev": true, 1997 | "requires": { 1998 | "ms": "2.1.2" 1999 | }, 2000 | "dependencies": { 2001 | "ms": { 2002 | "version": "2.1.2", 2003 | "dev": true 2004 | } 2005 | } 2006 | }, 2007 | "dir-glob": { 2008 | "version": "3.0.1", 2009 | "dev": true, 2010 | "requires": { 2011 | "path-type": "^4.0.0" 2012 | } 2013 | }, 2014 | "eastasianwidth": { 2015 | "version": "0.2.0", 2016 | "dev": true 2017 | }, 2018 | "emittery": { 2019 | "version": "1.0.1", 2020 | "dev": true 2021 | }, 2022 | "emoji-regex": { 2023 | "version": "9.2.2", 2024 | "dev": true 2025 | }, 2026 | "escalade": { 2027 | "version": "3.1.1", 2028 | "dev": true 2029 | }, 2030 | "escape-string-regexp": { 2031 | "version": "5.0.0", 2032 | "dev": true 2033 | }, 2034 | "esprima": { 2035 | "version": "4.0.1", 2036 | "dev": true 2037 | }, 2038 | "esutils": { 2039 | "version": "2.0.3", 2040 | "dev": true 2041 | }, 2042 | "fast-diff": { 2043 | "version": "1.3.0", 2044 | "dev": true 2045 | }, 2046 | "fast-glob": { 2047 | "version": "3.3.1", 2048 | "dev": true, 2049 | "requires": { 2050 | "@nodelib/fs.stat": "^2.0.2", 2051 | "@nodelib/fs.walk": "^1.2.3", 2052 | "glob-parent": "^5.1.2", 2053 | "merge2": "^1.3.0", 2054 | "micromatch": "^4.0.4" 2055 | } 2056 | }, 2057 | "fastfile": { 2058 | "version": "0.0.20", 2059 | "dev": true 2060 | }, 2061 | "fastq": { 2062 | "version": "1.15.0", 2063 | "dev": true, 2064 | "requires": { 2065 | "reusify": "^1.0.4" 2066 | } 2067 | }, 2068 | "ffjavascript": { 2069 | "version": "0.2.60", 2070 | "dev": true, 2071 | "requires": { 2072 | "wasmbuilder": "0.0.16", 2073 | "wasmcurves": "0.2.2", 2074 | "web-worker": "^1.2.0" 2075 | } 2076 | }, 2077 | "figures": { 2078 | "version": "5.0.0", 2079 | "dev": true, 2080 | "requires": { 2081 | "escape-string-regexp": "^5.0.0", 2082 | "is-unicode-supported": "^1.2.0" 2083 | } 2084 | }, 2085 | "fill-range": { 2086 | "version": "7.0.1", 2087 | "dev": true, 2088 | "requires": { 2089 | "to-regex-range": "^5.0.1" 2090 | } 2091 | }, 2092 | "find-up": { 2093 | "version": "6.3.0", 2094 | "dev": true, 2095 | "requires": { 2096 | "locate-path": "^7.1.0", 2097 | "path-exists": "^5.0.0" 2098 | } 2099 | }, 2100 | "fsevents": { 2101 | "version": "2.3.3", 2102 | "dev": true, 2103 | "optional": true 2104 | }, 2105 | "get-caller-file": { 2106 | "version": "2.0.5", 2107 | "dev": true 2108 | }, 2109 | "glob-parent": { 2110 | "version": "5.1.2", 2111 | "dev": true, 2112 | "requires": { 2113 | "is-glob": "^4.0.1" 2114 | } 2115 | }, 2116 | "globby": { 2117 | "version": "13.2.2", 2118 | "dev": true, 2119 | "requires": { 2120 | "dir-glob": "^3.0.1", 2121 | "fast-glob": "^3.3.0", 2122 | "ignore": "^5.2.4", 2123 | "merge2": "^1.4.1", 2124 | "slash": "^4.0.0" 2125 | } 2126 | }, 2127 | "ignore": { 2128 | "version": "5.2.4", 2129 | "dev": true 2130 | }, 2131 | "ignore-by-default": { 2132 | "version": "2.1.0", 2133 | "dev": true 2134 | }, 2135 | "imurmurhash": { 2136 | "version": "0.1.4", 2137 | "dev": true 2138 | }, 2139 | "indent-string": { 2140 | "version": "5.0.0", 2141 | "dev": true 2142 | }, 2143 | "irregular-plurals": { 2144 | "version": "3.5.0", 2145 | "dev": true 2146 | }, 2147 | "is-binary-path": { 2148 | "version": "2.1.0", 2149 | "dev": true, 2150 | "requires": { 2151 | "binary-extensions": "^2.0.0" 2152 | } 2153 | }, 2154 | "is-error": { 2155 | "version": "2.2.2", 2156 | "dev": true 2157 | }, 2158 | "is-extglob": { 2159 | "version": "2.1.1", 2160 | "dev": true 2161 | }, 2162 | "is-fullwidth-code-point": { 2163 | "version": "4.0.0", 2164 | "dev": true 2165 | }, 2166 | "is-glob": { 2167 | "version": "4.0.3", 2168 | "dev": true, 2169 | "requires": { 2170 | "is-extglob": "^2.1.1" 2171 | } 2172 | }, 2173 | "is-number": { 2174 | "version": "7.0.0", 2175 | "dev": true 2176 | }, 2177 | "is-plain-object": { 2178 | "version": "5.0.0", 2179 | "dev": true 2180 | }, 2181 | "is-promise": { 2182 | "version": "4.0.0", 2183 | "dev": true 2184 | }, 2185 | "is-unicode-supported": { 2186 | "version": "1.3.0", 2187 | "dev": true 2188 | }, 2189 | "js-string-escape": { 2190 | "version": "1.0.1", 2191 | "dev": true 2192 | }, 2193 | "js-yaml": { 2194 | "version": "3.14.1", 2195 | "dev": true, 2196 | "requires": { 2197 | "argparse": "^1.0.7", 2198 | "esprima": "^4.0.0" 2199 | } 2200 | }, 2201 | "load-json-file": { 2202 | "version": "7.0.1", 2203 | "dev": true 2204 | }, 2205 | "locate-path": { 2206 | "version": "7.2.0", 2207 | "dev": true, 2208 | "requires": { 2209 | "p-locate": "^6.0.0" 2210 | } 2211 | }, 2212 | "lodash": { 2213 | "version": "4.17.21", 2214 | "dev": true 2215 | }, 2216 | "lru-cache": { 2217 | "version": "6.0.0", 2218 | "dev": true, 2219 | "requires": { 2220 | "yallist": "^4.0.0" 2221 | } 2222 | }, 2223 | "map-age-cleaner": { 2224 | "version": "0.1.3", 2225 | "dev": true, 2226 | "requires": { 2227 | "p-defer": "^1.0.0" 2228 | } 2229 | }, 2230 | "matcher": { 2231 | "version": "5.0.0", 2232 | "dev": true, 2233 | "requires": { 2234 | "escape-string-regexp": "^5.0.0" 2235 | } 2236 | }, 2237 | "md5-hex": { 2238 | "version": "3.0.1", 2239 | "dev": true, 2240 | "requires": { 2241 | "blueimp-md5": "^2.10.0" 2242 | } 2243 | }, 2244 | "mem": { 2245 | "version": "9.0.2", 2246 | "dev": true, 2247 | "requires": { 2248 | "map-age-cleaner": "^0.1.3", 2249 | "mimic-fn": "^4.0.0" 2250 | } 2251 | }, 2252 | "merge2": { 2253 | "version": "1.4.1", 2254 | "dev": true 2255 | }, 2256 | "micromatch": { 2257 | "version": "4.0.5", 2258 | "dev": true, 2259 | "requires": { 2260 | "braces": "^3.0.2", 2261 | "picomatch": "^2.3.1" 2262 | } 2263 | }, 2264 | "mimic-fn": { 2265 | "version": "4.0.0", 2266 | "dev": true 2267 | }, 2268 | "ms": { 2269 | "version": "2.1.3", 2270 | "dev": true 2271 | }, 2272 | "nofilter": { 2273 | "version": "3.1.0", 2274 | "dev": true 2275 | }, 2276 | "normalize-path": { 2277 | "version": "3.0.0", 2278 | "dev": true 2279 | }, 2280 | "p-defer": { 2281 | "version": "1.0.0", 2282 | "dev": true 2283 | }, 2284 | "p-event": { 2285 | "version": "5.0.1", 2286 | "dev": true, 2287 | "requires": { 2288 | "p-timeout": "^5.0.2" 2289 | } 2290 | }, 2291 | "p-limit": { 2292 | "version": "4.0.0", 2293 | "dev": true, 2294 | "requires": { 2295 | "yocto-queue": "^1.0.0" 2296 | } 2297 | }, 2298 | "p-locate": { 2299 | "version": "6.0.0", 2300 | "dev": true, 2301 | "requires": { 2302 | "p-limit": "^4.0.0" 2303 | } 2304 | }, 2305 | "p-map": { 2306 | "version": "5.5.0", 2307 | "dev": true, 2308 | "requires": { 2309 | "aggregate-error": "^4.0.0" 2310 | } 2311 | }, 2312 | "p-timeout": { 2313 | "version": "5.1.0", 2314 | "dev": true 2315 | }, 2316 | "parse-ms": { 2317 | "version": "3.0.0", 2318 | "dev": true 2319 | }, 2320 | "path-exists": { 2321 | "version": "5.0.0", 2322 | "dev": true 2323 | }, 2324 | "path-type": { 2325 | "version": "4.0.0", 2326 | "dev": true 2327 | }, 2328 | "picomatch": { 2329 | "version": "2.3.1", 2330 | "dev": true 2331 | }, 2332 | "pkg-conf": { 2333 | "version": "4.0.0", 2334 | "dev": true, 2335 | "requires": { 2336 | "find-up": "^6.0.0", 2337 | "load-json-file": "^7.0.0" 2338 | } 2339 | }, 2340 | "plur": { 2341 | "version": "5.1.0", 2342 | "dev": true, 2343 | "requires": { 2344 | "irregular-plurals": "^3.3.0" 2345 | } 2346 | }, 2347 | "pretty-ms": { 2348 | "version": "8.0.0", 2349 | "dev": true, 2350 | "requires": { 2351 | "parse-ms": "^3.0.0" 2352 | } 2353 | }, 2354 | "queue-microtask": { 2355 | "version": "1.2.3", 2356 | "dev": true 2357 | }, 2358 | "r1csfile": { 2359 | "version": "0.0.47", 2360 | "dev": true, 2361 | "requires": { 2362 | "@iden3/bigarray": "0.0.2", 2363 | "@iden3/binfileutils": "0.0.11", 2364 | "fastfile": "0.0.20", 2365 | "ffjavascript": "0.2.60" 2366 | } 2367 | }, 2368 | "randomf": { 2369 | "version": "0.0.3" 2370 | }, 2371 | "readdirp": { 2372 | "version": "3.6.0", 2373 | "dev": true, 2374 | "requires": { 2375 | "picomatch": "^2.2.1" 2376 | } 2377 | }, 2378 | "require-directory": { 2379 | "version": "2.1.1", 2380 | "dev": true 2381 | }, 2382 | "resolve-cwd": { 2383 | "version": "3.0.0", 2384 | "dev": true, 2385 | "requires": { 2386 | "resolve-from": "^5.0.0" 2387 | } 2388 | }, 2389 | "resolve-from": { 2390 | "version": "5.0.0", 2391 | "dev": true 2392 | }, 2393 | "reusify": { 2394 | "version": "1.0.4", 2395 | "dev": true 2396 | }, 2397 | "rstark": { 2398 | "version": "file:../rstark/pkg" 2399 | }, 2400 | "run-parallel": { 2401 | "version": "1.2.0", 2402 | "dev": true, 2403 | "requires": { 2404 | "queue-microtask": "^1.2.2" 2405 | } 2406 | }, 2407 | "semver": { 2408 | "version": "7.5.4", 2409 | "dev": true, 2410 | "requires": { 2411 | "lru-cache": "^6.0.0" 2412 | } 2413 | }, 2414 | "serialize-error": { 2415 | "version": "7.0.1", 2416 | "dev": true, 2417 | "requires": { 2418 | "type-fest": "^0.13.1" 2419 | } 2420 | }, 2421 | "signal-exit": { 2422 | "version": "4.1.0", 2423 | "dev": true 2424 | }, 2425 | "slash": { 2426 | "version": "4.0.0", 2427 | "dev": true 2428 | }, 2429 | "slice-ansi": { 2430 | "version": "5.0.0", 2431 | "dev": true, 2432 | "requires": { 2433 | "ansi-styles": "^6.0.0", 2434 | "is-fullwidth-code-point": "^4.0.0" 2435 | } 2436 | }, 2437 | "sprintf-js": { 2438 | "version": "1.0.3", 2439 | "dev": true 2440 | }, 2441 | "stack-utils": { 2442 | "version": "2.0.6", 2443 | "dev": true, 2444 | "requires": { 2445 | "escape-string-regexp": "^2.0.0" 2446 | }, 2447 | "dependencies": { 2448 | "escape-string-regexp": { 2449 | "version": "2.0.0", 2450 | "dev": true 2451 | } 2452 | } 2453 | }, 2454 | "starkstark": { 2455 | "version": "git+ssh://git@github.com/vimwitch/starkstark.git#683bf06ef15882a67f86a26a33efedc5055df885", 2456 | "from": "starkstark@vimwitch/starkstark#main", 2457 | "requires": { 2458 | "@noble/hashes": "^1.3.1", 2459 | "randomf": "^0.0.3" 2460 | } 2461 | }, 2462 | "string-width": { 2463 | "version": "5.1.2", 2464 | "dev": true, 2465 | "requires": { 2466 | "eastasianwidth": "^0.2.0", 2467 | "emoji-regex": "^9.2.2", 2468 | "strip-ansi": "^7.0.1" 2469 | } 2470 | }, 2471 | "strip-ansi": { 2472 | "version": "7.1.0", 2473 | "dev": true, 2474 | "requires": { 2475 | "ansi-regex": "^6.0.1" 2476 | } 2477 | }, 2478 | "supertap": { 2479 | "version": "3.0.1", 2480 | "dev": true, 2481 | "requires": { 2482 | "indent-string": "^5.0.0", 2483 | "js-yaml": "^3.14.1", 2484 | "serialize-error": "^7.0.1", 2485 | "strip-ansi": "^7.0.1" 2486 | } 2487 | }, 2488 | "temp-dir": { 2489 | "version": "3.0.0", 2490 | "dev": true 2491 | }, 2492 | "time-zone": { 2493 | "version": "1.0.0", 2494 | "dev": true 2495 | }, 2496 | "to-regex-range": { 2497 | "version": "5.0.1", 2498 | "dev": true, 2499 | "requires": { 2500 | "is-number": "^7.0.0" 2501 | } 2502 | }, 2503 | "type-fest": { 2504 | "version": "0.13.1", 2505 | "dev": true 2506 | }, 2507 | "wasmbuilder": { 2508 | "version": "0.0.16", 2509 | "dev": true 2510 | }, 2511 | "wasmcurves": { 2512 | "version": "0.2.2", 2513 | "dev": true, 2514 | "requires": { 2515 | "wasmbuilder": "0.0.16" 2516 | } 2517 | }, 2518 | "web-worker": { 2519 | "version": "1.2.0", 2520 | "dev": true 2521 | }, 2522 | "well-known-symbols": { 2523 | "version": "2.0.0", 2524 | "dev": true 2525 | }, 2526 | "wrap-ansi": { 2527 | "version": "7.0.0", 2528 | "dev": true, 2529 | "requires": { 2530 | "ansi-styles": "^4.0.0", 2531 | "string-width": "^4.1.0", 2532 | "strip-ansi": "^6.0.0" 2533 | }, 2534 | "dependencies": { 2535 | "ansi-regex": { 2536 | "version": "5.0.1", 2537 | "dev": true 2538 | }, 2539 | "ansi-styles": { 2540 | "version": "4.3.0", 2541 | "dev": true, 2542 | "requires": { 2543 | "color-convert": "^2.0.1" 2544 | } 2545 | }, 2546 | "emoji-regex": { 2547 | "version": "8.0.0", 2548 | "dev": true 2549 | }, 2550 | "is-fullwidth-code-point": { 2551 | "version": "3.0.0", 2552 | "dev": true 2553 | }, 2554 | "string-width": { 2555 | "version": "4.2.3", 2556 | "dev": true, 2557 | "requires": { 2558 | "emoji-regex": "^8.0.0", 2559 | "is-fullwidth-code-point": "^3.0.0", 2560 | "strip-ansi": "^6.0.1" 2561 | } 2562 | }, 2563 | "strip-ansi": { 2564 | "version": "6.0.1", 2565 | "dev": true, 2566 | "requires": { 2567 | "ansi-regex": "^5.0.1" 2568 | } 2569 | } 2570 | } 2571 | }, 2572 | "write-file-atomic": { 2573 | "version": "5.0.1", 2574 | "dev": true, 2575 | "requires": { 2576 | "imurmurhash": "^0.1.4", 2577 | "signal-exit": "^4.0.1" 2578 | } 2579 | }, 2580 | "y18n": { 2581 | "version": "5.0.8", 2582 | "dev": true 2583 | }, 2584 | "yallist": { 2585 | "version": "4.0.0", 2586 | "dev": true 2587 | }, 2588 | "yargs": { 2589 | "version": "17.7.2", 2590 | "dev": true, 2591 | "requires": { 2592 | "cliui": "^8.0.1", 2593 | "escalade": "^3.1.1", 2594 | "get-caller-file": "^2.0.5", 2595 | "require-directory": "^2.1.1", 2596 | "string-width": "^4.2.3", 2597 | "y18n": "^5.0.5", 2598 | "yargs-parser": "^21.1.1" 2599 | }, 2600 | "dependencies": { 2601 | "ansi-regex": { 2602 | "version": "5.0.1", 2603 | "dev": true 2604 | }, 2605 | "emoji-regex": { 2606 | "version": "8.0.0", 2607 | "dev": true 2608 | }, 2609 | "is-fullwidth-code-point": { 2610 | "version": "3.0.0", 2611 | "dev": true 2612 | }, 2613 | "string-width": { 2614 | "version": "4.2.3", 2615 | "dev": true, 2616 | "requires": { 2617 | "emoji-regex": "^8.0.0", 2618 | "is-fullwidth-code-point": "^3.0.0", 2619 | "strip-ansi": "^6.0.1" 2620 | } 2621 | }, 2622 | "strip-ansi": { 2623 | "version": "6.0.1", 2624 | "dev": true, 2625 | "requires": { 2626 | "ansi-regex": "^5.0.1" 2627 | } 2628 | } 2629 | } 2630 | }, 2631 | "yargs-parser": { 2632 | "version": "21.1.1", 2633 | "dev": true 2634 | }, 2635 | "yocto-queue": { 2636 | "version": "1.0.0", 2637 | "dev": true 2638 | } 2639 | } 2640 | } 2641 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "circom-stark", 3 | "version": "0.0.1", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "ava --timeout 200000" 8 | }, 9 | "dependencies": { 10 | "rstark": "../rstark/pkg", 11 | "starkstark": "vimwitch/starkstark#main" 12 | }, 13 | "author": "", 14 | "license": "MIT", 15 | "devDependencies": { 16 | "r1csfile": "^0.0.47", 17 | "ava": "^5.3.1" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/compiler.mjs: -------------------------------------------------------------------------------- 1 | import { starkVariables, defaultStark } from 'starkstark' 2 | import { MultiPolynomial } from 'starkstark/src/MultiPolynomial.mjs' 3 | import { Polynomial } from 'starkstark/src/Polynomial.mjs' 4 | import { ScalarField } from 'starkstark/src/ScalarField.mjs' 5 | 6 | // export const field = new ScalarField( 7 | // 1n + 407n * (1n << 119n), // 0xCB800000000000000000000000000001 8 | // 85408008396924667383611388730472331217n 9 | // ) 10 | 11 | export const field = new ScalarField( 12 | 18446744069414584321n, 13 | 2717n 14 | ) 15 | 16 | // compile an assembly file to a set of STARK constraints 17 | const validOperations = { 18 | set: { 19 | argumentCount: 2, 20 | opcode: 0x0, 21 | }, 22 | mul: { 23 | argumentCount: 3, 24 | opcode: 0x1, 25 | }, 26 | add: { 27 | argumentCount: 3, 28 | opcode: 0x2, 29 | }, 30 | neg: { 31 | argumentCount: 2, 32 | opcode: 0x3, 33 | }, 34 | eq: { 35 | argumentCount: 2, 36 | opcode: 0x4, 37 | }, 38 | inv: { 39 | argumentCount: 2, 40 | opcode: 0x5, 41 | }, 42 | out: { 43 | argumentCount: 2, 44 | // virtual opcode not present in trace 45 | opcode: 0x99999999999, 46 | } 47 | } 48 | 49 | const opcodeCount = Object.keys(validOperations).length - 1 50 | 51 | // program should be the compiled program output from `compile` 52 | // TODO: check trace validity before proving? 53 | export function buildTrace(program, inputs = {}) { 54 | const { steps, registerCount, memoryRegisterCount, opcodeRegisterCount } = program 55 | const trace = [] 56 | const memoryRegisters = Array(memoryRegisterCount).fill(0n) 57 | for (const { opcode, name, args } of steps) { 58 | if (name === 'out') continue 59 | const currentMemory = [...memoryRegisters] 60 | const read1Selector = Array(memoryRegisterCount).fill(0n) 61 | const read2Selector = Array(memoryRegisterCount).fill(0n) 62 | const outputSelector = Array(memoryRegisterCount).fill(0n) 63 | const opcodeSelector = Array(opcodeCount).fill(0n) 64 | opcodeSelector[validOperations[name].opcode] = 1n 65 | let freeInput = 0n 66 | const scratch = Array(3).fill(0n) 67 | if (name === 'set') { 68 | // set some dummy read registers 69 | read1Selector[0] = 1n 70 | scratch[0] = currentMemory[0] 71 | read2Selector[0] = 1n 72 | scratch[1] = currentMemory[0] 73 | // set the output register 74 | outputSelector[+args[0]] = 1n 75 | // update the memory 76 | if (/^\d+$/.test(args[1]) || /^0x[0-9a-fA-F]+$/.test(args[1])) { 77 | memoryRegisters[+args[0]] = BigInt(args[1]) 78 | freeInput = BigInt(args[1]) 79 | } else if (typeof inputs[args[1]] === 'bigint') { 80 | // consider it a named variable 81 | memoryRegisters[+args[0]] = inputs[args[1]] 82 | freeInput = inputs[args[1]] 83 | } else { 84 | throw new Error(`No input supplied for named value "${args[1]}"`) 85 | } 86 | scratch[2] = freeInput 87 | } else if (name === 'add' || name === 'mul') { 88 | read1Selector[+args[1]] = 1n 89 | scratch[0] = currentMemory[+args[1]] 90 | read2Selector[+args[2]] = 1n 91 | scratch[1] = currentMemory[+args[2]] 92 | outputSelector[+args[0]] = 1n 93 | memoryRegisters[+args[0]] = field[name](memoryRegisters[+args[1]], memoryRegisters[+args[2]]) 94 | scratch[2] = memoryRegisters[+args[0]] 95 | } else if (name === 'neg') { 96 | read1Selector[+args[1]] = 1n 97 | scratch[0] = currentMemory[+args[1]] 98 | read2Selector[0] = 1n 99 | scratch[1] = currentMemory[0] 100 | outputSelector[+args[0]] = 1n 101 | memoryRegisters[+args[0]] = field.neg(memoryRegisters[+args[1]]) 102 | scratch[2] = memoryRegisters[+args[0]] 103 | } else if (name === 'eq') { 104 | read1Selector[+args[0]] = 1n 105 | scratch[0] = currentMemory[+args[0]] 106 | read2Selector[+args[1]] = 1n 107 | scratch[1] = currentMemory[+args[1]] 108 | // set a dummy output, this is constrained 109 | // to not change in the vm 110 | outputSelector[0] = 1n 111 | scratch[2] = memoryRegisters[0] 112 | } else if (name === 'inv') { 113 | read1Selector[+args[1]] = 1n 114 | scratch[0] = currentMemory[+args[1]] 115 | read2Selector[0] = 1n 116 | scratch[1] = currentMemory[0] 117 | outputSelector[+args[0]] = 1n 118 | memoryRegisters[+args[0]] = field.inv(memoryRegisters[+args[1]]) 119 | scratch[2] = memoryRegisters[+args[0]] 120 | } 121 | trace.push([currentMemory, outputSelector, read1Selector, read2Selector, opcodeSelector, freeInput, scratch].flat()) 122 | } 123 | trace.push([ 124 | memoryRegisters, 125 | [...Array(memoryRegisterCount-1).fill(0n), 1n], 126 | [...Array(memoryRegisterCount-1).fill(0n), 1n], 127 | [...Array(memoryRegisterCount-1).fill(0n), 1n], 128 | [...Array(opcodeCount-1).fill(0n), 1n], 129 | 0n, 130 | // scratch 131 | 0n,0n,0n 132 | ].flat()) 133 | return trace 134 | } 135 | 136 | export function compile(asm) { 137 | const steps = asm 138 | .split('\n') 139 | .filter(line => { 140 | if (line.trim().startsWith(';')) return false 141 | if (line.trim().length === 0) return false 142 | return true 143 | }) 144 | .map(line => line.trim()) 145 | .map(line => line.split(' ')) 146 | .map((operation, i) => { 147 | const commentIndex = operation.indexOf(';') 148 | const [ op, ...args ] = commentIndex >= 0 ? operation.slice(0, commentIndex) : operation 149 | if (!validOperations[op]) { 150 | throw new Error(`Invalid op "${op}"`) 151 | } 152 | const { opcode, argumentCount } = validOperations[op] 153 | if (argumentCount !== args.length) { 154 | throw new Error(`Invalid number of arguments for "${op}" on line ${i}. Expected ${argumentCount}, received ${args.length}`) 155 | } 156 | return { 157 | opcode, 158 | name: op, 159 | args, 160 | } 161 | }) 162 | // we now have an array of opcodes and arguments 163 | // determine the number of memory registers that we need 164 | // for the steps 165 | let memoryRegisterCount = 0 166 | for (const { name, args } of steps) { 167 | if (name === 'set') { 168 | // the set operation is the only one that accepts a value as an input 169 | // all other operations accept register indices 170 | if (+args[0] > memoryRegisterCount) { 171 | memoryRegisterCount = +args[0] 172 | } 173 | continue 174 | } 175 | if (name === 'out') { 176 | if (+args[0] > memoryRegisterCount) { 177 | memoryRegisterCount = +args[0] 178 | } 179 | continue 180 | } 181 | for (const i of args) { 182 | if (+i > memoryRegisterCount) { 183 | memoryRegisterCount = +i 184 | } 185 | } 186 | } 187 | // convert index to length 188 | memoryRegisterCount++ 189 | 190 | // the `out` opcode is not included in the trace 191 | const opcodeRegisterCount = opcodeCount 192 | 193 | // we need 3 selector values for each memory register 194 | // then a selector for each possible opcode 195 | // then a free input register 196 | // then 3 scratch registers 197 | const registerCount = memoryRegisterCount * 4 + opcodeRegisterCount + 1 + 3 198 | const variables = Array(1+2*registerCount) 199 | .fill() 200 | .map((_, i) => new MultiPolynomial(field).term({ coef: 1n, exps: { [i]: 1n }})) 201 | const cycleIndex = variables[0] 202 | const prevState = variables.slice(1, registerCount+1) 203 | const nextState = variables.slice(1+registerCount) 204 | 205 | const constraints = [] 206 | const boundary = [] 207 | 208 | const one = new MultiPolynomial(field).term({ coef: 1n, exps: { [0]: 0n }}) 209 | 210 | // now build the constraints 211 | 212 | // first we constrain each register to not change unless it's the output of an operation 213 | // to do this we define a constraint (a - a)(i - i_a) where a is the value in the register 214 | // i is the index of the register being mutated, and i_a is the index of register containing a 215 | // we define this constraint for each memory register 216 | for (let x = 0; x < memoryRegisterCount; x++) { 217 | const outputSelector = prevState[memoryRegisterCount + x] 218 | const c = prevState[x] 219 | .copy() 220 | .sub(nextState[x]) 221 | .mul(one.copy().sub(outputSelector)) 222 | constraints.push(c) 223 | } 224 | 225 | // now let's constrain that all selector values must be either 0 or 1 226 | for (let x = memoryRegisterCount; x < memoryRegisterCount * 4 + opcodeRegisterCount; x++) { 227 | // x^2 - x constrains x to be either 0 or 1 228 | // e.g. 0^2 - 0 = 0 and 1^2 - 1 = 0 229 | // but 2^2 - 2 != 0 230 | const c = prevState[x].copy().mul(prevState[x]).sub(prevState[x]) 231 | constraints.push(c) 232 | } 233 | 234 | // now let's constrain that for each selector range there is only one 235 | // 1 (selecting a certain register) 236 | for (let x = 1; x < 4; x++) { 237 | const c = new MultiPolynomial(field) 238 | for (let y = 0; y < memoryRegisterCount; y++) { 239 | c.add(prevState[x*memoryRegisterCount + y]) 240 | } 241 | c.sub(one) 242 | constraints.push(c) 243 | } 244 | 245 | const opcodeC = new MultiPolynomial(field) 246 | for (let x = 4*memoryRegisterCount; x < 4*memoryRegisterCount + opcodeRegisterCount; x++) { 247 | opcodeC.add(prevState[x]) 248 | } 249 | opcodeC.sub(one) 250 | constraints.push(opcodeC) 251 | 252 | // now build individual operation constraints 253 | 254 | const freeInRegister = prevState[4*memoryRegisterCount+opcodeRegisterCount] 255 | const scratch1 = prevState[4*memoryRegisterCount+opcodeRegisterCount + 1] 256 | const scratch2 = prevState[4*memoryRegisterCount+opcodeRegisterCount + 2] 257 | const scratch3 = prevState[4*memoryRegisterCount+opcodeRegisterCount + 3] 258 | 259 | const read1Constraint = new MultiPolynomial(field) 260 | const read2Constraint = new MultiPolynomial(field) 261 | const outputLast = new MultiPolynomial(field) 262 | const outputConstraint = new MultiPolynomial(field) 263 | for (let x = 0; x < memoryRegisterCount; x++) { 264 | outputConstraint.add(nextState[x].copy().mul(prevState[memoryRegisterCount + x])) 265 | outputLast.add(prevState[x].copy().mul(prevState[memoryRegisterCount + x])) 266 | read1Constraint.add(prevState[x].copy().mul(prevState[2*memoryRegisterCount + x])) 267 | read2Constraint.add(prevState[x].copy().mul(prevState[3*memoryRegisterCount + x])) 268 | } 269 | 270 | // use the scratch registers to store common intermediate values 271 | // e.g. multiply the selector by the registers and store in scratch 272 | // register 273 | constraints.push(read1Constraint.sub(scratch1)) 274 | const read1 = scratch1 275 | constraints.push(read2Constraint.sub(scratch2)) 276 | const read2 = scratch2 277 | constraints.push(outputConstraint.sub(scratch3)) 278 | const output = scratch3 279 | 280 | // now write the constraints for each operator 281 | 282 | // just constrain that the free input and output registers are equal 283 | const set = freeInRegister.copy().sub(output) 284 | constraints.push(set.copy().mul(prevState[4*memoryRegisterCount+validOperations['set'].opcode])) 285 | 286 | const add = read1.copy().add(read2).sub(output) 287 | constraints.push(add.copy().mul(prevState[4*memoryRegisterCount+validOperations['add'].opcode])) 288 | 289 | const neg = read1.copy().add(output) 290 | constraints.push(neg.copy().mul(prevState[4*memoryRegisterCount+validOperations['neg'].opcode])) 291 | 292 | const inv = read1.copy().mul(output).sub(one) 293 | constraints.push(inv.copy().mul(prevState[4*memoryRegisterCount+validOperations['inv'].opcode])) 294 | 295 | const mul = read1.copy().mul(read2).sub(output) 296 | constraints.push(mul.copy().mul(prevState[4*memoryRegisterCount+validOperations['mul'].opcode])) 297 | 298 | const eq = read1.copy().sub(read2) 299 | constraints.push(eq.copy().mul(prevState[4*memoryRegisterCount+validOperations['eq'].opcode])) 300 | 301 | // for the equality operation constrain that the output doesn't change 302 | // because we're not using it 303 | const eq2 = output.copy().sub(outputLast) 304 | constraints.push(eq2.copy().mul(prevState[4*memoryRegisterCount+validOperations['eq'].opcode])) 305 | 306 | // we now have our transition constraints 307 | // we need to build boundary constraints 308 | 309 | // we'll constrain each step in the trace depending on the opcode 310 | // TODO: build a polynomial for each opcode selector by summing values 311 | // using cycle index, e.g. if we want to active on cycle 2, and 3 312 | // v[0] + v[1] + v[2](cycleIndex - 2) + v[3](cycleIndex - 3) 313 | let step = 0 314 | for (const { opcode, name, args } of steps) { 315 | if (name === 'out') { 316 | // create a boundary constraint 317 | // TODO: support named variables 318 | boundary.push([step, +args[0], BigInt(args[1])]) 319 | continue 320 | } 321 | boundary.push([step, 4*memoryRegisterCount+opcode, 1n]) 322 | step++ 323 | } 324 | boundary.push([step, 4*memoryRegisterCount+opcodeRegisterCount-1, 1n]) 325 | 326 | // we now have a constraint system for a simple VM 327 | 328 | return { 329 | constraints, 330 | boundary, 331 | program: { steps, registerCount, memoryRegisterCount, opcodeRegisterCount } 332 | } 333 | } 334 | -------------------------------------------------------------------------------- /src/index.mjs: -------------------------------------------------------------------------------- 1 | import { compile, buildTrace } from './compiler.mjs' 2 | import * as wasm from 'rstark' 3 | 4 | export function serializeBigint(v) { 5 | let _v = v 6 | const out = [] 7 | while (_v > 0n) { 8 | out.push(Number(_v & ((1n << 32n) - 1n))) 9 | _v >>= 32n 10 | } 11 | return out 12 | } 13 | 14 | export function compileAndProve(asm, inputs = {}) { 15 | const compiled = compile(asm) 16 | const trace = buildTrace(compiled.program) 17 | const proof = wasm.prove({ 18 | transition_constraints: compiled.constraints.map(v => v.serialize()), 19 | boundary: compiled.boundary.map(v => [v[0], v[1], serializeBigint(v[2])]), 20 | trace: trace.map(t => t.map(v => serializeBigint(v))), 21 | }) 22 | wasm.verify(proof, { 23 | trace_len: trace.length, 24 | register_count: compiled.program.registerCount, 25 | transition_constraints: compiled.constraints.map(v => v.serialize()), 26 | boundary: compiled.boundary.map(v => [v[0], v[1], serializeBigint(v[2])]), 27 | }) 28 | } 29 | -------------------------------------------------------------------------------- /src/r1csCompiler.mjs: -------------------------------------------------------------------------------- 1 | import { ScalarField } from 'starkstark/src/ScalarField.mjs' 2 | import { R1CS } from '../src/r1csParser.mjs' 3 | import { buildWitness } from './witnessBuilder.mjs' 4 | 5 | export async function compileR1cs(buffer, input = [], memoryOverride) { 6 | const r = new R1CS(buffer) 7 | const { 8 | prime, 9 | constraints, 10 | nOutputs, 11 | nPubInputs, 12 | nPrvInputs, 13 | nVars 14 | } = r.data 15 | const baseField = new ScalarField(prime) 16 | const memory = memoryOverride ? memoryOverride : (await buildWitness(r.data, input)) 17 | const negOne = baseField.neg(1n) 18 | // order of variables 19 | // ONE, outputs, pub inputs, prv inputs 20 | // for all entries in the r1cs we must prove that ab - c = 0 21 | // where a, b, c are each linear combinations 22 | // more here https://github.com/iden3/r1csfile/blob/master/doc/r1cs_bin_format.md 23 | 24 | // variables are laid out in memory from 0-(nVars-1) 25 | // after that are scratch0, scratch1, scratch2, scratch3 26 | const scratch0 = `0x${nVars.toString(16)}` 27 | const scratch1 = `0x${(nVars+1).toString(16)}` 28 | const scratch2 = `0x${(nVars+2).toString(16)}` 29 | const scratch3 = `0x${(nVars+3).toString(16)}` 30 | 31 | const asm = [] 32 | for (const [i, v] of Object.entries(memory)) { 33 | asm.push(`set 0x${i.toString(16)} ${v}`) 34 | } 35 | for (const [a, b, c] of constraints) { 36 | // each are objects 37 | asm.push(...sum(scratch0, scratch1, a, negOne)) 38 | asm.push(...sum(scratch0, scratch2, b, negOne)) 39 | asm.push(...sum(scratch0, scratch3, c, negOne)) 40 | 41 | asm.push(`mul ${scratch0} ${scratch1} ${scratch2}`) 42 | asm.push(`set ${scratch1} 0`) 43 | asm.push(`neg ${scratch3} ${scratch3}`) 44 | asm.push(`add ${scratch0} ${scratch0} ${scratch3}`) 45 | asm.push(`eq ${scratch0} ${scratch1}`) 46 | } 47 | console.log(`Proving ${asm.length} steps with ${memory.length} memory slots`) 48 | await new Promise(r => setTimeout(r, 100)) 49 | return asm.join('\n') 50 | } 51 | 52 | // mulsum - multiply 2 numbers and add them to a third register 53 | // abc - constrain 3 registers to a*b - c = 0 54 | 55 | function sum(scratch0, scratch, map, negOne) { 56 | if (Object.keys(map).length === 0) { 57 | return [`set ${scratch} 0`] 58 | } 59 | const out = [] 60 | out.push(`set ${scratch} 0`) 61 | for (let x = 0; x < Object.keys(map).length; x++) { 62 | const key = Object.keys(map)[x] 63 | const val = map[key] 64 | if (val !== negOne) { 65 | out.push(`set ${scratch0} ${val}`) 66 | out.push(`mul ${scratch0} ${scratch0} ${key}`) 67 | } else { 68 | out.push(`neg ${scratch0} ${key}`) 69 | } 70 | out.push(`add ${scratch} ${scratch} ${scratch0}`) 71 | } 72 | return out 73 | } 74 | 75 | -------------------------------------------------------------------------------- /src/r1csParser.mjs: -------------------------------------------------------------------------------- 1 | // 0 dependence r1cs file parser 2 | 3 | function LEBytesToBigInt(_bytes) { 4 | const bytes = new Uint8Array(_bytes) 5 | let out = 0n 6 | for (let x = 0; x < bytes.length; x++) { 7 | out += BigInt(bytes[x]) * (1n << BigInt(8*x)) 8 | } 9 | return out 10 | } 11 | 12 | function LEBytesToUint(bytes) { 13 | if (bytes.byteLength > 6) { 14 | throw new Error('Byte array too long for uint') 15 | } 16 | return Number(LEBytesToBigInt(bytes)) 17 | } 18 | 19 | export class R1CS { 20 | get data() { 21 | return this._data 22 | } 23 | 24 | clone() { 25 | return new this.constructor(this._view.buffer.slice()) 26 | } 27 | 28 | constructor(buffer) { 29 | this._data = {} 30 | this._view = new DataView(buffer) 31 | this._offset = 0 32 | 33 | this.parse() 34 | } 35 | 36 | parse() { 37 | // read and check the magic value 38 | let offset = 0 39 | this.magicR1cs = this._view.getUint32(offset, true) 40 | offset += 4 41 | 42 | this.version = this._view.getUint32(offset, true) 43 | offset += 4 44 | 45 | this.sectionCount = this._view.getUint32(offset, true) 46 | offset += 4 47 | this.readSections() 48 | for (const k of Object.keys(this._sections)) { 49 | this.parseSection(k) 50 | } 51 | return this.data 52 | } 53 | 54 | readSections() { 55 | if (this._sections) return 56 | const sections = {} 57 | // skip the header then begin parsing 58 | let offset = 12 59 | for (let x = 0; x < this.sectionCount; x++) { 60 | const sectionType = this._view.getUint32(offset, true) 61 | offset += 4 62 | const sectionLength = this._view.getBigInt64(offset, true) 63 | offset += 8 64 | sections[sectionType] = { 65 | offset, 66 | length: sectionLength, 67 | type: sectionType, 68 | } 69 | offset += Number(sectionLength) 70 | } 71 | this._sections = sections 72 | } 73 | 74 | parseSection(index) { 75 | const section = this._sections[index] 76 | if (!section) throw new Error(`Unable to find section ${index}`) 77 | const { offset, length, type } = section 78 | 79 | if (typeof this[`_parseSection${section.type}`] === 'undefined') { 80 | throw new Error(`Unknown section type: ${section.type}`) 81 | } 82 | if (section.parsed) return 83 | if (section.type > 3 && section.type <= 5) { 84 | throw new Error('Support for custom gates is not implemented') 85 | } else if (section.type > 5) { 86 | this._sections[index].parsed = true 87 | return 88 | } 89 | this[`_parseSection${section.type}`](section) 90 | this._sections[index].parsed = true 91 | } 92 | 93 | // the header section, specifies number of constraints, vars, etc 94 | _parseSection1({ offset: _offset, length, type }) { 95 | let offset = _offset 96 | const fieldSize = this._view.getUint32(offset, true) 97 | offset += 4 98 | const prime = LEBytesToBigInt(this._view.buffer.slice(offset, offset + fieldSize)) 99 | offset += fieldSize 100 | const nWires = this._view.getUint32(offset, true) 101 | offset += 4 102 | const nOutputs = this._view.getUint32(offset, true) 103 | offset += 4 104 | const nPubInputs = this._view.getUint32(offset, true) 105 | offset += 4 106 | const nPrvInputs = this._view.getUint32(offset, true) 107 | offset += 4 108 | const nLabels = this._view.getBigInt64(offset, true) 109 | offset += 8 110 | const nConstraints = this._view.getUint32(offset, true) 111 | offset += 4 112 | 113 | Object.assign(this._data, { 114 | fieldSize, 115 | prime, 116 | nWires, 117 | nVars: nWires, // for compat with r1csfile 118 | nOutputs, 119 | nPubInputs, 120 | nPrvInputs, 121 | nLabels, 122 | nConstraints, 123 | }) 124 | } 125 | 126 | // constraints section 127 | _parseSection2({ offset: _offset, length, type }) { 128 | let offset = _offset 129 | const constraints = [] 130 | const parseTerm = (__offset) => { 131 | const t = {} 132 | // the number of terms in the linear combination 133 | const nT = this._view.getUint32(__offset, true) 134 | __offset += 4 135 | for (let y = 0; y < nT; y++) { 136 | const wireId = this._view.getUint32(__offset, true) 137 | __offset += 4 138 | const constant = LEBytesToBigInt(this._view.buffer.slice(__offset, __offset + this._data.fieldSize)) 139 | __offset += this._data.fieldSize 140 | t[wireId] = constant 141 | } 142 | return [t, __offset] 143 | } 144 | for (let x = 0; x < this._data.nConstraints; x++) { 145 | const constraint = [] 146 | { 147 | const [a, _] = parseTerm(offset) 148 | constraint.push(a) 149 | offset = _ 150 | } 151 | { 152 | const [b, _] = parseTerm(offset) 153 | constraint.push(b) 154 | offset = _ 155 | } 156 | { 157 | const [c, _] = parseTerm(offset) 158 | constraint.push(c) 159 | offset = _ 160 | } 161 | constraints.push(constraint) 162 | } 163 | Object.assign(this._data, { constraints }) 164 | } 165 | 166 | // wire id to label map 167 | _parseSection3({ offset: _offset, length, type }) { 168 | return 169 | 170 | /** 171 | * Label parsing is disabled in this implementation as it seems 172 | * to be unnecessary. In practice this is a list of n values where 173 | * value is simply 1, 2, 3, 4, 5, ... n 174 | * 175 | * e.g. wires are labeled as increasing integers 176 | **/ 177 | let offset = _offset 178 | const labels = [] 179 | for (; offset < Number(length)+_offset;) { 180 | const l = this._view.getBigInt64(offset, true) 181 | offset += 8 182 | labels.push(l) 183 | } 184 | Object.assign(this._data, { 185 | labels, 186 | nLabels: labels.length, 187 | }) 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /src/r1csStark.mjs: -------------------------------------------------------------------------------- 1 | import { R1CS } from './r1csParser.mjs' 2 | import { buildWitness } from './witnessBuilder.mjs' 3 | import { ScalarField } from 'starkstark/src/ScalarField.mjs' 4 | import { MultiPolynomial } from 'starkstark/src/MultiPolynomial.mjs' 5 | 6 | export const field = new ScalarField( 7 | 18446744069414584321n, 8 | 2717n 9 | ) 10 | 11 | export function compile(r1csBuffer, input = [], memoryOverride) { 12 | const { data } = new R1CS(r1csBuffer) 13 | const { 14 | prime, 15 | constraints, 16 | nOutputs, 17 | nPubInputs, 18 | nPrvInputs, 19 | nVars 20 | } = data 21 | 22 | if (prime !== field.p) { 23 | throw new Error(`r1cs prime does not match expected value. Got ${prime} expected ${field.p}`) 24 | } 25 | 26 | const registerCount = Math.ceil(nVars / 2) 27 | const memory = memoryOverride ?? buildWitness(data, input) 28 | if (memory.length % 2 === 1) { 29 | memory.push(0n) 30 | } 31 | 32 | // for all r1cs constraints make stark constraints 33 | // using signals in the trace memory 34 | // the trace will be of length 2 (only 1 step) 35 | // the prover just supplies the signals as input 36 | // in a single row 37 | // 38 | const variables = Array(1+2*registerCount) 39 | .fill() 40 | .map((_, i) => new MultiPolynomial(field).term({ coef: 1n, exps: { [i]: 1n }})) 41 | const cycleIndex = variables[0] 42 | const prevState = variables.slice(1, registerCount+1) 43 | const nextState = variables.slice(1+registerCount) 44 | 45 | const zero = new MultiPolynomial(field).term({ coef: 0n, exps: { [0]: 0n }}) 46 | const one = new MultiPolynomial(field).term({ coef: 1n, exps: { [0]: 0n }}) 47 | 48 | const varByIndex = (i) => { 49 | if (i < registerCount) { 50 | return nextState[i] 51 | } 52 | return prevState[i-registerCount] 53 | } 54 | 55 | const starkConstraints = [] 56 | 57 | for (const [a, b, c] of constraints) { 58 | const aPoly = zero.copy() 59 | for (const [key, value] of Object.entries(a)) { 60 | const coef = new MultiPolynomial(field).term({ coef: value, exps: { [0]: 0n }}) 61 | aPoly.add(one.copy().mul(varByIndex(+key)).mul(coef)) 62 | } 63 | const bPoly = zero.copy() 64 | for (const [key, value] of Object.entries(b)) { 65 | const coef = new MultiPolynomial(field).term({ coef: value, exps: { [0]: 0n }}) 66 | bPoly.add(one.copy().mul(varByIndex(+key)).mul(coef)) 67 | } 68 | const cPoly = zero.copy() 69 | for (const [key, value] of Object.entries(c)) { 70 | const coef = new MultiPolynomial(field).term({ coef: value, exps: { [0]: 0n }}) 71 | cPoly.add(one.copy().mul(varByIndex(+key)).mul(coef)) 72 | } 73 | 74 | starkConstraints.push(aPoly.copy().mul(bPoly).sub(cPoly)) 75 | } 76 | 77 | // where in the memory the public inputs start 78 | const pubInputsOffset = 1 + nOutputs 79 | return { 80 | constraints: starkConstraints, 81 | boundary: memory.slice(pubInputsOffset, pubInputsOffset+nPubInputs).map((val, i) => [1, i+pubInputsOffset, val]), 82 | trace: [memory.slice(0, registerCount), memory.slice(registerCount)].reverse(), 83 | program: { 84 | registerCount, 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/witnessBuilder.mjs: -------------------------------------------------------------------------------- 1 | import { ScalarField } from 'starkstark/src/ScalarField.mjs' 2 | import { MultiPolynomial } from 'starkstark/src/MultiPolynomial.mjs' 3 | import { Polynomial } from 'starkstark/src/Polynomial.mjs' 4 | 5 | // data: the parsed R1CS data 6 | // input: the private and public input values, in that order 7 | // 8 | // take only the input variables and solve a system of 9 | // equations (the constraints) to return a complete witness 10 | // 11 | // TODO: exploit structure of the constraint to solve more efficiently 12 | // when possible 13 | export function buildWitness(data, input = []) { 14 | const baseField = new ScalarField(data.prime) 15 | const { 16 | nOutputs, 17 | nPubInputs, 18 | nPrvInputs, 19 | nVars 20 | } = data 21 | const vars = Array(nVars).fill(null) 22 | vars[0] = 1n 23 | for (let x = 0; x < nPubInputs + nPrvInputs; x++) { 24 | vars[1+nOutputs+x] = input[x] 25 | } 26 | const constraints = [] 27 | // turn the raw constraints into multivariate polynomials 28 | for (const constraint of data.constraints) { 29 | const [a, b, c] = constraint 30 | const polyA = new MultiPolynomial(baseField) 31 | for (const [key, val] of Object.entries(a)) { 32 | polyA.term({ coef: val, exps: { [Number(key)]: 1n } }) 33 | } 34 | const polyB = new MultiPolynomial(baseField) 35 | for (const [key, val] of Object.entries(b)) { 36 | polyB.term({ coef: val, exps: { [Number(key)]: 1n } }) 37 | } 38 | const polyC = new MultiPolynomial(baseField) 39 | for (const [key, val] of Object.entries(c)) { 40 | polyC.term({ coef: val, exps: { [Number(key)]: 1n } }) 41 | } 42 | const finalPoly = polyA.copy().mul(polyB).sub(polyC) 43 | finalPoly.originalConstraint = constraint 44 | constraints.push(finalPoly) 45 | } 46 | // build a map of what constraints need what variables 47 | for (const [i, constraint] of Object.entries(constraints)) { 48 | const unknownVars = [] 49 | const unknownVarsMap = {} 50 | constraint.vars = [] 51 | const [a, b, c] = constraint.originalConstraint 52 | for (const obj of [a, b, c].flat()) { 53 | for (const key of Object.keys(obj)) { 54 | constraint.vars[+key] = true 55 | } 56 | } 57 | } 58 | const allConstraints = [...constraints] 59 | // iterate over the set of constraints 60 | // look for constraints that have only 1 unknown 61 | // and solve for that unknown 62 | // then iterate again 63 | // repeat until all variables are known 64 | while (vars.indexOf(null) !== -1) { 65 | const solved = [] 66 | // determine what variables are unknown. If there is not 67 | // exactly 1 unknown then skip 68 | for (const [key, constraint] of Object.entries(constraints)) { 69 | const unknownVarsMap = {} 70 | for (const [varIndex, ] of Object.entries(constraint.vars)) { 71 | if (vars[varIndex] === null) { 72 | unknownVarsMap[varIndex] = true 73 | if (Object.keys(unknownVarsMap).length > 1) { 74 | break 75 | } 76 | } 77 | } 78 | const unknownVars = Object.keys(unknownVarsMap).map(v => +v) 79 | if (unknownVars.length >= 2 || unknownVars.length === 0) continue 80 | // otherwise solve 81 | const cc = constraint.copy() 82 | cc.evaluatePartial(vars) 83 | // we should end up with either 84 | // 0 = x + c 85 | // or 86 | // 0 = x^2 + x 87 | // or a constraint with c = 0 88 | // in which case we solve a and b 89 | let out 90 | if (cc.expMap.size === 3) { 91 | const [a, b, c] = constraint.originalConstraint 92 | // check that c = 0 93 | if (Object.keys(c).length !== 0) { 94 | throw new Error('expected c = 0 in quadratic polynomial constraint') 95 | } 96 | // solve for the unknown in a and b 97 | const polyA = new Polynomial(baseField) 98 | const polyB = new Polynomial(baseField) 99 | for (const [key, val] of Object.entries(a)) { 100 | if (+unknownVars[0] === +key) { 101 | polyA.term({ coef: val, exp: 1n }) 102 | } else { 103 | polyA.term({ coef: baseField.mul(val, vars[+key]), exp: 0n }) 104 | } 105 | } 106 | for (const [key, val] of Object.entries(b)) { 107 | if (+unknownVars[0] === +key) { 108 | polyB.term({ coef: val, exp: 1n }) 109 | } else { 110 | polyB.term({ coef: baseField.mul(val, vars[+key]), exp: 0n }) 111 | } 112 | } 113 | out = polyA.solve() ?? polyB.solve() 114 | } else { 115 | const _expKey = Array(unknownVars[0]).fill(0n) 116 | _expKey.push(1n) 117 | const expKey = MultiPolynomial.expVectorToString(_expKey) 118 | const _expKey2 = Array(unknownVars[0]).fill(0n) 119 | _expKey2.push(2n) 120 | const expKey2 = MultiPolynomial.expVectorToString(_expKey2) 121 | if (cc.expMap.size !== 2) { 122 | continue 123 | throw new Error('expected exactly 2 remaining terms') 124 | } 125 | if (!cc.expMap.has(expKey)) { 126 | throw new Error('cannot find remaining variable') 127 | } 128 | if (cc.expMap.has(expKey2)) { 129 | // we're in the case of 0 = x^2 + x 130 | // reduce by dividing an x out 131 | cc.expMap.set('0', cc.expMap.get(expKey)) 132 | cc.expMap.set(expKey, cc.expMap.get(expKey2)) 133 | cc.expMap.delete(expKey2) 134 | } 135 | if (!cc.expMap.has('0')) { 136 | throw new Error('exactly one term should be a constant') 137 | } 138 | out = cc.field.div(cc.field.neg(cc.expMap.get('0')), cc.expMap.get(expKey)) 139 | } 140 | vars[unknownVars[0]] = out 141 | solved.push(constraint) 142 | } 143 | for (const c of solved) { 144 | const i = constraints.indexOf(c) 145 | constraints.splice(i, 1) 146 | } 147 | if (solved.length === 0) 148 | throw new Error('Unable to solve for remaining variables') 149 | } 150 | // attempt to evaluate the constraints using the provided inputs 151 | for (const c of allConstraints) { 152 | if (c.evaluate(vars) !== 0n) { 153 | throw new Error('invalid inputs') 154 | } 155 | } 156 | return vars 157 | } 158 | -------------------------------------------------------------------------------- /test/bits.r1cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chancehudson/circom-stark/8dc35ff5a3bcc9532b54ecb67cd475e0167d0bb7/test/bits.r1cs -------------------------------------------------------------------------------- /test/epochKeyLite_main.r1cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chancehudson/circom-stark/8dc35ff5a3bcc9532b54ecb67cd475e0167d0bb7/test/epochKeyLite_main.r1cs -------------------------------------------------------------------------------- /test/example.circom: -------------------------------------------------------------------------------- 1 | pragma circom 2.0.0; 2 | 3 | template Example() { 4 | signal input a; 5 | // signal input b; 6 | 7 | signal output c; 8 | signal output d; 9 | 10 | c <== 2+a; 11 | 12 | d <== 9*a; 13 | 14 | signal f <== c * d; 15 | 16 | } 17 | 18 | component main { public [ a ] } = Example(); 19 | 20 | -------------------------------------------------------------------------------- /test/example.r1cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chancehudson/circom-stark/8dc35ff5a3bcc9532b54ecb67cd475e0167d0bb7/test/example.r1cs -------------------------------------------------------------------------------- /test/example1.asm: -------------------------------------------------------------------------------- 1 | ; a simple repeated squaring program 2 | set 0x0 100 3 | ; calculate 100^4 4 | mul 0x1 0x0 0x0 5 | mul 0x1 0x0 0x1 6 | mul 0x1 0x0 0x1 7 | ; make a public signal and assert its expected value 8 | out 0x1 100000000 9 | ; now calculate 200^4 10 | set 0x0 200 11 | mul 0x1 0x0 0x0 12 | mul 0x1 0x0 0x1 13 | mul 0x1 0x0 0x1 14 | ; and output 15 | out 0x1 1600000000 16 | ; registers can be reused after an output is marked 17 | -------------------------------------------------------------------------------- /test/example1.test.mjs: -------------------------------------------------------------------------------- 1 | import test from 'ava' 2 | import fs from 'fs/promises' 3 | import path from 'path' 4 | import { fileURLToPath } from 'url' 5 | import { compile, buildTrace } from '../src/compiler.mjs' 6 | import * as wasm from 'rstark' 7 | 8 | const __dirname = path.dirname(fileURLToPath(import.meta.url)) 9 | 10 | function serializeBigint(v) { 11 | let _v = v 12 | const out = [] 13 | while (_v > 0n) { 14 | out.push(Number(_v & ((1n << 32n) - 1n))) 15 | _v >>= 32n 16 | } 17 | return out 18 | } 19 | 20 | test('should compile and prove example1', async t => { 21 | const asm = await fs.readFile(path.join(__dirname, './example1.asm')) 22 | const compiled = compile(asm.toString()) 23 | const trace = buildTrace(compiled.program) 24 | for (const line of trace) { 25 | t.is(line.length, compiled.program.registerCount) 26 | } 27 | const proof = wasm.prove({ 28 | transition_constraints: compiled.constraints.map(v => v.serialize()), 29 | boundary: compiled.boundary.map(v => [v[0], v[1], serializeBigint(v[2])]), 30 | trace: trace.map(t => t.map(v => serializeBigint(v))), 31 | }) 32 | wasm.verify(proof, { 33 | trace_len: trace.length, 34 | register_count: compiled.program.registerCount, 35 | transition_constraints: compiled.constraints.map(v => v.serialize()), 36 | boundary: compiled.boundary.map(v => [v[0], v[1], serializeBigint(v[2])]), 37 | }) 38 | t.pass() 39 | }) 40 | -------------------------------------------------------------------------------- /test/exampleR1cs.test.mjs: -------------------------------------------------------------------------------- 1 | import test from 'ava' 2 | import { compileR1cs } from '../src/r1csCompiler.mjs' 3 | import * as wasm from 'rstark' 4 | // import { compile, buildTrace } from '../src/compiler.mjs' 5 | import fs from 'fs/promises' 6 | import path from 'path' 7 | import { fileURLToPath } from 'url' 8 | import { compile } from '../src/r1csStark.mjs' 9 | 10 | const __dirname = path.dirname(fileURLToPath(import.meta.url)) 11 | 12 | function serializeBigint(v) { 13 | let _v = v 14 | const out = [] 15 | while (_v > 0n) { 16 | out.push(Number(_v & ((1n << 32n) - 1n))) 17 | _v >>= 32n 18 | } 19 | return out 20 | } 21 | 22 | test.skip('should compile and prove bits r1cs', async () => { 23 | // the number to be bitified, should fit in 60 bits 24 | const input = [100n] 25 | const file = path.join(__dirname, 'bits.r1cs') 26 | const fileData = await fs.readFile(file) 27 | const compiled = compile(fileData.buffer, input) 28 | const proof = wasm.prove({ 29 | transition_constraints: compiled.constraints.map(v => v.serialize()), 30 | boundary: compiled.boundary.map(v => [v[0], v[1], serializeBigint(v[2])]), 31 | trace: compiled.trace.map(t => t.map(v => serializeBigint(v))), 32 | }) 33 | wasm.verify(proof, { 34 | trace_len: compiled.trace.length, 35 | register_count: compiled.program.registerCount, 36 | transition_constraints: compiled.constraints.map(v => v.serialize()), 37 | boundary: compiled.boundary.map(v => [v[0], v[1], serializeBigint(v[2])]), 38 | }) 39 | 40 | t.pass() 41 | }) 42 | 43 | test('should compile and prove unirep epoch key r1cs', async t => { 44 | const input = Array(7).fill(0n) 45 | const file = path.join(__dirname, 'epochKeyLite_main.r1cs') 46 | const fileData = await fs.readFile(file) 47 | const compiled = compile(fileData.buffer, input) 48 | const _ = +new Date() 49 | const proof = wasm.prove({ 50 | transition_constraints: compiled.constraints.map(v => v.serialize()), 51 | boundary: compiled.boundary.map(v => [v[0], v[1], serializeBigint(v[2])]), 52 | trace: compiled.trace.map(t => t.map(v => serializeBigint(v))), 53 | }) 54 | console.log(`proved in ${+new Date() - _} ms`) 55 | wasm.verify(proof, { 56 | trace_len: compiled.trace.length, 57 | register_count: compiled.program.registerCount, 58 | transition_constraints: compiled.constraints.map(v => v.serialize()), 59 | boundary: compiled.boundary.map(v => [v[0], v[1], serializeBigint(v[2])]), 60 | }) 61 | 62 | t.pass() 63 | }) 64 | 65 | test('should compile and prove r1cs', async t => { 66 | const input = [ 67 | 12n, 68 | ] 69 | const file = path.join(__dirname, 'example.r1cs') 70 | const fileData = await fs.readFile(file) 71 | const compiled = compile(fileData.buffer, input) 72 | const proof = wasm.prove({ 73 | transition_constraints: compiled.constraints.map(v => v.serialize()), 74 | boundary: compiled.boundary.map(v => [v[0], v[1], serializeBigint(v[2])]), 75 | trace: compiled.trace.map(t => t.map(v => serializeBigint(v))), 76 | }) 77 | wasm.verify(proof, { 78 | trace_len: compiled.trace.length, 79 | register_count: compiled.program.registerCount, 80 | transition_constraints: compiled.constraints.map(v => v.serialize()), 81 | boundary: compiled.boundary.map(v => [v[0], v[1], serializeBigint(v[2])]), 82 | }) 83 | 84 | t.pass() 85 | }) 86 | 87 | test('should fail to prove invalid input', async t => { 88 | // if the circuit is properly constrained changing any of these 89 | // values by any amount should cause the proof to fail 90 | const inputMemory = [ 91 | 1n, 92 | 12n, 93 | 90n, 94 | 11n, // change by 1 95 | 1080n 96 | ] 97 | const file = path.join(__dirname, 'example.r1cs') 98 | const fileData = await fs.readFile(file) 99 | const compiled = compile(fileData.buffer, null, inputMemory) 100 | const proof = wasm.prove({ 101 | transition_constraints: compiled.constraints.map(v => v.serialize()), 102 | boundary: compiled.boundary.map(v => [v[0], v[1], serializeBigint(v[2])]), 103 | trace: compiled.trace.map(t => t.map(v => serializeBigint(v))), 104 | }) 105 | t.throws(() => { 106 | wasm.verify(proof, { 107 | trace_len: compiled.trace.length, 108 | register_count: compiled.program.registerCount, 109 | transition_constraints: compiled.constraints.map(v => v.serialize()), 110 | boundary: compiled.boundary.map(v => [v[0], v[1], serializeBigint(v[2])]), 111 | }) 112 | }) 113 | }) 114 | -------------------------------------------------------------------------------- /test/operators.test.mjs: -------------------------------------------------------------------------------- 1 | import test from 'ava' 2 | import { compile, buildTrace, field } from '../src/compiler.mjs' 3 | import * as wasm from 'rstark' 4 | 5 | function serializeBigint(v) { 6 | let _v = v 7 | const out = [] 8 | while (_v > 0n) { 9 | out.push(Number(_v & ((1n << 32n) - 1n))) 10 | _v >>= 32n 11 | } 12 | return out 13 | } 14 | 15 | async function proveAndVerify(asm, inputs) { 16 | const compiled = compile(asm) 17 | const trace = buildTrace(compiled.program, inputs) 18 | const proof = wasm.prove({ 19 | transition_constraints: compiled.constraints.map(v => v.serialize()), 20 | boundary: compiled.boundary.map(v => [v[0], v[1], serializeBigint(v[2])]), 21 | trace: trace.map(t => t.map(v => serializeBigint(v))), 22 | }) 23 | wasm.verify(proof, { 24 | trace_len: trace.length, 25 | register_count: compiled.program.registerCount, 26 | transition_constraints: compiled.constraints.map(v => v.serialize()), 27 | boundary: compiled.boundary.map(v => [v[0], v[1], serializeBigint(v[2])]), 28 | }) 29 | } 30 | 31 | test('should set using named value', async t => { 32 | const v = field.random() 33 | const asm = ` 34 | set 0x0 input1 35 | set 0x1 ${v.toString()} 36 | eq 0x0 0x1 37 | ` 38 | await proveAndVerify(asm, { 39 | input1: v 40 | }) 41 | t.pass() 42 | }) 43 | 44 | test('should add subtract eq', async t => { 45 | const asm = ` 46 | set 0x0 0x124129821400 47 | set 0x1 0x1247912469 48 | neg 0x2 0x1 49 | add 0x3 0x0 0x2 50 | add 0x1 0x3 0x1 51 | eq 0x0 0x1 52 | ` 53 | await proveAndVerify(asm) 54 | t.pass() 55 | }) 56 | 57 | test('should add registers', async t => { 58 | const v1 = field.random() 59 | const v2 = field.random() 60 | const sum = field.add(v1, v2) 61 | const asm = ` 62 | set 0x0 ${v1.toString()} 63 | set 0x1 ${v2.toString()} 64 | add 0x2 0x0 0x1 65 | set 0x3 ${sum.toString()} 66 | eq 0x2 0x3 67 | ` 68 | await proveAndVerify(asm) 69 | t.pass() 70 | }) 71 | 72 | test('should add registers in place', async t => { 73 | const v1 = field.random() 74 | const v2 = field.random() 75 | const sum = field.add(v1, v2) 76 | const asm = ` 77 | set 0x0 ${v1.toString()} 78 | set 0x1 ${v2.toString()} 79 | add 0x0 0x0 0x1 80 | set 0x1 ${sum.toString()} 81 | eq 0x0 0x1 82 | ` 83 | await proveAndVerify(asm) 84 | t.pass() 85 | }) 86 | 87 | test('should check equality of registers', async t => { 88 | const asm = ` 89 | set 0x0 0x124129821400 90 | set 0x1 0x124129821400 91 | eq 0x0 0x1 92 | ` 93 | await proveAndVerify(asm) 94 | t.pass() 95 | }) 96 | 97 | test('should fail to prove equality', async t => { 98 | const asm = ` 99 | set 0x0 0x124129821400 100 | set 0x1 0x124129821401 101 | eq 0x0 0x1 102 | ` 103 | await t.throwsAsync(() => proveAndVerify(asm)) 104 | }) 105 | 106 | test('should negate register', async t => { 107 | const v = field.random() 108 | const vNeg = field.neg(v) 109 | const asm = ` 110 | set 0x0 ${v.toString()} 111 | set 0x1 ${vNeg.toString()} 112 | neg 0x2 0x0 113 | eq 0x2 0x1 114 | ` 115 | await proveAndVerify(asm) 116 | t.pass() 117 | }) 118 | 119 | test('should negate in place', async t => { 120 | const v = field.random() 121 | const vNeg = field.neg(v) 122 | const asm = ` 123 | set 0x0 ${v.toString()} 124 | set 0x1 ${vNeg.toString()} 125 | neg 0x0 0x0 126 | eq 0x0 0x1 127 | ` 128 | await proveAndVerify(asm) 129 | t.pass() 130 | }) 131 | 132 | test('should multiply registers', async t => { 133 | const v1 = field.random() 134 | const v2 = field.random() 135 | const prod = field.mul(v1, v2) 136 | const asm = ` 137 | set 0x0 ${v1.toString()} 138 | set 0x1 ${v2.toString()} 139 | mul 0x2 0x0 0x1 140 | set 0x3 ${prod.toString()} 141 | eq 0x2 0x3 142 | ` 143 | await proveAndVerify(asm) 144 | t.pass() 145 | }) 146 | 147 | test('should multiply in place', async t => { 148 | const v1 = field.random() 149 | const v2 = field.random() 150 | const prod = field.mul(v1, v2) 151 | const asm = ` 152 | set 0x0 ${v1.toString()} 153 | set 0x1 ${v2.toString()} 154 | mul 0x0 0x0 0x1 155 | set 0x1 ${prod.toString()} 156 | eq 0x0 0x1 157 | ` 158 | await proveAndVerify(asm) 159 | t.pass() 160 | }) 161 | 162 | test('should mod inverse in place (0x2)', async t => { 163 | const v = field.random() 164 | const vInv = field.inv(v) 165 | const asm = ` 166 | set 0x0 ${v.toString()} 167 | set 0x1 ${vInv.toString()} 168 | inv 0x2 0x0 169 | eq 0x2 0x1 170 | ` 171 | await proveAndVerify(asm) 172 | t.pass() 173 | }) 174 | 175 | test('should mod inverse in place (0x0)', async t => { 176 | const v = field.random() 177 | const vInv = field.inv(v) 178 | const asm = ` 179 | set 0x0 ${v.toString()} 180 | set 0x1 ${vInv.toString()} 181 | inv 0x0 0x0 182 | eq 0x0 0x1 183 | ` 184 | await proveAndVerify(asm) 185 | t.pass() 186 | }) 187 | -------------------------------------------------------------------------------- /test/r1csParser.test.mjs: -------------------------------------------------------------------------------- 1 | import test from 'ava' 2 | import fs from 'fs/promises' 3 | import { R1CS } from '../src/r1csParser.mjs' 4 | import { readR1cs } from 'r1csfile' 5 | import path from 'path' 6 | import { fileURLToPath } from 'url' 7 | 8 | const __dirname = path.dirname(fileURLToPath(import.meta.url)) 9 | 10 | test('should parse r1cs and match r1csfile parsing for real circuit', async t => { 11 | const file = path.join(__dirname, 'epochKeyLite_main.r1cs') 12 | const data = await readR1cs(file) 13 | const r1csData = await fs.readFile(file) 14 | const r = new R1CS(r1csData.buffer) 15 | r.parse() 16 | 17 | t.is(r.data.nWires, data.nVars) 18 | t.is(r.data.nVars, data.nVars) 19 | t.is(r.data.prime, data.prime) 20 | t.is(r.data.nOutputs, data.nOutputs) 21 | t.is(r.data.nPrvInputs, data.nPrvInputs) 22 | t.is(r.data.nPubInputs, data.nPubInputs) 23 | // we're going to discard the labels 24 | // the r1csfile label parsing seems to be bugged 25 | // t.is(r.data.nLabels, data.nLabels) 26 | t.is(r.data.nConstraints, data.nConstraints) 27 | for (let x = 0; x < r.data.nConstraints; x++) { 28 | for (let y = 0; y < 3; y++) { 29 | // check that number of terms matches 30 | t.is(Object.keys(r.data.constraints[x][y]).length, Object.keys(data.constraints[x][y]).length) 31 | // check that each variable id and constant match 32 | for (const key of Object.keys(r.data.constraints[x][y])) { 33 | t.is(r.data.constraints[x][y][key], data.constraints[x][y][key]) 34 | } 35 | } 36 | } 37 | }) 38 | 39 | test('should parse r1cs and match r1csfile parsing for example circuit', async t => { 40 | const file = path.join(__dirname, 'example.r1cs') 41 | const data = await readR1cs(file) 42 | const r1csData = await fs.readFile(file) 43 | const r = new R1CS(r1csData.buffer) 44 | r.parse() 45 | 46 | t.is(r.data.nWires, data.nVars) 47 | t.is(r.data.nVars, data.nVars) 48 | t.is(r.data.prime, data.prime) 49 | t.is(r.data.nOutputs, data.nOutputs) 50 | t.is(r.data.nPrvInputs, data.nPrvInputs) 51 | t.is(r.data.nPubInputs, data.nPubInputs) 52 | // we're going to discard the labels 53 | // the r1csfile label parsing seems to be bugged 54 | // t.is(r.data.nLabels, data.nLabels) 55 | t.is(r.data.nConstraints, data.nConstraints) 56 | for (let x = 0; x < r.data.nConstraints; x++) { 57 | for (let y = 0; y < 3; y++) { 58 | // check that number of terms matches 59 | t.is(Object.keys(r.data.constraints[x][y]).length, Object.keys(data.constraints[x][y]).length) 60 | // check that each variable id and constant match 61 | for (const key of Object.keys(r.data.constraints[x][y])) { 62 | t.is(r.data.constraints[x][y][key], data.constraints[x][y][key]) 63 | } 64 | } 65 | } 66 | }) 67 | --------------------------------------------------------------------------------