@digitaldefiance/node-ecies-lib 4.8.2 → 4.10.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +195 -13
- package/package.json +10 -5
- package/src/constants.d.ts.map +1 -1
- package/src/constants.js +31 -25
- package/src/constants.js.map +1 -1
- package/src/interfaces/index.d.ts +1 -2
- package/src/interfaces/index.d.ts.map +1 -1
- package/src/interfaces/index.js +6 -3
- package/src/interfaces/index.js.map +1 -1
- package/src/interfaces/member.d.ts +30 -12
- package/src/interfaces/member.d.ts.map +1 -1
- package/src/interfaces/platform-buffer.d.ts +9 -0
- package/src/interfaces/platform-buffer.d.ts.map +1 -0
- package/src/interfaces/platform-buffer.js +3 -0
- package/src/interfaces/platform-buffer.js.map +1 -0
- package/src/interfaces/platform-id.d.ts +2 -2
- package/src/interfaces/platform-id.d.ts.map +1 -1
- package/src/lib/id-providers/buffer-provider.d.ts +54 -0
- package/src/lib/id-providers/buffer-provider.d.ts.map +1 -0
- package/src/lib/id-providers/buffer-provider.js +93 -0
- package/src/lib/id-providers/buffer-provider.js.map +1 -0
- package/src/lib/index.d.ts +1 -0
- package/src/lib/index.d.ts.map +1 -1
- package/src/lib/index.js +1 -0
- package/src/lib/index.js.map +1 -1
- package/src/lib/voting/audit.d.ts +39 -48
- package/src/lib/voting/audit.d.ts.map +1 -1
- package/src/lib/voting/audit.js +103 -111
- package/src/lib/voting/audit.js.map +1 -1
- package/src/lib/voting/bulletin-board.d.ts +47 -81
- package/src/lib/voting/bulletin-board.d.ts.map +1 -1
- package/src/lib/voting/bulletin-board.js +95 -231
- package/src/lib/voting/bulletin-board.js.map +1 -1
- package/src/lib/voting/encoder.d.ts +7 -16
- package/src/lib/voting/encoder.d.ts.map +1 -1
- package/src/lib/voting/encoder.js +11 -107
- package/src/lib/voting/encoder.js.map +1 -1
- package/src/lib/voting/enumerations/index.d.ts +6 -0
- package/src/lib/voting/enumerations/index.d.ts.map +1 -0
- package/src/lib/voting/enumerations/index.js +14 -0
- package/src/lib/voting/enumerations/index.js.map +1 -0
- package/src/lib/voting/event-logger.d.ts +13 -74
- package/src/lib/voting/event-logger.d.ts.map +1 -1
- package/src/lib/voting/event-logger.js +19 -140
- package/src/lib/voting/event-logger.js.map +1 -1
- package/src/lib/voting/examples.d.ts +112 -0
- package/src/lib/voting/examples.d.ts.map +1 -0
- package/src/lib/voting/examples.js +386 -0
- package/src/lib/voting/examples.js.map +1 -0
- package/src/lib/voting/factory.d.ts +38 -9
- package/src/lib/voting/factory.d.ts.map +1 -1
- package/src/lib/voting/factory.js +42 -8
- package/src/lib/voting/factory.js.map +1 -1
- package/src/lib/voting/hierarchical-aggregator.d.ts +44 -0
- package/src/lib/voting/hierarchical-aggregator.d.ts.map +1 -0
- package/src/lib/voting/hierarchical-aggregator.js +56 -0
- package/src/lib/voting/hierarchical-aggregator.js.map +1 -0
- package/src/lib/voting/index.d.ts +43 -7
- package/src/lib/voting/index.d.ts.map +1 -1
- package/src/lib/voting/index.js +53 -10
- package/src/lib/voting/index.js.map +1 -1
- package/src/lib/voting/interfaces/aggregated-tally.d.ts +10 -0
- package/src/lib/voting/interfaces/aggregated-tally.d.ts.map +1 -0
- package/src/lib/voting/interfaces/aggregated-tally.js +3 -0
- package/src/lib/voting/interfaces/aggregated-tally.js.map +1 -0
- package/src/lib/voting/interfaces/audit-entry.d.ts +10 -0
- package/src/lib/voting/interfaces/audit-entry.d.ts.map +1 -0
- package/src/lib/voting/interfaces/audit-entry.js +3 -0
- package/src/lib/voting/interfaces/audit-entry.js.map +1 -0
- package/src/lib/voting/interfaces/audit-log.d.ts +10 -0
- package/src/lib/voting/interfaces/audit-log.d.ts.map +1 -0
- package/src/lib/voting/interfaces/audit-log.js +3 -0
- package/src/lib/voting/interfaces/audit-log.js.map +1 -0
- package/src/lib/voting/interfaces/bulletin-board-entry.d.ts +10 -0
- package/src/lib/voting/interfaces/bulletin-board-entry.d.ts.map +1 -0
- package/src/lib/voting/interfaces/bulletin-board-entry.js +3 -0
- package/src/lib/voting/interfaces/bulletin-board-entry.js.map +1 -0
- package/src/lib/voting/interfaces/bulletin-board.d.ts +10 -0
- package/src/lib/voting/interfaces/bulletin-board.d.ts.map +1 -0
- package/src/lib/voting/interfaces/bulletin-board.js +3 -0
- package/src/lib/voting/interfaces/bulletin-board.js.map +1 -0
- package/src/lib/voting/interfaces/checkpoint-manager-extended.d.ts +10 -0
- package/src/lib/voting/interfaces/checkpoint-manager-extended.d.ts.map +1 -0
- package/src/lib/voting/interfaces/checkpoint-manager-extended.js +3 -0
- package/src/lib/voting/interfaces/checkpoint-manager-extended.js.map +1 -0
- package/src/lib/voting/interfaces/checkpoint-manager.d.ts +9 -0
- package/src/lib/voting/interfaces/checkpoint-manager.d.ts.map +1 -0
- package/src/lib/voting/interfaces/checkpoint-manager.js +3 -0
- package/src/lib/voting/interfaces/checkpoint-manager.js.map +1 -0
- package/src/lib/voting/interfaces/checkpoint-metadata.d.ts +8 -0
- package/src/lib/voting/interfaces/checkpoint-metadata.d.ts.map +1 -0
- package/src/lib/voting/interfaces/checkpoint-metadata.js +3 -0
- package/src/lib/voting/interfaces/checkpoint-metadata.js.map +1 -0
- package/src/lib/voting/interfaces/ecies-service-with-voting.d.ts +8 -0
- package/src/lib/voting/interfaces/ecies-service-with-voting.d.ts.map +1 -0
- package/src/lib/voting/interfaces/ecies-service-with-voting.js +3 -0
- package/src/lib/voting/interfaces/ecies-service-with-voting.js.map +1 -0
- package/src/lib/voting/interfaces/encrypted-vote.d.ts +10 -0
- package/src/lib/voting/interfaces/encrypted-vote.d.ts.map +1 -0
- package/src/lib/voting/interfaces/encrypted-vote.js +3 -0
- package/src/lib/voting/interfaces/encrypted-vote.js.map +1 -0
- package/src/lib/voting/interfaces/event-log-entry.d.ts +10 -0
- package/src/lib/voting/interfaces/event-log-entry.d.ts.map +1 -0
- package/src/lib/voting/interfaces/event-log-entry.js +3 -0
- package/src/lib/voting/interfaces/event-log-entry.js.map +1 -0
- package/src/lib/voting/interfaces/event-logger.d.ts +10 -0
- package/src/lib/voting/interfaces/event-logger.d.ts.map +1 -0
- package/src/lib/voting/interfaces/event-logger.js +3 -0
- package/src/lib/voting/interfaces/event-logger.js.map +1 -0
- package/src/lib/voting/interfaces/index.d.ts +37 -0
- package/src/lib/voting/interfaces/index.d.ts.map +1 -0
- package/src/lib/voting/interfaces/index.js +9 -0
- package/src/lib/voting/interfaces/index.js.map +1 -0
- package/src/lib/voting/interfaces/jurisdiction-config.d.ts +10 -0
- package/src/lib/voting/interfaces/jurisdiction-config.d.ts.map +1 -0
- package/src/lib/voting/interfaces/jurisdiction-config.js +3 -0
- package/src/lib/voting/interfaces/jurisdiction-config.js.map +1 -0
- package/src/lib/voting/interfaces/plaintext-vote.d.ts +10 -0
- package/src/lib/voting/interfaces/plaintext-vote.d.ts.map +1 -0
- package/src/lib/voting/interfaces/plaintext-vote.js +3 -0
- package/src/lib/voting/interfaces/plaintext-vote.js.map +1 -0
- package/src/lib/voting/interfaces/poll-configuration.d.ts +8 -0
- package/src/lib/voting/interfaces/poll-configuration.d.ts.map +1 -0
- package/src/lib/voting/interfaces/poll-configuration.js +3 -0
- package/src/lib/voting/interfaces/poll-configuration.js.map +1 -0
- package/src/lib/voting/interfaces/poll-results.d.ts +8 -0
- package/src/lib/voting/interfaces/poll-results.d.ts.map +1 -0
- package/src/lib/voting/interfaces/poll-results.js +3 -0
- package/src/lib/voting/interfaces/poll-results.js.map +1 -0
- package/src/lib/voting/interfaces/poll-tallier.d.ts +10 -0
- package/src/lib/voting/interfaces/poll-tallier.d.ts.map +1 -0
- package/src/lib/voting/interfaces/poll-tallier.js +3 -0
- package/src/lib/voting/interfaces/poll-tallier.js.map +1 -0
- package/src/lib/voting/interfaces/poll.d.ts +10 -0
- package/src/lib/voting/interfaces/poll.d.ts.map +1 -0
- package/src/lib/voting/interfaces/poll.js +3 -0
- package/src/lib/voting/interfaces/poll.js.map +1 -0
- package/src/lib/voting/interfaces/round-result.d.ts +8 -0
- package/src/lib/voting/interfaces/round-result.d.ts.map +1 -0
- package/src/lib/voting/interfaces/round-result.js +3 -0
- package/src/lib/voting/interfaces/round-result.js.map +1 -0
- package/src/lib/voting/interfaces/state-snapshot.d.ts +15 -0
- package/src/lib/voting/interfaces/state-snapshot.d.ts.map +1 -0
- package/src/lib/voting/interfaces/state-snapshot.js +3 -0
- package/src/lib/voting/interfaces/state-snapshot.js.map +1 -0
- package/src/lib/voting/interfaces/supermajority-config.d.ts +8 -0
- package/src/lib/voting/interfaces/supermajority-config.d.ts.map +1 -0
- package/src/lib/voting/interfaces/supermajority-config.js +3 -0
- package/src/lib/voting/interfaces/supermajority-config.js.map +1 -0
- package/src/lib/voting/interfaces/tally-proof.d.ts +10 -0
- package/src/lib/voting/interfaces/tally-proof.d.ts.map +1 -0
- package/src/lib/voting/interfaces/tally-proof.js +3 -0
- package/src/lib/voting/interfaces/tally-proof.js.map +1 -0
- package/src/lib/voting/interfaces/vote-encoder.d.ts +10 -0
- package/src/lib/voting/interfaces/vote-encoder.d.ts.map +1 -0
- package/src/lib/voting/interfaces/vote-encoder.js +3 -0
- package/src/lib/voting/interfaces/vote-encoder.js.map +1 -0
- package/src/lib/voting/interfaces/vote-logger-extended.d.ts +10 -0
- package/src/lib/voting/interfaces/vote-logger-extended.d.ts.map +1 -0
- package/src/lib/voting/interfaces/vote-logger-extended.js +3 -0
- package/src/lib/voting/interfaces/vote-logger-extended.js.map +1 -0
- package/src/lib/voting/interfaces/vote-logger.d.ts +9 -0
- package/src/lib/voting/interfaces/vote-logger.d.ts.map +1 -0
- package/src/lib/voting/interfaces/vote-logger.js +3 -0
- package/src/lib/voting/interfaces/vote-logger.js.map +1 -0
- package/src/lib/voting/interfaces/voting-consts.d.ts +9 -0
- package/src/lib/voting/interfaces/voting-consts.d.ts.map +1 -0
- package/src/lib/voting/interfaces/voting-consts.js +3 -0
- package/src/lib/voting/interfaces/voting-consts.js.map +1 -0
- package/src/lib/voting/interfaces/voting-key-derivation-options.d.ts +7 -0
- package/src/lib/voting/interfaces/voting-key-derivation-options.d.ts.map +1 -0
- package/src/lib/voting/interfaces/voting-key-derivation-options.js +3 -0
- package/src/lib/voting/interfaces/voting-key-derivation-options.js.map +1 -0
- package/src/lib/voting/interfaces/voting-poll-results.d.ts +7 -0
- package/src/lib/voting/interfaces/voting-poll-results.d.ts.map +1 -0
- package/src/lib/voting/interfaces/voting-poll-results.js +3 -0
- package/src/lib/voting/interfaces/voting-poll-results.js.map +1 -0
- package/src/lib/voting/interfaces/voting-receipt.d.ts +10 -0
- package/src/lib/voting/interfaces/voting-receipt.d.ts.map +1 -0
- package/src/lib/voting/interfaces/voting-receipt.js +3 -0
- package/src/lib/voting/interfaces/voting-receipt.js.map +1 -0
- package/src/lib/voting/interfaces/voting-security-validator.d.ts +8 -0
- package/src/lib/voting/interfaces/voting-security-validator.d.ts.map +1 -0
- package/src/lib/voting/interfaces/voting-security-validator.js +3 -0
- package/src/lib/voting/interfaces/voting-security-validator.js.map +1 -0
- package/src/lib/voting/node-persistent-state.d.ts +40 -0
- package/src/lib/voting/node-persistent-state.d.ts.map +1 -0
- package/src/lib/voting/node-persistent-state.js +222 -0
- package/src/lib/voting/node-persistent-state.js.map +1 -0
- package/src/lib/voting/persistent-state.d.ts +44 -0
- package/src/lib/voting/persistent-state.d.ts.map +1 -0
- package/src/lib/voting/persistent-state.js +106 -0
- package/src/lib/voting/persistent-state.js.map +1 -0
- package/src/lib/voting/poll-core.d.ts +14 -29
- package/src/lib/voting/poll-core.d.ts.map +1 -1
- package/src/lib/voting/poll-core.js +13 -176
- package/src/lib/voting/poll-core.js.map +1 -1
- package/src/lib/voting/poll.js +3 -3
- package/src/lib/voting/poll.js.map +1 -1
- package/src/lib/voting/security.d.ts +9 -15
- package/src/lib/voting/security.d.ts.map +1 -1
- package/src/lib/voting/security.js +12 -44
- package/src/lib/voting/security.js.map +1 -1
- package/src/lib/voting/tallier.d.ts +11 -20
- package/src/lib/voting/tallier.d.ts.map +1 -1
- package/src/lib/voting/tallier.js +17 -366
- package/src/lib/voting/tallier.js.map +1 -1
- package/src/lib/voting/test-voter-pool.d.ts +16 -0
- package/src/lib/voting/test-voter-pool.d.ts.map +1 -0
- package/src/lib/voting/test-voter-pool.js +69 -0
- package/src/lib/voting/test-voter-pool.js.map +1 -0
- package/src/lib/voting/us-election-example.d.ts +2 -0
- package/src/lib/voting/us-election-example.d.ts.map +1 -0
- package/src/lib/voting/us-election-example.js +170 -0
- package/src/lib/voting/us-election-example.js.map +1 -0
- package/src/member.d.ts +4 -1
- package/src/member.d.ts.map +1 -1
- package/src/member.js +40 -16
- package/src/member.js.map +1 -1
- package/src/secure-buffer.d.ts +1 -2
- package/src/secure-buffer.d.ts.map +1 -1
- package/src/secure-buffer.js +3 -9
- package/src/secure-buffer.js.map +1 -1
- package/src/services/ecies/crypto-core.d.ts.map +1 -1
- package/src/services/ecies/crypto-core.js +24 -0
- package/src/services/ecies/crypto-core.js.map +1 -1
- package/src/services/ecies/multi-recipient.d.ts +9 -1
- package/src/services/ecies/multi-recipient.d.ts.map +1 -1
- package/src/services/ecies/multi-recipient.js +153 -21
- package/src/services/ecies/multi-recipient.js.map +1 -1
- package/src/services/ecies/service.d.ts +56 -15
- package/src/services/ecies/service.d.ts.map +1 -1
- package/src/services/ecies/service.js +196 -39
- package/src/services/ecies/service.js.map +1 -1
- package/src/services/ecies/single-recipient.d.ts.map +1 -1
- package/src/services/ecies/single-recipient.js +4 -2
- package/src/services/ecies/single-recipient.js.map +1 -1
- package/src/services/encryption-stream.d.ts +1 -1
- package/src/services/encryption-stream.d.ts.map +1 -1
- package/src/services/encryption-stream.js +4 -8
- package/src/services/encryption-stream.js.map +1 -1
- package/src/services/multi-recipient-processor.d.ts +5 -2
- package/src/services/multi-recipient-processor.d.ts.map +1 -1
- package/src/services/multi-recipient-processor.js +29 -14
- package/src/services/multi-recipient-processor.js.map +1 -1
- package/src/test-mocks/mock-backend-member.d.ts +22 -3
- package/src/test-mocks/mock-backend-member.d.ts.map +1 -1
- package/src/test-mocks/mock-backend-member.js +71 -0
- package/src/test-mocks/mock-backend-member.js.map +1 -1
- package/src/lib/voting/types.d.ts +0 -67
- package/src/lib/voting/types.d.ts.map +0 -1
- package/src/lib/voting/types.js +0 -29
- package/src/lib/voting/types.js.map +0 -1
|
@@ -1,114 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VoteEncoder = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Vote Encoder - Encrypts votes using Paillier homomorphic encryption
|
|
6
|
+
* Node.js optimized - extends ecies-lib VoteEncoder with Buffer support
|
|
7
|
+
*/
|
|
8
|
+
const ecies_lib_1 = require("@digitaldefiance/ecies-lib");
|
|
9
|
+
/**
|
|
10
|
+
* Node.js VoteEncoder that extends ecies-lib VoteEncoder
|
|
11
|
+
* Specializes the generic TID parameter to Buffer for Node.js compatibility
|
|
12
|
+
*/
|
|
13
|
+
class VoteEncoder extends ecies_lib_1.VoteEncoder {
|
|
7
14
|
constructor(votingPublicKey) {
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
encodePlurality(choiceIndex, choiceCount) {
|
|
11
|
-
const encrypted = [];
|
|
12
|
-
for (let i = 0; i < choiceCount; i++) {
|
|
13
|
-
encrypted.push(i === choiceIndex
|
|
14
|
-
? this.votingPublicKey.encrypt(1n)
|
|
15
|
-
: this.votingPublicKey.encrypt(0n));
|
|
16
|
-
}
|
|
17
|
-
return { choiceIndex, encrypted };
|
|
18
|
-
}
|
|
19
|
-
encodeApproval(choices, choiceCount) {
|
|
20
|
-
const choiceSet = new Set(choices);
|
|
21
|
-
const encrypted = [];
|
|
22
|
-
for (let i = 0; i < choiceCount; i++) {
|
|
23
|
-
encrypted.push(choiceSet.has(i)
|
|
24
|
-
? this.votingPublicKey.encrypt(1n)
|
|
25
|
-
: this.votingPublicKey.encrypt(0n));
|
|
26
|
-
}
|
|
27
|
-
return { choices, encrypted };
|
|
28
|
-
}
|
|
29
|
-
encodeWeighted(choiceIndex, weight, choiceCount) {
|
|
30
|
-
const encrypted = [];
|
|
31
|
-
for (let i = 0; i < choiceCount; i++) {
|
|
32
|
-
encrypted.push(i === choiceIndex
|
|
33
|
-
? this.votingPublicKey.encrypt(weight)
|
|
34
|
-
: this.votingPublicKey.encrypt(0n));
|
|
35
|
-
}
|
|
36
|
-
return { choiceIndex, weight, encrypted };
|
|
37
|
-
}
|
|
38
|
-
encodeBorda(rankings, choiceCount) {
|
|
39
|
-
const encrypted = new Array(choiceCount);
|
|
40
|
-
const points = BigInt(rankings.length);
|
|
41
|
-
for (let i = 0; i < choiceCount; i++) {
|
|
42
|
-
encrypted[i] = this.votingPublicKey.encrypt(0n);
|
|
43
|
-
}
|
|
44
|
-
for (let rank = 0; rank < rankings.length; rank++) {
|
|
45
|
-
const choiceIndex = rankings[rank];
|
|
46
|
-
const choicePoints = points - BigInt(rank);
|
|
47
|
-
encrypted[choiceIndex] = this.votingPublicKey.encrypt(choicePoints);
|
|
48
|
-
}
|
|
49
|
-
return { rankings, encrypted };
|
|
50
|
-
}
|
|
51
|
-
encodeRankedChoice(rankings, choiceCount) {
|
|
52
|
-
const encrypted = new Array(choiceCount);
|
|
53
|
-
for (let i = 0; i < choiceCount; i++) {
|
|
54
|
-
encrypted[i] = this.votingPublicKey.encrypt(0n);
|
|
55
|
-
}
|
|
56
|
-
for (let rank = 0; rank < rankings.length; rank++) {
|
|
57
|
-
const choiceIndex = rankings[rank];
|
|
58
|
-
encrypted[choiceIndex] = this.votingPublicKey.encrypt(BigInt(rank + 1));
|
|
59
|
-
}
|
|
60
|
-
return { rankings, encrypted };
|
|
61
|
-
}
|
|
62
|
-
encode(method, data, choiceCount) {
|
|
63
|
-
switch (method) {
|
|
64
|
-
case types_1.VotingMethod.Plurality:
|
|
65
|
-
if (data.choiceIndex === undefined)
|
|
66
|
-
throw new Error('Choice required');
|
|
67
|
-
return this.encodePlurality(data.choiceIndex, choiceCount);
|
|
68
|
-
case types_1.VotingMethod.Approval:
|
|
69
|
-
if (!data.choices)
|
|
70
|
-
throw new Error('Choices required');
|
|
71
|
-
return this.encodeApproval(data.choices, choiceCount);
|
|
72
|
-
case types_1.VotingMethod.Weighted:
|
|
73
|
-
if (data.choiceIndex === undefined || !data.weight) {
|
|
74
|
-
throw new Error('Choice and weight required');
|
|
75
|
-
}
|
|
76
|
-
return this.encodeWeighted(data.choiceIndex, data.weight, choiceCount);
|
|
77
|
-
case types_1.VotingMethod.Borda:
|
|
78
|
-
if (!data.rankings)
|
|
79
|
-
throw new Error('Rankings required');
|
|
80
|
-
return this.encodeBorda(data.rankings, choiceCount);
|
|
81
|
-
case types_1.VotingMethod.RankedChoice:
|
|
82
|
-
if (!data.rankings)
|
|
83
|
-
throw new Error('Rankings required');
|
|
84
|
-
return this.encodeRankedChoice(data.rankings, choiceCount);
|
|
85
|
-
case types_1.VotingMethod.Quadratic:
|
|
86
|
-
if (data.choiceIndex === undefined || !data.weight) {
|
|
87
|
-
throw new Error('Choice and weight required');
|
|
88
|
-
}
|
|
89
|
-
return this.encodeWeighted(data.choiceIndex, data.weight, choiceCount);
|
|
90
|
-
case types_1.VotingMethod.Consensus:
|
|
91
|
-
if (data.choiceIndex === undefined)
|
|
92
|
-
throw new Error('Choice required');
|
|
93
|
-
return this.encodePlurality(data.choiceIndex, choiceCount);
|
|
94
|
-
case types_1.VotingMethod.ConsentBased: {
|
|
95
|
-
if (data.choiceIndex === undefined)
|
|
96
|
-
throw new Error('Choice required');
|
|
97
|
-
const encrypted = [];
|
|
98
|
-
for (let i = 0; i < choiceCount; i++) {
|
|
99
|
-
encrypted.push(i === data.choiceIndex
|
|
100
|
-
? this.votingPublicKey.encrypt(data.weight || 1n)
|
|
101
|
-
: this.votingPublicKey.encrypt(0n));
|
|
102
|
-
}
|
|
103
|
-
return {
|
|
104
|
-
choiceIndex: data.choiceIndex,
|
|
105
|
-
weight: data.weight,
|
|
106
|
-
encrypted,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
default:
|
|
110
|
-
throw new Error('Unknown voting method');
|
|
111
|
-
}
|
|
15
|
+
super(votingPublicKey);
|
|
112
16
|
}
|
|
113
17
|
}
|
|
114
18
|
exports.VoteEncoder = VoteEncoder;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encoder.js","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/encoder.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"encoder.js","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/encoder.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,0DAA4E;AAG5E;;;GAGG;AACH,MAAa,WAAY,SAAQ,uBAAuB;IACtD,YAAY,eAA0B;QACpC,KAAK,CAAC,eAAe,CAAC,CAAC;IACzB,CAAC;CAKF;AARD,kCAQC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-export all enumerations from ecies-lib
|
|
3
|
+
* This ensures enumeration parity between browser and Node.js implementations
|
|
4
|
+
*/
|
|
5
|
+
export { VotingMethod, SecurityLevel, EventType, AuditEventType, JurisdictionLevel, } from '@digitaldefiance/ecies-lib';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/enumerations/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,YAAY,EACZ,aAAa,EACb,SAAS,EACT,cAAc,EACd,iBAAiB,GAClB,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JurisdictionLevel = exports.AuditEventType = exports.EventType = exports.SecurityLevel = exports.VotingMethod = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Re-export all enumerations from ecies-lib
|
|
6
|
+
* This ensures enumeration parity between browser and Node.js implementations
|
|
7
|
+
*/
|
|
8
|
+
var ecies_lib_1 = require("@digitaldefiance/ecies-lib");
|
|
9
|
+
Object.defineProperty(exports, "VotingMethod", { enumerable: true, get: function () { return ecies_lib_1.VotingMethod; } });
|
|
10
|
+
Object.defineProperty(exports, "SecurityLevel", { enumerable: true, get: function () { return ecies_lib_1.SecurityLevel; } });
|
|
11
|
+
Object.defineProperty(exports, "EventType", { enumerable: true, get: function () { return ecies_lib_1.EventType; } });
|
|
12
|
+
Object.defineProperty(exports, "AuditEventType", { enumerable: true, get: function () { return ecies_lib_1.AuditEventType; } });
|
|
13
|
+
Object.defineProperty(exports, "JurisdictionLevel", { enumerable: true, get: function () { return ecies_lib_1.JurisdictionLevel; } });
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/enumerations/index.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,wDAMoC;AALlC,yGAAA,YAAY,OAAA;AACZ,0GAAA,aAAa,OAAA;AACb,sGAAA,SAAS,OAAA;AACT,2GAAA,cAAc,OAAA;AACd,8GAAA,iBAAiB,OAAA"}
|
|
@@ -1,83 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Event Logger for Government-Grade Voting
|
|
3
|
-
* Node.js optimized with
|
|
3
|
+
* Node.js optimized - extends ecies-lib PollEventLogger with Buffer support
|
|
4
4
|
* Implements requirement 1.3: Comprehensive event logging with microsecond timestamps
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
PollClosed = "poll_closed",
|
|
10
|
-
VoteVerified = "vote_verified",
|
|
11
|
-
TallyComputed = "tally_computed",
|
|
12
|
-
AuditRequested = "audit_requested"
|
|
13
|
-
}
|
|
14
|
-
export interface PollConfiguration {
|
|
15
|
-
readonly method: string;
|
|
16
|
-
readonly choices: string[];
|
|
17
|
-
readonly maxWeight?: bigint;
|
|
18
|
-
readonly threshold?: {
|
|
19
|
-
numerator: number;
|
|
20
|
-
denominator: number;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
export interface EventLogEntry {
|
|
24
|
-
/** Sequence number (monotonically increasing) */
|
|
25
|
-
readonly sequence: number;
|
|
26
|
-
/** Event type */
|
|
27
|
-
readonly eventType: EventType;
|
|
28
|
-
/** Microsecond-precision timestamp */
|
|
29
|
-
readonly timestamp: number;
|
|
30
|
-
/** Poll identifier */
|
|
31
|
-
readonly pollId: Buffer;
|
|
32
|
-
/** Creator/authority ID (for creation/closure events) */
|
|
33
|
-
readonly creatorId?: Buffer;
|
|
34
|
-
/** Anonymized voter token (for vote events) */
|
|
35
|
-
readonly voterToken?: Buffer;
|
|
36
|
-
/** Poll configuration (for creation events) */
|
|
37
|
-
readonly configuration?: PollConfiguration;
|
|
38
|
-
/** Final tally hash (for closure events) */
|
|
39
|
-
readonly tallyHash?: Buffer;
|
|
40
|
-
/** Additional metadata */
|
|
41
|
-
readonly metadata?: Record<string, unknown>;
|
|
42
|
-
}
|
|
43
|
-
export interface EventLogger {
|
|
44
|
-
/** Log poll creation event */
|
|
45
|
-
logPollCreated(pollId: Buffer, creatorId: Buffer, configuration: PollConfiguration): EventLogEntry;
|
|
46
|
-
/** Log vote cast event */
|
|
47
|
-
logVoteCast(pollId: Buffer, voterToken: Buffer, metadata?: Record<string, unknown>): EventLogEntry;
|
|
48
|
-
/** Log poll closure event */
|
|
49
|
-
logPollClosed(pollId: Buffer, tallyHash: Buffer, metadata?: Record<string, unknown>): EventLogEntry;
|
|
50
|
-
/** Log generic event */
|
|
51
|
-
logEvent(eventType: EventType, pollId: Buffer, data?: Partial<Omit<EventLogEntry, 'sequence' | 'timestamp' | 'eventType' | 'pollId'>>): EventLogEntry;
|
|
52
|
-
/** Get all events */
|
|
53
|
-
getEvents(): readonly EventLogEntry[];
|
|
54
|
-
/** Get events for specific poll */
|
|
55
|
-
getEventsForPoll(pollId: Buffer): readonly EventLogEntry[];
|
|
56
|
-
/** Get events by type */
|
|
57
|
-
getEventsByType(eventType: EventType): readonly EventLogEntry[];
|
|
58
|
-
/** Verify sequence integrity */
|
|
59
|
-
verifySequence(): boolean;
|
|
60
|
-
/** Export events for archival */
|
|
61
|
-
export(): Buffer;
|
|
62
|
-
}
|
|
6
|
+
import { PollEventLogger as BasePollEventLogger, EventType } from '@digitaldefiance/ecies-lib';
|
|
7
|
+
export type { EventLogEntry, EventLogger, PollConfiguration, } from './interfaces';
|
|
8
|
+
export { EventType };
|
|
63
9
|
/**
|
|
64
|
-
*
|
|
10
|
+
* Node.js PollEventLogger that extends ecies-lib PollEventLogger
|
|
11
|
+
* Uses Buffer for binary data instead of Uint8Array
|
|
12
|
+
*
|
|
13
|
+
* The base class handles all the logic, we just provide Node.js-specific defaults
|
|
14
|
+
* and ensure Buffer is used by default instead of Uint8Array.
|
|
65
15
|
*/
|
|
66
|
-
export declare class PollEventLogger
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
logVoteCast(pollId: Buffer, voterToken: Buffer, metadata?: Record<string, unknown>): EventLogEntry;
|
|
71
|
-
logPollClosed(pollId: Buffer, tallyHash: Buffer, metadata?: Record<string, unknown>): EventLogEntry;
|
|
72
|
-
logEvent(eventType: EventType, pollId: Buffer, data?: Partial<Omit<EventLogEntry, 'sequence' | 'timestamp' | 'eventType' | 'pollId'>>): EventLogEntry;
|
|
73
|
-
getEvents(): readonly EventLogEntry[];
|
|
74
|
-
getEventsForPoll(pollId: Buffer): readonly EventLogEntry[];
|
|
75
|
-
getEventsByType(eventType: EventType): readonly EventLogEntry[];
|
|
76
|
-
verifySequence(): boolean;
|
|
16
|
+
export declare class PollEventLogger extends BasePollEventLogger {
|
|
17
|
+
/**
|
|
18
|
+
* Override export method to return Buffer instead of Uint8Array
|
|
19
|
+
*/
|
|
77
20
|
export(): Buffer;
|
|
78
|
-
private appendEvent;
|
|
79
|
-
private serializeEvent;
|
|
80
|
-
private getMicrosecondTimestamp;
|
|
81
|
-
private encodeNumber;
|
|
82
21
|
}
|
|
83
22
|
//# sourceMappingURL=event-logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-logger.d.ts","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/event-logger.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"event-logger.d.ts","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/event-logger.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,eAAe,IAAI,mBAAmB,EACtC,SAAS,EACV,MAAM,4BAA4B,CAAC;AAGpC,YAAY,EACV,aAAa,EACb,WAAW,EACX,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,SAAS,EAAE,CAAC;AAErB;;;;;;GAMG;AACH,qBAAa,eAAgB,SAAQ,mBAAmB;IAKtD;;OAEG;IACH,MAAM,IAAI,MAAM;CAIjB"}
|
|
@@ -1,151 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PollEventLogger = exports.EventType = void 0;
|
|
2
4
|
/**
|
|
3
5
|
* Event Logger for Government-Grade Voting
|
|
4
|
-
* Node.js optimized with
|
|
6
|
+
* Node.js optimized - extends ecies-lib PollEventLogger with Buffer support
|
|
5
7
|
* Implements requirement 1.3: Comprehensive event logging with microsecond timestamps
|
|
6
8
|
*/
|
|
7
|
-
|
|
8
|
-
exports
|
|
9
|
-
var EventType;
|
|
10
|
-
(function (EventType) {
|
|
11
|
-
EventType["PollCreated"] = "poll_created";
|
|
12
|
-
EventType["VoteCast"] = "vote_cast";
|
|
13
|
-
EventType["PollClosed"] = "poll_closed";
|
|
14
|
-
EventType["VoteVerified"] = "vote_verified";
|
|
15
|
-
EventType["TallyComputed"] = "tally_computed";
|
|
16
|
-
EventType["AuditRequested"] = "audit_requested";
|
|
17
|
-
})(EventType || (exports.EventType = EventType = {}));
|
|
9
|
+
const ecies_lib_1 = require("@digitaldefiance/ecies-lib");
|
|
10
|
+
Object.defineProperty(exports, "EventType", { enumerable: true, get: function () { return ecies_lib_1.EventType; } });
|
|
18
11
|
/**
|
|
19
|
-
*
|
|
12
|
+
* Node.js PollEventLogger that extends ecies-lib PollEventLogger
|
|
13
|
+
* Uses Buffer for binary data instead of Uint8Array
|
|
14
|
+
*
|
|
15
|
+
* The base class handles all the logic, we just provide Node.js-specific defaults
|
|
16
|
+
* and ensure Buffer is used by default instead of Uint8Array.
|
|
20
17
|
*/
|
|
21
|
-
class PollEventLogger {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
creatorId,
|
|
29
|
-
configuration,
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
logVoteCast(pollId, voterToken, metadata) {
|
|
33
|
-
return this.appendEvent({
|
|
34
|
-
eventType: EventType.VoteCast,
|
|
35
|
-
pollId,
|
|
36
|
-
voterToken,
|
|
37
|
-
metadata,
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
logPollClosed(pollId, tallyHash, metadata) {
|
|
41
|
-
return this.appendEvent({
|
|
42
|
-
eventType: EventType.PollClosed,
|
|
43
|
-
pollId,
|
|
44
|
-
tallyHash,
|
|
45
|
-
metadata,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
logEvent(eventType, pollId, data) {
|
|
49
|
-
return this.appendEvent({
|
|
50
|
-
eventType,
|
|
51
|
-
pollId,
|
|
52
|
-
...data,
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
getEvents() {
|
|
56
|
-
return Object.freeze([...this.events]);
|
|
57
|
-
}
|
|
58
|
-
getEventsForPoll(pollId) {
|
|
59
|
-
const pollIdStr = pollId.toString('hex');
|
|
60
|
-
return Object.freeze(this.events.filter((e) => e.pollId.toString('hex') === pollIdStr));
|
|
61
|
-
}
|
|
62
|
-
getEventsByType(eventType) {
|
|
63
|
-
return Object.freeze(this.events.filter((e) => e.eventType === eventType));
|
|
64
|
-
}
|
|
65
|
-
verifySequence() {
|
|
66
|
-
for (let i = 0; i < this.events.length; i++) {
|
|
67
|
-
if (this.events[i].sequence !== i) {
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
18
|
+
class PollEventLogger extends ecies_lib_1.PollEventLogger {
|
|
19
|
+
// All methods are inherited from BasePollEventLogger
|
|
20
|
+
// The methods will work with Buffer since Buffer extends Uint8Array
|
|
21
|
+
// Node.js will automatically handle the conversion
|
|
22
|
+
/**
|
|
23
|
+
* Override export method to return Buffer instead of Uint8Array
|
|
24
|
+
*/
|
|
73
25
|
export() {
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
for (const event of this.events) {
|
|
77
|
-
parts.push(this.serializeEvent(event));
|
|
78
|
-
}
|
|
79
|
-
return Buffer.concat(parts);
|
|
80
|
-
}
|
|
81
|
-
appendEvent(partial) {
|
|
82
|
-
const entry = {
|
|
83
|
-
sequence: this.sequence++,
|
|
84
|
-
timestamp: this.getMicrosecondTimestamp(),
|
|
85
|
-
...partial,
|
|
86
|
-
};
|
|
87
|
-
this.events.push(entry);
|
|
88
|
-
return entry;
|
|
89
|
-
}
|
|
90
|
-
serializeEvent(event) {
|
|
91
|
-
const parts = [
|
|
92
|
-
this.encodeNumber(event.sequence),
|
|
93
|
-
this.encodeNumber(event.timestamp),
|
|
94
|
-
Buffer.from(event.eventType, 'utf8'),
|
|
95
|
-
this.encodeNumber(event.pollId.length),
|
|
96
|
-
event.pollId,
|
|
97
|
-
];
|
|
98
|
-
if (event.creatorId) {
|
|
99
|
-
parts.push(this.encodeNumber(1), this.encodeNumber(event.creatorId.length), event.creatorId);
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
parts.push(this.encodeNumber(0));
|
|
103
|
-
}
|
|
104
|
-
if (event.voterToken) {
|
|
105
|
-
parts.push(this.encodeNumber(1), this.encodeNumber(event.voterToken.length), event.voterToken);
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
parts.push(this.encodeNumber(0));
|
|
109
|
-
}
|
|
110
|
-
if (event.configuration) {
|
|
111
|
-
const configStr = JSON.stringify({
|
|
112
|
-
method: event.configuration.method,
|
|
113
|
-
choices: event.configuration.choices,
|
|
114
|
-
maxWeight: event.configuration.maxWeight?.toString(),
|
|
115
|
-
threshold: event.configuration.threshold,
|
|
116
|
-
});
|
|
117
|
-
const encoded = Buffer.from(configStr, 'utf8');
|
|
118
|
-
parts.push(this.encodeNumber(1), this.encodeNumber(encoded.length), encoded);
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
parts.push(this.encodeNumber(0));
|
|
122
|
-
}
|
|
123
|
-
if (event.tallyHash) {
|
|
124
|
-
parts.push(this.encodeNumber(1), this.encodeNumber(event.tallyHash.length), event.tallyHash);
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
parts.push(this.encodeNumber(0));
|
|
128
|
-
}
|
|
129
|
-
if (event.metadata) {
|
|
130
|
-
const metaStr = JSON.stringify(event.metadata);
|
|
131
|
-
const encoded = Buffer.from(metaStr, 'utf8');
|
|
132
|
-
parts.push(this.encodeNumber(1), this.encodeNumber(encoded.length), encoded);
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
parts.push(this.encodeNumber(0));
|
|
136
|
-
}
|
|
137
|
-
return Buffer.concat(parts);
|
|
138
|
-
}
|
|
139
|
-
getMicrosecondTimestamp() {
|
|
140
|
-
// Get milliseconds since epoch and convert to microseconds
|
|
141
|
-
// performance.now() is relative to process start, not epoch, so we only use Date.now()
|
|
142
|
-
const now = Date.now();
|
|
143
|
-
return now * 1000;
|
|
144
|
-
}
|
|
145
|
-
encodeNumber(n) {
|
|
146
|
-
const buffer = Buffer.alloc(8);
|
|
147
|
-
buffer.writeBigUInt64BE(BigInt(n));
|
|
148
|
-
return buffer;
|
|
26
|
+
const exported = super.export();
|
|
27
|
+
return Buffer.from(exported);
|
|
149
28
|
}
|
|
150
29
|
}
|
|
151
30
|
exports.PollEventLogger = PollEventLogger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-logger.js","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/event-logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"event-logger.js","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/event-logger.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,0DAGoC;AAU3B,0FAXP,qBAAS,OAWO;AAElB;;;;;;GAMG;AACH,MAAa,eAAgB,SAAQ,2BAAmB;IACtD,qDAAqD;IACrD,oEAAoE;IACpE,mDAAmD;IAEnD;;OAEG;IACH,MAAM;QACJ,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QAChC,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC/B,CAAC;CACF;AAZD,0CAYC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Voting System Usage Examples (Node.js)
|
|
3
|
+
* Shows how to use with node-ecies-lib Member class
|
|
4
|
+
*
|
|
5
|
+
* Note: This is the Node.js implementation using Buffer instead of Uint8Array.
|
|
6
|
+
* For the browser implementation, see @digitaldefiance/ecies-lib.
|
|
7
|
+
*
|
|
8
|
+
* IMPORTANT: These examples are for documentation purposes and demonstrate the API.
|
|
9
|
+
* Due to type incompatibilities between ecies-lib Member (Uint8Array) and
|
|
10
|
+
* node-ecies-lib voting system (Buffer), these examples may require type assertions
|
|
11
|
+
* or conversion utilities in actual usage. See the test files for working examples.
|
|
12
|
+
*
|
|
13
|
+
* These examples show the intended API usage but may not compile due to type
|
|
14
|
+
* incompatibilities. For working examples, see the test files in the test directory.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Example 1: Simple Plurality Vote
|
|
18
|
+
*
|
|
19
|
+
* This example shows the intended API usage. For working examples,
|
|
20
|
+
* see the test files which handle type conversions properly.
|
|
21
|
+
*/
|
|
22
|
+
declare function examplePlurality(): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Example 2: Ranked Choice Voting (True IRV)
|
|
25
|
+
*
|
|
26
|
+
* This example shows the intended API usage. For working examples,
|
|
27
|
+
* see the test files which handle type conversions properly.
|
|
28
|
+
*/
|
|
29
|
+
declare function exampleRankedChoice(): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Example 3: Weighted Voting (Stakeholder)
|
|
32
|
+
*
|
|
33
|
+
* This example shows the intended API usage. For working examples,
|
|
34
|
+
* see the test files which handle type conversions properly.
|
|
35
|
+
*/
|
|
36
|
+
declare function exampleWeighted(): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Example 4: Borda Count
|
|
39
|
+
*
|
|
40
|
+
* This example shows the intended API usage. For working examples,
|
|
41
|
+
* see the test files which handle type conversions properly.
|
|
42
|
+
*/
|
|
43
|
+
declare function exampleBorda(): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Example 5: Approval Voting
|
|
46
|
+
*
|
|
47
|
+
* This example shows the intended API usage. For working examples,
|
|
48
|
+
* see the test files which handle type conversions properly.
|
|
49
|
+
*/
|
|
50
|
+
declare function exampleApproval(): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Example 6: Receipt Verification
|
|
53
|
+
*
|
|
54
|
+
* This example shows the intended API usage. For working examples,
|
|
55
|
+
* see the test files which handle type conversions properly.
|
|
56
|
+
*/
|
|
57
|
+
declare function exampleReceipts(): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Example 7: Node.js-Specific - File-Based Vote Persistence
|
|
60
|
+
*
|
|
61
|
+
* This example shows how to save encrypted votes to disk using Node.js fs module.
|
|
62
|
+
* For working examples, see the test files which handle type conversions properly.
|
|
63
|
+
*/
|
|
64
|
+
declare function exampleFilePersistence(): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Example 8: Node.js-Specific - Streaming Large Voter Datasets
|
|
67
|
+
*
|
|
68
|
+
* This example shows how to process votes from a stream using Node.js.
|
|
69
|
+
* For working examples, see the test files which handle type conversions properly.
|
|
70
|
+
*/
|
|
71
|
+
declare function exampleStreamProcessing(): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Example 9: Node.js-Specific - Cryptographic Operations with Buffer
|
|
74
|
+
*
|
|
75
|
+
* This example shows Node.js-specific cryptographic operations using Buffer.
|
|
76
|
+
*/
|
|
77
|
+
declare function exampleBufferCrypto(): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Example 10: Node.js-Specific - Audit Log Export
|
|
80
|
+
*
|
|
81
|
+
* This example shows how to export audit logs to JSON files using Node.js.
|
|
82
|
+
* For working examples, see the test files which handle type conversions properly.
|
|
83
|
+
*/
|
|
84
|
+
declare function exampleAuditLogExport(): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Helper: Create member with voting keys derived from ECDH
|
|
87
|
+
*
|
|
88
|
+
* Note: This is pseudocode for documentation purposes.
|
|
89
|
+
* Actual implementation requires proper type conversions between
|
|
90
|
+
* ecies-lib Member (Uint8Array) and node-ecies-lib voting (Buffer).
|
|
91
|
+
*/
|
|
92
|
+
/**
|
|
93
|
+
* Creates a member with voting keys (documentation example)
|
|
94
|
+
* Note: This is pseudocode for documentation purposes.
|
|
95
|
+
* Actual implementation requires proper type conversions between
|
|
96
|
+
* ecies-lib Member (Uint8Array) and node-ecies-lib voting (Buffer).
|
|
97
|
+
*
|
|
98
|
+
* Example usage:
|
|
99
|
+
* ```typescript
|
|
100
|
+
* // This uses node-ecies-lib's Member.newMember() and deriveVotingKeys()
|
|
101
|
+
* const eciesService = new ECIESService();
|
|
102
|
+
* const memberWithMnemonic = Member.newMember(
|
|
103
|
+
* eciesService,
|
|
104
|
+
* memberType,
|
|
105
|
+
* name,
|
|
106
|
+
* new EmailString(email),
|
|
107
|
+
* );
|
|
108
|
+
* return { member: memberWithMnemonic.member };
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
export { examplePlurality, exampleRankedChoice, exampleWeighted, exampleBorda, exampleApproval, exampleReceipts, exampleFilePersistence, exampleStreamProcessing, exampleBufferCrypto, exampleAuditLogExport, };
|
|
112
|
+
//# sourceMappingURL=examples.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"examples.d.ts","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/examples.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAWH;;;;;GAKG;AACH,iBAAe,gBAAgB,kBAkC9B;AAED;;;;;GAKG;AACH,iBAAe,mBAAmB,kBA8BjC;AAED;;;;;GAKG;AACH,iBAAe,eAAe,kBA0B7B;AAED;;;;;GAKG;AACH,iBAAe,YAAY,kBAsB1B;AAED;;;;;GAKG;AACH,iBAAe,eAAe,kBA0B7B;AAED;;;;;GAKG;AACH,iBAAe,eAAe,kBAuB7B;AAED;;;;;GAKG;AACH,iBAAe,sBAAsB,kBAmCpC;AAED;;;;;GAKG;AACH,iBAAe,uBAAuB,kBA+BrC;AAED;;;;GAIG;AACH,iBAAe,mBAAmB,kBAoBjC;AAED;;;;;GAKG;AACH,iBAAe,qBAAqB,kBAmCnC;AAED;;;;;;GAMG;AACH;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,YAAY,EACZ,eAAe,EACf,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACnB,qBAAqB,GACtB,CAAC"}
|