Skip to content

Commit

Permalink
refactor: Reorganize prover steps
Browse files Browse the repository at this point in the history
Specifically: move sampling of quotients weights closer to calculation
of quotient codewords, with an eye to merging the two.
  • Loading branch information
aszepieniec committed Mar 29, 2024
1 parent fa38fa8 commit 006d795
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
25 changes: 13 additions & 12 deletions triton-vm/src/stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,26 @@ impl Stark {

prof_start!(maybe_profiler, "Fiat-Shamir", "hash");
proof_stream.enqueue(ProofItem::MerkleRoot(ext_merkle_tree.root()));

// Get the weights with which to compress the many quotients into one.
let quotient_combination_weights =
proof_stream.sample_scalars(MasterExtTable::NUM_CONSTRAINTS);
let quotient_combination_weights = Array1::from(quotient_combination_weights);
prof_stop!(maybe_profiler, "Fiat-Shamir");
prof_stop!(maybe_profiler, "ext tables");

// low-degree extend the trace codewords so that the all quotient codewords
// obtained by element-wise evaluation of the AIR constraints
prof_start!(maybe_profiler, "quotient-domain codewords");
let base_quotient_domain_codewords = master_base_table.quotient_domain_table();
let ext_quotient_domain_codewords = master_ext_table.quotient_domain_table();
prof_stop!(maybe_profiler, "quotient-domain codewords");

prof_start!(maybe_profiler, "quotient codewords");
prof_start!(
maybe_profiler,
"compute and combine quotient codewords",
"CC"
);
let master_quotient_table = all_quotients(
base_quotient_domain_codewords,
ext_quotient_domain_codewords,
Expand All @@ -193,24 +204,14 @@ impl Stark {
&challenges,
maybe_profiler,
);
prof_stop!(maybe_profiler, "quotient codewords");

prof_start!(maybe_profiler, "linearly combine quotient codewords", "CC");
// Create quotient codeword. This is a part of the combination codeword. To reduce the
// amount of hashing necessary, the quotient codeword is linearly summed instead of
// hashed prior to committing to it.
let quotient_combination_weights =
proof_stream.sample_scalars(MasterExtTable::NUM_CONSTRAINTS);
let quotient_combination_weights = Array1::from(quotient_combination_weights);
assert_eq!(
quotient_combination_weights.len(),
master_quotient_table.ncols()
);

let quotient_codeword =
Self::random_linear_sum(master_quotient_table.view(), quotient_combination_weights);
assert_eq!(quotient_domain.length, quotient_codeword.len());
prof_stop!(maybe_profiler, "linearly combine quotient codewords");
prof_stop!(maybe_profiler, "compute and combine quotient codewords");

prof_start!(maybe_profiler, "commit to quotient codeword segments");
prof_start!(maybe_profiler, "LDE", "LDE");
Expand Down
3 changes: 3 additions & 0 deletions triton-vm/src/table/extension_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ use crate::arithmetic_domain::ArithmeticDomain;
use crate::table::challenges::Challenges;
use crate::table::master_table::MasterExtTable;

/// The implementations of these functions are automatically generated using the
/// command `cargo run --bin constraint-evaluation-generator` and live in
/// `constraints.rs`.
pub trait Evaluable<FF: FiniteField> {
/// The code for this method must be generated by running
/// `cargo run --bin constraint-evaluation-generator`
Expand Down

0 comments on commit 006d795

Please sign in to comment.