Skip to content
Snippets Groups Projects

SignigKey: add read and write methods for private key:

Closed Moul requested to merge read_write_private_key_file into dev
Files
2
@@ -8,6 +8,7 @@ from typing import Optional, Union, TypeVar, Type
import libnacl.sign
import pyaes
from libnacl.utils import load_key
from pylibscrypt import scrypt
from .base58 import Base58Encoder
@@ -67,6 +68,28 @@ class SigningKey(libnacl.sign.Signer):
return cls(seed)
def save_private_key(self, path: str) -> None:
"""
Save authentication file
:param path: Authentication file path
"""
self.save(path)
def from_private_key(path: str) -> SigningKeyType:
"""
Read authentication file
Add public key attribute
:param path: Authentication file path
"""
key = load_key(path)
key.pubkey = Base58Encoder.encode(key.vk)
return key
def decrypt_seal(self, message: bytes) -> str:
"""
Decrypt message with a curve25519 version of the ed25519 key pair
Loading