Skip to content

Commit

Permalink
meta: Cleanup crate, comments, README, etc after curve generics refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
joeykraut committed Oct 10, 2023
1 parent c26bb6c commit edbf025
Show file tree
Hide file tree
Showing 26 changed files with 213 additions and 211 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[package]
name = "mpc-stark"
version = "0.2.4"
name = "ark-mpc"
version = "0.1.0"
description = "Malicious-secure SPDZ style two party secure computation"
keywords = ["mpc", "crypto", "cryptography"]
homepage = "https://renegade.fi"
authors = ["Joey Kraut <[email protected]>"]
edition = "2021"
readme = "README.md"
repository = "https://github.com/renegade-fi/mpc-ristretto"
repository = "https://github.com/renegade-fi/ark-mpc"
license = "MIT OR Apache-2.0"

[lib]
name = "mpc_stark"
name = "ark_mpc"
path = "src/lib.rs"

[features]
Expand Down
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
# MPC-Stark
# `ark-mpc`
<div>
<img
src="https://github.com/renegade-fi/mpc-stark/actions/workflows/test.yml/badge.svg"
src="https://github.com/renegade-fi/ark-mpc/actions/workflows/test.yml/badge.svg"
/>
<img
src="https://github.com/renegade-fi/mpc-stark/actions/workflows/clippy.yml/badge.svg"
src="https://github.com/renegade-fi/ark-mpc/actions/workflows/clippy.yml/badge.svg"
/>
<img
src="https://github.com/renegade-fi/mpc-stark/actions/workflows/rustfmt.yml/badge.svg"
src="https://github.com/renegade-fi/ark-mpc/actions/workflows/rustfmt.yml/badge.svg"
/>
<img
src="https://img.shields.io/crates/v/mpc-stark"
src="https://img.shields.io/crates/v/ark-mpc"
/>
</div>

