Skip to content

Commit 632e703

Browse files
committed
Saffron/Storage: use commitment::Commitment
1 parent 921197a commit 632e703

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

saffron/src/storage.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ impl<F: PrimeField> Data<F> {
6060

6161
/// Commit a `data` of length smaller than `SRS_SIZE`
6262
/// If greater data is provided, anything above `SRS_SIZE` is ignored
63-
pub fn to_commitment<G: KimchiCurve<ScalarField = F>>(&self, srs: &SRS<G>) -> G {
64-
commit_to_field_elems::<G>(srs, &self.data)[0]
63+
pub fn to_commitment<G: KimchiCurve<ScalarField = F>>(&self, srs: &SRS<G>) -> Commitment<G> {
64+
Commitment::from_data(srs, &self.data)
6565
}
6666

6767
/// Modifies inplace the provided data with `diff`
@@ -141,9 +141,15 @@ pub fn update<F: PrimeField>(path: &str, diff: &Diff<F>) -> std::io::Result<()>
141141

142142
#[cfg(test)]
143143
mod tests {
144-
use crate::{diff::Diff, encoding, storage, storage::Data, Curve, ScalarField, SRS_SIZE};
144+
use crate::{
145+
diff::Diff,
146+
encoding, storage,
147+
storage::{Commitment, Data},
148+
Curve, ScalarField, SRS_SIZE,
149+
};
145150
use ark_ff::{One, UniformRand, Zero};
146151
use mina_curves::pasta::Fp;
152+
use poly_commitment::ipa::SRS;
147153
use rand::Rng;
148154
use std::fs;
149155
use tempfile::NamedTempFile;
@@ -155,7 +161,7 @@ mod tests {
155161
fn test_data_consistency() {
156162
let mut rng = o1_utils::tests::make_test_rng(None);
157163

158-
let srs = poly_commitment::precomputed_srs::get_srs_test();
164+
let srs: SRS<Curve> = poly_commitment::precomputed_srs::get_srs_test();
159165

160166
// Path of the file that will contain the test data
161167
let file = NamedTempFile::new().unwrap();
@@ -176,7 +182,7 @@ mod tests {
176182
let read_data_comm = read_data.to_commitment(&srs);
177183

178184
// True if read data are the same as initial data
179-
Curve::eq(&data_comm, &read_data_comm)
185+
Commitment::eq(&data_comm, &read_data_comm)
180186
};
181187

182188
let (data_updated, update_consistency) = {
@@ -211,9 +217,10 @@ mod tests {
211217
let updated_read_data_comm = updated_read_data.to_commitment(&srs);
212218

213219
(
214-
Curve::ne(&updated_data_comm, &data_comm),
220+
// True if the data have changed because of the update
221+
Commitment::ne(&updated_data_comm, &data_comm),
215222
// True if read data from updated file are the same as updated data
216-
Curve::eq(&updated_data_comm, &updated_read_data_comm),
223+
Commitment::eq(&updated_data_comm, &updated_read_data_comm),
217224
)
218225
};
219226

0 commit comments

Comments
 (0)