diff --git a/Cargo.toml b/Cargo.toml index 4684821b..ce27d3e5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -87,7 +87,7 @@ strum = { version = "0.26", features = ["derive"] } syn = "2.0" test-strategy = "0.4.0" thiserror = "2.0" -twenty-first = "0.44.1" +twenty-first = "0.45.0" unicode-width = "0.2" divan = "0.1.17" diff --git a/triton-vm/src/fri.rs b/triton-vm/src/fri.rs index cde93581..3cac2587 100644 --- a/triton-vm/src/fri.rs +++ b/triton-vm/src/fri.rs @@ -166,8 +166,8 @@ impl ProverRound { } fn merkle_tree_from_codeword(codeword: &[XFieldElement]) -> ProverResult { - let digests = codeword_as_digests(codeword); - MerkleTree::new::(&digests).map_err(FriProvingError::MerkleTreeError) + let digests: Vec<_> = codeword.par_iter().map(|&xfe| xfe.into()).collect(); + MerkleTree::par_new(&digests).map_err(FriProvingError::MerkleTreeError) } fn split_and_fold(&self, folding_challenge: XFieldElement) -> Vec { @@ -385,7 +385,6 @@ impl FriVerifier<'_> { let folding_challenge = round.folding_challenge.unwrap(); (0..self.num_collinearity_checks) - .into_par_iter() .map(|i| { let point_a_x = domain.domain_value(a_indices[i] as u32).lift(); let point_b_x = domain.domain_value(b_indices[i] as u32).lift(); @@ -434,7 +433,7 @@ impl FriVerifier<'_> { fn last_round_codeword_merkle_root(&self) -> VerifierResult { let codeword_digests = codeword_as_digests(&self.last_round_codeword); - let merkle_tree = MerkleTree::new::(&codeword_digests) + let merkle_tree = MerkleTree::sequential_new(&codeword_digests) .map_err(FriValidationError::MerkleTreeError)?; Ok(merkle_tree.root()) @@ -618,7 +617,7 @@ impl Fri { } fn codeword_as_digests(codeword: &[XFieldElement]) -> Vec { - codeword.par_iter().map(|&xfe| xfe.into()).collect() + codeword.iter().map(|&xfe| xfe.into()).collect() } #[cfg(test)] diff --git a/triton-vm/src/proof_stream.rs b/triton-vm/src/proof_stream.rs index ebbaa3df..47c25cfe 100644 --- a/triton-vm/src/proof_stream.rs +++ b/triton-vm/src/proof_stream.rs @@ -223,7 +223,7 @@ mod tests { let num_leaves = 1 << tree_height; let leaf_values: Vec = random_elements(num_leaves); let leaf_digests = leaf_values.iter().map(|&xfe| xfe.into()).collect_vec(); - let merkle_tree = MerkleTree::new::(&leaf_digests).unwrap(); + let merkle_tree = MerkleTree::par_new(&leaf_digests).unwrap(); let indices_to_check = vec![5, 173, 175, 167, 228, 140, 252, 149, 232, 182, 5, 5, 182]; let auth_structure = merkle_tree .authentication_structure(&indices_to_check) diff --git a/triton-vm/src/shared_tests.rs b/triton-vm/src/shared_tests.rs index d63c6420..e594958f 100644 --- a/triton-vm/src/shared_tests.rs +++ b/triton-vm/src/shared_tests.rs @@ -64,7 +64,7 @@ pub(crate) struct LeavedMerkleTreeTestData { #[strategy(Just(#leaves.iter().map(|&x| x.into()).collect()))] pub leaves_as_digests: Vec, - #[strategy(Just(MerkleTree::new::(&#leaves_as_digests).unwrap()))] + #[strategy(Just(MerkleTree::par_new(&#leaves_as_digests).unwrap()))] pub merkle_tree: MerkleTree, #[strategy(Just(#revealed_indices.iter().map(|&i| #leaves[i]).collect()))] diff --git a/triton-vm/src/stark.rs b/triton-vm/src/stark.rs index a1bd3de7..e8ae219a 100644 --- a/triton-vm/src/stark.rs +++ b/triton-vm/src/stark.rs @@ -238,8 +238,7 @@ impl Prover { quotient_segments_rows.map(hash_row).collect::>(); profiler!(stop "hash rows of quotient segments"); profiler!(start "Merkle tree" ("hash")); - let quot_merkle_tree = - MerkleTree::new::(&fri_domain_quotient_segment_codewords_digests)?; + let quot_merkle_tree = MerkleTree::par_new(&fri_domain_quotient_segment_codewords_digests)?; let quot_merkle_tree_root = quot_merkle_tree.root(); proof_stream.enqueue(ProofItem::MerkleRoot(quot_merkle_tree_root)); profiler!(stop "Merkle tree"); @@ -1353,7 +1352,7 @@ impl Verifier { let interpret_xfe_as_bfes = |xfe: XFieldElement| xfe.coefficients.to_vec(); let collect_row_as_bfes = |row: &QuotientSegments| row.map(interpret_xfe_as_bfes).concat(); quotient_segment_rows - .par_iter() + .iter() .map(collect_row_as_bfes) .map(|row| Tip5::hash_varlen(&row)) .collect() diff --git a/triton-vm/src/table/master_table.rs b/triton-vm/src/table/master_table.rs index 00aa16df..8f3d7a83 100644 --- a/triton-vm/src/table/master_table.rs +++ b/triton-vm/src/table/master_table.rs @@ -410,7 +410,7 @@ where profiler!(stop "leafs"); profiler!(start "Merkle tree" ("hash")); - let merkle_tree = MerkleTree::new::(&hashed_rows).unwrap(); + let merkle_tree = MerkleTree::par_new(&hashed_rows).unwrap(); profiler!(stop "Merkle tree"); merkle_tree