Skip to main content

What it does

This function encrypts a sensitive TIN field using a key derived from the TIN, field type, and user signature. It also returns a hash of the signature for registry binding.

How the flow works

1

Caller invokes the function

The caller provides the TIN, field type, plaintext value, and user signature.
2

Validation

The SDK requires WebCrypto AES-GCM support and uses the exact field type and signature bytes for key derivation.
3

Main work

It generates or accepts a nonce, encrypts the value, and hashes the signature bytes.
4

Result

It returns { nonce, ciphertext, userAuthorizationHash } for the sensitive-field instruction.

Signature

bigint | number | string
required
TIN key input.
string
required
Field namespace bound into the key.
string
required
Plaintext field value.
Uint8Array | string
required
Authorization material used for key derivation and hashing.
Uint8Array
Optional AES-GCM nonce.

Result and errors

Returns ciphertext, nonce, and a 32-byte authorization hash. WebCrypto failures are propagated.
Source: tins.ts:1362-1379