Exemplo n.º 1
0
 def voter_id_hash(self):
     if self.voter_login_id:
         # for backwards compatibility with v3.0, and since it doesn't matter
         # too much if we hash the email or the unique login ID here.
         return utils.hash_b64(self.voter_login_id)
     else:
         return utils.hash_b64(self.voter_id)
Exemplo n.º 2
0
 def voter_id_hash(self):
   if self.voter_login_id:
     # for backwards compatibility with v3.0, and since it doesn't matter
     # too much if we hash the email or the unique login ID here.
     return utils.hash_b64(self.voter_login_id)
   else:
     return utils.hash_b64(self.voter_id)
Exemplo n.º 3
0
 def get_voters_hash(self):
     voters = self.get_voters()
     voters_json = dumps([
         v.toJSONDict(with_vote=False, with_vote_hash=False) for v in voters
     ])
     # logging.info("json for voters is: " + voters_json)
     return utils.hash_b64(voters_json)
Exemplo n.º 4
0
 def generate(self, m, secret_key, p, q, g):
     while True:
         hash = utils.hash_b64(m)
         hash_dec = utils.encode_string_to_decimal(hash)
         k = algs.Utils.random_k_relative_prime_p_1(p)
         k_inv = algs.Utils.inverse(k, p - 1)
         x = secret_key.x
         r = pow(g, k, p)
         s = ((hash_dec - x * r) * k_inv) % (p - 1)
         if s != 1:
             self.s = s
             self.r = r
             return None
Exemplo n.º 5
0
    def verify(self, m, public_key, p, q, g):
        correct = True
        y = public_key.y
        hash = utils.hash_b64(m)
        hash_dec = utils.encode_string_to_decimal(hash)
        if self.r >= p:
            correct = False
        if self.s >= p - 1:
            correct = False
        val = (pow(y, self.r, p) * pow(self.r, self.s, p)) % p
        if (pow(g, hash_dec, p) != val):
            correct = False

        return correct
Exemplo n.º 6
0
 def hash(self):
     s = utils.to_json(self.toJSONDict())
     return utils.hash_b64(s)
Exemplo n.º 7
0
 def get_hash(self):
     return utils.hash_b64(utils.to_json(self.toJSONDict()))
Exemplo n.º 8
0
 def hash(self):
   s = utils.to_json(self.toJSONDict())
   return utils.hash_b64(s)
Exemplo n.º 9
0
 def voter_id_hash(self):
     return utils.hash_b64(self.uid)
Exemplo n.º 10
0
 def get_hash(self):
     return utils.hash_b64(utils.to_json(self.toJSONDict()))
Exemplo n.º 11
0
 def get_hash(self):
     return utils.hash_b64(
         utils.to_json(self.toJSONDict(), no_whitespace=True))
Exemplo n.º 12
0
 def compute_vote_hash(self):
     vote_hash = utils.hash_b64(utils.to_json(self.vote))
     return vote_hash
Exemplo n.º 13
0
 def voter_id_hash(self):
   return utils.hash_b64(self.voter_id)
Exemplo n.º 14
0
 def compute_vote_hash(self):
   vote_hash = utils.hash_b64(utils.to_json(self.vote))
   return vote_hash
Exemplo n.º 15
0
 def get_voters_hash(self):
   voters = self.get_voters()
   voters_json = dumps([v.toJSONDict(with_vote=False, with_vote_hash=False) for v in voters])
   # logging.info("json for voters is: " + voters_json)
   return utils.hash_b64(voters_json)