Using keccak-256 for hashing. Closes #45.

pull/44/head
jMyles 2017-09-19 16:13:33 -07:00
parent 9e314d8b81
commit c55c0302e7
2 changed files with 6 additions and 5 deletions

View File

@ -1,10 +1,10 @@
import random
import sha3
# TODO: Replace these with actual hash functions.
def signature_hash(hash_input):
return random.getrandbits(128)
return sha3.keccak_256(hash_input).digest()
def content_hash(hash_input):
return random.getrandbits(128)
return sha3.keccak_256(hash_input).digest()

View File

@ -79,8 +79,9 @@ class Policy(object):
return policy
def hash(self, pubkey_sig_alice, hash_input):
hash_input = str(hash_input).encode()
self.hashed_part = content_hash(hash_input)
hash_input_for_id = (pubkey_sig_alice, self.hashed_part)
hash_input_for_id = str(pubkey_sig_alice).encode() + str(self.hashed_part).encode()
self.id = content_hash(hash_input_for_id)
return self.id