arnaucube
arnaucube/phantom-zonePublic Self-hosted repository
improve bomberman example
Janmajaya Mall janmajayamall@protonmail.com
Mon, 01 Jul 2024 20:13:02 +0530
commit

0faa3d027a15a6604d8e192ee7756aa4360afc39

parent

8877c4a4381274e27149fc5831921ceecf82cdcf

1 files changed, 13 insertions(+), 8 deletions(-)

jump to
M examples/bomberman.rs → examples/bomberman.rs

@@ -98,12 +98,12 @@ let player_1_bomb = Coordinates::new(thread_rng().gen::<u8>(), thread_rng().gen());

let player_2_bomb = Coordinates::new(thread_rng().gen::<u8>(), thread_rng().gen()); let player_3_bomb = Coordinates::new(thread_rng().gen::<u8>(), 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 @@ server_key.set_server_key();

// server parses all player inputs let player_0_moves_enc = { - let c = player_0_enc.unseed::<Vec<Vec<u64>>>().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::<Vec<Vec<u64>>>() + .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 = {