Updating build system (#44)

`python3 driver.py -h`
This commit is contained in:
Edward Chen
2022-02-25 17:13:10 -05:00
committed by GitHub
parent 76539bf05d
commit b9526234ac
44 changed files with 667 additions and 1021 deletions

View File

@@ -8,6 +8,7 @@ on:
env:
CARGO_TERM_COLOR: always
ABY_SOURCE: "./../ABY"
jobs:
build:
@@ -23,22 +24,22 @@ jobs:
with:
toolchain: stable
- uses: Swatinem/rust-cache@v1
- name: Initialize submodules
run: make fetch_deps
- name: Cache submodule build
- name: Set all features on
run: python3 driver.py --all_features
- name: Install third_party libraries
run: python3 driver.py --install
- name: Cache third_party build
uses: actions/cache@v2
with:
path: third_party/ABY/build
path: ${ABY_SOURCE}/build
key: ${{ runner.os }}
- name: Build submodules
run: make build_deps
- name: Typecheck
run: cargo check
- name: Check format
- name: Check
run: python3 driver.py --check
- name: Format
run: cargo fmt -- --check
- name: Lint
run: cargo clippy
run: python3 driver.py --lint
- name: Build
run: make build
- name: Run tests
run: make test
run: python3 driver.py --build
- name: Test
run: python3 driver.py --test

1
.gitignore vendored
View File

@@ -9,3 +9,4 @@ __pycache__
/x
/perf.data*
/.gdb_history
.features.txt

3
.gitmodules vendored
View File

@@ -1,3 +0,0 @@
[submodule "third_party/ABY"]
path = third_party/ABY
url = https://github.com/edwjchen/ABY.git

View File

@@ -13,20 +13,21 @@ rug = "1.11"
gmp-mpfr-sys = "1.4"
lazy_static = "1.4"
rand = "0.8"
rsmt2 = "0.14"
rsmt2 = { version = "0.14", optional = true }
#rsmt2 = { git = "https://github.com/alex-ozdemir/rsmt2.git" }
ieee754 = "0.2"
zokrates_parser = { path = "third_party/ZoKrates/zokrates_parser" }
zokrates_pest_ast = { path = "third_party/ZoKrates/zokrates_pest_ast" }
zokrates_parser = { path = "third_party/ZoKrates/zokrates_parser", optional = true }
zokrates_pest_ast = { path = "third_party/ZoKrates/zokrates_pest_ast", optional = true }
typed-arena = "2.0"
log = "0.4"
thiserror = "1.0"
bellman = "0.11"
bellman = { version = "0.11", optional = true }
ff = "0.11"
fxhash = "0.2"
good_lp = { version = "1.1", features = ["lp-solvers", "coin_cbc"], default-features = false, optional = true }
lp-solvers = { version = "0.0.4", optional = true }
serde_json = "1.0"
lang-c = "0.10.1"
lang-c = { version = "0.10.1", optional = true}
logos = "0.12"
pest = "2.1"
pest_derive = "2.1"
@@ -44,13 +45,24 @@ structopt = "0.3"
approx = "0.5.0"
[features]
default = ["lp", "bls12381"]
lp = ["good_lp", "lp-solvers"]
default = ["bls12381"]
bls12381 = []
c = ["lang-c"]
lp = ["good_lp", "lp-solvers"]
r1cs = ["bellman"]
smt = ["rsmt2"]
zok = ["zokrates_parser", "zokrates_pest_ast", ]
[[example]]
name = "circ"
required-features = ["lp"]
[[example]]
name = "zxi"
required-features = ["smt", "zok"]
[[example]]
name = "zxc"
required-features = ["smt", "zok"]
[[example]]
name = "opa_bench"

View File

@@ -1,49 +0,0 @@
all: test
fetch_deps:
git submodule update --init
build_deps: fetch_deps
./scripts/build_aby.zsh
build_aby_zokrates: build_deps build
./scripts/build_mpc_zokrates_test.zsh
./scripts/build_aby.zsh
build_aby_c: build_deps build
./scripts/build_mpc_c_test.zsh
./scripts/build_aby.zsh
build:
cargo build --release --examples
cargo build --examples
test: build build_aby_zokrates build_aby_c
cargo test
./scripts/zokrates_test.zsh
python3 ./scripts/aby_tests/zokrates_test_aby.py
python3 ./scripts/aby_tests/c_test_aby.py
./scripts/test_zok_to_ilp.zsh
./scripts/test_zok_to_ilp_pf.zsh
./scripts/test_datalog.zsh
c_aby: build_aby_c
python3 ./scripts/aby_tests/c_test_aby.py
z_aby: build_aby_zokrates
python3 ./scripts/aby_tests/zokrates_test_aby.py
clean:
# remove all generated files
touch ./third_party/ABY/build && rm -r -- ./third_party/ABY/build
touch ./third_party/ABY/src/examples/2pc_* && rm -r -- ./third_party/ABY/src/examples/2pc_*
sed '/add_subdirectory.*2pc.*/d' -i ./third_party/ABY/src/examples/CMakeLists.txt
rm -rf ./third_party/ABY/src/examples/2pc_*.txt
rm -rf scripts/aby_tests/__pycache__
rm -rf P V pi perf.data perf.data.old flamegraph.svg
format:
cargo fmt --all
lint:
cargo clippy

View File

@@ -14,7 +14,13 @@ tell me about them :)
2. circ uses some experimental APIs, so you'll need rust nightly!
3. To build the Z# interpreter cli,
`cargo build --release --example zxi --no-default-features`
`cargo build --release --example zxi --no-default-features --features smt,zok`
Alternatively, you can try our new driver script.
To set the required features for zxi and zxc,
`python3 driver.py -F smt zok`
To build,
`python3 driver.py -b`
## running

215
driver.py Executable file
View File

@@ -0,0 +1,215 @@
#!/usr/bin/env python3
import argparse
import subprocess
from util import *
def install(features):
"""
Used for installing third party libraries
Parameters
----------
features : set of str
set of features required
"""
def verify_path_empty(path) -> bool:
return not os.path.isdir(path) or (os.path.isdir(path) and not os.listdir(path))
for f in features:
if f == "aby":
if verify_path_empty(ABY_SOURCE):
subprocess.run(["git", "clone", "https://github.com/edwjchen/ABY.git", ABY_SOURCE])
subprocess.run(["./scripts/build_aby.zsh"])
# Get EZPC header file
subprocess.run(["mkdir", "-p", EZPC_SOURCE])
subprocess.run(["wget", "-O", EZPC_SOURCE+"/ezpc.h", "https://raw.githubusercontent.com/circify/circ/master/third_party/EZPC/ezpc.h"])
def check(features):
"""
Run cargo check
Parameters
----------
features : set of str
set of features required
"""
cmd = ["cargo", "check"]
cargo_features = filter_cargo_features(features)
if cargo_features:
cmd = cmd + ["--features"] + cargo_features
subprocess.run(cmd)
def build(features):
"""
Run cargo build and any test cases in the feature list
Parameters
----------
features : set of str
set of features required
"""
mode = load_mode()
check(features)
install(features)
cmd = ["cargo", "build"]
if mode:
cmd += ["--"+mode]
else:
# default to release mode
cmd += ["--release"]
cmd += ["--examples"]
cargo_features = filter_cargo_features(features)
if cargo_features:
cmd = cmd + ["--features"] + cargo_features
subprocess.run(cmd)
if "aby" in features:
if "c" in features:
subprocess.run(["./scripts/build_mpc_c_test.zsh"])
if "smt" in features and "zok" in features:
subprocess.run(["./scripts/build_mpc_zokrates_test.zsh"])
subprocess.run(["./scripts/build_aby.zsh"])
def test(features):
"""
Run cargo tests and any test cases in the feature list
Parameters
----------
features : set of str
set of features required
"""
build(features)
test_cmd = ["cargo", "test"]
cargo_features = filter_cargo_features(features)
if cargo_features:
test_cmd = test_cmd + ["--features"] + cargo_features
subprocess.run(test_cmd, check=True)
if "c" in features:
if "a" in features:
subprocess.run(["python3", "./scripts/aby_tests/c_test_aby.py"], check=True)
if "r1cs" in features and "smt" in features:
subprocess.run(["./scripts/test_datalog.zsh"], check=True)
if "zok" in features and "smt" in features:
if "aby" in features:
subprocess.run(["python3", "./scripts/aby_tests/zokrates_test_aby.py"], check=True)
if "lp" in features:
subprocess.run(["./scripts/test_zok_to_ilp.zsh"], check=True)
if "r1cs" in features:
subprocess.run(["./scripts/zokrates_test.zsh"], check=True)
if "lp" in features and "r1cs" in features:
subprocess.run(["./scripts/test_zok_to_ilp_pf.zsh"], check=True)
def format():
print("formatting!")
subprocess.run(["cargo", "fmt", "--all"], check=True)
def lint():
print("linting!")
subprocess.run(["cargo", "clippy"], check=True)
def clean(features):
print("cleaning!")
if "aby" in features:
subprocess.run(["./scripts/clean_aby.zsh"])
subprocess.run(["rm", "-rf", "scripts/aby_tests/__pycache__"])
subprocess.run(["rm", "-rf", "P", "V", "pi", "perf.data perf.data.old flamegraph.svg"])
def set_mode(mode):
def verify_mode(mode):
if mode not in ("debug", "release"):
raise RuntimeError(f"Unknown mode: {mode}, --mode <debug, release>")
verify_mode(mode)
save_mode(mode)
def set_features(features):
"""
Filter invalid features and save features to a file.
Parameters
----------
features : set of str
set of features required
"""
# reset features
if "none" in features:
features = set()
def verify_feature(f):
if f in valid_features:
return True
return False
features = set(sorted([f for f in features if verify_feature(f)]))
save_features(features)
print("Feature set:", sorted(list(features)))
return features
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-i", "--install", action="store_true", help="install all dependencies from the feature set")
parser.add_argument("-c", "--check", action="store_true", help="run `cargo check`")
parser.add_argument("-b", "--build", action="store_true", help="run `cargo build` and build all dependencies from the feature set")
parser.add_argument("-t", "--test", action="store_true", help="build and test all dependencies from the feature set")
parser.add_argument("-f", "--format", action="store_true", help="run `cargo fmt --all`")
parser.add_argument("-l", "--lint", action="store_true", help="run `cargo clippy`")
parser.add_argument("-C", "--clean", action="store_true", help="remove all generated files")
parser.add_argument("-m", "--mode", type=str, help="set `debug` or `release` mode")
parser.add_argument("-A", "--all_features", action="store_true", help="set all features on")
parser.add_argument("-L", "--list_features", action="store_true", help="print active features")
parser.add_argument("-F", "--features", nargs="+", help="set features on <aby, c, lp, r1cs, smt, zok>, reset features with -F none")
args = parser.parse_args()
def verify_single_action(args: argparse.Namespace):
if [bool(v) for v in vars(args).values()].count(True) != 1:
parser.error("parser error: only one action can be specified")
verify_single_action(args)
features = load_features()
set_env(features)
if args.install:
install(features)
if args.check:
check(features)
if args.build:
build(features)
if args.test:
test(features)
if args.format:
format()
if args.lint:
lint()
if args.clean:
clean(features)
if args.mode:
set_mode(args.mode)
if args.all_features:
features = set_features(valid_features)
if args.list_features:
print("Feature set: ", sorted(list(features)))
if args.features:
features = set_features(args.features)

View File

