Skip to main content

ShardRegistry

On-chain registry for GhostShard hash verification and emergency wallet locking.

Source

packages/contracts/ShardRegistry.compact

Ledgers

LedgerTypeDescription
shard_hashesMap<Bytes, Bytes>Shard hash by walletId:shardId
shard_locationsMap<Bytes, Counter>Storage type by walletId:shardId
shard_countsMap<Bytes, Counter>Shard count per wallet
wallet_lockedMap<Bytes, Counter>Lock status per wallet (0 = unlocked, 1 = locked)
total_shardsCounterGlobal shard count

Circuits

registerShard(wallet_id: Bytes, shard_id: Bytes, shard_hash: Bytes, storage_type: Counter)

Registers a shard hash on-chain. Fails if the wallet is locked.

Storage type encoding:

TypeCode
DID1
USB2
Password Manager3
Email4
Cloud5
Device6

emergencyLock(wallet_id: Bytes)

Locks a wallet, preventing new shard registrations. Use when compromise is suspected.

isLocked(wallet_id: Bytes): Counter

Returns 1 if the wallet is locked, 0 otherwise.

verifyShardHash(wallet_id: Bytes, shard_id: Bytes, hash: Bytes): Counter

Returns 1 if the provided hash matches the registered hash for the shard, 0 otherwise. Does not reveal the hash — the comparison happens inside the ZK circuit.

getShardCount(wallet_id: Bytes): Counter

Returns the number of registered shards for a wallet.

getShardLocation(wallet_id: Bytes, shard_id: Bytes): Counter

Returns the storage type code for a specific shard.

getTotalShards(): Counter

Returns the global shard count across all wallets.

Emergency Lock Flow

User suspects compromise
→ emergencyLock(walletId)
→ All registerShard() calls for this wallet will fail
→ User creates new wallet + new shards
→ Old shards are effectively invalidated

The lock is one-way — once locked, a wallet cannot be unlocked. The user must create a new wallet.