OxL Reference

fn seal

Encrypts one field of a topic element (@encrypted fields, §13.3): AES-256-GCM with the data key topic/<name>/<field> of the node's KMS (D-4663). Store the result in a bytes field of the element; open reverses it. The field name is bound to the ciphertext, so it does not open under another field.

Example:

oxl✓ checked in CI
use std.topic { seal, unseal }
use std.core { Utf8 }

fn main() -> () | TopicError io, db {
  let sealed = seal("Payments", "card", Utf8.encode("4111"))?
  let plain = unseal("Payments", "card", sealed)?
  print("{Utf8.decode(plain)!}")
}
Output
4111
pub(api) fn seal(name: str, field: str, plain: bytes) -> bytes | TopicError  db

Complexity. O(size of the field).

Since. 1.0.0-beta

Parameters

NameType
namestr
fieldstr
plainbytes

Returns

bytes

Errors

  • TopicError @error
  • `TopicError` when the data key is not available.

Effects

db

Defined in: std/topic/topic.oxl:713

See also