File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,23 @@ def sign_query(query, private_key):
102102 query .signature .CopyFrom (signature )
103103 return query
104104
105+ @staticmethod
106+ def is_signature_valid (message , signature ):
107+ """
108+ Verify signature validity.
109+ :param signature: the signature to be checked
110+ :param message: message to check the signature against
111+ :return: bool, whether the signature is valid for the message
112+ """
113+ message_hash = IrohaCrypto .hash (message )
114+ try :
115+ signature_bytes = binascii .unhexlify (signature .signature )
116+ public_key = binascii .unhexlify (signature .public_key )
117+ ed25519 .checkvalid (signature_bytes , message_hash , public_key )
118+ return True
119+ except (ed25519 .SignatureMismatch , ValueError ):
120+ return False
121+
105122 @staticmethod
106123 def reduced_hash (transaction ):
107124 """
You can’t perform that action at this time.
0 commit comments