bittensor_wallet.keyfile#
|
Prompts the user to enter a password for key encryption. |
|
Decrypts the passed keyfile data using ansible vault. |
|
Deserializes Keypair object from passed keyfile data. |
|
Encrypts the passed keyfile data using ansible vault. |
|
|
|
Retrieves the cold key password from the environment variables. |
|
Returns type of encryption method as a string. |
|
Returns true if the keyfile data is encrypted. |
|
Returns true if the keyfile data is ansible encrypted. |
|
Returns true if the keyfile data is legacy encrypted. |
|
Returns true if the keyfile data is NaCl encrypted. |
|
legacy_encrypt_keyfile_data. |
|
Serializes keypair object into keyfile data. |
|
Validates the password against a password policy. |
|
Module Contents#
Functions Details
- class bittensor_wallet.keyfile.Keyfile(path=None, name=None, should_save_to_env=False)
Bases:
object- check_and_update_encryption(print_result=True, no_prompt=False)
Check the version of keyfile and update if needed.
- data
Returns the keyfile data under path.
- decrypt(password=None)
Decrypts the file under the path.
- Parameters:
password (Option<String>) – The password used to decrypt the data. If
None, asks for user input.
- encrypt(password=None)
Encrypts the file under the path.
- Parameters:
password (Option<String>) – The password used to encrypt the data. If
None, asks for user input.
- env_var_name()
Returns local environment variable key name based on Keyfile path.
- exists_on_device()
Returns
Trueif the file exists on the device.- Returns:
Trueif the file is readable.
- get_keypair(password=None)
Returns the keypair from path, decrypts data if the file is encrypted.
- Parameters:
password (Option<String>) – The password used to decrypt the data. If
None, asks for user input.- Returns:
The Keypair loaded from the file.
- is_encrypted()
Returns
Trueif the file under path is encrypted.- Returns:
Trueif the file is encrypted.
- is_readable()
Returns
Trueif the file under path is readable.
- is_writable()
Returns
Trueif the file under path is writable.- Returns:
Trueif the file is writable.
- keypair
Returns the keypair from path, decrypts data if the file is encrypted.
- make_dirs()
Creates directories for the path if they do not exist.
- path
Returns the wallet path.
- remove_password_from_env()
Removes the password associated with the Keyfile from the local environment.
- save_password_to_env(password=None)
Saves the key’s password to the associated local environment variable.
- Parameters:
password (Option<String>) – The password to save. If
None, asks for user input.- Returns:
The base64-encoded encrypted password.
- set_keypair(keypair, encrypt=True, overwrite=False, password=None)
Writes the keypair to the file and optionally encrypts data.
- bittensor_wallet.keyfile.ask_password(validation_required)
Prompts the user to enter a password for key encryption.
- Parameters:
validation_required (bool) – If
True, validates the password against policy requirements.- Returns:
The valid password entered by the user.
- bittensor_wallet.keyfile.decrypt_keyfile_data(keyfile_data, password=None, password_env_var=None)
Decrypts the passed keyfile data using ansible vault.
- bittensor_wallet.keyfile.deserialize_keypair_from_keyfile_data(keyfile_data)
Deserializes Keypair object from passed keyfile data.
- Parameters:
keyfile_data (PyBytes) – The keyfile data to be loaded.
- Returns:
The Keypair loaded from bytes.
- Raises:
KeyFileError – The passed pybytes cannot construct a keypair object.
- bittensor_wallet.keyfile.encrypt_keyfile_data(keyfile_data, password=None)
Encrypts the passed keyfile data using ansible vault.
- bittensor_wallet.keyfile.get_coldkey_password_from_environment(env_var_name)
- bittensor_wallet.keyfile.get_password_from_environment(env_var_name)
Retrieves the cold key password from the environment variables.
- Parameters:
coldkey_name – The name of the cold key.
- Returns:
Option<String> - The password retrieved from the environment variables, or None if not found.
- bittensor_wallet.keyfile.keyfile_data_encryption_method(keyfile_data)
Returns type of encryption method as a string.
- bittensor_wallet.keyfile.keyfile_data_is_encrypted(keyfile_data)
Returns true if the keyfile data is encrypted.
- bittensor_wallet.keyfile.keyfile_data_is_encrypted_ansible(keyfile_data)
Returns true if the keyfile data is ansible encrypted.
- Parameters:
validate. (keyfile_data - The bytes to)
- Returns:
is_ansible -
Trueif the data is ansible encrypted.
- bittensor_wallet.keyfile.keyfile_data_is_encrypted_legacy(keyfile_data)
Returns true if the keyfile data is legacy encrypted.
- Parameters:
validate. (keyfile_data - The bytes to)
- Returns:
is_legacy - true if the data is legacy encrypted.
- bittensor_wallet.keyfile.keyfile_data_is_encrypted_nacl(keyfile_data)
Returns true if the keyfile data is NaCl encrypted.
- Parameters:
validate (keyfile_data - Bytes to)
- Returns:
is_nacl - true if the data is ansible encrypted.
- bittensor_wallet.keyfile.legacy_encrypt_keyfile_data(keyfile_data, password=None)
legacy_encrypt_keyfile_data.
- bittensor_wallet.keyfile.serialized_keypair_to_keyfile_data(keypair)
Serializes keypair object into keyfile data.
- Parameters:
keypair (Keypair) – The keypair object to be serialized.
- Returns:
Serialized keypair data.
- bittensor_wallet.keyfile.validate_password(password)
Validates the password against a password policy.
- Parameters:
password (str) – The password to verify.
- Returns:
Trueif the password meets validity requirements.
Classes Details
- class bittensor_wallet.keyfile.Keyfile(path=None, name=None, should_save_to_env=False)
Bases:
object- check_and_update_encryption(print_result=True, no_prompt=False)
Check the version of keyfile and update if needed.
- decrypt(password=None)
Decrypts the file under the path.
- Parameters:
password (Option<String>) – The password used to decrypt the data. If
None, asks for user input.
- encrypt(password=None)
Encrypts the file under the path.
- Parameters:
password (Option<String>) – The password used to encrypt the data. If
None, asks for user input.
- env_var_name()
Returns local environment variable key name based on Keyfile path.
- exists_on_device()
Returns
Trueif the file exists on the device.- Returns:
Trueif the file is readable.
- get_keypair(password=None)
Returns the keypair from path, decrypts data if the file is encrypted.
- Parameters:
password (Option<String>) – The password used to decrypt the data. If
None, asks for user input.- Returns:
The Keypair loaded from the file.
- is_encrypted()
Returns
Trueif the file under path is encrypted.- Returns:
Trueif the file is encrypted.
- is_readable()
Returns
Trueif the file under path is readable.
- is_writable()
Returns
Trueif the file under path is writable.- Returns:
Trueif the file is writable.
- make_dirs()
Creates directories for the path if they do not exist.
- set_keypair(keypair, encrypt=True, overwrite=False, password=None)
Writes the keypair to the file and optionally encrypts data.
- data
Returns the keyfile data under path.
- check_and_update_encryption(print_result=True, no_prompt=False)
Check the version of keyfile and update if needed.
- data
Returns the keyfile data under path.
- decrypt(password=None)
Decrypts the file under the path.
- Parameters:
password (Option<String>) – The password used to decrypt the data. If
None, asks for user input.
- encrypt(password=None)
Encrypts the file under the path.
- Parameters:
password (Option<String>) – The password used to encrypt the data. If
None, asks for user input.
- env_var_name()
Returns local environment variable key name based on Keyfile path.
- exists_on_device()
Returns
Trueif the file exists on the device.- Returns:
Trueif the file is readable.
- get_keypair(password=None)
Returns the keypair from path, decrypts data if the file is encrypted.
- Parameters:
password (Option<String>) – The password used to decrypt the data. If
None, asks for user input.- Returns:
The Keypair loaded from the file.
- is_encrypted()
Returns
Trueif the file under path is encrypted.- Returns:
Trueif the file is encrypted.
- is_readable()
Returns
Trueif the file under path is readable.
- is_writable()
Returns
Trueif the file under path is writable.- Returns:
Trueif the file is writable.
- keypair
Returns the keypair from path, decrypts data if the file is encrypted.
- make_dirs()
Creates directories for the path if they do not exist.
- path
Returns the wallet path.
- remove_password_from_env()
Removes the password associated with the Keyfile from the local environment.
- save_password_to_env(password=None)
Saves the key’s password to the associated local environment variable.
- Parameters:
password (Option<String>) – The password to save. If
None, asks for user input.- Returns:
The base64-encoded encrypted password.
- set_keypair(keypair, encrypt=True, overwrite=False, password=None)
Writes the keypair to the file and optionally encrypts data.