@digitaldefiance/node-ecies-lib 4.17.10 → 4.19.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 (50) hide show
  1. package/README.md +6 -1
  2. package/package.json +3 -3
  3. package/src/lib/voting/index.d.ts +1 -0
  4. package/src/lib/voting/index.d.ts.map +1 -1
  5. package/src/lib/voting/index.js +2 -0
  6. package/src/lib/voting/index.js.map +1 -1
  7. package/src/lib/voting/threshold/ceremony-coordinator.d.ts +25 -0
  8. package/src/lib/voting/threshold/ceremony-coordinator.d.ts.map +1 -0
  9. package/src/lib/voting/threshold/ceremony-coordinator.js +64 -0
  10. package/src/lib/voting/threshold/ceremony-coordinator.js.map +1 -0
  11. package/src/lib/voting/threshold/index.d.ts +16 -0
  12. package/src/lib/voting/threshold/index.d.ts.map +1 -1
  13. package/src/lib/voting/threshold/index.js +60 -1
  14. package/src/lib/voting/threshold/index.js.map +1 -1
  15. package/src/lib/voting/threshold/partial-decryption-service.d.ts +51 -0
  16. package/src/lib/voting/threshold/partial-decryption-service.d.ts.map +1 -0
  17. package/src/lib/voting/threshold/partial-decryption-service.js +65 -0
  18. package/src/lib/voting/threshold/partial-decryption-service.js.map +1 -0
  19. package/src/lib/voting/threshold/threshold-aggregators.d.ts +43 -0
  20. package/src/lib/voting/threshold/threshold-aggregators.d.ts.map +1 -0
  21. package/src/lib/voting/threshold/threshold-aggregators.js +53 -0
  22. package/src/lib/voting/threshold/threshold-aggregators.js.map +1 -0
  23. package/src/lib/voting/threshold/threshold-audit-log.d.ts +31 -0
  24. package/src/lib/voting/threshold/threshold-audit-log.d.ts.map +1 -0
  25. package/src/lib/voting/threshold/threshold-audit-log.js +101 -0
  26. package/src/lib/voting/threshold/threshold-audit-log.js.map +1 -0
  27. package/src/lib/voting/threshold/threshold-key-generator.d.ts +45 -0
  28. package/src/lib/voting/threshold/threshold-key-generator.d.ts.map +1 -0
  29. package/src/lib/voting/threshold/threshold-key-generator.js +60 -0
  30. package/src/lib/voting/threshold/threshold-key-generator.js.map +1 -0
  31. package/src/lib/voting/threshold/threshold-poll-factory.d.ts +16 -0
  32. package/src/lib/voting/threshold/threshold-poll-factory.d.ts.map +1 -0
  33. package/src/lib/voting/threshold/threshold-poll-factory.js +19 -0
  34. package/src/lib/voting/threshold/threshold-poll-factory.js.map +1 -0
  35. package/src/lib/voting/threshold/threshold-poll.d.ts +21 -0
  36. package/src/lib/voting/threshold/threshold-poll.d.ts.map +1 -0
  37. package/src/lib/voting/threshold/threshold-poll.js +22 -0
  38. package/src/lib/voting/threshold/threshold-poll.js.map +1 -0
  39. package/src/lib/voting/threshold-corporate-vote-example.d.ts +33 -0
  40. package/src/lib/voting/threshold-corporate-vote-example.d.ts.map +1 -0
  41. package/src/lib/voting/threshold-corporate-vote-example.js +206 -0
  42. package/src/lib/voting/threshold-corporate-vote-example.js.map +1 -0
  43. package/src/lib/voting/threshold-small-org-example.d.ts +38 -0
  44. package/src/lib/voting/threshold-small-org-example.d.ts.map +1 -0
  45. package/src/lib/voting/threshold-small-org-example.js +186 -0
  46. package/src/lib/voting/threshold-small-org-example.js.map +1 -0
  47. package/src/lib/voting/threshold-us-election-example.d.ts +33 -0
  48. package/src/lib/voting/threshold-us-election-example.d.ts.map +1 -0
  49. package/src/lib/voting/threshold-us-election-example.js +213 -0
  50. package/src/lib/voting/threshold-us-election-example.js.map +1 -0
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ /**
3
+ * Threshold Audit Log - Node.js Optimized
4
+ *
5
+ * Extends ecies-lib ThresholdAuditLog with Buffer support,
6
+ * converting Uint8Array fields (previousHash, entryHash, signature)
7
+ * to Buffer in returned entries.
8
+ *
9
+ * @module voting/threshold
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ThresholdAuditLog = void 0;
13
+ const ecies_lib_1 = require("@digitaldefiance/ecies-lib");
14
+ /**
15
+ * Convert Uint8Array fields in a ThresholdAuditEntry to Buffer.
16
+ */
17
+ function convertEntryToBuffer(entry) {
18
+ return {
19
+ ...entry,
20
+ previousHash: entry.previousHash instanceof Buffer
21
+ ? entry.previousHash
22
+ : Buffer.from(entry.previousHash),
23
+ entryHash: entry.entryHash instanceof Buffer
24
+ ? entry.entryHash
25
+ : Buffer.from(entry.entryHash),
26
+ signature: entry.signature instanceof Buffer
27
+ ? entry.signature
28
+ : Buffer.from(entry.signature),
29
+ };
30
+ }
31
+ /**
32
+ * Node.js ThresholdAuditLog that extends ecies-lib ThresholdAuditLog.
33
+ *
34
+ * Overrides methods to convert Uint8Array fields to Buffer in returned entries,
35
+ * following the same pattern as the node-ecies-lib ImmutableAuditLog.
36
+ */
37
+ class ThresholdAuditLog extends ecies_lib_1.ThresholdAuditLog {
38
+ constructor(authority) {
39
+ const authorityAdapter = {
40
+ ...authority,
41
+ sign: (data) => {
42
+ const bufferData = Buffer.isBuffer(data) ? data : Buffer.from(data);
43
+ const signature = authority.sign(bufferData);
44
+ return signature instanceof Uint8Array
45
+ ? signature
46
+ : new Uint8Array(signature);
47
+ },
48
+ verify: (signature, data) => {
49
+ const bufferSignature = Buffer.isBuffer(signature)
50
+ ? signature
51
+ : Buffer.from(signature);
52
+ const bufferData = Buffer.isBuffer(data) ? data : Buffer.from(data);
53
+ return authority.verify(bufferSignature, bufferData);
54
+ },
55
+ publicKey: authority.publicKey instanceof Uint8Array
56
+ ? authority.publicKey
57
+ : new Uint8Array(authority.publicKey),
58
+ idBytes: authority.idBytes instanceof Uint8Array
59
+ ? authority.idBytes
60
+ : new Uint8Array(authority.idBytes),
61
+ encryptDataStream: authority.encryptDataStream,
62
+ decryptDataStream: authority.decryptDataStream,
63
+ encryptData: authority.encryptData,
64
+ decryptData: authority.decryptData,
65
+ };
66
+ super(authorityAdapter);
67
+ }
68
+ recordKeyGeneration(pollId, metadata) {
69
+ return convertEntryToBuffer(super.recordKeyGeneration(pollId, metadata));
70
+ }
71
+ recordKeyShareDistribution(pollId, guardianId, guardianIndex, metadata) {
72
+ return convertEntryToBuffer(super.recordKeyShareDistribution(pollId, guardianId, guardianIndex, metadata));
73
+ }
74
+ recordCeremonyStarted(pollId, ceremonyId, metadata) {
75
+ return convertEntryToBuffer(super.recordCeremonyStarted(pollId, ceremonyId, metadata));
76
+ }
77
+ recordPartialSubmitted(pollId, ceremonyId, guardianId, guardianIndex, metadata) {
78
+ return convertEntryToBuffer(super.recordPartialSubmitted(pollId, ceremonyId, guardianId, guardianIndex, metadata));
79
+ }
80
+ recordCeremonyCompleted(pollId, ceremonyId, metadata) {
81
+ return convertEntryToBuffer(super.recordCeremonyCompleted(pollId, ceremonyId, metadata));
82
+ }
83
+ recordTallyPublished(pollId, metadata) {
84
+ return convertEntryToBuffer(super.recordTallyPublished(pollId, metadata));
85
+ }
86
+ getEntries() {
87
+ return super.getEntries().map((entry) => convertEntryToBuffer(entry));
88
+ }
89
+ getEntriesForPoll(pollId) {
90
+ return super
91
+ .getEntriesForPoll(pollId)
92
+ .map((entry) => convertEntryToBuffer(entry));
93
+ }
94
+ getEntriesForCeremony(ceremonyId) {
95
+ return super
96
+ .getEntriesForCeremony(ceremonyId)
97
+ .map((entry) => convertEntryToBuffer(entry));
98
+ }
99
+ }
100
+ exports.ThresholdAuditLog = ThresholdAuditLog;
101
+ //# sourceMappingURL=threshold-audit-log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"threshold-audit-log.js","sourceRoot":"","sources":["../../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/threshold/threshold-audit-log.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEH,0DAIoC;AAMpC;;GAEG;AACH,SAAS,oBAAoB,CAC3B,KAA+B;IAE/B,OAAO;QACL,GAAG,KAAK;QACR,YAAY,EACV,KAAK,CAAC,YAAY,YAAY,MAAM;YAClC,CAAC,CAAC,KAAK,CAAC,YAAY;YACpB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC;QACrC,SAAS,EACP,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MAAW,EACX,UAAkB,EAClB,QAAmD;QAEnD,OAAO,oBAAoB,CACzB,KAAK,CAAC,uBAAuB,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,CAC5D,CAAC;IACJ,CAAC;IAED,oBAAoB,CAClB,MAAW,EACX,QAAmD;QAEnD,OAAO,oBAAoB,CAAC,KAAK,CAAC,oBAAoB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC5E,CAAC;IAED,UAAU;QACR,OAAO,KAAK,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC;IACxE,CAAC;IAED,iBAAiB,CAAC,MAAW;QAC3B,OAAO,KAAK;aACT,iBAAiB,CAAC,MAAM,CAAC;aACzB,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,qBAAqB,CACnB,UAAkB;QAElB,OAAO,KAAK;aACT,qBAAqB,CAAC,UAAU,CAAC;aACjC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC;IACjD,CAAC;CACF;AAtID,8CAsIC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Threshold Key Generator - Node.js Optimized
3
+ *
4
+ * Extends ecies-lib ThresholdKeyGenerator with Buffer support for
5
+ * key shares and verification keys.
6
+ *
7
+ * @module voting/threshold
8
+ */
9
+ import { ThresholdKeyGenerator as BaseThresholdKeyGenerator } from '@digitaldefiance/ecies-lib';
10
+ import type { ThresholdKeyConfig, ThresholdKeyPair, KeyShare } from '@digitaldefiance/ecies-lib';
11
+ /**
12
+ * Buffer-based key share with verification key as Buffer.
13
+ */
14
+ export interface BufferKeyShare extends Omit<KeyShare, 'verificationKey'> {
15
+ readonly verificationKey: Buffer;
16
+ }
17
+ /**
18
+ * Buffer-based threshold key pair with Buffer verification keys and key shares.
19
+ */
20
+ export interface BufferThresholdKeyPair extends Omit<ThresholdKeyPair, 'verificationKeys' | 'keyShares'> {
21
+ readonly verificationKeys: readonly Buffer[];
22
+ readonly keyShares: readonly BufferKeyShare[];
23
+ }
24
+ /**
25
+ * Node.js ThresholdKeyGenerator that extends ecies-lib ThresholdKeyGenerator.
26
+ *
27
+ * Overrides `generate()` to return Buffer-based key shares and verification keys
28
+ * instead of Uint8Array-based ones.
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * const generator = new ThresholdKeyGenerator();
33
+ * const keyPair = await generator.generate({ totalShares: 5, threshold: 3 });
34
+ *
35
+ * // keyPair.keyShares[0].verificationKey is a Buffer
36
+ * // keyPair.verificationKeys[0] is a Buffer
37
+ * ```
38
+ */
39
+ export declare class ThresholdKeyGenerator extends BaseThresholdKeyGenerator {
40
+ /**
41
+ * Generate a threshold key pair with Buffer-based outputs.
42
+ */
43
+ generate(config: ThresholdKeyConfig): Promise<BufferThresholdKeyPair>;
44
+ }
45
+ //# sourceMappingURL=threshold-key-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"threshold-key-generator.d.ts","sourceRoot":"","sources":["../../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/threshold/threshold-key-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,qBAAqB,IAAI,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAChG,OAAO,KAAK,EACV,kBAAkB,EAClB,gBAAgB,EAChB,QAAQ,EACT,MAAM,4BAA4B,CAAC;AAEpC;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACvE,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,IAAI,CAClD,gBAAgB,EAChB,kBAAkB,GAAG,WAAW,CACjC;IACC,QAAQ,CAAC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C,QAAQ,CAAC,SAAS,EAAE,SAAS,cAAc,EAAE,CAAC;CAC/C;AA4BD;;;;;;;;;;;;;;GAcG;AACH,qBAAa,qBAAsB,SAAQ,yBAAyB;IAClE;;OAEG;IACG,QAAQ,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAI5E"}
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ /**
3
+ * Threshold Key Generator - Node.js Optimized
4
+ *
5
+ * Extends ecies-lib ThresholdKeyGenerator with Buffer support for
6
+ * key shares and verification keys.
7
+ *
8
+ * @module voting/threshold
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.ThresholdKeyGenerator = void 0;
12
+ const ecies_lib_1 = require("@digitaldefiance/ecies-lib");
13
+ /**
14
+ * Convert a Uint8Array-based KeyShare to a Buffer-based BufferKeyShare.
15
+ */
16
+ function convertKeyShareToBuffer(share) {
17
+ return {
18
+ index: share.index,
19
+ share: share.share,
20
+ verificationKey: Buffer.from(share.verificationKey),
21
+ };
22
+ }
23
+ /**
24
+ * Convert a Uint8Array-based ThresholdKeyPair to a Buffer-based BufferThresholdKeyPair.
25
+ */
26
+ function convertKeyPairToBuffer(keyPair) {
27
+ return {
28
+ publicKey: keyPair.publicKey,
29
+ verificationKeys: keyPair.verificationKeys.map((vk) => Buffer.from(vk)),
30
+ keyShares: keyPair.keyShares.map(convertKeyShareToBuffer),
31
+ config: keyPair.config,
32
+ theta: keyPair.theta,
33
+ };
34
+ }
35
+ /**
36
+ * Node.js ThresholdKeyGenerator that extends ecies-lib ThresholdKeyGenerator.
37
+ *
38
+ * Overrides `generate()` to return Buffer-based key shares and verification keys
39
+ * instead of Uint8Array-based ones.
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * const generator = new ThresholdKeyGenerator();
44
+ * const keyPair = await generator.generate({ totalShares: 5, threshold: 3 });
45
+ *
46
+ * // keyPair.keyShares[0].verificationKey is a Buffer
47
+ * // keyPair.verificationKeys[0] is a Buffer
48
+ * ```
49
+ */
50
+ class ThresholdKeyGenerator extends ecies_lib_1.ThresholdKeyGenerator {
51
+ /**
52
+ * Generate a threshold key pair with Buffer-based outputs.
53
+ */
54
+ async generate(config) {
55
+ const baseKeyPair = await super.generate(config);
56
+ return convertKeyPairToBuffer(baseKeyPair);
57
+ }
58
+ }
59
+ exports.ThresholdKeyGenerator = ThresholdKeyGenerator;
60
+ //# sourceMappingURL=threshold-key-generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"threshold-key-generator.js","sourceRoot":"","sources":["../../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/threshold/threshold-key-generator.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAEH,0DAAgG;AAyBhG;;GAEG;AACH,SAAS,uBAAuB,CAAC,KAAe;IAC9C,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,eAAe,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC;KACpD,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,sBAAsB,CAC7B,OAAyB;IAEzB,OAAO;QACL,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACvE,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,uBAAuB,CAAC;QACzD,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,KAAK,EAAE,OAAO,CAAC,KAAK;KACrB,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAa,qBAAsB,SAAQ,iCAAyB;IAClE;;OAEG;IACH,KAAK,CAAC,QAAQ,CAAC,MAA0B;QACvC,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACjD,OAAO,sBAAsB,CAAC,WAAW,CAAC,CAAC;IAC7C,CAAC;CACF;AARD,sDAQC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Threshold Poll Factory - Node.js Optimized
3
+ *
4
+ * Extends ecies-lib ThresholdPollFactory with Buffer as the default TID type.
5
+ *
6
+ * @module voting/threshold
7
+ */
8
+ import { ThresholdPollFactory as BaseThresholdPollFactory } from '@digitaldefiance/ecies-lib';
9
+ import type { PlatformID } from '../../../interfaces';
10
+ /**
11
+ * Node.js ThresholdPollFactory that extends ecies-lib ThresholdPollFactory.
12
+ * Specializes the generic TID parameter to Buffer by default.
13
+ */
14
+ export declare class ThresholdPollFactory<TID extends PlatformID = Buffer> extends BaseThresholdPollFactory<TID> {
15
+ }
16
+ //# sourceMappingURL=threshold-poll-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"threshold-poll-factory.d.ts","sourceRoot":"","sources":["../../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/threshold/threshold-poll-factory.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,oBAAoB,IAAI,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAE9F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;;GAGG;AACH,qBAAa,oBAAoB,CAC/B,GAAG,SAAS,UAAU,GAAG,MAAM,CAC/B,SAAQ,wBAAwB,CAAC,GAAG,CAAC;CAGtC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ /**
3
+ * Threshold Poll Factory - Node.js Optimized
4
+ *
5
+ * Extends ecies-lib ThresholdPollFactory with Buffer as the default TID type.
6
+ *
7
+ * @module voting/threshold
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.ThresholdPollFactory = void 0;
11
+ const ecies_lib_1 = require("@digitaldefiance/ecies-lib");
12
+ /**
13
+ * Node.js ThresholdPollFactory that extends ecies-lib ThresholdPollFactory.
14
+ * Specializes the generic TID parameter to Buffer by default.
15
+ */
16
+ class ThresholdPollFactory extends ecies_lib_1.ThresholdPollFactory {
17
+ }
18
+ exports.ThresholdPollFactory = ThresholdPollFactory;
19
+ //# sourceMappingURL=threshold-poll-factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"threshold-poll-factory.js","sourceRoot":"","sources":["../../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/threshold/threshold-poll-factory.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,0DAA8F;AAI9F;;;GAGG;AACH,MAAa,oBAEX,SAAQ,gCAA6B;CAGtC;AALD,oDAKC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Threshold Poll - Node.js Optimized
3
+ *
4
+ * Extends ecies-lib ThresholdPoll with Buffer as the default TID type.
5
+ *
6
+ * @module voting/threshold
7
+ */
8
+ import { ThresholdPoll as BaseThresholdPoll } from '@digitaldefiance/ecies-lib';
9
+ import type { ThresholdPollConfig } from '@digitaldefiance/ecies-lib';
10
+ import type { PublicKey } from 'paillier-bigint';
11
+ import type { PlatformID } from '../../../interfaces';
12
+ import type { IMember } from '../../../interfaces/member';
13
+ import type { VotingMethod } from '../enumerations';
14
+ /**
15
+ * Node.js ThresholdPoll that extends ecies-lib ThresholdPoll.
16
+ * Specializes the generic TID parameter to Buffer by default.
17
+ */
18
+ export declare class ThresholdPoll<TID extends PlatformID = Buffer> extends BaseThresholdPoll<TID> {
19
+ constructor(id: TID, choices: string[], method: VotingMethod, authority: IMember<TID>, publicKey: PublicKey, config: ThresholdPollConfig<TID>);
20
+ }
21
+ //# sourceMappingURL=threshold-poll.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"threshold-poll.d.ts","sourceRoot":"","sources":["../../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/threshold/threshold-poll.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,KAAK,EAEV,mBAAmB,EACpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;GAGG;AACH,qBAAa,aAAa,CACxB,GAAG,SAAS,UAAU,GAAG,MAAM,CAC/B,SAAQ,iBAAiB,CAAC,GAAG,CAAC;gBAE5B,EAAE,EAAE,GAAG,EACP,OAAO,EAAE,MAAM,EAAE,EACjB,MAAM,EAAE,YAAY,EACpB,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,EACvB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,mBAAmB,CAAC,GAAG,CAAC;CAWnC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ /**
3
+ * Threshold Poll - Node.js Optimized
4
+ *
5
+ * Extends ecies-lib ThresholdPoll with Buffer as the default TID type.
6
+ *
7
+ * @module voting/threshold
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.ThresholdPoll = void 0;
11
+ const ecies_lib_1 = require("@digitaldefiance/ecies-lib");
12
+ /**
13
+ * Node.js ThresholdPoll that extends ecies-lib ThresholdPoll.
14
+ * Specializes the generic TID parameter to Buffer by default.
15
+ */
16
+ class ThresholdPoll extends ecies_lib_1.ThresholdPoll {
17
+ constructor(id, choices, method, authority, publicKey, config) {
18
+ super(id, choices, method, authority, publicKey, config);
19
+ }
20
+ }
21
+ exports.ThresholdPoll = ThresholdPoll;
22
+ //# sourceMappingURL=threshold-poll.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"threshold-poll.js","sourceRoot":"","sources":["../../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/threshold/threshold-poll.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,0DAAgF;AAWhF;;;GAGG;AACH,MAAa,aAEX,SAAQ,yBAAsB;IAC9B,YACE,EAAO,EACP,OAAiB,EACjB,MAAoB,EACpB,SAAuB,EACvB,SAAoB,EACpB,MAAgC;QAEhC,KAAK,CACH,EAAE,EACF,OAAO,EACP,MAAM,EACN,SAA6B,EAC7B,SAAS,EACT,MAAM,CACP,CAAC;IACJ,CAAC;CACF;AApBD,sCAoBC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Threshold Corporate Shareholder Vote Example
3
+ *
4
+ * Demonstrates a 3-of-5 Guardian threshold voting setup with
5
+ * vote-count-based interval decryption — modeled after a corporate
6
+ * shareholder vote where results are revealed as voting milestones
7
+ * are reached.
8
+ *
9
+ * Key concepts shown:
10
+ * - Threshold key generation (3-of-5)
11
+ * - Guardian registration (board members / auditors)
12
+ * - Vote-count-based interval decryption (every 500 votes)
13
+ * - Real-time tally feed for stakeholders
14
+ * - Ceremony coordination with partial decryptions
15
+ *
16
+ * NOTE: This example is for documentation purposes and demonstrates the
17
+ * intended API. Due to type incompatibilities between ecies-lib Member
18
+ * (Uint8Array) and node-ecies-lib voting system (Buffer), some type
19
+ * assertions may be needed in actual usage. See test files for working
20
+ * integration examples.
21
+ */
22
+ /**
23
+ * Run a simulated corporate shareholder vote with threshold decryption.
24
+ *
25
+ * Setup:
26
+ * - 5 Guardians (board chair, CFO, external auditor, legal counsel, shareholder rep)
27
+ * - Threshold of 3 (majority of Guardians required)
28
+ * - Vote-count-based intervals (every 500 votes)
29
+ * - Real-time feed for investor relations
30
+ */
31
+ declare function runCorporateShareholderVote(): Promise<void>;
32
+ export { runCorporateShareholderVote };
33
+ //# sourceMappingURL=threshold-corporate-vote-example.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"threshold-corporate-vote-example.d.ts","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/threshold-corporate-vote-example.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAmBH;;;;;;;;GAQG;AACH,iBAAe,2BAA2B,IAAI,OAAO,CAAC,IAAI,CAAC,CAyO1D;AAOD,OAAO,EAAE,2BAA2B,EAAE,CAAC"}
@@ -0,0 +1,206 @@
1
+ "use strict";
2
+ /**
3
+ * Threshold Corporate Shareholder Vote Example
4
+ *
5
+ * Demonstrates a 3-of-5 Guardian threshold voting setup with
6
+ * vote-count-based interval decryption — modeled after a corporate
7
+ * shareholder vote where results are revealed as voting milestones
8
+ * are reached.
9
+ *
10
+ * Key concepts shown:
11
+ * - Threshold key generation (3-of-5)
12
+ * - Guardian registration (board members / auditors)
13
+ * - Vote-count-based interval decryption (every 500 votes)
14
+ * - Real-time tally feed for stakeholders
15
+ * - Ceremony coordination with partial decryptions
16
+ *
17
+ * NOTE: This example is for documentation purposes and demonstrates the
18
+ * intended API. Due to type incompatibilities between ecies-lib Member
19
+ * (Uint8Array) and node-ecies-lib voting system (Buffer), some type
20
+ * assertions may be needed in actual usage. See test files for working
21
+ * integration examples.
22
+ */
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.runCorporateShareholderVote = runCorporateShareholderVote;
25
+ const threshold_1 = require("./threshold");
26
+ /**
27
+ * Run a simulated corporate shareholder vote with threshold decryption.
28
+ *
29
+ * Setup:
30
+ * - 5 Guardians (board chair, CFO, external auditor, legal counsel, shareholder rep)
31
+ * - Threshold of 3 (majority of Guardians required)
32
+ * - Vote-count-based intervals (every 500 votes)
33
+ * - Real-time feed for investor relations
34
+ */
35
+ async function runCorporateShareholderVote() {
36
+ console.log('=== Corporate Shareholder Vote ===\n');
37
+ console.log('Configuration: 3-of-5 Guardian threshold');
38
+ console.log('Interval: Every 500 votes\n');
39
+ // ─── Step 1: Generate threshold keys ───────────────────────────
40
+ console.log('Step 1: Generating threshold keys...');
41
+ const thresholdConfig = {
42
+ totalShares: 5,
43
+ threshold: 3,
44
+ keyBitLength: 512, // Small for demo; use 2048+ in production
45
+ };
46
+ const keyGen = new threshold_1.ThresholdKeyGenerator();
47
+ keyGen.validateConfig(thresholdConfig);
48
+ const keyPair = await keyGen.generate(thresholdConfig);
49
+ console.log(` ${keyPair.keyShares.length} key shares generated`);
50
+ console.log(` Threshold: ${thresholdConfig.threshold} of ${thresholdConfig.totalShares}\n`);
51
+ // ─── Step 2: Register Guardians ────────────────────────────────
52
+ console.log('Step 2: Registering 5 Guardians...');
53
+ const guardianNames = [
54
+ 'Board Chairperson',
55
+ 'Chief Financial Officer',
56
+ 'External Auditor (Deloitte)',
57
+ 'General Counsel',
58
+ 'Shareholder Representative',
59
+ ];
60
+ const registry = new threshold_1.GuardianRegistry(thresholdConfig.totalShares);
61
+ const guardianIds = [];
62
+ for (let i = 0; i < thresholdConfig.totalShares; i++) {
63
+ const id = Buffer.from([i + 1]);
64
+ guardianIds.push(id);
65
+ const guardian = {
66
+ id,
67
+ name: guardianNames[i],
68
+ shareIndex: keyPair.keyShares[i].index,
69
+ verificationKey: keyPair.keyShares[i].verificationKey,
70
+ status: threshold_1.GuardianStatus.Online,
71
+ };
72
+ registry.register(guardian);
73
+ console.log(` [${i + 1}] ${guardianNames[i]} — Online`);
74
+ }
75
+ console.log(` Total registered: ${registry.count}\n`);
76
+ // ─── Step 3: Configure vote-count-based intervals ──────────────
77
+ console.log('Step 3: Configuring vote-count-based intervals...');
78
+ const intervalConfig = {
79
+ triggerType: threshold_1.IntervalTriggerType.VoteCountBased,
80
+ voteCountInterval: 500, // Decrypt every 500 votes
81
+ minimumIntervalMs: 60 * 1000, // 1 min minimum between ceremonies
82
+ ceremonyTimeoutMs: 3 * 60 * 1000, // 3 min timeout
83
+ };
84
+ // Demonstrate the interval scheduler
85
+ const pollId = Buffer.from([0, 0, 1]);
86
+ const scheduler = new threshold_1.IntervalScheduler();
87
+ scheduler.configure(pollId, intervalConfig);
88
+ // Track triggers
89
+ scheduler.onTrigger((event) => {
90
+ console.log(` ⏰ Interval trigger #${event.intervalNumber}: ` +
91
+ `${event.triggerReason} (${event.currentVoteCount} votes)`);
92
+ });
93
+ console.log(` Trigger: ${intervalConfig.triggerType}`);
94
+ console.log(` Every ${intervalConfig.voteCountInterval} votes`);
95
+ console.log(` Ceremony timeout: ${intervalConfig.ceremonyTimeoutMs / 1000}s\n`);
96
+ // ─── Step 4: Set up tally feed for stakeholders ────────────────
97
+ console.log('Step 4: Setting up stakeholder tally feed...');
98
+ const tallyFeed = new threshold_1.PublicTallyFeed();
99
+ // Investor relations subscriber
100
+ const irSubscription = tallyFeed.subscribe(pollId, (tally) => {
101
+ console.log(` 📊 IR Update — Interval ${tally.intervalNumber}:`);
102
+ tally.choices.forEach((choice, i) => {
103
+ const votes = tally.tallies[i];
104
+ const pct = tally.cumulativeVoteCount > 0
105
+ ? ((Number(votes) / tally.cumulativeVoteCount) * 100).toFixed(1)
106
+ : '0.0';
107
+ console.log(` ${choice}: ${votes} shares (${pct}%)`);
108
+ });
109
+ console.log(` Total shares voted: ${tally.cumulativeVoteCount}`);
110
+ console.log(` Guardians: ${tally.participatingGuardians.length}/5\n`);
111
+ });
112
+ console.log(' Investor Relations subscription active\n');
113
+ // ─── Step 5: Simulate vote-count milestone ceremony ────────────
114
+ console.log('Step 5: Simulating decryption at 500-vote milestone...');
115
+ // Proposal: "Approve merger with TechCorp Inc."
116
+ const choices = ['Approve', 'Reject', 'Abstain'];
117
+ // Simulate encrypted tallies after 500 votes
118
+ const votesAtMilestone = [280n, 150n, 70n]; // 500 total shares voted
119
+ const encryptedTally = votesAtMilestone.map((v) => keyPair.publicKey.encrypt(v));
120
+ // Create ceremony coordinator
121
+ const coordinator = new threshold_1.CeremonyCoordinator(keyPair.publicKey, keyPair.verificationKeys, keyPair.theta, thresholdConfig, intervalConfig.ceremonyTimeoutMs);
122
+ // Start ceremony
123
+ const ceremony = coordinator.startCeremony(pollId, 1, encryptedTally);
124
+ console.log(` Ceremony started: ${ceremony.id.slice(0, 16)}...`);
125
+ // 3 of 5 Guardians participate (Board Chair, CFO, External Auditor)
126
+ const partialService = new threshold_1.PartialDecryptionService(keyPair.publicKey);
127
+ const participatingIndices = [0, 1, 2]; // First 3 Guardians
128
+ console.log('\n Collecting partial decryptions (3 of 5):');
129
+ for (const idx of participatingIndices) {
130
+ const share = keyPair.keyShares[idx];
131
+ const partial = partialService.computePartial(encryptedTally, share, ceremony.nonce);
132
+ const accepted = coordinator.submitPartial(ceremony.id, partial);
133
+ console.log(` ${guardianNames[idx]}: ${accepted ? '✓' : '✗'}`);
134
+ }
135
+ console.log(`\n Ceremony status: ${ceremony.status}`);
136
+ // ─── Step 6: Publish milestone results ─────────────────────────
137
+ if (ceremony.result) {
138
+ console.log('\nStep 6: Publishing milestone tally...');
139
+ const intervalTally = {
140
+ pollId,
141
+ intervalNumber: 1,
142
+ tallies: ceremony.result.tallies,
143
+ choices,
144
+ voteCount: 500,
145
+ cumulativeVoteCount: 500,
146
+ proof: ceremony.result.combinedProof,
147
+ participatingGuardians: ceremony.result.participatingGuardians,
148
+ timestamp: Date.now(),
149
+ isFinal: false,
150
+ };
151
+ // Triggers IR subscriber callback
152
+ tallyFeed.publish(intervalTally);
153
+ // Show running totals
154
+ const history = tallyFeed.getHistory(pollId);
155
+ console.log(` Published intervals: ${history.length}`);
156
+ }
157
+ // ─── Step 7: Simulate final ceremony at vote close ─────────────
158
+ console.log('\nStep 7: Simulating final ceremony (all shares voted)...');
159
+ const finalVotes = [1200n, 650n, 150n]; // 2000 total shares
160
+ const finalEncrypted = finalVotes.map((v) => keyPair.publicKey.encrypt(v));
161
+ const finalCeremony = coordinator.startCeremony(pollId, -1, finalEncrypted);
162
+ // All 5 Guardians participate for the final tally
163
+ console.log(' All 5 Guardians participating in final ceremony:');
164
+ for (let idx = 0; idx < thresholdConfig.totalShares; idx++) {
165
+ const share = keyPair.keyShares[idx];
166
+ const partial = partialService.computePartial(finalEncrypted, share, finalCeremony.nonce);
167
+ const accepted = coordinator.submitPartial(finalCeremony.id, partial);
168
+ console.log(` ${guardianNames[idx]}: ${accepted ? '✓' : '✗'}`);
169
+ }
170
+ if (finalCeremony.result) {
171
+ const finalTally = {
172
+ pollId,
173
+ intervalNumber: -1,
174
+ tallies: finalCeremony.result.tallies,
175
+ choices,
176
+ voteCount: 2000,
177
+ cumulativeVoteCount: 2000,
178
+ proof: finalCeremony.result.combinedProof,
179
+ participatingGuardians: finalCeremony.result.participatingGuardians,
180
+ timestamp: Date.now(),
181
+ isFinal: true,
182
+ };
183
+ tallyFeed.publish(finalTally);
184
+ console.log('\n === FINAL RESULTS ===');
185
+ choices.forEach((choice, i) => {
186
+ const votes = finalCeremony.result.tallies[i];
187
+ const pct = ((Number(votes) / 2000) * 100).toFixed(1);
188
+ console.log(` ${choice}: ${votes} shares (${pct}%)`);
189
+ });
190
+ const approvalPct = (Number(finalCeremony.result.tallies[0]) / 2000) * 100;
191
+ console.log(`\n Merger ${approvalPct > 50 ? 'APPROVED' : 'REJECTED'} (${approvalPct.toFixed(1)}% approval)`);
192
+ }
193
+ // Cleanup
194
+ irSubscription.unsubscribe();
195
+ console.log('\n=== Corporate vote simulation complete ===');
196
+ console.log('In production:');
197
+ console.log(' - Shareholders vote via secure portal');
198
+ console.log(' - Results update every 500 votes cast');
199
+ console.log(' - Board Guardians coordinate decryption ceremonies');
200
+ console.log(' - External auditor verifies all proofs independently');
201
+ }
202
+ // Run example
203
+ if (require.main === module) {
204
+ runCorporateShareholderVote().catch(console.error);
205
+ }
206
+ //# sourceMappingURL=threshold-corporate-vote-example.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"threshold-corporate-vote-example.js","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/threshold-corporate-vote-example.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;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;AACd,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,2BAA2B,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACrD,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Threshold Small Organization Vote Example
3
+ *
4
+ * Demonstrates a 2-of-3 Guardian threshold voting setup with a single
5
+ * decryption at poll close — backward-compatible behavior where no
6
+ * interval decryption occurs during voting.
7
+ *
8
+ * This is the simplest threshold configuration, suitable for:
9
+ * - Small nonprofits or clubs
10
+ * - Board elections
11
+ * - Committee decisions
12
+ * - Any scenario where real-time tallies aren't needed but distributed
13
+ * trust is still desired
14
+ *
15
+ * Key concepts shown:
16
+ * - Minimal threshold setup (2-of-3)
17
+ * - Single decryption at poll close (no intervals)
18
+ * - Backward-compatible behavior with threshold security
19
+ * - Simple ceremony flow
20
+ *
21
+ * NOTE: This example is for documentation purposes and demonstrates the
22
+ * intended API. Due to type incompatibilities between ecies-lib Member
23
+ * (Uint8Array) and node-ecies-lib voting system (Buffer), some type
24
+ * assertions may be needed in actual usage. See test files for working
25
+ * integration examples.
26
+ */
27
+ /**
28
+ * Run a simulated small organization vote with threshold decryption.
29
+ *
30
+ * Setup:
31
+ * - 3 Guardians (president, secretary, treasurer)
32
+ * - Threshold of 2 (any two officers can decrypt)
33
+ * - Single decryption at poll close (no interval decryption)
34
+ * - Behaves like a standard poll but with distributed trust
35
+ */
36
+ declare function runSmallOrgVote(): Promise<void>;
37
+ export { runSmallOrgVote };
38
+ //# sourceMappingURL=threshold-small-org-example.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"threshold-small-org-example.d.ts","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/threshold-small-org-example.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAmBH;;;;;;;;GAQG;AACH,iBAAe,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAgN9C;AAOD,OAAO,EAAE,eAAe,EAAE,CAAC"}