> ## Documentation Index
> Fetch the complete documentation index at: https://trust-link-tsn.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# decryptTinSensitiveField — Decrypt sensitive field

> Decrypt a TIN-sensitive field locally after deriving the same key from the TIN, field type, and user signature.

## What it does

This function decrypts a sensitive field encrypted by `encryptTinSensitiveField`; the caller must supply the same TIN, field type, nonce, ciphertext, and signature.

## How the flow works

<Steps>
  <Step title="Caller invokes the function">The caller supplies the encrypted field and the same authorization inputs used during encryption.</Step>
  <Step title="Validation">The SDK derives the field-scoped AES-GCM key from the exact TIN, field type, and signature.</Step>
  <Step title="Main work">WebCrypto authenticates and decrypts the ciphertext with the supplied nonce.</Step>
  <Step title="Result">The plaintext field is returned locally.</Step>
</Steps>

## Signature

```ts theme={null}
export async function decryptTinSensitiveField(params: {
  tin: bigint | number | string; fieldType: string; nonce: Uint8Array;
  ciphertext: Uint8Array; userSignature: Uint8Array | string;
}): Promise<string>
```

<ParamField path="tin" type="bigint | number | string" required>TIN key input.</ParamField>
<ParamField path="fieldType" type="string" required>Field namespace used during encryption.</ParamField>
<ParamField path="nonce" type="Uint8Array" required>Encryption nonce.</ParamField>
<ParamField path="ciphertext" type="Uint8Array" required>Encrypted field value.</ParamField>
<ParamField path="userSignature" type="Uint8Array | string" required>Same authorization material used for encryption.</ParamField>

## Result and errors

Returns plaintext or propagates WebCrypto authentication/decryption failure.

```ts theme={null}
const value = await decryptTinSensitiveField({ tin, fieldType, nonce, ciphertext, userSignature });
```

Source: [`tins.ts:1381-1403`](https://github.com/Trustlink-Labs/TSN-Protocol/blob/main/tsn-protocol/sdks/tsn-sdk/src/tins.ts#L1381-L1403)
