-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: start to add cpu code for iris matching
- Loading branch information
Showing
20 changed files
with
3,123 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[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 | ||
iris-mpc-common = { path = "../iris-mpc-common" } | ||
num-traits = "0.2" | ||
rand.workspace = true | ||
rayon.workspace = true | ||
serde.workspace = true | ||
tokio.workspace = true | ||
thiserror = "1.0" | ||
tracing.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
use rayon::ThreadPoolBuildError; | ||
use thiserror::Error; | ||
|
||
/// An Error enum capturing the errors produced by this crate. | ||
#[derive(Error, Debug)] | ||
pub enum Error { | ||
/// Config Error | ||
#[error("Invalid Configuration")] | ||
Config, | ||
/// Type conversion error | ||
#[error("Conversion error")] | ||
Conversion, | ||
/// Error from the color_eyre crate | ||
#[error(transparent)] | ||
Eyre(#[from] eyre::Report), | ||
/// Invalid party id provided | ||
#[error("Invalid Party id {0}")] | ||
Id(usize), | ||
/// Message size is invalid | ||
#[error("Message size is invalid")] | ||
InvalidMessageSize, | ||
/// Size is invalid | ||
#[error("Size is invalid")] | ||
InvalidSize, | ||
/// A IO error has orccured | ||
#[error(transparent)] | ||
IO(#[from] std::io::Error), | ||
/// JMP verify failed | ||
#[error("JMP verify failed")] | ||
JmpVerify, | ||
/// Mask HW is to small | ||
#[error("Mask HW is to small")] | ||
MaskHW, | ||
/// Not enough triples | ||
#[error("Not enough triples")] | ||
NotEnoughTriples, | ||
/// Invalid number of parties | ||
#[error("Invalid number of parties {0}")] | ||
NumParty(usize), | ||
/// Verify failed | ||
#[error("Verify failed")] | ||
Verify, | ||
#[error(transparent)] | ||
ThreadPoolBuildError(#[from] ThreadPoolBuildError), | ||
/// Some other error has occurred. | ||
#[error("Err: {0}")] | ||
Other(String), | ||
} | ||
|
||
impl From<String> for Error { | ||
fn from(mes: String) -> Self { | ||
Self::Other(mes) | ||
} | ||
} | ||
|
||
impl From<&str> for Error { | ||
fn from(mes: &str) -> Self { | ||
Self::Other(mes.to_owned()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pub(crate) mod error; | ||
pub(crate) mod networks; | ||
pub(crate) mod protocol; | ||
pub(crate) mod shares; | ||
pub(crate) mod utils; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub(crate) mod network_trait; | ||
pub(crate) mod test_network; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use crate::error::Error; | ||
use bytes::{Bytes, BytesMut}; | ||
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)>; | ||
} |
Oops, something went wrong.