mirror of
https://github.com/tlsnotary/two-party-mul.git
synced 2026-01-09 11:57:56 -05:00
Added OT traits from mpz
This commit is contained in:
@@ -7,4 +7,5 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
mpz-share-conversion-core = { git = "https://github.com/tlsnotary/mpz", rev = "86f1687" }
|
||||
mpz-ot = { git = "https://github.com/tlsnotary/mpz", rev = "86f1687" }
|
||||
rand = "0.8"
|
||||
|
||||
16
src/lib.rs
16
src/lib.rs
@@ -1,19 +1,19 @@
|
||||
//! Implements the two-party multiplication protocol from here: <https://eprint.iacr.org/2019/523>
|
||||
|
||||
use mpz_ot::{ObliviousReceive, ObliviousSend};
|
||||
use mpz_share_conversion_core::Field;
|
||||
use rand::{rngs::ThreadRng, thread_rng, CryptoRng, RngCore};
|
||||
use std::marker::PhantomData;
|
||||
|
||||
mod role;
|
||||
use role::{M2ARole, OTReceiver, OTSender};
|
||||
|
||||
pub struct M2A<T: Field, U: M2ARole, V: CryptoRng + RngCore = ThreadRng> {
|
||||
pub struct M2A<T: Field, U, V: CryptoRng + RngCore = ThreadRng> {
|
||||
_field: PhantomData<T>,
|
||||
_role: PhantomData<U>,
|
||||
rng: V,
|
||||
}
|
||||
|
||||
impl<T: Field, V: CryptoRng + RngCore> M2A<T, OTSender, V> {}
|
||||
impl<T: Field, U: ObliviousSend<T>, V: CryptoRng + RngCore> M2A<T, U, V> {}
|
||||
|
||||
impl<T: Field, V: CryptoRng + RngCore> M2A<T, OTReceiver, V> {
|
||||
impl<T: Field, U: ObliviousReceive<bool, T>, V: CryptoRng + RngCore> M2A<T, U, V> {
|
||||
pub fn beta(&mut self) -> T {
|
||||
todo!()
|
||||
}
|
||||
@@ -23,7 +23,7 @@ impl<T: Field, V: CryptoRng + RngCore> M2A<T, OTReceiver, V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Field, U: M2ARole, V: CryptoRng + RngCore> M2A<T, U, V> {
|
||||
impl<T: Field, U, V: CryptoRng + RngCore> M2A<T, U, V> {
|
||||
// Bits needed for to represent elements of the field
|
||||
const KAPPA: u32 = T::BIT_SIZE;
|
||||
|
||||
@@ -44,7 +44,7 @@ impl<T: Field, U: M2ARole, V: CryptoRng + RngCore> M2A<T, U, V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Field, U: M2ARole> Default for M2A<T, U, ThreadRng> {
|
||||
impl<T: Field, U> Default for M2A<T, U, ThreadRng> {
|
||||
fn default() -> Self {
|
||||
let rng = thread_rng();
|
||||
Self {
|
||||
|
||||
13
src/role.rs
13
src/role.rs
@@ -1,13 +0,0 @@
|
||||
pub trait M2ARole: sealed::Sealed {}
|
||||
|
||||
pub struct OTSender;
|
||||
impl M2ARole for OTSender {}
|
||||
|
||||
pub struct OTReceiver;
|
||||
impl M2ARole for OTReceiver {}
|
||||
|
||||
mod sealed {
|
||||
pub trait Sealed {}
|
||||
impl Sealed for super::OTSender {}
|
||||
impl Sealed for super::OTReceiver {}
|
||||
}
|
||||
Reference in New Issue
Block a user