You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
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
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
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.
Use it in the TypeScript addon and delete OneValue.
Check whether the Go guest has the same wrapper and can use it too.
The dynamic value model belongs to the engine API in the "Stable Stack Encrypt Rust release" milestone. This issue is in the TypeScript milestone because that SDK is the first to need it.
Activity