Refactoring work for rnid

This commit is contained in:
Mark Qvist
2026-05-07 14:11:49 +02:00
parent c0ae63e27a
commit 928c02099b
4 changed files with 709 additions and 556 deletions
-1
View File
@@ -35,7 +35,6 @@ class Ed25519PrivateKey:
def __init__(self, seed):
self.seed = seed
self.sk = ed25519.SigningKey(self.seed)
#self.vk = self.sk.get_verifying_key()
@classmethod
def generate(cls):
+4
View File
@@ -62,3 +62,7 @@ def sha512(data):
digest.update(data)
return digest.digest()
def file_sha256(file):
if not hashlib: raise SystemError("The hashlib module is not available on this system")
else: return hashlib.file_digest(file, "sha256").digest()
+20 -2
View File
@@ -656,6 +656,22 @@ class Identity:
RNS.log("Error while saving identity to "+str(path), RNS.LOG_ERROR)
RNS.log("The contained exception was: "+str(e))
def pub_to_file(self, path):
"""
Saves the public identity to a file.
:param path: The full path specifying where to save the identity.
:returns: True if the file was saved, otherwise False.
"""
try:
with open(path, "wb") as key_file:
key_file.write(self.get_public_key())
return True
return False
except Exception as e:
RNS.log("Error while saving identity to "+str(path), RNS.LOG_ERROR)
RNS.log("The contained exception was: "+str(e))
def __init__(self,create_keys=True):
# Initialize keys to none
self.prv = None
@@ -695,13 +711,15 @@ class Identity:
"""
:returns: The private key as *bytes*
"""
return self.prv_bytes+self.sig_prv_bytes
if self.prv_bytes and self.sig_prv_bytes: return self.prv_bytes+self.sig_prv_bytes
else: return None
def get_public_key(self):
"""
:returns: The public key as *bytes*
"""
return self.pub_bytes+self.sig_pub_bytes
if self.pub_bytes and self.sig_pub_bytes: return self.pub_bytes+self.sig_pub_bytes
else: return None
def load_private_key(self, prv_bytes):
"""
+685 -553
View File
File diff suppressed because it is too large Load Diff