viff

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 diff
     1.1 --- a/viff/runtime.py	Thu Apr 03 21:57:35 2008 +0200
     1.2 +++ b/viff/runtime.py	Fri Apr 04 10:31:19 2008 +0200
     1.3 @@ -885,20 +885,25 @@
     1.4          return result
     1.5  
     1.6      @increment_pc
     1.7 -    def shamir_share(self, inputters, field, number=None):
     1.8 +    def shamir_share(self, inputters, field, number=None, threshold=None):
     1.9          """Secret share C{number} over C{field} using Shamir's method.
    1.10  
    1.11 -        Returns a list of shares.
    1.12 +        The number is shared using polynomial of degree C{threshold}
    1.13 +        (defaults to L{self.threshold}). Returns a list of shares
    1.14 +        unless unless there is only one inputter in which case the
    1.15 +        share is returned directly.
    1.16  
    1.17          Communication cost: n elements transmitted.
    1.18          """
    1.19          assert number is None or self.id in inputters
    1.20 +        if threshold is None:
    1.21 +            threshold = self.threshold
    1.22  
    1.23          results = []
    1.24          for peer_id in inputters:
    1.25              if peer_id == self.id:
    1.26                  pc = tuple(self.program_counter)
    1.27 -                shares = shamir.share(field(number), self.threshold,
    1.28 +                shares = shamir.share(field(number), threshold,
    1.29                                        self.num_players)
    1.30                  for other_id, share in shares:
    1.31                      if other_id.value == self.id:
     2.1 --- a/viff/test/test_matrix.py	Thu Apr 03 21:57:35 2008 +0200
     2.2 +++ b/viff/test/test_matrix.py	Fri Apr 04 10:31:19 2008 +0200
     2.3 @@ -52,3 +52,14 @@
     2.4          for i in range(1, 6):
     2.5              m = hyper(i, Zp)
     2.6              self.assertTrue(self.is_hyper(m))
     2.7 +
     2.8 +    def test_not_hyper(self):
     2.9 +        """Check a non-hyper-invertible matrix."""
    2.10 +        Zp = GF(11)
    2.11 +        # This is an invertible matrix, but it is not hyper-invertible
    2.12 +        # since none of the three the upper 2x2 matrices are
    2.13 +        # invertible.
    2.14 +        m = Matrix([[Zp(2), Zp(3), Zp(4)],
    2.15 +                    [Zp(4), Zp(6), Zp(9)],
    2.16 +                    [Zp(3), Zp(5), Zp(8)]])
    2.17 +        self.assertFalse(self.is_hyper(m))