Skip to content

Commit

Permalink
=Upgrade to Version 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
NigelSmart committed Jan 21, 2019
1 parent 3722a85 commit 862ecf5
Show file tree
Hide file tree
Showing 136 changed files with 9,058 additions and 1,357 deletions.
17 changes: 3 additions & 14 deletions Auto-Test-Data/1/SharingData.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,11 @@
1
1
3
4 3
1 1 1
1 1 0
1 0 1
0 1 1
0

4 3
1 0 0
0 1 0
0 0 1
0 0 0
0

3 3
1 1 0
1 0 1
0 1 1
0

3 3
1 0 0
Expand Down
Binary file modified Auto-Test-Data/18/FHE-Key-0.key
Binary file not shown.
Binary file modified Auto-Test-Data/18/FHE-Key-1.key
Binary file not shown.
2 changes: 1 addition & 1 deletion Auto-Test-Data/18/MKey-0.key
Original file line number Diff line number Diff line change
@@ -1 +1 @@
69668124728830222749676537464402630641
-50353559076551998191983263871003852201
2 changes: 1 addition & 1 deletion Auto-Test-Data/18/MKey-1.key
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-7275721642115876935252499140937909223
75170476096156849151915726440147616694
2 changes: 1 addition & 1 deletion Auto-Test-Data/18/SharingData.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

2
1 1
1 909456435
1 0
Binary file modified Auto-Test-Data/19/FHE-Key-0.key
Binary file not shown.
Binary file modified Auto-Test-Data/19/FHE-Key-1.key
Binary file not shown.
Binary file modified Auto-Test-Data/19/FHE-Key-2.key
Binary file not shown.
2 changes: 1 addition & 1 deletion Auto-Test-Data/19/MKey-0.key
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-22223222990748540167641026254521709816
-59706683718328805854482650106033049316
2 changes: 1 addition & 1 deletion Auto-Test-Data/19/MKey-1.key
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-50038966067612434297350435979181191254
-17711958676119375968134078680082403088
2 changes: 1 addition & 1 deletion Auto-Test-Data/19/MKey-2.key
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-58313909951702824099381522886862484881
-21081155086657054380708028142847685092
2 changes: 1 addition & 1 deletion Auto-Test-Data/19/SharingData.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

3
1 1 1
1 1717920867
1 0
Binary file modified Auto-Test-Data/20/FHE-Key-0.key
Binary file not shown.
Binary file modified Auto-Test-Data/20/FHE-Key-1.key
Binary file not shown.
2 changes: 1 addition & 1 deletion Auto-Test-Data/20/MKey-0.key
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1015476113 145381168
412990509 -291700140 -138980771
2 changes: 1 addition & 1 deletion Auto-Test-Data/20/MKey-1.key
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-370738863 289900084
-82423015 630799487 -839895794
4 changes: 2 additions & 2 deletions Auto-Test-Data/20/SharingData.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
2147565569
2148728833
0
3
2 2
Expand All @@ -7,4 +7,4 @@

2
1 1
2 0
3 0
Binary file modified Auto-Test-Data/21/FHE-Key-0.key
Binary file not shown.
Binary file modified Auto-Test-Data/21/FHE-Key-1.key
Binary file not shown.
Binary file modified Auto-Test-Data/21/FHE-Key-2.key
Binary file not shown.
2 changes: 1 addition & 1 deletion Auto-Test-Data/21/MKey-0.key
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-676069251 564673717
297498756 848979426 -889787852
2 changes: 1 addition & 1 deletion Auto-Test-Data/21/MKey-1.key
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-438825176 880516225
341235050 -911720159 606883365
2 changes: 1 addition & 1 deletion Auto-Test-Data/21/MKey-2.key
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-468377978 533752706
-110486774 -292638306 371320188
4 changes: 2 additions & 2 deletions Auto-Test-Data/21/SharingData.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
2147565569
2148728833
0
3
3 3
Expand All @@ -8,4 +8,4 @@

3
1 1 1
2 0
3 0
48 changes: 3 additions & 45 deletions Auto-Test-Data/22/SharingData.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,53 +113,11 @@
1
1
5
16 5
1 1 1 1 1
1 1 1 0 0
1 1 0 1 0
1 0 1 1 0
0 1 1 1 0
1 1 1 1 0
1 1 0 0 1
1 0 1 0 1
0 1 1 0 1
1 1 1 0 1
1 0 0 1 1
0 1 0 1 1
1 1 0 1 1
0 0 1 1 1
1 0 1 1 1
0 1 1 1 1
0

16 5
1 1 0 0 0
1 0 1 0 0
0 1 1 0 0
1 0 0 1 0
0 1 0 1 0
0 0 1 1 0
1 0 0 0 1
0 1 0 0 1
0 0 1 0 1
0 0 0 1 1
0 0 0 0 0
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
0

10 5
1 1 1 0 0
1 1 0 1 0
1 0 1 1 0
0 1 1 1 0
1 1 0 0 1
1 0 1 0 1
0 1 1 0 1
1 0 0 1 1
0 1 0 1 1
0 0 1 1 1
0

10 5
1 1 0 0 0
Expand Down
2 changes: 1 addition & 1 deletion Auto-Test-Data/25/SharingData.txt
Original file line number Diff line number Diff line change
Expand Up @@ -271,5 +271,5 @@

0

0
1

28 changes: 3 additions & 25 deletions Auto-Test-Data/6/SharingData.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,33 +89,11 @@
1
1
4
11 4
1 1 1 1
1 1 0 0
1 0 1 0
0 1 1 0
1 1 1 0
1 0 0 1
0 1 0 1
1 1 0 1
0 0 1 1
1 0 1 1
0 1 1 1
0

5 4
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
0 0 0 0
0

