From 0faa3d027a15a6604d8e192ee7756aa4360afc39 Mon Sep 17 00:00:00 2001 From: Janmajaya Mall Date: Mon, 1 Jul 2024 20:13:02 +0530 Subject: [PATCH] improve bomberman example --- examples/bomberman.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/examples/bomberman.rs b/examples/bomberman.rs index f802af6..e51a8a5 100644 --- a/examples/bomberman.rs +++ b/examples/bomberman.rs @@ -98,12 +98,12 @@ fn main() { let player_2_bomb = Coordinates::new(thread_rng().gen::(), thread_rng().gen()); let player_3_bomb = Coordinates::new(thread_rng().gen::(), thread_rng().gen()); - println!("P0 move coordinates: {:?}", &player_0_moves); - println!("P1 bomb coordinate : {:?}", &player_1_bomb); - println!("P2 bomb coordinate : {:?}", &player_2_bomb); - println!("P3 bomb coordinate : {:?}", &player_3_bomb); + println!("P0 moves coordinates: {:?}", &player_0_moves); + println!("P1 bomb coordinate : {:?}", &player_1_bomb); + println!("P2 bomb coordinate : {:?}", &player_2_bomb); + println!("P3 bomb coordinate : {:?}", &player_3_bomb); - // Al playes encrypt their private inputs + // Al players encrypt their private inputs let player_0_enc = cks[0].encrypt( player_0_moves .iter() @@ -124,9 +124,14 @@ fn main() { // server parses all player inputs let player_0_moves_enc = { - let c = player_0_enc.unseed::>>().key_switch(0); - (0..no_of_moves) - .map(|i| Coordinates::new(c.extract_at(2 * i), c.extract_at(i * 2 + 1))) + let c = player_0_enc + .unseed::>>() + .key_switch(0) + .extract_all(); + c.into_iter() + .chunks(2) + .into_iter() + .map(|mut x_y| Coordinates::new(x_y.next().unwrap(), x_y.next().unwrap())) .collect_vec() }; let player_1_bomb_enc = {