changeset 1446:161c652c4ae0

Added authentication codes to share.
author Janus Dam Nielsen <janus.nielsen@alexandra.dk>
date Mon, 05 Jul 2010 11:33:57 +0200
parents 67def1bd577b
children cc963bc7ae5e
files viff/bedoza.py viff/test/test_bedoza_runtime.py
diffstat 2 files changed, 5 insertions(+), 208 deletions(-) [+]
line wrap: on
line diff
--- a/viff/bedoza.py	Fri Jul 02 10:21:50 2010 +0200
+++ b/viff/bedoza.py	Mon Jul 05 11:33:57 2010 +0200
@@ -26,10 +26,10 @@
 class BeDOZaShare(Share):
     """A share in the BeDOZa runtime.
 
-    A share in the BeDOZa runtime is a pair ``(x_i, keys)`` of:
+    A share in the BeDOZa runtime is a pair ``(x_i, authentication_codes)`` of:
 
     - A share of a number, ``x_i``
-    - A n-tuple of keys, ``keys``
+    - A list of authentication_codes, ``authentication_codes``
 
     The :class:`Runtime` operates on shares, represented by this class.
     Shares are asynchronous in the sense that they promise to attain a
@@ -42,10 +42,10 @@
     that runtime.
     """
 
-    def __init__(self, runtime, field, value=None, keys=None):
+    def __init__(self, runtime, field, value=None, authentication_codes=None):
         self.share = value
-        self.keys = keys
-        Share.__init__(self, runtime, field, (value, keys))
+        self.authentication_codes = authentication_codes
+        Share.__init__(self, runtime, field, (value, authentication_codes))
 
 
 class BeDOZaRuntime(Runtime, HashBroadcastMixin):
--- a/viff/test/test_bedoza_runtime.py	Fri Jul 02 10:21:50 2010 +0200
+++ b/viff/test/test_bedoza_runtime.py	Mon Jul 05 11:33:57 2010 +0200
@@ -34,207 +34,4 @@
 
     runtime_class = BeDOZaRuntime
 
