@tevm/voltaire / crypto/X25519
crypto/X25519
Classes
InvalidPublicKeyError
Defined in: src/crypto/X25519/errors.js:87 Error thrown when public key is invalidSee
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
Extends
Constructors
Constructor
new InvalidPublicKeyError(Defined in: src/crypto/X25519/errors.js:92message,options?):InvalidPublicKeyError
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
Returns
InvalidPublicKeyError
Overrides
InvalidPublicKeyError.constructor
Properties
cause?
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)optionalcause:Error
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?
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debuggingoptionalcontext:Record<string,unknown>
Example
Inherited from
InvalidPublicKeyError.context
docsPath?
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this erroroptionaldocsPath:string
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():Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetryRecord<string,unknown>
Returns
Record<string, unknown>
Inherited from
InvalidPublicKeyError.toJSON
InvalidSecretKeyError
Defined in: src/crypto/X25519/errors.js:55 Error thrown when secret key is invalidSee
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
Extends
Constructors
Constructor
new InvalidSecretKeyError(Defined in: src/crypto/X25519/errors.js:60message,options?):InvalidSecretKeyError
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
Returns
InvalidSecretKeyError
Overrides
InvalidPrivateKeyError.constructor
Properties
cause?
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)optionalcause:Error
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?
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debuggingoptionalcontext:Record<string,unknown>
Example
Inherited from
InvalidPrivateKeyError.context
docsPath?
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this erroroptionaldocsPath:string
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():Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetryRecord<string,unknown>
Returns
Record<string, unknown>
Inherited from
InvalidPrivateKeyError.toJSON
X25519Error
Defined in: src/crypto/X25519/errors.js:23 Base error for X25519 operationsSee
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
Extends
Constructors
Constructor
new X25519Error(Defined in: src/crypto/X25519/errors.js:28message,options?):X25519Error
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
Returns
X25519Error
Overrides
CryptoError.constructor
Properties
cause?
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)optionalcause:Error
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?
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debuggingoptionalcontext:Record<string,unknown>
Example
Inherited from
CryptoError.context
docsPath?
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this erroroptionaldocsPath:string
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():Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetryRecord<string,unknown>
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 documentationSince
0.0.0Example
SecretKey
SecretKey = Uint8Array
Defined in: src/crypto/X25519/SecretKey.ts:12
X25519 secret key (32 bytes)
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Example
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 documentationSince
0.0.0Example
Variables
PUBLIC_KEY_SIZE
Defined in: src/crypto/X25519/constants.js:29 Public key size in bytesconstPUBLIC_KEY_SIZE:32=32
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
SECRET_KEY_SIZE
Defined in: src/crypto/X25519/constants.js:14 Secret key size in bytesconstSECRET_KEY_SIZE:32=32
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
SHARED_SECRET_SIZE
Defined in: src/crypto/X25519/constants.js:44 Shared secret size in bytesconstSHARED_SECRET_SIZE:32=32
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
X25519
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.constX25519:object
Type Declaration
derivePublicKey()
derivePublicKey: (Derive public key from secret keysecretKey) =>PublicKey
Parameters
secretKey
SecretKey
32-byte secret key
Returns
PublicKey
32-byte public key
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If secret key is invalidExample
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 documentationSince
0.0.0Throws
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 documentationSince
0.0.0Throws
Example
keypairFromSeed()
keypairFromSeed: (Generate X25519 keypair from seedseed) =>object
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 documentationSince
0.0.0Throws
If seed length is invalidExample
PUBLIC_KEY_SIZE
PUBLIC_KEY_SIZE: 32
Public key size in bytes
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
scalarmult()
scalarmult: (Perform X25519 scalar multiplication (ECDH) Computes shared secret from your secret key and their public key.secretKey,publicKey) =>SharedSecret
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 documentationSince
0.0.0Throws
If secret key is invalidThrows
If public key is invalidThrows
If scalar multiplication failsExample
SECRET_KEY_SIZE
SECRET_KEY_SIZE: 32
Secret key size in bytes
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
SHARED_SECRET_SIZE
SHARED_SECRET_SIZE: 32
Shared secret size in bytes
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
validatePublicKey()
validatePublicKey: (Validate a public key Checks if the public key has correct lengthpublicKey) =>boolean
Parameters
publicKey
PublicKey
Public key to validate
Returns
boolean
True if valid, false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
validateSecretKey()
validateSecretKey: (Validate a secret key Checks if the secret key has correct length and can derive a public keysecretKey) =>boolean
Parameters
secretKey
SecretKey
Secret key to validate
Returns
boolean
True if valid, false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
Functions
derivePublicKey()
derivePublicKey(Defined in: src/crypto/X25519/derivePublicKey.js:21 Derive public key from secret keysecretKey):PublicKey
Parameters
secretKey
SecretKey
32-byte secret key
Returns
PublicKey
32-byte public key
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If secret key is invalidExample
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 documentationSince
0.0.0Throws
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 documentationSince
0.0.0Throws
Example
keypairFromSeed()
keypairFromSeed(Defined in: src/crypto/X25519/keypairFromSeed.js:22 Generate X25519 keypair from seedseed):object
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 documentationSince
0.0.0Throws
If seed length is invalidExample
scalarmult()
scalarmult(Defined in: src/crypto/X25519/scalarmult.js:31 Perform X25519 scalar multiplication (ECDH) Computes shared secret from your secret key and their public key.secretKey,publicKey):SharedSecret
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 documentationSince
0.0.0Throws
If secret key is invalidThrows
If public key is invalidThrows
If scalar multiplication failsExample
validatePublicKey()
validatePublicKey(Defined in: src/crypto/X25519/validatePublicKey.js:20 Validate a public key Checks if the public key has correct lengthpublicKey):boolean
Parameters
publicKey
PublicKey
Public key to validate
Returns
boolean
True if valid, false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
validateSecretKey()
validateSecretKey(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 keysecretKey):boolean
Parameters
secretKey
SecretKey
Secret key to validate
Returns
boolean
True if valid, false otherwise

