@digitaldefiance/ecies-lib 4.17.10 → 4.18.0
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 +3 -2
- package/package.json +2 -2
- package/src/lib/voting/threshold/ceremony-coordinator.d.ts +152 -0
- package/src/lib/voting/threshold/ceremony-coordinator.d.ts.map +1 -0
- package/src/lib/voting/threshold/ceremony-coordinator.js +316 -0
- package/src/lib/voting/threshold/ceremony-coordinator.js.map +1 -0
- package/src/lib/voting/threshold/decryption-combiner.d.ts.map +1 -1
- package/src/lib/voting/threshold/decryption-combiner.js +3 -3
- package/src/lib/voting/threshold/decryption-combiner.js.map +1 -1
- package/src/lib/voting/threshold/guardian-registry.d.ts +1 -1
- package/src/lib/voting/threshold/guardian-registry.d.ts.map +1 -1
- package/src/lib/voting/threshold/index.d.ts +11 -0
- package/src/lib/voting/threshold/index.d.ts.map +1 -1
- package/src/lib/voting/threshold/index.js +32 -1
- package/src/lib/voting/threshold/index.js.map +1 -1
- package/src/lib/voting/threshold/interfaces/partial-decryption.d.ts +2 -2
- package/src/lib/voting/threshold/interfaces/partial-decryption.d.ts.map +1 -1
- package/src/lib/voting/threshold/interval-scheduler.d.ts +123 -0
- package/src/lib/voting/threshold/interval-scheduler.d.ts.map +1 -0
- package/src/lib/voting/threshold/interval-scheduler.js +281 -0
- package/src/lib/voting/threshold/interval-scheduler.js.map +1 -0
- package/src/lib/voting/threshold/partial-decryption-service.d.ts.map +1 -1
- package/src/lib/voting/threshold/partial-decryption-service.js +16 -15
- package/src/lib/voting/threshold/partial-decryption-service.js.map +1 -1
- package/src/lib/voting/threshold/public-tally-feed.d.ts +100 -0
- package/src/lib/voting/threshold/public-tally-feed.d.ts.map +1 -0
- package/src/lib/voting/threshold/public-tally-feed.js +202 -0
- package/src/lib/voting/threshold/public-tally-feed.js.map +1 -0
- package/src/lib/voting/threshold/tally-verifier.d.ts +85 -0
- package/src/lib/voting/threshold/tally-verifier.d.ts.map +1 -0
- package/src/lib/voting/threshold/tally-verifier.js +169 -0
- package/src/lib/voting/threshold/tally-verifier.js.map +1 -0
- package/src/lib/voting/threshold/threshold-audit-log.d.ts +71 -0
- package/src/lib/voting/threshold/threshold-audit-log.d.ts.map +1 -0
- package/src/lib/voting/threshold/threshold-audit-log.js +243 -0
- package/src/lib/voting/threshold/threshold-audit-log.js.map +1 -0
- package/src/lib/voting/threshold/threshold-county-aggregator.d.ts +81 -0
- package/src/lib/voting/threshold/threshold-county-aggregator.d.ts.map +1 -0
- package/src/lib/voting/threshold/threshold-county-aggregator.js +154 -0
- package/src/lib/voting/threshold/threshold-county-aggregator.js.map +1 -0
- package/src/lib/voting/threshold/threshold-key-generator.d.ts.map +1 -1
- package/src/lib/voting/threshold/threshold-key-generator.js.map +1 -1
- package/src/lib/voting/threshold/threshold-national-aggregator.d.ts +95 -0
- package/src/lib/voting/threshold/threshold-national-aggregator.d.ts.map +1 -0
- package/src/lib/voting/threshold/threshold-national-aggregator.js +210 -0
- package/src/lib/voting/threshold/threshold-national-aggregator.js.map +1 -0
- package/src/lib/voting/threshold/threshold-poll-factory.d.ts +88 -0
- package/src/lib/voting/threshold/threshold-poll-factory.d.ts.map +1 -0
- package/src/lib/voting/threshold/threshold-poll-factory.js +156 -0
- package/src/lib/voting/threshold/threshold-poll-factory.js.map +1 -0
- package/src/lib/voting/threshold/threshold-poll.d.ts +76 -0
- package/src/lib/voting/threshold/threshold-poll.d.ts.map +1 -0
- package/src/lib/voting/threshold/threshold-poll.js +144 -0
- package/src/lib/voting/threshold/threshold-poll.js.map +1 -0
- package/src/lib/voting/threshold/threshold-precinct-aggregator.d.ts +86 -0
- package/src/lib/voting/threshold/threshold-precinct-aggregator.d.ts.map +1 -0
- package/src/lib/voting/threshold/threshold-precinct-aggregator.js +156 -0
- package/src/lib/voting/threshold/threshold-precinct-aggregator.js.map +1 -0
- package/src/lib/voting/threshold/threshold-state-aggregator.d.ts +85 -0
- package/src/lib/voting/threshold/threshold-state-aggregator.d.ts.map +1 -0
- package/src/lib/voting/threshold/threshold-state-aggregator.js +164 -0
- package/src/lib/voting/threshold/threshold-state-aggregator.js.map +1 -0
package/README.md
CHANGED
|
@@ -33,6 +33,7 @@ This library implements a modern, enterprise-grade ECIES protocol (v4.0) featuri
|
|
|
33
33
|
### 🗳️ Cryptographic Voting System
|
|
34
34
|
|
|
35
35
|
- **15+ Voting Methods**: Plurality, Approval, Weighted, Borda Count, Score, Ranked Choice (IRV), STAR, STV, Yes/No, Supermajority, and more
|
|
36
|
+
- **Threshold Decryption**: Distributed trust with k-of-n Guardians, real-time interval tallies, and zero-knowledge proofs ([details](src/lib/voting/README.md#threshold-voting))
|
|
36
37
|
- **Government-Grade Security**: Homomorphic encryption, verifiable receipts, immutable audit logs, public bulletin board
|
|
37
38
|
- **Role Separation**: Poll aggregators cannot decrypt votes until closure (separate PollTallier)
|
|
38
39
|
- **Multi-Round Support**: True IRV, STAR voting, STV with intermediate decryption
|
|
@@ -1075,6 +1076,7 @@ class MemberService {
|
|
|
1075
1076
|
- **`PollEventLogger`**: Event tracking with microsecond timestamps
|
|
1076
1077
|
- **Hierarchical Aggregators**: `PrecinctAggregator`, `CountyAggregator`, `StateAggregator`, `NationalAggregator`
|
|
1077
1078
|
- **`BatchVoteProcessor`**: Batch processing and checkpoint management
|
|
1079
|
+
- **Threshold Voting**: `ThresholdKeyGenerator`, `GuardianRegistry`, `CeremonyCoordinator`, `DecryptionCombiner`, `IntervalScheduler`, `PublicTallyFeed`, `TallyVerifier`, `ThresholdPoll`, `ThresholdPollFactory`, `ThresholdAuditLog` — see [Threshold Voting docs](src/lib/voting/README.md#threshold-voting)
|
|
1078
1080
|
|
|
1079
1081
|
### ID Providers
|
|
1080
1082
|
|
|
@@ -1530,8 +1532,7 @@ A: Yes. Use `EncryptionStream` for memory-efficient processing of files of any s
|
|
|
1530
1532
|
|
|
1531
1533
|
### Recent Versions
|
|
1532
1534
|
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
+
**v4.18.0** - Threshold voting
|
|
1535
1536
|
**v4.16.x** - Voting key derivation security improvements, HKDF RFC 5869 compliance
|
|
1536
1537
|
**v4.13.0** - API naming improvements (SIMPLE→BASIC, SINGLE→WITH_LENGTH)
|
|
1537
1538
|
**v4.12.0** - AESGCMService refactoring, JSON encryption
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digitaldefiance/ecies-lib",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.18.0",
|
|
4
4
|
"description": "Digital Defiance ECIES Library",
|
|
5
5
|
"homepage": "https://github.com/Digital-Defiance/ecies-lib",
|
|
6
6
|
"repository": {
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"license": "MIT",
|
|
63
63
|
"packageManager": "yarn@4.11.0",
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@digitaldefiance/i18n-lib": "4.
|
|
65
|
+
"@digitaldefiance/i18n-lib": "4.5.0",
|
|
66
66
|
"@ethereumjs/wallet": "^2.0.4",
|
|
67
67
|
"@noble/curves": "^1.4.2",
|
|
68
68
|
"@noble/hashes": "^1.4.0",
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ceremony Coordinator
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates threshold decryption ceremonies by collecting partial
|
|
5
|
+
* decryptions from Guardians, validating ZK proofs, preventing duplicate
|
|
6
|
+
* submissions, and combining results when the threshold is met.
|
|
7
|
+
*
|
|
8
|
+
* @module voting/threshold
|
|
9
|
+
*/
|
|
10
|
+
import type { PublicKey } from 'paillier-bigint';
|
|
11
|
+
import type { PlatformID } from '../../../interfaces/platform-id';
|
|
12
|
+
import type { Ceremony } from './interfaces/ceremony';
|
|
13
|
+
import type { ICeremonyCoordinator } from './interfaces/ceremony-coordinator';
|
|
14
|
+
import type { PartialDecryption } from './interfaces/partial-decryption';
|
|
15
|
+
import type { ThresholdKeyConfig } from './interfaces/threshold-key-config';
|
|
16
|
+
/**
|
|
17
|
+
* Error thrown when a ceremony is not found.
|
|
18
|
+
*/
|
|
19
|
+
export declare class CeremonyNotFoundError extends Error {
|
|
20
|
+
constructor(message: string);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Error thrown when submitting to a ceremony that is already complete.
|
|
24
|
+
*/
|
|
25
|
+
export declare class CeremonyAlreadyCompleteError extends Error {
|
|
26
|
+
constructor(message: string);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Error thrown when a Guardian submits a duplicate partial decryption.
|
|
30
|
+
*/
|
|
31
|
+
export declare class DuplicatePartialSubmissionError extends Error {
|
|
32
|
+
constructor(message: string);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Error thrown when a partial decryption's ZK proof is invalid.
|
|
36
|
+
*/
|
|
37
|
+
export declare class InvalidCeremonyPartialProofError extends Error {
|
|
38
|
+
constructor(message: string);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Coordinates threshold decryption ceremonies.
|
|
42
|
+
*
|
|
43
|
+
* Manages the lifecycle of decryption ceremonies:
|
|
44
|
+
* 1. Start a ceremony with a unique nonce
|
|
45
|
+
* 2. Collect partial decryptions from Guardians (with duplicate prevention)
|
|
46
|
+
* 3. Validate ZK proofs on each submission
|
|
47
|
+
* 4. Combine partials when threshold k is reached
|
|
48
|
+
* 5. Handle timeout and notify subscribers on completion
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const coordinator = new CeremonyCoordinator<string>(
|
|
53
|
+
* publicKey,
|
|
54
|
+
* verificationKeys,
|
|
55
|
+
* theta,
|
|
56
|
+
* { totalShares: 5, threshold: 3 },
|
|
57
|
+
* 60_000, // 60s timeout
|
|
58
|
+
* );
|
|
59
|
+
*
|
|
60
|
+
* const ceremony = coordinator.startCeremony('poll-1', 1, encryptedTally);
|
|
61
|
+
*
|
|
62
|
+
* coordinator.onCeremonyComplete((c) => {
|
|
63
|
+
* console.log('Ceremony completed:', c.result?.tallies);
|
|
64
|
+
* });
|
|
65
|
+
*
|
|
66
|
+
* // Guardians submit their partials
|
|
67
|
+
* coordinator.submitPartial(ceremony.id, partial1);
|
|
68
|
+
* coordinator.submitPartial(ceremony.id, partial2);
|
|
69
|
+
* coordinator.submitPartial(ceremony.id, partial3); // triggers combine
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare class CeremonyCoordinator<TID extends PlatformID = Uint8Array> implements ICeremonyCoordinator<TID> {
|
|
73
|
+
private readonly _ceremonies;
|
|
74
|
+
private readonly _pollCeremonies;
|
|
75
|
+
private readonly _completionListeners;
|
|
76
|
+
private readonly _timeoutTimers;
|
|
77
|
+
private readonly _publicKey;
|
|
78
|
+
private readonly _verificationKeys;
|
|
79
|
+
private readonly _theta;
|
|
80
|
+
private readonly _config;
|
|
81
|
+
private readonly _ceremonyTimeoutMs;
|
|
82
|
+
private readonly _partialService;
|
|
83
|
+
private readonly _combiner;
|
|
84
|
+
/**
|
|
85
|
+
* Create a new CeremonyCoordinator.
|
|
86
|
+
*
|
|
87
|
+
* @param publicKey - The Paillier public key
|
|
88
|
+
* @param verificationKeys - Verification keys for each Guardian (indexed 0..n-1)
|
|
89
|
+
* @param theta - The theta value from key generation (for combining)
|
|
90
|
+
* @param config - Threshold configuration (k, n)
|
|
91
|
+
* @param ceremonyTimeoutMs - Timeout in ms for each ceremony (0 = no timeout)
|
|
92
|
+
*/
|
|
93
|
+
constructor(publicKey: PublicKey, verificationKeys: readonly Uint8Array[], theta: bigint, config: ThresholdKeyConfig, ceremonyTimeoutMs?: number);
|
|
94
|
+
/**
|
|
95
|
+
* Start a new decryption ceremony.
|
|
96
|
+
*
|
|
97
|
+
* Generates a unique nonce for replay protection and sets up
|
|
98
|
+
* timeout handling if configured.
|
|
99
|
+
*
|
|
100
|
+
* @param pollId - The poll this ceremony is for
|
|
101
|
+
* @param intervalNumber - The interval number triggering this ceremony
|
|
102
|
+
* @param encryptedTally - The encrypted tally ciphertexts to decrypt
|
|
103
|
+
* @returns The newly created ceremony
|
|
104
|
+
*/
|
|
105
|
+
startCeremony(pollId: TID, intervalNumber: number, encryptedTally: bigint[]): Ceremony<TID>;
|
|
106
|
+
/**
|
|
107
|
+
* Submit a partial decryption to a ceremony.
|
|
108
|
+
*
|
|
109
|
+
* Validates:
|
|
110
|
+
* - Ceremony exists and is in progress
|
|
111
|
+
* - Guardian has not already submitted (duplicate prevention)
|
|
112
|
+
* - Ceremony nonce matches (replay protection)
|
|
113
|
+
* - ZK proof is valid
|
|
114
|
+
*
|
|
115
|
+
* When k valid partials are collected, automatically combines them
|
|
116
|
+
* and marks the ceremony as completed.
|
|
117
|
+
*
|
|
118
|
+
* @param ceremonyId - The ceremony to submit to
|
|
119
|
+
* @param partial - The partial decryption with ZK proof
|
|
120
|
+
* @returns true if the submission was accepted
|
|
121
|
+
* @throws CeremonyNotFoundError if the ceremony doesn't exist
|
|
122
|
+
* @throws CeremonyAlreadyCompleteError if the ceremony is not in progress
|
|
123
|
+
* @throws DuplicatePartialSubmissionError if the Guardian already submitted
|
|
124
|
+
* @throws InvalidCeremonyPartialProofError if the ZK proof is invalid
|
|
125
|
+
*/
|
|
126
|
+
submitPartial(ceremonyId: string, partial: PartialDecryption): boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Get a ceremony by ID.
|
|
129
|
+
*/
|
|
130
|
+
getCeremony(ceremonyId: string): Ceremony<TID> | undefined;
|
|
131
|
+
/**
|
|
132
|
+
* Get all ceremonies for a poll.
|
|
133
|
+
*/
|
|
134
|
+
getCeremoniesForPoll(pollId: TID): readonly Ceremony<TID>[];
|
|
135
|
+
/**
|
|
136
|
+
* Subscribe to ceremony completion events.
|
|
137
|
+
*/
|
|
138
|
+
onCeremonyComplete(callback: (ceremony: Ceremony<TID>) => void): void;
|
|
139
|
+
/**
|
|
140
|
+
* Complete a ceremony by combining partial decryptions.
|
|
141
|
+
*/
|
|
142
|
+
private completeCeremony;
|
|
143
|
+
/**
|
|
144
|
+
* Handle ceremony timeout.
|
|
145
|
+
*/
|
|
146
|
+
private handleTimeout;
|
|
147
|
+
/**
|
|
148
|
+
* Compare two Uint8Arrays for equality.
|
|
149
|
+
*/
|
|
150
|
+
private uint8ArrayEquals;
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=ceremony-coordinator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ceremony-coordinator.d.ts","sourceRoot":"","sources":["../../../../../../../packages/digitaldefiance-ecies-lib/src/lib/voting/threshold/ceremony-coordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAGlE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAG5E;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,OAAO,EAAE,MAAM;CAI5B;AAED;;GAEG;AACH,qBAAa,4BAA6B,SAAQ,KAAK;gBACzC,OAAO,EAAE,MAAM;CAI5B;AAED;;GAEG;AACH,qBAAa,+BAAgC,SAAQ,KAAK;gBAC5C,OAAO,EAAE,MAAM;CAI5B;AAED;;GAEG;AACH,qBAAa,gCAAiC,SAAQ,KAAK;gBAC7C,OAAO,EAAE,MAAM;CAI5B;AAgCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qBAAa,mBAAmB,CAC9B,GAAG,SAAS,UAAU,GAAG,UAAU,CACnC,YAAW,oBAAoB,CAA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AEG;IACH,OAAO,CAAC,gBAAgB;IA+BxB;;OAEG;IACH,OAAO,CAAC,aAAa;IAYrB;;OAEG;IACH,OAAO,CAAC,gBAAgB;CAOzB"}
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Ceremony Coordinator
|
|
4
|
+
*
|
|
5
|
+
* Orchestrates threshold decryption ceremonies by collecting partial
|
|
6
|
+
* decryptions from Guardians, validating ZK proofs, preventing duplicate
|
|
7
|
+
* submissions, and combining results when the threshold is met.
|
|
8
|
+
*
|
|
9
|
+
* @module voting/threshold
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CeremonyCoordinator = exports.InvalidCeremonyPartialProofError = exports.DuplicatePartialSubmissionError = exports.CeremonyAlreadyCompleteError = exports.CeremonyNotFoundError = void 0;
|
|
13
|
+
const decryption_combiner_1 = require("./decryption-combiner");
|
|
14
|
+
const ceremony_status_1 = require("./enumerations/ceremony-status");
|
|
15
|
+
const partial_decryption_service_1 = require("./partial-decryption-service");
|
|
16
|
+
/**
|
|
17
|
+
* Error thrown when a ceremony is not found.
|
|
18
|
+
*/
|
|
19
|
+
class CeremonyNotFoundError extends Error {
|
|
20
|
+
constructor(message) {
|
|
21
|
+
super(message);
|
|
22
|
+
this.name = 'CeremonyNotFoundError';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.CeremonyNotFoundError = CeremonyNotFoundError;
|
|
26
|
+
/**
|
|
27
|
+
* Error thrown when submitting to a ceremony that is already complete.
|
|
28
|
+
*/
|
|
29
|
+
class CeremonyAlreadyCompleteError extends Error {
|
|
30
|
+
constructor(message) {
|
|
31
|
+
super(message);
|
|
32
|
+
this.name = 'CeremonyAlreadyCompleteError';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.CeremonyAlreadyCompleteError = CeremonyAlreadyCompleteError;
|
|
36
|
+
/**
|
|
37
|
+
* Error thrown when a Guardian submits a duplicate partial decryption.
|
|
38
|
+
*/
|
|
39
|
+
class DuplicatePartialSubmissionError extends Error {
|
|
40
|
+
constructor(message) {
|
|
41
|
+
super(message);
|
|
42
|
+
this.name = 'DuplicatePartialSubmissionError';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.DuplicatePartialSubmissionError = DuplicatePartialSubmissionError;
|
|
46
|
+
/**
|
|
47
|
+
* Error thrown when a partial decryption's ZK proof is invalid.
|
|
48
|
+
*/
|
|
49
|
+
class InvalidCeremonyPartialProofError extends Error {
|
|
50
|
+
constructor(message) {
|
|
51
|
+
super(message);
|
|
52
|
+
this.name = 'InvalidCeremonyPartialProofError';
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.InvalidCeremonyPartialProofError = InvalidCeremonyPartialProofError;
|
|
56
|
+
/**
|
|
57
|
+
* Converts a PlatformID to a string key for Map lookups.
|
|
58
|
+
*/
|
|
59
|
+
function toKey(id) {
|
|
60
|
+
if (id instanceof Uint8Array) {
|
|
61
|
+
return Array.from(id)
|
|
62
|
+
.map((b) => b.toString(16).padStart(2, '0'))
|
|
63
|
+
.join('');
|
|
64
|
+
}
|
|
65
|
+
return String(id);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Generate a cryptographically random nonce.
|
|
69
|
+
*/
|
|
70
|
+
function generateNonce(length = 32) {
|
|
71
|
+
const nonce = new Uint8Array(length);
|
|
72
|
+
crypto.getRandomValues(nonce);
|
|
73
|
+
return nonce;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Generate a unique ceremony ID from a nonce.
|
|
77
|
+
*/
|
|
78
|
+
function nonceToId(nonce) {
|
|
79
|
+
return Array.from(nonce)
|
|
80
|
+
.map((b) => b.toString(16).padStart(2, '0'))
|
|
81
|
+
.join('');
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Coordinates threshold decryption ceremonies.
|
|
85
|
+
*
|
|
86
|
+
* Manages the lifecycle of decryption ceremonies:
|
|
87
|
+
* 1. Start a ceremony with a unique nonce
|
|
88
|
+
* 2. Collect partial decryptions from Guardians (with duplicate prevention)
|
|
89
|
+
* 3. Validate ZK proofs on each submission
|
|
90
|
+
* 4. Combine partials when threshold k is reached
|
|
91
|
+
* 5. Handle timeout and notify subscribers on completion
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* const coordinator = new CeremonyCoordinator<string>(
|
|
96
|
+
* publicKey,
|
|
97
|
+
* verificationKeys,
|
|
98
|
+
* theta,
|
|
99
|
+
* { totalShares: 5, threshold: 3 },
|
|
100
|
+
* 60_000, // 60s timeout
|
|
101
|
+
* );
|
|
102
|
+
*
|
|
103
|
+
* const ceremony = coordinator.startCeremony('poll-1', 1, encryptedTally);
|
|
104
|
+
*
|
|
105
|
+
* coordinator.onCeremonyComplete((c) => {
|
|
106
|
+
* console.log('Ceremony completed:', c.result?.tallies);
|
|
107
|
+
* });
|
|
108
|
+
*
|
|
109
|
+
* // Guardians submit their partials
|
|
110
|
+
* coordinator.submitPartial(ceremony.id, partial1);
|
|
111
|
+
* coordinator.submitPartial(ceremony.id, partial2);
|
|
112
|
+
* coordinator.submitPartial(ceremony.id, partial3); // triggers combine
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
class CeremonyCoordinator {
|
|
116
|
+
_ceremonies = new Map();
|
|
117
|
+
_pollCeremonies = new Map();
|
|
118
|
+
_completionListeners = [];
|
|
119
|
+
_timeoutTimers = new Map();
|
|
120
|
+
_publicKey;
|
|
121
|
+
_verificationKeys;
|
|
122
|
+
_theta;
|
|
123
|
+
_config;
|
|
124
|
+
_ceremonyTimeoutMs;
|
|
125
|
+
_partialService;
|
|
126
|
+
_combiner;
|
|
127
|
+
/**
|
|
128
|
+
* Create a new CeremonyCoordinator.
|
|
129
|
+
*
|
|
130
|
+
* @param publicKey - The Paillier public key
|
|
131
|
+
* @param verificationKeys - Verification keys for each Guardian (indexed 0..n-1)
|
|
132
|
+
* @param theta - The theta value from key generation (for combining)
|
|
133
|
+
* @param config - Threshold configuration (k, n)
|
|
134
|
+
* @param ceremonyTimeoutMs - Timeout in ms for each ceremony (0 = no timeout)
|
|
135
|
+
*/
|
|
136
|
+
constructor(publicKey, verificationKeys, theta, config, ceremonyTimeoutMs = 0) {
|
|
137
|
+
this._publicKey = publicKey;
|
|
138
|
+
this._verificationKeys = verificationKeys;
|
|
139
|
+
this._theta = theta;
|
|
140
|
+
this._config = config;
|
|
141
|
+
this._ceremonyTimeoutMs = ceremonyTimeoutMs;
|
|
142
|
+
this._partialService = new partial_decryption_service_1.PartialDecryptionService(publicKey);
|
|
143
|
+
this._combiner = new decryption_combiner_1.DecryptionCombiner(publicKey, verificationKeys, theta);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Start a new decryption ceremony.
|
|
147
|
+
*
|
|
148
|
+
* Generates a unique nonce for replay protection and sets up
|
|
149
|
+
* timeout handling if configured.
|
|
150
|
+
*
|
|
151
|
+
* @param pollId - The poll this ceremony is for
|
|
152
|
+
* @param intervalNumber - The interval number triggering this ceremony
|
|
153
|
+
* @param encryptedTally - The encrypted tally ciphertexts to decrypt
|
|
154
|
+
* @returns The newly created ceremony
|
|
155
|
+
*/
|
|
156
|
+
startCeremony(pollId, intervalNumber, encryptedTally) {
|
|
157
|
+
const nonce = generateNonce();
|
|
158
|
+
const id = nonceToId(nonce);
|
|
159
|
+
const ceremony = {
|
|
160
|
+
id,
|
|
161
|
+
pollId,
|
|
162
|
+
intervalNumber,
|
|
163
|
+
nonce,
|
|
164
|
+
encryptedTally: [...encryptedTally],
|
|
165
|
+
status: ceremony_status_1.CeremonyStatus.InProgress,
|
|
166
|
+
partials: new Map(),
|
|
167
|
+
startedAt: Date.now(),
|
|
168
|
+
};
|
|
169
|
+
this._ceremonies.set(id, ceremony);
|
|
170
|
+
// Track ceremony under its poll
|
|
171
|
+
const pollKey = toKey(pollId);
|
|
172
|
+
const existing = this._pollCeremonies.get(pollKey) ?? [];
|
|
173
|
+
existing.push(id);
|
|
174
|
+
this._pollCeremonies.set(pollKey, existing);
|
|
175
|
+
// Set up timeout if configured
|
|
176
|
+
if (this._ceremonyTimeoutMs > 0) {
|
|
177
|
+
const timer = setTimeout(() => {
|
|
178
|
+
this.handleTimeout(id);
|
|
179
|
+
}, this._ceremonyTimeoutMs);
|
|
180
|
+
this._timeoutTimers.set(id, timer);
|
|
181
|
+
}
|
|
182
|
+
return ceremony;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Submit a partial decryption to a ceremony.
|
|
186
|
+
*
|
|
187
|
+
* Validates:
|
|
188
|
+
* - Ceremony exists and is in progress
|
|
189
|
+
* - Guardian has not already submitted (duplicate prevention)
|
|
190
|
+
* - Ceremony nonce matches (replay protection)
|
|
191
|
+
* - ZK proof is valid
|
|
192
|
+
*
|
|
193
|
+
* When k valid partials are collected, automatically combines them
|
|
194
|
+
* and marks the ceremony as completed.
|
|
195
|
+
*
|
|
196
|
+
* @param ceremonyId - The ceremony to submit to
|
|
197
|
+
* @param partial - The partial decryption with ZK proof
|
|
198
|
+
* @returns true if the submission was accepted
|
|
199
|
+
* @throws CeremonyNotFoundError if the ceremony doesn't exist
|
|
200
|
+
* @throws CeremonyAlreadyCompleteError if the ceremony is not in progress
|
|
201
|
+
* @throws DuplicatePartialSubmissionError if the Guardian already submitted
|
|
202
|
+
* @throws InvalidCeremonyPartialProofError if the ZK proof is invalid
|
|
203
|
+
*/
|
|
204
|
+
submitPartial(ceremonyId, partial) {
|
|
205
|
+
const ceremony = this._ceremonies.get(ceremonyId);
|
|
206
|
+
if (!ceremony) {
|
|
207
|
+
throw new CeremonyNotFoundError(`Ceremony '${ceremonyId}' not found`);
|
|
208
|
+
}
|
|
209
|
+
if (ceremony.status !== ceremony_status_1.CeremonyStatus.InProgress) {
|
|
210
|
+
throw new CeremonyAlreadyCompleteError(`Ceremony '${ceremonyId}' is not in progress (status: ${ceremony.status})`);
|
|
211
|
+
}
|
|
212
|
+
// Duplicate prevention: check if this Guardian already submitted
|
|
213
|
+
if (ceremony.partials.has(partial.guardianIndex)) {
|
|
214
|
+
throw new DuplicatePartialSubmissionError(`Guardian ${partial.guardianIndex} has already submitted a partial decryption for ceremony '${ceremonyId}'`);
|
|
215
|
+
}
|
|
216
|
+
// Validate ceremony nonce matches (replay protection)
|
|
217
|
+
if (!this.uint8ArrayEquals(partial.ceremonyNonce, ceremony.nonce)) {
|
|
218
|
+
throw new InvalidCeremonyPartialProofError(`Ceremony nonce mismatch for Guardian ${partial.guardianIndex} in ceremony '${ceremonyId}'`);
|
|
219
|
+
}
|
|
220
|
+
// Validate ZK proof
|
|
221
|
+
const vkIndex = partial.guardianIndex - 1; // 1-indexed to 0-indexed
|
|
222
|
+
if (vkIndex < 0 || vkIndex >= this._verificationKeys.length) {
|
|
223
|
+
throw new InvalidCeremonyPartialProofError(`Guardian index ${partial.guardianIndex} is out of range [1, ${this._verificationKeys.length}]`);
|
|
224
|
+
}
|
|
225
|
+
const isValid = this._partialService.verifyPartial(partial, ceremony.encryptedTally, this._verificationKeys[vkIndex], this._publicKey);
|
|
226
|
+
if (!isValid) {
|
|
227
|
+
throw new InvalidCeremonyPartialProofError(`ZK proof verification failed for Guardian ${partial.guardianIndex} in ceremony '${ceremonyId}'`);
|
|
228
|
+
}
|
|
229
|
+
// Accept the partial
|
|
230
|
+
ceremony.partials.set(partial.guardianIndex, partial);
|
|
231
|
+
// Check if we have enough partials to combine
|
|
232
|
+
if (ceremony.partials.size >= this._config.threshold) {
|
|
233
|
+
this.completeCeremony(ceremony);
|
|
234
|
+
}
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Get a ceremony by ID.
|
|
239
|
+
*/
|
|
240
|
+
getCeremony(ceremonyId) {
|
|
241
|
+
return this._ceremonies.get(ceremonyId);
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Get all ceremonies for a poll.
|
|
245
|
+
*/
|
|
246
|
+
getCeremoniesForPoll(pollId) {
|
|
247
|
+
const pollKey = toKey(pollId);
|
|
248
|
+
const ceremonyIds = this._pollCeremonies.get(pollKey) ?? [];
|
|
249
|
+
const ceremonies = [];
|
|
250
|
+
for (const id of ceremonyIds) {
|
|
251
|
+
const ceremony = this._ceremonies.get(id);
|
|
252
|
+
if (ceremony) {
|
|
253
|
+
ceremonies.push(ceremony);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return ceremonies;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Subscribe to ceremony completion events.
|
|
260
|
+
*/
|
|
261
|
+
onCeremonyComplete(callback) {
|
|
262
|
+
this._completionListeners.push(callback);
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Complete a ceremony by combining partial decryptions.
|
|
266
|
+
*/
|
|
267
|
+
completeCeremony(ceremony) {
|
|
268
|
+
// Clear timeout timer
|
|
269
|
+
const timer = this._timeoutTimers.get(ceremony.id);
|
|
270
|
+
if (timer !== undefined) {
|
|
271
|
+
clearTimeout(timer);
|
|
272
|
+
this._timeoutTimers.delete(ceremony.id);
|
|
273
|
+
}
|
|
274
|
+
try {
|
|
275
|
+
const partials = Array.from(ceremony.partials.values());
|
|
276
|
+
const result = this._combiner.combine(partials, ceremony.encryptedTally, this._publicKey, this._config);
|
|
277
|
+
ceremony.result = result;
|
|
278
|
+
ceremony.status = ceremony_status_1.CeremonyStatus.Completed;
|
|
279
|
+
ceremony.completedAt = Date.now();
|
|
280
|
+
// Notify listeners
|
|
281
|
+
for (const listener of this._completionListeners) {
|
|
282
|
+
listener(ceremony);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
catch {
|
|
286
|
+
ceremony.status = ceremony_status_1.CeremonyStatus.Failed;
|
|
287
|
+
ceremony.completedAt = Date.now();
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Handle ceremony timeout.
|
|
292
|
+
*/
|
|
293
|
+
handleTimeout(ceremonyId) {
|
|
294
|
+
this._timeoutTimers.delete(ceremonyId);
|
|
295
|
+
const ceremony = this._ceremonies.get(ceremonyId);
|
|
296
|
+
if (!ceremony || ceremony.status !== ceremony_status_1.CeremonyStatus.InProgress) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
ceremony.status = ceremony_status_1.CeremonyStatus.TimedOut;
|
|
300
|
+
ceremony.completedAt = Date.now();
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Compare two Uint8Arrays for equality.
|
|
304
|
+
*/
|
|
305
|
+
uint8ArrayEquals(a, b) {
|
|
306
|
+
if (a.length !== b.length)
|
|
307
|
+
return false;
|
|
308
|
+
for (let i = 0; i < a.length; i++) {
|
|
309
|
+
if (a[i] !== b[i])
|
|
310
|
+
return false;
|
|
311
|
+
}
|
|
312
|
+
return true;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
exports.CeremonyCoordinator = CeremonyCoordinator;
|
|
316
|
+
//# sourceMappingURL=ceremony-coordinator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ceremony-coordinator.js","sourceRoot":"","sources":["../../../../../../../packages/digitaldefiance-ecies-lib/src/lib/voting/threshold/ceremony-coordinator.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAIH,+DAA2D;AAC3D,oEAAgE;AAKhE,6EAAwE;AAExE;;GAEG;AACH,MAAa,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AALD,sDAKC;AAED;;GAEG;AACH,MAAa,4BAA6B,SAAQ,KAAK;IACrD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC;IAC7C,CAAC;CACF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CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAAE,OAAO,KAAK,CAAC;QAClC,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AApQD,kDAoQC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decryption-combiner.d.ts","sourceRoot":"","sources":["../../../../../../../packages/digitaldefiance-ecies-lib/src/lib/voting/threshold/decryption-combiner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EACV,kBAAkB,EAElB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,cAAc,CAAC;AAGtB;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,KAAK;gBACtC,OAAO,EAAE,MAAM;CAI5B;AAED;;GAEG;AACH,qBAAa,4BAA6B,SAAQ,KAAK;gBACzC,OAAO,EAAE,MAAM;CAI5B;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,kBAAmB,YAAW,mBAAmB;IAC5D,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAwB;IACzD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA2B;IAC1D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;gBAG7B,SAAS,EAAE,SAAS,EACpB,gBAAgB,EAAE,SAAS,UAAU,EAAE,EACvC,KAAK,EAAE,MAAM;IAOf;;;;;;;;;;;OAWG;IACH,OAAO,CACL,QAAQ,EAAE,SAAS,iBAAiB,EAAE,EACtC,cAAc,EAAE,MAAM,EAAE,EACxB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,kBAAkB,GACzB,kBAAkB;IAmFrB;;;;;;;OAOG;IACH,cAAc,CACZ,QAAQ,EAAE,kBAAkB,EAC5B,cAAc,EAAE,MAAM,EAAE,EACxB,gBAAgB,EAAE,SAAS,UAAU,EAAE,EACvC,SAAS,EAAE,SAAS,GACnB,OAAO;
|
|
1
|
+
{"version":3,"file":"decryption-combiner.d.ts","sourceRoot":"","sources":["../../../../../../../packages/digitaldefiance-ecies-lib/src/lib/voting/threshold/decryption-combiner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EACV,kBAAkB,EAElB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,cAAc,CAAC;AAGtB;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,KAAK;gBACtC,OAAO,EAAE,MAAM;CAI5B;AAED;;GAEG;AACH,qBAAa,4BAA6B,SAAQ,KAAK;gBACzC,OAAO,EAAE,MAAM;CAI5B;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,kBAAmB,YAAW,mBAAmB;IAC5D,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAwB;IACzD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA2B;IAC1D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;gBAG7B,SAAS,EAAE,SAAS,EACpB,gBAAgB,EAAE,SAAS,UAAU,EAAE,EACvC,KAAK,EAAE,MAAM;IAOf;;;;;;;;;;;OAWG;IACH,OAAO,CACL,QAAQ,EAAE,SAAS,iBAAiB,EAAE,EACtC,cAAc,EAAE,MAAM,EAAE,EACxB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,kBAAkB,GACzB,kBAAkB;IAmFrB;;;;;;;OAOG;IACH,cAAc,CACZ,QAAQ,EAAE,kBAAkB,EAC5B,cAAc,EAAE,MAAM,EAAE,EACxB,gBAAgB,EAAE,SAAS,UAAU,EAAE,EACvC,SAAS,EAAE,SAAS,GACnB,OAAO;IAyCV;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,uBAAuB;IAmD/B;;;;;;OAMG;IACH,OAAO,CAAC,0BAA0B;IAmBlC;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAyB1B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAWxB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAS1B;;OAEG;IACH,OAAO,CAAC,SAAS;IAQjB;;OAEG;IACH,OAAO,CAAC,GAAG;IAKX;;OAEG;IACH,OAAO,CAAC,MAAM;IAcd;;OAEG;IACH,OAAO,CAAC,UAAU;IAqBlB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAa1B;;OAEG;IACH,OAAO,CAAC,gBAAgB;CAOzB"}
|
|
@@ -98,7 +98,7 @@ class DecryptionCombiner {
|
|
|
98
98
|
const n = publicKey.n;
|
|
99
99
|
const n2 = n * n;
|
|
100
100
|
// Compute the tallies by combining partial decryptions for each ciphertext
|
|
101
|
-
const tallies = encryptedTally.map((
|
|
101
|
+
const tallies = encryptedTally.map((_ciphertext, ciphertextIndex) => this.combineSingleCiphertext(ciphertextIndex, usedPartials, n, n2, config));
|
|
102
102
|
// Build the combined ZK proof
|
|
103
103
|
const combinedProof = this.buildCombinedProof(usedPartials, encryptedTally, n2);
|
|
104
104
|
return {
|
|
@@ -167,7 +167,7 @@ class DecryptionCombiner {
|
|
|
167
167
|
* By the Paillier L-function property: L(c^(4·Δ·λ)) = 4·Δ·λ·m mod n
|
|
168
168
|
* So: plaintext = L(combined) · (4·Δ)^(-1) mod n
|
|
169
169
|
*/
|
|
170
|
-
combineSingleCiphertext(
|
|
170
|
+
combineSingleCiphertext(ciphertextIndex, partials, n, n2, config) {
|
|
171
171
|
const indices = partials.map((p) => p.guardianIndex);
|
|
172
172
|
const delta = this.factorial(BigInt(config.totalShares));
|
|
173
173
|
// Compute combined value using Lagrange interpolation in the exponent:
|
|
@@ -175,7 +175,7 @@ class DecryptionCombiner {
|
|
|
175
175
|
// where λ_i' = Δ · Π_{j≠i} j/(j-i) are integer Lagrange coefficients
|
|
176
176
|
let combined = 1n;
|
|
177
177
|
for (const partial of partials) {
|
|
178
|
-
const partialValue = partial.
|
|
178
|
+
const partialValue = partial.values[ciphertextIndex];
|
|
179
179
|
const lambda = this.lagrangeCoefficientInteger(partial.guardianIndex, indices, delta);
|
|
180
180
|
// combined *= partial_i^(2·lambda) mod n²
|
|
181
181
|
// The exponent can be negative, so we handle that with modular inverse
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decryption-combiner.js","sourceRoot":"","sources":["../../../../../../../packages/digitaldefiance-ecies-lib/src/lib/voting/threshold/decryption-combiner.ts"],"names":[],"mappings":";;;AAuBA,6EAAwE;AAExE;;GAEG;AACH,MAAa,yBAA0B,SAAQ,KAAK;IAClD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;IAC1C,CAAC;CACF;AALD,8DAKC;AAED;;GAEG;AACH,MAAa,4BAA6B,SAAQ,KAAK;IACrD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC;IAC7C,CAAC;CACF;AALD,oEAKC;AAED;;GAEG;AACH,MAAa,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AALD,gDAKC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAa,kBAAkB;IACZ,gBAAgB,CAAwB;IACxC,cAAc,CAA2B;IACzC,KAAK,CAAS;IAE/B,YACE,SAAoB,EACpB,gBAAuC,EACvC,KAAa;QAEb,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,I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,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1C,MAAM,sBAAsB,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC;QAExE,IAAI,CAAC;YACH,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC;YACtB,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;YAEjB,2EAA2E;YAC3E,MAAM,OAAO,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"decryption-combiner.js","sourceRoot":"","sources":["../../../../../../../packages/digitaldefiance-ecies-lib/src/lib/voting/threshold/decryption-combiner.ts"],"names":[],"mappings":";;;AAuBA,6EAAwE;AAExE;;GAEG;AACH,MAAa,yBAA0B,SAAQ,KAAK;IAClD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;IAC1C,CAAC;CACF;AALD,8DAKC;AAED;;GAEG;AACH,MAAa,4BAA6B,SAAQ,KAAK;IACrD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC;IAC7C,CAAC;CACF;AALD,oEAKC;AAED;;GAEG;AACH,MAAa,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AALD,gDAKC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAa,kBAAkB;IACZ,gBAAgB,CAAwB;IACxC,cAAc,CAA2B;IACzC,KAAK,CAAS;IAE/B,YACE,SAAoB,EACpB,gBAAuC,EACvC,KAAa;QAEb,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI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CAAC;CACF;AAhZD,gDAgZC"}
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
import type { PlatformID } from '../../../interfaces/platform-id';
|
|
11
11
|
import { GuardianStatus } from './enumerations/guardian-status';
|
|
12
12
|
import type { Guardian } from './interfaces/guardian';
|
|
13
|
-
import type { GuardianStatusChangeEvent } from './interfaces/guardian-status-change-event';
|
|
14
13
|
import type { IGuardianRegistry } from './interfaces/guardian-registry';
|
|
14
|
+
import type { GuardianStatusChangeEvent } from './interfaces/guardian-status-change-event';
|
|
15
15
|
/**
|
|
16
16
|
* Error thrown when attempting to register a Guardian with a duplicate ID.
|
|
17
17
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guardian-registry.d.ts","sourceRoot":"","sources":["../../../../../../../packages/digitaldefiance-ecies-lib/src/lib/voting/threshold/guardian-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"guardian-registry.d.ts","sourceRoot":"","sources":["../../../../../../../packages/digitaldefiance-ecies-lib/src/lib/voting/threshold/guardian-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AAE3F;;GAEG;AACH,qBAAa,8BAA+B,SAAQ,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;IA0BnD;;;;;;;OAOG;IACH,eAAe,CAAC,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,GAAG,IAAI;IA2BrD;;OAEG;IACH,cAAc,CACZ,QAAQ,EAAE,CAAC,KAAK,EAAE,yBAAyB,CAAC,GAAG,CAAC,KAAK,IAAI,GACxD,IAAI;CAGR"}
|
|
@@ -46,4 +46,15 @@ export { ThresholdKeyGenerator, InvalidThresholdConfigError, KeyGenerationFailed
|
|
|
46
46
|
export { PartialDecryptionService, InvalidPartialProofError, DeserializationError, } from './partial-decryption-service';
|
|
47
47
|
export { DecryptionCombiner, InsufficientPartialsError, InvalidPartialInCombineError, CombineFailedError, } from './decryption-combiner';
|
|
48
48
|
export { GuardianRegistry, GuardianAlreadyRegisteredError, GuardianNotFoundError, InvalidShareIndexError, RegistryFullError, } from './guardian-registry';
|
|
49
|
+
export { IntervalScheduler, PollNotConfiguredError, InvalidIntervalConfigError, PollSchedulingStateError, } from './interval-scheduler';
|
|
50
|
+
export { CeremonyCoordinator, CeremonyNotFoundError, CeremonyAlreadyCompleteError, DuplicatePartialSubmissionError, InvalidCeremonyPartialProofError, } from './ceremony-coordinator';
|
|
51
|
+
export { PublicTallyFeed } from './public-tally-feed';
|
|
52
|
+
export { TallyVerifier } from './tally-verifier';
|
|
53
|
+
export { ThresholdPoll } from './threshold-poll';
|
|
54
|
+
export { ThresholdPollFactory, InsufficientGuardiansError, InvalidThresholdPollConfigError, } from './threshold-poll-factory';
|
|
55
|
+
export { ThresholdPrecinctAggregator } from './threshold-precinct-aggregator';
|
|
56
|
+
export { ThresholdCountyAggregator } from './threshold-county-aggregator';
|
|
57
|
+
export { ThresholdStateAggregator } from './threshold-state-aggregator';
|
|
58
|
+
export { ThresholdNationalAggregator } from './threshold-national-aggregator';
|
|
59
|
+
export { ThresholdAuditLog } from './threshold-audit-log';
|
|
49
60
|
//# sourceMappingURL=index.d.ts.map
|