From d95ea007c52bbfb9125208d572e002d426411a2d Mon Sep 17 00:00:00 2001 From: sinu <65924192+sinui0@users.noreply.github.com> Date: Mon, 15 Jan 2024 16:43:15 -0800 Subject: [PATCH] rename mock ot to ideal --- garble/mpz-garble/Cargo.toml | 4 +- garble/mpz-garble/src/ot.rs | 4 +- garble/mpz-garble/src/protocol/deap/mock.rs | 18 +++---- garble/mpz-garble/src/protocol/deap/mod.rs | 22 ++++----- garble/mpz-garble/src/protocol/deap/vm.rs | 6 +-- garble/mpz-garble/tests/offline-garble.rs | 4 +- garble/mpz-garble/tests/semihonest.rs | 4 +- ot/mpz-ot/Cargo.toml | 4 +- ot/mpz-ot/src/actor/kos/mod.rs | 8 ++-- ot/mpz-ot/src/ideal/mod.rs | 7 +++ ot/mpz-ot/src/{mock => ideal}/owned.rs | 48 +++++++++---------- ot/mpz-ot/src/{mock => ideal}/shared.rs | 28 +++++------ ot/mpz-ot/src/kos/mod.rs | 9 ++-- ot/mpz-ot/src/lib.rs | 4 +- ot/mpz-ot/src/mock/mod.rs | 7 --- .../mpz-share-conversion/src/lib.rs | 8 ++-- .../mpz-share-conversion/src/mock.rs | 16 +++---- .../mpz-share-conversion/tests/converter.rs | 8 ++-- 18 files changed, 106 insertions(+), 103 deletions(-) create mode 100644 ot/mpz-ot/src/ideal/mod.rs rename ot/mpz-ot/src/{mock => ideal}/owned.rs (82%) rename ot/mpz-ot/src/{mock => ideal}/shared.rs (83%) delete mode 100644 ot/mpz-ot/src/mock/mod.rs diff --git a/garble/mpz-garble/Cargo.toml b/garble/mpz-garble/Cargo.toml index 89d6b699..04159631 100644 --- a/garble/mpz-garble/Cargo.toml +++ b/garble/mpz-garble/Cargo.toml @@ -8,7 +8,7 @@ name = "mpz_garble" [features] default = ["mock"] -mock = ["mpz-ot/mock"] +mock = ["mpz-ot/ideal"] [dependencies] mpz-circuits.workspace = true @@ -34,7 +34,7 @@ itybity.workspace = true opaque-debug.workspace = true [dev-dependencies] -mpz-ot = { workspace = true, features = ["mock"] } +mpz-ot = { workspace = true, features = ["ideal"] } rstest = { workspace = true } criterion = { workspace = true, features = ["async_tokio"] } tlsn-utils-aio = { workspace = true, features = ["duplex"] } diff --git a/garble/mpz-garble/src/ot.rs b/garble/mpz-garble/src/ot.rs index dcd66334..fbcb36ec 100644 --- a/garble/mpz-garble/src/ot.rs +++ b/garble/mpz-garble/src/ot.rs @@ -126,12 +126,12 @@ mod tests { use mpz_circuits::circuits::AES128; use mpz_garble_core::{ChaChaEncoder, Encoder}; - use mpz_ot::mock::mock_ot_shared_pair; + use mpz_ot::ideal::ideal_ot_shared_pair; #[tokio::test] async fn test_encoding_transfer() { let encoder = ChaChaEncoder::new([0u8; 32]); - let (sender, receiver) = mock_ot_shared_pair(); + let (sender, receiver) = ideal_ot_shared_pair(); let inputs = AES128 .inputs() diff --git a/garble/mpz-garble/src/protocol/deap/mock.rs b/garble/mpz-garble/src/protocol/deap/mock.rs index d3100ef6..4bbcd67b 100644 --- a/garble/mpz-garble/src/protocol/deap/mock.rs +++ b/garble/mpz-garble/src/protocol/deap/mock.rs @@ -1,6 +1,6 @@ //! Mocked DEAP VMs for testing -use mpz_ot::mock::{mock_ot_shared_pair, MockSharedOTReceiver, MockSharedOTSender}; +use mpz_ot::ideal::{ideal_ot_shared_pair, IdealSharedOTReceiver, IdealSharedOTSender}; use utils_aio::mux::{mock::MockMuxChannelFactory, MuxChannel}; use crate::config::Role; @@ -8,24 +8,24 @@ use crate::config::Role; use super::{vm::DEAPVm, DEAPThread}; /// Mock DEAP Leader VM. -pub type MockLeader = DEAPVm; +pub type MockLeader = DEAPVm; /// Mock DEAP Leader thread. -pub type MockLeaderThread = DEAPThread; +pub type MockLeaderThread = DEAPThread; /// Mock DEAP Follower VM. -pub type MockFollower = DEAPVm; +pub type MockFollower = DEAPVm; /// Mock DEAP Follower thread. -pub type MockFollowerThread = DEAPThread; +pub type MockFollowerThread = DEAPThread; /// Create a pair of mocked DEAP VMs pub async fn create_mock_deap_vm( id: &str, ) -> ( - DEAPVm, - DEAPVm, + DEAPVm, + DEAPVm, ) { let mut mux_factory = MockMuxChannelFactory::new(); - let (leader_ot_send, follower_ot_recv) = mock_ot_shared_pair(); - let (follower_ot_send, leader_ot_recv) = mock_ot_shared_pair(); + let (leader_ot_send, follower_ot_recv) = ideal_ot_shared_pair(); + let (follower_ot_send, leader_ot_recv) = ideal_ot_shared_pair(); let leader_channel = mux_factory.get_channel(id).await.unwrap(); let follower_channel = mux_factory.get_channel(id).await.unwrap(); diff --git a/garble/mpz-garble/src/protocol/deap/mod.rs b/garble/mpz-garble/src/protocol/deap/mod.rs index fd711632..e0900aba 100644 --- a/garble/mpz-garble/src/protocol/deap/mod.rs +++ b/garble/mpz-garble/src/protocol/deap/mod.rs @@ -889,7 +889,7 @@ impl State { #[cfg(test)] mod tests { use mpz_circuits::{circuits::AES128, ops::WrappingAdd, CircuitBuilder}; - use mpz_ot::mock::mock_ot_shared_pair; + use mpz_ot::ideal::ideal_ot_shared_pair; use utils_aio::duplex::MemoryDuplex; use crate::Memory; @@ -912,8 +912,8 @@ mod tests { #[tokio::test] async fn test_deap() { let (leader_channel, follower_channel) = MemoryDuplex::::new(); - let (leader_ot_send, follower_ot_recv) = mock_ot_shared_pair(); - let (follower_ot_send, leader_ot_recv) = mock_ot_shared_pair(); + let (leader_ot_send, follower_ot_recv) = ideal_ot_shared_pair(); + let (follower_ot_send, leader_ot_recv) = ideal_ot_shared_pair(); let mut leader = DEAP::new(Role::Leader, [42u8; 32]); let mut follower = DEAP::new(Role::Follower, [69u8; 32]); @@ -1005,8 +1005,8 @@ mod tests { #[tokio::test] async fn test_deap_load() { let (leader_channel, follower_channel) = MemoryDuplex::::new(); - let (leader_ot_send, follower_ot_recv) = mock_ot_shared_pair(); - let (follower_ot_send, leader_ot_recv) = mock_ot_shared_pair(); + let (leader_ot_send, follower_ot_recv) = ideal_ot_shared_pair(); + let (follower_ot_send, leader_ot_recv) = ideal_ot_shared_pair(); let mut leader = DEAP::new(Role::Leader, [42u8; 32]); let mut follower = DEAP::new(Role::Follower, [69u8; 32]); @@ -1120,8 +1120,8 @@ mod tests { #[tokio::test] async fn test_deap_decode_private() { let (leader_channel, follower_channel) = MemoryDuplex::::new(); - let (leader_ot_send, follower_ot_recv) = mock_ot_shared_pair(); - let (follower_ot_send, leader_ot_recv) = mock_ot_shared_pair(); + let (leader_ot_send, follower_ot_recv) = ideal_ot_shared_pair(); + let (follower_ot_send, leader_ot_recv) = ideal_ot_shared_pair(); let mut leader = DEAP::new(Role::Leader, [42u8; 32]); let mut follower = DEAP::new(Role::Follower, [69u8; 32]); @@ -1228,8 +1228,8 @@ mod tests { #[tokio::test] async fn test_deap_decode_shared() { let (leader_channel, follower_channel) = MemoryDuplex::::new(); - let (leader_ot_send, follower_ot_recv) = mock_ot_shared_pair(); - let (follower_ot_send, leader_ot_recv) = mock_ot_shared_pair(); + let (leader_ot_send, follower_ot_recv) = ideal_ot_shared_pair(); + let (follower_ot_send, leader_ot_recv) = ideal_ot_shared_pair(); let mut leader = DEAP::new(Role::Leader, [42u8; 32]); let mut follower = DEAP::new(Role::Follower, [69u8; 32]); @@ -1366,8 +1366,8 @@ mod tests { async fn run_zk(key: [u8; 16], msg: [u8; 16], expected_ciphertext: [u8; 16]) { let (leader_channel, follower_channel) = MemoryDuplex::::new(); - let (_, follower_ot_recv) = mock_ot_shared_pair(); - let (follower_ot_send, leader_ot_recv) = mock_ot_shared_pair(); + let (_, follower_ot_recv) = ideal_ot_shared_pair(); + let (follower_ot_send, leader_ot_recv) = ideal_ot_shared_pair(); let mut leader = DEAP::new(Role::Leader, [42u8; 32]); let mut follower = DEAP::new(Role::Follower, [69u8; 32]); diff --git a/garble/mpz-garble/src/protocol/deap/vm.rs b/garble/mpz-garble/src/protocol/deap/vm.rs index 7f0a8a55..c7708eb4 100644 --- a/garble/mpz-garble/src/protocol/deap/vm.rs +++ b/garble/mpz-garble/src/protocol/deap/vm.rs @@ -482,15 +482,15 @@ mod tests { use crate::protocol::deap::mock::create_mock_deap_vm; use core::{future::Future, pin::Pin}; - use mpz_ot::mock::{MockSharedOTReceiver, MockSharedOTSender}; + use mpz_ot::ideal::{IdealSharedOTReceiver, IdealSharedOTSender}; use rstest::{fixture, rstest}; // Leader and follower VMs in a set up state and the futures which need to be awaited // to trigger circuit execution. struct VmFixture { - leader_vm: DEAPVm, + leader_vm: DEAPVm, leader_fut: Pin>>>, - follower_vm: DEAPVm, + follower_vm: DEAPVm, follower_fut: Pin>>>, } diff --git a/garble/mpz-garble/tests/offline-garble.rs b/garble/mpz-garble/tests/offline-garble.rs index c3e049d2..c6982a5a 100644 --- a/garble/mpz-garble/tests/offline-garble.rs +++ b/garble/mpz-garble/tests/offline-garble.rs @@ -1,6 +1,6 @@ use mpz_circuits::{circuits::AES128, types::StaticValueType}; use mpz_garble_core::msg::GarbleMessage; -use mpz_ot::mock::mock_ot_shared_pair; +use mpz_ot::ideal::ideal_ot_shared_pair; use utils_aio::duplex::MemoryDuplex; use mpz_garble::{config::Visibility, Evaluator, Generator, GeneratorConfigBuilder, ValueMemory}; @@ -8,7 +8,7 @@ use mpz_garble::{config::Visibility, Evaluator, Generator, GeneratorConfigBuilde #[tokio::test] async fn test_offline_garble() { let (mut gen_channel, mut ev_channel) = MemoryDuplex::::new(); - let (ot_send, ot_recv) = mock_ot_shared_pair(); + let (ot_send, ot_recv) = ideal_ot_shared_pair(); let gen = Generator::new( GeneratorConfigBuilder::default().build().unwrap(), diff --git a/garble/mpz-garble/tests/semihonest.rs b/garble/mpz-garble/tests/semihonest.rs index a3f9c71d..bf7773a8 100644 --- a/garble/mpz-garble/tests/semihonest.rs +++ b/garble/mpz-garble/tests/semihonest.rs @@ -1,6 +1,6 @@ use mpz_circuits::{circuits::AES128, types::StaticValueType}; use mpz_garble_core::msg::GarbleMessage; -use mpz_ot::mock::mock_ot_shared_pair; +use mpz_ot::ideal::ideal_ot_shared_pair; use utils_aio::duplex::MemoryDuplex; use mpz_garble::{config::Visibility, Evaluator, Generator, GeneratorConfigBuilder, ValueMemory}; @@ -8,7 +8,7 @@ use mpz_garble::{config::Visibility, Evaluator, Generator, GeneratorConfigBuilde #[tokio::test] async fn test_semi_honest() { let (mut gen_channel, mut ev_channel) = MemoryDuplex::::new(); - let (ot_send, ot_recv) = mock_ot_shared_pair(); + let (ot_send, ot_recv) = ideal_ot_shared_pair(); let gen = Generator::new( GeneratorConfigBuilder::default().build().unwrap(), diff --git a/ot/mpz-ot/Cargo.toml b/ot/mpz-ot/Cargo.toml index fb7d95c0..ec171c99 100644 --- a/ot/mpz-ot/Cargo.toml +++ b/ot/mpz-ot/Cargo.toml @@ -7,10 +7,10 @@ edition = "2021" name = "mpz_ot" [features] -default = ["mock", "rayon", "actor"] +default = ["ideal", "rayon", "actor"] rayon = ["mpz-ot-core/rayon"] actor = ["dep:serde"] -mock = [] +ideal = [] [dependencies] mpz-core.workspace = true diff --git a/ot/mpz-ot/src/actor/kos/mod.rs b/ot/mpz-ot/src/actor/kos/mod.rs index 988c300a..a9e9eff4 100644 --- a/ot/mpz-ot/src/actor/kos/mod.rs +++ b/ot/mpz-ot/src/actor/kos/mod.rs @@ -34,8 +34,8 @@ pub(crate) fn into_kos_stream<'a, St: IoStream> + Send + Unpin, #[cfg(test)] mod tests { use crate::{ + ideal::{ideal_ot_pair, IdealOTReceiver, IdealOTSender}, kos::{Receiver, Sender}, - mock::{mock_ot_pair, MockOTReceiver, MockOTSender}, OTReceiverShared, OTSenderShared, VerifiableOTReceiverShared, }; @@ -83,12 +83,12 @@ mod tests { count: usize, ) -> ( SenderActor< - MockOTReceiver, + IdealOTReceiver, SplitSink>, Message<()>>, SplitStream>>, >, ReceiverActor< - MockOTSender, + IdealOTSender, SplitSink>, Message<()>>, SplitStream>>, >, @@ -98,7 +98,7 @@ mod tests { let (sender_sink, sender_stream) = sender_channel.split(); let (receiver_sink, receiver_stream) = receiver_channel.split(); - let (base_sender, base_receiver) = mock_ot_pair(); + let (base_sender, base_receiver) = ideal_ot_pair(); let sender = Sender::new(sender_config, base_receiver); let receiver = Receiver::new(receiver_config, base_sender); diff --git a/ot/mpz-ot/src/ideal/mod.rs b/ot/mpz-ot/src/ideal/mod.rs new file mode 100644 index 00000000..c2252022 --- /dev/null +++ b/ot/mpz-ot/src/ideal/mod.rs @@ -0,0 +1,7 @@ +//! Mock implementations of the OT protocols. + +mod owned; +mod shared; + +pub use owned::{ideal_ot_pair, IdealOTReceiver, IdealOTSender}; +pub use shared::{ideal_ot_shared_pair, IdealSharedOTReceiver, IdealSharedOTSender}; diff --git a/ot/mpz-ot/src/mock/owned.rs b/ot/mpz-ot/src/ideal/owned.rs similarity index 82% rename from ot/mpz-ot/src/mock/owned.rs rename to ot/mpz-ot/src/ideal/owned.rs index c03816af..c6a5380f 100644 --- a/ot/mpz-ot/src/mock/owned.rs +++ b/ot/mpz-ot/src/ideal/owned.rs @@ -11,42 +11,42 @@ use futures::{ use mpz_core::ProtocolMessage; use utils_aio::{sink::IoSink, stream::IoStream}; -/// Mock OT sender. +/// Ideal OT sender. #[derive(Debug)] -pub struct MockOTSender { +pub struct IdealOTSender { sender: mpsc::Sender>, msgs: Vec<[T; 2]>, choices_receiver: Option>>, } -/// Mock OT receiver. +/// Ideal OT receiver. #[derive(Debug)] -pub struct MockOTReceiver { +pub struct IdealOTReceiver { receiver: mpsc::Receiver>, choices: Vec, choices_sender: Option>>, } -impl ProtocolMessage for MockOTSender { +impl ProtocolMessage for IdealOTSender { type Msg = (); } -impl ProtocolMessage for MockOTReceiver { +impl ProtocolMessage for IdealOTReceiver { type Msg = (); } -/// Creates a pair of mock OT sender and receiver. -pub fn mock_ot_pair() -> (MockOTSender, MockOTReceiver) { +/// Creates a pair of ideal OT sender and receiver. +pub fn ideal_ot_pair() -> (IdealOTSender, IdealOTReceiver) { let (sender, receiver) = mpsc::channel(10); let (choices_sender, choices_receiver) = oneshot::channel(); ( - MockOTSender { + IdealOTSender { sender, msgs: Vec::default(), choices_receiver: Some(choices_receiver), }, - MockOTReceiver { + IdealOTReceiver { receiver, choices: Vec::default(), choices_sender: Some(choices_sender), @@ -55,7 +55,7 @@ pub fn mock_ot_pair() -> (MockOTSender, MockOTRecei } #[async_trait] -impl OTSetup for MockOTSender +impl OTSetup for IdealOTSender where T: Send + Sync, { @@ -69,7 +69,7 @@ where } #[async_trait] -impl OTSender<[T; 2]> for MockOTSender +impl OTSender<[T; 2]> for IdealOTSender where T: Send + Sync + Clone + 'static, { @@ -84,7 +84,7 @@ where } #[async_trait] -impl OTSenderWithIo<[T; 2]> for MockOTSender +impl OTSenderWithIo<[T; 2]> for IdealOTSender where T: Send + Sync + Clone + 'static, { @@ -100,7 +100,7 @@ where } #[async_trait] -impl OTSetup for MockOTReceiver +impl OTSetup for IdealOTReceiver where T: Send + Sync, { @@ -114,7 +114,7 @@ where } #[async_trait] -impl OTReceiver for MockOTReceiver +impl OTReceiver for IdealOTReceiver where T: Send + Sync + 'static, { @@ -129,7 +129,7 @@ where } #[async_trait] -impl OTReceiverWithIo for MockOTReceiver +impl OTReceiverWithIo for IdealOTReceiver where T: Send + Sync + 'static, { @@ -158,7 +158,7 @@ where } #[async_trait] -impl VerifiableOTReceiver for MockOTReceiver +impl VerifiableOTReceiver for IdealOTReceiver where U: Send + Sync + 'static, V: Send + Sync + 'static, @@ -175,7 +175,7 @@ where } #[async_trait] -impl VerifiableOTReceiverWithIo<[T; 2]> for MockOTReceiver +impl VerifiableOTReceiverWithIo<[T; 2]> for IdealOTReceiver where T: Send + Sync + 'static, { @@ -185,7 +185,7 @@ where } #[async_trait] -impl CommittedOTSender<[T; 2]> for MockOTSender +impl CommittedOTSender<[T; 2]> for IdealOTSender where T: Send + Sync + Clone + 'static, { @@ -199,7 +199,7 @@ where } #[async_trait] -impl CommittedOTSenderWithIo for MockOTSender +impl CommittedOTSenderWithIo for IdealOTSender where T: Send + 'static, { @@ -209,7 +209,7 @@ where } #[async_trait] -impl CommittedOTReceiver for MockOTReceiver +impl CommittedOTReceiver for IdealOTReceiver where T: Send + Sync + 'static, { @@ -229,7 +229,7 @@ where } #[async_trait] -impl VerifiableOTSender for MockOTSender +impl VerifiableOTSender for IdealOTSender where T: Send + Sync + Clone + 'static, { @@ -253,10 +253,10 @@ mod tests { // Test that the sender and receiver can be used to send and receive values #[tokio::test] - async fn test_mock_ot_owned() { + async fn test_ideal_ot_owned() { let values = vec![[0, 1], [2, 3]]; let choices = vec![false, true]; - let (mut sender, mut receiver) = mock_ot_pair::(); + let (mut sender, mut receiver) = ideal_ot_pair::(); OTSenderWithIo::send(&mut sender, &values).await.unwrap(); diff --git a/ot/mpz-ot/src/mock/shared.rs b/ot/mpz-ot/src/ideal/shared.rs similarity index 83% rename from ot/mpz-ot/src/mock/shared.rs rename to ot/mpz-ot/src/ideal/shared.rs index 137f86fb..fcd6fbc8 100644 --- a/ot/mpz-ot/src/mock/shared.rs +++ b/ot/mpz-ot/src/ideal/shared.rs @@ -11,17 +11,17 @@ use crate::{ CommittedOTSenderShared, OTError, OTReceiverShared, OTSenderShared, VerifiableOTReceiverShared, }; -/// Creates a mock sender and receiver pair. -pub fn mock_ot_shared_pair() -> (MockSharedOTSender, MockSharedOTReceiver) { +/// Creates a ideal sender and receiver pair. +pub fn ideal_ot_shared_pair() -> (IdealSharedOTSender, IdealSharedOTReceiver) { let sender_buffer = Arc::new(Mutex::new(HashMap::new())); let receiver_buffer = Arc::new(Mutex::new(HashMap::new())); - let sender = MockSharedOTSender { + let sender = IdealSharedOTSender { sender_buffer: sender_buffer.clone(), receiver_buffer: receiver_buffer.clone(), }; - let receiver = MockSharedOTReceiver { + let receiver = IdealSharedOTReceiver { sender_buffer, receiver_buffer, }; @@ -32,21 +32,21 @@ pub fn mock_ot_shared_pair() -> (MockSharedOTSender, MockSharedOTReceiver) { /// A mock oblivious transfer sender. #[derive(Clone, Debug)] #[allow(clippy::type_complexity)] -pub struct MockSharedOTSender { +pub struct IdealSharedOTSender { sender_buffer: Arc>>>, receiver_buffer: Arc>>>>, } #[async_trait] impl OTSenderShared<[T; 2]> - for MockSharedOTSender + for IdealSharedOTSender { async fn send(&self, id: &str, msgs: &[[T; 2]]) -> Result<(), OTError> { let msgs = Box::new(msgs.to_vec()); if let Some(sender) = self.receiver_buffer.lock().unwrap().remove(id) { sender .send(msgs) - .expect("MockOTSenderControl should be able to send"); + .expect("IdealOTSenderControl should be able to send"); } else { self.sender_buffer .lock() @@ -59,7 +59,7 @@ impl OTSenderShared<[T; 2]> #[async_trait] impl CommittedOTSenderShared<[T; 2]> - for MockSharedOTSender + for IdealSharedOTSender { async fn reveal(&self) -> Result<(), OTError> { Ok(()) @@ -69,13 +69,13 @@ impl CommittedOTSenderShared /// A mock oblivious transfer receiver. #[derive(Clone, Debug)] #[allow(clippy::type_complexity)] -pub struct MockSharedOTReceiver { +pub struct IdealSharedOTReceiver { sender_buffer: Arc>>>, receiver_buffer: Arc>>>>, } #[async_trait] -impl OTReceiverShared for MockSharedOTReceiver { +impl OTReceiverShared for IdealSharedOTReceiver { async fn receive(&self, id: &str, choices: &[bool]) -> Result, OTError> { if let Some(value) = self.sender_buffer.lock().unwrap().remove(id) { let value = *value @@ -111,10 +111,10 @@ impl OTReceiverShared for MockSharedOTReceive #[async_trait] impl VerifiableOTReceiverShared - for MockSharedOTReceiver + for IdealSharedOTReceiver { async fn verify(&self, _id: &str, _msgs: &[[T; 2]]) -> Result<(), OTError> { - // MockOT is always honest + // Ideal OT is always honest Ok(()) } } @@ -124,10 +124,10 @@ mod tests { use super::*; #[tokio::test] - async fn test_mock_ot() { + async fn test_ideal_ot() { let values = vec![[0, 1], [2, 3]]; let choices = vec![false, true]; - let (sender, receiver) = mock_ot_shared_pair(); + let (sender, receiver) = ideal_ot_shared_pair(); sender.send("", &values).await.unwrap(); diff --git a/ot/mpz-ot/src/kos/mod.rs b/ot/mpz-ot/src/kos/mod.rs index e6c92b23..39aca16b 100644 --- a/ot/mpz-ot/src/kos/mod.rs +++ b/ot/mpz-ot/src/kos/mod.rs @@ -52,7 +52,7 @@ mod tests { use utils_aio::{duplex::MemoryDuplex, sink::IoSink, stream::IoStream}; use crate::{ - mock::{mock_ot_pair, MockOTReceiver, MockOTSender}, + ideal::{ideal_ot_pair, IdealOTReceiver, IdealOTSender}, OTReceiver, OTSender, OTSetup, RandomOTReceiver, RandomOTSender, VerifiableOTReceiver, }; @@ -89,8 +89,11 @@ mod tests { receiver_sink: &mut Si, receiver_stream: &mut St, count: usize, - ) -> (Sender>, Receiver>) { - let (base_sender, base_receiver) = mock_ot_pair(); + ) -> ( + Sender>, + Receiver>, + ) { + let (base_sender, base_receiver) = ideal_ot_pair(); let mut sender = Sender::new(sender_config, base_receiver); let mut receiver = Receiver::new(receiver_config, base_sender); diff --git a/ot/mpz-ot/src/lib.rs b/ot/mpz-ot/src/lib.rs index 8ff88faf..6d5467fb 100644 --- a/ot/mpz-ot/src/lib.rs +++ b/ot/mpz-ot/src/lib.rs @@ -7,9 +7,9 @@ #[cfg(feature = "actor")] pub mod actor; pub mod chou_orlandi; +#[cfg(feature = "ideal")] +pub mod ideal; pub mod kos; -#[cfg(feature = "mock")] -pub mod mock; use async_trait::async_trait; use mpz_core::ProtocolMessage; diff --git a/ot/mpz-ot/src/mock/mod.rs b/ot/mpz-ot/src/mock/mod.rs deleted file mode 100644 index 3251e00f..00000000 --- a/ot/mpz-ot/src/mock/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -//! Mock implementations of the OT protocols. - -mod owned; -mod shared; - -pub use owned::{mock_ot_pair, MockOTReceiver, MockOTSender}; -pub use shared::{mock_ot_shared_pair, MockSharedOTReceiver, MockSharedOTSender}; diff --git a/share-conversion/mpz-share-conversion/src/lib.rs b/share-conversion/mpz-share-conversion/src/lib.rs index 7608954a..4601a8ec 100644 --- a/share-conversion/mpz-share-conversion/src/lib.rs +++ b/share-conversion/mpz-share-conversion/src/lib.rs @@ -100,7 +100,7 @@ mod tests { use crate::config::{ReceiverConfig, SenderConfig}; - use mpz_ot::mock::{mock_ot_shared_pair, MockSharedOTReceiver, MockSharedOTSender}; + use mpz_ot::ideal::{ideal_ot_shared_pair, IdealSharedOTReceiver, IdealSharedOTSender}; use mpz_share_conversion_core::{ fields::{gf2_128::Gf2_128, p256::P256, Field}, ShareType, @@ -132,10 +132,10 @@ mod tests { #[case] _pd: PhantomData, #[values(false, true)] malicious: bool, ) where - MockSharedOTSender: OTSendElement, - MockSharedOTReceiver: OTReceiveElement, + IdealSharedOTSender: OTSendElement, + IdealSharedOTReceiver: OTReceiveElement, { - let (ot_sender, ot_receiver) = mock_ot_shared_pair(); + let (ot_sender, ot_receiver) = ideal_ot_shared_pair(); let (mut sender_channel, mut receiver_channel) = MemoryDuplex::new(); let (mut sender, mut receiver) = create_pair::(); let mut rng = ChaCha20Rng::from_seed([0; 32]); diff --git a/share-conversion/mpz-share-conversion/src/mock.rs b/share-conversion/mpz-share-conversion/src/mock.rs index 4d3058bf..23e06ce9 100644 --- a/share-conversion/mpz-share-conversion/src/mock.rs +++ b/share-conversion/mpz-share-conversion/src/mock.rs @@ -3,14 +3,14 @@ use crate::{OTReceiveElement, OTSendElement}; use super::{ConverterReceiver, ConverterSender, ReceiverConfig, SenderConfig}; -use mpz_ot::mock::{mock_ot_shared_pair, MockSharedOTReceiver, MockSharedOTSender}; +use mpz_ot::ideal::{ideal_ot_shared_pair, IdealSharedOTReceiver, IdealSharedOTSender}; use mpz_share_conversion_core::fields::Field; use utils_aio::duplex::MemoryDuplex; /// A mock converter sender -pub type MockConverterSender = ConverterSender; +pub type MockConverterSender = ConverterSender; /// A mock converter receiver -pub type MockConverterReceiver = ConverterReceiver; +pub type MockConverterReceiver = ConverterReceiver; /// Creates a mock sender and receiver for testing the share conversion protocol. #[allow(clippy::type_complexity)] @@ -18,16 +18,16 @@ pub fn mock_converter_pair( sender_config: SenderConfig, receiver_config: ReceiverConfig, ) -> ( - ConverterSender, - ConverterReceiver, + ConverterSender, + ConverterReceiver, ) where - MockSharedOTSender: OTSendElement, - MockSharedOTReceiver: OTReceiveElement, + IdealSharedOTSender: OTSendElement, + IdealSharedOTReceiver: OTReceiveElement, { let (c1, c2) = MemoryDuplex::new(); - let (ot_sender, ot_receiver) = mock_ot_shared_pair(); + let (ot_sender, ot_receiver) = ideal_ot_shared_pair(); let sender = ConverterSender::new(sender_config, ot_sender, Box::new(c1)); let receiver = ConverterReceiver::new(receiver_config, ot_receiver, Box::new(c2)); diff --git a/share-conversion/mpz-share-conversion/tests/converter.rs b/share-conversion/mpz-share-conversion/tests/converter.rs index 26b3321b..6c8239f1 100644 --- a/share-conversion/mpz-share-conversion/tests/converter.rs +++ b/share-conversion/mpz-share-conversion/tests/converter.rs @@ -2,7 +2,7 @@ use std::marker::PhantomData; use rstest::*; -use mpz_ot::mock::{mock_ot_shared_pair, MockSharedOTReceiver, MockSharedOTSender}; +use mpz_ot::ideal::{ideal_ot_shared_pair, IdealSharedOTReceiver, IdealSharedOTSender}; use mpz_share_conversion::{ AdditiveToMultiplicative, ConverterReceiver, ConverterSender, Field, Gf2_128, MultiplicativeToAdditive, OTReceiveElement, OTSendElement, ReceiverConfig, SenderConfig, @@ -19,12 +19,12 @@ use rand_chacha::ChaCha12Rng; #[tokio::test] async fn test_converter(#[case] _pd: PhantomData) where - MockSharedOTSender: OTSendElement, - MockSharedOTReceiver: OTReceiveElement, + IdealSharedOTSender: OTSendElement, + IdealSharedOTReceiver: OTReceiveElement, { let mut rng = ChaCha12Rng::seed_from_u64(0); - let (ot_sender, ot_receiver) = mock_ot_shared_pair(); + let (ot_sender, ot_receiver) = ideal_ot_shared_pair(); let (sender_channel, receiver_channel) = MemoryDuplex::new(); let mut sender = ConverterSender::::new(