> ## Documentation Index
> Fetch the complete documentation index at: https://turnkey-0e7c1f5b-bc-add-sdk-typedoc.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# ToDerSignature

# Function: toDerSignature()

> **toDerSignature**(`rawSignature`): `string`

Defined in: [crypto.ts:584](https://github.com/tkhq/sdk/blob/ee72856c3f450731d7501ab05001215768b71500/packages/crypto/src/crypto.ts#L584)

Converts a raw ECDSA signature to DER-encoded format.

This function takes a raw ECDSA signature, which is a concatenation of two 32-byte integers (r and s),
and converts it into the DER-encoded format. DER (Distinguished Encoding Rules) is a binary encoding
for data structures described by ASN.1.

## Parameters

### rawSignature

`string`

The raw signature in hexadecimal string format.

## Returns

`string`

* The DER-encoded signature in hexadecimal string format.

## Throws

* Throws an error if the input signature is invalid or if the encoding process fails.

## Example

```ts theme={"system"}
// Example usage:
const rawSignature = "0x487cdb8a88f2f4044b701cbb116075c4cabe5fe4657a6358b395c0aab70694db3453a8057e442bd1aff0ecabe8a82c831f0edd7f2158b7c1feb3de9b1f20309b1c";
const derSignature = toDerSignature(rawSignature);
console.log(derSignature); // Outputs the DER-encoded signature as a hex string
// "30440220487cdb8a88f2f4044b701cbb116075c4cabe5fe4657a6358b395c0aab70694db02203453a8057e442bd1aff0ecabe8a82c831f0edd7f2158b7c1feb3de9b1f20309b"
```
