diff --git a/Cargo.lock b/Cargo.lock index 3e2331da..120ecbde 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,9 +19,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstream" -version = "0.6.15" +version = "0.6.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" +checksum = "23a1e53f0f5d86382dafe1cf314783b2044280f406e7e1506368220ad11b1338" dependencies = [ "anstyle", "anstyle-parse", @@ -34,36 +34,36 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" +checksum = "8365de52b16c035ff4fcafe0092ba9390540e3e352870ac09933bebcaa2c8c56" [[package]] name = "anstyle-parse" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.4" +version = "3.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" +checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" dependencies = [ "anstyle", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -147,9 +147,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.1.30" +version = "1.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b16803a61b81d9eabb7eae2588776c4c1e584b738ede45fdbb4c972cec1e9945" +checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" dependencies = [ "jobserver", "libc", @@ -231,9 +231,9 @@ checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" [[package]] name = "colorchoice" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "constant_time_eq" @@ -495,9 +495,9 @@ checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" [[package]] name = "libm" -version = "0.2.8" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" +checksum = "a00419de735aac21d53b0de5ce2c03bd3627277cf471300f27ebc89f7d828047" [[package]] name = "linux-raw-sys" @@ -668,9 +668,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.88" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] @@ -771,9 +771,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", @@ -800,9 +800,9 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rustix" -version = "0.38.37" +version = "0.38.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" +checksum = "aa260229e6538e52293eeb577aabd09945a09d6d9cc0fc550ed7529056c2e32a" dependencies = [ "bitflags", "errno", @@ -846,18 +846,18 @@ checksum = "a3f0bf26fd526d2a95683cd0f87bf103b8539e2ca1ef48ce002d67aad59aa0b4" [[package]] name = "serde" -version = "1.0.210" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "3ea7893ff5e2466df8d720bb615088341b295f849602c6956047f8f80f0e9bc1" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "7e85ad2009c50b58e87caa8cd6dac16bdf511bbfb7af6c33df902396aa480fa5" dependencies = [ "proc-macro2", "quote", @@ -866,9 +866,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.129" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6dbcf9b78a125ee667ae19388837dd12294b858d101fdd393cb9d5501ef09eb2" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ "itoa", "memchr", @@ -900,9 +900,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.79" +version = "2.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" +checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" dependencies = [ "proc-macro2", "quote", @@ -1145,8 +1145,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winter-crypto" -version = "0.9.0" -source = "git+https://github.com/facebook/winterfell?branch=next#9a9377fe1fab12dc0a54f258856e40ac960ddac2" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f9b62f424c65828678ed8e08faf90e7cfc91821453ed26521e0e0c561d5a630" dependencies = [ "blake3", "sha3", @@ -1156,9 +1157,9 @@ dependencies = [ [[package]] name = "winter-math" -version = "0.9.3" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b0e685b3b872d82e58a86519294a814b7bc7a4d3cd2c93570a7d80c0c5a1aba" +checksum = "16f3eb5a52d26a46037289f7f4153eb3528fc72c896d9f3b4037df0e102f83d4" dependencies = [ "serde", "winter-utils", @@ -1166,8 +1167,9 @@ dependencies = [ [[package]] name = "winter-rand-utils" -version = "0.9.0" -source = "git+https://github.com/facebook/winterfell?branch=next#9a9377fe1fab12dc0a54f258856e40ac960ddac2" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93be285803ef6d760974490097f1ddd8d2a749632361ff475aac8c4d2c10fb12" dependencies = [ "rand", "winter-utils", @@ -1175,9 +1177,9 @@ dependencies = [ [[package]] name = "winter-utils" -version = "0.9.3" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "961e81e9388877a25db1c034ba38253de2055f569633ae6a665d857a0556391b" +checksum = "5c548030dab203e9b0e5060ce791f5aa84f7672718d8e1cc5e41204d23e1d8dc" [[package]] name = "zerocopy" diff --git a/Cargo.toml b/Cargo.toml index 9e79c798..93310c91 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,12 +52,12 @@ num = { version = "0.4", default-features = false, features = ["alloc", "libm"] num-complex = { version = "0.4", default-features = false } rand = { version = "0.8", default-features = false } rand_core = { version = "0.6", default-features = false } -rand-utils = { git = "https://github.com/facebook/winterfell", branch = "next", package = "winter-rand-utils", optional = true } +rand-utils = { version = "0.10", package = "winter-rand-utils", optional = true } serde = { version = "1.0", default-features = false, optional = true, features = ["derive"] } sha3 = { version = "0.10", default-features = false } -winter-crypto = { git = "https://github.com/facebook/winterfell", branch = "next", default-features = false } -winter-math = { git = "https://github.com/facebook/winterfell", branch = "next", default-features = false } -winter-utils = { git = "https://github.com/facebook/winterfell", branch = "next", default-features = false } +winter-crypto = { version = "0.10", default-features = false } +winter-math = { version = "0.10", default-features = false } +winter-utils = { version = "0.10", default-features = false } [dev-dependencies] criterion = { version = "0.5", features = ["html_reports"] } @@ -65,7 +65,7 @@ getrandom = { version = "0.2", features = ["js"] } hex = { version = "0.4", default-features = false, features = ["alloc"] } proptest = "1.5" rand_chacha = { version = "0.3", default-features = false } -rand-utils = { git = "https://github.com/facebook/winterfell", branch = "next", package = "winter-rand-utils" } +rand-utils = { version = "0.10", package = "winter-rand-utils" } seq-macro = { version = "0.3" } [build-dependencies] diff --git a/src/hash/blake/mod.rs b/src/hash/blake/mod.rs index 30ed8482..47b80917 100644 --- a/src/hash/blake/mod.rs +++ b/src/hash/blake/mod.rs @@ -4,6 +4,7 @@ use core::{ ops::Deref, slice::from_raw_parts, }; +use std::vec::Vec; use super::{Digest, ElementHasher, Felt, FieldElement, Hasher}; use crate::utils::{ @@ -114,6 +115,11 @@ impl Hasher for Blake3_256 { Self::hash(prepare_merge(values)) } + fn merge_many(values: &[Self::Digest]) -> Self::Digest { + let bytes: Vec = values.iter().flat_map(|v| v.as_bytes()).collect(); + Blake3Digest(blake3::hash(&bytes).into()) + } + fn merge_with_int(seed: Self::Digest, value: u64) -> Self::Digest { let mut hasher = blake3::Hasher::new(); hasher.update(&seed.0); @@ -174,6 +180,11 @@ impl Hasher for Blake3_192 { Blake3Digest(*shrink_bytes(&blake3::hash(bytes).into())) } + fn merge_many(values: &[Self::Digest]) -> Self::Digest { + let bytes: Vec = values.iter().flat_map(|v| v.as_bytes()).collect(); + Blake3Digest(*shrink_bytes(&blake3::hash(&bytes).into())) + } + fn merge(values: &[Self::Digest; 2]) -> Self::Digest { Self::hash(prepare_merge(values)) } @@ -242,6 +253,11 @@ impl Hasher for Blake3_160 { Self::hash(prepare_merge(values)) } + fn merge_many(values: &[Self::Digest]) -> Self::Digest { + let bytes: Vec = values.iter().flat_map(|v| v.as_bytes()).collect(); + Blake3Digest(*shrink_bytes(&blake3::hash(&bytes).into())) + } + fn merge_with_int(seed: Self::Digest, value: u64) -> Self::Digest { let mut hasher = blake3::Hasher::new(); hasher.update(&seed.0); diff --git a/src/hash/rescue/rpo/mod.rs b/src/hash/rescue/rpo/mod.rs index 0d1d87bc..31ca6f35 100644 --- a/src/hash/rescue/rpo/mod.rs +++ b/src/hash/rescue/rpo/mod.rs @@ -1,3 +1,4 @@ +use alloc::vec::Vec; use core::ops::Range; use super::{ @@ -164,6 +165,12 @@ impl Hasher for Rpo256 { RpoDigest::new(state[DIGEST_RANGE].try_into().unwrap()) } + fn merge_many(values: &[Self::Digest]) -> Self::Digest { + let elements: Vec = + Self::Digest::digests_as_elements(values.iter()).copied().collect(); + Self::hash_elements(&elements) + } + fn merge_with_int(seed: Self::Digest, value: u64) -> Self::Digest { // initialize the state as follows: // - seed is copied into the first 4 elements of the rate portion of the state. diff --git a/src/hash/rescue/rpx/mod.rs b/src/hash/rescue/rpx/mod.rs index 8c6c53b6..36e381b5 100644 --- a/src/hash/rescue/rpx/mod.rs +++ b/src/hash/rescue/rpx/mod.rs @@ -1,3 +1,4 @@ +use alloc::vec::Vec; use core::ops::Range; use super::{ @@ -170,6 +171,12 @@ impl Hasher for Rpx256 { RpxDigest::new(state[DIGEST_RANGE].try_into().unwrap()) } + fn merge_many(values: &[Self::Digest]) -> Self::Digest { + let elements: Vec = + Self::Digest::digests_as_elements(values.iter()).copied().collect(); + Self::hash_elements(&elements) + } + fn merge_with_int(seed: Self::Digest, value: u64) -> Self::Digest { // initialize the state as follows: // - seed is copied into the first 4 elements of the rate portion of the state.