@tevm/voltaire / crypto/AesGcm
crypto/AesGcm
Classes
AesGcmError
Defined in: src/crypto/AesGcm/errors.js:21 Base error for AES-GCM operationsSee
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
Extends
Extended by
Constructors
Constructor
new AesGcmError(Defined in: src/crypto/AesGcm/errors.js:26message,options?):AesGcmError
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
Returns
AesGcmError
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/AesGcm/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/AesGcm/errors.js:118 Decryption failure errorSee
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
Extends
Constructors
Constructor
new DecryptionError(Defined in: src/crypto/AesGcm/errors.js:123message,options?):DecryptionError
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
Returns
DecryptionError
Overrides
AesGcmError.constructor
Properties
cause?
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)optionalcause:Error
Inherited from
AesGcmError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39
Machine-readable error code for programmatic handling
Example
Inherited from
AesGcmError.code
context?
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debuggingoptionalcontext:Record<string,unknown>
Example
Inherited from
AesGcmError.context
docsPath?
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this erroroptionaldocsPath:string
Example
Inherited from
AesGcmError.docsPath
name
name: string
Defined in: src/crypto/AesGcm/errors.js:130
Inherited from
AesGcmError.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
AesGcmError.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
AesGcmError.toJSON
InvalidKeyError
Defined in: src/crypto/AesGcm/errors.js:53 Invalid key errorSee
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
Extends
Constructors
Constructor
new InvalidKeyError(Defined in: src/crypto/AesGcm/errors.js:58message,options?):InvalidKeyError
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
Returns
InvalidKeyError
Overrides
AesGcmError.constructor
Properties
cause?
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)optionalcause:Error
Inherited from
AesGcmError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39
Machine-readable error code for programmatic handling
Example
Inherited from
AesGcmError.code
context?
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debuggingoptionalcontext:Record<string,unknown>
Example
Inherited from
AesGcmError.context
docsPath?
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this erroroptionaldocsPath:string
Example
Inherited from
AesGcmError.docsPath
name
name: string
Defined in: src/crypto/AesGcm/errors.js:65
Inherited from
AesGcmError.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
AesGcmError.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
AesGcmError.toJSON
InvalidNonceError
Defined in: src/crypto/AesGcm/errors.js:85 Invalid nonce errorSee
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
Extends
Constructors
Constructor
new InvalidNonceError(Defined in: src/crypto/AesGcm/errors.js:90message,options?):InvalidNonceError
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
Returns
InvalidNonceError
Overrides
AesGcmError.constructor
Properties
cause?
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)optionalcause:Error
Inherited from
AesGcmError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39
Machine-readable error code for programmatic handling
Example
Inherited from
AesGcmError.code
context?
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debuggingoptionalcontext:Record<string,unknown>
Example
Inherited from
AesGcmError.context
docsPath?
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this erroroptionaldocsPath:string
Example
Inherited from
AesGcmError.docsPath
name
name: string
Defined in: src/crypto/AesGcm/errors.js:97
Inherited from
AesGcmError.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
AesGcmError.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
AesGcmError.toJSON
Type Aliases
Key
Key = CryptoKey
Defined in: src/crypto/AesGcm/KeyTypes.ts:13
AES-GCM CryptoKey type
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
KeyMaterial
KeyMaterial = Uint8Array
Defined in: src/crypto/AesGcm/KeyTypes.ts:27
Raw key material (bytes)
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
Variables
AES128_KEY_SIZE
Defined in: src/crypto/AesGcm/constants.js:13 AES-128 key size in bytesconstAES128_KEY_SIZE:16=16
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
AES256_KEY_SIZE
Defined in: src/crypto/AesGcm/constants.js:27 AES-256 key size in bytesconstAES256_KEY_SIZE:32=32
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
AesGcm
Defined in: src/crypto/AesGcm/AesGcm.js:54 AES-GCM (Galois/Counter Mode) Authenticated Encryption Provides authenticated encryption using AES in GCM mode. Uses native WebCrypto API for optimal performance and security. Supports both AES-128-GCM and AES-256-GCM.constAesGcm:object
Type Declaration
AES128_KEY_SIZE
AES128_KEY_SIZE: number
AES-128 key size in bytes
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
AES256_KEY_SIZE
AES256_KEY_SIZE: number
AES-256 key size in bytes
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
decrypt()
decrypt: (Decrypt data with AES-GCMciphertext,key,nonce,additionalData?) =>Promise<Uint8Array<ArrayBufferLike>>
Parameters
ciphertext
Uint8Array<ArrayBufferLike>
Encrypted data with authentication tag
key
CryptoKey
AES key (128 or 256 bit)
nonce
Uint8Array<ArrayBufferLike>
12-byte nonce (IV) used during encryption
additionalData?
Uint8Array<ArrayBufferLike>
Optional additional authenticated data
Returns
Promise<Uint8Array<ArrayBufferLike>>
Decrypted plaintext
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If authentication fails or decryption errorExample
deriveKey()
deriveKey: (Derive key from password using PBKDF2password,salt,iterations,bits) =>Promise<CryptoKey>
Parameters
password
Password string or bytesstring | Uint8Array<ArrayBufferLike>
salt
Uint8Array<ArrayBufferLike>
Salt for key derivation (at least 16 bytes recommended)
iterations
number
Number of iterations (at least 100000 recommended)
bits
Key size in bits (128 or 256)128 | 256
Returns
Promise<CryptoKey>
Derived CryptoKey
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If key derivation failsExample
encrypt()
encrypt: (Encrypt data with AES-GCMplaintext,key,nonce,additionalData?) =>Promise<Uint8Array<ArrayBufferLike>>
Parameters
plaintext
Uint8Array<ArrayBufferLike>
Data to encrypt
key
CryptoKey
AES key (128 or 256 bit)
nonce
Uint8Array<ArrayBufferLike>
12-byte nonce (IV)
additionalData?
Uint8Array<ArrayBufferLike>
Optional additional authenticated data
Returns
Promise<Uint8Array<ArrayBufferLike>>
Ciphertext with authentication tag appended
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If encryption failsExample
exportKey()
exportKey: (Export CryptoKey to raw byteskey) =>Promise<Uint8Array<ArrayBufferLike>>
Parameters
key
CryptoKey
CryptoKey to export
Returns
Promise<Uint8Array<ArrayBufferLike>>
Raw key bytes
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If key export failsExample
generateKey()
generateKey: (Generate AES-GCM keybits) =>Promise<CryptoKey>
Parameters
bits
Key size in bits (128 or 256)128 | 256
Returns
Promise<CryptoKey>
CryptoKey for use with WebCrypto API
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If key generation failsExample
generateNonce()
generateNonce: () =>Generate random nonceUint8Array<ArrayBufferLike>
Returns
Uint8Array<ArrayBufferLike>
12-byte random nonce
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
importKey()
importKey: (Import raw key material as CryptoKeykeyMaterial) =>Promise<CryptoKey>
Parameters
keyMaterial
Uint8Array<ArrayBufferLike>
16-byte (128-bit) or 32-byte (256-bit) key
Returns
Promise<CryptoKey>
CryptoKey for use with WebCrypto API
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If key import fails or key size is invalidExample
NONCE_SIZE
NONCE_SIZE: number
Nonce/IV size in bytes (standard for GCM)
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
TAG_SIZE
TAG_SIZE: number
Authentication tag size in bytes
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
Example
NONCE_SIZE
Defined in: src/crypto/AesGcm/constants.js:41 Nonce/IV size in bytes (standard for GCM)constNONCE_SIZE:12=12
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
TAG_SIZE
Defined in: src/crypto/AesGcm/constants.js:55 Authentication tag size in bytesconstTAG_SIZE:16=16
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
Functions
decrypt()
decrypt(Defined in: src/crypto/AesGcm/decrypt.js:24 Decrypt data with AES-GCMciphertext,key,nonce,additionalData?):Promise<Uint8Array<ArrayBufferLike>>
Parameters
ciphertext
Uint8Array<ArrayBufferLike>
Encrypted data with authentication tag
key
CryptoKey
AES key (128 or 256 bit)
nonce
Uint8Array<ArrayBufferLike>
12-byte nonce (IV) used during encryption
additionalData?
Uint8Array<ArrayBufferLike>
Optional additional authenticated data
Returns
Promise<Uint8Array<ArrayBufferLike>>
Decrypted plaintext
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If authentication fails or decryption errorExample
deriveKey()
deriveKey(Defined in: src/crypto/AesGcm/deriveKey.js:21 Derive key from password using PBKDF2password,salt,iterations,bits):Promise<CryptoKey>
Parameters
password
Password string or bytesstring | Uint8Array<ArrayBufferLike>
salt
Uint8Array<ArrayBufferLike>
Salt for key derivation (at least 16 bytes recommended)
iterations
number
Number of iterations (at least 100000 recommended)
bits
Key size in bits (128 or 256)128 | 256
Returns
Promise<CryptoKey>
Derived CryptoKey
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If key derivation failsExample
encrypt()
encrypt(Defined in: src/crypto/AesGcm/encrypt.js:24 Encrypt data with AES-GCMplaintext,key,nonce,additionalData?):Promise<Uint8Array<ArrayBufferLike>>
Parameters
plaintext
Uint8Array<ArrayBufferLike>
Data to encrypt
key
CryptoKey
AES key (128 or 256 bit)
nonce
Uint8Array<ArrayBufferLike>
12-byte nonce (IV)
additionalData?
Uint8Array<ArrayBufferLike>
Optional additional authenticated data
Returns
Promise<Uint8Array<ArrayBufferLike>>
Ciphertext with authentication tag appended
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If encryption failsExample
exportKey()
exportKey(Defined in: src/crypto/AesGcm/exportKey.js:18 Export CryptoKey to raw byteskey):Promise<Uint8Array<ArrayBufferLike>>
Parameters
key
CryptoKey
CryptoKey to export
Returns
Promise<Uint8Array<ArrayBufferLike>>
Raw key bytes
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If key export failsExample
generateKey()
generateKey(Defined in: src/crypto/AesGcm/generateKey.js:18 Generate AES-GCM keybits):Promise<CryptoKey>
Parameters
bits
Key size in bits (128 or 256)128 | 256
Returns
Promise<CryptoKey>
CryptoKey for use with WebCrypto API
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
If key generation failsExample
generateNonce()
generateNonce():Defined in: src/crypto/AesGcm/generateNonce.js:16 Generate random nonceUint8Array<ArrayBufferLike>
Returns
Uint8Array<ArrayBufferLike>
12-byte random nonce
See
https://voltaire.tevm.sh/crypto for crypto documentationSince
0.0.0Throws
Example
importKey()
importKey(Defined in: src/crypto/AesGcm/importKey.js:19 Import raw key material as CryptoKeykeyMaterial):Promise<CryptoKey>
Parameters
keyMaterial
Uint8Array<ArrayBufferLike>
16-byte (128-bit) or 32-byte (256-bit) key
Returns
Promise<CryptoKey>
CryptoKey for use with WebCrypto API

