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

# crypto/P256

> Auto-generated API documentation

[**@tevm/voltaire**](../index.mdx)

***

[@tevm/voltaire](../index.mdx) / crypto/P256

# crypto/P256

## Classes

### InvalidPrivateKeyError

Defined in: [src/crypto/P256/errors.js:80](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/errors.js#L80)

Error for invalid private keys

#### See

[https://voltaire.tevm.sh/crypto](https://voltaire.tevm.sh/crypto) for crypto documentation

#### Since

0.0.0

#### Extends

* [`InvalidPrivateKeyError`](../index/index.mdx#invalidprivatekeyerror)

#### Constructors

##### Constructor

> **new InvalidPrivateKeyError**(`message`, `options?`): [`InvalidPrivateKeyError`](#invalidprivatekeyerror)

Defined in: [src/crypto/P256/errors.js:85](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/errors.js#L85)

###### Parameters

###### message

`string`

###### options?

###### cause?

`Error`

###### code?

`string`

###### context?

`Record`\<`string`, `unknown`>

###### docsPath?

`string`

###### Returns

[`InvalidPrivateKeyError`](#invalidprivatekeyerror)

###### Overrides

[`InvalidPrivateKeyError`](../index/index.mdx#invalidprivatekeyerror).[`constructor`](../index/index.mdx#constructor-9)

#### Properties

##### cause?

> `optional` **cause**: `Error`

Defined in: [src/primitives/errors/AbstractError.ts:56](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/errors/AbstractError.ts#L56)

Root cause of this error (for error chaining)

###### Inherited from

[`InvalidPrivateKeyError`](../index/index.mdx#invalidprivatekeyerror).[`cause`](../index/index.mdx#cause-9)

##### code

> **code**: `string`

Defined in: [src/primitives/errors/AbstractError.ts:39](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/errors/AbstractError.ts#L39)

Machine-readable error code for programmatic handling

###### Example

```ts theme={null}
'INVALID_FORMAT', 'INVALID_LENGTH'
```

###### Inherited from

[`InvalidPrivateKeyError`](../index/index.mdx#invalidprivatekeyerror).[`code`](../index/index.mdx#code-9)

##### context?

> `optional` **context**: `Record`\<`string`, `unknown`>

Defined in: [src/primitives/errors/AbstractError.ts:45](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/errors/AbstractError.ts#L45)

Additional context metadata for debugging

###### Example

```ts theme={null}
{ value: '0x123', expected: '20 bytes' }
```

###### Inherited from

[`InvalidPrivateKeyError`](../index/index.mdx#invalidprivatekeyerror).[`context`](../index/index.mdx#context-9)

##### docsPath?

> `optional` **docsPath**: `string`

Defined in: [src/primitives/errors/AbstractError.ts:51](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/errors/AbstractError.ts#L51)

Path to documentation for this error

###### Example

```ts theme={null}
'/primitives/address/from-hex#error-handling'
```

###### Inherited from

[`InvalidPrivateKeyError`](../index/index.mdx#invalidprivatekeyerror).[`docsPath`](../index/index.mdx#docspath-9)

##### name

> **name**: `string`

Defined in: [src/crypto/P256/errors.js:92](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/errors.js#L92)

###### Inherited from

`BaseInvalidPrivateKeyError.name`

#### Methods

##### getErrorChain()

> **getErrorChain**(): `string`

Defined in: [src/primitives/errors/AbstractError.ts:94](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/errors/AbstractError.ts#L94)

Get full error chain as string for logging

###### Returns

`string`

###### Inherited from

[`InvalidPrivateKeyError`](../index/index.mdx#invalidprivatekeyerror).[`getErrorChain`](../index/index.mdx#geterrorchain-18)

##### toJSON()

> **toJSON**(): `Record`\<`string`, `unknown`>

Defined in: [src/primitives/errors/AbstractError.ts:110](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/errors/AbstractError.ts#L110)

Serialize error to JSON for logging/telemetry

###### Returns

`Record`\<`string`, `unknown`>

###### Inherited from

[`InvalidPrivateKeyError`](../index/index.mdx#invalidprivatekeyerror).[`toJSON`](../index/index.mdx#tojson-18)

***

### InvalidPublicKeyError

Defined in: [src/crypto/P256/errors.js:58](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/errors.js#L58)

Error for invalid public keys

#### See

[https://voltaire.tevm.sh/crypto](https://voltaire.tevm.sh/crypto) for crypto documentation

#### Since

0.0.0

#### Extends

* [`InvalidPublicKeyError`](../index/index.mdx#invalidpublickeyerror)

#### Constructors

##### Constructor

> **new InvalidPublicKeyError**(`message`, `options?`): [`InvalidPublicKeyError`](#invalidpublickeyerror)

Defined in: [src/crypto/P256/errors.js:63](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/errors.js#L63)

###### Parameters

###### message

`string`

###### options?

###### cause?

`Error`

###### code?

`string`

###### context?

`Record`\<`string`, `unknown`>

###### docsPath?

`string`

###### Returns

[`InvalidPublicKeyError`](#invalidpublickeyerror)

###### Overrides

[`InvalidPublicKeyError`](../index/index.mdx#invalidpublickeyerror).[`constructor`](../index/index.mdx#constructor-10)

#### Properties

##### cause?

> `optional` **cause**: `Error`

Defined in: [src/primitives/errors/AbstractError.ts:56](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/errors/AbstractError.ts#L56)

Root cause of this error (for error chaining)

###### Inherited from

[`InvalidPublicKeyError`](../index/index.mdx#invalidpublickeyerror).[`cause`](../index/index.mdx#cause-10)

##### code

> **code**: `string`

Defined in: [src/primitives/errors/AbstractError.ts:39](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/errors/AbstractError.ts#L39)

Machine-readable error code for programmatic handling

###### Example

```ts theme={null}
'INVALID_FORMAT', 'INVALID_LENGTH'
```

###### Inherited from

[`InvalidPublicKeyError`](../index/index.mdx#invalidpublickeyerror).[`code`](../index/index.mdx#code-10)

##### context?

> `optional` **context**: `Record`\<`string`, `unknown`>

Defined in: [src/primitives/errors/AbstractError.ts:45](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/errors/AbstractError.ts#L45)

Additional context metadata for debugging

###### Example

```ts theme={null}
{ value: '0x123', expected: '20 bytes' }
```

###### Inherited from

[`InvalidPublicKeyError`](../index/index.mdx#invalidpublickeyerror).[`context`](../index/index.mdx#context-10)

##### docsPath?

> `optional` **docsPath**: `string`

Defined in: [src/primitives/errors/AbstractError.ts:51](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/errors/AbstractError.ts#L51)

Path to documentation for this error

###### Example

```ts theme={null}
'/primitives/address/from-hex#error-handling'
```

###### Inherited from

[`InvalidPublicKeyError`](../index/index.mdx#invalidpublickeyerror).[`docsPath`](../index/index.mdx#docspath-10)

##### name

> **name**: `string`

Defined in: [src/crypto/P256/errors.js:70](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/errors.js#L70)

###### Inherited from

`BaseInvalidPublicKeyError.name`

#### Methods

##### getErrorChain()

> **getErrorChain**(): `string`

Defined in: [src/primitives/errors/AbstractError.ts:94](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/errors/AbstractError.ts#L94)

Get full error chain as string for logging

###### Returns

`string`

###### Inherited from

[`InvalidPublicKeyError`](../index/index.mdx#invalidpublickeyerror).[`getErrorChain`](../index/index.mdx#geterrorchain-20)

##### toJSON()

> **toJSON**(): `Record`\<`string`, `unknown`>

Defined in: [src/primitives/errors/AbstractError.ts:110](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/errors/AbstractError.ts#L110)

Serialize error to JSON for logging/telemetry

###### Returns

`Record`\<`string`, `unknown`>

###### Inherited from

[`InvalidPublicKeyError`](../index/index.mdx#invalidpublickeyerror).[`toJSON`](../index/index.mdx#tojson-20)

***

### InvalidSignatureError

Defined in: [src/crypto/P256/errors.js:36](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/errors.js#L36)

Error for invalid signatures

#### See

[https://voltaire.tevm.sh/crypto](https://voltaire.tevm.sh/crypto) for crypto documentation

#### Since

0.0.0

#### Extends

* [`InvalidSignatureError`](../index/index.mdx#invalidsignatureerror)

#### Constructors

##### Constructor

> **new InvalidSignatureError**(`message`, `options?`): [`InvalidSignatureError`](#invalidsignatureerror)

Defined in: [src/crypto/P256/errors.js:41](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/errors.js#L41)

###### Parameters

###### message

`string`

###### options?

###### cause?

`Error`

###### code?

`string`

###### context?

`Record`\<`string`, `unknown`>

###### docsPath?

`string`

###### Returns

[`InvalidSignatureError`](#invalidsignatureerror)

###### Overrides

[`InvalidSignatureError`](../index/index.mdx#invalidsignatureerror).[`constructor`](../index/index.mdx#constructor-12)

#### Properties

##### cause?

> `optional` **cause**: `Error`

Defined in: [src/primitives/errors/AbstractError.ts:56](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/errors/AbstractError.ts#L56)

Root cause of this error (for error chaining)

###### Inherited from

[`InvalidSignatureError`](../index/index.mdx#invalidsignatureerror).[`cause`](../index/index.mdx#cause-12)

##### code

> **code**: `string`

Defined in: [src/primitives/errors/AbstractError.ts:39](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/errors/AbstractError.ts#L39)

Machine-readable error code for programmatic handling

###### Example

```ts theme={null}
'INVALID_FORMAT', 'INVALID_LENGTH'
```

###### Inherited from

[`InvalidSignatureError`](../index/index.mdx#invalidsignatureerror).[`code`](../index/index.mdx#code-12)

##### context?

> `optional` **context**: `Record`\<`string`, `unknown`>

Defined in: [src/primitives/errors/AbstractError.ts:45](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/errors/AbstractError.ts#L45)

Additional context metadata for debugging

###### Example

```ts theme={null}
{ value: '0x123', expected: '20 bytes' }
```

###### Inherited from

[`InvalidSignatureError`](../index/index.mdx#invalidsignatureerror).[`context`](../index/index.mdx#context-12)

##### docsPath?

> `optional` **docsPath**: `string`

Defined in: [src/primitives/errors/AbstractError.ts:51](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/errors/AbstractError.ts#L51)

Path to documentation for this error

###### Example

```ts theme={null}
'/primitives/address/from-hex#error-handling'
```

###### Inherited from

[`InvalidSignatureError`](../index/index.mdx#invalidsignatureerror).[`docsPath`](../index/index.mdx#docspath-12)

##### name

> **name**: `string`

Defined in: [src/crypto/P256/errors.js:48](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/errors.js#L48)

###### Inherited from

`BaseInvalidSignatureError.name`

#### Methods

##### getErrorChain()

> **getErrorChain**(): `string`

Defined in: [src/primitives/errors/AbstractError.ts:94](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/errors/AbstractError.ts#L94)

Get full error chain as string for logging

###### Returns

`string`

###### Inherited from

[`InvalidSignatureError`](../index/index.mdx#invalidsignatureerror).[`getErrorChain`](../index/index.mdx#geterrorchain-24)

##### toJSON()

> **toJSON**(): `Record`\<`string`, `unknown`>

Defined in: [src/primitives/errors/AbstractError.ts:110](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/errors/AbstractError.ts#L110)

Serialize error to JSON for logging/telemetry

###### Returns

`Record`\<`string`, `unknown`>

###### Inherited from

[`InvalidSignatureError`](../index/index.mdx#invalidsignatureerror).[`toJSON`](../index/index.mdx#tojson-24)

***

### P256Error

Defined in: [src/crypto/P256/errors.js:14](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/errors.js#L14)

Base error for P256 operations

#### See

[https://voltaire.tevm.sh/crypto](https://voltaire.tevm.sh/crypto) for crypto documentation

#### Since

0.0.0

#### Extends

* [`CryptoError`](../index/index.mdx#cryptoerror)

#### Constructors

##### Constructor

> **new P256Error**(`message`, `options?`): [`P256Error`](#p256error)

Defined in: [src/crypto/P256/errors.js:19](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/errors.js#L19)

###### Parameters

###### message

`string`

###### options?

###### cause?

`Error`

###### code?

`string`

###### context?

`Record`\<`string`, `unknown`>

###### docsPath?

`string`

###### Returns

[`P256Error`](#p256error)

###### Overrides

[`CryptoError`](../index/index.mdx#cryptoerror).[`constructor`](../index/index.mdx#constructor-1)

#### Properties

##### cause?

> `optional` **cause**: `Error`

Defined in: [src/primitives/errors/AbstractError.ts:56](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/errors/AbstractError.ts#L56)

Root cause of this error (for error chaining)

###### Inherited from

[`CryptoError`](../index/index.mdx#cryptoerror).[`cause`](../index/index.mdx#cause-1)

##### code

> **code**: `string`

Defined in: [src/primitives/errors/AbstractError.ts:39](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/errors/AbstractError.ts#L39)

Machine-readable error code for programmatic handling

###### Example

```ts theme={null}
'INVALID_FORMAT', 'INVALID_LENGTH'
```

###### Inherited from

[`CryptoError`](../index/index.mdx#cryptoerror).[`code`](../index/index.mdx#code-1)

##### context?

> `optional` **context**: `Record`\<`string`, `unknown`>

Defined in: [src/primitives/errors/AbstractError.ts:45](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/errors/AbstractError.ts#L45)

Additional context metadata for debugging

###### Example

```ts theme={null}
{ value: '0x123', expected: '20 bytes' }
```

###### Inherited from

[`CryptoError`](../index/index.mdx#cryptoerror).[`context`](../index/index.mdx#context-1)

##### docsPath?

> `optional` **docsPath**: `string`

Defined in: [src/primitives/errors/AbstractError.ts:51](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/errors/AbstractError.ts#L51)

Path to documentation for this error

###### Example

```ts theme={null}
'/primitives/address/from-hex#error-handling'
```

###### Inherited from

[`CryptoError`](../index/index.mdx#cryptoerror).[`docsPath`](../index/index.mdx#docspath-1)

##### name

> **name**: `string`

Defined in: [src/crypto/P256/errors.js:26](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/errors.js#L26)

###### Inherited from

`CryptoError.name`

#### Methods

##### getErrorChain()

> **getErrorChain**(): `string`

Defined in: [src/primitives/errors/AbstractError.ts:94](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/errors/AbstractError.ts#L94)

Get full error chain as string for logging

###### Returns

`string`

###### Inherited from

[`CryptoError`](../index/index.mdx#cryptoerror).[`getErrorChain`](../index/index.mdx#geterrorchain-2)

##### toJSON()

> **toJSON**(): `Record`\<`string`, `unknown`>

Defined in: [src/primitives/errors/AbstractError.ts:110](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/errors/AbstractError.ts#L110)

Serialize error to JSON for logging/telemetry

###### Returns

`Record`\<`string`, `unknown`>

###### Inherited from

[`CryptoError`](../index/index.mdx#cryptoerror).[`toJSON`](../index/index.mdx#tojson-2)

## Interfaces

### P256Constructor

Defined in: [src/crypto/P256/P256Constructor.ts:15](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/P256Constructor.ts#L15)

#### Properties

##### CURVE\_ORDER

> **CURVE\_ORDER**: `bigint`

Defined in: [src/crypto/P256/P256Constructor.ts:22](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/P256Constructor.ts#L22)

##### derivePublicKey()

> **derivePublicKey**: (`privateKey`) => [`P256PublicKeyType`](#p256publickeytype)

Defined in: [src/crypto/P256/P256Constructor.ts:18](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/P256Constructor.ts#L18)

Derive public key from private key

###### Parameters

###### privateKey

[`P256PrivateKeyType`](#p256privatekeytype)

32-byte private key

###### Returns

[`P256PublicKeyType`](#p256publickeytype)

64-byte uncompressed public key (x || y coordinates)

###### See

[https://voltaire.tevm.sh/crypto](https://voltaire.tevm.sh/crypto) for crypto documentation

###### Since

0.0.0

###### Throws

If private key is invalid

###### Example

```javascript theme={null}
import * as P256 from './crypto/P256/index.js';
const privateKey = new Uint8Array(32);
const publicKey = P256.derivePublicKey(privateKey);
```

##### ecdh()

> **ecdh**: (`privateKey`, `publicKey`) => `Uint8Array`\<`ArrayBufferLike`>

Defined in: [src/crypto/P256/P256Constructor.ts:19](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/P256Constructor.ts#L19)

Perform ECDH key exchange

Computes shared secret from your private key and their public key.
Returns the x-coordinate of the shared point.

###### Parameters

###### privateKey

[`P256PrivateKeyType`](#p256privatekeytype)

Your 32-byte private key

###### publicKey

[`P256PublicKeyType`](#p256publickeytype)

Their 64-byte uncompressed public key

###### Returns

`Uint8Array`\<`ArrayBufferLike`>

32-byte shared secret

###### See

[https://voltaire.tevm.sh/crypto](https://voltaire.tevm.sh/crypto) for crypto documentation

###### Since

0.0.0

###### Throws

If private key is invalid

###### Throws

If public key is invalid

###### Throws

If ECDH computation fails

###### Example

```javascript theme={null}
import * as P256 from './crypto/P256/index.js';
const myPrivateKey = new Uint8Array(32);
const theirPublicKey = P256.derivePublicKey(theirPrivateKey);
const sharedSecret = P256.ecdh(myPrivateKey, theirPublicKey);
```

##### PRIVATE\_KEY\_SIZE

> **PRIVATE\_KEY\_SIZE**: `number`

Defined in: [src/crypto/P256/P256Constructor.ts:23](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/P256Constructor.ts#L23)

##### PUBLIC\_KEY\_SIZE

> **PUBLIC\_KEY\_SIZE**: `number`

Defined in: [src/crypto/P256/P256Constructor.ts:24](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/P256Constructor.ts#L24)

##### SHARED\_SECRET\_SIZE

> **SHARED\_SECRET\_SIZE**: `number`

Defined in: [src/crypto/P256/P256Constructor.ts:26](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/P256Constructor.ts#L26)

##### sign()

> **sign**: (`messageHash`, `privateKey`) => [`P256SignatureType`](#p256signaturetype)

Defined in: [src/crypto/P256/P256Constructor.ts:16](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/P256Constructor.ts#L16)

Sign a message hash with a private key

Uses deterministic ECDSA (RFC 6979) for signature generation.

###### Parameters

###### messageHash

[`HashType`](../index/namespaces/HashType.mdx#hashtype)

32-byte message hash to sign

###### privateKey

[`P256PrivateKeyType`](#p256privatekeytype)

32-byte private key

###### Returns

[`P256SignatureType`](#p256signaturetype)

ECDSA signature with r, s components

###### See

[https://voltaire.tevm.sh/crypto](https://voltaire.tevm.sh/crypto) for crypto documentation

###### Since

0.0.0

###### Throws

If private key is invalid

###### Throws

If signing fails

###### Example

```javascript theme={null}
import * as P256 from './crypto/P256/index.js';
import * as Keccak256 from './crypto/Keccak256/index.js';
const messageHash = Keccak256.hashString('Hello!');
const privateKey = new Uint8Array(32);
const signature = P256.sign(messageHash, privateKey);
```

##### SIGNATURE\_COMPONENT\_SIZE

> **SIGNATURE\_COMPONENT\_SIZE**: `number`

Defined in: [src/crypto/P256/P256Constructor.ts:25](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/P256Constructor.ts#L25)

##### validatePrivateKey()

> **validatePrivateKey**: (`privateKey`) => `boolean`

Defined in: [src/crypto/P256/P256Constructor.ts:20](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/P256Constructor.ts#L20)

Validate a private key

Checks if the private key is in the valid range \[1, n-1]

###### Parameters

###### privateKey

[`P256PrivateKeyType`](#p256privatekeytype)

Private key to validate

###### Returns

`boolean`

True if valid, false otherwise

###### See

[https://voltaire.tevm.sh/crypto](https://voltaire.tevm.sh/crypto) for crypto documentation

###### Since

0.0.0

###### Throws

###### Example

```javascript theme={null}
import * as P256 from './crypto/P256/index.js';
const privateKey = new Uint8Array(32);
const isValid = P256.validatePrivateKey(privateKey);
```

##### validatePublicKey()

> **validatePublicKey**: (`publicKey`) => `boolean`

Defined in: [src/crypto/P256/P256Constructor.ts:21](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/P256Constructor.ts#L21)

Validate a public key

Checks if the public key is a valid point on the P256 curve

###### Parameters

###### publicKey

[`P256PublicKeyType`](#p256publickeytype)

Public key to validate

###### Returns

`boolean`

True if valid, false otherwise

###### See

[https://voltaire.tevm.sh/crypto](https://voltaire.tevm.sh/crypto) for crypto documentation

###### Since

0.0.0

###### Throws

###### Example

```javascript theme={null}
import * as P256 from './crypto/P256/index.js';
const publicKey = new Uint8Array(64);
const isValid = P256.validatePublicKey(publicKey);
```

##### verify()

> **verify**: (`signature`, `messageHash`, `publicKey`) => `boolean`

Defined in: [src/crypto/P256/P256Constructor.ts:17](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/P256Constructor.ts#L17)

Verify an ECDSA signature

###### Parameters

###### signature

[`P256SignatureType`](#p256signaturetype)

ECDSA signature to verify (r and s are HashType)

###### messageHash

[`HashType`](../index/namespaces/HashType.mdx#hashtype)

32-byte message hash that was signed

###### publicKey

[`P256PublicKeyType`](#p256publickeytype)

64-byte uncompressed public key

###### Returns

`boolean`

True if signature is valid, false otherwise

###### See

[https://voltaire.tevm.sh/crypto](https://voltaire.tevm.sh/crypto) for crypto documentation

###### Since

0.0.0

###### Throws

If public key format is invalid

###### Example

```javascript theme={null}
import * as P256 from './crypto/P256/index.js';
import * as Hash from './primitives/Hash/index.js';
const r = Hash.from(rBytes);
const s = Hash.from(sBytes);
const valid = P256.verify({ r, s }, messageHash, publicKey);
if (valid) console.log('Signature is valid!');
```

## Type Aliases

### P256PrivateKeyType

> **P256PrivateKeyType** = `Uint8Array`

Defined in: [src/crypto/P256/P256PrivateKeyType.ts:7](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/P256PrivateKeyType.ts#L7)

Private key (32 bytes scalar value)

#### See

[https://voltaire.tevm.sh/crypto](https://voltaire.tevm.sh/crypto) for crypto documentation

#### Since

0.0.0

***

### P256PublicKeyType

> **P256PublicKeyType** = `Uint8Array`

Defined in: [src/crypto/P256/P256PublicKeyType.ts:9](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/P256PublicKeyType.ts#L9)

Uncompressed public key (64 bytes)

Format: x-coordinate (32 bytes) || y-coordinate (32 bytes)

#### See

[https://voltaire.tevm.sh/crypto](https://voltaire.tevm.sh/crypto) for crypto documentation

#### Since

0.0.0

***

### P256SignatureType

> **P256SignatureType** = `object`

Defined in: [src/crypto/P256/P256SignatureType.ts:11](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/P256SignatureType.ts#L11)

ECDSA signature (r, s components)

Components:

* r: x-coordinate of the ephemeral public key (32 bytes, HashType)
* s: signature proof value (32 bytes, HashType)

#### See

[https://voltaire.tevm.sh/crypto](https://voltaire.tevm.sh/crypto) for crypto documentation

#### Since

0.0.0

#### Properties

##### r

> **r**: [`HashType`](../index/namespaces/HashType.mdx#hashtype)

Defined in: [src/crypto/P256/P256SignatureType.ts:12](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/P256SignatureType.ts#L12)

##### s

> **s**: [`HashType`](../index/namespaces/HashType.mdx#hashtype)

Defined in: [src/crypto/P256/P256SignatureType.ts:13](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/P256SignatureType.ts#L13)

## Variables

### CURVE\_ORDER

> `const` **CURVE\_ORDER**: `bigint` = `0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551n`

Defined in: [src/crypto/P256/constants.js:8](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/constants.js#L8)

P256 curve order (number of points on the curve)

#### See

[https://voltaire.tevm.sh/crypto](https://voltaire.tevm.sh/crypto) for crypto documentation

#### Since

0.0.0

***

### P256

> `const` **P256**: [`P256Constructor`](#p256constructor)

Defined in: [src/crypto/P256/P256.js:67](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/P256.js#L67)

P256 namespace with cryptographic operations

***

### PRIVATE\_KEY\_SIZE

> `const` **PRIVATE\_KEY\_SIZE**: `number` = `32`

Defined in: [src/crypto/P256/constants.js:18](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/constants.js#L18)

Private key size in bytes

#### See

[https://voltaire.tevm.sh/crypto](https://voltaire.tevm.sh/crypto) for crypto documentation

#### Since

0.0.0

***

### PUBLIC\_KEY\_SIZE

> `const` **PUBLIC\_KEY\_SIZE**: `number` = `64`

Defined in: [src/crypto/P256/constants.js:27](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/constants.js#L27)

Uncompressed public key size in bytes (64 bytes, no prefix)

#### See

[https://voltaire.tevm.sh/crypto](https://voltaire.tevm.sh/crypto) for crypto documentation

#### Since

0.0.0

***

### SHARED\_SECRET\_SIZE

> `const` **SHARED\_SECRET\_SIZE**: `number` = `32`

Defined in: [src/crypto/P256/constants.js:45](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/constants.js#L45)

ECDH shared secret size in bytes

#### See

[https://voltaire.tevm.sh/crypto](https://voltaire.tevm.sh/crypto) for crypto documentation

#### Since

0.0.0

***

### SIGNATURE\_COMPONENT\_SIZE

> `const` **SIGNATURE\_COMPONENT\_SIZE**: `number` = `32`

Defined in: [src/crypto/P256/constants.js:36](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/constants.js#L36)

Signature component size in bytes (r and s are each 32 bytes)

#### See

[https://voltaire.tevm.sh/crypto](https://voltaire.tevm.sh/crypto) for crypto documentation

#### Since

0.0.0

## Functions

### derivePublicKey()

> **derivePublicKey**(`privateKey`): [`P256PublicKeyType`](#p256publickeytype)

Defined in: [src/crypto/P256/derivePublicKey.js:21](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/derivePublicKey.js#L21)

Derive public key from private key

#### Parameters

##### privateKey

[`P256PrivateKeyType`](#p256privatekeytype)

32-byte private key

#### Returns

[`P256PublicKeyType`](#p256publickeytype)

64-byte uncompressed public key (x || y coordinates)

#### See

[https://voltaire.tevm.sh/crypto](https://voltaire.tevm.sh/crypto) for crypto documentation

#### Since

0.0.0

#### Throws

If private key is invalid

#### Example

```javascript theme={null}
import * as P256 from './crypto/P256/index.js';
const privateKey = new Uint8Array(32);
const publicKey = P256.derivePublicKey(privateKey);
```

***

### ecdh()

> **ecdh**(`privateKey`, `publicKey`): `Uint8Array`\<`ArrayBufferLike`>

Defined in: [src/crypto/P256/ecdh.js:32](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/ecdh.js#L32)

Perform ECDH key exchange

Computes shared secret from your private key and their public key.
Returns the x-coordinate of the shared point.

#### Parameters

##### privateKey

[`P256PrivateKeyType`](#p256privatekeytype)

Your 32-byte private key

##### publicKey

[`P256PublicKeyType`](#p256publickeytype)

Their 64-byte uncompressed public key

#### Returns

`Uint8Array`\<`ArrayBufferLike`>

32-byte shared secret

#### See

[https://voltaire.tevm.sh/crypto](https://voltaire.tevm.sh/crypto) for crypto documentation

#### Since

0.0.0

#### Throws

If private key is invalid

#### Throws

If public key is invalid

#### Throws

If ECDH computation fails

#### Example

```javascript theme={null}
import * as P256 from './crypto/P256/index.js';
const myPrivateKey = new Uint8Array(32);
const theirPublicKey = P256.derivePublicKey(theirPrivateKey);
const sharedSecret = P256.ecdh(myPrivateKey, theirPublicKey);
```

***

### sign()

> **sign**(`messageHash`, `privateKey`): [`P256SignatureType`](#p256signaturetype)

Defined in: [src/crypto/P256/sign.js:28](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/sign.js#L28)

Sign a message hash with a private key

Uses deterministic ECDSA (RFC 6979) for signature generation.

#### Parameters

##### messageHash

[`HashType`](../index/namespaces/HashType.mdx#hashtype)

32-byte message hash to sign

##### privateKey

[`P256PrivateKeyType`](#p256privatekeytype)

32-byte private key

#### Returns

[`P256SignatureType`](#p256signaturetype)

ECDSA signature with r, s components

#### See

[https://voltaire.tevm.sh/crypto](https://voltaire.tevm.sh/crypto) for crypto documentation

#### Since

0.0.0

#### Throws

If private key is invalid

#### Throws

If signing fails

#### Example

```javascript theme={null}
import * as P256 from './crypto/P256/index.js';
import * as Keccak256 from './crypto/Keccak256/index.js';
const messageHash = Keccak256.hashString('Hello!');
const privateKey = new Uint8Array(32);
const signature = P256.sign(messageHash, privateKey);
```

***

### validatePrivateKey()

> **validatePrivateKey**(`privateKey`): `boolean`

Defined in: [src/crypto/P256/validatePrivateKey.js:22](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/validatePrivateKey.js#L22)

Validate a private key

Checks if the private key is in the valid range \[1, n-1]

#### Parameters

##### privateKey

[`P256PrivateKeyType`](#p256privatekeytype)

Private key to validate

#### Returns

`boolean`

True if valid, false otherwise

#### See

[https://voltaire.tevm.sh/crypto](https://voltaire.tevm.sh/crypto) for crypto documentation

#### Since

0.0.0

#### Throws

#### Example

```javascript theme={null}
import * as P256 from './crypto/P256/index.js';
const privateKey = new Uint8Array(32);
const isValid = P256.validatePrivateKey(privateKey);
```

***

### validatePublicKey()

> **validatePublicKey**(`publicKey`): `boolean`

Defined in: [src/crypto/P256/validatePublicKey.js:22](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/validatePublicKey.js#L22)

Validate a public key

Checks if the public key is a valid point on the P256 curve

#### Parameters

##### publicKey

[`P256PublicKeyType`](#p256publickeytype)

Public key to validate

#### Returns

`boolean`

True if valid, false otherwise

#### See

[https://voltaire.tevm.sh/crypto](https://voltaire.tevm.sh/crypto) for crypto documentation

#### Since

0.0.0

#### Throws

#### Example

```javascript theme={null}
import * as P256 from './crypto/P256/index.js';
const publicKey = new Uint8Array(64);
const isValid = P256.validatePublicKey(publicKey);
```

***

### verify()

> **verify**(`signature`, `messageHash`, `publicKey`): `boolean`

Defined in: [src/crypto/P256/verify.js:26](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/P256/verify.js#L26)

Verify an ECDSA signature

#### Parameters

##### signature

[`P256SignatureType`](#p256signaturetype)

ECDSA signature to verify (r and s are HashType)

##### messageHash

[`HashType`](../index/namespaces/HashType.mdx#hashtype)

32-byte message hash that was signed

##### publicKey

[`P256PublicKeyType`](#p256publickeytype)

64-byte uncompressed public key

#### Returns

`boolean`

True if signature is valid, false otherwise

#### See

[https://voltaire.tevm.sh/crypto](https://voltaire.tevm.sh/crypto) for crypto documentation

#### Since

0.0.0

#### Throws

If public key format is invalid

#### Example

```javascript theme={null}
import * as P256 from './crypto/P256/index.js';
import * as Hash from './primitives/Hash/index.js';
const r = Hash.from(rBytes);
const s = Hash.from(sBytes);
const valid = P256.verify({ r, s }, messageHash, publicKey);
if (valid) console.log('Signature is valid!');
```