-    @protocol
-    def test_secret_share(self, runtime):
-        """Test sharing of random numbers."""
-
-        self.Zp = GF(6277101735386680763835789423176059013767194773182842284081)
-
-        def check((xi, Ks)):
-            # Check that we got the expected number of shares.
-            self.assert_type(xi, FieldElement)
-            self.assert_type(Ks[0], FieldElement)
-            self.assert_type(Ks[1], FieldElement)
-            self.assert_type(Ks[2], FieldElement)
-
-        if 1 == runtime.id:
-            share = runtime.secret_share([1], self.Zp, 42)
-        else:
-            share = runtime.secret_share([1], self.Zp)
-        share.addCallback(check)
-        return share
-
-    @protocol
-    def test_open_secret_share(self, runtime):
-        """Test sharing and open of a number."""
-
-        self.Zp = GF(6277101735386680763835789423176059013767194773182842284081)
-
-        def check(v):
-            self.assertEquals(v, 42)
-
-        if 1 == runtime.id:
-            x = runtime.secret_share([1], self.Zp, 42)
-        else:
-            x = runtime.secret_share([1], self.Zp)
-        d = runtime.open(x)
-        d.addCallback(check)
-        return d
-
-    @protocol
-    def test_random_share(self, runtime):
-        """Test creation of a random shared number."""
-
-        self.Zp = GF(6277101735386680763835789423176059013767194773182842284081)
-
-        def check(v):
-            self.assertEquals(True, True)
-
-        x = runtime.random_share(self.Zp)
-        d = runtime.open(x)
-        d.addCallback(check)
-        return d
-
-    @protocol
-    def test_sum(self, runtime):
-        """Test addition of two numbers."""
-
-        self.Zp = GF(6277101735386680763835789423176059013767194773182842284081)
-
-        x1 = 42
-        y1 = 7
-
-        def check(v):
-            self.assertEquals(v, x1 + y1)
-
-        if 1 == runtime.id:
-            x2 = runtime.secret_share([1], self.Zp, x1)
-        else:
-            x2 = runtime.secret_share([1], self.Zp)
-
-        if 3 == runtime.id:
-            y2 = runtime.secret_share([3], self.Zp, y1)
-        else:
-            y2 = runtime.secret_share([3], self.Zp)
-
-        z2 = runtime.add(x2, y2)
-        d = runtime.open(z2)
-        d.addCallback(check)
-        return d
-
-    @protocol
-    def test_sum_plus(self, runtime):
-        """Test addition of two numbers."""
-
-        self.Zp = GF(6277101735386680763835789423176059013767194773182842284081)
-
-        x1 = 42
-        y1 = 7
-
-        def check(v):
-            self.assertEquals(v, x1 + y1)
-
-        if 1 == runtime.id:
-            x2 = runtime.secret_share([1], self.Zp, x1)
-        else:
-            x2 = runtime.secret_share([1], self.Zp)
-
-        if 3 == runtime.id:
-            y2 = runtime.secret_share([3], self.Zp, y1)
-        else:
-            y2 = runtime.secret_share([3], self.Zp)
-
-        z2 = x2 + y2
-        d = runtime.open(z2)
-        d.addCallback(check)
-        return d
-
-    @protocol
-    def test_sum_constant(self, runtime):
-        """Test addition of two numbers."""
-
-        self.Zp = GF(6277101735386680763835789423176059013767194773182842284081)
-
-        x1 = 42
-        y1 = 7
-
-        def check(v):
-            self.assertEquals(v, x1 + y1)
-
-        if 1 == runtime.id:
-            x2 = runtime.secret_share([1], self.Zp, x1)
-        else:
-            x2 = runtime.secret_share([1], self.Zp)
-
-        z2 = x2 + y1
-        d = runtime.open(z2)
-        d.addCallback(check)
-        return d
-
-    @protocol
-    def test_sub(self, runtime):
-        """Test subtration of two numbers."""
-
-        self.Zp = GF(6277101735386680763835789423176059013767194773182842284081)
-
-        x1 = 42
-        y1 = 7
-
-        def check(v):
-            self.assertEquals(v, x1 - y1)
-
-        if 1 == runtime.id:
-            x2 = runtime.secret_share([1], self.Zp, x1)
-        else:
-            x2 = runtime.secret_share([1], self.Zp)
-
-        if 3 == runtime.id:
-            y2 = runtime.secret_share([3], self.Zp, y1)
-        else:
-            y2 = runtime.secret_share([3], self.Zp)
-
-        z2 = runtime.sub(x2, y2)
-        d = runtime.open(z2)
-        d.addCallback(check)
-        return d
-
-    @protocol
-    def test_sub_minus(self, runtime):
-        """Test subtration of two numbers."""
-
-        self.Zp = GF(6277101735386680763835789423176059013767194773182842284081)
-
-        x1 = 42
-        y1 = 7
-
-        def check(v):
-            self.assertEquals(v, x1 - y1)
-
-        if 1 == runtime.id:
-            x2 = runtime.secret_share([1], self.Zp, x1)
-        else:
-            x2 = runtime.secret_share([1], self.Zp)
-
-        if 3 == runtime.id:
-            y2 = runtime.secret_share([3], self.Zp, y1)
-        else:
-            y2 = runtime.secret_share([3], self.Zp)
-
-        z2 = x2 - y2
-        d = runtime.open(z2)
-        d.addCallback(check)
-        return d
-
-    @protocol
-    def test_sub_constant(self, runtime):
-        """Test subtration of two numbers."""
-
-        self.Zp = GF(6277101735386680763835789423176059013767194773182842284081)
-
-        x1 = 42
-        y1 = 7
-
-        def check(v):
-            self.assertEquals(v, x1 - y1)
-
-        if 1 == runtime.id:
-            x2 = runtime.secret_share([1], self.Zp, x1)
-        else:
-            x2 = runtime.secret_share([1], self.Zp)
-
-        z2 = x2 - y1
-        d = runtime.open(z2)
-        d.addCallback(check)
-        return d
-
 BeDOZaBasicCommandsTest.skip = "Skipped because the tested code is not implemented."