Skip to content

Creating and Managing Identities

Create a node

from keri_system import Node

node = Node(
    "/data", passphrase, network,
    role={"role": "org", "name": "acme"},
    governance={"keys": 3, "threshold": 2, "recovery_keys": 1, "witnesses": "all", "toad": 3},
    policy={"version": "1", "trusted_roots": ["self"], "rules": []},
).start()
node.publish()
print(node.aid)

The first start creates the keys and the inception event, which anchors the policy and the governance rules. Later starts load the identity and refuse to run if policy, governance or role no longer match the log.

publish sends events to the witnesses and raises Pending until enough receipts arrived. Call it again, or let the next operation do it.

Network

{
  "relay": "ws://transport:8080",
  "witnesses": [{"aid": "B...", "url": "http://witness-0:8080"}],
  "watchers": [{"aid": "B...", "url": "http://watcher-0:8080"}]
}

kerictl bootstrap creates such a network with keys. Witnesses and watchers of other operators are added by identifier and address.

Governance

Field Meaning
keys, threshold Signing keys, and how many must sign. Up to 16 keys
recovery_keys Keys that can each rotate alone
witnesses "all" or a list of identifiers
toad Witness threshold. The default is the smallest safe value

Key custody

Private keys are encrypted with AES-GCM under a key derived from the passphrase with scrypt. The passphrase needs at least 16 characters. Keys in current use are cached in memory for five minutes.

With an external wallet, private keys never enter the node:

Node(..., wallet={"url": "http://wallet:8080", "token": token})

Rotate

node.manager.rotate()
node.manager.rotate(cuts=[old_witness], adds=[new_witness])
node.manager.rotate(use_recovery=True)

Rotate regularly, when staff changes, and immediately when keys may be exposed. A recovery rotation uses one recovery key. If unwitnessed interaction events are pending, a rotation replaces them.

Delegate

The delegate is created with a delegator and waits for approval:

block = Node(..., role={"role": "block", "name": "unit", "delegator": org.aid}, ...)
org.approve_delegation(block.delegation_seal())
block.publish()

Rotations of a delegated identity are approved in the same way.

Resolve other identities

state = node.identity.resolve(aid)
node.identity.assess(aid, state)

resolve collects events from the witnesses and verifies them. assess asks the watchers and raises Conflict if one reports a conflict, or Unavailable if too few answer.

Change the policy

node.update_policy(policy) anchors the new policy in the log.