Consumer
TheConsumer sub-client handles read requests, partial decryption collection from validators, and final decryption. Requires a walletClient.
Methods
- accessCDR
- 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:`0x${string}`- Uncompressed secp256k1 public key (65 bytes,0x04prefix)params.recipientPrivKey:Uint8Array- 32-byte secp256k1 private key (for ECIES decryption of partials)params.globalPubKey:Uint8Array- DKG global public key (fromobserver.getGlobalPubKey())params.threshold:number- Minimum partials needed (fromobserver.getThreshold())params.timeoutMs(optional):number- Timeout for collecting partials (default:60000)params.feeOverride(optional):bigint- Skip fee query
Example
AccessCDRResponse
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.timeoutMs(optional):number- Timeout in milliseconds (default:60000)params.pollIntervalMs(optional):number- Polling interval (default:3000)
Example
PartialDecryptionEvent
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

