Skip to content

Commit

Permalink
Import CPU code (#292)
Browse files Browse the repository at this point in the history
* feat: start to add cpu code for iris matching

* feat: add more cpu code

* more cpu code

* .

* .

* added eyre error handling

* added static assertions

* removed hawk pack dependency

---------

Co-authored-by: Roman Walch <[email protected]>
Co-authored-by: Dragos Rotaru <[email protected]>
  • Loading branch information
3 people authored Sep 4, 2024
1 parent 19b1c80 commit 3793432
Show file tree
Hide file tree
Showing 21 changed files with 3,987 additions and 159 deletions.
299 changes: 140 additions & 159 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[workspace]
members = [
"iris-mpc",
"iris-mpc-cpu",
"iris-mpc-gpu",
"iris-mpc-common",
"iris-mpc-upgrade",
Expand Down
22 changes: 22 additions & 0 deletions iris-mpc-cpu/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "iris-mpc-cpu"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html


[dependencies]
aes-prng = "0.2"
bytes = "1.7"
bytemuck.workspace = true
eyre.workspace = true
futures.workspace = true
iris-mpc-common = { path = "../iris-mpc-common" }
num-traits = "0.2"
rand.workspace = true
rayon.workspace = true
serde.workspace = true
static_assertions.workspace = true
thiserror = "1.0"
tokio.workspace = true
tracing.workspace = true
5 changes: 5 additions & 0 deletions iris-mpc-cpu/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pub(crate) mod networks;
pub mod prelude;
pub(crate) mod protocol;
pub(crate) mod shares;
pub(crate) mod utils;
2 changes: 2 additions & 0 deletions iris-mpc-cpu/src/networks/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub(crate) mod network_trait;
pub(crate) mod test_network;
42 changes: 42 additions & 0 deletions iris-mpc-cpu/src/networks/network_trait.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use bytes::{Bytes, BytesMut};
use eyre::{Error, Result};
use iris_mpc_common::id::PartyID;
pub type IoError = std::io::Error;

#[allow(async_fn_in_trait)]
pub trait NetworkTrait: Send + Sync {
fn get_id(&self) -> PartyID;

async fn shutdown(self) -> Result<(), IoError>;

async fn send(&mut self, id: PartyID, data: Bytes) -> Result<(), IoError>;
async fn send_next_id(&mut self, data: Bytes) -> Result<(), IoError>;
async fn send_prev_id(&mut self, data: Bytes) -> Result<(), IoError>;

async fn receive(&mut self, id: PartyID) -> Result<BytesMut, IoError>;
async fn receive_prev_id(&mut self) -> Result<BytesMut, IoError>;
async fn receive_next_id(&mut self) -> Result<BytesMut, IoError>;

async fn broadcast(&mut self, data: Bytes) -> Result<Vec<BytesMut>, IoError>;
//======= sync world =========
fn blocking_send(&mut self, id: PartyID, data: Bytes) -> Result<(), IoError>;
fn blocking_send_next_id(&mut self, data: Bytes) -> Result<(), IoError>;
fn blocking_send_prev_id(&mut self, data: Bytes) -> Result<(), IoError>;

fn blocking_receive(&mut self, id: PartyID) -> Result<BytesMut, IoError>;
fn blocking_receive_prev_id(&mut self) -> Result<BytesMut, IoError>;
fn blocking_receive_next_id(&mut self) -> Result<BytesMut, IoError>;

fn blocking_broadcast(&mut self, data: Bytes) -> Result<Vec<BytesMut>, IoError>;
}

#[allow(async_fn_in_trait)]
pub trait NetworkEstablisher<N: NetworkTrait> {
fn get_id(&self) -> PartyID;
fn get_num_parties(&self) -> usize;
async fn open_channel(&mut self) -> Result<N, Error>;
async fn shutdown(self) -> Result<(), Error>;
//======= sync world =========
fn print_connection_stats(&self, out: &mut impl std::io::Write) -> std::io::Result<()>;
fn get_send_receive(&self, i: usize) -> std::io::Result<(u64, u64)>;
}
Loading

0 comments on commit 3793432

Please sign in to comment.