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}
"""
if not isinstance(self.identity, Identity):
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:
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()
signed_raw = raw + self.signature + "\n"
return signed_raw
return f"{self.raw()}{self.signature}\n"
def inline(self) -> str:
"""
......
......@@ -105,10 +105,11 @@ class Document:
:return:
"""
if self.signature is None:
raise MalformedDocumentError("Signature is None, can not create raw format")
raw = self.raw()
signed_raw = raw + self.signature + "\n"
return signed_raw
raise MalformedDocumentError(
"Signature is not defined, can not create signed raw format"
)
return f"{self.raw()}{self.signature}\n"
@property
def sha_hash(self) -> str:
......@@ -128,7 +129,7 @@ class Document:
:return:
"""
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)
......
......@@ -198,7 +198,7 @@ IdtySignature: {signature}
"""
Sign the current document
:param key: List of libnacl key instances
:param key: Libnacl key instance
:return:
"""
if not isinstance(self.identity, Identity):
......@@ -215,10 +215,9 @@ IdtySignature: {signature}
"""
if not isinstance(self.identity, Identity):
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:
raise MalformedDocumentError("Signature is None, can not create raw format")
raw = self.raw()
signed_raw = raw + self.signature + "\n"
return signed_raw
return f"{self.raw()}{self.signature}\n"
......@@ -960,7 +960,7 @@ Currency: {1}
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment