diff --git a/Cargo.toml b/Cargo.toml index 025249708..1913112a2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ arrow-csv = { version = "45.0" } bit-iter = { version = "1.1.1" } bigdecimal = { version = "0.4.5", features = ["serde"] } blake3 = { version = "1.3.3" } -blitzar = { version = "3.0.1" } +blitzar = { version = "3.0.2" } bumpalo = { version = "3.11.0" } bytemuck = {version = "1.14.2" } byte-slice-cast = { version = "1.2.1" } diff --git a/crates/proof-of-sql/src/sql/ast/add_subtract_expr_test.rs b/crates/proof-of-sql/src/sql/ast/add_subtract_expr_test.rs index 04a10bf96..1de3ec9bc 100644 --- a/crates/proof-of-sql/src/sql/ast/add_subtract_expr_test.rs +++ b/crates/proof-of-sql/src/sql/ast/add_subtract_expr_test.rs @@ -167,10 +167,7 @@ fn overflow_in_nonselected_rows_doesnt_error_out() { // select a, b from sxt.t where a + b >= 0 #[test] fn overflow_in_where_clause_doesnt_error_out() { - let data = owned_table([ - bigint("a", [i64::MAX, i64::MIN + 1]), - smallint("b", [1_i16, 0]), - ]); + let data = owned_table([bigint("a", [i64::MAX, i64::MIN]), smallint("b", [1_i16, 0])]); let t = "sxt.t".parse().unwrap(); let accessor = OwnedTableTestAccessor::::new_from_table(t, data, 0, ()); let ast: ProofPlan = dense_filter( diff --git a/crates/proof-of-sql/tests/integration_tests.rs b/crates/proof-of-sql/tests/integration_tests.rs index f54eca7bb..221b8882d 100644 --- a/crates/proof-of-sql/tests/integration_tests.rs +++ b/crates/proof-of-sql/tests/integration_tests.rs @@ -160,6 +160,85 @@ fn we_can_prove_a_basic_inequality_query_with_curve25519() { assert_eq!(owned_table_result, expected_result); } +#[test] +#[cfg(feature = "blitzar")] +fn we_can_prove_a_basic_query_containing_extrema_with_curve25519() { + let mut accessor = OwnedTableTestAccessor::::new_empty_with_setup(()); + accessor.add_table( + "sxt.table".parse().unwrap(), + owned_table([ + smallint("smallint", [i16::MIN, 0, i16::MAX]), + int("int", [i32::MIN, 0, i32::MAX]), + bigint("bigint", [i64::MIN, 0, i64::MAX]), + int128("int128", [i128::MIN, 0, i128::MAX]), + ]), + 0, + ); + let query = QueryExpr::try_new( + "SELECT * FROM table".parse().unwrap(), + "sxt".parse().unwrap(), + &accessor, + ) + .unwrap(); + let (proof, serialized_result) = + QueryProof::::new(query.proof_expr(), &accessor, &()); + let owned_table_result = proof + .verify(query.proof_expr(), &accessor, &serialized_result, &()) + .unwrap() + .table; + let expected_result = owned_table([ + smallint("smallint", [i16::MIN, 0, i16::MAX]), + int("int", [i32::MIN, 0, i32::MAX]), + bigint("bigint", [i64::MIN, 0, i64::MAX]), + int128("int128", [i128::MIN, 0, i128::MAX]), + ]); + assert_eq!(owned_table_result, expected_result); +} + +#[test] +#[cfg(feature = "blitzar")] +fn we_can_prove_a_basic_query_containing_extrema_with_dory() { + let dory_prover_setup = DoryProverPublicSetup::rand(4, 3, &mut test_rng()); + let dory_verifier_setup = (&dory_prover_setup).into(); + let mut accessor = OwnedTableTestAccessor::::new_empty_with_setup( + dory_prover_setup.clone(), + ); + accessor.add_table( + "sxt.table".parse().unwrap(), + owned_table([ + smallint("smallint", [i16::MIN, 0, i16::MAX]), + int("int", [i32::MIN, 0, i32::MAX]), + bigint("bigint", [i64::MIN, 0, i64::MAX]), + int128("int128", [i128::MIN, 0, i128::MAX]), + ]), + 0, + ); + let query = QueryExpr::try_new( + "SELECT * FROM table".parse().unwrap(), + "sxt".parse().unwrap(), + &accessor, + ) + .unwrap(); + let (proof, serialized_result) = + QueryProof::::new(query.proof_expr(), &accessor, &dory_prover_setup); + let owned_table_result = proof + .verify( + query.proof_expr(), + &accessor, + &serialized_result, + &dory_verifier_setup, + ) + .unwrap() + .table; + let expected_result = owned_table([ + smallint("smallint", [i16::MIN, 0, i16::MAX]), + int("int", [i32::MIN, 0, i32::MAX]), + bigint("bigint", [i64::MIN, 0, i64::MAX]), + int128("int128", [i128::MIN, 0, i128::MAX]), + ]); + assert_eq!(owned_table_result, expected_result); +} + #[test] #[cfg(feature = "blitzar")] fn we_can_prove_a_query_with_arithmetic_in_where_clause_with_curve25519() {