diff --git a/lbrynet/dht/distance.py b/lbrynet/dht/distance.py index cda548db2..8945f8b30 100644 --- a/lbrynet/dht/distance.py +++ b/lbrynet/dht/distance.py @@ -1,3 +1,6 @@ +from lbrynet.dht import constants + + class Distance(object): """Calculate the XOR result between two string variables. @@ -6,6 +9,8 @@ class Distance(object): """ def __init__(self, key): + if len(key) != constants.key_bits / 8: + raise ValueError("invalid key length: %i", len(key)) self.key = key self.val_key_one = long(key.encode('hex'), 16)