@digitaldefiance/ecies-lib 4.17.1 → 4.17.3

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 (170) hide show
  1. package/README.md +36 -1
  2. package/package.json +1 -1
  3. package/src/i18n-setup.d.ts +7 -1
  4. package/src/i18n-setup.d.ts.map +1 -1
  5. package/src/i18n-setup.js +12 -0
  6. package/src/i18n-setup.js.map +1 -1
  7. package/src/index.d.ts +1 -1
  8. package/src/index.d.ts.map +1 -1
  9. package/src/index.js +2 -1
  10. package/src/index.js.map +1 -1
  11. package/src/lib/voting/index.d.ts +1 -0
  12. package/src/lib/voting/index.d.ts.map +1 -1
  13. package/src/lib/voting/index.js +2 -0
  14. package/src/lib/voting/index.js.map +1 -1
  15. package/src/lib/voting/threshold/decryption-combiner.d.ts +141 -0
  16. package/src/lib/voting/threshold/decryption-combiner.d.ts.map +1 -0
  17. package/src/lib/voting/threshold/decryption-combiner.js +343 -0
  18. package/src/lib/voting/threshold/decryption-combiner.js.map +1 -0
  19. package/src/lib/voting/threshold/enumerations/ceremony-status.d.ts +19 -0
  20. package/src/lib/voting/threshold/enumerations/ceremony-status.d.ts.map +1 -0
  21. package/src/lib/voting/threshold/enumerations/ceremony-status.js +23 -0
  22. package/src/lib/voting/threshold/enumerations/ceremony-status.js.map +1 -0
  23. package/src/lib/voting/threshold/enumerations/guardian-status.d.ts +18 -0
  24. package/src/lib/voting/threshold/enumerations/guardian-status.d.ts.map +1 -0
  25. package/src/lib/voting/threshold/enumerations/guardian-status.js +22 -0
  26. package/src/lib/voting/threshold/enumerations/guardian-status.js.map +1 -0
  27. package/src/lib/voting/threshold/enumerations/index.d.ts +8 -0
  28. package/src/lib/voting/threshold/enumerations/index.d.ts.map +1 -0
  29. package/src/lib/voting/threshold/enumerations/index.js +11 -0
  30. package/src/lib/voting/threshold/enumerations/index.js.map +1 -0
  31. package/src/lib/voting/threshold/enumerations/interval-trigger-type.d.ts +15 -0
  32. package/src/lib/voting/threshold/enumerations/interval-trigger-type.d.ts.map +1 -0
  33. package/src/lib/voting/threshold/enumerations/interval-trigger-type.js +19 -0
  34. package/src/lib/voting/threshold/enumerations/interval-trigger-type.js.map +1 -0
  35. package/src/lib/voting/threshold/enumerations/threshold-audit-event-type.d.ts +29 -0
  36. package/src/lib/voting/threshold/enumerations/threshold-audit-event-type.d.ts.map +1 -0
  37. package/src/lib/voting/threshold/enumerations/threshold-audit-event-type.js +33 -0
  38. package/src/lib/voting/threshold/enumerations/threshold-audit-event-type.js.map +1 -0
  39. package/src/lib/voting/threshold/guardian-registry.d.ts +120 -0
  40. package/src/lib/voting/threshold/guardian-registry.d.ts.map +1 -0
  41. package/src/lib/voting/threshold/guardian-registry.js +227 -0
  42. package/src/lib/voting/threshold/guardian-registry.js.map +1 -0
  43. package/src/lib/voting/threshold/index.d.ts +49 -0
  44. package/src/lib/voting/threshold/index.d.ts.map +1 -0
  45. package/src/lib/voting/threshold/index.js +69 -0
  46. package/src/lib/voting/threshold/index.js.map +1 -0
  47. package/src/lib/voting/threshold/interfaces/ceremony-coordinator.d.ts +19 -0
  48. package/src/lib/voting/threshold/interfaces/ceremony-coordinator.d.ts.map +1 -0
  49. package/src/lib/voting/threshold/interfaces/ceremony-coordinator.js +3 -0
  50. package/src/lib/voting/threshold/interfaces/ceremony-coordinator.js.map +1 -0
  51. package/src/lib/voting/threshold/interfaces/ceremony.d.ts +33 -0
  52. package/src/lib/voting/threshold/interfaces/ceremony.d.ts.map +1 -0
  53. package/src/lib/voting/threshold/interfaces/ceremony.js +3 -0
  54. package/src/lib/voting/threshold/interfaces/ceremony.js.map +1 -0
  55. package/src/lib/voting/threshold/interfaces/combined-decryption.d.ts +20 -0
  56. package/src/lib/voting/threshold/interfaces/combined-decryption.d.ts.map +1 -0
  57. package/src/lib/voting/threshold/interfaces/combined-decryption.js +3 -0
  58. package/src/lib/voting/threshold/interfaces/combined-decryption.js.map +1 -0
  59. package/src/lib/voting/threshold/interfaces/combined-zk-proof.d.ts +16 -0
  60. package/src/lib/voting/threshold/interfaces/combined-zk-proof.d.ts.map +1 -0
  61. package/src/lib/voting/threshold/interfaces/combined-zk-proof.js +3 -0
  62. package/src/lib/voting/threshold/interfaces/combined-zk-proof.js.map +1 -0
  63. package/src/lib/voting/threshold/interfaces/decryption-combiner.d.ts +14 -0
  64. package/src/lib/voting/threshold/interfaces/decryption-combiner.d.ts.map +1 -0
  65. package/src/lib/voting/threshold/interfaces/decryption-combiner.js +3 -0
  66. package/src/lib/voting/threshold/interfaces/decryption-combiner.js.map +1 -0
  67. package/src/lib/voting/threshold/interfaces/guardian-registry.d.ts +28 -0
  68. package/src/lib/voting/threshold/interfaces/guardian-registry.d.ts.map +1 -0
  69. package/src/lib/voting/threshold/interfaces/guardian-registry.js +3 -0
  70. package/src/lib/voting/threshold/interfaces/guardian-registry.js.map +1 -0
  71. package/src/lib/voting/threshold/interfaces/guardian-status-change-event.d.ts +16 -0
  72. package/src/lib/voting/threshold/interfaces/guardian-status-change-event.d.ts.map +1 -0
  73. package/src/lib/voting/threshold/interfaces/guardian-status-change-event.js +3 -0
  74. package/src/lib/voting/threshold/interfaces/guardian-status-change-event.js.map +1 -0
  75. package/src/lib/voting/threshold/interfaces/guardian.d.ts +25 -0
  76. package/src/lib/voting/threshold/interfaces/guardian.d.ts.map +1 -0
  77. package/src/lib/voting/threshold/interfaces/guardian.js +3 -0
  78. package/src/lib/voting/threshold/interfaces/guardian.js.map +1 -0
  79. package/src/lib/voting/threshold/interfaces/index.d.ts +32 -0
  80. package/src/lib/voting/threshold/interfaces/index.d.ts.map +1 -0
  81. package/src/lib/voting/threshold/interfaces/index.js +6 -0
  82. package/src/lib/voting/threshold/interfaces/index.js.map +1 -0
  83. package/src/lib/voting/threshold/interfaces/interval-config.d.ts +17 -0
  84. package/src/lib/voting/threshold/interfaces/interval-config.d.ts.map +1 -0
  85. package/src/lib/voting/threshold/interfaces/interval-config.js +3 -0
  86. package/src/lib/voting/threshold/interfaces/interval-config.js.map +1 -0
  87. package/src/lib/voting/threshold/interfaces/interval-scheduler.d.ts +23 -0
  88. package/src/lib/voting/threshold/interfaces/interval-scheduler.d.ts.map +1 -0
  89. package/src/lib/voting/threshold/interfaces/interval-scheduler.js +3 -0
  90. package/src/lib/voting/threshold/interfaces/interval-scheduler.js.map +1 -0
  91. package/src/lib/voting/threshold/interfaces/interval-tally.d.ts +30 -0
  92. package/src/lib/voting/threshold/interfaces/interval-tally.d.ts.map +1 -0
  93. package/src/lib/voting/threshold/interfaces/interval-tally.js +3 -0
  94. package/src/lib/voting/threshold/interfaces/interval-tally.js.map +1 -0
  95. package/src/lib/voting/threshold/interfaces/interval-trigger-event.d.ts +20 -0
  96. package/src/lib/voting/threshold/interfaces/interval-trigger-event.d.ts.map +1 -0
  97. package/src/lib/voting/threshold/interfaces/interval-trigger-event.js +3 -0
  98. package/src/lib/voting/threshold/interfaces/interval-trigger-event.js.map +1 -0
  99. package/src/lib/voting/threshold/interfaces/key-share.d.ts +15 -0
  100. package/src/lib/voting/threshold/interfaces/key-share.d.ts.map +1 -0
  101. package/src/lib/voting/threshold/interfaces/key-share.js +3 -0
  102. package/src/lib/voting/threshold/interfaces/key-share.js.map +1 -0
  103. package/src/lib/voting/threshold/interfaces/partial-decryption-service.d.ts +17 -0
  104. package/src/lib/voting/threshold/interfaces/partial-decryption-service.d.ts.map +1 -0
  105. package/src/lib/voting/threshold/interfaces/partial-decryption-service.js +3 -0
  106. package/src/lib/voting/threshold/interfaces/partial-decryption-service.js.map +1 -0
  107. package/src/lib/voting/threshold/interfaces/partial-decryption.d.ts +20 -0
  108. package/src/lib/voting/threshold/interfaces/partial-decryption.d.ts.map +1 -0
  109. package/src/lib/voting/threshold/interfaces/partial-decryption.js +3 -0
  110. package/src/lib/voting/threshold/interfaces/partial-decryption.js.map +1 -0
  111. package/src/lib/voting/threshold/interfaces/public-tally-feed.d.ts +19 -0
  112. package/src/lib/voting/threshold/interfaces/public-tally-feed.d.ts.map +1 -0
  113. package/src/lib/voting/threshold/interfaces/public-tally-feed.js +3 -0
  114. package/src/lib/voting/threshold/interfaces/public-tally-feed.js.map +1 -0
  115. package/src/lib/voting/threshold/interfaces/tally-subscription.d.ts +16 -0
  116. package/src/lib/voting/threshold/interfaces/tally-subscription.d.ts.map +1 -0
  117. package/src/lib/voting/threshold/interfaces/tally-subscription.js +3 -0
  118. package/src/lib/voting/threshold/interfaces/tally-subscription.js.map +1 -0
  119. package/src/lib/voting/threshold/interfaces/tally-verifier.d.ts +12 -0
  120. package/src/lib/voting/threshold/interfaces/tally-verifier.d.ts.map +1 -0
  121. package/src/lib/voting/threshold/interfaces/tally-verifier.js +3 -0
  122. package/src/lib/voting/threshold/interfaces/tally-verifier.js.map +1 -0
  123. package/src/lib/voting/threshold/interfaces/threshold-aggregator.d.ts +15 -0
  124. package/src/lib/voting/threshold/interfaces/threshold-aggregator.d.ts.map +1 -0
  125. package/src/lib/voting/threshold/interfaces/threshold-aggregator.js +3 -0
  126. package/src/lib/voting/threshold/interfaces/threshold-aggregator.js.map +1 -0
  127. package/src/lib/voting/threshold/interfaces/threshold-audit-entry.d.ts +28 -0
  128. package/src/lib/voting/threshold/interfaces/threshold-audit-entry.d.ts.map +1 -0
  129. package/src/lib/voting/threshold/interfaces/threshold-audit-entry.js +3 -0
  130. package/src/lib/voting/threshold/interfaces/threshold-audit-entry.js.map +1 -0
  131. package/src/lib/voting/threshold/interfaces/threshold-key-config.d.ts +12 -0
  132. package/src/lib/voting/threshold/interfaces/threshold-key-config.d.ts.map +1 -0
  133. package/src/lib/voting/threshold/interfaces/threshold-key-config.js +3 -0
  134. package/src/lib/voting/threshold/interfaces/threshold-key-config.js.map +1 -0
  135. package/src/lib/voting/threshold/interfaces/threshold-key-generator.d.ts +12 -0
  136. package/src/lib/voting/threshold/interfaces/threshold-key-generator.d.ts.map +1 -0
  137. package/src/lib/voting/threshold/interfaces/threshold-key-generator.js +3 -0
  138. package/src/lib/voting/threshold/interfaces/threshold-key-generator.js.map +1 -0
  139. package/src/lib/voting/threshold/interfaces/threshold-key-pair.d.ts +30 -0
  140. package/src/lib/voting/threshold/interfaces/threshold-key-pair.d.ts.map +1 -0
  141. package/src/lib/voting/threshold/interfaces/threshold-key-pair.js +3 -0
  142. package/src/lib/voting/threshold/interfaces/threshold-key-pair.js.map +1 -0
  143. package/src/lib/voting/threshold/interfaces/threshold-poll-config.d.ts +19 -0
  144. package/src/lib/voting/threshold/interfaces/threshold-poll-config.d.ts.map +1 -0
  145. package/src/lib/voting/threshold/interfaces/threshold-poll-config.js +3 -0
  146. package/src/lib/voting/threshold/interfaces/threshold-poll-config.js.map +1 -0
  147. package/src/lib/voting/threshold/interfaces/threshold-poll-factory.d.ts +16 -0
  148. package/src/lib/voting/threshold/interfaces/threshold-poll-factory.d.ts.map +1 -0
  149. package/src/lib/voting/threshold/interfaces/threshold-poll-factory.js +3 -0
  150. package/src/lib/voting/threshold/interfaces/threshold-poll-factory.js.map +1 -0
  151. package/src/lib/voting/threshold/interfaces/threshold-poll.d.ts +25 -0
  152. package/src/lib/voting/threshold/interfaces/threshold-poll.d.ts.map +1 -0
  153. package/src/lib/voting/threshold/interfaces/threshold-poll.js +3 -0
  154. package/src/lib/voting/threshold/interfaces/threshold-poll.js.map +1 -0
  155. package/src/lib/voting/threshold/interfaces/verification-result.d.ts +17 -0
  156. package/src/lib/voting/threshold/interfaces/verification-result.d.ts.map +1 -0
  157. package/src/lib/voting/threshold/interfaces/verification-result.js +3 -0
  158. package/src/lib/voting/threshold/interfaces/verification-result.js.map +1 -0
  159. package/src/lib/voting/threshold/interfaces/zk-proof.d.ts +15 -0
  160. package/src/lib/voting/threshold/interfaces/zk-proof.d.ts.map +1 -0
  161. package/src/lib/voting/threshold/interfaces/zk-proof.js +3 -0
  162. package/src/lib/voting/threshold/interfaces/zk-proof.js.map +1 -0
  163. package/src/lib/voting/threshold/partial-decryption-service.d.ts +130 -0
  164. package/src/lib/voting/threshold/partial-decryption-service.d.ts.map +1 -0
  165. package/src/lib/voting/threshold/partial-decryption-service.js +288 -0
  166. package/src/lib/voting/threshold/partial-decryption-service.js.map +1 -0
  167. package/src/lib/voting/threshold/threshold-key-generator.d.ts +114 -0
  168. package/src/lib/voting/threshold/threshold-key-generator.d.ts.map +1 -0
  169. package/src/lib/voting/threshold/threshold-key-generator.js +275 -0
  170. package/src/lib/voting/threshold/threshold-key-generator.js.map +1 -0
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Guardian Registry
3
+ *
4
+ * Manages Guardian registration, status tracking, and backup designation
5
+ * for threshold voting. Guardians are trusted key holders who possess
6
+ * shares of the threshold decryption key.
7
+ *
8
+ * @module voting/threshold
9
+ */
10
+ import type { PlatformID } from '../../../interfaces/platform-id';
11
+ import { GuardianStatus } from './enumerations/guardian-status';
12
+ import type { Guardian } from './interfaces/guardian';
13
+ import type { GuardianStatusChangeEvent } from './interfaces/guardian-status-change-event';
14
+ import type { IGuardianRegistry } from './interfaces/guardian-registry';
15
+ /**
16
+ * Error thrown when attempting to register a Guardian with a duplicate ID.
17
+ */
18
+ export declare class GuardianAlreadyRegisteredError extends Error {
19
+ constructor(message: string);
20
+ }
21
+ /**
22
+ * Error thrown when a Guardian is not found.
23
+ */
24
+ export declare class GuardianNotFoundError extends Error {
25
+ constructor(message: string);
26
+ }
27
+ /**
28
+ * Error thrown when a share index is invalid or already taken.
29
+ */
30
+ export declare class InvalidShareIndexError extends Error {
31
+ constructor(message: string);
32
+ }
33
+ /**
34
+ * Error thrown when the registry is full (n Guardians already registered).
35
+ */
36
+ export declare class RegistryFullError extends Error {
37
+ constructor(message: string);
38
+ }
39
+ /**
40
+ * Registry for managing Guardians in a threshold voting system.
41
+ *
42
+ * Enforces that:
43
+ * - Total registered Guardians equals n (totalShares)
44
+ * - Each Guardian has a unique ID and share index in [1, n]
45
+ * - Status changes emit events for monitoring
46
+ * - Backup Guardians can be designated for unavailable Guardians
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * const registry = new GuardianRegistry(5); // 5 total shares
51
+ * registry.register({
52
+ * id: new Uint8Array([1]),
53
+ * name: 'Guardian 1',
54
+ * shareIndex: 1,
55
+ * verificationKey: vk1,
56
+ * status: GuardianStatus.Registered,
57
+ * });
58
+ * ```
59
+ */
60
+ export declare class GuardianRegistry<TID extends PlatformID = Uint8Array> implements IGuardianRegistry<TID> {
61
+ private readonly _guardians;
62
+ private readonly _indexMap;
63
+ private readonly _statusListeners;
64
+ private readonly _totalShares;
65
+ /**
66
+ * Create a new GuardianRegistry.
67
+ * @param totalShares The total number of key shares (n). The registry
68
+ * enforces that exactly n Guardians can be registered.
69
+ */
70
+ constructor(totalShares: number);
71
+ /** Total number of shares this registry manages */
72
+ get totalShares(): number;
73
+ /** Number of currently registered Guardians */
74
+ get count(): number;
75
+ /**
76
+ * Register a new Guardian.
77
+ *
78
+ * Validates:
79
+ * - Registry is not full (count < n)
80
+ * - Guardian ID is unique
81
+ * - Share index is in range [1, n] and not already taken
82
+ */
83
+ register(guardian: Guardian<TID>): void;
84
+ /**
85
+ * Get a Guardian by ID.
86
+ */
87
+ getGuardian(id: TID): Guardian<TID> | undefined;
88
+ /**
89
+ * Get a Guardian by share index.
90
+ */
91
+ getGuardianByIndex(index: number): Guardian<TID> | undefined;
92
+ /**
93
+ * Get all registered Guardians.
94
+ */
95
+ getAllGuardians(): readonly Guardian<TID>[];
96
+ /**
97
+ * Get all Guardians with Online status.
98
+ */
99
+ getOnlineGuardians(): readonly Guardian<TID>[];
100
+ /**
101
+ * Update a Guardian's status and emit a status change event.
102
+ *
103
+ * @throws GuardianNotFoundError if the Guardian is not registered
104
+ */
105
+ updateStatus(id: TID, status: GuardianStatus): void;
106
+ /**
107
+ * Designate a backup Guardian for a primary Guardian.
108
+ *
109
+ * The backup Guardian must already be registered. This creates a
110
+ * one-way link from the primary to the backup.
111
+ *
112
+ * @throws GuardianNotFoundError if either Guardian is not registered
113
+ */
114
+ designateBackup(guardianId: TID, backupId: TID): void;
115
+ /**
116
+ * Subscribe to Guardian status change events.
117
+ */
118
+ onStatusChange(callback: (event: GuardianStatusChangeEvent<TID>) => void): void;
119
+ }
120
+ //# sourceMappingURL=guardian-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guardian-registry.d.ts","sourceRoot":"","sources":["../../../../../../../packages/digitaldefiance-ecies-lib/src/lib/voting/threshold/guardian-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AAC3F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAExE;;GAEG;AACH,qBAAa,8BAA+B,SAAQ,KAAK;gBAC3C,OAAO,EAAE,MAAM;CAI5B;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,OAAO,EAAE,MAAM;CAI5B;AAED;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,OAAO,EAAE,MAAM;CAI5B;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;gBAC9B,OAAO,EAAE,MAAM;CAI5B;AAeD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,gBAAgB,CAAC,GAAG,SAAS,UAAU,GAAG,UAAU,CAC/D,YAAW,iBAAiB,CAAC,GAAG,CAAC;IAEjC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAyC;IACpE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkC;IAC5D,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAE1B;IACP,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IAEtC;;;;OAIG;gBACS,WAAW,EAAE,MAAM;IAS/B,mDAAmD;IACnD,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,+CAA+C;IAC/C,IAAI,KAAK,IAAI,MAAM,CAElB;IAED;;;;;;;OAOG;IACH,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI;IAqCvC;;OAEG;IACH,WAAW,CAAC,EAAE,EAAE,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,SAAS;IAI/C;;OAEG;IACH,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,SAAS;IAM5D;;OAEG;IACH,eAAe,IAAI,SAAS,QAAQ,CAAC,GAAG,CAAC,EAAE;IAI3C;;OAEG;IACH,kBAAkB,IAAI,SAAS,QAAQ,CAAC,GAAG,CAAC,EAAE;IAM9C;;;;OAIG;IACH,YAAY,CAAC,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI;IA0BnD;;;;;;;OAOG;IACH,eAAe,CAAC,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,GAAG,IAAI;IA2BrD;;OAEG;IACH,cAAc,CACZ,QAAQ,EAAE,CAAC,KAAK,EAAE,yBAAyB,CAAC,GAAG,CAAC,KAAK,IAAI,GACxD,IAAI;CAGR"}
@@ -0,0 +1,227 @@
1
+ "use strict";
2
+ /**
3
+ * Guardian Registry
4
+ *
5
+ * Manages Guardian registration, status tracking, and backup designation
6
+ * for threshold voting. Guardians are trusted key holders who possess
7
+ * shares of the threshold decryption key.
8
+ *
9
+ * @module voting/threshold
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.GuardianRegistry = exports.RegistryFullError = exports.InvalidShareIndexError = exports.GuardianNotFoundError = exports.GuardianAlreadyRegisteredError = void 0;
13
+ const guardian_status_1 = require("./enumerations/guardian-status");
14
+ /**
15
+ * Error thrown when attempting to register a Guardian with a duplicate ID.
16
+ */
17
+ class GuardianAlreadyRegisteredError extends Error {
18
+ constructor(message) {
19
+ super(message);
20
+ this.name = 'GuardianAlreadyRegisteredError';
21
+ }
22
+ }
23
+ exports.GuardianAlreadyRegisteredError = GuardianAlreadyRegisteredError;
24
+ /**
25
+ * Error thrown when a Guardian is not found.
26
+ */
27
+ class GuardianNotFoundError extends Error {
28
+ constructor(message) {
29
+ super(message);
30
+ this.name = 'GuardianNotFoundError';
31
+ }
32
+ }
33
+ exports.GuardianNotFoundError = GuardianNotFoundError;
34
+ /**
35
+ * Error thrown when a share index is invalid or already taken.
36
+ */
37
+ class InvalidShareIndexError extends Error {
38
+ constructor(message) {
39
+ super(message);
40
+ this.name = 'InvalidShareIndexError';
41
+ }
42
+ }
43
+ exports.InvalidShareIndexError = InvalidShareIndexError;
44
+ /**
45
+ * Error thrown when the registry is full (n Guardians already registered).
46
+ */
47
+ class RegistryFullError extends Error {
48
+ constructor(message) {
49
+ super(message);
50
+ this.name = 'RegistryFullError';
51
+ }
52
+ }
53
+ exports.RegistryFullError = RegistryFullError;
54
+ /**
55
+ * Converts a PlatformID to a string key for Map lookups.
56
+ * Handles Uint8Array (hex encoding), string, and objects with toString().
57
+ */
58
+ function toKey(id) {
59
+ if (id instanceof Uint8Array) {
60
+ return Array.from(id)
61
+ .map((b) => b.toString(16).padStart(2, '0'))
62
+ .join('');
63
+ }
64
+ return String(id);
65
+ }
66
+ /**
67
+ * Registry for managing Guardians in a threshold voting system.
68
+ *
69
+ * Enforces that:
70
+ * - Total registered Guardians equals n (totalShares)
71
+ * - Each Guardian has a unique ID and share index in [1, n]
72
+ * - Status changes emit events for monitoring
73
+ * - Backup Guardians can be designated for unavailable Guardians
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * const registry = new GuardianRegistry(5); // 5 total shares
78
+ * registry.register({
79
+ * id: new Uint8Array([1]),
80
+ * name: 'Guardian 1',
81
+ * shareIndex: 1,
82
+ * verificationKey: vk1,
83
+ * status: GuardianStatus.Registered,
84
+ * });
85
+ * ```
86
+ */
87
+ class GuardianRegistry {
88
+ _guardians = new Map();
89
+ _indexMap = new Map();
90
+ _statusListeners = [];
91
+ _totalShares;
92
+ /**
93
+ * Create a new GuardianRegistry.
94
+ * @param totalShares The total number of key shares (n). The registry
95
+ * enforces that exactly n Guardians can be registered.
96
+ */
97
+ constructor(totalShares) {
98
+ if (totalShares < 2 || !Number.isInteger(totalShares)) {
99
+ throw new Error(`totalShares must be an integer >= 2, got ${totalShares}`);
100
+ }
101
+ this._totalShares = totalShares;
102
+ }
103
+ /** Total number of shares this registry manages */
104
+ get totalShares() {
105
+ return this._totalShares;
106
+ }
107
+ /** Number of currently registered Guardians */
108
+ get count() {
109
+ return this._guardians.size;
110
+ }
111
+ /**
112
+ * Register a new Guardian.
113
+ *
114
+ * Validates:
115
+ * - Registry is not full (count < n)
116
+ * - Guardian ID is unique
117
+ * - Share index is in range [1, n] and not already taken
118
+ */
119
+ register(guardian) {
120
+ const key = toKey(guardian.id);
121
+ if (this._guardians.size >= this._totalShares) {
122
+ throw new RegistryFullError(`Registry is full: ${this._guardians.size}/${this._totalShares} Guardians registered`);
123
+ }
124
+ if (this._guardians.has(key)) {
125
+ throw new GuardianAlreadyRegisteredError(`Guardian with ID '${key}' is already registered`);
126
+ }
127
+ if (guardian.shareIndex < 1 ||
128
+ guardian.shareIndex > this._totalShares ||
129
+ !Number.isInteger(guardian.shareIndex)) {
130
+ throw new InvalidShareIndexError(`Share index must be an integer in [1, ${this._totalShares}], got ${guardian.shareIndex}`);
131
+ }
132
+ if (this._indexMap.has(guardian.shareIndex)) {
133
+ throw new InvalidShareIndexError(`Share index ${guardian.shareIndex} is already assigned to another Guardian`);
134
+ }
135
+ // Store a shallow copy to avoid external mutation of internal state
136
+ const stored = { ...guardian };
137
+ this._guardians.set(key, stored);
138
+ this._indexMap.set(guardian.shareIndex, key);
139
+ }
140
+ /**
141
+ * Get a Guardian by ID.
142
+ */
143
+ getGuardian(id) {
144
+ return this._guardians.get(toKey(id));
145
+ }
146
+ /**
147
+ * Get a Guardian by share index.
148
+ */
149
+ getGuardianByIndex(index) {
150
+ const key = this._indexMap.get(index);
151
+ if (key === undefined)
152
+ return undefined;
153
+ return this._guardians.get(key);
154
+ }
155
+ /**
156
+ * Get all registered Guardians.
157
+ */
158
+ getAllGuardians() {
159
+ return Array.from(this._guardians.values());
160
+ }
161
+ /**
162
+ * Get all Guardians with Online status.
163
+ */
164
+ getOnlineGuardians() {
165
+ return Array.from(this._guardians.values()).filter((g) => g.status === guardian_status_1.GuardianStatus.Online);
166
+ }
167
+ /**
168
+ * Update a Guardian's status and emit a status change event.
169
+ *
170
+ * @throws GuardianNotFoundError if the Guardian is not registered
171
+ */
172
+ updateStatus(id, status) {
173
+ const key = toKey(id);
174
+ const guardian = this._guardians.get(key);
175
+ if (!guardian) {
176
+ throw new GuardianNotFoundError(`Guardian with ID '${key}' is not registered`);
177
+ }
178
+ const previousStatus = guardian.status;
179
+ if (previousStatus === status)
180
+ return;
181
+ guardian.status = status;
182
+ const event = {
183
+ guardianId: guardian.id,
184
+ previousStatus,
185
+ newStatus: status,
186
+ timestamp: Date.now(),
187
+ };
188
+ for (const listener of this._statusListeners) {
189
+ listener(event);
190
+ }
191
+ }
192
+ /**
193
+ * Designate a backup Guardian for a primary Guardian.
194
+ *
195
+ * The backup Guardian must already be registered. This creates a
196
+ * one-way link from the primary to the backup.
197
+ *
198
+ * @throws GuardianNotFoundError if either Guardian is not registered
199
+ */
200
+ designateBackup(guardianId, backupId) {
201
+ const primaryKey = toKey(guardianId);
202
+ const backupKey = toKey(backupId);
203
+ const primary = this._guardians.get(primaryKey);
204
+ if (!primary) {
205
+ throw new GuardianNotFoundError(`Primary Guardian with ID '${primaryKey}' is not registered`);
206
+ }
207
+ const backup = this._guardians.get(backupKey);
208
+ if (!backup) {
209
+ throw new GuardianNotFoundError(`Backup Guardian with ID '${backupKey}' is not registered`);
210
+ }
211
+ // Replace the guardian entry with updated backupGuardianId
212
+ // Using object spread to create a new object with the readonly property set
213
+ const updated = {
214
+ ...primary,
215
+ backupGuardianId: backupId,
216
+ };
217
+ this._guardians.set(primaryKey, updated);
218
+ }
219
+ /**
220
+ * Subscribe to Guardian status change events.
221
+ */
222
+ onStatusChange(callback) {
223
+ this._statusListeners.push(callback);
224
+ }
225
+ }
226
+ exports.GuardianRegistry = GuardianRegistry;
227
+ //# sourceMappingURL=guardian-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guardian-registry.js","sourceRoot":"","sources":["../../../../../../../packages/digitaldefiance-ecies-lib/src/lib/voting/threshold/guardian-registry.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAGH,oEAAgE;AAKhE;;GAEG;AACH,MAAa,8BAA+B,SAAQ,KAAK;IACvD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gCAAgC,CAAC;IAC/C,CAAC;CACF;AALD,wEAKC;AAED;;GAEG;AACH,MAAa,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AALD,sDAKC;AAED;;GAEG;AACH,MAAa,sBAAuB,SAAQ,KAAK;IAC/C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AALD,wDAKC;AAED;;GAEG;AACH,MAAa,iBAAkB,SAAQ,KAAK;IAC1C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AALD,8CAKC;AAED;;;GAGG;AACH,SAAS,KAAK,CAAyB,EAAO;IAC5C,IAAI,EAAE,YAAY,UAAU,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;aAClB,GAAG,C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,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,qBAAqB,CAC7B,6BAA6B,UAAU,qBAAqB,CAC7D,CAAC;QACJ,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC9C,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,qBAAqB,CAC7B,4BAA4B,SAAS,qBAAqB,CAC3D,CAAC;QACJ,CAAC;QAED,2DAA2D;QAC3D,4EAA4E;QAC5E,MAAM,OAAO,GAAkB;YAC7B,GAAG,OAAO;YACV,gBAAgB,EAAE,QAAQ;SAC3B,CAAC;QACF,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,cAAc,CACZ,QAAyD;QAEzD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;CACF;AAzLD,4CAyLC"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Threshold Voting Module
3
+ *
4
+ * Implements Real-Time Threshold Voting for secure, distributed vote tallying.
5
+ * Based on Damgård et al.'s "Generalization of Paillier's Public-Key System
6
+ * with Applications to Electronic Voting."
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
+ *
15
+ * @example
16
+ * ```typescript
17
+ * import {
18
+ * ThresholdKeyGenerator,
19
+ * GuardianRegistry,
20
+ * CeremonyCoordinator,
21
+ * GuardianStatus,
22
+ * } from './voting/threshold';
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
+ export { ThresholdKeyGenerator, InvalidThresholdConfigError, KeyGenerationFailedError, } from './threshold-key-generator';
46
+ export { PartialDecryptionService, InvalidPartialProofError, DeserializationError, } from './partial-decryption-service';
47
+ export { DecryptionCombiner, InsufficientPartialsError, InvalidPartialInCombineError, CombineFailedError, } from './decryption-combiner';
48
+ export { GuardianRegistry, GuardianAlreadyRegisteredError, GuardianNotFoundError, InvalidShareIndexError, RegistryFullError, } from './guardian-registry';
49
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../packages/digitaldefiance-ecies-lib/src/lib/voting/threshold/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAGH,cAAc,gBAAgB,CAAC;AAG/B,mBAAmB,cAAc,CAAC;AAGlC,OAAO,EACL,qBAAqB,EACrB,2BAA2B,EAC3B,wBAAwB,GACzB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACL,kBAAkB,EAClB,yBAAyB,EACzB,4BAA4B,EAC5B,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,gBAAgB,EAChB,8BAA8B,EAC9B,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ /**
3
+ * Threshold Voting Module
4
+ *
5
+ * Implements Real-Time Threshold Voting for secure, distributed vote tallying.
6
+ * Based on Damgård et al.'s "Generalization of Paillier's Public-Key System
7
+ * with Applications to Electronic Voting."
8
+ *
9
+ * Key features:
10
+ * - Threshold Paillier cryptography (k-of-n Guardians required for decryption)
11
+ * - Real-time interval decryption during voting
12
+ * - Zero-knowledge proofs for all decryption operations
13
+ * - Integration with hierarchical aggregation (Precinct → County → State → National)
14
+ * - Backward compatible with single-authority polls
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import {
19
+ * ThresholdKeyGenerator,
20
+ * GuardianRegistry,
21
+ * CeremonyCoordinator,
22
+ * GuardianStatus,
23
+ * } from './voting/threshold';
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
+ exports.RegistryFullError = exports.InvalidShareIndexError = exports.GuardianNotFoundError = exports.GuardianAlreadyRegisteredError = exports.GuardianRegistry = exports.CombineFailedError = exports.InvalidPartialInCombineError = exports.InsufficientPartialsError = exports.DecryptionCombiner = exports.DeserializationError = exports.InvalidPartialProofError = exports.PartialDecryptionService = exports.KeyGenerationFailedError = exports.InvalidThresholdConfigError = exports.ThresholdKeyGenerator = void 0;
46
+ const tslib_1 = require("tslib");
47
+ // Re-export enumerations
48
+ tslib_1.__exportStar(require("./enumerations"), exports);
49
+ // Re-export classes
50
+ var threshold_key_generator_1 = require("./threshold-key-generator");
51
+ Object.defineProperty(exports, "ThresholdKeyGenerator", { enumerable: true, get: function () { return threshold_key_generator_1.ThresholdKeyGenerator; } });
52
+ Object.defineProperty(exports, "InvalidThresholdConfigError", { enumerable: true, get: function () { return threshold_key_generator_1.InvalidThresholdConfigError; } });
53
+ Object.defineProperty(exports, "KeyGenerationFailedError", { enumerable: true, get: function () { return threshold_key_generator_1.KeyGenerationFailedError; } });
54
+ var partial_decryption_service_1 = require("./partial-decryption-service");
55
+ Object.defineProperty(exports, "PartialDecryptionService", { enumerable: true, get: function () { return partial_decryption_service_1.PartialDecryptionService; } });
56
+ Object.defineProperty(exports, "InvalidPartialProofError", { enumerable: true, get: function () { return partial_decryption_service_1.InvalidPartialProofError; } });
57
+ Object.defineProperty(exports, "DeserializationError", { enumerable: true, get: function () { return partial_decryption_service_1.DeserializationError; } });
58
+ var decryption_combiner_1 = require("./decryption-combiner");
59
+ Object.defineProperty(exports, "DecryptionCombiner", { enumerable: true, get: function () { return decryption_combiner_1.DecryptionCombiner; } });
60
+ Object.defineProperty(exports, "InsufficientPartialsError", { enumerable: true, get: function () { return decryption_combiner_1.InsufficientPartialsError; } });
61
+ Object.defineProperty(exports, "InvalidPartialInCombineError", { enumerable: true, get: function () { return decryption_combiner_1.InvalidPartialInCombineError; } });
62
+ Object.defineProperty(exports, "CombineFailedError", { enumerable: true, get: function () { return decryption_combiner_1.CombineFailedError; } });
63
+ var guardian_registry_1 = require("./guardian-registry");
64
+ Object.defineProperty(exports, "GuardianRegistry", { enumerable: true, get: function () { return guardian_registry_1.GuardianRegistry; } });
65
+ Object.defineProperty(exports, "GuardianAlreadyRegisteredError", { enumerable: true, get: function () { return guardian_registry_1.GuardianAlreadyRegisteredError; } });
66
+ Object.defineProperty(exports, "GuardianNotFoundError", { enumerable: true, get: function () { return guardian_registry_1.GuardianNotFoundError; } });
67
+ Object.defineProperty(exports, "InvalidShareIndexError", { enumerable: true, get: function () { return guardian_registry_1.InvalidShareIndexError; } });
68
+ Object.defineProperty(exports, "RegistryFullError", { enumerable: true, get: function () { return guardian_registry_1.RegistryFullError; } });
69
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/digitaldefiance-ecies-lib/src/lib/voting/threshold/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;;;;AAEH,yBAAyB;AACzB,yDAA+B;AAK/B,oBAAoB;AACpB,qEAImC;AAHjC,gIAAA,qBAAqB,OAAA;AACrB,sIAAA,2BAA2B,OAAA;AAC3B,mIAAA,wBAAwB,OAAA;AAG1B,2EAIsC;AAHpC,sIAAA,wBAAwB,OAAA;AACxB,sIAAA,wBAAwB,OAAA;AACxB,kIAAA,oBAAoB,OAAA;AAGtB,6DAK+B;AAJ7B,yHAAA,kBAAkB,OAAA;AAClB,gIAAA,yBAAyB,OAAA;AACzB,mIAAA,4BAA4B,OAAA;AAC5B,yHAAA,kBAAkB,OAAA;AAGpB,yDAM6B;AAL3B,qHAAA,gBAAgB,OAAA;AAChB,mIAAA,8BAA8B,OAAA;AAC9B,0HAAA,qBAAqB,OAAA;AACrB,2HAAA,sBAAsB,OAAA;AACtB,sHAAA,iBAAiB,OAAA"}
@@ -0,0 +1,19 @@
1
+ import type { PlatformID } from '../../../../interfaces/platform-id';
2
+ import type { Ceremony } from './ceremony';
3
+ import type { PartialDecryption } from './partial-decryption';
4
+ /**
5
+ * Interface for coordinating decryption ceremonies.
6
+ */
7
+ export interface ICeremonyCoordinator<TID extends PlatformID = Uint8Array> {
8
+ /** Start a new decryption ceremony */
9
+ startCeremony(pollId: TID, intervalNumber: number, encryptedTally: bigint[]): Ceremony<TID>;
10
+ /** Submit a partial decryption */
11
+ submitPartial(ceremonyId: string, partial: PartialDecryption): boolean;
12
+ /** Get ceremony by ID */
13
+ getCeremony(ceremonyId: string): Ceremony<TID> | undefined;
14
+ /** Get ceremonies for a poll */
15
+ getCeremoniesForPoll(pollId: TID): readonly Ceremony<TID>[];
16
+ /** Subscribe to ceremony completion events */
17
+ onCeremonyComplete(callback: (ceremony: Ceremony<TID>) => void): void;
18
+ }
19
+ //# sourceMappingURL=ceremony-coordinator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ceremony-coordinator.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/digitaldefiance-ecies-lib/src/lib/voting/threshold/interfaces/ceremony-coordinator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,oBAAoB,CAAC,GAAG,SAAS,UAAU,GAAG,UAAU;IACvE,sCAAsC;IACtC,aAAa,CACX,MAAM,EAAE,GAAG,EACX,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,MAAM,EAAE,GACvB,QAAQ,CAAC,GAAG,CAAC,CAAC;IAEjB,kCAAkC;IAClC,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC;IAEvE,yBAAyB;IACzB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IAE3D,gCAAgC;IAChC,oBAAoB,CAAC,MAAM,EAAE,GAAG,GAAG,SAAS,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;IAE5D,8CAA8C;IAC9C,kBAAkB,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,IAAI,CAAC;CACvE"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ceremony-coordinator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ceremony-coordinator.js","sourceRoot":"","sources":["../../../../../../../../packages/digitaldefiance-ecies-lib/src/lib/voting/threshold/interfaces/ceremony-coordinator.ts"],"names":[],"mappings":""}
@@ -0,0 +1,33 @@
1
+ import type { PlatformID } from '../../../../interfaces/platform-id';
2
+ import type { CeremonyStatus } from '../enumerations/ceremony-status';
3
+ import type { CombinedDecryption } from './combined-decryption';
4
+ import type { PartialDecryption } from './partial-decryption';
5
+ /**
6
+ * A threshold decryption ceremony.
7
+ *
8
+ * Coordinates the collection of partial decryptions from Guardians
9
+ * to reveal an aggregate tally.
10
+ */
11
+ export interface Ceremony<TID extends PlatformID = Uint8Array> {
12
+ /** Unique ceremony identifier */
13
+ readonly id: string;
14
+ /** Associated poll ID */
15
+ readonly pollId: TID;
16
+ /** Interval number */
17
+ readonly intervalNumber: number;
18
+ /** Ceremony-specific nonce */
19
+ readonly nonce: Uint8Array;
20
+ /** Encrypted tally to decrypt */
21
+ readonly encryptedTally: bigint[];
22
+ /** Current status */
23
+ status: CeremonyStatus;
24
+ /** Collected partial decryptions (keyed by Guardian index) */
25
+ readonly partials: Map<number, PartialDecryption>;
26
+ /** Start timestamp */
27
+ readonly startedAt: number;
28
+ /** Completion timestamp */
29
+ completedAt?: number;
30
+ /** Result (if completed) */
31
+ result?: CombinedDecryption;
32
+ }
33
+ //# sourceMappingURL=ceremony.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ceremony.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/digitaldefiance-ecies-lib/src/lib/voting/threshold/interfaces/ceremony.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,WAAW,QAAQ,CAAC,GAAG,SAAS,UAAU,GAAG,UAAU;IAC3D,iCAAiC;IACjC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,yBAAyB;IACzB,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC;IACrB,sBAAsB;IACtB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,8BAA8B;IAC9B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,iCAAiC;IACjC,QAAQ,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC;IAClC,qBAAqB;IACrB,MAAM,EAAE,cAAc,CAAC;IACvB,8DAA8D;IAC9D,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAClD,sBAAsB;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,2BAA2B;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4BAA4B;IAC5B,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC7B"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ceremony.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ceremony.js","sourceRoot":"","sources":["../../../../../../../../packages/digitaldefiance-ecies-lib/src/lib/voting/threshold/interfaces/ceremony.ts"],"names":[],"mappings":""}
@@ -0,0 +1,20 @@
1
+ import type { CombinedZKProof } from './combined-zk-proof';
2
+ /**
3
+ * Result of combining k partial decryptions.
4
+ *
5
+ * Contains the decrypted plaintext tallies along with proof
6
+ * that the decryption was performed correctly.
7
+ */
8
+ export interface CombinedDecryption {
9
+ /** The decrypted plaintext tallies */
10
+ readonly tallies: bigint[];
11
+ /** Combined proof of correct decryption */
12
+ readonly combinedProof: CombinedZKProof;
13
+ /** Indices of participating Guardians */
14
+ readonly participatingGuardians: readonly number[];
15
+ /** Ceremony identifier */
16
+ readonly ceremonyId: string;
17
+ /** Timestamp of combination */
18
+ readonly timestamp: number;
19
+ }
20
+ //# sourceMappingURL=combined-decryption.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"combined-decryption.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/digitaldefiance-ecies-lib/src/lib/voting/threshold/interfaces/combined-decryption.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,sCAAsC;IACtC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAC3B,2CAA2C;IAC3C,QAAQ,CAAC,aAAa,EAAE,eAAe,CAAC;IACxC,yCAAyC;IACzC,QAAQ,CAAC,sBAAsB,EAAE,SAAS,MAAM,EAAE,CAAC;IACnD,0BAA0B;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,+BAA+B;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=combined-decryption.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"combined-decryption.js","sourceRoot":"","sources":["../../../../../../../../packages/digitaldefiance-ecies-lib/src/lib/voting/threshold/interfaces/combined-decryption.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ import type { ZKProof } from './zk-proof';
2
+ /**
3
+ * Combined zero-knowledge proof from multiple Guardians.
4
+ *
5
+ * Aggregates individual proofs to demonstrate that the combined
6
+ * decryption was performed correctly by authorized Guardians.
7
+ */
8
+ export interface CombinedZKProof {
9
+ /** Individual proofs from each Guardian */
10
+ readonly partialProofs: readonly ZKProof[];
11
+ /** Aggregated verification data */
12
+ readonly aggregatedCommitment: bigint;
13
+ /** Hash of all inputs */
14
+ readonly inputHash: Uint8Array;
15
+ }
16
+ //# sourceMappingURL=combined-zk-proof.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"combined-zk-proof.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/digitaldefiance-ecies-lib/src/lib/voting/threshold/interfaces/combined-zk-proof.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,2CAA2C;IAC3C,QAAQ,CAAC,aAAa,EAAE,SAAS,OAAO,EAAE,CAAC;IAC3C,mCAAmC;IACnC,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC,yBAAyB;IACzB,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;CAChC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=combined-zk-proof.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"combined-zk-proof.js","sourceRoot":"","sources":["../../../../../../../../packages/digitaldefiance-ecies-lib/src/lib/voting/threshold/interfaces/combined-zk-proof.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import type { PublicKey } from 'paillier-bigint';
2
+ import type { CombinedDecryption } from './combined-decryption';
3
+ import type { PartialDecryption } from './partial-decryption';
4
+ import type { ThresholdKeyConfig } from './threshold-key-config';
5
+ /**
6
+ * Interface for combining partial decryptions.
7
+ */
8
+ export interface IDecryptionCombiner {
9
+ /** Combine k partial decryptions into final plaintext */
10
+ combine(partials: readonly PartialDecryption[], encryptedTally: bigint[], publicKey: PublicKey, config: ThresholdKeyConfig): CombinedDecryption;
11
+ /** Verify a combined decryption */
12
+ verifyCombined(combined: CombinedDecryption, encryptedTally: bigint[], verificationKeys: readonly Uint8Array[], publicKey: PublicKey): boolean;
13
+ }
14
+ //# sourceMappingURL=decryption-combiner.d.ts.map