Skip to content

Commit

Permalink
fix!: fix GroupByExec so that it is composable with others
Browse files Browse the repository at this point in the history
  • Loading branch information
iajoiner committed Dec 4, 2024
1 parent 3ce6724 commit 0966227
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions crates/proof-of-sql/src/sql/proof_plans/group_by_exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,13 +361,13 @@ fn verify_group_by<S: Scalar>(
g_in_star_eval * sel_in_eval * sum_in_fold_eval - g_out_star_eval * sum_out_bar_fold_eval,
);

// g_in_star * g_in_fold - 1 = 0
// g_in_star * g_in_fold - input_ones = 0
builder.produce_sumcheck_subpolynomial_evaluation(
&SumcheckSubpolynomialType::Identity,
g_in_star_eval * g_in_fold_eval - one_eval,
);

// g_out_star * g_out_bar_fold - 1 = 0
// g_out_star * g_out_bar_fold - input_ones = 0
builder.produce_sumcheck_subpolynomial_evaluation(
&SumcheckSubpolynomialType::Identity,
g_out_star_eval * g_out_bar_fold_eval - one_eval,
Expand All @@ -390,6 +390,7 @@ pub fn prove_group_by<'a, S: Scalar>(
n: usize,
) {
let m_out = count_out.len();
let input_ones = alloc.alloc_slice_fill_copy(n, true);

// g_in_fold = alpha + sum beta^j * g_in[j]
let g_in_fold = alloc.alloc_slice_fill_copy(n, alpha);
Expand Down Expand Up @@ -442,19 +443,19 @@ pub fn prove_group_by<'a, S: Scalar>(
],
);

// g_in_star * g_in_fold - 1 = 0
// g_in_star * g_in_fold - input_ones = 0
builder.produce_sumcheck_subpolynomial(
SumcheckSubpolynomialType::Identity,
vec![
(
S::one(),
vec![Box::new(g_in_star as &[_]), Box::new(g_in_fold as &[_])],
),
(-S::one(), vec![]),
(-S::one(), vec![Box::new(input_ones as &[_])]),
],
);

// g_out_star * g_out_bar_fold - 1 = 0
// g_out_star * g_out_bar_fold - input_ones = 0
builder.produce_sumcheck_subpolynomial(
SumcheckSubpolynomialType::Identity,
vec![
Expand All @@ -465,7 +466,7 @@ pub fn prove_group_by<'a, S: Scalar>(
Box::new(g_out_bar_fold as &[_]),
],
),
(-S::one(), vec![]),
(-S::one(), vec![Box::new(input_ones as &[_])]),
],
);
}

0 comments on commit 0966227

Please sign in to comment.