6 4
1 1 0 0
1 0 1 0
0 1 1 0
1 0 0 1
0 1 0 1
0 0 1 1
0

4 4
1 0 0 0
Expand Down
6 changes: 5 additions & 1 deletion Auto-Test-Data/README.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
This directory contains files needed for the auto-testing of the system

The data sets are created on the assumption that the DEFAULT
parameters (in config.h) are used to compile the main programs.

1 Shamir (3,1)
2 Replicated (3,1) Maurer
3 Replicated (3,1) Reduced
Expand Down Expand Up @@ -26,7 +30,7 @@ This directory contains files needed for the auto-testing of the system
25 Shamir (10,4)


Where all bar the FHE examples use the prime
Where all bar the FHE and 32-bit examples use the prime

p=340282366920938463463374607431768211507

Expand Down
47 changes: 36 additions & 11 deletions Compiler/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,31 @@ class F(float):
__eq__ = lambda x,y: sint(float(x) == y)
__ne__ = lambda x,y: sint(float(x) != y)
__neg__ = lambda x: F(-float(x))
sfloat = lambda x,y=None,z=None,a=None,size=None: F(x) if size is None else Vector(F(x), size)
sfloat = lambda x,y=None,z=None,a=None,err=None,size=None: F(x) if size is None else Vector(F(x), size)
sfloat.vlen = 24
sfloat.plen = 8
sfloat.error = None

class CF(float):
v = p = z = s = None
__add__ = lambda x,y: CF(float(x) + y)
__sub__ = lambda x,y: CF(float(x) - y)
__mul__ = lambda x,y: CF(float(x) * y)
__div__ = lambda x,y: CF(0) if y == 0 else CF(float(x) / y)
__pow__ = lambda x,y: CF(float(x)**y)
__lt__ = lambda x,y: cint(float(x) < y)
__gt__ = lambda x,y: cint(float(x) > y)
__le__ = lambda x,y: cint(float(x) <= y)
__ge__ = lambda x,y: cint(float(x) >= y)
__eq__ = lambda x,y: cint(float(x) == y)
__ne__ = lambda x,y: cint(float(x) != y)
__neg__ = lambda x: CF(-float(x))

cfloat = lambda x,y=None,z=None,a=None,size=None: CF(x) if size is None else Vector(CF(x), size)
cfloat.vlen = 24
cfloat.plen = 8


class _fixregister(float):
v = None

Expand Down Expand Up @@ -254,17 +274,17 @@ class _sfix(_fixregister):

class _cfix(_fixregister):

less_than = lambda x,y,z=None: sint(float(x) < y) if isinstance(y, _sfix) \
less_than = lambda x,y,z=None: sint(float(x) < y) if (isinstance(y, _sfix) or isinstance(y,F)) \
else regint(float(x) < y)
less_equal = lambda x,y,z=None: sint(float(x) <= y) if isinstance(y, _sfix) \
less_equal = lambda x,y,z=None: sint(float(x) <= y) if (isinstance(y, _sfix) or isinstance(y,F))\
else regint(float(x) <= y)
greater_equal = lambda x,y,z=None: sint(float(x) >= y) if isinstance(y, _sfix) \
greater_equal = lambda x,y,z=None: sint(float(x) >= y) if (isinstance(y, _sfix) or isinstance(y,F)) \
else regint(float(x) >= y)
greater_than = lambda x,y,z=None: sint(float(x) > y) if isinstance(y, _sfix) \
greater_than = lambda x,y,z=None: sint(float(x) > y) if (isinstance(y, _sfix) or isinstance(y,F)) \
else regint(float(x) > y)
equal = lambda x,y,z=None: sint(float(x) == y) if isinstance(y, _sfix) \
equal = lambda x,y,z=None: sint(float(x) == y) if (isinstance(y, _sfix) or isinstance(y,F)) \
else regint(float(x) == y)
not_equal = lambda x,y,z=None: sint(float(x) != y) if isinstance(y, _sfix) \
not_equal = lambda x,y,z=None: sint(float(x) != y) if (isinstance(y, _sfix) or isinstance(y,F)) \
else regint(float(x) != y)

__lt__ = less_than
Expand Down Expand Up @@ -300,10 +320,10 @@ class _cfix(_fixregister):

import math
mpc_math = A()
# currently testing only works with sfix type
mpc_math.sin = lambda x: sfix(math.sin(x))
mpc_math.cos = lambda x: sfix(math.cos(x))
mpc_math.tan = lambda x: sfix(math.tan(x))
# currently testing for sfix type
mpc_math.test_sin_fx = lambda x: sfix(math.sin(x))
mpc_math.test_cos_fx = lambda x: sfix(math.cos(x))
mpc_math.test_tan_fx = lambda x: sfix(math.tan(x))
mpc_math.log2_fx = lambda x: sfix(math.log(x, 2))
mpc_math.log_fx = lambda x,y: sfix(math.log(x, y))
mpc_math.pow_fx = lambda x,y: sfix(math.pow(x, y))
Expand All @@ -315,6 +335,11 @@ class _cfix(_fixregister):
mpc_math.test_sqrt_no_param = lambda x: sfix(math.sqrt(x))
mpc_math.test_sqrt_param = lambda x, k, f: sfix(math.sqrt(x))

# currently testing for sfloat type
mpc_math.test_sin_float = lambda x: sfloat(math.sin(x))
mpc_math.test_cos_float = lambda x: sfloat(math.cos(x))
mpc_math.test_tan_float = lambda x: sfloat(math.tan(x))

sort = lambda x: x.sort()
chunky_odd_even_merge_sort = sort
chunkier_odd_even_merge_sort = lambda x,**kwargs: x.sort()
Expand Down
Loading

0 comments on commit 862ecf5

Please sign in to comment.