Skip to content

Commit

Permalink
integration: lowgear: Fix lowgear test
Browse files Browse the repository at this point in the history
  • Loading branch information
joeykraut committed Apr 20, 2024
1 parent de66a7b commit 60a748a
Show file tree
Hide file tree
Showing 16 changed files with 177 additions and 72 deletions.
4 changes: 2 additions & 2 deletions integration/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
context: ..
dockerfile: integration/Dockerfile
environment:
- RUST_BACKTRACE=1
- RUST_BACKTRACE=full
ports:
- "8000:8000"
command: >
Expand All @@ -18,7 +18,7 @@ services:
party1:
image: ark-mpc-integraton:latest
environment:
- RUST_BACKTRACE=1
- RUST_BACKTRACE=full
ports:
- "9000:9000"
command: >
Expand Down
34 changes: 17 additions & 17 deletions integration/src/authenticated_curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::{
// -----------

/// Test opening a shared point correctly
fn test_open_authenticated(test_args: &IntegrationTestArgs) -> Result<(), String> {
fn test_open_authenticated(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Sample a test point
let my_val = random_point();
let shared_val = share_authenticated_point(my_val, PARTY0, test_args);
Expand All @@ -38,7 +38,7 @@ fn test_open_authenticated(test_args: &IntegrationTestArgs) -> Result<(), String

/// Test opening a shared point with a corrupted MAC
#[allow(non_snake_case)]
fn test_open_authenticated__bad_mac(test_args: &IntegrationTestArgs) -> Result<(), String> {
fn test_open_authenticated__bad_mac(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Sample a test point
let my_val = random_point();
let mut shared_val = share_authenticated_point(my_val, PARTY0, test_args);
Expand All @@ -51,7 +51,7 @@ fn test_open_authenticated__bad_mac(test_args: &IntegrationTestArgs) -> Result<(

/// Test opening a shared point with a corrupted secret share
#[allow(non_snake_case)]
fn test_open_authenticated__bad_share(test_args: &IntegrationTestArgs) -> Result<(), String> {
fn test_open_authenticated__bad_share(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Sample a test point
let my_val = random_point();
let mut shared_val = share_authenticated_point(my_val, PARTY0, test_args);
Expand All @@ -67,7 +67,7 @@ fn test_open_authenticated__bad_share(test_args: &IntegrationTestArgs) -> Result
// --------------

/// Test addition with a public point
fn test_addition_public_point(test_args: &IntegrationTestArgs) -> Result<(), String> {
fn test_addition_public_point(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Sample a test point, party 1 will make theirs public
let value = random_point();

Expand All @@ -87,7 +87,7 @@ fn test_addition_public_point(test_args: &IntegrationTestArgs) -> Result<(), Str
}

/// Test addition between two secret shared points
fn test_add(test_args: &IntegrationTestArgs) -> Result<(), String> {
fn test_add(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Sample a test point
let value = random_point();

Expand All @@ -106,7 +106,7 @@ fn test_add(test_args: &IntegrationTestArgs) -> Result<(), String> {
}

/// Test batch addition
fn test_batch_add(test_args: &IntegrationTestArgs) -> Result<(), String> {
fn test_batch_add(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
let n = 10;
let fabric = &test_args.fabric;
let my_vals = (0..n).map(|_| random_point()).collect_vec();
Expand Down Expand Up @@ -135,7 +135,7 @@ fn test_batch_add(test_args: &IntegrationTestArgs) -> Result<(), String> {

/// Test addition between a batch of `AuthenticatedPointResult`s and
/// `CurvePoint`s
fn test_batch_add_public(test_args: &IntegrationTestArgs) -> Result<(), String> {
fn test_batch_add_public(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
let n = 10;
let fabric = &test_args.fabric;
let my_vals = (0..n).map(|_| random_point()).collect_vec();
Expand All @@ -162,7 +162,7 @@ fn test_batch_add_public(test_args: &IntegrationTestArgs) -> Result<(), String>
}

/// Test subtraction between a shared and a public point
fn test_sub_public_point(test_args: &IntegrationTestArgs) -> Result<(), String> {
fn test_sub_public_point(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Sample a test point, party 1 will make theirs public
let value = random_point();

Expand All @@ -182,7 +182,7 @@ fn test_sub_public_point(test_args: &IntegrationTestArgs) -> Result<(), String>
}

/// Test subtraction between two secret shared points
fn test_sub(test_args: &IntegrationTestArgs) -> Result<(), String> {
fn test_sub(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Sample a test point
let value = random_point();

Expand All @@ -201,7 +201,7 @@ fn test_sub(test_args: &IntegrationTestArgs) -> Result<(), String> {
}

/// Test batch subtraction
fn test_batch_sub(test_args: &IntegrationTestArgs) -> Result<(), String> {
fn test_batch_sub(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
let n = 10;
let fabric = &test_args.fabric;
let my_vals = (0..n).map(|_| random_point()).collect_vec();
Expand Down Expand Up @@ -230,7 +230,7 @@ fn test_batch_sub(test_args: &IntegrationTestArgs) -> Result<(), String> {

/// Test addition between a batch of `AuthenticatedPointResult`s and
/// `CurvePoint`s
fn test_batch_sub_public(test_args: &IntegrationTestArgs) -> Result<(), String> {
fn test_batch_sub_public(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
let n = 10;
let fabric = &test_args.fabric;
let my_vals = (0..n).map(|_| random_point()).collect_vec();
Expand All @@ -257,7 +257,7 @@ fn test_batch_sub_public(test_args: &IntegrationTestArgs) -> Result<(), String>
}

/// Test negation
fn test_negation(test_args: &IntegrationTestArgs) -> Result<(), String> {
fn test_negation(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Sample a test point
let value = random_point();

Expand All @@ -275,7 +275,7 @@ fn test_negation(test_args: &IntegrationTestArgs) -> Result<(), String> {
}

/// Test batch negation
fn test_batch_negation(test_args: &IntegrationTestArgs) -> Result<(), String> {
fn test_batch_negation(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
let n = 10;
let fabric = &test_args.fabric;
let my_values = (0..n).map(|_| random_point()).collect_vec();
Expand All @@ -295,7 +295,7 @@ fn test_batch_negation(test_args: &IntegrationTestArgs) -> Result<(), String> {
}

/// Test multiplication with a public scalar
fn test_multiplication_public_scalar(test_args: &IntegrationTestArgs) -> Result<(), String> {
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 point = random_point();
Expand All @@ -317,7 +317,7 @@ fn test_multiplication_public_scalar(test_args: &IntegrationTestArgs) -> Result<
}

/// Test multiplication with a secret shared scalar
fn test_multiplication(test_args: &IntegrationTestArgs) -> Result<(), String> {
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 point = random_point();
Expand All @@ -338,7 +338,7 @@ fn test_multiplication(test_args: &IntegrationTestArgs) -> Result<(), String> {
}

/// Test batch multiplication
fn test_batch_mul(test_args: &IntegrationTestArgs) -> Result<(), String> {
fn test_batch_mul(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
let n = 10;
let fabric = &test_args.fabric;
let my_vals = (0..n).map(|_| random_point()).collect_vec();
Expand Down Expand Up @@ -367,7 +367,7 @@ fn test_batch_mul(test_args: &IntegrationTestArgs) -> Result<(), String> {

/// Test addition between a batch of `AuthenticatedPointResult`s and
/// `CurvePoint`s
fn test_batch_mul_public(test_args: &IntegrationTestArgs) -> Result<(), String> {
fn test_batch_mul_public(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
let n = 10;
let fabric = &test_args.fabric;
let my_vals = (0..n).map(|_| random_point()).collect_vec();
Expand Down
36 changes: 18 additions & 18 deletions integration/src/authenticated_scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::{

/// Tests the authenticated opening of a shared value with no arithmetic done on
/// it
fn test_open_authenticated(test_args: &IntegrationTestArgs) -> Result<(), String> {
fn test_open_authenticated(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Each party samples a value
let mut rng = thread_rng();
let my_val = Scalar::random(&mut rng);
Expand All @@ -46,7 +46,7 @@ fn test_open_authenticated(test_args: &IntegrationTestArgs) -> Result<(), String

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

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

/// Test addition with a public value
fn test_add_public_value(test_args: &IntegrationTestArgs) -> Result<(), String> {
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 val = Scalar::random(&mut rng);
Expand All @@ -103,7 +103,7 @@ fn test_add_public_value(test_args: &IntegrationTestArgs) -> Result<(), String>
}

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

/// Test batch addition between two secret shared values
fn test_batch_add(test_args: &IntegrationTestArgs) -> Result<(), String> {
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;
Expand Down Expand Up @@ -156,7 +156,7 @@ fn test_batch_add(test_args: &IntegrationTestArgs) -> Result<(), String> {
}

/// Test batch addition between secret shared and public values
fn test_batch_add_public(test_args: &IntegrationTestArgs) -> Result<(), String> {
fn test_batch_add_public(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Each party samples a batch of values, party 1's values are made public
let n = 10;
let fabric = &test_args.fabric;
Expand Down Expand Up @@ -185,7 +185,7 @@ fn test_batch_add_public(test_args: &IntegrationTestArgs) -> Result<(), String>
}

/// Test subtraction between a shared point and a public scalar
fn test_sub_public_scalar(test_args: &IntegrationTestArgs) -> Result<(), String> {
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 val = Scalar::random(&mut rng);
Expand All @@ -209,7 +209,7 @@ fn test_sub_public_scalar(test_args: &IntegrationTestArgs) -> Result<(), String>
}

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

/// Test batch subtraction between two secret shared values
fn test_batch_sub(test_args: &IntegrationTestArgs) -> Result<(), String> {
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;
Expand Down Expand Up @@ -262,7 +262,7 @@ fn test_batch_sub(test_args: &IntegrationTestArgs) -> Result<(), String> {
}

/// Test batch subtraction between secret shared and public values
fn test_batch_sub_public(test_args: &IntegrationTestArgs) -> Result<(), String> {
fn test_batch_sub_public(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Each party samples a batch of values, party 1's values are made public
let n = 10;
let fabric = &test_args.fabric;
Expand Down Expand Up @@ -291,7 +291,7 @@ fn test_batch_sub_public(test_args: &IntegrationTestArgs) -> Result<(), String>
}

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

/// Test negation of a batch of values
fn test_batch_neg(test_args: &IntegrationTestArgs) -> Result<(), String> {
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;
Expand All @@ -335,7 +335,7 @@ fn test_batch_neg(test_args: &IntegrationTestArgs) -> Result<(), String> {
}

/// Test multiplication between a shared point and a public scalar
fn test_mul_public_scalar(test_args: &IntegrationTestArgs) -> Result<(), String> {
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 val = Scalar::random(&mut rng);
Expand All @@ -359,7 +359,7 @@ fn test_mul_public_scalar(test_args: &IntegrationTestArgs) -> Result<(), String>
}

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

/// Test batch multiplication between two secret shared values
fn test_batch_mul(test_args: &IntegrationTestArgs) -> Result<(), String> {
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;
Expand Down Expand Up @@ -412,7 +412,7 @@ fn test_batch_mul(test_args: &IntegrationTestArgs) -> Result<(), String> {
}

/// Test batch addition between secret shared and public values
fn test_batch_mul_public(test_args: &IntegrationTestArgs) -> Result<(), String> {
fn test_batch_mul_public(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Each party samples a batch of values, party 1's values are made public
let n = 10;
let fabric = &test_args.fabric;
Expand Down Expand Up @@ -441,7 +441,7 @@ fn test_batch_mul_public(test_args: &IntegrationTestArgs) -> Result<(), String>
}

/// Test the case in which we add and then multiply by a public value
fn test_public_add_then_mul(test_args: &IntegrationTestArgs) -> Result<(), String> {
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 val = Scalar::random(&mut rng);
Expand Down
6 changes: 3 additions & 3 deletions integration/src/circuits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::{
///
/// We take the inner product <a, b> where party 0 chooses a, and party 1
/// chooses b
fn test_inner_product(test_args: &IntegrationTestArgs) -> Result<(), String> {
fn test_inner_product(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Sample local values
let n = 100;
let fabric = &test_args.fabric;
Expand Down Expand Up @@ -52,7 +52,7 @@ fn test_inner_product(test_args: &IntegrationTestArgs) -> Result<(), String> {
/// Tests a multiscalar multiplication
///
/// Party 0 selects all the scalars, party 1 selects the points
fn test_msm(test_args: &IntegrationTestArgs) -> Result<(), String> {
fn test_msm(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Sample local values
let n = 100;
let fabric = &test_args.fabric;
Expand Down Expand Up @@ -87,7 +87,7 @@ fn test_msm(test_args: &IntegrationTestArgs) -> Result<(), String> {
}

/// Tests evaluation of a shared polynomial on a public input
fn test_polynomial_eval(test_args: &IntegrationTestArgs) -> Result<(), String> {
fn test_polynomial_eval(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
let fabric = &test_args.fabric;
let mut rng = thread_rng();
let public_modifier = Scalar::random(&mut rng);
Expand Down
2 changes: 1 addition & 1 deletion integration/src/fabric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{
// ---------

/// Tests that sharing a value over the fabric works correctly
fn test_fabric_share_and_open(test_args: &IntegrationTestArgs) -> Result<(), String> {
fn test_fabric_share_and_open(test_args: &mut IntegrationTestArgs) -> Result<(), String> {
// Each party shares their party ID with the counterparty
let my_party_id = Scalar::from(test_args.party_id);

Expand Down
Loading

0 comments on commit 60a748a

Please sign in to comment.