Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[workspace]
members = ["integration", "mp-spdz-rs", "offline-phase", "online-phase"]
resolver = "3"

[profile.bench]
opt-level = 3
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use ark_mpc::{
PARTY0, PARTY1,
};
use ark_curve25519::EdwardsProjective as Curve25519Projective;
use rand::thread_rng;
use rand::rng;

type Curve = Curve25519Projective;

Expand All @@ -36,7 +36,7 @@ async fn main() {
let network = QuicTwoPartyNet::new(PARTY0, local_addr, peer_addr);

// MPC circuit
let mut rng = thread_rng();
let mut rng = rng();
let my_val = Scalar::<Curve>::random(&mut rng);
let fabric = MpcFabric::new(network, beaver);

Expand Down
18 changes: 9 additions & 9 deletions integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ edition = "2021"

[dependencies]
# === Cryptography === #
ark-bn254 = "0.4"
ark-ec = "0.4"
ark-bn254 = "0.5"
ark-ec = "0.5"
ark-mpc = { path = "../online-phase", features = ["test_helpers"] }
ark-mpc-offline = { path = "../offline-phase", features = ["parallel"] }

# === Runtime + Harness === #
clap = { version = "3.2.8", features = ["derive"] }
colored = "2"
env_logger = "0.10"
clap = { version = "4.6.0", features = ["derive"] }
colored = "3"
env_logger = "0.11"
futures = "0.3"
inventory = "0.3"
tokio = "1.26"
tokio = "1.50"

# === Misc === #
dns-lookup = "1.0"
itertools = "0.12"
rand = "0.8"
dns-lookup = "3.0"
itertools = "0.14"
rand = "0.10"
tracing = "0.1"
6 changes: 3 additions & 3 deletions integration/src/authenticated_curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use ark_mpc::{
random_point, PARTY0, PARTY1,
};
use itertools::Itertools;
use rand::thread_rng;
use rand::rng;

use crate::{
helpers::{
Expand Down Expand Up @@ -297,7 +297,7 @@ fn test_batch_negation(test_args: &mut IntegrationTestArgs) -> Result<(), String
/// Test multiplication with a public scalar
fn test_multiplication_public_scalar(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Sample a test point, party 1 will make theirs public
let mut rng = thread_rng();
let mut rng = rng();
let point = random_point();
let scalar = Scalar::random(&mut rng);

Expand All @@ -319,7 +319,7 @@ fn test_multiplication_public_scalar(test_args: &mut IntegrationTestArgs) -> Res
/// Test multiplication with a secret shared scalar
fn test_multiplication(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Sample a test point, party 1 will make theirs public
let mut rng = thread_rng();
let mut rng = rng();
let point = random_point();
let scalar = Scalar::random(&mut rng);

Expand Down
38 changes: 19 additions & 19 deletions integration/src/authenticated_scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use ark_mpc::{
ResultValue, PARTY0, PARTY1,
};
use itertools::Itertools;
use rand::thread_rng;
use rand::rng;
use std::ops::Neg;

use crate::{
Expand All @@ -26,7 +26,7 @@ use crate::{
/// it
fn test_open_authenticated(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Each party samples a value
let mut rng = thread_rng();
let mut rng = rng();
let my_val = Scalar::random(&mut rng);

// Share the values with the counterparty and compute the expected result
Expand All @@ -47,7 +47,7 @@ fn test_open_authenticated(test_args: &mut IntegrationTestArgs) -> Result<(), St
/// Tests opening with a corrupted MAC
#[allow(non_snake_case)]
fn test_open_authenticated__bad_mac(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
let mut rng = thread_rng();
let mut rng = rng();
let my_val = Scalar::random(&mut rng);
let mut party0_value = share_authenticated_scalar(my_val, PARTY0, test_args);

Expand All @@ -62,7 +62,7 @@ fn test_open_authenticated__bad_mac(test_args: &mut IntegrationTestArgs) -> Resu
/// Tests opening with a corrupted secret share
#[allow(non_snake_case)]
fn test_open_authenticated__bad_share(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
let mut rng = thread_rng();
let mut rng = rng();
let my_val = Scalar::random(&mut rng);
let mut party0_value = share_authenticated_scalar(my_val, PARTY0, test_args);

Expand All @@ -81,7 +81,7 @@ fn test_open_authenticated__bad_share(test_args: &mut IntegrationTestArgs) -> Re
/// Test addition with a public value
fn test_add_public_value(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Each party samples a value, party 1's value is made public
let mut rng = thread_rng();
let mut rng = rng();
let val = Scalar::random(&mut rng);
let my_value = test_args.fabric.allocate_scalar(ResultValue::Scalar(val));

Expand All @@ -105,7 +105,7 @@ fn test_add_public_value(test_args: &mut IntegrationTestArgs) -> Result<(), Stri
/// Test addition between two secret shared values
fn test_add(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Each party samples a value
let mut rng = thread_rng();
let mut rng = rng();
let my_val = Scalar::random(&mut rng);

// Share the values with the counterparty and compute the expected result
Expand All @@ -130,7 +130,7 @@ fn test_batch_add(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Each party samples a batch of values
let n = 10;
let fabric = &test_args.fabric;
let mut rng = thread_rng();
let mut rng = rng();
let my_vals = (0..n).map(|_| Scalar::random(&mut rng)).collect_vec();
let my_vals_allocated = fabric.allocate_scalars(my_vals.clone());

Expand Down Expand Up @@ -160,7 +160,7 @@ fn test_batch_add_public(test_args: &mut IntegrationTestArgs) -> Result<(), Stri
// Each party samples a batch of values, party 1's values are made public
let n = 10;
let fabric = &test_args.fabric;
let mut rng = thread_rng();
let mut rng = rng();
let my_vals = (0..n).map(|_| Scalar::random(&mut rng)).collect_vec();
let my_vals_allocated = fabric.allocate_scalars(my_vals.clone());

Expand All @@ -187,7 +187,7 @@ fn test_batch_add_public(test_args: &mut IntegrationTestArgs) -> Result<(), Stri
/// Test subtraction between a shared point and a public scalar
fn test_sub_public_scalar(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Each party samples a value, party 1's value is made public
let mut rng = thread_rng();
let mut rng = rng();
let val = Scalar::random(&mut rng);
let my_value = test_args.fabric.allocate_scalar(ResultValue::Scalar(val));

Expand All @@ -211,7 +211,7 @@ fn test_sub_public_scalar(test_args: &mut IntegrationTestArgs) -> Result<(), Str
/// Test subtraction between two secret shared values
fn test_sub(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Each party samples a value
let mut rng = thread_rng();
let mut rng = rng();
let my_val = Scalar::random(&mut rng);

// Share the values with the counterparty and compute the expected result
Expand All @@ -236,7 +236,7 @@ fn test_batch_sub(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Each party samples a batch of values
let n = 10;
let fabric = &test_args.fabric;
let mut rng = thread_rng();
let mut rng = rng();
let my_vals = (0..n).map(|_| Scalar::random(&mut rng)).collect_vec();
let my_vals_allocated = fabric.allocate_scalars(my_vals.clone());

Expand Down Expand Up @@ -266,7 +266,7 @@ fn test_batch_sub_public(test_args: &mut IntegrationTestArgs) -> Result<(), Stri
// Each party samples a batch of values, party 1's values are made public
let n = 10;
let fabric = &test_args.fabric;
let mut rng = thread_rng();
let mut rng = rng();
let my_vals = (0..n).map(|_| Scalar::random(&mut rng)).collect_vec();
let my_vals_allocated = fabric.allocate_scalars(my_vals.clone());

Expand All @@ -293,7 +293,7 @@ fn test_batch_sub_public(test_args: &mut IntegrationTestArgs) -> Result<(), Stri
/// Test negation of a value
fn test_neg(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Each party samples a value
let mut rng = thread_rng();
let mut rng = rng();
let my_val = Scalar::random(&mut rng);

// Share the values with the counterparty and compute the expected result
Expand All @@ -316,7 +316,7 @@ fn test_batch_neg(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Party 0 chooses the values alone for this test
let n = 10;
let fabric = &test_args.fabric;
let mut rng = thread_rng();
let mut rng = rng();
let my_vals = (0..n).map(|_| Scalar::random(&mut rng)).collect_vec();
let my_vals_allocated = fabric.allocate_scalars(my_vals.clone());

Expand All @@ -337,7 +337,7 @@ fn test_batch_neg(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
/// Test multiplication between a shared point and a public scalar
fn test_mul_public_scalar(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Each party samples a value, party 1's value is made public
let mut rng = thread_rng();
let mut rng = rng();
let val = Scalar::random(&mut rng);
let my_value = test_args.fabric.allocate_scalar(ResultValue::Scalar(val));

Expand All @@ -361,7 +361,7 @@ fn test_mul_public_scalar(test_args: &mut IntegrationTestArgs) -> Result<(), Str
/// Test multiplication between two secret shared values
fn test_mul(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Each party samples a value
let mut rng = thread_rng();
let mut rng = rng();
let my_val = Scalar::random(&mut rng);

// Share the values with the counterparty and compute the expected result
Expand All @@ -386,7 +386,7 @@ fn test_batch_mul(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Each party samples a batch of values
let n = 10;
let fabric = &test_args.fabric;
let mut rng = thread_rng();
let mut rng = rng();
let my_vals = (0..n).map(|_| Scalar::random(&mut rng)).collect_vec();
let my_vals_allocated = fabric.allocate_scalars(my_vals.clone());

Expand Down Expand Up @@ -416,7 +416,7 @@ fn test_batch_mul_public(test_args: &mut IntegrationTestArgs) -> Result<(), Stri
// Each party samples a batch of values, party 1's values are made public
let n = 10;
let fabric = &test_args.fabric;
let mut rng = thread_rng();
let mut rng = rng();
let my_vals = (0..n).map(|_| Scalar::random(&mut rng)).collect_vec();
let my_vals_allocated = fabric.allocate_scalars(my_vals.clone());

Expand All @@ -443,7 +443,7 @@ fn test_batch_mul_public(test_args: &mut IntegrationTestArgs) -> Result<(), Stri
/// Test the case in which we add and then multiply by a public value
fn test_public_add_then_mul(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Each party samples a value, party 1's value is made public
let mut rng = thread_rng();
let mut rng = rng();
let val = Scalar::random(&mut rng);
let my_value = test_args.fabric.allocate_scalar(ResultValue::Scalar(val));

Expand Down
10 changes: 5 additions & 5 deletions integration/src/circuits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use ark_mpc::{
random_point, PARTY0, PARTY1,
};
use itertools::Itertools;
use rand::thread_rng;
use rand::rng;

use crate::{
helpers::{
Expand All @@ -23,7 +23,7 @@ fn test_inner_product(test_args: &mut IntegrationTestArgs) -> Result<(), String>
// Sample local values
let n = 100;
let fabric = &test_args.fabric;
let mut rng = thread_rng();
let mut rng = rng();

let my_vals = (0..n).map(|_| Scalar::random(&mut rng)).collect_vec();

Expand Down Expand Up @@ -56,7 +56,7 @@ fn test_msm(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Sample local values
let n = 100;
let fabric = &test_args.fabric;
let mut rng = thread_rng();
let mut rng = rng();

let my_scalars = (0..n).map(|_| Scalar::random(&mut rng)).collect_vec();
let my_points = (0..n).map(|_| random_point()).collect_vec();
Expand Down Expand Up @@ -89,14 +89,14 @@ fn test_msm(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
/// Tests evaluation of a shared polynomial on a public input
fn test_polynomial_eval(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
let fabric = &test_args.fabric;
let mut rng = thread_rng();
let mut rng = rng();
let public_modifier = Scalar::random(&mut rng);
let public_modifier =
share_plaintext_value(fabric.allocate_scalar(public_modifier), PARTY0, fabric);

// Party 0 and party 1 choose a public input
let fabric = &test_args.fabric;
let my_x = fabric.allocate_scalar(Scalar::random(&mut thread_rng()));
let my_x = fabric.allocate_scalar(Scalar::random(&mut rng));
let x = fabric.exchange_value(my_x.clone()) + my_x;
let x_res = await_result(x.clone());

Expand Down
2 changes: 1 addition & 1 deletion integration/src/lowgear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use ark_mpc::{algebra::Scalar, MpcFabric, PARTY0, PARTY1};
use ark_mpc_offline::{
lowgear::{self, LowGear},
lowgear::LowGear,
structs::OfflineSizingParams,
};

Expand Down
9 changes: 6 additions & 3 deletions integration/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct Args {
#[clap(short, long, value_parser)]
test: Option<String>,
/// Whether running in docker or not, used for peer lookup
#[clap(long, takes_value = false, value_parser)]
#[clap(long)]
docker: bool,
}

Expand Down Expand Up @@ -129,11 +129,14 @@ fn main() {
let peer_addr: SocketAddr = {
if args.docker {
let other_host_alias = format!("party{}", if args.party == 1 { 0 } else { 1 });
let hosts = lookup_host(other_host_alias.as_str()).unwrap();
let hosts = lookup_host(other_host_alias.as_str())
.unwrap()
.collect::<Vec<_>>();

println!("Lookup successful for {}... found hosts: {:?}", other_host_alias, hosts);

format!("{}:{}", hosts[0], args.port2).parse().unwrap()
let peer_host = hosts.first().expect("DNS lookup returned no hosts");
format!("{}:{}", peer_host, args.port2).parse().unwrap()
} else {
format!("{}:{}", "127.0.0.1", args.port2).parse().unwrap()
}
Expand Down
18 changes: 9 additions & 9 deletions mp-spdz-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,26 @@ required-features = ["test-helpers"]

[dependencies]
# === Arithmetic + Crypto === #
ark-bn254 = "0.4"
ark-ec = { version = "0.4" }
ark-ff = { version = "0.4" }
ark-bn254 = "0.5"
ark-ec = { version = "0.5" }
ark-ff = { version = "0.5" }
ark-mpc = { path = "../online-phase" }

# === Bindings === #
cxx = "1.0"

# === Misc === #
rand = { version = "0.8.4", optional = true }
rayon = { version = "1.10", optional = true }
rand = { version = "0.10.0", optional = true }
rayon = { version = "1.11", optional = true }
serde = { version = "1.0", features = ["derive"] }

[build-dependencies]
cxx-build = "1.0"
itertools = "0.12.0"
itertools = "0.14.0"
pkg-config = "0.3"

[dev-dependencies]
ark-bn254 = "0.4"
criterion = { version = "0.5", features = ["async", "async_tokio"] }
rand = "0.8.4"
ark-bn254 = "0.5"
criterion = { version = "0.8", features = ["async", "async_tokio"] }
rand = "0.10.0"
serde_json = "1.0"
Loading