viff

changeset 1393:36c8915d718a

Orlandi: Used new tripple function.
author Janus Dam Nielsen <janus.nielsen@alexandra.dk>
date Thu, 12 Nov 2009 10:43:57 +0100
parents 8144c02c12f6
children 86d966f49a8a
files viff/orlandi.py
diffstat 1 files changed, 4 insertions(+), 17 deletions(-) [+]
line diff
     1.1 --- a/viff/orlandi.py	Fri Oct 30 12:23:46 2009 +0100
     1.2 +++ b/viff/orlandi.py	Thu Nov 12 10:43:57 2009 +0100
     1.3 @@ -28,7 +28,7 @@
     1.4  from hash_broadcast import HashBroadcastMixin
     1.5  
     1.6  try:
     1.7 -    from pypaillier import encrypt_r, decrypt
     1.8 +    from pypaillier import encrypt_r, decrypt, tripple
     1.9      import commitment
    1.10      commitment.set_reference_string(23434347834783478783478L,
    1.11                                      489237823478234783478020L)
    1.12 @@ -881,17 +881,10 @@
    1.13              pc = tuple(self.program_counter)
    1.14              p3 = field.modulus**3
    1.15              for pi in self.players.keys():
    1.16 -                n = self.players[pi].pubkey['n']
    1.17 -                nsq = n * n
    1.18                  # choose random d_i,j in Z_p^3
    1.19                  dij = random_number(p3)
    1.20 -                # Enc_ek_i(1;1)^d_ij
    1.21 -                enc = encrypt_r(1, 1, self.players[pi].pubkey)
    1.22 -                t1 = pow(enc, dij.value, nsq)
    1.23 -                # alpha_i^b_j.
    1.24 -                t2 = pow(alphas[pi - 1], bj.value, nsq)
    1.25                  # gamma_ij = alpha_i^b_j Enc_ek_i(1;1)^d_ij
    1.26 -                gammaij = (t2 * t1) % nsq
    1.27 +                gammaij = tripple(alphas[pi - 1], bj.value, dij.value, self.players[pi].pubkey)
    1.28                  # Broadcast gamma_ij
    1.29                  if pi != self.id:
    1.30                      self.protocols[pi].sendData(pc, PAILLIER, str(gammaij))
    1.31 @@ -1140,19 +1133,13 @@
    1.32                  # 3) the gammaij he received is equal to the gammaij
    1.33                  # he now computes based on the values he reveives
    1.34                  for j in xrange(len(ais)):
    1.35 -                    n = self.players[self.id].pubkey['n']
    1.36 -                    nsq = n * n
    1.37                      dij = dijs[j]
    1.38                      # 5) ... and dij < p^3.
    1.39                      if dij >= (field.modulus**3):
    1.40                          raise OrlandiException("Inconsistent random value dij %i from player %i" % (dij, j + 1))
    1.41 -                    # Enc_ek_i(1;1)^d_ij
    1.42 -                    enc = encrypt_r(1, 1, self.players[self.id].pubkey)
    1.43 -                    t1 = pow(enc, dij.value, nsq)
    1.44 -                    # alpha_i^b_j.
    1.45 -                    t2 = pow(alphas[self.id - 1], bis[j][0].value, nsq)
    1.46                      # gamma_ij = alpha_i^b_j Enc_ek_i(1;1)^d_ij
    1.47 -                    gammaij = (t2) * (t1) % nsq
    1.48 +                    gammaij = tripple(alphas[self.id - 1], bis[j][0].value, 
    1.49 +                                      dij.value, self.players[self.id].pubkey)
    1.50                      if gammaij != gammas[j]:
    1.51                          raise OrlandiException("Inconsistent gammaij, %i, %i" % (gammaij, gammas[j]))
    1.52