diff --git a/crates/proof-of-sql/src/sql/mod.rs b/crates/proof-of-sql/src/sql/mod.rs index dc3914b3d..d185a21c2 100644 --- a/crates/proof-of-sql/src/sql/mod.rs +++ b/crates/proof-of-sql/src/sql/mod.rs @@ -3,4 +3,5 @@ pub mod parse; pub mod postprocessing; pub mod proof; pub mod proof_exprs; +pub mod proof_gadgets; pub mod proof_plans; diff --git a/crates/proof-of-sql/src/sql/proof_exprs/inequality_expr.rs b/crates/proof-of-sql/src/sql/proof_exprs/inequality_expr.rs index b9d204966..f3f416e10 100644 --- a/crates/proof-of-sql/src/sql/proof_exprs/inequality_expr.rs +++ b/crates/proof-of-sql/src/sql/proof_exprs/inequality_expr.rs @@ -1,8 +1,7 @@ use super::{ - prover_evaluate_equals_zero, prover_evaluate_or, prover_evaluate_sign, - result_evaluate_equals_zero, result_evaluate_or, result_evaluate_sign, - scale_and_add_subtract_eval, scale_and_subtract, verifier_evaluate_equals_zero, - verifier_evaluate_or, verifier_evaluate_sign, DynProofExpr, ProofExpr, + prover_evaluate_equals_zero, prover_evaluate_or, result_evaluate_equals_zero, + result_evaluate_or, scale_and_add_subtract_eval, scale_and_subtract, + verifier_evaluate_equals_zero, verifier_evaluate_or, DynProofExpr, ProofExpr, }; use crate::{ base::{ @@ -11,7 +10,10 @@ use crate::{ proof::ProofError, scalar::Scalar, }, - sql::proof::{FinalRoundBuilder, VerificationBuilder}, + sql::{ + proof::{FinalRoundBuilder, VerificationBuilder}, + proof_gadgets::{prover_evaluate_sign, result_evaluate_sign, verifier_evaluate_sign}, + }, utils::log, }; use alloc::boxed::Box; diff --git a/crates/proof-of-sql/src/sql/proof_exprs/mod.rs b/crates/proof-of-sql/src/sql/proof_exprs/mod.rs index cb5c7303a..298ad945d 100644 --- a/crates/proof-of-sql/src/sql/proof_exprs/mod.rs +++ b/crates/proof-of-sql/src/sql/proof_exprs/mod.rs @@ -20,11 +20,6 @@ use multiply_expr::MultiplyExpr; #[cfg(all(test, feature = "blitzar"))] mod multiply_expr_test; -mod bitwise_verification; -use bitwise_verification::{verify_constant_abs_decomposition, verify_constant_sign_decomposition}; -#[cfg(test)] -mod bitwise_verification_test; - mod dyn_proof_expr; pub(crate) use dyn_proof_expr::DynProofExpr; @@ -69,11 +64,6 @@ use equals_expr::{ #[cfg(all(test, feature = "blitzar"))] mod equals_expr_test; -mod sign_expr; -use sign_expr::{prover_evaluate_sign, result_evaluate_sign, verifier_evaluate_sign}; -#[cfg(all(test, feature = "blitzar"))] -mod sign_expr_test; - mod table_expr; pub(crate) use table_expr::TableExpr; diff --git a/crates/proof-of-sql/src/sql/proof_exprs/bitwise_verification.rs b/crates/proof-of-sql/src/sql/proof_gadgets/bitwise_verification.rs similarity index 100% rename from crates/proof-of-sql/src/sql/proof_exprs/bitwise_verification.rs rename to crates/proof-of-sql/src/sql/proof_gadgets/bitwise_verification.rs diff --git a/crates/proof-of-sql/src/sql/proof_exprs/bitwise_verification_test.rs b/crates/proof-of-sql/src/sql/proof_gadgets/bitwise_verification_test.rs similarity index 100% rename from crates/proof-of-sql/src/sql/proof_exprs/bitwise_verification_test.rs rename to crates/proof-of-sql/src/sql/proof_gadgets/bitwise_verification_test.rs diff --git a/crates/proof-of-sql/src/sql/proof_gadgets/mod.rs b/crates/proof-of-sql/src/sql/proof_gadgets/mod.rs new file mode 100644 index 000000000..0ec348767 --- /dev/null +++ b/crates/proof-of-sql/src/sql/proof_gadgets/mod.rs @@ -0,0 +1,12 @@ +//! This module contains shared proof logic for multiple `ProofExpr` / `ProofPlan` implementations. +mod bitwise_verification; +use bitwise_verification::{verify_constant_abs_decomposition, verify_constant_sign_decomposition}; +#[cfg(test)] +mod bitwise_verification_test; +mod sign_expr; +pub(crate) use sign_expr::{prover_evaluate_sign, result_evaluate_sign, verifier_evaluate_sign}; +pub mod range_check; +#[cfg(all(test, feature = "blitzar"))] +pub mod range_check_test; +#[cfg(all(test, feature = "blitzar"))] +mod sign_expr_test; diff --git a/crates/proof-of-sql/src/sql/proof_plans/range_check.rs b/crates/proof-of-sql/src/sql/proof_gadgets/range_check.rs similarity index 99% rename from crates/proof-of-sql/src/sql/proof_plans/range_check.rs rename to crates/proof-of-sql/src/sql/proof_gadgets/range_check.rs index 931d9733f..7a699b0ce 100644 --- a/crates/proof-of-sql/src/sql/proof_plans/range_check.rs +++ b/crates/proof-of-sql/src/sql/proof_gadgets/range_check.rs @@ -403,12 +403,10 @@ where #[cfg(test)] mod tests { + use super::*; use crate::{ base::scalar::{Curve25519Scalar as S, Scalar}, - sql::{ - proof::FinalRoundBuilder, - proof_plans::range_check::{decompose_scalar_to_words, get_logarithmic_derivative}, - }, + sql::proof::FinalRoundBuilder, }; use bumpalo::Bump; use num_traits::Inv; diff --git a/crates/proof-of-sql/src/sql/proof_plans/range_check_test_plan.rs b/crates/proof-of-sql/src/sql/proof_gadgets/range_check_test.rs similarity index 97% rename from crates/proof-of-sql/src/sql/proof_plans/range_check_test_plan.rs rename to crates/proof-of-sql/src/sql/proof_gadgets/range_check_test.rs index 446bd077e..8bd046043 100644 --- a/crates/proof-of-sql/src/sql/proof_plans/range_check_test_plan.rs +++ b/crates/proof-of-sql/src/sql/proof_gadgets/range_check_test.rs @@ -92,15 +92,13 @@ impl ProofPlan for RangeCheckTestPlan { #[cfg(all(test, feature = "blitzar"))] mod tests { - + use super::*; use crate::{ base::database::{ owned_table_utility::{owned_table, scalar}, ColumnRef, ColumnType, OwnedTableTestAccessor, }, - sql::{ - proof::VerifiableQueryResult, proof_plans::range_check_test_plan::RangeCheckTestPlan, - }, + sql::proof::VerifiableQueryResult, }; use blitzar::proof::InnerProductProof; diff --git a/crates/proof-of-sql/src/sql/proof_exprs/sign_expr.rs b/crates/proof-of-sql/src/sql/proof_gadgets/sign_expr.rs similarity index 100% rename from crates/proof-of-sql/src/sql/proof_exprs/sign_expr.rs rename to crates/proof-of-sql/src/sql/proof_gadgets/sign_expr.rs diff --git a/crates/proof-of-sql/src/sql/proof_exprs/sign_expr_test.rs b/crates/proof-of-sql/src/sql/proof_gadgets/sign_expr_test.rs similarity index 100% rename from crates/proof-of-sql/src/sql/proof_exprs/sign_expr_test.rs rename to crates/proof-of-sql/src/sql/proof_gadgets/sign_expr_test.rs diff --git a/crates/proof-of-sql/src/sql/proof_plans/mod.rs b/crates/proof-of-sql/src/sql/proof_plans/mod.rs index c56ee5ff7..3a5edb7d0 100644 --- a/crates/proof-of-sql/src/sql/proof_plans/mod.rs +++ b/crates/proof-of-sql/src/sql/proof_plans/mod.rs @@ -50,7 +50,3 @@ pub use dyn_proof_plan::DynProofPlan; #[cfg(test)] mod demo_mock_plan; - -pub mod range_check; -#[cfg(all(test, feature = "blitzar"))] -pub mod range_check_test_plan;