From ae28f04ce4dd1ee29e819e37731a303b546c9c08 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Mon, 10 Jul 2023 00:54:02 +0200 Subject: [PATCH] Added bytes input to destination hash convenience functions --- RNS/Destination.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/RNS/Destination.py b/RNS/Destination.py index f140e00..f79a689 100755 --- a/RNS/Destination.py +++ b/RNS/Destination.py @@ -99,7 +99,12 @@ class Destination: name_hash = RNS.Identity.full_hash(Destination.expand_name(None, app_name, *aspects).encode("utf-8"))[:(RNS.Identity.NAME_HASH_LENGTH//8)] addr_hash_material = name_hash if identity != None: - addr_hash_material += identity.hash + if isinstance(identity, RNS.Identity): + addr_hash_material += identity.hash + elif isinstance(identity, bytes) and len(identity) == RNS.Reticulum.TRUNCATED_HASHLENGTH//8: + addr_hash_material += identity + else: + raise TypeError("Invalid material supplied for destination hash calculation") return RNS.Identity.full_hash(addr_hash_material)[:RNS.Reticulum.TRUNCATED_HASHLENGTH//8]