mirror of
https://github.com/circify/circ.git
synced 2026-04-21 03:00:54 -04:00
updated testing suite for both zok and c frontends
This commit is contained in:
Binary file not shown.
Binary file not shown.
20
scripts/aby_tests/c_test_aby.py
Executable file
20
scripts/aby_tests/c_test_aby.py
Executable file
@@ -0,0 +1,20 @@
|
||||
from utils import run_tests
|
||||
from test_suite import *
|
||||
|
||||
if __name__ == "__main__":
|
||||
tests = arithmetic_tests + \
|
||||
arithmetic_boolean_tests + \
|
||||
nary_arithmetic_tests + \
|
||||
bitwise_tests + \
|
||||
boolean_tests + \
|
||||
nary_boolean_tests + \
|
||||
const_arith_tests + \
|
||||
const_bool_tests # + \
|
||||
# loop_tests + \
|
||||
# ite_tests + \
|
||||
# function_tests + \
|
||||
# shift_tests + \
|
||||
# misc_tests
|
||||
# arr_tests + \
|
||||
|
||||
run_tests('c', tests)
|
||||
@@ -2,49 +2,49 @@ arithmetic_tests = [
|
||||
[
|
||||
"Add two numbers - 1",
|
||||
3,
|
||||
"./third_party/ABY/build/bin/2pc_add_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_add",
|
||||
{"a": 1, "b": 0},
|
||||
{"a": 0, "b": 2},
|
||||
],
|
||||
[
|
||||
"Add two numbers - 2",
|
||||
2,
|
||||
"./third_party/ABY/build/bin/2pc_add_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_add",
|
||||
{"a": 0, "b": 0},
|
||||
{"a": 0, "b": 2},
|
||||
],
|
||||
[
|
||||
"Subtract two numbers",
|
||||
1,
|
||||
"./third_party/ABY/build/bin/2pc_sub_zok_test",
|
||||
"./third_party/ABY/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_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_sub",
|
||||
{"a": 2, "b": 0},
|
||||
{"a": 0, "b": 3},
|
||||
],
|
||||
[
|
||||
"Multiply two numbers - 1",
|
||||
0,
|
||||
"./third_party/ABY/build/bin/2pc_mult_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_mult",
|
||||
{"a": 0, "b": 0},
|
||||
{"a": 0, "b": 5},
|
||||
],
|
||||
[
|
||||
"Multiply two numbers - 2",
|
||||
5,
|
||||
"./third_party/ABY/build/bin/2pc_mult_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_mult",
|
||||
{"a": 1, "b": 0},
|
||||
{"a": 0, "b": 5},
|
||||
],
|
||||
[
|
||||
"Multiply two numbers - 3",
|
||||
10,
|
||||
"./third_party/ABY/build/bin/2pc_mult_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_mult",
|
||||
{"a": 2, "b": 0},
|
||||
{"a": 0, "b": 5},
|
||||
],
|
||||
@@ -52,7 +52,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_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_mult_add_pub",
|
||||
{"a": 5, "b": 0, "v": 7},
|
||||
{"a": 0, "b": 7, "v": 7},
|
||||
],
|
||||
@@ -60,7 +60,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_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_mult_add_pub",
|
||||
{"a": 5, "b": 0, "v": 7},
|
||||
{"a": 0, "b": 7, "v": 0},
|
||||
],
|
||||
@@ -70,112 +70,112 @@ arithmetic_boolean_tests = [
|
||||
[
|
||||
"Test two numbers are equal - 1",
|
||||
0,
|
||||
"./third_party/ABY/build/bin/2pc_int_equals_zok_test",
|
||||
"./third_party/ABY/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_zok_test",
|
||||
"./third_party/ABY/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_zok_test",
|
||||
"./third_party/ABY/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_zok_test",
|
||||
"./third_party/ABY/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_zok_test",
|
||||
"./third_party/ABY/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_zok_test",
|
||||
"./third_party/ABY/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_zok_test",
|
||||
"./third_party/ABY/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_zok_test",
|
||||
"./third_party/ABY/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_zok_test",
|
||||
"./third_party/ABY/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_zok_test",
|
||||
"./third_party/ABY/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_zok_test",
|
||||
"./third_party/ABY/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_zok_test",
|
||||
"./third_party/ABY/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_zok_test",
|
||||
"./third_party/ABY/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_zok_test",
|
||||
"./third_party/ABY/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_zok_test",
|
||||
"./third_party/ABY/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_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_int_equals",
|
||||
{"a": 12, "b": 0},
|
||||
{"a": 0, "b": 12},
|
||||
],
|
||||
@@ -185,7 +185,7 @@ nary_arithmetic_tests = [
|
||||
[
|
||||
"Test a + b + c",
|
||||
6,
|
||||
"./third_party/ABY/build/bin/2pc_nary_arithmetic_add_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_nary_arithmetic_add",
|
||||
{"a": 1, "b": 0, "c": 0},
|
||||
{"a": 0, "b": 2, "c": 3},
|
||||
],
|
||||
@@ -195,84 +195,84 @@ bitwise_tests = [
|
||||
[
|
||||
"Bitwise & - 1",
|
||||
0,
|
||||
"./third_party/ABY/build/bin/2pc_bitwise_and_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_bitwise_and",
|
||||
{"a": 0, "b": 0},
|
||||
{"a": 0, "b": 0},
|
||||
],
|
||||
[
|
||||
"Bitwise & - 2",
|
||||
0,
|
||||
"./third_party/ABY/build/bin/2pc_bitwise_and_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_bitwise_and",
|
||||
{"a": 1, "b": 0},
|
||||
{"a": 0, "b": 0},
|
||||
],
|
||||
[
|
||||
"Bitwise & - 3",
|
||||
0,
|
||||
"./third_party/ABY/build/bin/2pc_bitwise_and_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_bitwise_and",
|
||||
{"a": 0, "b": 0},
|
||||
{"a": 0, "b": 1},
|
||||
],
|
||||
[
|
||||
"Bitwise & - 4",
|
||||
1,
|
||||
"./third_party/ABY/build/bin/2pc_bitwise_and_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_bitwise_and",
|
||||
{"a": 1, "b": 0},
|
||||
{"a": 0, "b": 1},
|
||||
],
|
||||
[
|
||||
"Bitwise | - 1",
|
||||
0,
|
||||
"./third_party/ABY/build/bin/2pc_bitwise_or_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_bitwise_or",
|
||||
{"a": 0, "b": 0},
|
||||
{"a": 0, "b": 0},
|
||||
],
|
||||
[
|
||||
"Bitwise | - 2",
|
||||
1,
|
||||
"./third_party/ABY/build/bin/2pc_bitwise_or_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_bitwise_or",
|
||||
{"a": 1, "b": 0},
|
||||
{"a": 0, "b": 0},
|
||||
],
|
||||
[
|
||||
"Bitwise | - 3",
|
||||
1,
|
||||
"./third_party/ABY/build/bin/2pc_bitwise_or_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_bitwise_or",
|
||||
{"a": 0, "b": 0},
|
||||
{"a": 0, "b": 1},
|
||||
],
|
||||
[
|
||||
"Bitwise | - 4",
|
||||
1,
|
||||
"./third_party/ABY/build/bin/2pc_bitwise_or_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_bitwise_or",
|
||||
{"a": 1, "b": 0},
|
||||
{"a": 0, "b": 1},
|
||||
],
|
||||
[
|
||||
"Bitwise ^ - 1",
|
||||
0,
|
||||
"./third_party/ABY/build/bin/2pc_bitwise_xor_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_bitwise_xor",
|
||||
{"a": 0, "b": 0},
|
||||
{"a": 0, "b": 0},
|
||||
],
|
||||
[
|
||||
"Bitwise ^ - 2",
|
||||
1,
|
||||
"./third_party/ABY/build/bin/2pc_bitwise_xor_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_bitwise_xor",
|
||||
{"a": 1, "b": 0},
|
||||
{"a": 0, "b": 0},
|
||||
],
|
||||
[
|
||||
"Bitwise ^ - 3",
|
||||
1,
|
||||
"./third_party/ABY/build/bin/2pc_bitwise_xor_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_bitwise_xor",
|
||||
{"a": 0, "b": 0},
|
||||
{"a": 0, "b": 1},
|
||||
],
|
||||
[
|
||||
"Bitwise ^ - 4",
|
||||
0,
|
||||
"./third_party/ABY/build/bin/2pc_bitwise_xor_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_bitwise_xor",
|
||||
{"a": 1, "b": 0},
|
||||
{"a": 0, "b": 1},
|
||||
],
|
||||
@@ -282,70 +282,70 @@ boolean_tests = [
|
||||
[
|
||||
"Boolean && - 1",
|
||||
0,
|
||||
"./third_party/ABY/build/bin/2pc_boolean_and_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_boolean_and",
|
||||
{"a": 0, "b": 0},
|
||||
{"a": 0, "b": 0},
|
||||
],
|
||||
[
|
||||
"Boolean && - 2",
|
||||
0,
|
||||
"./third_party/ABY/build/bin/2pc_boolean_and_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_boolean_and",
|
||||
{"a": 1, "b": 0},
|
||||
{"a": 0, "b": 0},
|
||||
],
|
||||
[
|
||||
"Boolean && - 3",
|
||||
0,
|
||||
"./third_party/ABY/build/bin/2pc_boolean_and_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_boolean_and",
|
||||
{"a": 0, "b": 0},
|
||||
{"a": 0, "b": 1},
|
||||
],
|
||||
[
|
||||
"Boolean && - 4",
|
||||
1,
|
||||
"./third_party/ABY/build/bin/2pc_boolean_and_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_boolean_and",
|
||||
{"a": 1, "b": 0},
|
||||
{"a": 0, "b": 1},
|
||||
],
|
||||
[
|
||||
"Boolean || - 1",
|
||||
0,
|
||||
"./third_party/ABY/build/bin/2pc_boolean_or_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_boolean_or",
|
||||
{"a": 0, "b": 0},
|
||||
{"a": 0, "b": 0},
|
||||
],
|
||||
[
|
||||
"Boolean || - 2",
|
||||
1,
|
||||
"./third_party/ABY/build/bin/2pc_boolean_or_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_boolean_or",
|
||||
{"a": 1, "b": 0},
|
||||
{"a": 0, "b": 0},
|
||||
],
|
||||
[
|
||||
"Boolean || - 3",
|
||||
1,
|
||||
"./third_party/ABY/build/bin/2pc_boolean_or_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_boolean_or",
|
||||
{"a": 0, "b": 0},
|
||||
{"a": 0, "b": 1},
|
||||
],
|
||||
[
|
||||
"Boolean || - 4",
|
||||
1,
|
||||
"./third_party/ABY/build/bin/2pc_boolean_or_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_boolean_or",
|
||||
{"a": 1, "b": 0},
|
||||
{"a": 0, "b": 1},
|
||||
],
|
||||
[
|
||||
"Boolean == - 1",
|
||||
0,
|
||||
"./third_party/ABY/build/bin/2pc_boolean_equals_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_boolean_equals",
|
||||
{"a": 0, "b": 0},
|
||||
{"a": 0, "b": 1},
|
||||
],
|
||||
[
|
||||
"Boolean == - 2",
|
||||
1,
|
||||
"./third_party/ABY/build/bin/2pc_boolean_equals_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_boolean_equals",
|
||||
{"a": 1, "b": 0},
|
||||
{"a": 0, "b": 1},
|
||||
],
|
||||
@@ -355,14 +355,14 @@ nary_boolean_tests = [
|
||||
[
|
||||
"Test a & b & c - 1",
|
||||
0,
|
||||
"./third_party/ABY/build/bin/2pc_nary_boolean_and_zok_test",
|
||||
"./third_party/ABY/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_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_nary_boolean_and",
|
||||
{"a": 1, "b": 0, "c": 0},
|
||||
{"a": 0, "b": 1, "c": 1},
|
||||
],
|
||||
@@ -373,7 +373,7 @@ const_arith_tests = [
|
||||
[
|
||||
"Test add client int + server int to const value",
|
||||
6,
|
||||
"./third_party/ABY/build/bin/2pc_const_arith_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_const_arith",
|
||||
{"a": 2, "b": 0},
|
||||
{"a": 0, "b": 3},
|
||||
],
|
||||
@@ -383,14 +383,14 @@ const_bool_tests = [
|
||||
[
|
||||
"Test server value == const value - 1",
|
||||
0,
|
||||
"./third_party/ABY/build/bin/2pc_const_bool_zok_test",
|
||||
"./third_party/ABY/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_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_const_bool",
|
||||
{"a": 1, "b": 0},
|
||||
{"a": 0, "b": 0},
|
||||
],
|
||||
@@ -400,28 +400,28 @@ ite_tests = [
|
||||
[
|
||||
"Test ite ret bool - 1",
|
||||
0,
|
||||
"./third_party/ABY/build/bin/2pc_ite_ret_bool_zok_test",
|
||||
"./third_party/ABY/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_zok_test",
|
||||
"./third_party/ABY/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_zok_test",
|
||||
"./third_party/ABY/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_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_ite_ret_int",
|
||||
{"a": 32, "b": 0, "sel": 0},
|
||||
{"a": 0, "b": 45, "sel": 0},
|
||||
],
|
||||
@@ -431,14 +431,14 @@ arr_tests = [
|
||||
[
|
||||
"Array sum test",
|
||||
3,
|
||||
"./third_party/ABY/build/bin/2pc_array_sum_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_array_sum",
|
||||
{"a": 2, "b": 0},
|
||||
{"a": 0, "b": 1},
|
||||
],
|
||||
[
|
||||
"Array ret test",
|
||||
"2\n1",
|
||||
"./third_party/ABY/build/bin/2pc_array_ret_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_array_ret",
|
||||
{"a": 2, "b": 0},
|
||||
{"a": 0, "b": 1},
|
||||
],
|
||||
@@ -448,14 +448,14 @@ loop_tests = [
|
||||
[
|
||||
"Loop sum const - 1",
|
||||
10,
|
||||
"./third_party/ABY/build/bin/2pc_loop_sum_zok_test",
|
||||
"./third_party/ABY/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_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_loop_sum",
|
||||
{"a": 10, "b": 0},
|
||||
{"a": 0, "b": 3},
|
||||
],
|
||||
@@ -465,14 +465,14 @@ function_tests = [
|
||||
[
|
||||
"Sum() two numbers - 1",
|
||||
3,
|
||||
"./third_party/ABY/build/bin/2pc_function_sum_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_function_sum",
|
||||
{"a": 1, "b": 0},
|
||||
{"a": 0, "b": 2},
|
||||
],
|
||||
[
|
||||
"Sum() two numbers - 2",
|
||||
2,
|
||||
"./third_party/ABY/build/bin/2pc_function_sum_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_function_sum",
|
||||
{"a": 0, "b": 0},
|
||||
{"a": 0, "b": 2},
|
||||
],
|
||||
@@ -483,35 +483,35 @@ shift_tests = [
|
||||
[
|
||||
"Left Shift a by 1 - 1",
|
||||
20,
|
||||
"./third_party/ABY/build/bin/2pc_lhs_zok_test",
|
||||
"./third_party/ABY/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_zok_test",
|
||||
"./third_party/ABY/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_zok_test",
|
||||
"./third_party/ABY/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_zok_test",
|
||||
"./third_party/ABY/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_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_rhs",
|
||||
{"a": 0, "b": 0},
|
||||
{"a": 0, "b": 2},
|
||||
],
|
||||
@@ -521,28 +521,28 @@ misc_tests = [
|
||||
[
|
||||
"Millionaire's problem: server has more money than client",
|
||||
0,
|
||||
"./third_party/ABY/build/bin/2pc_millionaire_zok_test",
|
||||
"./third_party/ABY/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_zok_test",
|
||||
"./third_party/ABY/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_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_millionaire",
|
||||
{"a": 1, "b": 0},
|
||||
{"a": 0, "b": 2},
|
||||
],
|
||||
[
|
||||
"Conversion problem",
|
||||
7,
|
||||
"./third_party/ABY/build/bin/2pc_conv_zok_test",
|
||||
"./third_party/ABY/build/bin/2pc_conv",
|
||||
{"a": 0, "b": 0},
|
||||
{"a": 0, "b": 7},
|
||||
],
|
||||
@@ -3,14 +3,34 @@ import sys
|
||||
from typing import List
|
||||
import time
|
||||
|
||||
def init_progress_bar(toolbar_width=40):
|
||||
''' Initialize progress bar '''
|
||||
print("Running ABY unit tests")
|
||||
sys.stdout.write("[%s]" % (" " * toolbar_width))
|
||||
sys.stdout.flush()
|
||||
sys.stdout.write("\b" * (toolbar_width+1))
|
||||
|
||||
def update_progress_bar():
|
||||
''' Increment progress bar '''
|
||||
sys.stdout.write("=")
|
||||
sys.stdout.flush()
|
||||
|
||||
def end_progress_bar():
|
||||
''' Close progress bar '''
|
||||
sys.stdout.write("]\n") # this ends the progress bar
|
||||
|
||||
def flatten_args(args: dict) -> list:
|
||||
''' flatten dictionary into list '''
|
||||
''' Flatten dictionary into list '''
|
||||
flat_args = []
|
||||
for k, v in args.items():
|
||||
flat_args.append(str(k))
|
||||
flat_args.append(str(v))
|
||||
return flat_args
|
||||
|
||||
def update_path(path: str, lang: str) -> str:
|
||||
'''Append path with language type'''
|
||||
return f'{path}_{lang}_test'
|
||||
|
||||
def build_server_cmd(exec: str, args: dict) -> List[str]:
|
||||
return [exec, "-r", "0", "-i"] + flatten_args(args)
|
||||
|
||||
@@ -43,16 +63,39 @@ def run_test(desc: str, expected: str, server_cmd: List[str], client_cmd: List[s
|
||||
# print("Exception: ", e)
|
||||
return False
|
||||
|
||||
def run_tests(lang: str, tests: List[dict]):
|
||||
'''
|
||||
tests will be a list of all tests to run. each element in the list will be
|
||||
1. description of test case: string
|
||||
2. expected output: string
|
||||
3. executable path: string
|
||||
4. server arguments: dict[name] = value
|
||||
5. client arguments: dict[name] = value
|
||||
'''
|
||||
failed_test_descs = []
|
||||
num_retries = 3
|
||||
progress_inc = 5
|
||||
init_progress_bar(len(tests) // progress_inc)
|
||||
for t, test in enumerate(tests):
|
||||
assert len(test) == 5, "test configurations are wrong for test: "+test[0]
|
||||
desc = test[0]
|
||||
expected = str(test[1])
|
||||
path = update_path(test[2], lang)
|
||||
server_cmd = build_server_cmd(path, test[3])
|
||||
client_cmd = build_client_cmd(path, test[4])
|
||||
|
||||
def init_progress_bar(toolbar_width=40):
|
||||
print("Running ABY unit tests")
|
||||
sys.stdout.write("[%s]" % (" " * toolbar_width))
|
||||
sys.stdout.flush()
|
||||
sys.stdout.write("\b" * (toolbar_width+1))
|
||||
test_results = []
|
||||
for i in range(num_retries):
|
||||
test_results.append(run_test(desc, expected, server_cmd, client_cmd))
|
||||
|
||||
if not any(test_results):
|
||||
failed_test_descs.append(desc)
|
||||
|
||||
def update_progress_bar():
|
||||
sys.stdout.write("=")
|
||||
sys.stdout.flush()
|
||||
if t % progress_inc == 0:
|
||||
update_progress_bar()
|
||||
end_progress_bar()
|
||||
|
||||
if len(failed_test_descs) == 0:
|
||||
print("All tests passed ✅")
|
||||
|
||||
def end_progress_bar():
|
||||
sys.stdout.write("]\n") # this ends the progress bar
|
||||
assert len(failed_test_descs) == 0, "there were failed test cases:\n\t- " + "\n\t- ".join(failed_test_descs)
|
||||
@@ -1,13 +1,7 @@
|
||||
from utils import *
|
||||
from zokrates_test_suite import *
|
||||
from utils import run_tests
|
||||
from test_suite import *
|
||||
|
||||
def run_tests():
|
||||
# tests will be a list of all tests to run. each element in the list will be
|
||||
# 1. description of test case: string
|
||||
# 2. expected output: string
|
||||
# 3. executable path: string
|
||||
# 4. server arguments: dict[name] = value
|
||||
# 5. client arguments: dict[name] = value
|
||||
if __name__ == "__main__":
|
||||
tests = arithmetic_tests + \
|
||||
arithmetic_boolean_tests + \
|
||||
nary_arithmetic_tests + \
|
||||
@@ -23,33 +17,4 @@ def run_tests():
|
||||
misc_tests
|
||||
# arr_tests + \
|
||||
|
||||
failed_test_descs = []
|
||||
num_retries = 3
|
||||
progress_inc = 5
|
||||
init_progress_bar(len(tests) // progress_inc)
|
||||
for t, test in enumerate(tests):
|
||||
assert len(test) == 5, "test configurations are wrong for test: "+test[0]
|
||||
desc = test[0]
|
||||
expected = str(test[1])
|
||||
path = test[2]
|
||||
server_cmd = build_server_cmd(path, test[3])
|
||||
client_cmd = build_client_cmd(path, test[4])
|
||||
|
||||
test_results = []
|
||||
for i in range(num_retries):
|
||||
test_results.append(run_test(desc, expected, server_cmd, client_cmd))
|
||||
|
||||
if not any(test_results):
|
||||
failed_test_descs.append(desc)
|
||||
|
||||
if t % progress_inc == 0:
|
||||
update_progress_bar()
|
||||
end_progress_bar()
|
||||
|
||||
if len(failed_test_descs) == 0:
|
||||
print("All tests passed ✅")
|
||||
|
||||
assert len(failed_test_descs) == 0, "there were failed test cases:\n\t- " + "\n\t- ".join(failed_test_descs)
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_tests()
|
||||
run_tests('zok', tests)
|
||||
|
||||
@@ -23,35 +23,35 @@ function mpc_test {
|
||||
RUST_BACKTRACE=1 measure_time $BIN -p $parties $zpath
|
||||
}
|
||||
|
||||
# # build mpc arithmetic tests
|
||||
# mpc_test 2 ./examples/C/mpc/unit_tests/arithmetic_tests/2pc_add.c
|
||||
# mpc_test 2 ./examples/C/mpc/unit_tests/arithmetic_tests/2pc_sub.c
|
||||
# mpc_test 2 ./examples/C/mpc/unit_tests/arithmetic_tests/2pc_mult.c
|
||||
# mpc_test 2 ./examples/C/mpc/unit_tests/arithmetic_tests/2pc_mult_add_pub.c
|
||||
# build mpc arithmetic tests
|
||||
mpc_test 2 ./examples/C/mpc/unit_tests/arithmetic_tests/2pc_add.c
|
||||
mpc_test 2 ./examples/C/mpc/unit_tests/arithmetic_tests/2pc_sub.c
|
||||
mpc_test 2 ./examples/C/mpc/unit_tests/arithmetic_tests/2pc_mult.c
|
||||
mpc_test 2 ./examples/C/mpc/unit_tests/arithmetic_tests/2pc_mult_add_pub.c
|
||||
|
||||
# mpc_test 2 ./examples/C/mpc/unit_tests/arithmetic_tests/2pc_int_equals.c
|
||||
# mpc_test 2 ./examples/C/mpc/unit_tests/arithmetic_tests/2pc_int_greater_than.c
|
||||
# mpc_test 2 ./examples/C/mpc/unit_tests/arithmetic_tests/2pc_int_greater_equals.c
|
||||
# mpc_test 2 ./examples/C/mpc/unit_tests/arithmetic_tests/2pc_int_less_than.c
|
||||
# mpc_test 2 ./examples/C/mpc/unit_tests/arithmetic_tests/2pc_int_less_equals.c
|
||||
mpc_test 2 ./examples/C/mpc/unit_tests/arithmetic_tests/2pc_int_equals.c
|
||||
mpc_test 2 ./examples/C/mpc/unit_tests/arithmetic_tests/2pc_int_greater_than.c
|
||||
mpc_test 2 ./examples/C/mpc/unit_tests/arithmetic_tests/2pc_int_greater_equals.c
|
||||
mpc_test 2 ./examples/C/mpc/unit_tests/arithmetic_tests/2pc_int_less_than.c
|
||||
mpc_test 2 ./examples/C/mpc/unit_tests/arithmetic_tests/2pc_int_less_equals.c
|
||||
|
||||
# # build mpc nary arithmetic tests
|
||||
# mpc_test 2 ./examples/C/mpc/unit_tests/nary_arithmetic_tests/2pc_nary_arithmetic_add.c
|
||||
# build mpc nary arithmetic tests
|
||||
mpc_test 2 ./examples/C/mpc/unit_tests/nary_arithmetic_tests/2pc_nary_arithmetic_add.c
|
||||
|
||||
# # build mpc bitwise tests
|
||||
# mpc_test 2 ./examples/C/mpc/unit_tests/bitwise_tests/2pc_bitwise_and.c
|
||||
# mpc_test 2 ./examples/C/mpc/unit_tests/bitwise_tests/2pc_bitwise_or.c
|
||||
# mpc_test 2 ./examples/C/mpc/unit_tests/bitwise_tests/2pc_bitwise_xor.c
|
||||
# build mpc bitwise tests
|
||||
mpc_test 2 ./examples/C/mpc/unit_tests/bitwise_tests/2pc_bitwise_and.c
|
||||
mpc_test 2 ./examples/C/mpc/unit_tests/bitwise_tests/2pc_bitwise_or.c
|
||||
mpc_test 2 ./examples/C/mpc/unit_tests/bitwise_tests/2pc_bitwise_xor.c
|
||||
|
||||
# # build mpc boolean tests
|
||||
# mpc_test 2 ./examples/C/mpc/unit_tests/boolean_tests/2pc_boolean_and.c
|
||||
# mpc_test 2 ./examples/C/mpc/unit_tests/boolean_tests/2pc_boolean_or.c
|
||||
# mpc_test 2 ./examples/C/mpc/unit_tests/boolean_tests/2pc_boolean_equals.c
|
||||
# build mpc boolean tests
|
||||
mpc_test 2 ./examples/C/mpc/unit_tests/boolean_tests/2pc_boolean_and.c
|
||||
mpc_test 2 ./examples/C/mpc/unit_tests/boolean_tests/2pc_boolean_or.c
|
||||
mpc_test 2 ./examples/C/mpc/unit_tests/boolean_tests/2pc_boolean_equals.c
|
||||
|
||||
# # build mpc nary boolean tests
|
||||
# mpc_test 2 ./examples/C/mpc/unit_tests/nary_boolean_tests/2pc_nary_boolean_and.c
|
||||
# build mpc nary boolean tests
|
||||
mpc_test 2 ./examples/C/mpc/unit_tests/nary_boolean_tests/2pc_nary_boolean_and.c
|
||||
|
||||
# # build mpc const tests
|
||||
# mpc_test 2 ./examples/C/mpc/unit_tests/const_tests/2pc_const_arith.c
|
||||
# build mpc const tests
|
||||
mpc_test 2 ./examples/C/mpc/unit_tests/const_tests/2pc_const_arith.c
|
||||
mpc_test 2 ./examples/C/mpc/unit_tests/const_tests/2pc_const_bool.c
|
||||
|
||||
|
||||
Reference in New Issue
Block a user