diff --git a/ot/mpz-ot/src/ideal/owned.rs b/ot/mpz-ot/src/ideal/owned.rs index c6a5380f..7eaebd62 100644 --- a/ot/mpz-ot/src/ideal/owned.rs +++ b/ot/mpz-ot/src/ideal/owned.rs @@ -1,7 +1,6 @@ use crate::{ - CommittedOTReceiver, CommittedOTSender, CommittedOTSenderWithIo, OTError, OTReceiver, - OTReceiverWithIo, OTSender, OTSenderWithIo, OTSetup, VerifiableOTReceiver, - VerifiableOTReceiverWithIo, VerifiableOTSender, + CommittedOTReceiver, CommittedOTSender, OTError, OTReceiver, OTSender, OTSetup, + VerifiableOTReceiver, VerifiableOTSender, }; use async_trait::async_trait; use futures::{ @@ -79,16 +78,6 @@ where _stream: &mut St, msgs: &[[T; 2]], ) -> Result<(), OTError> { - >::send(self, msgs).await - } -} - -#[async_trait] -impl OTSenderWithIo<[T; 2]> for IdealOTSender -where - T: Send + Sync + Clone + 'static, -{ - async fn send(&mut self, msgs: &[[T; 2]]) -> Result<(), OTError> { self.msgs.extend(msgs.iter().cloned()); self.sender @@ -124,16 +113,6 @@ where _stream: &mut St, choices: &[bool], ) -> Result, OTError> { - >::receive(self, choices).await - } -} - -#[async_trait] -impl OTReceiverWithIo for IdealOTReceiver -where - T: Send + Sync + 'static, -{ - async fn receive(&mut self, choices: &[bool]) -> Result, OTError> { self.choices.extend(choices.iter().copied()); let payload = self @@ -174,16 +153,6 @@ where } } -#[async_trait] -impl VerifiableOTReceiverWithIo<[T; 2]> for IdealOTReceiver -where - T: Send + Sync + 'static, -{ - async fn verify(&mut self, _msgs: &[[T; 2]]) -> Result<(), OTError> { - Ok(()) - } -} - #[async_trait] impl CommittedOTSender<[T; 2]> for IdealOTSender where @@ -198,16 +167,6 @@ where } } -#[async_trait] -impl CommittedOTSenderWithIo for IdealOTSender -where - T: Send + 'static, -{ - async fn reveal(&mut self) -> Result<(), OTError> { - Ok(()) - } -} - #[async_trait] impl CommittedOTReceiver for IdealOTReceiver where @@ -249,20 +208,32 @@ where #[cfg(test)] mod tests { + use utils_aio::duplex::MemoryDuplex; + use super::*; // Test that the sender and receiver can be used to send and receive values #[tokio::test] async fn test_ideal_ot_owned() { + let (send_channel, recv_channel) = MemoryDuplex::<()>::new(); + + let (mut send_sink, mut send_stream) = send_channel.split(); + let (mut recv_sink, mut recv_stream) = recv_channel.split(); + let values = vec![[0, 1], [2, 3]]; let choices = vec![false, true]; let (mut sender, mut receiver) = ideal_ot_pair::(); - OTSenderWithIo::send(&mut sender, &values).await.unwrap(); + sender + .send(&mut send_sink, &mut send_stream, &values) + .await + .unwrap(); - let received = OTReceiverWithIo::receive(&mut receiver, &choices) + let received = receiver + .receive(&mut recv_sink, &mut recv_stream, &choices) .await .unwrap(); + assert_eq!(received, vec![0, 3]); } } diff --git a/ot/mpz-ot/src/lib.rs b/ot/mpz-ot/src/lib.rs index 6d5467fb..2bc79e3e 100644 --- a/ot/mpz-ot/src/lib.rs +++ b/ot/mpz-ot/src/lib.rs @@ -291,82 +291,3 @@ pub trait VerifiableOTReceiverShared: OTReceiverShared { /// * `msgs` - The purported messages sent by the sender. async fn verify(&self, id: &str, msgs: &[V]) -> Result<(), OTError>; } - -// ######################################################################## -// ############################## With IO ################################# -// ######################################################################## - -/// An oblivious transfer sender that owns its own IO channels. -#[async_trait] -pub trait OTSenderWithIo -where - T: Send + Sync, -{ - /// Obliviously transfers the messages to the receiver. - /// - /// # Arguments - /// - /// * `msgs` - The messages to obliviously transfer. - async fn send(&mut self, msgs: &[T]) -> Result<(), OTError>; -} - -/// An oblivious transfer sender that owns its own IO channels, and -/// can reveal its messages. -#[async_trait] -pub trait CommittedOTSenderWithIo { - /// Reveals all messages sent to the receiver. - /// - /// # Warning - /// - /// Obviously, you should be sure you want to do this before calling this function! - async fn reveal(&mut self) -> Result<(), OTError>; -} - -/// An oblivious transfer sender that owns its own IO Channels, -/// and can verify the receiver's choices. -#[async_trait] -pub trait VerifiableOTSenderWithIo { - /// Receives the purported choices made by the receiver and verifies them. - async fn verify_choices(&mut self) -> Result; -} - -/// An oblivious transfer receiver that owns its own IO channels. -#[async_trait] -pub trait OTReceiverWithIo -where - T: Send + Sync, - U: Send + Sync, -{ - /// Obliviously receives data from the sender. - /// - /// # Arguments - /// - /// * `choices` - The choices made by the receiver. - async fn receive(&mut self, choices: &[T]) -> Result, OTError>; -} - -/// An oblivious transfer receiver that can reveal its choices. -#[async_trait] -pub trait CommittedOTReceiverWithIo { - /// Reveals the choices made by the receiver. - /// - /// # Warning - /// - /// Obviously, you should be sure you want to do this before calling this function! - async fn reveal_choices(&mut self) -> Result<(), OTError>; -} - -/// An oblivious transfer receiver that owns its own IO channels, and -/// can verify the sender's messages. -#[async_trait] -pub trait VerifiableOTReceiverWithIo -where - T: Send + Sync, -{ - /// Verifies purported messages sent by the sender. - /// - /// # Arguments - /// - /// * `msgs` - The purported messages sent by the sender. - async fn verify(&mut self, msgs: &[T]) -> Result<(), OTError>; -}