diff --git a/crates/common/src/config.rs b/crates/common/src/config.rs index 2c327bfd2..5aa1f2792 100644 --- a/crates/common/src/config.rs +++ b/crates/common/src/config.rs @@ -238,7 +238,7 @@ pub enum NetworkSetting { impl Default for NetworkSetting { fn default() -> Self { - Self::Bandwidth + Self::Latency } } diff --git a/crates/components/hmac-sha256/benches/prf.rs b/crates/components/hmac-sha256/benches/prf.rs index 926f50371..cc966741e 100644 --- a/crates/components/hmac-sha256/benches/prf.rs +++ b/crates/components/hmac-sha256/benches/prf.rs @@ -19,13 +19,16 @@ fn criterion_benchmark(c: &mut Criterion) { group.sample_size(10); let rt = tokio::runtime::Runtime::new().unwrap(); - group.bench_function("prf", |b| b.to_async(&rt).iter(prf)); + group.bench_function("prf_normal", |b| b.to_async(&rt).iter(|| prf(Mode::Normal))); + group.bench_function("prf_reduced", |b| { + b.to_async(&rt).iter(|| prf(Mode::Reduced)) + }); } criterion_group!(benches, criterion_benchmark); criterion_main!(benches); -async fn prf() { +async fn prf(mode: Mode) { let mut rng = StdRng::seed_from_u64(0); let pms = [42u8; 32]; @@ -52,8 +55,8 @@ async fn prf() { follower_vm.assign(follower_pms, pms).unwrap(); follower_vm.commit(follower_pms).unwrap(); - let mut leader = MpcPrf::new(Mode::default()); - let mut follower = MpcPrf::new(Mode::default()); + let mut leader = MpcPrf::new(mode); + let mut follower = MpcPrf::new(mode); let leader_output = leader.alloc(&mut leader_vm, leader_pms).unwrap(); let follower_output = follower.alloc(&mut follower_vm, follower_pms).unwrap(); diff --git a/crates/components/hmac-sha256/src/config.rs b/crates/components/hmac-sha256/src/config.rs index 85914b0f5..90834ac64 100644 --- a/crates/components/hmac-sha256/src/config.rs +++ b/crates/components/hmac-sha256/src/config.rs @@ -8,9 +8,3 @@ pub enum Mode { /// Computes the whole PRF in MPC. Normal, } - -impl Default for Mode { - fn default() -> Self { - Self::Reduced - } -} diff --git a/crates/mpc-tls/src/config.rs b/crates/mpc-tls/src/config.rs index 4e5e8b1da..424a8fc17 100644 --- a/crates/mpc-tls/src/config.rs +++ b/crates/mpc-tls/src/config.rs @@ -69,9 +69,9 @@ impl Config { } impl ConfigBuilder { - /// Optimizes the protocol for low bandwidth networks. - pub fn low_bandwidth(&mut self) -> &mut Self { - self.prf = Some(PrfMode::Reduced); + /// Optimizes the protocol for high bandwidth networks. + pub fn high_bandwidth(&mut self) -> &mut Self { + self.prf = Some(PrfMode::Normal); self } @@ -105,7 +105,7 @@ impl ConfigBuilder { .max_recv_records .unwrap_or_else(|| PROTOCOL_RECORD_COUNT_RECV + default_record_count(max_recv)); - let prf = self.prf.unwrap_or_default(); + let prf = self.prf.unwrap_or(PrfMode::Reduced); Ok(Config { defer_decryption, diff --git a/crates/prover/src/config.rs b/crates/prover/src/config.rs index c7f9a2a25..1a685a643 100644 --- a/crates/prover/src/config.rs +++ b/crates/prover/src/config.rs @@ -55,8 +55,8 @@ impl ProverConfig { builder.max_recv_records(max_recv_records); } - if let NetworkSetting::Latency = self.protocol_config.network() { - builder.low_bandwidth(); + if let NetworkSetting::Bandwidth = self.protocol_config.network() { + builder.high_bandwidth(); } builder.build().unwrap() diff --git a/crates/verifier/src/config.rs b/crates/verifier/src/config.rs index 8f2abc194..dfc89f142 100644 --- a/crates/verifier/src/config.rs +++ b/crates/verifier/src/config.rs @@ -58,8 +58,8 @@ impl VerifierConfig { builder.max_recv_records(max_recv_records); } - if let NetworkSetting::Latency = protocol_config.network() { - builder.low_bandwidth(); + if let NetworkSetting::Bandwidth = protocol_config.network() { + builder.high_bandwidth(); } builder.build().unwrap()