Skip to content

Commit

Permalink
Update example: Now without ideal functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
jschneider-bensch committed Apr 18, 2024
1 parent 69f1244 commit 9b6d3db
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions atlas-spec/mpc-engine/examples/run_mpc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
use std::thread;

use hacspec_lib::Randomness;
use mpc_engine::circuit::{Circuit, WiredGate};

use rand::RngCore;

fn build_circuit() -> Circuit {
Circuit {
input_widths: vec![1, 1, 1, 1],
gates: vec![
WiredGate::Input(0), // Gate 0
WiredGate::Input(1), // Gate 1
WiredGate::Input(2), // Gate 2
WiredGate::And(0, 1), // Gate 3
WiredGate::And(3, 2), // Gate 4
],
output_gates: vec![4],
}
}
fn main() {
let circuit = build_circuit();

let num_parties = circuit.number_of_parties();

// Set up channels
let mut party_channels = mpc_engine::utils::set_up_channels(num_parties);

let mut party_join_handles = Vec::new();
for _i in 0..num_parties {
let channel_config = party_channels
.pop()
.expect("every party should have a channel configuration");
let c = circuit.clone();
let party_join_handle = thread::spawn(move || {
let mut rng = rand::thread_rng();
let mut bytes = [0u8; 500];
rng.fill_bytes(&mut bytes);
let rng = Randomness::new(bytes.to_vec());
let mut p = mpc_engine::party::Party::new(channel_config, &c, rng);

let _ = p.run();
});
party_join_handles.push(party_join_handle);
}

for _i in 0..num_parties {
party_join_handles
.pop()
.expect("every party should have a join handle")
.join()
.expect("party did not panic");
}
}

0 comments on commit 9b6d3db

Please sign in to comment.