From 250abd98de9573fefe49998cfb89166ae5d2d886 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Tue, 27 May 2025 15:01:38 +0000 Subject: [PATCH 01/18] 2.5.1 --- package-lock.json | 4 ++-- package.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index a88e1055c8..0602bde94d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "o1js", - "version": "2.5.0", + "version": "2.5.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "o1js", - "version": "2.5.0", + "version": "2.5.1", "license": "Apache-2.0", "dependencies": { "blakejs": "1.2.1", diff --git a/package.json b/package.json index 523a6ebb8c..f9c489db32 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "o1js", "description": "TypeScript framework for zk-SNARKs and zkApps", - "version": "2.5.0", + "version": "2.5.1", "license": "Apache-2.0", "homepage": "https://github.com/o1-labs/o1js/", "repository": { @@ -54,7 +54,7 @@ "build:wasm": "./src/bindings/scripts/update-wasm-and-types.sh", "build:web": "rimraf ./dist/web && node src/build/build-web.js", "build:examples": "npm run build && rimraf ./dist/examples && npx tsc -p tsconfig.examples.json && npx tsc -p benchmark/tsconfig.json", - "checkForBindings" : "test -d ./src/bindings/compiled || npm run build:bindings-download", + "checkForBindings": "test -d ./src/bindings/compiled || npm run build:bindings-download", "build:docs": "npx typedoc", "prepublish:web": "npm run checkForBindings && NODE_ENV=production node src/build/build-web.js", "prepublish:node": "npm run checkForBindings && node src/build/copy-artifacts.js && rimraf ./dist/node && tsc -p tsconfig.node.json && node src/build/copy-to-dist.js && NODE_ENV=production node src/build/build-node.js", From 98dd1e777994de727a8a7ab9a9ccf658852f7047 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Tue, 27 May 2025 15:01:45 +0000 Subject: [PATCH 02/18] Update CHANGELOG for new version v2.5.1 --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0adebb8a1d..3032e4c974 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm _Security_ in case of vulnerabilities. --> -## [Unreleased](https://github.com/o1-labs/o1js/compare/4e23a60...HEAD) +## [Unreleased](https://github.com/o1-labs/o1js/compare/250abd98d...HEAD) + +## [2.5.1](https://github.com/o1-labs/o1js/compare/1ad7333e9e...250abd98d) - 2025-05-27 ## [2.5.0](https://github.com/o1-labs/o1js/compare/6ff7f8470a...4e23a60) From 7b51ea0da0eee2ed292fe7e3c092fd242cb0d82a Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 30 May 2025 17:10:29 +0700 Subject: [PATCH 03/18] Update CHANGELOG.md --- CHANGELOG.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f9a35aee5f..308c9157e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,10 +21,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Added -- [PR! 1905](https://github.com/o1-labs/o1js/pull/1905) API support for circuit chunking - - still requires memory optimizations to be fully functional, and - - proof-systems version still needs to be updated to include [this commit](https://github.com/o1-labs/proof-systems/pull/3222/commits/8c37c293f8159eed3676964ba47fc5dc0ae6ea1e) - - that fixed the zero knowledge rows mismatch across Kimchi WASM bindings +- [PR! 1905](https://github.com/o1-labs/o1js/pull/1905) API support for circuit chunking [WIP] + - still requires memory optimizations to be fully functional ## [2.5.0](https://github.com/o1-labs/o1js/compare/6ff7f8470a...4e23a60) From 6b3f2681054f12fead525ee43e313c10fc016ceb Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 30 May 2025 17:11:46 +0700 Subject: [PATCH 04/18] fix changelog --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 308c9157e8..47c7cf5658 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - [PR! 1905](https://github.com/o1-labs/o1js/pull/1905) API support for circuit chunking [WIP] - still requires memory optimizations to be fully functional +- [PR !1848](https://github.com/o1-labs/o1js/pull/1848) Dynamic array provable type ## [2.5.0](https://github.com/o1-labs/o1js/compare/6ff7f8470a...4e23a60) @@ -32,8 +33,6 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Added -- [PR !1848](https://github.com/o1-labs/o1js/pull/1848) Dynamic array provable type - - [PR !2076](https://github.com/o1-labs/o1js/pull/2076) - o1js-bindings is no longer a submodule (same directory structure) - compiled artifacts are now gitignored From 447d346709ce1eccd6a369fd8b11e16a3697ff69 Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 30 May 2025 17:12:09 +0700 Subject: [PATCH 05/18] bump version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0602bde94d..ef08fe0b1e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "o1js", - "version": "2.5.1", + "version": "2.6.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "o1js", - "version": "2.5.1", + "version": "2.6.0", "license": "Apache-2.0", "dependencies": { "blakejs": "1.2.1", diff --git a/package.json b/package.json index f9c489db32..8335f65bd9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "o1js", "description": "TypeScript framework for zk-SNARKs and zkApps", - "version": "2.5.1", + "version": "2.6.0", "license": "Apache-2.0", "homepage": "https://github.com/o1-labs/o1js/", "repository": { From 23bd2e9f24c1ef11ea9ee6e21e28a6fa5be93d1f Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 30 May 2025 17:13:11 +0700 Subject: [PATCH 06/18] correct commit hash in changelog --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47c7cf5658..8778490f4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,9 +15,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm _Security_ in case of vulnerabilities. --> -## [Unreleased](https://github.com/o1-labs/o1js/compare/250abd98d...HEAD) +## [Unreleased](https://github.com/o1-labs/o1js/compare/3eef10d...HEAD) -## [2.5.1](https://github.com/o1-labs/o1js/compare/1ad7333e9e...250abd98d) - 2025-05-27 +## [2.6.0](https://github.com/o1-labs/o1js/compare/4e23a60...3eef10d) - 2025-05-30 ### Added From 1d00b617657e8157a5aba9c5ddf3532c31f74ea8 Mon Sep 17 00:00:00 2001 From: Trivo25 <22175568+Trivo25@users.noreply.github.com> Date: Fri, 30 May 2025 10:15:33 +0000 Subject: [PATCH 07/18] auto update npmDepsHash --- npmDepsHash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npmDepsHash b/npmDepsHash index f5faf0dff3..7fa47557e6 100644 --- a/npmDepsHash +++ b/npmDepsHash @@ -1 +1 @@ -sha256-m3NmZHhCuQxDpYHmB3sRLvitqu2bzbnNaAKY2KOCSIM= +sha256-BbQaG1unSH42VqtTjETCpm7lU29C1DskfXAJbYBvO5A= From ee4c6c6aa0712aea13a1af06dbcf373300e9b164 Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 30 May 2025 18:06:39 +0700 Subject: [PATCH 08/18] minor change to start CI --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8778490f4f..69daed9263 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,8 +21,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Added -- [PR! 1905](https://github.com/o1-labs/o1js/pull/1905) API support for circuit chunking [WIP] - - still requires memory optimizations to be fully functional +- [PR! 1905](https://github.com/o1-labs/o1js/pull/1905) API support for circuit chunking + - work in progress - still requires memory optimizations to be fully functional - [PR !1848](https://github.com/o1-labs/o1js/pull/1848) Dynamic array provable type ## [2.5.0](https://github.com/o1-labs/o1js/compare/6ff7f8470a...4e23a60) From 235159677b2ea3b23b8d484df6279395eb3632e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ana=C3=AFs=20Querol?= Date: Fri, 30 May 2025 15:21:13 +0200 Subject: [PATCH 09/18] bindings: pass signature kind as parameter --- src/bindings/ocaml/lib/consistency_test.ml | 4 +++- src/bindings/ocaml/lib/local_ledger.ml | 2 ++ src/mina | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/bindings/ocaml/lib/consistency_test.ml b/src/bindings/ocaml/lib/consistency_test.ml index 03ee9ea78c..03ac425216 100644 --- a/src/bindings/ocaml/lib/consistency_test.ml +++ b/src/bindings/ocaml/lib/consistency_test.ml @@ -5,6 +5,7 @@ module Other_impl = Pickles.Impls.Wrap module Field = Impl.Field module Account_update = Mina_base.Account_update module Zkapp_command = Mina_base.Zkapp_command +(*module Signed_command = Mina_base.Signed_command*) (* Test - functions that have a ts implementation, exposed for ts-ml consistency tests *) @@ -339,7 +340,8 @@ module Transaction_hash = struct } } in - let payment = Signed_command.sign kp payload in + let signature_kind = Mina_signature_kind.t_DEPRECATED in + let payment = Signed_command.sign ~signature_kind kp payload in (payment :> Signed_command.t) |> Signed_command.to_yojson |> Yojson.Safe.to_string |> Js.string end diff --git a/src/bindings/ocaml/lib/local_ledger.ml b/src/bindings/ocaml/lib/local_ledger.ml index 84c0c84bb5..eae8610c2f 100644 --- a/src/bindings/ocaml/lib/local_ledger.ml +++ b/src/bindings/ocaml/lib/local_ledger.ml @@ -139,11 +139,13 @@ let check_account_update_signatures zkapp_command = zkapp_command in let tx_commitment = Zkapp_command.commitment zkapp_command in + let signature_kind = Mina_signature_kind.t_DEPRECATED in let full_tx_commitment = Zkapp_command.Transaction_commitment.create_complete tx_commitment ~memo_hash:(Mina_base.Signed_command_memo.hash memo) ~fee_payer_hash: (Zkapp_command.Digest.Account_update.create + ~signature_kind (Account_update.of_fee_payer fee_payer) ) in let key_to_string = Signature_lib.Public_key.Compressed.to_base58_check in diff --git a/src/mina b/src/mina index a8a86f54f0..a645bf8c9c 160000 --- a/src/mina +++ b/src/mina @@ -1 +1 @@ -Subproject commit a8a86f54f0028c51c8b34d180b01e0cc8c54cfee +Subproject commit a645bf8c9c3c477a94415d6c7495016c4724c4e8 From 80f1deaa7310559ed5648dee9107c6407f34e38c Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 31 May 2025 09:24:41 +0700 Subject: [PATCH 10/18] remove caml_bigint_256_print --- src/bindings/crypto/bindings/bigint256.ts | 3 --- src/bindings/crypto/bindings/bindings.unit-test.ts | 1 - 2 files changed, 4 deletions(-) diff --git a/src/bindings/crypto/bindings/bigint256.ts b/src/bindings/crypto/bindings/bigint256.ts index e266a06b92..478c1589f8 100644 --- a/src/bindings/crypto/bindings/bigint256.ts +++ b/src/bindings/crypto/bindings/bigint256.ts @@ -38,9 +38,6 @@ const Bigint256Bindings = withPrefix('caml_bigint_256', { if (x === y) return 0; return 1; }, - print([, x]: Bigint256): void { - console.log(x.toString()); - }, to_string(x: Bigint256) { return toMlStringAscii(x[1].toString()); }, diff --git a/src/bindings/crypto/bindings/bindings.unit-test.ts b/src/bindings/crypto/bindings/bindings.unit-test.ts index bb376424ba..f59f5b895d 100644 --- a/src/bindings/crypto/bindings/bindings.unit-test.ts +++ b/src/bindings/crypto/bindings/bindings.unit-test.ts @@ -113,7 +113,6 @@ equivalentRecord(Bigint256Bindings, wasm, { caml_bigint_256_bytes_per_limb: { from: [], to: number }, caml_bigint_256_div: { from: [bigint256, bigint256], to: bigint256 }, caml_bigint_256_compare: { from: [bigint256, bigint256], to: number }, - caml_bigint_256_print: undefined, // this would spam the console caml_bigint_256_to_string: { from: [bigint256], to: decimalString }, caml_bigint_256_test_bit: { from: [bigint256, numberLessThan(256)], From 65671f6cdbb8cad36f88c8ddc66036c2d8ec37eb Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 31 May 2025 09:24:57 +0700 Subject: [PATCH 11/18] remove caml_bigint_256_to_string --- src/bindings/crypto/bindings/bigint256.ts | 3 --- src/bindings/crypto/bindings/bindings.unit-test.ts | 1 - 2 files changed, 4 deletions(-) diff --git a/src/bindings/crypto/bindings/bigint256.ts b/src/bindings/crypto/bindings/bigint256.ts index 478c1589f8..8a6c126aa4 100644 --- a/src/bindings/crypto/bindings/bigint256.ts +++ b/src/bindings/crypto/bindings/bigint256.ts @@ -38,9 +38,6 @@ const Bigint256Bindings = withPrefix('caml_bigint_256', { if (x === y) return 0; return 1; }, - to_string(x: Bigint256) { - return toMlStringAscii(x[1].toString()); - }, // TODO performance critical test_bit(b: Bigint256, i: number): MlBool { return MlBool(!!(b[1] & (1n << BigInt(i)))); diff --git a/src/bindings/crypto/bindings/bindings.unit-test.ts b/src/bindings/crypto/bindings/bindings.unit-test.ts index f59f5b895d..c2536d37b1 100644 --- a/src/bindings/crypto/bindings/bindings.unit-test.ts +++ b/src/bindings/crypto/bindings/bindings.unit-test.ts @@ -113,7 +113,6 @@ equivalentRecord(Bigint256Bindings, wasm, { caml_bigint_256_bytes_per_limb: { from: [], to: number }, caml_bigint_256_div: { from: [bigint256, bigint256], to: bigint256 }, caml_bigint_256_compare: { from: [bigint256, bigint256], to: number }, - caml_bigint_256_to_string: { from: [bigint256], to: decimalString }, caml_bigint_256_test_bit: { from: [bigint256, numberLessThan(256)], to: boolean, From 8bf28a6e1a30b058573655061c7d00a1f4eae0af Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 31 May 2025 09:28:26 +0700 Subject: [PATCH 12/18] get rid of equivalentRecord for Fp bindings --- .../crypto/bindings/bindings.unit-test.ts | 45 ------------------- 1 file changed, 45 deletions(-) diff --git a/src/bindings/crypto/bindings/bindings.unit-test.ts b/src/bindings/crypto/bindings/bindings.unit-test.ts index c2536d37b1..73da3a1955 100644 --- a/src/bindings/crypto/bindings/bindings.unit-test.ts +++ b/src/bindings/crypto/bindings/bindings.unit-test.ts @@ -122,51 +122,6 @@ equivalentRecord(Bigint256Bindings, wasm, { caml_bigint_256_deep_copy: { from: [bigint256], to: bigint256 }, }); -equivalentRecord( - FpBindings as Omit< - typeof FpBindings, - | 'caml_pasta_fp_copy' - | 'caml_pasta_fp_mut_add' - | 'caml_pasta_fp_mut_sub' - | 'caml_pasta_fp_mut_mul' - | 'caml_pasta_fp_mut_square' - >, - wasm, - { - caml_pasta_fp_size_in_bits: { from: [], to: number }, - caml_pasta_fp_size: { from: [], to: fp }, - caml_pasta_fp_add: { from: [fp, fp], to: fp }, - caml_pasta_fp_sub: { from: [fp, fp], to: fp }, - caml_pasta_fp_negate: { from: [fp], to: fp }, - caml_pasta_fp_mul: { from: [fp, fp], to: fp }, - caml_pasta_fp_div: { from: [fp, fp], to: fp }, - caml_pasta_fp_inv: { from: [fp], to: option(fp) }, - caml_pasta_fp_square: { from: [fp], to: fp }, - caml_pasta_fp_is_square: { from: [fp], to: boolean }, - caml_pasta_fp_sqrt: { from: [fp], to: option(fp) }, - caml_pasta_fp_of_int: { from: [uint31], to: fp }, - caml_pasta_fp_to_string: { from: [fp], to: decimalString }, - caml_pasta_fp_of_string: { from: [decimalString], to: fp }, - caml_pasta_fp_print: undefined, // this would spam the console - // these aren't defined in Rust - // caml_pasta_fp_copy: { from: [fp, fp], to: unit }, - // caml_pasta_fp_mut_add: { from: [fp, fp], to: unit }, - // caml_pasta_fp_mut_sub: { from: [fp, fp], to: unit }, - // caml_pasta_fp_mut_mul: { from: [fp, fp], to: unit }, - // caml_pasta_fp_mut_square: { from: [fp], to: unit }, - caml_pasta_fp_compare: { from: [fp, fp], to: number }, - caml_pasta_fp_equal: { from: [fp, fp], to: boolean }, - caml_pasta_fp_random: undefined, // random outputs won't match - caml_pasta_fp_rng: undefined, // random outputs won't match - caml_pasta_fp_to_bigint: { from: [fp], to: bigint256 }, - caml_pasta_fp_of_bigint: { from: [bigint256], to: fp }, - caml_pasta_fp_two_adic_root_of_unity: { from: [], to: fp }, - caml_pasta_fp_domain_generator: { from: [numberLessThan(32)], to: fp }, - caml_pasta_fp_to_bytes: undefined, // not implemented - caml_pasta_fp_of_bytes: undefined, // not implemented - caml_pasta_fp_deep_copy: { from: [fp], to: fp }, - } -); equivalentRecord( FqBindings as Omit< From 83802dd82afadc73a854ae37475e2f1bd8a9a513 Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 31 May 2025 09:29:23 +0700 Subject: [PATCH 13/18] get rid of equivalentRecord for Fq bindings --- .../crypto/bindings/bindings.unit-test.ts | 46 +------------------ 1 file changed, 1 insertion(+), 45 deletions(-) diff --git a/src/bindings/crypto/bindings/bindings.unit-test.ts b/src/bindings/crypto/bindings/bindings.unit-test.ts index 73da3a1955..a9d9333daf 100644 --- a/src/bindings/crypto/bindings/bindings.unit-test.ts +++ b/src/bindings/crypto/bindings/bindings.unit-test.ts @@ -123,51 +123,7 @@ equivalentRecord(Bigint256Bindings, wasm, { }); -equivalentRecord( - FqBindings as Omit< - typeof FqBindings, - | 'caml_pasta_fq_copy' - | 'caml_pasta_fq_mut_add' - | 'caml_pasta_fq_mut_sub' - | 'caml_pasta_fq_mut_mul' - | 'caml_pasta_fq_mut_square' - >, - wasm, - { - caml_pasta_fq_size_in_bits: { from: [], to: number }, - caml_pasta_fq_size: { from: [], to: fq }, - caml_pasta_fq_add: { from: [fq, fq], to: fq }, - caml_pasta_fq_sub: { from: [fq, fq], to: fq }, - caml_pasta_fq_negate: { from: [fq], to: fq }, - caml_pasta_fq_mul: { from: [fq, fq], to: fq }, - caml_pasta_fq_div: { from: [fq, fq], to: fq }, - caml_pasta_fq_inv: { from: [fq], to: option(fq) }, - caml_pasta_fq_square: { from: [fq], to: fq }, - caml_pasta_fq_is_square: { from: [fq], to: boolean }, - caml_pasta_fq_sqrt: { from: [fq], to: option(fq) }, - caml_pasta_fq_of_int: { from: [uint31], to: fq }, - caml_pasta_fq_to_string: { from: [fq], to: decimalString }, - caml_pasta_fq_of_string: { from: [decimalString], to: fq }, - caml_pasta_fq_print: undefined, // this would spam the console - // these aren't defined in Rust - // caml_pasta_fq_copy: { from: [fq, fq], to: unit }, - // caml_pasta_fq_mut_add: { from: [fq, fq], to: unit }, - // caml_pasta_fq_mut_sub: { from: [fq, fq], to: unit }, - // caml_pasta_fq_mut_mul: { from: [fq, fq], to: unit }, - // caml_pasta_fq_mut_square: { from: [fq], to: unit }, - caml_pasta_fq_compare: { from: [fq, fq], to: number }, - caml_pasta_fq_equal: { from: [fq, fq], to: boolean }, - caml_pasta_fq_random: undefined, // random outputs won't match - caml_pasta_fq_rng: undefined, // random outputs won't match - caml_pasta_fq_to_bigint: { from: [fq], to: bigint256 }, - caml_pasta_fq_of_bigint: { from: [bigint256], to: fq }, - caml_pasta_fq_two_adic_root_of_unity: { from: [], to: fq }, - caml_pasta_fq_domain_generator: { from: [numberLessThan(32)], to: fq }, - caml_pasta_fq_to_bytes: undefined, // not implemented - caml_pasta_fq_of_bytes: undefined, // not implemented - caml_pasta_fq_deep_copy: { from: [fq], to: fq }, - } -); + // elliptic curve From c0a005b39a6494e0ee0fbb436d576a763555db48 Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 31 May 2025 09:49:53 +0700 Subject: [PATCH 14/18] Omit instead of remove --- src/bindings/crypto/bindings/bigint256.ts | 6 ++++++ src/bindings/crypto/bindings/bindings.unit-test.ts | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/bindings/crypto/bindings/bigint256.ts b/src/bindings/crypto/bindings/bigint256.ts index 8a6c126aa4..e266a06b92 100644 --- a/src/bindings/crypto/bindings/bigint256.ts +++ b/src/bindings/crypto/bindings/bigint256.ts @@ -38,6 +38,12 @@ const Bigint256Bindings = withPrefix('caml_bigint_256', { if (x === y) return 0; return 1; }, + print([, x]: Bigint256): void { + console.log(x.toString()); + }, + to_string(x: Bigint256) { + return toMlStringAscii(x[1].toString()); + }, // TODO performance critical test_bit(b: Bigint256, i: number): MlBool { return MlBool(!!(b[1] & (1n << BigInt(i)))); diff --git a/src/bindings/crypto/bindings/bindings.unit-test.ts b/src/bindings/crypto/bindings/bindings.unit-test.ts index a9d9333daf..054c0d44b7 100644 --- a/src/bindings/crypto/bindings/bindings.unit-test.ts +++ b/src/bindings/crypto/bindings/bindings.unit-test.ts @@ -106,7 +106,7 @@ function option(spec: Spec): Spec, S | undefined> { }; } -equivalentRecord(Bigint256Bindings, wasm, { +equivalentRecord(Bigint256Bindings as Omit, wasm, { caml_bigint_256_of_numeral: undefined, // TODO caml_bigint_256_of_decimal_string: { from: [decimalString], to: bigint256 }, caml_bigint_256_num_limbs: { from: [], to: number }, From 4da69266f9c515697d920a7f0524821c94f3976c Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 31 May 2025 09:53:06 +0700 Subject: [PATCH 15/18] include bindings in prettier --- .prettierignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.prettierignore b/.prettierignore index 35c87961dc..15f22e2dac 100644 --- a/.prettierignore +++ b/.prettierignore @@ -4,6 +4,6 @@ benchmark/ dist/ node_modules/ o1js-reference/ -src/bindings/ +src/bindings/mina-transaction/gen/ src/mina/ **/*.d.ts From c44208c3a640e86e8ea5976173e0994525e65734 Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 31 May 2025 09:54:20 +0700 Subject: [PATCH 16/18] ignore compile artefacts --- .prettierignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.prettierignore b/.prettierignore index 15f22e2dac..53a2b2efce 100644 --- a/.prettierignore +++ b/.prettierignore @@ -5,5 +5,6 @@ dist/ node_modules/ o1js-reference/ src/bindings/mina-transaction/gen/ +src/bindings/compiled/ src/mina/ **/*.d.ts From d742d8100bc0d68b052eaadea2c66657cacf51d9 Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 31 May 2025 09:55:15 +0700 Subject: [PATCH 17/18] format with new prettier included files --- CHANGELOG.md | 2 +- README-nix.md | 1 - package.json | 2 +- src/bindings/README.md | 2 - src/bindings/crypto/bigint.unit-test.ts | 4 +- src/bindings/crypto/bindings.ts | 5 +- .../crypto/bindings/bindings.unit-test.ts | 38 +- .../crypto/bindings/conversion-base.ts | 5 +- .../crypto/bindings/conversion-core.ts | 26 +- .../crypto/bindings/conversion-oracles.ts | 13 +- .../crypto/bindings/conversion-proof.ts | 96 +- .../bindings/conversion-verifier-index.ts | 70 +- src/bindings/crypto/bindings/curve.ts | 8 +- src/bindings/crypto/bindings/field.ts | 7 +- src/bindings/crypto/bindings/kimchi-types.ts | 24 +- src/bindings/crypto/bindings/lookup.ts | 7 +- src/bindings/crypto/bindings/srs.ts | 18 +- src/bindings/crypto/bindings/test-utils.ts | 5 +- src/bindings/crypto/bindings/util.ts | 5 +- src/bindings/crypto/bindings/vector.ts | 4 +- src/bindings/crypto/constants.ts | 1468 +++++++++-------- .../crypto/elliptic-curve-endomorphism.ts | 42 +- src/bindings/crypto/elliptic-curve.ts | 94 +- .../crypto/elliptic-curve.unit-test.ts | 49 +- src/bindings/crypto/finite-field-examples.ts | 11 +- src/bindings/crypto/finite-field.ts | 30 +- src/bindings/crypto/finite-field.unit-test.ts | 24 +- src/bindings/crypto/glv.unit-test.ts | 5 +- src/bindings/crypto/non-negative.ts | 10 +- src/bindings/crypto/poseidon.unit-test.ts | 4 +- src/bindings/index.ts | 6 +- src/bindings/js/node/node-backend.js | 4 +- src/bindings/js/web/web-backend.js | 28 +- src/bindings/js/web/worker-helpers.js | 4 +- src/bindings/js/web/worker-spec.js | 24 +- src/bindings/lib/binable.ts | 70 +- src/bindings/lib/binable.unit-test.ts | 16 +- src/bindings/lib/encoding.ts | 11 +- src/bindings/lib/from-layout.ts | 123 +- src/bindings/lib/generic.ts | 40 +- src/bindings/lib/provable-generic.ts | 185 +-- .../mina-transaction/v1/derived-leaves.ts | 48 +- .../v1/transaction-leaves-bigint.ts | 14 +- .../mina-transaction/v1/transaction-leaves.ts | 24 +- src/bindings/mina-transaction/v2/leaves.ts | 115 +- src/bindings/mina-transaction/v2/schema.ts | 268 ++- src/bindings/mina-transaction/v2/util.ts | 8 +- .../verification-key.unit-test.ts | 7 +- src/lib/provable/dynamic-array.ts | 59 +- .../provable/test/dynamic-array.unit-test.ts | 17 +- 50 files changed, 1282 insertions(+), 1868 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c2e6114419..725c4e856b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - [PR! 1905](https://github.com/o1-labs/o1js/pull/1905) API support for circuit chunking - still requires memory optimizations to be fully functional, and - - proof-systems version still needs to be updated to include [this commit](https://github.com/o1-labs/proof-systems/pull/3222/commits/8c37c293f8159eed3676964ba47fc5dc0ae6ea1e) + - proof-systems version still needs to be updated to include [this commit](https://github.com/o1-labs/proof-systems/pull/3222/commits/8c37c293f8159eed3676964ba47fc5dc0ae6ea1e) - that fixed the zero knowledge rows mismatch across Kimchi WASM bindings ## [2.5.0](https://github.com/o1-labs/o1js/compare/6ff7f8470a...4e23a60) diff --git a/README-nix.md b/README-nix.md index 0ea028c683..94622dab7a 100644 --- a/README-nix.md +++ b/README-nix.md @@ -92,7 +92,6 @@ On macos the first time you run this command, you can expect it to take hours (o Then, you will observe that the current devshell becomes a Nix shell with the right configuration for `o1js` and `mina`. - From within the shell, you can build o1js and update the bindings. ```console diff --git a/package.json b/package.json index 523a6ebb8c..8b42034ac3 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "build:wasm": "./src/bindings/scripts/update-wasm-and-types.sh", "build:web": "rimraf ./dist/web && node src/build/build-web.js", "build:examples": "npm run build && rimraf ./dist/examples && npx tsc -p tsconfig.examples.json && npx tsc -p benchmark/tsconfig.json", - "checkForBindings" : "test -d ./src/bindings/compiled || npm run build:bindings-download", + "checkForBindings": "test -d ./src/bindings/compiled || npm run build:bindings-download", "build:docs": "npx typedoc", "prepublish:web": "npm run checkForBindings && NODE_ENV=production node src/build/build-web.js", "prepublish:node": "npm run checkForBindings && node src/build/copy-artifacts.js && rimraf ./dist/node && tsc -p tsconfig.node.json && node src/build/copy-to-dist.js && NODE_ENV=production node src/build/build-node.js", diff --git a/src/bindings/README.md b/src/bindings/README.md index c10796cd87..51b7cd7d59 100644 --- a/src/bindings/README.md +++ b/src/bindings/README.md @@ -2,7 +2,6 @@ This directory collects code required by o1js to bind to lower layers of the proof system and the Mina transaction logic, which are written in Rust and OCaml. - **Directory structure** - `/compiled` - compiled JS and Wasm artifacts produced by `js_of_ocaml` and `wasm-bindgen` from Rust and OCaml source code. We keep these artifacts in the source tree so that developing on o1js can be done with standard JS tooling and doesn't require setting up the full OCaml/Rust build pipeline. @@ -12,4 +11,3 @@ This directory collects code required by o1js to bind to lower layers of the pro - `/mina-transaction` - TS types and modules that specialize the generic tooling in `/lib` to Mina's zkApp protocol; mostly auto-generated from OCaml. - `/ocaml` - OCaml library exposing Snarky, Pickles and parts of the Mina transaction logic to JS. Also, OCaml scripts that help auto-generate TypeScript for Mina- and crypto-related types and constants. - `/scripts` - scripts that build parts of o1js from their OCaml and Rust sources, including the contents of `/compiled` and other generated TS files. - diff --git a/src/bindings/crypto/bigint.unit-test.ts b/src/bindings/crypto/bigint.unit-test.ts index 333fc1d3bf..fedd06d9a2 100644 --- a/src/bindings/crypto/bigint.unit-test.ts +++ b/src/bindings/crypto/bigint.unit-test.ts @@ -37,9 +37,7 @@ test(Random.field, (x) => testBigintRoundtrip(x, fieldSize)); // failure cases expect(() => bigIntToBytes(256n, 1)).toThrow(/does not fit in 1 bytes/); expect(() => bigIntToBytes(100_000n, 2)).toThrow(/does not fit in 2 bytes/); -expect(() => bigIntToBytes(4n * Fp.modulus, 32)).toThrow( - /does not fit in 32 bytes/ -); +expect(() => bigIntToBytes(4n * Fp.modulus, 32)).toThrow(/does not fit in 32 bytes/); // parseHexString32 diff --git a/src/bindings/crypto/bindings.ts b/src/bindings/crypto/bindings.ts index ad1e456575..8e9fcb35ff 100644 --- a/src/bindings/crypto/bindings.ts +++ b/src/bindings/crypto/bindings.ts @@ -9,10 +9,7 @@ import { PallasBindings, VestaBindings } from './bindings/curve.js'; import { FpBindings, FqBindings } from './bindings/field.js'; import { FpVectorBindings, FqVectorBindings } from './bindings/vector.js'; import type * as wasmNamespace from '../compiled/node_bindings/plonk_wasm.cjs'; -import { - fieldsFromRustFlat, - fieldsToRustFlat, -} from './bindings/conversion-base.js'; +import { fieldsFromRustFlat, fieldsToRustFlat } from './bindings/conversion-base.js'; import { proofConversion } from './bindings/conversion-proof.js'; import { conversionCore } from './bindings/conversion-core.js'; import { verifierIndexConversion } from './bindings/conversion-verifier-index.js'; diff --git a/src/bindings/crypto/bindings/bindings.unit-test.ts b/src/bindings/crypto/bindings/bindings.unit-test.ts index bb376424ba..85bf77c7e4 100644 --- a/src/bindings/crypto/bindings/bindings.unit-test.ts +++ b/src/bindings/crypto/bindings/bindings.unit-test.ts @@ -16,13 +16,7 @@ import { toMlStringAscii, } from './bigint256.js'; import { wasm } from '../../js/node/node-backend.js'; -import { - Spec, - ToSpec, - FromSpec, - defaultAssertEqual, - id, -} from '../../../lib/testing/equivalent.js'; +import { Spec, ToSpec, FromSpec, defaultAssertEqual, id } from '../../../lib/testing/equivalent.js'; import { Random } from '../../../lib/testing/property.js'; import { WasmAffine, @@ -35,18 +29,8 @@ import { import { equivalentRecord } from './test-utils.js'; import { Field, FpBindings, FqBindings } from './field.js'; import { MlBool, MlOption } from '../../../lib/ml/base.js'; -import { - OrInfinity, - PallasBindings, - VestaBindings, - toMlOrInfinity, -} from './curve.js'; -import { - GroupProjective, - Pallas, - ProjectiveCurve, - Vesta, -} from '../elliptic-curve.js'; +import { OrInfinity, PallasBindings, VestaBindings, toMlOrInfinity } from './curve.js'; +import { GroupProjective, Pallas, ProjectiveCurve, Vesta } from '../elliptic-curve.js'; import { WasmGPallas, WasmGVesta, @@ -280,13 +264,7 @@ function projective( let randomScaled = Random(() => Curve.scale(Curve.one, Scalar.random())); return { - rng: Random.oneOf( - Curve.zero, - Curve.one, - randomScaled, - randomScaled, - randomScaled - ), + rng: Random.oneOf(Curve.zero, Curve.one, randomScaled, randomScaled, randomScaled), // excessively expensive to work around limited Rust API - only use for tests there(p: GroupProjective): WasmP { let { x, y, infinity } = Curve.toAffine(p); @@ -324,13 +302,7 @@ function affine( affineOne: () => WasmA ): Spec { let randomScaled = Random(() => Curve.scale(Curve.one, Scalar.random())); - let rngProjective = Random.oneOf( - Curve.zero, - Curve.one, - randomScaled, - randomScaled, - randomScaled - ); + let rngProjective = Random.oneOf(Curve.zero, Curve.one, randomScaled, randomScaled, randomScaled); let rng = Random.map(rngProjective, (p) => toMlOrInfinity(Curve.toAffine(p))); return { diff --git a/src/bindings/crypto/bindings/conversion-base.ts b/src/bindings/crypto/bindings/conversion-base.ts index 117c082996..9f67829df3 100644 --- a/src/bindings/crypto/bindings/conversion-base.ts +++ b/src/bindings/crypto/bindings/conversion-base.ts @@ -78,10 +78,7 @@ function affineFromRust(pt: A): OrInfinity { const tmpBytes = new Uint8Array(32); -function affineToRust( - pt: OrInfinity, - makeAffine: () => A -) { +function affineToRust(pt: OrInfinity, makeAffine: () => A) { let res = makeAffine(); if (pt === Infinity) { res.infinity = true; diff --git a/src/bindings/crypto/bindings/conversion-core.ts b/src/bindings/crypto/bindings/conversion-core.ts index 1708bcff4d..1628f3db39 100644 --- a/src/bindings/crypto/bindings/conversion-core.ts +++ b/src/bindings/crypto/bindings/conversion-core.ts @@ -86,9 +86,7 @@ function conversionCorePerField( gateToRust(gate: Gate) { let [, typ, [, ...wires], coeffs] = gate; - let rustWires = new wasm.WasmGateWires( - ...mapTuple(wires, self.wireToRust) - ); + let rustWires = new wasm.WasmGateWires(...mapTuple(wires, self.wireToRust)); let rustCoeffs = fieldsToRustFlat(coeffs); return new Gate(typ, rustWires, rustCoeffs); }, @@ -104,14 +102,10 @@ function conversionCorePerField( pointFromRust: affineFromRust, pointsToRust([, ...points]: MlArray): Uint32Array { - return mapToUint32Array(points, (point) => - unwrap(self.pointToRust(point)) - ); + return mapToUint32Array(points, (point) => unwrap(self.pointToRust(point))); }, pointsFromRust(points: Uint32Array): MlArray { - let arr = mapFromUintArray(points, (ptr) => - affineFromRust(wrap(ptr, CommitmentCurve)) - ); + let arr = mapFromUintArray(points, (ptr) => affineFromRust(wrap(ptr, CommitmentCurve))); return [0, ...arr]; }, @@ -133,9 +127,7 @@ function conversionCorePerField( return mapToUint32Array(comms, (c) => unwrap(self.polyCommToRust(c))); }, polyCommsFromRust(rustComms: Uint32Array): MlArray { - let comms = mapFromUintArray(rustComms, (ptr) => - self.polyCommFromRust(wrap(ptr, PolyComm)) - ); + let comms = mapFromUintArray(rustComms, (ptr) => self.polyCommFromRust(wrap(ptr, PolyComm))); return [0, ...comms]; }, }; @@ -176,18 +168,12 @@ function freeOnFinalize(instance: T) { // directly, but unfortunately the destructor name is some mangled internal // string generated by wasm_bindgen. For now, this is the best, // least-brittle way to free once the original class instance gets collected. - let instanceRepresentative = wrap( - (instance as any).__wbg_ptr, - (instance as any).constructor - ); + let instanceRepresentative = wrap((instance as any).__wbg_ptr, (instance as any).constructor); registry.register(instance, instanceRepresentative, instance); return instance; } -function mapFromUintArray( - array: Uint32Array | Uint8Array, - map: (i: number) => T -) { +function mapFromUintArray(array: Uint32Array | Uint8Array, map: (i: number) => T) { let n = array.length; let result: T[] = Array(n); for (let i = 0; i < n; i++) { diff --git a/src/bindings/crypto/bindings/conversion-oracles.ts b/src/bindings/crypto/bindings/conversion-oracles.ts index 1f71915204..1094c96c28 100644 --- a/src/bindings/crypto/bindings/conversion-oracles.ts +++ b/src/bindings/crypto/bindings/conversion-oracles.ts @@ -6,12 +6,7 @@ import type { } from '../../compiled/node_bindings/plonk_wasm.cjs'; import type * as wasmNamespace from '../../compiled/node_bindings/plonk_wasm.cjs'; import { MlOption } from '../../../lib/ml/base.js'; -import { - Field, - Oracles, - RandomOracles, - ScalarChallenge, -} from './kimchi-types.js'; +import { Field, Oracles, RandomOracles, ScalarChallenge } from './kimchi-types.js'; import { fieldFromRust, fieldToRust, @@ -80,11 +75,7 @@ function oraclesConversionPerField({ RandomOracles, Oracles }: WasmClasses) { let jointCombiner = ro.joint_combiner; let jointCombinerOption = MlOption<[0, ScalarChallenge, Field]>( jointCombinerChal && - jointCombiner && [ - 0, - [0, fieldFromRust(jointCombinerChal)], - fieldFromRust(jointCombiner), - ] + jointCombiner && [0, [0, fieldFromRust(jointCombinerChal)], fieldFromRust(jointCombiner)] ); let mlRo: RandomOracles = [ 0, diff --git a/src/bindings/crypto/bindings/conversion-proof.ts b/src/bindings/crypto/bindings/conversion-proof.ts index f496ad9af2..0fec9f1ac0 100644 --- a/src/bindings/crypto/bindings/conversion-proof.ts +++ b/src/bindings/crypto/bindings/conversion-proof.ts @@ -40,12 +40,7 @@ import { fieldsToRustFlat, fieldsFromRustFlat, } from './conversion-base.js'; -import { - ConversionCore, - ConversionCores, - mapToUint32Array, - unwrap, -} from './conversion-core.js'; +import { ConversionCore, ConversionCores, mapToUint32Array, unwrap } from './conversion-core.js'; export { proofConversion }; @@ -68,25 +63,17 @@ type WasmOpeningProof = WasmFpOpeningProof | WasmFqOpeningProof; type WasmProverProof = WasmFpProverProof | WasmFqProverProof; type WasmLookupCommitments = WasmFpLookupCommitments | WasmFqLookupCommitments; type WasmRuntimeTable = WasmFpRuntimeTable | WasmFqRuntimeTable; -type WasmRuntimeTableCfg = - | WasmPastaFpRuntimeTableCfg - | WasmPastaFqRuntimeTableCfg; +type WasmRuntimeTableCfg = WasmPastaFpRuntimeTableCfg | WasmPastaFqRuntimeTableCfg; type WasmLookupTable = WasmPastaFpLookupTable | WasmPastaFqLookupTable; type WasmClasses = { - ProverCommitments: - | typeof WasmFpProverCommitments - | typeof WasmFqProverCommitments; + ProverCommitments: typeof WasmFpProverCommitments | typeof WasmFqProverCommitments; OpeningProof: typeof WasmFpOpeningProof | typeof WasmFqOpeningProof; VecVec: typeof WasmVecVecFp | typeof WasmVecVecFq; ProverProof: typeof WasmFpProverProof | typeof WasmFqProverProof; - LookupCommitments: - | typeof WasmFpLookupCommitments - | typeof WasmFqLookupCommitments; + LookupCommitments: typeof WasmFpLookupCommitments | typeof WasmFqLookupCommitments; RuntimeTable: typeof WasmFpRuntimeTable | typeof WasmFqRuntimeTable; - RuntimeTableCfg: - | typeof WasmPastaFpRuntimeTableCfg - | typeof WasmPastaFqRuntimeTableCfg; + RuntimeTableCfg: typeof WasmPastaFpRuntimeTableCfg | typeof WasmPastaFqRuntimeTableCfg; LookupTable: typeof WasmPastaFpLookupTable | typeof WasmPastaFqLookupTable; }; @@ -128,18 +115,14 @@ function proofConversionPerField( LookupTable, }: WasmClasses ) { - function commitmentsToRust( - commitments: ProverCommitments - ): WasmProverCommitments { + function commitmentsToRust(commitments: ProverCommitments): WasmProverCommitments { let wComm = core.polyCommsToRust(commitments[1]); let zComm = core.polyCommToRust(commitments[2]); let tComm = core.polyCommToRust(commitments[3]); let lookup = MlOption.mapFrom(commitments[4], lookupCommitmentsToRust); return new ProverCommitments(wComm, zComm, tComm, lookup); } - function commitmentsFromRust( - commitments: WasmProverCommitments - ): ProverCommitments { + function commitmentsFromRust(commitments: WasmProverCommitments): ProverCommitments { let wComm = core.polyCommsFromRust(commitments.w_comm); let zComm = core.polyCommFromRust(commitments.z_comm); let tComm = core.polyCommFromRust(commitments.t_comm); @@ -148,17 +131,13 @@ function proofConversionPerField( return [0, wComm as MlTuple, zComm, tComm, lookup]; } - function lookupCommitmentsToRust( - lookup: LookupCommitments - ): WasmLookupCommitments { + function lookupCommitmentsToRust(lookup: LookupCommitments): WasmLookupCommitments { let sorted = core.polyCommsToRust(lookup[1]); let aggreg = core.polyCommToRust(lookup[2]); let runtime = MlOption.mapFrom(lookup[3], core.polyCommToRust); return new LookupCommitments(sorted, aggreg, runtime); } - function lookupCommitmentsFromRust( - lookup: WasmLookupCommitments - ): LookupCommitments { + function lookupCommitmentsFromRust(lookup: WasmLookupCommitments): LookupCommitments { let sorted = core.polyCommsFromRust(lookup.sorted); let aggreg = core.polyCommFromRust(lookup.aggreg); let runtime = MlOption.mapTo(lookup.runtime, core.polyCommFromRust); @@ -188,8 +167,7 @@ function proofConversionPerField( let [, ...l] = core.pointsFromRust(proof.lr_0); let [, ...r] = core.pointsFromRust(proof.lr_1); let n = l.length; - if (n !== r.length) - throw Error('openingProofFromRust: l and r length mismatch.'); + if (n !== r.length) throw Error('openingProofFromRust: l and r length mismatch.'); let lr = l.map<[0, OrInfinity, OrInfinity]>((li, i) => [0, li, r[i]]); let delta = core.pointFromRust(proof.delta); let z1 = fieldFromRust(proof.z1); @@ -203,19 +181,11 @@ function proofConversionPerField( return new RuntimeTable(id, core.vectorToRust(data)); } - function runtimeTableCfgToRust([ - , - id, - firstColumn, - ]: RuntimeTableCfg): WasmRuntimeTableCfg { + function runtimeTableCfgToRust([, id, firstColumn]: RuntimeTableCfg): WasmRuntimeTableCfg { return new RuntimeTableCfg(id, core.vectorToRust(firstColumn)); } - function lookupTableToRust([ - , - id, - [, ...data], - ]: LookupTable): WasmLookupTable { + function lookupTableToRust([, id, [, ...data]]: LookupTable): WasmLookupTable { let n = data.length; let wasmData = new VecVec(n); for (let i = 0; i < n; i++) { @@ -258,23 +228,18 @@ function proofConversionPerField( let commitments = commitmentsFromRust(wasmProof.commitments); let openingProof = openingProofFromRust(wasmProof.proof); // TODO typed as `any` in wasm-bindgen, this is the correct type - let [, wasmPublicEvals, ...wasmEvals]: WasmProofEvaluations = - wasmProof.evals; + let [, wasmPublicEvals, ...wasmEvals]: WasmProofEvaluations = wasmProof.evals; let publicEvals = pointEvalsOptionFromRust(wasmPublicEvals); let evals = proofEvaluationsFromRust([0, ...wasmEvals]); let ftEval1 = fieldFromRust(wasmProof.ft_eval1); let public_ = fieldsFromRustFlat(wasmProof.public_); let prevChallengeScalars = wasmProof.prev_challenges_scalars; - let [, ...prevChallengeComms] = core.polyCommsFromRust( - wasmProof.prev_challenges_comms - ); - let prevChallenges = prevChallengeComms.map( - (comms, i) => { - let scalars = fieldsFromRustFlat(prevChallengeScalars.get(i)); - return [0, scalars, comms]; - } - ); + let [, ...prevChallengeComms] = core.polyCommsFromRust(wasmProof.prev_challenges_comms); + let prevChallenges = prevChallengeComms.map((comms, i) => { + let scalars = fieldsFromRustFlat(prevChallengeScalars.get(i)); + return [0, scalars, comms]; + }); wasmProof.free(); let proof: ProverProof = [ 0, @@ -289,24 +254,15 @@ function proofConversionPerField( }, runtimeTablesToRust([, ...tables]: MlArray): Uint32Array { - return mapToUint32Array(tables, (table) => - unwrap(runtimeTableToRust(table)) - ); + return mapToUint32Array(tables, (table) => unwrap(runtimeTableToRust(table))); }, - runtimeTableCfgsToRust([ - , - ...tableCfgs - ]: MlArray): Uint32Array { - return mapToUint32Array(tableCfgs, (tableCfg) => - unwrap(runtimeTableCfgToRust(tableCfg)) - ); + runtimeTableCfgsToRust([, ...tableCfgs]: MlArray): Uint32Array { + return mapToUint32Array(tableCfgs, (tableCfg) => unwrap(runtimeTableCfgToRust(tableCfg))); }, lookupTablesToRust([, ...tables]: MlArray) { - return mapToUint32Array(tables, (table) => - unwrap(lookupTableToRust(table)) - ); + return mapToUint32Array(tables, (table) => unwrap(lookupTableToRust(table))); }, }; } @@ -330,9 +286,7 @@ function mapProofEvaluations(map: (x: Field1) => Field2) { evals: MlOption> ): MlOption> => MlOption.map(evals, mapPointEvals); - return function mapProofEvaluations( - evals: ProofEvaluations - ): ProofEvaluations { + return function mapProofEvaluations(evals: ProofEvaluations): ProofEvaluations { let [ , w, @@ -394,6 +348,4 @@ function mapProofEvaluations(map: (x: Field1) => Field2) { // helper -type RemoveLeadingZero = T extends [0, ...infer U] - ? U - : never; +type RemoveLeadingZero = T extends [0, ...infer U] ? U : never; diff --git a/src/bindings/crypto/bindings/conversion-verifier-index.ts b/src/bindings/crypto/bindings/conversion-verifier-index.ts index e2c2d92b50..ac4cb71821 100644 --- a/src/bindings/crypto/bindings/conversion-verifier-index.ts +++ b/src/bindings/crypto/bindings/conversion-verifier-index.ts @@ -15,19 +15,9 @@ import type { } from '../../compiled/node_bindings/plonk_wasm.cjs'; import type * as wasmNamespace from '../../compiled/node_bindings/plonk_wasm.cjs'; import { MlBool, MlArray, MlOption } from '../../../lib/ml/base.js'; -import { - Field, - VerifierIndex, - Domain, - VerificationEvals, - PolyComm, -} from './kimchi-types.js'; +import { Field, VerifierIndex, Domain, VerificationEvals, PolyComm } from './kimchi-types.js'; import { fieldFromRust, fieldToRust } from './conversion-base.js'; -import { - ConversionCore, - ConversionCores, - freeOnFinalize, -} from './conversion-core.js'; +import { ConversionCore, ConversionCores, freeOnFinalize } from './conversion-core.js'; import { Lookup, LookupInfo, LookupSelectors } from './lookup.js'; export { verifierIndexConversion }; @@ -35,29 +25,19 @@ export { verifierIndexConversion }; type wasm = typeof wasmNamespace; type WasmDomain = WasmFpDomain | WasmFqDomain; -type WasmVerificationEvals = - | WasmFpPlonkVerificationEvals - | WasmFqPlonkVerificationEvals; +type WasmVerificationEvals = WasmFpPlonkVerificationEvals | WasmFqPlonkVerificationEvals; type WasmShifts = WasmFpShifts | WasmFqShifts; type WasmVerifierIndex = WasmFpPlonkVerifierIndex | WasmFqPlonkVerifierIndex; -type WasmLookupVerifierIndex = - | WasmFpLookupVerifierIndex - | WasmFqLookupVerifierIndex; +type WasmLookupVerifierIndex = WasmFpLookupVerifierIndex | WasmFqLookupVerifierIndex; type WasmLookupSelector = WasmFpLookupSelectors | WasmFqLookupSelectors; type WasmClasses = { Domain: typeof WasmFpDomain | typeof WasmFqDomain; - VerificationEvals: - | typeof WasmFpPlonkVerificationEvals - | typeof WasmFqPlonkVerificationEvals; + VerificationEvals: typeof WasmFpPlonkVerificationEvals | typeof WasmFqPlonkVerificationEvals; Shifts: typeof WasmFpShifts | typeof WasmFqShifts; - VerifierIndex: - | typeof WasmFpPlonkVerifierIndex - | typeof WasmFqPlonkVerifierIndex; - LookupVerifierIndex: - | typeof WasmFpLookupVerifierIndex - | typeof WasmFqLookupVerifierIndex; + VerifierIndex: typeof WasmFpPlonkVerifierIndex | typeof WasmFqPlonkVerifierIndex; + LookupVerifierIndex: typeof WasmFpLookupVerifierIndex | typeof WasmFqLookupVerifierIndex; LookupSelector: typeof WasmFpLookupSelectors | typeof WasmFqLookupSelectors; }; @@ -104,9 +84,7 @@ function verifierIndexConversionPerField( return [0, logSizeOfGroup, groupGen]; } - function verificationEvalsToRust( - evals: VerificationEvals - ): WasmVerificationEvals { + function verificationEvalsToRust(evals: VerificationEvals): WasmVerificationEvals { let sigmaComm = core.polyCommsToRust(evals[1]); let coefficientsComm = core.polyCommsToRust(evals[2]); let genericComm = core.polyCommToRust(evals[3]); @@ -138,9 +116,7 @@ function verifierIndexConversionPerField( rotComm ); } - function verificationEvalsFromRust( - evals: WasmVerificationEvals - ): VerificationEvals { + function verificationEvalsFromRust(evals: WasmVerificationEvals): VerificationEvals { let mlEvals: VerificationEvals = [ 0, core.polyCommsFromRust(evals.sigma_comm), @@ -162,9 +138,7 @@ function verifierIndexConversionPerField( return mlEvals; } - function lookupVerifierIndexToRust( - lookup: Lookup - ): WasmLookupVerifierIndex { + function lookupVerifierIndexToRust(lookup: Lookup): WasmLookupVerifierIndex { let [ , joint_lookup_used, @@ -183,9 +157,7 @@ function verifierIndexConversionPerField( MlOption.mapFrom(runtime_tables_selector, core.polyCommToRust) ); } - function lookupVerifierIndexFromRust( - lookup: WasmLookupVerifierIndex - ): Lookup { + function lookupVerifierIndexFromRust(lookup: WasmLookupVerifierIndex): Lookup { let mlLookup: Lookup = [ 0, MlBool(lookup.joint_lookup_used), @@ -213,26 +185,16 @@ function verifierIndexConversionPerField( MlOption.mapFrom(ffmul, core.polyCommToRust) ); } - function lookupSelectorsFromRust( - selector: WasmLookupSelector - ): LookupSelectors { + function lookupSelectorsFromRust(selector: WasmLookupSelector): LookupSelectors { let lookup = MlOption.mapTo(selector.lookup, core.polyCommFromRust); let xor = MlOption.mapTo(selector.xor, core.polyCommFromRust); - let range_check = MlOption.mapTo( - selector.range_check, - core.polyCommFromRust - ); + let range_check = MlOption.mapTo(selector.range_check, core.polyCommFromRust); let ffmul = MlOption.mapTo(selector.ffmul, core.polyCommFromRust); selector.free(); return [0, lookup, xor, range_check, ffmul]; } - function lookupInfoToRust([ - , - maxPerRow, - maxJointSize, - features, - ]: LookupInfo): WasmLookupInfo { + function lookupInfoToRust([, maxPerRow, maxJointSize, features]: LookupInfo): WasmLookupInfo { let [, patterns, joint_lookup_used, uses_runtime_tables] = features; let [, xor, lookup, range_check, foreign_field_mul] = patterns; let wasmPatterns = new wasm.LookupPatterns( @@ -302,7 +264,7 @@ function verifierIndexConversionPerField( evals, shifts, lookupIndex, - zkRows, + zkRows ); }, verifierIndexFromRust(vk: WasmVerifierIndex): VerifierIndex { @@ -316,7 +278,7 @@ function verifierIndexConversionPerField( verificationEvalsFromRust(vk.evals), self.shiftsFromRust(vk.shifts), MlOption.mapTo(vk.lookup_index, lookupVerifierIndexFromRust), - vk.zk_rows + vk.zk_rows, ]; vk.free(); return mlVk; diff --git a/src/bindings/crypto/bindings/curve.ts b/src/bindings/crypto/bindings/curve.ts index 373d2b202d..3a11c6a2ad 100644 --- a/src/bindings/crypto/bindings/curve.ts +++ b/src/bindings/crypto/bindings/curve.ts @@ -3,13 +3,7 @@ */ import { MlPair } from '../../../lib/ml/base.js'; import { Field } from './field.js'; -import { - Pallas, - Vesta, - ProjectiveCurve, - GroupProjective, - GroupAffine, -} from '../elliptic-curve.js'; +import { Pallas, Vesta, ProjectiveCurve, GroupProjective, GroupAffine } from '../elliptic-curve.js'; import { withPrefix } from './util.js'; export { diff --git a/src/bindings/crypto/bindings/field.ts b/src/bindings/crypto/bindings/field.ts index dab53d3c6f..03994a63a7 100644 --- a/src/bindings/crypto/bindings/field.ts +++ b/src/bindings/crypto/bindings/field.ts @@ -104,8 +104,7 @@ function createFieldBindings(Field: FiniteField) { return [0, x]; }, of_bigint([, x]: Bigint256): Field { - if (x >= Field.modulus) - throw Error('of_bigint: input exceeds field size'); + if (x >= Field.modulus) throw Error('of_bigint: input exceeds field size'); // copying to a new array to break mutable reference return [0, x]; }, @@ -117,9 +116,7 @@ function createFieldBindings(Field: FiniteField) { // w^(2^i) = 1, w^(2^(i-1)) = -1 // computed by taking the 2^32th root and squaring 32-i times if (i > 32 || i < 0) - throw Error( - 'log2 size of evaluation domain must be in [0, 32], got ' + i - ); + throw Error('log2 size of evaluation domain must be in [0, 32], got ' + i); if (i === 0) return [0, 1n]; let generator = Field.twoadicRoot; for (let j = 32; j > i; j--) { diff --git a/src/bindings/crypto/bindings/kimchi-types.ts b/src/bindings/crypto/bindings/kimchi-types.ts index 54a15b4a52..d8e4f459f8 100644 --- a/src/bindings/crypto/bindings/kimchi-types.ts +++ b/src/bindings/crypto/bindings/kimchi-types.ts @@ -5,10 +5,7 @@ import type { Lookup } from './lookup.js'; import type { MlArray, MlOption, MlTuple } from '../../../lib/ml/base.js'; import type { OrInfinity } from './curve.js'; import type { Field } from './field.js'; -import type { - WasmFpSrs, - WasmFqSrs, -} from '../../compiled/node_bindings/plonk_wasm.cjs'; +import type { WasmFpSrs, WasmFqSrs } from '../../compiled/node_bindings/plonk_wasm.cjs'; export { Field, @@ -50,10 +47,7 @@ type Gate = [ coeffs: MlArray ]; -type PolyComm = [ - _: 0, - elems: MlArray, -]; +type PolyComm = [_: 0, elems: MlArray]; // verifier index @@ -87,7 +81,7 @@ type VerifierIndex = [ evals: VerificationEvals, shifts: MlArray, lookup_index: MlOption>, - zkRows: number, + zkRows: number ]; // oracles @@ -138,11 +132,7 @@ type OpeningProof = [ z2: Field, sg: OrInfinity ]; -type PointEvaluations = [ - _: 0, - zeta: MlArray, - zeta_omega: MlArray -]; +type PointEvaluations = [_: 0, zeta: MlArray, zeta_omega: MlArray]; type nColumns = 15; type nPermutsMinus1 = 6; @@ -188,11 +178,7 @@ type ProverProof = [ prev_challenges: MlArray ]; -type ProofWithPublic = [ - _: 0, - public_evals: MlOption>, - proof: ProverProof -]; +type ProofWithPublic = [_: 0, public_evals: MlOption>, proof: ProverProof]; // tables diff --git a/src/bindings/crypto/bindings/lookup.ts b/src/bindings/crypto/bindings/lookup.ts index d6c0e20e1e..77ef8bb732 100644 --- a/src/bindings/crypto/bindings/lookup.ts +++ b/src/bindings/crypto/bindings/lookup.ts @@ -15,12 +15,7 @@ type LookupFeatures = [ joint_lookup_used: MlBool, uses_runtime_tables: MlBool ]; -type LookupInfo = [ - _: 0, - max_per_row: number, - max_joint_size: number, - features: LookupFeatures -]; +type LookupInfo = [_: 0, max_per_row: number, max_joint_size: number, features: LookupFeatures]; type LookupSelectors = [ _: 0, lookup: MlOption, diff --git a/src/bindings/crypto/bindings/srs.ts b/src/bindings/crypto/bindings/srs.ts index 2021a33470..9c9499b60c 100644 --- a/src/bindings/crypto/bindings/srs.ts +++ b/src/bindings/crypto/bindings/srs.ts @@ -1,8 +1,5 @@ import type { Wasm, RustConversion } from '../bindings.js'; -import type { - WasmFpSrs, - WasmFqSrs, -} from '../../compiled/node_bindings/plonk_wasm.cjs'; +import type { WasmFpSrs, WasmFqSrs } from '../../compiled/node_bindings/plonk_wasm.cjs'; import { PolyComm } from './kimchi-types.js'; import { type CacheHeader, @@ -80,10 +77,7 @@ function srsPerField(f: 'fp' | 'fq', wasm: Wasm, conversion: RustConversion) { let lagrangeCommitment = (srs: WasmFpSrs, domain_size: number, i: number) => wasm[`caml_${f}_srs_lagrange_commitment`](srs, domain_size, i); let lagrangeCommitmentsWholeDomainPtr = (srs: WasmSrs, domain_size: number) => - wasm[`caml_${f}_srs_lagrange_commitments_whole_domain_ptr`]( - srs, - domain_size - ); + wasm[`caml_${f}_srs_lagrange_commitments_whole_domain_ptr`](srs, domain_size); let setLagrangeBasis = wasm[`caml_${f}_srs_set_lagrange_basis`]; let getLagrangeBasis = (srs: WasmSrs, n: number) => wasm[`caml_${f}_srs_get_lagrange_basis`](srs, n); @@ -107,9 +101,7 @@ function srsPerField(f: 'fp' | 'fq', wasm: Wasm, conversion: RustConversion) { srs = readCache(cache, header, (bytes) => { // TODO: this takes a bit too long, about 300ms for 2^16 // `pointsToRust` is the clear bottleneck - let jsonSrs: OrInfinityJson[] = JSON.parse( - new TextDecoder().decode(bytes) - ); + let jsonSrs: OrInfinityJson[] = JSON.parse(new TextDecoder().decode(bytes)); let mlSrs = MlArray.mapTo(jsonSrs, OrInfinity.fromJSON); let wasmSrs = conversion[f].pointsToRust(mlSrs); return setSrs(wasmSrs); @@ -153,9 +145,7 @@ function srsPerField(f: 'fp' | 'fq', wasm: Wasm, conversion: RustConversion) { let header = cacheHeaderLagrange(f, domainSize); let didRead = readCache(cache, header, (bytes) => { - let comms: PolyCommJson[] = JSON.parse( - new TextDecoder().decode(bytes) - ); + let comms: PolyCommJson[] = JSON.parse(new TextDecoder().decode(bytes)); let mlComms = polyCommsFromJSON(comms); let wasmComms = conversion[f].polyCommsToRust(mlComms); diff --git a/src/bindings/crypto/bindings/test-utils.ts b/src/bindings/crypto/bindings/test-utils.ts index 07e44dffc5..60f8b14504 100644 --- a/src/bindings/crypto/bindings/test-utils.ts +++ b/src/bindings/crypto/bindings/test-utils.ts @@ -1,7 +1,4 @@ -import { - equivalent, - SpecFromFunctions, -} from '../../../lib/testing/equivalent.js'; +import { equivalent, SpecFromFunctions } from '../../../lib/testing/equivalent.js'; export { equivalentRecord }; diff --git a/src/bindings/crypto/bindings/util.ts b/src/bindings/crypto/bindings/util.ts index 25f3b2a798..af36956272 100644 --- a/src/bindings/crypto/bindings/util.ts +++ b/src/bindings/crypto/bindings/util.ts @@ -1,9 +1,6 @@ export { withPrefix, mapTuple }; -function withPrefix>( - prefix: prefix, - obj: T -) { +function withPrefix>(prefix: prefix, obj: T) { return Object.fromEntries( Object.entries(obj).map(([k, v]) => { return [`${prefix}_${k}`, v]; diff --git a/src/bindings/crypto/bindings/vector.ts b/src/bindings/crypto/bindings/vector.ts index 8f0246a3f1..c7edb98e07 100644 --- a/src/bindings/crypto/bindings/vector.ts +++ b/src/bindings/crypto/bindings/vector.ts @@ -24,9 +24,7 @@ const FieldVectorBindings = { get(v: FieldVector, i: number): Field { let value = v[i + 1] as Field | undefined; if (value === undefined) { - throw Error( - `FieldVector.get(): Index out of bounds, got ${i}/${v.length - 1}` - ); + throw Error(`FieldVector.get(): Index out of bounds, got ${i}/${v.length - 1}`); } // copying to a new array to break mutable reference return [...value]; diff --git a/src/bindings/crypto/constants.ts b/src/bindings/crypto/constants.ts index 371e649768..6b3dabb366 100644 --- a/src/bindings/crypto/constants.ts +++ b/src/bindings/crypto/constants.ts @@ -1,1115 +1,1123 @@ // @gen this file is generated from `bindings/ocaml/o1js_constants.ml` - don't edit it directly -export { prefixes, prefixHashes, prefixHashesLegacy, versionBytes, protocolVersions, poseidonParamsKimchiFp, poseidonParamsLegacyFp, mocks } +export { + prefixes, + prefixHashes, + prefixHashesLegacy, + versionBytes, + protocolVersions, + poseidonParamsKimchiFp, + poseidonParamsLegacyFp, + mocks, +}; let prefixes = { - "event": "MinaZkappEvent******", - "events": "MinaZkappEvents*****", - "sequenceEvents": "MinaZkappSeqEvents**", - "zkappBodyMainnet": "MainnetZkappBody****", - "zkappBodyTestnet": "TestnetZkappBody****", - "accountUpdateCons": "MinaAcctUpdateCons**", - "accountUpdateNode": "MinaAcctUpdateNode**", - "zkappMemo": "MinaZkappMemo*******", - "signatureMainnet": "MinaSignatureMainnet", - "signatureTestnet": "CodaSignature*******", - "zkappUri": "MinaZkappUri********", - "deriveTokenId": "MinaDeriveTokenId***", - "sideLoadedVK": "MinaSideLoadedVk****" + event: 'MinaZkappEvent******', + events: 'MinaZkappEvents*****', + sequenceEvents: 'MinaZkappSeqEvents**', + zkappBodyMainnet: 'MainnetZkappBody****', + zkappBodyTestnet: 'TestnetZkappBody****', + accountUpdateCons: 'MinaAcctUpdateCons**', + accountUpdateNode: 'MinaAcctUpdateNode**', + zkappMemo: 'MinaZkappMemo*******', + signatureMainnet: 'MinaSignatureMainnet', + signatureTestnet: 'CodaSignature*******', + zkappUri: 'MinaZkappUri********', + deriveTokenId: 'MinaDeriveTokenId***', + sideLoadedVK: 'MinaSideLoadedVk****', }; let prefixHashes = { - "CodaReceiptUC*******": [ - "2930292359494829300271368860633580634815819151887078160583250237349129726103", - "15303314845540397914948764201521841781296890621466368017042313538410516382474", - "8520568699315305732843613022173524514377597839978192694761879649747314556194" + 'CodaReceiptUC*******': [ + '2930292359494829300271368860633580634815819151887078160583250237349129726103', + '15303314845540397914948764201521841781296890621466368017042313538410516382474', + '8520568699315305732843613022173524514377597839978192694761879649747314556194', + ], + 'CodaReceiptZkapp****': [ + '10173709693039436418323173817852473796760618468635274081106091878172355412495', + '8139892805413950771311540201181177376747817902069998595519899391903936767134', + '13514876620613630149351219463845257700223634963001020028151406467995275024594', ], - "CodaReceiptZkapp****": [ - "10173709693039436418323173817852473796760618468635274081106091878172355412495", - "8139892805413950771311540201181177376747817902069998595519899391903936767134", - "13514876620613630149351219463845257700223634963001020028151406467995275024594" + 'Coinbase************': [ + '16825847102297458526359719396083434368788313103713242309655412848174457920423', + '21732702256017917816272795771734458959259892802453584375610183841451053027064', + '20669950187190141732603807229833302926112666951294341954340514712643194206110', ], - "Coinbase************": [ - "16825847102297458526359719396083434368788313103713242309655412848174457920423", - "21732702256017917816272795771734458959259892802453584375610183841451053027064", - "20669950187190141732603807229833302926112666951294341954340514712643194206110" + 'PendingCoinbases****': [ + '16730315671906078134534118281698719603694322959719576832314142406897554025946', + '25168172107432119701402092802564698772609386283424806773354665411015030859956', + '20203823516569384790863281992678977204769111540506990077513414850340465376267', ], - "PendingCoinbases****": [ - "16730315671906078134534118281698719603694322959719576832314142406897554025946", - "25168172107432119701402092802564698772609386283424806773354665411015030859956", - "20203823516569384790863281992678977204769111540506990077513414850340465376267" + 'CoinbaseStackData***': [ + '23795978781100345043289806728009175185120094645976380845310050347461663815988', + '22848259504294538625391413055517172710405127059374914145881816600826824598643', + '8292468073974572410325570929211069869427868613763277519881895337391418731450', ], - "CoinbaseStackData***": [ - "23795978781100345043289806728009175185120094645976380845310050347461663815988", - "22848259504294538625391413055517172710405127059374914145881816600826824598643", - "8292468073974572410325570929211069869427868613763277519881895337391418731450" + CoinbaseStackStaHash: [ + '335203117218289187585524630708440909952721586869179589604793956147132569543', + '27066428515933869709871979311099618239824992817474733219473754649926311088531', + '21249847167218596842529246266817628519376871370045151307329588726090940941283', ], - "CoinbaseStackStaHash": [ - "335203117218289187585524630708440909952721586869179589604793956147132569543", - "27066428515933869709871979311099618239824992817474733219473754649926311088531", - "21249847167218596842529246266817628519376871370045151307329588726090940941283" + 'CoinbaseStack*******': [ + '10365018507282248303752506973112854406071106890516858854157506926717812932750', + '19289691782405010481159082968251292806607879795611766141901748131065655579721', + '8987039650233860747996941600635099179155585390854763935988086491644855810711', ], - "CoinbaseStack*******": [ - "10365018507282248303752506973112854406071106890516858854157506926717812932750", - "19289691782405010481159082968251292806607879795611766141901748131065655579721", - "8987039650233860747996941600635099179155585390854763935988086491644855810711" + 'MinaCheckpoints*****': [ + '15873130589302091361863210575263731242593763730169570459166821652327279429416', + '27741778946681194402252199348726997679847260280438775383573755416459042152245', + '7598438620402360345138640933713109733801127070065255775405685972203496634081', ], - "MinaCheckpoints*****": [ - "15873130589302091361863210575263731242593763730169570459166821652327279429416", - "27741778946681194402252199348726997679847260280438775383573755416459042152245", - "7598438620402360345138640933713109733801127070065255775405685972203496634081" + 'MinaMergeSnark******': [ + '5465206932306554741198859294482250047374987110116571903153751264716396266207', + '28325265961862852836567844362114881306407823522046946129773393861560948847052', + '20049678444717746759028157787181298288785775657186008836042341914370292827996', ], - "MinaMergeSnark******": [ - "5465206932306554741198859294482250047374987110116571903153751264716396266207", - "28325265961862852836567844362114881306407823522046946129773393861560948847052", - "20049678444717746759028157787181298288785775657186008836042341914370292827996" + 'MinaBaseSnark*******': [ + '15502310217431654911062859746106286672455410530942120153504175184205809302248', + '3469045624943527165009161295743804688154058669917024998601801713171804105078', + '16667965011323249535055526937874001443515091810412343722400939445165393857780', ], - "MinaBaseSnark*******": [ - "15502310217431654911062859746106286672455410530942120153504175184205809302248", - "3469045624943527165009161295743804688154058669917024998601801713171804105078", - "16667965011323249535055526937874001443515091810412343722400939445165393857780" + 'MinaProtoState******': [ + '5218970939948495870036503265499543025475317910763049867270287867667146978870', + '7663210626148314949787033187186036425676070286961909238040356477815169631084', + '19859188289320816036969227839574854326171440874550138016648548415357198703337', ], - "MinaProtoState******": [ - "5218970939948495870036503265499543025475317910763049867270287867667146978870", - "7663210626148314949787033187186036425676070286961909238040356477815169631084", - "19859188289320816036969227839574854326171440874550138016648548415357198703337" + 'MinaProtoStateBody**': [ + '3548547909990922956559515810876765435326873020883079662683136168632773655275', + '134182536761489093478066959027928272525080293912190881939140820794450385287', + '18910449726094816833941350890285540874861148441082116020102338532207375519343', ], - "MinaProtoStateBody**": [ - "3548547909990922956559515810876765435326873020883079662683136168632773655275", - "134182536761489093478066959027928272525080293912190881939140820794450385287", - "18910449726094816833941350890285540874861148441082116020102338532207375519343" + 'MinaVrfMessage******': [ + '24101363367502572671624471609928959797353672294440762288404204895418767914646', + '5171820881164007689309616183632792746219180909518238150637460314245246143263', + '10979796915023089328772347959806029121878467684484216605075459818053899045444', ], - "MinaVrfMessage******": [ - "24101363367502572671624471609928959797353672294440762288404204895418767914646", - "5171820881164007689309616183632792746219180909518238150637460314245246143263", - "10979796915023089328772347959806029121878467684484216605075459818053899045444" + MinaSignatureMainnet: [ + '28597293842583882050529337819282358444728515448690248936274177901465134844489', + '13029865398778858891320837481651890827971447635226272051516204921834229015884', + '2324960771278703080070347074343683653953770644553957353754880132143131569147', ], - "MinaSignatureMainnet": [ - "28597293842583882050529337819282358444728515448690248936274177901465134844489", - "13029865398778858891320837481651890827971447635226272051516204921834229015884", - "2324960771278703080070347074343683653953770644553957353754880132143131569147" + 'CodaSignature*******': [ + '6547874669265470003564181123405173756111990160585052594027544303901364349512', + '22191763046611062479784309793717481299019591714391827084400612211604078633201', + '15360317550574394687602808211901764964514686767298144053612144955373862517277', ], - "CodaSignature*******": [ - "6547874669265470003564181123405173756111990160585052594027544303901364349512", - "22191763046611062479784309793717481299019591714391827084400612211604078633201", - "15360317550574394687602808211901764964514686767298144053612144955373862517277" + 'MinaVrfOutput*******': [ + '2251514781415689779315070305878469259850299612928948069881728941286436529416', + '28445424317765931437563566658155841532256907311948842353165636913979445243675', + '1697103740469522139030362533818365124680980524626250761960654638291888644330', ], - "MinaVrfOutput*******": [ - "2251514781415689779315070305878469259850299612928948069881728941286436529416", - "28445424317765931437563566658155841532256907311948842353165636913979445243675", - "1697103740469522139030362533818365124680980524626250761960654638291888644330" + 'MinaVrfEvaluation***': [ + '28080055385183205248434069314913715411795750554846638282391132356635075327118', + '25018718747831549163470950235902703474807728450690404911050923194299837536932', + '3256623657773355300700179149632147114566124258546613752475489953689825740823', ], - "MinaVrfEvaluation***": [ - "28080055385183205248434069314913715411795750554846638282391132356635075327118", - "25018718747831549163470950235902703474807728450690404911050923194299837536932", - "3256623657773355300700179149632147114566124258546613752475489953689825740823" + 'MinaEpochSeed*******': [ + '7920024158807749362970659876749181530334941449960381128739613586571256360405', + '13756862713999441076472977832321298402266591073703520273734381195492800342833', + '16931743843465107540110860558687538825985475311420101960428698400767332393906', ], - "MinaEpochSeed*******": [ - "7920024158807749362970659876749181530334941449960381128739613586571256360405", - "13756862713999441076472977832321298402266591073703520273734381195492800342833", - "16931743843465107540110860558687538825985475311420101960428698400767332393906" + 'MinaTransitionSnark*': [ + '11049595972041980914958840531625028328602860712038036656362464370121336040984', + '24369517789348117364784880800333031735213111703459853079908318927717982912175', + '996573540734206293061884582007205418029995442386259428924494388795357965385', ], - "MinaTransitionSnark*": [ - "11049595972041980914958840531625028328602860712038036656362464370121336040984", - "24369517789348117364784880800333031735213111703459853079908318927717982912175", - "996573540734206293061884582007205418029995442386259428924494388795357965385" + 'MinaAccount*********': [ + '21547009634669789644192675386133007766042650219024716227935570378579547706642', + '3869977418072959680344087467966431440327948593054069717779845397512987438978', + '17591003611016737523041467644989399067682599282318802410210271366172380277153', ], - "MinaAccount*********": [ - "21547009634669789644192675386133007766042650219024716227935570378579547706642", - "3869977418072959680344087467966431440327948593054069717779845397512987438978", - "17591003611016737523041467644989399067682599282318802410210271366172380277153" + 'MinaSideLoadedVk****': [ + '27153629295534844750482612843518005572402188741101822965689207110291504095805', + '11073437601016088346212553894160581939150688827288603152461976873708720172824', + '9169013693168830396847022454402673046094697740892173219744332585469764409612', ], - "MinaSideLoadedVk****": [ - "27153629295534844750482612843518005572402188741101822965689207110291504095805", - "11073437601016088346212553894160581939150688827288603152461976873708720172824", - "9169013693168830396847022454402673046094697740892173219744332585469764409612" + 'MinaZkappAccount****': [ + '11742420651603425685690711434636216727968618158667382343736587130720645535016', + '20917169788479399921968659996772666237321879817943938162255353371266230737562', + '20221577186851444354528754069740362935513598751580381763045954351047955571417', ], - "MinaZkappAccount****": [ - "11742420651603425685690711434636216727968618158667382343736587130720645535016", - "20917169788479399921968659996772666237321879817943938162255353371266230737562", - "20221577186851444354528754069740362935513598751580381763045954351047955571417" + 'MinaZkappPayload****': [ + '15735138827391397348912010094577234813869450438840158969759900004702547928125', + '25095612872941242247876048162039143509752212627701285511972307921367391645919', + '7245494597725009330136300549232949784423520250577599502394596645257342395146', ], - "MinaZkappPayload****": [ - "15735138827391397348912010094577234813869450438840158969759900004702547928125", - "25095612872941242247876048162039143509752212627701285511972307921367391645919", - "7245494597725009330136300549232949784423520250577599502394596645257342395146" + 'MainnetZkappBody****': [ + '10214915150831852734808709087755641273868350720962413399868532305813227181967', + '19231103515031626108540280352804904215178644233964839448405623573586547300771', + '3202185325412846279878024015439663797323768206239602518916650099275135615824', ], - "MainnetZkappBody****": [ - "10214915150831852734808709087755641273868350720962413399868532305813227181967", - "19231103515031626108540280352804904215178644233964839448405623573586547300771", - "3202185325412846279878024015439663797323768206239602518916650099275135615824" + 'TestnetZkappBody****': [ + '20037733640875789833090442509053816933966165101372309054048970230906793051053', + '1106678471497583468621635190733109842219273971961053291385773425960251864224', + '25565387364959491931899708566015584890804577695743228799735258954982776499278', ], - "TestnetZkappBody****": [ - "20037733640875789833090442509053816933966165101372309054048970230906793051053", - "1106678471497583468621635190733109842219273971961053291385773425960251864224", - "25565387364959491931899708566015584890804577695743228799735258954982776499278" + 'MinaZkappPred*******': [ + '1288860557840839698672685006364179285130411098848600694737282320588924548492', + '24648295833336558525603848295184424886548932461541421142783307792871113347031', + '1330615836835056811243082335077124866238751435915242573993316916713469087050', ], - "MinaZkappPred*******": [ - "1288860557840839698672685006364179285130411098848600694737282320588924548492", - "24648295833336558525603848295184424886548932461541421142783307792871113347031", - "1330615836835056811243082335077124866238751435915242573993316916713469087050" + 'MinaZkappPredAcct***': [ + '16247099195538206941970428186933809576049890124762896310373916059400681012938', + '15171999803179862436296250357712424012107969488385552487664863256867849154640', + '4695118160519310765712802705640939163487421977728313886668234870398464448283', ], - "MinaZkappPredAcct***": [ - "16247099195538206941970428186933809576049890124762896310373916059400681012938", - "15171999803179862436296250357712424012107969488385552487664863256867849154640", - "4695118160519310765712802705640939163487421977728313886668234870398464448283" + 'MinaZkappPredPS*****': [ + '28115844434401213157045670864292277190427496512916771660477513364996586226191', + '17764239860871865704512758086410304367016330694375482081848267812860896213477', + '2608563583120825722034995217249250504732387097295075568312443453761249924462', ], - "MinaZkappPredPS*****": [ - "28115844434401213157045670864292277190427496512916771660477513364996586226191", - "17764239860871865704512758086410304367016330694375482081848267812860896213477", - "2608563583120825722034995217249250504732387097295075568312443453761249924462" + 'MinaAcctUpdAcctPred*': [ + '11173347481325879282537380504137543614432174467122278589147153842480174214350', + '22433785030516935555884954114999194863743668497200511950547006360846720681436', + '4261224905860522407514587942832658209487173552801239748203234114069543449134', ], - "MinaAcctUpdAcctPred*": [ - "11173347481325879282537380504137543614432174467122278589147153842480174214350", - "22433785030516935555884954114999194863743668497200511950547006360846720681436", - "4261224905860522407514587942832658209487173552801239748203234114069543449134" + 'MinaAcctUpdateCons**': [ + '7974184247425786365466969127827083941281743695327546149120833518746435921046', + '1079147682067570431747049877519099849334832444581201545961023544596733431550', + '9670106619202136718451303928765479503313491401619698334696903962327538130992', ], - "MinaAcctUpdateCons**": [ - "7974184247425786365466969127827083941281743695327546149120833518746435921046", - "1079147682067570431747049877519099849334832444581201545961023544596733431550", - "9670106619202136718451303928765479503313491401619698334696903962327538130992" + 'MinaAcctUpdateNode**': [ + '15921812961830232432174711488904180713275251781093575291539345321597011303739', + '5852213322332241594845871336918115662219071361771346507406094569679662937607', + '21122827334147180286039671993443893600964526985496742826857975683524856341379', ], - "MinaAcctUpdateNode**": [ - "15921812961830232432174711488904180713275251781093575291539345321597011303739", - "5852213322332241594845871336918115662219071361771346507406094569679662937607", - "21122827334147180286039671993443893600964526985496742826857975683524856341379" + 'MinaAcctUpdStckFrm**': [ + '1223279431820750727612295994589444883292600761079562536688416996919972234987', + '1873141333924103856860857609363983758885824745969813373245393521390926426683', + '3550105212452130151915860825756512345408015936295894584118372238840612023788', ], - "MinaAcctUpdStckFrm**": [ - "1223279431820750727612295994589444883292600761079562536688416996919972234987", - "1873141333924103856860857609363983758885824745969813373245393521390926426683", - "3550105212452130151915860825756512345408015936295894584118372238840612023788" + MinaActUpStckFrmCons: [ + '2363089775097766730570162674460603870980415123701610894146069429352874281636', + '8717086429614898734892919627864489205116600585932141922995487227707208282057', + '14660270392332597302006144557344641683528071714290878702086758222477469533211', ], - "MinaActUpStckFrmCons": [ - "2363089775097766730570162674460603870980415123701610894146069429352874281636", - "8717086429614898734892919627864489205116600585932141922995487227707208282057", - "14660270392332597302006144557344641683528071714290878702086758222477469533211" + 'MinaZkappUri********': [ + '534822897390732927195976832726937157108052596941484097303405936433225931144', + '21308674973525253012607500915181592359821899373849668837401701284134790635210', + '19235616568963430752220890547731083898076295596325584947617173371158207986317', ], - "MinaZkappUri********": [ - "534822897390732927195976832726937157108052596941484097303405936433225931144", - "21308674973525253012607500915181592359821899373849668837401701284134790635210", - "19235616568963430752220890547731083898076295596325584947617173371158207986317" + 'MinaZkappEvent******': [ + '4144672248660824652311280789227568759501644435839088465487215978090977152836', + '16580012705864177241905923711864666027965216928284588602669501632136706453456', + '28268897103231723777184618409092967932555901943057586428182153116992131011025', ], - "MinaZkappEvent******": [ - "4144672248660824652311280789227568759501644435839088465487215978090977152836", - "16580012705864177241905923711864666027965216928284588602669501632136706453456", - "28268897103231723777184618409092967932555901943057586428182153116992131011025" + 'MinaZkappEvents*****': [ + '22941690192200157010958144262626906691861453230235765939870625581651903942109', + '8085194290973996063041942057794139208480036474122767282118588735695477304146', + '26729904183313179836453835886592671283117737890095730465188585661277543615385', ], - "MinaZkappEvents*****": [ - "22941690192200157010958144262626906691861453230235765939870625581651903942109", - "8085194290973996063041942057794139208480036474122767282118588735695477304146", - "26729904183313179836453835886592671283117737890095730465188585661277543615385" + 'MinaZkappSeqEvents**': [ + '20111532619758468729019280527752703188436440291616049387250019116440725105679', + '28272901079534355755544153990297346241256584111406088887261772513761686581936', + '11593971643819429831651280663135869674712971584194549509498204047075895747923', ], - "MinaZkappSeqEvents**": [ - "20111532619758468729019280527752703188436440291616049387250019116440725105679", - "28272901079534355755544153990297346241256584111406088887261772513761686581936", - "11593971643819429831651280663135869674712971584194549509498204047075895747923" + 'MinaZkappMemo*******': [ + '2662735671148484138098041239517130399444285195614926917304994766121342901330', + '1889560324711062089177091328630260720221153765601231238715650562289804935970', + '4150523804923664151142435309968051550133270766858171566059780615187901817023', ], - "MinaZkappMemo*******": [ - "2662735671148484138098041239517130399444285195614926917304994766121342901330", - "1889560324711062089177091328630260720221153765601231238715650562289804935970", - "4150523804923664151142435309968051550133270766858171566059780615187901817023" + 'MinaZkappTest*******': [ + '23523101868899742954180674496902908392567863852999903167375927084079494055612', + '4491786955849351692402874941062803293792761915358826996649017458255778371918', + '18160445324611651688025194683090940451613686777550031421971998315243738422364', ], - "MinaZkappTest*******": [ - "23523101868899742954180674496902908392567863852999903167375927084079494055612", - "4491786955849351692402874941062803293792761915358826996649017458255778371918", - "18160445324611651688025194683090940451613686777550031421971998315243738422364" + 'MinaDeriveTokenId***': [ + '6192019453766080264591455948244350296532066491511280821771403784079613278630', + '3474280028978446563781013959252007045004226094384968366087940198662654278266', + '20434002876694963787609307807174199928279086350854834006718281273564667456637', ], - "MinaDeriveTokenId***": [ - "6192019453766080264591455948244350296532066491511280821771403784079613278630", - "3474280028978446563781013959252007045004226094384968366087940198662654278266", - "20434002876694963787609307807174199928279086350854834006718281273564667456637" + CodaReceiptEmpty: [ + '14564582992068613478915821183083107733064540968050799295374021047658500056219', + '21765043973285063733734239399942750176857972907855721619600674857294623000734', + '18519955733587546799174091248819038069762857427193969217428957100491271613694', ], - "CodaReceiptEmpty": [ - "14564582992068613478915821183083107733064540968050799295374021047658500056219", - "21765043973285063733734239399942750176857972907855721619600674857294623000734", - "18519955733587546799174091248819038069762857427193969217428957100491271613694" + MinaZkappEventsEmpty: [ + '11558119263070965853863267079253872832625419457395008685779236645292569607921', + '25458142203119307439619503192644060065091275427503371449742352140981637359577', + '28343474290528262467651243371210869540984529302238754668057531270656874883506', ], - "MinaZkappEventsEmpty": [ - "11558119263070965853863267079253872832625419457395008685779236645292569607921", - "25458142203119307439619503192644060065091275427503371449742352140981637359577", - "28343474290528262467651243371210869540984529302238754668057531270656874883506" + MinaZkappActionsEmpty: [ + '2965377540200775924504968637505084669999360240500907972788072774778139588064', + '17888733104410001265760460027725887240172765470923695174284923303416908725309', + '6155733123951817300356401771271939707310716210385193729101357561319788034953', ], - "MinaZkappActionsEmpty": [ - "2965377540200775924504968637505084669999360240500907972788072774778139588064", - "17888733104410001265760460027725887240172765470923695174284923303416908725309", - "6155733123951817300356401771271939707310716210385193729101357561319788034953" + MinaZkappActionStateEmptyElt: [ + '25079927036070901246064867767436987657692091363973573142121686150614948079097', + '26431778411571512074795067173224334387034335867358343719815640998216694007738', + '25080775363764450744501815075506845022058095277795060631172637381645274354727', ], - "MinaZkappActionStateEmptyElt": [ - "25079927036070901246064867767436987657692091363973573142121686150614948079097", - "26431778411571512074795067173224334387034335867358343719815640998216694007738", - "25080775363764450744501815075506845022058095277795060631172637381645274354727" + CoinbaseStack: [ + '13478948633790621346997153068092516261975764161208078295837519850718904039733', + '23794571567771902109532327523992257297445027552423990566905688786749549749640', + '12437776415960587857483436445253285567999534294199440886476575966193776753527', ], - "CoinbaseStack": [ - "13478948633790621346997153068092516261975764161208078295837519850718904039733", - "23794571567771902109532327523992257297445027552423990566905688786749549749640", - "12437776415960587857483436445253285567999534294199440886476575966193776753527" + PendingCoinbaseMerkleTree: [ + '21962074494103541153175746450273873003299668759086391980006382367241943398196', + '2903435713642676558047328375873609628346075739786101737671585224825766548393', + '25831764682100331646870313396659195191400312071282528592914032765816857800473', ], - "PendingCoinbaseMerkleTree": [ - "21962074494103541153175746450273873003299668759086391980006382367241943398196", - "2903435713642676558047328375873609628346075739786101737671585224825766548393", - "25831764682100331646870313396659195191400312071282528592914032765816857800473" - ] }; let prefixHashesLegacy = { - "CodaReceiptUC*******": [ - "17081977821176270994512651394491195177111442160604726653596300537904083542874", - "22524836078442467808299966370016521142448937585030982609163888361124501146539", - "12924279821307137198726349959646209575189430925513631516289320462608412110369" + 'CodaReceiptUC*******': [ + '17081977821176270994512651394491195177111442160604726653596300537904083542874', + '22524836078442467808299966370016521142448937585030982609163888361124501146539', + '12924279821307137198726349959646209575189430925513631516289320462608412110369', ], - "MinaSignatureMainnet": [ - "25220214331362653986409717908235786107802222826119905443072293294098933388948", - "7563646774167489166725044360539949525624365058064455335567047240620397351731", - "171774671134240704318655896509797243441784148630375331692878460323037832932" + MinaSignatureMainnet: [ + '25220214331362653986409717908235786107802222826119905443072293294098933388948', + '7563646774167489166725044360539949525624365058064455335567047240620397351731', + '171774671134240704318655896509797243441784148630375331692878460323037832932', + ], + 'CodaSignature*******': [ + '28132119227444686413214523693400847740858213284875453355294308721084881982354', + '24895072146662946646133617369498198544578131474807621989761680811592073367193', + '3216013753133880902260672769141972972810073620591719805178695684388949134646', ], - "CodaSignature*******": [ - "28132119227444686413214523693400847740858213284875453355294308721084881982354", - "24895072146662946646133617369498198544578131474807621989761680811592073367193", - "3216013753133880902260672769141972972810073620591719805178695684388949134646" - ] }; let versionBytes = { - "tokenIdKey": 28, - "receiptChainHash": 12, - "ledgerHash": 5, - "epochSeed": 13, - "stateHash": 16, - "publicKey": 203, - "userCommandMemo": 20, - "privateKey": 90, - "signature": 154, - "transactionHash": 29, - "signedCommandV1": 19 + tokenIdKey: 28, + receiptChainHash: 12, + ledgerHash: 5, + epochSeed: 13, + stateHash: 16, + publicKey: 203, + userCommandMemo: 20, + privateKey: 90, + signature: 154, + transactionHash: 29, + signedCommandV1: 19, }; -let protocolVersions = { "txnVersion": 3 }; +let protocolVersions = { txnVersion: 3 }; let poseidonParamsKimchiFp = { - "mds": [ + mds: [ [ - "12035446894107573964500871153637039653510326950134440362813193268448863222019", - "25461374787957152039031444204194007219326765802730624564074257060397341542093", - "27667907157110496066452777015908813333407980290333709698851344970789663080149" + '12035446894107573964500871153637039653510326950134440362813193268448863222019', + '25461374787957152039031444204194007219326765802730624564074257060397341542093', + '27667907157110496066452777015908813333407980290333709698851344970789663080149', ], [ - "4491931056866994439025447213644536587424785196363427220456343191847333476930", - "14743631939509747387607291926699970421064627808101543132147270746750887019919", - "9448400033389617131295304336481030167723486090288313334230651810071857784477" + '4491931056866994439025447213644536587424785196363427220456343191847333476930', + '14743631939509747387607291926699970421064627808101543132147270746750887019919', + '9448400033389617131295304336481030167723486090288313334230651810071857784477', ], [ - "10525578725509990281643336361904863911009900817790387635342941550657754064843", - "27437632000253211280915908546961303399777448677029255413769125486614773776695", - "27566319851776897085443681456689352477426926500749993803132851225169606086988" - ] + '10525578725509990281643336361904863911009900817790387635342941550657754064843', + '27437632000253211280915908546961303399777448677029255413769125486614773776695', + '27566319851776897085443681456689352477426926500749993803132851225169606086988', + ], ], - "roundConstants": [ + roundConstants: [ [ - "21155079691556475130150866428468322463125560312786319980770950159250751855431", - "16883442198399350202652499677723930673110172289234921799701652810789093522349", - "17030687036425314703519085065002231920937594822150793091243263847382891822670" + '21155079691556475130150866428468322463125560312786319980770950159250751855431', + '16883442198399350202652499677723930673110172289234921799701652810789093522349', + '17030687036425314703519085065002231920937594822150793091243263847382891822670', ], [ - "25216718237129482752721276445368692059997901880654047883630276346421457427360", - "9054264347380455706540423067244764093107767235485930776517975315876127782582", - "26439087121446593160953570192891907825526260324480347638727375735543609856888" + '25216718237129482752721276445368692059997901880654047883630276346421457427360', + '9054264347380455706540423067244764093107767235485930776517975315876127782582', + '26439087121446593160953570192891907825526260324480347638727375735543609856888', ], [ - "15251000790817261169639394496851831733819930596125214313084182526610855787494", - "10861916012597714684433535077722887124099023163589869801449218212493070551767", - "18597653523270601187312528478986388028263730767495975370566527202946430104139" + '15251000790817261169639394496851831733819930596125214313084182526610855787494', + '10861916012597714684433535077722887124099023163589869801449218212493070551767', + '18597653523270601187312528478986388028263730767495975370566527202946430104139', ], [ - "15831416454198644276563319006805490049460322229057756462580029181847589006611", - "15171856919255965617705854914448645702014039524159471542852132430360867202292", - "15488495958879593647482715143904752785889816789652405888927117106448507625751" + '15831416454198644276563319006805490049460322229057756462580029181847589006611', + '15171856919255965617705854914448645702014039524159471542852132430360867202292', + '15488495958879593647482715143904752785889816789652405888927117106448507625751', ], [ - "19039802679983063488134304670998725949842655199289961967801223969839823940152", - "4720101937153217036737330058775388037616286510783561045464678919473230044408", - "10226318327254973427513859412126640040910264416718766418164893837597674300190" + '19039802679983063488134304670998725949842655199289961967801223969839823940152', + '4720101937153217036737330058775388037616286510783561045464678919473230044408', + '10226318327254973427513859412126640040910264416718766418164893837597674300190', ], [ - "20878756131129218406920515859235137275859844638301967889441262030146031838819", - "7178475685651744631172532830973371642652029385893667810726019303466125436953", - "1996970955918516145107673266490486752153434673064635795711751450164177339618" + '20878756131129218406920515859235137275859844638301967889441262030146031838819', + '7178475685651744631172532830973371642652029385893667810726019303466125436953', + '1996970955918516145107673266490486752153434673064635795711751450164177339618', ], [ - "15205545916434157464929420145756897321482314798910153575340430817222504672630", - "25660296961552699573824264215804279051322332899472350724416657386062327210698", - "13842611741937412200312851417353455040950878279339067816479233688850376089318" + '15205545916434157464929420145756897321482314798910153575340430817222504672630', + '25660296961552699573824264215804279051322332899472350724416657386062327210698', + '13842611741937412200312851417353455040950878279339067816479233688850376089318', ], [ - "1383799642177300432144836486981606294838630135265094078921115713566691160459", - "1135532281155277588005319334542025976079676424839948500020664227027300010929", - "4384117336930380014868572224801371377488688194169758696438185377724744869360" + '1383799642177300432144836486981606294838630135265094078921115713566691160459', + '1135532281155277588005319334542025976079676424839948500020664227027300010929', + '4384117336930380014868572224801371377488688194169758696438185377724744869360', ], [ - "21725577575710270071808882335900370909424604447083353471892004026180492193649", - "676128913284806802699862508051022306366147359505124346651466289788974059668", - "25186611339598418732666781049829183886812651492845008333418424746493100589207" + '21725577575710270071808882335900370909424604447083353471892004026180492193649', + '676128913284806802699862508051022306366147359505124346651466289788974059668', + '25186611339598418732666781049829183886812651492845008333418424746493100589207', ], [ - "10402240124664763733060094237696964473609580414190944671778761753887884341073", - "11918307118590866200687906627767559273324023585642003803337447146531313172441", - "16895677254395661024186292503536662354181715337630376909778003268311296637301" + '10402240124664763733060094237696964473609580414190944671778761753887884341073', + '11918307118590866200687906627767559273324023585642003803337447146531313172441', + '16895677254395661024186292503536662354181715337630376909778003268311296637301', ], [ - "23818602699032741669874498456696325705498383130221297580399035778119213224810", - "4285193711150023248690088154344086684336247475445482883105661485741762600154", - "19133204443389422404056150665863951250222934590192266371578950735825153238612" + '23818602699032741669874498456696325705498383130221297580399035778119213224810', + '4285193711150023248690088154344086684336247475445482883105661485741762600154', + '19133204443389422404056150665863951250222934590192266371578950735825153238612', ], [ - "5515589673266504033533906836494002702866463791762187140099560583198974233395", - "11830435563729472715615302060564876527985621376031612798386367965451821182352", - "7510711479224915247011074129666445216001563200717943545636462819681638560128" + '5515589673266504033533906836494002702866463791762187140099560583198974233395', + '11830435563729472715615302060564876527985621376031612798386367965451821182352', + '7510711479224915247011074129666445216001563200717943545636462819681638560128', ], [ - "24694843201907722940091503626731830056550128225297370217610328578733387733444", - "27361655066973784653563425664091383058914302579694897188019422193564924110528", - "21606788186194534241166833954371013788633495786419718955480491478044413102713" + '24694843201907722940091503626731830056550128225297370217610328578733387733444', + '27361655066973784653563425664091383058914302579694897188019422193564924110528', + '21606788186194534241166833954371013788633495786419718955480491478044413102713', ], [ - "19934060063390905409309407607814787335159021816537006003398035237707924006757", - "8495813630060004961768092461554180468161254914257386012937942498774724649553", - "27524960680529762202005330464726908693944660961000958842417927307941561848461" + '19934060063390905409309407607814787335159021816537006003398035237707924006757', + '8495813630060004961768092461554180468161254914257386012937942498774724649553', + '27524960680529762202005330464726908693944660961000958842417927307941561848461', ], [ - "15178481650950399259757805400615635703086255035073919114667254549690862896985", - "16164780354695672259791105197274509251141405713012804937107314962551600380870", - "10529167793600778056702353412758954281652843049850979705476598375597148191979" + '15178481650950399259757805400615635703086255035073919114667254549690862896985', + '16164780354695672259791105197274509251141405713012804937107314962551600380870', + '10529167793600778056702353412758954281652843049850979705476598375597148191979', ], [ - "721141070179074082553302896292167103755384741083338957818644728290501449040", - "22044408985956234023934090378372374883099115753118261312473550998188148912041", - "27068254103241989852888872162525066148367014691482601147536314217249046186315" + '721141070179074082553302896292167103755384741083338957818644728290501449040', + '22044408985956234023934090378372374883099115753118261312473550998188148912041', + '27068254103241989852888872162525066148367014691482601147536314217249046186315', ], [ - "3880429241956357176819112098792744584376727450211873998699580893624868748961", - "17387097125522937623262508065966749501583017524609697127088211568136333655623", - "6256814421247770895467770393029354017922744712896100913895513234184920631289" + '3880429241956357176819112098792744584376727450211873998699580893624868748961', + '17387097125522937623262508065966749501583017524609697127088211568136333655623', + '6256814421247770895467770393029354017922744712896100913895513234184920631289', ], [ - "2942627347777337187690939671601251987500285937340386328746818861972711408579", - "24031654937764287280548628128490074801809101323243546313826173430897408945397", - "14401457902976567713827506689641442844921449636054278900045849050301331732143" + '2942627347777337187690939671601251987500285937340386328746818861972711408579', + '24031654937764287280548628128490074801809101323243546313826173430897408945397', + '14401457902976567713827506689641442844921449636054278900045849050301331732143', ], [ - "20170632877385406450742199836933900257692624353889848352407590794211839130727", - "24056496193857444725324410428861722338174099794084586764867109123681727290181", - "11257913009612703357266904349759250619633397075667824800196659858304604714965" + '20170632877385406450742199836933900257692624353889848352407590794211839130727', + '24056496193857444725324410428861722338174099794084586764867109123681727290181', + '11257913009612703357266904349759250619633397075667824800196659858304604714965', ], [ - "22228158921984425749199071461510152694025757871561406897041788037116931009246", - "9152163378317846541430311327336774331416267016980485920222768197583559318682", - "13906695403538884432896105059360907560653506400343268230130536740148070289175" + '22228158921984425749199071461510152694025757871561406897041788037116931009246', + '9152163378317846541430311327336774331416267016980485920222768197583559318682', + '13906695403538884432896105059360907560653506400343268230130536740148070289175', ], [ - "7220714562509721437034241786731185291972496952091254931195414855962344025067", - "27608867305903811397208862801981345878179337369367554478205559689592889691927", - "13288465747219756218882697408422850918209170830515545272152965967042670763153" + '7220714562509721437034241786731185291972496952091254931195414855962344025067', + '27608867305903811397208862801981345878179337369367554478205559689592889691927', + '13288465747219756218882697408422850918209170830515545272152965967042670763153', ], [ - "8251343892709140154567051772980662609566359215743613773155065627504813327653", - "22035238365102171608166944627493632660244312563934708756134297161332908879090", - "13560937766273321037807329177749403409731524715067067740487246745322577571823" + '8251343892709140154567051772980662609566359215743613773155065627504813327653', + '22035238365102171608166944627493632660244312563934708756134297161332908879090', + '13560937766273321037807329177749403409731524715067067740487246745322577571823', ], [ - "21652518608959234550262559135285358020552897349934571164032339186996805408040", - "22479086963324173427634460342145551255011746993910136574926173581069603086891", - "13676501958531751140966255121288182631772843001727158043704693838707387130095" + '21652518608959234550262559135285358020552897349934571164032339186996805408040', + '22479086963324173427634460342145551255011746993910136574926173581069603086891', + '13676501958531751140966255121288182631772843001727158043704693838707387130095', ], [ - "5680310394102577950568930199056707827608275306479994663197187031893244826674", - "25125360450906166639190392763071557410047335755341060350879819485506243289998", - "22659254028501616785029594492374243581602744364859762239504348429834224676676" + '5680310394102577950568930199056707827608275306479994663197187031893244826674', + '25125360450906166639190392763071557410047335755341060350879819485506243289998', + '22659254028501616785029594492374243581602744364859762239504348429834224676676', ], [ - "23101411405087512171421838856759448177512679869882987631073569441496722536782", - "24149774013240355952057123660656464942409328637280437515964899830988178868108", - "5782097512368226173095183217893826020351125522160843964147125728530147423065" + '23101411405087512171421838856759448177512679869882987631073569441496722536782', + '24149774013240355952057123660656464942409328637280437515964899830988178868108', + '5782097512368226173095183217893826020351125522160843964147125728530147423065', ], [ - "13540762114500083869920564649399977644344247485313990448129838910231204868111", - "20421637734328811337527547703833013277831804985438407401987624070721139913982", - "7742664118615900772129122541139124149525273579639574972380600206383923500701" + '13540762114500083869920564649399977644344247485313990448129838910231204868111', + '20421637734328811337527547703833013277831804985438407401987624070721139913982', + '7742664118615900772129122541139124149525273579639574972380600206383923500701', ], [ - "1109643801053963021778418773196543643970146666329661268825691230294798976318", - "16580663920817053843121063692728699890952505074386761779275436996241901223840", - "14638514680222429058240285918830106208025229459346033470787111294847121792366" + '1109643801053963021778418773196543643970146666329661268825691230294798976318', + '16580663920817053843121063692728699890952505074386761779275436996241901223840', + '14638514680222429058240285918830106208025229459346033470787111294847121792366', ], [ - "17080385857812672649489217965285727739557573467014392822992021264701563205891", - "26176268111736737558502775993925696791974738793095023824029827577569530708665", - "4382756253392449071896813428140986330161215829425086284611219278674857536001" + '17080385857812672649489217965285727739557573467014392822992021264701563205891', + '26176268111736737558502775993925696791974738793095023824029827577569530708665', + '4382756253392449071896813428140986330161215829425086284611219278674857536001', ], [ - "13934033814940585315406666445960471293638427404971553891617533231178815348902", - "27054912732979753314774418228399230433963143177662848084045249524271046173121", - "28916070403698593376490976676534962592542013020010643734621202484860041243391" + '13934033814940585315406666445960471293638427404971553891617533231178815348902', + '27054912732979753314774418228399230433963143177662848084045249524271046173121', + '28916070403698593376490976676534962592542013020010643734621202484860041243391', ], [ - "24820015636966360150164458094894587765384135259446295278101998130934963922381", - "7969535238488580655870884015145760954416088335296905520306227531221721881868", - "7690547696740080985104189563436871930607055124031711216224219523236060212249" + '24820015636966360150164458094894587765384135259446295278101998130934963922381', + '7969535238488580655870884015145760954416088335296905520306227531221721881868', + '7690547696740080985104189563436871930607055124031711216224219523236060212249', ], [ - "9712576468091272384496248353414290908377825697488757134833205246106605867289", - "12148698031438398980683630141370402088785182722473169207262735228500190477924", - "14359657643133476969781351728574842164124292705609900285041476162075031948227" + '9712576468091272384496248353414290908377825697488757134833205246106605867289', + '12148698031438398980683630141370402088785182722473169207262735228500190477924', + '14359657643133476969781351728574842164124292705609900285041476162075031948227', ], [ - "23563839965372067275137992801035780013422228997724286060975035719045352435470", - "4184634822776323233231956802962638484057536837393405750680645555481330909086", - "16249511905185772125762038789038193114431085603985079639889795722501216492487" + '23563839965372067275137992801035780013422228997724286060975035719045352435470', + '4184634822776323233231956802962638484057536837393405750680645555481330909086', + '16249511905185772125762038789038193114431085603985079639889795722501216492487', ], [ - "11001863048692031559800673473526311616702863826063550559568315794438941516621", - "4702354107983530219070178410740869035350641284373933887080161024348425080464", - "23751680507533064238793742311430343910720206725883441625894258483004979501613" + '11001863048692031559800673473526311616702863826063550559568315794438941516621', + '4702354107983530219070178410740869035350641284373933887080161024348425080464', + '23751680507533064238793742311430343910720206725883441625894258483004979501613', ], [ - "28670526516158451470169873496541739545860177757793329093045522432279094518766", - "3568312993091537758218792253361873752799472566055209125947589819564395417072", - "1819755756343439646550062754332039103654718693246396323207323333948654200950" + '28670526516158451470169873496541739545860177757793329093045522432279094518766', + '3568312993091537758218792253361873752799472566055209125947589819564395417072', + '1819755756343439646550062754332039103654718693246396323207323333948654200950', ], [ - "5372129954699791301953948907349887257752247843844511069896766784624930478273", - "17512156688034945920605615850550150476471921176481039715733979181538491476080", - "25777105342317622165159064911913148785971147228777677435200128966844208883059" + '5372129954699791301953948907349887257752247843844511069896766784624930478273', + '17512156688034945920605615850550150476471921176481039715733979181538491476080', + '25777105342317622165159064911913148785971147228777677435200128966844208883059', ], [ - "25350392006158741749134238306326265756085455157012701586003300872637887157982", - "20096724945283767296886159120145376967480397366990493578897615204296873954844", - "8063283381910110762785892100479219642751540456251198202214433355775540036851" + '25350392006158741749134238306326265756085455157012701586003300872637887157982', + '20096724945283767296886159120145376967480397366990493578897615204296873954844', + '8063283381910110762785892100479219642751540456251198202214433355775540036851', ], [ - "4393613870462297385565277757207010824900723217720226130342463666351557475823", - "9874972555132910032057499689351411450892722671352476280351715757363137891038", - "23590926474329902351439438151596866311245682682435235170001347511997242904868" + '4393613870462297385565277757207010824900723217720226130342463666351557475823', + '9874972555132910032057499689351411450892722671352476280351715757363137891038', + '23590926474329902351439438151596866311245682682435235170001347511997242904868', ], [ - "17723373371137275859467518615551278584842947963894791032296774955869958211070", - "2350345015303336966039836492267992193191479606566494799781846958620636621159", - "27755207882790211140683010581856487965587066971982625511152297537534623405016" + '17723373371137275859467518615551278584842947963894791032296774955869958211070', + '2350345015303336966039836492267992193191479606566494799781846958620636621159', + '27755207882790211140683010581856487965587066971982625511152297537534623405016', ], [ - "6584607987789185408123601849106260907671314994378225066806060862710814193906", - "609759108847171587253578490536519506369136135254150754300671591987320319770", - "28435187585965602110074342250910608316032945187476441868666714022529803033083" + '6584607987789185408123601849106260907671314994378225066806060862710814193906', + '609759108847171587253578490536519506369136135254150754300671591987320319770', + '28435187585965602110074342250910608316032945187476441868666714022529803033083', ], [ - "16016664911651770663938916450245705908287192964254704641717751103464322455303", - "17551273293154696089066968171579395800922204266630874071186322718903959339163", - "20414195497994754529479032467015716938594722029047207834858832838081413050198" + '16016664911651770663938916450245705908287192964254704641717751103464322455303', + '17551273293154696089066968171579395800922204266630874071186322718903959339163', + '20414195497994754529479032467015716938594722029047207834858832838081413050198', ], [ - "19773307918850685463180290966774465805537520595602496529624568184993487593855", - "24598603838812162820757838364185126333280131847747737533989799467867231166980", - "11040972566103463398651864390163813377135738019556270484707889323659789290225" + '19773307918850685463180290966774465805537520595602496529624568184993487593855', + '24598603838812162820757838364185126333280131847747737533989799467867231166980', + '11040972566103463398651864390163813377135738019556270484707889323659789290225', ], [ - "5189242080957784038860188184443287562488963023922086723850863987437818393811", - "1435203288979376557721239239445613396009633263160237764653161500252258220144", - "13066591163578079667911016543985168493088721636164837520689376346534152547210" + '5189242080957784038860188184443287562488963023922086723850863987437818393811', + '1435203288979376557721239239445613396009633263160237764653161500252258220144', + '13066591163578079667911016543985168493088721636164837520689376346534152547210', ], [ - "17345901407013599418148210465150865782628422047458024807490502489711252831342", - "22139633362249671900128029132387275539363684188353969065288495002671733200348", - "1061056418502836172283188490483332922126033656372467737207927075184389487061" + '17345901407013599418148210465150865782628422047458024807490502489711252831342', + '22139633362249671900128029132387275539363684188353969065288495002671733200348', + '1061056418502836172283188490483332922126033656372467737207927075184389487061', ], [ - "10241738906190857416046229928455551829189196941239601756375665129874835232299", - "27808033332417845112292408673209999320983657696373938259351951416571545364415", - "18820154989873674261497645724903918046694142479240549687085662625471577737140" + '10241738906190857416046229928455551829189196941239601756375665129874835232299', + '27808033332417845112292408673209999320983657696373938259351951416571545364415', + '18820154989873674261497645724903918046694142479240549687085662625471577737140', ], [ - "7983688435214640842673294735439196010654951226956101271763849527529940619307", - "17067928657801807648925755556866676899145460770352731818062909643149568271566", - "24472070825156236829515738091791182856425635433388202153358580534810244942762" + '7983688435214640842673294735439196010654951226956101271763849527529940619307', + '17067928657801807648925755556866676899145460770352731818062909643149568271566', + '24472070825156236829515738091791182856425635433388202153358580534810244942762', ], [ - "25752201169361795911258625731016717414310986450004737514595241038036936283227", - "26041505376284666160132119888949817249574689146924196064963008712979256107535", - "23977050489096115210391718599021827780049209314283111721864956071820102846008" + '25752201169361795911258625731016717414310986450004737514595241038036936283227', + '26041505376284666160132119888949817249574689146924196064963008712979256107535', + '23977050489096115210391718599021827780049209314283111721864956071820102846008', ], [ - "26678257097278788410676026718736087312816016749016738933942134600725962413805", - "10480026985951498884090911619636977502506079971893083605102044931823547311729", - "21126631300593007055117122830961273871167754554670317425822083333557535463396" + '26678257097278788410676026718736087312816016749016738933942134600725962413805', + '10480026985951498884090911619636977502506079971893083605102044931823547311729', + '21126631300593007055117122830961273871167754554670317425822083333557535463396', ], [ - "1564862894215434177641156287699106659379648851457681469848362532131406827573", - "13247162472821152334486419054854847522301612781818744556576865965657773174584", - "8673615954922496961704442777870253767001276027366984739283715623634850885984" + '1564862894215434177641156287699106659379648851457681469848362532131406827573', + '13247162472821152334486419054854847522301612781818744556576865965657773174584', + '8673615954922496961704442777870253767001276027366984739283715623634850885984', ], [ - "2794525076937490807476666942602262298677291735723129868457629508555429470085", - "4656175953888995612264371467596648522808911819700660048695373348629527757049", - "23221574237857660318443567292601561932489621919104226163978909845174616477329" + '2794525076937490807476666942602262298677291735723129868457629508555429470085', + '4656175953888995612264371467596648522808911819700660048695373348629527757049', + '23221574237857660318443567292601561932489621919104226163978909845174616477329', ], [ - "1878392460078272317716114458784636517603142716091316893054365153068227117145", - "2370412714505757731457251173604396662292063533194555369091306667486647634097", - "17409784861870189930766639925394191888667317762328427589153989811980152373276" + '1878392460078272317716114458784636517603142716091316893054365153068227117145', + '2370412714505757731457251173604396662292063533194555369091306667486647634097', + '17409784861870189930766639925394191888667317762328427589153989811980152373276', ], [ - "25869136641898166514111941708608048269584233242773814014385564101168774293194", - "11361209360311194794795494027949518465383235799633128250259863567683341091323", - "14913258820718821235077379851098720071902170702113538811112331615559409988569" + '25869136641898166514111941708608048269584233242773814014385564101168774293194', + '11361209360311194794795494027949518465383235799633128250259863567683341091323', + '14913258820718821235077379851098720071902170702113538811112331615559409988569', ], [ - "12957012022018304419868287033513141736995211906682903915897515954290678373899", - "17128889547450684566010972445328859295804027707361763477802050112063630550300", - "23329219085372232771288306767242735245018143857623151155581182779769305489903" + '12957012022018304419868287033513141736995211906682903915897515954290678373899', + '17128889547450684566010972445328859295804027707361763477802050112063630550300', + '23329219085372232771288306767242735245018143857623151155581182779769305489903', ], [ - "1607741027962933685476527275858938699728586794398382348454736018784568853937", - "2611953825405141009309433982109911976923326848135736099261873796908057448476", - "7372230383134982628913227482618052530364724821976589156840317933676130378411" + '1607741027962933685476527275858938699728586794398382348454736018784568853937', + '2611953825405141009309433982109911976923326848135736099261873796908057448476', + '7372230383134982628913227482618052530364724821976589156840317933676130378411', ], [ - "20203606758501212620842735123770014952499754751430660463060696990317556818571", - "4678361398979174017885631008335559529633853759463947250620930343087749944307", - "27176462634198471376002287271754121925750749676999036165457559387195124025594" + '20203606758501212620842735123770014952499754751430660463060696990317556818571', + '4678361398979174017885631008335559529633853759463947250620930343087749944307', + '27176462634198471376002287271754121925750749676999036165457559387195124025594', ], [ - "6361981813552614697928697527332318530502852015189048838072565811230204474643", - "13815234633287489023151647353581705241145927054858922281829444557905946323248", - "10888828634279127981352133512429657747610298502219125571406085952954136470354" - ] + '6361981813552614697928697527332318530502852015189048838072565811230204474643', + '13815234633287489023151647353581705241145927054858922281829444557905946323248', + '10888828634279127981352133512429657747610298502219125571406085952954136470354', + ], ], - "fullRounds": 55, - "partialRounds": 0, - "hasInitialRoundConstant": false, - "stateSize": 3, - "rate": 2, - "power": 7 + fullRounds: 55, + partialRounds: 0, + hasInitialRoundConstant: false, + stateSize: 3, + rate: 2, + power: 7, }; let poseidonParamsLegacyFp = { - "mds": [ + mds: [ [ - "5328350144166205084223774245058198666309664348635459768305312917086056785354", - "15214731724107930304595906373487084110291887262136882623959435918484004667388", - "22399519358931858664262538157042328690232277435337286643350379269028878354609" + '5328350144166205084223774245058198666309664348635459768305312917086056785354', + '15214731724107930304595906373487084110291887262136882623959435918484004667388', + '22399519358931858664262538157042328690232277435337286643350379269028878354609', ], [ - "10086628405675314879458652402278736459294354590428582803795166650930540770072", - "17127968360683744052278857147989507037142007029142438136689352416106177192235", - "14207324749280135281015658576564097509614634975132487654324863824516044294735" + '10086628405675314879458652402278736459294354590428582803795166650930540770072', + '17127968360683744052278857147989507037142007029142438136689352416106177192235', + '14207324749280135281015658576564097509614634975132487654324863824516044294735', ], [ - "3059104278162906687184746935153057867173086006783171716838577369156969739687", - "16755849208683706534025643823697988418063305979108082130624352443958404325985", - "16889774624482628108075965871448623911656600744832339664842346756371603433407" - ] + '3059104278162906687184746935153057867173086006783171716838577369156969739687', + '16755849208683706534025643823697988418063305979108082130624352443958404325985', + '16889774624482628108075965871448623911656600744832339664842346756371603433407', + ], ], - "roundConstants": [ + roundConstants: [ [ - "1346081094044643970582493287085428191977688221215786919106342366360741041016", - "10635969173348128974923358283368657934408577270968219574411363948927109531877", - "18431955373344919956072236142080066866861234899777299873162413437379924987003" + '1346081094044643970582493287085428191977688221215786919106342366360741041016', + '10635969173348128974923358283368657934408577270968219574411363948927109531877', + '18431955373344919956072236142080066866861234899777299873162413437379924987003', ], [ - "5797044060651575840084283729791357462720161727701814038830889113712361837236", - "931288489507796144596974766082847744938192694315568692730730202141894005205", - "13659894470945121760517769979107966886673294523737498361566285362771110125394" + '5797044060651575840084283729791357462720161727701814038830889113712361837236', + '931288489507796144596974766082847744938192694315568692730730202141894005205', + '13659894470945121760517769979107966886673294523737498361566285362771110125394', ], [ - "6076231707445968054305995680347976771585015308155855387339303513025362636128", - "28822740034050339685362260108484262889265034407340240070058997651710236456303", - "23420266473857869790486107029614186913447272961845992963194006142267563993493" + '6076231707445968054305995680347976771585015308155855387339303513025362636128', + '28822740034050339685362260108484262889265034407340240070058997651710236456303', + '23420266473857869790486107029614186913447272961845992963194006142267563993493', ], [ - "13753917374184785903125509246122783296344288469304898921025291716613575849357", - "22396739346703340038555577564698139382745239004673153148674304627904081092826", - "13064238335532551154986111986409392866270911640785653458047811526842088084911" + '13753917374184785903125509246122783296344288469304898921025291716613575849357', + '22396739346703340038555577564698139382745239004673153148674304627904081092826', + '13064238335532551154986111986409392866270911640785653458047811526842088084911', ], [ - "23165923875642452719095776619341762858050322341374771345641255745672274104746", - "1876216571769482372914291210815859835162659440705283782713345335434924136736", - "25448252060136178247213604035267580231762596830634036926922217427938159849142" + '23165923875642452719095776619341762858050322341374771345641255745672274104746', + '1876216571769482372914291210815859835162659440705283782713345335434924136736', + '25448252060136178247213604035267580231762596830634036926922217427938159849142', ], [ - "2161875315509206970842862195937323600322108268401381254431163181777726747153", - "19159855698625842998331760283165907305622417625829203038229273729196960321630", - "24828563875172432296791053766778475681869974948122169083176331088266823626561" + '2161875315509206970842862195937323600322108268401381254431163181777726747153', + '19159855698625842998331760283165907305622417625829203038229273729196960321630', + '24828563875172432296791053766778475681869974948122169083176331088266823626561', ], [ - "15959479662608710141128458274961057999257961784282074767105536637788386907463", - "8006369581283017287449277389162056290714176164680299906116833200510117952858", - "18794336794618132129607701188430371953320538976527988886453665523008714542779" + '15959479662608710141128458274961057999257961784282074767105536637788386907463', + '8006369581283017287449277389162056290714176164680299906116833200510117952858', + '18794336794618132129607701188430371953320538976527988886453665523008714542779', ], [ - "19408271715954593722501381885401160867835377473312521553027032015227895029571", - "13654747284005184272412579731446984220568337794941823533879059135026064413631", - "14094055032353750931629930778481002727722804310855727808905931659115939920989" + '19408271715954593722501381885401160867835377473312521553027032015227895029571', + '13654747284005184272412579731446984220568337794941823533879059135026064413631', + '14094055032353750931629930778481002727722804310855727808905931659115939920989', ], [ - "13241818625838429282823260827177433104574315653706102174619924764342778921524", - "25709259239494174564705048436260891089407557689981668111890003079561388887725", - "26866626910239634723971078462134580196819809568632305020800296809092442642381" + '13241818625838429282823260827177433104574315653706102174619924764342778921524', + '25709259239494174564705048436260891089407557689981668111890003079561388887725', + '26866626910239634723971078462134580196819809568632305020800296809092442642381', ], [ - "23886826350713085163238005260075062110062681905356997481925492650252417143049", - "16853602711255261520713463306790360324679500458440235992292027384928526778856", - "18444710386168488194610417945072711530390091945738595259171890487504771614189" + '23886826350713085163238005260075062110062681905356997481925492650252417143049', + '16853602711255261520713463306790360324679500458440235992292027384928526778856', + '18444710386168488194610417945072711530390091945738595259171890487504771614189', ], [ - "16896789009769903615328691751424474161656500693270070895928499575572871141439", - "23842266984616972287898037872537536999393060934879414668030219493005225085992", - "24369698563802298585444760814856330583118549706483939267059237951238240608187" + '16896789009769903615328691751424474161656500693270070895928499575572871141439', + '23842266984616972287898037872537536999393060934879414668030219493005225085992', + '24369698563802298585444760814856330583118549706483939267059237951238240608187', ], [ - "25360195173713628054110426524260405937218170863260484655473435413697869858790", - "1486437708678506228822038923353468635394979165769861487132708983207562337116", - "18653498960429911228442559598959970807723487073275324556015861725806677047150" + '25360195173713628054110426524260405937218170863260484655473435413697869858790', + '1486437708678506228822038923353468635394979165769861487132708983207562337116', + '18653498960429911228442559598959970807723487073275324556015861725806677047150', ], [ - "18878179044241268037057256060083772636369783391816038647949347814518015576522", - "178715779905629247116805974152863592571182389085419970371289655361443016848", - "8381006794425876451998903949255801618132578446062133243427381291481465852184" + '18878179044241268037057256060083772636369783391816038647949347814518015576522', + '178715779905629247116805974152863592571182389085419970371289655361443016848', + '8381006794425876451998903949255801618132578446062133243427381291481465852184', ], [ - "4176946262813877719206528849579392120806054050640974718891398605746592169324", - "16376345520728802444699629729684297833862527190772376028981704525651968727081", - "8399065769082251057361366626601550736334213197703006866551331927128775757919" + '4176946262813877719206528849579392120806054050640974718891398605746592169324', + '16376345520728802444699629729684297833862527190772376028981704525651968727081', + '8399065769082251057361366626601550736334213197703006866551331927128775757919', ], [ - "15435308585611812393531506745122614542196708285088622615406141986333182280857", - "4082259282787276939431186930090898350392871145699460879678141552997816391817", - "26348742719959309014730178326877937464605873211235784184917342950648457078699" + '15435308585611812393531506745122614542196708285088622615406141986333182280857', + '4082259282787276939431186930090898350392871145699460879678141552997816391817', + '26348742719959309014730178326877937464605873211235784184917342950648457078699', ], [ - "9707631711734344681918469569872517425107158187591261754498805460753455298868", - "27910768846011709391567916011595957279088224137468948238696800459136335473132", - "20407239095656434708569263842372155762970847207558227886302782130015730063802" + '9707631711734344681918469569872517425107158187591261754498805460753455298868', + '27910768846011709391567916011595957279088224137468948238696800459136335473132', + '20407239095656434708569263842372155762970847207558227886302782130015730063802', ], [ - "22726225412881182965250630589245572283256255052470345984553083359461473893802", - "12443967854426795490638709950679156338200426963050610832781263082981525248175", - "27102543658848146076219989119639465430524061997280788166887046421706499775415" + '22726225412881182965250630589245572283256255052470345984553083359461473893802', + '12443967854426795490638709950679156338200426963050610832781263082981525248175', + '27102543658848146076219989119639465430524061997280788166887046421706499775415', ], [ - "14427224233985680214097547669945064793149553513421479297921556194475574770861", - "22917454832925781549840198815703114840452733537799472739275668965081704937832", - "3455076056123630366063931123762198941796412458154689469887583689725886013901" + '14427224233985680214097547669945064793149553513421479297921556194475574770861', + '22917454832925781549840198815703114840452733537799472739275668965081704937832', + '3455076056123630366063931123762198941796412458154689469887583689725886013901', ], [ - "4513100023937785913596662867311227004762025658663076805918211014066645403017", - "18187619530784075723418065322038024507729605774832001333883311123910954334059", - "9447065431426150382325592560406989926365684509675374414068135115024495130938" + '4513100023937785913596662867311227004762025658663076805918211014066645403017', + '18187619530784075723418065322038024507729605774832001333883311123910954334059', + '9447065431426150382325592560406989926365684509675374414068135115024495130938', ], [ - "3227816098015819796753427754968234889554095489076864339942014527747604603014", - "14798316759185072116520458171957899889489461918408669809912344751222514418582", - "23013904852315603905843158448056763116188801262838729536210355401378476650033" + '3227816098015819796753427754968234889554095489076864339942014527747604603014', + '14798316759185072116520458171957899889489461918408669809912344751222514418582', + '23013904852315603905843158448056763116188801262838729536210355401378476650033', ], [ - "20979191509934291452182967564058656088941447895799901211038858159903580333267", - "20772973010251235271448378823573767262405703078344288856168565499702414379868", - "10105446427739226002497411811738001382334316505480517822035303561899927603685" + '20979191509934291452182967564058656088941447895799901211038858159903580333267', + '20772973010251235271448378823573767262405703078344288856168565499702414379868', + '10105446427739226002497411811738001382334316505480517822035303561899927603685', ], [ - "11079074761356717003579108002319997196881121172538617046865136940931215263187", - "4693927775411489288330326150094711670434597808961717172753867514688725690438", - "18581720304902876944842830383273503265470859268712618325357902881821721540119" + '11079074761356717003579108002319997196881121172538617046865136940931215263187', + '4693927775411489288330326150094711670434597808961717172753867514688725690438', + '18581720304902876944842830383273503265470859268712618325357902881821721540119', ], [ - "3065369948183164725765083504606321683481629263177690053939474679689088169185", - "18515622379147081456114962668688706121098539582467584736624699157043365677487", - "17563088600719312877716085528177751048248154461245613291986010180187238198006" + '3065369948183164725765083504606321683481629263177690053939474679689088169185', + '18515622379147081456114962668688706121098539582467584736624699157043365677487', + '17563088600719312877716085528177751048248154461245613291986010180187238198006', ], [ - "26199746176994924146211004840756471702409132230831594954444947705902602287290", - "7576136600627345523051497639367002272003104458453478964661395239732811642605", - "20058687874612168338994287374025378897088936171250328231848098497610185784281" + '26199746176994924146211004840756471702409132230831594954444947705902602287290', + '7576136600627345523051497639367002272003104458453478964661395239732811642605', + '20058687874612168338994287374025378897088936171250328231848098497610185784281', ], [ - "16894722532414195606958290526999761110785277556463400588047573469106594850228", - "13961730805696859614283621225672002906734926278118993580398533742874863598733", - "25256842011135514243352951950573936602906198374305137963222382546140030647211" + '16894722532414195606958290526999761110785277556463400588047573469106594850228', + '13961730805696859614283621225672002906734926278118993580398533742874863598733', + '25256842011135514243352951950573936602906198374305137963222382546140030647211', ], [ - "18530360047537856737482157200091774590035773602620205695980247565433703032532", - "23014819965938599260086897799541446473887833964178378497976832161473586995397", - "27911426213258307990762460361663504655967992659180759140364181941291843542489" + '18530360047537856737482157200091774590035773602620205695980247565433703032532', + '23014819965938599260086897799541446473887833964178378497976832161473586995397', + '27911426213258307990762460361663504655967992659180759140364181941291843542489', ], [ - "1067338118323302017358103178057182291035336430305886255160210378977812067042", - "17219092885519007424608854460610388434712113621163885775309496940189894433620", - "16432921127615937542183846559291144733339643093361323334499888895135356545408" + '1067338118323302017358103178057182291035336430305886255160210378977812067042', + '17219092885519007424608854460610388434712113621163885775309496940189894433620', + '16432921127615937542183846559291144733339643093361323334499888895135356545408', ], [ - "28608851042959977114787048070153637607786033079364369200270218128830983558707", - "10121629780013165888398831090128011045011860641816380162950736555305748332191", - "2348036340843128746981122630521268144839343500596932561106759754644596320722" + '28608851042959977114787048070153637607786033079364369200270218128830983558707', + '10121629780013165888398831090128011045011860641816380162950736555305748332191', + '2348036340843128746981122630521268144839343500596932561106759754644596320722', ], [ - "16619881370356823200358060093334065394764987467483650323706184068451904156452", - "2302436627861989749837563733434625231689351276818486757748445924305258835336", - "27514536540953539473280001431110316405453388911725550380123851609652679788049" + '16619881370356823200358060093334065394764987467483650323706184068451904156452', + '2302436627861989749837563733434625231689351276818486757748445924305258835336', + '27514536540953539473280001431110316405453388911725550380123851609652679788049', ], [ - "9459277727420672604737117687200019308525004979918488827092207438664125039815", - "23425670740358068509956137586663046763224562225383386726193078231034380596217", - "7641885067011661443791509688937280323563328029517832788240965464798835873658" + '9459277727420672604737117687200019308525004979918488827092207438664125039815', + '23425670740358068509956137586663046763224562225383386726193078231034380596217', + '7641885067011661443791509688937280323563328029517832788240965464798835873658', ], [ - "9579420382351699601929202663836555665702024548386778299996961509578687980280", - "18513671386572584282611234979588379470994484682444053600751415262497237017703", - "24923151431234706142737221165378041700050312199585085101919834422744926421604" + '9579420382351699601929202663836555665702024548386778299996961509578687980280', + '18513671386572584282611234979588379470994484682444053600751415262497237017703', + '24923151431234706142737221165378041700050312199585085101919834422744926421604', ], [ - "21131320841803068139502705966375283830095161079635803028011171241658723560073", - "19208476595309656066589572658712717685014329237892885950958199953675225096566", - "24023185216737416080949689106968568821656545490748664446389634158498624398204" + '21131320841803068139502705966375283830095161079635803028011171241658723560073', + '19208476595309656066589572658712717685014329237892885950958199953675225096566', + '24023185216737416080949689106968568821656545490748664446389634158498624398204', ], [ - "7510552996848634969347937904645640209946785877619890235458182993413526028718", - "3694415017252995094553868781762548289196990492336482360084813900937464847638", - "9219021070107873028263141554048987416559034633883158827414043929220388719352" + '7510552996848634969347937904645640209946785877619890235458182993413526028718', + '3694415017252995094553868781762548289196990492336482360084813900937464847638', + '9219021070107873028263141554048987416559034633883158827414043929220388719352', ], [ - "5058327241234443421111591959922712922949620710493120384930391763032694640881", - "13148252221647574076185511663661016015859769210867362839817254885265598775418", - "15186790492457240277904880519227706403545816456632095870015828239411033220638" + '5058327241234443421111591959922712922949620710493120384930391763032694640881', + '13148252221647574076185511663661016015859769210867362839817254885265598775418', + '15186790492457240277904880519227706403545816456632095870015828239411033220638', ], [ - "2775942914650502409705888572245750999561427024488403026572311267798009048466", - "6277965230841030155341171319927732572492215818164736949144854827643964384893", - "24144742149845235561087977558785057713814731737434473021812189457617252043745" + '2775942914650502409705888572245750999561427024488403026572311267798009048466', + '6277965230841030155341171319927732572492215818164736949144854827643964384893', + '24144742149845235561087977558785057713814731737434473021812189457617252043745', ], [ - "25789129719327437503403457598813971826156253950521984610569937361506914183550", - "21500534320778995945845999974779950304491968082325255355181901574840373597824", - "17185359848218837018503091932245529880546896465437232425673134558221638601375" + '25789129719327437503403457598813971826156253950521984610569937361506914183550', + '21500534320778995945845999974779950304491968082325255355181901574840373597824', + '17185359848218837018503091932245529880546896465437232425673134558221638601375', ], [ - "12253896579078110143384981818031883112606762215016553811786428215758384195713", - "12956658260778456372481429232709881794962204180363200699121804724437678625542", - "3023603786717368708677300377055384474816569333060487675635618249403832078921" + '12253896579078110143384981818031883112606762215016553811786428215758384195713', + '12956658260778456372481429232709881794962204180363200699121804724437678625542', + '3023603786717368708677300377055384474816569333060487675635618249403832078921', ], [ - "4186492855716808019562789862833898284927736051002588766326482010810259565130", - "4263939782228419774639068267872291539552889472311225829898746091327730032923", - "24068843626280451423530509388397151179174104901782990365720205643492047328816" + '4186492855716808019562789862833898284927736051002588766326482010810259565130', + '4263939782228419774639068267872291539552889472311225829898746091327730032923', + '24068843626280451423530509388397151179174104901782990365720205643492047328816', ], [ - "14564937827374621319716285527475223392664010281568256859627186463065876537730", - "28367596550218705971881480694115935470211319172596432472834880507822452927283", - "28712267437482356021504544448225827500268648754270274754623969882031853409874" + '14564937827374621319716285527475223392664010281568256859627186463065876537730', + '28367596550218705971881480694115935470211319172596432472834880507822452927283', + '28712267437482356021504544448225827500268648754270274754623969882031853409874', ], [ - "4542596163006916397403529184431773692747461300288194722982487051249951403191", - "2530461821259252672899452671728393208543894014761816288817584587718369998371", - "12886393063011539390567049190923398676964700147222878509238966758839020897414" + '4542596163006916397403529184431773692747461300288194722982487051249951403191', + '2530461821259252672899452671728393208543894014761816288817584587718369998371', + '12886393063011539390567049190923398676964700147222878509238966758839020897414', ], [ - "21593897590707514492037699253654745501762191795293908682495110982956631870528", - "13233005790593128135480716846773978578237145313006994631606474472023504621256", - "21621863098292803642478350494794106282518362577273973885587684567452726939909" + '21593897590707514492037699253654745501762191795293908682495110982956631870528', + '13233005790593128135480716846773978578237145313006994631606474472023504621256', + '21621863098292803642478350494794106282518362577273973885587684567452726939909', ], [ - "26068620073001644720969640099644251616742620988609091568084348314770436291745", - "18248589586787935500122854210401321966459127818593446990365211078521058875685", - "21247134484403265289037859533347798468858819117600251067578809852124865474448" + '26068620073001644720969640099644251616742620988609091568084348314770436291745', + '18248589586787935500122854210401321966459127818593446990365211078521058875685', + '21247134484403265289037859533347798468858819117600251067578809852124865474448', ], [ - "7947383127165915366383984718363902897504221803836013123394785749404572432524", - "22173041014621867335598230447618036223462011647696367239478182269973488867154", - "16773227734018849308448505860847939069870370055633571816925675705713088305139" + '7947383127165915366383984718363902897504221803836013123394785749404572432524', + '22173041014621867335598230447618036223462011647696367239478182269973488867154', + '16773227734018849308448505860847939069870370055633571816925675705713088305139', ], [ - "10708707957340055662073314227607620808612686977606082605219160019699644826999", - "21249897193797038261479589555720746994050836195265348846222835266344091683000", - "12581195059139097540117398803363514148192715293133623516709277290477633379593" + '10708707957340055662073314227607620808612686977606082605219160019699644826999', + '21249897193797038261479589555720746994050836195265348846222835266344091683000', + '12581195059139097540117398803363514148192715293133623516709277290477633379593', ], [ - "19779599816866992123290302397082614570282926215253589712189610064229996603178", - "21749216503901548676985371189807470207364320167486559936962401093285243029177", - "17600045923623503357380202389718735904174992978547372448837488832457719009224" + '19779599816866992123290302397082614570282926215253589712189610064229996603178', + '21749216503901548676985371189807470207364320167486559936962401093285243029177', + '17600045923623503357380202389718735904174992978547372448837488832457719009224', ], [ - "2732872979548118117758016335601225525660858727422778256671975055129965858636", - "13703031005128062046175331918702218558750713240446179585947851411173844703597", - "28447710105386636841938034820015573492556750872924193415447818187228356409281" + '2732872979548118117758016335601225525660858727422778256671975055129965858636', + '13703031005128062046175331918702218558750713240446179585947851411173844703597', + '28447710105386636841938034820015573492556750872924193415447818187228356409281', ], [ - "28539960355005748517007309210788803416171161412204526246799800716567376494244", - "21329318452221893900731030722137844458345358926323127858742388587761302609863", - "28135302149599894709369178097439582767613940517471323224020113411362601191873" + '28539960355005748517007309210788803416171161412204526246799800716567376494244', + '21329318452221893900731030722137844458345358926323127858742388587761302609863', + '28135302149599894709369178097439582767613940517471323224020113411362601191873', ], [ - "24980774120400248734054527936006392540889095705961960837980443629260392758683", - "20339911045808632098936066397942175169549806052128535543540543556255197716643", - "7929293103930252545581851978492699598413941396422930641071359388697302362494" + '24980774120400248734054527936006392540889095705961960837980443629260392758683', + '20339911045808632098936066397942175169549806052128535543540543556255197716643', + '7929293103930252545581851978492699598413941396422930641071359388697302362494', ], [ - "8911092207145893152276662096451247820054843777071569723455408545101628926203", - "19648860643145256523615441075182036100116634560394529500146405733687718224516", - "14635387208623683806428528837466762532853903031263830054986064902455379735903" + '8911092207145893152276662096451247820054843777071569723455408545101628926203', + '19648860643145256523615441075182036100116634560394529500146405733687718224516', + '14635387208623683806428528837466762532853903031263830054986064902455379735903', ], [ - "11555212214346132926966321609673228184079851030522218543981385635403167028692", - "20896918157639814425520058178561910811657326967880217845710779511927814874973", - "4650158165912007049140499755153804318686705949436165235742106170124284287326" + '11555212214346132926966321609673228184079851030522218543981385635403167028692', + '20896918157639814425520058178561910811657326967880217845710779511927814874973', + '4650158165912007049140499755153804318686705949436165235742106170124284287326', ], [ - "13880660273492757167295696447853232191657893303250187467329180558670697369810", - "8043529172463774320604378774840863923445982272478964686447801046272917236836", - "2134399296482715903442913099374581981696436050603410080564843555725771329441" + '13880660273492757167295696447853232191657893303250187467329180558670697369810', + '8043529172463774320604378774840863923445982272478964686447801046272917236836', + '2134399296482715903442913099374581981696436050603410080564843555725771329441', ], [ - "27320952903412641133501507962185246982787769547770982814240701526492601978122", - "23417491374379751329394424924400186404791519133465537872457405970098902747611", - "17612427354278346772575179176139417348059847375297761006336024476146551185903" + '27320952903412641133501507962185246982787769547770982814240701526492601978122', + '23417491374379751329394424924400186404791519133465537872457405970098902747611', + '17612427354278346772575179176139417348059847375297761006336024476146551185903', ], [ - "10710998507064742997612080847223278109404482930427999113323732519626499166548", - "14958094513415797513745395709487730603918953350067504982704138489305723550923", - "24096319595904213497633343966229498735553590589105811393277073274927955202995" + '10710998507064742997612080847223278109404482930427999113323732519626499166548', + '14958094513415797513745395709487730603918953350067504982704138489305723550923', + '24096319595904213497633343966229498735553590589105811393277073274927955202995', ], [ - "17983724131200292654039765185049138356840415443160477259330748730019147254309", - "17598096800487588874709548646068838880468456205252324677357706597166777506441", - "27420647821110229619898200875848631488422182349567475956209153112306555222281" + '17983724131200292654039765185049138356840415443160477259330748730019147254309', + '17598096800487588874709548646068838880468456205252324677357706597166777506441', + '27420647821110229619898200875848631488422182349567475956209153112306555222281', ], [ - "448538544835457571662601142415301047108854812427100562339376187510452313026", - "23494184556634922103535803143214434479598067155171780264810485708203176455201", - "22626342941879801989161990529511235538216563009907378573817996229389756621777" + '448538544835457571662601142415301047108854812427100562339376187510452313026', + '23494184556634922103535803143214434479598067155171780264810485708203176455201', + '22626342941879801989161990529511235538216563009907378573817996229389756621777', ], [ - "26128268137723417163973860961686381960826033145738852158792607959175787222856", - "20225791828042873305317281581105429726352058325970107209484198122707862156597", - "7538871133759632802857159609785118198934349221046986784429069814655215585732" + '26128268137723417163973860961686381960826033145738852158792607959175787222856', + '20225791828042873305317281581105429726352058325970107209484198122707862156597', + '7538871133759632802857159609785118198934349221046986784429069814655215585732', ], [ - "26184554861259642274153262777073624024579929401668865520166966302070394487366", - "28755259264665180745537307265993667261709206143628938749669440804401623257679", - "11896066093033549470312328497237649508068258723531931099214795928200015717321" + '26184554861259642274153262777073624024579929401668865520166966302070394487366', + '28755259264665180745537307265993667261709206143628938749669440804401623257679', + '11896066093033549470312328497237649508068258723531931099214795928200015717321', ], [ - "21657721599978732693249012287058163532690942515202465984736373311077240614059", - "9214914097169852704753116653702415951907628005986883140609006971322091003693", - "18710111680849814325169297240208687402588261569152088592693815711857504371037" + '21657721599978732693249012287058163532690942515202465984736373311077240614059', + '9214914097169852704753116653702415951907628005986883140609006971322091003693', + '18710111680849814325169297240208687402588261569152088592693815711857504371037', ], [ - "6813635166770764528979084175325709935892248249948967889926276426090222296643", - "20546585456429436268067726231902751119458200511988152296570567167520382569278", - "20087466019194902429054761607398988292568594301671509779549344754172952693871" + '6813635166770764528979084175325709935892248249948967889926276426090222296643', + '20546585456429436268067726231902751119458200511988152296570567167520382569278', + '20087466019194902429054761607398988292568594301671509779549344754172952693871', ], [ - "28185105286740691904534067831357491310995891986363455251895371651360605333143", - "10108348212894231193041286244259038275269464277821588425688314560368589986063", - "11433633215392393209829215018579238412423821563056156785641278458497271271546" + '28185105286740691904534067831357491310995891986363455251895371651360605333143', + '10108348212894231193041286244259038275269464277821588425688314560368589986063', + '11433633215392393209829215018579238412423821563056156785641278458497271271546', ], [ - "27870881917195016999862550657996865268956893566432995492427618003637597051321", - "102309803677783876701097881491240456320211833502658383473112057006867019389", - "22844040227595875612525628393174357057929113317578127744718774517498324646590" + '27870881917195016999862550657996865268956893566432995492427618003637597051321', + '102309803677783876701097881491240456320211833502658383473112057006867019389', + '22844040227595875612525628393174357057929113317578127744718774517498324646590', ], [ - "18364790233947478619325319418813215212267974311771564959136180502266118026133", - "2480624341921718230432383518425561514824501138863702825916674641657321180841", - "16778939567530361665956758171503829349658551798564323167725356065198936433124" + '18364790233947478619325319418813215212267974311771564959136180502266118026133', + '2480624341921718230432383518425561514824501138863702825916674641657321180841', + '16778939567530361665956758171503829349658551798564323167725356065198936433124', ], [ - "11947564511486966895926950599696532964589539443187518177489990556481125699966", - "3133187646540385483015602955087323554103587039123577645562801570574691666057", - "27704797101265438206569218421707753788081674727344603874614391656565567951541" + '11947564511486966895926950599696532964589539443187518177489990556481125699966', + '3133187646540385483015602955087323554103587039123577645562801570574691666057', + '27704797101265438206569218421707753788081674727344603874614391656565567951541', ], [ - "13001484695584753475562184349533365512515447041450030471627087395341039487710", - "477322000667279478600757543806155989948171541982639893984064422067850617496", - "13913755821658634147813329813115566967428755223601185963529801459396673113438" + '13001484695584753475562184349533365512515447041450030471627087395341039487710', + '477322000667279478600757543806155989948171541982639893984064422067850617496', + '13913755821658634147813329813115566967428755223601185963529801459396673113438', ], [ - "16621869429023470107454028095846067937827722393398508604914831452950874033411", - "21755744236927410239079501831014076529931327263341620300431356747367343619046", - "26538666591151124505694487799121414506088199961481579132019627484065014831180" + '16621869429023470107454028095846067937827722393398508604914831452950874033411', + '21755744236927410239079501831014076529931327263341620300431356747367343619046', + '26538666591151124505694487799121414506088199961481579132019627484065014831180', ], [ - "3066480818457008068617042549071052338581291837882909165666223566402713429090", - "16182268213934119294035309949459684472027705439038023775276926916166831108357", - "28907604876608422892474268478706783033050951245339691569015166507728369585190" + '3066480818457008068617042549071052338581291837882909165666223566402713429090', + '16182268213934119294035309949459684472027705439038023775276926916166831108357', + '28907604876608422892474268478706783033050951245339691569015166507728369585190', ], [ - "27973960109508292680965426133498827831691369851701664449575719912259359998113", - "1456924360278399121996742356757866616312146358469991014696110099534285524446", - "8234248752911525485438611255163504976087091103090603316695312869292347668495" + '27973960109508292680965426133498827831691369851701664449575719912259359998113', + '1456924360278399121996742356757866616312146358469991014696110099534285524446', + '8234248752911525485438611255163504976087091103090603316695312869292347668495', ], [ - "8716078950082339630026654067608811496722305720644485560320987802533380421009", - "19016744645809919602099479306503354923553336014593353020688463619133130053825", - "24379650661051444982012238084495990858827340608012118841005379796362233056432" + '8716078950082339630026654067608811496722305720644485560320987802533380421009', + '19016744645809919602099479306503354923553336014593353020688463619133130053825', + '24379650661051444982012238084495990858827340608012118841005379796362233056432', ], [ - "2245379544097631382062919677963998259142792890502492881341386639439507471783", - "28788137434161061988371619554419440748189388934884757179010092973102292086583", - "7187000185648741287953633167647835668543536354944774631102766873251849991238" + '2245379544097631382062919677963998259142792890502492881341386639439507471783', + '28788137434161061988371619554419440748189388934884757179010092973102292086583', + '7187000185648741287953633167647835668543536354944774631102766873251849991238', ], [ - "18319349500538500800225762827448369057030532278398270164660609327776487168142", - "2622932985948021877314529887962683530522545893985767148345336304947201715671", - "13805188629797792210337544360632964855143280581052079479249966961215582531026" + '18319349500538500800225762827448369057030532278398270164660609327776487168142', + '2622932985948021877314529887962683530522545893985767148345336304947201715671', + '13805188629797792210337544360632964855143280581052079479249966961215582531026', ], [ - "27457600993464082637917106210690168172469473943609357897393615707457194410878", - "15448646156961779103834447043970817898237835202826003934642165760908058355399", - "9396792545729486882231669677795667529746274932273033601723318032992363022062" + '27457600993464082637917106210690168172469473943609357897393615707457194410878', + '15448646156961779103834447043970817898237835202826003934642165760908058355399', + '9396792545729486882231669677795667529746274932273033601723318032992363022062', ], [ - "9927877141952679457141759789181418464292082444806533413864151258248124544859", - "23827901395971835838179844085051957393677906360196119690926757794561937573142", - "3273544693673216914876067527455588276979859627093391584406340272737391174619" + '9927877141952679457141759789181418464292082444806533413864151258248124544859', + '23827901395971835838179844085051957393677906360196119690926757794561937573142', + '3273544693673216914876067527455588276979859627093391584406340272737391174619', ], [ - "19571510438350300564152393820251652609646082150148656806391655428002614034315", - "4458840243585913642400750597703353770666314833058197517675446022682775625834", - "6452218213610300363069953741424106105609715382419342511693148495219793324457" + '19571510438350300564152393820251652609646082150148656806391655428002614034315', + '4458840243585913642400750597703353770666314833058197517675446022682775625834', + '6452218213610300363069953741424106105609715382419342511693148495219793324457', ], [ - "14558167930891460678441266912176752652821641543245953113671886345167213541771", - "10650967986920075561478528461783351160938460620955779955379459848889204404950", - "19990009778942542934049216419052172134625404062770188357110708518621145688588" + '14558167930891460678441266912176752652821641543245953113671886345167213541771', + '10650967986920075561478528461783351160938460620955779955379459848889204404950', + '19990009778942542934049216419052172134625404062770188357110708518621145688588', ], [ - "26855242974447190235826233682457047761532515293146087151296725996543442567035", - "22785340043356532865086769889360674409753343398766563441587096485751538658065", - "28603049427449348335651629195385434188071937908693764500052489540779792538285" + '26855242974447190235826233682457047761532515293146087151296725996543442567035', + '22785340043356532865086769889360674409753343398766563441587096485751538658065', + '28603049427449348335651629195385434188071937908693764500052489540779792538285', ], [ - "20545812864989828913452616721240947168977365844984763819184465128164378967167", - "23234068381345797209897730226956922073109641728569353961504167817770340037954", - "26031714567641615877877111172701145299483019910006153132858512509897185854695" + '20545812864989828913452616721240947168977365844984763819184465128164378967167', + '23234068381345797209897730226956922073109641728569353961504167817770340037954', + '26031714567641615877877111172701145299483019910006153132858512509897185854695', ], [ - "9512221744061419790435674197238913998387834650389922233458121639503195504983", - "12587458000103271975978240683793268604398305885278203470492658961734100340536", - "9670291694005369437277651504604785512303147991710650505302465204429311229197" + '9512221744061419790435674197238913998387834650389922233458121639503195504983', + '12587458000103271975978240683793268604398305885278203470492658961734100340536', + '9670291694005369437277651504604785512303147991710650505302465204429311229197', ], [ - "26995526763045548800439747262386290359229145489609341602564040676717570935439", - "23742712112104280264401317024221734961713400615669958343926511931219510484675", - "27931469778579449247589315744656633392873808631802461175539563849884447358271" + '26995526763045548800439747262386290359229145489609341602564040676717570935439', + '23742712112104280264401317024221734961713400615669958343926511931219510484675', + '27931469778579449247589315744656633392873808631802461175539563849884447358271', ], [ - "20669006894143187877081688942720159738269397552445286314270368345994751825389", - "26891772301075275370472640177651637211280740381619976926886106618375467277414", - "28387986011980449959047232529988203397251084614417760995257355718700961696092" + '20669006894143187877081688942720159738269397552445286314270368345994751825389', + '26891772301075275370472640177651637211280740381619976926886106618375467277414', + '28387986011980449959047232529988203397251084614417760995257355718700961696092', ], [ - "6579105010484741592730389416372694666279917604793318157514380025250233913402", - "11007035767869292700964744408562802781669930023548892567535397874932420229930", - "981148366863906885900456473323410468923514528856216824044152942069412627408" + '6579105010484741592730389416372694666279917604793318157514380025250233913402', + '11007035767869292700964744408562802781669930023548892567535397874932420229930', + '981148366863906885900456473323410468923514528856216824044152942069412627408', ], [ - "22213671088722307302576907504985884923571642958053627659840326928319445671280", - "1318836216310789598614608105109389429335273432455224127576823891011367206122", - "25586582796990779718352441955439394949194222626688223867952982491529809559257" + '22213671088722307302576907504985884923571642958053627659840326928319445671280', + '1318836216310789598614608105109389429335273432455224127576823891011367206122', + '25586582796990779718352441955439394949194222626688223867952982491529809559257', ], [ - "4923739488579452777913681531125585976446366144127161879759262506690369040090", - "23505612338866210737103599484620591026802005128655081877133994175016351514827", - "323887003859465324514901860965142186539600668250760639664361851354147799637" + '4923739488579452777913681531125585976446366144127161879759262506690369040090', + '23505612338866210737103599484620591026802005128655081877133994175016351514827', + '323887003859465324514901860965142186539600668250760639664361851354147799637', ], [ - "10198923064967306784017949469108033682156920551672348936591491217255268794658", - "9593680688139131432883442351722730169325112619984238956948153423155998917175", - "27027988263960602112273050725720071355535922812577299127302015348825197871870" + '10198923064967306784017949469108033682156920551672348936591491217255268794658', + '9593680688139131432883442351722730169325112619984238956948153423155998917175', + '27027988263960602112273050725720071355535922812577299127302015348825197871870', ], [ - "14419883951157390867695097127684346981136020111885301573583640959136319507752", - "5104414988075833278683649298543440897371415916271358703850262680431809374355", - "24739655595299332818980677669648719986462429574612913501586844601377825836782" + '14419883951157390867695097127684346981136020111885301573583640959136319507752', + '5104414988075833278683649298543440897371415916271358703850262680431809374355', + '24739655595299332818980677669648719986462429574612913501586844601377825836782', ], [ - "28522818684103966731129743408029731246564480741348128436668680764518115102581", - "21520350704208288978690888796633940487888044365108767319141211249242880355961", - "17391005598311948834360476853940353239444383292422171321575043660157438608537" + '28522818684103966731129743408029731246564480741348128436668680764518115102581', + '21520350704208288978690888796633940487888044365108767319141211249242880355961', + '17391005598311948834360476853940353239444383292422171321575043660157438608537', ], [ - "15367833944125677011173327826570204350687925236257190051755087781855930646142", - "21715073802090413714601069529558707101797361591183718695054701329871284436172", - "8994093285353831008525761670339342200997965950202092028313103110478252647618" + '15367833944125677011173327826570204350687925236257190051755087781855930646142', + '21715073802090413714601069529558707101797361591183718695054701329871284436172', + '8994093285353831008525761670339342200997965950202092028313103110478252647618', ], [ - "8370824693889782161629525898408725452177580012023459750897244954935682978671", - "16123253540853556024347150096993154278773652905830608614979368087152152043083", - "3535380953353495025888433493640531836449699255364366295870140701379497967423" + '8370824693889782161629525898408725452177580012023459750897244954935682978671', + '16123253540853556024347150096993154278773652905830608614979368087152152043083', + '3535380953353495025888433493640531836449699255364366295870140701379497967423', ], [ - "6954518484798178646508803478426114267143074508396663899281411171704702743829", - "28903134801897070276701950388422104654018369750191967384271618837091859516942", - "20872505363530172448468374920196608937030884647150175861507911076568784054834" + '6954518484798178646508803478426114267143074508396663899281411171704702743829', + '28903134801897070276701950388422104654018369750191967384271618837091859516942', + '20872505363530172448468374920196608937030884647150175861507911076568784054834', ], [ - "6902861581703501105786795670676641959401710346423594578401934671029571262513", - "10124161387604183369443890585742198433184078889862870469507328332805848271064", - "10488004060799269337071647841224034919633445750252076195310163972966405029030" + '6902861581703501105786795670676641959401710346423594578401934671029571262513', + '10124161387604183369443890585742198433184078889862870469507328332805848271064', + '10488004060799269337071647841224034919633445750252076195310163972966405029030', ], [ - "507704911991278613147490289466075160618843900088471236546244459176211783848", - "7252739745607302667257774481690407709040936359589867974787811552896597703097", - "23278073497974004442836030100920157527910770509761505828038443336325476654930" + '507704911991278613147490289466075160618843900088471236546244459176211783848', + '7252739745607302667257774481690407709040936359589867974787811552896597703097', + '23278073497974004442836030100920157527910770509761505828038443336325476654930', ], [ - "22766285055433137793164317120096790621982728188995759745859222009100808389090", - "23129058299483468195787339200845749049960038336751758017949899311636830205152", - "16665333681978951552434356320651834889869437822496200946959897681307959400425" + '22766285055433137793164317120096790621982728188995759745859222009100808389090', + '23129058299483468195787339200845749049960038336751758017949899311636830205152', + '16665333681978951552434356320651834889869437822496200946959897681307959400425', ], [ - "12145699202182574939376505075528461451757079041659894988784442097333218352048", - "26340666275844437932755852805027863696219004039301187587209926587657008948704", - "19208771804191839410002226941825269105677187954811130189835856228258013753206" + '12145699202182574939376505075528461451757079041659894988784442097333218352048', + '26340666275844437932755852805027863696219004039301187587209926587657008948704', + '19208771804191839410002226941825269105677187954811130189835856228258013753206', ], [ - "21957102494792377508237608216278079874536155315851198461024084071231867104453", - "6933367436450995525851693784691226222726503560893470094614235356287049091852", - "15707767379191450768747057313641112321773921923533732633534831270357733757271" + '21957102494792377508237608216278079874536155315851198461024084071231867104453', + '6933367436450995525851693784691226222726503560893470094614235356287049091852', + '15707767379191450768747057313641112321773921923533732633534831270357733757271', ], [ - "27661963645951389261638591385668507557739541354225916772550248746235106571003", - "19699458096897937575096494582288688995241392471402204995195057374756282223421", - "902873385171181344315871113842580653512118892800584003934454469411716098791" + '27661963645951389261638591385668507557739541354225916772550248746235106571003', + '19699458096897937575096494582288688995241392471402204995195057374756282223421', + '902873385171181344315871113842580653512118892800584003934454469411716098791', ], [ - "17184835876565576154014372215369798779520343573944211203710896053325717110660", - "664657295519303589036289440053175741110032988007278988577620229144220576240", - "10803972669668998371638869508774217165881281885838503958226056357738500321396" + '17184835876565576154014372215369798779520343573944211203710896053325717110660', + '664657295519303589036289440053175741110032988007278988577620229144220576240', + '10803972669668998371638869508774217165881281885838503958226056357738500321396', ], [ - "2329846733754251453632375727999372856194157027336139087170310553870624325301", - "14139944357035048486675740400655356660678187875721949218090128899571575479791", - "18368148273419807418427674359327442879484531833435081951870369910704734685351" + '2329846733754251453632375727999372856194157027336139087170310553870624325301', + '14139944357035048486675740400655356660678187875721949218090128899571575479791', + '18368148273419807418427674359327442879484531833435081951870369910704734685351', ], [ - "10480273665080572189328459165704340191901489646067580012574464138528963201459", - "21773636700078124500346009061678153597323236568110076029811348966753228682835", - "18184268307211429260956076021417309535471438696101133218049142374847151474905" + '10480273665080572189328459165704340191901489646067580012574464138528963201459', + '21773636700078124500346009061678153597323236568110076029811348966753228682835', + '18184268307211429260956076021417309535471438696101133218049142374847151474905', ], [ - "25957533025669311312382992376854735734491934602484112256289764602447226406852", - "22223261506176684934865714490719116745135417403915426392159449667435294570739", - "22937309162832499167063076416585504361695925730111272512450449042837586253575" + '25957533025669311312382992376854735734491934602484112256289764602447226406852', + '22223261506176684934865714490719116745135417403915426392159449667435294570739', + '22937309162832499167063076416585504361695925730111272512450449042837586253575', ], [ - "16956181785481598286719868503945127919581091625126206673934113115358441284347", - "8497782777197814773596870810881707148695901557289856910220737358078100998191", - "21135503731586600979470064722475007625236017670426339278983640892218291297054" + '16956181785481598286719868503945127919581091625126206673934113115358441284347', + '8497782777197814773596870810881707148695901557289856910220737358078100998191', + '21135503731586600979470064722475007625236017670426339278983640892218291297054', ], [ - "17809297343844488723046665739910571149089769215421130894378638450427880983923", - "72435395972188389387093550708873189001876361107443937983754878061522372356", - "7511239878692099209014947248389283109997289411550315391143819429585903287870" - ] + '17809297343844488723046665739910571149089769215421130894378638450427880983923', + '72435395972188389387093550708873189001876361107443937983754878061522372356', + '7511239878692099209014947248389283109997289411550315391143819429585903287870', + ], ], - "fullRounds": 63, - "partialRounds": 0, - "hasInitialRoundConstant": true, - "stateSize": 3, - "rate": 2, - "power": 5 + fullRounds: 63, + partialRounds: 0, + hasInitialRoundConstant: true, + stateSize: 3, + rate: 2, + power: 5, }; let mocks = { - "dummyVerificationKeyHash": - "3392518251768960475377392625298437850623664973002200885669375116181514017494" + dummyVerificationKeyHash: + '3392518251768960475377392625298437850623664973002200885669375116181514017494', }; - diff --git a/src/bindings/crypto/elliptic-curve-endomorphism.ts b/src/bindings/crypto/elliptic-curve-endomorphism.ts index eb5aa003f3..a10dec4a23 100644 --- a/src/bindings/crypto/elliptic-curve-endomorphism.ts +++ b/src/bindings/crypto/elliptic-curve-endomorphism.ts @@ -13,13 +13,7 @@ import { } from './elliptic-curve.js'; import { FiniteField, mod } from './finite-field.js'; -export { - Endomorphism, - decompose, - computeEndoConstants, - computeGlvData, - GlvData, -}; +export { Endomorphism, decompose, computeEndoConstants, computeGlvData, GlvData }; /** * Define methods leveraging a curve endomorphism @@ -34,12 +28,7 @@ function Endomorphism( ) { if (endoScalar === undefined || endoBase === undefined) { try { - ({ endoScalar, endoBase } = computeEndoConstants( - Field, - Scalar, - generator, - a - )); + ({ endoScalar, endoBase } = computeEndoConstants(Field, Scalar, generator, a)); } catch (e: any) { return undefined; } @@ -66,14 +55,7 @@ function Endomorphism( }, scale(g: GroupAffine, s: bigint) { let gProj = projectiveFromAffine(g); - let sGProj = glvScaleProjective( - gProj, - s, - Field.modulus, - a, - endoBase_, - glvData - ); + let sGProj = glvScaleProjective(gProj, s, Field.modulus, a, endoBase_, glvData); return projectiveToAffine(sGProj, Field.modulus); }, }; @@ -131,11 +113,7 @@ function endomorphism(P: GroupAffine, endoBase: bigint, p: bigint) { return { x: mod(endoBase * P.x, p), y: P.y }; } -function endomorphismProjective( - P: GroupProjective, - endoBase: bigint, - p: bigint -) { +function endomorphismProjective(P: GroupProjective, endoBase: bigint, p: bigint) { return { x: mod(endoBase * P.x, p), y: P.y, z: P.z }; } @@ -185,12 +163,7 @@ function glvScaleProjective( * * Throws if conditions for a cube root-based endomorphism are not met. */ -function computeEndoConstants( - Field: FiniteField, - Scalar: FiniteField, - G: GroupAffine, - a: bigint -) { +function computeEndoConstants(Field: FiniteField, Scalar: FiniteField, G: GroupAffine, a: bigint) { let p = Field.modulus; let q = Scalar.modulus; // if there is a cube root of unity, it generates a subgroup of order 3 @@ -260,10 +233,7 @@ type GlvData = ReturnType; * * For random / "typical" l, we will have |vij| ~ sqrt(p) for all vij */ -function egcdStopEarly( - l: bigint, - p: bigint -): [[bigint, bigint], [bigint, bigint]] { +function egcdStopEarly(l: bigint, p: bigint): [[bigint, bigint], [bigint, bigint]] { if (l > p) throw Error('a > p'); let [r0, r1] = [p, l]; let [s0, s1] = [1n, 0n]; diff --git a/src/bindings/crypto/elliptic-curve.ts b/src/bindings/crypto/elliptic-curve.ts index 4e823e9dce..ed1e3eafd6 100644 --- a/src/bindings/crypto/elliptic-curve.ts +++ b/src/bindings/crypto/elliptic-curve.ts @@ -1,13 +1,5 @@ import { bigIntToBits } from './bigint-helpers.js'; -import { - FiniteField, - Fp, - createField, - inverse, - mod, - p, - q, -} from './finite-field.js'; +import { FiniteField, Fp, createField, inverse, mod, p, q } from './finite-field.js'; import { Endomorphism } from './elliptic-curve-endomorphism.js'; export { Pallas, @@ -42,8 +34,7 @@ const vestaGeneratorProjective = { x: 1n, y: 11426906929455361843568202299992114520848200991084027513389447476559454104162n, }; -const vestaEndoBase = - 2942865608506852014473558576493638302197734138389222805617480874486368177743n; +const vestaEndoBase = 2942865608506852014473558576493638302197734138389222805617480874486368177743n; const pallasEndoBase = 20444556541222657078399132219657928148671392403212669005631716460534733845831n; const vestaEndoScalar = @@ -195,12 +186,7 @@ function projectiveNeg({ x, y, z }: GroupProjective, p: bigint) { return { x, y: y === 0n ? 0n : p - y, z }; } -function projectiveAdd( - g: GroupProjective, - h: GroupProjective, - p: bigint, - a: bigint -) { +function projectiveAdd(g: GroupProjective, h: GroupProjective, p: bigint, a: bigint) { if (g.z === 0n) return h; if (h.z === 0n) return g; let X1 = g.x, @@ -329,21 +315,11 @@ function getProjectiveDouble(p: bigint, a: bigint) { ); } -function projectiveSub( - g: GroupProjective, - h: GroupProjective, - p: bigint, - a: bigint -) { +function projectiveSub(g: GroupProjective, h: GroupProjective, p: bigint, a: bigint) { return projectiveAdd(g, projectiveNeg(h, p), p, a); } -function projectiveScale( - g: GroupProjective, - x: bigint | boolean[], - p: bigint, - a: bigint -) { +function projectiveScale(g: GroupProjective, x: bigint | boolean[], p: bigint, a: bigint) { let double = getProjectiveDouble(p, a); let bits = typeof x === 'bigint' ? bigIntToBits(x) : x; let h = projectiveZero; @@ -354,11 +330,7 @@ function projectiveScale( return h; } -function projectiveFromAffine({ - x, - y, - infinity, -}: GroupAffine): GroupProjective { +function projectiveFromAffine({ x, y, infinity }: GroupAffine): GroupProjective { if (infinity) return projectiveZero; return { x, y, z: 1n }; } @@ -395,12 +367,7 @@ function projectiveEqual(g: GroupProjective, h: GroupProjective, p: bigint) { return mod(g.y * hz3, p) === mod(h.y * gz3, p); } -function projectiveOnCurve( - { x, y, z }: GroupProjective, - p: bigint, - b: bigint, - a: bigint -) { +function projectiveOnCurve({ x, y, z }: GroupProjective, p: bigint, b: bigint, a: bigint) { // substitution x -> x/z^2 and y -> y/z^3 gives // the equation y^2 = x^3 + a*x*z^4 + b*z^6 // (note: we allow a restricted set of x,y for z==0; this seems fine) @@ -413,12 +380,7 @@ function projectiveOnCurve( } // checks whether the elliptic curve point g is in the subgroup defined by [order]g = 0 -function projectiveInSubgroup( - g: GroupProjective, - p: bigint, - order: bigint, - a: bigint -) { +function projectiveInSubgroup(g: GroupProjective, p: bigint, order: bigint, a: bigint) { let orderTimesG = projectiveScale(g, order, p, a); return projectiveEqual(orderTimesG, projectiveZero, p); } @@ -449,13 +411,11 @@ function createCurveProjective({ one: { ...generator, z: 1n }, hasEndomorphism: endoBase !== undefined && endoScalar !== undefined, get endoBase() { - if (endoBase === undefined) - throw Error('`endoBase` for this curve was not provided.'); + if (endoBase === undefined) throw Error('`endoBase` for this curve was not provided.'); return endoBase; }, get endoScalar() { - if (endoScalar === undefined) - throw Error('`endoScalar` for this curve was not provided.'); + if (endoScalar === undefined) throw Error('`endoScalar` for this curve was not provided.'); return endoScalar; }, a, @@ -487,8 +447,7 @@ function createCurveProjective({ return projectiveScale(g, s, p, a); }, endomorphism({ x, y, z }: GroupProjective) { - if (endoBase === undefined) - throw Error('endomorphism needs `endoBase` parameter.'); + if (endoBase === undefined) throw Error('endomorphism needs `endoBase` parameter.'); return { x: mod(endoBase * x, p), y, z }; }, toAffine(g: GroupProjective) { @@ -525,24 +484,14 @@ const Vesta = createCurveProjective({ const affineZero: PointAtInfinity = { x: 0n, y: 0n, infinity: true }; -function affineOnCurve( - { x, y, infinity }: GroupAffine, - p: bigint, - a: bigint, - b: bigint -) { +function affineOnCurve({ x, y, infinity }: GroupAffine, p: bigint, a: bigint, b: bigint) { if (infinity) return true; // y^2 = x^3 + ax + b let x2 = mod(x * x, p); return mod(y * y - x * x2 - a * x - b, p) === 0n; } -function affineAdd( - g: GroupAffine, - h: GroupAffine, - p: bigint, - a: bigint -): GroupAffine { +function affineAdd(g: GroupAffine, h: GroupAffine, p: bigint, a: bigint): GroupAffine { if (g.infinity) return h; if (h.infinity) return g; @@ -566,11 +515,7 @@ function affineAdd( return { x: x3, y: y3, infinity: false }; } -function affineDouble( - { x, y, infinity }: GroupAffine, - p: bigint, - a: bigint -): GroupAffine { +function affineDouble({ x, y, infinity }: GroupAffine, p: bigint, a: bigint): GroupAffine { if (infinity) return affineZero; // m = (3*x^2 + a) / 2y let d = inverse(2n * y, p); @@ -588,12 +533,7 @@ function affineNegate({ x, y, infinity }: GroupAffine, p: bigint): GroupAffine { return { x, y: y === 0n ? 0n : p - y, infinity }; } -function affineScale( - g: GroupAffine, - s: bigint | boolean[], - p: bigint, - a: bigint -) { +function affineScale(g: GroupAffine, s: bigint | boolean[], p: bigint, a: bigint) { let gProj = projectiveFromAffine(g); let sgProj = projectiveScale(gProj, s, p, a); return projectiveToAffine(sgProj, p); @@ -664,9 +604,7 @@ function createCurveAffine({ fromNonzero(g: { x: bigint; y: bigint }): GroupAffine { if (g.x === 0n && g.y === 0n) { - throw Error( - 'fromNonzero: got (0, 0), which is reserved for the zero point' - ); + throw Error('fromNonzero: got (0, 0), which is reserved for the zero point'); } return { ...g, infinity: false }; }, diff --git a/src/bindings/crypto/elliptic-curve.unit-test.ts b/src/bindings/crypto/elliptic-curve.unit-test.ts index 228967db31..edd72da1f3 100644 --- a/src/bindings/crypto/elliptic-curve.unit-test.ts +++ b/src/bindings/crypto/elliptic-curve.unit-test.ts @@ -1,9 +1,4 @@ -import { - createCurveAffine, - createCurveProjective, - Pallas, - Vesta, -} from './elliptic-curve.js'; +import { createCurveAffine, createCurveProjective, Pallas, Vesta } from './elliptic-curve.js'; import { Fp, Fq } from './finite-field.js'; import assert from 'node:assert/strict'; import { test, Random } from '../../lib/testing/property.js'; @@ -18,11 +13,7 @@ for (let [G, Field, Scalar] of [ // endomorphism constants if (G.hasEndomorphism) { assert.equal(Field.power(G.endoBase, 3n), 1n, 'cube root in base field'); - assert.equal( - Scalar.power(G.endoScalar, 3n), - 1n, - 'cube root in scalar field' - ); + assert.equal(Scalar.power(G.endoScalar, 3n), 1n, 'cube root in scalar field'); } let randomScalar = Random(Scalar.random); @@ -30,13 +21,7 @@ for (let [G, Field, Scalar] of [ // create random points by scaling 1 with a random scalar let randomPoint = Random(() => G.scale(G.one, Scalar.random())); // let one / zero be sampled 20% of times each - randomPoint = Random.oneOf( - G.zero, - G.one, - randomPoint, - randomPoint, - randomPoint - ); + randomPoint = Random.oneOf(G.zero, G.one, randomPoint, randomPoint, randomPoint); test( randomPoint, @@ -52,10 +37,7 @@ for (let [G, Field, Scalar] of [ if (G.a === 0n) { // can't be on curve because b=5 is a non-square assert(!Field.isSquare(G.b)); - assert( - !G.isOnCurve({ x: 0n, y, z: 1n }), - 'x=0 => y^2 = b is not on curve' - ); + assert(!G.isOnCurve({ x: 0n, y, z: 1n }), 'x=0 => y^2 = b is not on curve'); // can't be on curve because the implied equation is f^6 = f^6 + b assert( !G.isOnCurve({ x: Field.power(f, 2n), y: Field.power(f, 3n), z: 1n }), @@ -84,10 +66,7 @@ for (let [G, Field, Scalar] of [ // algebraic laws - addition assert(G.equal(G.add(X, Y), G.add(Y, X)), 'commutative'); - assert( - G.equal(G.add(X, G.add(Y, Z)), G.add(G.add(X, Y), Z)), - 'associative' - ); + assert(G.equal(G.add(X, G.add(Y, Z)), G.add(G.add(X, Y), Z)), 'associative'); assert(G.equal(G.add(X, G.zero), X), 'identity'); assert(G.equal(G.add(X, G.negate(X)), G.zero), 'inverse'); @@ -103,10 +82,7 @@ for (let [G, Field, Scalar] of [ // algebraic laws - scaling assert( - G.equal( - G.scale(X, Scalar.add(x, y)), - G.add(G.scale(X, x), G.scale(X, y)) - ), + G.equal(G.scale(X, Scalar.add(x, y)), G.add(G.scale(X, x), G.scale(X, y))), 'distributive' ); assert( @@ -120,10 +96,7 @@ for (let [G, Field, Scalar] of [ // endomorphism if (G.hasEndomorphism) { - assert( - G.equal(G.endomorphism(X), G.scale(X, G.endoScalar)), - 'efficient endomorphism' - ); + assert(G.equal(G.endomorphism(X), G.scale(X, G.endoScalar)), 'efficient endomorphism'); } // subgroup @@ -131,15 +104,11 @@ for (let [G, Field, Scalar] of [ // affine let affineX = G.toAffine(X); - assert( - G.equal(G.fromAffine(affineX), X), - 'affine - projective roundtrip' - ); + assert(G.equal(G.fromAffine(affineX), X), 'affine - projective roundtrip'); let { x: xa, y: ya } = affineX; assert( G.equal(X, G.zero) || - Field.square(ya) === - Field.add(Field.add(Field.power(xa, 3n), Field.mul(G.a, xa)), G.b), + Field.square(ya) === Field.add(Field.add(Field.power(xa, 3n), Field.mul(G.a, xa)), G.b), 'affine on curve (or zero)' ); } diff --git a/src/bindings/crypto/finite-field-examples.ts b/src/bindings/crypto/finite-field-examples.ts index a958f99c44..7f7a1aeba5 100644 --- a/src/bindings/crypto/finite-field-examples.ts +++ b/src/bindings/crypto/finite-field-examples.ts @@ -14,12 +14,10 @@ let pSecp256k1 = (1n << 256n) - (1n << 32n) - 0b1111010001n; let pSecq256k1 = (1n << 256n) - 0x14551231950b75fc4402da1732fc9bebfn; let pBls12_377 = 0x01ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1ef3622fba094800170b5d44300000008508c00000000001n; -let qBls12_377 = - 0x12ab655e9a2ca55660b44d1e5c37b00159aa76fed00000010a11800000000001n; +let qBls12_377 = 0x12ab655e9a2ca55660b44d1e5c37b00159aa76fed00000010a11800000000001n; let pBls12_381 = 0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaabn; -let qBls12_381 = - 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001n; +let qBls12_381 = 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001n; let exampleFields = { Fp, @@ -30,10 +28,7 @@ let exampleFields = { f25519: createField(p25519), secp256k1: createField(pSecp256k1), secq256k1: createField(pSecq256k1), - secp256r1: - createField( - 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffffn - ), + secp256r1: createField(0xffffffff00000001000000000000000000000000ffffffffffffffffffffffffn), bls12_377_base: createField(pBls12_377), bls12_377_scalar: createField(qBls12_377), bls12_381_base: createField(pBls12_381), diff --git a/src/bindings/crypto/finite-field.ts b/src/bindings/crypto/finite-field.ts index ac3d4cda03..fe8b86f470 100644 --- a/src/bindings/crypto/finite-field.ts +++ b/src/bindings/crypto/finite-field.ts @@ -11,16 +11,12 @@ const p = 0x40000000000000000000000000000000224698fc094cf91b992d30ed00000001n; const q = 0x40000000000000000000000000000000224698fc0994a8dd8c46eb2100000001n; // this is `t`, where p = 2^32 * t + 1 -const pMinusOneOddFactor = - 0x40000000000000000000000000000000224698fc094cf91b992d30edn; -const qMinusOneOddFactor = - 0x40000000000000000000000000000000224698fc0994a8dd8c46eb21n; +const pMinusOneOddFactor = 0x40000000000000000000000000000000224698fc094cf91b992d30edn; +const qMinusOneOddFactor = 0x40000000000000000000000000000000224698fc0994a8dd8c46eb21n; // primitive roots of unity, computed as (5^t mod p). this works because 5 generates the multiplicative group mod p -const twoadicRootFp = - 0x2bce74deac30ebda362120830561f81aea322bf2b7bb7584bdad6fabd87ea32fn; -const twoadicRootFq = - 0x2de6a9b8746d3f589e5c4dfd492ae26e9bb97ea3c106f049a70e2c1102b6d05fn; +const twoadicRootFp = 0x2bce74deac30ebda362120830561f81aea322bf2b7bb7584bdad6fabd87ea32fn; +const twoadicRootFq = 0x2de6a9b8746d3f589e5c4dfd492ae26e9bb97ea3c106f049a70e2c1102b6d05fn; // GENERAL FINITE FIELD ALGORITHMS @@ -69,13 +65,7 @@ function inverse(a: bigint, p: bigint) { // faster inversion algorithm based on // Thomas Pornin, "Optimized Binary GCD for Modular Inversion", https://eprint.iacr.org/2020/972.pdf // about 3x faster than `inverse()` -function fastInverse( - x: bigint, - p: bigint, - n: number, - kmax: bigint, - twoToMinusKmax: bigint -) { +function fastInverse(x: bigint, p: bigint, n: number, kmax: bigint, twoToMinusKmax: bigint) { x = mod(x, p); if (x === 0n) return undefined; @@ -249,8 +239,7 @@ function createField( p: bigint, constants?: { oddFactor: bigint; twoadicRoot: bigint; twoadicity: bigint } ) { - let { oddFactor, twoadicRoot, twoadicity } = - constants ?? computeFieldConstants(p); + let { oddFactor, twoadicRoot, twoadicity } = constants ?? computeFieldConstants(p); let sizeInBits = log2(p); let sizeInBytes = Math.ceil(sizeInBits / 8); let sizeHighestByte = sizeInBits - 8 * (sizeInBytes - 1); @@ -336,12 +325,7 @@ function createField( fromBigint(x: bigint) { return mod(x, p); }, - rot( - x: bigint, - bits: bigint, - direction: 'left' | 'right' = 'left', - maxBits = 64n - ) { + rot(x: bigint, bits: bigint, direction: 'left' | 'right' = 'left', maxBits = 64n) { if (direction === 'right') bits = maxBits - bits; let full = x << bits; let excess = full >> maxBits; diff --git a/src/bindings/crypto/finite-field.unit-test.ts b/src/bindings/crypto/finite-field.unit-test.ts index 358971dc59..f6b8e61911 100644 --- a/src/bindings/crypto/finite-field.unit-test.ts +++ b/src/bindings/crypto/finite-field.unit-test.ts @@ -37,16 +37,8 @@ for (let F of fields) { assert.equal(F.mul(p - 1n, 2n), p - 2n, 'mul'); assert.equal(F.mul(p - 3n, p - 3n), 9n, 'mul'); - assert.equal( - F.mul(F.mul(x, y), z), - F.mul(x, F.mul(y, z)), - 'mul associative' - ); - assert.equal( - F.mul(z, F.add(x, y)), - F.add(F.mul(z, x), F.mul(z, y)), - 'mul distributive' - ); + assert.equal(F.mul(F.mul(x, y), z), F.mul(x, F.mul(y, z)), 'mul associative'); + assert.equal(F.mul(z, F.add(x, y)), F.add(F.mul(z, x), F.mul(z, y)), 'mul distributive'); assert.equal(F.inverse(0n), undefined, '0 has no inverse'); assert.equal(F.inverse(1n), 1n, 'inverse 1'); @@ -76,11 +68,7 @@ for (let F of fields) { if (F.M >= 2n) { assert(F.isSquare(p - 1n), 'isSquare -1'); - assert.equal( - F.isSquare(0n), - F.isSquare(p), - 'isSquare handles non-canonical 0' - ); + assert.equal(F.isSquare(0n), F.isSquare(p), 'isSquare handles non-canonical 0'); let i = F.power(F.twoadicRoot, 1n << (F.M - 2n)); assert([i, F.negate(i)].includes(F.sqrt(p - 1n)!), 'sqrt -1'); } @@ -89,11 +77,7 @@ for (let F of fields) { assert.equal(F.power(2n, p - 1n), 1n, 'power mod p-1'); assert.equal(F.power(2n, p - 1n + 3n), 8n, 'power mod p-1'); assert.equal(F.power(x, 4n), F.square(F.square(x)), 'power'); - assert.equal( - F.power(x, y + z), - F.mul(F.power(x, y), F.power(x, z)), - 'power & mul' - ); + assert.equal(F.power(x, y + z), F.mul(F.power(x, y), F.power(x, z)), 'power & mul'); assert.equal(F.dot([x, y], [y, x]), F.mul(2n, F.mul(x, y)), 'dot'); assert.equal(F.dot([x, y], [F.negate(y), x]), 0n, 'dot'); diff --git a/src/bindings/crypto/glv.unit-test.ts b/src/bindings/crypto/glv.unit-test.ts index dea2d10619..fdbec984a2 100644 --- a/src/bindings/crypto/glv.unit-test.ts +++ b/src/bindings/crypto/glv.unit-test.ts @@ -37,10 +37,7 @@ function testGlv(params: CurveParams) { // decompose s and assert decomposition is correct let [s0, s1] = decompose(s, data); - assert( - Curve.Scalar.mod(s0.value + s1.value * lambda) === s, - 'valid decomposition' - ); + assert(Curve.Scalar.mod(s0.value + s1.value * lambda) === s, 'valid decomposition'); if (s0.abs > maxS0) maxS0 = s0.abs; if (s1.abs > maxS1) maxS1 = s1.abs; diff --git a/src/bindings/crypto/non-negative.ts b/src/bindings/crypto/non-negative.ts index 26879d3658..5e0d9e17ed 100644 --- a/src/bindings/crypto/non-negative.ts +++ b/src/bindings/crypto/non-negative.ts @@ -26,9 +26,7 @@ function asPositiveInteger(n: PositiveInteger) { function isInteger(n: N): n is Integer { return Number.isInteger(n); } -function isNonNegativeInteger( - n: N -): n is NonNegativeInteger { +function isNonNegativeInteger(n: N): n is NonNegativeInteger { return Number.isInteger(n) && n >= 0; } function isPositiveInteger(n: N): n is PositiveInteger { @@ -57,10 +55,6 @@ type NonNegativeInteger = number extends T : T; type PositiveInteger = number extends T ? never - : `${T}` extends - | `-${string}` - | `${string}.${string}` - | `${string}e-${string}` - | `0` + : `${T}` extends `-${string}` | `${string}.${string}` | `${string}e-${string}` | `0` ? never : T; diff --git a/src/bindings/crypto/poseidon.unit-test.ts b/src/bindings/crypto/poseidon.unit-test.ts index e6759749c9..e908d4c202 100644 --- a/src/bindings/crypto/poseidon.unit-test.ts +++ b/src/bindings/crypto/poseidon.unit-test.ts @@ -45,9 +45,7 @@ console.log('poseidon implementation matches the test vectors! 🎉'); test(Random.array(Random.field, Random.nat(20)), (xs) => { let g1 = Poseidon.hashToGroup(xs)!; - let [, g2x, g2y] = mlTest.poseidon.hashToGroup( - MlArray.to(xs.map(FieldConst.fromBigint)) - ); + let [, g2x, g2y] = mlTest.poseidon.hashToGroup(MlArray.to(xs.map(FieldConst.fromBigint))); expect(g1).toBeDefined(); expect(g1.x).toEqual(FieldConst.toBigint(g2x)); diff --git a/src/bindings/index.ts b/src/bindings/index.ts index 95064823b5..a64a7847a3 100644 --- a/src/bindings/index.ts +++ b/src/bindings/index.ts @@ -1,3 +1,3 @@ -export * as EllipticCurve from "./crypto/elliptic-curve.js"; -export * as FiniteField from "./crypto/finite-field.js"; -export * as BigIntHelpers from "./crypto/bigint-helpers.js"; \ No newline at end of file +export * as EllipticCurve from './crypto/elliptic-curve.js'; +export * as FiniteField from './crypto/finite-field.js'; +export * as BigIntHelpers from './crypto/bigint-helpers.js'; diff --git a/src/bindings/js/node/node-backend.js b/src/bindings/js/node/node-backend.js index 6f9762e053..9b844239ac 100644 --- a/src/bindings/js/node/node-backend.js +++ b/src/bindings/js/node/node-backend.js @@ -74,7 +74,5 @@ async function startWorkers(src, memory, builder) { } async function terminateWorkers() { - return Promise.all(wasmWorkers.map((w) => w.terminate())).then( - () => (wasmWorkers = undefined) - ); + return Promise.all(wasmWorkers.map((w) => w.terminate())).then(() => (wasmWorkers = undefined)); } diff --git a/src/bindings/js/web/web-backend.js b/src/bindings/js/web/web-backend.js index 5652c17399..0393b99c52 100644 --- a/src/bindings/js/web/web-backend.js +++ b/src/bindings/js/web/web-backend.js @@ -1,10 +1,6 @@ import plonkWasm from '../../../web_bindings/plonk_wasm.js'; import { workerSpec } from './worker-spec.js'; -import { - srcFromFunctionModule, - inlineWorker, - waitForMessage, -} from './worker-helpers.js'; +import { srcFromFunctionModule, inlineWorker, waitForMessage } from './worker-helpers.js'; import o1jsWebSrc from 'string:../../../web_bindings/o1js_web.bc.js'; import { WithThreadPool, workers } from '../../../lib/proof-system/workers.js'; @@ -54,19 +50,14 @@ async function initializeBindings() { } async function initThreadPool() { - if (workerPromise === undefined) - throw Error('need to initialize worker first'); + if (workerPromise === undefined) throw Error('need to initialize worker first'); let worker = await workerPromise; - numWorkers ??= Math.max( - 1, - workers.numWorkers ?? (navigator.hardwareConcurrency ?? 1) - 1 - ); + numWorkers ??= Math.max(1, workers.numWorkers ?? (navigator.hardwareConcurrency ?? 1) - 1); await workerCall(worker, 'initThreadPool', numWorkers); } async function exitThreadPool() { - if (workerPromise === undefined) - throw Error('need to initialize worker first'); + if (workerPromise === undefined) throw Error('need to initialize worker first'); let worker = await workerPromise; await workerCall(worker, 'exitThreadPool'); } @@ -125,20 +116,13 @@ async function mainWorker() { await init(module, memory); postMessage({ type: data.id }); } -mainWorker.deps = [ - plonkWasm, - workerSpec, - workerExport, - onMessage, - waitForMessage, -]; +mainWorker.deps = [plonkWasm, workerSpec, workerExport, onMessage, waitForMessage]; function overrideBindings(plonk_wasm, worker) { let spec = workerSpec(plonk_wasm); for (let key in spec) { plonk_wasm[key] = (...args) => { - if (spec[key].disabled) - throw Error(`Wasm method '${key}' is disabled on the web.`); + if (spec[key].disabled) throw Error(`Wasm method '${key}' is disabled on the web.`); let u32_ptr = wasm.create_zero_u32_ptr(); worker.postMessage({ type: 'run', diff --git a/src/bindings/js/web/worker-helpers.js b/src/bindings/js/web/worker-helpers.js index 264db951a2..8fc89e709d 100644 --- a/src/bindings/js/web/worker-helpers.js +++ b/src/bindings/js/web/worker-helpers.js @@ -81,9 +81,7 @@ async function startWorkers(module, memory, builder) { self._workers.push(worker); } URL.revokeObjectURL(url); - await Promise.all( - self._workers.map((w) => waitForMessage(w, 'wasm_bindgen_worker_ready')) - ); + await Promise.all(self._workers.map((w) => waitForMessage(w, 'wasm_bindgen_worker_ready'))); builder.build(); } startWorkers.deps = [srcFromFunctionModule, waitForMessage, workerHelperMain]; diff --git a/src/bindings/js/web/worker-spec.js b/src/bindings/js/web/worker-spec.js index 4db90068a2..924d6985fa 100644 --- a/src/bindings/js/web/worker-spec.js +++ b/src/bindings/js/web/worker-spec.js @@ -130,35 +130,19 @@ function workerSpec(wasm) { res: wasm.WasmFqPolyComm, }, fp_oracles_create: { - args: [ - undefined /* Uint32Array */, - wasm.WasmFpPlonkVerifierIndex, - wasm.WasmFpProverProof, - ], + args: [undefined /* Uint32Array */, wasm.WasmFpPlonkVerifierIndex, wasm.WasmFpProverProof], res: wasm.WasmFpOracles, }, fq_oracles_create: { - args: [ - undefined /* Uint32Array */, - wasm.WasmFqPlonkVerifierIndex, - wasm.WasmFqProverProof, - ], + args: [undefined /* Uint32Array */, wasm.WasmFqPlonkVerifierIndex, wasm.WasmFqProverProof], res: wasm.WasmFqOracles, }, caml_fp_srs_batch_accumulator_check: { - args: [ - wasm.WasmFpSrs, - undefined /* UintXArray */, - undefined /* UintXArray */, - ], + args: [wasm.WasmFpSrs, undefined /* UintXArray */, undefined /* UintXArray */], res: bool, }, caml_fq_srs_batch_accumulator_check: { - args: [ - wasm.WasmFqSrs, - undefined /* UintXArray */, - undefined /* UintXArray */, - ], + args: [wasm.WasmFqSrs, undefined /* UintXArray */, undefined /* UintXArray */], res: bool, }, caml_fp_srs_lagrange_commitment: { diff --git a/src/bindings/lib/binable.ts b/src/bindings/lib/binable.ts index 5b6aad03b4..f350268128 100644 --- a/src/bindings/lib/binable.ts +++ b/src/bindings/lib/binable.ts @@ -57,18 +57,12 @@ function defineBinable({ }): Binable { // spec: input offset has to be a non-negative integer, and be smaller than the bytes length // output offset has to be greater or equal input, and not exceed the bytes length - let readBytes_ = ( - bytes: number[], - offset: NonNegativeInteger - ) => { + let readBytes_ = (bytes: number[], offset: NonNegativeInteger) => { assertNonNegativeInteger(offset, 'readBytes: offset must be integer >= 0'); - if (offset >= bytes.length) - throw Error('readBytes: offset must be within bytes length'); + if (offset >= bytes.length) throw Error('readBytes: offset must be within bytes length'); let [value, end] = readBytes(bytes, offset); if (end < offset) - throw Error( - 'offset returned by readBytes must be greater than initial offset' - ); + throw Error('offset returned by readBytes must be greater than initial offset'); if (end > bytes.length) throw Error('offset returned by readBytes must not exceed bytes length'); return [value, end] as [T, number]; @@ -79,17 +73,13 @@ function defineBinable({ // spec: fromBytes throws if the input bytes are not all used fromBytes(bytes) { let [value, offset] = readBytes_(bytes, 0); - if (offset < bytes.length) - throw Error('fromBytes: input bytes left over'); + if (offset < bytes.length) throw Error('fromBytes: input bytes left over'); return value; }, }; } -function withVersionNumber( - binable: Binable, - versionNumber: number -): Binable { +function withVersionNumber(binable: Binable, versionNumber: number): Binable { return defineBinable({ toBytes(t) { let bytes = binable.toBytes(t); @@ -99,19 +89,14 @@ function withVersionNumber( readBytes(bytes, offset) { let version = bytes[offset++]; if (version !== versionNumber) { - throw Error( - `fromBytes: Invalid version byte. Expected ${versionNumber}, got ${version}.` - ); + throw Error(`fromBytes: Invalid version byte. Expected ${versionNumber}, got ${version}.`); } return binable.readBytes(bytes, offset); }, }); } -function withCheck( - { toBytes, readBytes }: Binable, - check: (t: T) => void -): Binable { +function withCheck({ toBytes, readBytes }: Binable, check: (t: T) => void): Binable { return defineBinable({ toBytes, readBytes(bytes, start) { @@ -139,9 +124,7 @@ function record>( }, readBytes(bytes, start) { let [tupleValue, end] = tupleBinable.readBytes(bytes, start); - let value = Object.fromEntries( - keys.map((key, i) => [key, tupleValue[i]]) - ) as any; + let value = Object.fromEntries(keys.map((key, i) => [key, tupleValue[i]])) as any; return [value, end]; }, }); @@ -233,8 +216,7 @@ function BinableInt(bits: PositiveInteger) { if (nBytes * 8 !== bits) throw Error('bits must be evenly divisible by 8'); return defineBinable({ toBytes(n: bigint) { - if (n < -maxValue || n >= maxValue) - throw Error(`int${bits} out of range, got ${n}`); + if (n < -maxValue || n >= maxValue) throw Error(`int${bits} out of range, got ${n}`); if (n >= 0) { if (n < 0x80n) return bigIntToBytes(n, 1); if (n < 0x8000n) return [CODE_INT16, ...bigIntToBytes(n, 2)]; @@ -242,12 +224,9 @@ function BinableInt(bits: PositiveInteger) { else return [CODE_INT64, ...bigIntToBytes(n, 8)]; } else { let M = 1n << 64n; - if (n >= -0x80n) - return [CODE_NEG_INT8, ...bigIntToBytes((M + n) & 0xffn, 1)]; - if (n >= -0x8000n) - return [CODE_INT16, ...bigIntToBytes((M + n) & 0xffffn, 2)]; - if (n >= -0x80000000) - return [CODE_INT32, ...bigIntToBytes((M + n) & 0xffff_ffffn, 4)]; + if (n >= -0x80n) return [CODE_NEG_INT8, ...bigIntToBytes((M + n) & 0xffn, 1)]; + if (n >= -0x8000n) return [CODE_INT16, ...bigIntToBytes((M + n) & 0xffffn, 2)]; + if (n >= -0x80000000) return [CODE_INT32, ...bigIntToBytes((M + n) & 0xffff_ffffn, 4)]; else return [CODE_INT64, ...bigIntToBytes(M + n, 8)]; } }, @@ -293,15 +272,13 @@ function BinableUint(bits: PositiveInteger) { let maxValue = 1n << BigInt(bits - 1); return iso(binableInt, { to(uint: bigint) { - if (uint < 0n || uint >= 2n * maxValue) - throw Error(`uint${bits} out of range, got ${uint}`); + if (uint < 0n || uint >= 2n * maxValue) throw Error(`uint${bits} out of range, got ${uint}`); let ret = uint >= maxValue ? uint - 2n * maxValue : uint; return ret; }, from(int: bigint) { let uint = int < 0n ? int + 2n * maxValue : int; - if (uint < 0n || uint >= 2n * maxValue) - throw Error(`uint${bits} out of range, got ${uint}`); + if (uint < 0n || uint >= 2n * maxValue) throw Error(`uint${bits} out of range, got ${uint}`); return uint; }, }); @@ -314,16 +291,11 @@ const BinableUint32 = BinableUint(32); // same as Random_oracle.prefix_to_field in OCaml // converts string to bytes and bytes to field; throws if bytes don't fit in one field -function prefixToField( - Field: GenericSignableField, - prefix: string -) { +function prefixToField(Field: GenericSignableField, prefix: string) { let fieldSize = Field.sizeInBytes; if (prefix.length >= fieldSize) throw Error('prefix too long'); let stringBytes = stringToBytes(prefix); - return Field.fromBytes( - stringBytes.concat(Array(fieldSize - stringBytes.length).fill(0)) - ); + return Field.fromBytes(stringBytes.concat(Array(fieldSize - stringBytes.length).fill(0))); } function bitsToBytes([...bits]: boolean[]) { @@ -363,10 +335,7 @@ function bytesToBits(bytes: number[]) { * This is useful for serializing field elements, where -- depending on the circumstance -- we either want a * 32-byte (= 256-bit) serialization, or a 255-bit serialization */ -function withBits( - binable: Binable, - sizeInBits: number -): BinableWithBits { +function withBits(binable: Binable, sizeInBits: number): BinableWithBits { return { ...binable, toBits(t: T) { @@ -380,10 +349,7 @@ function withBits( }; } -function iso( - binable: Binable, - { to, from }: { to(s: S): T; from(t: T): S } -): Binable { +function iso(binable: Binable, { to, from }: { to(s: S): T; from(t: T): S }): Binable { return defineBinable({ toBytes(s: S) { return binable.toBytes(to(s)); diff --git a/src/bindings/lib/binable.unit-test.ts b/src/bindings/lib/binable.unit-test.ts index e62fcc99a3..ffd538c899 100644 --- a/src/bindings/lib/binable.unit-test.ts +++ b/src/bindings/lib/binable.unit-test.ts @@ -36,18 +36,14 @@ test(Random.field, (field) => { let result = Field.fromBytes(bytes); expect(result).toEqual(field); }); -test.negative(Random.field.invalid, (field) => - Field.fromBytes(Field.toBytes(field)) -); +test.negative(Random.field.invalid, (field) => Field.fromBytes(Field.toBytes(field))); test(Random.scalar, (scalar) => { let bytes = Scalar.toBytes(scalar); let result = Scalar.fromBytes(bytes); expect(result).toEqual(scalar); }); -test.negative(Random.scalar.invalid, (scalar) => - Scalar.fromBytes(Scalar.toBytes(scalar)) -); +test.negative(Random.scalar.invalid, (scalar) => Scalar.fromBytes(Scalar.toBytes(scalar))); // public key @@ -109,10 +105,10 @@ let randomAccountBalance: Random = Random.record({ address: Random.publicKey, balance: Random.uint64, }); -let AccountBalance: Binable = record( - { address: PublicKey, balance: UInt64 }, - ['address', 'balance'] -); +let AccountBalance: Binable = record({ address: PublicKey, balance: UInt64 }, [ + 'address', + 'balance', +]); test(randomAccountBalance, (accountBalance) => { let bytes = AccountBalance.toBytes(accountBalance); diff --git a/src/bindings/lib/encoding.ts b/src/bindings/lib/encoding.ts index 45cb889671..13739da75b 100644 --- a/src/bindings/lib/encoding.ts +++ b/src/bindings/lib/encoding.ts @@ -1,13 +1,7 @@ import { bytesToBigInt, changeBase } from '../crypto/bigint-helpers.js'; import { Field } from '../../lib/provable/wrapped.js'; -export { - stringToFields, - stringFromFields, - bytesToFields, - bytesFromFields, - Bijective, -}; +export { stringToFields, stringFromFields, bytesToFields, bytesFromFields, Bijective }; // functions for encoding data as field elements @@ -147,8 +141,7 @@ function bigIntToBytes(x: bigint, length: number) { } let array = new Uint8Array(bytes); if (length === undefined) return array; - if (array.length > length) - throw Error(`bigint doesn't fit into ${length} bytes.`); + if (array.length > length) throw Error(`bigint doesn't fit into ${length} bytes.`); let sizedArray = new Uint8Array(length); sizedArray.set(array); return sizedArray; diff --git a/src/bindings/lib/from-layout.ts b/src/bindings/lib/from-layout.ts index a23a9bc214..a1fd4fcfc8 100644 --- a/src/bindings/lib/from-layout.ts +++ b/src/bindings/lib/from-layout.ts @@ -5,12 +5,7 @@ import { primitiveTypes, } from './generic.js'; -export { - ProvableFromLayout, - SignableFromLayout, - GenericLayout, - genericLayoutFold, -}; +export { ProvableFromLayout, SignableFromLayout, GenericLayout, genericLayoutFold }; type GenericTypeMap< Field, @@ -35,11 +30,7 @@ type GenericTypeMap< }; type AnyTypeMap = GenericTypeMap; -type TypeMapValues< - TypeMap extends AnyTypeMap, - JsonMap extends AnyTypeMap, - BaseType -> = { +type TypeMapValues = { [K in keyof TypeMap & keyof JsonMap]: BaseType; }; @@ -49,26 +40,14 @@ type TypeMapProvable< JsonMap extends AnyTypeMap > = { [K in keyof TypeMap & keyof JsonMap]: K extends keyof ValueMap - ? GenericProvableExtended< - TypeMap[K], - ValueMap[K], - JsonMap[K], - TypeMap['Field'] - > + ? GenericProvableExtended : never; }; type TypeMapSignable = { - [K in keyof TypeMap & keyof JsonMap]: GenericSignable< - TypeMap[K], - JsonMap[K], - TypeMap['Field'] - >; + [K in keyof TypeMap & keyof JsonMap]: GenericSignable; }; -function SignableFromLayout< - TypeMap extends AnyTypeMap, - JsonMap extends AnyTypeMap ->( +function SignableFromLayout( TypeMap: TypeMapSignable, customTypes: Record> ) { @@ -148,8 +127,7 @@ function SignableFromLayout< value = empty(optionTypeData.inner); if (optionTypeData.optionType === 'closedInterval') { let innerInner = optionTypeData.inner.entries.lower; - let innerType = - TypeMap[innerInner.type as keyof TypeMap & keyof JsonMap]; + let innerType = TypeMap[innerInner.type as keyof TypeMap & keyof JsonMap]; value.lower = innerType.fromJSON(optionTypeData.rangeMin); value.upper = innerType.fromJSON(optionTypeData.rangeMax); } @@ -157,9 +135,7 @@ function SignableFromLayout< return { isSome, value }; } case 'orUndefined': { - return json === null - ? undefined - : fromJSON(optionTypeData.inner, json); + return json === null ? undefined : fromJSON(optionTypeData.inner, json); } default: throw Error('bug'); @@ -297,10 +273,7 @@ function ProvableFromLayout< JsonMap extends AnyTypeMap >( TypeMap: TypeMapProvable, - customTypes: Record< - string, - GenericProvableExtended - > + customTypes: Record> ) { type Field = TypeMap['Field']; const Field = TypeMap.Field; @@ -310,17 +283,15 @@ function ProvableFromLayout< type FoldSpec = GenericFoldSpec; - const { toInput, toJSON, fromJSON, empty, toJSONEssential } = - SignableFromLayout(TypeMap, customTypes); + const { toInput, toJSON, fromJSON, empty, toJSONEssential } = SignableFromLayout( + TypeMap, + customTypes + ); function layoutFold(spec: FoldSpec, typeData: Layout, value?: T) { return genericLayoutFold(TypeMap, customTypes, spec, typeData, value); } - function layoutMap( - map: (typeData: BaseType, value: T) => R, - typeData: Layout, - value: T - ) { + function layoutMap(map: (typeData: BaseType, value: T) => R, typeData: Layout, value: T) { return genericLayoutMap(TypeMap, customTypes, map, typeData, value); } @@ -453,11 +424,7 @@ function ProvableFromLayout< let length = aux.length; let value = []; for (let i = 0, offset = 0; i < length; i++, offset += size) { - value[i] = fromFields( - arrayTypeData.inner, - fields.slice(offset, offset + size), - aux[i] - ); + value[i] = fromFields(arrayTypeData.inner, fields.slice(offset, offset + size), aux[i]); } return value; } @@ -486,11 +453,7 @@ function ProvableFromLayout< for (let i = 0; i < keys.length; i++) { let typeEntry = entries[keys[i]]; let size = sizeInFields(typeEntry); - values[keys[i]] = fromFields( - typeEntry, - fields.slice(offset, offset + size), - aux[i] - ); + values[keys[i]] = fromFields(typeEntry, fields.slice(offset, offset + size), aux[i]); offset += size; } return values; @@ -518,19 +481,11 @@ function ProvableFromLayout< } function toValue(typeData: Layout, value: any) { - return layoutMap( - (type, value) => type.toValue(value), - typeData, - value - ); + return layoutMap((type, value) => type.toValue(value), typeData, value); } function fromValue(typeData: Layout, value: any) { - return layoutMap( - (type, value) => type.fromValue(value), - typeData, - value - ); + return layoutMap((type, value) => type.fromValue(value), typeData, value); } return { provableFromLayout, toJSONEssential, empty }; @@ -546,10 +501,7 @@ type GenericFoldSpec = { option: { isSome: R; value: R }, typeData: FlaggedOptionLayout ) => R; - reduceOrUndefined: ( - value: R | undefined, - innerTypeData: GenericLayout - ) => R; + reduceOrUndefined: (value: R | undefined, innerTypeData: GenericLayout) => R; }; function genericLayoutFold< @@ -577,16 +529,11 @@ function genericLayoutFold< v = Array(arrayTypeData.staticLength).fill(undefined); } let array = - v?.map((x) => - genericLayoutFold(TypeMap, customTypes, spec, arrayTypeData.inner, x) - ) ?? []; + v?.map((x) => genericLayoutFold(TypeMap, customTypes, spec, arrayTypeData.inner, x)) ?? []; return spec.reduceArray(array, arrayTypeData); } if (typeData.type === 'option') { - let { optionType, inner } = typeData as OptionLayout< - TypeMap, - BaseLayout - >; + let { optionType, inner } = typeData as OptionLayout>; switch (optionType) { case 'closedInterval': case 'flaggedOption': @@ -594,13 +541,7 @@ function genericLayoutFold< return spec.reduceFlaggedOption( { isSome: spec.map(TypeMap.Bool, v?.isSome, 'Bool'), - value: genericLayoutFold( - TypeMap, - customTypes, - spec, - inner, - v?.value - ), + value: genericLayoutFold(TypeMap, customTypes, spec, inner, v?.value), }, typeData as FlaggedOptionLayout ); @@ -619,22 +560,12 @@ function genericLayoutFold< let v: Record | undefined = value as any; let object: Record = {}; keys.forEach((key) => { - object[key] = genericLayoutFold( - TypeMap, - customTypes, - spec, - entries[key], - v?.[key] - ); + object[key] = genericLayoutFold(TypeMap, customTypes, spec, entries[key], v?.[key]); }); return spec.reduceObject(keys, object); } if (primitiveTypes.has(typeData.type)) { - return spec.map( - (primitiveTypeMap as any)[typeData.type], - value, - typeData.type - ); + return spec.map((primitiveTypeMap as any)[typeData.type], value, typeData.type); } return spec.map((TypeMap as any)[typeData.type], value, typeData.type); } @@ -715,10 +646,10 @@ type OptionLayout> = { ) & WithChecked; -type FlaggedOptionLayout< - TypeMap extends AnyTypeMap, - T = BaseLayout -> = Exclude, { optionType: 'orUndefined' }>; +type FlaggedOptionLayout> = Exclude< + OptionLayout, + { optionType: 'orUndefined' } +>; type ArrayLayout = { type: 'array'; diff --git a/src/bindings/lib/generic.ts b/src/bindings/lib/generic.ts index 86df1cf8f6..119d5f218d 100644 --- a/src/bindings/lib/generic.ts +++ b/src/bindings/lib/generic.ts @@ -43,28 +43,17 @@ type GenericSignable = { empty: () => T; }; -type GenericProvableExtended = GenericProvable< - T, - TValue, - Field -> & +type GenericProvableExtended = GenericProvable & GenericSignable; -type GenericProvableExtendedPure = GenericProvablePure< - T, - TValue, - Field -> & +type GenericProvableExtendedPure = GenericProvablePure & GenericSignable; -type GenericSignableField = (( - value: number | string | bigint | Field -) => Field) & +type GenericSignableField = ((value: number | string | bigint | Field) => Field) & GenericSignable & Binable & { sizeInBytes: number; toBigint: (x: Field) => bigint }; -type GenericField = GenericSignableField & - GenericProvable; +type GenericField = GenericSignableField & GenericProvable; type GenericSignableBool = ((value: boolean) => Bool) & GenericSignable & @@ -101,28 +90,13 @@ const undefinedType = { let primitiveTypes = new Set(['number', 'string', 'null']); -function EmptyNull(): GenericProvableExtendedPure< - null, - null, - null, - Field -> { +function EmptyNull(): GenericProvableExtendedPure { return emptyType; } -function EmptyUndefined(): GenericProvableExtendedPure< - undefined, - undefined, - null, - Field -> { +function EmptyUndefined(): GenericProvableExtendedPure { return undefinedType; } -function EmptyVoid(): GenericProvableExtendedPure< - void, - void, - null, - Field -> { +function EmptyVoid(): GenericProvableExtendedPure { return undefinedType; } diff --git a/src/bindings/lib/provable-generic.ts b/src/bindings/lib/provable-generic.ts index 443cc5ae7c..af81c9b4bb 100644 --- a/src/bindings/lib/provable-generic.ts +++ b/src/bindings/lib/provable-generic.ts @@ -43,11 +43,12 @@ function createDerivers(): { signable: SignableConstructor; } { type Signable = GenericSignable; - type ProvableExtended< + type ProvableExtended = GenericProvableExtended< T, - TValue = any, - TJson = JSONValue - > = GenericProvableExtended; + TValue, + TJson, + Field + >; type HashInput = GenericHashInput; const HashInput = createHashInput(); @@ -55,9 +56,7 @@ function createDerivers(): { * A function that gives us a hint that the input type is a `Provable` and we shouldn't continue * recursing into its properties, when computing methods that aren't required by the `Provable` interface. */ - function isProvable( - typeObj: object - ): typeObj is GenericProvable { + function isProvable(typeObj: object): typeObj is GenericProvable { return ( 'sizeInFields' in typeObj && 'toFields' in typeObj && @@ -72,13 +71,10 @@ function createDerivers(): { /** * Accepts objects of the form { provable: Provable } */ - function hasProvable( - typeObj: object - ): typeObj is { provable: GenericProvable } { + function hasProvable(typeObj: object): typeObj is { provable: GenericProvable } { return ( 'provable' in typeObj && - (typeof typeObj.provable === 'object' || - typeof typeObj.provable === 'function') && + (typeof typeObj.provable === 'object' || typeof typeObj.provable === 'function') && typeObj.provable !== null && isProvable(typeObj.provable) ); @@ -96,13 +92,11 @@ function createDerivers(): { function sizeInFields(typeObj: NestedProvable): number { if (isPrimitive(typeObj)) return 0; - if (!complexTypes.has(typeof typeObj)) - throw Error(`provable: unsupported type "${typeObj}"`); + if (!complexTypes.has(typeof typeObj)) throw Error(`provable: unsupported type "${typeObj}"`); if (hasProvable(typeObj)) return typeObj.provable.sizeInFields(); - if (Array.isArray(typeObj)) - return typeObj.map(sizeInFields).reduce((a, b) => a + b, 0); + if (Array.isArray(typeObj)) return typeObj.map(sizeInFields).reduce((a, b) => a + b, 0); if (isProvable(typeObj)) return typeObj.sizeInFields(); @@ -114,8 +108,7 @@ function createDerivers(): { function toFields(typeObj: NestedProvable, obj: any): Field[] { if (isPrimitive(typeObj)) return []; - if (!complexTypes.has(typeof typeObj)) - throw Error(`provable: unsupported type "${typeObj}"`); + if (!complexTypes.has(typeof typeObj)) throw Error(`provable: unsupported type "${typeObj}"`); if (hasProvable(typeObj)) return typeObj.provable.toFields(obj); @@ -127,9 +120,7 @@ function createDerivers(): { throw Error(`Expected an array for type, but got ${typeof obj}`); } if (typeObj.length !== obj.length) { - throw Error( - `Expected array length ${typeObj.length}, but got ${obj.length}` - ); + throw Error(`Expected array length ${typeObj.length}, but got ${obj.length}`); } return typeObj.map((t, i) => toFields(t, obj[i])).flat(); } @@ -153,25 +144,15 @@ function createDerivers(): { if (hasProvable(typeObj)) return typeObj.provable.toAuxiliary(obj); - if (Array.isArray(typeObj)) - return typeObj.map((t, i) => toAuxiliary(t, obj?.[i])); + if (Array.isArray(typeObj)) return typeObj.map((t, i) => toAuxiliary(t, obj?.[i])); if (isProvable(typeObj)) return typeObj.toAuxiliary(obj); return Object.keys(typeObj).map((k) => toAuxiliary(typeObj[k], obj?.[k])); } - function fromFields( - typeObj: NestedProvable, - fields: Field[], - aux: any[] = [] - ): any { - if ( - typeObj === Number || - typeObj === String || - typeObj === Boolean || - typeObj === BigInt - ) + function fromFields(typeObj: NestedProvable, fields: Field[], aux: any[] = []): any { + if (typeObj === Number || typeObj === String || typeObj === Boolean || typeObj === BigInt) return aux[0]; if (typeObj === undefined || typeObj === null) return typeObj; @@ -186,9 +167,7 @@ function createDerivers(): { let offset = 0; for (let subObj of typeObj) { let size = sizeInFields(subObj); - array.push( - fromFields(subObj, fields.slice(offset, offset + size), aux[i]) - ); + array.push(fromFields(subObj, fields.slice(offset, offset + size), aux[i])); offset += size; i++; } @@ -209,13 +188,11 @@ function createDerivers(): { function check(typeObj: NestedProvable, obj: any): void { if (isPrimitive(typeObj)) return; - if (!complexTypes.has(typeof typeObj)) - throw Error(`provable: unsupported type "${typeObj}"`); + if (!complexTypes.has(typeof typeObj)) throw Error(`provable: unsupported type "${typeObj}"`); if (hasProvable(typeObj)) return typeObj.provable.check(obj); - if (Array.isArray(typeObj)) - return typeObj.forEach((t, i) => check(t, obj[i])); + if (Array.isArray(typeObj)) return typeObj.forEach((t, i) => check(t, obj[i])); if (isProvable(typeObj)) return typeObj.check(obj); @@ -249,11 +226,9 @@ function createDerivers(): { function toCanonical(typeObj: NestedProvable, value: any): any { if (isPrimitive(typeObj)) return value; - if (!complexTypes.has(typeof typeObj)) - throw Error(`provable: unsupported type "${typeObj}"`); + if (!complexTypes.has(typeof typeObj)) throw Error(`provable: unsupported type "${typeObj}"`); - if (hasProvable(typeObj)) - return typeObj.provable.toCanonical?.(value) ?? value; + if (hasProvable(typeObj)) return typeObj.provable.toCanonical?.(value) ?? value; if (Array.isArray(typeObj)) { return typeObj.forEach((t, i) => toCanonical(t, value[i])); @@ -285,8 +260,7 @@ function createDerivers(): { sizeInFields: () => sizeInFields(type), toFields: (obj: T) => toFields(type, obj), toAuxiliary: (obj?: T) => toAuxiliary(type, obj), - fromFields: (fields: Field[], aux: any[]) => - fromFields(type, fields, aux) as T, + fromFields: (fields: Field[], aux: any[]) => fromFields(type, fields, aux) as T, check: (obj: T) => check(type, obj), toValue(x) { return toValue(type, x); @@ -310,33 +284,20 @@ function createDerivers(): { ): InferredSignable { type T = InferSignable; type J = InferJson; - let objectKeys = - typeof typeObj === 'object' && typeObj !== null - ? Object.keys(typeObj) - : []; - let primitives = new Set([ - Number, - String, - Boolean, - BigInt, - null, - undefined, - ]); + let objectKeys = typeof typeObj === 'object' && typeObj !== null ? Object.keys(typeObj) : []; + let primitives = new Set([Number, String, Boolean, BigInt, null, undefined]); if (!primitives.has(typeObj as any) && !complexTypes.has(typeof typeObj)) { throw Error(`provable: unsupported type "${typeObj}"`); } function toInput(typeObj: any, obj: any): HashInput { if (primitives.has(typeObj)) return {}; - if (!complexTypes.has(typeof typeObj)) - throw Error(`provable: unsupported type "${typeObj}"`); + if (!complexTypes.has(typeof typeObj)) throw Error(`provable: unsupported type "${typeObj}"`); if ('provable' in typeObj) return toInput(typeObj.provable, obj); if (Array.isArray(typeObj)) { - return typeObj - .map((t, i) => toInput(t, obj[i])) - .reduce(HashInput.append, HashInput.empty); + return typeObj.map((t, i) => toInput(t, obj[i])).reduce(HashInput.append, HashInput.empty); } if ('toInput' in typeObj) return typeObj.toInput(obj) as HashInput; if ('toFields' in typeObj) { @@ -348,39 +309,31 @@ function createDerivers(): { } function toJSON(typeObj: any, obj: any): JSONValue { if (typeObj === BigInt) return obj.toString(); - if (typeObj === String || typeObj === Number || typeObj === Boolean) - return obj; + if (typeObj === String || typeObj === Number || typeObj === Boolean) return obj; if (typeObj === undefined || typeObj === null) return null; - if (!complexTypes.has(typeof typeObj)) - throw Error(`provable: unsupported type "${typeObj}"`); + if (!complexTypes.has(typeof typeObj)) throw Error(`provable: unsupported type "${typeObj}"`); if ('provable' in typeObj) return toJSON(typeObj.provable, obj); - if (Array.isArray(typeObj)) - return typeObj.map((t, i) => toJSON(t, obj[i])); + if (Array.isArray(typeObj)) return typeObj.map((t, i) => toJSON(t, obj[i])); if ('toJSON' in typeObj) return typeObj.toJSON(obj); if (shouldTerminate?.(typeObj) === true) { throw Error(`Expected \`toJSON()\` method on ${display(typeObj)}`); } - return Object.fromEntries( - Object.keys(typeObj).map((k) => [k, toJSON(typeObj[k], obj[k])]) - ); + return Object.fromEntries(Object.keys(typeObj).map((k) => [k, toJSON(typeObj[k], obj[k])])); } function fromJSON(typeObj: any, json: any): any { if (typeObj === BigInt) return BigInt(json as string); - if (typeObj === String || typeObj === Number || typeObj === Boolean) - return json; + if (typeObj === String || typeObj === Number || typeObj === Boolean) return json; if (typeObj === null || typeObj === undefined) return undefined; - if (!complexTypes.has(typeof typeObj)) - throw Error(`provable: unsupported type "${typeObj}"`); + if (!complexTypes.has(typeof typeObj)) throw Error(`provable: unsupported type "${typeObj}"`); if ('provable' in typeObj) return fromJSON(typeObj.provable, json); - if (Array.isArray(typeObj)) - return typeObj.map((t, i) => fromJSON(t, json[i])); + if (Array.isArray(typeObj)) return typeObj.map((t, i) => fromJSON(t, json[i])); if ('fromJSON' in typeObj) return typeObj.fromJSON(json); if (shouldTerminate?.(typeObj) === true) { @@ -401,8 +354,7 @@ function createDerivers(): { if (typeObj === Boolean) return false; if (typeObj === BigInt) return 0n; if (typeObj === null || typeObj === undefined) return typeObj; - if (!complexTypes.has(typeof typeObj)) - throw Error(`provable: unsupported type "${typeObj}"`); + if (!complexTypes.has(typeof typeObj)) throw Error(`provable: unsupported type "${typeObj}"`); if ('provable' in typeObj) return empty(typeObj.provable); @@ -413,9 +365,7 @@ function createDerivers(): { throw Error(`Expected \`empty()\` method on ${display(typeObj)}`); } - return Object.fromEntries( - Object.keys(typeObj).map((k) => [k, empty(typeObj[k])]) - ); + return Object.fromEntries(Object.keys(typeObj).map((k) => [k, empty(typeObj[k])])); } return { @@ -434,17 +384,14 @@ function createDerivers(): { function createMap(name: S) { function map(typeObj: any, obj: any): any { if (primitives.has(typeObj)) return obj; - if (!complexTypes.has(typeof typeObj)) - throw Error(`provable: unsupported type "${typeObj}"`); + if (!complexTypes.has(typeof typeObj)) throw Error(`provable: unsupported type "${typeObj}"`); if (hasProvable(typeObj) && name in typeObj.provable) return (typeObj.provable as any)[name](obj); if (Array.isArray(typeObj)) return typeObj.map((t, i) => map(t, obj[i])); if (name in typeObj) return typeObj[name](obj); - return Object.fromEntries( - Object.keys(typeObj).map((k) => [k, map(typeObj[k], obj[k])]) - ); + return Object.fromEntries(Object.keys(typeObj).map((k) => [k, map(typeObj[k], obj[k])])); } return map; } @@ -473,20 +420,9 @@ function createHashInput() { // some type inference helpers -type JSONValue = - | number - | string - | boolean - | null - | Array - | { [key: string]: JSONValue }; - -type Struct = GenericProvableExtended< - NonMethods, - any, - any, - Field -> & +type JSONValue = number | string | boolean | null | Array | { [key: string]: JSONValue }; + +type Struct = GenericProvableExtended, any, any, Field> & Constructor & { _isStruct: true }; type NonMethodKeys = { @@ -498,13 +434,7 @@ type Constructor = new (...args: any) => T; type Tuple = [T, ...T[]] | []; -type Primitive = - | typeof String - | typeof Number - | typeof Boolean - | typeof BigInt - | null - | undefined; +type Primitive = typeof String | typeof Number | typeof Boolean | typeof BigInt | null | undefined; type InferPrimitive

