client.did module¶
-
class
factom_did.client.did.
DID
(did=None, management_keys=None, did_keys=None, services=None, spec_version='0.2.0')¶ Bases:
object
Enables the construction of a DID document, by facilitating the construction of management keys and DID keys and the addition of services. Allows exporting of the resulting DID object into a format suitable for recording on the Factom blockchain.
Provides encryption functionality of private keys for the DID and their export to a string or to a JSON file.
-
did
¶ The decentralized identifier, a 32 byte hexadecimal string
Type: str, optional
-
management_keys
¶ A list of management keys
Type: ManagementKey[], optional
-
deactivate
()¶ Raises: RuntimeError
– If no management keys are available for the DIDReturns: Return type: DIDDeactivator
-
did_key
(alias, purpose, key_type=<KeyType.EdDSA: 'Ed25519VerificationKey'>, controller=None, priority_requirement=None)¶ Creates a new DID key for the DID.
Parameters: - alias (str) – A human-readable nickname for the key. It should be unique across the keys defined in the DID document.
- purpose (DIDKeyPurpose or DIDKeyPurpose[]) – Shows what purpose(s) the key serves. (PublicKey, AuthenticationKey or both)
- key_type (KeyType, optional) – Identifies the type of signature that the key pair can be used to generate and verify.
- controller (str, optional) – An entity that will be making the signatures. It must be a valid DID. If the argument is not passed in, the default value is used which is the current DID itself.
- priority_requirement (int, optional) – A non-negative integer showing the minimum hierarchical level a key must have in order to remove this key.
-
export_encrypted_keys_as_json
(password)¶ Exports encrypted keys as JSON.
Parameters: password (str) – A password to use for the encryption of the keys. Returns: Encrypted keys JSON. Return type: str
-
export_encrypted_keys_as_str
(password)¶ Exports encrypted keys cipher text.
Parameters: password (str) – A password to use for the encryption of the keys. Returns: Encrypted keys cipher text. Return type: str
-
export_entry_data
()¶ Exports content that can be recorded on-chain to create the DID.
Returns: A dictionary with the ExtIDs and entry content of strings used that are the header columns. Return type: dict Raises: ValueError
– If there are no management keys. If there is no management key with priority 0. If the entry size exceeds the entry size limit.
-
get_chain
()¶ Returns: The chain ID where this DID is (or will be) stored Return type: str
-
id
¶
-
static
is_valid_did
(did)¶
-
mainnet
()¶ Sets the DID network to mainnet.
-
management_key
(alias, priority, key_type=<KeyType.EdDSA: 'Ed25519VerificationKey'>, controller=None, priority_requirement=None)¶ Creates a new management key for the DID.
Parameters: - alias (str) – A human-readable nickname for the key. It should be unique across the keys defined in the DID document.
- priority (int) – A non-negative integer showing the hierarchical level of the key. Keys with lower priority override keys with higher priority.
- key_type (KeyType, optional) – Identifies the type of signature that the key pair can be used to generate and verify.
- controller (str, optional) – An entity that controls the key. It must be a valid DID. If the argument is not passed in, the default value is used which is the current DID itself.
- priority_requirement (int, optional) – A non-negative integer showing the minimum hierarchical level a key must have in order to remove this key.
-
method_spec_version_upgrade
(new_spec_version)¶ Parameters: new_spec_version (str) – The new DID Method version
Raises: RuntimeError
– If no management keys are available for the DIDValueError
– If the new version is not an upgrade on the current version
Returns: Return type:
-
record_on_chain
(factomd, walletd, ec_address, verbose=False)¶ Attempts to create the DIDManagement chain.
Parameters: - factomd (obj) – Factomd instance, instantiated from the Python factom-api package.
- walletd (obj) – Factom walletd instance, instantiated from the Python factom-api package.
- ec_address (str) – EC address used to pay for the chain & entry creation.
- verbose (bool, optional) – If true, display the contents of the entry that will be recorded on-chain.
Raises: RuntimeError
– If the chain cannot be created
-
service
(alias, service_type, endpoint, priority_requirement=None, custom_fields=None)¶ Adds a new service to the DID Document.
Parameters: - alias (str) – A human-readable nickname for the service endpoint. It should be unique across the services defined in the DID document.
- service_type (str) – Type of the service endpoint.
- endpoint (str) – A service endpoint may represent any type of service the subject wishes to advertise, including decentralized identity management services for further discovery, authentication, authorization, or interaction. The service endpoint must be a valid URL.
- priority_requirement (int, optional) – A non-negative integer showing the minimum hierarchical level a key must have in order to remove this service.
- custom_fields (dict, optional) – A dictionary containing custom fields (e.g “description”: “My public social inbox”).
-
testnet
()¶ Sets the DID network to testnet.
-
update
()¶ Raises: RuntimeError
– If no management keys are available for the DIDReturns: An object allowing updates to the existing DID Return type: DIDUpdater
-