diff --git a/crates/mpz-ot-core/src/ferret/mod.rs b/crates/mpz-ot-core/src/ferret/mod.rs index 6b478b06..ac73c005 100644 --- a/crates/mpz-ot-core/src/ferret/mod.rs +++ b/crates/mpz-ot-core/src/ferret/mod.rs @@ -1,7 +1,4 @@ //! An implementation of the [`Ferret`](https://eprint.iacr.org/2020/924.pdf) protocol. - -use mpz_core::lpn::LpnParameters; - pub mod cuckoo; pub mod error; pub mod mpcot; @@ -19,22 +16,6 @@ pub const CUCKOO_HASH_NUM: usize = 3; /// Trial numbers in Cuckoo hash insertion. pub const CUCKOO_TRIAL_NUM: usize = 100; -/// LPN parameters with regular noise. -/// Derived from https://github.com/emp-toolkit/emp-ot/blob/master/emp-ot/ferret/constants.h -pub const LPN_PARAMETERS_REGULAR: LpnParameters = LpnParameters { - n: 10_180_608, - k: 124_000, - t: 4_971, -}; - -/// LPN parameters with uniform noise. -/// Derived from Table 2. -pub const LPN_PARAMETERS_UNIFORM: LpnParameters = LpnParameters { - n: 10_616_092, - k: 588_160, - t: 1_324, -}; - /// The type of Lpn parameters. #[derive(Debug, Clone, Copy, Default)] pub enum LpnType { diff --git a/crates/mpz-ot/src/ferret/mod.rs b/crates/mpz-ot/src/ferret/mod.rs index 086e5e8b..9d421885 100644 --- a/crates/mpz-ot/src/ferret/mod.rs +++ b/crates/mpz-ot/src/ferret/mod.rs @@ -44,6 +44,138 @@ impl FerretConfig { } } +/// Ferret config with regular LPN parameters. +/// Parameters for setup with small extension output. +pub const FERRET_REGULAR_SETUP_SMALL: FerretConfig = FerretConfig { + lpn_parameters: LpnParameters { + n: 102_400, + k: 6_750, + t: 1_600, + }, + lpn_type: LpnType::Regular, +}; + +/// Ferret config with regular LPN parameters. +/// Parameters for extension with small extension output. +pub const FERRET_REGULAR_EXTENSION_SMALL: FerretConfig = FerretConfig { + lpn_parameters: LpnParameters { + n: 1_740_800, + k: 66_400, + t: 1700, + }, + lpn_type: LpnType::Regular, +}; + +/// Ferret config with regular LPN parameters. +/// Parameters for setup with medium extension output. +pub const FERRET_REGULAR_SETUP_MEDIUM: FerretConfig = FerretConfig { + lpn_parameters: LpnParameters { + n: 283_648, + k: 18_584, + t: 1_108, + }, + lpn_type: LpnType::Regular, +}; + +/// Ferret config with regular LPN parameters. +/// Parameters for extension with medium extension output. +pub const FERRET_REGULAR_EXTENSION_MEDIUM: FerretConfig = FerretConfig { + lpn_parameters: LpnParameters { + n: 5_324_800, + k: 240_000, + t: 1_300, + }, + lpn_type: LpnType::Regular, +}; + +/// Ferret config with regular LPN parameters. +/// Parameters for setup with large extension output. +pub const FERRET_REGULAR_SETUP_LARGE: FerretConfig = FerretConfig { + lpn_parameters: LpnParameters { + n: 518_656, + k: 34_643, + t: 1_013, + }, + lpn_type: LpnType::Regular, +}; + +/// Ferret config with regular LPN parameters. +/// Parameters for extension with large extension output. +pub const FERRET_REGULAR_EXTENSION_LARGE: FerretConfig = FerretConfig { + lpn_parameters: LpnParameters { + n: 10_485_760, + k: 458_000, + t: 1280, + }, + lpn_type: LpnType::Regular, +}; + +/// Ferret config with uniform LPN parameters. +/// Parameters for setup with small extension output. +pub const FERRET_UNIFORM_SETUP_SMALL: FerretConfig = FerretConfig { + lpn_parameters: LpnParameters { + n: 98_000, + k: 4_450, + t: 1_600, + }, + lpn_type: LpnType::Uniform, +}; + +/// Ferret config with uniform LPN parameters. +/// Parameters for extension with small extension output. +pub const FERRET_UNIFORM_EXTENSION_SMALL: FerretConfig = FerretConfig { + lpn_parameters: LpnParameters { + n: 1_071_888, + k: 40_800, + t: 1720, + }, + lpn_type: LpnType::Uniform, +}; + +/// Ferret config with uniform LPN parameters. +/// Parameters for setup with medium extension output. +pub const FERRET_UNIFORM_SETUP_MEDIUM: FerretConfig = FerretConfig { + lpn_parameters: LpnParameters { + n: 283_648, + k: 18_584, + t: 1_108, + }, + lpn_type: LpnType::Uniform, +}; + +/// Ferret config with uniform LPN parameters. +/// Parameters for extension with medium extension output. +pub const FERRET_UNIFORM_EXTENSION_MEDIUM: FerretConfig = FerretConfig { + lpn_parameters: LpnParameters { + n: 5_324_800, + k: 240_000, + t: 1_300, + }, + lpn_type: LpnType::Uniform, +}; + +/// Ferret config with uniform LPN parameters. +/// Parameters for setup with large extension output. +pub const FERRET_UNIFORM_SETUP_LARGE: FerretConfig = FerretConfig { + lpn_parameters: LpnParameters { + n: 545_656, + k: 34_643, + t: 1_050, + }, + lpn_type: LpnType::Uniform, +}; + +/// Ferret config with uniform LPN parameters. +/// Parameters for extension with large extension output. +pub const FERRET_UNIFORM_EXTENSION_LARGE: FerretConfig = FerretConfig { + lpn_parameters: LpnParameters { + n: 10_488_928, + k: 458_000, + t: 1_280, + }, + lpn_type: LpnType::Uniform, +}; + #[cfg(test)] mod tests { use super::*; diff --git a/crates/mpz-ot/src/ferret/spcot.rs b/crates/mpz-ot/src/ferret/spcot.rs index 5fcb6e6c..e63a1aa9 100644 --- a/crates/mpz-ot/src/ferret/spcot.rs +++ b/crates/mpz-ot/src/ferret/spcot.rs @@ -54,11 +54,7 @@ pub(crate) async fn send>( let checkfr = ctx.io_mut().expect_next().await?; - let (output, check_msg) = CpuBackend::blocking(move || { - sender - .check(&y_star, checkfr) - }) - .await?; + let (output, check_msg) = CpuBackend::blocking(move || sender.check(&y_star, checkfr)).await?; ctx.io_mut().send(check_msg).await?; @@ -128,8 +124,7 @@ pub(crate) async fn receive