client.encryptor module¶
-
factom_did.client.encryptor.
encrypt_keys
(management_keys, did_keys, password)¶ Encrypts keys with a password.
Parameters: - management_keys (ManagementKeyModel[]) – A list of management keys to be encrypted.
- did_keys (DidKeyModel[]) – A list of did keys to be encrypted.
- password (str) – A password to use for the encryption of the keys.
Returns: An object containing salt, initial vector, tag and encrypted data.
Return type: obj
-
factom_did.client.encryptor.
decrypt_keys_from_str
(cipher_text_b64, password, encryption_algo='AES-GCM')¶ Decrypts keys from cipher text and password.
Parameters: - cipher_text_b64 (str) – Base 64 encoded cipher text.
- password (str) – A password used for the encryption of the keys.
- encryption_algo (str) – The encryption algorithm used. Currently only ‘AES-GCM’ is supported
Returns: An object containing dictionaries of decrypted management and did keys.
Return type: obj
Raises: ValueError
– If the cipher text or the password used for the encryption is invalid.
-
factom_did.client.encryptor.
decrypt_keys_from_json_str
(encrypted_keys_json_str, password)¶ Decrypts keys from JSON string and password. The JSON string must have a schema compatible with the one produced by DID.export_encrypted_keys_as_json():
- ‘{
- “encryptionAlgo”: {
- “salt”: …, “iv”: …, “name”: …, “tagLength”: …,
}, “data”: … (encrypted private keys), “did”: …
}’
Parameters: - encrypted_keys_json_str (str) – JSON string containing encrypted keys data.
- password (str) – A password used for the encryption of the keys.
Returns: An object containing dictionaries of decrypted management and did keys.
Return type: obj
Raises: ValueError
– If the JSON or the password used for the encryption is invalid.
-
factom_did.client.encryptor.
decrypt_keys_from_json_file
(file_path, password)¶ Decrypts keys from JSON file and password. The file must contain valid JSON with a schema compatible with the one produced by DID.export_encrypted_keys_as_json(). See decrypt_keys_from_json_str for details.
Parameters: - file_path (str) – Path to a file to read from.
- password (str) – A password used for the encryption of the keys.
Returns: An object containing dictionaries of decrypted management and did keys.
Return type: obj
Raises: ValueError
– If the file or the password is invalid.