Skip to main content
@tevm/voltaire
@tevm/voltaire / crypto/X25519

crypto/X25519

Classes

InvalidPublicKeyError

Defined in: src/crypto/X25519/errors.js:87 Error thrown when public key is invalid

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

Example

Extends

Constructors

Constructor
new InvalidPublicKeyError(message, options?): InvalidPublicKeyError
Defined in: src/crypto/X25519/errors.js:92
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
Returns
InvalidPublicKeyError
Overrides
InvalidPublicKeyError.constructor

Properties

cause?
optional cause: Error
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)
Inherited from
InvalidPublicKeyError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39 Machine-readable error code for programmatic handling
Example
Inherited from
InvalidPublicKeyError.code
context?
optional context: Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debugging
Example
Inherited from
InvalidPublicKeyError.context
docsPath?
optional docsPath: string
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this error
Example
Inherited from
InvalidPublicKeyError.docsPath
name
name: string
Defined in: src/crypto/X25519/errors.js:99
Inherited from
BaseInvalidPublicKeyError.name

Methods

getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94 Get full error chain as string for logging
Returns
string
Inherited from
InvalidPublicKeyError.getErrorChain
toJSON()
toJSON(): Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetry
Returns
Record<string, unknown>
Inherited from
InvalidPublicKeyError.toJSON

InvalidSecretKeyError

Defined in: src/crypto/X25519/errors.js:55 Error thrown when secret key is invalid

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

Example

Extends

Constructors

Constructor
new InvalidSecretKeyError(message, options?): InvalidSecretKeyError
Defined in: src/crypto/X25519/errors.js:60
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
Returns
InvalidSecretKeyError
Overrides
InvalidPrivateKeyError.constructor

Properties

cause?
optional cause: Error
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)
Inherited from
InvalidPrivateKeyError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39 Machine-readable error code for programmatic handling
Example
Inherited from
InvalidPrivateKeyError.code
context?
optional context: Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debugging
Example
Inherited from
InvalidPrivateKeyError.context
docsPath?
optional docsPath: string
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this error
Example
Inherited from
InvalidPrivateKeyError.docsPath
name
name: string
Defined in: src/crypto/X25519/errors.js:67
Inherited from
InvalidPrivateKeyError.name

Methods

getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94 Get full error chain as string for logging
Returns
string
Inherited from
InvalidPrivateKeyError.getErrorChain
toJSON()
toJSON(): Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetry
Returns
Record<string, unknown>
Inherited from
InvalidPrivateKeyError.toJSON

X25519Error

Defined in: src/crypto/X25519/errors.js:23 Base error for X25519 operations

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

Example

Extends

Constructors

Constructor
new X25519Error(message, options?): X25519Error
Defined in: src/crypto/X25519/errors.js:28
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
Returns
X25519Error
Overrides
CryptoError.constructor

Properties

cause?
optional cause: Error
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)
Inherited from
CryptoError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39 Machine-readable error code for programmatic handling
Example
Inherited from
CryptoError.code
context?
optional context: Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debugging
Example
Inherited from
CryptoError.context
docsPath?
optional docsPath: string
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this error
Example
Inherited from
CryptoError.docsPath
name
name: string
Defined in: src/crypto/X25519/errors.js:35
Inherited from
CryptoError.name

Methods

getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94 Get full error chain as string for logging
Returns
string
Inherited from
CryptoError.getErrorChain
toJSON()
toJSON(): Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetry
Returns
Record<string, unknown>
Inherited from
CryptoError.toJSON

Type Aliases

PublicKey

PublicKey = Uint8Array
Defined in: src/crypto/X25519/PublicKey.ts:12 X25519 public key (32 bytes)

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Example


SecretKey

SecretKey = Uint8Array
Defined in: src/crypto/X25519/SecretKey.ts:12 X25519 secret key (32 bytes)

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Example


SharedSecret

SharedSecret = Uint8Array
Defined in: src/crypto/X25519/SharedSecret.ts:12 Shared secret from key exchange (32 bytes)

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Example

Variables

PUBLIC_KEY_SIZE

const PUBLIC_KEY_SIZE: 32 = 32
Defined in: src/crypto/X25519/constants.js:29 Public key size in bytes

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

Example


SECRET_KEY_SIZE

const SECRET_KEY_SIZE: 32 = 32
Defined in: src/crypto/X25519/constants.js:14 Secret key size in bytes

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

Example


SHARED_SECRET_SIZE

const SHARED_SECRET_SIZE: 32 = 32
Defined in: src/crypto/X25519/constants.js:44 Shared secret size in bytes

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

Example


X25519

const X25519: object
Defined in: src/crypto/X25519/X25519.js:56 X25519 Elliptic Curve Diffie-Hellman Curve25519 key exchange algorithm for secure shared secret generation. Fast, simple, and designed for ECDH key agreement. Used in modern protocols like TLS 1.3, WireGuard, Signal, and SSH.

Type Declaration

