diff --git a/Cargo.lock b/Cargo.lock index 175c74a2..550ce5e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,18 +4,18 @@ version = 4 [[package]] name = "addr2line" -version = "0.21.0" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" [[package]] name = "aead" @@ -24,7 +24,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" dependencies = [ "crypto-common", - "generic-array", + "generic-array 0.14.7", ] [[package]] @@ -40,12 +40,12 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.11" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" dependencies = [ "cfg-if", - "getrandom", + "getrandom 0.3.3", "once_cell", "version_check", "zerocopy", @@ -62,9 +62,9 @@ dependencies = [ [[package]] name = "aligned-vec" -version = "0.6.1" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e0966165eaf052580bd70eb1b32cb3d6245774c0104d1b2793e9650bf83b52a" +checksum = "dc890384c8602f339876ded803c97ad529f3842aba97f6392b3dba0dd171769b" dependencies = [ "equator", ] @@ -77,30 +77,30 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstyle" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" +checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" [[package]] name = "arbitrary" -version = "1.3.2" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" +checksum = "c3d036a3c4ab069c7b410a2ce876bd74808d2d0888a82667669f8e783a898bf1" dependencies = [ "derive_arbitrary", ] [[package]] name = "arrayref" -version = "0.3.7" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" [[package]] name = "arrayvec" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "assert_matches" @@ -119,23 +119,23 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.3.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "backtrace" -version = "0.3.71" +version = "0.3.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" +checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002" dependencies = [ "addr2line", - "cc", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", + "windows-targets 0.52.6", ] [[package]] @@ -146,29 +146,30 @@ checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" [[package]] name = "base64ct" -version = "1.0.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a32fd6af2b5827bce66c29053ba0e7c42b9dcab01835835058558c10851a46b" +checksum = "55248b47b0caf0546f7988906588779981c43bb1bc9d0c44087278f80cdb44ba" [[package]] -name = "bellman" -version = "0.14.0" +name = "bellpepper-core" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afceed28bac7f9f5a508bca8aeeff51cdfa4770c0b967ac55c621e2ddfd6171" +checksum = "b2c9a1b2f748c59938bc72165ebdf34efffeecee9cfbe0bb7d6b01aea21cd523" dependencies = [ - "bitvec", "blake2s_simd", "byteorder", - "crossbeam-channel", "ff", - "group", - "lazy_static", - "log", - "num_cpus", - "pairing", - "rand_core", - "rayon", - "subtle", + "serde", + "thiserror 1.0.69", +] + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", ] [[package]] @@ -179,7 +180,7 @@ checksum = "568b6890865156d9043af490d4c4081c385dd68ea10acd6ca15733d511e6b51c" dependencies = [ "hmac", "pbkdf2", - "rand", + "rand 0.8.5", "sha2", "unicode-normalization", "zeroize", @@ -187,18 +188,18 @@ dependencies = [ [[package]] name = "bit-set" -version = "0.5.3" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3" dependencies = [ "bit-vec", ] [[package]] name = "bit-vec" -version = "0.6.3" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" +checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" [[package]] name = "bitflags" @@ -208,9 +209,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394" [[package]] name = "bitvec" @@ -226,9 +227,9 @@ dependencies = [ [[package]] name = "blake2b_simd" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23285ad32269793932e830392f2fe2f83e26488fd3ec778883a93c8323735780" +checksum = "06e903a20b159e944f91ec8499fe1e55651480c541ea0a584f5d967c49ad9d99" dependencies = [ "arrayref", "arrayvec", @@ -237,9 +238,9 @@ dependencies = [ [[package]] name = "blake2s_simd" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94230421e395b9920d23df13ea5d77a20e1725331f90fbbf6df6040b33f756ae" +checksum = "e90f7deecfac93095eb874a40febd69427776e24e1bd7f87f33ac62d6f0174df" dependencies = [ "arrayref", "arrayvec", @@ -252,7 +253,7 @@ version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ - "generic-array", + "generic-array 0.14.7", ] [[package]] @@ -262,15 +263,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7bc6d6292be3a19e6379786dac800f551e5865a5bb51ebbe3064ab80433f403" dependencies = [ "ff", - "rand_core", + "rand_core 0.6.4", "subtle", ] [[package]] name = "borsh" -version = "1.5.6" +version = "1.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b74d67a0fc0af8e9823b79fd1c43a0900e5a8f0e0f4cc9210796bf3a820126" +checksum = "ad8646f98db542e39fc66e68a20b2144f6a732636df7c2354e74645faaa433ce" dependencies = [ "borsh-derive", "cfg_aliases", @@ -278,9 +279,9 @@ dependencies = [ [[package]] name = "borsh-derive" -version = "1.5.6" +version = "1.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d37ed1b2c9b78421218a0b4f6d8349132d6ec2cfeba1cfb0118b0a8e268df9e" +checksum = "fdd1d3c0c2f5833f22386f252fe8ed005c7f59fdcddeef025c01b4c3b9fd9ac3" dependencies = [ "once_cell", "proc-macro-crate", @@ -291,15 +292,21 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.16.0" +version = "3.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" + +[[package]] +name = "byte-slice-cast" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7575182f7272186991736b70173b0ea045398f984bf5ebbb3804736ce1330c9d" [[package]] name = "bytemuck" -version = "1.16.0" +version = "1.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78834c15cb5d5efe3452d58b1e8ba890dd62d21907f867f383358198e56ebca5" +checksum = "3995eaeebcdf32f91f980d360f78732ddc061097ab4e39991ae7a6ace9194677" [[package]] name = "byteorder" @@ -324,18 +331,19 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.16" +version = "1.2.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be714c154be609ec7f5dad223a33bf1482fff90472de28f7362806e6d4832b8c" +checksum = "65193589c6404eb80b450d618eaf9a2cafaaafd57ecce47370519ef674a7bd44" dependencies = [ + "find-msvc-tools", "shlex", ] [[package]] name = "cfg-if" -version = "1.0.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9" [[package]] name = "cfg_aliases" @@ -407,18 +415,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.25" +version = "4.5.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b95dca1b68188a08ca6af9d96a6576150f598824bdb528c1190460c2940a0b48" +checksum = "7eac00902d9d136acd712710d71823fb8ac8004ca445a89e73a41d45aa712931" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.25" +version = "4.5.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ab52925392148efd3f7562f2136a81ffb778076bcc85727c6e020d6dd57cf15" +checksum = "2ad9bbf750e73b5884fb8a211a9424a1906c1e156724260fdae972f31d70e1d6" dependencies = [ "anstyle", "clap_lex", @@ -426,15 +434,18 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" +checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" [[package]] name = "cobs" -version = "0.2.3" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" +checksum = "0fa961b519f0b462e3a3b4a34b64d119eeaca1d59af726fe450bbba07a9fc0a1" +dependencies = [ + "thiserror 2.0.16", +] [[package]] name = "const-crc32-nostd" @@ -444,9 +455,9 @@ checksum = "808ac43170e95b11dd23d78aa9eaac5bea45776a602955552c4e833f3f0f823d" [[package]] name = "constant_time_eq" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" +checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" [[package]] name = "core2" @@ -459,18 +470,18 @@ dependencies = [ [[package]] name = "cpp_demangle" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8227005286ec39567949b33df9896bcadfa6051bccca2488129f108ca23119" +checksum = "96e58d342ad113c2b878f16d5d034c03be492ae460cdbc02b7f0f2284d310c7d" dependencies = [ "cfg-if", ] [[package]] name = "cpufeatures" -version = "0.2.12" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" dependencies = [ "libc", ] @@ -528,9 +539,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" dependencies = [ "crossbeam-epoch", "crossbeam-utils", @@ -547,15 +558,15 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.19" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "crunchy" -version = "0.2.2" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" +checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" [[package]] name = "crypto-common" @@ -563,8 +574,8 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "generic-array", - "rand_core", + "generic-array 0.14.7", + "rand_core 0.6.4", "typenum", ] @@ -596,9 +607,9 @@ dependencies = [ [[package]] name = "derive_arbitrary" -version = "1.3.2" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" +checksum = "1e567bd82dcff979e4b03460c307b3cdc9e96fde3d73bed1496d2bc75d9dd62a" dependencies = [ "proc-macro2", "quote", @@ -639,18 +650,46 @@ dependencies = [ [[package]] name = "document-features" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6969eaabd2421f8a2775cfd2471a2b634372b4a25d41e3bd647b79912850a0" +checksum = "95249b50c6c185bee49034bcb378a49dc2b5dff0be90ff6616d31d64febab05d" dependencies = [ "litrs", ] +[[package]] +name = "ec-gpu" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd63582de2b59ea1aa48d7c1941b5d87618d95484397521b3acdfa0e1e9f5e45" + +[[package]] +name = "ec-gpu-gen" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2353854622ec1abfd22243eb958453b95f1502e2a56648bf9db49ccbfb55f01" +dependencies = [ + "bitvec", + "crossbeam-channel", + "ec-gpu", + "execute", + "ff", + "group", + "hex", + "log", + "num_cpus", + "once_cell", + "rayon", + "sha2", + "thiserror 1.0.69", + "yastl", +] + [[package]] name = "either" -version = "1.11.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "embedded-io" @@ -666,18 +705,18 @@ checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" [[package]] name = "equator" -version = "0.2.2" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c35da53b5a021d2484a7cc49b2ac7f2d840f8236a286f84202369bd338d761ea" +checksum = "4711b213838dfee0117e3be6ac926007d7f433d7bbe33595975d4190cb07e6fc" dependencies = [ "equator-macro", ] [[package]] name = "equator-macro" -version = "0.2.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bf679796c0322556351f287a51b49e48f7c4986e727b5dd78c972d30e2e16cc" +checksum = "44f23cf4b44bfce11a86ace86f8a73ffdec849c9fd00a386a53d278bd9e81fb3" dependencies = [ "proc-macro2", "quote", @@ -686,37 +725,80 @@ dependencies = [ [[package]] name = "equivalent" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" -version = "0.3.9" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.61.0", +] + +[[package]] +name = "execute" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a82608ee96ce76aeab659e9b8d3c2b787bffd223199af88c674923d861ada10" +dependencies = [ + "execute-command-macro", + "execute-command-tokens", + "generic-array 1.2.0", +] + +[[package]] +name = "execute-command-macro" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90dec53d547564e911dc4ff3ecb726a64cf41a6fa01a2370ebc0d95175dd08bd" +dependencies = [ + "execute-command-macro-impl", ] +[[package]] +name = "execute-command-macro-impl" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce8cd46a041ad005ab9c71263f9a0ff5b529eac0fe4cc9b4a20f4f0765d8cf4b" +dependencies = [ + "execute-command-tokens", + "quote", + "syn", +] + +[[package]] +name = "execute-command-tokens" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69dc321eb6be977f44674620ca3aa21703cb20ffbe560e1ae97da08401ffbcad" + [[package]] name = "fastrand" -version = "2.1.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "ff" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393" dependencies = [ "bitvec", - "rand_core", + "rand_core 0.6.4", "subtle", ] +[[package]] +name = "find-msvc-tools" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fd99930f64d146689264c637b5af2f0233a933bef0d8570e2526bf9e083192d" + [[package]] name = "findshlibs" version = "0.10.2" @@ -729,6 +811,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "flume" +version = "0.10.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1657b4441c3403d9f7b3409e47575237dac27b1b5726df654a6ecbf92f0f7577" +dependencies = [ + "spin 0.9.8", +] + [[package]] name = "fnv" version = "1.0.7" @@ -751,9 +842,9 @@ dependencies = [ [[package]] name = "frost-core" -version = "2.0.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5afd375261c34d31ff24dad068382f4bc3c95010c919d4fb8d483dc3d85c023" +checksum = "2619366c227233c0f817ae01156bd21b8cf74d2bd96cbe0889f4c2e266724e44" dependencies = [ "byteorder", "const-crc32-nostd", @@ -761,28 +852,27 @@ dependencies = [ "derive-getters", "document-features", "hex", - "itertools 0.13.0", + "itertools 0.14.0", "postcard", - "rand_core", + "rand_core 0.6.4", "serde", "serdect", - "thiserror 1.0.60", - "thiserror-nostd-notrait", + "thiserror 2.0.16", "visibility", "zeroize", ] [[package]] name = "frost-rerandomized" -version = "2.0.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a9d77595060546b53543d96b83dbeacaf3907e40a89763a8bb22124812b0cb6" +checksum = "4c5eb1ea58c0250b7ce834337f7b19e0417686d14ffc7f626137dea9149762d4" dependencies = [ "derive-getters", "document-features", "frost-core", "hex", - "rand_core", + "rand_core 0.6.4", ] [[package]] @@ -801,24 +891,51 @@ dependencies = [ "version_check", ] +[[package]] +name = "generic-array" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8c8444bc9d71b935156cc0ccab7f622180808af7867b1daae6547d773591703" +dependencies = [ + "typenum", +] + [[package]] name = "getrandom" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" dependencies = [ "cfg-if", "js-sys", "libc", - "wasi", + "wasi 0.11.1+wasi-snapshot-preview1", "wasm-bindgen", ] +[[package]] +name = "getrandom" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasi 0.14.7+wasi-0.2.4", +] + [[package]] name = "gimli" -version = "0.28.1" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" + +[[package]] +name = "glob" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" [[package]] name = "group" @@ -828,15 +945,17 @@ checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff", "memuse", - "rand_core", + "rand 0.8.5", + "rand_core 0.6.4", + "rand_xorshift 0.3.0", "subtle", ] [[package]] name = "half" -version = "2.4.1" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" +checksum = "459196ed295495a68f7d7fe1d84f6c4b7ff0e21fe3017b2f283c6fac3ad803c9" dependencies = [ "cfg-if", "crunchy", @@ -853,9 +972,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.5" +version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" [[package]] name = "heapless" @@ -867,15 +986,15 @@ dependencies = [ "hash32", "rustc_version", "serde", - "spin", + "spin 0.9.8", "stable_deref_trait", ] [[package]] name = "hermit-abi" -version = "0.3.9" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" [[package]] name = "hex" @@ -903,9 +1022,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "92119844f513ffa41556430369ab02c295a3578af21cf945caa3e9e0c2481ac3" dependencies = [ "equivalent", "hashbrown", @@ -913,9 +1032,9 @@ dependencies = [ [[package]] name = "inferno" -version = "0.11.19" +version = "0.11.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "321f0f839cd44a4686e9504b0a62b4d69a50b62072144c71c68f5873c167b8d9" +checksum = "232929e1d75fe899576a3d5c7416ad0d88dbfbb3c3d6aa00873a7408a50ddb88" dependencies = [ "ahash", "indexmap", @@ -931,22 +1050,22 @@ dependencies = [ [[package]] name = "inout" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" dependencies = [ - "generic-array", + "generic-array 0.14.7", ] [[package]] name = "is-terminal" -version = "0.4.12" +version = "0.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" +checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9" dependencies = [ "hermit-abi", "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -958,15 +1077,6 @@ 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" @@ -978,16 +1088,17 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "js-sys" -version = "0.3.69" +version = "0.3.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +checksum = "0c0b063578492ceec17683ef2f8c5e89121fbd0b172cbc280635ab7567db2738" dependencies = [ + "once_cell", "wasm-bindgen", ] @@ -1001,55 +1112,55 @@ dependencies = [ "bls12_381", "ff", "group", - "rand_core", + "rand_core 0.6.4", "subtle", ] [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.171" +version = "0.2.175" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" +checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543" [[package]] name = "libm" -version = "0.2.8" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" +checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" [[package]] name = "libredox" -version = "0.1.3" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +checksum = "416f7e718bdb06000964960ffa43b4335ad4012ae8b99060261aa4a8088d5ccb" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.9.4", "libc", ] [[package]] name = "linux-raw-sys" -version = "0.4.13" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" [[package]] name = "litrs" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" +checksum = "f5e54036fe321fd421e10d732f155734c4e4afd610dd556d9a82833ab3ee0bed" [[package]] name = "lock_api" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" dependencies = [ "autocfg", "scopeguard", @@ -1057,26 +1168,27 @@ dependencies = [ [[package]] name = "log" -version = "0.4.21" +version = "0.4.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" [[package]] name = "masp_note_encryption" -version = "2.0.0" +version = "3.0.5" dependencies = [ "arbitrary", "borsh", "chacha20", "chacha20poly1305", "cipher", - "rand_core", + "nam-blstrs", + "rand_core 0.6.4", "subtle", ] [[package]] name = "masp_primitives" -version = "2.0.0" +version = "3.0.5" dependencies = [ "aes", "arbitrary", @@ -1097,14 +1209,14 @@ dependencies = [ "lazy_static", "masp_note_encryption", "memuse", - "nam-bls12_381", + "nam-blstrs", "nam-jubjub", "nam-num-traits", "nonempty 0.11.0", "proptest", - "rand", - "rand_core", - "rand_xorshift", + "rand 0.8.5", + "rand_core 0.6.4", + "rand_xorshift 0.3.0", "sha2", "subtle", "zcash_encoding", @@ -1112,97 +1224,151 @@ dependencies = [ [[package]] name = "masp_proofs" -version = "2.0.0" +version = "3.0.5" dependencies = [ - "bellman", "blake2b_simd", "byteorder", "criterion", "directories", - "getrandom", + "ff", + "getrandom 0.2.16", "group", "itertools 0.14.0", "lazy_static", "masp_primitives", "minreq", - "nam-bls12_381", + "nam-bellperson", + "nam-blstrs", "nam-jubjub", "nam-redjubjub", + "pairing", "pprof", - "rand_core", - "rand_xorshift", + "rand_core 0.6.4", + "rand_xorshift 0.3.0", "tracing", ] [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" [[package]] name = "memmap2" -version = "0.9.5" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" +dependencies = [ + "libc", +] + +[[package]] +name = "memmap2" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd3f7eed9d3848f8b98834af67102b720745c4ec028fcd0aa0239277e7de374f" +checksum = "843a98750cd611cc2965a8213b53b43e715f13c37a9e096c6408e69990961db7" dependencies = [ "libc", ] [[package]] name = "memuse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2145869435ace5ea6ea3d35f59be559317ec9a0d04e1812d5f185a87b6d36f1a" +checksum = "3d97bbf43eb4f088f8ca469930cde17fa036207c9a5e02ccc5107c4e8b17c964" [[package]] name = "miniz_oxide" -version = "0.7.2" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" dependencies = [ - "adler", + "adler2", ] [[package]] name = "minreq" -version = "2.11.2" +version = "2.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fdef521c74c2884a4f3570bcdb6d2a77b3c533feb6b27ac2ae72673cc221c64" +checksum = "05015102dad0f7d61691ca347e9d9d9006685a64aefb3d79eecf62665de2153d" dependencies = [ - "log", - "once_cell", "rustls", "rustls-webpki", "webpki-roots", ] [[package]] -name = "nam-bls12_381" -version = "0.8.1-nam.0" +name = "nam-bellperson" +version = "0.26.2-nam.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e768b0e2383163f2f4bbce1112d6454b2cb515950b0a9177733f0d71254d2c68" +checksum = "130c55b8c2814e06aeb0d919e2aaaf8c7ef0a80cd6bdeca2d5d680e1cc382258" +dependencies = [ + "bellpepper-core", + "bincode", + "blake2s_simd", + "byteorder", + "crossbeam-channel", + "digest", + "ec-gpu", + "ec-gpu-gen", + "ff", + "group", + "log", + "memmap2 0.5.10", + "nam-blstrs", + "pairing", + "rand 0.8.5", + "rand_core 0.6.4", + "rayon", + "rustversion", + "serde", + "sha2", + "thiserror 1.0.69", +] + +[[package]] +name = "nam-blst" +version = "0.3.15-nam.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc1632631c6e2ff973612128336180d9002de7137df421633e7c4d7e8a2d6c3d" dependencies = [ "arbitrary", + "cc", + "glob", + "threadpool", + "zeroize", +] + +[[package]] +name = "nam-blstrs" +version = "0.7.1-nam.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9b31595611bdfcbe0880c411d325e6aae7bade26fcdc5dc4cc8aeec54a7db06" +dependencies = [ + "arbitrary", + "byte-slice-cast", "ff", "group", + "nam-blst", "pairing", - "rand_core", + "rand_core 0.6.4", + "serde", "subtle", ] [[package]] name = "nam-jubjub" -version = "0.10.1-nam.0" +version = "1.10.1-nam.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdced0f5975d8f80cb82a84d464481acb7b586d22f447dda86947d6a572997b9" +checksum = "7a23e14862160638c432432025599689ccd1e28c05428d8a437986240c0b89f2" dependencies = [ "arbitrary", "bitvec", "ff", "group", - "nam-bls12_381", - "rand_core", + "nam-blstrs", + "rand_core 0.6.4", "subtle", ] @@ -1228,9 +1394,9 @@ dependencies = [ "hex", "jubjub", "pasta_curves", - "rand_core", + "rand_core 0.6.4", "serde", - "thiserror 2.0.10", + "thiserror 2.0.16", "zeroize", ] @@ -1241,9 +1407,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e457988762db7daad8d79f8a837a07295f5cc178d9236ba77db7339072ffb61e" dependencies = [ "nam-reddsa", - "rand_core", + "rand_core 0.6.4", "serde", - "thiserror 1.0.60", + "thiserror 1.0.69", "zeroize", ] @@ -1272,9 +1438,9 @@ checksum = "549e471b99ccaf2f89101bec68f4d244457d5a95a9c3d0672e9564124397741d" [[package]] name = "num-bigint" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" dependencies = [ "num-integer", "num-traits", @@ -1306,14 +1472,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", - "libm", ] [[package]] name = "num_cpus" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +checksum = "91df4bbde75afed763b708b7eee1e8e7651e02d97f6d5dd763e89367e957b23b" dependencies = [ "hermit-abi", "libc", @@ -1321,24 +1486,24 @@ dependencies = [ [[package]] name = "object" -version = "0.32.2" +version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.19.0" +version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "oorandom" -version = "11.1.3" +version = "11.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" +checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" [[package]] name = "opaque-debug" @@ -1361,29 +1526,6 @@ dependencies = [ "group", ] -[[package]] -name = "parking_lot" -version = "0.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets 0.52.5", -] - [[package]] name = "password-hash" version = "0.5.0" @@ -1391,7 +1533,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "346f04948ba92c43e8469c1ee6736c7563d71012b17d40745260fe106aac2166" dependencies = [ "base64ct", - "rand_core", + "rand_core 0.6.4", "subtle", ] @@ -1403,7 +1545,7 @@ checksum = "d3e57598f73cc7e1b2ac63c79c517b31a0877cd7c402cdcaa311b5208de7a095" dependencies = [ "ff", "group", - "rand", + "rand 0.8.5", "static_assertions", "subtle", ] @@ -1420,15 +1562,15 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.14" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] name = "plotters" -version = "0.3.5" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" +checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747" dependencies = [ "num-traits", "plotters-backend", @@ -1439,15 +1581,15 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.5" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" +checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a" [[package]] name = "plotters-svg" -version = "0.3.5" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" +checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670" dependencies = [ "plotters-backend", ] @@ -1465,9 +1607,9 @@ dependencies = [ [[package]] name = "postcard" -version = "1.1.1" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "170a2601f67cc9dba8edd8c4870b15f71a6a2dc196daec8c83f72b59dff628a8" +checksum = "6764c3b5dd454e283a30e6dfe78e9b31096d9e32036b5d1eaac7a6119ccb9a24" dependencies = [ "cobs", "embedded-io 0.4.0", @@ -1478,9 +1620,9 @@ dependencies = [ [[package]] name = "pprof" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebbe2f8898beba44815fdc9e5a4ae9c929e21c5dc29b0c774a15555f7f58d6d0" +checksum = "afad4d4df7b31280028245f152d5a575083e2abb822d05736f5e47653e77689f" dependencies = [ "aligned-vec", "backtrace", @@ -1492,51 +1634,54 @@ dependencies = [ "log", "nix", "once_cell", - "parking_lot", "smallvec", + "spin 0.10.0", "symbolic-demangle", "tempfile", - "thiserror 1.0.60", + "thiserror 1.0.69", ] [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] [[package]] name = "proc-macro-crate" -version = "3.1.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +checksum = "219cb19e96be00ab2e37d6e299658a0cfa83e52429179969b0f0121b4ac46983" dependencies = [ "toml_edit", ] [[package]] name = "proc-macro2" -version = "1.0.92" +version = "1.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" +checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" dependencies = [ "unicode-ident", ] [[package]] name = "proptest" -version = "1.4.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" +checksum = "6fcdab19deb5195a31cf7726a210015ff1496ba1464fd42cb4f537b8b01b471f" dependencies = [ "bit-set", "bit-vec", - "bitflags 2.5.0", + "bitflags 2.9.4", "lazy_static", "num-traits", - "rand", - "rand_chacha", - "rand_xorshift", + "rand 0.9.2", + "rand_chacha 0.9.0", + "rand_xorshift 0.4.0", "regex-syntax", "rusty-fork", "tempfile", @@ -1560,13 +1705,19 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.36" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + [[package]] name = "radium" version = "0.7.0" @@ -1580,8 +1731,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha", - "rand_core", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.3", ] [[package]] @@ -1591,7 +1752,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.3", ] [[package]] @@ -1600,7 +1771,16 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom", + "getrandom 0.2.16", +] + +[[package]] +name = "rand_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +dependencies = [ + "getrandom 0.3.3", ] [[package]] @@ -1609,14 +1789,23 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" dependencies = [ - "rand_core", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_xorshift" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "513962919efc330f829edb2535844d1b912b0fbe2ca165d613e4e8788bb05a5a" +dependencies = [ + "rand_core 0.9.3", ] [[package]] name = "rayon" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" +checksum = "368f01d005bf8fd9b1206fb6fa653e6c4a81ceb1466406b81792d87c5677a58f" dependencies = [ "either", "rayon-core", @@ -1624,39 +1813,30 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.12.1" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" dependencies = [ "crossbeam-deque", "crossbeam-utils", ] -[[package]] -name = "redox_syscall" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" -dependencies = [ - "bitflags 2.5.0", -] - [[package]] name = "redox_users" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ - "getrandom", + "getrandom 0.2.16", "libredox", - "thiserror 1.0.60", + "thiserror 1.0.69", ] [[package]] name = "regex" -version = "1.10.4" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +checksum = "23d7fd106d8c02486a8d64e778353d1cffe08ce79ac2e82f540c86d0facf6912" dependencies = [ "aho-corasick", "memchr", @@ -1666,9 +1846,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.6" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +checksum = "6b9458fa0bfeeac22b5ca447c63aaf45f28439a709ccd244698632f9aa6394d6" dependencies = [ "aho-corasick", "memchr", @@ -1677,15 +1857,15 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +checksum = "caf4aa5b0f434c91fe5c7f1ecb6a5ece2130b02ad2a590589dda5146df959001" [[package]] name = "rgb" -version = "0.8.37" +version = "0.8.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05aaa8004b64fd573fc9d002f4e632d51ad4f026c2b5ba95fcb6c2f32c2c47d8" +checksum = "0c6a884d2998352bb4daf0183589aec883f16a6da1f4dde84d8e2e9a5409a1ce" dependencies = [ "bytemuck", ] @@ -1698,7 +1878,7 @@ checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" dependencies = [ "cc", "cfg-if", - "getrandom", + "getrandom 0.2.16", "libc", "untrusted", "windows-sys 0.52.0", @@ -1706,9 +1886,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.24" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace" [[package]] name = "rustc_version" @@ -1721,15 +1901,15 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.34" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.9.4", "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.61.0", ] [[package]] @@ -1754,6 +1934,12 @@ dependencies = [ "untrusted", ] +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + [[package]] name = "rusty-fork" version = "0.3.0" @@ -1768,9 +1954,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.18" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "same-file" @@ -1799,24 +1985,34 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.24" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cb6eb87a131f756572d7fb904f6e7b68633f09cca868c5df1c4b8d1a694bbba" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" [[package]] name = "serde" -version = "1.0.202" +version = "1.0.225" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" +checksum = "fd6c24dee235d0da097043389623fb913daddf92c76e9f5a1db88607a0bcbd1d" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.225" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "659356f9a0cb1e529b24c01e43ad2bdf520ec4ceaf83047b83ddcc2251f96383" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.202" +version = "1.0.225" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" +checksum = "0ea936adf78b1f766949a4977b91d2f5595825bd6ec079aa9543ad2685fc4516" dependencies = [ "proc-macro2", "quote", @@ -1825,13 +2021,15 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.145" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" dependencies = [ "itoa", + "memchr", "ryu", "serde", + "serde_core", ] [[package]] @@ -1846,9 +2044,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.8" +version = "0.10.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" dependencies = [ "cfg-if", "cpufeatures", @@ -1863,9 +2061,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "smallvec" -version = "1.13.2" +version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" [[package]] name = "spin" @@ -1876,6 +2074,15 @@ dependencies = [ "lock_api", ] +[[package]] +name = "spin" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5fe4ccb98d9c292d56fec89a5e07da7fc4cf0dc11e156b41793132775d3e591" +dependencies = [ + "lock_api", +] + [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -1896,27 +2103,27 @@ checksum = "9091b6114800a5f2141aee1d1b9d6ca3592ac062dc5decb3764ec5895a47b4eb" [[package]] name = "subtle" -version = "2.4.1" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "symbolic-common" -version = "12.13.1" +version = "12.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf08b42a6f9469bd8584daee39a1352c8133ccabc5151ccccb15896ef047d99a" +checksum = "9da12f8fecbbeaa1ee62c1d50dc656407e007c3ee7b2a41afce4b5089eaef15e" dependencies = [ "debugid", - "memmap2", + "memmap2 0.9.8", "stable_deref_trait", "uuid", ] [[package]] name = "symbolic-demangle" -version = "12.13.1" +version = "12.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32f73b5a5bd4da72720c45756a2d11edf110116b87f998bda59b97be8c2c7cf1" +checksum = "6fd35afe0ef9d35d3dcd41c67ddf882fc832a387221338153b7cd685a105495c" dependencies = [ "cpp_demangle", "rustc-demangle", @@ -1925,9 +2132,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.96" +version = "2.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" +checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" dependencies = [ "proc-macro2", "quote", @@ -1942,39 +2149,40 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.10.1" +version = "3.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +checksum = "84fa4d11fadde498443cca10fd3ac23c951f0dc59e080e9f4b93d4df4e4eea53" dependencies = [ - "cfg-if", "fastrand", + "getrandom 0.3.3", + "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.61.0", ] [[package]] name = "thiserror" -version = "1.0.60" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ - "thiserror-impl 1.0.60", + "thiserror-impl 1.0.69", ] [[package]] name = "thiserror" -version = "2.0.10" +version = "2.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3ac7f54ca534db81081ef1c1e7f6ea8a3ef428d2fc069097c079443d24124d3" +checksum = "3467d614147380f2e4e374161426ff399c91084acd2363eaf549172b3d5e60c0" dependencies = [ - "thiserror-impl 2.0.10", + "thiserror-impl 2.0.16", ] [[package]] name = "thiserror-impl" -version = "1.0.60" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", @@ -1983,9 +2191,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.10" +version = "2.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e9465d30713b56a37ede7185763c3492a91be2f5fa68d958c44e41ab9248beb" +checksum = "6c5e1be1c48b9172ee610da68fd9cd2770e7a4056cb3fc98710ee6906f0c7960" dependencies = [ "proc-macro2", "quote", @@ -1993,23 +2201,12 @@ dependencies = [ ] [[package]] -name = "thiserror-nostd-notrait" -version = "1.0.57" +name = "threadpool" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8444e638022c44d2a9337031dee8acb732bcc7fbf52ac654edc236b26408b61" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" dependencies = [ - "thiserror-nostd-notrait-impl", -] - -[[package]] -name = "thiserror-nostd-notrait-impl" -version = "1.0.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585e5ef40a784ce60b49c67d762110688d211d395d39e096be204535cf64590e" -dependencies = [ - "proc-macro2", - "quote", - "syn", + "num_cpus", ] [[package]] @@ -2024,9 +2221,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.6.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "bfa5fdc3bce6191a1dbc8c02d5c8bffcf557bafa17c124c5264a458f1b0613fa" dependencies = [ "tinyvec_macros", ] @@ -2039,26 +2236,39 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "toml_datetime" -version = "0.6.5" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +checksum = "a197c0ec7d131bfc6f7e82c8442ba1595aeab35da7adbf05b6b73cd06a16b6be" +dependencies = [ + "serde_core", +] [[package]] name = "toml_edit" -version = "0.21.1" +version = "0.23.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +checksum = "c2ad0b7ae9cfeef5605163839cb9221f453399f15cfb5c10be9885fcf56611f9" dependencies = [ "indexmap", "toml_datetime", + "toml_parser", + "winnow", +] + +[[package]] +name = "toml_parser" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b551886f449aa90d4fe2bdaa9f4a2577ad2dde302c61ecf262d80b116db95c10" +dependencies = [ "winnow", ] [[package]] name = "tracing" -version = "0.1.40" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ "pin-project-lite", "tracing-attributes", @@ -2067,9 +2277,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.27" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" dependencies = [ "proc-macro2", "quote", @@ -2078,18 +2288,18 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.32" +version = "0.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" dependencies = [ "once_cell", ] [[package]] name = "typenum" -version = "1.17.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" [[package]] name = "unarray" @@ -2099,15 +2309,15 @@ checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d" [[package]] name = "unicode-normalization" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" dependencies = [ "tinyvec", ] @@ -2130,15 +2340,19 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "uuid" -version = "1.8.0" +version = "1.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" +checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2" +dependencies = [ + "js-sys", + "wasm-bindgen", +] [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "visibility" @@ -2153,9 +2367,9 @@ dependencies = [ [[package]] name = "wait-timeout" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +checksum = "09ac3b126d3914f9849036f826e054cbabdc8519970b8998ddaf3b5bd3c65f11" dependencies = [ "libc", ] @@ -2172,29 +2386,49 @@ dependencies = [ [[package]] name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasi" +version = "0.14.7+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "883478de20367e224c0090af9cf5f9fa85bed63a95c1abf3afc5c083ebc06e8c" +dependencies = [ + "wasip2", +] + +[[package]] +name = "wasip2" +version = "1.0.1+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" +dependencies = [ + "wit-bindgen", +] [[package]] name = "wasm-bindgen" -version = "0.2.92" +version = "0.2.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +checksum = "7e14915cadd45b529bb8d1f343c4ed0ac1de926144b746e2710f9cd05df6603b" dependencies = [ "cfg-if", + "once_cell", + "rustversion", "wasm-bindgen-macro", + "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.92" +version = "0.2.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +checksum = "e28d1ba982ca7923fd01448d5c30c6864d0a14109560296a162f80f305fb93bb" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", "syn", @@ -2203,9 +2437,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.92" +version = "0.2.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +checksum = "7c3d463ae3eff775b0c45df9da45d68837702ac35af998361e2c84e7c5ec1b0d" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2213,9 +2447,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.92" +version = "0.2.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +checksum = "7bb4ce89b08211f923caf51d527662b75bdc9c9c7aab40f86dcb9fb85ac552aa" dependencies = [ "proc-macro2", "quote", @@ -2226,15 +2460,18 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.92" +version = "0.2.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +checksum = "f143854a3b13752c6950862c906306adb27c7e839f7414cec8fea35beab624c1" +dependencies = [ + "unicode-ident", +] [[package]] name = "web-sys" -version = "0.3.69" +version = "0.3.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +checksum = "77e4b637749ff0d92b8fad63aa1f7cff3cbe125fd49c175cd6345e7272638b12" dependencies = [ "js-sys", "wasm-bindgen", @@ -2264,11 +2501,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.8" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.61.0", ] [[package]] @@ -2277,6 +2514,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-link" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45e46c0661abb7180e7b9c281db115305d49ca1709ab8242adf09666d2173c65" + [[package]] name = "windows-sys" version = "0.48.0" @@ -2292,7 +2535,25 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.61.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e201184e40b2ede64bc2ea34968b28e33622acdbbf37104f0e4a33f7abe657aa" +dependencies = [ + "windows-link", ] [[package]] @@ -2312,18 +2573,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", - "windows_x86_64_msvc 0.52.5", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -2334,9 +2595,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -2346,9 +2607,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -2358,15 +2619,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -2376,9 +2637,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -2388,9 +2649,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -2400,9 +2661,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -2412,19 +2673,25 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.5.40" +version = "0.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf" dependencies = [ "memchr", ] +[[package]] +name = "wit-bindgen" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" + [[package]] name = "wyz" version = "0.5.1" @@ -2434,6 +2701,16 @@ dependencies = [ "tap", ] +[[package]] +name = "yastl" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ca6c5a4d66c1a9ea261811cf4773c27343de7e5033e1b75ea3f297dc7db3c1a" +dependencies = [ + "flume", + "scopeguard", +] + [[package]] name = "zcash_encoding" version = "0.2.2" @@ -2446,18 +2723,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.34" +version = "0.8.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" +checksum = "0894878a5fa3edfd6da3f88c4805f4c8558e2b996227a3d864f47fe11e38282c" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.34" +version = "0.8.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" +checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" dependencies = [ "proc-macro2", "quote", @@ -2466,9 +2743,9 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.7.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" dependencies = [ "zeroize_derive", ] diff --git a/Cargo.toml b/Cargo.toml index 3a971606..61d4d678 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ members = [ [workspace.package] -version = "2.0.0" +version = "3.0.5" [profile.release] lto = true diff --git a/masp_note_encryption/Cargo.toml b/masp_note_encryption/Cargo.toml index b6c5af3a..763a2205 100644 --- a/masp_note_encryption/Cargo.toml +++ b/masp_note_encryption/Cargo.toml @@ -19,6 +19,7 @@ all-features = true rustdoc-args = ["--cfg", "docsrs"] [dependencies] +bls12_381 = {package = "nam-blstrs", version = "0.7.1-nam.0" } cipher = { version = "0.4", default-features = false } chacha20 = { version = "0.9", default-features = false } chacha20poly1305 = { version = "0.10", default-features = false } diff --git a/masp_note_encryption/src/lib.rs b/masp_note_encryption/src/lib.rs index 71079387..b90d72a5 100644 --- a/masp_note_encryption/src/lib.rs +++ b/masp_note_encryption/src/lib.rs @@ -122,6 +122,9 @@ enum NoteValidity { Invalid, } +pub type ExtractedCommitment = bls12_381::Scalar; +pub type ExtractedCommitmentBytes = [u8; 32]; + /// Trait that encapsulates protocol-specific note encryption types and logic. /// /// This trait enables most of the note encryption logic to be shared between Sapling and @@ -138,8 +141,6 @@ pub trait Domain { type IncomingViewingKey; type OutgoingViewingKey; type ValueCommitment; - type ExtractedCommitment; - type ExtractedCommitmentBytes: Eq + for<'a> From<&'a Self::ExtractedCommitment>; type Memo; /// Derives the `EphemeralSecretKey` corresponding to this note. @@ -209,7 +210,7 @@ pub trait Domain { fn derive_ock( ovk: &Self::OutgoingViewingKey, cv: &Self::ValueCommitment, - cmstar_bytes: &Self::ExtractedCommitmentBytes, + cmstar_bytes: &ExtractedCommitmentBytes, ephemeral_key: &EphemeralKeyBytes, ) -> OutgoingCipherKey; @@ -229,7 +230,7 @@ pub trait Domain { fn epk(ephemeral_key: &EphemeralKeyBytes) -> Option; /// Derives the `ExtractedCommitment` for this note. - fn cmstar(note: &Self::Note) -> Self::ExtractedCommitment; + fn cmstar(note: &Self::Note) -> ExtractedCommitment; /// Parses the given note plaintext from the recipient's perspective. /// @@ -349,7 +350,7 @@ pub trait ShieldedOutput { fn ephemeral_key(&self) -> EphemeralKeyBytes; /// Exposes the `cmu_bytes` or `cmx_bytes` field of the output. - fn cmstar_bytes(&self) -> D::ExtractedCommitmentBytes; + fn cmstar_bytes(&self) -> ExtractedCommitmentBytes; /// Exposes the note ciphertext of the output. fn enc_ciphertext(&self) -> &[u8; CIPHERTEXT_SIZE]; @@ -450,11 +451,11 @@ impl NoteEncryption { pub fn encrypt_outgoing_plaintext( &self, cv: &D::ValueCommitment, - cmstar: &D::ExtractedCommitment, + cmstar: &ExtractedCommitment, rng: &mut R, ) -> [u8; OUT_CIPHERTEXT_SIZE] { let (ock, input) = if let Some(ovk) = &self.ovk { - let ock = D::derive_ock(ovk, cv, &cmstar.into(), &D::epk_bytes(&self.epk)); + let ock = D::derive_ock(ovk, cv, &cmstar.to_bytes_le(), &D::epk_bytes(&self.epk)); let input = D::outgoing_plaintext_bytes(&self.note, &self.esk); (ock, input) @@ -539,7 +540,7 @@ fn parse_note_plaintext_without_memo_ivk( domain: &D, ivk: &D::IncomingViewingKey, ephemeral_key: &EphemeralKeyBytes, - cmstar_bytes: &D::ExtractedCommitmentBytes, + cmstar_bytes: &ExtractedCommitmentBytes, plaintext: &[u8], ) -> Option<(D::Note, D::Recipient)> { let (note, to) = domain.parse_note_plaintext_without_memo_ivk(ivk, plaintext)?; @@ -554,9 +555,9 @@ fn parse_note_plaintext_without_memo_ivk( fn check_note_validity( note: &D::Note, ephemeral_key: &EphemeralKeyBytes, - cmstar_bytes: &D::ExtractedCommitmentBytes, + cmstar_bytes: &ExtractedCommitmentBytes, ) -> NoteValidity { - if &D::ExtractedCommitmentBytes::from(&D::cmstar(note)) == cmstar_bytes { + if &D::cmstar(note).to_bytes_le() == cmstar_bytes { if let Some(derived_esk) = D::derive_esk(note) { if D::epk_bytes(&D::ka_derive_public(note, &derived_esk)) .ct_eq(ephemeral_key) diff --git a/masp_primitives/Cargo.toml b/masp_primitives/Cargo.toml index 512e1708..b6b35488 100644 --- a/masp_primitives/Cargo.toml +++ b/masp_primitives/Cargo.toml @@ -43,11 +43,11 @@ num-traits = { package = "nam-num-traits", version = "0.2.20-nam.0" } subtle = "2.2.3" # - Shielded protocols -bls12_381 = { package = "nam-bls12_381", version = "0.8.1-nam.0" } +bls12_381 = {package = "nam-blstrs", version = "0.7.1-nam.0" } ff = "0.13" group = { version = "0.13", features = ["wnaf-memuse"] } incrementalmerkletree = { version = "0.8.2", features = ["legacy-api"] } -jubjub = { package = "nam-jubjub", version = "0.10.1-nam.0" } +jubjub = { package = "nam-jubjub", version = "1.10.1-nam.1" } nonempty = "0.11" # - Static constants @@ -77,7 +77,7 @@ borsh = {version = "1.2.0", features = ["unstable__schema", "derive"]} arbitrary = {version = "1.3", features = ["derive"], optional = true } [dependencies.masp_note_encryption] -version = "2.0.0" +version = "3.0.5" path = "../masp_note_encryption" features = ["pre-zip-212"] @@ -92,7 +92,7 @@ rand_xorshift = "0.3" transparent-inputs = [] test-dependencies = ["proptest"] default = ["transparent-inputs"] -arbitrary = ["dep:arbitrary", "masp_note_encryption/arbitrary", "bls12_381/arbitrary", "jubjub/arbitrary"] +arbitrary = ["dep:arbitrary", "masp_note_encryption/arbitrary", "jubjub/arbitrary", "bls12_381/arbitrary"] [badges] maintenance = { status = "actively-developed" } diff --git a/masp_primitives/src/constants.rs b/masp_primitives/src/constants.rs index 36ecf1a7..ba3128df 100644 --- a/masp_primitives/src/constants.rs +++ b/masp_primitives/src/constants.rs @@ -47,174 +47,208 @@ pub const ASSET_IDENTIFIER_PERSONALIZATION: &[u8; 8] = b"MASP__t_"; /// The prover will demonstrate knowledge of discrete log with respect to this base when /// they are constructing a proof, in order to authorize proof construction. -pub const PROOF_GENERATION_KEY_GENERATOR: SubgroupPoint = SubgroupPoint::from_raw_unchecked( - bls12_381::Scalar::from_raw([ - 0x5f3c_723a_a253_1b66, - 0x1e24_f832_67f1_5abd, - 0x4ba1_f065_e719_fd03, - 0x4caa_eaca_af28_ed4b, - ]), - bls12_381::Scalar::from_raw([ - 0xfe6f_96be_c575_bff8, - 0x36b4_9c71_a2af_0708, - 0xc654_dfdd_3600_4de9, - 0x0093_0d67_d690_6365, - ]), -); +pub fn proof_generation_key_generator() -> SubgroupPoint { + SubgroupPoint::from_raw_unchecked( + bls12_381::Scalar::from_u64s_le(&[ + 0x5f3c_723a_a253_1b66, + 0x1e24_f832_67f1_5abd, + 0x4ba1_f065_e719_fd03, + 0x4caa_eaca_af28_ed4b, + ]) + .unwrap(), + bls12_381::Scalar::from_u64s_le(&[ + 0xfe6f_96be_c575_bff8, + 0x36b4_9c71_a2af_0708, + 0xc654_dfdd_3600_4de9, + 0x0093_0d67_d690_6365, + ]) + .unwrap(), + ) +} /// The note commitment is randomized over this generator. -pub const NOTE_COMMITMENT_RANDOMNESS_GENERATOR: SubgroupPoint = SubgroupPoint::from_raw_unchecked( - bls12_381::Scalar::from_raw([ - 0xfc033fa2bf88cb2e, - 0xcd80edf5fe44c7bf, - 0xc6de7556abb84082, - 0x434c9be15267b091, - ]), - bls12_381::Scalar::from_raw([ - 0xc6b8daa0ee22aeed, - 0x690b295c66b85c64, - 0x6d277197e97af8f0, - 0x29e2926993d3bc73, - ]), -); +pub fn note_commitment_randomness_generator() -> SubgroupPoint { + SubgroupPoint::from_raw_unchecked( + bls12_381::Scalar::from_u64s_le(&[ + 0xfc033fa2bf88cb2e, + 0xcd80edf5fe44c7bf, + 0xc6de7556abb84082, + 0x434c9be15267b091, + ]) + .unwrap(), + bls12_381::Scalar::from_u64s_le(&[ + 0xc6b8daa0ee22aeed, + 0x690b295c66b85c64, + 0x6d277197e97af8f0, + 0x29e2926993d3bc73, + ]) + .unwrap(), + ) +} /// The node commitment is randomized again by the position in order to supply the /// nullifier computation with a unique input w.r.t. the note being spent, to prevent /// Faerie gold attacks. -pub const NULLIFIER_POSITION_GENERATOR: SubgroupPoint = SubgroupPoint::from_raw_unchecked( - bls12_381::Scalar::from_raw([ - 0xaafee844265fc1e7, - 0x1e09674f28a4b844, - 0x84678dc2d85293df, - 0x50de6d98fee5282f, - ]), - bls12_381::Scalar::from_raw([ - 0xed034e3ee13a1eb3, - 0x226945aee96dfe0a, - 0xf3f70dc31afe799d, - 0x03260f0bf1244050, - ]), -); +pub fn nullifier_position_generator() -> SubgroupPoint { + SubgroupPoint::from_raw_unchecked( + bls12_381::Scalar::from_u64s_le(&[ + 0xaafee844265fc1e7, + 0x1e09674f28a4b844, + 0x84678dc2d85293df, + 0x50de6d98fee5282f, + ]) + .unwrap(), + bls12_381::Scalar::from_u64s_le(&[ + 0xed034e3ee13a1eb3, + 0x226945aee96dfe0a, + 0xf3f70dc31afe799d, + 0x03260f0bf1244050, + ]) + .unwrap(), + ) +} /// The value commitment is randomized over this generator, for privacy. -pub const VALUE_COMMITMENT_RANDOMNESS_GENERATOR: SubgroupPoint = SubgroupPoint::from_raw_unchecked( - bls12_381::Scalar::from_raw([ - 0xdd93d364cb8cec7e, - 0x91cc3e3835675450, - 0xcfa86026b8d99be9, - 0x1c6da0ce9a5e5fdb, - ]), - bls12_381::Scalar::from_raw([ - 0x28e5fce99ce692d0, - 0xf94c2daa360302fe, - 0xbc900cd4b8ae1150, - 0x555f11f9b720d50b, - ]), -); +pub fn value_commitment_randomness_generator() -> SubgroupPoint { + SubgroupPoint::from_raw_unchecked( + bls12_381::Scalar::from_u64s_le(&[ + 0xdd93d364cb8cec7e, + 0x91cc3e3835675450, + 0xcfa86026b8d99be9, + 0x1c6da0ce9a5e5fdb, + ]) + .unwrap(), + bls12_381::Scalar::from_u64s_le(&[ + 0x28e5fce99ce692d0, + 0xf94c2daa360302fe, + 0xbc900cd4b8ae1150, + 0x555f11f9b720d50b, + ]) + .unwrap(), + ) +} /// The spender proves discrete log with respect to this base at spend time. -pub const SPENDING_KEY_GENERATOR: SubgroupPoint = SubgroupPoint::from_raw_unchecked( - bls12_381::Scalar::from_raw([ - 0xec75293d81248452, - 0x39f5b03380af6020, - 0xf831c2b19fec6026, - 0x5b389522a9e81532, - ]), - bls12_381::Scalar::from_raw([ - 0x14b62623a186b4b1, - 0x2012d031f624fd52, - 0x75defecff1f49ef2, - 0x0cbc5f9f1e52e0ab, - ]), -); +pub fn spending_key_generator() -> SubgroupPoint { + SubgroupPoint::from_raw_unchecked( + bls12_381::Scalar::from_u64s_le(&[ + 0xec75293d81248452, + 0x39f5b03380af6020, + 0xf831c2b19fec6026, + 0x5b389522a9e81532, + ]) + .unwrap(), + bls12_381::Scalar::from_u64s_le(&[ + 0x14b62623a186b4b1, + 0x2012d031f624fd52, + 0x75defecff1f49ef2, + 0x0cbc5f9f1e52e0ab, + ]) + .unwrap(), + ) +} /// The generators (for each segment) used in all Pedersen commitments. -pub const PEDERSEN_HASH_GENERATORS: &[SubgroupPoint] = &[ - SubgroupPoint::from_raw_unchecked( - bls12_381::Scalar::from_raw([ - 0x1010503570c3ebf6, - 0x5c22a82a281c9181, - 0x98ba470b0d28801b, - 0x113de62be6e0d323, - ]), - bls12_381::Scalar::from_raw([ - 0xf031edff274efb14, - 0x2ba3032d7064d633, - 0x15cea14bc9f6b04b, - 0x5059678472abb6ae, - ]), - ), - SubgroupPoint::from_raw_unchecked( - bls12_381::Scalar::from_raw([ - 0xb9efa2cb80331936, - 0x0a0df10182a290fd, - 0xfc7cbea3c311f67f, - 0x08c02a4c57f7f2cf, - ]), - bls12_381::Scalar::from_raw([ - 0xdaf19ac3ab182662, - 0xec376560c925452d, - 0x4dc07857131f22a0, - 0x2e560a50271fd3fc, - ]), - ), - SubgroupPoint::from_raw_unchecked( - bls12_381::Scalar::from_raw([ - 0xc93573b98709291e, - 0xdf0694e57c6cbc03, - 0x413bc3c44e7aabe0, - 0x210f22d61b65767d, - ]), - bls12_381::Scalar::from_raw([ - 0x4781e2656b1ddaad, - 0xc6262ed423179659, - 0xfb33884c42727482, - 0x3f46b3371cff7474, - ]), - ), - SubgroupPoint::from_raw_unchecked( - bls12_381::Scalar::from_raw([ - 0xcf0bc7224a63d094, - 0x2bcc52dbba0ebf3a, - 0xa02f0d3f7aad771d, - 0x274e99b16d4af911, - ]), - bls12_381::Scalar::from_raw([ - 0xe82e9061620a1df4, - 0xfd0153cfe15ec653, - 0x6b15ec6e59478694, - 0x31f5e34f0804a874, - ]), - ), - SubgroupPoint::from_raw_unchecked( - bls12_381::Scalar::from_raw([ - 0xc64e25ca51961b53, - 0x7058160b9afaafaf, - 0x50aa77ad2f57d2f7, - 0x3ca8b98873e5d19e, - ]), - bls12_381::Scalar::from_raw([ - 0x9dab539b32327842, - 0x5eb152c4606beb7e, - 0x238af7c9376608d6, - 0x10609ce821a5a292, - ]), - ), - SubgroupPoint::from_raw_unchecked( - bls12_381::Scalar::from_raw([ - 0xf0ef2a816469118e, - 0x5bdd5c30d83781f0, - 0xdb3ff866eaf1bc85, - 0x1ab3fe2ac6b3ff8a, - ]), - bls12_381::Scalar::from_raw([ - 0xe7c079b4e48233f5, - 0xa6b5863148627619, - 0xd5681f2f5c740d19, - 0x2031e442c4af8277, - ]), - ), -]; +pub fn pedersen_hash_generators() -> [SubgroupPoint; 6] { + [ + SubgroupPoint::from_raw_unchecked( + bls12_381::Scalar::from_u64s_le(&[ + 0x1010503570c3ebf6, + 0x5c22a82a281c9181, + 0x98ba470b0d28801b, + 0x113de62be6e0d323, + ]) + .unwrap(), + bls12_381::Scalar::from_u64s_le(&[ + 0xf031edff274efb14, + 0x2ba3032d7064d633, + 0x15cea14bc9f6b04b, + 0x5059678472abb6ae, + ]) + .unwrap(), + ), + SubgroupPoint::from_raw_unchecked( + bls12_381::Scalar::from_u64s_le(&[ + 0xb9efa2cb80331936, + 0x0a0df10182a290fd, + 0xfc7cbea3c311f67f, + 0x08c02a4c57f7f2cf, + ]) + .unwrap(), + bls12_381::Scalar::from_u64s_le(&[ + 0xdaf19ac3ab182662, + 0xec376560c925452d, + 0x4dc07857131f22a0, + 0x2e560a50271fd3fc, + ]) + .unwrap(), + ), + SubgroupPoint::from_raw_unchecked( + bls12_381::Scalar::from_u64s_le(&[ + 0xc93573b98709291e, + 0xdf0694e57c6cbc03, + 0x413bc3c44e7aabe0, + 0x210f22d61b65767d, + ]) + .unwrap(), + bls12_381::Scalar::from_u64s_le(&[ + 0x4781e2656b1ddaad, + 0xc6262ed423179659, + 0xfb33884c42727482, + 0x3f46b3371cff7474, + ]) + .unwrap(), + ), + SubgroupPoint::from_raw_unchecked( + bls12_381::Scalar::from_u64s_le(&[ + 0xcf0bc7224a63d094, + 0x2bcc52dbba0ebf3a, + 0xa02f0d3f7aad771d, + 0x274e99b16d4af911, + ]) + .unwrap(), + bls12_381::Scalar::from_u64s_le(&[ + 0xe82e9061620a1df4, + 0xfd0153cfe15ec653, + 0x6b15ec6e59478694, + 0x31f5e34f0804a874, + ]) + .unwrap(), + ), + SubgroupPoint::from_raw_unchecked( + bls12_381::Scalar::from_u64s_le(&[ + 0xc64e25ca51961b53, + 0x7058160b9afaafaf, + 0x50aa77ad2f57d2f7, + 0x3ca8b98873e5d19e, + ]) + .unwrap(), + bls12_381::Scalar::from_u64s_le(&[ + 0x9dab539b32327842, + 0x5eb152c4606beb7e, + 0x238af7c9376608d6, + 0x10609ce821a5a292, + ]) + .unwrap(), + ), + SubgroupPoint::from_raw_unchecked( + bls12_381::Scalar::from_u64s_le(&[ + 0xf0ef2a816469118e, + 0x5bdd5c30d83781f0, + 0xdb3ff866eaf1bc85, + 0x1ab3fe2ac6b3ff8a, + ]) + .unwrap(), + bls12_381::Scalar::from_u64s_le(&[ + 0xe7c079b4e48233f5, + 0xa6b5863148627619, + 0xd5681f2f5c740d19, + 0x2031e442c4af8277, + ]) + .unwrap(), + ), + ] +} /// The maximum number of chunks per segment of the Pedersen hash. pub const PEDERSEN_HASH_CHUNKS_PER_GENERATOR: usize = 63; @@ -232,7 +266,7 @@ lazy_static! { fn generate_pedersen_hash_exp_table() -> Vec>> { let window = PEDERSEN_HASH_EXP_WINDOW_SIZE; - PEDERSEN_HASH_GENERATORS + pedersen_hash_generators() .iter() .cloned() .map(|mut g| { @@ -287,48 +321,48 @@ mod tests { } #[test] - fn proof_generation_key_base_generator() { + fn test_proof_generation_key_base_generator() { assert_eq!( find_group_hash(&[], PROOF_GENERATION_KEY_BASE_GENERATOR_PERSONALIZATION), - PROOF_GENERATION_KEY_GENERATOR, + proof_generation_key_generator(), ); } #[test] - fn note_commitment_randomness_generator() { + fn test_note_commitment_randomness_generator() { assert_eq!( find_group_hash(b"r", PEDERSEN_HASH_GENERATORS_PERSONALIZATION), - NOTE_COMMITMENT_RANDOMNESS_GENERATOR, + note_commitment_randomness_generator(), ); } #[test] - fn nullifier_position_generator() { + fn test_nullifier_position_generator() { assert_eq!( find_group_hash(&[], NULLIFIER_POSITION_IN_TREE_GENERATOR_PERSONALIZATION), - NULLIFIER_POSITION_GENERATOR, + nullifier_position_generator(), ); } #[test] - fn value_commitment_randomness_generator() { + fn test_value_commitment_randomness_generator() { assert_eq!( find_group_hash(b"r", VALUE_COMMITMENT_RANDOMNESS_PERSONALIZATION), - VALUE_COMMITMENT_RANDOMNESS_GENERATOR, + value_commitment_randomness_generator(), ); } #[test] - fn spending_key_generator() { + fn test_spending_key_generator() { assert_eq!( find_group_hash(&[], SPENDING_KEY_GENERATOR_PERSONALIZATION), - SPENDING_KEY_GENERATOR, + spending_key_generator(), ); } #[test] - fn pedersen_hash_generators() { - for (m, actual) in PEDERSEN_HASH_GENERATORS.iter().enumerate() { + fn test_pedersen_hash_generators() { + for (m, actual) in pedersen_hash_generators().iter().enumerate() { assert_eq!( &find_group_hash( &(m as u32).to_le_bytes(), @@ -342,11 +376,11 @@ mod tests { #[test] fn no_duplicate_fixed_base_generators() { let fixed_base_generators = [ - PROOF_GENERATION_KEY_GENERATOR, - NOTE_COMMITMENT_RANDOMNESS_GENERATOR, - NULLIFIER_POSITION_GENERATOR, - VALUE_COMMITMENT_RANDOMNESS_GENERATOR, - SPENDING_KEY_GENERATOR, + proof_generation_key_generator(), + note_commitment_randomness_generator(), + nullifier_position_generator(), + value_commitment_randomness_generator(), + spending_key_generator(), ]; // Check for duplicates, far worse than spec inconsistencies! @@ -401,17 +435,17 @@ mod tests { #[test] fn pedersen_hash_generators_consistency() { - check_consistency_of_pedersen_hash_generators(PEDERSEN_HASH_GENERATORS); + check_consistency_of_pedersen_hash_generators(&pedersen_hash_generators()); } #[test] #[should_panic(expected = "Linear relation between generators!")] fn test_jubjub_bls12_pedersen_hash_generators_consistency_check_linear_relation() { - let mut pedersen_hash_generators = PEDERSEN_HASH_GENERATORS.to_vec(); + let mut pedersen_hash_gens = pedersen_hash_generators().to_vec(); // Test for linear relation - pedersen_hash_generators.push(PEDERSEN_HASH_GENERATORS[0] + PEDERSEN_HASH_GENERATORS[1]); + pedersen_hash_gens.push(pedersen_hash_generators()[0] + pedersen_hash_generators()[1]); - check_consistency_of_pedersen_hash_generators(&pedersen_hash_generators); + check_consistency_of_pedersen_hash_generators(&pedersen_hash_gens); } } diff --git a/masp_primitives/src/convert.rs b/masp_primitives/src/convert.rs index 123be812..7d139f9a 100644 --- a/masp_primitives/src/convert.rs +++ b/masp_primitives/src/convert.rs @@ -11,6 +11,7 @@ use borsh::schema::Definition; use borsh::schema::Fields; use borsh::schema::add_definition; use borsh::{BorshDeserialize, BorshSerialize}; +use ff::Field; use group::{Curve, GroupEncoding}; use std::collections::BTreeMap; use std::{ @@ -31,7 +32,7 @@ impl AllowedConversion { pub fn uncommitted() -> bls12_381::Scalar { // The smallest u-coordinate that is not on the curve // is one. - bls12_381::Scalar::one() + bls12_381::Scalar::ONE } /// Computes the note commitment, returning the full point. diff --git a/masp_primitives/src/sapling.rs b/masp_primitives/src/sapling.rs index 279cd99b..c4c4ef90 100644 --- a/masp_primitives/src/sapling.rs +++ b/masp_primitives/src/sapling.rs @@ -30,7 +30,7 @@ use subtle::{Choice, ConstantTimeEq, CtOption}; use crate::{ asset_type::AssetType, - constants::{self, SPENDING_KEY_GENERATOR}, + constants::{self, spending_key_generator}, keys::prf_expand, merkle_tree::{HashSer, Hashable}, transaction::components::amount::MAX_MONEY, @@ -183,7 +183,7 @@ pub(crate) fn spend_sig_internal( let rsk = ask.randomize(ar); // We compute `rk` from there (needed for key prefixing) - let rk = PublicKey::from_private(&rsk, SPENDING_KEY_GENERATOR); + let rk = PublicKey::from_private(&rsk, spending_key_generator()); // Compute the signature's message for rk/spend_auth_sig let mut data_to_be_signed = [0u8; 64]; @@ -191,7 +191,7 @@ pub(crate) fn spend_sig_internal( data_to_be_signed[32..64].copy_from_slice(&sighash[..]); // Do the signing - rsk.sign(&data_to_be_signed, rng, SPENDING_KEY_GENERATOR) + rsk.sign(&data_to_be_signed, rng, spending_key_generator()) } #[derive(Clone)] @@ -204,7 +204,7 @@ pub struct ValueCommitment { impl ValueCommitment { pub fn commitment(&self) -> jubjub::SubgroupPoint { (CofactorGroup::clear_cofactor(&self.asset_generator) * jubjub::Fr::from(self.value)) - + (constants::VALUE_COMMITMENT_RANDOMNESS_GENERATOR * self.randomness) + + (constants::value_commitment_randomness_generator() * self.randomness) } } @@ -218,7 +218,7 @@ impl ProofGenerationKey { pub fn to_viewing_key(&self) -> ViewingKey { ViewingKey { ak: self.ak, - nk: NullifierDerivingKey(constants::PROOF_GENERATION_KEY_GENERATOR * self.nsk), + nk: NullifierDerivingKey(constants::proof_generation_key_generator() * self.nsk), } } } @@ -332,7 +332,7 @@ impl Hash for ViewingKey { impl ViewingKey { pub fn rk(&self, ar: jubjub::Fr) -> jubjub::SubgroupPoint { - self.ak + constants::SPENDING_KEY_GENERATOR * ar + self.ak + constants::spending_key_generator() * ar } pub fn ivk(&self) -> SaplingIvk { @@ -789,7 +789,7 @@ impl Note { pub fn uncommitted() -> bls12_381::Scalar { // The smallest u-coordinate that is not on the curve // is one. - bls12_381::Scalar::one() + bls12_381::Scalar::ONE } /// Computes the note commitment, returning the full point. @@ -820,7 +820,7 @@ impl Note { ); // Compute final commitment - (constants::NOTE_COMMITMENT_RANDOMNESS_GENERATOR * self.rcm()) + hash_of_contents + (constants::note_commitment_randomness_generator() * self.rcm()) + hash_of_contents } /// Computes the nullifier given the nullifier deriving key and @@ -828,7 +828,7 @@ impl Note { pub fn nf(&self, nk: &NullifierDerivingKey, position: u64) -> Nullifier { // Compute rho = cm + position.G let rho = self.cm_full_point() - + (constants::NULLIFIER_POSITION_GENERATOR * jubjub::Fr::from(position)); + + (constants::nullifier_position_generator() * jubjub::Fr::from(position)); // Compute nf = BLAKE2s(nk | rho) Nullifier::from_slice( diff --git a/masp_primitives/src/sapling/keys.rs b/masp_primitives/src/sapling/keys.rs index 06352c58..ff18f4e3 100644 --- a/masp_primitives/src/sapling/keys.rs +++ b/masp_primitives/src/sapling/keys.rs @@ -5,7 +5,7 @@ //! [section 4.2.2]: https://zips.z.cash/protocol/protocol.pdf#saplingkeycomponents use crate::{ - constants::{PROOF_GENERATION_KEY_GENERATOR, SPENDING_KEY_GENERATOR}, + constants::{proof_generation_key_generator, spending_key_generator}, keys::prf_expand, }; use borsh::BorshSchema; @@ -73,7 +73,7 @@ impl ExpandedSpendingKey { pub fn proof_generation_key(&self) -> ProofGenerationKey { ProofGenerationKey { - ak: SPENDING_KEY_GENERATOR * self.ask, + ak: spending_key_generator() * self.ask, nsk: self.nsk, } } @@ -161,8 +161,8 @@ impl FullViewingKey { pub fn from_expanded_spending_key(expsk: &ExpandedSpendingKey) -> Self { FullViewingKey { vk: ViewingKey { - ak: SPENDING_KEY_GENERATOR * expsk.ask, - nk: NullifierDerivingKey(PROOF_GENERATION_KEY_GENERATOR * expsk.nsk), + ak: spending_key_generator() * expsk.ask, + nk: NullifierDerivingKey(proof_generation_key_generator() * expsk.nsk), }, ovk: expsk.ovk, } @@ -292,7 +292,7 @@ mod tests { use group::{Group, GroupEncoding}; use super::FullViewingKey; - use crate::constants::SPENDING_KEY_GENERATOR; + use crate::constants::spending_key_generator; #[test] fn ak_must_be_prime_order() { @@ -310,7 +310,7 @@ mod tests { ); // Set ak to a basepoint. - let basepoint = SPENDING_KEY_GENERATOR; + let basepoint = spending_key_generator(); buf[0..32].copy_from_slice(&basepoint.to_bytes()); // nk is allowed to be the identity. diff --git a/masp_primitives/src/sapling/note_encryption.rs b/masp_primitives/src/sapling/note_encryption.rs index 704c02b0..164e1dbe 100644 --- a/masp_primitives/src/sapling/note_encryption.rs +++ b/masp_primitives/src/sapling/note_encryption.rs @@ -1,20 +1,21 @@ //! Implementation of in-band secret distribution for MASP transactions. +use std::convert::TryInto; + use blake2b_simd::{Hash as Blake2bHash, Params as Blake2bParams}; use byteorder::{LittleEndian, WriteBytesExt}; use ff::PrimeField; use group::{GroupEncoding, WnafBase, WnafScalar, cofactor::CofactorGroup}; use jubjub::{AffinePoint, ExtendedPoint}; -use memuse::DynamicUsage; -use std::convert::TryInto; - -use crate::asset_type::AssetType; use masp_note_encryption::{ BatchDomain, COMPACT_NOTE_SIZE, Domain, ENC_CIPHERTEXT_SIZE, EphemeralKeyBytes, - NOTE_PLAINTEXT_SIZE, NoteEncryption, NotePlaintextBytes, OUT_PLAINTEXT_SIZE, OutPlaintextBytes, - OutgoingCipherKey, ShieldedOutput, try_compact_note_decryption, try_note_decryption, - try_output_recovery_with_ock, try_output_recovery_with_ovk, + ExtractedCommitment, ExtractedCommitmentBytes, NOTE_PLAINTEXT_SIZE, NoteEncryption, + NotePlaintextBytes, OUT_PLAINTEXT_SIZE, OutPlaintextBytes, OutgoingCipherKey, ShieldedOutput, + try_compact_note_decryption, try_note_decryption, try_output_recovery_with_ock, + try_output_recovery_with_ovk, }; +use memuse::DynamicUsage; +use crate::asset_type::AssetType; use crate::{ consensus::{self, BlockHeight, NetworkUpgrade::MASP}, memo::MemoBytes, @@ -188,8 +189,6 @@ impl Domain for SaplingDomain

{ type IncomingViewingKey = PreparedIncomingViewingKey; type OutgoingViewingKey = OutgoingViewingKey; type ValueCommitment = jubjub::ExtendedPoint; - type ExtractedCommitment = bls12_381::Scalar; - type ExtractedCommitmentBytes = [u8; 32]; type Memo = MemoBytes; fn derive_esk(note: &Self::Note) -> Option { @@ -272,7 +271,7 @@ impl Domain for SaplingDomain

{ fn derive_ock( ovk: &Self::OutgoingViewingKey, cv: &Self::ValueCommitment, - cmu_bytes: &Self::ExtractedCommitmentBytes, + cmu_bytes: &ExtractedCommitmentBytes, epk: &EphemeralKeyBytes, ) -> OutgoingCipherKey { prf_ock(ovk, cv, cmu_bytes, epk) @@ -326,7 +325,7 @@ impl Domain for SaplingDomain

{ }) } - fn cmstar(note: &Self::Note) -> Self::ExtractedCommitment { + fn cmstar(note: &Self::Note) -> ExtractedCommitment { note.cmu() } diff --git a/masp_primitives/src/sapling/prover.rs b/masp_primitives/src/sapling/prover.rs index 69ee7cb2..bf692028 100644 --- a/masp_primitives/src/sapling/prover.rs +++ b/masp_primitives/src/sapling/prover.rs @@ -86,7 +86,7 @@ pub trait TxProver { pub mod mock { use crate::{ asset_type::AssetType, - constants::SPENDING_KEY_GENERATOR, + constants::spending_key_generator, convert::AllowedConversion, merkle_tree::MerklePath, sapling::{ @@ -121,7 +121,7 @@ pub mod mock { let cv = asset_type.value_commitment(value, rcv).commitment().into(); let rk = - PublicKey(proof_generation_key.ak.into()).randomize(ar, SPENDING_KEY_GENERATOR); + PublicKey(proof_generation_key.ak.into()).randomize(ar, spending_key_generator()); Ok(([0u8; GROTH_PROOF_SIZE], cv, rk)) } diff --git a/masp_primitives/src/sapling/redjubjub.rs b/masp_primitives/src/sapling/redjubjub.rs index 33f53180..62db36d2 100644 --- a/masp_primitives/src/sapling/redjubjub.rs +++ b/masp_primitives/src/sapling/redjubjub.rs @@ -281,7 +281,7 @@ mod tests { use rand_xorshift::XorShiftRng; use super::*; - use crate::constants::SPENDING_KEY_GENERATOR; + use crate::constants::spending_key_generator; #[test] fn test_batch_verify() { @@ -289,7 +289,7 @@ mod tests { 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, 0xe5, ]); - let p_g = SPENDING_KEY_GENERATOR; + let p_g = spending_key_generator(); let sk1 = PrivateKey(jubjub::Fr::random(&mut rng)); let vk1 = PublicKey::from_private(&sk1, p_g); @@ -330,7 +330,7 @@ mod tests { 0xbc, 0xe5, ]); let zero = jubjub::ExtendedPoint::identity(); - let p_g = SPENDING_KEY_GENERATOR; + let p_g = spending_key_generator(); let jubjub_modulus_bytes = [ 0xb7, 0x2c, 0xf7, 0xd6, 0x5e, 0x0e, 0x97, 0xd0, 0x82, 0x10, 0xc8, 0xcc, 0x93, 0x20, @@ -371,7 +371,7 @@ mod tests { 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, 0xe5, ]); - let p_g = SPENDING_KEY_GENERATOR; + let p_g = spending_key_generator(); for _ in 0..1000 { let sk = PrivateKey(jubjub::Fr::random(&mut rng)); @@ -406,7 +406,7 @@ mod tests { 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, 0xe5, ]); - let p_g = SPENDING_KEY_GENERATOR; + let p_g = spending_key_generator(); for _ in 0..1000 { let sk = PrivateKey(jubjub::Fr::random(&mut rng)); diff --git a/masp_primitives/src/test_vectors/pedersen_hash_vectors.rs b/masp_primitives/src/test_vectors/pedersen_hash_vectors.rs index c1e876ea..7871aaa3 100644 --- a/masp_primitives/src/test_vectors/pedersen_hash_vectors.rs +++ b/masp_primitives/src/test_vectors/pedersen_hash_vectors.rs @@ -7,26 +7,26 @@ pub fn get_vectors<'a>() -> Vec> { TestVector { personalization: Personalization::NoteCommitment, input_bits: vec![1, 1, 1, 1, 1, 1], - hash_u: "0x688ceb7437fd0d16cca7cad37c0a7c3869895e406a81a31b1861b909275bfc88", - hash_v: "0x502192be198774a4f7406fd7b8a8b43af5aa3bcd8b7e78a8226932000808d402", + hash_u: "Scalar(0x688ceb7437fd0d16cca7cad37c0a7c3869895e406a81a31b1861b909275bfc88)", + hash_v: "Scalar(0x502192be198774a4f7406fd7b8a8b43af5aa3bcd8b7e78a8226932000808d402)", }, TestVector { personalization: Personalization::NoteCommitment, input_bits: vec![1, 1, 1, 1, 1, 1, 0], - hash_u: "0x234451cd80d13cd6d1385e9d4cb882cbdb18f26685e3e7bd24dc2369430afeb9", - hash_v: "0x05a9ce5e558cdc9194ffa8b9d832b99825ca4f51ae12c4f077c457db30c91065", + hash_u: "Scalar(0x234451cd80d13cd6d1385e9d4cb882cbdb18f26685e3e7bd24dc2369430afeb9)", + hash_v: "Scalar(0x05a9ce5e558cdc9194ffa8b9d832b99825ca4f51ae12c4f077c457db30c91065)", }, TestVector { personalization: Personalization::NoteCommitment, input_bits: vec![1, 1, 1, 1, 1, 1, 1], - hash_u: "0x6b272b824bc986b0173fc09a455edca0a5d22768a98fb7192444712ef32808be", - hash_v: "0x634d7c334a5e088291e3f870fc1218a5da828d2bd503e824e27caec308351a38", + hash_u: "Scalar(0x6b272b824bc986b0173fc09a455edca0a5d22768a98fb7192444712ef32808be)", + hash_v: "Scalar(0x634d7c334a5e088291e3f870fc1218a5da828d2bd503e824e27caec308351a38)", }, TestVector { personalization: Personalization::NoteCommitment, input_bits: vec![1, 1, 1, 1, 1, 1, 1, 0, 0], - hash_u: "0x6b272b824bc986b0173fc09a455edca0a5d22768a98fb7192444712ef32808be", - hash_v: "0x634d7c334a5e088291e3f870fc1218a5da828d2bd503e824e27caec308351a38", + hash_u: "Scalar(0x6b272b824bc986b0173fc09a455edca0a5d22768a98fb7192444712ef32808be)", + hash_v: "Scalar(0x634d7c334a5e088291e3f870fc1218a5da828d2bd503e824e27caec308351a38)", }, TestVector { personalization: Personalization::NoteCommitment, @@ -39,8 +39,8 @@ pub fn get_vectors<'a>() -> Vec> { 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, ], - hash_u: "0x27d9f0ef30978c3c33aae4385def72c89133a414ee291f22382b64960bf12776", - hash_v: "0x34d821379faaef894d4f6f7843330135d7674f3354e74da16cde7f71304e5986", + hash_u: "Scalar(0x27d9f0ef30978c3c33aae4385def72c89133a414ee291f22382b64960bf12776)", + hash_v: "Scalar(0x34d821379faaef894d4f6f7843330135d7674f3354e74da16cde7f71304e5986)", }, TestVector { personalization: Personalization::NoteCommitment, @@ -53,8 +53,8 @@ pub fn get_vectors<'a>() -> Vec> { 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, ], - hash_u: "0x2ff1f563cf23423311edbba6bfa74bb299276ab63d1adc7e7de4b31af723e57c", - hash_v: "0x15327fa4c172eed9de5807c7c40c067a046c1c573653863be3f63bb5e90dca34", + hash_u: "Scalar(0x2ff1f563cf23423311edbba6bfa74bb299276ab63d1adc7e7de4b31af723e57c)", + hash_v: "Scalar(0x15327fa4c172eed9de5807c7c40c067a046c1c573653863be3f63bb5e90dca34)", }, TestVector { personalization: Personalization::NoteCommitment, @@ -67,8 +67,8 @@ pub fn get_vectors<'a>() -> Vec> { 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, ], - hash_u: "0x348521f4e0671456faa2380dd13284f1405dcb66f48f17c62eba3345a252ea8a", - hash_v: "0x4033936c9e1c32b1d53872a732b328826514250dc343a291823ef1d14f6e63eb", + hash_u: "Scalar(0x348521f4e0671456faa2380dd13284f1405dcb66f48f17c62eba3345a252ea8a)", + hash_v: "Scalar(0x4033936c9e1c32b1d53872a732b328826514250dc343a291823ef1d14f6e63eb)", }, TestVector { personalization: Personalization::NoteCommitment, @@ -101,8 +101,8 @@ pub fn get_vectors<'a>() -> Vec> { 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, ], - hash_u: "0x271cc89e1212443b95478688150f3155fe75a83f5ff770f89a9b74d10bdd3f3a", - hash_v: "0x3013b8071ec5c166e694c4017b1aa5eedc5425d9093665ae78bde3101ae3788c", + hash_u: "Scalar(0x271cc89e1212443b95478688150f3155fe75a83f5ff770f89a9b74d10bdd3f3a)", + hash_v: "Scalar(0x3013b8071ec5c166e694c4017b1aa5eedc5425d9093665ae78bde3101ae3788c)", }, TestVector { personalization: Personalization::NoteCommitment, @@ -136,8 +136,8 @@ pub fn get_vectors<'a>() -> Vec> { 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, ], - hash_u: "0x587d068feda4ba7a1819a7f2140a8750461a3f792c0b882b54089ffcbdcacac6", - hash_v: "0x18bae31842680141a43131337c52d7188a8c116c8fcc9e8b1ca5f6103cfc2c4b", + hash_u: "Scalar(0x587d068feda4ba7a1819a7f2140a8750461a3f792c0b882b54089ffcbdcacac6)", + hash_v: "Scalar(0x18bae31842680141a43131337c52d7188a8c116c8fcc9e8b1ca5f6103cfc2c4b)", }, TestVector { personalization: Personalization::NoteCommitment, @@ -177,8 +177,8 @@ pub fn get_vectors<'a>() -> Vec> { 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, ], - hash_u: "0x2a8ca83879317ad95347b3618b449970aeee988842df186d69858e552ea8511e", - hash_v: "0x296e1576c2584c686e9d0b700524f426e511faa9bcb3486444f39bc9efaccc3c", + hash_u: "Scalar(0x2a8ca83879317ad95347b3618b449970aeee988842df186d69858e552ea8511e)", + hash_v: "Scalar(0x296e1576c2584c686e9d0b700524f426e511faa9bcb3486444f39bc9efaccc3c)", }, TestVector { personalization: Personalization::NoteCommitment, @@ -218,32 +218,32 @@ pub fn get_vectors<'a>() -> Vec> { 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, ], - hash_u: "0x5820ac7e268473eb8ef0a2f77916b5d5f85a4d59c4dd458d84462d890e219a33", - hash_v: "0x03eb040d1d41bd4330e9de1fe7a9a810b9d92144f0b4c557426c6645afeb8650", + hash_u: "Scalar(0x5820ac7e268473eb8ef0a2f77916b5d5f85a4d59c4dd458d84462d890e219a33)", + hash_v: "Scalar(0x03eb040d1d41bd4330e9de1fe7a9a810b9d92144f0b4c557426c6645afeb8650)", }, TestVector { personalization: Personalization::MerkleTree(0), input_bits: vec![0, 0, 0, 0, 0, 0], - hash_u: "0x4c7359694ffe4cda10bd830efea7b1b0dc605bcf838aed6e8c31c1a5e690ad17", - hash_v: "0x1e4748c3bf57e91eadeec064c7c8022690a662bb98d4466712b8454e4eb0a767", + hash_u: "Scalar(0x4c7359694ffe4cda10bd830efea7b1b0dc605bcf838aed6e8c31c1a5e690ad17)", + hash_v: "Scalar(0x1e4748c3bf57e91eadeec064c7c8022690a662bb98d4466712b8454e4eb0a767)", }, TestVector { personalization: Personalization::MerkleTree(0), input_bits: vec![0, 0, 0, 0, 0, 0, 0], - hash_u: "0x1c131c4619368e89364db7a57f4c7c1bf459ffbed9db0bb8faf937a97e80f2b0", - hash_v: "0x382f18acc73160d4b6b813b1855f8b8ee436f54bcfab52f10ad5df38f5b8ce42", + hash_u: "Scalar(0x1c131c4619368e89364db7a57f4c7c1bf459ffbed9db0bb8faf937a97e80f2b0)", + hash_v: "Scalar(0x382f18acc73160d4b6b813b1855f8b8ee436f54bcfab52f10ad5df38f5b8ce42)", }, TestVector { personalization: Personalization::MerkleTree(0), input_bits: vec![0, 0, 0, 0, 0, 0, 1], - hash_u: "0x0d92e9c44f81cbe3ad448ddb5de5bd18010afae5b3d35b586216f1e520f2e197", - hash_v: "0x01326781a51d66883174581243e0ce6af641ec93132bc04312eaaef6097243c5", + hash_u: "Scalar(0x0d92e9c44f81cbe3ad448ddb5de5bd18010afae5b3d35b586216f1e520f2e197)", + hash_v: "Scalar(0x01326781a51d66883174581243e0ce6af641ec93132bc04312eaaef6097243c5)", }, TestVector { personalization: Personalization::MerkleTree(0), input_bits: vec![0, 0, 0, 0, 0, 0, 1, 0, 0], - hash_u: "0x0d92e9c44f81cbe3ad448ddb5de5bd18010afae5b3d35b586216f1e520f2e197", - hash_v: "0x01326781a51d66883174581243e0ce6af641ec93132bc04312eaaef6097243c5", + hash_u: "Scalar(0x0d92e9c44f81cbe3ad448ddb5de5bd18010afae5b3d35b586216f1e520f2e197)", + hash_v: "Scalar(0x01326781a51d66883174581243e0ce6af641ec93132bc04312eaaef6097243c5)", }, TestVector { personalization: Personalization::MerkleTree(0), @@ -256,8 +256,8 @@ pub fn get_vectors<'a>() -> Vec> { 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, ], - hash_u: "0x3658faeda53bb7050e33819f484d204213903eeb83dbfc3608410eb9a7a45af7", - hash_v: "0x3597090f9fd5480662a5a4d7d657a05e045d167576b0fb7099f7fd57d072e543", + hash_u: "Scalar(0x3658faeda53bb7050e33819f484d204213903eeb83dbfc3608410eb9a7a45af7)", + hash_v: "Scalar(0x3597090f9fd5480662a5a4d7d657a05e045d167576b0fb7099f7fd57d072e543)", }, TestVector { personalization: Personalization::MerkleTree(0), @@ -270,8 +270,8 @@ pub fn get_vectors<'a>() -> Vec> { 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, ], - hash_u: "0x4e94d2f3dfff0a596bb5fa22dee84f6dc0013687902af79635f898dfb6219ce7", - hash_v: "0x4b58a2ce897edff5e0e922b53df71fd2a1ffe8d63491d44cdebebdf1a1410dbd", + hash_u: "Scalar(0x4e94d2f3dfff0a596bb5fa22dee84f6dc0013687902af79635f898dfb6219ce7)", + hash_v: "Scalar(0x4b58a2ce897edff5e0e922b53df71fd2a1ffe8d63491d44cdebebdf1a1410dbd)", }, TestVector { personalization: Personalization::MerkleTree(0), @@ -284,8 +284,8 @@ pub fn get_vectors<'a>() -> Vec> { 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, ], - hash_u: "0x2ee5c93f7f68f8eb5aa2cf133684cc99637654c907a12a9bee8720cfe2906eb1", - hash_v: "0x0382d4a60a3e5e2e67a46ddbcb42355c9fa5b4fb6e5d699b5572b107a7d55342", + hash_u: "Scalar(0x2ee5c93f7f68f8eb5aa2cf133684cc99637654c907a12a9bee8720cfe2906eb1)", + hash_v: "Scalar(0x0382d4a60a3e5e2e67a46ddbcb42355c9fa5b4fb6e5d699b5572b107a7d55342)", }, TestVector { personalization: Personalization::MerkleTree(0), @@ -318,8 +318,8 @@ pub fn get_vectors<'a>() -> Vec> { 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, ], - hash_u: "0x329316db53c6ac408bc34aab6273cadfed6a2942657a94353e764047887faa5f", - hash_v: "0x1754afaa548626ad4339195bf09c046cc5c20b171d41e24d26b20a2a072abd7b", + hash_u: "Scalar(0x329316db53c6ac408bc34aab6273cadfed6a2942657a94353e764047887faa5f)", + hash_v: "Scalar(0x1754afaa548626ad4339195bf09c046cc5c20b171d41e24d26b20a2a072abd7b)", }, TestVector { personalization: Personalization::MerkleTree(0), @@ -353,8 +353,8 @@ pub fn get_vectors<'a>() -> Vec> { 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, ], - hash_u: "0x620f81c8115e310da9ab70e7a9565922538496b23957441aaa98fb70abf9d2b6", - hash_v: "0x23cdea82950c2bf2b6257b6cc11ba102a6507e3865493f2fc7ab0bb5d5fbd391", + hash_u: "Scalar(0x620f81c8115e310da9ab70e7a9565922538496b23957441aaa98fb70abf9d2b6)", + hash_v: "Scalar(0x23cdea82950c2bf2b6257b6cc11ba102a6507e3865493f2fc7ab0bb5d5fbd391)", }, TestVector { personalization: Personalization::MerkleTree(0), @@ -394,8 +394,8 @@ pub fn get_vectors<'a>() -> Vec> { 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, ], - hash_u: "0x61e972424e32f31eae275a609066dc8f77b0a640c1b75e7d634853f710d3f639", - hash_v: "0x16a5ef5bb2c5c56c153baba6969ee90ebfb15fb7bf59a98a563ad8eaf30a15d6", + hash_u: "Scalar(0x61e972424e32f31eae275a609066dc8f77b0a640c1b75e7d634853f710d3f639)", + hash_v: "Scalar(0x16a5ef5bb2c5c56c153baba6969ee90ebfb15fb7bf59a98a563ad8eaf30a15d6)", }, TestVector { personalization: Personalization::MerkleTree(0), @@ -435,32 +435,32 @@ pub fn get_vectors<'a>() -> Vec> { 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, ], - hash_u: "0x6005ee60a24d199a3cd9b3bcdfc708d940fa97af1df82e64f5b0b5c1dcc5b2ce", - hash_v: "0x42cd89fe82400fe7b831d1f9bc4ee9d9aa725c18de9df151517f529d5fdbb47d", + hash_u: "Scalar(0x6005ee60a24d199a3cd9b3bcdfc708d940fa97af1df82e64f5b0b5c1dcc5b2ce)", + hash_v: "Scalar(0x42cd89fe82400fe7b831d1f9bc4ee9d9aa725c18de9df151517f529d5fdbb47d)", }, TestVector { personalization: Personalization::MerkleTree(34), input_bits: vec![0, 1, 0, 0, 0, 1], - hash_u: "0x615ff470cd4ef66d3dff9495e844e424a3dfe32425b3d4b3f05e499609e367f0", - hash_v: "0x10b35f0ce8cab5913bd1b42ba8f1c9307e83f00938f73312450313e217a12589", + hash_u: "Scalar(0x615ff470cd4ef66d3dff9495e844e424a3dfe32425b3d4b3f05e499609e367f0)", + hash_v: "Scalar(0x10b35f0ce8cab5913bd1b42ba8f1c9307e83f00938f73312450313e217a12589)", }, TestVector { personalization: Personalization::MerkleTree(34), input_bits: vec![0, 1, 0, 0, 0, 1, 0], - hash_u: "0x2b9999eed9ee9f7b47416c9d3e2c04e8efba8ffa118f053334a72b95bb24b0b1", - hash_v: "0x2f61df138aeb1ddbb2465751590f7f44b54ed230f49be9c1e5d5409306e305bd", + hash_u: "Scalar(0x2b9999eed9ee9f7b47416c9d3e2c04e8efba8ffa118f053334a72b95bb24b0b1)", + hash_v: "Scalar(0x2f61df138aeb1ddbb2465751590f7f44b54ed230f49be9c1e5d5409306e305bd)", }, TestVector { personalization: Personalization::MerkleTree(34), input_bits: vec![0, 1, 0, 0, 0, 1, 1], - hash_u: "0x0a663b2f154bdb39238e9df3cbe3090735d572f5220b0d5f16b70652d4af7be8", - hash_v: "0x3ee3bf0c0090caa881f9b8c2a74fee82bd314cb37d7b096408c969947af09472", + hash_u: "Scalar(0x0a663b2f154bdb39238e9df3cbe3090735d572f5220b0d5f16b70652d4af7be8)", + hash_v: "Scalar(0x3ee3bf0c0090caa881f9b8c2a74fee82bd314cb37d7b096408c969947af09472)", }, TestVector { personalization: Personalization::MerkleTree(34), input_bits: vec![0, 1, 0, 0, 0, 1, 1, 0, 0], - hash_u: "0x0a663b2f154bdb39238e9df3cbe3090735d572f5220b0d5f16b70652d4af7be8", - hash_v: "0x3ee3bf0c0090caa881f9b8c2a74fee82bd314cb37d7b096408c969947af09472", + hash_u: "Scalar(0x0a663b2f154bdb39238e9df3cbe3090735d572f5220b0d5f16b70652d4af7be8)", + hash_v: "Scalar(0x3ee3bf0c0090caa881f9b8c2a74fee82bd314cb37d7b096408c969947af09472)", }, TestVector { personalization: Personalization::MerkleTree(34), @@ -473,8 +473,8 @@ pub fn get_vectors<'a>() -> Vec> { 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, ], - hash_u: "0x05bdfd5c6604e985b30c9538930d12bccfa68a26078d5e02ea216fc64d0d71e7", - hash_v: "0x4fa06743e983ed637105f6b861c10c697fbcd6b10396a74aa910a68dc2ea8aa5", + hash_u: "Scalar(0x05bdfd5c6604e985b30c9538930d12bccfa68a26078d5e02ea216fc64d0d71e7)", + hash_v: "Scalar(0x4fa06743e983ed637105f6b861c10c697fbcd6b10396a74aa910a68dc2ea8aa5)", }, TestVector { personalization: Personalization::MerkleTree(34), @@ -487,8 +487,8 @@ pub fn get_vectors<'a>() -> Vec> { 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, ], - hash_u: "0x5cea25c1e65cd8498e4bdd4e768b715532cb7bc8d090ff6f6d1e24ddbe1248ee", - hash_v: "0x2199cf19940eb989b658e84f15490ecfeaae530187883bab518410aae9bfe705", + hash_u: "Scalar(0x5cea25c1e65cd8498e4bdd4e768b715532cb7bc8d090ff6f6d1e24ddbe1248ee)", + hash_v: "Scalar(0x2199cf19940eb989b658e84f15490ecfeaae530187883bab518410aae9bfe705)", }, TestVector { personalization: Personalization::MerkleTree(34), @@ -501,8 +501,8 @@ pub fn get_vectors<'a>() -> Vec> { 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, ], - hash_u: "0x652eab9e283fd44ecdbb52c95f7cecb34993db0cbb6cfdcfdc7f869d284ad9cd", - hash_v: "0x5289ba48aedea8f902c793db56fd1cff9b4c2ee1c99f425f1f25d1fe6a68ea3c", + hash_u: "Scalar(0x652eab9e283fd44ecdbb52c95f7cecb34993db0cbb6cfdcfdc7f869d284ad9cd)", + hash_v: "Scalar(0x5289ba48aedea8f902c793db56fd1cff9b4c2ee1c99f425f1f25d1fe6a68ea3c)", }, TestVector { personalization: Personalization::MerkleTree(34), @@ -535,8 +535,8 @@ pub fn get_vectors<'a>() -> Vec> { 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, ], - hash_u: "0x0571ef36476845e1d8e19eb8f4f1efe50ae96b670aed3f01e6cb8673c050bc80", - hash_v: "0x6f79f970e4029385598e5d3fff1fa6d625140ce579912dcadfeeda584f9eab2f", + hash_u: "Scalar(0x0571ef36476845e1d8e19eb8f4f1efe50ae96b670aed3f01e6cb8673c050bc80)", + hash_v: "Scalar(0x6f79f970e4029385598e5d3fff1fa6d625140ce579912dcadfeeda584f9eab2f)", }, TestVector { personalization: Personalization::MerkleTree(34), @@ -570,8 +570,8 @@ pub fn get_vectors<'a>() -> Vec> { 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, ], - hash_u: "0x37af7bd1429adb1982472b7ef73575c2a9a0bb9469548f2d78f2fb5189d860b1", - hash_v: "0x551f92af81fcacb9c22adb4bf06af88936eba79f6ec7eb1b13613a7c0765c26d", + hash_u: "Scalar(0x37af7bd1429adb1982472b7ef73575c2a9a0bb9469548f2d78f2fb5189d860b1)", + hash_v: "Scalar(0x551f92af81fcacb9c22adb4bf06af88936eba79f6ec7eb1b13613a7c0765c26d)", }, TestVector { personalization: Personalization::MerkleTree(34), @@ -611,8 +611,8 @@ pub fn get_vectors<'a>() -> Vec> { 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, ], - hash_u: "0x37bc50fcb8f17f54316b3e6ca3e987705feeff9a3cfe3f5efb5adc4ceb5705e2", - hash_v: "0x54b43f361d6233d56c36ce03ed8e95c373718cc94f7f51ea7282c0f6980f42a5", + hash_u: "Scalar(0x37bc50fcb8f17f54316b3e6ca3e987705feeff9a3cfe3f5efb5adc4ceb5705e2)", + hash_v: "Scalar(0x54b43f361d6233d56c36ce03ed8e95c373718cc94f7f51ea7282c0f6980f42a5)", }, TestVector { personalization: Personalization::MerkleTree(34), @@ -652,8 +652,8 @@ pub fn get_vectors<'a>() -> Vec> { 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, ], - hash_u: "0x45a13b9f8d6daf256d259cbcf87f53854dece663bd034de3ac164f0261ec4f29", - hash_v: "0x37307d49e9da6d04d0bc156fc7de4eb177177513a4c24a21789605bc1f6d0da2", + hash_u: "Scalar(0x45a13b9f8d6daf256d259cbcf87f53854dece663bd034de3ac164f0261ec4f29)", + hash_v: "Scalar(0x37307d49e9da6d04d0bc156fc7de4eb177177513a4c24a21789605bc1f6d0da2)", }, TestVector { personalization: Personalization::MerkleTree(27), @@ -666,8 +666,8 @@ pub fn get_vectors<'a>() -> Vec> { 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, ], - hash_u: "0x06055db8549227eefcf25b30599801f9b5f54e2439afc18703f561ee2e259534", - hash_v: "0x4b736cb086e4132765757fa7239899c5655ee17cc653e006ee17c55e560d6a35", + hash_u: "Scalar(0x06055db8549227eefcf25b30599801f9b5f54e2439afc18703f561ee2e259534)", + hash_v: "Scalar(0x4b736cb086e4132765757fa7239899c5655ee17cc653e006ee17c55e560d6a35)", }, TestVector { personalization: Personalization::MerkleTree(36), @@ -680,8 +680,8 @@ pub fn get_vectors<'a>() -> Vec> { 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, ], - hash_u: "0x6796119af309e8daf6a6b667c291be4d8b683c8f91deb6306c0054115474b37b", - hash_v: "0x15aefb950d74f21f53f93ffc58f461e4205bd0722b3b0190afa5bbe3098775da", + hash_u: "Scalar(0x6796119af309e8daf6a6b667c291be4d8b683c8f91deb6306c0054115474b37b)", + hash_v: "Scalar(0x15aefb950d74f21f53f93ffc58f461e4205bd0722b3b0190afa5bbe3098775da)", }, TestVector { personalization: Personalization::MerkleTree(0), @@ -694,8 +694,8 @@ pub fn get_vectors<'a>() -> Vec> { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ], - hash_u: "0x0c5795b83693946d3c9321a0471019b7c85567736e1fa5ce93ffabedab8b4c86", - hash_v: "0x15aefb950d74f21f53f93ffc58f461e4205bd0722b3b0190afa5bbe3098775da", + hash_u: "Scalar(0x0c5795b83693946d3c9321a0471019b7c85567736e1fa5ce93ffabedab8b4c86)", + hash_v: "Scalar(0x15aefb950d74f21f53f93ffc58f461e4205bd0722b3b0190afa5bbe3098775da)", }, TestVector { personalization: Personalization::NoteCommitment, @@ -708,8 +708,8 @@ pub fn get_vectors<'a>() -> Vec> { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ], - hash_u: "0x6de8499ad50b555936477cd7b009d60b9dc855dec64e9a77fc0a9e10d1da6acd", - hash_v: "0x4b736cb086e4132765757fa7239899c5655ee17cc653e006ee17c55e560d6a35", + hash_u: "Scalar(0x6de8499ad50b555936477cd7b009d60b9dc855dec64e9a77fc0a9e10d1da6acd)", + hash_v: "Scalar(0x4b736cb086e4132765757fa7239899c5655ee17cc653e006ee17c55e560d6a35)", }, ] } diff --git a/masp_primitives/src/transaction/components/sapling.rs b/masp_primitives/src/transaction/components/sapling.rs index 757067d1..61ef7c02 100644 --- a/masp_primitives/src/transaction/components/sapling.rs +++ b/masp_primitives/src/transaction/components/sapling.rs @@ -487,7 +487,7 @@ impl PartialOrd for OutputDescription { fn partial_cmp(&self, other: &Self) -> Option { ( self.cv.to_bytes(), - self.cmu.to_bytes(), + self.cmu.to_bytes_le(), self.ephemeral_key.clone(), self.enc_ciphertext, self.out_ciphertext, @@ -495,7 +495,7 @@ impl PartialOrd for OutputDescription { ) .partial_cmp(&( other.cv.to_bytes(), - other.cmu.to_bytes(), + other.cmu.to_bytes_le(), other.ephemeral_key.clone(), other.enc_ciphertext, other.out_ciphertext, @@ -509,7 +509,7 @@ impl Hash for OutputDescription { H: Hasher, { self.cv.to_bytes().hash(state); - self.cmu.to_bytes().hash(state); + self.cmu.to_bytes_le().hash(state); self.ephemeral_key.hash(state); self.enc_ciphertext.hash(state); self.out_ciphertext.hash(state); @@ -529,12 +529,12 @@ impl PartialOrd for ConvertDescription { fn partial_cmp(&self, other: &Self) -> Option { ( self.cv.to_bytes(), - self.anchor.to_bytes(), + self.anchor.to_bytes_le(), self.zkproof.clone(), ) .partial_cmp(&( other.cv.to_bytes(), - other.anchor.to_bytes(), + other.anchor.to_bytes_le(), other.zkproof.clone(), )) } @@ -546,7 +546,7 @@ impl Hash for ConvertDescription { H: Hasher, { self.cv.to_bytes().hash(state); - self.anchor.to_bytes().hash(state); + self.anchor.to_bytes_le().hash(state); self.zkproof.hash(state); } } @@ -625,7 +625,7 @@ pub mod testing { use rand::{SeedableRng, rngs::StdRng}; use crate::{ - constants::{SPENDING_KEY_GENERATOR, VALUE_COMMITMENT_RANDOMNESS_GENERATOR}, + constants::{spending_key_generator, value_commitment_randomness_generator}, sapling::{ Nullifier, redjubjub::{PrivateKey, PublicKey}, @@ -654,9 +654,9 @@ pub mod testing { /// roundtrip testing). pub fn arb_spend_description()( cv in arb_extended_point(), - anchor in vec(any::(), 64) - .prop_map(|v| <[u8;64]>::try_from(v.as_slice()).unwrap()) - .prop_map(|v| bls12_381::Scalar::from_bytes_wide(&v)), + anchor in vec(any::(), 32) + .prop_map(|v| <[u8;32]>::try_from(v.as_slice()).unwrap()) + .prop_map(|v| bls12_381::Scalar::from_bytes_le(&v).unwrap()), nullifier in prop::array::uniform32(any::()) .prop_map(|v| Nullifier::from_slice(&v).unwrap()), zkproof in vec(any::(), GROTH_PROOF_SIZE) @@ -666,14 +666,14 @@ pub mod testing { ) -> SpendDescription { let mut rng = StdRng::from_seed(rng_seed); let sk1 = PrivateKey(jubjub::Fr::random(&mut rng)); - let rk = PublicKey::from_private(&sk1, SPENDING_KEY_GENERATOR); + let rk = PublicKey::from_private(&sk1, spending_key_generator()); SpendDescription { cv, anchor, nullifier, rk, zkproof, - spend_auth_sig: sk1.sign(&fake_sighash_bytes, &mut rng, SPENDING_KEY_GENERATOR), + spend_auth_sig: sk1.sign(&fake_sighash_bytes, &mut rng, spending_key_generator()), } } } @@ -683,9 +683,9 @@ pub mod testing { /// roundtrip testing). pub fn arb_output_description()( cv in arb_extended_point(), - cmu in vec(any::(), 64) - .prop_map(|v| <[u8;64]>::try_from(v.as_slice()).unwrap()) - .prop_map(|v| bls12_381::Scalar::from_bytes_wide(&v)), + cmu in vec(any::(), 32) + .prop_map(|v| <[u8;32]>::try_from(v.as_slice()).unwrap()) + .prop_map(|v| bls12_381::Scalar::from_bytes_le(&v).unwrap()), enc_ciphertext in vec(any::(), 580+32) .prop_map(|v| <[u8;580+32]>::try_from(v.as_slice()).unwrap()), epk in arb_extended_point(), @@ -726,7 +726,7 @@ pub mod testing { shielded_converts, shielded_outputs, value_balance, - authorization: Authorized { binding_sig: bsk.sign(&fake_bvk_bytes, &mut rng, VALUE_COMMITMENT_RANDOMNESS_GENERATOR) }, + authorization: Authorized { binding_sig: bsk.sign(&fake_bvk_bytes, &mut rng, value_commitment_randomness_generator()) }, } ) } @@ -744,9 +744,9 @@ pub mod testing { /// roundtrip testing). pub fn arb_convert_description()( cv in arb_extended_point(), - anchor in vec(any::(), 64) - .prop_map(|v| <[u8;64]>::try_from(v.as_slice()).unwrap()) - .prop_map(|v| bls12_381::Scalar::from_bytes_wide(&v)), + anchor in vec(any::(), 32) + .prop_map(|v| <[u8;32]>::try_from(v.as_slice()).unwrap()) + .prop_map(|v| bls12_381::Scalar::from_bytes_le(&v).unwrap()), zkproof in vec(any::(), GROTH_PROOF_SIZE) .prop_map(|v| <[u8;GROTH_PROOF_SIZE]>::try_from(v.as_slice()).unwrap()), ) -> ConvertDescription { diff --git a/masp_primitives/src/transaction/components/sapling/builder.rs b/masp_primitives/src/transaction/components/sapling/builder.rs index fc526f42..baaef045 100644 --- a/masp_primitives/src/transaction/components/sapling/builder.rs +++ b/masp_primitives/src/transaction/components/sapling/builder.rs @@ -694,11 +694,13 @@ impl BorshSchema for SaplingBuilder { impl BorshSerialize for SaplingBuilder { fn serialize(&self, writer: &mut W) -> std::io::Result<()> { self.params.serialize(writer)?; - self.spend_anchor.map(|x| x.to_bytes()).serialize(writer)?; + self.spend_anchor + .map(|x| x.to_bytes_le()) + .serialize(writer)?; self.target_height.serialize(writer)?; self.value_balance.serialize(writer)?; self.convert_anchor - .map(|x| x.to_bytes()) + .map(|x| x.to_bytes_le()) .serialize(writer)?; self.spends.serialize(writer)?; self.converts.serialize(writer)?; @@ -710,14 +712,14 @@ impl BorshDeserialize for SaplingBui fn deserialize_reader(reader: &mut R) -> std::io::Result { let params = P::deserialize_reader(reader)?; let spend_anchor: Option> = Option::<[u8; 32]>::deserialize_reader(reader)? - .map(|x| bls12_381::Scalar::from_bytes(&x).into()); + .map(|x| bls12_381::Scalar::from_bytes_le(&x).into()); let spend_anchor = spend_anchor .map(|x| x.ok_or_else(|| std::io::Error::from(std::io::ErrorKind::InvalidData))) .transpose()?; let target_height = BlockHeight::deserialize_reader(reader)?; let value_balance = I128Sum::deserialize_reader(reader)?; let convert_anchor: Option> = Option::<[u8; 32]>::deserialize_reader(reader)? - .map(|x| bls12_381::Scalar::from_bytes(&x).into()); + .map(|x| bls12_381::Scalar::from_bytes_le(&x).into()); let convert_anchor = convert_anchor .map(|x| x.ok_or_else(|| std::io::Error::from(std::io::ErrorKind::InvalidData))) .transpose()?; diff --git a/masp_primitives/src/zip32/sapling.rs b/masp_primitives/src/zip32/sapling.rs index 77875ce1..565a9600 100644 --- a/masp_primitives/src/zip32/sapling.rs +++ b/masp_primitives/src/zip32/sapling.rs @@ -9,7 +9,7 @@ use super::{ Scope, ViewingKey, }; use crate::{ - constants::{PROOF_GENERATION_KEY_GENERATOR, SPENDING_KEY_GENERATOR}, + constants::{proof_generation_key_generator, spending_key_generator}, keys::{prf_expand, prf_expand_vec}, sapling::keys::{DecodingError, ExpandedSpendingKey, FullViewingKey, OutgoingViewingKey}, sapling::{ProofGenerationKey, SaplingIvk, redjubjub::PrivateKey}, @@ -104,7 +104,7 @@ pub fn sapling_derive_internal_fvk( let r = prf_expand(i.as_bytes(), &[0x18]); let r = r.as_bytes(); // PROOF_GENERATION_KEY_GENERATOR = \mathcal{H}^Sapling - let nk_internal = NullifierDerivingKey(PROOF_GENERATION_KEY_GENERATOR * i_nsk + fvk.vk.nk.0); + let nk_internal = NullifierDerivingKey(proof_generation_key_generator() * i_nsk + fvk.vk.nk.0); let dk_internal = DiversifierKey(r[..32].try_into().unwrap()); let ovk_internal = OutgoingViewingKey(r[32..].try_into().unwrap()); @@ -665,9 +665,9 @@ impl ExtendedFullViewingKey { fvk: { let i_ask = jubjub::Fr::from_bytes_wide(prf_expand(i_l, &[0x13]).as_array()); let i_nsk = jubjub::Fr::from_bytes_wide(prf_expand(i_l, &[0x14]).as_array()); - let ak = (SPENDING_KEY_GENERATOR * i_ask) + self.fvk.vk.ak; + let ak = (spending_key_generator() * i_ask) + self.fvk.vk.ak; let nk = NullifierDerivingKey( - (PROOF_GENERATION_KEY_GENERATOR * i_nsk) + self.fvk.vk.nk.0, + (proof_generation_key_generator() * i_nsk) + self.fvk.vk.nk.0, ); FullViewingKey { @@ -1008,7 +1008,7 @@ impl PseudoExtendedKey { /// Augment this spending key with proof generation data. Fails if the proof /// generation key is inconsistent with this key. pub fn augment_proof_generation_key(&mut self, pgk: ProofGenerationKey) -> Result<(), ()> { - let nk = NullifierDerivingKey(PROOF_GENERATION_KEY_GENERATOR * pgk.nsk); + let nk = NullifierDerivingKey(proof_generation_key_generator() * pgk.nsk); if nk == self.xfvk.fvk.vk.nk && pgk.ak == self.xfvk.fvk.vk.ak { self.nsk = Some(pgk.nsk); Ok(()) @@ -1020,7 +1020,7 @@ impl PseudoExtendedKey { /// Augment this this extended key with spend authorization data. Fails if /// spend authorizing key is inconsistent with this key. pub fn augment_spend_authorizing_key(&mut self, ask: PrivateKey) -> Result<(), ()> { - let ak = SPENDING_KEY_GENERATOR * ask.0; + let ak = spending_key_generator() * ask.0; if ak == self.xfvk.fvk.vk.ak { self.ask = Some(ask.0); Ok(()) diff --git a/masp_proofs/Cargo.toml b/masp_proofs/Cargo.toml index 450d8bb8..d40a3d98 100644 --- a/masp_proofs/Cargo.toml +++ b/masp_proofs/Cargo.toml @@ -15,16 +15,18 @@ categories = ["cryptography::cryptocurrencies"] all-features = true [dependencies] -masp_primitives = { version = "2.0.0", path = "../masp_primitives" } +masp_primitives = { version = "3.0.5", path = "../masp_primitives" } # Dependencies exposed in a public API: # (Breaking upgrades to these require a breaking upgrade to this crate.) -bellman = { version = "0.14", default-features = false, features = ["groth16"] } -bls12_381 = { package = "nam-bls12_381", version = "0.8.1-nam.0" } +bellman = { package = "nam-bellperson", version="0.26.2-nam.2", features = ["groth16"] } +bls12_381 = {package = "nam-blstrs", version = "0.7.1-nam.0" } +ff = "0.13" group = "0.13" -jubjub = { package = "nam-jubjub", version = "0.10.1-nam.0" } +jubjub = { package = "nam-jubjub", version = "1.10.1-nam.1" } lazy_static = "1" minreq = { version = "2.11.0", features = ["https"], optional = true } +pairing = "0.23.0" rand_core = "0.6" tracing = "0.1" @@ -46,11 +48,10 @@ rand_xorshift = "0.3" pprof = { version = "0.14", features = ["criterion", "flamegraph"] } [features] -default = ["local-prover", "multicore"] +default = ["local-prover"] bundled-prover = [] download-params = ["minreq", "directories"] local-prover = ["directories"] -multicore = ["bellman/multicore"] embed-verifying-key = [] benchmarks = [] js = ["getrandom/js"] diff --git a/masp_proofs/src/circuit.rs b/masp_proofs/src/circuit.rs index e6dbf9d0..9a640daf 100644 --- a/masp_proofs/src/circuit.rs +++ b/masp_proofs/src/circuit.rs @@ -2,5 +2,6 @@ pub mod convert; pub mod ecc; +pub mod gadgets; pub mod pedersen_hash; pub mod sapling; diff --git a/masp_proofs/src/circuit/convert.rs b/masp_proofs/src/circuit/convert.rs index 650664ec..66c4516e 100644 --- a/masp_proofs/src/circuit/convert.rs +++ b/masp_proofs/src/circuit/convert.rs @@ -10,6 +10,7 @@ use crate::circuit::sapling::expose_value_commitment; use bellman::gadgets::Assignment; use bellman::gadgets::boolean; use bellman::gadgets::num; +use group::ff::Field; pub const TREE_DEPTH: usize = masp_primitives::sapling::SAPLING_COMMITMENT_TREE_DEPTH; @@ -41,7 +42,7 @@ impl Circuit for Convert { { // Compute the note's value as a linear combination // of the bits. - let mut coeff = bls12_381::Scalar::one(); + let mut coeff = bls12_381::Scalar::ONE; for bit in &value_bits { value_num = value_num.add_bool_with_coeff(CS::one(), bit, coeff); coeff = coeff.double(); @@ -116,7 +117,7 @@ impl Circuit for Convert { cs.enforce( || "conditionally enforce correct root", |lc| lc + cur.get_variable() - rt.get_variable(), - |lc| lc + &value_num.lc(bls12_381::Scalar::one()), + |lc| lc + &value_num.lc(bls12_381::Scalar::ONE), |lc| lc, ); @@ -221,7 +222,7 @@ fn test_convert_circuit_with_bls12_381() { ); assert_eq!(cs.num_inputs(), 4); - assert_eq!(cs.get_input(0, "ONE"), bls12_381::Scalar::one()); + assert_eq!(cs.get_input(0, "ONE"), bls12_381::Scalar::ONE); assert_eq!( cs.get_input(1, "value commitment/commitment point/u/input variable"), expected_value_commitment.get_u() diff --git a/masp_proofs/src/circuit/ecc.rs b/masp_proofs/src/circuit/ecc.rs index 80711c87..1fe4d40e 100644 --- a/masp_proofs/src/circuit/ecc.rs +++ b/masp_proofs/src/circuit/ecc.rs @@ -12,9 +12,9 @@ use bellman::gadgets::lookup::lookup3_xy; use bellman::gadgets::boolean::Boolean; +use crate::constants::{FixedGenerator, edward_d, montgomery_a, montgomery_scale}; use group::Curve; - -use crate::constants::{EDWARDS_D, FixedGenerator, MONTGOMERY_A, MONTGOMERY_SCALE}; +use group::ff::Field; #[derive(Clone)] pub struct EdwardsPoint { @@ -157,7 +157,7 @@ impl EdwardsPoint { if *condition.get_value().get()? { Ok(*self.u.get_value().get()?) } else { - Ok(bls12_381::Scalar::zero()) + Ok(bls12_381::Scalar::ZERO) } })?; @@ -168,7 +168,7 @@ impl EdwardsPoint { cs.enforce( || "u' computation", |lc| lc + self.u.get_variable(), - |_| condition.lc(one, bls12_381::Scalar::one()), + |_| condition.lc(one, bls12_381::Scalar::ONE), |lc| lc + u_prime.get_variable(), ); @@ -177,7 +177,7 @@ impl EdwardsPoint { if *condition.get_value().get()? { Ok(*self.v.get_value().get()?) } else { - Ok(bls12_381::Scalar::one()) + Ok(bls12_381::Scalar::ONE) } })?; @@ -187,8 +187,8 @@ impl EdwardsPoint { cs.enforce( || "v' computation", |lc| lc + self.v.get_variable(), - |_| condition.lc(one, bls12_381::Scalar::one()), - |lc| lc + v_prime.get_variable() - &condition.not().lc(one, bls12_381::Scalar::one()), + |_| condition.lc(one, bls12_381::Scalar::ONE), + |lc| lc + v_prime.get_variable() - &condition.not().lc(one, bls12_381::Scalar::ONE), ); Ok(EdwardsPoint { @@ -266,7 +266,7 @@ impl EdwardsPoint { || "on curve check", |lc| lc - u2.get_variable() + v2.get_variable(), |lc| lc + one, - |lc| lc + one + (EDWARDS_D, u2v2.get_variable()), + |lc| lc + one + (edward_d(), u2v2.get_variable()), ); Ok(EdwardsPoint { @@ -306,14 +306,14 @@ impl EdwardsPoint { // Compute C = d*A*A let c = AllocatedNum::alloc(cs.namespace(|| "C"), || { let mut t0 = a.get_value().get()?.square(); - t0.mul_assign(EDWARDS_D); + t0.mul_assign(edward_d()); Ok(t0) })?; cs.enforce( || "C computation", - |lc| lc + (EDWARDS_D, a.get_variable()), + |lc| lc + (edward_d(), a.get_variable()), |lc| lc + a.get_variable(), |lc| lc + c.get_variable(), ); @@ -323,7 +323,7 @@ impl EdwardsPoint { let mut t0 = *a.get_value().get()?; t0 = t0.double(); - let mut t1 = bls12_381::Scalar::one(); + let mut t1 = bls12_381::Scalar::ONE; t1.add_assign(c.get_value().get()?); let res = t1.invert().map(|t1| t0 * t1); @@ -349,7 +349,7 @@ impl EdwardsPoint { t0 = t0.double().neg(); t0.add_assign(t.get_value().get()?); - let mut t1 = bls12_381::Scalar::one(); + let mut t1 = bls12_381::Scalar::ONE; t1.sub_assign(c.get_value().get()?); let res = t1.invert().map(|t1| t0 * t1); @@ -407,14 +407,14 @@ impl EdwardsPoint { let c = AllocatedNum::alloc(cs.namespace(|| "C"), || { let mut t0 = *a.get_value().get()?; t0.mul_assign(b.get_value().get()?); - t0.mul_assign(EDWARDS_D); + t0.mul_assign(edward_d()); Ok(t0) })?; cs.enforce( || "C computation", - |lc| lc + (EDWARDS_D, a.get_variable()), + |lc| lc + (edward_d(), a.get_variable()), |lc| lc + b.get_variable(), |lc| lc + c.get_variable(), ); @@ -424,7 +424,7 @@ impl EdwardsPoint { let mut t0 = *a.get_value().get()?; t0.add_assign(b.get_value().get()?); - let mut t1 = bls12_381::Scalar::one(); + let mut t1 = bls12_381::Scalar::ONE; t1.add_assign(c.get_value().get()?); let ret = t1.invert().map(|t1| t0 * t1); @@ -449,7 +449,7 @@ impl EdwardsPoint { t0.sub_assign(a.get_value().get()?); t0.sub_assign(b.get_value().get()?); - let mut t1 = bls12_381::Scalar::one(); + let mut t1 = bls12_381::Scalar::ONE; t1.sub_assign(c.get_value().get()?); let ret = t1.invert().map(|t1| t0 * t1); @@ -487,7 +487,7 @@ impl MontgomeryPoint { // Compute u = (scale*x) / y let u = AllocatedNum::alloc(cs.namespace(|| "u"), || { let mut t0 = *self.x.get_value().get()?; - t0.mul_assign(MONTGOMERY_SCALE); + t0.mul_assign(montgomery_scale()); let ret = self.y.get_value().get()?.invert().map(|invy| t0 * invy); if bool::from(ret.is_some()) { @@ -499,17 +499,17 @@ impl MontgomeryPoint { cs.enforce( || "u computation", - |lc| lc + &self.y.lc(bls12_381::Scalar::one()), + |lc| lc + &self.y.lc(bls12_381::Scalar::ONE), |lc| lc + u.get_variable(), - |lc| lc + &self.x.lc(MONTGOMERY_SCALE), + |lc| lc + &self.x.lc(montgomery_scale()), ); // Compute v = (x - 1) / (x + 1) let v = AllocatedNum::alloc(cs.namespace(|| "v"), || { let mut t0 = *self.x.get_value().get()?; let mut t1 = t0; - t0.sub_assign(&bls12_381::Scalar::one()); - t1.add_assign(&bls12_381::Scalar::one()); + t0.sub_assign(&bls12_381::Scalar::ONE); + t1.add_assign(&bls12_381::Scalar::ONE); let ret = t1.invert().map(|t1| t0 * t1); if bool::from(ret.is_some()) { @@ -522,9 +522,9 @@ impl MontgomeryPoint { let one = CS::one(); cs.enforce( || "v computation", - |lc| lc + &self.x.lc(bls12_381::Scalar::one()) + one, + |lc| lc + &self.x.lc(bls12_381::Scalar::ONE) + one, |lc| lc + v.get_variable(), - |lc| lc + &self.x.lc(bls12_381::Scalar::one()) - one, + |lc| lc + &self.x.lc(bls12_381::Scalar::ONE) - one, ); Ok(EdwardsPoint { u, v }) @@ -562,15 +562,15 @@ impl MontgomeryPoint { cs.enforce( || "evaluate lambda", - |lc| lc + &other.x.lc(bls12_381::Scalar::one()) - &self.x.lc(bls12_381::Scalar::one()), + |lc| lc + &other.x.lc(bls12_381::Scalar::ONE) - &self.x.lc(bls12_381::Scalar::ONE), |lc| lc + lambda.get_variable(), - |lc| lc + &other.y.lc(bls12_381::Scalar::one()) - &self.y.lc(bls12_381::Scalar::one()), + |lc| lc + &other.y.lc(bls12_381::Scalar::ONE) - &self.y.lc(bls12_381::Scalar::ONE), ); // Compute x'' = lambda^2 - A - x - x' let xprime = AllocatedNum::alloc(cs.namespace(|| "xprime"), || { let mut t0 = lambda.get_value().get()?.square(); - t0.sub_assign(MONTGOMERY_A); + t0.sub_assign(montgomery_a()); t0.sub_assign(self.x.get_value().get()?); t0.sub_assign(other.x.get_value().get()?); @@ -584,9 +584,9 @@ impl MontgomeryPoint { |lc| lc + lambda.get_variable(), |lc| lc + lambda.get_variable(), |lc| { - lc + (MONTGOMERY_A, one) - + &self.x.lc(bls12_381::Scalar::one()) - + &other.x.lc(bls12_381::Scalar::one()) + lc + (montgomery_a(), one) + + &self.x.lc(bls12_381::Scalar::ONE) + + &other.x.lc(bls12_381::Scalar::ONE) + xprime.get_variable() }, ); @@ -605,9 +605,9 @@ impl MontgomeryPoint { // y' + y = lambda(x - x') cs.enforce( || "evaluate yprime", - |lc| lc + &self.x.lc(bls12_381::Scalar::one()) - xprime.get_variable(), + |lc| lc + &self.x.lc(bls12_381::Scalar::ONE) - xprime.get_variable(), |lc| lc + lambda.get_variable(), - |lc| lc + yprime.get_variable() + &self.y.lc(bls12_381::Scalar::one()), + |lc| lc + yprime.get_variable() + &self.y.lc(bls12_381::Scalar::ONE), ); Ok(MontgomeryPoint { @@ -732,7 +732,7 @@ mod test { for _ in 0..100 { let mut cs = TestConstraintSystem::::new(); - let p = masp_primitives::constants::NOTE_COMMITMENT_RANDOMNESS_GENERATOR; + let p = masp_primitives::constants::note_commitment_randomness_generator(); let s = jubjub::Fr::random(&mut rng); let q = jubjub::ExtendedPoint::from(p * s).to_affine(); let (u1, v1) = (q.get_u(), q.get_v()); @@ -862,13 +862,13 @@ mod test { assert_eq!(q.u.get_value().unwrap(), u0); assert_eq!(q.v.get_value().unwrap(), v0); - cs.set("select/v'/num", bls12_381::Scalar::one()); + cs.set("select/v'/num", bls12_381::Scalar::ONE); assert_eq!(cs.which_is_unsatisfied().unwrap(), "select/v' computation"); - cs.set("select/u'/num", bls12_381::Scalar::zero()); + cs.set("select/u'/num", bls12_381::Scalar::ZERO); assert_eq!(cs.which_is_unsatisfied().unwrap(), "select/u' computation"); } else { - assert_eq!(q.u.get_value().unwrap(), bls12_381::Scalar::zero()); - assert_eq!(q.v.get_value().unwrap(), bls12_381::Scalar::one()); + assert_eq!(q.u.get_value().unwrap(), bls12_381::Scalar::ZERO); + assert_eq!(q.v.get_value().unwrap(), bls12_381::Scalar::ONE); cs.set("select/v'/num", u0); assert_eq!(cs.which_is_unsatisfied().unwrap(), "select/v' computation"); @@ -1063,7 +1063,7 @@ mod test { .unwrap(); let largest_small_subgroup_order = jubjub::Fr::from(8); - let (zero_u, zero_v) = (bls12_381::Scalar::zero(), bls12_381::Scalar::one()); + let (zero_u, zero_v) = (bls12_381::Scalar::ZERO, bls12_381::Scalar::ONE); // generator for jubjub let (u, v) = ( diff --git a/masp_proofs/src/circuit/gadgets.rs b/masp_proofs/src/circuit/gadgets.rs new file mode 100644 index 00000000..69e27f9a --- /dev/null +++ b/masp_proofs/src/circuit/gadgets.rs @@ -0,0 +1,50 @@ +use bellman::gadgets::boolean::{AllocatedBit, Boolean}; +use bellman::{ConstraintSystem, SynthesisError}; +use group::ff::PrimeFieldBits; +use masp_primitives::ff::PrimeField; + +pub fn field_into_boolean_vec_le( + mut cs: CS, + value: Option, +) -> Result, SynthesisError> +where + F: PrimeFieldBits, + Scalar: PrimeField, + CS: ConstraintSystem, +{ + // Deconstruct in big-endian bit order + let values = match &value { + Some(value) => { + let field_char = F::char_le_bits(); + let mut field_char = field_char.into_iter().rev(); + + let mut tmp = Vec::with_capacity(F::NUM_BITS as usize); + + let mut found_one = false; + for b in value.to_le_bits().into_iter().rev() { + // Skip leading bits + found_one |= field_char.next().unwrap(); + if !found_one { + continue; + } + + tmp.push(Some(b)); + } + + assert_eq!(tmp.len(), F::NUM_BITS as usize); + + tmp + } + None => vec![None; F::NUM_BITS as usize], + }; + + // Allocate in little-endian order + let bits = values + .into_iter() + .rev() + .enumerate() + .map(|(i, b)| AllocatedBit::alloc(cs.namespace(|| format!("bit {}", i)), b)) + .collect::, SynthesisError>>()?; + + Ok(bits.into_iter().map(Boolean::from).collect()) +} diff --git a/masp_proofs/src/circuit/sapling.rs b/masp_proofs/src/circuit/sapling.rs index 51f26617..5d5f05ad 100644 --- a/masp_proofs/src/circuit/sapling.rs +++ b/masp_proofs/src/circuit/sapling.rs @@ -11,11 +11,13 @@ use masp_primitives::{ use super::ecc; use super::pedersen_hash; +use crate::circuit::gadgets; use crate::constants::{ NOTE_COMMITMENT_RANDOMNESS_GENERATOR, NULLIFIER_POSITION_GENERATOR, PROOF_GENERATION_KEY_GENERATOR, SPENDING_KEY_GENERATOR, VALUE_COMMITMENT_RANDOMNESS_GENERATOR, }; use bellman::gadgets::{Assignment, blake2s, boolean, multipack, num}; +use group::ff::Field; use itertools::multizip; pub const TREE_DEPTH: usize = SAPLING_COMMITMENT_TREE_DEPTH; @@ -113,7 +115,7 @@ where // Booleanize the randomness. This does not ensure // the bit representation is "in the field" because // it doesn't matter for security. - let rcv = boolean::field_into_boolean_vec_le( + let rcv = gadgets::field_into_boolean_vec_le( cs.namespace(|| "rcv"), value_commitment.as_ref().map(|c| c.randomness), )?; @@ -152,7 +154,7 @@ impl Circuit for Spend { // Rerandomize ak and expose it as an input to the circuit { - let ar = boolean::field_into_boolean_vec_le(cs.namespace(|| "ar"), self.ar)?; + let ar = gadgets::field_into_boolean_vec_le(cs.namespace(|| "ar"), self.ar)?; // Compute the randomness in the exponent let ar = ecc::fixed_base_multiplication( @@ -170,7 +172,7 @@ impl Circuit for Spend { let nk; { // Witness nsk as bits - let nsk = boolean::field_into_boolean_vec_le( + let nsk = gadgets::field_into_boolean_vec_le( cs.namespace(|| "nsk"), self.proof_generation_key.as_ref().map(|k| k.nsk), )?; @@ -254,7 +256,7 @@ impl Circuit for Spend { // Compute the note's value as a linear combination // of the bits. - let mut coeff = bls12_381::Scalar::one(); + let mut coeff = bls12_381::Scalar::ONE; for bit in &value_bits { value_num = value_num.add_bool_with_coeff(CS::one(), bit, coeff); coeff = coeff.double(); @@ -290,7 +292,7 @@ impl Circuit for Spend { { // Booleanize the randomness for the note commitment - let rcm = boolean::field_into_boolean_vec_le( + let rcm = gadgets::field_into_boolean_vec_le( cs.namespace(|| "rcm"), self.commitment_randomness, )?; @@ -375,7 +377,7 @@ impl Circuit for Spend { cs.enforce( || "conditionally enforce correct root", |lc| lc + cur.get_variable() - rt.get_variable(), - |lc| lc + &value_num.lc(bls12_381::Scalar::one()), + |lc| lc + &value_num.lc(bls12_381::Scalar::ONE), |lc| lc, ); @@ -513,7 +515,7 @@ impl Circuit for Output { note_contents.extend(g_d.repr(cs.namespace(|| "representation of g_d"))?); // Booleanize our ephemeral secret key - let esk = boolean::field_into_boolean_vec_le(cs.namespace(|| "esk"), self.esk)?; + let esk = gadgets::field_into_boolean_vec_le(cs.namespace(|| "esk"), self.esk)?; // Create the ephemeral public key from g_d. let epk = g_d.mul(cs.namespace(|| "epk computation"), &esk)?; @@ -567,7 +569,7 @@ impl Circuit for Output { { // Booleanize the randomness - let rcm = boolean::field_into_boolean_vec_le( + let rcm = gadgets::field_into_boolean_vec_le( cs.namespace(|| "rcm"), self.commitment_randomness, )?; @@ -737,7 +739,7 @@ fn test_input_circuit_with_bls12_381() { } assert_eq!(cs.num_inputs(), 8); - assert_eq!(cs.get_input(0, "ONE"), bls12_381::Scalar::one()); + assert_eq!(cs.get_input(0, "ONE"), bls12_381::Scalar::ONE); assert_eq!(cs.get_input(1, "rk/u/input variable"), rk.get_u()); assert_eq!(cs.get_input(2, "rk/v/input variable"), rk.get_v()); assert_eq!( @@ -927,7 +929,7 @@ fn test_input_circuit_with_bls12_381_external_test_vectors() { assert_eq!(cs.get("randomization of note commitment/u3/num"), cmu); assert_eq!(cs.num_inputs(), 8); - assert_eq!(cs.get_input(0, "ONE"), bls12_381::Scalar::one()); + assert_eq!(cs.get_input(0, "ONE"), bls12_381::Scalar::ONE); assert_eq!(cs.get_input(1, "rk/u/input variable"), rk.get_u()); assert_eq!(cs.get_input(2, "rk/v/input variable"), rk.get_v()); assert_eq!( @@ -1041,7 +1043,7 @@ fn test_output_circuit_with_bls12_381() { .to_affine(); assert_eq!(cs.num_inputs(), 6); - assert_eq!(cs.get_input(0, "ONE"), bls12_381::Scalar::one()); + assert_eq!(cs.get_input(0, "ONE"), bls12_381::Scalar::ONE); assert_eq!( cs.get_input(1, "value commitment/commitment point/u/input variable"), expected_value_commitment.get_u() diff --git a/masp_proofs/src/constants.rs b/masp_proofs/src/constants.rs index 49813f86..6c5d4683 100644 --- a/masp_proofs/src/constants.rs +++ b/masp_proofs/src/constants.rs @@ -4,31 +4,40 @@ use bls12_381::Scalar; use group::{Curve, Group, ff::Field}; use jubjub::ExtendedPoint; use lazy_static::lazy_static; -use masp_primitives::constants::{PEDERSEN_HASH_CHUNKS_PER_GENERATOR, PEDERSEN_HASH_GENERATORS}; +use masp_primitives::constants::{PEDERSEN_HASH_CHUNKS_PER_GENERATOR, pedersen_hash_generators}; /// The `d` constant of the twisted Edwards curve. -pub(crate) const EDWARDS_D: Scalar = Scalar::from_raw([ - 0x0106_5fd6_d634_3eb1, - 0x292d_7f6d_3757_9d26, - 0xf5fd_9207_e6bd_7fd4, - 0x2a93_18e7_4bfa_2b48, -]); +pub(crate) fn edward_d() -> Scalar { + Scalar::from_u64s_le(&[ + 0x0106_5fd6_d634_3eb1, + 0x292d_7f6d_3757_9d26, + 0xf5fd_9207_e6bd_7fd4, + 0x2a93_18e7_4bfa_2b48, + ]) + .unwrap() +} /// The `A` constant of the birationally equivalent Montgomery curve. -pub(crate) const MONTGOMERY_A: Scalar = Scalar::from_raw([ - 0x0000_0000_0000_a002, - 0x0000_0000_0000_0000, - 0x0000_0000_0000_0000, - 0x0000_0000_0000_0000, -]); +pub(crate) fn montgomery_a() -> Scalar { + Scalar::from_u64s_le(&[ + 0x0000_0000_0000_a002, + 0x0000_0000_0000_0000, + 0x0000_0000_0000_0000, + 0x0000_0000_0000_0000, + ]) + .unwrap() +} /// The scaling factor used for conversion to and from the Montgomery form. -pub(crate) const MONTGOMERY_SCALE: Scalar = Scalar::from_raw([ - 0x8f45_35f7_cf82_b8d9, - 0xce40_6970_3da8_8abd, - 0x31de_341e_77d7_64e5, - 0x2762_de61_e862_645e, -]); +pub(crate) fn montgomery_scale() -> Scalar { + Scalar::from_u64s_le(&[ + 0x8f45_35f7_cf82_b8d9, + 0xce40_6970_3da8_8abd, + 0x31de_341e_77d7_64e5, + 0x2762_de61_e862_645e, + ]) + .unwrap() +} /// The number of chunks needed to represent a full scalar during fixed-base /// exponentiation. @@ -42,19 +51,19 @@ pub type FixedGeneratorOwned = Vec>; lazy_static! { pub static ref PROOF_GENERATION_KEY_GENERATOR: FixedGeneratorOwned = - generate_circuit_generator(masp_primitives::constants::PROOF_GENERATION_KEY_GENERATOR); + generate_circuit_generator(masp_primitives::constants::proof_generation_key_generator()); pub static ref NOTE_COMMITMENT_RANDOMNESS_GENERATOR: FixedGeneratorOwned = - generate_circuit_generator(masp_primitives::constants::NOTE_COMMITMENT_RANDOMNESS_GENERATOR); + generate_circuit_generator(masp_primitives::constants::note_commitment_randomness_generator()); pub static ref NULLIFIER_POSITION_GENERATOR: FixedGeneratorOwned = - generate_circuit_generator(masp_primitives::constants::NULLIFIER_POSITION_GENERATOR); + generate_circuit_generator(masp_primitives::constants::nullifier_position_generator()); pub static ref VALUE_COMMITMENT_RANDOMNESS_GENERATOR: FixedGeneratorOwned = - generate_circuit_generator(masp_primitives::constants::VALUE_COMMITMENT_RANDOMNESS_GENERATOR); + generate_circuit_generator(masp_primitives::constants::value_commitment_randomness_generator()); pub static ref SPENDING_KEY_GENERATOR: FixedGeneratorOwned = - generate_circuit_generator(masp_primitives::constants::SPENDING_KEY_GENERATOR); + generate_circuit_generator(masp_primitives::constants::spending_key_generator()); /// The pre-computed window tables `[-4, 3, 2, 1, 1, 2, 3, 4]` of different magnitudes /// of the Pedersen hash segment generators. @@ -68,7 +77,7 @@ pub fn generate_circuit_generator(mut r#gen: jubjub::SubgroupPoint) -> FixedGene let mut windows = vec![]; for _ in 0..FIXED_BASE_CHUNKS_PER_GENERATOR { - let mut coeffs = vec![(Scalar::zero(), Scalar::one())]; + let mut coeffs = vec![(Scalar::ZERO, Scalar::ONE)]; let mut g = r#gen; for _ in 0..7 { let g_affine = jubjub::ExtendedPoint::from(g).to_affine(); @@ -91,7 +100,7 @@ pub(crate) fn to_montgomery_coords(g: ExtendedPoint) -> Option<(Scalar, Scalar)> let g = g.to_affine(); let (x, y) = (g.get_u(), g.get_v()); - if y == Scalar::one() { + if y == Scalar::ONE { // The only solution for y = 1 is x = 0. (0, 1) is the neutral element, so we map // this to the point at infinity. None @@ -109,7 +118,7 @@ pub(crate) fn to_montgomery_coords(g: ExtendedPoint) -> Option<(Scalar, Scalar)> // (0, -1) is the point of order two which is not // the neutral element, so we map it to (0, 0) which is // the only affine point of order 2. - Some((Scalar::zero(), Scalar::zero())) + Some((Scalar::ZERO, Scalar::ZERO)) } else { // The mapping is defined as above. // @@ -117,12 +126,12 @@ pub(crate) fn to_montgomery_coords(g: ExtendedPoint) -> Option<(Scalar, Scalar)> // u = (1 + y) / (1 - y) // v = u / x - let u = (Scalar::one() + y) * (Scalar::one() - y).invert().unwrap(); + let u = (Scalar::ONE + y) * (Scalar::ONE - y).invert().unwrap(); let v = u * x.invert().unwrap(); // Scale it into the correct curve constants // scaling factor = sqrt(4 / (a - d)) - Some((u, v * MONTGOMERY_SCALE)) + Some((u, v * montgomery_scale())) } } } @@ -131,7 +140,7 @@ pub(crate) fn to_montgomery_coords(g: ExtendedPoint) -> Option<(Scalar, Scalar)> /// Pedersen hash. fn generate_pedersen_circuit_generators() -> Vec>> { // Process each segment - PEDERSEN_HASH_GENERATORS + pedersen_hash_generators() .iter() .cloned() .map(|mut r#gen| { @@ -167,27 +176,30 @@ fn generate_pedersen_circuit_generators() -> Vec>> { mod tests { use super::*; /// The `d` constant of the twisted Edwards curve. - pub(crate) const EDWARDS_D: Scalar = Scalar::from_raw([ - 0x0106_5fd6_d634_3eb1, - 0x292d_7f6d_3757_9d26, - 0xf5fd_9207_e6bd_7fd4, - 0x2a93_18e7_4bfa_2b48, - ]); + pub(crate) fn edwards_d() -> Scalar { + Scalar::from_u64s_le(&[ + 0x0106_5fd6_d634_3eb1, + 0x292d_7f6d_3757_9d26, + 0xf5fd_9207_e6bd_7fd4, + 0x2a93_18e7_4bfa_2b48, + ]) + .unwrap() + } #[test] - fn edwards_d() { + fn test_edwards_d() { // d = -(10240/10241) assert_eq!( -Scalar::from(10240) * Scalar::from(10241).invert().unwrap(), - EDWARDS_D + edwards_d() ); } #[test] - fn montgomery_scale() { + fn test_montgomery_scale() { // scaling factor = sqrt(4 / (a - d)) assert_eq!( - MONTGOMERY_SCALE.square() * (-Scalar::one() - EDWARDS_D), + montgomery_scale().square() * (-Scalar::ONE - edwards_d()), Scalar::from(4), ); } diff --git a/masp_proofs/src/downloadreader.rs b/masp_proofs/src/downloadreader.rs index 04f46d1b..5e72acdc 100644 --- a/masp_proofs/src/downloadreader.rs +++ b/masp_proofs/src/downloadreader.rs @@ -62,7 +62,7 @@ impl io::Read for ResponseLazyReader { let error = format!("download response failed: {:?}", error); *self = Complete(Err(error.clone())); - return Err(io::Error::new(io::ErrorKind::Other, error)); + return Err(io::Error::other(error)); } } } @@ -75,7 +75,7 @@ impl io::Read for ResponseLazyReader { // Return a zero-byte read for download success and EOF. Ok(()) => Ok(0), // Keep returning the download error, - Err(error) => Err(io::Error::new(io::ErrorKind::Other, error.clone())), + Err(error) => Err(io::Error::other(error.clone())), }; } } diff --git a/masp_proofs/src/lib.rs b/masp_proofs/src/lib.rs index 3011d6eb..b0213243 100644 --- a/masp_proofs/src/lib.rs +++ b/masp_proofs/src/lib.rs @@ -142,9 +142,8 @@ fn fetch_params( timeout: Option, ) -> Result { // Ensure that the default MASP parameters location exists. - let params_dir = default_params_folder().ok_or_else(|| { - io::Error::new(io::ErrorKind::Other, "Could not load default params folder") - })?; + let params_dir = default_params_folder() + .ok_or_else(|| io::Error::other("Could not load default params folder"))?; std::fs::create_dir_all(¶ms_dir)?; let params_path = params_dir.join(name); diff --git a/masp_proofs/src/sapling/prover.rs b/masp_proofs/src/sapling/prover.rs index d2fd656f..8e6d42b8 100644 --- a/masp_proofs/src/sapling/prover.rs +++ b/masp_proofs/src/sapling/prover.rs @@ -1,12 +1,16 @@ +use super::masp_compute_value_balance; +use crate::circuit::convert::Convert; +use crate::circuit::sapling::{Output, Spend}; use bellman::{ gadgets::multipack, groth16::{Parameters, PreparedVerifyingKey, Proof, create_random_proof, verify_proof}, }; use bls12_381::Bls12; +use group::ff::Field; use group::{Curve, GroupEncoding}; use masp_primitives::{ asset_type::AssetType, - constants::{SPENDING_KEY_GENERATOR, VALUE_COMMITMENT_RANDOMNESS_GENERATOR}, + constants::{spending_key_generator, value_commitment_randomness_generator}, convert::AllowedConversion, merkle_tree::MerklePath, sapling::{ @@ -18,10 +22,6 @@ use masp_primitives::{ use rand_core::OsRng; use std::ops::{AddAssign, Neg}; -use super::masp_compute_value_balance; -use crate::circuit::convert::Convert; -use crate::circuit::sapling::{Output, Spend}; - /// A context object for creating the Sapling components of a Zcash transaction. pub struct SaplingProvingContext { bsk: jubjub::Fr, @@ -84,7 +84,7 @@ impl SaplingProvingContext { let payment_address = viewing_key.to_payment_address(diversifier).ok_or(())?; // This is the result of the re-randomization, we compute it for the caller - let rk = PublicKey(proof_generation_key.ak.into()).randomize(ar, SPENDING_KEY_GENERATOR); + let rk = PublicKey(proof_generation_key.ak.into()).randomize(ar, spending_key_generator()); // Let's compute the nullifier while we have the position let note = Note { @@ -118,7 +118,7 @@ impl SaplingProvingContext { // Try to verify the proof: // Construct public input for circuit - let mut public_input = [bls12_381::Scalar::zero(); 7]; + let mut public_input = [bls12_381::Scalar::ZERO; 7]; { let affine = rk.0.to_affine(); let (u, v) = (affine.get_u(), affine.get_v()); @@ -253,7 +253,7 @@ impl SaplingProvingContext { // Try to verify the proof: // Construct public input for circuit - let mut public_input = [bls12_381::Scalar::zero(); 3]; + let mut public_input = [bls12_381::Scalar::ZERO; 3]; { let affine = jubjub::ExtendedPoint::from(value_commitment.commitment()).to_affine(); let (u, v) = (affine.get_u(), affine.get_v()); @@ -288,7 +288,7 @@ impl SaplingProvingContext { let bsk = PrivateKey(self.bsk); // Grab the `bvk` using DerivePublic. - let bvk = PublicKey::from_private(&bsk, VALUE_COMMITMENT_RANDOMNESS_GENERATOR); + let bvk = PublicKey::from_private(&bsk, value_commitment_randomness_generator()); // In order to check internal consistency, let's use the accumulated value // commitments (as the verifier would) and apply value_balance to compare @@ -321,7 +321,7 @@ impl SaplingProvingContext { Ok(bsk.sign( &data_to_be_signed, &mut rng, - VALUE_COMMITMENT_RANDOMNESS_GENERATOR, + value_commitment_randomness_generator(), )) } } diff --git a/masp_proofs/src/sapling/verifier.rs b/masp_proofs/src/sapling/verifier.rs index 36b124e9..2369d7c2 100644 --- a/masp_proofs/src/sapling/verifier.rs +++ b/masp_proofs/src/sapling/verifier.rs @@ -68,7 +68,7 @@ impl SaplingVerificationContextInner { } // Construct public input for circuit - let mut public_input = [bls12_381::Scalar::zero(); 7]; + let mut public_input = [bls12_381::Scalar::default(); 7]; { let affine = rk_affine; let (u, v) = (affine.get_u(), affine.get_v()); @@ -117,7 +117,7 @@ impl SaplingVerificationContextInner { self.cv_sum += cv; // Construct public input for circuit - let mut public_input = [bls12_381::Scalar::zero(); 3]; + let mut public_input = [bls12_381::Scalar::default(); 3]; { let affine = cv.to_affine(); let (u, v) = (affine.get_u(), affine.get_v()); @@ -148,7 +148,7 @@ impl SaplingVerificationContextInner { self.cv_sum -= cv; // Construct public input for circuit - let mut public_input = [bls12_381::Scalar::zero(); 5]; + let mut public_input = [bls12_381::Scalar::default(); 5]; { let affine = cv.to_affine(); let (u, v) = (affine.get_u(), affine.get_v()); diff --git a/masp_proofs/src/sapling/verifier/batch.rs b/masp_proofs/src/sapling/verifier/batch.rs index b94319f6..f68d3646 100644 --- a/masp_proofs/src/sapling/verifier/batch.rs +++ b/masp_proofs/src/sapling/verifier/batch.rs @@ -1,11 +1,42 @@ -use bellman::groth16; +#[cfg(feature = "benchmarks")] +use bellman::groth16::prepare_verifying_key; +use bellman::groth16::{PreparedVerifyingKey, Proof}; +use bellman::{SynthesisError, groth16}; use bls12_381::Bls12; use group::GroupEncoding; use masp_primitives::transaction::components::sapling::{Authorized, Bundle}; +use pairing::Engine; use rand_core::{CryptoRng, RngCore}; use super::SaplingVerificationContextInner; +/// Batch of zk proofs and public inputs +#[derive(Default, Clone, Debug)] +pub struct Batch { + /// The batch of zk proofs + proofs: Vec>, + /// The public inputs for each corresponding proofs + inputs: Vec::Fr>>, +} + +impl Batch { + /// Verify all proofs in the batch + pub fn verify( + &self, + vk: &PreparedVerifyingKey, + rng: &mut impl RngCore, + ) -> Result { + let proofs = self.proofs.iter().collect::>(); + groth16::verify_proofs_batch(vk, rng, proofs.as_slice(), self.inputs.as_slice()) + } + + /// Add a proof to a batch + pub fn queue(&mut self, proof: Proof, inputs: Vec<::Fr>) { + self.proofs.push(proof); + self.inputs.push(inputs); + } +} + /// Batch validation context for MASP/Sapling. /// /// This batch-validates Spend, Convert, and Output proofs, and RedJubjub signatures. @@ -13,9 +44,9 @@ use super::SaplingVerificationContextInner; /// Signatures are verified assuming ZIP 216 is active. pub struct BatchValidator { bundles_added: bool, - spend_proofs: groth16::batch::Verifier, - convert_proofs: groth16::batch::Verifier, - output_proofs: groth16::batch::Verifier, + spend_proofs: Batch, + convert_proofs: Batch, + output_proofs: Batch, signatures: redjubjub::batch::Verifier, } @@ -30,9 +61,9 @@ impl BatchValidator { pub fn new() -> Self { BatchValidator { bundles_added: false, - spend_proofs: groth16::batch::Verifier::new(), - convert_proofs: groth16::batch::Verifier::new(), - output_proofs: groth16::batch::Verifier::new(), + spend_proofs: Default::default(), + convert_proofs: Default::default(), + output_proofs: Default::default(), signatures: redjubjub::batch::Verifier::new(), } } @@ -81,7 +112,7 @@ impl BatchValidator { true }, |this, proof, public_inputs| { - this.spend_proofs.queue((proof, public_inputs.to_vec())); + this.spend_proofs.queue(proof, public_inputs.to_vec()); true }, ); @@ -103,7 +134,7 @@ impl BatchValidator { zkproof, self, |this, proof, public_inputs| { - this.convert_proofs.queue((proof, public_inputs.to_vec())); + this.convert_proofs.queue(proof, public_inputs.to_vec()); true }, ); @@ -132,7 +163,7 @@ impl BatchValidator { epk, zkproof, |proof, public_inputs| { - self.output_proofs.queue((proof, public_inputs.to_vec())); + self.output_proofs.queue(proof, public_inputs.to_vec()); true }, ); @@ -184,24 +215,22 @@ impl BatchValidator { return false; } - #[cfg(feature = "multicore")] - let verify_proofs = |batch: groth16::batch::Verifier, vk| batch.verify_multicore(vk); - - #[cfg(not(feature = "multicore"))] - let mut verify_proofs = - |batch: groth16::batch::Verifier, vk| batch.verify(&mut rng, vk); + let prepared_spend_key = groth16::prepare_verifying_key(spend_vk); + let prepared_conv_key = groth16::prepare_verifying_key(convert_vk); + let prepared_out_key = groth16::prepare_verifying_key(output_vk); + let mut verify_proofs = |batch: &Batch, vk| batch.verify(vk, &mut rng); - if verify_proofs(self.spend_proofs, spend_vk).is_err() { + if verify_proofs(&self.spend_proofs, &prepared_spend_key).is_err() { tracing::debug!("Spend proof batch validation failed"); return false; } - if verify_proofs(self.convert_proofs, convert_vk).is_err() { + if verify_proofs(&self.convert_proofs, &prepared_conv_key).is_err() { tracing::debug!("Convert proof batch validation failed"); return false; } - if verify_proofs(self.output_proofs, output_vk).is_err() { + if verify_proofs(&self.output_proofs, &prepared_out_key).is_err() { tracing::debug!("Output proof batch validation failed"); return false; } @@ -221,35 +250,32 @@ impl BatchValidator { } /// Verify the spend proofs Intended for testing purposes only. - pub fn verify_spend_proofs( + pub fn verify_spend_proofs( self, spend_vk: &groth16::VerifyingKey, - ) -> Result<(), bellman::VerificationError> { - #[cfg(feature = "multicore")] - return self.spend_proofs.verify_multicore(spend_vk); - #[cfg(not(feature = "multicore"))] - return self.spend_proofs.verify(spend_vk); + rng: &mut R, + ) -> Result { + let prepared = prepare_verifying_key(spend_vk); + self.spend_proofs.verify(&prepared, rng) } /// Verify the convert proofs. Intended for testing purposes only. - pub fn verify_convert_proofs( + pub fn verify_convert_proofs( self, convert_vk: &groth16::VerifyingKey, - ) -> Result<(), bellman::VerificationError> { - #[cfg(feature = "multicore")] - return self.convert_proofs.verify_multicore(convert_vk); - #[cfg(not(feature = "multicore"))] - return self.convert_proofs.verify(convert_vk); + rng: &mut R, + ) -> Result { + let prepared = prepare_verifying_key(convert_vk); + self.convert_proofs.verify(&prepared, rng) } /// Verify the output proofs. Intended for testing purposes only. - pub fn verify_output_proofs( + pub fn verify_output_proofs( self, output_vk: &groth16::VerifyingKey, - ) -> Result<(), bellman::VerificationError> { - #[cfg(feature = "multicore")] - return self.output_proofs.verify_multicore(output_vk); - #[cfg(not(feature = "multicore"))] - return self.output_proofs.verify(output_vk); + rng: &mut R, + ) -> Result { + let prepared = prepare_verifying_key(output_vk); + self.output_proofs.verify(&prepared, rng) } } diff --git a/masp_proofs/src/sapling/verifier/single.rs b/masp_proofs/src/sapling/verifier/single.rs index 36776eb9..b613a60e 100644 --- a/masp_proofs/src/sapling/verifier/single.rs +++ b/masp_proofs/src/sapling/verifier/single.rs @@ -2,7 +2,7 @@ use bellman::groth16::{PreparedVerifyingKey, Proof, verify_proof}; use bls12_381::Bls12; use group::GroupEncoding; use masp_primitives::{ - constants::{SPENDING_KEY_GENERATOR, VALUE_COMMITMENT_RANDOMNESS_GENERATOR}, + constants::{spending_key_generator, value_commitment_randomness_generator}, sapling::redjubjub::{PublicKey, Signature}, transaction::components::I128Sum, }; @@ -52,7 +52,7 @@ impl SaplingVerificationContext { rk.verify_with_zip216( &msg, &spend_auth_sig, - SPENDING_KEY_GENERATOR, + spending_key_generator(), zip216_enabled, ) }, @@ -116,7 +116,7 @@ impl SaplingVerificationContext { bvk.verify_with_zip216( &data_to_be_signed, &binding_sig, - VALUE_COMMITMENT_RANDOMNESS_GENERATOR, + value_commitment_randomness_generator(), self.zip216_enabled, ) },