> ## 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.

# primitives/PrivateKey

> Auto-generated API documentation

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

***

[@tevm/voltaire](../index.mdx) / primitives/PrivateKey

# primitives/PrivateKey

## Type Aliases

### PrivateKeyType

> **PrivateKeyType** = `Uint8Array` & `object`

Defined in: [src/primitives/PrivateKey/PrivateKeyType.ts:7](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/PrivateKey/PrivateKeyType.ts#L7)

Branded PrivateKey type - 32 byte private key for cryptographic operations
Prevents accidental exposure or misuse of sensitive key material

#### Type Declaration

##### \[brand]

> `readonly` **\[brand]**: `"PrivateKey"`

##### length

> `readonly` **length**: `32`

## Variables

### \_sign()

> `const` **\_sign**: (`privateKey`, `hash`) => [`Secp256k1SignatureType`](../crypto/Secp256k1.mdx#secp256k1signaturetype)

Defined in: [src/primitives/PrivateKey/index.ts:25](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/PrivateKey/index.ts#L25)

#### Parameters

##### privateKey

[`PrivateKeyType`](#privatekeytype)

##### hash

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

#### Returns

[`Secp256k1SignatureType`](../crypto/Secp256k1.mdx#secp256k1signaturetype)

***

### PrivateKey

> `const` **PrivateKey**: `object`

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

#### Type Declaration

##### from()

> **from**: (`hex`) => [`PrivateKeyType`](#privatekeytype)

Create PrivateKey from hex string

###### Parameters

###### hex

`string`

Hex string (32 bytes)

###### Returns

[`PrivateKeyType`](#privatekeytype)

Private key

###### Throws

If hex string format is invalid

###### Throws

If hex is not 32 bytes

###### Example

```typescript theme={null}
const pk = PrivateKey.from("0x1234...");
```

##### fromBytes()

> **fromBytes**: (`bytes`) => [`PrivateKeyType`](#privatekeytype)

Create PrivateKey from raw bytes

###### Parameters

###### bytes

`Uint8Array`\<`ArrayBufferLike`>

Raw bytes (must be 32 bytes)

###### Returns

[`PrivateKeyType`](#privatekeytype)

Private key

###### Throws

If bytes is not 32 bytes

###### Example

```javascript theme={null}
import * as PrivateKey from './primitives/PrivateKey/index.js';
const bytes = new Uint8Array(32);
const privateKey = PrivateKey.fromBytes(bytes);
```

##### sign()

> **sign**: (`privateKey`, `hash`) => [`Secp256k1SignatureType`](../crypto/Secp256k1.mdx#secp256k1signaturetype)

###### Parameters

###### privateKey

`string`

###### hash

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

###### Returns

[`Secp256k1SignatureType`](../crypto/Secp256k1.mdx#secp256k1signaturetype)

##### toAddress()

> **toAddress**: (`privateKey`) => [`AddressType`](Address.mdx#addresstype)

###### Parameters

###### privateKey

`string`

###### Returns

[`AddressType`](Address.mdx#addresstype)

##### toHex()

> **toHex**: (`privateKey`) => `string`

###### Parameters

###### privateKey

`string`

###### Returns

`string`

##### toPublicKey()

> **toPublicKey**: (`privateKey`) => [`PublicKeyType`](PublicKey.mdx#publickeytype)

###### Parameters

###### privateKey

`string`

###### Returns

[`PublicKeyType`](PublicKey.mdx#publickeytype)

## Functions

### \_toAddress()

> **\_toAddress**(`this`): [`AddressType`](Address.mdx#addresstype)

Defined in: [src/primitives/PrivateKey/toAddress.ts:17](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/PrivateKey/toAddress.ts#L17)

Derive Ethereum address from private key

#### Parameters

##### this

[`PrivateKeyType`](#privatekeytype)

Private key

#### Returns

[`AddressType`](Address.mdx#addresstype)

Ethereum address (20 bytes)

#### Example

```typescript theme={null}
const address = PrivateKey._toAddress.call(pk);
```

***

### \_toHex()

> **\_toHex**(`this`): `string`

Defined in: [src/primitives/PrivateKey/toHex.ts:14](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/PrivateKey/toHex.ts#L14)

Convert PrivateKey to hex string

#### Parameters

##### this

[`PrivateKeyType`](#privatekeytype)

Private key

#### Returns

`string`

Hex string

#### Example

```typescript theme={null}
const hex = PrivateKey._toHex.call(pk);
```

***

### \_toPublicKey()

> **\_toPublicKey**(`this`): [`PublicKeyType`](PublicKey.mdx#publickeytype)

Defined in: [src/primitives/PrivateKey/toPublicKey.ts:16](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/PrivateKey/toPublicKey.ts#L16)

Derive public key from private key

#### Parameters

##### this

[`PrivateKeyType`](#privatekeytype)

Private key

#### Returns

[`PublicKeyType`](PublicKey.mdx#publickeytype)

Public key (uncompressed 64 bytes)

#### Example

```typescript theme={null}
const publicKey = PrivateKey._toPublicKey.call(pk);
```

***

### from()

> **from**(`hex`): [`PrivateKeyType`](#privatekeytype)

Defined in: [src/primitives/PrivateKey/from.ts:22](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/PrivateKey/from.ts#L22)

Create PrivateKey from hex string

#### Parameters

##### hex

`string`

Hex string (32 bytes)

#### Returns

[`PrivateKeyType`](#privatekeytype)

Private key

#### Throws

If hex string format is invalid

#### Throws

If hex is not 32 bytes

#### Example

```typescript theme={null}
const pk = PrivateKey.from("0x1234...");
```

***

### fromBytes()

> **fromBytes**(`bytes`): [`PrivateKeyType`](#privatekeytype)

Defined in: [src/primitives/PrivateKey/fromBytes.js:17](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/PrivateKey/fromBytes.js#L17)

Create PrivateKey from raw bytes

#### Parameters

##### bytes

`Uint8Array`\<`ArrayBufferLike`>

Raw bytes (must be 32 bytes)

#### Returns

[`PrivateKeyType`](#privatekeytype)

Private key

#### Throws

If bytes is not 32 bytes

#### Example

```javascript theme={null}
import * as PrivateKey from './primitives/PrivateKey/index.js';
const bytes = new Uint8Array(32);
const privateKey = PrivateKey.fromBytes(bytes);
```

***

### sign()

> **sign**(`privateKey`, `hash`): [`Secp256k1SignatureType`](../crypto/Secp256k1.mdx#secp256k1signaturetype)

Defined in: [src/primitives/PrivateKey/index.ts:40](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/PrivateKey/index.ts#L40)

#### Parameters

##### privateKey

`string`

##### hash

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

#### Returns

[`Secp256k1SignatureType`](../crypto/Secp256k1.mdx#secp256k1signaturetype)

***

### Sign()

> **Sign**(`deps`): (`privateKey`, `hash`) => [`Secp256k1SignatureType`](../crypto/Secp256k1.mdx#secp256k1signaturetype)

Defined in: [src/primitives/PrivateKey/sign.js:7](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/PrivateKey/sign.js#L7)

Factory: Sign a message hash with private key

#### Parameters

##### deps

Crypto dependencies

###### secp256k1Sign

(`messageHash`, `privateKey`) => [`Secp256k1SignatureType`](../crypto/Secp256k1.mdx#secp256k1signaturetype)

Secp256k1 signing function

#### Returns

Function that creates ECDSA signature

> (`privateKey`, `hash`): [`Secp256k1SignatureType`](../crypto/Secp256k1.mdx#secp256k1signaturetype)

##### Parameters

###### privateKey

[`PrivateKeyType`](#privatekeytype)

###### hash

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

##### Returns

[`Secp256k1SignatureType`](../crypto/Secp256k1.mdx#secp256k1signaturetype)

***

### toAddress()

> **toAddress**(`privateKey`): [`AddressType`](Address.mdx#addresstype)

Defined in: [src/primitives/PrivateKey/index.ts:36](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/PrivateKey/index.ts#L36)

#### Parameters

##### privateKey

`string`

#### Returns

[`AddressType`](Address.mdx#addresstype)

***

### toHex()

> **toHex**(`privateKey`): `string`

Defined in: [src/primitives/PrivateKey/index.ts:28](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/PrivateKey/index.ts#L28)

#### Parameters

##### privateKey

`string`

#### Returns

`string`

***

### toPublicKey()

> **toPublicKey**(`privateKey`): [`PublicKeyType`](PublicKey.mdx#publickeytype)

Defined in: [src/primitives/PrivateKey/index.ts:32](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/PrivateKey/index.ts#L32)

#### Parameters

##### privateKey

`string`

#### Returns

[`PublicKeyType`](PublicKey.mdx#publickeytype)

## References

### BrandedPrivateKey

Renames and re-exports [PrivateKeyType](#privatekeytype)

***

### default

Renames and re-exports [PrivateKey](#privatekey)