= P extends typeof String ? string : P extends typeof Number @@ -650,18 +580,8 @@ type IsPureBase = A extends { : false; type InferredProvable = IsPure extends true - ? GenericProvableExtendedPure< - InferProvable, - InferValue, - InferJson, - Field - > - : GenericProvableExtended< - InferProvable, - InferValue, - InferJson, - Field - >; + ? GenericProvableExtendedPure, InferValue, InferJson, Field> + : GenericProvableExtended, InferValue, InferJson, Field>; // signable @@ -685,11 +605,7 @@ type InferSignable = A extends { } : never; -type InferredSignable = GenericSignable< - InferSignable, - InferJson, - Field ->; +type InferredSignable = GenericSignable, InferJson, Field>; // deep union type for flexible fromValue @@ -721,10 +637,7 @@ type From = A extends { // nested -type InferProvableNested< - Field, - A extends NestedProvable -> = A extends Primitive +type InferProvableNested> = A extends Primitive ? InferPrimitive : A extends { provable: GenericProvable } ? P @@ -742,10 +655,7 @@ type InferProvableNested< } : never; -type InferValueNested< - Field, - A extends NestedProvable -> = A extends Primitive +type InferValueNested> = A extends Primitive ? InferPrimitiveValue : A extends { provable: GenericProvable } ? U @@ -763,10 +673,7 @@ type InferValueNested< } : never; -type InferJsonNested< - Field, - A extends NestedProvable -> = A extends Primitive +type InferJsonNested> = A extends Primitive ? InferPrimitiveJson : A extends { provable: GenericProvable } ? A['provable'] extends WithJson diff --git a/src/bindings/mina-transaction/v1/derived-leaves.ts b/src/bindings/mina-transaction/v1/derived-leaves.ts index cf3b932fac..6cc4eda2f9 100644 --- a/src/bindings/mina-transaction/v1/derived-leaves.ts +++ b/src/bindings/mina-transaction/v1/derived-leaves.ts @@ -39,16 +39,9 @@ function derivedLeafTypes({ const fieldBase = provable(Field); return { - TokenId: createEncodedField( - fieldBase, - Encoding.TokenId, - Field(defaultTokenId) - ), + TokenId: createEncodedField(fieldBase, Encoding.TokenId, Field(defaultTokenId)), StateHash: createEncodedField(fieldBase, Encoding.StateHash), - TokenSymbol: createTokenSymbol( - provable({ field: Field, symbol: String }), - Field - ), + TokenSymbol: createTokenSymbol(provable({ field: Field, symbol: String }), Field), AuthRequired: createAuthRequired( provable({ constant: Bool, @@ -77,16 +70,9 @@ function derivedLeafTypesSignable({ const fieldBase = signable(Field); return { - TokenId: createEncodedField( - fieldBase, - Encoding.TokenId, - Field(defaultTokenId) - ), + TokenId: createEncodedField(fieldBase, Encoding.TokenId, Field(defaultTokenId)), StateHash: createEncodedField(fieldBase, Encoding.StateHash), - TokenSymbol: createTokenSymbol( - signable({ field: Field, symbol: String }), - Field - ), + TokenSymbol: createTokenSymbol(signable({ field: Field, symbol: String }), Field), AuthRequired: createAuthRequired( signable({ constant: Bool, @@ -103,10 +89,11 @@ function derivedLeafTypesSignable({ const defaultTokenId = 1; -function createEncodedField< - Field, - Base extends GenericSignable ->(base: Base, encoding: Base58, empty?: Field) { +function createEncodedField>( + base: Base, + encoding: Base58, + empty?: Field +) { return { ...(base as Omit), empty: empty !== undefined ? () => empty : base.empty, @@ -121,10 +108,10 @@ function createEncodedField< type TokenSymbol = { symbol: string; field: Field }; -function createTokenSymbol< - Field, - Base extends GenericSignable, any, Field> ->(base: Base, Field: GenericSignableField) { +function createTokenSymbol, any, Field>>( + base: Base, + Field: GenericSignableField +) { let self = { ...(base as Omit), toInput({ field }: TokenSymbol): GenericHashInput { @@ -136,9 +123,7 @@ function createTokenSymbol< fromJSON(symbol: string): TokenSymbol { let bytesLength = stringLengthInBytes(symbol); if (bytesLength > tokenSymbolLength) - throw Error( - `Token symbol ${symbol} should be a maximum of 6 bytes, but is ${bytesLength}` - ); + throw Error(`Token symbol ${symbol} should be a maximum of 6 bytes, but is ${bytesLength}`); return { symbol, field: prefixToField(Field, symbol) }; }, }; @@ -215,10 +200,7 @@ function createZkappUri( return dataAsHash({ empty() { - let hash = HashHelpers.hashWithPrefix(prefixes.zkappUri, [ - Field(0), - Field(0), - ]); + let hash = HashHelpers.hashWithPrefix(prefixes.zkappUri, [Field(0), Field(0)]); return { data: '', hash }; }, toValue(data) { diff --git a/src/bindings/mina-transaction/v1/transaction-leaves-bigint.ts b/src/bindings/mina-transaction/v1/transaction-leaves-bigint.ts index 338fb23a02..1d01aadb36 100644 --- a/src/bindings/mina-transaction/v1/transaction-leaves-bigint.ts +++ b/src/bindings/mina-transaction/v1/transaction-leaves-bigint.ts @@ -1,18 +1,8 @@ -import { - Field, - Bool, - UInt32, - UInt64, - Sign, -} from '../../../mina-signer/src/field-bigint.js'; +import { Field, Bool, UInt32, UInt64, Sign } from '../../../mina-signer/src/field-bigint.js'; import { PublicKey } from '../../../mina-signer/src/curve-bigint.js'; import { derivedLeafTypesSignable } from './derived-leaves.js'; import { createEvents } from '../../../lib/mina/v1/events.js'; -import { - Poseidon, - HashHelpers, - packToFields, -} from '../../../mina-signer/src/poseidon-bigint.js'; +import { Poseidon, HashHelpers, packToFields } from '../../../mina-signer/src/poseidon-bigint.js'; import { mocks, protocolVersions } from '../../crypto/constants.js'; import { signable } from '../../../mina-signer/src/derivers-bigint.js'; diff --git a/src/bindings/mina-transaction/v1/transaction-leaves.ts b/src/bindings/mina-transaction/v1/transaction-leaves.ts index 8576fe385f..03cda60ae0 100644 --- a/src/bindings/mina-transaction/v1/transaction-leaves.ts +++ b/src/bindings/mina-transaction/v1/transaction-leaves.ts @@ -12,17 +12,7 @@ import { import { provable } from '../../../lib/provable/types/provable-derivers.js'; import { mocks, protocolVersions } from '../../crypto/constants.js'; -export { - PublicKey, - Field, - Bool, - AuthRequired, - UInt64, - UInt32, - Sign, - BalanceChange, - TokenId, -}; +export { PublicKey, Field, Bool, AuthRequired, UInt64, UInt32, Sign, BalanceChange, TokenId }; export { Events, @@ -47,8 +37,12 @@ type StateHash = Field; type TokenSymbol = { symbol: string; field: Field }; type ZkappUri = { data: string; hash: Field }; -const { TokenId, StateHash, TokenSymbol, AuthRequired, ZkappUri } = - derivedLeafTypes({ Field, Bool, HashHelpers, packToFields }); +const { TokenId, StateHash, TokenSymbol, AuthRequired, ZkappUri } = derivedLeafTypes({ + Field, + Bool, + HashHelpers, + packToFields, +}); type Event = Field[]; type Events = { @@ -96,8 +90,6 @@ const MayUseToken = { Bool.check(inheritFromParent); parentsOwnToken .and(inheritFromParent) - .assertFalse( - 'MayUseToken: parentsOwnToken and inheritFromParent cannot both be true' - ); + .assertFalse('MayUseToken: parentsOwnToken and inheritFromParent cannot both be true'); }, }; diff --git a/src/bindings/mina-transaction/v2/leaves.ts b/src/bindings/mina-transaction/v2/leaves.ts index 61ff018f1c..38b013529f 100644 --- a/src/bindings/mina-transaction/v2/leaves.ts +++ b/src/bindings/mina-transaction/v2/leaves.ts @@ -7,7 +7,7 @@ import { withVersionNumber } from '../../lib/binable.js'; import { Bool } from '../../../lib/provable/bool.js'; import { Field } from '../../../lib/provable/field.js'; import { Provable } from '../../../lib/provable/provable.js'; -import { HashInput } from '../../../lib/provable/types/provable-derivers.js' +import { HashInput } from '../../../lib/provable/types/provable-derivers.js'; import { Struct } from '../../../lib/provable/types/struct.js'; import { toBase58Check } from '../../../lib/util/base58.js'; @@ -17,7 +17,9 @@ export { Int64, UInt32, UInt64, Sign } from '../../../lib/provable/int.js'; export { PublicKey } from '../../../lib/provable/crypto/signature.js'; // for now, we erase the value conversion in the proxy, as it is currently not utilized -function proxyProvableSerializable(T: ProvableSerializable): ProvableSerializable { +function proxyProvableSerializable( + T: ProvableSerializable +): ProvableSerializable { return { sizeInFields(): number { return T.sizeInFields(); @@ -53,8 +55,8 @@ function proxyProvableSerializable(T: ProvableSerializable): Pro check(x: T) { T.check(x); - } - } + }, + }; } export interface Option { @@ -77,15 +79,12 @@ export function Option(T: ProvableSerializable) { const valueInput = T.toInput(x.value); return { fields: valueInput.fields, - packed: flagInput.packed!.concat(valueInput.packed ?? []) - } + packed: flagInput.packed!.concat(valueInput.packed ?? []), + }; }, toFields(x: Option): Field[] { - return [ - ...Bool.toFields(x.isSome), - ...T.toFields(x.value) - ]; + return [...Bool.toFields(x.isSome), ...T.toFields(x.value)]; }, toAuxiliary(x?: Option): any[] { @@ -108,24 +107,24 @@ export function Option(T: ProvableSerializable) { }, check(_x: Option) { - throw new Error('TODO') - } - } -}; + throw new Error('TODO'); + }, + }; +} Option.map = (option: Option, f: (value: A) => B): Option => ({ isSome: option.isSome, - value: f(option.value) + value: f(option.value), }); Option.none = (defaultValue: T): Option => ({ isSome: new Bool(false), - value: defaultValue + value: defaultValue, }); Option.some = (value: T): Option => ({ isSome: new Bool(true), - value + value, }); export interface Range { @@ -136,7 +135,7 @@ export interface Range { export function Range(T: Provable) { return Struct({ lower: T, - upper: T + upper: T, }); } @@ -163,13 +162,14 @@ export const CommittedList: ProvableSerializable = { }, toAuxiliary(x?: CommittedList): any[] { - if(x === undefined) throw new Error('cannot convert undefined CommittedList into auxiliary data'); + if (x === undefined) + throw new Error('cannot convert undefined CommittedList into auxiliary data'); return [x.data]; }, fromFields(fields: Field[], aux: any[]): CommittedList { // TODO: runtime type-check the aux data - return {data: aux[0], hash: fields[0]}; + return { data: aux[0], hash: fields[0] }; }, toValue(x: CommittedList): CommittedList { @@ -182,7 +182,7 @@ export const CommittedList: ProvableSerializable = { check(_x: CommittedList) { throw new Error('TODO'); - } + }, }; export type Events = CommittedList; @@ -193,13 +193,8 @@ export type Actions = CommittedList; export const Actions = CommittedList; -export type AuthRequiredIdentifier = - | 'Impossible' - | 'None' - | 'Proof' - | 'Signature' - | 'Either' - // TODO: Both +export type AuthRequiredIdentifier = 'Impossible' | 'None' | 'Proof' | 'Signature' | 'Either'; +// TODO: Both export interface AuthRequired { constant: Bool; @@ -208,66 +203,52 @@ export interface AuthRequired { } export const AuthRequired = { - ...proxyProvableSerializable(Struct({constant: Bool, signatureNecessary: Bool, signatureSufficient: Bool})), + ...proxyProvableSerializable( + Struct({ constant: Bool, signatureNecessary: Bool, signatureSufficient: Bool }) + ), empty(): AuthRequired { return { constant: new Bool(true), signatureNecessary: new Bool(false), - signatureSufficient: new Bool(true) - } + signatureSufficient: new Bool(true), + }; }, isImpossible(x: AuthRequired): Bool { - return Bool.allTrue([ - x.constant, - x.signatureNecessary, - x.signatureSufficient.not() - ]); + return Bool.allTrue([x.constant, x.signatureNecessary, x.signatureSufficient.not()]); }, isNone(x: AuthRequired): Bool { - return Bool.allTrue([ - x.constant, - x.signatureNecessary.not(), - x.signatureSufficient - ]); + return Bool.allTrue([x.constant, x.signatureNecessary.not(), x.signatureSufficient]); }, isProof(x: AuthRequired): Bool { return Bool.allTrue([ x.constant.not(), x.signatureNecessary.not(), - x.signatureSufficient.not() + x.signatureSufficient.not(), ]); }, isSignature(x: AuthRequired): Bool { - return Bool.allTrue([ - x.constant.not(), - x.signatureNecessary, - x.signatureSufficient - ]); + return Bool.allTrue([x.constant.not(), x.signatureNecessary, x.signatureSufficient]); }, isEither(x: AuthRequired): Bool { - return Bool.allTrue([ - x.constant.not(), - x.signatureNecessary.not(), - x.signatureSufficient - ]); + return Bool.allTrue([x.constant.not(), x.signatureNecessary.not(), x.signatureSufficient]); }, identifier(x: AuthRequired): AuthRequiredIdentifier { - if(AuthRequired.isImpossible(x).toBoolean()) { + if (AuthRequired.isImpossible(x).toBoolean()) { return 'Impossible'; - } else if(AuthRequired.isNone(x).toBoolean()) { + } else if (AuthRequired.isNone(x).toBoolean()) { return 'None'; - } else if(AuthRequired.isProof(x).toBoolean()) { + } else if (AuthRequired.isProof(x).toBoolean()) { return 'Proof'; - } else if(AuthRequired.isSignature(x).toBoolean()) { + } else if (AuthRequired.isSignature(x).toBoolean()) { return 'Signature'; - } else if(AuthRequired.isEither(x).toBoolean()) { + } else if (AuthRequired.isEither(x).toBoolean()) { return 'Either'; } else { throw new Error('invariant broken: invalid authorization level encoding'); @@ -276,7 +257,7 @@ export const AuthRequired = { toJSON(x: AuthRequired): any { return AuthRequired.identifier(x); - } + }, }; AuthRequired satisfies ProvableSerializable; @@ -289,7 +270,7 @@ export const StateHash: ProvableSerializable = { toJSON(x: StateHash): any { const bytes = withVersionNumber(Field, 1).toBytes(x); return toBase58Check(bytes, versionBytes.stateHash); - } + }, }; export type TokenId = Field; @@ -297,12 +278,12 @@ export type TokenId = Field; export const TokenId = Field; export interface TokenSymbol { - field: Field, - symbol: string + field: Field; + symbol: string; } export const TokenSymbol: ProvableSerializable = { - ...proxyProvableSerializable(Struct({field: Field, symbol: String})), + ...proxyProvableSerializable(Struct({ field: Field, symbol: String })), toJSON(x: TokenSymbol): any { return x.symbol; @@ -310,16 +291,16 @@ export const TokenSymbol: ProvableSerializable = { toInput(x: TokenSymbol): HashInput { return { packed: [[x.field, 48]] }; - } + }, }; export interface ZkappUri { - data: string, - hash: Field + data: string; + hash: Field; } export const ZkappUri: ProvableSerializable = { - ...proxyProvableSerializable(Struct({data: String, hash: Field})), + ...proxyProvableSerializable(Struct({ data: String, hash: Field })), toJSON(x: ZkappUri): any { return x.data; @@ -334,5 +315,5 @@ export const ZkappUri: ProvableSerializable = { data: aux[0], hash: fields[0], }; - } + }, }; diff --git a/src/bindings/mina-transaction/v2/schema.ts b/src/bindings/mina-transaction/v2/schema.ts index ea60de014a..ff5951023e 100644 --- a/src/bindings/mina-transaction/v2/schema.ts +++ b/src/bindings/mina-transaction/v2/schema.ts @@ -1,8 +1,8 @@ -import * as BindingsLeaves from './leaves.js' +import * as BindingsLeaves from './leaves.js'; import { FieldsDecoder, ProvableSerializable } from './util.js'; import { versionBytes } from '../../crypto/constants.js'; import { Provable } from '../../../lib/provable/provable.js'; -import { HashInput } from '../../../lib/provable/types/provable-derivers.js' +import { HashInput } from '../../../lib/provable/types/provable-derivers.js'; import { toBase58Check } from '../../../lib/util/base58.js'; const JsArray = Array; @@ -31,7 +31,7 @@ abstract class ProvableBindingsType { } fromFields(fields: BindingsLeaves.Field[], aux: any[]): T { - return this.Type().fromFields(fields, aux) as never as T + return this.Type().fromFields(fields, aux) as never as T; } toValue(x: T): T { @@ -53,40 +53,66 @@ export type BindingsType = | BindingsType.Option | BindingsType.Array; -function assertBindingsTypeImplementsProvable & ProvableSerializable>(_x?: B) {} +function assertBindingsTypeImplementsProvable< + T, + B extends BindingsType & ProvableSerializable +>(_x?: B) {} assertBindingsTypeImplementsProvable>(); assertBindingsTypeImplementsProvable>(); -assertBindingsTypeImplementsProvable>(); +assertBindingsTypeImplementsProvable< + BindingsLeaves.AuthRequired, + BindingsType +>(); assertBindingsTypeImplementsProvable>(); assertBindingsTypeImplementsProvable>(); -assertBindingsTypeImplementsProvable>(); +assertBindingsTypeImplementsProvable< + BindingsLeaves.PublicKey, + BindingsType +>(); assertBindingsTypeImplementsProvable>(); -assertBindingsTypeImplementsProvable>(); -assertBindingsTypeImplementsProvable>(); +assertBindingsTypeImplementsProvable< + BindingsLeaves.TokenId, + BindingsType +>(); +assertBindingsTypeImplementsProvable< + BindingsLeaves.TokenSymbol, + BindingsType +>(); assertBindingsTypeImplementsProvable>(); assertBindingsTypeImplementsProvable>(); -assertBindingsTypeImplementsProvable>(); -assertBindingsTypeImplementsProvable<{x: number}, BindingsType<{x: number}>>(); +assertBindingsTypeImplementsProvable< + BindingsLeaves.ZkappUri, + BindingsType +>(); +assertBindingsTypeImplementsProvable<{ x: number }, BindingsType<{ x: number }>>(); assertBindingsTypeImplementsProvable>(); -assertBindingsTypeImplementsProvable, BindingsType>>(); -assertBindingsTypeImplementsProvable>, BindingsType>>>(); +assertBindingsTypeImplementsProvable< + BindingsLeaves.Option, + BindingsType> +>(); +assertBindingsTypeImplementsProvable< + BindingsLeaves.Option>, + BindingsType>> +>(); export namespace BindingsType { export class Object implements Provable { - readonly _T!: T extends {[key: string]: any} ? void : never; + readonly _T!: T extends { [key: string]: any } ? void : never; readonly name: string; readonly keys: (keyof T)[]; - readonly entries: T extends {[key: string]: any} ? {[key in keyof T]: BindingsType} : never; + readonly entries: T extends { [key: string]: any } + ? { [key in keyof T]: BindingsType } + : never; constructor({ name, keys, - entries + entries, }: { - name: Object['name'], - keys: Object['keys'], - entries: Object['entries'] + name: Object['name']; + keys: Object['keys']; + entries: Object['entries']; }) { this.name = name; this.keys = keys; @@ -95,7 +121,7 @@ export namespace BindingsType { sizeInFields(): number { let sum = 0; - for(const key of this.keys) { + for (const key of this.keys) { sum += this.entries[key].sizeInFields(); } return sum; @@ -103,9 +129,9 @@ export namespace BindingsType { toJSON(x: T): any { // TODO: type safety - const x2 = x as {[key in keyof T]: any}; + const x2 = x as { [key in keyof T]: any }; const json: Partial = {}; - for(const key of this.keys) { + for (const key of this.keys) { json[key] = this.entries[key].toJSON(x2[key]); } return json; @@ -113,9 +139,9 @@ export namespace BindingsType { toInput(x: T): HashInput { // TODO: type safety - const x2 = x as {[key in keyof T]: any}; + const x2 = x as { [key in keyof T]: any }; const acc: HashInput = { fields: [], packed: [] }; - for(const key of this.keys) { + for (const key of this.keys) { // surely there is an optimization here to avoid allocating so many temporary arrays const { fields, packed } = this.entries[key].toInput(x2[key]); acc.fields!.push(...(fields ?? [])); @@ -126,15 +152,17 @@ export namespace BindingsType { toFields(x: T): BindingsLeaves.Field[] { // TODO: type safety - const x2 = x as {[key in keyof T]: any}; + const x2 = x as { [key in keyof T]: any }; return this.keys.map((key) => this.entries[key].toFields(x2[key])).flat(); } toAuxiliary(x?: T): any[] { // TODO: type safety - const x2 = x as {[key in keyof T]: any} | undefined; - const entries2 = this.entries as {[key in keyof T]: BindingsType}; - return this.keys.map((key) => entries2[key].toAuxiliary(x2 !== undefined ? x2[key] : undefined)); + const x2 = x as { [key in keyof T]: any } | undefined; + const entries2 = this.entries as { [key in keyof T]: BindingsType }; + return this.keys.map((key) => + entries2[key].toAuxiliary(x2 !== undefined ? x2[key] : undefined) + ); } fromFields(fields: BindingsLeaves.Field[], aux: any[]): T { @@ -143,12 +171,14 @@ export namespace BindingsType { // const obj: Partial = {}; const obj: any = {}; - for(const i in this.keys) { + for (const i in this.keys) { const key = this.keys[i]; const entryType = this.entries[key]; const entryAux = aux[i]; // console.log(`${this.name}[${JSON.stringify(key)}] :: aux = ${JSON.stringify(entryAux)}`); - obj[key] = decoder.decode(entryType.sizeInFields(), (entryFields) => entryType.fromFields(entryFields, entryAux)); + obj[key] = decoder.decode(entryType.sizeInFields(), (entryFields) => + entryType.fromFields(entryFields, entryAux) + ); } return obj; @@ -163,7 +193,7 @@ export namespace BindingsType { } check(_x: T) { - throw new Error('TODO') + throw new Error('TODO'); } } @@ -176,15 +206,15 @@ export namespace BindingsType { staticLength, inner, }: { - staticLength: Array['staticLength'], - inner: Array['inner'], + staticLength: Array['staticLength']; + inner: Array['inner']; }) { this.staticLength = staticLength; this.inner = inner; } sizeInFields(): number { - if(this.staticLength !== null) { + if (this.staticLength !== null) { return this.staticLength * this.inner.sizeInFields(); } else { return 0; @@ -198,7 +228,7 @@ export namespace BindingsType { } toInput(x: T): HashInput { - if(!(x instanceof JsArray)) throw new Error('impossible'); + if (!(x instanceof JsArray)) throw new Error('impossible'); // TODO: type safety const inner: BindingsType = this.inner; @@ -212,7 +242,7 @@ export namespace BindingsType { } toFields(x: T): BindingsLeaves.Field[] { - if(!(x instanceof JsArray)) throw new Error('impossible'); + if (!(x instanceof JsArray)) throw new Error('impossible'); // TODO: type safety const inner: BindingsType = this.inner; @@ -220,11 +250,11 @@ export namespace BindingsType { } toAuxiliary(x?: T): any[] { - if(this.staticLength !== null) { - if(x !== undefined) { + if (this.staticLength !== null) { + if (x !== undefined) { // TODO: type safety const x2 = x as any[]; - if(x2.length !== this.staticLength) throw new Error('invalid array length'); + if (x2.length !== this.staticLength) throw new Error('invalid array length'); return x2.map((v) => this.inner.toAuxiliary(v)); } else { return new JsArray(this.staticLength).fill(this.inner.toAuxiliary()); @@ -236,10 +266,11 @@ export namespace BindingsType { } fromFields(fields: BindingsLeaves.Field[], aux: any[]): T { - if(this.staticLength !== null) { + if (this.staticLength !== null) { const decoder = new FieldsDecoder(fields); const x = new JsArray(); - for(let i = 0; i < this.staticLength; i++) x[i] = decoder.decode(this.inner.sizeInFields(), (f) => this.inner.fromFields(f, aux[i])); + for (let i = 0; i < this.staticLength; i++) + x[i] = decoder.decode(this.inner.sizeInFields(), (f) => this.inner.fromFields(f, aux[i])); // TODO: type safety return x as T; } else { @@ -257,7 +288,7 @@ export namespace BindingsType { } check(_x: T) { - throw new Error('TODO') + throw new Error('TODO'); } } @@ -267,9 +298,7 @@ export namespace BindingsType { export class OrUndefined implements Provable { readonly _T!: T extends infer _U | undefined ? void : never; - constructor( - public readonly inner: T extends infer U | undefined ? BindingsType : never - ) {} + constructor(public readonly inner: T extends infer U | undefined ? BindingsType : never) {} sizeInFields(): number { return 0; @@ -283,15 +312,15 @@ export namespace BindingsType { } toInput(_x: T): any { - return {} + return {}; } toFields(_x: T): BindingsLeaves.Field[] { - return [] + return []; } toAuxiliary(x?: T): any[] { - return x === undefined ? [false] : [true, this.inner.toAuxiliary(x)] + return x === undefined ? [false] : [true, this.inner.toAuxiliary(x)]; } fromFields(fields: BindingsLeaves.Field[], aux: any[]): T { @@ -308,7 +337,7 @@ export namespace BindingsType { } check(_x: T) { - throw new Error('TODO') + throw new Error('TODO'); } } @@ -321,19 +350,28 @@ export namespace BindingsType { super(); } - Type() { return BindingsLeaves.Option(this.inner as ProvableSerializable); } + Type() { + return BindingsLeaves.Option(this.inner as ProvableSerializable); + } } - export class ClosedInterval extends ProvableBindingsType>> { + export class ClosedInterval extends ProvableBindingsType< + T, + BindingsLeaves.Option> + > { readonly _T!: T extends BindingsLeaves.Option> ? void : never; constructor( - public readonly inner: T extends BindingsLeaves.Option> ? BindingsType : never + public readonly inner: T extends BindingsLeaves.Option> + ? BindingsType + : never ) { super(); } - Type() { return BindingsLeaves.Option(BindingsLeaves.Range(this.inner as ProvableSerializable)); } + Type() { + return BindingsLeaves.Option(BindingsLeaves.Range(this.inner as ProvableSerializable)); + } } } @@ -392,7 +430,7 @@ export namespace BindingsType { } check(_x: T) { - throw new Error('TODO') + throw new Error('TODO'); } } @@ -406,67 +444,112 @@ export namespace BindingsType { readonly type: 'string' = 'string'; } - export class Actions extends ProvableBindingsType { + export class Actions extends ProvableBindingsType< + T, + BindingsLeaves.Actions + > { readonly _T!: T extends number ? void : never; readonly type: 'number' = 'number'; - Type() { return BindingsLeaves.Actions; } + Type() { + return BindingsLeaves.Actions; + } } - export class AuthRequired extends ProvableBindingsType { + export class AuthRequired extends ProvableBindingsType< + T, + BindingsLeaves.AuthRequired + > { readonly _T!: T extends BindingsLeaves.AuthRequired ? void : never; readonly type: 'AuthRequired' = 'AuthRequired'; - Type() { return BindingsLeaves.AuthRequired; } + Type() { + return BindingsLeaves.AuthRequired; + } } - export class Bool extends ProvableBindingsType { + export class Bool extends ProvableBindingsType< + T, + BindingsLeaves.Bool + > { readonly _T!: T extends BindingsLeaves.Bool ? void : never; readonly type: 'Bool' = 'Bool'; - Type() { return BindingsLeaves.Bool; } + Type() { + return BindingsLeaves.Bool; + } } - export class Events extends ProvableBindingsType { + export class Events extends ProvableBindingsType< + T, + BindingsLeaves.Events + > { readonly _T!: T extends number ? void : never; readonly type: 'number' = 'number'; - Type() { return BindingsLeaves.Events; } + Type() { + return BindingsLeaves.Events; + } } - export class Field extends ProvableBindingsType { + export class Field extends ProvableBindingsType< + T, + BindingsLeaves.Field + > { readonly _T!: T extends BindingsLeaves.Field ? void : never; readonly type: 'Field' = 'Field'; - Type() { return BindingsLeaves.Field; } + Type() { + return BindingsLeaves.Field; + } } - export class Int64 extends ProvableBindingsType { + export class Int64 extends ProvableBindingsType< + T, + BindingsLeaves.Int64 + > { readonly _T!: T extends BindingsLeaves.Int64 ? void : never; readonly type: 'Int64' = 'Int64'; - Type() { return BindingsLeaves.Int64; } + Type() { + return BindingsLeaves.Int64; + } } - export class PublicKey extends ProvableBindingsType { + export class PublicKey extends ProvableBindingsType< + T, + BindingsLeaves.PublicKey + > { readonly _T!: T extends BindingsLeaves.PublicKey ? void : never; readonly type: 'PublicKey' = 'PublicKey'; - Type() { return BindingsLeaves.PublicKey; } + Type() { + return BindingsLeaves.PublicKey; + } } - export class Sign extends ProvableBindingsType { + export class Sign extends ProvableBindingsType< + T, + BindingsLeaves.Sign + > { readonly _T!: T extends BindingsLeaves.Sign ? void : never; readonly type: 'Sign' = 'Sign'; - Type() { return BindingsLeaves.Sign; } + Type() { + return BindingsLeaves.Sign; + } } - export class StateHash extends ProvableBindingsType { + export class StateHash extends ProvableBindingsType< + T, + BindingsLeaves.StateHash + > { readonly _T!: T extends BindingsLeaves.StateHash ? void : never; readonly type: 'StateHash' = 'StateHash'; - Type() { return BindingsLeaves.StateHash; } + Type() { + return BindingsLeaves.StateHash; + } } // TODO NOW @@ -482,7 +565,10 @@ export namespace BindingsType { toJSON(x: T): any { // TODO: type safety - return toBase58Check(BindingsLeaves.Field.toBytes(x as BindingsLeaves.Field), versionBytes.tokenIdKey); + return toBase58Check( + BindingsLeaves.Field.toBytes(x as BindingsLeaves.Field), + versionBytes.tokenIdKey + ); } toInput(x: T): HashInput { @@ -513,36 +599,56 @@ export namespace BindingsType { } check(_x: T) { - throw new Error('TODO') + throw new Error('TODO'); } } - export class TokenSymbol extends ProvableBindingsType { + export class TokenSymbol extends ProvableBindingsType< + T, + BindingsLeaves.TokenSymbol + > { readonly _T!: T extends BindingsLeaves.TokenId ? void : never; readonly type: 'TokenId' = 'TokenId'; - Type() { return BindingsLeaves.TokenSymbol; } + Type() { + return BindingsLeaves.TokenSymbol; + } } - export class UInt32 extends ProvableBindingsType { + export class UInt32 extends ProvableBindingsType< + T, + BindingsLeaves.UInt32 + > { readonly _T!: T extends BindingsLeaves.UInt32 ? void : never; readonly type: 'UInt32' = 'UInt32'; - Type() { return BindingsLeaves.UInt32; } + Type() { + return BindingsLeaves.UInt32; + } } - export class UInt64 extends ProvableBindingsType { + export class UInt64 extends ProvableBindingsType< + T, + BindingsLeaves.UInt64 + > { readonly _T!: T extends BindingsLeaves.UInt64 ? void : never; readonly type: 'UInt64' = 'UInt64'; - Type() { return BindingsLeaves.UInt64; } + Type() { + return BindingsLeaves.UInt64; + } } - export class ZkappUri extends ProvableBindingsType { + export class ZkappUri extends ProvableBindingsType< + T, + BindingsLeaves.ZkappUri + > { readonly _T!: T extends BindingsLeaves.ZkappUri ? void : never; readonly type: 'ZkappUri'; - Type() { return BindingsLeaves.ZkappUri; } + Type() { + return BindingsLeaves.ZkappUri; + } } } } diff --git a/src/bindings/mina-transaction/v2/util.ts b/src/bindings/mina-transaction/v2/util.ts index 96be6fa52d..f07f86fea9 100644 --- a/src/bindings/mina-transaction/v2/util.ts +++ b/src/bindings/mina-transaction/v2/util.ts @@ -1,6 +1,6 @@ import { Field } from '../../../lib/provable/field.js'; import { Provable } from '../../../lib/provable/provable.js'; -import { HashInput } from '../../../lib/provable/types/provable-derivers.js' +import { HashInput } from '../../../lib/provable/types/provable-derivers.js'; export type ProvableSerializable = Provable & { toJSON(x: T): any; @@ -10,10 +10,7 @@ export type ProvableSerializable = Provable & { // TODO: refactor Provable to use this kind of an interface (will save a lot of array slicing) // TODO: this could also handle aux data in addition to fields export class FieldsDecoder { - constructor( - private fields: Field[], - private index: number = 0 - ) {} + constructor(private fields: Field[], private index: number = 0) {} decode(size: number, f: (subFields: Field[]) => T): T { const subFields = this.fields.slice(this.index, this.index + size); @@ -21,4 +18,3 @@ export class FieldsDecoder { return f(subFields); } } - diff --git a/src/lib/proof-system/verification-key.unit-test.ts b/src/lib/proof-system/verification-key.unit-test.ts index 02819fde8e..24e9cd82c4 100644 --- a/src/lib/proof-system/verification-key.unit-test.ts +++ b/src/lib/proof-system/verification-key.unit-test.ts @@ -13,10 +13,9 @@ let vkIsValid = await VerificationKey.checkValidity(generated); assert(vkIsValid, 'valid verification key is being rejected as invalid'); const invalidVerificationKey = new VerificationKey({ - data: generated.data, - hash: Field.random(), - }); - + data: generated.data, + hash: Field.random(), +}); let vkIsNotValid = await VerificationKey.checkValidity(invalidVerificationKey); assert(vkIsNotValid === false, 'invalid verification key is being accepted as valid'); diff --git a/src/lib/provable/dynamic-array.ts b/src/lib/provable/dynamic-array.ts index d0a63538ac..2667692696 100644 --- a/src/lib/provable/dynamic-array.ts +++ b/src/lib/provable/dynamic-array.ts @@ -119,16 +119,16 @@ class DynamicArrayBase { /** * Create a new {@link DynamicArrayBase} instance from an optional list of * {@link ProvableValue} elements, and optional length. - * + * * - If no parameters are passed, it creates an empty array of length 0. * - If only `array` is passed, it creates a new array with the elements * of the array. * - If only `length` is passed, it creates a dummy array of the given length * filled with NULL values. * - If both `array` and `length` are passed, it creates a new array with the - * elements of the array, and the length of the dynamic array is set to the + * elements of the array, and the length of the dynamic array is set to the * `length` passed, which should be less or equal than the length of the - * `array` passed (this is to allow for arrays with dummy values at the end). + * `array` passed (this is to allow for arrays with dummy values at the end). * - In any case, if `length` is larger than the capacity, it throws. * * @example @@ -141,14 +141,11 @@ class DynamicArrayBase { */ constructor(array?: ProvableValue[], length?: Field) { const NULL = ProvableType.synthesize(this.innerType); - + const a = array ?? []; const l = length ?? new Field(a.length); - - assert( - a.length <= this.capacity, - 'DynamicArray(): array must not exceed capacity' - ); + + assert(a.length <= this.capacity, 'DynamicArray(): array must not exceed capacity'); if (length?.isConstant()) { assert( l.toBigInt() <= BigInt(a.length), @@ -166,7 +163,7 @@ class DynamicArrayBase { * Asserts 0 <= i < this.length, using a cached check that's not * duplicated when doing it on the same variable multiple times, failing * with an error message otherwise. - * + * * @param i - the index to check * @param message - optional error message to use in case the assertion fails */ @@ -196,7 +193,7 @@ class DynamicArrayBase { * the array. * * Note: The correct type for `i` is actually UInt16 which doesn't exist. The - * method is not complete (but sound) for i >= 2^16. This means that if the + * method is not complete (but sound) for i >= 2^16. This means that if the * index is larger than 2^16, the constraints could be satisfiable but the * result is not correct (because the capacity can at most be 2^16). */ @@ -292,14 +289,14 @@ class DynamicArrayBase { * * **Note**: this doesn't cost constraints, but currently doesn't preserve any * cached constraints. - * + * * @param capacity - the new capacity of the array */ growCapacityTo(capacity: number, message?: string): DynamicArray { let errorMessage = message ?? `growCapacityTo: new capacity ${capacity} must be greater than current capacity ${this.capacity}`; - assert(capacity >= this.capacity,errorMessage); + assert(capacity >= this.capacity, errorMessage); let NewArray = DynamicArray(this.innerType, { capacity }); let NULL = ProvableType.synthesize(this.innerType); let array = pad(this.array, capacity, NULL); @@ -314,7 +311,7 @@ class DynamicArrayBase { * **Note**: this doesn't cost constraints, but currently doesn't preserve any * cached constraints. * - * @param increment - the amount to increase the capacity by + * @param increment - the amount to increase the capacity by */ growCapacityBy(increment: number): DynamicArray { return this.growCapacityTo(this.capacity + increment); @@ -369,8 +366,7 @@ class DynamicArrayBase { */ setLengthTo(n: Field, message?: string): void { let errorMessage = - message ?? - `setLengthTo: cannot set length to n because it exceeds capacity ${this.capacity}`; + message ?? `setLengthTo: cannot set length to n because it exceeds capacity ${this.capacity}`; n.assertLessThanOrEqual(new Field(this.capacity), errorMessage); this.length = n; } @@ -386,14 +382,13 @@ class DynamicArrayBase { * array = array.growCapacityhBy(1); * array.push(value); * ``` - * + * * @param value - the value to push into the array * @param message - optional error message to use in case the assertion fails */ push(value: ProvableValue, message?: string): void { let errorMessage = - message ?? - `push(): cannot push value because it would exceed capacity ${this.capacity}.`; + message ?? `push(): cannot push value because it would exceed capacity ${this.capacity}.`; let oldLength = this.length; this.increaseLengthBy(new Field(1), errorMessage); this.setOrDoNothing(oldLength, value); @@ -408,9 +403,7 @@ class DynamicArrayBase { * @param message - optional error message to use in case the assertion fails */ pop(n?: Field, message?: string): void { - let errorMessage = - message ?? - `pop(): cannot pop n elements because the length is smaller`; + let errorMessage = message ?? `pop(): cannot pop n elements because the length is smaller`; let dec = n !== undefined ? n : new Field(1); this.decreaseLengthBy(dec, errorMessage); @@ -451,8 +444,7 @@ class DynamicArrayBase { */ shiftLeft(n: Field, message?: string): void { let errorMessage = - message ?? - `shiftLeft(): cannot shift left because provided n would exceed current length.`; + message ?? `shiftLeft(): cannot shift left because provided n would exceed current length.`; let NULL = ProvableType.synthesize(this.innerType); for (let i = 0; i < this.capacity; i++) { let offset = new Field(i).add(n); @@ -469,7 +461,7 @@ class DynamicArrayBase { /** * Shifts all elements of the array to the right by `n` positions, increasing * the length by `n`, which must result in less than or equal to the capacity - * (failing with an error message otherwise). The new elements on the left are + * (failing with an error message otherwise). The new elements on the left are * set to NULL values. * * @param n - the number of positions to shift right @@ -515,7 +507,7 @@ class DynamicArrayBase { * * @param start - the starting index of the slice (inclusive) * @param end - the ending index of the slice (exclusive) - * + * * @returns a new DynamicArray instance with the sliced values */ slice(start?: Field, end?: Field): DynamicArray { @@ -533,7 +525,7 @@ class DynamicArrayBase { * is the sum of the capacities of the two arrays. * * @param other - the dynamic array to concatenate - * + * * @returns a new DynamicArray instance with the concatenated values */ concat(other: DynamicArray): DynamicArray { @@ -581,7 +573,7 @@ class DynamicArrayBase { /** * Checks whether the dynamic array includes a value. - * + * * @param value - the value to check for inclusion in the array * @returns */ @@ -592,7 +584,6 @@ class DynamicArrayBase { return isSome; } - // cached variables to not duplicate constraints if we do something like // array.get(i), array.set(i, ..) on the same index #indexMasks: Map = new Map(); @@ -634,11 +625,11 @@ class DynamicArrayBase { return mask; } -/** - * Converts the current instance of the dynamic array to a plain array of values. - * - * @returns An array of values representing the elements in the dynamic array. - */ + /** + * Converts the current instance of the dynamic array to a plain array of values. + * + * @returns An array of values representing the elements in the dynamic array. + */ toValue(): Value[] { return (this.constructor as any as { provable: Provable }).provable.toValue(this); } diff --git a/src/lib/provable/test/dynamic-array.unit-test.ts b/src/lib/provable/test/dynamic-array.unit-test.ts index e3e89457cd..5da2f6012f 100644 --- a/src/lib/provable/test/dynamic-array.unit-test.ts +++ b/src/lib/provable/test/dynamic-array.unit-test.ts @@ -5,7 +5,6 @@ import { DynamicArray } from '../dynamic-array.js'; import { assert } from '../gadgets/common.js'; import { Provable } from '../provable.js'; - // Out-of-circuit checks of dynamic arrays { function expectThrows(fn: () => void | Promise, msg: string) { @@ -31,7 +30,9 @@ import { Provable } from '../provable.js'; assert(fromLength.capacity === 8); let fromArrayLength = new Bytestring( - [new UInt8(1), new UInt8(2), new UInt8(3), new UInt8(0)], new Field(3)); + [new UInt8(1), new UInt8(2), new UInt8(3), new UInt8(0)], + new Field(3) + ); assert(fromArrayLength.length.equals(new Field(3))); assert(fromArrayLength.capacity === 8); assert(fromArrayLength.get(new Field(0)).value.equals(new Field(1))); @@ -332,7 +333,7 @@ import { Provable } from '../provable.js'; // Using dynamic arrays as private input { class Bytestring extends DynamicArray(UInt8, { capacity: 8 }) {} - + let AsPrivateInput = ZkProgram({ name: 'dynamicarrays', methods: { @@ -350,11 +351,11 @@ import { Provable } from '../provable.js'; }, }, }); - + await AsPrivateInput.compile(); - + let bytes = new Bytestring([new UInt8(1), new UInt8(2), new UInt8(3)]); - + await AsPrivateInput.pushAndPop(bytes, UInt8.from(4)); } @@ -430,7 +431,9 @@ import { Provable } from '../provable.js'; bytes.push(v0.add(new UInt8(1))); bytes.push(v0.mul(new UInt8(0))); let mapped = bytes.map(UInt8, (value) => value.add(UInt8.from(1))); - assert(mapped.get(new Field(0)).value.equals(v0.value.mul(new Field(2)).add(new Field(1)))); + assert( + mapped.get(new Field(0)).value.equals(v0.value.mul(new Field(2)).add(new Field(1))) + ); assert(mapped.get(new Field(1)).value.equals(v0.value.add(new Field(2)))); assert(mapped.get(new Field(2)).value.equals(new Field(1))); From dcc87d8ff93efbc28df0e9f97f312c2c66bdc636 Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Thu, 5 Jun 2025 14:36:43 -0400 Subject: [PATCH 18/18] update mina --- src/mina | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mina b/src/mina index 990fb36011..9d95b2ce52 160000 --- a/src/mina +++ b/src/mina @@ -1 +1 @@ -Subproject commit 990fb36011269d308dcca664e4cfae3b0c04eab9 +Subproject commit 9d95b2ce52a7ae1cadbe0d569eb80014c62d13e3