Repository navigation
Description
Background
@cipherstash/recipher is the TypeScript SDK on Stack Encrypt (the Rust crate stack-encrypt). Its plan has opaque(value): encrypt a whole JavaScript object as one ciphertext, under one data key, with nothing inside it searchable. Rust has the same thing as OpaqueBlob<T>, and Go has it as an opaque struct.
All three store an opaque value the same way. The value is written as a storage blob: vitaminc's storage profile, a frozen, versioned binary encoding that starts with "VCS" and a version byte (vitaminc_aead_frame::storage, specified in vitaminc's STORAGE.md). The blob is then encrypted as an ordinary bytes value.
- Rust:
OpaqueBlob::encodewrites the blob withstorage::to_vecfrom the value's serdeSerialize. - Go:
opaqueBytesinlanguages/golang/encrypt/gensupport/codec.gowrites it withvcffi.MarshalStoragefrom the Go struct (Seal Go opaque structs with vitaminc's storage profile instead of JSON #1367), and seals it as the one field of a record.
Problem
The TypeScript SDK has no way to write or read a storage blob from a JavaScript value, so opaque(..) is not built (#1775 left it out).
A JavaScript value reaches Rust as a frame: vitaminc's transport encoding, which the value bridge (recipher-value-napi) writes from a live JavaScript value. The frame and the storage profile share their scalar encodings and their array and object layout, but nothing converts one into the other. storage::to_vec only takes a Rust Serialize, and storage::from_slice only gives one back.
Verified on next with a small program against the engine:
- The ciphertext of an
OpaqueBlobdecrypts as aVec<u8>, and the bytes are exactly the blobOpaqueBlob::encodewrites. - A blob encrypted as a plain
Vec<u8>decrypts as theOpaqueBlobit encodes.
So the engine needs no new entry point. What is missing is the conversion between a JavaScript value and a storage blob.
One rule carries over from the format: version 1 of the storage profile holds plain scalars only, with no logical types. A Date, a VcDate, a VcDecimal or a VcTimestamp inside an opaque object has no storage form. In Go, vcffi.MarshalStorage refuses a value with no storage form, and opaqueBytes reports it as an encoding error. Whether a Go time.Time field hits that refusal has not been checked.
Proposal
- Write a blob from a JavaScript value. Walk the value the bridge reads (a
JsRef, or the frame it snapshots) into a storage blob. The two formats differ in four ways: the blob's header, a marker for a present optional value, a map node whose keys keep their type, and no logical types. Refuse a logical type with a typed refusal that names the property, such asrecipher::no_storage_form. - Read a blob into a JavaScript value. Decrypt as bytes, check the
"VCS"header, and build the value with the bridge'sJsBuilder. Refuse a blob with a later version, or one that is malformed, with the storage profile's own error kinds. - Add
opaque(value)to the core, returning aCiphertextthat decrypts to the object. Add exchange tests in which a blob written by Rust'sOpaqueBloband by a Go opaque struct opens in TypeScript, and one written by TypeScript opens in both. - Decide where the converter lives. It can sit in the value bridge, or in
vitaminc-aead-framebeside the storage profile, where it could be shared with a future wasm build. This depends on which vitaminc code moves into this repository.
Relationship to other work
@cipherstash/recipherencrypts a string only — add every value type, arrays and JSON documents #1812 and feat(recipher-js): every value type, arrays and JSON documents #1775 (TypeScript value types), which leftopaqueout.- Seal Go opaque structs with vitaminc's storage profile instead of JSON #1367 did the same for Go, with
vcffi.MarshalStorage. - The plan in docs(plans): the TypeScript SDK on Stack Encrypt, a core with EQL as an extension #1747 ("A file, and a whole object") describes
opaque.
Activity
docs(plans): opaque needs a storage-blob converter, not an engine change
coderdan commentedon Nov 25, 2026
The converter itself is now tracked upstream: cipherstash/vitaminc#643 (frame to storage blob and back, and whether storage version 2 adds dates and UUIDs).
docs(plans): opaque needs a storage-blob converter, not an engine change
docs(plans): opaque needs a storage-blob converter, not an engine change
coderdan commentedon Nov 25, 2026
Checked: Go does not refuse
time.Timein an opaque struct.vcffi.MarshalStoragewrites a type that formats itself as text as text, so atime.Timeis stored as RFC 3339 text and opens as text, not a timestamp. What Go refuses is its logical-type values (encrypt.Date,encrypt.Decimal) and a passthrough, withvcffi.ErrUnwritable(vcffi/storage.goat the versionlanguages/golang/go.modpins). So the TypeScript converter has a choice to make for aDate: refuse it, or write it as text as Go does. #1828 documents both rules in the integration guide.