@digitaldefiance/ecies-lib 4.17.2 → 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.
Files changed (169) hide show
  1. package/package.json +2 -2
  2. package/src/i18n-setup.d.ts +7 -1
  3. package/src/i18n-setup.d.ts.map +1 -1
  4. package/src/i18n-setup.js +12 -0
  5. package/src/i18n-setup.js.map +1 -1
  6. package/src/index.d.ts +1 -1
  7. package/src/index.d.ts.map +1 -1
  8. package/src/index.js +2 -1
  9. package/src/index.js.map +1 -1
  10. package/src/lib/voting/index.d.ts +1 -0
  11. package/src/lib/voting/index.d.ts.map +1 -1
  12. package/src/lib/voting/index.js +2 -0
  13. package/src/lib/voting/index.js.map +1 -1
  14. package/src/lib/voting/threshold/decryption-combiner.d.ts +141 -0
  15. package/src/lib/voting/threshold/decryption-combiner.d.ts.map +1 -0
  16. package/src/lib/voting/threshold/decryption-combiner.js +343 -0
  17. package/src/lib/voting/threshold/decryption-combiner.js.map +1 -0
  18. package/src/lib/voting/threshold/enumerations/ceremony-status.d.ts +19 -0
  19. package/src/lib/voting/threshold/enumerations/ceremony-status.d.ts.map +1 -0
  20. package/src/lib/voting/threshold/enumerations/ceremony-status.js +23 -0
  21. package/src/lib/voting/threshold/enumerations/ceremony-status.js.map +1 -0
  22. package/src/lib/voting/threshold/enumerations/guardian-status.d.ts +18 -0
  23. package/src/lib/voting/threshold/enumerations/guardian-status.d.ts.map +1 -0
  24. package/src/lib/voting/threshold/enumerations/guardian-status.js +22 -0
  25. package/src/lib/voting/threshold/enumerations/guardian-status.js.map +1 -0
  26. package/src/lib/voting/threshold/enumerations/index.d.ts +8 -0
  27. package/src/lib/voting/threshold/enumerations/index.d.ts.map +1 -0
  28. package/src/lib/voting/threshold/enumerations/index.js +11 -0
  29. package/src/lib/voting/threshold/enumerations/index.js.map +1 -0
  30. package/src/lib/voting/threshold/enumerations/interval-trigger-type.d.ts +15 -0
  31. package/src/lib/voting/threshold/enumerations/interval-trigger-type.d.ts.map +1 -0
  32. package/src/lib/voting/threshold/enumerations/interval-trigger-type.js +19 -0
  33. package/src/lib/voting/threshold/enumerations/interval-trigger-type.js.map +1 -0
  34. package/src/lib/voting/threshold/enumerations/threshold-audit-event-type.d.ts +29 -0
  35. package/src/lib/voting/threshold/enumerations/threshold-audit-event-type.d.ts.map +1 -0
  36. package/src/lib/voting/threshold/enumerations/threshold-audit-event-type.js +33 -0
  37. package/src/lib/voting/threshold/enumerations/threshold-audit-event-type.js.map +1 -0
  38. package/src/lib/voting/threshold/guardian-registry.d.ts +120 -0
  39. package/src/lib/voting/threshold/guardian-registry.d.ts.map +1 -0
  40. package/src/lib/voting/threshold/guardian-registry.js +227 -0
  41. package/src/lib/voting/threshold/guardian-registry.js.map +1 -0
  42. package/src/lib/voting/threshold/index.d.ts +49 -0
  43. package/src/lib/voting/threshold/index.d.ts.map +1 -0
  44. package/src/lib/voting/threshold/index.js +69 -0
  45. package/src/lib/voting/threshold/index.js.map +1 -0
  46. package/src/lib/voting/threshold/interfaces/ceremony-coordinator.d.ts +19 -0
  47. package/src/lib/voting/threshold/interfaces/ceremony-coordinator.d.ts.map +1 -0
  48. package/src/lib/voting/threshold/interfaces/ceremony-coordinator.js +3 -0
  49. package/src/lib/voting/threshold/interfaces/ceremony-coordinator.js.map +1 -0
  50. package/src/lib/voting/threshold/interfaces/ceremony.d.ts +33 -0
  51. package/src/lib/voting/threshold/interfaces/ceremony.d.ts.map +1 -0
  52. package/src/lib/voting/threshold/interfaces/ceremony.js +3 -0
  53. package/src/lib/voting/threshold/interfaces/ceremony.js.map +1 -0
  54. package/src/lib/voting/threshold/interfaces/combined-decryption.d.ts +20 -0
  55. package/src/lib/voting/threshold/interfaces/combined-decryption.d.ts.map +1 -0
  56. package/src/lib/voting/threshold/interfaces/combined-decryption.js +3 -0
  57. package/src/lib/voting/threshold/interfaces/combined-decryption.js.map +1 -0
  58. package/src/lib/voting/threshold/interfaces/combined-zk-proof.d.ts +16 -0
  59. package/src/lib/voting/threshold/interfaces/combined-zk-proof.d.ts.map +1 -0
  60. package/src/lib/voting/threshold/interfaces/combined-zk-proof.js +3 -0
  61. package/src/lib/voting/threshold/interfaces/combined-zk-proof.js.map +1 -0
  62. package/src/lib/voting/threshold/interfaces/decryption-combiner.d.ts +14 -0
  63. package/src/lib/voting/threshold/interfaces/decryption-combiner.d.ts.map +1 -0
  64. package/src/lib/voting/threshold/interfaces/decryption-combiner.js +3 -0
  65. package/src/lib/voting/threshold/interfaces/decryption-combiner.js.map +1 -0
  66. package/src/lib/voting/threshold/interfaces/guardian-registry.d.ts +28 -0
  67. package/src/lib/voting/threshold/interfaces/guardian-registry.d.ts.map +1 -0
  68. package/src/lib/voting/threshold/interfaces/guardian-registry.js +3 -0
  69. package/src/lib/voting/threshold/interfaces/guardian-registry.js.map +1 -0
  70. package/src/lib/voting/threshold/interfaces/guardian-status-change-event.d.ts +16 -0
  71. package/src/lib/voting/threshold/interfaces/guardian-status-change-event.d.ts.map +1 -0
  72. package/src/lib/voting/threshold/interfaces/guardian-status-change-event.js +3 -0
  73. package/src/lib/voting/threshold/interfaces/guardian-status-change-event.js.map +1 -0
  74. package/src/lib/voting/threshold/interfaces/guardian.d.ts +25 -0
  75. package/src/lib/voting/threshold/interfaces/guardian.d.ts.map +1 -0
  76. package/src/lib/voting/threshold/interfaces/guardian.js +3 -0
  77. package/src/lib/voting/threshold/interfaces/guardian.js.map +1 -0
  78. package/src/lib/voting/threshold/interfaces/index.d.ts +32 -0
  79. package/src/lib/voting/threshold/interfaces/index.d.ts.map +1 -0
  80. package/src/lib/voting/threshold/interfaces/index.js +6 -0
  81. package/src/lib/voting/threshold/interfaces/index.js.map +1 -0
  82. package/src/lib/voting/threshold/interfaces/interval-config.d.ts +17 -0
  83. package/src/lib/voting/threshold/interfaces/interval-config.d.ts.map +1 -0
  84. package/src/lib/voting/threshold/interfaces/interval-config.js +3 -0
  85. package/src/lib/voting/threshold/interfaces/interval-config.js.map +1 -0
  86. package/src/lib/voting/threshold/interfaces/interval-scheduler.d.ts +23 -0
  87. package/src/lib/voting/threshold/interfaces/interval-scheduler.d.ts.map +1 -0
  88. package/src/lib/voting/threshold/interfaces/interval-scheduler.js +3 -0
  89. package/src/lib/voting/threshold/interfaces/interval-scheduler.js.map +1 -0
  90. package/src/lib/voting/threshold/interfaces/interval-tally.d.ts +30 -0
  91. package/src/lib/voting/threshold/interfaces/interval-tally.d.ts.map +1 -0
  92. package/src/lib/voting/threshold/interfaces/interval-tally.js +3 -0
  93. package/src/lib/voting/threshold/interfaces/interval-tally.js.map +1 -0
  94. package/src/lib/voting/threshold/interfaces/interval-trigger-event.d.ts +20 -0
  95. package/src/lib/voting/threshold/interfaces/interval-trigger-event.d.ts.map +1 -0
  96. package/src/lib/voting/threshold/interfaces/interval-trigger-event.js +3 -0
  97. package/src/lib/voting/threshold/interfaces/interval-trigger-event.js.map +1 -0
  98. package/src/lib/voting/threshold/interfaces/key-share.d.ts +15 -0
  99. package/src/lib/voting/threshold/interfaces/key-share.d.ts.map +1 -0
  100. package/src/lib/voting/threshold/interfaces/key-share.js +3 -0
  101. package/src/lib/voting/threshold/interfaces/key-share.js.map +1 -0
  102. package/src/lib/voting/threshold/interfaces/partial-decryption-service.d.ts +17 -0
  103. package/src/lib/voting/threshold/interfaces/partial-decryption-service.d.ts.map +1 -0
  104. package/src/lib/voting/threshold/interfaces/partial-decryption-service.js +3 -0
  105. package/src/lib/voting/threshold/interfaces/partial-decryption-service.js.map +1 -0
  106. package/src/lib/voting/threshold/interfaces/partial-decryption.d.ts +20 -0
  107. package/src/lib/voting/threshold/interfaces/partial-decryption.d.ts.map +1 -0
  108. package/src/lib/voting/threshold/interfaces/partial-decryption.js +3 -0
  109. package/src/lib/voting/threshold/interfaces/partial-decryption.js.map +1 -0
  110. package/src/lib/voting/threshold/interfaces/public-tally-feed.d.ts +19 -0
  111. package/src/lib/voting/threshold/interfaces/public-tally-feed.d.ts.map +1 -0
  112. package/src/lib/voting/threshold/interfaces/public-tally-feed.js +3 -0
  113. package/src/lib/voting/threshold/interfaces/public-tally-feed.js.map +1 -0
  114. package/src/lib/voting/threshold/interfaces/tally-subscription.d.ts +16 -0
  115. package/src/lib/voting/threshold/interfaces/tally-subscription.d.ts.map +1 -0
  116. package/src/lib/voting/threshold/interfaces/tally-subscription.js +3 -0
  117. package/src/lib/voting/threshold/interfaces/tally-subscription.js.map +1 -0
  118. package/src/lib/voting/threshold/interfaces/tally-verifier.d.ts +12 -0
  119. package/src/lib/voting/threshold/interfaces/tally-verifier.d.ts.map +1 -0
  120. package/src/lib/voting/threshold/interfaces/tally-verifier.js +3 -0
  121. package/src/lib/voting/threshold/interfaces/tally-verifier.js.map +1 -0
  122. package/src/lib/voting/threshold/interfaces/threshold-aggregator.d.ts +15 -0
  123. package/src/lib/voting/threshold/interfaces/threshold-aggregator.d.ts.map +1 -0
  124. package/src/lib/voting/threshold/interfaces/threshold-aggregator.js +3 -0
  125. package/src/lib/voting/threshold/interfaces/threshold-aggregator.js.map +1 -0
  126. package/src/lib/voting/threshold/interfaces/threshold-audit-entry.d.ts +28 -0
  127. package/src/lib/voting/threshold/interfaces/threshold-audit-entry.d.ts.map +1 -0
  128. package/src/lib/voting/threshold/interfaces/threshold-audit-entry.js +3 -0
  129. package/src/lib/voting/threshold/interfaces/threshold-audit-entry.js.map +1 -0
  130. package/src/lib/voting/threshold/interfaces/threshold-key-config.d.ts +12 -0
  131. package/src/lib/voting/threshold/interfaces/threshold-key-config.d.ts.map +1 -0
  132. package/src/lib/voting/threshold/interfaces/threshold-key-config.js +3 -0
  133. package/src/lib/voting/threshold/interfaces/threshold-key-config.js.map +1 -0
  134. package/src/lib/voting/threshold/interfaces/threshold-key-generator.d.ts +12 -0
  135. package/src/lib/voting/threshold/interfaces/threshold-key-generator.d.ts.map +1 -0
  136. package/src/lib/voting/threshold/interfaces/threshold-key-generator.js +3 -0
  137. package/src/lib/voting/threshold/interfaces/threshold-key-generator.js.map +1 -0
  138. package/src/lib/voting/threshold/interfaces/threshold-key-pair.d.ts +30 -0
  139. package/src/lib/voting/threshold/interfaces/threshold-key-pair.d.ts.map +1 -0
  140. package/src/lib/voting/threshold/interfaces/threshold-key-pair.js +3 -0
  141. package/src/lib/voting/threshold/interfaces/threshold-key-pair.js.map +1 -0
  142. package/src/lib/voting/threshold/interfaces/threshold-poll-config.d.ts +19 -0
  143. package/src/lib/voting/threshold/interfaces/threshold-poll-config.d.ts.map +1 -0
  144. package/src/lib/voting/threshold/interfaces/threshold-poll-config.js +3 -0
  145. package/src/lib/voting/threshold/interfaces/threshold-poll-config.js.map +1 -0
  146. package/src/lib/voting/threshold/interfaces/threshold-poll-factory.d.ts +16 -0
  147. package/src/lib/voting/threshold/interfaces/threshold-poll-factory.d.ts.map +1 -0
  148. package/src/lib/voting/threshold/interfaces/threshold-poll-factory.js +3 -0
  149. package/src/lib/voting/threshold/interfaces/threshold-poll-factory.js.map +1 -0
  150. package/src/lib/voting/threshold/interfaces/threshold-poll.d.ts +25 -0
  151. package/src/lib/voting/threshold/interfaces/threshold-poll.d.ts.map +1 -0
  152. package/src/lib/voting/threshold/interfaces/threshold-poll.js +3 -0
  153. package/src/lib/voting/threshold/interfaces/threshold-poll.js.map +1 -0
  154. package/src/lib/voting/threshold/interfaces/verification-result.d.ts +17 -0
  155. package/src/lib/voting/threshold/interfaces/verification-result.d.ts.map +1 -0
  156. package/src/lib/voting/threshold/interfaces/verification-result.js +3 -0
  157. package/src/lib/voting/threshold/interfaces/verification-result.js.map +1 -0
  158. package/src/lib/voting/threshold/interfaces/zk-proof.d.ts +15 -0
  159. package/src/lib/voting/threshold/interfaces/zk-proof.d.ts.map +1 -0
  160. package/src/lib/voting/threshold/interfaces/zk-proof.js +3 -0
  161. package/src/lib/voting/threshold/interfaces/zk-proof.js.map +1 -0
  162. package/src/lib/voting/threshold/partial-decryption-service.d.ts +130 -0
  163. package/src/lib/voting/threshold/partial-decryption-service.d.ts.map +1 -0
  164. package/src/lib/voting/threshold/partial-decryption-service.js +288 -0
  165. package/src/lib/voting/threshold/partial-decryption-service.js.map +1 -0
  166. package/src/lib/voting/threshold/threshold-key-generator.d.ts +114 -0
  167. package/src/lib/voting/threshold/threshold-key-generator.d.ts.map +1 -0
  168. package/src/lib/voting/threshold/threshold-key-generator.js +275 -0
  169. package/src/lib/voting/threshold/threshold-key-generator.js.map +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitaldefiance/ecies-lib",
