> For the complete documentation index, see [llms.txt](https://docs.stacks.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stacks.co/reference/stacks.js/stacks-bitcoin-staking/signer/verifysignergrant.md).

# verifySignerGrant

Checks a signer-key grant signature locally. Recovers the public key from the signature over the grant hash and compares it with `publicKey`, as pox-5 `grant-signer-key` does.

***

### Usage

```ts
import { verifySignerGrant } from '@stacks/bitcoin-staking';
import { STACKS_MAINNET } from '@stacks/network';

// signerKey: 33-byte compressed public key, hex. signerSignature: from signSignerGrant.
function assertGrantSignature(signerKey: string, signerSignature: string) {
  const valid = verifySignerGrant({
    signerManager: 'SP2C2YFP12AJZB4MABJBAJ55XECVS7E4PMMZ89YZR.my-signer-manager',
    authId: 1n,
    chainId: STACKS_MAINNET.chainId,
    publicKey: signerKey,
    signature: signerSignature,
  });
  if (!valid) throw new Error('signature does not match signerKey');
}
```

#### Notes

* `true` means the signature passes the signature checks of `grant-signer-key` for these inputs, which otherwise fail with `ERR_INVALID_SIGNATURE_RECOVER (u13)` or `ERR_INVALID_SIGNATURE_PUBKEY (u14)` ([pox-5.clar L2766-L2778](https://github.com/stacks-network/stacks-core/blob/10474cdec9f9c0bdf05841b58cffc89cdad87a9b/stackslib/src/chainstate/stacks/boot/pox-5.clar#L2766-L2778)). It does not check whether the `authId` is already used ([fetchSignerKeyGrantUsed](/reference/stacks.js/stacks-bitcoin-staking/fetch/fetchsignerkeygrantused.md)) or who sends the transaction.
* The recovered key is compressed and compared as case-insensitive hex. Pass the 33-byte compressed public key: an uncompressed key returns `false`.
* Returns `false` instead of throwing when the signature or public key is malformed, for example a signature that is not 65 bytes.
* Makes no network request.

[**Reference Link**](https://github.com/stx-labs/stacks.js/blob/6101c99efe5a9616ce7e16cef68e28fd10676e7e/packages/bitcoin-staking/src/signer.ts#L75-L104)

***

### Signature

```ts
function verifySignerGrant(
  opts: SignerKeyGrantOptions & {
    publicKey: string | Uint8Array;
    signature: string | Uint8Array;
  }
): boolean;
```

`opts` extends [SignerKeyGrantOptions](/reference/stacks.js/stacks-bitcoin-staking/types/signerkeygrantoptions.md) with `publicKey` and `signature`.

***

### Returns

`boolean`

`true` if the key recovered from `signature` equals `publicKey`.

***

### Parameters

#### opts.signerManager (required)

* **Type**: `string`

Stacks principal of the signer-manager the grant authorizes.

#### opts.authId (required)

* **Type**: `IntegerType`

Replay nonce the signer signed.

#### opts.chainId (required)

* **Type**: `number`

Chain ID the signer signed for: `1` on mainnet, `0x80000000` on testnet.

#### opts.publicKey (required)

* **Type**: `string | Uint8Array`

Compressed public key of the signer, as hex or bytes.

#### opts.signature (required)

* **Type**: `string | Uint8Array`

65-byte RSV signature, as hex or bytes.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.stacks.co/reference/stacks.js/stacks-bitcoin-staking/signer/verifysignergrant.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
