Consumer
TheConsumer sub-client handles read requests, partial decryption collection from validators, and final decryption. Requires a walletClient.
v0.1.1 also exposes readVault as an alias for accessCDR, and
readFileVault as an alias for downloadFile.Methods
- accessCDR
- downloadFile
- read
- collectPartials
- decryptDataKey
accessCDR
High-level method that submits a read request, collects partial decryptions from validators, and combines them to recover the original data.| Method | Type |
|---|---|
accessCDR | (params: AccessCDRParams) => Promise<AccessCDRResponse> |
params.uuid:number- The vault UUIDparams.accessAuxData:`0x${string}`- Auxiliary data passed to the read conditionparams.requesterPubKey(optional):`0x${string}`- Uncompressed secp256k1 public key (65 bytes,0x04prefix). If omitted, the SDK generates an ephemeral keypair.params.recipientPrivKey(optional):Uint8Array- 32-byte secp256k1 private key (for ECIES decryption of partials). If omitted, the SDK generates an ephemeral keypair.params.globalPubKey(optional):Uint8Array- DKG global public key (fromobserver.getGlobalPubKey()). If omitted, the SDK queries it for you.params.threshold(optional):number- Minimum partials needed (fromobserver.getThreshold()). If omitted, the SDK queries it for you.params.timeoutMs(optional):number- Timeout for collecting partials (default:60000)params.feeOverride(optional):bigint- Skip fee queryparams.onInvalidPartial(optional):(event, error) => void- Called when a partial fails signature verification inevm-eventsmode
Example
If you want the shortest high-level path, you can omit
requesterPubKey, recipientPrivKey, globalPubKey, and threshold
and let accessCDR() fill them in.AccessCDRResponse
downloadFile
High-level method that reads the encrypted file key through CDR, downloads the encrypted blob from aStorageProvider, and returns the decrypted file bytes.
Parameters:
params.uuid:number- The vault UUIDparams.accessAuxData:`0x${string}`- Auxiliary data passed to the read conditionparams.storageProvider:StorageProvider- Backend used to fetch the encrypted contentparams.requesterPubKey(optional):`0x${string}`- Explicit requester public key for the read flowparams.recipientPrivKey(optional):Uint8Array- Explicit recipient private key for the read flowparams.globalPubKey(optional):Uint8Array- DKG global public key. Auto-queried if omitted.params.threshold(optional):number- Minimum partials needed. Auto-queried if omitted.params.timeoutMs(optional):number- Timeout for validator partial collectionparams.feeOverride(optional):bigint- Skip read fee queryparams.onInvalidPartial(optional):(event, error) => void- Called when a partial fails signature verification inevm-eventsmodeparams.skipCidVerification(optional):boolean- Skip CID integrity verification of the downloaded encrypted file
Example
For Story license-gated reads,
accessAuxData should encode the caller’s
license token IDs as abi.encode(uint256[] licenseTokenIds).downloadFile() inherits the same optional key / threshold auto-management
behavior as accessCDR().content is the raw decrypted file bytes. Decode it as text only if the
original file was text-based.read
Submits a read request on-chain. The caller must satisfy the vault’s read condition. Emits an event that validators listen for to begin generating partial decryptions.| Method | Type |
|---|---|
read | (params: ReadParams) => Promise<ReadResponse> |
params.uuid:number- The vault UUIDparams.accessAuxData:`0x${string}`- Auxiliary data passed to the read conditionparams.requesterPubKey:`0x${string}`- Your ephemeral uncompressed secp256k1 public keyparams.feeOverride(optional):bigint- Skip fee query
Example
ReadResponse
collectPartials
Polls the blockchain forEncryptedPartialDecryptionSubmitted events until enough partial decryptions have been collected.
| Method | Type |
|---|---|
collectPartials | (params: CollectPartialsParams) => Promise<PartialDecryptionEvent[]> |
params.uuid:number- The vault UUIDparams.minPartials:number- Number of partials needed (= threshold)params.fromBlock:bigint- Block number where the read request was submittedparams.requesterPubKey(optional):`0x${string}`- Required incosmos-abcimodeparams.timeoutMs(optional):number- Timeout in milliseconds (default:60000)params.pollIntervalMs(optional):number- Polling interval (default:3000)params.onInvalidPartial(optional):(event, error) => void- Called when a partial fails signature verification inevm-eventsmodeparams.attestationConfig(optional):AttestationConfig- Verifies each validator attestation and rejects invalid partials
Example
PartialDecryptionEvent
In
cosmos-abci mode, requesterPubKey and signature are omitted because
the keeper verifies signatures on ingress and does not persist those fields.decryptDataKey
Decrypts the collected partial decryptions using ECIES, then combines them via TDH2 to recover the original plaintext.| Method | Type |
|---|---|
decryptDataKey | (params: DecryptParams) => Promise<Uint8Array> |
params.ciphertext:TDH2Ciphertext- The encrypted data ({ raw, label })params.partials:PartialDecryptionEvent[]- Collected partial decryptionsparams.recipientPrivKey:Uint8Array- Your ephemeral secp256k1 private key (32 bytes)params.globalPubKey:Uint8Array- DKG global public keyparams.label:Uint8Array- 32-byte label (fromuuidToLabel(uuid))params.threshold:number- Minimum partials needed
Example

