Skip to content

Commit

Permalink
docs: Fix intra-doc links
Browse files Browse the repository at this point in the history
changelog: ignore
  • Loading branch information
jan-ferdinand committed Sep 4, 2024
1 parent 65545fe commit d83b806
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 70 deletions.
64 changes: 42 additions & 22 deletions triton-air/src/challenge_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,28 @@ use strum::EnumIter;
#[repr(usize)]
#[derive(Debug, Display, Copy, Clone, Eq, PartialEq, Hash, EnumCount, EnumIter, Arbitrary)]
pub enum ChallengeId {
/// The indeterminate for the [Evaluation Argument](EvalArg) compressing the program digest
/// into a single extension field element, _i.e._, [`CompressedProgramDigest`].
/// The indeterminate for the [Evaluation Argument][eval] compressing the program digest
/// into a single extension field element, _i.e._,
/// [`CompressedProgramDigest`][Self::CompressedProgramDigest].
/// Relates to program attestation.
///
/// [eval]: crate::cross_table_argument::EvalArg
CompressProgramDigestIndeterminate,

/// The indeterminate for the [Evaluation Argument](EvalArg) with standard input.
/// The indeterminate for the [Evaluation Argument][eval] with standard input.
///
/// [eval]: crate::cross_table_argument::EvalArg
StandardInputIndeterminate,

/// The indeterminate for the [Evaluation Argument](EvalArg) with standard output.
/// The indeterminate for the [Evaluation Argument][eval] with standard output.
///
/// [eval]: crate::cross_table_argument::EvalArg
StandardOutputIndeterminate,

/// The indeterminate for the instruction
/// [Lookup Argument](crate::table::cross_table_argument::LookupArg)
/// between the [Processor Table](crate::table::processor_table) and the
/// [Program Table](crate::table::program_table) guaranteeing that the instructions and their
/// [Lookup Argument](crate::cross_table_argument::LookupArg)
/// between the [Processor Table](crate::table::processor) and the
/// [Program Table](crate::table::program) guaranteeing that the instructions and their
/// arguments are copied correctly.
InstructionLookupIndeterminate,

Expand Down Expand Up @@ -87,18 +94,20 @@ pub enum ChallengeId {
///
/// Used by the evaluation argument [`PrepareChunkEvalArg`][prep] and in the Hash Table.
///
/// [rate]: tip5::RATE
/// [prep]: crate::table::table_column::ProgramExtTableColumn::PrepareChunkRunningEvaluation
/// [rate]: twenty_first::prelude::tip5::RATE
/// [prep]: crate::table_column::ProgramExtTableColumn::PrepareChunkRunningEvaluation
ProgramAttestationPrepareChunkIndeterminate,

/// The indeterminate for the bus over which the [`RATE`][rate]-sized chunks of instructions
/// are sent. Relates to program attestation.
/// Used by the evaluation arguments [`SendChunkEvalArg`][send] and
/// [`ReceiveChunkEvalArg`][recv]. See also: [`ProgramAttestationPrepareChunkIndeterminate`].
/// [`ReceiveChunkEvalArg`][recv]. See also:
/// [`ProgramAttestationPrepareChunkIndeterminate`][ind].
///
/// [rate]: tip5::RATE
/// [send]: crate::table::table_column::ProgramExtTableColumn::SendChunkRunningEvaluation
/// [recv]: crate::table::table_column::HashExtTableColumn::ReceiveChunkRunningEvaluation
/// [rate]: twenty_first::prelude::tip5::RATE
/// [send]: crate::table_column::ProgramExtTableColumn::SendChunkRunningEvaluation
/// [recv]: crate::table_column::HashExtTableColumn::ReceiveChunkRunningEvaluation
/// [ind]: ChallengeId::ProgramAttestationPrepareChunkIndeterminate
ProgramAttestationSendChunkIndeterminate,

HashCIWeight,
Expand Down Expand Up @@ -160,23 +169,34 @@ pub enum ChallengeId {
// When modifying this, be sure to add to the compile-time assertions in the
// `#[test] const fn compile_time_index_assertions() { … }`
// at the end of this file.
/// The terminal for the [`EvaluationArgument`](EvalArg) with standard input.
/// Makes use of challenge [`StandardInputIndeterminate`].
/// The terminal for the [`EvaluationArgument`][eval] with standard input.
/// Makes use of challenge
/// [`StandardInputIndeterminate`][Self::StandardInputIndeterminate].
///
/// [eval]: crate::cross_table_argument::EvalArg
StandardInputTerminal,

/// The terminal for the [`EvaluationArgument`](EvalArg) with standard output.
/// Makes use of challenge [`StandardOutputIndeterminate`].
/// The terminal for the [`EvaluationArgument`][eval] with standard output.
/// Makes use of challenge
/// [`StandardOutputIndeterminate`][Self::StandardOutputIndeterminate].
///
/// [eval]: crate::cross_table_argument::EvalArg
StandardOutputTerminal,

/// The terminal for the [`EvaluationArgument`](EvalArg) establishing correctness of the
/// [Lookup Table](crate::table::lookup_table::LookupTable).
/// Makes use of challenge [`LookupTablePublicIndeterminate`].
/// The terminal for the [`EvaluationArgument`][eval] establishing correctness of the
/// [Lookup Table](crate::table::lookup::LookupTable).
/// Makes use of challenge
/// [`LookupTablePublicIndeterminate`][Self::LookupTablePublicIndeterminate].
///
/// [eval]: crate::cross_table_argument::EvalArg
LookupTablePublicTerminal,

/// The digest of the program to be executed, compressed into a single extension field element.
/// The compression happens using an [`EvaluationArgument`](EvalArg) under challenge
/// [`CompressProgramDigestIndeterminate`].
/// The compression happens using an [`EvaluationArgument`][eval] under challenge
/// [`CompressProgramDigestIndeterminate`][Self::CompressProgramDigestIndeterminate].
/// Relates to program attestation.
///
/// [eval]: crate::cross_table_argument::EvalArg
CompressedProgramDigest,
}

Expand Down
11 changes: 2 additions & 9 deletions triton-air/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub mod table_column;
///
/// Using substitution and the introduction of new variables, the degree of the AIR as specified
/// in the respective tables
/// (e.g., in [`processor_table::ExtProcessorTable::transition_constraints`])
/// (e.g., in [`table::processor::ProcessorTable::transition_constraints`])
/// is lowered to this value.
/// For example, with a target degree of 2 and a (fictional) constraint of the form
/// `a = b²·c²·d`,
Expand All @@ -25,14 +25,7 @@ pub mod table_column;
/// - introduce new constraints `e = b²`, `f = c²`, and `g = e·f`,
/// - replace the original constraint with `a = g·d`.
///
/// The degree lowering happens in the constraint evaluation generator.
/// It can be executed by running `cargo run --bin constraint-evaluation-generator`.
/// Executing the constraint evaluator is a prerequisite for running both the Stark prover
/// and the Stark verifier.
///
/// The new variables introduced by the degree lowering step are called “derived columns.”
/// They are added to the [`DegreeLoweringTable`], whose sole purpose is to store the values
/// of these derived columns.
/// The degree lowering happens in the Triton VM's build script, `build.rs`.
pub const TARGET_DEGREE: isize = 4;

pub trait AIR {
Expand Down
16 changes: 9 additions & 7 deletions triton-air/src/table/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ use crate::table_column::MasterBaseTableColumn;
use crate::table_column::MasterExtTableColumn;
use crate::AIR;

/// See [`HashTable::base_field_element_into_16_bit_limbs`] for more details.
pub const MONTGOMERY_MODULUS: BFieldElement =
BFieldElement::new(((1_u128 << 64) % BFieldElement::P as u128) as u64);

pub const POWER_MAP_EXPONENT: u64 = 7;
pub const NUM_ROUND_CONSTANTS: usize = tip5::STATE_SIZE;
const POWER_MAP_EXPONENT: u64 = 7;
const NUM_ROUND_CONSTANTS: usize = tip5::STATE_SIZE;

pub const PERMUTATION_TRACE_LENGTH: usize = NUM_ROUNDS + 1;

Expand Down Expand Up @@ -159,9 +158,11 @@ impl HashTable {
.fold(constant(1), |accumulator, factor| accumulator * factor)
}

/// The [`HashBaseTableColumn`] for the round constant corresponding to the given index.
/// The [main column][col] for the round constant corresponding to the given index.
/// Valid indices are 0 through 15, corresponding to the 16 round constants
/// [`Constant0`] through [`Constant15`].
/// `Constant0` through `Constant15`.
///
/// [col]: crate::table_column::HashBaseTableColumn
pub fn round_constant_column_by_index(index: usize) -> <Self as AIR>::MainColumn {
match index {
0 => <Self as AIR>::MainColumn::Constant0,
Expand Down Expand Up @@ -1329,8 +1330,8 @@ impl AIR for HashTable {
/// 1. Processing the `hash` instruction.
/// 1. Padding mode.
///
/// Changing the mode is only possible when the current [`RoundNumber`] is [`NUM_ROUNDS`].
/// The mode evolves as
/// Changing the mode is only possible when the current [`RoundNumber`][round_no]
/// is [`NUM_ROUNDS`]. The mode evolves as
/// [`ProgramHashing`][prog_hash] → [`Sponge`][sponge] → [`Hash`][hash] → [`Pad`][pad].
/// Once mode [`Pad`][pad] is reached, it is not possible to change the mode anymore.
/// Skipping any or all of the modes [`Sponge`][sponge], [`Hash`][hash], or [`Pad`][pad]
Expand All @@ -1344,6 +1345,7 @@ impl AIR for HashTable {
/// The empty program is not valid since any valid [`Program`][program] must execute
/// instruction `halt`.
///
/// [round_no]: crate::table_column::HashBaseTableColumn::RoundNumber
/// [program]: isa::program::Program
/// [prog_hash]: HashTableMode::ProgramHashing
/// [sponge]: HashTableMode::Sponge
Expand Down
18 changes: 9 additions & 9 deletions triton-air/src/table_column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ pub enum RamBaseTableColumn {
/// Is [`INSTRUCTION_TYPE_READ`] for instruction `read_mem` and [`INSTRUCTION_TYPE_WRITE`]
/// for instruction `write_mem`. For padding rows, this is set to [`PADDING_INDICATOR`].
///
/// [`INSTRUCTION_TYPE_READ`]: crate::table::ram_table::INSTRUCTION_TYPE_READ
/// [`INSTRUCTION_TYPE_WRITE`]: crate::table::ram_table::INSTRUCTION_TYPE_WRITE
/// [`PADDING_INDICATOR`]: crate::table::ram_table::PADDING_INDICATOR
/// [`INSTRUCTION_TYPE_READ`]: crate::table::ram::INSTRUCTION_TYPE_READ
/// [`INSTRUCTION_TYPE_WRITE`]: crate::table::ram::INSTRUCTION_TYPE_WRITE
/// [`PADDING_INDICATOR`]: crate::table::ram::PADDING_INDICATOR
InstructionType,
RamPointer,
RamValue,
Expand Down Expand Up @@ -236,14 +236,14 @@ pub enum JumpStackExtTableColumn {
pub enum HashBaseTableColumn {
/// The indicator for the [`HashTableMode`][mode].
///
/// [mode]: crate::table::hash_table::HashTableMode
/// [mode]: crate::table::hash::HashTableMode
Mode,

/// The current instruction. Only relevant for [`Mode`][mode] [`Sponge`][mode_sponge]
/// in order to distinguish between the different Sponge instructions.
///
/// [mode]: HashBaseTableColumn::Mode
/// [mode_sponge]: crate::table::hash_table::HashTableMode::Sponge
/// [mode_sponge]: crate::table::hash::HashTableMode::Sponge
CI,

/// The number of the current round in the permutation. The round number evolves as
Expand All @@ -255,10 +255,10 @@ pub enum HashBaseTableColumn {
///
/// [ci]: HashBaseTableColumn::CI
/// [mode]: HashBaseTableColumn::Mode
/// [mode_prog_hash]: crate::table::hash_table::HashTableMode::ProgramHashing
/// [mode_sponge]: crate::table::hash_table::HashTableMode::Sponge
/// [mode_hash]: crate::table::hash_table::HashTableMode::Hash
/// [mode_pad]: crate::table::hash_table::HashTableMode::Pad
/// [mode_prog_hash]: crate::table::hash::HashTableMode::ProgramHashing
/// [mode_sponge]: crate::table::hash::HashTableMode::Sponge
/// [mode_hash]: crate::table::hash::HashTableMode::Hash
/// [mode_pad]: crate::table::hash::HashTableMode::Pad
RoundNumber,

State0HighestLkIn,
Expand Down
2 changes: 1 addition & 1 deletion triton-constraint-builder/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ impl Codegen for TasmBackend {
/// Emits a function that emits [Triton assembly][tasm] that evaluates Triton VM's AIR
/// constraints over the [extension field][XFieldElement].
///
/// [tasm]: triton_vm::prelude::triton_asm
/// [tasm]: isa::triton_asm
fn constraint_evaluation_code(constraints: &Constraints) -> TokenStream {
let doc_comment = Self::doc_comment_static_version();

Expand Down
4 changes: 2 additions & 2 deletions triton-vm/src/aet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@ impl AlgebraicExecutionTrace {
///
/// Guaranteed to be a power of two.
///
/// [pad]: master_table::MasterBaseTable::pad
/// [pad]: table::master_table::MasterBaseTable::pad
pub fn padded_height(&self) -> usize {
self.height().height.next_power_of_two()
}

/// The height of the [AET](AlgebraicExecutionTrace) before [padding][pad].
/// Corresponds to the height of the longest table.
///
/// [pad]: master_table::MasterBaseTable::pad
/// [pad]: table::master_table::MasterBaseTable::pad
pub fn height(&self) -> TableHeight {
TableId::iter()
.map(|t| TableHeight::new(t, self.height_of_table(t)))
Expand Down
26 changes: 15 additions & 11 deletions triton-vm/src/challenges.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Challenges are needed for the [cross-table arguments](CrossTableArg), _i.e._,
//! [Permutation Arguments](crate::cross_table_argument::PermArg),
//! [Evaluation Arguments](crate::cross_table_argument::EvalArg), and
//! [Lookup Arguments](crate::cross_table_argument::LookupArg),
//! [Permutation Arguments](air::cross_table_argument::PermArg),
//! [Evaluation Arguments](EvalArg), and
//! [Lookup Arguments](air::cross_table_argument::LookupArg),
//! as well as for the RAM Table's Contiguity Argument.
//!
//! There are three types of challenges:
Expand Down Expand Up @@ -50,14 +50,18 @@ impl Challenges {
/// from publicly known values and other, sampled challenges.
///
/// Concretely:
/// - The [`StandardInputTerminal`] is computed from Triton VM's public input and the sampled
/// indeterminate [`StandardInputIndeterminate`].
/// - The [`StandardOutputTerminal`] is computed from Triton VM's public output and the sampled
/// indeterminate [`StandardOutputIndeterminate`].
/// - The [`LookupTablePublicTerminal`] is computed from the publicly known and constant
/// lookup table and the sampled indeterminate [`LookupTablePublicIndeterminate`].
/// - The [`CompressedProgramDigest`] is computed from the program to be executed and the
/// sampled indeterminate [`CompressProgramDigestIndeterminate`].
/// - The [`StandardInputTerminal`][ChallengeId::StandardInputTerminal] is computed
/// from Triton VM's public input and the sampled indeterminate
/// [`StandardInputIndeterminate`][ChallengeId::StandardInputIndeterminate].
/// - The [`StandardOutputTerminal`][ChallengeId::StandardOutputTerminal] is computed
/// from Triton VM's public output and the sampled indeterminate
/// [`StandardOutputIndeterminate`][ChallengeId::StandardOutputIndeterminate].
/// - The [`LookupTablePublicTerminal`][ChallengeId::LookupTablePublicTerminal] is
/// computed from the publicly known and constant lookup table and the sampled indeterminate
/// [`LookupTablePublicIndeterminate`][ChallengeId::LookupTablePublicIndeterminate].
/// - The [`CompressedProgramDigest`][ChallengeId::CompressedProgramDigest] is computed
/// from the program to be executed and the sampled indeterminate
/// [`CompressProgramDigestIndeterminate`][ChallengeId::CompressProgramDigestIndeterminate].
pub const SAMPLE_COUNT: usize = Self::COUNT - ChallengeId::NUM_DERIVED_CHALLENGES;

pub fn new(mut challenges: Vec<XFieldElement>, claim: &Claim) -> Self {
Expand Down
4 changes: 2 additions & 2 deletions triton-vm/src/stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,8 @@ impl Stark {
/// length of the execution trace and the FRI expansion factor, a security parameter.
///
/// In principle, the FRI domain is also influenced by the AIR's degree
/// (see [`TARGET_DEGREE`]). However, by segmenting the quotient polynomial into
/// [`TARGET_DEGREE`]-many parts, that influence is mitigated.
/// (see [`air::TARGET_DEGREE`]). However, by segmenting the quotient polynomial into
/// `TARGET_DEGREE`-many parts, that influence is mitigated.
pub fn derive_fri(&self, padded_height: usize) -> fri::SetupResult<Fri> {
let interpolant_degree = interpolant_degree(padded_height, self.num_trace_randomizers);
let interpolant_codeword_length = interpolant_degree as usize + 1;
Expand Down
8 changes: 2 additions & 6 deletions triton-vm/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,14 @@ pub enum ConstraintType {
Terminal,
}

/// A single row of a [`MasterBaseTable`][table].
/// A single row of a [`MasterBaseTable`].
///
/// Usually, the elements in the table are [`BFieldElement`]s. For out-of-domain rows, which is
/// relevant for “Domain Extension to Eliminate Pretenders” (DEEP), the elements are
/// [`XFieldElement`]s.
///
/// [table]: master_table::MasterBaseTable
pub type BaseRow<T> = [T; MasterBaseTable::NUM_COLUMNS];

/// A single row of a [`MasterExtensionTable`][table].
///
/// [table]: master_table::MasterExtTable
/// A single row of a [`MasterExtTable`].
pub type ExtensionRow = [XFieldElement; MasterExtTable::NUM_COLUMNS];

/// An element of the split-up quotient polynomial.
Expand Down
2 changes: 1 addition & 1 deletion triton-vm/src/table/master_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ use crate::table::*;
/// [`MasterExtensionTable`][master_ext_table] but does induce a nonzero number of constraints
/// and thus terms in the [quotient combination][all_quotients_combined].
///
/// [cross_arg]: cross_table_argument::GrandCrossTableArg
/// [cross_arg]: air::cross_table_argument::GrandCrossTableArg
/// [overwrite_cache]: crate::config::overwrite_lde_trace_caching_to
/// [lde]: Self::low_degree_extend_all_columns
/// [quot_table]: Self::quotient_domain_table
Expand Down

0 comments on commit d83b806

Please sign in to comment.