@digitaldefiance/ecies-lib 4.8.7 → 4.9.1

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 (296) hide show
  1. package/package.json +8 -8
  2. package/src/builders/member-builder.d.ts +1 -2
  3. package/src/builders/member-builder.d.ts.map +1 -1
  4. package/src/builders/member-builder.js.map +1 -1
  5. package/src/constants.d.ts +1 -1
  6. package/src/constants.d.ts.map +1 -1
  7. package/src/constants.js +2 -0
  8. package/src/constants.js.map +1 -1
  9. package/src/interfaces/constants.d.ts +1 -1
  10. package/src/interfaces/constants.d.ts.map +1 -1
  11. package/src/interfaces/ecies-consts.d.ts +1 -0
  12. package/src/interfaces/ecies-consts.d.ts.map +1 -1
  13. package/src/interfaces/index.d.ts +2 -4
  14. package/src/interfaces/index.d.ts.map +1 -1
  15. package/src/interfaces/index.js +2 -5
  16. package/src/interfaces/index.js.map +1 -1
  17. package/src/interfaces/isolated-private-key-async.d.ts +13 -0
  18. package/src/interfaces/isolated-private-key-async.d.ts.map +1 -0
  19. package/src/interfaces/isolated-private-key-async.js +3 -0
  20. package/src/interfaces/isolated-private-key-async.js.map +1 -0
  21. package/src/interfaces/isolated-public-key-async.d.ts +17 -0
  22. package/src/interfaces/isolated-public-key-async.d.ts.map +1 -0
  23. package/src/interfaces/isolated-public-key-async.js +3 -0
  24. package/src/interfaces/isolated-public-key-async.js.map +1 -0
  25. package/src/interfaces/platform-buffer.d.ts +5 -5
  26. package/src/interfaces/platform-buffer.d.ts.map +1 -1
  27. package/src/interfaces/voting-service.d.ts +0 -111
  28. package/src/interfaces/voting-service.d.ts.map +1 -1
  29. package/src/interfaces/voting-service.js +0 -7
  30. package/src/interfaces/voting-service.js.map +1 -1
  31. package/src/lib/id-providers/index.d.ts +1 -0
  32. package/src/lib/id-providers/index.d.ts.map +1 -1
  33. package/src/lib/id-providers/index.js +3 -1
  34. package/src/lib/id-providers/index.js.map +1 -1
  35. package/src/lib/id-providers/uint8array-provider.d.ts +54 -0
  36. package/src/lib/id-providers/uint8array-provider.d.ts.map +1 -0
  37. package/src/lib/id-providers/uint8array-provider.js +97 -0
  38. package/src/lib/id-providers/uint8array-provider.js.map +1 -0
  39. package/src/lib/voting/audit.d.ts +4 -38
  40. package/src/lib/voting/audit.d.ts.map +1 -1
  41. package/src/lib/voting/audit.js +8 -10
  42. package/src/lib/voting/audit.js.map +1 -1
  43. package/src/lib/voting/bulletin-board.d.ts +4 -56
  44. package/src/lib/voting/bulletin-board.d.ts.map +1 -1
  45. package/src/lib/voting/bulletin-board.js.map +1 -1
  46. package/src/lib/voting/encoder.d.ts +2 -1
  47. package/src/lib/voting/encoder.d.ts.map +1 -1
  48. package/src/lib/voting/encoder.js +9 -9
  49. package/src/lib/voting/encoder.js.map +1 -1
  50. package/src/lib/voting/enumerations/audit-event-type.d.ts +6 -0
  51. package/src/lib/voting/enumerations/audit-event-type.d.ts.map +1 -0
  52. package/src/lib/voting/enumerations/audit-event-type.js +10 -0
  53. package/src/lib/voting/enumerations/audit-event-type.js.map +1 -0
  54. package/src/lib/voting/enumerations/event-type.d.ts +9 -0
  55. package/src/lib/voting/enumerations/event-type.d.ts.map +1 -0
  56. package/src/lib/voting/enumerations/event-type.js +13 -0
  57. package/src/lib/voting/enumerations/event-type.js.map +1 -0
  58. package/src/lib/voting/enumerations/index.d.ts +6 -0
  59. package/src/lib/voting/enumerations/index.d.ts.map +1 -0
  60. package/src/lib/voting/enumerations/index.js +9 -0
  61. package/src/lib/voting/enumerations/index.js.map +1 -0
  62. package/src/lib/voting/enumerations/jurisdictional-level.d.ts +7 -0
  63. package/src/lib/voting/enumerations/jurisdictional-level.d.ts.map +1 -0
  64. package/src/lib/voting/enumerations/jurisdictional-level.js +11 -0
  65. package/src/lib/voting/enumerations/jurisdictional-level.js.map +1 -0
  66. package/src/lib/voting/enumerations/security-level.d.ts +6 -0
  67. package/src/lib/voting/enumerations/security-level.d.ts.map +1 -0
  68. package/src/lib/voting/enumerations/security-level.js +10 -0
  69. package/src/lib/voting/enumerations/security-level.js.map +1 -0
  70. package/src/lib/voting/enumerations/voting-method.d.ts +41 -0
  71. package/src/lib/voting/enumerations/voting-method.d.ts.map +1 -0
  72. package/src/lib/voting/{types.js → enumerations/voting-method.js} +1 -1
  73. package/src/lib/voting/enumerations/voting-method.js.map +1 -0
  74. package/src/lib/voting/event-logger.d.ts +14 -65
  75. package/src/lib/voting/event-logger.d.ts.map +1 -1
  76. package/src/lib/voting/event-logger.js +32 -19
  77. package/src/lib/voting/event-logger.js.map +1 -1
  78. package/src/lib/voting/factory.d.ts +2 -2
  79. package/src/lib/voting/factory.d.ts.map +1 -1
  80. package/src/lib/voting/factory.js +6 -6
  81. package/src/lib/voting/factory.js.map +1 -1
  82. package/src/lib/voting/hierarchical-aggregator.d.ts +72 -0
  83. package/src/lib/voting/hierarchical-aggregator.d.ts.map +1 -0
  84. package/src/lib/voting/hierarchical-aggregator.js +234 -0
  85. package/src/lib/voting/hierarchical-aggregator.js.map +1 -0
  86. package/src/lib/voting/index.d.ts +8 -5
  87. package/src/lib/voting/index.d.ts.map +1 -1
  88. package/src/lib/voting/index.js +12 -7
  89. package/src/lib/voting/index.js.map +1 -1
  90. package/src/lib/voting/interfaces/aggregated-tally.d.ts +11 -0
  91. package/src/lib/voting/interfaces/aggregated-tally.d.ts.map +1 -0
  92. package/src/{interfaces/member-with-mnemonic.js → lib/voting/interfaces/aggregated-tally.js} +1 -1
  93. package/src/lib/voting/interfaces/aggregated-tally.js.map +1 -0
  94. package/src/lib/voting/interfaces/audit-entry.d.ts +25 -0
  95. package/src/lib/voting/interfaces/audit-entry.d.ts.map +1 -0
  96. package/src/lib/voting/interfaces/audit-entry.js +3 -0
  97. package/src/lib/voting/interfaces/audit-entry.js.map +1 -0
  98. package/src/lib/voting/interfaces/audit-log.d.ts +13 -0
  99. package/src/lib/voting/interfaces/audit-log.d.ts.map +1 -0
  100. package/src/lib/voting/interfaces/audit-log.js +3 -0
  101. package/src/lib/voting/interfaces/audit-log.js.map +1 -0
  102. package/src/lib/voting/interfaces/bulletin-board-entry.d.ts +20 -0
  103. package/src/lib/voting/interfaces/bulletin-board-entry.d.ts.map +1 -0
  104. package/src/lib/voting/interfaces/bulletin-board-entry.js +3 -0
  105. package/src/lib/voting/interfaces/bulletin-board-entry.js.map +1 -0
  106. package/src/lib/voting/interfaces/bulletin-board.d.ts +24 -0
  107. package/src/lib/voting/interfaces/bulletin-board.d.ts.map +1 -0
  108. package/src/lib/voting/interfaces/bulletin-board.js +3 -0
  109. package/src/lib/voting/interfaces/bulletin-board.js.map +1 -0
  110. package/src/lib/voting/interfaces/checkpoint-manager-extended.d.ts +14 -0
  111. package/src/lib/voting/interfaces/checkpoint-manager-extended.d.ts.map +1 -0
  112. package/src/lib/voting/interfaces/checkpoint-manager-extended.js +3 -0
  113. package/src/lib/voting/interfaces/checkpoint-manager-extended.js.map +1 -0
  114. package/src/lib/voting/interfaces/checkpoint-manager.d.ts +8 -0
  115. package/src/lib/voting/interfaces/checkpoint-manager.d.ts.map +1 -0
  116. package/src/lib/voting/interfaces/checkpoint-manager.js +3 -0
  117. package/src/lib/voting/interfaces/checkpoint-manager.js.map +1 -0
  118. package/src/lib/voting/interfaces/checkpoint-metadata.d.ts +9 -0
  119. package/src/lib/voting/interfaces/checkpoint-metadata.d.ts.map +1 -0
  120. package/src/lib/voting/interfaces/checkpoint-metadata.js +3 -0
  121. package/src/lib/voting/interfaces/checkpoint-metadata.js.map +1 -0
  122. package/src/lib/voting/interfaces/ecies-service-with-voting.d.ts +55 -0
  123. package/src/lib/voting/interfaces/ecies-service-with-voting.d.ts.map +1 -0
  124. package/src/lib/voting/interfaces/ecies-service-with-voting.js +3 -0
  125. package/src/lib/voting/interfaces/ecies-service-with-voting.js.map +1 -0
  126. package/src/lib/voting/interfaces/encrypted-vote.d.ts +23 -0
  127. package/src/lib/voting/interfaces/encrypted-vote.d.ts.map +1 -0
  128. package/src/lib/voting/interfaces/encrypted-vote.js +3 -0
  129. package/src/lib/voting/interfaces/encrypted-vote.js.map +1 -0
  130. package/src/lib/voting/interfaces/event-log-entry.d.ts +24 -0
  131. package/src/lib/voting/interfaces/event-log-entry.d.ts.map +1 -0
  132. package/src/lib/voting/interfaces/event-log-entry.js +3 -0
  133. package/src/lib/voting/interfaces/event-log-entry.js.map +1 -0
  134. package/src/lib/voting/interfaces/event-logger.d.ts +25 -0
  135. package/src/lib/voting/interfaces/event-logger.d.ts.map +1 -0
  136. package/src/lib/voting/interfaces/event-logger.js +3 -0
  137. package/src/lib/voting/interfaces/event-logger.js.map +1 -0
  138. package/src/lib/voting/interfaces/index.d.ts +31 -0
  139. package/src/lib/voting/interfaces/index.d.ts.map +1 -0
  140. package/src/lib/voting/interfaces/index.js +5 -0
  141. package/src/lib/voting/interfaces/index.js.map +1 -0
  142. package/src/lib/voting/interfaces/jurisdiction-config.d.ts +9 -0
  143. package/src/lib/voting/interfaces/jurisdiction-config.d.ts.map +1 -0
  144. package/src/lib/voting/interfaces/jurisdiction-config.js +3 -0
  145. package/src/lib/voting/interfaces/jurisdiction-config.js.map +1 -0
  146. package/src/lib/voting/interfaces/plaintext-vote.d.ts +18 -0
  147. package/src/lib/voting/interfaces/plaintext-vote.d.ts.map +1 -0
  148. package/src/lib/voting/interfaces/plaintext-vote.js +3 -0
  149. package/src/lib/voting/interfaces/plaintext-vote.js.map +1 -0
  150. package/src/lib/voting/interfaces/poll-configuration.d.ts +10 -0
  151. package/src/lib/voting/interfaces/poll-configuration.d.ts.map +1 -0
  152. package/src/lib/voting/interfaces/poll-configuration.js +3 -0
  153. package/src/lib/voting/interfaces/poll-configuration.js.map +1 -0
  154. package/src/lib/voting/interfaces/poll-results.d.ts +25 -0
  155. package/src/lib/voting/interfaces/poll-results.d.ts.map +1 -0
  156. package/src/lib/voting/interfaces/poll-results.js +3 -0
  157. package/src/lib/voting/interfaces/poll-results.js.map +1 -0
  158. package/src/lib/voting/interfaces/poll-tallier.d.ts +18 -0
  159. package/src/lib/voting/interfaces/poll-tallier.d.ts.map +1 -0
  160. package/src/lib/voting/interfaces/poll-tallier.js +3 -0
  161. package/src/lib/voting/interfaces/poll-tallier.js.map +1 -0
  162. package/src/lib/voting/interfaces/poll.d.ts +41 -0
  163. package/src/lib/voting/interfaces/poll.d.ts.map +1 -0
  164. package/src/lib/voting/interfaces/poll.js +3 -0
  165. package/src/lib/voting/interfaces/poll.js.map +1 -0
  166. package/src/lib/voting/interfaces/round-result.d.ts +15 -0
  167. package/src/lib/voting/interfaces/round-result.d.ts.map +1 -0
  168. package/src/lib/voting/interfaces/round-result.js +3 -0
  169. package/src/lib/voting/interfaces/round-result.js.map +1 -0
  170. package/src/lib/voting/interfaces/state-snapshot.d.ts +9 -0
  171. package/src/lib/voting/interfaces/state-snapshot.d.ts.map +1 -0
  172. package/src/lib/voting/interfaces/state-snapshot.js +3 -0
  173. package/src/lib/voting/interfaces/state-snapshot.js.map +1 -0
  174. package/src/lib/voting/interfaces/supermajority-config.d.ts +11 -0
  175. package/src/lib/voting/interfaces/supermajority-config.d.ts.map +1 -0
  176. package/src/lib/voting/interfaces/supermajority-config.js +3 -0
  177. package/src/lib/voting/interfaces/supermajority-config.js.map +1 -0
  178. package/src/lib/voting/interfaces/tally-proof.d.ts +18 -0
  179. package/src/lib/voting/interfaces/tally-proof.d.ts.map +1 -0
  180. package/src/lib/voting/interfaces/tally-proof.js +3 -0
  181. package/src/lib/voting/interfaces/tally-proof.js.map +1 -0
  182. package/src/lib/voting/interfaces/vote-encoder.d.ts +59 -0
  183. package/src/lib/voting/interfaces/vote-encoder.d.ts.map +1 -0
  184. package/src/lib/voting/interfaces/vote-encoder.js +3 -0
  185. package/src/lib/voting/interfaces/vote-encoder.js.map +1 -0
  186. package/src/lib/voting/interfaces/vote-logger-extended.d.ts +15 -0
  187. package/src/lib/voting/interfaces/vote-logger-extended.d.ts.map +1 -0
  188. package/src/lib/voting/interfaces/vote-logger-extended.js +3 -0
  189. package/src/lib/voting/interfaces/vote-logger-extended.js.map +1 -0
  190. package/src/lib/voting/interfaces/vote-logger.d.ts +11 -0
  191. package/src/lib/voting/interfaces/vote-logger.d.ts.map +1 -0
  192. package/src/lib/voting/interfaces/vote-logger.js +3 -0
  193. package/src/lib/voting/interfaces/vote-logger.js.map +1 -0
  194. package/src/lib/voting/interfaces/voting-consts.d.ts.map +1 -0
  195. package/src/lib/voting/interfaces/voting-consts.js.map +1 -0
  196. package/src/lib/voting/interfaces/voting-key-derivation-options.d.ts +26 -0
  197. package/src/lib/voting/interfaces/voting-key-derivation-options.d.ts.map +1 -0
  198. package/src/lib/voting/interfaces/voting-key-derivation-options.js +3 -0
  199. package/src/lib/voting/interfaces/voting-key-derivation-options.js.map +1 -0
  200. package/src/lib/voting/interfaces/voting-poll-results.d.ts +20 -0
  201. package/src/lib/voting/interfaces/voting-poll-results.d.ts.map +1 -0
  202. package/src/lib/voting/interfaces/voting-poll-results.js +3 -0
  203. package/src/lib/voting/interfaces/voting-poll-results.js.map +1 -0
  204. package/src/lib/voting/interfaces/voting-receipt.d.ts +18 -0
  205. package/src/lib/voting/interfaces/voting-receipt.d.ts.map +1 -0
  206. package/src/lib/voting/interfaces/voting-receipt.js +3 -0
  207. package/src/lib/voting/interfaces/voting-receipt.js.map +1 -0
  208. package/src/lib/voting/interfaces/voting-security-validator.d.ts +37 -0
  209. package/src/lib/voting/interfaces/voting-security-validator.d.ts.map +1 -0
  210. package/src/lib/voting/interfaces/voting-security-validator.js +3 -0
  211. package/src/lib/voting/interfaces/voting-security-validator.js.map +1 -0
  212. package/src/lib/voting/persistent-state.d.ts +21 -0
  213. package/src/lib/voting/persistent-state.d.ts.map +1 -0
  214. package/src/lib/voting/persistent-state.js +32 -0
  215. package/src/lib/voting/persistent-state.js.map +1 -0
  216. package/src/lib/voting/poll-core.d.ts +3 -3
  217. package/src/lib/voting/poll-core.d.ts.map +1 -1
  218. package/src/lib/voting/poll-core.js +6 -7
  219. package/src/lib/voting/poll-core.js.map +1 -1
  220. package/src/lib/voting/security.d.ts +2 -6
  221. package/src/lib/voting/security.d.ts.map +1 -1
  222. package/src/lib/voting/security.js +25 -28
  223. package/src/lib/voting/security.js.map +1 -1
  224. package/src/lib/voting/tallier.d.ts +5 -5
  225. package/src/lib/voting/tallier.d.ts.map +1 -1
  226. package/src/lib/voting/tallier.js +26 -26
  227. package/src/lib/voting/tallier.js.map +1 -1
  228. package/src/lib/voting/test-voter-pool.d.ts +16 -0
  229. package/src/lib/voting/test-voter-pool.d.ts.map +1 -0
  230. package/src/lib/voting/test-voter-pool.js +65 -0
  231. package/src/lib/voting/test-voter-pool.js.map +1 -0
  232. package/src/member.d.ts +8 -1
  233. package/src/member.d.ts.map +1 -1
  234. package/src/member.js +6 -6
  235. package/src/member.js.map +1 -1
  236. package/src/services/ecies/interfaces/decryption-result.d.ts +5 -0
  237. package/src/services/ecies/interfaces/decryption-result.d.ts.map +1 -0
  238. package/src/services/ecies/interfaces/decryption-result.js +3 -0
  239. package/src/services/ecies/interfaces/decryption-result.js.map +1 -0
  240. package/src/services/ecies/interfaces/encryption-result.d.ts +7 -0
  241. package/src/services/ecies/interfaces/encryption-result.d.ts.map +1 -0
  242. package/src/services/ecies/interfaces/encryption-result.js +3 -0
  243. package/src/services/ecies/interfaces/encryption-result.js.map +1 -0
  244. package/src/services/ecies/interfaces/index.d.ts +9 -0
  245. package/src/services/ecies/interfaces/index.d.ts.map +1 -0
  246. package/src/services/ecies/interfaces/index.js +3 -0
  247. package/src/services/ecies/interfaces/index.js.map +1 -0
  248. package/src/services/ecies/interfaces/multi-encrypted-message.d.ts +11 -0
  249. package/src/services/ecies/interfaces/multi-encrypted-message.d.ts.map +1 -0
  250. package/src/services/ecies/interfaces/multi-encrypted-message.js +3 -0
  251. package/src/services/ecies/interfaces/multi-encrypted-message.js.map +1 -0
  252. package/src/services/ecies/interfaces/multi-encrypted-parsed-header.d.ts +10 -0
  253. package/src/services/ecies/interfaces/multi-encrypted-parsed-header.d.ts.map +1 -0
  254. package/src/services/ecies/interfaces/multi-encrypted-parsed-header.js +3 -0
  255. package/src/services/ecies/interfaces/multi-encrypted-parsed-header.js.map +1 -0
  256. package/src/services/ecies/interfaces/multi-recipient.d.ts +6 -0
  257. package/src/services/ecies/interfaces/multi-recipient.d.ts.map +1 -0
  258. package/src/services/ecies/interfaces/multi-recipient.js +3 -0
  259. package/src/services/ecies/interfaces/multi-recipient.js.map +1 -0
  260. package/src/services/ecies/interfaces/simple-keypair.d.ts +5 -0
  261. package/src/services/ecies/interfaces/simple-keypair.d.ts.map +1 -0
  262. package/src/services/ecies/interfaces/simple-keypair.js +3 -0
  263. package/src/services/ecies/interfaces/simple-keypair.js.map +1 -0
  264. package/src/services/ecies/interfaces/single-encrypted-parsed-header.d.ts +11 -0
  265. package/src/services/ecies/interfaces/single-encrypted-parsed-header.d.ts.map +1 -0
  266. package/src/services/ecies/interfaces/single-encrypted-parsed-header.js +3 -0
  267. package/src/services/ecies/interfaces/single-encrypted-parsed-header.js.map +1 -0
  268. package/src/services/ecies/interfaces/wallet-seed.d.ts +6 -0
  269. package/src/services/ecies/interfaces/wallet-seed.d.ts.map +1 -0
  270. package/src/services/ecies/interfaces/wallet-seed.js +3 -0
  271. package/src/services/ecies/interfaces/wallet-seed.js.map +1 -0
  272. package/src/services/ecies/multi-recipient.d.ts.map +1 -1
  273. package/src/services/ecies/multi-recipient.js +14 -5
  274. package/src/services/ecies/multi-recipient.js.map +1 -1
  275. package/src/interfaces/member-with-mnemonic.d.ts +0 -8
  276. package/src/interfaces/member-with-mnemonic.d.ts.map +0 -1
  277. package/src/interfaces/member-with-mnemonic.js.map +0 -1
  278. package/src/interfaces/voting-consts.d.ts.map +0 -1
  279. package/src/interfaces/voting-consts.js.map +0 -1
  280. package/src/interfaces/voting-poll.d.ts +0 -455
  281. package/src/interfaces/voting-poll.d.ts.map +0 -1
  282. package/src/interfaces/voting-poll.js +0 -54
  283. package/src/interfaces/voting-poll.js.map +0 -1
  284. package/src/lib/voting/poll.d.ts +0 -125
  285. package/src/lib/voting/poll.d.ts.map +0 -1
  286. package/src/lib/voting/poll.js +0 -323
  287. package/src/lib/voting/poll.js.map +0 -1
  288. package/src/lib/voting/types.d.ts +0 -146
  289. package/src/lib/voting/types.d.ts.map +0 -1
  290. package/src/lib/voting/types.js.map +0 -1
  291. package/src/services/ecies/interfaces.d.ts +0 -55
  292. package/src/services/ecies/interfaces.d.ts.map +0 -1
  293. package/src/services/ecies/interfaces.js +0 -6
  294. package/src/services/ecies/interfaces.js.map +0 -1
  295. /package/src/{interfaces → lib/voting/interfaces}/voting-consts.d.ts +0 -0
  296. /package/src/{interfaces → lib/voting/interfaces}/voting-consts.js +0 -0
