Zaphenath is a smart contract system for secure key-value storage with inactivity-based conditional access. It supports role-based access control, data privacy before inactivity timeouts, and multi-user custodianship. Designed for sensitive data management, such as wills or internal company secrets.
🧭 Live docs: https://zaphenath.astervia.tech
- Create, read, update, and delete encrypted key data.
- Automatic data exposure after owner inactivity (ping-based).
- Fine-grained role control:
Owner,Writer,Reader,None. - Custodian system supports delegated read/write/ping permissions.
.
├── src/
│ ├── Zaphenath.sol # Main contract logic
│ ├── Role.sol # Role enum
│ ├── Custodian.sol # Custodian struct
│ └── KeyData.sol # KeyData struct with mappings
├── test/
│ └── Zaphenath.t.sol # Full test suite using Foundry
├── script/
│ └── Zaphenath.s.sol # Deployment script
└── foundry.toml # Foundry config
Ensure Foundry is installed:
curl -L https://foundry.paradigm.xyz | bash
foundryupStart a local node:
anvilThen deploy:
forge script script/Zaphenath.s.sol --broadcast --rpc-url http://localhost:8545Set your private key and RPC in environment variables or .env:
export PRIVATE_KEY=<your_private_key>
export RPC_URL=https://sepolia.infura.io/v3/YOUR_INFURA_KEYThen run:
forge script script/Zaphenath.s.sol --broadcast --rpc-url $RPC_URL --private-key $PRIVATE_KEYRun the test suite with verbose output:
forge test -vvYou'll see detailed logs thanks to console.log statements.
| Role | Description |
|---|---|
| Owner | Full control, set custodians |
| Writer | Can update or delete the key |
| Reader | Can read after timeout (or before, if allowed) |
| None | No access |
Use setCustodian() and removeCustodian() to manage roles.
About reading keys: Roles are just formalities when reading keys. Since
readKeyis aviewfunction, one can use a reader address to declare identity and execute this function (viewfunctions don't require signed transactions). So we advise you to combine on-chain and off-chain methods to guarantee your privacy when using smart contracts like this.
- Each key has a
timeout(in seconds) andlastPingtimestamp. - When
block.timestamp - lastPing > timeout, key data becomes available. ping()resets the timer, keeping data private.
MIT License. See LICENSE file.