# Authentication.sign

Signs a challenge using a stored WebAuthn P256 Credential. If no Credential is provided, a prompt will be displayed for the user to select an existing Credential that was previously registered.

## Imports

:::code-group
```ts [Named]
import { Authentication } from 'ox/webauthn'
```

```ts [Entrypoint]
import * as Authentication from 'ox/webauthn/Authentication'
```
:::

## Examples

```ts twoslash
import { Registration, Authentication } from 'ox/webauthn'

const credential = await Registration.create({
  name: 'Example'
})

const { metadata, signature } = await Authentication.sign({
  // [!code focus]
  credentialId: credential.id, // [!code focus]
  challenge: '0xdeadbeef' // [!code focus]
}) // [!code focus]
// @log: {
// @log:   metadata: {
// @log:     authenticatorData: '0x49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000',
// @log:     clientDataJSON: '{"type":"webauthn.get","challenge":"9jEFijuhEWrM4SOW-tChJbUEHEP44VcjcJ-Bqo1fTM8","origin":"http://localhost:5173","crossOrigin":false}',
// @log:     challengeIndex: 23,
// @log:     typeIndex: 1,
// @log:     userVerificationRequired: true,
// @log:   },
// @log:   signature: { r: 51231...4215n, s: 12345...6789n },
// @log: }
```

## Definition

```ts
function sign(
  options: sign.Options,
): Promise<sign.ReturnType>
```

**Source:** [src/webauthn/Authentication.ts](https://github.com/wevm/ox/blob/main/src/webauthn/Authentication.ts#L488)

## Parameters

### options

* **Type:** `sign.Options`

Options.

#### options.challenge

* **Type:** `0x${string}`

The challenge to sign.

#### options.credentialId

* **Type:** `string | string[]`
* **Optional**

The credential ID to use.

#### options.extensions

* **Type:** `AuthenticationExtensionsClientInputs`
* **Optional**

List of Web Authentication API credentials to use during creation or authentication.

#### options.getFn

* **Type:** `(options?: CredentialRequestOptions`
* **Optional**

Credential request function. Useful for environments that do not support
the WebAuthn API natively (i.e. React Native or testing environments).

#### options.rpId

* **Type:** `string`
* **Optional**

The relying party identifier to use.

#### options.timeout

* **Type:** `number`
* **Optional**

Time, in milliseconds, that the caller is willing to wait for the operation.

#### options.userVerification

* **Type:** `UserVerificationRequirement`
* **Optional**

The user verification requirement.

## Return Type

The signature.

`Promise<sign.ReturnType>`
