@digitaldefiance/node-ecies-lib 4.16.30 → 4.17.4

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.
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.30",
3
+ "version": "4.17.4",
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.30",
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",
@@ -2,28 +2,34 @@
2
2
  * Node.js ECIES i18n setup and configuration.
3
3
  *
4
4
  * This is the single source of truth for i18n in node-ecies-lib.
5
- * Uses I18nBuilder pattern for proper engine initialization and registers:
6
- * - Core component (for error messages)
7
- * - ECIES component (imported from ecies-lib - translations defined there)
5
+ * Uses createI18nSetup factory for proper engine initialization and registers:
6
+ * - Core component (automatic via factory)
7
+ * - ECIES component (imported from ecies-lib via createEciesComponentPackage)
8
8
  * - Node ECIES component (translations defined here)
9
9
  *
10
10
  * All components support translateStringKey for direct branded enum translation.
11
11
  */
12
12
  import { EciesComponentId } from '@digitaldefiance/ecies-lib';
13
- import { ComponentConfig, I18nEngine, type BrandedMasterStringsCollection, type CoreLanguageCode } from '@digitaldefiance/i18n-lib';
13
+ import { ComponentConfig, I18nEngine, type BrandedMasterStringsCollection, type CoreLanguageCode, type I18nComponentPackage } from '@digitaldefiance/i18n-lib';
14
14
  import { NodeEciesComponentId, NodeEciesStringKey } from './node-keys';
15
15
  import type { NodeEciesStringKeyValue } from './node-keys';
16
16
  export { NodeEciesComponentId, EciesComponentId };
17
17
  /**
18
18
  * Master strings collection for the Node ECIES component.
19
19
  * These are the translations specific to node-ecies-lib.
20
- * ECIES translations come from ecies-lib via createEciesComponentConfig().
20
+ * ECIES translations come from ecies-lib via createEciesComponentPackage().
21
21
  */
22
22
  export declare const NodeEciesComponentStrings: BrandedMasterStringsCollection<typeof NodeEciesStringKey, CoreLanguageCode>;
23
23
  /**
24
24
  * Create Node ECIES component configuration
25
25
  */
26
26
  export declare function createNodeEciesComponentConfig(): ComponentConfig;
27
+ /**
28
+ * Creates an I18nComponentPackage bundling the Node ECIES ComponentConfig
29
+ * with its branded string key enum. Use this with createI18nSetup's
30
+ * libraryComponents array.
31
+ */
32
+ export declare function createNodeEciesComponentPackage(): I18nComponentPackage;
27
33
  /**
28
34
  * Get or create the Node ECIES i18n engine.
29
35
  *
@@ -1 +1 @@
1
- {"version":3,"file":"node-ecies-i18n-setup.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-ecies-lib/src/i18n/node-ecies-i18n-setup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAEL,gBAAgB,EAEjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,eAAe,EAIf,UAAU,EAEV,KAAK,8BAA8B,EACnC,KAAK,gBAAgB,EACtB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAY3D,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,CAAC;AAElD;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,EAAE,8BAA8B,CACpE,OAAO,kBAAkB,EACzB,gBAAgB,CAUjB,CAAC;AAEF;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,eAAe,CAMhE;AAoDD;;;;;GAKG;AACH,wBAAgB,sBAAsB,IAAI,UAAU,CAkCnD;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAG/C;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,uBAAuB,EAClC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EAC3C,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,CAMR;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,uBAAuB,EAClC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EAC3C,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,CAMR"}
1
+ {"version":3,"file":"node-ecies-i18n-setup.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-ecies-lib/src/i18n/node-ecies-i18n-setup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAEL,gBAAgB,EACjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,eAAe,EAEf,UAAU,EAEV,KAAK,8BAA8B,EACnC,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EAC1B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAY3D,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,CAAC;AAElD;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,EAAE,8BAA8B,CACpE,OAAO,kBAAkB,EACzB,gBAAgB,CAUjB,CAAC;AAEF;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,eAAe,CAMhE;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,IAAI,oBAAoB,CAKtE;AAID;;;;;GAKG;AACH,wBAAgB,sBAAsB,IAAI,UAAU,CAenD;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAE/C;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,uBAAuB,EAClC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EAC3C,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,CAMR;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,uBAAuB,EAClC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EAC3C,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,CAMR"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NodeEciesComponentStrings = exports.EciesComponentId = exports.NodeEciesComponentId = void 0;
4
4
  exports.createNodeEciesComponentConfig = createNodeEciesComponentConfig;
5
+ exports.createNodeEciesComponentPackage = createNodeEciesComponentPackage;
5
6
  exports.getNodeEciesI18nEngine = getNodeEciesI18nEngine;
6
7
  exports.resetNodeEciesI18nEngine = resetNodeEciesI18nEngine;
7
8
  exports.getNodeEciesTranslation = getNodeEciesTranslation;
@@ -10,9 +11,9 @@ exports.safeGetNodeEciesTranslation = safeGetNodeEciesTranslation;
10
11
  * Node.js ECIES i18n setup and configuration.
11
12
  *
12
13
  * This is the single source of truth for i18n in node-ecies-lib.
13
- * Uses I18nBuilder pattern for proper engine initialization and registers:
14
- * - Core component (for error messages)
15
- * - ECIES component (imported from ecies-lib - translations defined there)
14
+ * Uses createI18nSetup factory for proper engine initialization and registers:
15
+ * - Core component (automatic via factory)
16
+ * - ECIES component (imported from ecies-lib via createEciesComponentPackage)
16
17
  * - Node ECIES component (translations defined here)
17
18
  *
18
19
  * All components support translateStringKey for direct branded enum translation.
@@ -26,7 +27,7 @@ const translations_1 = require("./translations");
26
27
  /**
27
28
  * Master strings collection for the Node ECIES component.
28
29
  * These are the translations specific to node-ecies-lib.
29
- * ECIES translations come from ecies-lib via createEciesComponentConfig().
30
+ * ECIES translations come from ecies-lib via createEciesComponentPackage().
30
31
  */
