diff --git a/expander_compiler/src/frontend/api.rs b/expander_compiler/src/frontend/api.rs index 1277620..8c7df53 100644 --- a/expander_compiler/src/frontend/api.rs +++ b/expander_compiler/src/frontend/api.rs @@ -20,7 +20,7 @@ pub trait BasicAPI { binary_op!(or); binary_op!(and); - fn display(&self, _x: impl ToVariableOrValue) {} + fn display(&self, _label: &str, _x: impl ToVariableOrValue) {} fn div( &mut self, x: impl ToVariableOrValue, @@ -78,15 +78,7 @@ pub trait UnconstrainedAPI { binary_op!(unconstrained_bit_xor); } -// DebugAPI is used for debugging purposes -// Only DebugBuilder will implement functions in this trait, other builders will panic -pub trait DebugAPI { - fn value_of(&self, x: impl ToVariableOrValue) -> C::CircuitField; -} - -pub trait RootAPI: - Sized + BasicAPI + UnconstrainedAPI + DebugAPI + 'static -{ +pub trait RootAPI: Sized + BasicAPI + UnconstrainedAPI + 'static { fn memorized_simple_call) -> Vec + 'static>( &mut self, f: F, diff --git a/expander_compiler/src/frontend/builder.rs b/expander_compiler/src/frontend/builder.rs index 3fc8b2e..2027c51 100644 --- a/expander_compiler/src/frontend/builder.rs +++ b/expander_compiler/src/frontend/builder.rs @@ -17,7 +17,7 @@ use crate::{ utils::function_id::get_function_id, }; -use super::api::{BasicAPI, DebugAPI, RootAPI, UnconstrainedAPI}; +use super::api::{BasicAPI, RootAPI, UnconstrainedAPI}; pub struct Builder { instructions: Vec>, @@ -447,12 +447,6 @@ impl RootAPI for RootBuilder { } } -impl DebugAPI for RootBuilder { - fn value_of(&self, _x: impl ToVariableOrValue) -> C::CircuitField { - panic!("ValueOf is not supported in non-debug mode"); - } -} - impl RootBuilder { pub fn new( num_inputs: usize, diff --git a/expander_compiler/src/frontend/debug.rs b/expander_compiler/src/frontend/debug.rs index 85885c0..85334f5 100644 --- a/expander_compiler/src/frontend/debug.rs +++ b/expander_compiler/src/frontend/debug.rs @@ -10,7 +10,7 @@ use crate::{ }; use super::{ - api::{BasicAPI, DebugAPI, RootAPI, UnconstrainedAPI}, + api::{BasicAPI, RootAPI, UnconstrainedAPI}, builder::{get_variable_id, new_variable, ToVariableOrValue, VariableOrValue}, Variable, }; @@ -20,9 +20,9 @@ pub struct DebugBuilder { } impl BasicAPI for DebugBuilder { - fn display(&self, x: impl ToVariableOrValue<::CircuitField>) { + fn display(&self, str: &str, x: impl ToVariableOrValue<::CircuitField>) { let x = self.convert_to_value(x); - println!("x: {:?}", x); + println!("{}: {:?}", str, x); } fn add( @@ -372,12 +372,6 @@ impl UnconstrainedAPI for DebugBuilder { } } -impl DebugAPI for DebugBuilder { - fn value_of(&self, x: impl ToVariableOrValue) -> C::CircuitField { - self.convert_to_value(x) - } -} - impl RootAPI for DebugBuilder { fn memorized_simple_call) -> Vec + 'static>( &mut self, diff --git a/expander_compiler/src/frontend/mod.rs b/expander_compiler/src/frontend/mod.rs index fe2ffea..99ab895 100644 --- a/expander_compiler/src/frontend/mod.rs +++ b/expander_compiler/src/frontend/mod.rs @@ -29,7 +29,7 @@ pub mod internal { } pub mod extra { - pub use super::api::{DebugAPI, UnconstrainedAPI}; + pub use super::api::UnconstrainedAPI; pub use super::debug::DebugBuilder; pub use crate::utils::serde::Serde; diff --git a/rsa_circuit/src/tests/u2048_mul_no_mod.rs b/rsa_circuit/src/tests/u2048_mul_no_mod.rs index f75a496..a0ebaf7 100644 --- a/rsa_circuit/src/tests/u2048_mul_no_mod.rs +++ b/rsa_circuit/src/tests/u2048_mul_no_mod.rs @@ -28,11 +28,7 @@ impl GenericDefine for MulNoModCircuit { let res = U2048Variable::mul_without_mod_reduction(&x, &y, &two_to_120, builder); - // for i in 0..2 * N_LIMBS { - // println!("{i}"); - // builder.display(res[i]); - // builder.display(self.result[i]); - // } + // builder.display("first limb", x.limbs[0]); for i in 0..2 * N_LIMBS { builder.assert_is_equal(res[i], self.result[i]);