Uploader
TheUploader sub-client handles vault allocation, TDH2 encryption, and writing encrypted data on-chain. Requires a walletClient.
Use
uploadCDR() for small secrets stored directly in the vault and
uploadFile() when the encrypted bytes should live in an external storage
backend.v0.1.1 also exposes createVault as an alias for uploadCDR, and
createFileVault as an alias for uploadFile.Methods
- uploadCDR
- uploadFile
- allocate
- write
- encryptDataKey
uploadCDR
High-level method that allocates a vault, encrypts your data, and writes the ciphertext in a single call.| Method | Type |
|---|---|
uploadCDR | (params: UploadCDRParams) => Promise<UploadCDRResponse> |
params.dataKey:Uint8Array- The secret payload bytes to encrypt. Despite the name, this can be arbitrary data, not only a cryptographic key.params.globalPubKey:Uint8Array- The DKG global public key (fromobserver.getGlobalPubKey())params.updatable:boolean- Whether the vault can be rewritten after initial writeparams.writeConditionAddr:`0x${string}`- Address of the write condition contractparams.readConditionAddr:`0x${string}`- Address of the read condition contractparams.writeConditionData:`0x${string}`- ABI-encoded data passed to the write conditionparams.readConditionData:`0x${string}`- ABI-encoded data passed to the read conditionparams.accessAuxData:`0x${string}`- Auxiliary data passed to conditions during writeparams.allocateFeeOverride(optional):bigint- Skip fee query and use this valueparams.writeFeeOverride(optional):bigint- Skip fee query and use this value
Example
Keep
uploadCDR() payloads small enough that the resulting TDH2 ciphertext
fits the vault limit (observer.getMaxEncryptedDataSize(), which is 1024
bytes on Aeneid).UploadCDRResponse
uploadFile
High-level method that encrypts file bytes locally, uploads the encrypted blob through aStorageProvider, and writes the encrypted file key plus content
pointer to CDR in one call.
Parameters:
params.content:Uint8Array- File bytes to encrypt and uploadparams.storageProvider:StorageProvider- Backend used for upload and downloadparams.globalPubKey:Uint8Array- DKG global public keyparams.updatable:boolean- Whether the vault can be rewrittenparams.writeConditionAddr:`0x${string}`- Address of the write condition contractparams.readConditionAddr:`0x${string}`- Address of the read condition contractparams.writeConditionData:`0x${string}`- ABI-encoded write condition dataparams.readConditionData:`0x${string}`- ABI-encoded read condition dataparams.accessAuxData:`0x${string}`- Auxiliary data passed to conditions during writeparams.allocateFeeOverride(optional):bigint- Skip the allocate fee queryparams.writeFeeOverride(optional):bigint- Skip the write fee query
Example
HeliaProvider is the only storage backend fully tested on Aeneid in the
current release. GatewayProvider, StorachaProvider, and
SynapseProvider are implemented but were not yet end-to-end validated in
the release run.uploadFile() keeps the file bytes off-chain. The vault stores a TDH2
ciphertext of a small JSON payload containing { cid, key }.In browser code, pass file bytes from
new Uint8Array(await file.arrayBuffer()) instead of readFile(...).allocate
Creates a new CDR vault on-chain with the specified access control conditions.| Method | Type |
|---|---|
allocate | (params: AllocateParams) => Promise<AllocateResponse> |
params.updatable:boolean- Whether the vault can be rewrittenparams.writeConditionAddr:`0x${string}`- Write condition contract addressparams.readConditionAddr:`0x${string}`- Read condition contract addressparams.writeConditionData:`0x${string}`- ABI-encoded write condition dataparams.readConditionData:`0x${string}`- ABI-encoded read condition dataparams.feeOverride(optional):bigint- Skip fee queryparams.skipConditionValidation(optional):boolean- Skip interface validation when intentionally using an EOA condition address
Example
uploadCDR() and uploadFile() do not expose skipConditionValidation, so
use a real condition contract with those high-level helpers.AllocateResponse
write
Writes encrypted data to an existing vault. The caller must satisfy the vault’s write condition.| Method | Type |
|---|---|
write | (params: WriteParams) => Promise<WriteResponse> |
params.uuid:number- The vault UUIDparams.accessAuxData:`0x${string}`- Auxiliary data passed to the write conditionparams.encryptedData:`0x${string}`- Hex-encoded TDH2 ciphertextparams.feeOverride(optional):bigint- Skip fee query
Example
WriteResponse
encryptDataKey
Locally encrypts data using TDH2 threshold encryption. No blockchain interaction.| Method | Type |
|---|---|
encryptDataKey | (params: EncryptParams) => Promise<TDH2Ciphertext> |
params.dataKey:Uint8Array- The plaintext data to encryptparams.globalPubKey:Uint8Array- DKG global public key (34 bytes)params.label:Uint8Array- 32-byte label binding ciphertext to a vault (useuuidToLabel(uuid))
Example
TDH2Ciphertext

