address-bookDirectory

Directory contract ABI and address constants for viewing key management

ABI and address constants for Seismic's Directory contract, which manages per-user AES-256 encryption keys.

Overview

The Directory contract is deployed at a fixed genesis address on all Seismic networks. It stores per-user viewing keys using shielded storage (suint256), enabling privacy-preserving balance queries and event decryption.

Users register their AES-256 encryption keys in the Directory, which are then used by contracts to encrypt sensitive data (like token balances and amounts) so only the key holder can decrypt them.

Constants

DIRECTORY_ADDRESS

The canonical Directory contract address, deployed at a fixed genesis address on all Seismic networks.

from seismic_web3 import DIRECTORY_ADDRESS

# Genesis address for Directory contract
DIRECTORY_ADDRESS: str = "0x1000000000000000000000000000000000000004"

DIRECTORY_ABI

Complete ABI for the Directory contract, including only the four functions needed by the Python SDK.

from seismic_web3 import DIRECTORY_ABI

DIRECTORY_ABI: list[dict[str, Any]]

Import

ABI Contents

Functions

Function
Parameters
Returns
Description

checkHasKey(address)

_addr

bool

Check if address has registered a viewing key (view)

keyHash(address)

to

bytes32

Get hash of address's viewing key (view)

getKey()

None

uint256

Get caller's viewing key (view, shielded)

setKey(suint256)

_key

None

Set caller's viewing key (nonpayable, shielded)

Events

None included in this ABI subset.

Full ABI

Usage Examples

Creating a Contract Instance

Check if User Has Key

Get Key Hash

Register Viewing Key

Get Your Own Key

Update Viewing Key

Using with SRC20 Tokens

How Viewing Keys Work

Registration

  1. User generates a 256-bit AES-GCM encryption key

  2. User calls setKey() with shielded key value

  3. Contract stores key in shielded storage (encrypted at rest)

  4. Key is associated with user's address

Key Storage

  • Keys are stored using suint256 (shielded uint256)

  • Only accessible to the key owner via signed reads

  • Contracts can compute key hash without revealing key value

Key Hash

  • Public identifier for encryption key

  • Used by contracts to tag encrypted data

  • Computed as SHA-256 hash of key value

  • Visible to everyone (not sensitive)

Encryption Flow

  1. Contract checks if recipient has registered key (checkHasKey)

  2. Contract retrieves recipient's key hash (keyHash)

  3. Contract encrypts sensitive data using key

  4. Contract emits event with encryptKeyHash + encryptedAmount

  5. Recipient decrypts using their locally-stored key

Privacy Features

What Gets Encrypted

  • Viewing key value (stored as suint256)

  • Data encrypted by contracts using the viewing key

What Remains Visible

  • Whether an address has a key registered (checkHasKey)

  • Hash of the viewing key (keyHash)

  • Contract interactions (transactions)

Decryption

To decrypt data encrypted with your viewing key:

Security Considerations

Key Generation

  • Use cryptographically secure random number generator

  • Never reuse keys across networks

  • Store keys securely (encrypted local storage recommended)

Key Storage

  • Never commit viewing keys to version control

  • Use encrypted storage for production keys

  • Consider hardware security modules (HSM) for high-value accounts

  • Back up keys securely (losing key = losing ability to decrypt)

Key Rotation

  • Consider rotating keys periodically

  • Old encrypted data remains encrypted with old key

  • New data uses new key after rotation

  • Keep old keys to decrypt historical data

Privacy Tradeoffs

  • Key hash is public (reveals key identity, not value)

  • checkHasKey reveals whether user has registered

  • Transaction patterns visible on-chain

  • Key registration is a public action

When to Use

Use the Directory contract when:

  • Registering your viewing key for privacy features

  • Checking if a user can receive encrypted data

  • Building privacy-preserving applications

  • Implementing encrypted balance queries

  • Creating tools for viewing key management

Comparison with Other Contracts

Contract
Purpose
Key Storage
Privacy Level

Directory

Viewing key management

Shielded

High (keys encrypted)

SRC20

Token transfers

N/A

High (amounts encrypted)

Deposit

Validator deposits

N/A

None (public deposits)

Contract Source

This ABI matches the TypeScript DirectoryAbi in seismic-viem and the Solidity contract at:

Note: Only the four functions needed by the Python SDK are included in this ABI. The full contract may have additional functions.

See Also

Last updated