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

# buildLinkSensitiveFieldInstruction — Link sensitive field

> Build the TIN registry instruction that stores an encrypted sensitive field bound to a user authorization hash.

## What it does

This helper encodes an encrypted sensitive field and the 32-byte user authorization hash into a Solana registry instruction.

## How the flow works

<Steps>
  <Step title="Caller invokes the function">The caller supplies the owner, registry, field type, encrypted bytes, and authorization hash.</Step>
  <Step title="Validation">The SDK rejects `userAuthorizationHash` unless it is exactly 32 bytes.</Step>
  <Step title="Main work">It serializes the field with instruction tag `10` and binds the hash to the instruction payload.</Step>
  <Step title="Result">The caller receives one owner-signed `TransactionInstruction`.</Step>
</Steps>

## Signature

```ts theme={null}
export function buildLinkSensitiveFieldInstruction(params: {
  owner: PublicKey; registry: PublicKey; fieldType: string; nonce: Uint8Array;
  ciphertext: Uint8Array; metadata?: string; userAuthorizationHash: Uint8Array;
  programId?: PublicKey | string | null;
}): TransactionInstruction
```

<ParamField path="userAuthorizationHash" type="Uint8Array" required>Exactly 32 bytes identifying the user authorization.</ParamField>
<ParamField path="fieldType" type="string" required>Sensitive field type.</ParamField>
<ParamField path="nonce" type="Uint8Array" required>Encryption nonce.</ParamField>
<ParamField path="ciphertext" type="Uint8Array" required>Encrypted field value.</ParamField>
<ParamField path="metadata" type="string" required={false}>Metadata JSON; defaults to `{}`.</ParamField>

## Result and errors

Throws `userAuthorizationHash must be 32 bytes` for an invalid hash length. Returns one Solana instruction otherwise.

```ts theme={null}
transaction.add(buildLinkSensitiveFieldInstruction(params));
```

Source: [`tins.ts:934-960`](https://github.com/Trustlink-Labs/TSN-Protocol/blob/main/tsn-protocol/sdks/tsn-sdk/src/tins.ts#L934-L960)
