# WebAuthnP256.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 { WebAuthnP256 } from 'ox'
```

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

## Examples

```ts twoslash
import { WebAuthnP256 } from 'ox'

const credential = await WebAuthnP256.createCredential({
  name: 'Example'
})

const { metadata, signature } = await WebAuthnP256.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/core/WebAuthnP256.ts](https://github.com/wevm/ox/blob/main/src/core/WebAuthnP256.ts#L401)

## Parameters

### options

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

Options.

## Return Type

The signature.

`Promise<sign.ReturnType>`
