@digitaldefiance/node-ecies-lib 4.16.27 → 4.17.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +72 -34
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -2,26 +2,12 @@
2
2
 
3
3
  [![npm version](https://badge.fury.io/js/%40digitaldefiance%2Fnode-ecies-lib.svg)](https://www.npmjs.com/package/@digitaldefiance/node-ecies-lib)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
- [![Tests](https://img.shields.io/badge/tests-1100%2B%20passing-brightgreen)](https://github.com/Digital-Defiance/ecies-lib)
5
+ [![Tests](https://img.shields.io/badge/tests-1953%20passing-brightgreen)](https://github.com/Digital-Defiance/ecies-lib)
6
6
 
7
7
  A Node.js-specific implementation of the Digital Defiance ECIES (Elliptic Curve Integrated Encryption Scheme) library, providing secure encryption, decryption, and key management capabilities using Node.js crypto primitives. This package is designed to be binary compatible with similarly numbered releases of the browser-based `@digitaldefiance/ecies-lib`, enabling seamless cross-platform cryptographic operations.
8
8
 
9
9
  Part of [Express Suite](https://github.com/Digital-Defiance/express-suite)
10
10
 
11
- > Current Version: v4.16.25
12
-
13
- ## What's New in v4.16.x
14
-
15
- ✨ **Voting Key Derivation Security Improvements** - Enhanced voting key derivation to use both X and Y coordinates of the shared secret for improved security and cross-platform consistency with the browser implementation.
16
-
17
- **Key Changes:**
18
- - **HKDF Salt Handling**: Per RFC 5869, when salt is not provided or empty, it now uses a string of HashLen zeros instead of an empty buffer, ensuring consistency with Web Crypto API implementation
19
- - **Private Key Normalization**: `deriveVotingKeysFromECDH` now handles 31-byte private keys (which can occur ~0.4% of the time when Node.js createECDH returns keys with leading zeros) by padding to 32 bytes
20
- - **Uncompressed Public Keys**: Voting key derivation now uses uncompressed format (65 bytes with 0x04 prefix) for maximum entropy in ECDH shared secret computation
21
- - **Simplified Prime Generation**: Removed constant-time padding in `generateDeterministicPrime` for cleaner implementation
22
- - **i18n Improvements**: Uses `I18nBuilder` pattern with `withStringKeyEnums()` for registering branded enums
23
- - **String Key Enum Registration**: Added `registerStringKeyEnum()` for direct translation via `translateStringKey()`
24
-
25
11
  This library implements a modern, enterprise-grade ECIES protocol (v4.0) featuring HKDF key derivation, AAD binding, and optimized multi-recipient encryption. It includes a pluggable ID provider system, memory-efficient streaming encryption, and comprehensive internationalization.
26
12
 
27
13
  ## Features
@@ -37,10 +23,12 @@ This library implements a modern, enterprise-grade ECIES protocol (v4.0) featuri
37
23
  - **Curve**: `secp256k1` for ECDH key exchange and ECDSA signatures.
38
24
  - **Symmetric**: `AES-256-GCM` for authenticated symmetric encryption.
39
25
  - **Hashing**: `SHA-256` and `SHA-512`.
26
+ - **Key Derivation**: `PBKDF2` with configurable profiles.
27
+ - **Checksums**: `CRC8`, `CRC16-CCITT`, `CRC32` for data integrity.
40
28
  - **Modes**:
41
- - **Basic**: Minimal overhead (no length prefix).
42
- - **WithLength**: Includes data length prefix.
43
- - **Multiple**: Efficient encryption for up to 65,535 recipients.
29
+ - **Basic**: Minimal overhead (no length prefix) - Use for fixed-size data
30
+ - **WithLength**: Includes data length prefix - Use for variable-size data or streaming
31
+ - **Multiple**: Efficient encryption for up to 65,535 recipients - Use for group messaging
44
32
 
45
33
  ### 🆔 Identity & Management
46
34
 
@@ -55,14 +43,28 @@ This library implements a modern, enterprise-grade ECIES protocol (v4.0) featuri
55
43
 
56
44
  ### 🚀 Advanced Capabilities
57
45
 
58
- - **Streaming Encryption**: Memory-efficient processing for large files (<10MB RAM usage for any file size).
46
+ - **Streaming Encryption**: Memory-efficient processing for large files (<10MB RAM usage for any file size) with Node.js Transform streams.
47
+ - **Fluent Builders**: Type-safe configuration with `ECIESBuilder` and `MemberBuilder` for clean, chainable APIs.
59
48
  - **Internationalization (i18n)**: Automatic error translation in 8 languages (en-US, en-GB, fr, es, de, zh-CN, ja, uk).
60
49
  - **Runtime Configuration**: Injectable configuration profiles via `ConstantsRegistry` for dependency injection and testing.
61
50
  - **Cross-Platform**: Fully compatible with similarly numbered releases of `@digitaldefiance/ecies-lib` (browser).
62
51
 
63
52
  ### 🗳️ Government-Grade Voting System
64
53
 
65
- A comprehensive voting system built on homomorphic encryption with 17 voting methods and 1100+ test cases:
54
+ A comprehensive voting system built on homomorphic encryption with 17 voting methods and 1100+ test cases.
55
+
56
+ **When to use:**
57
+ - Government elections requiring verifiable results and audit trails
58
+ - Corporate governance and shareholder voting with privacy guarantees
59
+ - Anonymous surveys with cryptographic receipt verification
60
+ - Multi-round elections (IRV, STAR, STV) with intermediate tallies
61
+ - Stakeholder voting with weighted votes and role separation
62
+ - Any voting scenario requiring homomorphic encryption and tamper-proof audit logs
63
+
64
+ **When NOT to use:**
65
+ - Simple polls where privacy is not a concern (use a basic database instead)
66
+ - Real-time result displays during voting (results are encrypted until poll closure)
67
+ - Systems where the computational overhead of homomorphic encryption is prohibitive
66
68
 
67
69
  - **All 17 Methods Fully Implemented**: Plurality, Approval, Weighted, Borda Count, Score, Yes/No, Yes/No/Abstain, Supermajority, Ranked Choice (IRV), Two-Round, STAR, STV, Quadratic, Consensus, Consent-Based
68
70
  - **Node.js Optimized**: Uses Buffer instead of Uint8Array for better Node.js performance
@@ -156,24 +158,31 @@ import {
156
158
  } from '@digitaldefiance/node-ecies-lib';
157
159
  import { ObjectIdProvider } from '@digitaldefiance/ecies-lib';
158
160
 
159
- // 1. Configure (Optional - defaults to ObjectIdProvider)
160
- registerNodeRuntimeConfiguration('my-app-config', {
161
- idProvider: new ObjectIdProvider()
162
- });
161
+ try {
162
+ // 1. Configure (Optional - defaults to ObjectIdProvider)
163
+ registerNodeRuntimeConfiguration('my-app-config', {
164
+ idProvider: new ObjectIdProvider()
165
+ });
163
166
 
164
- // 2. Initialize Service
165
- const ecies = new ECIESService();
167
+ // 2. Initialize Service
168
+ const ecies = new ECIESService();
166
169
 
167
- // 3. Generate Keys
168
- const mnemonic = ecies.generateNewMnemonic();
169
- const { privateKey, publicKey } = ecies.mnemonicToSimpleKeyPair(mnemonic);
170
+ // 3. Generate Keys
171
+ const mnemonic = ecies.generateNewMnemonic();
172
+ const { privateKey, publicKey } = ecies.mnemonicToSimpleKeyPair(mnemonic);
170
173
 
171
- // 4. Encrypt & Decrypt
172
- const message = Buffer.from('Hello, Secure World!');
173
- const encrypted = ecies.encryptWithLength(publicKey, message);
174
- const decrypted = ecies.decryptWithLengthAndHeader(privateKey, encrypted);
174
+ // 4. Encrypt & Decrypt
175
+ const message = Buffer.from('Hello, Secure World!');
176
+ const encrypted = ecies.encryptWithLength(publicKey, message);
177
+ const decrypted = ecies.decryptWithLengthAndHeader(privateKey, encrypted);
175
178
 
176
- console.log(decrypted.toString()); // "Hello, Secure World!"
179
+ console.log(decrypted.toString()); // "Hello, Secure World!"
180
+ } catch (error) {
181
+ console.error('Encryption error:', error.message);
182
+ if (error.code === 'INVALID_KEY') {
183
+ console.error('Invalid key provided');
184
+ }
185
+ }
177
186
  ```
178
187
 
179
188
  ### 2. Strong Typing with ID Providers (New in v4.10.7)
@@ -478,6 +487,35 @@ const encrypted = member.encryptData('My Secrets');
478
487
  - **`EciesMultiRecipient`**: Specialized service for handling multi-recipient messages.
479
488
  - **`EncryptionStream`**: Helper for chunked file encryption.
480
489
  - **`Pbkdf2Service`**: Secure authentication using PBKDF2 and encrypted key bundles.
490
+ - **`AESGCMService`**: Instance-based AES-256-GCM encryption with JSON support.
491
+ - **Methods**: `encrypt()`, `decrypt()`, `encryptJson()`, `decryptJson()`, `combineEncryptedDataAndTag()`
492
+ - Supports authenticated encryption with optional AAD
493
+ - **`CrcService`**: CRC checksum computation and verification.
494
+ - **Algorithms**: CRC8, CRC16-CCITT, CRC32
495
+ - **Methods**: `crc8()`, `crc16()`, `crc32()`, `verifyCrc8()`, `verifyCrc16()`, `verifyCrc32()`
496
+ - Supports async stream processing
497
+ - **`ChunkProcessor`**: Processes data in chunks for streaming encryption.
498
+ - **`MultiRecipientProcessor`**: Handles multi-recipient encryption operations.
499
+ - **`ProgressTracker`**: Tracks progress for long-running encryption operations.
500
+
501
+ ### Builders
502
+
503
+ - **`ECIESBuilder`**: Fluent builder for ECIESService configuration
504
+ - **Methods**: `create()`, `withServiceConfig()`, `withConstants()`, `withI18n()`, `build()`
505
+ - Simplifies service initialization with method chaining
506
+ - **`MemberBuilder`**: Fluent builder for creating Member instances
507
+ - **Methods**: `withId()`, `withName()`, `withEmail()`, `withPhone()`, `withType()`, `withKeys()`, `build()`
508
+ - Provides type-safe member construction with validation
509
+
510
+ ### Stream Transforms
511
+
512
+ - **`EciesEncryptTransform`**: Node.js Transform stream for ECIES encryption
513
+ - **`EciesDecryptTransform`**: Node.js Transform stream for ECIES decryption
514
+ - **`ChecksumTransform`**: Transform stream for CRC checksum computation
515
+ - **`XorTransform`**: Transform stream for XOR cipher operations
516
+ - **`XorMultipleTransform`**: Transform stream for multiple XOR operations
517
+
518
+ All transforms extend Node.js `Transform` class for use with Node.js streams.
481
519
 
482
520
  ### Configuration & Registry
483
521
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitaldefiance/node-ecies-lib",
3
- "version": "4.16.27",
3
+ "version": "4.17.2",
4
4
  "description": "Digital Defiance Node ECIES Library",
5
5
  "homepage": "https://github.com/Digital-Defiance/node-ecies-lib",
6
6
  "repository": {
@@ -59,9 +59,9 @@
59
59
  "license": "MIT",
60
60
  "packageManager": "yarn@4.10.3",
61
61
  "dependencies": {
62
- "@digitaldefiance/ecies-lib": "4.16.26",
62
+ "@digitaldefiance/ecies-lib": "4.17.2",
63
63
  "@digitaldefiance/express-suite-test-utils": "1.1.0",
64
- "@digitaldefiance/i18n-lib": "4.3.0",
64
+ "@digitaldefiance/i18n-lib": "4.3.2",
65
65
  "@ethereumjs/wallet": "^2.0.4",
66
66
  "@noble/curves": "^1.4.2",
67
67
  "@noble/hashes": "^1.4.0",