@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,87 +1,53 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Public Bulletin Board for Government-Grade Voting
|
|
3
|
+
* Node.js optimized - extends ecies-lib PublicBulletinBoard with Buffer support
|
|
4
|
+
* Implements requirement 1.2: Append-only, publicly verifiable vote publication
|
|
5
|
+
*/
|
|
6
|
+
import { PublicBulletinBoard as BasePublicBulletinBoard } from '@digitaldefiance/ecies-lib';
|
|
2
7
|
import type { IMember } from '../../interfaces/member';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
readonly sequence: number;
|
|
6
|
-
/** Microsecond-precision timestamp */
|
|
7
|
-
readonly timestamp: number;
|
|
8
|
-
/** Poll identifier */
|
|
9
|
-
readonly pollId: TID;
|
|
10
|
-
/** Encrypted vote data */
|
|
11
|
-
readonly encryptedVote: bigint[];
|
|
12
|
-
/** Hash of voter ID (anonymized) */
|
|
13
|
-
readonly voterIdHash: Buffer;
|
|
14
|
-
/** Merkle root of all entries up to this point */
|
|
15
|
-
readonly merkleRoot: Buffer;
|
|
16
|
-
/** Hash of this entry */
|
|
17
|
-
readonly entryHash: Buffer;
|
|
18
|
-
/** Authority signature */
|
|
19
|
-
readonly signature: Buffer;
|
|
20
|
-
}
|
|
21
|
-
export interface TallyProof<TID extends PlatformID = Buffer> {
|
|
22
|
-
/** Poll identifier */
|
|
23
|
-
readonly pollId: TID;
|
|
24
|
-
/** Final tallies */
|
|
25
|
-
readonly tallies: bigint[];
|
|
26
|
-
/** Choice names */
|
|
27
|
-
readonly choices: string[];
|
|
28
|
-
/** Timestamp of tally */
|
|
29
|
-
readonly timestamp: number;
|
|
30
|
-
/** Hash of all encrypted votes */
|
|
31
|
-
readonly votesHash: Buffer;
|
|
32
|
-
/** Cryptographic proof of correct decryption */
|
|
33
|
-
readonly decryptionProof: Buffer;
|
|
34
|
-
/** Authority signature */
|
|
35
|
-
readonly signature: Buffer;
|
|
36
|
-
}
|
|
37
|
-
export interface BulletinBoard<TID extends PlatformID = Buffer> {
|
|
38
|
-
/** Publish encrypted vote to bulletin board */
|
|
39
|
-
publishVote(pollId: TID, encryptedVote: bigint[], voterIdHash: Buffer): BulletinBoardEntry<TID>;
|
|
40
|
-
/** Publish tally with cryptographic proof */
|
|
41
|
-
publishTally(pollId: TID, tallies: bigint[], choices: string[], encryptedVotes: bigint[][]): TallyProof<TID>;
|
|
42
|
-
/** Get all entries for a poll */
|
|
43
|
-
getEntries(pollId: TID): readonly BulletinBoardEntry<TID>[];
|
|
44
|
-
/** Get all entries (entire bulletin board) */
|
|
45
|
-
getAllEntries(): readonly BulletinBoardEntry<TID>[];
|
|
46
|
-
/** Get tally proof for a poll */
|
|
47
|
-
getTallyProof(pollId: TID): TallyProof<TID> | undefined;
|
|
48
|
-
/** Verify entry signature and hash */
|
|
49
|
-
verifyEntry(entry: BulletinBoardEntry): boolean;
|
|
50
|
-
/** Verify tally proof */
|
|
51
|
-
verifyTallyProof(proof: TallyProof<TID>): boolean;
|
|
52
|
-
/** Verify Merkle tree integrity */
|
|
53
|
-
verifyMerkleTree(): boolean;
|
|
54
|
-
/** Export complete bulletin board for archival */
|
|
55
|
-
export(): Buffer;
|
|
56
|
-
}
|
|
8
|
+
import type { BulletinBoardEntry, TallyProof } from './interfaces';
|
|
9
|
+
export type { BulletinBoardEntry, TallyProof, BulletinBoard, } from './interfaces';
|
|
57
10
|
/**
|
|
58
|
-
*
|
|
11
|
+
* Node.js PublicBulletinBoard that extends ecies-lib PublicBulletinBoard
|
|
12
|
+
* Uses Buffer for binary data instead of Uint8Array
|
|
13
|
+
*
|
|
14
|
+
* The base class handles all the logic, we just provide Node.js-specific defaults
|
|
15
|
+
* and ensure Buffer is used by default instead of Uint8Array.
|
|
59
16
|
*/
|
|
60
|
-
export declare class PublicBulletinBoard
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
17
|
+
export declare class PublicBulletinBoard extends BasePublicBulletinBoard {
|
|
18
|
+
constructor(authority: IMember<Buffer>);
|
|
19
|
+
/**
|
|
20
|
+
* Override publishVote to ensure Buffer types are returned
|
|
21
|
+
*/
|
|
22
|
+
publishVote(pollId: Buffer, encryptedVote: bigint[], voterIdHash: Buffer): BulletinBoardEntry<Buffer>;
|
|
23
|
+
/**
|
|
24
|
+
* Override publishTally to ensure Buffer types are returned
|
|
25
|
+
*/
|
|
26
|
+
publishTally(pollId: Buffer, tallies: bigint[], choices: string[], encryptedVotes: bigint[][]): TallyProof<Buffer>;
|
|
27
|
+
/**
|
|
28
|
+
* Override getEntries to ensure Buffer types are returned and array is immutable
|
|
29
|
+
*/
|
|
30
|
+
getEntries(pollId: Buffer): readonly BulletinBoardEntry<Buffer>[];
|
|
31
|
+
/**
|
|
32
|
+
* Override getAllEntries to ensure Buffer types are returned and array is immutable
|
|
33
|
+
*/
|
|
34
|
+
getAllEntries(): readonly BulletinBoardEntry<Buffer>[];
|
|
35
|
+
/**
|
|
36
|
+
* Override getTallyProof to ensure Buffer types are returned
|
|
37
|
+
*/
|
|
38
|
+
getTallyProof(pollId: Buffer): TallyProof<Buffer> | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Override export method to return Buffer instead of Uint8Array
|
|
41
|
+
*/
|
|
74
42
|
export(): Buffer;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
private encodeNumber;
|
|
85
|
-
private encodeBigInt;
|
|
43
|
+
/**
|
|
44
|
+
* Get all votes published to the bulletin board
|
|
45
|
+
* Returns the encrypted votes for verification
|
|
46
|
+
*/
|
|
47
|
+
getVotes(): readonly {
|
|
48
|
+
pollId: Buffer;
|
|
49
|
+
encryptedVote: bigint[];
|
|
50
|
+
voterIdHash: Buffer;
|
|
51
|
+
}[];
|
|
86
52
|
}
|
|
87
53
|
//# sourceMappingURL=bulletin-board.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bulletin-board.d.ts","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/bulletin-board.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bulletin-board.d.ts","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/bulletin-board.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,mBAAmB,IAAI,uBAAuB,EAE/C,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAGnE,YAAY,EACV,kBAAkB,EAClB,UAAU,EACV,aAAa,GACd,MAAM,cAAc,CAAC;AAEtB;;;;;;GAMG;AACH,qBAAa,mBAAoB,SAAQ,uBAAuB;gBAClD,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC;IAMtC;;OAEG;IACH,WAAW,CACT,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EAAE,EACvB,WAAW,EAAE,MAAM,GAClB,kBAAkB,CAAC,MAAM,CAAC;IAmB7B;;OAEG;IACH,YAAY,CACV,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE,MAAM,EAAE,EACjB,cAAc,EAAE,MAAM,EAAE,EAAE,GACzB,UAAU,CAAC,MAAM,CAAC;IAmBrB;;OAEG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,kBAAkB,CAAC,MAAM,CAAC,EAAE;IAcjE;;OAEG;IACH,aAAa,IAAI,SAAS,kBAAkB,CAAC,MAAM,CAAC,EAAE;IAatD;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,SAAS;IAc7D;;OAEG;IACH,MAAM,IAAI,MAAM;IAKhB;;;OAGG;IACH,QAAQ,IAAI,SAAS;QACnB,MAAM,EAAE,MAAM,CAAC;QACf,aAAa,EAAE,MAAM,EAAE,CAAC;QACxB,WAAW,EAAE,MAAM,CAAC;KACrB,EAAE;CAQJ"}
|
|
@@ -3,255 +3,119 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PublicBulletinBoard = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Public Bulletin Board for Government-Grade Voting
|
|
6
|
-
* Node.js optimized with
|
|
6
|
+
* Node.js optimized - extends ecies-lib PublicBulletinBoard with Buffer support
|
|
7
7
|
* Implements requirement 1.2: Append-only, publicly verifiable vote publication
|
|
8
8
|
*/
|
|
9
|
-
const
|
|
10
|
-
const constants_1 = require("../../constants");
|
|
11
|
-
const Constants = (0, constants_1.getNodeRuntimeConfiguration)();
|
|
9
|
+
const ecies_lib_1 = require("@digitaldefiance/ecies-lib");
|
|
12
10
|
/**
|
|
13
|
-
*
|
|
11
|
+
* Node.js PublicBulletinBoard that extends ecies-lib PublicBulletinBoard
|
|
12
|
+
* Uses Buffer for binary data instead of Uint8Array
|
|
13
|
+
*
|
|
14
|
+
* The base class handles all the logic, we just provide Node.js-specific defaults
|
|
15
|
+
* and ensure Buffer is used by default instead of Uint8Array.
|
|
14
16
|
*/
|
|
15
|
-
class PublicBulletinBoard {
|
|
16
|
-
entries = [];
|
|
17
|
-
tallyProofs = new Map();
|
|
18
|
-
authority;
|
|
19
|
-
sequence = 0;
|
|
17
|
+
class PublicBulletinBoard extends ecies_lib_1.PublicBulletinBoard {
|
|
20
18
|
constructor(authority) {
|
|
21
|
-
|
|
19
|
+
// Cast to the ecies-lib IMember type which has a different signature
|
|
20
|
+
// The node-ecies-lib IMember is compatible but has a different signature
|
|
21
|
+
super(authority);
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Override publishVote to ensure Buffer types are returned
|
|
25
|
+
*/
|
|
23
26
|
publishVote(pollId, encryptedVote, voterIdHash) {
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
pollId: Buffer.from(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const entryHash = this.sha256(entryData);
|
|
35
|
-
const signature = this.authority.sign(entryHash);
|
|
36
|
-
const entry = {
|
|
37
|
-
sequence: this.sequence++,
|
|
38
|
-
timestamp,
|
|
39
|
-
pollId,
|
|
40
|
-
encryptedVote,
|
|
41
|
-
voterIdHash,
|
|
42
|
-
merkleRoot,
|
|
43
|
-
entryHash,
|
|
44
|
-
signature,
|
|
27
|
+
// Convert Buffer arguments to Uint8Array for parent class
|
|
28
|
+
const entry = super.publishVote(new Uint8Array(pollId), encryptedVote, new Uint8Array(voterIdHash));
|
|
29
|
+
// Convert Uint8Array fields to Buffer
|
|
30
|
+
return {
|
|
31
|
+
...entry,
|
|
32
|
+
pollId: Buffer.from(entry.pollId),
|
|
33
|
+
voterIdHash: Buffer.from(entry.voterIdHash),
|
|
34
|
+
entryHash: Buffer.from(entry.entryHash),
|
|
35
|
+
signature: Buffer.from(entry.signature),
|
|
36
|
+
merkleRoot: Buffer.from(entry.merkleRoot),
|
|
45
37
|
};
|
|
46
|
-
this.entries.push(entry);
|
|
47
|
-
return entry;
|
|
48
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Override publishTally to ensure Buffer types are returned
|
|
41
|
+
*/
|
|
49
42
|
publishTally(pollId, tallies, choices, encryptedVotes) {
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
decryptionProof,
|
|
60
|
-
});
|
|
61
|
-
const signature = this.authority.sign(proofData);
|
|
62
|
-
const proof = {
|
|
63
|
-
pollId,
|
|
64
|
-
tallies,
|
|
65
|
-
choices,
|
|
66
|
-
timestamp,
|
|
67
|
-
votesHash,
|
|
68
|
-
decryptionProof,
|
|
69
|
-
signature,
|
|
43
|
+
// Convert Buffer argument to Uint8Array for parent class
|
|
44
|
+
const proof = super.publishTally(new Uint8Array(pollId), tallies, choices, encryptedVotes);
|
|
45
|
+
// Convert Uint8Array fields to Buffer
|
|
46
|
+
return {
|
|
47
|
+
...proof,
|
|
48
|
+
pollId: Buffer.from(proof.pollId),
|
|
49
|
+
votesHash: Buffer.from(proof.votesHash),
|
|
50
|
+
decryptionProof: Buffer.from(proof.decryptionProof),
|
|
51
|
+
signature: Buffer.from(proof.signature),
|
|
70
52
|
};
|
|
71
|
-
this.tallyProofs.set(pollId.toString('hex'), proof);
|
|
72
|
-
return proof;
|
|
73
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Override getEntries to ensure Buffer types are returned and array is immutable
|
|
56
|
+
*/
|
|
74
57
|
getEntries(pollId) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
58
|
+
// Convert Buffer argument to Uint8Array for parent class
|
|
59
|
+
const entries = super.getEntries(new Uint8Array(pollId));
|
|
60
|
+
const bufferEntries = entries.map((entry) => ({
|
|
61
|
+
...entry,
|
|
62
|
+
pollId: Buffer.from(entry.pollId),
|
|
63
|
+
voterIdHash: Buffer.from(entry.voterIdHash),
|
|
64
|
+
entryHash: Buffer.from(entry.entryHash),
|
|
65
|
+
signature: Buffer.from(entry.signature),
|
|
66
|
+
merkleRoot: Buffer.from(entry.merkleRoot),
|
|
67
|
+
}));
|
|
68
|
+
return Object.freeze(bufferEntries);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Override getAllEntries to ensure Buffer types are returned and array is immutable
|
|
72
|
+
*/
|
|
78
73
|
getAllEntries() {
|
|
79
|
-
|
|
80
|
-
|
|
74
|
+
const entries = super.getAllEntries();
|
|
75
|
+
const bufferEntries = entries.map((entry) => ({
|
|
76
|
+
...entry,
|
|
77
|
+
pollId: Buffer.from(entry.pollId),
|
|
78
|
+
voterIdHash: Buffer.from(entry.voterIdHash),
|
|
79
|
+
entryHash: Buffer.from(entry.entryHash),
|
|
80
|
+
signature: Buffer.from(entry.signature),
|
|
81
|
+
merkleRoot: Buffer.from(entry.merkleRoot),
|
|
82
|
+
}));
|
|
83
|
+
return Object.freeze(bufferEntries);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Override getTallyProof to ensure Buffer types are returned
|
|
87
|
+
*/
|
|
81
88
|
getTallyProof(pollId) {
|
|
82
|
-
|
|
89
|
+
// Convert Buffer argument to Uint8Array for parent class
|
|
90
|
+
const proof = super.getTallyProof(new Uint8Array(pollId));
|
|
91
|
+
if (!proof)
|
|
92
|
+
return undefined;
|
|
93
|
+
return {
|
|
94
|
+
...proof,
|
|
95
|
+
pollId: Buffer.from(proof.pollId),
|
|
96
|
+
votesHash: Buffer.from(proof.votesHash),
|
|
97
|
+
decryptionProof: Buffer.from(proof.decryptionProof),
|
|
98
|
+
signature: Buffer.from(proof.signature),
|
|
99
|
+
};
|
|
83
100
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
101
|
+
/**
|
|
102
|
+
* Override export method to return Buffer instead of Uint8Array
|
|
103
|
+
*/
|
|
104
|
+
export() {
|
|
105
|
+
const exported = super.export();
|
|
106
|
+
return Buffer.from(exported);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Get all votes published to the bulletin board
|
|
110
|
+
* Returns the encrypted votes for verification
|
|
111
|
+
*/
|
|
112
|
+
getVotes() {
|
|
113
|
+
const entries = this.getAllEntries();
|
|
114
|
+
return entries.map((entry) => ({
|
|
88
115
|
pollId: entry.pollId,
|
|
89
116
|
encryptedVote: entry.encryptedVote,
|
|
90
|
-
voterIdHash: entry.voterIdHash,
|
|
91
|
-
|
|
92
|
-
});
|
|
93
|
-
const computedHash = this.sha256(entryData);
|
|
94
|
-
if (!computedHash.equals(entry.entryHash)) {
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
return this.authority.verify(entry.signature, entry.entryHash);
|
|
98
|
-
}
|
|
99
|
-
verifyTallyProof(proof) {
|
|
100
|
-
const pollIdBytes = Buffer.from(Constants.idProvider.toBytes(proof.pollId));
|
|
101
|
-
const proofData = this.serializeTallyProof({
|
|
102
|
-
pollId: pollIdBytes,
|
|
103
|
-
tallies: proof.tallies,
|
|
104
|
-
choices: proof.choices,
|
|
105
|
-
timestamp: proof.timestamp,
|
|
106
|
-
votesHash: proof.votesHash,
|
|
107
|
-
decryptionProof: proof.decryptionProof,
|
|
108
|
-
});
|
|
109
|
-
return this.authority.verify(proof.signature, proofData);
|
|
110
|
-
}
|
|
111
|
-
verifyMerkleTree() {
|
|
112
|
-
for (let i = 0; i < this.entries.length; i++) {
|
|
113
|
-
const entry = this.entries[i];
|
|
114
|
-
const expectedRoot = this.computeMerkleRoot(this.entries.slice(0, i));
|
|
115
|
-
if (!entry.merkleRoot.equals(expectedRoot)) {
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return true;
|
|
120
|
-
}
|
|
121
|
-
export() {
|
|
122
|
-
const parts = [];
|
|
123
|
-
// Export entries
|
|
124
|
-
parts.push(this.encodeNumber(this.entries.length));
|
|
125
|
-
for (const entry of this.entries) {
|
|
126
|
-
parts.push(this.serializeEntry(entry));
|
|
127
|
-
}
|
|
128
|
-
// Export tally proofs
|
|
129
|
-
parts.push(this.encodeNumber(this.tallyProofs.size));
|
|
130
|
-
for (const proof of this.tallyProofs.values()) {
|
|
131
|
-
parts.push(this.serializeTallyProofFull(proof));
|
|
132
|
-
}
|
|
133
|
-
return Buffer.concat(parts);
|
|
134
|
-
}
|
|
135
|
-
computeMerkleRoot(entries) {
|
|
136
|
-
if (entries.length === 0) {
|
|
137
|
-
return Buffer.alloc(32);
|
|
138
|
-
}
|
|
139
|
-
let hashes = entries.map((e) => e.entryHash);
|
|
140
|
-
while (hashes.length > 1) {
|
|
141
|
-
const nextLevel = [];
|
|
142
|
-
for (let i = 0; i < hashes.length; i += 2) {
|
|
143
|
-
if (i + 1 < hashes.length) {
|
|
144
|
-
nextLevel.push(this.sha256(Buffer.concat([hashes[i], hashes[i + 1]])));
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
nextLevel.push(hashes[i]);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
hashes = nextLevel;
|
|
151
|
-
}
|
|
152
|
-
return hashes[0];
|
|
153
|
-
}
|
|
154
|
-
hashEncryptedVotes(votes) {
|
|
155
|
-
const parts = [];
|
|
156
|
-
for (const vote of votes) {
|
|
157
|
-
for (const value of vote) {
|
|
158
|
-
parts.push(this.encodeBigInt(value));
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
return this.sha256(Buffer.concat(parts));
|
|
162
|
-
}
|
|
163
|
-
generateDecryptionProof(encryptedVotes, tallies) {
|
|
164
|
-
// Simplified proof: hash of encrypted votes + tallies
|
|
165
|
-
// In production, use ZK-SNARK or similar
|
|
166
|
-
const parts = [];
|
|
167
|
-
for (const vote of encryptedVotes) {
|
|
168
|
-
for (const value of vote) {
|
|
169
|
-
parts.push(this.encodeBigInt(value));
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
for (const tally of tallies) {
|
|
173
|
-
parts.push(this.encodeBigInt(tally));
|
|
174
|
-
}
|
|
175
|
-
return this.sha256(Buffer.concat(parts));
|
|
176
|
-
}
|
|
177
|
-
serializeEntryData(data) {
|
|
178
|
-
const parts = [
|
|
179
|
-
this.encodeNumber(data.sequence),
|
|
180
|
-
this.encodeNumber(data.timestamp),
|
|
181
|
-
data.pollId,
|
|
182
|
-
data.voterIdHash,
|
|
183
|
-
data.merkleRoot,
|
|
184
|
-
];
|
|
185
|
-
for (const value of data.encryptedVote) {
|
|
186
|
-
parts.push(this.encodeBigInt(value));
|
|
187
|
-
}
|
|
188
|
-
return Buffer.concat(parts);
|
|
189
|
-
}
|
|
190
|
-
serializeTallyProof(data) {
|
|
191
|
-
const parts = [
|
|
192
|
-
data.pollId,
|
|
193
|
-
this.encodeNumber(data.timestamp),
|
|
194
|
-
data.votesHash,
|
|
195
|
-
data.decryptionProof,
|
|
196
|
-
];
|
|
197
|
-
for (const tally of data.tallies) {
|
|
198
|
-
parts.push(this.encodeBigInt(tally));
|
|
199
|
-
}
|
|
200
|
-
for (const choice of data.choices) {
|
|
201
|
-
parts.push(Buffer.from(choice, 'utf8'));
|
|
202
|
-
}
|
|
203
|
-
return Buffer.concat(parts);
|
|
204
|
-
}
|
|
205
|
-
serializeEntry(entry) {
|
|
206
|
-
const pollIdBytes = Buffer.from(Constants.idProvider.toBytes(entry.pollId));
|
|
207
|
-
const parts = [
|
|
208
|
-
this.encodeNumber(entry.sequence),
|
|
209
|
-
this.encodeNumber(entry.timestamp),
|
|
210
|
-
this.encodeNumber(pollIdBytes.length),
|
|
211
|
-
pollIdBytes,
|
|
212
|
-
this.encodeNumber(entry.encryptedVote.length),
|
|
213
|
-
];
|
|
214
|
-
for (const value of entry.encryptedVote) {
|
|
215
|
-
parts.push(this.encodeBigInt(value));
|
|
216
|
-
}
|
|
217
|
-
parts.push(this.encodeNumber(entry.voterIdHash.length), entry.voterIdHash, this.encodeNumber(entry.merkleRoot.length), entry.merkleRoot, this.encodeNumber(entry.entryHash.length), entry.entryHash, this.encodeNumber(entry.signature.length), entry.signature);
|
|
218
|
-
return Buffer.concat(parts);
|
|
219
|
-
}
|
|
220
|
-
serializeTallyProofFull(proof) {
|
|
221
|
-
const pollIdBytes = Buffer.from(Constants.idProvider.toBytes(proof.pollId));
|
|
222
|
-
const parts = [
|
|
223
|
-
this.encodeNumber(pollIdBytes.length),
|
|
224
|
-
pollIdBytes,
|
|
225
|
-
this.encodeNumber(proof.tallies.length),
|
|
226
|
-
];
|
|
227
|
-
for (const tally of proof.tallies) {
|
|
228
|
-
parts.push(this.encodeBigInt(tally));
|
|
229
|
-
}
|
|
230
|
-
parts.push(this.encodeNumber(proof.choices.length));
|
|
231
|
-
for (const choice of proof.choices) {
|
|
232
|
-
const encoded = Buffer.from(choice, 'utf8');
|
|
233
|
-
parts.push(this.encodeNumber(encoded.length), encoded);
|
|
234
|
-
}
|
|
235
|
-
parts.push(this.encodeNumber(proof.timestamp), this.encodeNumber(proof.votesHash.length), proof.votesHash, this.encodeNumber(proof.decryptionProof.length), proof.decryptionProof, this.encodeNumber(proof.signature.length), proof.signature);
|
|
236
|
-
return Buffer.concat(parts);
|
|
237
|
-
}
|
|
238
|
-
getMicrosecondTimestamp() {
|
|
239
|
-
// Get milliseconds since epoch and convert to microseconds
|
|
240
|
-
// performance.now() is relative to process start, not epoch, so we only use Date.now()
|
|
241
|
-
const now = Date.now();
|
|
242
|
-
return now * 1000;
|
|
243
|
-
}
|
|
244
|
-
sha256(data) {
|
|
245
|
-
return (0, crypto_1.createHash)('sha256').update(data).digest();
|
|
246
|
-
}
|
|
247
|
-
encodeNumber(n) {
|
|
248
|
-
const buffer = Buffer.alloc(8);
|
|
249
|
-
buffer.writeBigUInt64BE(BigInt(n));
|
|
250
|
-
return buffer;
|
|
251
|
-
}
|
|
252
|
-
encodeBigInt(n) {
|
|
253
|
-
const hex = n.toString(16).padStart(64, '0');
|
|
254
|
-
return Buffer.from(hex, 'hex');
|
|
117
|
+
voterIdHash: Buffer.from(entry.voterIdHash), // Convert Uint8Array to Buffer
|
|
118
|
+
}));
|
|
255
119
|
}
|
|
256
120
|
}
|
|
257
121
|
exports.PublicBulletinBoard = PublicBulletinBoard;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bulletin-board.js","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/bulletin-board.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,
|
|
1
|
+
{"version":3,"file":"bulletin-board.js","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/bulletin-board.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,23 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Vote Encoder - Encrypts votes using Paillier homomorphic encryption
|
|
3
|
-
* Node.js optimized
|
|
3
|
+
* Node.js optimized - extends ecies-lib VoteEncoder with Buffer support
|
|
4
4
|
*/
|
|
5
|
+
import { VoteEncoder as BaseVoteEncoder } from '@digitaldefiance/ecies-lib';
|
|
5
6
|
import type { PublicKey } from 'paillier-bigint';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Node.js VoteEncoder that extends ecies-lib VoteEncoder
|
|
9
|
+
* Specializes the generic TID parameter to Buffer for Node.js compatibility
|
|
10
|
+
*/
|
|
11
|
+
export declare class VoteEncoder extends BaseVoteEncoder<Buffer> {
|
|
10
12
|
constructor(votingPublicKey: PublicKey);
|
|
11
|
-
encodePlurality(choiceIndex: number, choiceCount: number): EncryptedVote<TID>;
|
|
12
|
-
encodeApproval(choices: number[], choiceCount: number): EncryptedVote<TID>;
|
|
13
|
-
encodeWeighted(choiceIndex: number, weight: bigint, choiceCount: number): EncryptedVote<TID>;
|
|
14
|
-
encodeBorda(rankings: number[], choiceCount: number): EncryptedVote<TID>;
|
|
15
|
-
encodeRankedChoice(rankings: number[], choiceCount: number): EncryptedVote<TID>;
|
|
16
|
-
encode(method: VotingMethod, data: {
|
|
17
|
-
choiceIndex?: number;
|
|
18
|
-
choices?: number[];
|
|
19
|
-
rankings?: number[];
|
|
20
|
-
weight?: bigint;
|
|
21
|
-
}, choiceCount: number): EncryptedVote<TID>;
|
|
22
13
|
}
|
|
23
14
|
//# sourceMappingURL=encoder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encoder.d.ts","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/encoder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"encoder.d.ts","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-node-ecies-lib/src/lib/voting/encoder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;;GAGG;AACH,qBAAa,WAAY,SAAQ,eAAe,CAAC,MAAM,CAAC;gBAC1C,eAAe,EAAE,SAAS;CAOvC"}
|