Skip to main content

miden_prover/
proving_options.rs

1use miden_core::proof::HashFunction;
2use miden_processor::ExecutionOptions;
3
4// PROVING OPTIONS
5// ================================================================================================
6
7/// A set of parameters specifying how Miden VM execution proofs are to be generated.
8///
9/// This struct combines execution options (VM parameters) with the hash function to use
10/// for proof generation. The actual STARK proving parameters (FRI config, security level, etc.)
11/// are determined by the hash function and hardcoded in the prover's config module.
12#[derive(Debug, Clone, Eq, PartialEq)]
13pub struct ProvingOptions {
14    exec_options: ExecutionOptions,
15    hash_fn: HashFunction,
16}
17
18impl ProvingOptions {
19    // CONSTRUCTORS
20    // --------------------------------------------------------------------------------------------
21
22    /// Creates a new instance of [ProvingOptions] with the specified hash function.
23    ///
24    /// The STARK proving parameters (security level, FRI config, etc.) are determined
25    /// by the hash function and hardcoded in the prover's config module.
26    pub fn new(hash_fn: HashFunction) -> Self {
27        Self {
28            exec_options: ExecutionOptions::default(),
29            hash_fn,
30        }
31    }
32
33    /// Creates a new instance of [ProvingOptions] targeting 96-bit security level.
34    ///
35    /// Note: The actual security parameters are hardcoded in the prover's config module.
36    /// This is a convenience constructor that is equivalent to `new(hash_fn)`.
37    pub fn with_96_bit_security(hash_fn: HashFunction) -> Self {
38        Self::new(hash_fn)
39    }
40
41    /// Sets [ExecutionOptions] for this [ProvingOptions].
42    ///
43    /// This sets the maximum number of cycles a program is allowed to execute as well as
44    /// the number of cycles the program is expected to execute.
45    pub fn with_execution_options(mut self, exec_options: ExecutionOptions) -> Self {
46        self.exec_options = exec_options;
47        self
48    }
49
50    // PUBLIC ACCESSORS
51    // --------------------------------------------------------------------------------------------
52
53    /// Returns the hash function to be used in STARK proof generation.
54    pub const fn hash_fn(&self) -> HashFunction {
55        self.hash_fn
56    }
57
58    /// Returns the execution options specified for this [ProvingOptions]
59    pub const fn execution_options(&self) -> &ExecutionOptions {
60        &self.exec_options
61    }
62}
63
64impl Default for ProvingOptions {
65    fn default() -> Self {
66        Self::new(HashFunction::Blake3_256)
67    }
68}