This commit is contained in:
Victor Shyba 2020-12-24 03:06:57 -03:00
parent 0a53ad5721
commit 2a17787242

View file

@ -26,16 +26,16 @@ def is_comment_signed_by_channel(comment: dict, channel: Output, sign_comment_id
if isinstance(channel, Output): if isinstance(channel, Output):
try: try:
signing_field = comment['comment_id'] if sign_comment_id else comment['comment'] signing_field = comment['comment_id'] if sign_comment_id else comment['comment']
return verify(channel, signing_field.encode(), comment) return verify(channel, signing_field.encode(), comment, cid2hash(comment['channel_id']))
except KeyError: except KeyError:
pass pass
return False return False
def verify(channel, data, signature): def verify(channel, data, signature, channel_hash=None):
pieces = [ pieces = [
signature['signing_ts'].encode(), signature['signing_ts'].encode(),
channel.claim_hash, channel_hash or channel.claim_hash,
data data
] ]
return Output.is_signature_valid( return Output.is_signature_valid(