3
- "version": "4.17.2",
3
+ "version": "4.17.4",
4
4
  "description": "Digital Defiance ECIES Library",
5
5
  "homepage": "https://github.com/Digital-Defiance/ecies-lib",
6
6
  "repository": {
@@ -62,7 +62,7 @@
62
62
  "license": "MIT",
63
63
  "packageManager": "yarn@4.11.0",
64
64
  "dependencies": {
65
- "@digitaldefiance/i18n-lib": "4.3.2",
65
+ "@digitaldefiance/i18n-lib": "4.4.0",
66
66
  "@ethereumjs/wallet": "^2.0.4",
67
67
  "@noble/curves": "^1.4.2",
68
68
  "@noble/hashes": "^1.4.0",
@@ -2,7 +2,7 @@
2
2
  * ECIES i18n Setup - v2.0 Architecture
3
3
  * Uses i18n-lib 2.0 patterns with runtime validation
4
4
  */
5
- import type { BrandedPluralMasterStringsCollection, ComponentConfig, CoreLanguageCode, EngineConfig } from '@digitaldefiance/i18n-lib';
5
+ import type { BrandedPluralMasterStringsCollection, ComponentConfig, CoreLanguageCode, EngineConfig, I18nComponentPackage } from '@digitaldefiance/i18n-lib';
6
6
  import { I18nEngine } from '@digitaldefiance/i18n-lib';
7
7
  import { EciesComponentId, EciesStringKey, type EciesStringKeyValue } from './enumerations/ecies-string-key';
8
8
  export declare const EciesI18nEngineKey: "DigitalDefiance.Ecies.I18nEngine";
@@ -18,6 +18,12 @@ export declare const EciesComponentStrings: BrandedPluralMasterStringsCollection
18
18
  * Note: Includes all 8 supported languages
19
19
  */
20
20
  export declare function createEciesComponentConfig(): ComponentConfig;
21
+ /**
22
+ * Creates an I18nComponentPackage bundling the ECIES ComponentConfig
23
+ * with its branded string key enum. Use this with createI18nSetup's
24
+ * libraryComponents array.
25
+ */
26
+ export declare function createEciesComponentPackage(): I18nComponentPackage;
21
27
  export declare function getEciesI18nEngine(config?: EngineConfig): I18nEngine;
22
28
  /**
23
29
  * Proxy for backward compatibility
@@ -1 +1 @@
1
- {"version":3,"file":"i18n-setup.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-ecies-lib/src/i18n-setup.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,oCAAoC,EACpC,eAAe,EACf,gBAAgB,EAChB,YAAY,EACb,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,UAAU,EAIX,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,KAAK,mBAAmB,EACzB,MAAM,iCAAiC,CAAC;AASzC,eAAO,MAAM,kBAAkB,EAAG,kCAA2C,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,oCAAoC,CACtE,OAAO,cAAc,EACrB,gBAAgB,CAUjB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,eAAe,CAK5D;AA+CD,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,UAAU,CAKpE;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,YAI1B,CAAC;AAEH;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,mBAAmB,EAC9B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EAC3C,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,CAMR;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,mBAAmB,EAC9B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EAC3C,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,CAMR"}
1
+ {"version":3,"file":"i18n-setup.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-ecies-lib/src/i18n-setup.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,oCAAoC,EACpC,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,oBAAoB,EACrB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,UAAU,EAIX,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,KAAK,mBAAmB,EACzB,MAAM,iCAAiC,CAAC;AASzC,eAAO,MAAM,kBAAkB,EAAG,kCAA2C,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,oCAAoC,CACtE,OAAO,cAAc,EACrB,gBAAgB,CAUjB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,eAAe,CAK5D;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,IAAI,oBAAoB,CAKlE;AA+CD,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,UAAU,CAKpE;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,YAI1B,CAAC;AAEH;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,mBAAmB,EAC9B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EAC3C,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,CAMR;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,mBAAmB,EAC9B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EAC3C,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,CAMR"}
package/src/i18n-setup.js CHANGED
@@ -6,6 +6,7 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.eciesI18nEngine = exports.EciesComponentStrings = exports.EciesComponentId = exports.EciesI18nEngineKey = void 0;
8
8
  exports.createEciesComponentConfig = createEciesComponentConfig;
9
+ exports.createEciesComponentPackage = createEciesComponentPackage;
9
10
  exports.getEciesI18nEngine = getEciesI18nEngine;
10
11
  exports.resetEciesI18nEngine = resetEciesI18nEngine;
11
12
  exports.getEciesTranslation = getEciesTranslation;
@@ -46,6 +47,17 @@ function createEciesComponentConfig() {
46
47
  strings: exports.EciesComponentStrings,
47
48
  };
48
49
  }
50
+ /**
51
+ * Creates an I18nComponentPackage bundling the ECIES ComponentConfig
52
+ * with its branded string key enum. Use this with createI18nSetup's
53
+ * libraryComponents array.
54
+ */
55
+ function createEciesComponentPackage() {
56
+ return {
57
+ config: createEciesComponentConfig(),
58
+ stringKeyEnum: ecies_string_key_1.EciesStringKey,
59
+ };
60
+ }
49
61
  /**
50
62
  * Create ECIES i18n engine instance
51
63
  * Uses i18n 2.0 pattern with runtime validation
@@ -1 +1 @@
1
- {"version":3,"file":"i18n-setup.js","sourceRoot":"","sources":["../../../../packages/digitaldefiance-ecies-lib/src/i18n-setup.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAqDH,gEAKC;AA+CD,gDAKC;AAcD,oDAEC;AAKD,kDAUC;AAKD,oDAUC;AApJD,wDAKmC;AACnC,sEAIyC;AAUhC,iGAbP,mCAAgB,OAaO;AATzB,0CAAuD;AACvD,gDAA2D;AAC3D,0CAAwD;AACxD,0CAAuD;AACvD,0CAAyD;AACzD,0CAA0D;AAC1D,gDAAmE;AAEtD,QAAA,kBAAkB,GAAG,kCAA2C,CAAC;AAG9E;;;;GAIG;AACU,QAAA,qBAAqB,GAG9B;IACF,CAA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AAM,CAAC,MAAM,CAAC,MAAM,SAAS,EACpD,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAC1B,CAAC;IACJ,CAAC;IAED,sEAAsE;IACtE,MAAM,CAAC,qBAAqB,CAAC,iCAAc,CAAC,CAAC;IAE7C,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,IAAI,YAAoC,CAAC;AAEzC,SAAgB,kBAAkB,CAAC,MAAqB;IACtD,IAAI,CAAC,YAAY,IAAI,CAAC,qBAAU,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC;QACxD,YAAY,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;GAEG;AACU,QAAA,eAAe,GAAG,IAAI,KAAK,CAAC,EAAgB,EAAE;IACzD,GAAG,CAAC,QAAQ,EAAE,IAAI;QAChB,OAAO,kBAAkB,EAAE,CAAC,IAAwB,CAAC,CAAC;IACxD,CAAC;CACF,CAAC,CAAC;AAEH;;GAEG;AACH,SAAgB,oBAAoB;IAClC,YAAY,GAAG,SAAS,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,SAAgB,mBAAmB,CACjC,SAA8B,EAC9B,SAA2C,EAC3C,QAAiB;IAEjB,OAAO,kBAAkB,EAAE,CAAC,kBAAkB,CAC5C,SAAS,EACT,SAAS,EACT,QAAQ,CACT,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAClC,SAA8B,EAC9B,SAA2C,EAC3C,QAAiB;IAEjB,OAAO,kBAAkB,EAAE,CAAC,sBAAsB,CAChD,SAAS,EACT,SAAS,EACT,QAAQ,CACT,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"i18n-setup.js","sourceRoot":"","sources":["../../../../packages/digitaldefiance-ecies-lib/src/i18n-setup.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAsDH,gEAKC;AAOD,k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,EAC9B,SAA2C,EAC3C,QAAiB;IAEjB,OAAO,kBAAkB,EAAE,CAAC,kBAAkB,CAC5C,SAAS,EACT,SAAS,EACT,QAAQ,CACT,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAClC,SAA8B,EAC9B,SAA2C,EAC3C,QAAiB;IAEjB,OAAO,kBAAkB,EAAE,CAAC,sBAAsB,CAChD,SAAS,EACT,SAAS,EACT,QAAQ,CACT,CAAC;AACJ,CAAC"}
package/src/index.d.ts CHANGED
@@ -12,7 +12,7 @@ import './lib/crypto-polyfill';
12
12
  export * from './builders/index';
13
13
  export * from './core/index';
14
14
  export * from './lib/index';
15
- export { createEciesComponentConfig, EciesComponentStrings, EciesI18nEngineKey, getEciesI18nEngine, getEciesTranslation, resetEciesI18nEngine, safeEciesTranslation, } from './i18n-setup';
15
+ export { createEciesComponentConfig, createEciesComponentPackage, EciesComponentStrings, EciesI18nEngineKey, getEciesI18nEngine, getEciesTranslation, resetEciesI18nEngine, safeEciesTranslation, } from './i18n-setup';
16
16
  export { encryptionTypeEnumToType, encryptionTypeToString, ensureEciesEncryptionTypeEnum, validateEciesEncryptionTypeEnum, } from './utils/encryption-type-utils';
17
17
  export * from './constants';
18
18
  export * from './typed-configuration';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-ecies-lib/src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,uBAAuB,CAAC;AAG/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAG5B,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAItB,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,6BAA6B,EAC7B,+BAA+B,GAChC,MAAM,+BAA+B,CAAC;AASvC,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,8BAA8B,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,YAAY,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AAGxB,cAAc,cAAc,CAAC;AAG7B,YAAY,EACV,UAAU,EACV,SAAS,EACT,OAAO,IAAI,eAAe,GAC3B,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-ecies-lib/src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,uBAAuB,CAAC;AAG/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAG5B,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,EAC3B,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAItB,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,6BAA6B,EAC7B,+BAA+B,GAChC,MAAM,+BAA+B,CAAC;AASvC,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,8BAA8B,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,YAAY,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AAGxB,cAAc,cAAc,CAAC;AAG7B,YAAY,EACV,UAAU,EACV,SAAS,EACT,OAAO,IAAI,eAAe,GAC3B,MAAM,iBAAiB,CAAC"}
package/src/index.js CHANGED
@@ -10,7 +10,7 @@
10
10
  * - i18n 2.0 integration
11
11
  */
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.ENCRYPTION_STATE_VERSION = exports.validateEciesEncryptionTypeEnum = exports.ensureEciesEncryptionTypeEnum = exports.encryptionTypeToString = exports.encryptionTypeEnumToType = exports.safeEciesTranslation = exports.resetEciesI18nEngine = exports.getEciesTranslation = exports.getEciesI18nEngine = exports.EciesI18nEngineKey = exports.EciesComponentStrings = exports.createEciesComponentConfig = void 0;
13
+ exports.ENCRYPTION_STATE_VERSION = exports.validateEciesEncryptionTypeEnum = exports.ensureEciesEncryptionTypeEnum = exports.encryptionTypeToString = exports.encryptionTypeEnumToType = exports.safeEciesTranslation = exports.resetEciesI18nEngine = exports.getEciesTranslation = exports.getEciesI18nEngine = exports.EciesI18nEngineKey = exports.EciesComponentStrings = exports.createEciesComponentPackage = exports.createEciesComponentConfig = void 0;
14
14
  const tslib_1 = require("tslib");
15
15
  // CRITICAL: Apply crypto polyfill BEFORE any @noble/curves imports
16
16
  // This ensures crypto.getRandomValues returns pure Uint8Array instances
@@ -22,6 +22,7 @@ tslib_1.__exportStar(require("./lib/index"), exports);
22
22
  // i18n v2
23
23
  var i18n_setup_1 = require("./i18n-setup");
24
24
  Object.defineProperty(exports, "createEciesComponentConfig", { enumerable: true, get: function () { return i18n_setup_1.createEciesComponentConfig; } });
25
+ Object.defineProperty(exports, "createEciesComponentPackage", { enumerable: true, get: function () { return i18n_setup_1.createEciesComponentPackage; } });
25
26
  Object.defineProperty(exports, "EciesComponentStrings", { enumerable: true, get: function () { return i18n_setup_1.EciesComponentStrings; } });
26
27
  Object.defineProperty(exports, "EciesI18nEngineKey", { enumerable: true, get: function () { return i18n_setup_1.EciesI18nEngineKey; } });
27
28
  Object.defineProperty(exports, "getEciesI18nEngine", { enumerable: true, get: function () { return i18n_setup_1.getEciesI18nEngine; } });
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/digitaldefiance-ecies-lib/src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;AAEH,mEAAmE;AACnE,wEAAwE;AACxE,iCAA+B;AAE/B,kBAAkB;AAClB,2DAAiC;AACjC,uDAA6B;AAC7B,sDAA4B;AAE5B,UAAU;AACV,2CAQsB;AAPpB,wHAAA,0BAA0B,OAAA;AAC1B,mHAAA,qBAAqB,OAAA;AACrB,gHAAA,kBAAkB,OAAA;AAClB,gHAAA,kBAAkB,OAAA;AAClB,iHAAA,mBAAmB,OAAA;AACnB,kHAAA,oBAAoB,OAAA;AACpB,kHAAA,oBAAoB,OAAA;AAGtB,mFAAmF;AACnF,mEAAmE;AACnE,uEAKuC;AAJrC,iIAAA,wBAAwB,OAAA;AACxB,+HAAA,sBAAsB,OAAA;AACtB,sIAAA,6BAA6B,OAAA;AAC7B,wIAAA,+BAA+B,OAAA;AAGjC,2DAA2D;AAC3D,oEAAoE;AACpE,8DAA8D;AAE9D,kEAAkE;AAClE,gEAAgE;AAEhE,sDAA4B;AAC5B,gEAAsC;AACtC,yDAA+B;AAC/B,yDAA+B;AAC/B,mDAAyB;AACzB,uDAA6B;AAC7B,uEAA6C;AAC7C,kEAAyE;AAAhE,4HAAA,wBAAwB,OAAA;AAEjC,qEAA2C;AAC3C,qEAA2C;AAC3C,uEAA6C;AAC7C,6DAAmC;AACnC,4DAAkC;AAClC,mDAAyB;AACzB,4DAAkC;AAClC,yDAA+B;AAC/B,0DAAgC;AAChC,0DAAgC;AAChC,qDAA2B;AAC3B,uDAA6B;AAC7B,wDAA8B;AAC9B,kDAAwB;AACxB,kDAAwB;AAExB,qEAAqE;AACrE,uDAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/digitaldefiance-ecies-lib/src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;AAEH,mEAAmE;AACnE,wEAAwE;AACxE,iCAA+B;AAE/B,kBAAkB;AAClB,2DAAiC;AACjC,uDAA6B;AAC7B,sDAA4B;AAE5B,UAAU;AACV,2CASsB;AARpB,wHAAA,0BAA0B,OAAA;AAC1B,yHAAA,2BAA2B,OAAA;AAC3B,mHAAA,qBAAqB,OAAA;AACrB,gHAAA,kBAAkB,OAAA;AAClB,gHAAA,kBAAkB,OAAA;AAClB,iHAAA,mBAAmB,OAAA;AACnB,kHAAA,oBAAoB,OAAA;AACpB,kHAAA,oBAAoB,OAAA;AAGtB,mFAAmF;AACnF,mEAAmE;AACnE,uEAKuC;AAJrC,iIAAA,wBAAwB,OAAA;AACxB,+HAAA,sBAAsB,OAAA;AACtB,sIAAA,6BAA6B,OAAA;AAC7B,wIAAA,+BAA+B,OAAA;AAGjC,2DAA2D;AAC3D,oEAAoE;AACpE,8DAA8D;AAE9D,kEAAkE;AAClE,gEAAgE;AAEhE,sDAA4B;AAC5B,gEAAsC;AACtC,yDAA+B;AAC/B,yDAA+B;AAC/B,mDAAyB;AACzB,uDAA6B;AAC7B,uEAA6C;AAC7C,kEAAyE;AAAhE,4HAAA,wBAAwB,OAAA;AAEjC,qEAA2C;AAC3C,qEAA2C;AAC3C,uEAA6C;AAC7C,6DAAmC;AACnC,4DAAkC;AAClC,mDAAyB;AACzB,4DAAkC;AAClC,yDAA+B;AAC/B,0DAAgC;AAChC,0DAAgC;AAChC,qDAA2B;AAC3B,uDAA6B;AAC7B,wDAA8B;AAC9B,kDAAwB;AACxB,kDAAwB;AAExB,qEAAqE;AACrE,uDAA6B"}
@@ -44,4 +44,5 @@ export { PrecinctAggregator, CountyAggregator, StateAggregator, NationalAggregat
44
44
  export { BatchVoteProcessor } from './persistent-state';
45
45
  export * from './enumerations';
46
46
  export type * from './interfaces';
47
+ export * from './threshold';
47
48
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-ecies-lib/src/lib/voting/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,kBAAkB,GACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAGxD,cAAc,gBAAgB,CAAC;AAG/B,mBAAmB,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-ecies-lib/src/lib/voting/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,kBAAkB,GACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAGxD,cAAc,gBAAgB,CAAC;AAG/B,mBAAmB,cAAc,CAAC;AAGlC,cAAc,aAAa,CAAC"}
@@ -62,4 +62,6 @@ var persistent_state_1 = require("./persistent-state");
62
62
  Object.defineProperty(exports, "BatchVoteProcessor", { enumerable: true, get: function () { return persistent_state_1.BatchVoteProcessor; } });
63
63
  // Re-export enumerations
64
64
  tslib_1.__exportStar(require("./enumerations"), exports);
65
+ // Re-export threshold voting module
66
+ tslib_1.__exportStar(require("./threshold"), exports);
65
67
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-ecies-lib/src/lib/voting/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;;;;AAEH,yCAAmC;AAA1B,iGAAA,IAAI,OAAA;AACb,qCAAwC;AAA/B,sGAAA,WAAW,OAAA;AACpB,qCAAwC;AAA/B,sGAAA,WAAW,OAAA;AACpB,qCAAwC;AAA/B,sGAAA,WAAW,OAAA;AACpB,uCAAsE;AAA7D,mHAAA,uBAAuB,OAAA;AAAE,2GAAA,eAAe,OAAA;AACjD,iCAA4C;AAAnC,0GAAA,iBAAiB,OAAA;AAC1B,mDAAuD;AAA9C,qHAAA,mBAAmB,OAAA;AAC5B,+CAAiD;AAAxC,+GAAA,eAAe,OAAA;AACxB,qEAKmC;AAJjC,6HAAA,kBAAkB,OAAA;AAClB,2HAAA,gBAAgB,OAAA;AAChB,0HAAA,eAAe,OAAA;AACf,6HAAA,kBAAkB,OAAA;AAEpB,uDAAwD;AAA/C,sHAAA,kBAAkB,OAAA;AAE3B,yBAAyB;AACzB,yDAA+B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-ecies-lib/src/lib/voting/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;;;;AAEH,yCAAmC;AAA1B,iGAAA,IAAI,OAAA;AACb,qCAAwC;AAA/B,sGAAA,WAAW,OAAA;AACpB,qCAAwC;AAA/B,sGAAA,WAAW,OAAA;AACpB,qCAAwC;AAA/B,sGAAA,WAAW,OAAA;AACpB,uCAAsE;AAA7D,mHAAA,uBAAuB,OAAA;AAAE,2GAAA,eAAe,OAAA;AACjD,iCAA4C;AAAnC,0GAAA,iBAAiB,OAAA;AAC1B,mDAAuD;AAA9C,qHAAA,mBAAmB,OAAA;AAC5B,+CAAiD;AAAxC,+GAAA,eAAe,OAAA;AACxB,qEAKmC;AAJjC,6HAAA,kBAAkB,OAAA;AAClB,2HAAA,gBAAgB,OAAA;AAChB,0HAAA,eAAe,OAAA;AACf,6HAAA,kBAAkB,OAAA;AAEpB,uDAAwD;AAA/C,sHAAA,kBAAkB,OAAA;AAE3B,yBAAyB;AACzB,yDAA+B;AAK/B,oCAAoC;AACpC,sDAA4B"}
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Decryption Combiner
3
+ *
4
+ * Combines k partial decryptions using Lagrange interpolation to produce
5
+ * the final plaintext tally. Based on Damgård et al.'s threshold Paillier scheme.
6
+ *
7
+ * The combining process:
8
+ * 1. Verify each partial decryption's ZK proof
9
+ * 2. Compute Lagrange coefficients for the participating share indices
10
+ * 3. Combine partials: product of partial_i^(2·λ_i) mod n²
11
+ * 4. Apply the Paillier L-function: L(x) = (x - 1) / n
12
+ * 5. Multiply by the modular inverse of 4·Δ² to recover plaintext
13
+ *
14
+ * Where Δ = n! (factorial of total shares count).
15
+ */
16
+ import type { PublicKey } from 'paillier-bigint';
17
+ import type { CombinedDecryption, IDecryptionCombiner, PartialDecryption, ThresholdKeyConfig } from './interfaces';
18
+ /**
19
+ * Error thrown when there are insufficient partial decryptions.
20
+ */
21
+ export declare class InsufficientPartialsError extends Error {
22
+ constructor(message: string);
23
+ }
24
+ /**
25
+ * Error thrown when a partial decryption's ZK proof is invalid during combining.
26
+ */
27
+ export declare class InvalidPartialInCombineError extends Error {
28
+ constructor(message: string);
29
+ }
30
+ /**
31
+ * Error thrown when decryption combining fails.
32
+ */
33
+ export declare class CombineFailedError extends Error {
34
+ constructor(message: string);
35
+ }
36
+ /**
37
+ * Combines k partial decryptions into the final plaintext using
38
+ * Lagrange interpolation over the Paillier ciphertext space.
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const combiner = new DecryptionCombiner(publicKey, verificationKeys);
43
+ *
44
+ * const result = combiner.combine(
45
+ * partials,
46
+ * encryptedTally,
47
+ * publicKey,
48
+ * { totalShares: 9, threshold: 5 }
49
+ * );
50
+ *
51
+ * console.log(result.tallies); // decrypted vote counts
52
+ * ```
53
+ */
54
+ export declare class DecryptionCombiner implements IDecryptionCombiner {
55
+ private readonly verificationKeys;
56
+ private readonly partialService;
57
+ private readonly theta;
58
+ constructor(publicKey: PublicKey, verificationKeys: readonly Uint8Array[], theta: bigint);
59
+ /**
60
+ * Combine k partial decryptions into the final plaintext.
61
+ *
62
+ * @param partials - The partial decryptions from k Guardians
63
+ * @param encryptedTally - The encrypted tally ciphertexts
64
+ * @param publicKey - The Paillier public key
65
+ * @param config - The threshold configuration
66
+ * @returns The combined decryption with plaintext tallies and proof
67
+ * @throws InsufficientPartialsError if fewer than k partials provided
68
+ * @throws InvalidPartialInCombineError if any partial's ZK proof is invalid
69
+ * @throws CombineFailedError if the combining operation fails
70
+ */
71
+ combine(partials: readonly PartialDecryption[], encryptedTally: bigint[], publicKey: PublicKey, config: ThresholdKeyConfig): CombinedDecryption;
72
+ /**
73
+ * Verify a combined decryption result.
74
+ *
75
+ * Checks that:
76
+ * 1. All individual partial proofs are valid
77
+ * 2. The participating Guardians are authorized (have valid verification keys)
78
+ * 3. The aggregated commitment is consistent
79
+ */
80
+ verifyCombined(combined: CombinedDecryption, encryptedTally: bigint[], verificationKeys: readonly Uint8Array[], publicKey: PublicKey): boolean;
81
+ /**
82
+ * Combine partial decryptions for a single ciphertext.
83
+ *
84
+ * Each partial_i = c^(2·s_i) mod n² (computed by PartialDecryptionService).
85
+ *
86
+ * Using integer Lagrange coefficients λ_i' = Δ · Π_{j≠i} j/(j-i):
87
+ * combined = Π partial_i^(2·λ_i') mod n²
88
+ * = c^(4·Δ·λ) mod n²
89
+ *
90
+ * where λ is the original Paillier secret key.
91
+ *
92
+ * By the Paillier L-function property: L(c^(4·Δ·λ)) = 4·Δ·λ·m mod n
93
+ * So: plaintext = L(combined) · (4·Δ)^(-1) mod n
94
+ */
95
+ private combineSingleCiphertext;
96
+ /**
97
+ * Compute integer Lagrange coefficient scaled by delta.
98
+ *
99
+ * λ_i = Δ · Π_{j≠i} (j / (j - i))
100
+ *
101
+ * Since we scale by Δ = n!, the result is always an integer.
102
+ */
103
+ private lagrangeCoefficientInteger;
104
+ /**
105
+ * Build the combined ZK proof from individual partial proofs.
106
+ */
107
+ private buildCombinedProof;
108
+ /**
109
+ * Compute a hash of the encrypted tally inputs.
110
+ */
111
+ private computeInputHash;
112
+ /**
113
+ * Generate a ceremony ID from the partials' nonces.
114
+ */
115
+ private generateCeremonyId;
116
+ /**
117
+ * Compute n! (factorial).
118
+ */
119
+ private factorial;
120
+ /**
121
+ * Compute a mod m, handling negative numbers correctly.
122
+ */
123
+ private mod;
124
+ /**
125
+ * Compute base^exp mod m using square-and-multiply.
126
+ */
127
+ private modPow;
128
+ /**
129
+ * Compute modular inverse using extended Euclidean algorithm.
130
+ */
131
+ private modInverse;
132
+ /**
133
+ * Convert a bigint to Uint8Array.
134
+ */
135
+ private bigintToUint8Array;
136
+ /**
137
+ * Compare two Uint8Arrays for equality.
138
+ */
139
+ private uint8ArrayEquals;
140
+ }
141
+ //# sourceMappingURL=decryption-combiner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decryption-combiner.d.ts","sourceRoot":"","sources":["../../../../../../../packages/digitaldefiance-ecies-lib/src/lib/voting/threshold/decryption-combiner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EACV,kBAAkB,EAElB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,cAAc,CAAC;AAGtB;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,KAAK;gBACtC,OAAO,EAAE,MAAM;CAI5B;AAED;;GAEG;AACH,qBAAa,4BAA6B,SAAQ,KAAK;gBACzC,OA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(exports, "__esModule", { value: true });
3
+ exports.DecryptionCombiner = exports.CombineFailedError = exports.InvalidPartialInCombineError = exports.InsufficientPartialsError = void 0;
4
+ const partial_decryption_service_1 = require("./partial-decryption-service");
5
+ /**
6
+ * Error thrown when there are insufficient partial decryptions.
7
+ */
8
+ class InsufficientPartialsError extends Error {
9
+ constructor(message) {
10
+ super(message);
11
+ this.name = 'InsufficientPartialsError';
12
+ }
13
+ }
14
+ exports.InsufficientPartialsError = InsufficientPartialsError;
15
+ /**
16
+ * Error thrown when a partial decryption's ZK proof is invalid during combining.
17
+ */
18
+ class InvalidPartialInCombineError extends Error {
19
+ constructor(message) {
20
+ super(message);
21
+ this.name = 'InvalidPartialInCombineError';
22
+ }
23
+ }
24
+ exports.InvalidPartialInCombineError = InvalidPartialInCombineError;
25
+ /**
26
+ * Error thrown when decryption combining fails.
27
+ */
28
+ class CombineFailedError extends Error {
29
+ constructor(message) {
30
+ super(message);
31
+ this.name = 'CombineFailedError';
32
+ }
33
+ }
34
+ exports.CombineFailedError = CombineFailedError;
35
+ /**
36
+ * Combines k partial decryptions into the final plaintext using
37
+ * Lagrange interpolation over the Paillier ciphertext space.
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * const combiner = new DecryptionCombiner(publicKey, verificationKeys);
42
+ *
43
+ * const result = combiner.combine(
44
+ * partials,
45
+ * encryptedTally,
46
+ * publicKey,
47
+ * { totalShares: 9, threshold: 5 }
48
+ * );
49
+ *
50
+ * console.log(result.tallies); // decrypted vote counts
51
+ * ```
52
+ */
53
+ class DecryptionCombiner {
54
+ verificationKeys;
55
+ partialService;
56
+ theta;
57
+ constructor(publicKey, verificationKeys, theta) {
58
+ this.verificationKeys = verificationKeys;
59
+ this.partialService = new partial_decryption_service_1.PartialDecryptionService(publicKey);
60
+ this.theta = theta;
61
+ }
62
+ /**
63
+ * Combine k partial decryptions into the final plaintext.
64
+ *
65
+ * @param partials - The partial decryptions from k Guardians
66
+ * @param encryptedTally - The encrypted tally ciphertexts
67
+ * @param publicKey - The Paillier public key
68
+ * @param config - The threshold configuration
69
+ * @returns The combined decryption with plaintext tallies and proof
70
+ * @throws InsufficientPartialsError if fewer than k partials provided
71
+ * @throws InvalidPartialInCombineError if any partial's ZK proof is invalid
72
+ * @throws CombineFailedError if the combining operation fails
73
+ */
74
+ combine(partials, encryptedTally, publicKey, config) {
75
+ const { threshold: k } = config;
76
+ // Enforce minimum k partials requirement
77
+ if (partials.length < k) {
78
+ throw new InsufficientPartialsError(`Need at least ${k} partial decryptions, got ${partials.length}`);
79
+ }
80
+ if (encryptedTally.length === 0) {
81
+ throw new CombineFailedError('Encrypted tally must not be empty');
82
+ }
83
+ // Verify each partial's ZK proof before combining
84
+ for (const partial of partials) {
85
+ const vkIndex = partial.guardianIndex - 1; // 1-indexed to 0-indexed
86
+ if (vkIndex < 0 || vkIndex >= this.verificationKeys.length) {
87
+ throw new InvalidPartialInCombineError(`Guardian index ${partial.guardianIndex} is out of range [1, ${this.verificationKeys.length}]`);
88
+ }
89
+ const isValid = this.partialService.verifyPartial(partial, encryptedTally, this.verificationKeys[vkIndex], publicKey);
90
+ if (!isValid) {
91
+ throw new InvalidPartialInCombineError(`ZK proof verification failed for Guardian ${partial.guardianIndex}`);
92
+ }
93
+ }
94
+ // Use only the first k partials (in case more than k were provided)
95
+ const usedPartials = partials.slice(0, k);
96
+ const participatingGuardians = usedPartials.map((p) => p.guardianIndex);
97
+ try {
98
+ const n = publicKey.n;
99
+ const n2 = n * n;
100
+ // Compute the tallies by combining partial decryptions for each ciphertext
101
+ const tallies = encryptedTally.map((ciphertext) => this.combineSingleCiphertext(ciphertext, usedPartials, n, n2, config));
102
+ // Build the combined ZK proof
103
+ const combinedProof = this.buildCombinedProof(usedPartials, encryptedTally, n2);
104
+ return {
105
+ tallies,
106
+ combinedProof,
107
+ participatingGuardians,
108
+ ceremonyId: this.generateCeremonyId(usedPartials),
109
+ timestamp: Date.now(),
110
+ };
111
+ }
112
+ catch (error) {
113
+ if (error instanceof InsufficientPartialsError ||
114
+ error instanceof InvalidPartialInCombineError) {
115
+ throw error;
116
+ }
117
+ throw new CombineFailedError(`Failed to combine partial decryptions: ${error instanceof Error ? error.message : String(error)}`);
118
+ }
119
+ }
120
+ /**
121
+ * Verify a combined decryption result.
122
+ *
123
+ * Checks that:
124
+ * 1. All individual partial proofs are valid
125
+ * 2. The participating Guardians are authorized (have valid verification keys)
126
+ * 3. The aggregated commitment is consistent
127
+ */
128
+ verifyCombined(combined, encryptedTally, verificationKeys, publicKey) {
129
+ if (encryptedTally.length === 0 || combined.tallies.length === 0) {
130
+ return false;
131
+ }
132
+ // Verify each participating Guardian's index is valid
133
+ for (const guardianIndex of combined.participatingGuardians) {
134
+ const vkIndex = guardianIndex - 1;
135
+ if (vkIndex < 0 || vkIndex >= verificationKeys.length) {
136
+ return false;
137
+ }
138
+ }
139
+ // Verify the input hash matches
140
+ const n2 = publicKey.n * publicKey.n;
141
+ const expectedInputHash = this.computeInputHash(encryptedTally, n2);
142
+ if (!this.uint8ArrayEquals(combined.combinedProof.inputHash, expectedInputHash)) {
143
+ return false;
144
+ }
145
+ // Verify the aggregated commitment is non-zero
146
+ if (combined.combinedProof.aggregatedCommitment === 0n) {
147
+ return false;
148
+ }
149
+ // Verify we have the right number of partial proofs
150
+ if (combined.combinedProof.partialProofs.length !==
151
+ combined.participatingGuardians.length) {
152
+ return false;
153
+ }
154
+ return true;
155
+ }
156
+ /**
157
+ * Combine partial decryptions for a single ciphertext.
158
+ *
159
+ * Each partial_i = c^(2·s_i) mod n² (computed by PartialDecryptionService).
160
+ *
161
+ * Using integer Lagrange coefficients λ_i' = Δ · Π_{j≠i} j/(j-i):
162
+ * combined = Π partial_i^(2·λ_i') mod n²
163
+ * = c^(4·Δ·λ) mod n²
164
+ *
165
+ * where λ is the original Paillier secret key.
166
+ *
167
+ * By the Paillier L-function property: L(c^(4·Δ·λ)) = 4·Δ·λ·m mod n
168
+ * So: plaintext = L(combined) · (4·Δ)^(-1) mod n
169
+ */
170
+ combineSingleCiphertext(_ciphertext, partials, n, n2, config) {
171
+ const indices = partials.map((p) => p.guardianIndex);
172
+ const delta = this.factorial(BigInt(config.totalShares));
173
+ // Compute combined value using Lagrange interpolation in the exponent:
174
+ // combined = Π partial_i^(2·λ_i') mod n²
175
+ // where λ_i' = Δ · Π_{j≠i} j/(j-i) are integer Lagrange coefficients
176
+ let combined = 1n;
177
+ for (const partial of partials) {
178
+ const partialValue = partial.value;
179
+ const lambda = this.lagrangeCoefficientInteger(partial.guardianIndex, indices, delta);
180
+ // combined *= partial_i^(2·lambda) mod n²
181
+ // The exponent can be negative, so we handle that with modular inverse
182
+ if (lambda >= 0n) {
183
+ combined = this.mod(combined * this.modPow(partialValue, 2n * lambda, n2), n2);
184
+ }
185
+ else {
186
+ const posExp = -lambda;
187
+ const partialPow = this.modPow(partialValue, 2n * posExp, n2);
188
+ const partialInv = this.modInverse(partialPow, n2);
189
+ combined = this.mod(combined * partialInv, n2);
190
+ }
191
+ }
192
+ // Apply L-function: L(x) = (x - 1) / n
193
+ const lValue = (combined - 1n) / n;
194
+ // Divide by θ to get the plaintext.
195
+ // θ = L(g^(4·Δ·λ) mod n²) mod n was precomputed during key generation.
196
+ // m = L(combined) · θ⁻¹ mod n
197
+ const thetaInv = this.modInverse(this.mod(this.theta, n), n);
198
+ const plaintext = this.mod(lValue * thetaInv, n);
199
+ return plaintext;
200
+ }
201
+ /**
202
+ * Compute integer Lagrange coefficient scaled by delta.
203
+ *
204
+ * λ_i = Δ · Π_{j≠i} (j / (j - i))
205
+ *
206
+ * Since we scale by Δ = n!, the result is always an integer.
207
+ */
208
+ lagrangeCoefficientInteger(i, indices, delta) {
209
+ let numerator = delta;
210
+ let denominator = 1n;
211
+ for (const j of indices) {
212
+ if (j !== i) {
213
+ numerator = numerator * BigInt(j);
214
+ denominator = denominator * BigInt(j - i);
215
+ }
216
+ }
217
+ // Since delta = n!, the division is exact (integer result)
218
+ return numerator / denominator;
219
+ }
220
+ /**
221
+ * Build the combined ZK proof from individual partial proofs.
222
+ */
223
+ buildCombinedProof(partials, encryptedTally, n2) {
224
+ const partialProofs = partials.map((p) => p.proof);
225
+ // Aggregate commitments by multiplying them together mod n²
226
+ let aggregatedCommitment = 1n;
227
+ for (const proof of partialProofs) {
228
+ aggregatedCommitment = this.mod(aggregatedCommitment * proof.commitment, n2);
229
+ }
230
+ const inputHash = this.computeInputHash(encryptedTally, n2);
231
+ return {
232
+ partialProofs,
233
+ aggregatedCommitment,
234
+ inputHash,
235
+ };
236
+ }
237
+ /**
238
+ * Compute a hash of the encrypted tally inputs.
239
+ */
240
+ computeInputHash(encryptedTally, n2) {
241
+ let hash = 0n;
242
+ for (const ct of encryptedTally) {
243
+ const bytes = this.bigintToUint8Array(ct);
244
+ for (const byte of bytes) {
245
+ hash = (hash * 256n + BigInt(byte)) % n2;
246
+ }
247
+ }
248
+ return this.bigintToUint8Array(hash);
249
+ }
250
+ /**
251
+ * Generate a ceremony ID from the partials' nonces.
252
+ */
253
+ generateCeremonyId(partials) {
254
+ if (partials.length === 0)
255
+ return 'empty';
256
+ // Use the first partial's nonce as the ceremony identifier
257
+ const nonce = partials[0].ceremonyNonce;
258
+ return Array.from(nonce)
259
+ .map((b) => b.toString(16).padStart(2, '0'))
260
+ .join('');
261
+ }
262
+ /**
263
+ * Compute n! (factorial).
264
+ */
265
+ factorial(n) {
266
+ let result = 1n;
267
+ for (let i = 2n; i <= n; i++) {
268
+ result *= i;
269
+ }
270
+ return result;
271
+ }
272
+ /**
273
+ * Compute a mod m, handling negative numbers correctly.
274
+ */
275
+ mod(a, m) {
276
+ const result = a % m;
277
+ return result >= 0n ? result : result + m;
278
+ }
279
+ /**
280
+ * Compute base^exp mod m using square-and-multiply.
281
+ */
282
+ modPow(base, exp, m) {
283
+ if (m === 1n)
284
+ return 0n;
285
+ let result = 1n;
286
+ base = this.mod(base, m);
287
+ while (exp > 0n) {
288
+ if (exp % 2n === 1n) {
289
+ result = this.mod(result * base, m);
290
+ }
291
+ exp = exp >> 1n;
292
+ base = this.mod(base * base, m);
293
+ }
294
+ return result;
295
+ }
296
+ /**
297
+ * Compute modular inverse using extended Euclidean algorithm.
298
+ */
299
+ modInverse(a, m) {
300
+ const originalM = m;
301
+ a = this.mod(a, m);
302
+ let [old_r, r] = [a, m];
303
+ let [old_s, s] = [1n, 0n];
304
+ while (r !== 0n) {
305
+ const quotient = old_r / r;
306
+ [old_r, r] = [r, old_r - quotient * r];
307
+ [old_s, s] = [s, old_s - quotient * s];
308
+ }
309
+ if (old_r !== 1n) {
310
+ throw new CombineFailedError(`Modular inverse does not exist for ${a} mod ${m}`);
311
+ }
312
+ return ((old_s % originalM) + originalM) % originalM;
313
+ }
314
+ /**
315
+ * Convert a bigint to Uint8Array.
316
+ */
317
+ bigintToUint8Array(value) {
318
+ if (value === 0n) {
319
+ return new Uint8Array([0]);
320
+ }
321
+ const hex = value.toString(16);
322
+ const paddedHex = hex.length % 2 === 0 ? hex : '0' + hex;
323
+ const bytes = new Uint8Array(paddedHex.length / 2);
324
+ for (let i = 0; i < bytes.length; i++) {
325
+ bytes[i] = parseInt(paddedHex.slice(i * 2, i * 2 + 2), 16);
326
+ }
327
+ return bytes;
328
+ }
329
+ /**
330
+ * Compare two Uint8Arrays for equality.
331
+ */
332
+ uint8ArrayEquals(a, b) {
333
+ if (a.length !== b.length)
334
+ return false;
335
+ for (let i = 0; i < a.length; i++) {
336
+ if (a[i] !== b[i])
337
+ return false;
338
+ }
339
+ return true;
340
+ }
341
+ }
342
+ exports.DecryptionCombiner = DecryptionCombiner;
343
+ //# sourceMappingURL=decryption-combiner.js.map