From 7593d06bd990ffa277f9bf9ad532f14148000c8a Mon Sep 17 00:00:00 2001 From: Jonas Schneider-Bensch Date: Wed, 28 Feb 2024 14:41:36 +0100 Subject: [PATCH 1/5] Introduce computational and statistical security parameter constants --- mpc-spec/src/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mpc-spec/src/lib.rs b/mpc-spec/src/lib.rs index c73895c..00341c5 100644 --- a/mpc-spec/src/lib.rs +++ b/mpc-spec/src/lib.rs @@ -3,4 +3,10 @@ //! This crate is an executable specification of an MPC engine based on the //! WRK17 protocol. +/// The computational security parameter, in bytes. +pub const COMPUTATIONAL_SECURITY: usize = 128 / 8; + +/// The statistical security parameter, in bytes. +pub const STATISTICAL_SECURITY: usize = 128 / 8; + pub mod circuit; From d5b0ddd5426990914feb775ae2c89edceb7ae0be Mon Sep 17 00:00:00 2001 From: Jonas Schneider-Bensch Date: Wed, 28 Feb 2024 14:58:53 +0100 Subject: [PATCH 2/5] Define basic primitives needed for messages --- mpc-spec/src/lib.rs | 1 + mpc-spec/src/primitives/auth_share.rs | 13 +++++++++++++ mpc-spec/src/primitives/mac.rs | 8 ++++++++ mpc-spec/src/primitives/mod.rs | 4 ++++ 4 files changed, 26 insertions(+) create mode 100644 mpc-spec/src/primitives/auth_share.rs create mode 100644 mpc-spec/src/primitives/mac.rs create mode 100644 mpc-spec/src/primitives/mod.rs diff --git a/mpc-spec/src/lib.rs b/mpc-spec/src/lib.rs index 00341c5..1f12c49 100644 --- a/mpc-spec/src/lib.rs +++ b/mpc-spec/src/lib.rs @@ -10,3 +10,4 @@ pub const COMPUTATIONAL_SECURITY: usize = 128 / 8; pub const STATISTICAL_SECURITY: usize = 128 / 8; pub mod circuit; +pub mod primitives; diff --git a/mpc-spec/src/primitives/auth_share.rs b/mpc-spec/src/primitives/auth_share.rs new file mode 100644 index 0000000..fdb95df --- /dev/null +++ b/mpc-spec/src/primitives/auth_share.rs @@ -0,0 +1,13 @@ +//! This module defines the interface for share authentication. +use super::mac::{Mac, MacKey}; + +/// An authenticated share of a bit. +#[allow(dead_code)] // TODO: Remove this later. +pub struct AuthShare { + /// Party i's share of the bit + share: bool, + /// MACs on the shared bit provided by the other parties + macs: Vec<(usize, Mac)>, + /// Keys for authenticating the other parties' shares of the bit + keys: Vec<(usize, MacKey)>, +} diff --git a/mpc-spec/src/primitives/mac.rs b/mpc-spec/src/primitives/mac.rs new file mode 100644 index 0000000..d1b2481 --- /dev/null +++ b/mpc-spec/src/primitives/mac.rs @@ -0,0 +1,8 @@ +//! This module defines an information theoretic MAC for authenticating bits. + +use crate::COMPUTATIONAL_SECURITY; + +/// A MAC on a bit. +pub type Mac = [u8; COMPUTATIONAL_SECURITY]; +/// A MAC key for authenticating a bit to another party. +pub type MacKey = [u8; COMPUTATIONAL_SECURITY]; diff --git a/mpc-spec/src/primitives/mod.rs b/mpc-spec/src/primitives/mod.rs new file mode 100644 index 0000000..46a8713 --- /dev/null +++ b/mpc-spec/src/primitives/mod.rs @@ -0,0 +1,4 @@ +//! This module provides interfaces for the basic primitives used in WRK17. + +pub mod auth_share; +pub mod mac; From 8f17d219012c3b278cb78330855611aed1a7d787 Mon Sep 17 00:00:00 2001 From: Jonas Schneider-Bensch Date: Wed, 28 Feb 2024 14:59:53 +0100 Subject: [PATCH 3/5] Define top-level and FPre messages --- mpc-spec/src/lib.rs | 1 + mpc-spec/src/messages.rs | 87 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 mpc-spec/src/messages.rs diff --git a/mpc-spec/src/lib.rs b/mpc-spec/src/lib.rs index 1f12c49..a6a12ed 100644 --- a/mpc-spec/src/lib.rs +++ b/mpc-spec/src/lib.rs @@ -10,4 +10,5 @@ pub const COMPUTATIONAL_SECURITY: usize = 128 / 8; pub const STATISTICAL_SECURITY: usize = 128 / 8; pub mod circuit; +pub mod messages; pub mod primitives; diff --git a/mpc-spec/src/messages.rs b/mpc-spec/src/messages.rs new file mode 100644 index 0000000..10d767c --- /dev/null +++ b/mpc-spec/src/messages.rs @@ -0,0 +1,87 @@ +//! This module defines message types for the MPC protocol and its sub-protocols. +use crate::{ + circuit::WireIndex, + primitives::{ + auth_share::AuthShare, + mac::{Mac, MacKey}, + }, + COMPUTATIONAL_SECURITY, +}; + +/// Messages that must be handled by the preprocessing subprotocol, or ideal functionality. +pub enum FPreRequest { + /// A party initialization request. from the indicated party. + Init { + /// The requesting party. + from: usize, + }, + /// A request for a random authenticated share. + Random { + /// The requesting party. + from: usize, + }, + /// A request for the AND of two shares. + And { + /// The requesting party. + from: usize, + /// The first AND input share. + lhs: AuthShare, + /// The second AND input share. + rhs: AuthShare, + }, +} + +/// Messages that are the outcome of the FPre subprotocol. +pub enum FPreResponse { + /// The response to an `Init` request. + Init { + /// The receiver of the message. + to: usize, + /// A fresh global MAC key. + global_mac_key: MacKey, + }, + /// The response to a `Random` request. + Random { + /// The receiver of the message. + to: usize, + /// A fresh random authenticated bit share. + share: AuthShare, + }, + /// The response to an `And` request. + And { + /// The receiver of the message. + to: usize, + /// A fresh random authenticated bit share of the AND of the requested shares. + and_share: AuthShare, + }, +} + +/// An overall message type for all messages between parties. +/// +/// It includes: +/// - top-level protocol messages +/// - suprotocol messages (incomplete) +/// - messages for the FPre subprotocol +/// - (not currently) messages for the remaining sub-protocols the implement +/// FPre +pub enum MPCMessage { + /// A garbled AND gate, to be sent to the evaluator + GarbledAnd(Vec, Vec, Vec, Vec), + /// A MAC on a wire mask share + WireMac(usize, bool, Mac), + /// Masked input wire value + MaskedInput(bool), + /// A wire label, to be sent to the evaluator + WireLabel { + /// The originator of the label + from: usize, + /// The wire the label belongs to + wire: WireIndex, + /// The wire label + label: [u8; COMPUTATIONAL_SECURITY], + }, + /// A message to the FPre subprotocol + FPreRequest(FPreRequest), + /// The FPre subprotocol response + FPreResponse(FPreResponse), +} From 58dab028f88b5f0e59281579b3c11694da5811f2 Mon Sep 17 00:00:00 2001 From: Jonas Schneider-Bensch Date: Mon, 4 Mar 2024 10:38:02 +0100 Subject: [PATCH 4/5] Make `AuthShare` fields `pub (crate)` --- mpc-spec/src/primitives/auth_share.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mpc-spec/src/primitives/auth_share.rs b/mpc-spec/src/primitives/auth_share.rs index fdb95df..aeade22 100644 --- a/mpc-spec/src/primitives/auth_share.rs +++ b/mpc-spec/src/primitives/auth_share.rs @@ -5,9 +5,9 @@ use super::mac::{Mac, MacKey}; #[allow(dead_code)] // TODO: Remove this later. pub struct AuthShare { /// Party i's share of the bit - share: bool, + pub(crate) share: bool, /// MACs on the shared bit provided by the other parties - macs: Vec<(usize, Mac)>, + pub(crate) macs: Vec<(usize, Mac)>, /// Keys for authenticating the other parties' shares of the bit - keys: Vec<(usize, MacKey)>, + pub(crate) keys: Vec<(usize, MacKey)>, } From 17c14d4a8151382fd904853e222ce4f83e54d86c Mon Sep 17 00:00:00 2001 From: Jonas Schneider-Bensch Date: Mon, 4 Mar 2024 10:39:09 +0100 Subject: [PATCH 5/5] Fix typo in documentation of `MPCMessage` --- mpc-spec/src/messages.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mpc-spec/src/messages.rs b/mpc-spec/src/messages.rs index 10d767c..0c477e9 100644 --- a/mpc-spec/src/messages.rs +++ b/mpc-spec/src/messages.rs @@ -62,7 +62,7 @@ pub enum FPreResponse { /// - top-level protocol messages /// - suprotocol messages (incomplete) /// - messages for the FPre subprotocol -/// - (not currently) messages for the remaining sub-protocols the implement +/// - (not currently) messages for the remaining sub-protocols which implement /// FPre pub enum MPCMessage { /// A garbled AND gate, to be sent to the evaluator