|
@@ -40,10 +40,11 @@ class RelayDescriptor:
|
|
|
signed = signingkey.sign(serialized.encode("ascii"))
|
|
|
self.descdict["sig"] = signed.signature
|
|
|
|
|
|
-
|
|
|
-def verify_relaydesc(desc):
|
|
|
- serialized = desc.__str__(False)
|
|
|
- desc.descdict["idkey"].verify(serialized.encode("ascii"), desc.descdict["sig"])
|
|
|
+ @staticmethod
|
|
|
+ def verify(desc):
|
|
|
+ assert(type(desc) is RelayDescriptor)
|
|
|
+ serialized = desc.__str__(False)
|
|
|
+ desc.descdict["idkey"].verify(serialized.encode("ascii"), desc.descdict["sig"])
|
|
|
|
|
|
|
|
|
# A consensus is a dict containing:
|
|
@@ -108,14 +109,14 @@ class Consensus:
|
|
|
idx = bisect.bisect_right(cdf, val)
|
|
|
return self.consdict['relays'][idx-1]
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-def verify_consensus(consensus, verifkeylist):
|
|
|
- """Use the given list of verification keys to check the
|
|
|
- signatures on the consensus."""
|
|
|
- serialized = consensus.__str__(False)
|
|
|
- for i, vk in enumerate(verifkeylist):
|
|
|
- vk.verify(serialized.encode("ascii"), consensus.consdict['sigs'][i])
|
|
|
+ @staticmethod
|
|
|
+ def verify(consensus, verifkeylist):
|
|
|
+ """Use the given list of verification keys to check the
|
|
|
+ signatures on the consensus."""
|
|
|
+ assert(type(consensus) is Consensus)
|
|
|
+ serialized = consensus.__str__(False)
|
|
|
+ for i, vk in enumerate(verifkeylist):
|
|
|
+ vk.verify(serialized.encode("ascii"), consensus.consdict['sigs'][i])
|
|
|
|
|
|
|
|
|
class DirAuthNetMsg(network.NetMsg):
|