@@ -1,455 +0,0 @@
1
- /**
2
- * Voting Poll System Interfaces
3
- *
4
- * Common interfaces for the voting poll system that must be implemented
5
- * consistently across ecies-lib (browser) and node-ecies-lib (Node.js).
6
- *
7
- * These interfaces ensure type safety and API consistency across platforms,
8
- * enabling cross-platform voting applications with identical behavior.
9
- */
10
- import type { PublicKey, PrivateKey, KeyPair } from 'paillier-bigint';
11
- import type { PlatformBuffer } from './platform-buffer';
12
- /**
13
- * Voting methods supported by the poll system.
14
- * See VotingMethod in lib/voting/types.ts for detailed descriptions.
15
- */
16
- /**
17
- * Voting methods supported by the poll system
18
- */
19
- export declare enum VotingMethod {
20
- Plurality = "plurality",
21
- Approval = "approval",
22
- Weighted = "weighted",
23
- Borda = "borda",
24
- Score = "score",
25
- YesNo = "yes-no",
26
- YesNoAbstain = "yes-no-abstain",
27
- Supermajority = "supermajority",
28
- RankedChoice = "ranked-choice",
29
- TwoRound = "two-round",
30
- STAR = "star",
31
- STV = "stv",
32
- Quadratic = "quadratic",
33
- Consensus = "consensus",
34
- ConsentBased = "consent-based"
35
- }
36
- /**
37
- * Vote receipt proving participation.
38
- * Cryptographically signed proof that a vote was cast.
39
- */
40
- export interface IVoteReceipt {
41
- /** Unique identifier of the voter */
42
- voterId: PlatformBuffer;
43
- /** Unique identifier of the poll */
44
- pollId: PlatformBuffer;
45
- /** Unix timestamp when vote was cast */
46
- timestamp: number;
47
- /** Cryptographic signature from poll authority */
48
- signature: PlatformBuffer;
49
- /** Random nonce for uniqueness */
50
- nonce: PlatformBuffer;
51
- }
52
- /**
53
- * Encrypted vote data using Paillier homomorphic encryption.
54
- * Structure varies by voting method.
55
- */
56
- export interface IEncryptedVote {
57
- /** Single choice index (for Plurality, Weighted, etc.) */
58
- choiceIndex?: number;
59
- /** Multiple choice indices (for Approval voting) */
60
- choices?: number[];
61
- /** Ranked choice indices in preference order (for RCV, Borda) */
62
- rankings?: number[];
63
- /** Vote weight (for Weighted voting) */
64
- weight?: bigint;
65
- /** Score value 0-10 (for Score voting) */
66
- score?: number;
67
- /** Array of encrypted vote values (one per choice) */
68
- encrypted: bigint[];
69
- /** Plaintext vote data (only for insecure methods) */
70
- plaintext?: IPlaintextVote;
71
- }
72
- /**
73
- * Plaintext vote data for insecure voting methods.
74
- * WARNING: Only use for Quadratic, Consensus, or ConsentBased methods.
75
- */
76
- export interface IPlaintextVote {
77
- /** Unique identifier of the voter */
78
- voterId: PlatformBuffer;
79
- /** Single choice index */
80
- choiceIndex?: number;
81
- /** Multiple choice indices */
82
- choices?: number[];
83
- /** Vote weight */
84
- weight?: bigint;
85
- /** Objection text (for consent-based voting) */
86
- objection?: string;
87
- }
88
- /**
89
- * Results of a completed poll after tallying.
90
- * Includes winner(s), tallies, and round-by-round data for multi-round methods.
91
- */
92
- export interface IPollResults {
93
- /** Voting method used */
94
- method: VotingMethod;
95
- /** Array of choice names */
96
- choices: string[];
97
- /** Index of winning choice (undefined if tie) */
98
- winner?: number;
99
- /** Indices of tied winners (for ties or multi-winner methods) */
100
- winners?: number[];
101
- /** Indices of eliminated choices (for RCV) */
102
- eliminated?: number[];
103
- /** Round-by-round results (for multi-round methods) */
104
- rounds?: IRoundResult[];
105
- /** Final vote tallies for each choice */
106
- tallies: bigint[];
107
- /** Total number of unique voters */
108
- voterCount: number;
109
- }
110
- /**
111
- * Results from a single round of multi-round voting.
112
- * Used in RCV, Two-Round, STAR, and STV methods.
113
- */
114
- export interface IRoundResult {
115
- /** Round number (1-indexed) */
116
- round: number;
117
- /** Vote tallies for this round */
118
- tallies: bigint[];
119
- /** Index of choice eliminated this round (if any) */
120
- eliminated?: number;
121
- /** Index of winner determined this round (if any) */
122
- winner?: number;
123
- }
124
- /**
125
- * Configuration for supermajority voting.
126
- * Defines the required threshold as a fraction (e.g., 2/3, 3/4).
127
- */
128
- export interface ISupermajorityConfig {
129
- /** Numerator of the fraction (e.g., 2 for 2/3) */
130
- numerator: number;
131
- /** Denominator of the fraction (e.g., 3 for 2/3) */
132
- denominator: number;
133
- }
134
- /**
135
- * Member interface for voting operations.
136
- * Extends base member with voting-specific capabilities.
137
- */
138
- export interface IVotingMember {
139
- /** Unique identifier of the member */
140
- readonly id: PlatformBuffer;
141
- /** ECDSA public key for signing */
142
- readonly publicKey: PlatformBuffer;
143
- /** Paillier public key for vote encryption (optional) */
144
- readonly votingPublicKey?: PublicKey;
145
- /** Paillier private key for vote decryption (optional) */
146
- readonly votingPrivateKey?: PrivateKey;
147
- /**
148
- * Sign data with member's private key.
149
- * @param data - Data to sign
150
- * @returns Signature
151
- */
152
- sign(data: PlatformBuffer): PlatformBuffer;
153
- /**
154
- * Verify signature against data.
155
- * @param signature - Signature to verify
156
- * @param data - Original data
157
- * @returns True if signature is valid
158
- */
159
- verify(signature: PlatformBuffer, data: PlatformBuffer): boolean;
160
- }
161
- /**
162
- * Poll interface for vote aggregation and management.
163
- * Holds encrypted votes and issues receipts, but cannot decrypt votes.
164
- */
165
- export interface IPoll {
166
- /** Unique identifier of the poll */
167
- readonly id: PlatformBuffer;
168
- /** Array of choice names */
169
- readonly choices: ReadonlyArray<string>;
170
- /** Voting method used */
171
- readonly method: VotingMethod;
172
- /** Whether poll is closed to new votes */
173
- readonly isClosed: boolean;
174
- /** Total number of unique voters */
175
- readonly voterCount: number;
176
- /** Unix timestamp when poll was created */
177
- readonly createdAt: number;
178
- /** Unix timestamp when poll was closed (undefined if open) */
179
- readonly closedAt: number | undefined;
180
- /**
181
- * Cast a vote in the poll.
182
- * @param voter - Member casting the vote
183
- * @param vote - Encrypted vote data
184
- * @returns Vote receipt
185
- * @throws Error if poll is closed or voter already voted
186
- */
187
- vote(voter: IVotingMember, vote: IEncryptedVote): IVoteReceipt;
188
- /**
189
- * Verify a vote receipt is valid.
190
- * @param voter - Member who cast the vote
191
- * @param receipt - Receipt to verify
192
- * @returns True if receipt is valid
193
- */
194
- verifyReceipt(voter: IVotingMember, receipt: IVoteReceipt): boolean;
195
- /**
196
- * Close the poll to new votes.
197
- * @throws Error if poll is already closed
198
- */
199
- close(): void;
200
- /**
201
- * Get encrypted votes for tallying (read-only).
202
- * @returns Map of voter ID to encrypted vote data
203
- */
204
- getEncryptedVotes(): ReadonlyMap<string, readonly bigint[]>;
205
- }
206
- /**
207
- * Vote encoder interface for encrypting votes.
208
- * Converts vote choices into encrypted Paillier ciphertexts.
209
- */
210
- export interface IVoteEncoder {
211
- /**
212
- * Encode a plurality vote (single choice).
213
- * @param choiceIndex - Index of chosen option
214
- * @param choiceCount - Total number of choices
215
- * @returns Encrypted vote
216
- */
217
- encodePlurality(choiceIndex: number, choiceCount: number): IEncryptedVote;
218
- /**
219
- * Encode an approval vote (multiple choices).
220
- * @param choices - Indices of approved options
221
- * @param choiceCount - Total number of choices
222
- * @returns Encrypted vote
223
- */
224
- encodeApproval(choices: number[], choiceCount: number): IEncryptedVote;
225
- /**
226
- * Encode a weighted vote.
227
- * @param choiceIndex - Index of chosen option
228
- * @param weight - Vote weight (must be positive)
229
- * @param choiceCount - Total number of choices
230
- * @returns Encrypted vote
231
- */
232
- encodeWeighted(choiceIndex: number, weight: bigint, choiceCount: number): IEncryptedVote;
233
- /**
234
- * Encode a Borda count vote (ranked with points).
235
- * @param rankings - Indices in preference order
236
- * @param choiceCount - Total number of choices
237
- * @returns Encrypted vote
238
- */
239
- encodeBorda(rankings: number[], choiceCount: number): IEncryptedVote;
240
- /**
241
- * Encode a ranked choice vote (for IRV).
242
- * @param rankings - Indices in preference order
243
- * @param choiceCount - Total number of choices
244
- * @returns Encrypted vote
245
- */
246
- encodeRankedChoice(rankings: number[], choiceCount: number): IEncryptedVote;
247
- /**
248
- * Encode vote based on method.
249
- * @param method - Voting method
250
- * @param data - Vote data
251
- * @param choiceCount - Total number of choices
252
- * @returns Encrypted vote
253
- */
254
- encode(method: VotingMethod, data: {
255
- choiceIndex?: number;
256
- choices?: number[];
257
- rankings?: number[];
258
- weight?: bigint;
259
- }, choiceCount: number): IEncryptedVote;
260
- }
261
- /**
262
- * Poll tallier interface for decrypting and tallying votes.
263
- * Holds private key and can decrypt results after poll closes.
264
- */
265
- export interface IPollTallier {
266
- /**
267
- * Tally votes and determine winner(s).
268
- * @param poll - Poll to tally
269
- * @returns Poll results
270
- * @throws Error if poll is not closed
271
- */
272
- tally(poll: IPoll): IPollResults;
273
- /**
274
- * Tally ranked choice votes using IRV algorithm.
275
- * @param poll - Poll to tally
276
- * @returns Poll results with elimination rounds
277
- */
278
- tallyRankedChoice(poll: IPoll): IPollResults;
279
- }
280
- /**
281
- * Poll factory interface for creating polls.
282
- */
283
- export interface IPollFactory {
284
- /**
285
- * Create a poll with specified method.
286
- * @param choices - Array of choice names
287
- * @param method - Voting method
288
- * @param authority - Poll authority
289
- * @param options - Optional configuration
290
- * @returns New poll
291
- */
292
- create(choices: string[], method: VotingMethod, authority: IVotingMember, options?: {
293
- maxWeight?: bigint;
294
- }): IPoll;
295
- /**
296
- * Create a plurality poll.
297
- * @param choices - Array of choice names
298
- * @param authority - Poll authority
299
- * @returns New poll
300
- */
301
- createPlurality(choices: string[], authority: IVotingMember): IPoll;
302
- /**
303
- * Create an approval voting poll.
304
- * @param choices - Array of choice names
305
- * @param authority - Poll authority
306
- * @returns New poll
307
- */
308
- createApproval(choices: string[], authority: IVotingMember): IPoll;
309
- /**
310
- * Create a weighted voting poll.
311
- * @param choices - Array of choice names
312
- * @param authority - Poll authority
313
- * @param maxWeight - Maximum vote weight
314
- * @returns New poll
315
- */
316
- createWeighted(choices: string[], authority: IVotingMember, maxWeight: bigint): IPoll;
317
- /**
318
- * Create a Borda count poll.
319
- * @param choices - Array of choice names
320
- * @param authority - Poll authority
321
- * @returns New poll
322
- */
323
- createBorda(choices: string[], authority: IVotingMember): IPoll;
324
- /**
325
- * Create a ranked choice poll.
326
- * @param choices - Array of choice names
327
- * @param authority - Poll authority
328
- * @returns New poll
329
- */
330
- createRankedChoice(choices: string[], authority: IVotingMember): IPoll;
331
- }
332
- /**
333
- * Options for deriving Paillier voting keys from ECDH keys.
334
- */
335
- export interface IVotingKeyDerivationOptions {
336
- /** Elliptic curve name (default: 'secp256k1') */
337
- curveName?: string;
338
- /** Public key magic byte (default: 0x04) */
339
- publicKeyMagic?: number;
340
- /** Raw public key length (default: 64) */
341
- rawPublicKeyLength?: number;
342
- /** Public key length with prefix (default: 65) */
343
- publicKeyLength?: number;
344
- /** HMAC algorithm (default: 'sha512') */
345
- hmacAlgorithm?: string;
346
- /** HKDF info string (default: 'PaillierPrimeGen') */
347
- hkdfInfo?: string;
348
- /** HKDF output length (default: 64) */
349
- hkdfLength?: number;
350
- /** Key pair bit length (default: 3072) */
351
- keypairBitLength?: number;
352
- /** Prime test iterations (default: 256) */
353
- primeTestIterations?: number;
354
- /** Max prime generation attempts (default: 20000) */
355
- maxPrimeAttempts?: number;
356
- }
357
- /**
358
- * Security level classification for voting methods.
359
- * Determines cryptographic security guarantees.
360
- */
361
- export declare enum SecurityLevel {
362
- /** Fully homomorphic - no intermediate decryption required */
363
- FullyHomomorphic = "fully-homomorphic",
364
- /** Multi-round - requires intermediate decryption between rounds */
365
- MultiRound = "multi-round",
366
- /** Insecure - cannot be made secure with Paillier encryption */
367
- Insecure = "insecure"
368
- }
369
- /**
370
- * Voting security validator interface.
371
- * Validates voting methods against security requirements.
372
- */
373
- export interface IVotingSecurityValidator {
374
- /**
375
- * Check if voting method is fully secure (no intermediate decryption).
376
- * @param method - Voting method to check
377
- * @returns True if method is fully homomorphic
378
- */
379
- isFullySecure(method: VotingMethod): boolean;
380
- /**
381
- * Check if voting method requires multiple rounds.
382
- * @param method - Voting method to check
383
- * @returns True if method requires intermediate decryption
384
- */
385
- requiresMultipleRounds(method: VotingMethod): boolean;
386
- /**
387
- * Get security level for voting method.
388
- * @param method - Voting method to check
389
- * @returns Security level classification
390
- */
391
- getSecurityLevel(method: VotingMethod): SecurityLevel;
392
- /**
393
- * Validate voting method against security requirements.
394
- * Throws error if method doesn't meet requirements.
395
- * @param method - Voting method to validate
396
- * @param options - Validation options
397
- * @throws Error if validation fails
398
- */
399
- validate(method: VotingMethod, options?: {
400
- requireFullySecure?: boolean;
401
- allowInsecure?: boolean;
402
- }): void;
403
- }
404
- /**
405
- * Integrated ECIES service with voting support.
406
- * Provides access to voting key derivation and serialization.
407
- */
408
- export interface IECIESServiceWithVoting {
409
- /** Voting service accessor */
410
- readonly voting: {
411
- /**
412
- * Derive Paillier voting keys from ECDH key pair.
413
- * @param ecdhPrivateKey - ECDH private key
414
- * @param ecdhPublicKey - ECDH public key
415
- * @param options - Derivation options
416
- * @returns Paillier key pair
417
- */
418
- deriveVotingKeysFromECDH(ecdhPrivateKey: PlatformBuffer, ecdhPublicKey: PlatformBuffer, options?: IVotingKeyDerivationOptions): Promise<KeyPair>;
419
- /**
420
- * Generate deterministic key pair from seed.
421
- * WARNING: For testing only!
422
- * @param seed - Random seed (min 32 bytes)
423
- * @param bitLength - Key bit length
424
- * @param iterations - Prime test iterations
425
- * @returns Paillier key pair
426
- */
427
- generateDeterministicKeyPair(seed: PlatformBuffer, bitLength?: number, iterations?: number): Promise<KeyPair>;
428
- /**
429
- * Serialize public key to buffer.
430
- * @param publicKey - Public key
431
- * @returns Serialized buffer
432
- */
433
- votingPublicKeyToBuffer(publicKey: PublicKey): PlatformBuffer | Promise<PlatformBuffer>;
434
- /**
435
- * Deserialize public key from buffer.
436
- * @param buffer - Serialized buffer
437
- * @returns Public key
438
- */
439
- bufferToVotingPublicKey(buffer: PlatformBuffer): Promise<PublicKey>;
440
- /**
441
- * Serialize private key to buffer.
442
- * @param privateKey - Private key
443
- * @returns Serialized buffer
444
- */
445
- votingPrivateKeyToBuffer(privateKey: PrivateKey): PlatformBuffer;
446
- /**
447
- * Deserialize private key from buffer.
448
- * @param buffer - Serialized buffer
449
- * @param publicKey - Corresponding public key
450
- * @returns Private key
451
- */
452
- bufferToVotingPrivateKey(buffer: PlatformBuffer, publicKey: PublicKey): Promise<PrivateKey>;
453
- };
454
- }
455
- //# sourceMappingURL=voting-poll.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"voting-poll.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/voting-poll.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;GAGG;AAEH;;GAEG;AACH,oBAAY,YAAY;IAEtB,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,QAAQ,aAAa;IACrB,KAAK,UAAU;IACf,KAAK,UAAU;IACf,KAAK,WAAW;IAChB,YAAY,mBAAmB;IAC/B,aAAa,kBAAkB;IAG/B,YAAY,kBAAkB;IAC9B,QAAQ,cAAc;IACtB,IAAI,SAAS;IACb,GAAG,QAAQ;IAGX,SAAS,cAAc;IACvB,SAAS,cAAc;IACvB,YAAY,kBAAkB;CAC/B;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,qCAAqC;IACrC,OAAO,EAAE,cAAc,CAAC;IACxB,oCAAoC;IACpC,MAAM,EAAE,cAAc,CAAC;IACvB,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,SAAS,EAAE,cAAc,CAAC;IAC1B,kCAAkC;IACl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C;QAEpB;;;;WAIG;QACH,uBAAuB,CACrB,SAAS,EAAE,SAAS,GACnB,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;QAC5C;;;;WAIG;QACH,uBAAuB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;QACpE;;;;WAIG;QACH,wBAAwB,CAAC,UAAU,EAAE,UAAU,GAAG,cAAc,CAAC;QACjE;;;;;WAKG;QACH,wBAAwB,CACtB,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC,UAAU,CAAC,CAAC;KACxB,CAAC;CACH"}
@@ -1,54 +0,0 @@
1
- "use strict";
2
- /**
3
- * Voting Poll System Interfaces
4
- *
5
- * Common interfaces for the voting poll system that must be implemented
6
- * consistently across ecies-lib (browser) and node-ecies-lib (Node.js).
7
- *
8
- * These interfaces ensure type safety and API consistency across platforms,
9
- * enabling cross-platform voting applications with identical behavior.
10
- */
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.SecurityLevel = exports.VotingMethod = void 0;
13
- /**
14
- * Voting methods supported by the poll system.
15
- * See VotingMethod in lib/voting/types.ts for detailed descriptions.
16
- */
17
- /**
18
- * Voting methods supported by the poll system
19
- */
20
- var VotingMethod;
21
- (function (VotingMethod) {
22
- // Fully homomorphic (single-round, privacy-preserving)
23
- VotingMethod["Plurality"] = "plurality";
24
- VotingMethod["Approval"] = "approval";
25
- VotingMethod["Weighted"] = "weighted";
26
- VotingMethod["Borda"] = "borda";
27
- VotingMethod["Score"] = "score";
28
- VotingMethod["YesNo"] = "yes-no";
29
- VotingMethod["YesNoAbstain"] = "yes-no-abstain";
30
- VotingMethod["Supermajority"] = "supermajority";
31
- // Multi-round (requires decryption between rounds)
32
- VotingMethod["RankedChoice"] = "ranked-choice";
33
- VotingMethod["TwoRound"] = "two-round";
34
- VotingMethod["STAR"] = "star";
35
- VotingMethod["STV"] = "stv";
36
- // Insecure (requires non-additive operations)
37
- VotingMethod["Quadratic"] = "quadratic";
38
- VotingMethod["Consensus"] = "consensus";
39
- VotingMethod["ConsentBased"] = "consent-based";
40
- })(VotingMethod || (exports.VotingMethod = VotingMethod = {}));
41
- /**
42
- * Security level classification for voting methods.
43
- * Determines cryptographic security guarantees.
44
- */
45
- var SecurityLevel;
46
- (function (SecurityLevel) {
47
- /** Fully homomorphic - no intermediate decryption required */
48
- SecurityLevel["FullyHomomorphic"] = "fully-homomorphic";
49
- /** Multi-round - requires intermediate decryption between rounds */
50
- SecurityLevel["MultiRound"] = "multi-round";
51
- /** Insecure - cannot be made secure with Paillier encryption */
52
- SecurityLevel["Insecure"] = "insecure";
53
- })(SecurityLevel || (exports.SecurityLevel = SecurityLevel = {}));
54
- //# sourceMappingURL=voting-poll.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"voting-poll.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/voting-poll.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAKH;;;GAGG;AAEH;;GAEG;AACH,IAAY,YAqBX;AArBD,WAAY,YAAY;IACtB,uDAAuD;IACvD,uCAAuB,CAAA;IACvB,qCAAqB,CAAA;IACrB,qCAAqB,CAAA;IACrB,+BAAe,CAAA;IACf,+BAAe,CAAA;IACf,gCAAgB,CAAA;IAChB,+CAA+B,CAAA;IAC/B,+CAA+B,CAAA;IAE/B,mDAAmD;IACnD,8CAA8B,CAAA;IAC9B,sCAAsB,CAAA;IACtB,6BAAa,CAAA;IACb,2BAAW,CAAA;IAEX,8CAA8C;IAC9C,uCAAuB,CAAA;IACvB,uCAAuB,CAAA;IACvB,8CAA8B,CAAA;AAChC,CAAC,EArBW,YAAY,4BAAZ,YAAY,QAqBvB;AAkWD;;;GAGG;AACH,IAAY,aAOX;AAPD,WAAY,aAAa;IACvB,8DAA8D;IAC9D,uDAAsC,CAAA;IACtC,oEAAoE;IACpE,2CAA0B,CAAA;IAC1B,gEAAgE;IAChE,sCAAqB,CAAA;AACvB,CAAC,EAPW,aAAa,6BAAb,aAAa,QAOxB"}
@@ -1,125 +0,0 @@
1
- import { KeyPair as PaillierKeyPair } from 'paillier-bigint';
2
- import { PlatformID } from '../../interfaces';
3
- import { Member } from '../../member';
4
- import { ECIESService } from '../../services/ecies/service';
5
- import { VotingService } from '../../services/voting.service';
6
- export interface ECKeyPairBuffer {
7
- privateKey: Uint8Array;
8
- publicKey: Uint8Array;
9
- }
10
- /**
11
- * Result of a voting poll with decrypted tallies
12
- */
13
- export interface VotingPollResults {
14
- /** Total number of votes cast */
15
- totalVotes: bigint;
16
- /** Tallies for each choice */
17
- tallies: bigint[];
18
- /** Choice names */
19
- choices: string[];
20
- /** Percentage for each choice (0-100) */
21
- percentages: number[];
22
- /** Index of the winning choice */
23
- winnerIndex: number;
24
- /** Name of the winning choice */
25
- winnerName: string;
26
- /** Number of unique voters */
27
- voterCount: number;
28
- }
29
- /**
30
- * VotingPoll provides a high-level interface for conducting secure, verifiable polls
31
- * using Paillier homomorphic encryption.
32
- *
33
- * Features:
34
- * - Privacy-preserving vote aggregation (votes remain encrypted until tally)
35
- * - Verifiable receipts for each voter
36
- * - Multiple tallying and analysis methods
37
- * - Ranked choice voting support
38
- * - Weighted voting support
39
- */
40
- export declare class VotingPoll<TID extends PlatformID = Uint8Array> {
41
- readonly choices: string[];
42
- readonly votes: bigint[];
43
- private readonly paillierKeyPair;
44
- private readonly ecKeyPair;
45
- private readonly eciesService;
46
- readonly receipts: Map<string, Uint8Array>;
47
- private readonly createdAt;
48
- private closedAt?;
49
- constructor(eciesService: ECIESService, choices: string[], paillierKeyPair: PaillierKeyPair, ecKeyPair: ECKeyPairBuffer, votes: bigint[]);
50
- generateEncryptedReceipt(member: Member<TID>): Promise<Uint8Array>;
51
- memberVoted(member: Member<TID>): boolean;
52
- verifyReceipt(member: Member<TID>, encryptedReceipt: Uint8Array): Promise<boolean>;
53
- vote(choiceIndex: number, member: Member<TID>): Promise<Uint8Array>;
54
- voteWeighted(choiceIndex: number, weight: bigint, member: Member<TID>): Promise<Uint8Array>;
55
- voteRanked(rankedChoices: number[], member: Member<TID>): Promise<Uint8Array>;
56
- voteApproval(approvedChoices: number[], member: Member<TID>): Promise<Uint8Array>;
57
- get tallies(): bigint[];
58
- getTally(choiceIndex: number): bigint;
59
- get leadingChoice(): string;
60
- /**
61
- * Get the index of the leading choice
62
- */
63
- get leadingChoiceIndex(): number;
64
- /**
65
- * Get complete poll results with percentages and winner
66
- */
67
- getResults(): VotingPollResults;
68
- /**
69
- * Get sorted results (descending by vote count)
70
- */
71
- getSortedResults(): Array<{
72
- choice: string;
73
- index: number;
74
- tally: bigint;
75
- percentage: number;
76
- }>;
77
- /**
78
- * Check if there is a tie for first place
79
- */
80
- get hasTie(): boolean;
81
- /**
82
- * Get all choices tied for first place
83
- */
84
- get tiedChoices(): string[];
85
- /**
86
- * Get total number of unique voters
87
- */
88
- get voterCount(): number;
89
- /**
90
- * Get total encrypted votes (sum of all choice tallies)
91
- * Note: This returns encrypted sum - decrypt with getTotalVotes()
92
- */
93
- get encryptedTotalVotes(): bigint;
94
- /**
95
- * Get total decrypted vote count
96
- */
97
- getTotalVotes(): bigint;
98
- /**
99
- * Close the poll (no more votes can be cast)
100
- */
101
- close(): void;
102
- /**
103
- * Check if poll is closed
104
- */
105
- get isClosed(): boolean;
106
- /**
107
- * Get poll creation timestamp
108
- */
109
- get createdAtTimestamp(): Date;
110
- /**
111
- * Get poll closed timestamp (undefined if not closed)
112
- */
113
- get closedAtTimestamp(): Date | undefined;
114
- /**
115
- * Get poll duration in milliseconds (undefined if not closed)
116
- */
117
- get durationMs(): number | undefined;
118
- static newPoll(eciesService: ECIESService, choices: string[], paillierKeyPair: PaillierKeyPair, ecKeyPair: ECKeyPairBuffer): VotingPoll;
119
- static newPollWithKeys(eciesService: ECIESService, votingService: VotingService, choices: string[]): Promise<{
120
- poll: VotingPoll;
121
- paillierKeyPair: PaillierKeyPair;
122
- ecKeyPair: ECKeyPairBuffer;
123
- }>;
124
- }
125
- //# sourceMappingURL=poll.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"poll.d.ts","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-ecies-lib/src/lib/voting/poll.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAG9D,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,UAAU,CAAC;IACvB,SAAS,EAAE,UAAU,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,iCAAiC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,8BAA8B;IAC9B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,mBAAmB;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,yCAAyC;IACzC,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,kCAAkC;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,8BAA8B;IAC9B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;GAUG;AACH,qBAAa,UAAU,CAAC,GAAG,SAAS,UAAU,GAAG,UAAU;IACzD,SAAgB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClC,SAAgB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAkB;IAClD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkB;IAC5C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAC5C,SAAgB,QAAQ,EAAE,GAAG,CAA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