viff

changeset 1440:91222852a0a4

Use the Comb algorithm to compute the gammaij.
author Janus Dam Nielsen <janus.nielsen@alexandra.dk>
date Thu, 20 May 2010 10:50:25 +0200
parents 6d3dc3f181d3
children 2ec27c8979b6
files viff/orlandi.py
diffstat 1 files changed, 20 insertions(+), 3 deletions(-) [+]
line diff
     1.1 --- a/viff/orlandi.py	Thu May 20 10:41:45 2010 +0200
     1.2 +++ b/viff/orlandi.py	Thu May 20 10:50:25 2010 +0200
     1.3 @@ -54,6 +54,14 @@
     1.4      # It is only if the OrlandiRuntime is used that things blow up.
     1.5      print "Error: The commitment module is not available."
     1.6  
     1.7 +try:
     1.8 +    import tripple
     1.9 +
    1.10 +except ImportError:
    1.11 +    # The tripple module is not released yet, so we cannot expect
    1.12 +    # the import to work.
    1.13 +    print "Error: The tripple module is not available."
    1.14 +
    1.15  # import logging
    1.16  # LOG_FILENAME = 'logging_example.out'
    1.17  # logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG,)
    1.18 @@ -969,11 +977,16 @@
    1.19              results = [None] * len(self.players.keys())
    1.20              pc = tuple(self.program_counter)
    1.21              p3 = field.modulus**3
    1.22 +            bjvalue = bj.value
    1.23              for pi in self.players.keys():
    1.24                  # choose random d_i,j in Z_p^3
    1.25                  dij = random_number(p3).value
    1.26                  # gamma_ij = alpha_i^b_j Enc_ek_i(1;1)^d_ij
    1.27 -                gammaij = tripple_2c(alphas[pi - 1], bj.value, dij, self.players[pi].pubkey)
    1.28 +                # gammaij = tripple_2c(alphas[pi - 1], bj.value, dij, self.players[pi].pubkey)
    1.29 +                player = self.players[pi]
    1.30 +                fixed_base = player.pubkey['fixed_base']
    1.31 +                gammaij = fixed_base.calc(dij, alphas[pi - 1], bjvalue)
    1.32 +                
    1.33                  # Broadcast gamma_ij
    1.34                  if pi != self.id:
    1.35                      self.protocols[pi].sendData(pc, PAILLIER, str(gammaij))
    1.36 @@ -1221,6 +1234,9 @@
    1.37  
    1.38                  # 3) the gammaij he received is equal to the gammaij
    1.39                  # he now computes based on the values he reveives
    1.40 +                player = self.players[self.id]
    1.41 +                fixed_base = player.pubkey['fixed_base']
    1.42 +                alpha = alphas[self.id - 1]
    1.43                  modulus_3 = field.modulus**3
    1.44                  for j in xrange(len(ais)):
    1.45                      dij = dijs[j]
    1.46 @@ -1228,8 +1244,9 @@
    1.47                      if dij >= (modulus_3):
    1.48                          raise OrlandiException("Inconsistent random value dij %i from player %i" % (dij, j + 1))
    1.49                      # gamma_ij = alpha_i^b_j Enc_ek_i(1;1)^d_ij
    1.50 -                    gammaij = tripple_2c(alphas[self.id - 1], bis[j][0].value, 
    1.51 -                                      dij, self.players[self.id].pubkey)
    1.52 +                    # gammaij = tripple_2c(alphas[self.id - 1], bis[j][0].value, 
    1.53 +                    #                   dij, self.players[self.id].pubkey)
    1.54 +                    gammaij = fixed_base.calc(dij, alpha, bis[j][0].value)
    1.55                      if gammaij != gammas[j]:
    1.56                          raise OrlandiException("Inconsistent gammaij, %i, %i" % (gammaij, gammas[j]))
    1.57