Skip to content

KeyData Struct

The KeyData struct holds the full state of a single key in the Zaphenath contract. It encapsulates all metadata and access configurations for secure storage.

๐Ÿ“˜ Definition

struct KeyData {
    address owner;
    bytes data;
    uint256 lastPing;
    uint256 timeout;
    mapping(address => Custodian) custodians;
    bool exists;
}

โ„น๏ธ The KeyData struct uses an internal mapping, so it cannot be returned or passed directly in external/public functions.

๐Ÿ” Fields

Field Type Description
owner address Owner of the key
data bytes Encrypted or opaque data payload
lastPing uint256 Timestamp of last ping()
timeout uint256 Number of seconds before data becomes accessible
custodians mapping(address => Custodian) Role and ping permission map for external users
exists bool Tracks if the key is initialized

๐Ÿง  Design Considerations

  • Uses nested mappings to support per-user access control.
  • exists avoids accidental reads on uninitialized keys.

๐Ÿงช Testing Tips

  • Validate default values upon key creation
  • Verify access rules with various custodian combinations
  • Ensure timeout enforcement and ping() logic are working

โžก๏ธ Proceed to Using Roles and Permissions