Skip to content

Commit

Permalink
refactor: replace dynamic dory code with generic code where appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
stuarttimwhite committed Dec 11, 2024
1 parent 1604077 commit 8b4b1b2
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use super::{
dynamic_dory_structure::{
full_width_of_row, index_from_row_and_column, matrix_size, row_and_column_from_index,
},
G1Affine, F,
};
use super::{G1Affine, F};
use crate::{
base::{commitment::CommittableColumn, database::ColumnType, if_rayon},
proof_primitive::dory::offset_to_bytes::OffsetToBytes,
proof_primitive::{
dory::offset_to_bytes::OffsetToBytes,
dynamic_matrix_utils::matrix_structure::{
full_width_of_row, index_from_row_and_column, matrix_size, row_and_column_from_index,
},
},
};
use alloc::{vec, vec::Vec};
use ark_ec::CurveGroup;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
use super::{
dynamic_dory_helper::{compute_dynamic_v_vec, compute_dynamic_vecs},
DeferredGT, G1Affine, VMVProverState, VMVVerifierState, F,
dynamic_dory_helper::compute_dynamic_v_vec, DeferredGT, G1Affine, VMVProverState,
VMVVerifierState, F,
};
use crate::{
base::scalar::MontScalar,
proof_primitive::dynamic_matrix_utils::standard_basis_helper::compute_dynamic_vecs,
};
use alloc::vec::Vec;
use itertools::Itertools;

/// Builds a [`VMVProverState`] from the given parameters.
pub(super) fn build_dynamic_vmv_prover_state(
Expand All @@ -11,7 +16,12 @@ pub(super) fn build_dynamic_vmv_prover_state(
T_vec_prime: Vec<G1Affine>,
nu: usize,
) -> VMVProverState {
let (lo_vec, hi_vec) = compute_dynamic_vecs(b_point);
let (lo_vec, hi_vec) =
compute_dynamic_vecs(&b_point.iter().copied().map(MontScalar).collect_vec());
let (lo_vec, hi_vec) = (
lo_vec.into_iter().map(|m| m.0).collect_vec(),
hi_vec.into_iter().map(|m| m.0).collect_vec(),
);
let v_vec = compute_dynamic_v_vec(a, &hi_vec, nu);
VMVProverState {
v_vec,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use super::{
dynamic_dory_structure::{full_width_of_row, row_and_column_from_index, row_start_index},
pairings, DoryScalar, DynamicDoryCommitment, G1Projective, ProverSetup, GT,
use super::{pairings, DoryScalar, DynamicDoryCommitment, G1Projective, ProverSetup, GT};
use crate::{
base::{commitment::CommittableColumn, if_rayon, slice_ops::slice_cast},
proof_primitive::dynamic_matrix_utils::matrix_structure::{
full_width_of_row, row_and_column_from_index, row_start_index,
},
};
use crate::base::{commitment::CommittableColumn, if_rayon, slice_ops::slice_cast};
use alloc::vec::Vec;
use ark_ec::VariableBaseMSM;
use bytemuck::TransparentWrapper;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use super::{
blitzar_metadata_table::{create_blitzar_metadata_tables, signed_commits},
dynamic_dory_structure::row_and_column_from_index,
pairings, DynamicDoryCommitment, G1Affine, ProverSetup,
};
use crate::base::{commitment::CommittableColumn, if_rayon, slice_ops::slice_cast};
use crate::{
base::{commitment::CommittableColumn, if_rayon, slice_ops::slice_cast},
proof_primitive::dynamic_matrix_utils::matrix_structure::row_and_column_from_index,
};
use blitzar::compute::ElementP2;
#[cfg(feature = "rayon")]
use rayon::iter::{IntoParallelIterator, ParallelIterator};
Expand Down
33 changes: 23 additions & 10 deletions crates/proof-of-sql/src/proof_primitive/dory/dynamic_dory_helper.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
use super::{
blitzar_metadata_table::create_blitzar_metadata_tables,
dynamic_dory_standard_basis_helper::fold_dynamic_standard_basis_tensors,
dynamic_dory_structure::row_and_column_from_index, ExtendedVerifierState, G1Affine,
blitzar_metadata_table::create_blitzar_metadata_tables, ExtendedVerifierState, G1Affine,
ProverSetup, F,
};
use crate::{
base::{commitment::CommittableColumn, slice_ops::slice_cast},
proof_primitive::dory::{
dynamic_dory_standard_basis_helper::compute_dynamic_standard_basis_vecs, DoryScalar,
base::{commitment::CommittableColumn, scalar::MontScalar, slice_ops::slice_cast},
proof_primitive::{
dory::{
dynamic_dory_standard_basis_helper::compute_dynamic_standard_basis_vecs, DoryScalar,
},
dynamic_matrix_utils::{
matrix_structure::row_and_column_from_index,
standard_basis_helper::fold_dynamic_standard_basis_tensors,
},
},
};
use alloc::{vec, vec::Vec};
Expand Down Expand Up @@ -137,11 +141,20 @@ pub(super) fn fold_dynamic_tensors(state: &ExtendedVerifierState) -> (F, F) {
})
.collect_vec();
let (lo_fold, hi_fold) = fold_dynamic_standard_basis_tensors(
&standard_basis_point,
&state.alphas,
&state.alpha_invs,
&standard_basis_point
.iter()
.copied()
.map(MontScalar)
.collect_vec(),
&state.alphas.iter().copied().map(MontScalar).collect_vec(),
&state
.alpha_invs
.iter()
.copied()
.map(MontScalar)
.collect_vec(),
);
(lo_fold * lo_inv_prod, hi_fold * hi_inv_prod)
(lo_fold.0 * lo_inv_prod, hi_fold.0 * hi_inv_prod)
}

#[cfg(test)]
Expand Down

0 comments on commit 8b4b1b2

Please sign in to comment.