> ## Documentation Index
> Fetch the complete documentation index at: https://docs.crossmint.com/llms.txt
> Use this file to discover all available pages before exploring further.

# WalletAuthService

Service for handling wallet-based authentication and decryption with Crossmint.

The `WalletAuthService` class provides methods to retrieve a challenge for wallet authentication and to decrypt credentials using that challenge.

## Constructors

### new WalletAuthService()

> **new WalletAuthService**(): [`WalletAuthService`](./WalletAuthService)

#### Returns

[`WalletAuthService`](./WalletAuthService)

## Methods

### decrypt()

> **decrypt**(`credential`, `challenge`, `signature`, `userAddress`): `Promise`\<`any`>

Decrypts an encrypted verifiable credential using a signed challenge.

This method sends the signed challenge, the user's address, and the encrypted credential to Crossmint for decryption.

#### Parameters

| Parameter     | Type                                                                           | Description                                                 |
| ------------- | ------------------------------------------------------------------------------ | ----------------------------------------------------------- |
| `credential`  | [`EncryptedVerifiableCredential`](../interfaces/EncryptedVerifiableCredential) | The encrypted verifiable credential to decrypt.             |
| `challenge`   | `string`                                                                       | The challenge that was signed by the user's wallet.         |
| `signature`   | `string`                                                                       | The signature of the challenge signed by the user's wallet. |
| `userAddress` | `string`                                                                       | The blockchain address of the user requesting decryption.   |

#### Returns

`Promise`\<`any`>

A promise that resolves to the decrypted data.

#### Throws

Will throw an error if the decryption request fails or if the response is invalid.

#### Defined in

[services/walletAuth.ts:57](https://github.com/Crossmint/crossmint-sdk/blob/main/packages/client/verifiable-credentials/src/services/walletAuth.ts#L57)

***

### getChallenge()

> **getChallenge**(`userAddress`): `Promise`\<`string`>

Retrieves a challenge nonce for wallet authentication.

This method requests a challenge from Crossmint that can be signed by the user's wallet to authenticate the user.

#### Parameters

| Parameter     | Type     | Description                                                  |
| ------------- | -------- | ------------------------------------------------------------ |
| `userAddress` | `string` | The blockchain address of the user requesting the challenge. |

#### Returns

`Promise`\<`string`>

A promise that resolves to a string representing the challenge to sign.

#### Throws

Will throw an error if the challenge request fails or if the response is invalid.

#### Defined in

[services/walletAuth.ts:20](https://github.com/Crossmint/crossmint-sdk/blob/main/packages/client/verifiable-credentials/src/services/walletAuth.ts#L20)
