> ## 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.

# decryptTinSocialIdentity — Decrypt social identity

> Decrypt a TIN social identity locally with the same derived AES-GCM key and return the plaintext only to the caller.

## What it does

This function reverses `encryptTinSocialIdentity` locally. It derives the same TIN-scoped key and decrypts the supplied nonce and ciphertext.

## How the flow works

<Steps>
  <Step title="Caller invokes the function">The caller supplies the TIN, nonce, and ciphertext.</Step>
  <Step title="Validation">WebCrypto imports the derived AES-GCM key and validates the authentication tag.</Step>
  <Step title="Main work">The SDK decrypts the ciphertext using the supplied nonce.</Step>
  <Step title="Result">The plaintext string is returned to the local caller.</Step>
</Steps>

## Signature

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

<ParamField path="tin" type="bigint | number | string" required>TIN used to derive the decryption key.</ParamField>
<ParamField path="nonce" type="Uint8Array" required>Nonce returned by encryption.</ParamField>
<ParamField path="ciphertext" type="Uint8Array" required>AES-GCM ciphertext.</ParamField>

## Result and errors

Returns plaintext or propagates WebCrypto authentication/decryption failure.

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

Source: [`tins.ts:1348-1360`](https://github.com/Trustlink-Labs/TSN-Protocol/blob/main/tsn-protocol/sdks/tsn-sdk/src/tins.ts#L1348-L1360)
