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)
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)
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
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
def hash(self): s = utils.to_json(self.toJSONDict()) return utils.hash_b64(s)
def get_hash(self): return utils.hash_b64(utils.to_json(self.toJSONDict()))
def voter_id_hash(self): return utils.hash_b64(self.uid)
def get_hash(self): return utils.hash_b64( utils.to_json(self.toJSONDict(), no_whitespace=True))
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)
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)