Changelog - 2026-02-11
Crypto Algorithm Refactor & ECDH Key Exchange
In one line. All crypto algorithms now share one options-object API, and ECDH is a full member of the crypto type hierarchy.
What changed
- Options-object API.
encrypt()anddecrypt()on AES and RSA take{ message, secret, opts? }instead of positional arguments.encryptFile()anddecryptFile()take{ absolutePath, secret }. ECDHextendsAbstractCryptoAlgorithm. It gets scoped logging, analgorithmfield ('ecdh-p256') and is exported from@venizia/ignis-helpersnext to AES and RSA. It uses the Web Crypto API, so it works in Bun and browsers.- Seven generic parameters.
ICryptoAlgorithmsplitsMessageTypeintoEncryptInputTypeandDecryptInputType, because ECDH encrypts strings but decryptsIECDHEncryptedPayloadobjects. - New ECDH default. The HKDF info default is now
'ignis-ecdh-aes-gcm'.
Who is affected
- Code that calls AES or RSA
encrypt()/decrypt(). Update every call (see Migration). - Code that extends
BaseCryptoAlgorithmor implementsICryptoAlgorithm. Add the extra generic parameter. - Code that uses
ECDH. It now uses the options-object API and the HKDF info default changed (above); check your calls.
Breaking changes
WARNING
Every AES and RSA encrypt() / decrypt() call, and every custom crypto subclass, must be updated.
Before:
typescript
aes.encrypt(message, secret);
aes.decrypt(encrypted, secret);
aes.encrypt(message, secret, { iv, inputEncoding, outputEncoding });
rsa.encrypt(message, publicKey);
rsa.decrypt(encrypted, privateKey);
// 6 params
ICryptoAlgorithm<AlgorithmNameType, MessageType, SecretKeyType, EncryptReturnType, DecryptReturnType, ExtraOptions>After:
typescript
aes.encrypt({ message, secret });
aes.decrypt({ message: encrypted, secret });
aes.encrypt({ message, secret, opts: { iv, inputEncoding, outputEncoding } });
rsa.encrypt({ message, secret: publicKey });
rsa.decrypt({ message: encrypted, secret: privateKey });
// 7 params
ICryptoAlgorithm<AlgorithmNameType, EncryptInputType, DecryptInputType, SecretKeyType, EncryptReturnType, DecryptReturnType, ExtraOptions>Migration
- Convert every AES and RSA
encrypt/decryptcall from positional arguments to the options object (above). - Move any third-argument options into the
optsproperty. - If you extended
BaseCryptoAlgorithm, add the extra generic parameter:
typescript
// Before (6 params)
class MyAlgo extends BaseCryptoAlgorithm<MyType, string, string, string, string, IMyOptions> {}
// After (7 params)
class MyAlgo extends BaseCryptoAlgorithm<MyType, string, string, string, string, string, IMyOptions> {}Details
typescript
const ecdh = ECDH.withAlgorithm();
const alice = await ecdh.generateKeyPair();
const bob = await ecdh.generateKeyPair();
const bobPub = await ecdh.importPublicKey({ rawKeyB64: bob.publicKeyB64 });
const aliceKey = await ecdh.deriveAESKey({
privateKey: alice.keyPair.privateKey,
peerPublicKey: bobPub,
});
const encrypted = await ecdh.encrypt({ message: 'Hello!', secret: aliceKey });