client.keys.abstract module

class factom_did.client.keys.abstract.AbstractDIDKey(alias, key_type, controller, priority_requirement, public_key=None, private_key=None)

Bases: object

Represents the common fields and functionality in a ManagementKey and a DidKey.

alias

A human-readable nickname for the key.

Type:str
key_type

Identifies the type of signature that the key pair can be used to generate and verify.

Type:KeyType
controller

An entity that controls the key.

Type:str
priority_requirement

A non-negative integer showing the minimum hierarchical level a key must have in order to remove this key.

Type:int
public_key

The public key.

Type:bytes or str, optional
private_key

The private key.

Type:bytes or str, optional
static from_entry_dict(entry_dict, version='1.0.0')

Creates an AbstractDIDKey object from an on-chain entry

Parameters:
  • entry_dict (dict) – The on-chain entry, represented as a Python dictionary
  • version (str) – The entry schema version
Returns:

Return type:

AbstractDIDKey

Raises:

NotImplementedError – If the supplied version is not supported

full_id(did)

Constructs the full ID of the key.

Parameters:did (str) –
Returns:The full id for the key, constituting of the DID_METHOD_NAME, the network, the chain ID and the key alias.
Return type:str
private_key
public_key
rotate()

Generates new key pair for the key.

sign(message, hash_f=None)
signing_key
to_entry_dict(did, version='1.0.0')

Converts the object to a dictionary suitable for recording on-chain.

Parameters:
  • did (str) – The DID with which this key is associated. Note that this can be different from the key controller.
  • version (str) – The entry schema version
Returns:

Dictionary with id, type, controller and an optional priorityRequirement fields. In addition to those, there is one extra field for the public key: if the selected signature type is SignatureType.RSA, then this field is called publicKeyPem, otherwise it is called publicKeyBase58.

Return type:

dict

verify(message, signature, hash_f=None)
verifying_key