Skip to content

stack-encrypt: the dynamic value model refuses a UUID, so no SDK can encrypt one — add it #1821

Todo

Description

@coderdan

Background

Stack Encrypt (the Rust crate stack-encrypt) encrypts values. The language SDKs reach it through stack_encrypt::dynamic, the part of the crate for values whose type is known only at run time. The Go SDK uses it through its WASI guest, and the TypeScript SDK @cipherstash/recipher uses it through its Node addon.

A value enters dynamic as a frame: vitaminc's transport encoding of one value, which a binding writes from its own language's value. dynamic::ValueFrame holds one frame and admits only the types in the engine's value model. The model is a subset of what a frame can carry.

vitaminc, the library below the engine, has a UUID type: the logical type Logical::Uuid over 16 bytes, with a sealed leaf of its own and the value type vitaminc_aead::Uuid.

Problem

The value model has no UUID, so no SDK can encrypt one, although vitaminc and the engine's static Rust path both can.

Verified on next with a small program against the engine (stack-encrypt with dynamic and vitaminc-aead's uuid feature):

  • keyset.encrypt(vitaminc_aead::Uuid::new(id)) works, and decrypting it as vitaminc_aead::Uuid gives the UUID back. Decrypting it as a String or as bytes is refused: "the ciphertext opened, but it does not hold a value of the type string". So the sealed leaf records that the value is a UUID.
  • vitaminc_aead::to_frame of the same UUID gives a valid frame: the logical-type envelope 0xF3, the UUID's id and parameter, then 16 bytes.
  • ValueFrame::of of that frame is refused: "expected a null, bool, integer, float, string, bytes, date, timestamp or decimal in range".

Where the model is defined:

  • model and model_null in packages/stack-encrypt/src/dynamic/value_frame.rs admit a date, a decimal and a timestamp, and nothing else with a logical type.
  • scalar_kind in the same file, and ValueKind in dynamic/kind.rs, have no UUID kind, so a plan field cannot declare one.
  • The test what_the_model_does_not_hold_is_refused asserts that a UUID is refused.

The model took its current shape when #1144 added dates, timestamps, decimals and every integer width. UUID was not part of #1144, and no reason for leaving it out is recorded, so this looks like an omission rather than a decision. dynamic/term.rs already mentions UUIDs when it says how equality terms treat each type.

Impact: a UUID is a common column type, such as a user ID or an external reference. Today an SDK user has to encrypt it as text, which stores a different leaf, decrypts as a string, and does not match a UUID encrypted from Rust. The TypeScript SDK refuses a VcUuid with recipher::uuid and tells the user to encrypt its text. The Go SDK has no UUID kind at all.

Proposal

  1. Add a UUID to the value model: ValueKind::Uuid ("uuid" in a plan), admitted by model and model_null as Logical::Uuid over 16 bytes. A typed null for a UUID field is padded to the UUID's length, as other fixed-width nulls are.
  2. Say which indexes a UUID field takes. Equality is the obvious one. Match and order terms over a UUID should be refused when the plan is built, with an error that names the field.
  3. Add UUID cases to the conformance corpus (conformance/stack-encrypt/v1), including the equality term, so that Rust, Go and TypeScript agree on the bytes.
  4. Then each SDK adds it: the TypeScript SDK stops refusing a VcUuid (and drops recipher::uuid), and the Go SDK gains a UUID kind in record.Kind, gensupport and stashgen.

Relationship to other work

Activity

  1. added
    enhancement
    on Nov 25, 2026
  2. self-assigned this
    on Nov 25, 2026
  3. added
    Rust
    on Nov 25, 2026
  4. coderdan commented on Nov 27, 2026

    @coderdan
    ContributorAuthor

    Where a UUID stands in each SDK:

    This issue stays open until #1994 and the TypeScript part are done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

RustSDKenhancement

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions