mirror of
https://gitlab.com/pulsechaincom/staking-deposit-cli.git
synced 2025-01-10 21:11:21 +00:00
Groups credential properties together
This commit is contained in:
parent
ef0ad43216
commit
c6401c8e7b
@ -51,21 +51,6 @@ class Credential:
|
||||
withdrawal_credentials += SHA256(self.withdrawal_pk)[1:]
|
||||
return withdrawal_credentials
|
||||
|
||||
def signing_keystore(self, password: str) -> Keystore:
|
||||
secret = self.signing_sk.to_bytes(32, 'big')
|
||||
return ScryptKeystore.encrypt(secret=secret, password=password, path=self.signing_key_path)
|
||||
|
||||
def save_signing_keystore(self, password: str, folder: str) -> str:
|
||||
keystore = self.signing_keystore(password)
|
||||
filefolder = os.path.join(folder, 'keystore-%s-%i.json' % (keystore.path.replace('/', '_'), time.time()))
|
||||
keystore.save(filefolder)
|
||||
return filefolder
|
||||
|
||||
def verify_keystore(self, keystore_filefolder: str, password: str) -> bool:
|
||||
saved_keystore = Keystore.from_json(keystore_filefolder)
|
||||
secret_bytes = saved_keystore.decrypt(password)
|
||||
return self.signing_sk == int.from_bytes(secret_bytes, 'big')
|
||||
|
||||
@property
|
||||
def deposit_message(self) -> DepositMessage:
|
||||
return DepositMessage(
|
||||
@ -93,6 +78,22 @@ class Credential:
|
||||
datum_dict.update({'fork_version': self.fork_version})
|
||||
return datum_dict
|
||||
|
||||
def signing_keystore(self, password: str) -> Keystore:
|
||||
secret = self.signing_sk.to_bytes(32, 'big')
|
||||
return ScryptKeystore.encrypt(secret=secret, password=password, path=self.signing_key_path)
|
||||
|
||||
def save_signing_keystore(self, password: str, folder: str) -> str:
|
||||
keystore = self.signing_keystore(password)
|
||||
filefolder = os.path.join(folder, 'keystore-%s-%i.json' % (keystore.path.replace('/', '_'), time.time()))
|
||||
keystore.save(filefolder)
|
||||
return filefolder
|
||||
|
||||
def verify_keystore(self, keystore_filefolder: str, password: str) -> bool:
|
||||
saved_keystore = Keystore.from_json(keystore_filefolder)
|
||||
secret_bytes = saved_keystore.decrypt(password)
|
||||
return self.signing_sk == int.from_bytes(secret_bytes, 'big')
|
||||
|
||||
|
||||
|
||||
class CredentialList:
|
||||
def __init__(self, credentials: List[Credential]):
|
||||
|
Loading…
Reference in New Issue
Block a user