-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_OGC_LOADGC_EGC.mpc
73 lines (58 loc) · 2.25 KB
/
test_OGC_LOADGC_EGC.mpc
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
from datetime import datetime
class bcolors:
HEADER = '\033[95m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
def test(actual, expected):
total_tests = cint.load_mem(5000)
total_tests += 1
total_tests.store_in_mem(5000)
if_then(actual != expected)
print_ln(bcolors.FAIL + 'FAILURE: expected %s, got %s' + bcolors.ENDC, expected, actual)
failed_tests = cint.load_mem(6000)
failed_tests += 1
failed_tests.store_in_mem(6000)
else_then()
print_ln(bcolors.OKGREEN + "TEST: %s equals %s" + bcolors.ENDC, expected, actual)
end_if()
def test_garbled_circuits_are_loaded_and_evaluated_successfully_with_comparison_circuit():
print_ln("\n Testing: should evaluate comparison circuit correctly")
less_eq_circuit=66001
number_of_circuits=1
OGC(less_eq_circuit, number_of_circuits)
LOADGC(less_eq_circuit,number_of_circuits)
sregint.push(sregint(2))
sregint.push(sregint(3))
EGC(less_eq_circuit)
answer = sregint.pop()
a = sbit()
bitsint(a, answer, 0)
expected_result = sint(a).reveal() == 1
test(expected_result, 1)
def test_garbled_circuits_are_loaded_and_evaluated_two_times_successfully_with_comparison_circuit():
print_ln("\n Testing: should evaluate several comparison circuits correctly")
less_eq_circuit=66001
number_of_circuits=2
OGC(less_eq_circuit, number_of_circuits)
LOADGC(less_eq_circuit,number_of_circuits)
sregint.push(sregint(2))
sregint.push(sregint(3))
EGC(less_eq_circuit)
answer_a = sregint.pop()
a = sbit()
bitsint(a, answer_a, 0)
sregint.push(sregint(2))
sregint.push(sregint(3))
EGC(less_eq_circuit)
answer_b = sregint.pop()
b = sbit()
bitsint(b, answer_b, 0)
expected_result_a = sint(a).reveal() == 1
expected_result_b = sint(a).reveal() == 1
test(expected_result_a, 1)
test(expected_result_b, 1)
test_garbled_circuits_are_loaded_and_evaluated_successfully_with_comparison_circuit()
test_garbled_circuits_are_loaded_and_evaluated_two_times_successfully_with_comparison_circuit()
print_str("\n \n TESTS:" + bcolors.OKGREEN + " %s" + bcolors.ENDC + "/" + bcolors.FAIL + "%s failed" + bcolors.ENDC + "\n \n", cint.load_mem(5000), cint.load_mem(6000))