@tevm/voltaire / crypto/ChaCha20Poly1305
crypto/ChaCha20Poly1305
Classes
ChaCha20Poly1305Error
Defined in: src/crypto/ChaCha20Poly1305/errors.js:21 Base error for ChaCha20-Poly1305 operationsSee
https://voltaire.tevm.sh/crypto/chacha20poly1305 for crypto documentationSince
0.0.0Throws
Example
Extends
Extended by
Constructors
Constructor
new ChaCha20Poly1305Error(Defined in: src/crypto/ChaCha20Poly1305/errors.js:26message,options?):ChaCha20Poly1305Error
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
Returns
ChaCha20Poly1305Error
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/ChaCha20Poly1305/errors.js:33
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
DecryptionError
Defined in: src/crypto/ChaCha20Poly1305/errors.js:118 Decryption failure errorSee
https://voltaire.tevm.sh/crypto/chacha20poly1305 for crypto documentationSince
0.0.0Throws
Example
Extends
Constructors
Constructor
new DecryptionError(Defined in: src/crypto/ChaCha20Poly1305/errors.js:123message,options?):DecryptionError
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
Returns
DecryptionError
Overrides
ChaCha20Poly1305Error.constructor
Properties
cause?
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)optionalcause:Error
Inherited from
ChaCha20Poly1305Error.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39
Machine-readable error code for programmatic handling
Example
Inherited from
ChaCha20Poly1305Error.code
context?
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debuggingoptionalcontext:Record<string,unknown>
Example
Inherited from
ChaCha20Poly1305Error.context
docsPath?
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this erroroptionaldocsPath:string
Example
Inherited from
ChaCha20Poly1305Error.docsPath
name
name: string
Defined in: src/crypto/ChaCha20Poly1305/errors.js:130
Inherited from
ChaCha20Poly1305Error.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
ChaCha20Poly1305Error.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
ChaCha20Poly1305Error.toJSON
InvalidKeyError
Defined in: src/crypto/ChaCha20Poly1305/errors.js:53 Invalid key errorSee
https://voltaire.tevm.sh/crypto/chacha20poly1305 for crypto documentationSince
0.0.0Throws
Example
Extends
Constructors
Constructor
new InvalidKeyError(Defined in: src/crypto/ChaCha20Poly1305/errors.js:58message,options?):InvalidKeyError
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
Returns
InvalidKeyError
Overrides
ChaCha20Poly1305Error.constructor
Properties
cause?
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)optionalcause:Error
Inherited from
ChaCha20Poly1305Error.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39
Machine-readable error code for programmatic handling
Example
Inherited from
ChaCha20Poly1305Error.code
context?
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debuggingoptionalcontext:Record<string,unknown>
Example
Inherited from
ChaCha20Poly1305Error.context
docsPath?
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this erroroptionaldocsPath:string
Example
Inherited from
ChaCha20Poly1305Error.docsPath
name
name: string
Defined in: src/crypto/ChaCha20Poly1305/errors.js:65
Inherited from
ChaCha20Poly1305Error.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
ChaCha20Poly1305Error.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
ChaCha20Poly1305Error.toJSON
InvalidNonceError
Defined in: src/crypto/ChaCha20Poly1305/errors.js:85 Invalid nonce errorSee
https://voltaire.tevm.sh/crypto/chacha20poly1305 for crypto documentationSince
0.0.0Throws
Example
Extends
Constructors
Constructor
new InvalidNonceError(Defined in: src/crypto/ChaCha20Poly1305/errors.js:90message,options?):InvalidNonceError
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
Returns
InvalidNonceError
Overrides
ChaCha20Poly1305Error.constructor
Properties
cause?
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)optionalcause:Error
Inherited from
ChaCha20Poly1305Error.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39
Machine-readable error code for programmatic handling
Example
Inherited from
ChaCha20Poly1305Error.code
context?
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debuggingoptionalcontext:Record<string,unknown>
Example
Inherited from
ChaCha20Poly1305Error.context
docsPath?
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this erroroptionaldocsPath:string
Example
Inherited from
ChaCha20Poly1305Error.docsPath
name
name: string
Defined in: src/crypto/ChaCha20Poly1305/errors.js:97
Inherited from
ChaCha20Poly1305Error.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
ChaCha20Poly1305Error.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
ChaCha20Poly1305Error.toJSON
Variables
ChaCha20Poly1305
Defined in: src/crypto/ChaCha20Poly1305/ChaCha20Poly1305.js:39 ChaCha20-Poly1305 Authenticated Encryption (RFC 8439) Provides authenticated encryption using ChaCha20 stream cipher with Poly1305 MAC. Optimized for software implementations. Uses @noble/ciphers for cryptographic operations.constChaCha20Poly1305:object
Type Declaration
decrypt()
decrypt: (Decrypt data with ChaCha20-Poly1305ciphertext,key,nonce,additionalData?) =>Uint8Array<ArrayBufferLike>
Parameters
ciphertext
Uint8Array<ArrayBufferLike>
Encrypted data with authentication tag
key
Uint8Array<ArrayBufferLike>
32-byte key (256 bits)
nonce
Uint8Array<ArrayBufferLike>
12-byte nonce (96 bits) used during encryption
additionalData?
Uint8Array<ArrayBufferLike>
Optional additional authenticated data
Returns
Uint8Array<ArrayBufferLike>
Decrypted plaintext
See
https://voltaire.tevm.sh/crypto/chacha20poly1305 for crypto documentationSince
0.0.0Throws
If key is not 32 bytesThrows
If nonce is not 12 bytesThrows
If authentication fails or decryption errorExample
encrypt()
encrypt: (Encrypt data with ChaCha20-Poly1305plaintext,key,nonce,additionalData?) =>Uint8Array<ArrayBufferLike>
Parameters
plaintext
Uint8Array<ArrayBufferLike>
Data to encrypt
key
Uint8Array<ArrayBufferLike>
32-byte key (256 bits)
nonce
Uint8Array<ArrayBufferLike>
12-byte nonce (96 bits)
additionalData?
Uint8Array<ArrayBufferLike>
Optional additional authenticated data
Returns
Uint8Array<ArrayBufferLike>
Ciphertext with authentication tag appended (16 bytes)
See
https://voltaire.tevm.sh/crypto/chacha20poly1305 for crypto documentationSince
0.0.0Throws
If key is not 32 bytesThrows
If nonce is not 12 bytesThrows
If encryption failsExample
generateKey()
generateKey: () =>Generate random ChaCha20-Poly1305 keyUint8Array<ArrayBufferLike>
Returns
Uint8Array<ArrayBufferLike>
32-byte random key (256 bits)
See
https://voltaire.tevm.sh/crypto/chacha20poly1305 for crypto documentationSince
0.0.0Throws
Example
generateNonce()
generateNonce: () =>Generate random nonceUint8Array<ArrayBufferLike>
Returns
Uint8Array<ArrayBufferLike>
12-byte random nonce (96 bits)
See
https://voltaire.tevm.sh/crypto/chacha20poly1305 for crypto documentationSince
0.0.0Throws
Example
KEY_SIZE
KEY_SIZE: number
ChaCha20-Poly1305 key size in bytes (256 bits)
See
https://voltaire.tevm.sh/crypto/chacha20poly1305 for crypto documentationSince
0.0.0Throws
Example
NONCE_SIZE
NONCE_SIZE: number
Nonce/IV size in bytes (96 bits)
See
https://voltaire.tevm.sh/crypto/chacha20poly1305 for crypto documentationSince
0.0.0Throws
Example
TAG_SIZE
TAG_SIZE: number
Authentication tag size in bytes (128 bits)
See
https://voltaire.tevm.sh/crypto/chacha20poly1305 for crypto documentationSince
0.0.0Throws
Example
Example
KEY_SIZE
Defined in: src/crypto/ChaCha20Poly1305/constants.js:13 ChaCha20-Poly1305 key size in bytes (256 bits)constKEY_SIZE:32=32
See
https://voltaire.tevm.sh/crypto/chacha20poly1305 for crypto documentationSince
0.0.0Throws
Example
NONCE_SIZE
Defined in: src/crypto/ChaCha20Poly1305/constants.js:27 Nonce/IV size in bytes (96 bits)constNONCE_SIZE:12=12
See
https://voltaire.tevm.sh/crypto/chacha20poly1305 for crypto documentationSince
0.0.0Throws
Example
TAG_SIZE
Defined in: src/crypto/ChaCha20Poly1305/constants.js:41 Authentication tag size in bytes (128 bits)constTAG_SIZE:16=16
See
https://voltaire.tevm.sh/crypto/chacha20poly1305 for crypto documentationSince
0.0.0Throws
Example
Functions
decrypt()
decrypt(Defined in: src/crypto/ChaCha20Poly1305/decrypt.js:31 Decrypt data with ChaCha20-Poly1305ciphertext,key,nonce,additionalData?):Uint8Array<ArrayBufferLike>
Parameters
ciphertext
Uint8Array<ArrayBufferLike>
Encrypted data with authentication tag
key
Uint8Array<ArrayBufferLike>
32-byte key (256 bits)
nonce
Uint8Array<ArrayBufferLike>
12-byte nonce (96 bits) used during encryption
additionalData?
Uint8Array<ArrayBufferLike>
Optional additional authenticated data
Returns
Uint8Array<ArrayBufferLike>
Decrypted plaintext
See
https://voltaire.tevm.sh/crypto/chacha20poly1305 for crypto documentationSince
0.0.0Throws
If key is not 32 bytesThrows
If nonce is not 12 bytesThrows
If authentication fails or decryption errorExample
encrypt()
encrypt(Defined in: src/crypto/ChaCha20Poly1305/encrypt.js:31 Encrypt data with ChaCha20-Poly1305plaintext,key,nonce,additionalData?):Uint8Array<ArrayBufferLike>
Parameters
plaintext
Uint8Array<ArrayBufferLike>
Data to encrypt
key
Uint8Array<ArrayBufferLike>
32-byte key (256 bits)
nonce
Uint8Array<ArrayBufferLike>
12-byte nonce (96 bits)
additionalData?
Uint8Array<ArrayBufferLike>
Optional additional authenticated data
Returns
Uint8Array<ArrayBufferLike>
Ciphertext with authentication tag appended (16 bytes)
See
https://voltaire.tevm.sh/crypto/chacha20poly1305 for crypto documentationSince
0.0.0Throws
If key is not 32 bytesThrows
If nonce is not 12 bytesThrows
If encryption failsExample
generateKey()
generateKey():Defined in: src/crypto/ChaCha20Poly1305/generateKey.js:17 Generate random ChaCha20-Poly1305 keyUint8Array<ArrayBufferLike>
Returns
Uint8Array<ArrayBufferLike>
32-byte random key (256 bits)
See
https://voltaire.tevm.sh/crypto/chacha20poly1305 for crypto documentationSince
0.0.0Throws
Example
generateNonce()
generateNonce():Defined in: src/crypto/ChaCha20Poly1305/generateNonce.js:17 Generate random nonceUint8Array<ArrayBufferLike>
Returns
Uint8Array<ArrayBufferLike>
12-byte random nonce (96 bits)