@@ -1,13 +1,18 @@
#![allow(unused_imports)]
#[cfg(feature = "r1cs")]
use bellman::gadgets::test::TestConstraintSystem;
#[cfg(feature = "r1cs")]
use bellman::groth16::{
create_random_proof, generate_parameters, generate_random_parameters, prepare_verifying_key,
verify_proof, Parameters, Proof, VerifyingKey,
};
#[cfg(feature = "r1cs")]
use bellman::Circuit;
use bls12_381::{Bls12, Scalar};
#[cfg(feature = "c")]
use circ::front::c::{self, C};
use circ::front::datalog::{self, Datalog};
#[cfg(all(feature = "smt", feature = "zok"))]
use circ::front::zsharp::{self, ZSharpFE};
use circ::front::{FrontEnd, Mode};
use circ::ir::{
@@ -16,11 +21,15 @@ use circ::ir::{
};
use circ::target::aby::output::write_aby_exec;
use circ::target::aby::trans::to_aby;
#[cfg(feature = "lp")]
use circ::target::ilp::trans::to_ilp;
#[cfg(feature = "r1cs")]
use circ::target::r1cs::bellman::parse_instance;
use circ::target::r1cs::opt::reduce_linearities;
use circ::target::r1cs::trans::to_r1cs;
#[cfg(feature = "smt")]
use circ::target::smt::find_model;
#[cfg(feature = "lp")]
use good_lp::default_solver;
use std::fs::File;
use std::io::Read;
@@ -58,6 +67,7 @@ struct FrontendOptions {
value_threshold: Option<u64>,
/// File with input witness
#[allow(dead_code)]
#[structopt(long, name = "FILE", parse(from_os_str))]
inputs: Option<PathBuf>,
@@ -72,6 +82,7 @@ struct FrontendOptions {
#[derive(Debug, StructOpt)]
enum Backend {
#[allow(dead_code)]
R1cs {
#[structopt(long, default_value = "P", parse(from_os_str))]
prover_key: PathBuf,
@@ -173,6 +184,7 @@ fn main() {
};
let language = determine_language(&options.frontend.language, &options.path);
let cs = match language {
#[cfg(all(feature = "smt", feature = "zok"))]
DeterminedLanguage::Zsharp => {
let inputs = zsharp::Inputs {
file: options.path,
@@ -181,6 +193,10 @@ fn main() {
};
ZSharpFE::gen(inputs)
}
#[cfg(not(all(feature = "smt", feature = "zok")))]
DeterminedLanguage::Zsharp => {
panic!("Missing feature: smt,zok");
}
DeterminedLanguage::Datalog => {
let inputs = datalog::Inputs {
file: options.path,
@@ -189,6 +205,7 @@ fn main() {
};
Datalog::gen(inputs)
}
#[cfg(feature = "c")]
DeterminedLanguage::C => {
let inputs = c::Inputs {
file: options.path,
@@ -197,6 +214,10 @@ fn main() {
};
C::gen(inputs)
}
#[cfg(not(feature = "c"))]
DeterminedLanguage::C => {
panic!("Missing feature: c");
}
};
let cs = match mode {
Mode::Opt => opt(cs, vec![Opt::ScalarizeVars, Opt::ConstantFold]),
@@ -246,6 +267,7 @@ fn main() {
println!("Done with IR optimization");
match options.backend {
#[cfg(feature = "r1cs")]
Backend::R1cs {
action,
proof,
@@ -255,7 +277,7 @@ fn main() {
..
} => {
println!("Converting to r1cs");
let r1cs = to_r1cs(cs, circ::front::zsharp::ZSHARP_MODULUS.clone());
let r1cs = to_r1cs(cs, circ::front::ZSHARP_MODULUS.clone());
println!("Pre-opt R1cs size: {}", r1cs.constraints().len());
let r1cs = reduce_linearities(r1cs);
println!("Final R1cs size: {}", r1cs.constraints().len());
@@ -292,6 +314,10 @@ fn main() {
}
}
}
#[cfg(not(feature = "r1cs"))]
Backend::R1cs { .. } => {
panic!("Missing feature: r1cs");
}
Backend::Mpc { cost_model } => {
println!("Converting to aby");
let lang_str = match language {
@@ -303,6 +329,7 @@ fn main() {
to_aby(cs, &path_buf, &lang_str, &cost_model);
write_aby_exec(&path_buf, &lang_str);
}
#[cfg(feature = "lp")]
Backend::Ilp { .. } => {
println!("Converting to ilp");
let ilp = to_ilp(cs);
@@ -323,6 +350,11 @@ fn main() {
}
}
}
#[cfg(not(feature = "lp"))]
Backend::Ilp { .. } => {
panic!("Missing feature: lp");
}
#[cfg(feature = "smt")]
Backend::Smt { .. } => {
if options.frontend.lint_prim_rec {
assert_eq!(cs.outputs.len(), 1);
@@ -342,5 +374,9 @@ fn main() {
todo!()
}
}
#[cfg(not(feature = "smt"))]
Backend::Smt { .. } => {
panic!("Missing feature: smt");
}
}
}

View File

@@ -8,6 +8,7 @@ use bellman::Circuit;
use bls12_381::{Bls12, Scalar};
*/
use circ::front::zsharp::{self, ZSharpFE};
use circ::front::{FrontEnd, Mode};
use circ::ir::opt::{opt, Opt};
/*
@@ -86,6 +87,7 @@ fn main() {
.init();
let options = Options::from_args();
println!("{:?}", options);
let cs = {
let inputs = zsharp::Inputs {
file: options.path,
@@ -128,8 +130,9 @@ fn main() {
let verifier_key = options.verifier_key;
let instance = options.instance;
*/
println!("Converting to r1cs");
let r1cs = to_r1cs(cs, circ::front::zsharp::ZSHARP_MODULUS.clone());
let r1cs = to_r1cs(cs, circ::front::ZSHARP_MODULUS.clone());
let r1cs = if options.skip_linred {
println!("Skipping linearity reduction, as requested.");
r1cs

View File

@@ -1,4 +1,5 @@
use circ::front::zsharp::{Inputs, ZSharpFE};
use circ::front::Mode;
use std::path::PathBuf;
use structopt::StructOpt;

View File

@@ -1,351 +0,0 @@
Options { input_file_path: "./examples/C/mpc/ilp_benchmarks/2pc_ilp_bench_1.c", inputs: None, parties: Some(2), maximize: false }
Done with IR optimization
Converting to aby
Welcome to the CBC MILP Solver
Version: 2.10.3
Build Date: Mar 24 2020
command line - Cbc_C_Interface -solve -quit (default strategy 1)
Continuous objective value is -84992 - 1.04 seconds
Cgl0004I processed model has 20004 rows, 13023 columns (13023 integer (13023 of which binary)) and 59011 elements
Cutoff increment increased from 1e-05 to 0.1999
Cbc0038I Initial state - 0 integers unsatisfied sum - 0
Cbc0038I Solution found of 84992
Cbc0038I Before mini branch and bound, 13023 integers at bound fixed and 0 continuous
Cbc0038I Mini branch and bound did not improve solution (1.17 seconds)
Cbc0038I After 1.17 seconds - Feasibility pump exiting with objective of 84992 - took 0.02 seconds
Cbc0012I Integer solution of 84992 found by feasibility pump after 0 iterations and 0 nodes (1.17 seconds)
Cbc0001I Search completed - best objective 84992, took 0 iterations and 0 nodes (1.18 seconds)
Cbc0035I Maximum depth 0, 0 variables fixed on reduced cost
Cuts at root node changed objective from 84992 to 84992
Probing was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Gomory was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Knapsack was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Clique was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
MixedIntegerRounding2 was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
FlowCover was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
TwoMirCuts was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
ZeroHalf was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Result - Optimal solution found
Objective value: -84992.00000000
Enumerated nodes: 0
Total iterations: 0
Time (CPU seconds): 1.24
Time (Wallclock seconds): 1.34
Total time (CPU seconds): 1.24 (Wallclock seconds): 1.34
Options { input_file_path: "./examples/C/mpc/ilp_benchmarks/2pc_ilp_bench_2.c", inputs: None, parties: Some(2), maximize: false }
Done with IR optimization
Converting to aby
Welcome to the CBC MILP Solver
Version: 2.10.3
Build Date: Mar 24 2020
command line - Cbc_C_Interface -solve -quit (default strategy 1)
Continuous objective value is -169992 - 17.44 seconds
Cgl0004I processed model has 40004 rows, 26023 columns (26023 integer (26023 of which binary)) and 118011 elements
Cutoff increment increased from 1e-05 to 0.1999
Cbc0038I Initial state - 0 integers unsatisfied sum - 0
Cbc0038I Solution found of 169992
Cbc0038I Before mini branch and bound, 26023 integers at bound fixed and 0 continuous
Cbc0038I Mini branch and bound did not improve solution (17.71 seconds)
Cbc0038I After 17.71 seconds - Feasibility pump exiting with objective of 169992 - took 0.05 seconds
Cbc0012I Integer solution of 169992 found by feasibility pump after 0 iterations and 0 nodes (17.72 seconds)
Cbc0001I Search completed - best objective 169992, took 0 iterations and 0 nodes (17.75 seconds)
Cbc0035I Maximum depth 0, 0 variables fixed on reduced cost
Cuts at root node changed objective from 169992 to 169992
Probing was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Gomory was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Knapsack was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Clique was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
MixedIntegerRounding2 was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
FlowCover was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
TwoMirCuts was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
ZeroHalf was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Result - Optimal solution found
Objective value: -169992.00000000
Enumerated nodes: 0
Total iterations: 0
Time (CPU seconds): 17.88
Time (Wallclock seconds): 18.07
Total time (CPU seconds): 17.88 (Wallclock seconds): 18.07
Options { input_file_path: "./examples/C/mpc/ilp_benchmarks/2pc_ilp_bench_3.c", inputs: None, parties: Some(2), maximize: false }
Done with IR optimization
Converting to aby
Welcome to the CBC MILP Solver
Version: 2.10.3
Build Date: Mar 24 2020
command line - Cbc_C_Interface -solve -quit (default strategy 1)
Continuous objective value is -254992 - 31.61 seconds
Cgl0004I processed model has 60004 rows, 39023 columns (39023 integer (39023 of which binary)) and 177011 elements
Cutoff increment increased from 1e-05 to 0.1999
Cbc0038I Initial state - 0 integers unsatisfied sum - 0
Cbc0038I Solution found of 254992
Cbc0038I Before mini branch and bound, 39023 integers at bound fixed and 0 continuous
Cbc0038I Mini branch and bound did not improve solution (32.07 seconds)
Cbc0038I After 32.07 seconds - Feasibility pump exiting with objective of 254992 - took 0.10 seconds
Cbc0012I Integer solution of 254992 found by feasibility pump after 0 iterations and 0 nodes (32.09 seconds)
Cbc0001I Search completed - best objective 254992, took 0 iterations and 0 nodes (32.14 seconds)
Cbc0035I Maximum depth 0, 0 variables fixed on reduced cost
Cuts at root node changed objective from 254992 to 254992
Probing was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Gomory was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Knapsack was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Clique was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
MixedIntegerRounding2 was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
FlowCover was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
TwoMirCuts was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
ZeroHalf was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Result - Optimal solution found
Objective value: -254992.00000000
Enumerated nodes: 0
Total iterations: 0
Time (CPU seconds): 32.35
Time (Wallclock seconds): 32.55
Total time (CPU seconds): 32.35 (Wallclock seconds): 32.55
Options { input_file_path: "./examples/C/mpc/ilp_benchmarks/2pc_ilp_bench_4.c", inputs: None, parties: Some(2), maximize: false }
Done with IR optimization
Converting to aby
Welcome to the CBC MILP Solver
Version: 2.10.3
Build Date: Mar 24 2020
command line - Cbc_C_Interface -solve -quit (default strategy 1)
Continuous objective value is -339992 - 47.89 seconds
Cgl0004I processed model has 80004 rows, 52023 columns (52023 integer (52023 of which binary)) and 236011 elements
Cutoff increment increased from 1e-05 to 0.1999
Cbc0038I Initial state - 0 integers unsatisfied sum - 0
Cbc0038I Solution found of 339992
Cbc0038I Before mini branch and bound, 52023 integers at bound fixed and 0 continuous
Cbc0038I Mini branch and bound did not improve solution (48.53 seconds)
Cbc0038I After 48.53 seconds - Feasibility pump exiting with objective of 339992 - took 0.13 seconds
Cbc0012I Integer solution of 339992 found by feasibility pump after 0 iterations and 0 nodes (48.55 seconds)
Cbc0001I Search completed - best objective 339992, took 0 iterations and 0 nodes (48.63 seconds)
Cbc0035I Maximum depth 0, 0 variables fixed on reduced cost
Cuts at root node changed objective from 339992 to 339992
Probing was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Gomory was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Knapsack was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Clique was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
MixedIntegerRounding2 was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
FlowCover was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
TwoMirCuts was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
ZeroHalf was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Result - Optimal solution found
Objective value: -339992.00000000
Enumerated nodes: 0
Total iterations: 0
Time (CPU seconds): 48.97
Time (Wallclock seconds): 49.32
Total time (CPU seconds): 48.97 (Wallclock seconds): 49.32
Options { input_file_path: "./examples/C/mpc/ilp_benchmarks/2pc_ilp_bench_5.c", inputs: None, parties: Some(2), maximize: false }
Done with IR optimization
Converting to aby
Welcome to the CBC MILP Solver
Version: 2.10.3
Build Date: Mar 24 2020
command line - Cbc_C_Interface -solve -quit (default strategy 1)
Continuous objective value is -424992 - 61.73 seconds
Cgl0004I processed model has 100004 rows, 65023 columns (65023 integer (65023 of which binary)) and 295011 elements
Cutoff increment increased from 1e-05 to 0.1999
Cbc0038I Initial state - 0 integers unsatisfied sum - 0
Cbc0038I Solution found of 424992
Cbc0038I Before mini branch and bound, 65023 integers at bound fixed and 0 continuous
Cbc0038I Mini branch and bound did not improve solution (62.58 seconds)
Cbc0038I After 62.58 seconds - Feasibility pump exiting with objective of 424992 - took 0.17 seconds
Cbc0012I Integer solution of 424992 found by feasibility pump after 0 iterations and 0 nodes (62.61 seconds)
Cbc0001I Search completed - best objective 424992, took 0 iterations and 0 nodes (62.71 seconds)
Cbc0035I Maximum depth 0, 0 variables fixed on reduced cost
Cuts at root node changed objective from 424992 to 424992
Probing was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Gomory was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Knapsack was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Clique was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
MixedIntegerRounding2 was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
FlowCover was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
TwoMirCuts was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
ZeroHalf was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Result - Optimal solution found
Objective value: -424992.00000000
Enumerated nodes: 0
Total iterations: 0
Time (CPU seconds): 63.16
Time (Wallclock seconds): 63.62
Total time (CPU seconds): 63.16 (Wallclock seconds): 63.62
Options { input_file_path: "./examples/C/mpc/ilp_benchmarks/2pc_ilp_bench_6.c", inputs: None, parties: Some(2), maximize: false }
Done with IR optimization
Converting to aby
Welcome to the CBC MILP Solver
Version: 2.10.3
Build Date: Mar 24 2020
command line - Cbc_C_Interface -solve -quit (default strategy 1)
Continuous objective value is -509992 - 78.45 seconds
Cgl0004I processed model has 120004 rows, 78023 columns (78023 integer (78023 of which binary)) and 354011 elements
Cutoff increment increased from 1e-05 to 0.1999
Cbc0038I Initial state - 0 integers unsatisfied sum - 0
Cbc0038I Solution found of 509992
Cbc0038I Before mini branch and bound, 78023 integers at bound fixed and 0 continuous
Cbc0038I Mini branch and bound did not improve solution (79.47 seconds)
Cbc0038I After 79.47 seconds - Feasibility pump exiting with objective of 509992 - took 0.18 seconds
Cbc0012I Integer solution of 509992 found by feasibility pump after 0 iterations and 0 nodes (79.50 seconds)
Cbc0001I Search completed - best objective 509992, took 0 iterations and 0 nodes (79.61 seconds)
Cbc0035I Maximum depth 0, 0 variables fixed on reduced cost
Cuts at root node changed objective from 509992 to 509992
Probing was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Gomory was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Knapsack was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Clique was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
MixedIntegerRounding2 was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
FlowCover was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
TwoMirCuts was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
ZeroHalf was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Result - Optimal solution found
Objective value: -509992.00000000
Enumerated nodes: 0
Total iterations: 0
Time (CPU seconds): 80.21
Time (Wallclock seconds): 80.80
Total time (CPU seconds): 80.21 (Wallclock seconds): 80.80
Options { input_file_path: "./examples/C/mpc/ilp_benchmarks/2pc_ilp_bench_7.c", inputs: None, parties: Some(2), maximize: false }
Done with IR optimization
Converting to aby
Welcome to the CBC MILP Solver
Version: 2.10.3
Build Date: Mar 24 2020
command line - Cbc_C_Interface -solve -quit (default strategy 1)
Continuous objective value is -594992 - 138.52 seconds
Cgl0004I processed model has 140004 rows, 91023 columns (91023 integer (91023 of which binary)) and 413011 elements
Cutoff increment increased from 1e-05 to 0.1999
Cbc0038I Initial state - 0 integers unsatisfied sum - 0
Cbc0038I Solution found of 594992
Cbc0038I Before mini branch and bound, 91023 integers at bound fixed and 0 continuous
Cbc0038I Mini branch and bound did not improve solution (139.85 seconds)
Cbc0038I After 139.85 seconds - Feasibility pump exiting with objective of 594992 - took 0.26 seconds
Cbc0012I Integer solution of 594992 found by feasibility pump after 0 iterations and 0 nodes (139.88 seconds)
Cbc0001I Search completed - best objective 594992, took 0 iterations and 0 nodes (140.00 seconds)
Cbc0035I Maximum depth 0, 0 variables fixed on reduced cost
Cuts at root node changed objective from 594992 to 594992
Probing was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Gomory was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Knapsack was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Clique was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
MixedIntegerRounding2 was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
FlowCover was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
TwoMirCuts was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
ZeroHalf was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Result - Optimal solution found
Objective value: -594992.00000000
Enumerated nodes: 0
Total iterations: 0
Time (CPU seconds): 140.76
Time (Wallclock seconds): 141.60
Total time (CPU seconds): 140.76 (Wallclock seconds): 141.60
Options { input_file_path: "./examples/C/mpc/ilp_benchmarks/2pc_ilp_bench_8.c", inputs: None, parties: Some(2), maximize: false }
Done with IR optimization
Converting to aby
Welcome to the CBC MILP Solver
Version: 2.10.3
Build Date: Mar 24 2020
command line - Cbc_C_Interface -solve -quit (default strategy 1)
Continuous objective value is -679992 - 176.22 seconds
Cgl0004I processed model has 160004 rows, 104023 columns (104023 integer (104023 of which binary)) and 472011 elements
Cutoff increment increased from 1e-05 to 0.1999
Cbc0038I Initial state - 0 integers unsatisfied sum - 0
Cbc0038I Solution found of 679992
Cbc0038I Before mini branch and bound, 104023 integers at bound fixed and 0 continuous
Cbc0038I Mini branch and bound did not improve solution (177.73 seconds)
Cbc0038I After 177.73 seconds - Feasibility pump exiting with objective of 679992 - took 0.30 seconds
Cbc0012I Integer solution of 679992 found by feasibility pump after 0 iterations and 0 nodes (177.77 seconds)
Cbc0001I Search completed - best objective 679992, took 0 iterations and 0 nodes (177.94 seconds)
Cbc0035I Maximum depth 0, 0 variables fixed on reduced cost
Cuts at root node changed objective from 679992 to 679992
Probing was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Gomory was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Knapsack was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Clique was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
MixedIntegerRounding2 was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
FlowCover was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
TwoMirCuts was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
ZeroHalf was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Result - Optimal solution found
Objective value: -679992.00000000
Enumerated nodes: 0
Total iterations: 0
Time (CPU seconds): 178.93
Time (Wallclock seconds): 179.74
Total time (CPU seconds): 178.93 (Wallclock seconds): 179.74
Options { input_file_path: "./examples/C/mpc/ilp_benchmarks/2pc_ilp_bench_9.c", inputs: None, parties: Some(2), maximize: false }
Done with IR optimization
Converting to aby
Welcome to the CBC MILP Solver
Version: 2.10.3
Build Date: Mar 24 2020
command line - Cbc_C_Interface -solve -quit (default strategy 1)
Continuous objective value is -764992 - 186.23 seconds
Cgl0004I processed model has 180004 rows, 117023 columns (117023 integer (117023 of which binary)) and 531011 elements
Cutoff increment increased from 1e-05 to 0.1999
Cbc0038I Initial state - 0 integers unsatisfied sum - 0
Cbc0038I Solution found of 764992
Cbc0038I Before mini branch and bound, 117023 integers at bound fixed and 0 continuous
Cbc0038I Mini branch and bound did not improve solution (187.96 seconds)
Cbc0038I After 187.96 seconds - Feasibility pump exiting with objective of 764992 - took 0.34 seconds
Cbc0012I Integer solution of 764992 found by feasibility pump after 0 iterations and 0 nodes (188.01 seconds)
Cbc0001I Search completed - best objective 764992, took 0 iterations and 0 nodes (188.19 seconds)
Cbc0035I Maximum depth 0, 0 variables fixed on reduced cost
Cuts at root node changed objective from 764992 to 764992
Probing was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Gomory was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Knapsack was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Clique was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
MixedIntegerRounding2 was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
FlowCover was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
TwoMirCuts was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
ZeroHalf was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Result - Optimal solution found
Objective value: -764992.00000000
Enumerated nodes: 0
Total iterations: 0
Time (CPU seconds): 189.31
Time (Wallclock seconds): 190.20
Total time (CPU seconds): 189.31 (Wallclock seconds): 190.20

View File

@@ -1,351 +0,0 @@
Options { input_file_path: "./examples/C/mpc/ilp_benchmarks/2pc_ilp_bench_1.c", inputs: None, parties: Some(2), maximize: false }
Done with IR optimization
Converting to aby
Welcome to the CBC MILP Solver
Version: 2.10.3
Build Date: Mar 24 2020
command line - Cbc_C_Interface -solve -quit (default strategy 1)
Continuous objective value is -169992 - 16.54 seconds
Cgl0004I processed model has 40004 rows, 26023 columns (26023 integer (26023 of which binary)) and 118011 elements
Cutoff increment increased from 1e-05 to 0.1999
Cbc0038I Initial state - 0 integers unsatisfied sum - 0
Cbc0038I Solution found of 169992
Cbc0038I Before mini branch and bound, 26023 integers at bound fixed and 0 continuous
Cbc0038I Mini branch and bound did not improve solution (16.81 seconds)
Cbc0038I After 16.81 seconds - Feasibility pump exiting with objective of 169992 - took 0.06 seconds
Cbc0012I Integer solution of 169992 found by feasibility pump after 0 iterations and 0 nodes (16.82 seconds)
Cbc0001I Search completed - best objective 169992, took 0 iterations and 0 nodes (16.85 seconds)
Cbc0035I Maximum depth 0, 0 variables fixed on reduced cost
Cuts at root node changed objective from 169992 to 169992
Probing was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Gomory was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Knapsack was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Clique was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
MixedIntegerRounding2 was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
FlowCover was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
TwoMirCuts was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
ZeroHalf was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Result - Optimal solution found
Objective value: -169992.00000000
Enumerated nodes: 0
Total iterations: 0
Time (CPU seconds): 16.98
Time (Wallclock seconds): 17.14
Total time (CPU seconds): 16.98 (Wallclock seconds): 17.14
Options { input_file_path: "./examples/C/mpc/ilp_benchmarks/2pc_ilp_bench_2.c", inputs: None, parties: Some(2), maximize: false }
Done with IR optimization
Converting to aby
Welcome to the CBC MILP Solver
Version: 2.10.3
Build Date: Mar 24 2020
command line - Cbc_C_Interface -solve -quit (default strategy 1)
Continuous objective value is -339992 - 38.37 seconds
Cgl0004I processed model has 80004 rows, 52023 columns (52023 integer (52023 of which binary)) and 236011 elements
Cutoff increment increased from 1e-05 to 0.1999
Cbc0038I Initial state - 0 integers unsatisfied sum - 0
Cbc0038I Solution found of 339992
Cbc0038I Before mini branch and bound, 52023 integers at bound fixed and 0 continuous
Cbc0038I Mini branch and bound did not improve solution (39.05 seconds)
Cbc0038I After 39.05 seconds - Feasibility pump exiting with objective of 339992 - took 0.13 seconds
Cbc0012I Integer solution of 339992 found by feasibility pump after 0 iterations and 0 nodes (39.06 seconds)
Cbc0001I Search completed - best objective 339992, took 0 iterations and 0 nodes (39.13 seconds)
Cbc0035I Maximum depth 0, 0 variables fixed on reduced cost
Cuts at root node changed objective from 339992 to 339992
Probing was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Gomory was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Knapsack was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Clique was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
MixedIntegerRounding2 was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
FlowCover was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
TwoMirCuts was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
ZeroHalf was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Result - Optimal solution found
Objective value: -339992.00000000
Enumerated nodes: 0
Total iterations: 0
Time (CPU seconds): 39.47
Time (Wallclock seconds): 39.85
Total time (CPU seconds): 39.47 (Wallclock seconds): 39.85
Options { input_file_path: "./examples/C/mpc/ilp_benchmarks/2pc_ilp_bench_3.c", inputs: None, parties: Some(2), maximize: false }
Done with IR optimization
Converting to aby
Welcome to the CBC MILP Solver
Version: 2.10.3
Build Date: Mar 24 2020
command line - Cbc_C_Interface -solve -quit (default strategy 1)
Continuous objective value is -509992 - 81.53 seconds
Cgl0004I processed model has 120004 rows, 78023 columns (78023 integer (78023 of which binary)) and 354011 elements
Cutoff increment increased from 1e-05 to 0.1999
Cbc0038I Initial state - 0 integers unsatisfied sum - 0
Cbc0038I Solution found of 509992
Cbc0038I Before mini branch and bound, 78023 integers at bound fixed and 0 continuous
Cbc0038I Mini branch and bound did not improve solution (82.55 seconds)
Cbc0038I After 82.55 seconds - Feasibility pump exiting with objective of 509992 - took 0.21 seconds
Cbc0012I Integer solution of 509992 found by feasibility pump after 0 iterations and 0 nodes (82.58 seconds)
Cbc0001I Search completed - best objective 509992, took 0 iterations and 0 nodes (82.70 seconds)
Cbc0035I Maximum depth 0, 0 variables fixed on reduced cost
Cuts at root node changed objective from 509992 to 509992
Probing was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Gomory was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Knapsack was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Clique was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
MixedIntegerRounding2 was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
FlowCover was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
TwoMirCuts was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
ZeroHalf was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Result - Optimal solution found
Objective value: -509992.00000000
Enumerated nodes: 0
Total iterations: 0
Time (CPU seconds): 83.31
Time (Wallclock seconds): 83.88
Total time (CPU seconds): 83.31 (Wallclock seconds): 83.88
Options { input_file_path: "./examples/C/mpc/ilp_benchmarks/2pc_ilp_bench_4.c", inputs: None, parties: Some(2), maximize: false }
Done with IR optimization
Converting to aby
Welcome to the CBC MILP Solver
Version: 2.10.3
Build Date: Mar 24 2020
command line - Cbc_C_Interface -solve -quit (default strategy 1)
Continuous objective value is -679992 - 5.17 seconds
Cgl0004I processed model has 160004 rows, 104023 columns (104023 integer (104023 of which binary)) and 472011 elements
Cutoff increment increased from 1e-05 to 0.1999
Cbc0038I Initial state - 0 integers unsatisfied sum - 0
Cbc0038I Solution found of 679992
Cbc0038I Before mini branch and bound, 104023 integers at bound fixed and 0 continuous
Cbc0038I Mini branch and bound did not improve solution (6.63 seconds)
Cbc0038I After 6.63 seconds - Feasibility pump exiting with objective of 679992 - took 0.27 seconds
Cbc0012I Integer solution of 679992 found by feasibility pump after 0 iterations and 0 nodes (6.68 seconds)
Cbc0001I Search completed - best objective 679992, took 0 iterations and 0 nodes (6.85 seconds)
Cbc0035I Maximum depth 0, 0 variables fixed on reduced cost
Cuts at root node changed objective from 679992 to 679992
Probing was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Gomory was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Knapsack was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Clique was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
MixedIntegerRounding2 was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
FlowCover was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
TwoMirCuts was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
ZeroHalf was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Result - Optimal solution found
Objective value: -679992.00000000
Enumerated nodes: 0
Total iterations: 0
Time (CPU seconds): 7.43
Time (Wallclock seconds): 7.89
Total time (CPU seconds): 7.43 (Wallclock seconds): 7.89
Options { input_file_path: "./examples/C/mpc/ilp_benchmarks/2pc_ilp_bench_5.c", inputs: None, parties: Some(2), maximize: false }
Done with IR optimization
Converting to aby
Welcome to the CBC MILP Solver
Version: 2.10.3
Build Date: Mar 24 2020
command line - Cbc_C_Interface -solve -quit (default strategy 1)
Continuous objective value is -849992 - 285.77 seconds
Cgl0004I processed model has 200004 rows, 130023 columns (130023 integer (130023 of which binary)) and 590011 elements
Cutoff increment increased from 1e-05 to 0.1999
Cbc0038I Initial state - 0 integers unsatisfied sum - 0
Cbc0038I Solution found of 849992
Cbc0038I Before mini branch and bound, 130023 integers at bound fixed and 0 continuous
Cbc0038I Mini branch and bound did not improve solution (287.74 seconds)
Cbc0038I After 287.74 seconds - Feasibility pump exiting with objective of 849992 - took 0.39 seconds
Cbc0012I Integer solution of 849992 found by feasibility pump after 0 iterations and 0 nodes (287.79 seconds)
Cbc0001I Search completed - best objective 849992, took 0 iterations and 0 nodes (288.03 seconds)
Cbc0035I Maximum depth 0, 0 variables fixed on reduced cost
Cuts at root node changed objective from 849992 to 849992
Probing was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Gomory was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Knapsack was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Clique was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
MixedIntegerRounding2 was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
FlowCover was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
TwoMirCuts was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
ZeroHalf was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Result - Optimal solution found
Objective value: -849992.00000000
Enumerated nodes: 0
Total iterations: 0
Time (CPU seconds): 289.52
Time (Wallclock seconds): 290.49
Total time (CPU seconds): 289.52 (Wallclock seconds): 290.49
Options { input_file_path: "./examples/C/mpc/ilp_benchmarks/2pc_ilp_bench_6.c", inputs: None, parties: Some(2), maximize: false }
Done with IR optimization
Converting to aby
Welcome to the CBC MILP Solver
Version: 2.10.3
Build Date: Mar 24 2020
command line - Cbc_C_Interface -solve -quit (default strategy 1)
Continuous objective value is -1.01999e+06 - 498.81 seconds
Cgl0004I processed model has 240004 rows, 156023 columns (156023 integer (156023 of which binary)) and 708011 elements
Cutoff increment increased from 1e-05 to 0.1999
Cbc0038I Initial state - 0 integers unsatisfied sum - 0
Cbc0038I Solution found of 1.01999e+06
Cbc0038I Before mini branch and bound, 156023 integers at bound fixed and 0 continuous
Cbc0038I Mini branch and bound did not improve solution (501.69 seconds)
Cbc0038I After 501.69 seconds - Feasibility pump exiting with objective of 1.01999e+06 - took 0.52 seconds
Cbc0012I Integer solution of 1019992 found by feasibility pump after 0 iterations and 0 nodes (501.77 seconds)
Cbc0001I Search completed - best objective 1019992, took 0 iterations and 0 nodes (502.09 seconds)
Cbc0035I Maximum depth 0, 0 variables fixed on reduced cost
Cuts at root node changed objective from 1.01999e+06 to 1.01999e+06
Probing was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Gomory was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Knapsack was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Clique was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
MixedIntegerRounding2 was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
FlowCover was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
TwoMirCuts was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
ZeroHalf was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Result - Optimal solution found
Objective value: -1019992.00000000
Enumerated nodes: 0
Total iterations: 0
Time (CPU seconds): 504.09
Time (Wallclock seconds): 506.03
Total time (CPU seconds): 504.09 (Wallclock seconds): 506.03
Options { input_file_path: "./examples/C/mpc/ilp_benchmarks/2pc_ilp_bench_7.c", inputs: None, parties: Some(2), maximize: false }
Done with IR optimization
Converting to aby
Welcome to the CBC MILP Solver
Version: 2.10.3
Build Date: Mar 24 2020
command line - Cbc_C_Interface -solve -quit (default strategy 1)
Continuous objective value is -1.18999e+06 - 18.77 seconds
Cgl0004I processed model has 280004 rows, 182023 columns (182023 integer (182023 of which binary)) and 826011 elements
Cutoff increment increased from 1e-05 to 0.1999
Cbc0038I Initial state - 0 integers unsatisfied sum - 0
Cbc0038I Solution found of 1.18999e+06
Cbc0038I Before mini branch and bound, 182023 integers at bound fixed and 0 continuous
Cbc0038I Mini branch and bound did not improve solution (21.66 seconds)
Cbc0038I After 21.66 seconds - Feasibility pump exiting with objective of 1.18999e+06 - took 0.57 seconds
Cbc0012I Integer solution of 1189992 found by feasibility pump after 0 iterations and 0 nodes (21.74 seconds)
Cbc0001I Search completed - best objective 1189992, took 0 iterations and 0 nodes (22.04 seconds)
Cbc0035I Maximum depth 0, 0 variables fixed on reduced cost
Cuts at root node changed objective from 1.18999e+06 to 1.18999e+06
Probing was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Gomory was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Knapsack was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Clique was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
MixedIntegerRounding2 was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
FlowCover was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
TwoMirCuts was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
ZeroHalf was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Result - Optimal solution found
Objective value: -1189992.00000000
Enumerated nodes: 0
Total iterations: 0
Time (CPU seconds): 23.25
Time (Wallclock seconds): 24.30
Total time (CPU seconds): 23.25 (Wallclock seconds): 24.30
Options { input_file_path: "./examples/C/mpc/ilp_benchmarks/2pc_ilp_bench_8.c", inputs: None, parties: Some(2), maximize: false }
Done with IR optimization
Converting to aby
Welcome to the CBC MILP Solver
Version: 2.10.3
Build Date: Mar 24 2020
command line - Cbc_C_Interface -solve -quit (default strategy 1)
Continuous objective value is -1.35999e+06 - 1020.30 seconds
Cgl0004I processed model has 320004 rows, 208023 columns (208023 integer (208023 of which binary)) and 944011 elements
Cutoff increment increased from 1e-05 to 0.1999
Cbc0038I Initial state - 0 integers unsatisfied sum - 0
Cbc0038I Solution found of 1.35999e+06
Cbc0038I Before mini branch and bound, 208023 integers at bound fixed and 0 continuous
Cbc0038I Mini branch and bound did not improve solution (1024.39 seconds)
Cbc0038I After 1024.39 seconds - Feasibility pump exiting with objective of 1.35999e+06 - took 0.78 seconds
Cbc0012I Integer solution of 1359992 found by feasibility pump after 0 iterations and 0 nodes (1024.50 seconds)
Cbc0001I Search completed - best objective 1359992, took 0 iterations and 0 nodes (1024.96 seconds)
Cbc0035I Maximum depth 0, 0 variables fixed on reduced cost
Cuts at root node changed objective from 1.35999e+06 to 1.35999e+06
Probing was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Gomory was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Knapsack was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Clique was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
MixedIntegerRounding2 was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
FlowCover was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
TwoMirCuts was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
ZeroHalf was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Result - Optimal solution found
Objective value: -1359992.00000000
Enumerated nodes: 0
Total iterations: 0
Time (CPU seconds): 1028.31
Time (Wallclock seconds): 1032.55
Total time (CPU seconds): 1028.31 (Wallclock seconds): 1032.55
Options { input_file_path: "./examples/C/mpc/ilp_benchmarks/2pc_ilp_bench_9.c", inputs: None, parties: Some(2), maximize: false }
Done with IR optimization
Converting to aby
Welcome to the CBC MILP Solver
Version: 2.10.3
Build Date: Mar 24 2020
command line - Cbc_C_Interface -solve -quit (default strategy 1)
Continuous objective value is -764992 - 309.78 seconds
Cgl0004I processed model has 180004 rows, 117023 columns (117023 integer (117023 of which binary)) and 531011 elements
Cutoff increment increased from 1e-05 to 0.1999
Cbc0038I Initial state - 0 integers unsatisfied sum - 0
Cbc0038I Solution found of 764992
Cbc0038I Before mini branch and bound, 117023 integers at bound fixed and 0 continuous
Cbc0038I Mini branch and bound did not improve solution (311.74 seconds)
Cbc0038I After 311.74 seconds - Feasibility pump exiting with objective of 764992 - took 0.38 seconds
Cbc0012I Integer solution of 764992 found by feasibility pump after 0 iterations and 0 nodes (311.81 seconds)
Cbc0001I Search completed - best objective 764992, took 0 iterations and 0 nodes (312.04 seconds)
Cbc0035I Maximum depth 0, 0 variables fixed on reduced cost
Cuts at root node changed objective from 764992 to 764992
Probing was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Gomory was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Knapsack was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Clique was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
MixedIntegerRounding2 was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
FlowCover was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
TwoMirCuts was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
ZeroHalf was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Result - Optimal solution found
Objective value: -764992.00000000
Enumerated nodes: 0
Total iterations: 0
Time (CPU seconds): 313.23
Time (Wallclock seconds): 314.35
Total time (CPU seconds): 313.23 (Wallclock seconds): 314.35

View File

@@ -1,13 +1,16 @@
#!/usr/bin/env python
import os
from utils import run_tests
from test_suite import *
ABY_SOURCE = os.getenv("ABY_SOURCE")
if __name__ == "__main__":
tests = [[
"loop add",
3,
"./third_party/ABY/build/bin/2pc_loop_add",
ABY_SOURCE+"/build/bin/2pc_loop_add",
{"a": 1, "b": 0},
{"a": 0, "b": 2},
]]

View File

@@ -1,50 +1,53 @@
import os
ABY_SOURCE = os.getenv('ABY_SOURCE')
arithmetic_tests = [
[
"Add two numbers - 1",
3,
"./third_party/ABY/build/bin/2pc_add",
ABY_SOURCE+"/build/bin/2pc_add",
{"a": 1, "b": 0},
{"a": 0, "b": 2},
],
[
"Add two numbers - 2",
2,
"./third_party/ABY/build/bin/2pc_add",
ABY_SOURCE+"/build/bin/2pc_add",
{"a": 0, "b": 0},
{"a": 0, "b": 2},
],
[
"Subtract two numbers",
1,
"./third_party/ABY/build/bin/2pc_sub",
ABY_SOURCE+"/build/bin/2pc_sub",
{"a": 3, "b": 0},
{"a": 0, "b": 2},
],
[
"Subtract two numbers, negative -1 == 4294967295 because u32",
4294967295,
"./third_party/ABY/build/bin/2pc_sub",
ABY_SOURCE+"/build/bin/2pc_sub",
{"a": 2, "b": 0},
{"a": 0, "b": 3},
],
[
"Multiply two numbers - 1",
0,
"./third_party/ABY/build/bin/2pc_mult",
ABY_SOURCE+"/build/bin/2pc_mult",
{"a": 0, "b": 0},
{"a": 0, "b": 5},
],
[
"Multiply two numbers - 2",
5,
"./third_party/ABY/build/bin/2pc_mult",
ABY_SOURCE+"/build/bin/2pc_mult",
{"a": 1, "b": 0},
{"a": 0, "b": 5},
],
[
"Multiply two numbers - 3",
10,
"./third_party/ABY/build/bin/2pc_mult",
ABY_SOURCE+"/build/bin/2pc_mult",
{"a": 2, "b": 0},
{"a": 0, "b": 5},
],
@@ -52,7 +55,7 @@ arithmetic_tests = [
# only server side public value works
"Multiply two numbers together and add with public value",
42,
"./third_party/ABY/build/bin/2pc_mult_add_pub",
ABY_SOURCE+"/build/bin/2pc_mult_add_pub",
{"a": 5, "b": 0, "v": 7},
{"a": 0, "b": 7, "v": 7},
],
@@ -60,7 +63,7 @@ arithmetic_tests = [
# only server side public value works
"Multiply two numbers together and add with public value, check only server side public value is added",
42,
"./third_party/ABY/build/bin/2pc_mult_add_pub",
ABY_SOURCE+"/build/bin/2pc_mult_add_pub",
{"a": 5, "b": 0, "v": 7},
{"a": 0, "b": 7, "v": 0},
],
@@ -70,21 +73,21 @@ mod_tests = [
[
"Mod two numbers - 1",
0,
"./third_party/ABY/build/bin/2pc_mod",
ABY_SOURCE+"/build/bin/2pc_mod",
{"a": 0, "b": 0},
{"a": 0, "b": 2},
],
[
"Mod two numbers - 2",
1,
"./third_party/ABY/build/bin/2pc_mod",
ABY_SOURCE+"/build/bin/2pc_mod",
{"a": 1, "b": 0},
{"a": 0, "b": 2},
],
[
"Mod two numbers - 3",
0,
"./third_party/ABY/build/bin/2pc_mod",
ABY_SOURCE+"/build/bin/2pc_mod",
{"a": 2, "b": 0},
{"a": 0, "b": 2},
],
@@ -94,7 +97,7 @@ unsigned_arithmetic_tests = [
[
"Add two unsigned numbers - 1",
3,
"./third_party/ABY/build/bin/2pc_add_unsigned",
ABY_SOURCE+"/build/bin/2pc_add_unsigned",
{"a": 1, "b": 0},
{"a": 0, "b": 2},
],
@@ -104,112 +107,112 @@ arithmetic_boolean_tests = [
[
"Test two numbers are equal - 1",
0,
"./third_party/ABY/build/bin/2pc_int_equals",
ABY_SOURCE+"/build/bin/2pc_int_equals",
{"a": 5, "b": 0},
{"a": 0, "b": 7},
],
[
"Test two numbers are equal - 2",
1,
"./third_party/ABY/build/bin/2pc_int_equals",
ABY_SOURCE+"/build/bin/2pc_int_equals",
{"a": 7, "b": 0},
{"a": 0, "b": 7},
],
[
"Test int > int - 1",
0,
"./third_party/ABY/build/bin/2pc_int_greater_than",
ABY_SOURCE+"/build/bin/2pc_int_greater_than",
{"a": 5, "b": 0},
{"a": 0, "b": 7},
],
[
"Test int > int - 2",
0,
"./third_party/ABY/build/bin/2pc_int_greater_than",
ABY_SOURCE+"/build/bin/2pc_int_greater_than",
{"a": 7, "b": 0},
{"a": 0, "b": 7},
],
[
"Test int > int - 3",
1,
"./third_party/ABY/build/bin/2pc_int_greater_than",
ABY_SOURCE+"/build/bin/2pc_int_greater_than",
{"a": 8, "b": 0},
{"a": 0, "b": 7},
],
[
"Test int >= int - 1",
1,
"./third_party/ABY/build/bin/2pc_int_greater_equals",
ABY_SOURCE+"/build/bin/2pc_int_greater_equals",
{"a": 8, "b": 0},
{"a": 0, "b": 7},
],
[
"Test int >= int - 2",
1,
"./third_party/ABY/build/bin/2pc_int_greater_equals",
ABY_SOURCE+"/build/bin/2pc_int_greater_equals",
{"a": 7, "b": 0},
{"a": 0, "b": 7},
],
[
"Test int >= int - 3",
0,
"./third_party/ABY/build/bin/2pc_int_greater_equals",
ABY_SOURCE+"/build/bin/2pc_int_greater_equals",
{"a": 6, "b": 0},
{"a": 0, "b": 7},
],
[
"Test int < int - 1",
0,
"./third_party/ABY/build/bin/2pc_int_less_than",
ABY_SOURCE+"/build/bin/2pc_int_less_than",
{"a": 7, "b": 0},
{"a": 0, "b": 2},
],
[
"Test int < int - 2",
0,
"./third_party/ABY/build/bin/2pc_int_less_than",
ABY_SOURCE+"/build/bin/2pc_int_less_than",
{"a": 7, "b": 0},
{"a": 0, "b": 7},
],
[
"Test int < int - 3",
1,
"./third_party/ABY/build/bin/2pc_int_less_than",
ABY_SOURCE+"/build/bin/2pc_int_less_than",
{"a": 2, "b": 0},
{"a": 0, "b": 7},
],
[
"Test int <= int - 1",
1,
"./third_party/ABY/build/bin/2pc_int_less_equals",
ABY_SOURCE+"/build/bin/2pc_int_less_equals",
{"a": 7, "b": 0},
{"a": 0, "b": 8},
],
[
"Test int <= int - 2",
1,
"./third_party/ABY/build/bin/2pc_int_less_equals",
ABY_SOURCE+"/build/bin/2pc_int_less_equals",
{"a": 7, "b": 0},
{"a": 0, "b": 7},
],
[
"Test int <= int - 3",
0,
"./third_party/ABY/build/bin/2pc_int_less_equals",
ABY_SOURCE+"/build/bin/2pc_int_less_equals",
{"a": 8, "b": 0},
{"a": 0, "b": 7},
],
[
"Test int == int - 1",
0,
"./third_party/ABY/build/bin/2pc_int_equals",
ABY_SOURCE+"/build/bin/2pc_int_equals",
{"a": 7, "b": 0},
{"a": 0, "b": 8},
],
[
"Test int == int - 2",
1,
"./third_party/ABY/build/bin/2pc_int_equals",
ABY_SOURCE+"/build/bin/2pc_int_equals",
{"a": 12, "b": 0},
{"a": 0, "b": 12},
],
@@ -219,7 +222,7 @@ nary_arithmetic_tests = [
[
"Test a + b + c",
6,
"./third_party/ABY/build/bin/2pc_nary_arithmetic_add",
ABY_SOURCE+"/build/bin/2pc_nary_arithmetic_add",
{"a": 1, "b": 0, "c": 0},
{"a": 0, "b": 2, "c": 3},
],
@@ -229,84 +232,84 @@ bitwise_tests = [
[
"Bitwise & - 1",
0,
"./third_party/ABY/build/bin/2pc_bitwise_and",
ABY_SOURCE+"/build/bin/2pc_bitwise_and",
{"a": 0, "b": 0},
{"a": 0, "b": 0},
],
[
"Bitwise & - 2",
0,
"./third_party/ABY/build/bin/2pc_bitwise_and",
ABY_SOURCE+"/build/bin/2pc_bitwise_and",
{"a": 1, "b": 0},
{"a": 0, "b": 0},
],
[
"Bitwise & - 3",
0,
"./third_party/ABY/build/bin/2pc_bitwise_and",
ABY_SOURCE+"/build/bin/2pc_bitwise_and",
{"a": 0, "b": 0},
{"a": 0, "b": 1},
],
[
"Bitwise & - 4",
1,
"./third_party/ABY/build/bin/2pc_bitwise_and",
ABY_SOURCE+"/build/bin/2pc_bitwise_and",
{"a": 1, "b": 0},
{"a": 0, "b": 1},
],
[
"Bitwise | - 1",
0,
"./third_party/ABY/build/bin/2pc_bitwise_or",
ABY_SOURCE+"/build/bin/2pc_bitwise_or",
{"a": 0, "b": 0},
{"a": 0, "b": 0},
],
[
"Bitwise | - 2",
1,
"./third_party/ABY/build/bin/2pc_bitwise_or",
ABY_SOURCE+"/build/bin/2pc_bitwise_or",
{"a": 1, "b": 0},
{"a": 0, "b": 0},
],
[
"Bitwise | - 3",
1,
"./third_party/ABY/build/bin/2pc_bitwise_or",
ABY_SOURCE+"/build/bin/2pc_bitwise_or",
{"a": 0, "b": 0},
{"a": 0, "b": 1},
],
[
"Bitwise | - 4",
1,
"./third_party/ABY/build/bin/2pc_bitwise_or",
ABY_SOURCE+"/build/bin/2pc_bitwise_or",
{"a": 1, "b": 0},
{"a": 0, "b": 1},
],
[
"Bitwise ^ - 1",
0,
"./third_party/ABY/build/bin/2pc_bitwise_xor",
ABY_SOURCE+"/build/bin/2pc_bitwise_xor",
{"a": 0, "b": 0},
{"a": 0, "b": 0},
],
[
"Bitwise ^ - 2",
1,
"./third_party/ABY/build/bin/2pc_bitwise_xor",
ABY_SOURCE+"/build/bin/2pc_bitwise_xor",
{"a": 1, "b": 0},
{"a": 0, "b": 0},
],
[
"Bitwise ^ - 3",
1,
"./third_party/ABY/build/bin/2pc_bitwise_xor",
ABY_SOURCE+"/build/bin/2pc_bitwise_xor",
{"a": 0, "b": 0},
{"a": 0, "b": 1},
],
[
"Bitwise ^ - 4",
0,
"./third_party/ABY/build/bin/2pc_bitwise_xor",
ABY_SOURCE+"/build/bin/2pc_bitwise_xor",
{"a": 1, "b": 0},
{"a": 0, "b": 1},
],
@@ -316,70 +319,70 @@ boolean_tests = [
[
"Boolean && - 1",
0,
"./third_party/ABY/build/bin/2pc_boolean_and",
ABY_SOURCE+"/build/bin/2pc_boolean_and",
{"a": 0, "b": 0},
{"a": 0, "b": 0},
],
[
"Boolean && - 2",
0,
"./third_party/ABY/build/bin/2pc_boolean_and",
ABY_SOURCE+"/build/bin/2pc_boolean_and",
{"a": 1, "b": 0},
{"a": 0, "b": 0},
],
[
"Boolean && - 3",
0,
"./third_party/ABY/build/bin/2pc_boolean_and",
ABY_SOURCE+"/build/bin/2pc_boolean_and",
{"a": 0, "b": 0},
{"a": 0, "b": 1},
],
[
"Boolean && - 4",
1,
"./third_party/ABY/build/bin/2pc_boolean_and",
ABY_SOURCE+"/build/bin/2pc_boolean_and",
{"a": 1, "b": 0},
{"a": 0, "b": 1},
],
[
"Boolean || - 1",
0,
"./third_party/ABY/build/bin/2pc_boolean_or",
ABY_SOURCE+"/build/bin/2pc_boolean_or",
{"a": 0, "b": 0},
{"a": 0, "b": 0},
],
[
"Boolean || - 2",
1,
"./third_party/ABY/build/bin/2pc_boolean_or",
ABY_SOURCE+"/build/bin/2pc_boolean_or",
{"a": 1, "b": 0},
{"a": 0, "b": 0},
],
[
"Boolean || - 3",
1,
"./third_party/ABY/build/bin/2pc_boolean_or",
ABY_SOURCE+"/build/bin/2pc_boolean_or",
{"a": 0, "b": 0},
{"a": 0, "b": 1},
],
[
"Boolean || - 4",
1,
"./third_party/ABY/build/bin/2pc_boolean_or",
ABY_SOURCE+"/build/bin/2pc_boolean_or",
{"a": 1, "b": 0},
{"a": 0, "b": 1},
],
[
"Boolean == - 1",
0,
"./third_party/ABY/build/bin/2pc_boolean_equals",
ABY_SOURCE+"/build/bin/2pc_boolean_equals",
{"a": 0, "b": 0},
{"a": 0, "b": 1},
],
[
"Boolean == - 2",
1,
"./third_party/ABY/build/bin/2pc_boolean_equals",
ABY_SOURCE+"/build/bin/2pc_boolean_equals",
{"a": 1, "b": 0},
{"a": 0, "b": 1},
],
@@ -389,14 +392,14 @@ nary_boolean_tests = [
[
"Test a & b & c - 1",
0,
"./third_party/ABY/build/bin/2pc_nary_boolean_and",
ABY_SOURCE+"/build/bin/2pc_nary_boolean_and",
{"a": 1, "b": 0, "c": 0},
{"a": 0, "b": 1, "c": 0},
],
[
"Test a & b & c - 2",
1,
"./third_party/ABY/build/bin/2pc_nary_boolean_and",
ABY_SOURCE+"/build/bin/2pc_nary_boolean_and",
{"a": 1, "b": 0, "c": 0},
{"a": 0, "b": 1, "c": 1},
],
@@ -407,7 +410,7 @@ const_arith_tests = [
[
"Test add client int + server int to const value",
6,
"./third_party/ABY/build/bin/2pc_const_arith",
ABY_SOURCE+"/build/bin/2pc_const_arith",
{"a": 2, "b": 0},
{"a": 0, "b": 3},
],
@@ -417,14 +420,14 @@ const_bool_tests = [
[
"Test server value == const value - 1",
0,
"./third_party/ABY/build/bin/2pc_const_bool",
ABY_SOURCE+"/build/bin/2pc_const_bool",
{"a": 0, "b": 0},
{"a": 0, "b": 0},
],
[
"Test server value == const value - 2",
1,
"./third_party/ABY/build/bin/2pc_const_bool",
ABY_SOURCE+"/build/bin/2pc_const_bool",
{"a": 1, "b": 0},
{"a": 0, "b": 0},
],
@@ -434,42 +437,42 @@ ite_tests = [
[
"Test ite ret bool - 1",
0,
"./third_party/ABY/build/bin/2pc_ite_ret_bool",
ABY_SOURCE+"/build/bin/2pc_ite_ret_bool",
{"a": 0, "b": 0, "sel": 1},
{"a": 0, "b": 1, "sel": 1},
],
[
"Test ite ret bool - 2",
1,
"./third_party/ABY/build/bin/2pc_ite_ret_bool",
ABY_SOURCE+"/build/bin/2pc_ite_ret_bool",
{"a": 0, "b": 0, "sel": 0},
{"a": 0, "b": 1, "sel": 0},
],
[
"Test ite ret int - 1",
32,
"./third_party/ABY/build/bin/2pc_ite_ret_int",
ABY_SOURCE+"/build/bin/2pc_ite_ret_int",
{"a": 32, "b": 0, "sel": 1},
{"a": 0, "b": 45, "sel": 1},
],
[
"Test ite ret int - 2",
45,
"./third_party/ABY/build/bin/2pc_ite_ret_int",
ABY_SOURCE+"/build/bin/2pc_ite_ret_int",
{"a": 32, "b": 0, "sel": 0},
{"a": 0, "b": 45, "sel": 0},
],
[
"Test ite only if - 1",
32,
"./third_party/ABY/build/bin/2pc_ite_ret_int",
ABY_SOURCE+"/build/bin/2pc_ite_ret_int",
{"a": 32, "b": 0, "sel": 1},
{"a": 0, "b": 45, "sel": 1},
],
[
"Test ite only if - 2",
45,
"./third_party/ABY/build/bin/2pc_ite_ret_int",
ABY_SOURCE+"/build/bin/2pc_ite_ret_int",
{"a": 32, "b": 0, "sel": 0},
{"a": 0, "b": 45, "sel": 0},
],
@@ -479,28 +482,28 @@ array_tests = [
[
"Array sum test",
3,
"./third_party/ABY/build/bin/2pc_array_sum",
ABY_SOURCE+"/build/bin/2pc_array_sum",
{"a": 2, "b": 0},
{"a": 0, "b": 1},
],
[
"Array index test",
3,
"./third_party/ABY/build/bin/2pc_array_index",
ABY_SOURCE+"/build/bin/2pc_array_index",
{"a": 2, "b": 0},
{"a": 0, "b": 1},
],
[
"Array index test 2",
2,
"./third_party/ABY/build/bin/2pc_array_index_2",
ABY_SOURCE+"/build/bin/2pc_array_index_2",
{"a": 2, "b": 0},
{"a": 0, "b": 1},
],
# [
# "Array ret test",
# "2\n1",
# "./third_party/ABY/build/bin/2pc_array_ret",
# ABY_SOURCE+"/build/bin/2pc_array_ret",
# {"a": 2, "b": 0},
# {"a": 0, "b": 1},
# ],
@@ -510,35 +513,35 @@ c_array_tests = [
[
"C array test",
2,
"./third_party/ABY/build/bin/2pc_array",
ABY_SOURCE+"/build/bin/2pc_array",
{"a": 2, "b": 0},
{"a": 0, "b": 2},
],
[
"C array test 1",
17,
"./third_party/ABY/build/bin/2pc_array_1",
ABY_SOURCE+"/build/bin/2pc_array_1",
{"a": 10, "b": 0},
{"a": 0, "b": 3},
],
[
"C array test 2",
17,
"./third_party/ABY/build/bin/2pc_array_2",
ABY_SOURCE+"/build/bin/2pc_array_2",
{"a": 10, "b": 0},
{"a": 0, "b": 3},
],
[
"C array test 3",
18,
"./third_party/ABY/build/bin/2pc_array_3",
ABY_SOURCE+"/build/bin/2pc_array_3",
{"a": 2, "b": 0},
{"a": 0, "b": 3},
],
[
"C array test 3",
30,
"./third_party/ABY/build/bin/2pc_array_sum_c",
ABY_SOURCE+"/build/bin/2pc_array_sum_c",
{"a": [1,2,3,4,5], "b": 7},
{"a": 6, "b": [1,2,3,4,5]},
],
@@ -548,31 +551,31 @@ loop_tests = [
[
"Loop sum const - 1",
10,
"./third_party/ABY/build/bin/2pc_loop_sum",
ABY_SOURCE+"/build/bin/2pc_loop_sum",
{"a": 2, "b": 0},
{"a": 0, "b": 1},
],
[
"Loop sum const - 2",
10,
"./third_party/ABY/build/bin/2pc_loop_sum",
ABY_SOURCE+"/build/bin/2pc_loop_sum",
{"a": 10, "b": 0},
{"a": 0, "b": 3},
],
]
function_tests = [
[
"Function add two numbers - 1",
[
"Sum() two numbers - 1",
6,
"./third_party/ABY/build/bin/2pc_function_add",
ABY_SOURCE+"/build/bin/2pc_function_add",
{"a": 1, "b": 0},
{"a": 0, "b": 2},
],
[
"Function add two numbers - 2",
"Sum() two numbers - 2",
4,
"./third_party/ABY/build/bin/2pc_function_add",
ABY_SOURCE+"/build/bin/2pc_function_add",
{"a": 0, "b": 0},
{"a": 0, "b": 2},
],
@@ -582,35 +585,35 @@ shift_tests = [
[
"Left Shift a by 1 - 1",
20,
"./third_party/ABY/build/bin/2pc_lhs",
ABY_SOURCE+"/build/bin/2pc_lhs",
{"a": 10, "b": 0},
{"a": 0, "b": 2},
],
[
"Left Shift a by 1 - 2",
0,
"./third_party/ABY/build/bin/2pc_lhs",
ABY_SOURCE+"/build/bin/2pc_lhs",
{"a": 0, "b": 0},
{"a": 0, "b": 2},
],
[
"Left Shift a by 1 - 3",
0,
"./third_party/ABY/build/bin/2pc_lhs",
ABY_SOURCE+"/build/bin/2pc_lhs",
{"a": 2147483648, "b": 0},
{"a": 0, "b": 2},
],
[
"Right Shift a by 1 - 1",
10,
"./third_party/ABY/build/bin/2pc_rhs",
ABY_SOURCE+"/build/bin/2pc_rhs",
{"a": 20, "b": 0},
{"a": 0, "b": 2},
],
[
"Right Shift a by 1 - 2",
0,
"./third_party/ABY/build/bin/2pc_rhs",
ABY_SOURCE+"/build/bin/2pc_rhs",
{"a": 0, "b": 0},
{"a": 0, "b": 2},
],
@@ -621,28 +624,28 @@ div_tests = [
[
"Divide a by 1",
10,
"./third_party/ABY/build/bin/2pc_div",
ABY_SOURCE+"/build/bin/2pc_div",
{"a": 10, "b": 0},
{"a": 0, "b": 1},
],
[
"Divide a by b - 1",
5,
"./third_party/ABY/build/bin/2pc_div",
ABY_SOURCE+"/build/bin/2pc_div",
{"a": 10, "b": 0},
{"a": 0, "b": 2},
],
[
"Divide a by b - 2",
5,
"./third_party/ABY/build/bin/2pc_div",
ABY_SOURCE+"/build/bin/2pc_div",
{"a": 11, "b": 0},
{"a": 0, "b": 2},
],
[
"Divide a by b - 3",
0,
"./third_party/ABY/build/bin/2pc_div",
ABY_SOURCE+"/build/bin/2pc_div",
{"a": 49, "b": 0},
{"a": 0, "b": 50},
],
@@ -652,28 +655,28 @@ misc_tests = [
[
"Millionaire's problem: server has more money than client",
0,
"./third_party/ABY/build/bin/2pc_millionaire",
ABY_SOURCE+"/build/bin/2pc_millionaire",
{"a": 2, "b": 0},
{"a": 0, "b": 1},
],
[
"Millionaire's problem: server has equal money to client",
0,
"./third_party/ABY/build/bin/2pc_millionaire",
ABY_SOURCE+"/build/bin/2pc_millionaire",
{"a": 1, "b": 0},
{"a": 0, "b": 1},
],
[
"Millionaire's problem: server has less money than client",
1,
"./third_party/ABY/build/bin/2pc_millionaire",
ABY_SOURCE+"/build/bin/2pc_millionaire",
{"a": 1, "b": 0},
{"a": 0, "b": 2},
],
[
"Conversion problem",
7,
"./third_party/ABY/build/bin/2pc_conv",
ABY_SOURCE+"/build/bin/2pc_conv",
{"a": 0, "b": 0},
{"a": 0, "b": 7},
],
@@ -683,7 +686,7 @@ kmeans_tests = [
[
"kmeans",
103,
"./third_party/ABY/build/bin/2pc_kmeans",
ABY_SOURCE+"/build/bin/2pc_kmeans",
{"a": [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19], "b": [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]},
{"a": [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19], "b": [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]},
# {"a": [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99], "b": 0},
@@ -695,14 +698,14 @@ biomatch_tests = [
[
"biomatch - 1",
14,
"./third_party/ABY/build/bin/2pc_biomatch",
ABY_SOURCE+"/build/bin/2pc_biomatch",
{"db": [0,1,2,3,1,2,3,4,2,3,4,5,3,4,5,6,4,5,6,7,5,6,7,8,6,7,8,9,7,8,9,10,8,9,10,11,9,10,11,12,10,11,12,13,11,12,13,14,12,13,14,15,13,14,15,16,14,15,16,17,15,16,17,18,16,17,18,19,17,18,19,20,18,19,20,21,19,20,21,22,20,21,22,23,21,22,23,24,22,23,24,25,23,24,25,26,24,25,26,27,25,26,27,28,26,27,28,29,27,28,29,30,28,29,30,31,29,30,31,32,30,31,32,33,31,32,33,34,32,33,34,35,33,34,35,36,34,35,36,37,35,36,37,38,36,37,38,39,37,38,39,40,38,39,40,41,39,40,41,42,40,41,42,43,41,42,43,44,42,43,44,45,43,44,45,46,44,45,46,47,45,46,47,48,46,47,48,49,47,48,49,50,48,49,50,51,49,50,51,52,50,51,52,53,51,52,53,54,52,53,54,55,53,54,55,56,54,55,56,57,55,56,57,58,56,57,58,59,57,58,59,60,58,59,60,61,59,60,61,62,60,61,62,63,61,62,63,64,62,63,64,65,63,64,65,66,64,65,66,67,65,66,67,68,66,67,68,69,67,68,69,70,68,69,70,71,69,70,71,72,70,71,72,73,71,72,73,74,72,73,74,75,73,74,75,76,74,75,76,77,75,76,77,78,76,77,78,79,77,78,79,80,78,79,80,81,79,80,81,82,80,81,82,83,81,82,83,84,82,83,84,85,83,84,85,86,84,85,86,87,85,86,87,88,86,87,88,89,87,88,89,90,88,89,90,91,89,90,91,92,90,91,92,93,91,92,93,94,92,93,94,95,93,94,95,96,94,95,96,97,95,96,97,98,96,97,98,99,97,98,99,100,98,99,100,101,99,100,101,102,100,101,102,103,101,102,103,104,102,103,104,105,103,104,105,106,104,105,106,107,105,106,107,108,106,107,108,109,107,108,109,110,108,109,110,111,109,110,111,112,110,111,112,113,111,112,113,114,112,113,114,115,113,114,115,116,114,115,116,117,115,116,117,118,116,117,118,119,117,118,119,120,118,119,120,121,119,120,121,122,120,121,122,123,121,122,123,124,122,123,124,125,123,124,125,126,124,125,126,127,125,126,127,128,126,127,128,129,127,128,129,130,128,129,130,131,129,130,131,132,130,131,132,133,131,132,133,134,132,133,134,135,133,134,135,136,134,135,136,137,135,136,137,138,136,137,138,139,137,138,139,140,138,139,140,141,139,140,141,142,140,141,142,143,141,142,143,144,142,143,144,145,143,144,145,146,144,145,146,147,145,146,147,148,146,147,148,149,147,148,149,150,148,149,150,151,149,150,151,152,150,151,152,153,151,152,153,154,152,153,154,155,153,154,155,156,154,155,156,157,155,156,157,158,156,157,158,159,157,158,159,160,158,159,160,161,159,160,161,162,160,161,162,163,161,162,163,164,162,163,164,165,163,164,165,166,164,165,166,167,165,166,167,168,166,167,168,169,167,168,169,170,168,169,170,171,169,170,171,172,170,171,172,173,171,172,173,174,172,173,174,175,173,174,175,176,174,175,176,177,175,176,177,178,176,177,178,179,177,178,179,180,178,179,180,181,179,180,181,182,180,181,182,183,181,182,183,184,182,183,184,185,183,184,185,186,184,185,186,187,185,186,187,188,186,187,188,189,187,188,189,190,188,189,190,191,189,190,191,192,190,191,192,193,191,192,193,194,192,193,194,195,193,194,195,196,194,195,196,197,195,196,197,198,196,197,198,199,197,198,199,200,198,199,200,201,199,200,201,202,200,201,202,203,201,202,203,204,202,203,204,205,203,204,205,206,204,205,206,207,205,206,207,208,206,207,208,209,207,208,209,210,208,209,210,211,209,210,211,212,210,211,212,213,211,212,213,214,212,213,214,215,213,214,215,216,214,215,216,217,215,216,217,218,216,217,218,219,217,218,219,220,218,219,220,221,219,220,221,222,220,221,222,223,221,222,223,224,222,223,224,225,223,224,225,226,224,225,226,227,225,226,227,228,226,227,228,229,227,228,229,230,228,229,230,231,229,230,231,232,230,231,232,233,231,232,233,234,232,233,234,235,233,234,235,236,234,235,236,237,235,236,237,238,236,237,238,239,237,238,239,240,238,239,240,241,239,240,241,242,240,241,242,243,241,242,243,244,242,243,244,245,243,244,245,246,244,245,246,247,245,246,247,248,246,247,248,249,247,248,249,250,248,249,250,251,249,250,251,252,250,251,252,253,251,252,253,254,252,253,254,255,253,254,255,256,254,255,256,257,255,256,257,258], "sample": [0,0,0,0]},
{"db": [0,1,2,3,1,2,3,4,2,3,4,5,3,4,5,6,4,5,6,7,5,6,7,8,6,7,8,9,7,8,9,10,8,9,10,11,9,10,11,12,10,11,12,13,11,12,13,14,12,13,14,15,13,14,15,16,14,15,16,17,15,16,17,18,16,17,18,19,17,18,19,20,18,19,20,21,19,20,21,22,20,21,22,23,21,22,23,24,22,23,24,25,23,24,25,26,24,25,26,27,25,26,27,28,26,27,28,29,27,28,29,30,28,29,30,31,29,30,31,32,30,31,32,33,31,32,33,34,32,33,34,35,33,34,35,36,34,35,36,37,35,36,37,38,36,37,38,39,37,38,39,40,38,39,40,41,39,40,41,42,40,41,42,43,41,42,43,44,42,43,44,45,43,44,45,46,44,45,46,47,45,46,47,48,46,47,48,49,47,48,49,50,48,49,50,51,49,50,51,52,50,51,52,53,51,52,53,54,52,53,54,55,53,54,55,56,54,55,56,57,55,56,57,58,56,57,58,59,57,58,59,60,58,59,60,61,59,60,61,62,60,61,62,63,61,62,63,64,62,63,64,65,63,64,65,66,64,65,66,67,65,66,67,68,66,67,68,69,67,68,69,70,68,69,70,71,69,70,71,72,70,71,72,73,71,72,73,74,72,73,74,75,73,74,75,76,74,75,76,77,75,76,77,78,76,77,78,79,77,78,79,80,78,79,80,81,79,80,81,82,80,81,82,83,81,82,83,84,82,83,84,85,83,84,85,86,84,85,86,87,85,86,87,88,86,87,88,89,87,88,89,90,88,89,90,91,89,90,91,92,90,91,92,93,91,92,93,94,92,93,94,95,93,94,95,96,94,95,96,97,95,96,97,98,96,97,98,99,97,98,99,100,98,99,100,101,99,100,101,102,100,101,102,103,101,102,103,104,102,103,104,105,103,104,105,106,104,105,106,107,105,106,107,108,106,107,108,109,107,108,109,110,108,109,110,111,109,110,111,112,110,111,112,113,111,112,113,114,112,113,114,115,113,114,115,116,114,115,116,117,115,116,117,118,116,117,118,119,117,118,119,120,118,119,120,121,119,120,121,122,120,121,122,123,121,122,123,124,122,123,124,125,123,124,125,126,124,125,126,127,125,126,127,128,126,127,128,129,127,128,129,130,128,129,130,131,129,130,131,132,130,131,132,133,131,132,133,134,132,133,134,135,133,134,135,136,134,135,136,137,135,136,137,138,136,137,138,139,137,138,139,140,138,139,140,141,139,140,141,142,140,141,142,143,141,142,143,144,142,143,144,145,143,144,145,146,144,145,146,147,145,146,147,148,146,147,148,149,147,148,149,150,148,149,150,151,149,150,151,152,150,151,152,153,151,152,153,154,152,153,154,155,153,154,155,156,154,155,156,157,155,156,157,158,156,157,158,159,157,158,159,160,158,159,160,161,159,160,161,162,160,161,162,163,161,162,163,164,162,163,164,165,163,164,165,166,164,165,166,167,165,166,167,168,166,167,168,169,167,168,169,170,168,169,170,171,169,170,171,172,170,171,172,173,171,172,173,174,172,173,174,175,173,174,175,176,174,175,176,177,175,176,177,178,176,177,178,179,177,178,179,180,178,179,180,181,179,180,181,182,180,181,182,183,181,182,183,184,182,183,184,185,183,184,185,186,184,185,186,187,185,186,187,188,186,187,188,189,187,188,189,190,188,189,190,191,189,190,191,192,190,191,192,193,191,192,193,194,192,193,194,195,193,194,195,196,194,195,196,197,195,196,197,198,196,197,198,199,197,198,199,200,198,199,200,201,199,200,201,202,200,201,202,203,201,202,203,204,202,203,204,205,203,204,205,206,204,205,206,207,205,206,207,208,206,207,208,209,207,208,209,210,208,209,210,211,209,210,211,212,210,211,212,213,211,212,213,214,212,213,214,215,213,214,215,216,214,215,216,217,215,216,217,218,216,217,218,219,217,218,219,220,218,219,220,221,219,220,221,222,220,221,222,223,221,222,223,224,222,223,224,225,223,224,225,226,224,225,226,227,225,226,227,228,226,227,228,229,227,228,229,230,228,229,230,231,229,230,231,232,230,231,232,233,231,232,233,234,232,233,234,235,233,234,235,236,234,235,236,237,235,236,237,238,236,237,238,239,237,238,239,240,238,239,240,241,239,240,241,242,240,241,242,243,241,242,243,244,242,243,244,245,243,244,245,246,244,245,246,247,245,246,247,248,246,247,248,249,247,248,249,250,248,249,250,251,249,250,251,252,250,251,252,253,251,252,253,254,252,253,254,255,253,254,255,256,254,255,256,257,255,256,257,258], "sample": [0,0,0,0]}
],
[
"biomatch - 2",
0,
"./third_party/ABY/build/bin/2pc_biomatch",
ABY_SOURCE+"/build/bin/2pc_biomatch",
{"db": [0,1,2,3,1,2,3,4,2,3,4,5,3,4,5,6,4,5,6,7,5,6,7,8,6,7,8,9,7,8,9,10,8,9,10,11,9,10,11,12,10,11,12,13,11,12,13,14,12,13,14,15,13,14,15,16,14,15,16,17,15,16,17,18,16,17,18,19,17,18,19,20,18,19,20,21,19,20,21,22,20,21,22,23,21,22,23,24,22,23,24,25,23,24,25,26,24,25,26,27,25,26,27,28,26,27,28,29,27,28,29,30,28,29,30,31,29,30,31,32,30,31,32,33,31,32,33,34,32,33,34,35,33,34,35,36,34,35,36,37,35,36,37,38,36,37,38,39,37,38,39,40,38,39,40,41,39,40,41,42,40,41,42,43,41,42,43,44,42,43,44,45,43,44,45,46,44,45,46,47,45,46,47,48,46,47,48,49,47,48,49,50,48,49,50,51,49,50,51,52,50,51,52,53,51,52,53,54,52,53,54,55,53,54,55,56,54,55,56,57,55,56,57,58,56,57,58,59,57,58,59,60,58,59,60,61,59,60,61,62,60,61,62,63,61,62,63,64,62,63,64,65,63,64,65,66,64,65,66,67,65,66,67,68,66,67,68,69,67,68,69,70,68,69,70,71,69,70,71,72,70,71,72,73,71,72,73,74,72,73,74,75,73,74,75,76,74,75,76,77,75,76,77,78,76,77,78,79,77,78,79,80,78,79,80,81,79,80,81,82,80,81,82,83,81,82,83,84,82,83,84,85,83,84,85,86,84,85,86,87,85,86,87,88,86,87,88,89,87,88,89,90,88,89,90,91,89,90,91,92,90,91,92,93,91,92,93,94,92,93,94,95,93,94,95,96,94,95,96,97,95,96,97,98,96,97,98,99,97,98,99,100,98,99,100,101,99,100,101,102,100,101,102,103,101,102,103,104,102,103,104,105,103,104,105,106,104,105,106,107,105,106,107,108,106,107,108,109,107,108,109,110,108,109,110,111,109,110,111,112,110,111,112,113,111,112,113,114,112,113,114,115,113,114,115,116,114,115,116,117,115,116,117,118,116,117,118,119,117,118,119,120,118,119,120,121,119,120,121,122,120,121,122,123,121,122,123,124,122,123,124,125,123,124,125,126,124,125,126,127,125,126,127,128,126,127,128,129,127,128,129,130,128,129,130,131,129,130,131,132,130,131,132,133,131,132,133,134,132,133,134,135,133,134,135,136,134,135,136,137,135,136,137,138,136,137,138,139,137,138,139,140,138,139,140,141,139,140,141,142,140,141,142,143,141,142,143,144,142,143,144,145,143,144,145,146,144,145,146,147,145,146,147,148,146,147,148,149,147,148,149,150,148,149,150,151,149,150,151,152,150,151,152,153,151,152,153,154,152,153,154,155,153,154,155,156,154,155,156,157,155,156,157,158,156,157,158,159,157,158,159,160,158,159,160,161,159,160,161,162,160,161,162,163,161,162,163,164,162,163,164,165,163,164,165,166,164,165,166,167,165,166,167,168,166,167,168,169,167,168,169,170,168,169,170,171,169,170,171,172,170,171,172,173,171,172,173,174,172,173,174,175,173,174,175,176,174,175,176,177,175,176,177,178,176,177,178,179,177,178,179,180,178,179,180,181,179,180,181,182,180,181,182,183,181,182,183,184,182,183,184,185,183,184,185,186,184,185,186,187,185,186,187,188,186,187,188,189,187,188,189,190,188,189,190,191,189,190,191,192,190,191,192,193,191,192,193,194,192,193,194,195,193,194,195,196,194,195,196,197,195,196,197,198,196,197,198,199,197,198,199,200,198,199,200,201,199,200,201,202,200,201,202,203,201,202,203,204,202,203,204,205,203,204,205,206,204,205,206,207,205,206,207,208,206,207,208,209,207,208,209,210,208,209,210,211,209,210,211,212,210,211,212,213,211,212,213,214,212,213,214,215,213,214,215,216,214,215,216,217,215,216,217,218,216,217,218,219,217,218,219,220,218,219,220,221,219,220,221,222,220,221,222,223,221,222,223,224,222,223,224,225,223,224,225,226,224,225,226,227,225,226,227,228,226,227,228,229,227,228,229,230,228,229,230,231,229,230,231,232,230,231,232,233,231,232,233,234,232,233,234,235,233,234,235,236,234,235,236,237,235,236,237,238,236,237,238,239,237,238,239,240,238,239,240,241,239,240,241,242,240,241,242,243,241,242,243,244,242,243,244,245,243,244,245,246,244,245,246,247,245,246,247,248,246,247,248,249,247,248,249,250,248,249,250,251,249,250,251,252,250,251,252,253,251,252,253,254,252,253,254,255,253,254,255,256,254,255,256,257,255,256,257,258], "sample": [0,0,0,0]},
{"db": [0,1,2,3,1,2,3,4,2,3,4,5,3,4,5,6,4,5,6,7,5,6,7,8,6,7,8,9,7,8,9,10,8,9,10,11,9,10,11,12,10,11,12,13,11,12,13,14,12,13,14,15,13,14,15,16,14,15,16,17,15,16,17,18,16,17,18,19,17,18,19,20,18,19,20,21,19,20,21,22,20,21,22,23,21,22,23,24,22,23,24,25,23,24,25,26,24,25,26,27,25,26,27,28,26,27,28,29,27,28,29,30,28,29,30,31,29,30,31,32,30,31,32,33,31,32,33,34,32,33,34,35,33,34,35,36,34,35,36,37,35,36,37,38,36,37,38,39,37,38,39,40,38,39,40,41,39,40,41,42,40,41,42,43,41,42,43,44,42,43,44,45,43,44,45,46,44,45,46,47,45,46,47,48,46,47,48,49,47,48,49,50,48,49,50,51,49,50,51,52,50,51,52,53,51,52,53,54,52,53,54,55,53,54,55,56,54,55,56,57,55,56,57,58,56,57,58,59,57,58,59,60,58,59,60,61,59,60,61,62,60,61,62,63,61,62,63,64,62,63,64,65,63,64,65,66,64,65,66,67,65,66,67,68,66,67,68,69,67,68,69,70,68,69,70,71,69,70,71,72,70,71,72,73,71,72,73,74,72,73,74,75,73,74,75,76,74,75,76,77,75,76,77,78,76,77,78,79,77,78,79,80,78,79,80,81,79,80,81,82,80,81,82,83,81,82,83,84,82,83,84,85,83,84,85,86,84,85,86,87,85,86,87,88,86,87,88,89,87,88,89,90,88,89,90,91,89,90,91,92,90,91,92,93,91,92,93,94,92,93,94,95,93,94,95,96,94,95,96,97,95,96,97,98,96,97,98,99,97,98,99,100,98,99,100,101,99,100,101,102,100,101,102,103,101,102,103,104,102,103,104,105,103,104,105,106,104,105,106,107,105,106,107,108,106,107,108,109,107,108,109,110,108,109,110,111,109,110,111,112,110,111,112,113,111,112,113,114,112,113,114,115,113,114,115,116,114,115,116,117,115,116,117,118,116,117,118,119,117,118,119,120,118,119,120,121,119,120,121,122,120,121,122,123,121,122,123,124,122,123,124,125,123,124,125,126,124,125,126,127,125,126,127,128,126,127,128,129,127,128,129,130,128,129,130,131,129,130,131,132,130,131,132,133,131,132,133,134,132,133,134,135,133,134,135,136,134,135,136,137,135,136,137,138,136,137,138,139,137,138,139,140,138,139,140,141,139,140,141,142,140,141,142,143,141,142,143,144,142,143,144,145,143,144,145,146,144,145,146,147,145,146,147,148,146,147,148,149,147,148,149,150,148,149,150,151,149,150,151,152,150,151,152,153,151,152,153,154,152,153,154,155,153,154,155,156,154,155,156,157,155,156,157,158,156,157,158,159,157,158,159,160,158,159,160,161,159,160,161,162,160,161,162,163,161,162,163,164,162,163,164,165,163,164,165,166,164,165,166,167,165,166,167,168,166,167,168,169,167,168,169,170,168,169,170,171,169,170,171,172,170,171,172,173,171,172,173,174,172,173,174,175,173,174,175,176,174,175,176,177,175,176,177,178,176,177,178,179,177,178,179,180,178,179,180,181,179,180,181,182,180,181,182,183,181,182,183,184,182,183,184,185,183,184,185,186,184,185,186,187,185,186,187,188,186,187,188,189,187,188,189,190,188,189,190,191,189,190,191,192,190,191,192,193,191,192,193,194,192,193,194,195,193,194,195,196,194,195,196,197,195,196,197,198,196,197,198,199,197,198,199,200,198,199,200,201,199,200,201,202,200,201,202,203,201,202,203,204,202,203,204,205,203,204,205,206,204,205,206,207,205,206,207,208,206,207,208,209,207,208,209,210,208,209,210,211,209,210,211,212,210,211,212,213,211,212,213,214,212,213,214,215,213,214,215,216,214,215,216,217,215,216,217,218,216,217,218,219,217,218,219,220,218,219,220,221,219,220,221,222,220,221,222,223,221,222,223,224,222,223,224,225,223,224,225,226,224,225,226,227,225,226,227,228,226,227,228,229,227,228,229,230,228,229,230,231,229,230,231,232,230,231,232,233,231,232,233,234,232,233,234,235,233,234,235,236,234,235,236,237,235,236,237,238,236,237,238,239,237,238,239,240,238,239,240,241,239,240,241,242,240,241,242,243,241,242,243,244,242,243,244,245,243,244,245,246,244,245,246,247,245,246,247,248,246,247,248,249,247,248,249,250,248,249,250,251,249,250,251,252,250,251,252,253,251,252,253,254,252,253,254,255,253,254,255,256,254,255,256,257,255,256,257,258], "sample": [1,2,3,4]}
],
@@ -712,63 +715,63 @@ ilp_benchmark_tests = [
[
"ilp bench - array sum 1",
1000,
"./third_party/ABY/build/bin/2pc_ilp_bench_1",
ABY_SOURCE+"/build/bin/2pc_ilp_bench_1",
{"a": 2, "b": 0},
{"a": 0, "b": 1},
],
[
"ilp bench - array sum 2",
2000,
"./third_party/ABY/build/bin/2pc_ilp_bench_2",
ABY_SOURCE+"/build/bin/2pc_ilp_bench_2",
{"a": 2, "b": 0},
{"a": 0, "b": 1},
],
[
"ilp bench - array sum 3",
3000,
"./third_party/ABY/build/bin/2pc_ilp_bench_3",
ABY_SOURCE+"/build/bin/2pc_ilp_bench_3",
{"a": 2, "b": 0},
{"a": 0, "b": 1},
],
[
"ilp bench - array sum 4",
4000,
"./third_party/ABY/build/bin/2pc_ilp_bench_4",
ABY_SOURCE+"/build/bin/2pc_ilp_bench_4",
{"a": 2, "b": 0},
{"a": 0, "b": 1},
],
[
"ilp bench - array sum 5",
5000,
"./third_party/ABY/build/bin/2pc_ilp_bench_5",
ABY_SOURCE+"/build/bin/2pc_ilp_bench_5",
{"a": 2, "b": 0},
{"a": 0, "b": 1},
],
[
"ilp bench - array sum 6",
6000,
"./third_party/ABY/build/bin/2pc_ilp_bench_6",
ABY_SOURCE+"/build/bin/2pc_ilp_bench_6",
{"a": 2, "b": 0},
{"a": 0, "b": 1},
],
[
"ilp bench - array sum 7",
7000,
"./third_party/ABY/build/bin/2pc_ilp_bench_7",
ABY_SOURCE+"/build/bin/2pc_ilp_bench_7",
{"a": 2, "b": 0},
{"a": 0, "b": 1},
],
[
"ilp bench - array sum 8",
8000,
"./third_party/ABY/build/bin/2pc_ilp_bench_8",
ABY_SOURCE+"/build/bin/2pc_ilp_bench_8",
{"a": 2, "b": 0},
{"a": 0, "b": 1},
],
[
"ilp bench - array sum 9",
9000,
"./third_party/ABY/build/bin/2pc_ilp_bench_9",
ABY_SOURCE+"/build/bin/2pc_ilp_bench_9",
{"a": 2, "b": 0},
{"a": 0, "b": 1},
],
@@ -779,7 +782,7 @@ millionaires_test = [
[
"Millionaire's problem",
0,
"./third_party/ABY/build/bin/2pc_millionaires",
ABY_SOURCE+"/build/bin/2pc_millionaires",
{"a": 2, "b": 0},
{"a": 0, "b": 1},
],
@@ -789,7 +792,7 @@ millionaires_test = [
# [
# "Array sum test 2",
# 6,
# "./third_party/ABY/build/bin/2pc_array_sum_2",
# ABY_SOURCE+"/build/bin/2pc_array_sum_2",
# {"a": 2, "b": 0},
# {"a": 0, "b": 1},
# ],

View File

@@ -1,6 +1,10 @@
#!/usr/bin/env zsh
mkdir -p -- third_party/ABY/build
cd third_party/ABY/build
cmake .. -DABY_BUILD_EXE=On
make
if [[ ! -z ${ABY_SOURCE} ]]; then
mkdir -p -- ${ABY_SOURCE}/build
cd ${ABY_SOURCE}/build
cmake .. -DABY_BUILD_EXE=On
make
else
echo "Missing ABY_SOURCE environment variable."
fi

View File

@@ -4,7 +4,7 @@ set -ex
disable -r time
cargo build --release --example circ
# cargo build --release --features c --example circ
BIN=./target/release/examples/circ
export CARGO_MANIFEST_DIR=$(pwd)
@@ -85,8 +85,6 @@ mpc_test 2 ./examples/C/mpc/unit_tests/function_tests/2pc_function_add.c
# # mpc_test 2 ./examples/C/mpc/unit_tests/shift_tests/2pc_lhs.c
# # mpc_test 2 ./examples/C/mpc/unit_tests/shift_tests/2pc_rhs.c
# # benchmarks
# # mpc_test 2 ./examples/C/mpc/benchmarks/2pc_kmeans.c
# # mpc_test 2 ./examples/C/mpc/benchmarks/2pc_biomatch.c

View File

@@ -4,7 +4,7 @@ set -ex
disable -r time
cargo build --release --example circ
# cargo build --release --features smt,zok --example circ
BIN=./target/release/examples/circ
export CARGO_MANIFEST_DIR=$(pwd)
@@ -60,16 +60,16 @@ mpc_test 2 ./examples/ZoKrates/mpc/unit_tests/const_tests/2pc_const_bool.zok
mpc_test 2 ./examples/ZoKrates/mpc/unit_tests/ite_tests/2pc_ite_ret_bool.zok
mpc_test 2 ./examples/ZoKrates/mpc/unit_tests/ite_tests/2pc_ite_ret_int.zok
# build mpc array tests
# mpc_test 2 ./examples/ZoKrates/mpc/unit_tests/array_tests/2pc_array_sum.zok
# mpc_test 2 ./examples/ZoKrates/mpc/unit_tests/array_tests/2pc_array_ret.zok
# build mps loop tests
mpc_test 2 ./examples/ZoKrates/mpc/unit_tests/loop_tests/2pc_loop_sum.zok
# build mpc function tests
mpc_test 2 ./examples/ZoKrates/mpc/unit_tests/function_tests/2pc_function_add.zok
# build mpc array tests
# mpc_test 2 ./examples/ZoKrates/mpc/unit_tests/array_tests/2pc_array_sum.zok
# mpc_test 2 ./examples/ZoKrates/mpc/unit_tests/array_tests/2pc_array_ret.zok
# build mpc shift tests
# mpc_test 2 ./examples/ZoKrates/mpc/unit_tests/shift_tests/2pc_lhs.zok
# mpc_test 2 ./examples/ZoKrates/mpc/unit_tests/shift_tests/2pc_rhs.zok

View File

@@ -4,7 +4,7 @@ set -ex
disable -r time
cargo build --release --example circ
# cargo build --release --example circ
BIN=./target/release/examples/circ

9
scripts/clean_aby.zsh Executable file
View File

@@ -0,0 +1,9 @@
#!/usr/bin/env zsh
if [[ ! -z ${ABY_SOURCE} ]]; then
rm -rf ${ABY_SOURCE}/build
rm -rf ${ABY_SOURCE}/src/examples/2pc_*
sed '/add_subdirectory.*2pc.*/d' -i ${ABY_SOURCE}/src/examples/CMakeLists.txt
else
echo "Missing ABY_SOURCE environment variable."
fi

View File

@@ -4,8 +4,6 @@ set -ex
disable -r time
cargo build --example circ
BIN=./target/debug/examples/circ
$BIN --language datalog ./examples/datalog/parse_test/one_rule.pl r1cs --action count || true

View File

@@ -4,7 +4,7 @@ set -ex
disable -r time
cargo build --release --example circ
# cargo build --release --features lp,smt,zok --example circ
BIN=./target/release/examples/circ

View File

@@ -4,7 +4,7 @@ set -ex
disable -r time
cargo build --release --example circ
# cargo build --release --features lp,r1cs,smt,zok --example circ
BIN=./target/release/examples/circ
@@ -12,7 +12,7 @@ function ilp_test {
zpath=$1
expected_max=$2
# writes to assignment.txt
max=$($BIN $zpath ilp | grep 'Max va' | awk '{ print $3 }')
max=$($BIN $zpath ilp | grep 'Max va' | awk '{ print $3 }')
if [[ $max == $expected_max ]]
then
$BIN --value-threshold $max $zpath r1cs --action setup

View File

@@ -4,8 +4,8 @@ set -ex
disable -r time
cargo build --release --example circ
#cargo build --example circ
# cargo build --release --features r1cs,smt,zok --example circ
# cargo build --example circ
#BIN=./target/debug/examples/circ
BIN=./target/release/examples/circ

View File

@@ -123,8 +123,7 @@ impl MemManager {
alloc.size
}
}
#[cfg(test)]
#[cfg(all(feature = "smt", feature = "test", feature = "zok"))]
mod test {
use super::*;
use crate::target::smt::check_sat;
@@ -134,7 +133,7 @@ mod test {
fn bv_var(s: &str, w: usize) -> Term {
leaf_term(Op::Var(s.to_owned(), Sort::BitVector(w)))
}
#[test]
fn sat_test() {
let cs = Rc::new(RefCell::new(Computation::new(false)));
let mut mem = MemManager::default();
@@ -157,7 +156,6 @@ mod test {
assert!(check_sat(&sys))
}
#[test]
fn unsat_test() {
let cs = Rc::new(RefCell::new(Computation::new(false)));
let mut mem = MemManager::default();

View File

@@ -10,7 +10,7 @@ use log::debug;
use rug::Integer;
use crate::circify::{Circify, Loc, Val};
use crate::front::zsharp::{PROVER_VIS, PUBLIC_VIS};
use crate::front::{PROVER_VIS, PUBLIC_VIS};
use crate::ir::opt::cfold::fold;
use crate::ir::term::extras::as_uint_constant;
use crate::ir::term::*;

View File

@@ -9,7 +9,7 @@ use super::error::ErrorKind;
use super::ty::Ty;
use crate::circify::{CirCtx, Embeddable};
use crate::front::zsharp::{ZSHARP_FIELD_SORT, ZSHARP_MODULUS_ARC};
use crate::front::{ZSHARP_FIELD_SORT, ZSHARP_MODULUS_ARC};
use crate::ir::term::*;
/// A term

View File

@@ -1,11 +1,57 @@
//! Input language front-ends
#[cfg(feature = "c")]
pub mod c;
pub mod datalog;
#[cfg(all(feature = "smt", feature = "zok"))]
pub mod zsharp;
use crate::ir::{
proof,
term::{PartyId, Sort},
};
use super::ir::term::Computation;
use std::fmt::{self, Display, Formatter};
use lazy_static::lazy_static;
use rug::Integer;
use std::{
fmt::{self, Display, Formatter},
sync::Arc,
};
/// The prover visibility
pub const PROVER_VIS: Option<PartyId> = Some(proof::PROVER_ID);
/// Public visibility
pub const PUBLIC_VIS: Option<PartyId> = None;
// The modulus for Z#.
// TODO: handle this better!
#[cfg(feature = "bls12381")]
lazy_static! {
/// The modulus for Z#
pub static ref ZSHARP_MODULUS: Integer = Integer::from_str_radix(
"52435875175126190479447740508185965837690552500527637822603658699938581184513", // BLS12-381 group order
10
)
.unwrap();
}
#[cfg(not(feature = "bls12381"))]
lazy_static! {
/// The modulus for Z#
pub static ref ZSHARP_MODULUS: Integer = Integer::from_str_radix(
"21888242871839275222246405745257275088548364400416034343698204186575808495617", // BN-254 group order
10
)
.unwrap();
}
lazy_static! {
/// The modulus for Z#, as an ARC
pub static ref ZSHARP_MODULUS_ARC: Arc<Integer> = Arc::new(ZSHARP_MODULUS.clone());
/// The modulus for Z#, as an IR sort
pub static ref ZSHARP_FIELD_SORT: Sort = Sort::Field(ZSHARP_MODULUS_ARC.clone());
}
/// A front-end
pub trait FrontEnd {

View File

@@ -6,7 +6,9 @@ pub mod zvisit;
use super::{FrontEnd, Mode};
use crate::circify::{CircError, Circify, Loc, Val};
use crate::ir::proof::{self, ConstraintMetadata};
use crate::front::ZSHARP_MODULUS;
use crate::front::{PROVER_VIS, PUBLIC_VIS};
use crate::ir::proof::ConstraintMetadata;
use crate::ir::term::*;
use log::{debug, warn};
use rug::Integer;
@@ -20,21 +22,9 @@ use zokrates_pest_ast as ast;
use term::*;
use zvisit::{ZConstLiteralRewriter, ZGenericInf, ZStatementWalker, ZVisitorMut};
/// The modulus for the Z# language as a Sort
pub use term::ZSHARP_FIELD_SORT;
/// The modulus for the ZSharp language
pub use term::ZSHARP_MODULUS;
/// The modulus for the ZSharp language (ARC)
pub use term::ZSHARP_MODULUS_ARC;
// garbage collection increment for adaptive GC threshold
const GC_INC: usize = 32;
/// The prover visibility
pub const PROVER_VIS: Option<PartyId> = Some(proof::PROVER_ID);
/// Public visibility
pub const PUBLIC_VIS: Option<PartyId> = None;
/// Inputs to the Z# compiler
pub struct Inputs {
/// The file to look for `main` in.

View File

@@ -3,7 +3,10 @@ use std::collections::{BTreeMap, HashMap};
use std::fmt::{self, Display, Formatter};
use std::sync::Arc;
use lazy_static::lazy_static;
use crate::front::ZSHARP_FIELD_SORT;
use crate::front::ZSHARP_MODULUS;
use crate::front::ZSHARP_MODULUS_ARC;
use log::warn;
use rug::Integer;
@@ -11,35 +14,6 @@ use crate::circify::{CirCtx, Embeddable};
use crate::ir::opt::cfold::fold as constant_fold;
use crate::ir::term::*;
// The modulus for Z#.
// TODO: handle this better!
#[cfg(feature = "bls12381")]
lazy_static! {
/// The modulus for Z#
pub static ref ZSHARP_MODULUS: Integer = Integer::from_str_radix(
"52435875175126190479447740508185965837690552500527637822603658699938581184513", // BLS12-381 group order
10
)
.unwrap();
}
#[cfg(not(feature = "bls12381"))]
lazy_static! {
/// The modulus for Z#
pub static ref ZSHARP_MODULUS: Integer = Integer::from_str_radix(
"21888242871839275222246405745257275088548364400416034343698204186575808495617", // BN-254 group order
10
)
.unwrap();
}
lazy_static! {
/// The modulus for Z#, as an ARC
pub static ref ZSHARP_MODULUS_ARC: Arc<Integer> = Arc::new(ZSHARP_MODULUS.clone());
/// The modulus for Z#, as an IR sort
pub static ref ZSHARP_FIELD_SORT: Sort = Sort::Field(ZSHARP_MODULUS_ARC.clone());
}
#[derive(Clone, PartialEq, Eq)]
pub enum Ty {
Uint(usize),

View File

@@ -3,6 +3,7 @@
use super::super::term::{cond, const_val, Ty, T};
use super::super::{span_to_string, ZGen};
use crate::ir::term::{bv_lit, leaf_term, term, BoolNaryOp, Op, Sort, Term, Value};
#[cfg(feature = "smt")]
use crate::target::smt::find_unique_model;
use lazy_static::lazy_static;

View File

@@ -238,8 +238,7 @@ pub fn fold_cache(node: &Term, cache: &mut TermCache<Term>) -> Term {
t.cs.iter()
.map(|c| c_get(c).as_bv_opt().cloned())
.collect::<Option<Vec<_>>>()
.map(|v| v.into_iter().reduce(BitVector::concat))
.flatten()
.and_then(|v| v.into_iter().reduce(BitVector::concat))
.map(|bv| leaf_term(Op::Const(Value::BitVector(bv))))
}
Op::BoolToBv => get(0).as_bool_opt().map(|b| {

View File

@@ -186,7 +186,7 @@ pub fn inline(assertions: &mut Vec<Term>, public_inputs: &FxHashSet<String>) {
*assertions = new_assertions;
}
#[cfg(test)]
#[cfg(all(feature = "smt", feature = "test"))]
mod test {
use super::*;
use crate::target::smt::{check_sat, find_model};

View File

@@ -2,6 +2,7 @@
use crate::ir::term::{BvNaryOp, Computation, Op, PostOrderIter, TermMap};
#[cfg(feature = "lp")]
pub mod ilp;
/// The sharing scheme used for an operation
@@ -18,6 +19,7 @@ pub enum ShareType {
/// List of share types.
pub const SHARE_TYPES: [ShareType; 3] = [ShareType::Arithmetic, ShareType::Boolean, ShareType::Yao];
#[cfg(feature = "lp")]
impl ShareType {
fn char(&self) -> char {
match self {
@@ -42,7 +44,7 @@ pub fn all_boolean_sharing(c: &Computation) -> SharingMap {
}
/// Assigns arithmetic sharing to addition and multiplication
pub fn some_arith_sharing(c: &Computation) -> SharingMap {
pub fn some_arith_sharing(c: &Computation, _cm: &str) -> SharingMap {
c.outputs
.iter()
.flat_map(|output| {

View File

@@ -1,5 +1,6 @@
//! Utility functions to write compiler output to ABY
use crate::target::aby::utils::get_aby_source;
use std::fs;
use std::fs::{File, OpenOptions};
use std::io::{prelude::*, BufRead, BufReader};
@@ -7,7 +8,7 @@ use std::path::Path;
/// Given Path `path`, return the filename of the path
fn get_filename(path: &Path) -> String {
Path::new(&path.iter().last().unwrap().to_os_string())
Path::new(&path.iter().last().unwrap())
.file_stem()
.unwrap()
.to_os_string()
@@ -15,17 +16,25 @@ fn get_filename(path: &Path) -> String {
.unwrap()
}
/// In ABY examples, remove the existing directory and create a directory
/// in order to write the new test case
/// Given Path `path` and &str `content`, check if the file contents match
fn check_file_contents_match(path: &str, content: &str) -> bool {
if !Path::new(path).exists() {
false
} else {
let old_content = fs::read_to_string(path).expect("Failed to read file");
old_content.trim() == content.trim()
}
}
/// Create a new directory to write ABY test case
fn create_dir_in_aby(filename: &str) {
let path = format!("third_party/ABY/src/examples/{}", filename);
let _ = fs::remove_dir_all(&path);
let path = format!("{}/src/examples/{}", get_aby_source(), filename);
fs::create_dir_all(format!("{}/common", path)).expect("Failed to create directory");
}
/// Update the CMake file in ABY
fn update_cmake_file(filename: &str) {
let cmake_filename = "third_party/ABY/src/examples/CMakeLists.txt";
let cmake_filename = format!("{}/src/examples/CMakeLists.txt", get_aby_source());
let file = File::open(&cmake_filename).expect("Failed to open cmake file");
let reader = BufReader::new(file);
let mut flag = false;
@@ -51,19 +60,23 @@ fn update_cmake_file(filename: &str) {
/// Create a CMake file for the corresponding filename (testcase)
/// in the ABY examples directory
fn write_test_cmake_file(filename: &str) {
let path = format!("third_party/ABY/src/examples/{}/CMakeLists.txt", filename);
let path = format!(
"{}/src/examples/{}/CMakeLists.txt",
get_aby_source(),
filename
);
fs::write(
&path,
format!(
concat!(
"add_executable({}_test {}_test.cpp common/{}.cpp)\n",
"target_link_libraries({}_test ABY::aby ENCRYPTO_utils::encrypto_utils)"
),
filename, filename, filename, filename
let content = format!(
concat!(
"add_executable({}_test {}_test.cpp common/{}.cpp)\n",
"target_link_libraries({}_test ABY::aby ENCRYPTO_utils::encrypto_utils)"
),
)
.expect("Failed to write to cmake file");
filename, filename, filename, filename
);
if !check_file_contents_match(&path, &content) {
fs::write(&path, content).expect("Failed to write to cmake file");
}
}
/// Write the testcase in the ABY examples directory
@@ -71,11 +84,17 @@ fn write_test_file(filename: &str) {
let template = fs::read_to_string("third_party/ABY_templates/test_template.txt")
.expect("Unable to read file");
let path = format!(
"third_party/ABY/src/examples/{}/{}_test.cpp",
filename, filename
"{}/src/examples/{}/{}_test.cpp",
get_aby_source(),
filename,
filename
);
fs::write(&path, template.replace("{fn}", filename)).expect("Failed to write to test file");
let content = template.replace("{fn}", filename);
if !check_file_contents_match(&path, &content) {
fs::write(&path, content).expect("Failed to write to test file");
}
}
/// Using the h_template.txt, write the .h file for the new test case
@@ -83,45 +102,61 @@ fn write_h_file(filename: &str) {
let template = fs::read_to_string("third_party/ABY_templates/h_template.txt")
.expect("Unable to read file");
let path = format!(
"third_party/ABY/src/examples/{}/common/{}.h",
filename, filename
"{}/src/examples/{}/common/{}.h",
get_aby_source(),
filename,
filename
);
fs::write(&path, template.replace("{fn}", &*filename)).expect("Failed to write to h file");
let content = template.replace("{fn}", filename);
if !check_file_contents_match(&path, &content) {
fs::write(&path, content).expect("Failed to write to h file");
}
}
/// Using the cpp_template.txt, write the .cpp file for the new test case
fn write_circ_file(filename: &str) {
let setup_file_path = format!("third_party/ABY/src/examples/{}_setup_tmp.txt", filename);
let setup_file_path = format!(
"{}/src/examples/{}_setup_tmp.txt",
get_aby_source(),
filename
);
let mut setup_file = File::open(setup_file_path).expect("Unable to open the file");
let mut setup = String::new();
setup_file
.read_to_string(&mut setup)
.expect("Unable to read the file");
let circuit_file_path = format!("third_party/ABY/src/examples/{}_circuit_tmp.txt", filename);
let circuit_file_path = format!(
"{}/src/examples/{}_circuit_tmp.txt",
get_aby_source(),
filename
);
let mut circuit_file = File::open(circuit_file_path).expect("Unable to open the file");
let mut circuit = String::new();
circuit_file
.read_to_string(&mut circuit)
.expect("Unable to read the file");
let content = format!("{}\n{}", setup, circuit);
let complete_circuit = format!("{}\n{}", setup, circuit);
let template = fs::read_to_string("third_party/ABY_templates/cpp_template.txt")
.expect("Unable to read file");
let path = format!(
"third_party/ABY/src/examples/{}/common/{}.cpp",
filename, filename
"{}/src/examples/{}/common/{}.cpp",
get_aby_source(),
filename,
filename
);
fs::write(
&path,
template
.replace("{fn}", &*filename)
.replace("{circ}", &content),
)
.expect("Failed to write to cpp file");
let content = template
.replace("{fn}", filename)
.replace("{circ}", &complete_circuit);
if !check_file_contents_match(&path, &content) {
fs::write(&path, content).expect("Failed to write to cpp file");
}
}
/// Write circuit output from translation later to ABY

View File

@@ -5,9 +5,13 @@
//! [Link to comment in EzPC Compiler](https://github.com/mpc-msri/EzPC/blob/da94a982709123c8186d27c9c93e27f243d85f0e/EzPC/EzPC/codegen.ml)
use crate::ir::term::*;
#[cfg(feature = "lp")]
use crate::target::aby::assignment::ilp::assign;
#[cfg(not(feature = "lp"))]
use crate::target::aby::assignment::some_arith_sharing;
use crate::target::aby::assignment::{ShareType, SharingMap};
use crate::target::aby::utils::*;
use log::debug;
use std::fmt;
use std::path::Path;
@@ -56,7 +60,7 @@ impl ToABY {
match &t.op {
Op::Var(name, _) => {
if b {
name.to_string().replace(".", "_")
name.to_string().replace('.', "_")
} else {
name.to_string()
}
@@ -300,7 +304,7 @@ impl ToABY {
if !self.cache.contains_key(&t) {
self.cache.insert(
t.clone(),
EmbeddedTerm::Bool(format!("s_{}", name.replace(".", "_"))),
EmbeddedTerm::Bool(format!("s_{}", name.replace('.', "_"))),
);
}
}
@@ -454,7 +458,7 @@ impl ToABY {
if !self.cache.contains_key(&t) {
self.cache.insert(
t.clone(),
EmbeddedTerm::Bv(format!("s_{}", name.replace(".", "_"))),
EmbeddedTerm::Bv(format!("s_{}", name.replace('.', "_"))),
);
}
}
@@ -465,7 +469,7 @@ impl ToABY {
"share* {} = {}->PutCONSGate((uint64_t){}, (uint32_t){});\n",
share,
s_circ,
format!("{}", b).replace("#", "0"),
format!("{}", b).replace('#', "0"),
b.width()
);
write_line_to_file(&self.circuit_fname, &s);
@@ -518,6 +522,7 @@ impl ToABY {
a_conv,
b_conv
);
write_line_to_file(&self.circuit_fname, &s);
self.cache.insert(t.clone(), EmbeddedTerm::Bv(share));
@@ -613,16 +618,15 @@ pub fn to_aby(ir: Computation, path: &Path, lang: &str, cm: &str) {
metadata: md,
values: _,
} = ir.clone();
for t in terms.clone() {
println!("terms: {}", t);
}
#[cfg(feature = "lp")]
let s_map: SharingMap = assign(&ir, cm);
// let s_map: SharingMap = some_arith_sharing(&ir);
#[cfg(not(feature = "lp"))]
let s_map: SharingMap = some_arith_sharing(&ir, cm);
let mut converter = ToABY::new(md, s_map, path, lang);
for t in terms {
println!("terms: {}", t);
debug!("terms: {}", t);
converter.lower(t.clone());
}

View File

@@ -1,12 +1,22 @@
//! Utility functions to write compiler output to ABY
use std::env;
use std::fs;
use std::io::prelude::*;
use std::path::Path;
/// Get ABY source directory
pub fn get_aby_source() -> String {
let key = "ABY_SOURCE";
match env::var(key) {
Ok(val) => val,
Err(e) => panic!("Missing env variable: ABY_SOURCE, {}", e),
}
}
/// Given Path `path` and String denominator `lang`, return the filename of the path
pub fn get_path(path: &Path, lang: &str, t: &str) -> String {
let filename = Path::new(&path.iter().last().unwrap().to_os_string())
let filename = Path::new(&path.iter().last().unwrap())
.file_stem()
.unwrap()
.to_os_string()
@@ -16,7 +26,7 @@ pub fn get_path(path: &Path, lang: &str, t: &str) -> String {
let name = format!("{}_{}", filename, lang);
// TODO: clean
let path = format!("third_party/ABY/src/examples/{}_{}_tmp.txt", name, t);
let path = format!("{}/src/examples/{}_{}_tmp.txt", get_aby_source(), name, t);
if Path::new(&path).exists() {
fs::remove_file(&path).expect("Failed to remove old circuit_tmp file");

View File

@@ -7,8 +7,8 @@
use crate::ir::term::extras::Letified;
use crate::ir::term::*;
use crate::target::bitsize;
use crate::target::ilp::Ilp;
use crate::target::r1cs::trans::bitsize;
use good_lp::{variable, Expression};
use log::debug;

View File

@@ -1,8 +1,18 @@
//! Target circuit representations (and lowering passes)
#[cfg(feature = "lp")]
pub mod aby;
#[cfg(feature = "lp")]
pub mod ilp;
pub mod r1cs;
#[cfg(feature = "smt")]
pub mod smt;
/// Returns the number of bits needed to hold `n`.
pub fn bitsize(mut n: usize) -> usize {
let mut acc = 0;
while n > 0 {
n >>= 1;
acc += 1;
}
acc
}

View File

@@ -9,6 +9,7 @@ use std::fmt::Display;
use std::hash::Hash;
use std::rc::Rc;
#[cfg(feature = "r1cs")]
pub mod bellman;
pub mod opt;
pub mod trans;

View File

@@ -5,6 +5,7 @@
//! is a good intro to how this process works.
use crate::ir::term::extras::Letified;
use crate::ir::term::*;
use crate::target::bitsize;
use crate::target::r1cs::*;
use fxhash::{FxHashMap, FxHashSet};
@@ -927,16 +928,6 @@ pub fn to_r1cs(cs: Computation, modulus: Integer) -> R1cs<String> {
converter.r1cs
}
/// Returns the number of bits needed to hold `n`.
pub fn bitsize(mut n: usize) -> usize {
let mut acc = 0;
while n > 0 {
n >>= 1;
acc += 1;
}
acc
}
#[cfg(test)]
pub mod test {
use super::*;

1
third_party/ABY vendored

Submodule third_party/ABY deleted from 378b2048ea

View File

@@ -2,7 +2,7 @@
#include "../../../abycore/circuit/booleancircuits.h"
#include "../../../abycore/circuit/arithmeticcircuits.h"
#include "../../../abycore/circuit/circuit.h"
#include "../../../../../../EZPC/ezpc.h"
#include "../../../../../EZPC/ezpc.h"
#include "../../../abycore/sharing/sharing.h"

View File

@@ -389,5 +389,3 @@ share *read_share(Circuit *circ, e_role role, uint32_t bitlen,
share *rand_sh = role == SERVER ? circ->PutINGate(rand_val, bitlen, SERVER) : circ->PutDummyINGate(bitlen);
return circ->PutSUBGate(add_sh, rand_sh);
}
#endif

52
util.py Normal file
View File

@@ -0,0 +1,52 @@
import os
from os import path
# Gloable variables
feature_path = ".features.txt"
mode_path = ".mode.txt"
valid_features = {"aby", "c", "lp", "r1cs", "smt", "zok"}
cargo_features = {"c", "lp", "r1cs", "smt", "zok"}
# Environment variables
ABY_SOURCE="./../ABY"
EZPC_SOURCE="./../EZPC"
def set_env(features):
for f in features:
if f == 'aby':
if not os.getenv("ABY_SOURCE"):
os.environ["ABY_SOURCE"] = ABY_SOURCE
if not os.getenv("EZPC_SOURCE"):
os.environ["EZPC_SOURCE"] = EZPC_SOURCE
def save_mode(mode):
""" Save mode to file """
with open(mode_path, 'w') as f:
f.write(mode)
def load_mode():
""" Load mode from file """
if path.exists(mode_path):
with open(mode_path, 'r') as f:
return f.read().strip()
else:
return ""
def save_features(features):
""" Save features to file """
with open(feature_path, 'w') as f:
feature_str = "\n".join(features)
f.write(feature_str)
def load_features():
""" Load features from file """
if path.exists(feature_path):
with open(feature_path, 'r') as f:
features = f.read().splitlines()
return set(features)
else:
return set()
def filter_cargo_features(features):
""" Filter feature list to cargo-specific features """
return [" ".join([f for f in features if f in cargo_features])]