## viff

### changeset 1213:7610deb0ebab

Get rid of increment_pc for prss_* These function still need a unique program counter, though, so they now increment it themselves as needed.
author Martin Geisler Fri, 18 Sep 2009 14:42:26 +0200 2daaf0e7a1f6 34a7d23462a7 viff/equality.py viff/passive.py 2 files changed, 19 insertions(+), 11 deletions(-) [+]
line diff
```     1.1 --- a/viff/equality.py	Fri Sep 18 14:41:44 2009 +0200
1.2 +++ b/viff/equality.py	Fri Sep 18 14:42:26 2009 +0200
1.3 @@ -20,13 +20,10 @@
1.4  is mixed with.
1.5  """
1.6
1.7 -from viff.runtime import increment_pc
1.8 -
1.9  class ProbabilisticEqualityMixin:
1.10      """This class implements probabilistic constant-round secure
1.11      equality-testing of secret shared numbers."""
1.12
1.13 -    @increment_pc
1.14      def equal(self, share_x, share_y):
1.15          """Equality testing with secret shared result.
1.16
```
```     2.1 --- a/viff/passive.py	Fri Sep 18 14:41:44 2009 +0200
2.2 +++ b/viff/passive.py	Fri Sep 18 14:42:26 2009 +0200
2.3 @@ -22,7 +22,7 @@
2.4  import operator
2.5
2.6  from viff import shamir
2.7 -from viff.runtime import Runtime, increment_pc, Share, ShareList, gather_shares
2.8 +from viff.runtime import Runtime, Share, ShareList, gather_shares
2.10  from viff.field import GF256, FieldElement
2.11  from viff.util import rand, profile
2.12 @@ -239,6 +239,18 @@
2.13          else:
2.14              return share_a + share_b - 2 * share_a * share_b
2.15
2.17 +        """Create unique key for PRSS.
2.18 +
2.19 +        This increments the program counter and returns it as a tuple.
2.20 +        Each straight-line program (typically a callback attached to
2.21 +        some :class:`Deferred`) is executed in a context with unique
2.22 +        starting program counter. This ensures that consequetive calls
2.23 +        to PRSS-related methods will use unique program counters.
2.24 +        """
2.25 +        self.program_counter[-1] += 1
2.26 +        return tuple(self.program_counter)
2.27 +
2.28      def prss_share(self, inputters, field, element=None):
2.29          """Creates pseudo-random secret sharings.
2.30
2.31 @@ -266,7 +278,7 @@
2.32          n = self.num_players
2.33
2.34          # Key used for PRSS.
2.35 -        key = tuple(self.program_counter)
2.37
2.38          # The shares for which we have all the keys.
2.39          all_shares = []
2.40 @@ -307,7 +319,6 @@
2.41          else:
2.42              return result
2.43
2.44 -    @increment_pc
2.46          """Generate shares of a uniformly random element from the field given.
2.47
2.48 @@ -322,7 +333,7 @@
2.49              modulus = field.modulus
2.50
2.51          # Key used for PRSS.
2.54          prfs = self.players[self.id].prfs(modulus)
2.56
2.57 @@ -363,7 +374,7 @@
2.58              modulus = field.modulus
2.59
2.60          # Key used for PRSS.
2.63          prfs = self.players[self.id].prfs(modulus ** quantity)
2.65                              modulus, quantity)
2.66 @@ -375,7 +386,7 @@
2.67          Communication cost: none.
2.68          """
2.69          # Key used for PRSS.
2.72          prfs = self.players[self.id].prfs(field.modulus)
2.73          zero_share = prss_zero(self.num_players, self.threshold, self.id,
2.75 @@ -402,7 +413,7 @@
2.76          n = self.num_players
2.77          k = self.options.security_parameter
2.78          prfs = self.players[self.id].prfs(2**k)