## Example
`mpc-stark` provides a malicious secure [SPDZ](https://eprint.iacr.org/2011/535.pdf) style framework for two party secure computation. The circuit is constructed on the fly, by overloading arithmetic operators of MPC types, see the example below in which each of the parties shares a value and together they compute the product:
`ark-mpc` provides a malicious secure [SPDZ](https://eprint.iacr.org/2011/535.pdf) style framework for two party secure computation. The circuit is constructed on the fly, by overloading arithmetic operators of MPC types, see the example below in which each of the parties shares a value and together they compute the product:
```rust
use mpc_stark::{
use ark_mpc::{
algebra::scalar::Scalar, beaver::SharedValueSource, network::QuicTwoPartyNet, MpcFabric,
PARTY0, PARTY1,
};
use ark_curve25519::EdwardsProjective as Curve25519Projective;
use rand::thread_rng;

type Curve = Curve25519Projective;

#[tokio::main]
async fn main() {
// Beaver source should be defined outside of the crate and rely on separate infrastructure
Expand All @@ -34,7 +37,7 @@ async fn main() {

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

let a = fabric.share_scalar(my_val, PARTY0 /* sender */); // party0 value
Expand All @@ -50,7 +53,7 @@ async fn main() {
## Tests
Unit tests for isolated parts of the library are available via
```bash
cargo test --lib
cargo test --lib --all-features
```

The bulk of this library's testing is best done with real communication; and so most of the tests are integration tests. The integration tests can be run as
Expand Down
6 changes: 3 additions & 3 deletions benches/circuit_msm_throughput.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
use std::time::{Duration, Instant};

use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
use itertools::Itertools;
use mpc_stark::{
use ark_mpc::{
algebra::authenticated_curve::AuthenticatedPointResult, test_helpers::execute_mock_mpc,
};
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
use itertools::Itertools;
use tokio::runtime::Builder as RuntimeBuilder;

/// Measure the throughput and latency of a variable-sized MSM
Expand Down
2 changes: 1 addition & 1 deletion benches/circuit_mul_throughput.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
use std::time::{Duration, Instant};

use ark_mpc::{test_helpers::execute_mock_mpc, PARTY0};
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
use mpc_stark::{test_helpers::execute_mock_mpc, PARTY0};
use tokio::runtime::Builder as RuntimeBuilder;

/// Measure the throughput and latency of a set of sequential multiplication gates
Expand Down
8 changes: 4 additions & 4 deletions benches/gate_throughput.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use std::{path::Path, sync::Mutex};

use ark_mpc::{
algebra::scalar::Scalar, beaver::PartyIDBeaverSource, network::NoRecvNetwork,
test_helpers::TestCurve, MpcFabric, PARTY0,
};
use cpuprofiler::{Profiler as CpuProfiler, PROFILER};
use criterion::{
criterion_group, criterion_main, profiler::Profiler as CriterionProfiler, BenchmarkId,
Criterion, Throughput,
};
use mpc_stark::{
algebra::scalar::Scalar, beaver::PartyIDBeaverSource, network::NoRecvNetwork,
test_helpers::TestCurve, MpcFabric, PARTY0,
};
use rand::{rngs::OsRng, thread_rng};
use tokio::runtime::Builder as RuntimeBuilder;

Expand Down
8 changes: 4 additions & 4 deletions benches/gate_throughput_traced.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
use std::time::Instant;

use clap::Parser;
use cpuprofiler::PROFILER;
use gperftools::HEAP_PROFILER;
use mpc_stark::{
use ark_mpc::{
algebra::scalar::Scalar, beaver::PartyIDBeaverSource, network::NoRecvNetwork,
test_helpers::TestCurve, MpcFabric, PARTY0,
};
use clap::Parser;
use cpuprofiler::PROFILER;
use gperftools::HEAP_PROFILER;
use rand::thread_rng;

// -----------
Expand Down
2 changes: 1 addition & 1 deletion benches/growable_buffer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use ark_mpc::{algebra::scalar::Scalar, buffer::GrowableBuffer, test_helpers::TestCurve};
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
use mpc_stark::{algebra::scalar::Scalar, buffer::GrowableBuffer, test_helpers::TestCurve};

// --------------
// | Benchmarks |
Expand Down
8 changes: 4 additions & 4 deletions benches/native_msm.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//! Defines a benchmark for native multiscalar-multiplication on `Scalar` and `StarkPoint` types
//! Defines a benchmark for native multiscalar-multiplication on `Scalar` and `CurvePoint` types
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
use itertools::Itertools;
use mpc_stark::{
use ark_mpc::{
algebra::{curve::CurvePoint, scalar::Scalar},
random_point,
test_helpers::TestCurve,
};
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
use itertools::Itertools;
use rand::thread_rng;

/// The maximum power of two to scale the MSM benchmark to
Expand Down
2 changes: 1 addition & 1 deletion benches/test_stats.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! A simple benchmark for testing that stats collection is properly working
use mpc_stark::{algebra::scalar::Scalar, test_helpers::execute_mock_mpc, PARTY0, PARTY1};
use ark_mpc::{algebra::scalar::Scalar, test_helpers::execute_mock_mpc, PARTY0, PARTY1};
use rand::{distributions::uniform::SampleRange, thread_rng};

#[tokio::main]
Expand Down
48 changes: 24 additions & 24 deletions integration/authenticated_curve.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Integration tests for the `AuthenticatedStarkPoint` type
//! Integration tests for the `AuthenticatedPointResult` type
use itertools::Itertools;
use mpc_stark::{
use ark_mpc::{
algebra::{
authenticated_curve::{
test_helpers::{modify_mac, modify_public_modifier, modify_share},
Expand All @@ -11,6 +10,7 @@ use mpc_stark::{
},
random_point, PARTY0, PARTY1,
};
use itertools::Itertools;
use rand::thread_rng;

use crate::{
Expand Down Expand Up @@ -151,7 +151,7 @@ fn test_batch_add(test_args: &IntegrationTestArgs) -> Result<(), String> {
assert_point_batches_eq(res_open, expected_result)
}

/// Test addition between a batch of `AuthenticatedStarkPoint`s and `StarkPoint`s
/// Test addition between a batch of `AuthenticatedPointResult`s and `CurvePoint`s
fn test_batch_add_public(test_args: &IntegrationTestArgs) -> Result<(), String> {
let n = 10;
let fabric = &test_args.fabric;
Expand Down Expand Up @@ -245,7 +245,7 @@ fn test_batch_sub(test_args: &IntegrationTestArgs) -> Result<(), String> {
assert_point_batches_eq(res_open, expected_result)
}

/// Test addition between a batch of `AuthenticatedStarkPoint`s and `StarkPoint`s
/// Test addition between a batch of `AuthenticatedPointResult`s and `CurvePoint`s
fn test_batch_sub_public(test_args: &IntegrationTestArgs) -> Result<(), String> {
let n = 10;
let fabric = &test_args.fabric;
Expand Down Expand Up @@ -384,7 +384,7 @@ fn test_batch_mul(test_args: &IntegrationTestArgs) -> Result<(), String> {
assert_point_batches_eq(res_open, expected_result)
}

/// Test addition between a batch of `AuthenticatedStarkPoint`s and `StarkPoint`s
/// Test addition between a batch of `AuthenticatedPointResult`s and `CurvePoint`s
fn test_batch_mul_public(test_args: &IntegrationTestArgs) -> Result<(), String> {
let n = 10;
let fabric = &test_args.fabric;
Expand Down Expand Up @@ -412,91 +412,91 @@ fn test_batch_mul_public(test_args: &IntegrationTestArgs) -> Result<(), String>
}

inventory::submit!(IntegrationTest {
name: "authenticated_stark_point::test_open_authenticated",
name: "authenticated_curve_point::test_open_authenticated",
test_fn: test_open_authenticated
});

inventory::submit!(IntegrationTest {
name: "authenticated_stark_point::test_open_authenticated__bad_mac",
name: "authenticated_curve_point::test_open_authenticated__bad_mac",
test_fn: test_open_authenticated__bad_mac
});

inventory::submit!(IntegrationTest {
name: "authenticated_stark_point::test_open_authenticated__bad_share",
name: "authenticated_curve_point::test_open_authenticated__bad_share",
test_fn: test_open_authenticated__bad_share
});

inventory::submit!(IntegrationTest {
name: "authenticated_stark_point::test_open_authenticated__bad_public_modifier",
name: "authenticated_curve_point::test_open_authenticated__bad_public_modifier",
test_fn: test_open_authenticated__bad_public_modifier
});

inventory::submit!(IntegrationTest {
name: "authenticated_stark_point::test_addition_public_point",
name: "authenticated_curve_point::test_addition_public_point",
test_fn: test_addition_public_point
});

inventory::submit!(IntegrationTest {
name: "authenticated_stark_point::test_add",
name: "authenticated_curve_point::test_add",
test_fn: test_add
});

inventory::submit!(IntegrationTest {
name: "authenticated_stark_point::test_batch_add",
name: "authenticated_curve_point::test_batch_add",
test_fn: test_batch_add
});

inventory::submit!(IntegrationTest {
name: "authenticated_stark_point::test_batch_add_public",
name: "authenticated_curve_point::test_batch_add_public",
test_fn: test_batch_add_public
});

inventory::submit!(IntegrationTest {
name: "authenticated_stark_point::test_sub_public_point",
name: "authenticated_curve_point::test_sub_public_point",
test_fn: test_sub_public_point
});

inventory::submit!(IntegrationTest {
name: "authenticated_stark_point::test_sub",
name: "authenticated_curve_point::test_sub",
test_fn: test_sub
});

inventory::submit!(IntegrationTest {
name: "authenticated_stark_point::test_batch_sub",
name: "authenticated_curve_point::test_batch_sub",
test_fn: test_batch_sub
});

inventory::submit!(IntegrationTest {
name: "authenticated_stark_point::test_batch_sub_public",
name: "authenticated_curve_point::test_batch_sub_public",
test_fn: test_batch_sub_public
});

inventory::submit!(IntegrationTest {
name: "authenticated_stark_point::test_negation",
name: "authenticated_curve_point::test_negation",
test_fn: test_negation
});

inventory::submit!(IntegrationTest {
name: "authenticated_stark_point::test_batch_negation",
name: "authenticated_curve_point::test_batch_negation",
test_fn: test_batch_negation
});

inventory::submit!(IntegrationTest {
name: "authenticated_stark_point::test_multiplication_public_scalar",
name: "authenticated_curve_point::test_multiplication_public_scalar",
test_fn: test_multiplication_public_scalar
});

inventory::submit!(IntegrationTest {
name: "authenticated_stark_point::test_multiplication",
name: "authenticated_curve_point::test_multiplication",
test_fn: test_multiplication
});

inventory::submit!(IntegrationTest {
name: "authenticated_stark_point::test_batch_mul",
name: "authenticated_curve_point::test_batch_mul",
test_fn: test_batch_mul
});

inventory::submit!(IntegrationTest {
name: "authenticated_stark_point::test_batch_mul_public",
name: "authenticated_curve_point::test_batch_mul_public",
test_fn: test_batch_mul_public
});
6 changes: 3 additions & 3 deletions integration/authenticated_scalar.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//! Integration tests for arithmetic on the `AuthenticatedScalar` type which provides
//! Integration tests for arithmetic on the `AuthenticatedScalarResult` type which provides
//! a malicious-secure primitive
use itertools::Itertools;
use mpc_stark::{
use ark_mpc::{
algebra::{
authenticated_scalar::{test_helpers::*, AuthenticatedScalarResult},
scalar::Scalar,
},
ResultValue, PARTY0, PARTY1,
};
use itertools::Itertools;
use rand::thread_rng;
use std::ops::Neg;

Expand Down
4 changes: 2 additions & 2 deletions integration/circuits.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//! Tests for more complicated operations (i.e. circuits)
use itertools::Itertools;
use mpc_stark::{
use ark_mpc::{
algebra::{
authenticated_curve::AuthenticatedPointResult,
authenticated_scalar::AuthenticatedScalarResult, scalar::Scalar,
},
random_point, PARTY0, PARTY1,
};
use itertools::Itertools;
use rand::thread_rng;

use crate::{
Expand Down
2 changes: 1 addition & 1 deletion integration/fabric.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Defines tests for the fabric directly
use mpc_stark::{algebra::scalar::Scalar, PARTY0, PARTY1};
use ark_mpc::{algebra::scalar::Scalar, PARTY0, PARTY1};

use crate::{
helpers::{assert_scalars_eq, await_result, share_scalar},
Expand Down
Loading

0 comments on commit edbf025

Please sign in to comment.