The Config class allows you to customize the elliptic curve, symmetric encryption algorithm, and key compression settings used during ECIES operations. You can either use the default exported ECIES_CONFIG instance or instantiate a new Config object for custom requirements.
Supported Elliptic Curves
secp256k1 (Default)x25519ed25519
Supported Symmetric Algorithms
aes-256-gcm (Default)xchacha20
Configuration Options
| Option | Type | Default | Notes |
|---|
ellipticCurve | EllipticCurve | "secp256k1" | Selects the curve for key exchange. |
isEphemeralKeyCompressed | boolean | false | Only applicable to secp256k1. |
isHkdfKeyCompressed | boolean | false | Only applicable to secp256k1. |
symmetricAlgorithm | SymmetricAlgorithm | "aes-256-gcm" | Selects the symmetric cipher. |
symmetricNonceLength | NonceLength | 16 | Only applicable to aes-256-gcm. Supports 12 or 16. |
Ephemeral Key Size
The ephemeralKeySize getter returns the expected byte size of the ephemeral public key based on the selected ellipticCurve and compression settings.
import { Config, ECIES_CONFIG } from 'eciesjs';
// Use default settings
const defaultConfig = ECIES_CONFIG;
// Create custom settings
const customConfig = new Config();
customConfig.ellipticCurve = 'x25519';
customConfig.symmetricAlgorithm = 'xchacha20';
console.log(customConfig.ephemeralKeySize);