Key Lifecycle
This guide outlines the full lifecycle of a key in the Zaphenath systemβfrom creation to deletion, including access control and timeout transitions.
πͺͺ 1. Key Creation
Keys are created using createKey() by the owner.
zaph.createKey(keyId, data, timeout);
keyId: A unique identifier per owner (hashed internally)data: Encrypted or confidential contenttimeout: Seconds until public access if no ping
π 2. Key Access
Reading a key requires:
- Caller to be
Reader,Writer, orOwner - Timeout to have passed
zaph.readKey(keyId, owner);
[!WARNING] >
readKeyis aviewfunction. That means users can declare identity by providing addresses instead of signing transactions. After your timeout expires, any user that knows aReaderaddress can access your content. You should use on-chain and off-chain strategies to guarantee your privacy.
π 3. Maintaining Privacy (Ping)
The owner or a custodian (if allowed) must call ping() periodically to reset the lastPing timestamp:
zaph.ping(keyId, owner);
Failing to ping will result in data becoming readable after the timeout period.
π§βπ€βπ§ 4. Managing Custodians
The owner can assign or remove custodians:
zaph.setCustodian(keyId, owner, user, Role.Writer, true);
zaph.removeCustodian(keyId, owner, user);
βοΈ 5. Updating Keys
Users with Writer or Owner roles can update:
zaph.updateKey(keyId, owner, newData, newTimeout);
π 6. Deleting Keys
Writers and Owners can delete the key permanently:
zaph.deleteKey(keyId, owner);
π 7. Access Reverts to Public (Post-Timeout)
Once timeout expires and no ping has occurred, any custodian with Reader or higher access can read the key.
β‘οΈ See Examples for practical workflows