@@ -60,8 +60,8 @@ impl<F: PrimeField> Data<F> {
60
60
61
61
/// Commit a `data` of length smaller than `SRS_SIZE`
62
62
/// 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 )
65
65
}
66
66
67
67
/// Modifies inplace the provided data with `diff`
@@ -141,9 +141,15 @@ pub fn update<F: PrimeField>(path: &str, diff: &Diff<F>) -> std::io::Result<()>
141
141
142
142
#[ cfg( test) ]
143
143
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
+ } ;
145
150
use ark_ff:: { One , UniformRand , Zero } ;
146
151
use mina_curves:: pasta:: Fp ;
152
+ use poly_commitment:: ipa:: SRS ;
147
153
use rand:: Rng ;
148
154
use std:: fs;
149
155
use tempfile:: NamedTempFile ;
@@ -155,7 +161,7 @@ mod tests {
155
161
fn test_data_consistency ( ) {
156
162
let mut rng = o1_utils:: tests:: make_test_rng ( None ) ;
157
163
158
- let srs = poly_commitment:: precomputed_srs:: get_srs_test ( ) ;
164
+ let srs: SRS < Curve > = poly_commitment:: precomputed_srs:: get_srs_test ( ) ;
159
165
160
166
// Path of the file that will contain the test data
161
167
let file = NamedTempFile :: new ( ) . unwrap ( ) ;
@@ -176,7 +182,7 @@ mod tests {
176
182
let read_data_comm = read_data. to_commitment ( & srs) ;
177
183
178
184
// 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)
180
186
} ;
181
187
182
188
let ( data_updated, update_consistency) = {
@@ -211,9 +217,10 @@ mod tests {
211
217
let updated_read_data_comm = updated_read_data. to_commitment ( & srs) ;
212
218
213
219
(
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) ,
215
222
// 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) ,
217
224
)
218
225
} ;
219
226
0 commit comments