Skip to content

Commit

Permalink
Merge branch 'main' into perf/vlen-msm-impl
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtrombetta authored Oct 7, 2024
2 parents 4e352e7 + 7034414 commit 43bd8c0
Show file tree
Hide file tree
Showing 44 changed files with 335 additions and 153 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,6 @@ range_plus_one = "deny"
cloned_instead_of_copied = "deny"
from_iter_instead_of_collect = "deny"
cast_lossless = "deny"
redundant_closure_for_method_calls = "deny"
inconsistent_struct_constructor = "deny"
default_trait_access = "deny"
3 changes: 2 additions & 1 deletion crates/proof-of-sql/examples/posql_db/commit_accessor.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use core::error::Error;
use indexmap::IndexMap;
use proof_of_sql::base::{
commitment::{Commitment, QueryCommitments, TableCommitment},
database::{CommitmentAccessor, MetadataAccessor, SchemaAccessor, TableRef},
Expand All @@ -13,7 +14,7 @@ impl<C: Commitment + Serialize + for<'a> Deserialize<'a>> CommitAccessor<C> {
pub fn new(base_path: PathBuf) -> Self {
Self {
base_path,
inner: Default::default(),
inner: IndexMap::default(),
}
}
pub fn write_commit(
Expand Down
2 changes: 1 addition & 1 deletion crates/proof-of-sql/examples/posql_db/csv_accessor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl CsvDataAccessor {
pub fn new(base_path: PathBuf) -> Self {
Self {
base_path,
inner: Default::default(),
inner: RecordBatchAccessor::default(),
}
}
pub fn load_table(
Expand Down
4 changes: 2 additions & 2 deletions crates/proof-of-sql/src/base/commitment/column_commitments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ impl<C: Commitment> ColumnCommitments<C> {
.expect("we've already checked that self and other have equal column counts");

Ok(ColumnCommitments {
column_metadata,
commitments,
column_metadata,
})
}

Expand All @@ -293,8 +293,8 @@ impl<C: Commitment> ColumnCommitments<C> {
.expect("we've already checked that self and other have equal column counts");

Ok(ColumnCommitments {
column_metadata,
commitments,
column_metadata,
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl CommitmentEvaluationProof for InnerProductProof {
_setup: &Self::ProverPublicSetup<'_>,
) -> Self {
assert!(!a.is_empty());
let b = &mut vec![Default::default(); a.len()];
let b = &mut vec![MontScalar::default(); a.len()];
if b_point.is_empty() {
assert_eq!(b.len(), 1);
b[0] = Self::Scalar::ONE;
Expand Down Expand Up @@ -124,7 +124,7 @@ impl CommitmentEvaluationProof for InnerProductProof {
_setup: &Self::VerifierPublicSetup<'_>,
) -> Result<(), Self::Error> {
assert!(table_length > 0);
let b = &mut vec![Default::default(); table_length];
let b = &mut vec![MontScalar::default(); table_length];
if b_point.is_empty() {
assert_eq!(b.len(), 1);
b[0] = Self::Scalar::ONE;
Expand All @@ -140,7 +140,7 @@ impl CommitmentEvaluationProof for InnerProductProof {
.iter()
.zip(batching_factors.iter())
.map(|(c, m)| *m * c)
.fold(Default::default(), |mut a, c| {
.fold(RistrettoPoint::default(), |mut a, c| {
a += c;
a
}),
Expand Down
5 changes: 4 additions & 1 deletion crates/proof-of-sql/src/base/commitment/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,11 @@ impl Commitment for RistrettoPoint {
offset: usize,
_setup: &Self::PublicSetup<'_>,
) -> Vec<Self> {
use curve25519_dalek::ristretto::CompressedRistretto;

let sequences: Vec<_> = committable_columns.iter().map(Into::into).collect();
let mut compressed_commitments = vec![Default::default(); committable_columns.len()];
let mut compressed_commitments =
vec![CompressedRistretto::default(); committable_columns.len()];
blitzar::compute::compute_curve25519_commitments(
&mut compressed_commitments,
&sequences,
Expand Down
43 changes: 25 additions & 18 deletions crates/proof-of-sql/src/base/commitment/naive_commitment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl Neg for NaiveCommitment {
type Output = NaiveCommitment;

fn neg(self) -> Self::Output {
Self(self.0.iter().map(|s| s.neg()).collect())
Self(self.0.iter().map(core::ops::Neg::neg).collect())
}
}

Expand Down Expand Up @@ -119,36 +119,40 @@ impl Commitment for NaiveCommitment {
let mut vectors: Vec<TestScalar> = vec![TestScalar::ZERO; offset];
let mut existing_scalars: Vec<TestScalar> = match cc {
CommittableColumn::Boolean(bool_vec) => {
bool_vec.iter().map(|b| b.into()).collect()
bool_vec.iter().map(core::convert::Into::into).collect()
}
CommittableColumn::TinyInt(tiny_int_vec) => {
tiny_int_vec.iter().map(|b| b.into()).collect()
tiny_int_vec.iter().map(core::convert::Into::into).collect()
}
CommittableColumn::SmallInt(small_int_vec) => {
small_int_vec.iter().map(|b| b.into()).collect()
CommittableColumn::SmallInt(small_int_vec) => small_int_vec
.iter()
.map(core::convert::Into::into)
.collect(),
CommittableColumn::Int(int_vec) => {
int_vec.iter().map(core::convert::Into::into).collect()
}
CommittableColumn::Int(int_vec) => int_vec.iter().map(|b| b.into()).collect(),
CommittableColumn::BigInt(big_int_vec) => {
big_int_vec.iter().map(|b| b.into()).collect()
big_int_vec.iter().map(core::convert::Into::into).collect()
}
CommittableColumn::Int128(int_128_vec) => {
int_128_vec.iter().map(|b| b.into()).collect()
int_128_vec.iter().map(core::convert::Into::into).collect()
}
CommittableColumn::Decimal75(_, _, u64_vec) => {
u64_vec.iter().map(|b| b.into()).collect()
u64_vec.iter().map(core::convert::Into::into).collect()
}
CommittableColumn::Scalar(scalar_vec) => {
scalar_vec.iter().map(|b| b.into()).collect()
scalar_vec.iter().map(core::convert::Into::into).collect()
}
CommittableColumn::VarChar(varchar_vec) => {
varchar_vec.iter().map(|b| b.into()).collect()
varchar_vec.iter().map(core::convert::Into::into).collect()
}
CommittableColumn::TimestampTZ(_, _, i64_vec) => {
i64_vec.iter().map(|b| b.into()).collect()
}
CommittableColumn::RangeCheckWord(u8_scalar_vec) => {
u8_scalar_vec.iter().map(|b| b.into()).collect()
i64_vec.iter().map(core::convert::Into::into).collect()
}
CommittableColumn::RangeCheckWord(u8_scalar_vec) => u8_scalar_vec
.iter()
.map(core::convert::Into::into)
.collect(),
};
vectors.append(&mut existing_scalars);
NaiveCommitment(vectors)
Expand All @@ -168,8 +172,10 @@ fn we_can_compute_commitments_from_commitable_columns() {
[4, 0, 0, 0],
[5, 0, 0, 0],
];
let column_a_scalars: Vec<TestScalar> = column_a.iter().map(|a| a.into()).collect();
let column_b_scalars: Vec<TestScalar> = column_b.iter().map(|b| b.into()).collect();
let column_a_scalars: Vec<TestScalar> =
column_a.iter().map(core::convert::Into::into).collect();
let column_b_scalars: Vec<TestScalar> =
column_b.iter().map(core::convert::Into::into).collect();
let commitable_column_a = CommittableColumn::BigInt(&column_a);
let commitable_column_b = CommittableColumn::VarChar(column_b);
let committable_columns: &[CommittableColumn] = &[commitable_column_a, commitable_column_b];
Expand All @@ -181,7 +187,8 @@ fn we_can_compute_commitments_from_commitable_columns() {
#[test]
fn we_can_compute_commitments_from_commitable_columns_with_offset() {
let column_a = [0i64, 1, 10, -5, 0, 10];
let column_a_scalars: Vec<TestScalar> = column_a.iter().map(|a| a.into()).collect();
let column_a_scalars: Vec<TestScalar> =
column_a.iter().map(core::convert::Into::into).collect();
let commitable_column_a = CommittableColumn::BigInt(&column_a[1..]);
let committable_columns: &[CommittableColumn] = &[commitable_column_a];
let commitments = NaiveCommitment::compute_commitments(committable_columns, 1, &());
Expand Down
Loading

0 comments on commit 43bd8c0

Please sign in to comment.