Skip to content

Ping Mechanism

The ping() function is a core feature of the Zaphenath contract. It keeps data private by updating the lastPing timestamp and thereby delaying the timeout.

๐Ÿงญ Purpose

Zaphenath allows data to be accessed only after the owner has been inactive for a certain period. This inactivity is measured as:

block.timestamp - lastPing > timeout

By calling ping(), the owner or an authorized custodian can reset this timer.

๐Ÿ” Function Signature

function ping(bytes32 keyId, address owner) external;

โœ… Who Can Ping?

  • Owner: Always allowed
  • Custodians: Only if canPing was set to true by the owner

๐Ÿ›  Use Cases

  • Keep private data hidden as long as the user is "active"
  • Allow a trusted custodian to maintain activity on behalf of a user
  • Ensure data is only released if truly inactive or incapacitated

โš ๏ธ Behavior

  • If a user fails to call ping() and timeout expires, data becomes readable by Readers and Writers
  • Repeated ping() calls extend the private window indefinitely

๐Ÿงช Testing Scenarios

  • Owner calls ping() โ†’ should update lastPing
  • Custodian without ping permission โ†’ call reverts
  • Custodian with ping permission โ†’ call succeeds
  • No ping() and time advances โ†’ readKey() becomes accessible

โžก๏ธ Continue to Key Lifecycle