Skip to content

stack-encrypt has no scalar-checked dynamic value, so an SDK writes its own Scalar wrapper to use keyset.encrypt — add one to dynamic #1802

Todo

Description

@coderdan

Background

The Stack Encrypt engine (the Rust crate stack-encrypt) encrypts a single value with keyset.encrypt(value). That call accepts only a type that is one scalar: a string, a number, a date and so on, and not a list or a map. Rust checks this at compile time through the Scalar trait.

A language SDK does not have Rust types for its values. It hands the engine a ValueFrame (stack_encrypt::dynamic), a value read at run time that can hold anything in the value model, a list or a map included.

Problem

A ValueFrame is not Scalar, because it might hold a container. So an SDK that wants the plain keyset.encrypt(value) path for a run-time value has to write its own wrapper type that checks the frame holds one scalar and then implements Encrypt, Scalar and Zeroize by hand.

The TypeScript SDK's addon does this in languages/typescript/packages/recipher-js/crate/src/value.rs (OneValue). It is about 60 lines that every SDK built on the dynamic value model would have to repeat, and it implements Scalar outside the engine, on a promise the engine cannot check.

Proposal

  1. Add a scalar-checked dynamic value to stack_encrypt::dynamic: a type made from a ValueFrame by a constructor that fails when the frame holds a container, and that implements what keyset.encrypt needs.
  2. Use it in the TypeScript addon and delete OneValue.
  3. Check whether the Go guest has the same wrapper and can use it too.

Relationship to other work

Activity

  1. self-assigned this
    on Nov 24, 2026
  2. added
    enhancement
    on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

SDKenhancement

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions