Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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
Exemple #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
Exemple #6
0
 def hash(self):
     s = utils.to_json(self.toJSONDict())
     return utils.hash_b64(s)
Exemple #7
0
 def get_hash(self):
     return utils.hash_b64(utils.to_json(self.toJSONDict()))
Exemple #8
0
 def hash(self):
   s = utils.to_json(self.toJSONDict())
   return utils.hash_b64(s)
Exemple #9
0
 def voter_id_hash(self):
     return utils.hash_b64(self.uid)
Exemple #10
0
 def get_hash(self):
     return utils.hash_b64(utils.to_json(self.toJSONDict()))
 def get_hash(self):
     return utils.hash_b64(
         utils.to_json(self.toJSONDict(), no_whitespace=True))
Exemple #12
0
 def compute_vote_hash(self):
     vote_hash = utils.hash_b64(utils.to_json(self.vote))
     return vote_hash
 def voter_id_hash(self):
   return utils.hash_b64(self.voter_id)
Exemple #14
0
 def compute_vote_hash(self):
   vote_hash = utils.hash_b64(utils.to_json(self.vote))
   return vote_hash
Exemple #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)