From cd790c404ea13171846b3dcaec82c79f53a13579 Mon Sep 17 00:00:00 2001 From: Ian Joiner <14581281+iajoiner@users.noreply.github.com> Date: Fri, 13 Dec 2024 16:52:14 -0500 Subject: [PATCH 1/2] refactor: move proof pieces used by `ProofExpr`s and `ProofPlan`s to `proof_gadgets` --- crates/proof-of-sql/src/sql/mod.rs | 1 + .../src/sql/proof_exprs/inequality_expr.rs | 12 +++++++----- crates/proof-of-sql/src/sql/proof_exprs/mod.rs | 10 ---------- .../bitwise_verification.rs | 0 .../bitwise_verification_test.rs | 0 crates/proof-of-sql/src/sql/proof_gadgets/mod.rs | 12 ++++++++++++ .../{proof_plans => proof_gadgets}/range_check.rs | 2 +- .../range_check_test_plan.rs | 4 ++-- .../sql/{proof_exprs => proof_gadgets}/sign_expr.rs | 0 .../{proof_exprs => proof_gadgets}/sign_expr_test.rs | 0 crates/proof-of-sql/src/sql/proof_plans/mod.rs | 4 ---- 11 files changed, 23 insertions(+), 22 deletions(-) rename crates/proof-of-sql/src/sql/{proof_exprs => proof_gadgets}/bitwise_verification.rs (100%) rename crates/proof-of-sql/src/sql/{proof_exprs => proof_gadgets}/bitwise_verification_test.rs (100%) create mode 100644 crates/proof-of-sql/src/sql/proof_gadgets/mod.rs rename crates/proof-of-sql/src/sql/{proof_plans => proof_gadgets}/range_check.rs (99%) rename crates/proof-of-sql/src/sql/{proof_plans => proof_gadgets}/range_check_test_plan.rs (98%) rename crates/proof-of-sql/src/sql/{proof_exprs => proof_gadgets}/sign_expr.rs (100%) rename crates/proof-of-sql/src/sql/{proof_exprs => proof_gadgets}/sign_expr_test.rs (100%) 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..a1fba600a --- /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}; +#[cfg(all(test, feature = "blitzar"))] +mod sign_expr_test; +pub mod range_check; +#[cfg(all(test, feature = "blitzar"))] +pub mod range_check_test_plan; \ No newline at end of file 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..d668b80d1 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,11 +403,11 @@ 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}, }, }; use bumpalo::Bump; 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_plan.rs similarity index 98% 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_plan.rs index 446bd077e..d7a401ac5 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_plan.rs @@ -92,14 +92,14 @@ 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, + 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; From db711cde11c22827ba2d1f1fa1bdae59bed4f391 Mon Sep 17 00:00:00 2001 From: Ian Joiner <14581281+iajoiner@users.noreply.github.com> Date: Fri, 13 Dec 2024 16:59:21 -0500 Subject: [PATCH 2/2] fix: rename `range_check_test_plan.rs` to `range_check_test.rs` --- crates/proof-of-sql/src/sql/proof_gadgets/mod.rs | 6 +++--- crates/proof-of-sql/src/sql/proof_gadgets/range_check.rs | 4 +--- .../{range_check_test_plan.rs => range_check_test.rs} | 4 +--- 3 files changed, 5 insertions(+), 9 deletions(-) rename crates/proof-of-sql/src/sql/proof_gadgets/{range_check_test_plan.rs => range_check_test.rs} (98%) diff --git a/crates/proof-of-sql/src/sql/proof_gadgets/mod.rs b/crates/proof-of-sql/src/sql/proof_gadgets/mod.rs index a1fba600a..0ec348767 100644 --- a/crates/proof-of-sql/src/sql/proof_gadgets/mod.rs +++ b/crates/proof-of-sql/src/sql/proof_gadgets/mod.rs @@ -5,8 +5,8 @@ use bitwise_verification::{verify_constant_abs_decomposition, verify_constant_si mod bitwise_verification_test; mod sign_expr; pub(crate) use sign_expr::{prover_evaluate_sign, result_evaluate_sign, verifier_evaluate_sign}; -#[cfg(all(test, feature = "blitzar"))] -mod sign_expr_test; pub mod range_check; #[cfg(all(test, feature = "blitzar"))] -pub mod range_check_test_plan; \ No newline at end of file +pub mod range_check_test; +#[cfg(all(test, feature = "blitzar"))] +mod sign_expr_test; diff --git a/crates/proof-of-sql/src/sql/proof_gadgets/range_check.rs b/crates/proof-of-sql/src/sql/proof_gadgets/range_check.rs index d668b80d1..7a699b0ce 100644 --- a/crates/proof-of-sql/src/sql/proof_gadgets/range_check.rs +++ b/crates/proof-of-sql/src/sql/proof_gadgets/range_check.rs @@ -406,9 +406,7 @@ mod tests { use super::*; use crate::{ base::scalar::{Curve25519Scalar as S, Scalar}, - sql::{ - proof::FinalRoundBuilder, - }, + sql::proof::FinalRoundBuilder, }; use bumpalo::Bump; use num_traits::Inv; diff --git a/crates/proof-of-sql/src/sql/proof_gadgets/range_check_test_plan.rs b/crates/proof-of-sql/src/sql/proof_gadgets/range_check_test.rs similarity index 98% rename from crates/proof-of-sql/src/sql/proof_gadgets/range_check_test_plan.rs rename to crates/proof-of-sql/src/sql/proof_gadgets/range_check_test.rs index d7a401ac5..8bd046043 100644 --- a/crates/proof-of-sql/src/sql/proof_gadgets/range_check_test_plan.rs +++ b/crates/proof-of-sql/src/sql/proof_gadgets/range_check_test.rs @@ -98,9 +98,7 @@ mod tests { owned_table_utility::{owned_table, scalar}, ColumnRef, ColumnType, OwnedTableTestAccessor, }, - sql::{ - proof::VerifiableQueryResult, - }, + sql::proof::VerifiableQueryResult, }; use blitzar::proof::InnerProductProof;