Documentation Index
Fetch the complete documentation index at: https://docs.story.foundation/llms.txt
Use this file to discover all available pages before exploring further.
Consumer
TheConsumer sub-client handles read requests, partial decryption collection from validators, and final decryption. Requires a walletClient.
The SDK also exposes
readVault as an alias for accessCDR, and
readFileVault as an alias for downloadFile./dkg/cdr_partials), keyed by (uuid, requesterPubKey). The keeper verifies
each validator’s signature on ingress, so the SDK does not re-verify signatures
locally. For defense-in-depth, pass an attestationConfig to verify each
validator’s SGX enclave before accepting their partials.
Methods
- accessCDR
- downloadFile
- read
- collectPartials
- decryptDataKey
- prefetchRegistry
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 and zeroes it after use.params.globalPubKey(optional):Uint8Array- DKG global public key (fromobserver.getGlobalPubKey()). If omitted, the SDK queries it for you.params.timeoutMs(optional):number- Timeout for collecting partials.120_000is a good starting point.params.feeOverride(optional):bigint- Explicit read fee. Skips thereadFee()auto-query (strict-equality semantics — not a way to pay a different amount).params.onInvalidPartial(optional):(event, error) => void- Called when a validator’s partial is excluded because its attestation failed theattestationConfigchecks.params.attestationConfig(optional):AttestationConfig- Verifies each validator’s SGX enclave before accepting their partials.
Example
If you want the shortest high-level path, you can omit
requesterPubKey,
recipientPrivKey, and globalPubKey and let accessCDR() fill them in.
The threshold is derived automatically from the partial-decryption bucket’s
DKG round.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.timeoutMs(optional):number- Timeout for validator partial collectionparams.feeOverride(optional):bigint- Explicit read fee. Skips thereadFee()auto-query.params.onInvalidPartial(optional):(event, error) => void- Called when a validator’s partial is excluded because its attestation failed theattestationConfigchecks.params.attestationConfig(optional):AttestationConfig- Verifies each validator’s SGX enclave before accepting their partials.params.skipCidVerification(optional):boolean- Skip CID integrity verification of the downloaded encrypted file (default:false)
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 auto-management behavior as
accessCDR(), and returns cid and txHash alongside content.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. This prompts validators to submit encrypted 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 key. Partials are indexed by this value.params.feeOverride(optional):bigint- Explicit read fee. Skips thereadFee()auto-query.
Example
ReadResponse
collectPartials
Polls the Story-API REST endpoint (/dkg/cdr_partials) until at least a
threshold’s worth of partial-decryption submissions have been surfaced for the
given (uuid, requesterPubKey).
| Method | Type |
|---|---|
collectPartials | (params: CollectPartialsParams) => Promise<PartialDecryptionEvent[]> |
params.uuid:number- The vault UUIDparams.requesterPubKey:`0x${string}`- The uncompressed secp256k1 public key used in the matchingread()requestparams.timeoutMs(optional):number- Timeout in milliseconds.120_000is a good starting point.params.pollIntervalMs(optional):number- Polling interval in millisecondsparams.onInvalidPartial(optional):(event, error) => void- Called when a validator’s partial is excluded because its attestation failed theattestationConfigchecksparams.attestationConfig(optional):AttestationConfig- Verifies each validator’s SGX enclave and excludes partials from untrusted validators
observer.getThresholdAt(round)), so a DKG rollover mid-poll does not
measure the bucket against the wrong round. The vault ciphertext is read once at
the start of the call and pinned for the rest of the poll loop.
Example
PartialDecryptionEvent
Every event returned from a successful
collectPartials call shares the same
round and ciphertext — the result is filtered to the bucket matching the
vault’s current ciphertext.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))
partials.length —
collectPartials already returns exactly the threshold count needed for
reconstruction. Pass exactly the partials you want combined.
Example
prefetchRegistry
Warms the validatorcommPubKey + attestation cache for the active DKG round.
The first accessCDR() / downloadFile() call after construction would
otherwise stall on this fetch. Frontends that know a read is imminent (for
example, right after wallet connection) can call this in the background.
| Method | Type |
|---|---|
prefetchRegistry | () => Promise<void> |
Example

