diff --git a/plonky2x/src/backend/circuit/mock.rs b/plonky2x/src/backend/circuit/mock.rs index 25afc7fff..3861c25f4 100644 --- a/plonky2x/src/backend/circuit/mock.rs +++ b/plonky2x/src/backend/circuit/mock.rs @@ -30,6 +30,7 @@ impl, const D: usize> MockCircuitBuild { PublicInput::new(&self.io) } + /// Generates a mock proof. pub fn mock_prove( &self, input: &PublicInput, diff --git a/plonky2x/src/frontend/builder/mod.rs b/plonky2x/src/frontend/builder/mod.rs index a0adb6978..4338d3629 100644 --- a/plonky2x/src/frontend/builder/mod.rs +++ b/plonky2x/src/frontend/builder/mod.rs @@ -25,6 +25,7 @@ use super::vars::EvmVariable; use crate::backend::circuit::{CircuitBuild, DefaultParameters, MockCircuitBuild, PlonkParameters}; use crate::frontend::hint::asynchronous::generator::AsyncHintDataRef; use crate::frontend::vars::{BoolVariable, CircuitVariable, Variable}; +use crate::prelude::ArrayVariable; use crate::utils::eth::beacon::BeaconClient; use crate::utils::eth::beaconchain::BeaconchainAPIClient; @@ -264,6 +265,16 @@ impl, const D: usize> CircuitBuilder { V::init(self) } + /// Initializes an array of variables with no value in the circuit. + pub fn init_array(&mut self) -> ArrayVariable { + ArrayVariable::init(self) + } + + /// Initializes an array of variables with no value in the circuit without any validity checks. + pub fn init_array_unsafe(&mut self) -> ArrayVariable { + ArrayVariable::init_unsafe(self) + } + /// Initializes a variable with no value in the circuit without any validity checks. pub fn init_unsafe(&mut self) -> V { V::init_unsafe(self) @@ -274,6 +285,15 @@ impl, const D: usize> CircuitBuilder { V::constant(self, value) } + /// Initializes an array of variables with a constant value in the circuit. + pub fn constant_array( + &mut self, + value: &[V::ValueType], + ) -> ArrayVariable { + assert_eq!(value.len(), N); + ArrayVariable::constant(self, value.to_vec()) + } + /// Asserts that the given variable is valid. pub fn assert_is_valid(&mut self, variable: V) { variable.assert_is_valid(self)