Skip to main content

Function: seal()

seal(key, field, plaintext): SealedField

Defined in: packages/persistence/src/personal/fields.ts:66

Encrypts one personal field under the subject's key with AES-256-GCM. The authenticated additional data is subjectId, table.column and the key id, so the ciphertext opens only in the row and column it was sealed for. The text is encrypted as given: no normalisation, so NFC and NFD forms come back as they went in.

Synchronous and free of any port call, so it is safe inside a transaction: resolve the key with SubjectKeys.get before the transaction opens.

Parameters​

key​

SubjectKey

A resolved key. A revoked handle (destroyed subject) is refused.

field​

PersonalField

The table and _ct column the value will be stored in.

plaintext​

string

The value.

Returns​

SealedField

The key id and ciphertext to store.

Throws​

invalid_field; key_unavailable when the key was destroyed after it was resolved.