From 3515480b1a353d03ffda0e1e00c430335144cde5 Mon Sep 17 00:00:00 2001 From: Alex Barnsley <8069294+alexbarnsley@users.noreply.github.com> Date: Tue, 15 Apr 2025 11:42:23 +0100 Subject: [PATCH 1/2] refactor: add new message static method --- crypto/utils/message.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/crypto/utils/message.py b/crypto/utils/message.py index 665a130..5780e47 100644 --- a/crypto/utils/message.py +++ b/crypto/utils/message.py @@ -28,6 +28,19 @@ def __init__(self, public_key: Union[bytes, str], message: Union[bytes, str], si else: self.signature = signature + @staticmethod + def new(public_key: Union[bytes, str], message: Union[bytes, str], signature: Union[bytes, str]): + """Creates a new message object + + Returns: + Message: returns a message object + """ + return Message( + public_key=public_key, + message=message, + signature=signature, + ) + @classmethod def sign(cls, message: Union[bytes, str], passphrase: Union[bytes, str]): """Signs a message From 2bed9b03e22253f45c62dffb1eb9e52bb8f85afc Mon Sep 17 00:00:00 2001 From: Alex Barnsley <8069294+alexbarnsley@users.noreply.github.com> Date: Tue, 15 Apr 2025 12:03:56 +0100 Subject: [PATCH 2/2] cast message string --- crypto/utils/message.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crypto/utils/message.py b/crypto/utils/message.py index 5780e47..fe76e9c 100644 --- a/crypto/utils/message.py +++ b/crypto/utils/message.py @@ -118,3 +118,11 @@ def to_json(self): data = self.to_dict() return json.dumps(data) + + def __str__(self): + """Returns a string representation of the message + + Returns: + str: string representation of the message + """ + return self.to_json()