diff --git a/nkms/crypto/hash.py b/nkms/crypto/hash.py index ddfea31ff..41583023e 100644 --- a/nkms/crypto/hash.py +++ b/nkms/crypto/hash.py @@ -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) \ No newline at end of file + return sha3.keccak_256(hash_input).digest() \ No newline at end of file diff --git a/nkms/policy/models.py b/nkms/policy/models.py index 57f2f6a94..d17ea9817 100644 --- a/nkms/policy/models.py +++ b/nkms/policy/models.py @@ -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