Skip to content

Commit

Permalink
misc: deprecate aliases StarkHasher, MTMaker
Browse files Browse the repository at this point in the history
- use `Tip5` in favor of `StarkHasher`
- use `CpuParallel` in favor of `MTMaker`
  • Loading branch information
jan-ferdinand committed Feb 12, 2024
1 parent 68435a6 commit f9f0e28
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
5 changes: 2 additions & 3 deletions triton-vm/src/fri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use crate::profiler::TritonProfiler;
use crate::proof_item::FriResponse;
use crate::proof_item::ProofItem;
use crate::proof_stream::ProofStream;
use crate::stark::MTMaker;

pub(crate) type SetupResult<T> = Result<T, FriSetupError>;
pub(crate) type ProverResult<T> = Result<T, FriProvingError>;
Expand Down Expand Up @@ -168,7 +167,7 @@ impl<H: AlgebraicHasher> ProverRound<H> {

fn merkle_tree_from_codeword(codeword: &[XFieldElement]) -> ProverResult<MerkleTree<H>> {
let digests = codeword_as_digests(codeword);
MTMaker::from_digests(&digests).map_err(FriProvingError::MerkleTreeError)
CpuParallel::from_digests(&digests).map_err(FriProvingError::MerkleTreeError)
}

fn split_and_fold(&self, folding_challenge: XFieldElement) -> Vec<XFieldElement> {
Expand Down Expand Up @@ -467,7 +466,7 @@ impl<'stream, H: AlgebraicHasher> FriVerifier<'stream, H> {

fn last_round_codeword_merkle_root(&self) -> VerifierResult<Digest> {
let codeword_digests = codeword_as_digests(&self.last_round_codeword);
let merkle_tree: MerkleTree<H> = MTMaker::from_digests(&codeword_digests)
let merkle_tree: MerkleTree<H> = CpuParallel::from_digests(&codeword_digests)
.map_err(FriValidationError::MerkleTreeError)?;

Ok(merkle_tree.root())
Expand Down
3 changes: 1 addition & 2 deletions triton-vm/src/proof_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ mod tests {
use crate::proof_item::FriResponse;
use crate::proof_item::ProofItem;
use crate::shared_tests::LeavedMerkleTreeTestData;
use crate::stark::MTMaker;
use crate::table::BaseRow;
use crate::table::ExtensionRow;
use crate::table::QuotientSegments;
Expand Down Expand Up @@ -239,7 +238,7 @@ mod tests {
let num_leaves = 1 << tree_height;
let leaf_values: Vec<XFieldElement> = random_elements(num_leaves);
let leaf_digests = leaf_values.iter().map(|&xfe| xfe.into()).collect_vec();
let merkle_tree: MerkleTree<Tip5> = MTMaker::from_digests(&leaf_digests).unwrap();
let merkle_tree: MerkleTree<Tip5> = CpuParallel::from_digests(&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)
Expand Down
5 changes: 4 additions & 1 deletion triton-vm/src/stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@ use crate::table::extension_table::Evaluable;
use crate::table::master_table::*;
use crate::table::QuotientSegments;

#[deprecated(since = "0.37.0", note = "Use `Tip5` directly instead.")]
pub type StarkHasher = Tip5;

pub type StarkProofStream = ProofStream<Tip5>;

/// The Merkle tree maker in use. Keeping this as a type alias should make it easier to switch
/// between different Merkle tree makers.
#[deprecated(since = "0.37.0", note = "Use `CpuParallel` directly instead.")]
pub type MTMaker = CpuParallel;

/// The number of segments the quotient polynomial is split into.
Expand Down Expand Up @@ -230,7 +233,7 @@ impl Stark {
prof_stop!(maybe_profiler, "hash rows of quotient segments");
prof_start!(maybe_profiler, "Merkle tree", "hash");
let quot_merkle_tree: MerkleTree<Tip5> =
MTMaker::from_digests(&fri_domain_quotient_segment_codewords_digests)?;
CpuParallel::from_digests(&fri_domain_quotient_segment_codewords_digests)?;
let quot_merkle_tree_root = quot_merkle_tree.root();
proof_stream.enqueue(ProofItem::MerkleRoot(quot_merkle_tree_root));
prof_stop!(maybe_profiler, "Merkle tree");
Expand Down
3 changes: 1 addition & 2 deletions triton-vm/src/table/master_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use crate::error::ProvingError;
use crate::profiler::prof_start;
use crate::profiler::prof_stop;
use crate::profiler::TritonProfiler;
use crate::stark::MTMaker;
use crate::stark::NUM_RANDOMIZER_POLYNOMIALS;
use crate::table::cascade_table::CascadeTable;
use crate::table::challenges::Challenges;
Expand Down Expand Up @@ -308,7 +307,7 @@ where
prof_stop!(maybe_profiler, "leafs");

prof_start!(maybe_profiler, "Merkle tree");
let merkle_tree = MTMaker::from_digests(&hashed_rows).unwrap();
let merkle_tree = CpuParallel::from_digests(&hashed_rows).unwrap();
prof_stop!(maybe_profiler, "Merkle tree");

merkle_tree
Expand Down

0 comments on commit f9f0e28

Please sign in to comment.