@@ -14,7 +14,7 @@ use mxx::{
1414 matrix:: dcrt_poly:: DCRTPolyMatrix ,
1515 poly:: dcrt:: params:: DCRTPolyParams ,
1616 sampler:: {
17- PolyTrapdoorSampler , hash:: DCRTPolyHashSampler , trapdoor:: DCRTPolyTrapdoorSampler ,
17+ hash:: DCRTPolyHashSampler , trapdoor:: DCRTPolyTrapdoorSampler ,
1818 uniform:: DCRTPolyUniformSampler ,
1919 } ,
2020 utils:: { log_mem, timed_read, timed_read_async} ,
@@ -203,8 +203,7 @@ async fn run_bench_offline(config: RunConfig, data_dir: PathBuf) -> Result<()> {
203203 config. crt_bits as usize ,
204204 config. base_bits ,
205205 ) ;
206- let trapdoor_sampler =
207- DCRTPolyTrapdoorSampler :: new ( & params, config. trapdoor_sigma . expect ( "trapdoor sigma exist" ) ) ;
206+ let trapdoor_sigma = config. trapdoor_sigma . expect ( "trapdoor sigma exist" ) ;
208207 let abe = KeyPolicyABE :: <
209208 DCRTPolyMatrix ,
210209 DCRTPolyHashSampler < Keccak256 > ,
@@ -216,7 +215,7 @@ async fn run_bench_offline(config: RunConfig, data_dir: PathBuf) -> Result<()> {
216215 & params,
217216 config. knapsack_size ,
218217 config. e_b_sigma ,
219- trapdoor_sampler ,
218+ trapdoor_sigma ,
220219 ) ;
221220 let mut t_setup = Duration :: ZERO ;
222221 let mut t_keygen = Duration :: ZERO ;
@@ -226,7 +225,7 @@ async fn run_bench_offline(config: RunConfig, data_dir: PathBuf) -> Result<()> {
226225 // 1) setup
227226 log_mem ( "starting setup" ) ;
228227 let ( mpk, msk) : ( MasterPK < DCRTPolyMatrix > , MasterSK < DCRTPolyMatrix , DCRTPolyTrapdoorSampler > ) =
229- timed_read ( "setup" , || abe. setup ( params. clone ( ) , config. arith_input_size ) , & mut t_setup) ;
228+ timed_read ( "setup" , || abe. setup ( & params, config. arith_input_size ) , & mut t_setup) ;
230229 log_mem ( "finished setup" ) ;
231230
232231 let dir_path = if data_dir. exists ( ) {
@@ -239,15 +238,7 @@ async fn run_bench_offline(config: RunConfig, data_dir: PathBuf) -> Result<()> {
239238 log_mem ( "starting keygen" ) ;
240239 let fsk: FuncSK < DCRTPolyMatrix > = timed_read_async (
241240 "keygen" ,
242- || {
243- abe. keygen (
244- params. clone ( ) ,
245- mpk. clone ( ) ,
246- msk. clone ( ) ,
247- config. arith_height ,
248- dir_path. clone ( ) ,
249- )
250- } ,
241+ || abe. keygen ( & params, mpk. clone ( ) , msk. clone ( ) , config. arith_height , dir_path. clone ( ) ) ,
251242 & mut t_keygen,
252243 )
253244 . await ;
@@ -268,8 +259,7 @@ async fn run_bench_online(config: RunConfig, data_dir: PathBuf) -> Result<()> {
268259 config. crt_bits as usize ,
269260 config. base_bits ,
270261 ) ;
271- let trapdoor_sampler =
272- DCRTPolyTrapdoorSampler :: new ( & params, config. trapdoor_sigma . expect ( "trapdoor sigma exist" ) ) ;
262+ let trapdoor_sigma = config. trapdoor_sigma . expect ( "trapdoor sigma exist" ) ;
273263 let abe = KeyPolicyABE :: <
274264 DCRTPolyMatrix ,
275265 DCRTPolyHashSampler < Keccak256 > ,
@@ -281,7 +271,7 @@ async fn run_bench_online(config: RunConfig, data_dir: PathBuf) -> Result<()> {
281271 & params,
282272 config. knapsack_size ,
283273 config. e_b_sigma ,
284- trapdoor_sampler ,
274+ trapdoor_sigma ,
285275 ) ;
286276 let mut t_read_mpk = Duration :: ZERO ;
287277 let mut t_enc = Duration :: ZERO ;
@@ -304,7 +294,7 @@ async fn run_bench_online(config: RunConfig, data_dir: PathBuf) -> Result<()> {
304294 ) ;
305295 let ct: Ciphertext < DCRTPolyMatrix > = timed_read (
306296 "enc" ,
307- || abe. enc ( params. clone ( ) , mpk, & vec ! [ BigUint :: ZERO ; config. arith_input_size] , true ) ,
297+ || abe. enc ( & params, mpk, & vec ! [ BigUint :: ZERO ; config. arith_input_size] , true ) ,
308298 & mut t_enc,
309299 ) ;
310300 log_mem ( "finished enc" ) ;
@@ -333,11 +323,8 @@ async fn run_bench_online(config: RunConfig, data_dir: PathBuf) -> Result<()> {
333323 } ,
334324 & mut t_read_fsk,
335325 ) ;
336- let bit: bool = timed_read (
337- "dec" ,
338- || abe. dec ( params. clone ( ) , ct, mpk, fsk, config. arith_height ) ,
339- & mut t_dec,
340- ) ;
326+ let bit: bool =
327+ timed_read ( "dec" , || abe. dec ( & params, ct, mpk, fsk, config. arith_height ) , & mut t_dec) ;
341328 log_mem ( format ! ( "finished decryption: result={}" , bit) ) ;
342329 Ok ( ( ) )
343330}
0 commit comments