Skip to content
Snippets Groups Projects
Commit ad73122e authored by Vincent Texier's avatar Vincent Texier
Browse files

[enh] #95 optimize code

parent 603e231b
No related branches found
No related tags found
No related merge requests found
Pipeline #12907 passed
...@@ -220,14 +220,14 @@ CertTimestamp: {timestamp} ...@@ -220,14 +220,14 @@ CertTimestamp: {timestamp}
""" """
if not isinstance(self.identity, Identity): if not isinstance(self.identity, Identity):
raise MalformedDocumentError( raise MalformedDocumentError(
"Identity is a pubkey or None, can not create raw format" "Identity is not defined or properly defined. Can not create raw format"
) )
if self.signature is None: if self.signature is None:
raise MalformedDocumentError("Signature is None, can not create raw format") raise MalformedDocumentError(
"Signature is not defined, can not create signed raw format"
)
raw = self.raw() return f"{self.raw()}{self.signature}\n"
signed_raw = raw + self.signature + "\n"
return signed_raw
def inline(self) -> str: def inline(self) -> str:
""" """
......
...@@ -105,10 +105,11 @@ class Document: ...@@ -105,10 +105,11 @@ class Document:
:return: :return:
""" """
if self.signature is None: if self.signature is None:
raise MalformedDocumentError("Signature is None, can not create raw format") raise MalformedDocumentError(
raw = self.raw() "Signature is not defined, can not create signed raw format"
signed_raw = raw + self.signature + "\n" )
return signed_raw
return f"{self.raw()}{self.signature}\n"
@property @property
def sha_hash(self) -> str: def sha_hash(self) -> str:
...@@ -128,7 +129,7 @@ class Document: ...@@ -128,7 +129,7 @@ class Document:
:return: :return:
""" """
if self.signature is None: if self.signature is None:
raise Exception("Signature is None, can not check signature") raise Exception("Signature is not defined, can not check signature")
verifying_key = VerifyingKey(pubkey) verifying_key = VerifyingKey(pubkey)
......
...@@ -198,7 +198,7 @@ IdtySignature: {signature} ...@@ -198,7 +198,7 @@ IdtySignature: {signature}
""" """
Sign the current document Sign the current document
:param key: List of libnacl key instances :param key: Libnacl key instance
:return: :return:
""" """
if not isinstance(self.identity, Identity): if not isinstance(self.identity, Identity):
...@@ -215,10 +215,9 @@ IdtySignature: {signature} ...@@ -215,10 +215,9 @@ IdtySignature: {signature}
""" """
if not isinstance(self.identity, Identity): if not isinstance(self.identity, Identity):
raise MalformedDocumentError( raise MalformedDocumentError(
"Identity is a pubkey or None, can not create raw format" "Identity is not defined or properly defined. Can not create raw format"
) )
if self.signature is None: if self.signature is None:
raise MalformedDocumentError("Signature is None, can not create raw format") raise MalformedDocumentError("Signature is None, can not create raw format")
raw = self.raw()
signed_raw = raw + self.signature + "\n" return f"{self.raw()}{self.signature}\n"
return signed_raw
...@@ -960,7 +960,7 @@ Currency: {1} ...@@ -960,7 +960,7 @@ Currency: {1}
def check_signatures(self, pubkeys: List[str]): def check_signatures(self, pubkeys: List[str]):
""" """
Check if the signatures matches pubkeys Check if the signatures matches the pubkeys
:param pubkeys: List of Base58 public keys :param pubkeys: List of Base58 public keys
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment