changeset 631:979fbf411c6e

Merged.
author Martin Geisler <mg@daimi.au.dk>
date Fri, 04 Apr 2008 10:31:19 +0200
parents cabb3c5b04c2 d497fab5e1ec
children c4f413f47784
files viff/runtime.py viff/test/test_matrix.py
diffstat 2 files changed, 19 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/viff/runtime.py	Thu Apr 03 21:57:35 2008 +0200
+++ b/viff/runtime.py	Fri Apr 04 10:31:19 2008 +0200
@@ -885,20 +885,25 @@
         return result
 
     @increment_pc
-    def shamir_share(self, inputters, field, number=None):
+    def shamir_share(self, inputters, field, number=None, threshold=None):
         """Secret share C{number} over C{field} using Shamir's method.
 
-        Returns a list of shares.
+        The number is shared using polynomial of degree C{threshold}
+        (defaults to L{self.threshold}). Returns a list of shares
+        unless unless there is only one inputter in which case the
+        share is returned directly.
 
         Communication cost: n elements transmitted.
         """
         assert number is None or self.id in inputters
+        if threshold is None:
+            threshold = self.threshold
 
         results = []
         for peer_id in inputters:
             if peer_id == self.id:
                 pc = tuple(self.program_counter)
-                shares = shamir.share(field(number), self.threshold,
+                shares = shamir.share(field(number), threshold,
                                       self.num_players)
                 for other_id, share in shares:
                     if other_id.value == self.id:
--- a/viff/test/test_matrix.py	Thu Apr 03 21:57:35 2008 +0200
+++ b/viff/test/test_matrix.py	Fri Apr 04 10:31:19 2008 +0200
@@ -52,3 +52,14 @@
         for i in range(1, 6):
             m = hyper(i, Zp)
             self.assertTrue(self.is_hyper(m))
+
+    def test_not_hyper(self):
+        """Check a non-hyper-invertible matrix."""
+        Zp = GF(11)
+        # This is an invertible matrix, but it is not hyper-invertible
+        # since none of the three the upper 2x2 matrices are
+        # invertible.
+        m = Matrix([[Zp(2), Zp(3), Zp(4)],
+                    [Zp(4), Zp(6), Zp(9)],
+                    [Zp(3), Zp(5), Zp(8)]])
+        self.assertFalse(self.is_hyper(m))