derivePublicKey()
derivePublicKey: (secretKey) => PublicKey
Derive public key from secret key
Parameters
secretKey
SecretKey 32-byte secret key
Returns
PublicKey 32-byte public key
See
https://voltaire.tevm.sh/crypto for crypto documentation
Since
0.0.0
Throws
If secret key is invalid
Example
generateKeypair()
generateKeypair: () => object
Generate random keypair Uses crypto.getRandomValues for secure random generation
Returns
object Object with secretKey and publicKey
publicKey
publicKey: PublicKey
secretKey
secretKey: SecretKey
See
https://voltaire.tevm.sh/crypto for crypto documentation
Since
0.0.0
Throws
Example
generateSecretKey()
generateSecretKey: () => SecretKey
Generate random secret key Uses crypto.getRandomValues for secure random generation
Returns
SecretKey 32-byte random secret key
See
https://voltaire.tevm.sh/crypto for crypto documentation
Since
0.0.0
Throws
Example
keypairFromSeed()
keypairFromSeed: (seed) => object
Generate X25519 keypair from seed
Parameters
seed
Uint8Array<ArrayBufferLike> 32-byte seed for deterministic generation
Returns
object Object with secretKey and publicKey
publicKey
publicKey: PublicKey
secretKey
secretKey: SecretKey
See
https://voltaire.tevm.sh/crypto for crypto documentation
Since
0.0.0
Throws
If seed length is invalid
Example
PUBLIC_KEY_SIZE
PUBLIC_KEY_SIZE: 32
Public key size in bytes
See
https://voltaire.tevm.sh/crypto for crypto documentation
Since
0.0.0
Throws
Example
scalarmult()
scalarmult: (secretKey, publicKey) => SharedSecret
Perform X25519 scalar multiplication (ECDH) Computes shared secret from your secret key and their public key.
Parameters
secretKey
SecretKey Your 32-byte secret key
publicKey
PublicKey Their 32-byte public key
Returns
SharedSecret 32-byte shared secret
See
https://voltaire.tevm.sh/crypto for crypto documentation
Since
0.0.0
Throws
If secret key is invalid
Throws
If public key is invalid
Throws
If scalar multiplication fails
Example
SECRET_KEY_SIZE
SECRET_KEY_SIZE: 32
Secret key size in bytes
See
https://voltaire.tevm.sh/crypto for crypto documentation
Since
0.0.0
Throws
Example
SHARED_SECRET_SIZE
SHARED_SECRET_SIZE: 32
Shared secret size in bytes
See
https://voltaire.tevm.sh/crypto for crypto documentation
Since
0.0.0
Throws
Example
validatePublicKey()
validatePublicKey: (publicKey) => boolean
Validate a public key Checks if the public key has correct length
Parameters
publicKey
PublicKey Public key to validate
Returns
boolean True if valid, false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentation
Since
0.0.0
Throws
Example
validateSecretKey()
validateSecretKey: (secretKey) => boolean
Validate a secret key Checks if the secret key has correct length and can derive a public key
Parameters
secretKey
SecretKey Secret key to validate
Returns
boolean True if valid, false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentation
Since
0.0.0
Throws
Example

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

Example

Functions

derivePublicKey()

derivePublicKey(secretKey): PublicKey
Defined in: src/crypto/X25519/derivePublicKey.js:21 Derive public key from secret key

Parameters

secretKey
SecretKey 32-byte secret key

Returns

PublicKey 32-byte public key

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

If secret key is invalid

Example


generateKeypair()

generateKeypair(): object
Defined in: src/crypto/X25519/generateKeypair.js:21 Generate random keypair Uses crypto.getRandomValues for secure random generation

Returns

object Object with secretKey and publicKey
publicKey
publicKey: PublicKey
secretKey
secretKey: SecretKey

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

Example


generateSecretKey()

generateSecretKey(): SecretKey
Defined in: src/crypto/X25519/generateSecretKey.js:20 Generate random secret key Uses crypto.getRandomValues for secure random generation

Returns

SecretKey 32-byte random secret key

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

Example


keypairFromSeed()

keypairFromSeed(seed): object
Defined in: src/crypto/X25519/keypairFromSeed.js:22 Generate X25519 keypair from seed

Parameters

seed
Uint8Array<ArrayBufferLike> 32-byte seed for deterministic generation

Returns

object Object with secretKey and publicKey
publicKey
publicKey: PublicKey
secretKey
secretKey: SecretKey

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

If seed length is invalid

Example


scalarmult()

scalarmult(secretKey, publicKey): SharedSecret
Defined in: src/crypto/X25519/scalarmult.js:31 Perform X25519 scalar multiplication (ECDH) Computes shared secret from your secret key and their public key.

Parameters

secretKey
SecretKey Your 32-byte secret key
publicKey
PublicKey Their 32-byte public key

Returns

SharedSecret 32-byte shared secret

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

If secret key is invalid

Throws

If public key is invalid

Throws

If scalar multiplication fails

Example


validatePublicKey()

validatePublicKey(publicKey): boolean
Defined in: src/crypto/X25519/validatePublicKey.js:20 Validate a public key Checks if the public key has correct length

Parameters

publicKey
PublicKey Public key to validate

Returns

boolean True if valid, false otherwise

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

Example


validateSecretKey()

validateSecretKey(secretKey): boolean
Defined in: src/crypto/X25519/validateSecretKey.js:21 Validate a secret key Checks if the secret key has correct length and can derive a public key

Parameters

secretKey
SecretKey Secret key to validate

Returns

boolean True if valid, false otherwise

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

Example