31
32
  exports.NodeEciesComponentStrings = {
32
33
  [i18n_lib_1.LanguageCodes.EN_US]: translations_1.englishTranslations,
@@ -48,51 +49,18 @@ function createNodeEciesComponentConfig() {
48
49
  aliases: ['NodeEciesStringKey'],
49
50
  };
50
51
  }
51
- let _nodeEciesI18nEngine = null;
52
- let _componentRegistered = false;
53
52
  /**
54
- * Register the engine with all required components using I18nBuilder
53
+ * Creates an I18nComponentPackage bundling the Node ECIES ComponentConfig
54
+ * with its branded string key enum. Use this with createI18nSetup's
55
+ * libraryComponents array.
55
56
  */
56
- function registerEngine() {
57
- const newEngine = i18n_lib_1.I18nBuilder.create()
58
- .withLanguages((0, i18n_lib_1.getCoreLanguageDefinitions)())
59
- .withDefaultLanguage(i18n_lib_1.LanguageCodes.EN_US)
60
- .withInstanceKey('default')
61
- .build();
62
- // Register Core i18n component (required for error messages)
63
- const coreReg = (0, i18n_lib_1.createCoreComponentRegistration)();
64
- newEngine.register({
65
- id: coreReg.component.id,
66
- strings: coreReg.strings,
67
- });
68
- // Register ECIES component from ecies-lib (translations are defined there)
69
- const eciesConfig = (0, ecies_lib_1.createEciesComponentConfig)();
70
- newEngine.register({
71
- ...eciesConfig,
72
- aliases: ['EciesStringKey'],
73
- });
74
- // Register Node ECIES component (translations defined in this lib)
75
- newEngine.register(createNodeEciesComponentConfig());
76
- // Register branded string key enums for translateStringKey support
77
- // Done after build to avoid issues with jest.resetModules() in tests
78
- try {
79
- if (!newEngine.hasStringKeyEnum(ecies_lib_1.EciesStringKey)) {
80
- newEngine.registerStringKeyEnum(ecies_lib_1.EciesStringKey);
81
- }
82
- }
83
- catch {
84
- // Silently ignore if enum registration fails (e.g., in test environments)
85
- }
86
- try {
87
- if (!newEngine.hasStringKeyEnum(node_keys_1.NodeEciesStringKey)) {
88
- newEngine.registerStringKeyEnum(node_keys_1.NodeEciesStringKey);
89
- }
90
- }
91
- catch {
92
- // Silently ignore if enum registration fails (e.g., in test environments)
93
- }
94
- return newEngine;
57
+ function createNodeEciesComponentPackage() {
58
+ return {
59
+ config: createNodeEciesComponentConfig(),
60
+ stringKeyEnum: node_keys_1.NodeEciesStringKey,
61
+ };
95
62
  }
63
+ let _nodeEciesI18nEngine = null;
96
64
  /**
97
65
  * Get or create the Node ECIES i18n engine.
98
66
  *
@@ -100,32 +68,17 @@ function registerEngine() {
100
68
  * allowing translateStringKey to work with both EciesStringKey and NodeEciesStringKey.
101
69
  */
102
70
  function getNodeEciesI18nEngine() {
103
- if (i18n_lib_1.I18nEngine.hasInstance('default')) {
104
- _nodeEciesI18nEngine = i18n_lib_1.I18nEngine.getInstance('default');
105
- // Ensure our components are registered on existing instance
106
- if (!_componentRegistered) {
107
- // Register ECIES component if not present (translations from ecies-lib)
108
- const eciesConfig = (0, ecies_lib_1.createEciesComponentConfig)();
109
- _nodeEciesI18nEngine.registerIfNotExists({
110
- ...eciesConfig,
111
- aliases: ['EciesStringKey'],
112
- });
113
- // Register Node ECIES component if not present
114
- _nodeEciesI18nEngine.registerIfNotExists(createNodeEciesComponentConfig());
115
- // Register branded string key enums for translateStringKey support
116
- if (!_nodeEciesI18nEngine.hasStringKeyEnum(ecies_lib_1.EciesStringKey)) {
117
- _nodeEciesI18nEngine.registerStringKeyEnum(ecies_lib_1.EciesStringKey);
118
- }
119
- if (!_nodeEciesI18nEngine.hasStringKeyEnum(node_keys_1.NodeEciesStringKey)) {
120
- _nodeEciesI18nEngine.registerStringKeyEnum(node_keys_1.NodeEciesStringKey);
121
- }
122
- _componentRegistered = true;
123
- }
124
- }
125
- else {
126
- _nodeEciesI18nEngine = registerEngine();
127
- _componentRegistered = true;
71
+ if (_nodeEciesI18nEngine && i18n_lib_1.I18nEngine.hasInstance('default')) {
72
+ return _nodeEciesI18nEngine;
128
73
  }
74
+ const result = (0, i18n_lib_1.createI18nSetup)({
75
+ componentId: node_keys_1.NodeEciesComponentId,
76
+ stringKeyEnum: node_keys_1.NodeEciesStringKey,
77
+ strings: exports.NodeEciesComponentStrings,
78
+ aliases: ['NodeEciesStringKey'],
79
+ libraryComponents: [(0, ecies_lib_1.createEciesComponentPackage)()],
80
+ });
81
+ _nodeEciesI18nEngine = result.engine;
129
82
  return _nodeEciesI18nEngine;
130
83
  }
131
84
  /**
@@ -133,7 +86,6 @@ function getNodeEciesI18nEngine() {
133
86
  */
134
87
  function resetNodeEciesI18nEngine() {
135
88
  _nodeEciesI18nEngine = null;
136
- _componentRegistered = false;
137
89
  }
138
90
  /**
139
91
  * Helper to translate Node ECIES strings.
@@ -1 +1 @@
1
- {"version":3,"file":"node-ecies-i18n-setup.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-ecies-lib/src/i18n/node-ecies-i18n-setup.ts"],"names":[],"mappings":";;;AAgEA,wEAMC;AA0DD,wDAkCC;AAKD,4DAGC;AAMD,0DAUC;AAKD,kEAUC;AAzMD;;;;;;;;;;GAUG;AACH,0DAIoC;AAyBL,iGA3B7B,4BAAgB,OA2B6B;AAxB/C,wDASmC;A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AAE,CAAC;gBAC3D,oBAAoB,CAAC,qBAAqB,CAAC,0BAAc,CAAC,CAAC;YAC7D,CAAC;YACD,IAAI,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,8BAAkB,CAAC,EAAE,CAAC;gBAC/D,oBAAoB,CAAC,qBAAqB,CAAC,8BAAkB,CAAC,CAAC;YACjE,CAAC;YAED,oBAAoB,GAAG,IAAI,CAAC;QAC9B,CAAC;IACH,CAAC;SAAM,CAAC;QACN,oBAAoB,GAAG,cAAc,EAAE,CAAC;QACxC,oBAAoB,GAAG,IAAI,CAAC;IAC9B,CAAC;IAED,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AAED;;GAEG;AACH,SAAgB,wBAAwB;IACtC,oBAAoB,GAAG,IAAI,CAAC;IAC5B,oBAAoB,GAAG,KAAK,CAAC;AAC/B,CAAC;AAED;;;GAGG;AACH,SAAgB,uBAAuB,CACrC,SAAkC,EAClC,SAA2C,EAC3C,QAAiB;IAEjB,OAAO,sBAAsB,EAAE,CAAC,kBAAkB,CAChD,SAAS,EACT,SAAS,EACT,QAAQ,CACT,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAgB,2BAA2B,CACzC,SAAkC,EAClC,SAA2C,EAC3C,QAAiB;IAEjB,OAAO,sBAAsB,EAAE,CAAC,sBAAsB,CACpD,SAAS,EACT,SAAS,EACT,QAAQ,CACT,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"node-ecies-i18n-setup.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-ecies-lib/src/i18n/node-ecies-i18n-setup.ts"],"names":[],"mappings":";;;AA8DA,wEAMC;AAOD,0EAKC;AAUD,wDAeC;AAKD,4DAEC;AAMD,0DAUC;AAKD,kEAUC;AA/ID;;;;;;;;;;GAUG;AACH,0DAGoC;AAwBL,iGAzB7B,4BAAgB,OAyB6B;AAvB/C,wDAQmC;AAEnC,2CAAuE;AAa9D,qGAbA,gCAAoB,OAaA;AAX7B,iDASwB;AAIxB;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D,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AAED;;GAEG;AACH,SAAgB,wBAAwB;IACtC,oBAAoB,GAAG,IAAI,CAAC;AAC9B,CAAC;AAED;;;GAGG;AACH,SAAgB,uBAAuB,CACrC,SAAkC,EAClC,SAA2C,EAC3C,QAAiB;IAEjB,OAAO,sBAAsB,EAAE,CAAC,kBAAkB,CAChD,SAAS,EACT,SAAS,EACT,QAAQ,CACT,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAgB,2BAA2B,CACzC,SAAkC,EAClC,SAA2C,EAC3C,QAAiB;IAEjB,OAAO,sBAAsB,EAAE,CAAC,sBAAsB,CACpD,SAAS,EACT,SAAS,EACT,QAAQ,CACT,CAAC;AACJ,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Re-export all threshold enumerations from ecies-lib
3
+ * This ensures enumeration parity between browser and Node.js implementations
4
+ */
5
+ export { CeremonyStatus, GuardianStatus, IntervalTriggerType, ThresholdAuditEventType, } from '@digitaldefiance/ecies-lib';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/threshold/enumerations/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ThresholdAuditEventType = exports.IntervalTriggerType = exports.GuardianStatus = exports.CeremonyStatus = void 0;
4
+ /**
5
+ * Re-export all threshold enumerations from ecies-lib
6
+ * This ensures enumeration parity between browser and Node.js implementations
7
+ */
8
+ var ecies_lib_1 = require("@digitaldefiance/ecies-lib");
9
+ Object.defineProperty(exports, "CeremonyStatus", { enumerable: true, get: function () { return ecies_lib_1.CeremonyStatus; } });
10
+ Object.defineProperty(exports, "GuardianStatus", { enumerable: true, get: function () { return ecies_lib_1.GuardianStatus; } });
11
+ Object.defineProperty(exports, "IntervalTriggerType", { enumerable: true, get: function () { return ecies_lib_1.IntervalTriggerType; } });
12
+ Object.defineProperty(exports, "ThresholdAuditEventType", { enumerable: true, get: function () { return ecies_lib_1.ThresholdAuditEventType; } });
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/threshold/enumerations/index.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,wDAKoC;AAJlC,2GAAA,cAAc,OAAA;AACd,2GAAA,cAAc,OAAA;AACd,gHAAA,mBAAmB,OAAA;AACnB,oHAAA,uBAAuB,OAAA"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Threshold Voting Module - Node.js Optimized
3
+ *
4
+ * Re-exports threshold voting components from ecies-lib and adds
5
+ * Node.js-specific extensions with Buffer support for improved performance.
6
+ *
7
+ * Key features:
8
+ * - Threshold Paillier cryptography (k-of-n Guardians required for decryption)
9
+ * - Real-time interval decryption during voting
10
+ * - Zero-knowledge proofs for all decryption operations
11
+ * - Integration with hierarchical aggregation (Precinct → County → State → National)
12
+ * - Backward compatible with single-authority polls
13
+ * - Node.js Buffer support for efficient serialization
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * import {
18
+ * ThresholdKeyGenerator,
19
+ * GuardianRegistry,
20
+ * CeremonyCoordinator,
21
+ * GuardianStatus,
22
+ * } from '@digitaldefiance/node-ecies-lib';
23
+ *
24
+ * // Generate threshold keys (5-of-9 configuration)
25
+ * const keyGen = new ThresholdKeyGenerator();
26
+ * const keyPair = await keyGen.generate({ totalShares: 9, threshold: 5 });
27
+ *
28
+ * // Register Guardians
29
+ * const registry = new GuardianRegistry();
30
+ * keyPair.keyShares.forEach((share, i) => {
31
+ * registry.register({
32
+ * id: guardianIds[i],
33
+ * name: `Guardian ${i + 1}`,
34
+ * shareIndex: share.index,
35
+ * verificationKey: share.verificationKey,
36
+ * status: GuardianStatus.Online,
37
+ * });
38
+ * });
39
+ *
40
+ * // Create threshold poll and conduct voting...
41
+ * ```
42
+ */
43
+ export * from './enumerations';
44
+ export type * from './interfaces';
45
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/threshold/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAGH,cAAc,gBAAgB,CAAC;AAG/B,mBAAmB,cAAc,CAAC"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ /**
3
+ * Threshold Voting Module - Node.js Optimized
4
+ *
5
+ * Re-exports threshold voting components from ecies-lib and adds
6
+ * Node.js-specific extensions with Buffer support for improved performance.
7
+ *
8
+ * Key features:
9
+ * - Threshold Paillier cryptography (k-of-n Guardians required for decryption)
10
+ * - Real-time interval decryption during voting
11
+ * - Zero-knowledge proofs for all decryption operations
12
+ * - Integration with hierarchical aggregation (Precinct → County → State → National)
13
+ * - Backward compatible with single-authority polls
14
+ * - Node.js Buffer support for efficient serialization
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import {
19
+ * ThresholdKeyGenerator,
20
+ * GuardianRegistry,
21
+ * CeremonyCoordinator,
22
+ * GuardianStatus,
23
+ * } from '@digitaldefiance/node-ecies-lib';
24
+ *
25
+ * // Generate threshold keys (5-of-9 configuration)
26
+ * const keyGen = new ThresholdKeyGenerator();
27
+ * const keyPair = await keyGen.generate({ totalShares: 9, threshold: 5 });
28
+ *
29
+ * // Register Guardians
30
+ * const registry = new GuardianRegistry();
31
+ * keyPair.keyShares.forEach((share, i) => {
32
+ * registry.register({
33
+ * id: guardianIds[i],
34
+ * name: `Guardian ${i + 1}`,
35
+ * shareIndex: share.index,
36
+ * verificationKey: share.verificationKey,
37
+ * status: GuardianStatus.Online,
38
+ * });
39
+ * });
40
+ *
41
+ * // Create threshold poll and conduct voting...
42
+ * ```
43
+ */
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ const tslib_1 = require("tslib");
46
+ // Re-export enumerations from ecies-lib
47
+ tslib_1.__exportStar(require("./enumerations"), exports);
48
+ // Node.js-specific extensions will be added in Task 17
49
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/threshold/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;;;AAEH,wCAAwC;AACxC,yDAA+B;AAK/B,uDAAuD"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Re-export all threshold interfaces from ecies-lib
3
+ * This ensures interface parity between browser and Node.js implementations
4
+ *
5
+ * Node.js-specific Buffer extensions will be added in future tasks.
6
+ */
7
+ export type { KeyShare, ThresholdKeyConfig, ThresholdKeyPair, ZKProof, PartialDecryption, CombinedZKProof, CombinedDecryption, Guardian, GuardianStatusChangeEvent, IntervalConfig, IntervalTriggerEvent, Ceremony, IntervalTally, TallySubscription, VerificationResult, ThresholdPollConfig, ThresholdAuditEntry, IThresholdKeyGenerator, IPartialDecryptionService, IDecryptionCombiner, IGuardianRegistry, IIntervalScheduler, ICeremonyCoordinator, IPublicTallyFeed, ITallyVerifier, IThresholdPoll, IThresholdPollFactory, IThresholdAggregator, } from '@digitaldefiance/ecies-lib';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/threshold/interfaces/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,YAAY,EAEV,QAAQ,EACR,kBAAkB,EAClB,gBAAgB,EAChB,OAAO,EACP,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAElB,QAAQ,EACR,yBAAyB,EAEzB,cAAc,EACd,oBAAoB,EAEpB,QAAQ,EAER,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAElB,mBAAmB,EAEnB,mBAAmB,EAEnB,sBAAsB,EACtB,yBAAyB,EACzB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/threshold/interfaces/index.ts"],"names":[],"mappings":""}