Merge pull request #49 from vacp2p/Pravdyvy/sc-core-helpers

Sc Core helperfunctions
This commit is contained in:
tyshko-rostyslav 2025-03-14 03:54:54 +01:00 committed by GitHub
commit af458635e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 644 additions and 443 deletions

538
Cargo.lock generated
View File

@ -351,12 +351,6 @@ dependencies = [
"memchr",
]
[[package]]
name = "allocator-api2"
version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
[[package]]
name = "anyhow"
version = "1.0.96"
@ -383,24 +377,21 @@ dependencies = [
[[package]]
name = "ark-bn254"
version = "0.5.0"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d69eab57e8d2663efa5c63135b2af4f396d66424f88954c21104125ab6b3e6bc"
checksum = "a22f4561524cd949590d78d7d4c5df8f592430d221f7f3c9497bbafd8972120f"
dependencies = [
"ark-ec",
"ark-ff",
"ark-r1cs-std",
"ark-std",
]
[[package]]
name = "ark-crypto-primitives"
version = "0.5.0"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e0c292754729c8a190e50414fd1a37093c786c709899f29c9f7daccecfa855e"
checksum = "1f3a13b34da09176a8baba701233fdffbaa7c1b1192ce031a3da4e55ce1f1a56"
dependencies = [
"ahash 0.8.11",
"ark-crypto-primitives-macros",
"ark-ec",
"ark-ff",
"ark-relations",
@ -410,91 +401,74 @@ dependencies = [
"blake2",
"derivative",
"digest 0.10.7",
"fnv",
"merlin",
"sha2 0.10.8",
]
[[package]]
name = "ark-crypto-primitives-macros"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7e89fe77d1f0f4fe5b96dfc940923d88d17b6a773808124f21e764dfb063c6a"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.98",
]
[[package]]
name = "ark-ec"
version = "0.5.0"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43d68f2d516162846c1238e755a7c4d131b892b70cc70c471a8e3ca3ed818fce"
checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba"
dependencies = [
"ahash 0.8.11",
"ark-ff",
"ark-poly",
"ark-serialize",
"ark-std",
"educe",
"fnv",
"hashbrown 0.15.2",
"itertools 0.13.0",
"num-bigint 0.4.6",
"num-integer",
"derivative",
"hashbrown 0.13.2",
"itertools 0.10.5",
"num-traits",
"zeroize",
]
[[package]]
name = "ark-ff"
version = "0.5.0"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a177aba0ed1e0fbb62aa9f6d0502e9b46dad8c2eab04c14258a1212d2557ea70"
checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba"
dependencies = [
"ark-ff-asm",
"ark-ff-macros",
"ark-serialize",
"ark-std",
"arrayvec 0.7.6",
"derivative",
"digest 0.10.7",
"educe",
"itertools 0.13.0",
"itertools 0.10.5",
"num-bigint 0.4.6",
"num-traits",
"paste 1.0.15",
"rustc_version",
"zeroize",
]
[[package]]
name = "ark-ff-asm"
version = "0.5.0"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62945a2f7e6de02a31fe400aa489f0e0f5b2502e69f95f853adb82a96c7a6b60"
checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348"
dependencies = [
"quote",
"syn 2.0.98",
"syn 1.0.109",
]
[[package]]
name = "ark-ff-macros"
version = "0.5.0"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09be120733ee33f7693ceaa202ca41accd5653b779563608f1234f78ae07c4b3"
checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565"
dependencies = [
"num-bigint 0.4.6",
"num-traits",
"proc-macro2",
"quote",
"syn 2.0.98",
"syn 1.0.109",
]
[[package]]
name = "ark-groth16"
version = "0.5.0"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88f1d0f3a534bb54188b8dcc104307db6c56cdae574ddc3212aec0625740fc7e"
checksum = "20ceafa83848c3e390f1cbf124bc3193b3e639b3f02009e0e290809a501b95fc"
dependencies = [
"ark-crypto-primitives",
"ark-ec",
@ -507,41 +481,22 @@ dependencies = [
[[package]]
name = "ark-poly"
version = "0.5.0"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "579305839da207f02b89cd1679e50e67b4331e2f9294a57693e5051b7703fe27"
checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf"
dependencies = [
"ahash 0.8.11",
"ark-ff",
"ark-serialize",
"ark-std",
"educe",
"fnv",
"hashbrown 0.15.2",
]
[[package]]
name = "ark-r1cs-std"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "941551ef1df4c7a401de7068758db6503598e6f01850bdb2cfdb614a1f9dbea1"
dependencies = [
"ark-ec",
"ark-ff",
"ark-relations",
"ark-std",
"educe",
"num-bigint 0.4.6",
"num-integer",
"num-traits",
"tracing",
"derivative",
"hashbrown 0.13.2",
]
[[package]]
name = "ark-relations"
version = "0.5.1"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec46ddc93e7af44bcab5230937635b06fb5744464dd6a7e7b083e80ebd274384"
checksum = "00796b6efc05a3f48225e59cb6a2cda78881e7c390872d5786aaf112f31fb4f0"
dependencies = [
"ark-ff",
"ark-std",
@ -551,33 +506,32 @@ dependencies = [
[[package]]
name = "ark-serialize"
version = "0.5.0"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f4d068aaf107ebcd7dfb52bc748f8030e0fc930ac8e360146ca54c1203088f7"
checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5"
dependencies = [
"ark-serialize-derive",
"ark-std",
"arrayvec 0.7.6",
"digest 0.10.7",
"num-bigint 0.4.6",
]
[[package]]
name = "ark-serialize-derive"
version = "0.5.0"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "213888f660fddcca0d257e88e54ac05bca01885f258ccdf695bafd77031bb69d"
checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.98",
"syn 1.0.109",
]
[[package]]
name = "ark-snark"
version = "0.5.1"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d368e2848c2d4c129ce7679a7d0d2d612b6a274d3ea6a13bad4445d61b381b88"
checksum = "84d3cc6833a335bb8a600241889ead68ee89a3cf8448081fb7694c0fe503da63"
dependencies = [
"ark-ff",
"ark-relations",
@ -587,20 +541,14 @@ dependencies = [
[[package]]
name = "ark-std"
version = "0.5.0"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "246a225cc6131e9ee4f24619af0f19d67761fff15d7ccc22e42b80846e69449a"
checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185"
dependencies = [
"num-traits",
"rand 0.8.5",
]
[[package]]
name = "arraydeque"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d902e3d592a523def97af8f317b08ce16b7ab854c1985a0c671e6f15cebc236"
[[package]]
name = "arrayref"
version = "0.3.9"
@ -622,12 +570,6 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
[[package]]
name = "arrayvec"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
[[package]]
name = "atty"
version = "0.2.14"
@ -822,8 +764,8 @@ dependencies = [
[[package]]
name = "bonsai-sdk"
version = "1.3.0"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.3#c3b70f107156899b905f601097840caeb926d6b7"
version = "1.2.5"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.2#2225069ebc465320695ef3d5e028f6072e103718"
dependencies = [
"duplicate",
"maybe-async",
@ -942,16 +884,16 @@ dependencies = [
[[package]]
name = "cargo_metadata"
version = "0.19.1"
version = "0.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8769706aad5d996120af43197bf46ef6ad0fda35216b4505f926a365a232d924"
checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037"
dependencies = [
"camino",
"cargo-platform",
"semver",
"serde",
"serde_json",
"thiserror 2.0.11",
"thiserror 1.0.69",
]
[[package]]
@ -1025,7 +967,7 @@ dependencies = [
"clap_lex",
"indexmap 1.9.3",
"once_cell",
"strsim 0.10.0",
"strsim",
"termcolor",
"textwrap",
]
@ -1036,7 +978,7 @@ version = "3.2.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae6371b8bdc8b7d3959e9cf7b22d4435ef3e79e138688421ec654acf8c81b008"
dependencies = [
"heck 0.4.1",
"heck",
"proc-macro-error",
"proc-macro2",
"quote",
@ -1295,41 +1237,6 @@ dependencies = [
"find_cuda_helper",
]
[[package]]
name = "darling"
version = "0.20.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989"
dependencies = [
"darling_core",
"darling_macro",
]
[[package]]
name = "darling_core"
version = "0.20.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5"
dependencies = [
"fnv",
"ident_case",
"proc-macro2",
"quote",
"strsim 0.11.1",
"syn 2.0.98",
]
[[package]]
name = "darling_macro"
version = "0.20.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806"
dependencies = [
"darling_core",
"quote",
"syn 2.0.98",
]
[[package]]
name = "der"
version = "0.7.9"
@ -1371,37 +1278,6 @@ dependencies = [
"syn 2.0.98",
]
[[package]]
name = "derive_builder"
version = "0.20.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "507dfb09ea8b7fa618fcf76e953f4f5e192547945816d5358edffe39f6f94947"
dependencies = [
"derive_builder_macro",
]
[[package]]
name = "derive_builder_core"
version = "0.20.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8"
dependencies = [
"darling",
"proc-macro2",
"quote",
"syn 2.0.98",
]
[[package]]
name = "derive_builder_macro"
version = "0.20.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c"
dependencies = [
"derive_builder_core",
"syn 2.0.98",
]
[[package]]
name = "derive_more"
version = "0.99.19"
@ -1421,16 +1297,7 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05"
dependencies = [
"derive_more-impl 1.0.0",
]
[[package]]
name = "derive_more"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "093242cf7570c207c83073cf82f79706fe7b8317e98620a47d5be7c3d8497678"
dependencies = [
"derive_more-impl 2.0.1",
"derive_more-impl",
]
[[package]]
@ -1445,18 +1312,6 @@ dependencies = [
"unicode-xid",
]
[[package]]
name = "derive_more-impl"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.98",
"unicode-xid",
]
[[package]]
name = "digest"
version = "0.8.1"
@ -1551,7 +1406,7 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de78e66ac9061e030587b2a2e75cc88f22304913c907b11307bca737141230cb"
dependencies = [
"heck 0.4.1",
"heck",
"proc-macro-error",
]
@ -1569,18 +1424,6 @@ dependencies = [
"spki",
]
[[package]]
name = "educe"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d7bc049e1bd8cdeb31b68bbd586a9464ecf9f3944af3958a7a9d0f8b9799417"
dependencies = [
"enum-ordinalize",
"proc-macro2",
"quote",
"syn 2.0.98",
]
[[package]]
name = "either"
version = "1.14.0"
@ -1641,26 +1484,6 @@ dependencies = [
"syn 2.0.98",
]
[[package]]
name = "enum-ordinalize"
version = "4.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fea0dcfa4e54eeb516fe454635a95753ddd39acda650ce703031c6973e315dd5"
dependencies = [
"enum-ordinalize-derive",
]
[[package]]
name = "enum-ordinalize-derive"
version = "4.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d28318a75d4aead5c4db25382e8ef717932d0346600cacae6357eb5941bc5ff"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.98",
]
[[package]]
name = "env_logger"
version = "0.10.2"
@ -2066,9 +1889,9 @@ dependencies = [
[[package]]
name = "hashbrown"
version = "0.14.5"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"
dependencies = [
"ahash 0.8.11",
]
@ -2078,18 +1901,6 @@ name = "hashbrown"
version = "0.15.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289"
dependencies = [
"allocator-api2",
]
[[package]]
name = "hashlink"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af"
dependencies = [
"hashbrown 0.14.5",
]
[[package]]
name = "heck"
@ -2097,12 +1908,6 @@ version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "heck"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "hermit-abi"
version = "0.1.19"
@ -2433,12 +2238,6 @@ dependencies = [
"syn 2.0.98",
]
[[package]]
name = "ident_case"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]]
name = "idna"
version = "1.0.3"
@ -2524,24 +2323,6 @@ dependencies = [
"either",
]
[[package]]
name = "itertools"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57"
dependencies = [
"either",
]
[[package]]
name = "itertools"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
dependencies = [
"either",
]
[[package]]
name = "itertools"
version = "0.14.0"
@ -2768,64 +2549,6 @@ dependencies = [
"pkg-config",
]
[[package]]
name = "malachite"
version = "0.4.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fbdf9cb251732db30a7200ebb6ae5d22fe8e11397364416617d2c2cf0c51cb5"
dependencies = [
"malachite-base",
"malachite-float",
"malachite-nz",
"malachite-q",
]
[[package]]
name = "malachite-base"
version = "0.4.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ea0ed76adf7defc1a92240b5c36d5368cfe9251640dcce5bd2d0b7c1fd87aeb"
dependencies = [
"hashbrown 0.14.5",
"itertools 0.11.0",
"libm",
"ryu",
]
[[package]]
name = "malachite-float"
version = "0.4.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af9d20db1c73759c1377db7b27575df6f2eab7368809dd62c0a715dc1bcc39f7"
dependencies = [
"itertools 0.11.0",
"malachite-base",
"malachite-nz",
"malachite-q",
]
[[package]]
name = "malachite-nz"
version = "0.4.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34a79feebb2bc9aa7762047c8e5495269a367da6b5a90a99882a0aeeac1841f7"
dependencies = [
"itertools 0.11.0",
"libm",
"malachite-base",
]
[[package]]
name = "malachite-q"
version = "0.4.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50f235d5747b1256b47620f5640c2a17a88c7569eebdf27cd9cb130e1a619191"
dependencies = [
"itertools 0.11.0",
"malachite-base",
"malachite-nz",
]
[[package]]
name = "malloc_buf"
version = "0.0.6"
@ -2882,18 +2605,6 @@ dependencies = [
"serde_json",
]
[[package]]
name = "merlin"
version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58c38e2799fc0978b65dfff8023ec7843e2330bb462f19198840b34b6582397d"
dependencies = [
"byteorder",
"keccak",
"rand_core 0.6.4",
"zeroize",
]
[[package]]
name = "metal"
version = "0.29.0"
@ -3902,12 +3613,11 @@ dependencies = [
[[package]]
name = "risc0-binfmt"
version = "1.3.0"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.3#c3b70f107156899b905f601097840caeb926d6b7"
version = "1.2.5"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.2#2225069ebc465320695ef3d5e028f6072e103718"
dependencies = [
"anyhow",
"borsh",
"derive_more 1.0.0",
"elf",
"risc0-zkp",
"risc0-zkvm-platform",
@ -3917,29 +3627,26 @@ dependencies = [
[[package]]
name = "risc0-build"
version = "2.0.0"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.3#c3b70f107156899b905f601097840caeb926d6b7"
version = "1.2.5"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.2#2225069ebc465320695ef3d5e028f6072e103718"
dependencies = [
"anyhow",
"cargo_metadata",
"derive_builder",
"dirs",
"docker-generate",
"hex",
"risc0-binfmt",
"risc0-zkp",
"risc0-zkvm-platform",
"rzup",
"serde",
"serde_json",
"stability",
"tempfile",
]
[[package]]
name = "risc0-build-kernel"
version = "1.3.0"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.3#c3b70f107156899b905f601097840caeb926d6b7"
version = "1.2.5"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.2#2225069ebc465320695ef3d5e028f6072e103718"
dependencies = [
"cc",
"directories",
@ -3952,8 +3659,8 @@ dependencies = [
[[package]]
name = "risc0-circuit-keccak"
version = "1.3.0"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.3#c3b70f107156899b905f601097840caeb926d6b7"
version = "1.2.5"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.2#2225069ebc465320695ef3d5e028f6072e103718"
dependencies = [
"anyhow",
"bytemuck",
@ -3973,8 +3680,8 @@ dependencies = [
[[package]]
name = "risc0-circuit-keccak-sys"
version = "1.3.0"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.3#c3b70f107156899b905f601097840caeb926d6b7"
version = "1.2.5"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.2#2225069ebc465320695ef3d5e028f6072e103718"
dependencies = [
"cc",
"cust",
@ -3988,8 +3695,8 @@ dependencies = [
[[package]]
name = "risc0-circuit-recursion"
version = "1.3.0"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.3#c3b70f107156899b905f601097840caeb926d6b7"
version = "1.2.5"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.2#2225069ebc465320695ef3d5e028f6072e103718"
dependencies = [
"anyhow",
"bytemuck",
@ -4013,8 +3720,8 @@ dependencies = [
[[package]]
name = "risc0-circuit-recursion-sys"
version = "1.3.0"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.3#c3b70f107156899b905f601097840caeb926d6b7"
version = "1.2.5"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.2#2225069ebc465320695ef3d5e028f6072e103718"
dependencies = [
"glob",
"risc0-build-kernel",
@ -4025,8 +3732,8 @@ dependencies = [
[[package]]
name = "risc0-circuit-rv32im"
version = "1.3.0"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.3#c3b70f107156899b905f601097840caeb926d6b7"
version = "1.2.5"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.2#2225069ebc465320695ef3d5e028f6072e103718"
dependencies = [
"anyhow",
"auto_ops",
@ -4039,8 +3746,8 @@ dependencies = [
"derive_more 1.0.0",
"enum-map",
"lazy-regex",
"malachite",
"metal",
"num-bigint 0.4.6",
"num-derive",
"num-traits",
"rand 0.8.5",
@ -4053,14 +3760,13 @@ dependencies = [
"risc0-zkvm-platform",
"serde",
"sha2 0.10.8",
"smallvec",
"tracing",
]
[[package]]
name = "risc0-circuit-rv32im-sys"
version = "1.3.0"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.3#c3b70f107156899b905f601097840caeb926d6b7"
version = "1.2.5"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.2#2225069ebc465320695ef3d5e028f6072e103718"
dependencies = [
"glob",
"risc0-build-kernel",
@ -4071,8 +3777,8 @@ dependencies = [
[[package]]
name = "risc0-core"
version = "1.3.0"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.3#c3b70f107156899b905f601097840caeb926d6b7"
version = "1.2.5"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.2#2225069ebc465320695ef3d5e028f6072e103718"
dependencies = [
"bytemuck",
"nvtx",
@ -4082,8 +3788,8 @@ dependencies = [
[[package]]
name = "risc0-groth16"
version = "1.3.0"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.3#c3b70f107156899b905f601097840caeb926d6b7"
version = "1.2.5"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.2#2225069ebc465320695ef3d5e028f6072e103718"
dependencies = [
"anyhow",
"ark-bn254",
@ -4106,8 +3812,8 @@ dependencies = [
[[package]]
name = "risc0-sys"
version = "1.3.0"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.3#c3b70f107156899b905f601097840caeb926d6b7"
version = "1.2.5"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.2#2225069ebc465320695ef3d5e028f6072e103718"
dependencies = [
"anyhow",
"cust",
@ -4117,8 +3823,8 @@ dependencies = [
[[package]]
name = "risc0-zkp"
version = "1.3.0"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.3#c3b70f107156899b905f601097840caeb926d6b7"
version = "1.2.5"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.2#2225069ebc465320695ef3d5e028f6072e103718"
dependencies = [
"anyhow",
"blake2",
@ -4142,14 +3848,13 @@ dependencies = [
"risc0-zkvm-platform",
"serde",
"sha2 0.10.8",
"stability",
"tracing",
]
[[package]]
name = "risc0-zkvm"
version = "1.3.0"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.3#c3b70f107156899b905f601097840caeb926d6b7"
version = "1.2.5"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.2#2225069ebc465320695ef3d5e028f6072e103718"
dependencies = [
"addr2line 0.22.0",
"anyhow",
@ -4158,7 +3863,6 @@ dependencies = [
"borsh",
"bytemuck",
"bytes",
"derive_more 2.0.1",
"elf",
"enum-map",
"getrandom 0.2.15",
@ -4181,7 +3885,6 @@ dependencies = [
"risc0-zkvm-platform",
"rrs-lib",
"rustc-demangle",
"rzup",
"semver",
"serde",
"sha2 0.10.8",
@ -4193,8 +3896,8 @@ dependencies = [
[[package]]
name = "risc0-zkvm-platform"
version = "1.3.0"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.3#c3b70f107156899b905f601097840caeb926d6b7"
version = "1.2.5"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.2#2225069ebc465320695ef3d5e028f6072e103718"
dependencies = [
"bytemuck",
"cfg-if 1.0.0",
@ -4361,17 +4064,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd"
[[package]]
name = "rzup"
version = "0.3.0"
source = "git+https://github.com/risc0/risc0.git?branch=release-1.3#c3b70f107156899b905f601097840caeb926d6b7"
name = "sc_core"
version = "0.1.0"
dependencies = [
"semver",
"accounts",
"anyhow",
"bincode",
"common",
"elliptic-curve",
"env_logger",
"hex",
"k256",
"log",
"monotree",
"rand 0.8.5",
"risc0-zkvm",
"secp256k1-zkp",
"serde",
"strum",
"tempfile",
"thiserror 2.0.11",
"toml 0.8.20",
"yaml-rust2",
"serde_json",
"sha2 0.10.8",
"storage",
"utxo",
]
[[package]]
@ -4537,7 +4250,7 @@ dependencies = [
"serde",
"serde_json",
"tokio",
"toml 0.7.8",
"toml",
]
[[package]]
@ -4773,34 +4486,6 @@ version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "strsim"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "strum"
version = "0.26.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06"
dependencies = [
"strum_macros",
]
[[package]]
name = "strum_macros"
version = "0.26.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be"
dependencies = [
"heck 0.5.0",
"proc-macro2",
"quote",
"rustversion",
"syn 2.0.98",
]
[[package]]
name = "subtle"
version = "1.0.0"
@ -5082,18 +4767,6 @@ dependencies = [
"toml_edit 0.19.15",
]
[[package]]
name = "toml"
version = "0.8.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148"
dependencies = [
"serde",
"serde_spanned",
"toml_datetime",
"toml_edit 0.22.24",
]
[[package]]
name = "toml_datetime"
version = "0.6.8"
@ -5123,8 +4796,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474"
dependencies = [
"indexmap 2.7.1",
"serde",
"serde_spanned",
"toml_datetime",
"winnow 0.7.3",
]
@ -5788,17 +5459,6 @@ dependencies = [
"lzma-sys",
]
[[package]]
name = "yaml-rust2"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a1a1c0bc9823338a3bdf8c61f994f23ac004c6fa32c08cd152984499b445e8d"
dependencies = [
"arraydeque",
"encoding_rs",
"hashlink",
]
[[package]]
name = "yoke"
version = "0.7.5"

View File

@ -17,6 +17,7 @@ members = [
"sequencer_core",
"rpc_primitives",
"common",
"sc_core",
]
[workspace.dependencies]

View File

@ -10,7 +10,7 @@ serde_json.workspace = true
serde.workspace = true
reqwest.workspace = true
monotree.workspace = true
risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-1.3" }
risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-1.2" }
[dependencies.rpc_primitives]
path = "../rpc_primitives"

View File

@ -19,7 +19,7 @@ reqwest.workspace = true
thiserror.workspace = true
tokio.workspace = true
tempfile.workspace = true
risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-1.3" }
risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-1.2" }
hex.workspace = true
actix-rt.workspace = true

36
sc_core/Cargo.toml Normal file
View File

@ -0,0 +1,36 @@
[package]
name = "sc_core"
version = "0.1.0"
edition = "2021"
[dependencies]
anyhow.workspace = true
serde_json.workspace = true
env_logger.workspace = true
log.workspace = true
serde.workspace = true
rand.workspace = true
k256.workspace = true
sha2.workspace = true
monotree.workspace = true
bincode.workspace = true
elliptic-curve.workspace = true
hex.workspace = true
risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-1.2" }
[dependencies.accounts]
path = "../accounts"
[dependencies.storage]
path = "../storage"
[dependencies.utxo]
path = "../utxo"
[dependencies.common]
path = "../common"
[dependencies.secp256k1-zkp]
workspace = true
features = ["std", "rand-std", "rand", "serde", "global-context"]

3
sc_core/src/lib.rs Normal file
View File

@ -0,0 +1,3 @@
pub mod proofs_circuits;
pub mod transaction_payloads_tools;
pub mod utxo_manipulator;

View File

@ -0,0 +1,299 @@
use bincode;
use k256::Scalar;
use monotree::hasher::Blake3;
use monotree::{Hasher, Monotree};
use rand::thread_rng;
use secp256k1_zkp::{CommitmentSecrets, Generator, PedersenCommitment, Tag, Tweak, SECP256K1};
use sha2::{Digest, Sha256};
use storage::{
commitment::Commitment, commitments_sparse_merkle_tree::CommitmentsSparseMerkleTree,
nullifier::UTXONullifier, nullifier_sparse_merkle_tree::NullifierSparseMerkleTree,
};
use utxo::utxo_core::UTXO;
fn hash(input: &[u8]) -> Vec<u8> {
Sha256::digest(input).to_vec()
}
// Generate nullifiers
// takes the input_utxo and nsk
// returns the nullifiers[i], where the nullifier[i] = hash(in_commitments[i] || nsk) where the hash function
pub fn generate_nullifiers(input_utxo: &UTXO, nsk: &[u8]) -> Vec<u8> {
let mut input = bincode::serialize(input_utxo).unwrap().to_vec();
input.extend_from_slice(nsk);
hash(&input)
}
// Generate commitments for output UTXOs
// uses the list of input_utxos[]
// returns in_commitments[] where each in_commitments[i] = Commitment(in_utxos[i]) where the commitment
pub fn generate_commitments(input_utxos: &[UTXO]) -> Vec<Vec<u8>> {
input_utxos
.iter()
.map(|utxo| {
let serialized = bincode::serialize(utxo).unwrap(); // Serialize UTXO.
hash(&serialized)
})
.collect()
}
// Validate inclusion proof for in_commitments
// takes the in_commitments[i] as a leaf, the root hash root_commitment and the path in_commitments_proofs[i][],
// returns True if the in_commitments[i] is in the tree with root hash root_commitment otherwise returns False, as membership proof.
pub fn validate_in_commitments_proof(
in_commitment: &Vec<u8>,
root_commitment: Vec<u8>,
in_commitments_proof: &[Vec<u8>],
) -> bool {
// Placeholder implementation.
// Replace with Merkle proof verification logic.
// hash(&[pedersen_commitment.serialize().to_vec(), in_commitments_proof.concat()].concat()) == root_commitment
let mut nsmt = CommitmentsSparseMerkleTree {
curr_root: Option::Some(root_commitment),
tree: Monotree::default(),
hasher: Blake3::new(),
};
let commitments: Vec<_> = in_commitments_proof
.into_iter()
.map(|n_p| Commitment {
commitment_hash: n_p.clone(),
})
.collect();
nsmt.insert_items(commitments).unwrap();
nsmt.get_non_membership_proof(in_commitment.clone())
.unwrap()
.1
.is_some()
}
// Validate non-membership proof for nullifiers
// takes the nullifiers[i], path nullifiers_proof[i][] and the root hash root_nullifier,
// returns True if the nullifiers[i] is not in the tree with root hash root_nullifier otherwise returns False, as non-membership proof.
pub fn validate_nullifiers_proof(
nullifier: [u8; 32],
root_nullifier: [u8; 32],
nullifiers_proof: &[[u8; 32]],
) -> bool {
let mut nsmt = NullifierSparseMerkleTree {
curr_root: Option::Some(root_nullifier),
tree: Monotree::default(),
hasher: Blake3::new(),
};
let nullifiers: Vec<_> = nullifiers_proof
.into_iter()
.map(|n_p| UTXONullifier { utxo_hash: *n_p })
.collect();
nsmt.insert_items(nullifiers).unwrap();
nsmt.get_non_membership_proof(nullifier)
.unwrap()
.1
.is_none()
}
#[allow(unused)]
fn private_kernel(
root_commitment: &[u8],
root_nullifier: [u8; 32],
input_utxos: &[UTXO],
in_commitments_proof: &[Vec<u8>],
nullifiers_proof: &[[u8; 32]],
nullifier_secret_key: Scalar,
) -> (Vec<u8>, Vec<Vec<u8>>) {
let nullifiers: Vec<_> = input_utxos
.into_iter()
.map(|utxo| generate_nullifiers(&utxo, &nullifier_secret_key.to_bytes()))
.collect();
let in_commitments = generate_commitments(&input_utxos);
for in_commitment in in_commitments {
validate_in_commitments_proof(
&in_commitment,
root_commitment.to_vec(),
in_commitments_proof,
);
}
for nullifier in nullifiers.iter() {
validate_nullifiers_proof(
nullifier[0..32].try_into().unwrap(),
root_nullifier,
nullifiers_proof,
);
}
(vec![], nullifiers)
}
#[allow(unused)]
fn commitment_secrets_random(value: u64) -> CommitmentSecrets {
CommitmentSecrets {
value,
value_blinding_factor: Tweak::new(&mut thread_rng()),
generator_blinding_factor: Tweak::new(&mut thread_rng()),
}
}
pub fn tag_random() -> Tag {
use rand::thread_rng;
use rand::RngCore;
let mut bytes = [0u8; 32];
thread_rng().fill_bytes(&mut bytes);
Tag::from(bytes)
}
pub fn commit(comm: &CommitmentSecrets, tag: Tag) -> PedersenCommitment {
let generator = Generator::new_blinded(SECP256K1, tag, comm.generator_blinding_factor);
PedersenCommitment::new(SECP256K1, comm.value, comm.value_blinding_factor, generator)
}
// Check balances
// takes the public_info and output_utxos[],
// returns the True if the token amount in public_info matches the sum of all output_utxos[], otherwise return False.
pub fn check_balances(public_info: u128, output_utxos: &[UTXO]) -> bool {
let total_output: u128 = output_utxos.iter().map(|utxo| utxo.amount).sum();
public_info == total_output
}
// Verify Pedersen commitment
// takes the public_info, secret_r and pedersen_commitment and
// checks that commitment(public_info,secret_r) is equal pedersen_commitment where the commitment is pedersen commitment.
pub fn verify_commitment(
public_info: u64,
secret_r: &[u8],
pedersen_commitment: &PedersenCommitment,
) -> bool {
let commitment_secrets = CommitmentSecrets {
value: public_info,
value_blinding_factor: Tweak::from_slice(secret_r).unwrap(),
generator_blinding_factor: Tweak::new(&mut thread_rng()),
};
let tag = tag_random();
let commitment = commit(&commitment_secrets, tag);
commitment == *pedersen_commitment
}
#[allow(unused)]
fn de_kernel(
root_commitment: &[u8],
root_nullifier: [u8; 32],
public_info: u64,
input_utxos: &[UTXO],
in_commitments_proof: &[Vec<u8>],
nullifiers_proof: &[[u8; 32]],
nullifier_secret_key: Scalar,
) -> (Vec<u8>, Vec<Vec<u8>>) {
check_balances(public_info as u128, input_utxos);
let nullifiers: Vec<_> = input_utxos
.into_iter()
.map(|utxo| generate_nullifiers(&utxo, &nullifier_secret_key.to_bytes()))
.collect();
let in_commitments = generate_commitments(&input_utxos);
for in_commitment in in_commitments {
validate_in_commitments_proof(
&in_commitment,
root_commitment.to_vec(),
in_commitments_proof,
);
}
for nullifier in nullifiers.iter() {
validate_nullifiers_proof(
nullifier[0..32].try_into().unwrap(),
root_nullifier,
nullifiers_proof,
);
}
(vec![], nullifiers)
}
// Validate inclusion proof for in_commitments
// takes the pedersen_commitment as a leaf, the root hash root_commitment and the path in_commitments_proof[],
// returns True if the pedersen_commitment is in the tree with root hash root_commitment
// otherwise
// returns False, as membership proof.
pub fn validate_in_commitments_proof_se(
pedersen_commitment: &PedersenCommitment,
root_commitment: Vec<u8>,
in_commitments_proof: &[Vec<u8>],
) -> bool {
let mut nsmt = CommitmentsSparseMerkleTree {
curr_root: Option::Some(root_commitment),
tree: Monotree::default(),
hasher: Blake3::new(),
};
let commitments: Vec<_> = in_commitments_proof
.into_iter()
.map(|n_p| Commitment {
commitment_hash: n_p.clone(),
})
.collect();
nsmt.insert_items(commitments).unwrap();
nsmt.get_non_membership_proof(pedersen_commitment.serialize().to_vec())
.unwrap()
.1
.is_some()
}
// Generate nullifiers SE
// takes the pedersen_commitment and nsk then
// returns a list of nullifiers, where the nullifier = hash(pedersen_commitment || nsk) where the hash function will be determined
pub fn generate_nullifiers_se(pedersen_commitment: &PedersenCommitment, nsk: &[u8]) -> Vec<u8> {
let mut input = pedersen_commitment.serialize().to_vec();
input.extend_from_slice(nsk);
hash(&input)
}
#[allow(unused)]
fn se_kernel(
root_commitment: &[u8],
root_nullifier: [u8; 32],
public_info: u64,
pedersen_commitment: PedersenCommitment,
secret_r: &[u8],
output_utxos: &[UTXO],
in_commitments_proof: &[Vec<u8>],
nullifiers_proof: &[[u8; 32]],
nullifier_secret_key: Scalar,
) -> (Vec<u8>, Vec<Vec<u8>>, Vec<u8>) {
check_balances(public_info as u128, output_utxos);
let out_commitments = generate_commitments(output_utxos);
let nullifier = generate_nullifiers_se(&pedersen_commitment, &nullifier_secret_key.to_bytes());
validate_in_commitments_proof_se(
&pedersen_commitment,
root_commitment.to_vec(),
in_commitments_proof,
);
verify_commitment(public_info, secret_r, &pedersen_commitment);
(vec![], out_commitments, nullifier)
}

View File

@ -0,0 +1,92 @@
use accounts::account_core::Account;
use anyhow::Result;
use rand::thread_rng;
use risc0_zkvm::Receipt;
use secp256k1_zkp::{CommitmentSecrets, PedersenCommitment, Tweak};
use storage::transaction::{TransactionPayload, TxKind};
use utxo::utxo_core::UTXO;
use crate::proofs_circuits::{commit, generate_nullifiers, tag_random};
pub fn create_public_transaction_payload(execution_input: Vec<u8>) -> TransactionPayload {
TransactionPayload {
tx_kind: TxKind::Public,
execution_input,
execution_output: vec![],
utxo_commitments_spent_hashes: vec![],
utxo_commitments_created_hashes: vec![],
nullifier_created_hashes: vec![],
execution_proof_private: "".to_string(),
encoded_data: vec![],
ephemeral_pub_key: vec![],
}
}
pub fn encode_utxos_to_receivers(
utxos_receivers: Vec<(UTXO, &Account)>,
) -> Vec<(Vec<u8>, Vec<u8>)> {
let mut all_encoded_data = vec![];
for (utxo, receiver) in utxos_receivers {
let ephm_key_holder = &receiver.produce_ephemeral_key_holder();
let encoded_data = Account::encrypt_data(
&ephm_key_holder,
receiver.key_holder.viewing_public_key,
&serde_json::to_vec(&utxo).unwrap(),
);
let encoded_data_vec = (encoded_data.0, encoded_data.1.to_vec());
all_encoded_data.push(encoded_data_vec);
}
all_encoded_data
}
pub fn generate_nullifiers_spent_utxos(utxos_spent: Vec<(UTXO, &Account)>) -> Vec<Vec<u8>> {
let mut all_nullifiers = vec![];
for (utxo, spender) in utxos_spent {
let nullifier = generate_nullifiers(
&utxo,
&spender
.key_holder
.utxo_secret_key_holder
.nullifier_secret_key
.to_bytes()
.to_vec(),
);
all_nullifiers.push(nullifier);
}
all_nullifiers
}
pub fn encode_receipt(receipt: Receipt) -> Result<String> {
Ok(hex::encode(serde_json::to_vec(&receipt)?))
}
pub fn generate_secret_random_commitment(
value: u64,
account: &Account,
) -> Result<PedersenCommitment> {
let commitment_secrets = CommitmentSecrets {
value,
value_blinding_factor: Tweak::from_slice(
&account
.key_holder
.utxo_secret_key_holder
.viewing_secret_key
.to_bytes()
.to_vec(),
)?,
generator_blinding_factor: Tweak::new(&mut thread_rng()),
};
let tag = tag_random();
let commitment = commit(&commitment_secrets, tag);
Ok(commitment)
}

View File

@ -0,0 +1,110 @@
use anyhow::Result;
use storage::nullifier::UTXONullifier;
use utxo::utxo_core::{UTXOPayload, UTXO};
pub fn utxo_change_owner(
utxo: &mut UTXO,
nullifier: UTXONullifier,
new_owner: [u8; 32],
) -> Result<UTXO> {
let new_payload = UTXOPayload {
owner: new_owner,
asset: utxo.asset.clone(),
amount: utxo.amount,
privacy_flag: utxo.privacy_flag,
};
utxo.consume_utxo(nullifier)?;
Ok(UTXO::create_utxo_from_payload(new_payload)?)
}
pub fn utxo_substact_part_another_owner(
utxo: &mut UTXO,
nullifier: UTXONullifier,
amount: u128,
new_owner: [u8; 32],
) -> Result<(UTXO, UTXO)> {
if amount > utxo.amount {
anyhow::bail!("Amount too big");
}
let diff = utxo.amount - amount;
let new_payload1 = UTXOPayload {
owner: utxo.owner,
asset: utxo.asset.clone(),
amount: diff,
privacy_flag: utxo.privacy_flag,
};
let new_payload2 = UTXOPayload {
owner: new_owner,
asset: utxo.asset.clone(),
amount,
privacy_flag: utxo.privacy_flag,
};
utxo.consume_utxo(nullifier)?;
Ok((
UTXO::create_utxo_from_payload(new_payload1)?,
UTXO::create_utxo_from_payload(new_payload2)?,
))
}
pub fn utxo_substract_part(
utxo: &mut UTXO,
nullifier: UTXONullifier,
amount: u128,
) -> Result<(UTXO, UTXO)> {
let new_owner = utxo.owner;
utxo_substact_part_another_owner(utxo, nullifier, amount, new_owner)
}
pub fn utxo_split_n_users(
utxo: &mut UTXO,
nullifier: UTXONullifier,
users_amounts: Vec<([u8; 32], u128)>,
) -> Result<Vec<UTXO>> {
let cumulative_diff = users_amounts
.iter()
.fold(0, |acc, (_, amount)| acc + *amount);
if cumulative_diff > utxo.amount {
anyhow::bail!("Amount too big");
}
let mut utxo_res = vec![];
for (new_owner, amount) in users_amounts {
let new_payload = UTXOPayload {
owner: new_owner,
asset: utxo.asset.clone(),
amount,
privacy_flag: utxo.privacy_flag,
};
let new_utxo = UTXO::create_utxo_from_payload(new_payload)?;
utxo_res.push(new_utxo);
}
if cumulative_diff != utxo.amount {
let new_payload = UTXOPayload {
owner: utxo.owner,
asset: utxo.asset.clone(),
amount: utxo.amount - cumulative_diff,
privacy_flag: utxo.privacy_flag,
};
let new_utxo = UTXO::create_utxo_from_payload(new_payload)?;
utxo_res.push(new_utxo);
}
utxo.consume_utxo(nullifier)?;
Ok(utxo_res)
}

View File

@ -11,7 +11,7 @@ log.workspace = true
serde.workspace = true
thiserror.workspace = true
risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-1.3" }
risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-1.2" }
test-methods = { path = "test_methods" }
[dependencies.accounts]

View File

@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"
[build-dependencies]
risc0-build = { git = "https://github.com/risc0/risc0.git", branch = "release-1.3" }
risc0-build = { git = "https://github.com/risc0/risc0.git", branch = "release-1.2" }
[package.metadata.risc0]
methods = ["guest"]