@digitaldefiance/ecies-lib 4.5.17 → 4.6.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/package.json +1 -1
- package/src/constants.d.ts +7 -0
- package/src/constants.d.ts.map +1 -1
- package/src/constants.js +25 -1
- package/src/constants.js.map +1 -1
- package/src/enumerations/index.d.ts +1 -0
- package/src/enumerations/index.d.ts.map +1 -1
- package/src/enumerations/index.js +1 -0
- package/src/enumerations/index.js.map +1 -1
- package/src/enumerations/voting-error-type.d.ts +37 -0
- package/src/enumerations/voting-error-type.d.ts.map +1 -0
- package/src/enumerations/voting-error-type.js +48 -0
- package/src/enumerations/voting-error-type.js.map +1 -0
- package/src/errors/guid.d.ts.map +1 -1
- package/src/errors/guid.js +1 -1
- package/src/errors/guid.js.map +1 -1
- package/src/errors/index.d.ts +1 -0
- package/src/errors/index.d.ts.map +1 -1
- package/src/errors/index.js +1 -0
- package/src/errors/index.js.map +1 -1
- package/src/errors/voting.d.ts +16 -0
- package/src/errors/voting.d.ts.map +1 -0
- package/src/errors/voting.js +25 -0
- package/src/errors/voting.js.map +1 -0
- package/src/index.d.ts +2 -1
- package/src/index.d.ts.map +1 -1
- package/src/index.js +3 -14
- package/src/index.js.map +1 -1
- package/src/interfaces/constants.d.ts +2 -0
- package/src/interfaces/constants.d.ts.map +1 -1
- package/src/interfaces/ecies-library.d.ts +260 -0
- package/src/interfaces/ecies-library.d.ts.map +1 -0
- package/src/interfaces/ecies-library.js +9 -0
- package/src/interfaces/ecies-library.js.map +1 -0
- package/src/interfaces/index.d.ts +3 -0
- package/src/interfaces/index.d.ts.map +1 -1
- package/src/interfaces/index.js +3 -0
- package/src/interfaces/index.js.map +1 -1
- 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/voting-consts.d.ts +82 -0
- package/src/interfaces/voting-consts.d.ts.map +1 -0
- package/src/interfaces/voting-consts.js +3 -0
- package/src/interfaces/voting-consts.js.map +1 -0
- package/src/interfaces/voting-service.d.ts +172 -0
- package/src/interfaces/voting-service.d.ts.map +1 -0
- package/src/interfaces/voting-service.js +10 -0
- package/src/interfaces/voting-service.js.map +1 -0
- package/src/isolated-private.d.ts +61 -0
- package/src/isolated-private.d.ts.map +1 -0
- package/src/isolated-private.js +148 -0
- package/src/isolated-private.js.map +1 -0
- package/src/isolated-public.d.ts +117 -0
- package/src/isolated-public.d.ts.map +1 -0
- package/src/isolated-public.js +334 -0
- package/src/isolated-public.js.map +1 -0
- package/src/lib/buffer-compat.d.ts +2 -2
- package/src/lib/buffer-compat.d.ts.map +1 -1
- package/src/lib/buffer-compat.js.map +1 -1
- package/src/lib/crypto-polyfill.d.ts.map +1 -1
- package/src/lib/crypto-polyfill.js +2 -1
- package/src/lib/crypto-polyfill.js.map +1 -1
- package/src/lib/guid.d.ts.map +1 -1
- package/src/lib/guid.js +1 -1
- package/src/lib/guid.js.map +1 -1
- package/src/lib/id-providers/guidv4-provider.d.ts.map +1 -1
- package/src/lib/id-providers/guidv4-provider.js +1 -1
- package/src/lib/id-providers/guidv4-provider.js.map +1 -1
- package/src/services/multi-recipient-processor.d.ts.map +1 -1
- package/src/services/multi-recipient-processor.js +1 -1
- package/src/services/multi-recipient-processor.js.map +1 -1
- package/src/services/voting.service.d.ts +32 -2
- package/src/services/voting.service.d.ts.map +1 -1
- package/src/services/voting.service.js +234 -31
- package/src/services/voting.service.js.map +1 -1
- package/src/types.d.ts.map +1 -1
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common interfaces for ECIES library across ecies-lib (browser) and node-ecies-lib (Node.js)
|
|
3
|
+
*
|
|
4
|
+
* This file defines the shared contracts that both implementations must adhere to,
|
|
5
|
+
* ensuring consistent behavior and cross-platform compatibility.
|
|
6
|
+
*/
|
|
7
|
+
import type { EciesEncryptionType } from '../enumerations/ecies-encryption-type';
|
|
8
|
+
import type { PlatformBuffer } from './platform-buffer';
|
|
9
|
+
import type { IVotingService } from './voting-service';
|
|
10
|
+
export type { IVotingService };
|
|
11
|
+
/**
|
|
12
|
+
* ECIES encryption options
|
|
13
|
+
*/
|
|
14
|
+
export interface IEciesEncryptionOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Encryption type to use
|
|
17
|
+
*/
|
|
18
|
+
encryptionType?: EciesEncryptionType;
|
|
19
|
+
/**
|
|
20
|
+
* Additional authenticated data for AES-GCM
|
|
21
|
+
*/
|
|
22
|
+
aad?: PlatformBuffer;
|
|
23
|
+
/**
|
|
24
|
+
* Custom ephemeral key pair (for testing)
|
|
25
|
+
*/
|
|
26
|
+
ephemeralKeyPair?: {
|
|
27
|
+
privateKey: PlatformBuffer;
|
|
28
|
+
publicKey: PlatformBuffer;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Common interface for ECIES encryption/decryption operations
|
|
33
|
+
*/
|
|
34
|
+
export interface IEciesService {
|
|
35
|
+
/**
|
|
36
|
+
* Encrypt data for a single recipient
|
|
37
|
+
*
|
|
38
|
+
* @param recipientPublicKey - Recipient's public key (compressed or uncompressed)
|
|
39
|
+
* @param plaintext - Data to encrypt
|
|
40
|
+
* @param options - Encryption options
|
|
41
|
+
* @returns Encrypted data with ephemeral public key and MAC
|
|
42
|
+
*/
|
|
43
|
+
encrypt(recipientPublicKey: PlatformBuffer, plaintext: PlatformBuffer, options?: IEciesEncryptionOptions): Promise<PlatformBuffer>;
|
|
44
|
+
/**
|
|
45
|
+
* Decrypt data encrypted for this recipient
|
|
46
|
+
*
|
|
47
|
+
* @param recipientPrivateKey - Recipient's private key
|
|
48
|
+
* @param ciphertext - Encrypted data
|
|
49
|
+
* @param options - Decryption options
|
|
50
|
+
* @returns Decrypted plaintext
|
|
51
|
+
*/
|
|
52
|
+
decrypt(recipientPrivateKey: PlatformBuffer, ciphertext: PlatformBuffer, options?: Partial<IEciesEncryptionOptions>): Promise<PlatformBuffer>;
|
|
53
|
+
/**
|
|
54
|
+
* Encrypt data for multiple recipients
|
|
55
|
+
*
|
|
56
|
+
* @param recipientPublicKeys - Array of recipient public keys
|
|
57
|
+
* @param plaintext - Data to encrypt
|
|
58
|
+
* @param options - Encryption options
|
|
59
|
+
* @returns Encrypted data structure for all recipients
|
|
60
|
+
*/
|
|
61
|
+
encryptMultiRecipient(recipientPublicKeys: PlatformBuffer[], plaintext: PlatformBuffer, options?: IEciesEncryptionOptions): Promise<PlatformBuffer>;
|
|
62
|
+
/**
|
|
63
|
+
* Decrypt multi-recipient encrypted data
|
|
64
|
+
*
|
|
65
|
+
* @param recipientPrivateKey - Recipient's private key
|
|
66
|
+
* @param ciphertext - Multi-recipient encrypted data
|
|
67
|
+
* @param recipientIndex - Index of this recipient in the recipient list
|
|
68
|
+
* @param options - Decryption options
|
|
69
|
+
* @returns Decrypted plaintext
|
|
70
|
+
*/
|
|
71
|
+
decryptMultiRecipient(recipientPrivateKey: PlatformBuffer, ciphertext: PlatformBuffer, recipientIndex: number, options?: Partial<IEciesEncryptionOptions>): Promise<PlatformBuffer>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Common interface for cryptographic core operations
|
|
75
|
+
*/
|
|
76
|
+
export interface ICryptoCoreService {
|
|
77
|
+
/**
|
|
78
|
+
* Generate a random ECDH key pair
|
|
79
|
+
*
|
|
80
|
+
* @param curveName - Elliptic curve to use (default: 'secp256k1')
|
|
81
|
+
* @returns Key pair with private and public keys
|
|
82
|
+
*/
|
|
83
|
+
generateKeyPair(curveName?: string): Promise<{
|
|
84
|
+
privateKey: PlatformBuffer;
|
|
85
|
+
publicKey: PlatformBuffer;
|
|
86
|
+
}>;
|
|
87
|
+
/**
|
|
88
|
+
* Derive public key from private key
|
|
89
|
+
*
|
|
90
|
+
* @param privateKey - ECDH private key
|
|
91
|
+
* @param curveName - Elliptic curve to use (default: 'secp256k1')
|
|
92
|
+
* @param compressed - Whether to return compressed public key
|
|
93
|
+
* @returns Public key
|
|
94
|
+
*/
|
|
95
|
+
derivePublicKey(privateKey: PlatformBuffer, curveName?: string, compressed?: boolean): Promise<PlatformBuffer>;
|
|
96
|
+
/**
|
|
97
|
+
* Perform ECDH key agreement
|
|
98
|
+
*
|
|
99
|
+
* @param privateKey - Our private key
|
|
100
|
+
* @param publicKey - Their public key
|
|
101
|
+
* @param curveName - Elliptic curve to use (default: 'secp256k1')
|
|
102
|
+
* @returns Shared secret
|
|
103
|
+
*/
|
|
104
|
+
deriveSharedSecret(privateKey: PlatformBuffer, publicKey: PlatformBuffer, curveName?: string): Promise<PlatformBuffer>;
|
|
105
|
+
/**
|
|
106
|
+
* Sign data with ECDSA
|
|
107
|
+
*
|
|
108
|
+
* @param privateKey - Signing key
|
|
109
|
+
* @param data - Data to sign
|
|
110
|
+
* @param curveName - Elliptic curve to use (default: 'secp256k1')
|
|
111
|
+
* @returns Signature
|
|
112
|
+
*/
|
|
113
|
+
sign(privateKey: PlatformBuffer, data: PlatformBuffer, curveName?: string): Promise<PlatformBuffer>;
|
|
114
|
+
/**
|
|
115
|
+
* Verify ECDSA signature
|
|
116
|
+
*
|
|
117
|
+
* @param publicKey - Verification key
|
|
118
|
+
* @param data - Original data
|
|
119
|
+
* @param signature - Signature to verify
|
|
120
|
+
* @param curveName - Elliptic curve to use (default: 'secp256k1')
|
|
121
|
+
* @returns True if signature is valid
|
|
122
|
+
*/
|
|
123
|
+
verify(publicKey: PlatformBuffer, data: PlatformBuffer, signature: PlatformBuffer, curveName?: string): Promise<boolean>;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Common interface for PBKDF2 key derivation
|
|
127
|
+
*/
|
|
128
|
+
export interface IPbkdf2Service {
|
|
129
|
+
/**
|
|
130
|
+
* Derive a key from a password using PBKDF2
|
|
131
|
+
*
|
|
132
|
+
* @param password - Password to derive from
|
|
133
|
+
* @param salt - Salt value
|
|
134
|
+
* @param iterations - Number of iterations
|
|
135
|
+
* @param keyLength - Desired key length in bytes
|
|
136
|
+
* @param hashAlgorithm - Hash algorithm (default: 'sha256')
|
|
137
|
+
* @returns Derived key
|
|
138
|
+
*/
|
|
139
|
+
derive(password: string | PlatformBuffer, salt: PlatformBuffer, iterations: number, keyLength: number, hashAlgorithm?: string): Promise<PlatformBuffer>;
|
|
140
|
+
/**
|
|
141
|
+
* Generate a random salt
|
|
142
|
+
*
|
|
143
|
+
* @param length - Salt length in bytes (default: 32)
|
|
144
|
+
* @returns Random salt
|
|
145
|
+
*/
|
|
146
|
+
generateSalt(length?: number): PlatformBuffer;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Common interface for AES-GCM encryption
|
|
150
|
+
*/
|
|
151
|
+
export interface IAesGcmService {
|
|
152
|
+
/**
|
|
153
|
+
* Encrypt data with AES-GCM
|
|
154
|
+
*
|
|
155
|
+
* @param key - Encryption key (16, 24, or 32 bytes)
|
|
156
|
+
* @param plaintext - Data to encrypt
|
|
157
|
+
* @param aad - Additional authenticated data (optional)
|
|
158
|
+
* @returns IV (12 bytes) + ciphertext + auth tag (16 bytes)
|
|
159
|
+
*/
|
|
160
|
+
encrypt(key: PlatformBuffer, plaintext: PlatformBuffer, aad?: PlatformBuffer): Promise<PlatformBuffer>;
|
|
161
|
+
/**
|
|
162
|
+
* Decrypt AES-GCM encrypted data
|
|
163
|
+
*
|
|
164
|
+
* @param key - Decryption key
|
|
165
|
+
* @param ciphertext - IV + encrypted data + auth tag
|
|
166
|
+
* @param aad - Additional authenticated data (optional)
|
|
167
|
+
* @returns Decrypted plaintext
|
|
168
|
+
*/
|
|
169
|
+
decrypt(key: PlatformBuffer, ciphertext: PlatformBuffer, aad?: PlatformBuffer): Promise<PlatformBuffer>;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Common interface for checksum/hashing operations
|
|
173
|
+
*/
|
|
174
|
+
export interface IChecksumService {
|
|
175
|
+
/**
|
|
176
|
+
* Compute SHA-256 hash
|
|
177
|
+
*
|
|
178
|
+
* @param data - Data to hash
|
|
179
|
+
* @returns SHA-256 hash (32 bytes)
|
|
180
|
+
*/
|
|
181
|
+
sha256(data: PlatformBuffer): Promise<PlatformBuffer>;
|
|
182
|
+
/**
|
|
183
|
+
* Compute SHA-512 hash
|
|
184
|
+
*
|
|
185
|
+
* @param data - Data to hash
|
|
186
|
+
* @returns SHA-512 hash (64 bytes)
|
|
187
|
+
*/
|
|
188
|
+
sha512(data: PlatformBuffer): Promise<PlatformBuffer>;
|
|
189
|
+
/**
|
|
190
|
+
* Compute HMAC with SHA-256
|
|
191
|
+
*
|
|
192
|
+
* @param key - HMAC key
|
|
193
|
+
* @param data - Data to authenticate
|
|
194
|
+
* @returns HMAC tag (32 bytes)
|
|
195
|
+
*/
|
|
196
|
+
hmacSha256(key: PlatformBuffer, data: PlatformBuffer): Promise<PlatformBuffer>;
|
|
197
|
+
/**
|
|
198
|
+
* Compute HMAC with SHA-512
|
|
199
|
+
*
|
|
200
|
+
* @param key - HMAC key
|
|
201
|
+
* @param data - Data to authenticate
|
|
202
|
+
* @returns HMAC tag (64 bytes)
|
|
203
|
+
*/
|
|
204
|
+
hmacSha512(key: PlatformBuffer, data: PlatformBuffer): Promise<PlatformBuffer>;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Platform-specific random number generation
|
|
208
|
+
*/
|
|
209
|
+
export interface IRandomService {
|
|
210
|
+
/**
|
|
211
|
+
* Generate cryptographically secure random bytes
|
|
212
|
+
*
|
|
213
|
+
* @param length - Number of bytes to generate
|
|
214
|
+
* @returns Random bytes
|
|
215
|
+
*/
|
|
216
|
+
randomBytes(length: number): PlatformBuffer;
|
|
217
|
+
/**
|
|
218
|
+
* Generate a random integer in range [0, max)
|
|
219
|
+
*
|
|
220
|
+
* @param max - Upper bound (exclusive)
|
|
221
|
+
* @returns Random integer
|
|
222
|
+
*/
|
|
223
|
+
randomInt(max: number): number;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Root interface combining all service interfaces
|
|
227
|
+
* Both ecies-lib and node-ecies-lib should provide implementations
|
|
228
|
+
* that conform to these contracts
|
|
229
|
+
*/
|
|
230
|
+
export interface IEciesLibrary {
|
|
231
|
+
/**
|
|
232
|
+
* Core ECIES encryption/decryption operations
|
|
233
|
+
*/
|
|
234
|
+
ecies: IEciesService;
|
|
235
|
+
/**
|
|
236
|
+
* Low-level cryptographic primitives
|
|
237
|
+
*/
|
|
238
|
+
cryptoCore: ICryptoCoreService;
|
|
239
|
+
/**
|
|
240
|
+
* PBKDF2 key derivation
|
|
241
|
+
*/
|
|
242
|
+
pbkdf2: IPbkdf2Service;
|
|
243
|
+
/**
|
|
244
|
+
* AES-GCM symmetric encryption
|
|
245
|
+
*/
|
|
246
|
+
aesGcm: IAesGcmService;
|
|
247
|
+
/**
|
|
248
|
+
* Checksum and hashing operations
|
|
249
|
+
*/
|
|
250
|
+
checksum: IChecksumService;
|
|
251
|
+
/**
|
|
252
|
+
* Voting system (Paillier homomorphic encryption)
|
|
253
|
+
*/
|
|
254
|
+
voting: IVotingService;
|
|
255
|
+
/**
|
|
256
|
+
* Cryptographically secure random number generation
|
|
257
|
+
*/
|
|
258
|
+
random: IRandomService;
|
|
259
|
+
}
|
|
260
|
+
//# sourceMappingURL=ecies-library.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecies-library.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/ecies-library.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGvD,YAAY,EAAE,cAAc,EAAE,CAAC;AA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AAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,MAAM,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAEtD;;;;;OAKG;IACH,MAAM,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAEtD;;;;;;OAMG;IACH,UAAU,CACR,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,cAAc,CAAC,CAAC;IAE3B;;;;;;OAMG;IACH,UAAU,CACR,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,cAAc,CAAC,CAAC;CAC5B;AAID;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,CAAC;IAE5C;;;;;OAKG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CAChC;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,KAAK,EAAE,aAAa,CAAC;IAErB;;OAEG;IACH,UAAU,EAAE,kBAAkB,CAAC;IAE/B;;OAEG;IACH,MAAM,EAAE,cAAc,CAAC;IAEvB;;OAEG;IACH,MAAM,EAAE,cAAc,CAAC;IAEvB;;OAEG;IACH,QAAQ,EAAE,gBAAgB,CAAC;IAE3B;;OAEG;IACH,MAAM,EAAE,cAAc,CAAC;IAEvB;;OAEG;IACH,MAAM,EAAE,cAAc,CAAC;CACxB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Common interfaces for ECIES library across ecies-lib (browser) and node-ecies-lib (Node.js)
|
|
4
|
+
*
|
|
5
|
+
* This file defines the shared contracts that both implementations must adhere to,
|
|
6
|
+
* ensuring consistent behavior and cross-platform compatibility.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
//# sourceMappingURL=ecies-library.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecies-library.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/ecies-library.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
|
|
@@ -4,6 +4,7 @@ export * from './constants';
|
|
|
4
4
|
export * from './ecies-config';
|
|
5
5
|
export * from './ecies-consts';
|
|
6
6
|
export * from './ecies-file-service';
|
|
7
|
+
export * from './ecies-library';
|
|
7
8
|
export * from './frontend-member-operational';
|
|
8
9
|
export * from './guid';
|
|
9
10
|
export type * from './member';
|
|
@@ -12,4 +13,6 @@ export type * from './member-with-mnemonic';
|
|
|
12
13
|
export * from './pbkdf2-config';
|
|
13
14
|
export * from './pbkdf2-consts';
|
|
14
15
|
export * from './pbkdf2-result';
|
|
16
|
+
export * from './platform-buffer';
|
|
17
|
+
export * from './voting-consts';
|
|
15
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,QAAQ,CAAC;AACvB,mBAAmB,UAAU,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,mBAAmB,wBAAwB,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,QAAQ,CAAC;AACvB,mBAAmB,UAAU,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,mBAAmB,wBAAwB,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC"}
|
package/src/interfaces/index.js
CHANGED
|
@@ -7,10 +7,13 @@ tslib_1.__exportStar(require("./constants"), exports);
|
|
|
7
7
|
tslib_1.__exportStar(require("./ecies-config"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./ecies-consts"), exports);
|
|
9
9
|
tslib_1.__exportStar(require("./ecies-file-service"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./ecies-library"), exports);
|
|
10
11
|
tslib_1.__exportStar(require("./frontend-member-operational"), exports);
|
|
11
12
|
tslib_1.__exportStar(require("./guid"), exports);
|
|
12
13
|
tslib_1.__exportStar(require("./member-storage"), exports);
|
|
13
14
|
tslib_1.__exportStar(require("./pbkdf2-config"), exports);
|
|
14
15
|
tslib_1.__exportStar(require("./pbkdf2-consts"), exports);
|
|
15
16
|
tslib_1.__exportStar(require("./pbkdf2-result"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./platform-buffer"), exports);
|
|
18
|
+
tslib_1.__exportStar(require("./voting-consts"), exports);
|
|
16
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/index.ts"],"names":[],"mappings":";;;AAAA,4DAAkC;AAClC,4DAAkC;AAClC,sDAA4B;AAC5B,yDAA+B;AAC/B,yDAA+B;AAC/B,+DAAqC;AACrC,wEAA8C;AAC9C,iDAAuB;AAEvB,2DAAiC;AAEjC,0DAAgC;AAChC,0DAAgC;AAChC,0DAAgC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/index.ts"],"names":[],"mappings":";;;AAAA,4DAAkC;AAClC,4DAAkC;AAClC,sDAA4B;AAC5B,yDAA+B;AAC/B,yDAA+B;AAC/B,+DAAqC;AACrC,0DAAgC;AAChC,wEAA8C;AAC9C,iDAAuB;AAEvB,2DAAiC;AAEjC,0DAAgC;AAChC,0DAAgC;AAChC,0DAAgC;AAChC,4DAAkC;AAClC,0DAAgC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"member.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/member.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD;;;;GAIG;AACH,MAAM,WAAW,OAAO;IAEtB,QAAQ,CAAC,EA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AC9B,OAAO,CAAC,UAAU,CAAC,CAAC;IAEvB,WAAW,CAAC,aAAa,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAG5D,MAAM,IAAI,MAAM,CAAC;IACjB,OAAO,IAAI,IAAI,CAAC;CACjB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform-agnostic buffer type
|
|
3
|
+
*
|
|
4
|
+
* This type adapts to the execution environment:
|
|
5
|
+
* - Browser (ecies-lib): Uint8Array
|
|
6
|
+
* - Node.js (node-ecies-lib): Buffer (which extends Uint8Array)
|
|
7
|
+
*/
|
|
8
|
+
export type PlatformBuffer = Uint8Array | Buffer;
|
|
9
|
+
//# sourceMappingURL=platform-buffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform-buffer.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/platform-buffer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform-buffer.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/platform-buffer.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constants for voting operations using Paillier homomorphic encryption.
|
|
3
|
+
* These values are critical for cryptographic operations and should be consistent
|
|
4
|
+
* across all implementations (ecies-lib, node-ecies-lib, BrightChain).
|
|
5
|
+
*/
|
|
6
|
+
export interface IVotingConsts {
|
|
7
|
+
/**
|
|
8
|
+
* Info string used in HKDF for prime generation.
|
|
9
|
+
* This provides domain separation in the key derivation process.
|
|
10
|
+
*/
|
|
11
|
+
readonly PRIME_GEN_INFO: 'PaillierPrimeGen';
|
|
12
|
+
/**
|
|
13
|
+
* Number of iterations for Miller-Rabin primality test.
|
|
14
|
+
* With 256 rounds, probability of false positive is < 2^-512.
|
|
15
|
+
*/
|
|
16
|
+
readonly PRIME_TEST_ITERATIONS: 256;
|
|
17
|
+
/**
|
|
18
|
+
* Bit length for Paillier key pair generation.
|
|
19
|
+
* 3072 bits provides ~128-bit security level (NIST recommended).
|
|
20
|
+
*/
|
|
21
|
+
readonly KEYPAIR_BIT_LENGTH: 3072;
|
|
22
|
+
/**
|
|
23
|
+
* Offset of the public key in the key pair buffer.
|
|
24
|
+
* Used for buffer serialization calculations.
|
|
25
|
+
*/
|
|
26
|
+
readonly PUB_KEY_OFFSET: 768;
|
|
27
|
+
/**
|
|
28
|
+
* HKDF output length in bytes.
|
|
29
|
+
* SHA-512 produces 64 bytes.
|
|
30
|
+
*/
|
|
31
|
+
readonly HKDF_LENGTH: 64;
|
|
32
|
+
/**
|
|
33
|
+
* HMAC algorithm for HKDF key derivation.
|
|
34
|
+
*/
|
|
35
|
+
readonly HMAC_ALGORITHM: 'sha512';
|
|
36
|
+
/**
|
|
37
|
+
* Hash algorithm for key ID generation and HMAC tagging.
|
|
38
|
+
*/
|
|
39
|
+
readonly HASH_ALGORITHM: 'sha256';
|
|
40
|
+
/**
|
|
41
|
+
* Radix for bit string representation (binary).
|
|
42
|
+
*/
|
|
43
|
+
readonly BITS_RADIX: 2;
|
|
44
|
+
/**
|
|
45
|
+
* Radix for key serialization (hexadecimal).
|
|
46
|
+
*/
|
|
47
|
+
readonly KEY_RADIX: 16;
|
|
48
|
+
/**
|
|
49
|
+
* Format for key serialization.
|
|
50
|
+
*/
|
|
51
|
+
readonly KEY_FORMAT: 'hex';
|
|
52
|
+
/**
|
|
53
|
+
* Format for digest output.
|
|
54
|
+
*/
|
|
55
|
+
readonly DIGEST_FORMAT: 'hex';
|
|
56
|
+
/**
|
|
57
|
+
* Current version of the voting key format.
|
|
58
|
+
* Increment when serialization format changes.
|
|
59
|
+
*/
|
|
60
|
+
readonly KEY_VERSION: 1;
|
|
61
|
+
/**
|
|
62
|
+
* Magic identifier for voting keys.
|
|
63
|
+
* Used to identify key type in serialized format.
|
|
64
|
+
*/
|
|
65
|
+
readonly KEY_MAGIC: 'BCVK';
|
|
66
|
+
/**
|
|
67
|
+
* Maximum attempts to generate a prime number using DRBG.
|
|
68
|
+
* Prevents infinite loops in prime generation.
|
|
69
|
+
*/
|
|
70
|
+
readonly DRBG_PRIME_ATTEMPTS: 20000;
|
|
71
|
+
/**
|
|
72
|
+
* Length of key ID in bytes.
|
|
73
|
+
* SHA-256 produces 32 bytes.
|
|
74
|
+
*/
|
|
75
|
+
readonly KEY_ID_LENGTH: 32;
|
|
76
|
+
/**
|
|
77
|
+
* Length of instance ID in bytes.
|
|
78
|
+
* SHA-256 produces 32 bytes.
|
|
79
|
+
*/
|
|
80
|
+
readonly INSTANCE_ID_LENGTH: 32;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=voting-consts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"voting-consts.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/voting-consts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,QAAQ,CAAC,cAAc,EAAE,kBAAkB,CAAC;IAE5C;;;OAGG;IACH,QAAQ,CAAC,qBAAqB,EAAE,GAAG,CAAC;IAEpC;;;OAGG;IACH,QAAQ,CAAC,kBAAkB,EAAE,IAAI,CAAC;IAElC;;;OAGG;IACH,QAAQ,CAAC,cAAc,EAAE,GAAG,CAAC;IAE7B;;;OAGG;IACH,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,cAAc,EAAE,QAAQ,CAAC;IAElC;;OAEG;IACH,QAAQ,CAAC,cAAc,EAAE,QAAQ,CAAC;IAElC;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IAEvB;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC;IAEvB;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,aAAa,EAAE,KAAK,CAAC;IAE9B;;;OAGG;IACH,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;IAExB;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B;;;OAGG;IACH,QAAQ,CAAC,mBAAmB,EAAE,KAAK,CAAC;IAEpC;;;OAGG;IACH,QAAQ,CAAC,aAAa,EAAE,EAAE,CAAC;IAE3B;;;OAGG;IACH,QAAQ,CAAC,kBAAkB,EAAE,EAAE,CAAC;CACjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"voting-consts.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/voting-consts.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common interface for VotingService across ecies-lib and node-ecies-lib
|
|
3
|
+
*
|
|
4
|
+
* This interface defines the shared contract that both browser (Web Crypto)
|
|
5
|
+
* and Node.js (crypto module) implementations must adhere to, ensuring
|
|
6
|
+
* consistent behavior and cross-platform compatibility.
|
|
7
|
+
*/
|
|
8
|
+
import type { KeyPair, PrivateKey, PublicKey } from 'paillier-bigint';
|
|
9
|
+
import type { IsolatedPrivateKey } from '../isolated-private';
|
|
10
|
+
import type { IsolatedPublicKey } from '../isolated-public';
|
|
11
|
+
import type { PlatformBuffer } from './platform-buffer';
|
|
12
|
+
/**
|
|
13
|
+
* Common interface for VotingService implementations
|
|
14
|
+
*/
|
|
15
|
+
export interface IVotingService {
|
|
16
|
+
/**
|
|
17
|
+
* Serialize a base Paillier public key with magic/version/keyId
|
|
18
|
+
* Format: [magic:4][version:1][keyId:32][n_length:4][n:variable]
|
|
19
|
+
*
|
|
20
|
+
* @param publicKey - Paillier public key to serialize
|
|
21
|
+
* @returns Platform-specific buffer (Uint8Array or Buffer)
|
|
22
|
+
*/
|
|
23
|
+
votingPublicKeyToBuffer(publicKey: PublicKey): PlatformBuffer | Promise<PlatformBuffer>;
|
|
24
|
+
/**
|
|
25
|
+
* Deserialize a base Paillier public key from buffer
|
|
26
|
+
* Format: [magic:4][version:1][keyId:32][n_length:4][n:variable]
|
|
27
|
+
*
|
|
28
|
+
* @param buffer - Serialized public key
|
|
29
|
+
* @returns Deserialized Paillier public key
|
|
30
|
+
*/
|
|
31
|
+
bufferToVotingPublicKey(buffer: PlatformBuffer): Promise<PublicKey>;
|
|
32
|
+
/**
|
|
33
|
+
* Serialize a base Paillier private key with magic/version
|
|
34
|
+
* Format: [magic:4][version:1][lambda_length:4][lambda:variable][mu_length:4][mu:variable]
|
|
35
|
+
*
|
|
36
|
+
* @param privateKey - Paillier private key to serialize
|
|
37
|
+
* @returns Platform-specific buffer (Uint8Array or Buffer)
|
|
38
|
+
*/
|
|
39
|
+
votingPrivateKeyToBuffer(privateKey: PrivateKey): PlatformBuffer;
|
|
40
|
+
/**
|
|
41
|
+
* Deserialize a base Paillier private key from buffer
|
|
42
|
+
* Format: [magic:4][version:1][lambda_length:4][lambda:variable][mu_length:4][mu:variable]
|
|
43
|
+
*
|
|
44
|
+
* @param buffer - Serialized private key
|
|
45
|
+
* @param publicKey - Corresponding public key
|
|
46
|
+
* @returns Deserialized Paillier private key
|
|
47
|
+
*/
|
|
48
|
+
bufferToVotingPrivateKey(buffer: PlatformBuffer, publicKey: PublicKey): Promise<PrivateKey>;
|
|
49
|
+
/**
|
|
50
|
+
* Serialize an IsolatedPublicKey with magic/version/keyId/instanceId
|
|
51
|
+
* Format: [magic:4][version:1][keyId:32][instanceId:32][n_length:4][n:variable]
|
|
52
|
+
*
|
|
53
|
+
* @param publicKey - Isolated public key to serialize
|
|
54
|
+
* @returns Platform-specific buffer (Uint8Array or Buffer)
|
|
55
|
+
*/
|
|
56
|
+
isolatedPublicKeyToBuffer(publicKey: IsolatedPublicKey): PlatformBuffer;
|
|
57
|
+
/**
|
|
58
|
+
* Deserialize an IsolatedPublicKey from buffer
|
|
59
|
+
* Format: [magic:4][version:1][keyId:32][instanceId:32][n_length:4][n:variable]
|
|
60
|
+
*
|
|
61
|
+
* @param buffer - Serialized isolated public key
|
|
62
|
+
* @returns Deserialized IsolatedPublicKey
|
|
63
|
+
*/
|
|
64
|
+
bufferToIsolatedPublicKey(buffer: PlatformBuffer): Promise<IsolatedPublicKey>;
|
|
65
|
+
/**
|
|
66
|
+
* Serialize an IsolatedPrivateKey
|
|
67
|
+
* Uses same format as base private key
|
|
68
|
+
*
|
|
69
|
+
* @param privateKey - Isolated private key to serialize
|
|
70
|
+
* @returns Platform-specific buffer (Uint8Array or Buffer)
|
|
71
|
+
*/
|
|
72
|
+
isolatedPrivateKeyToBuffer(privateKey: IsolatedPrivateKey): PlatformBuffer;
|
|
73
|
+
/**
|
|
74
|
+
* Deserialize an IsolatedPrivateKey from buffer
|
|
75
|
+
*
|
|
76
|
+
* @param buffer - Serialized isolated private key
|
|
77
|
+
* @param publicKey - Corresponding IsolatedPublicKey
|
|
78
|
+
* @returns Deserialized IsolatedPrivateKey
|
|
79
|
+
*/
|
|
80
|
+
bufferToIsolatedPrivateKey(buffer: PlatformBuffer, publicKey: IsolatedPublicKey): Promise<IsolatedPrivateKey>;
|
|
81
|
+
/**
|
|
82
|
+
* Derive Paillier voting keys from ECDH key pair
|
|
83
|
+
*
|
|
84
|
+
* SECURITY: This is the proper way to generate voting keys - they must be
|
|
85
|
+
* derived from ECDH keys to bind them to user identity.
|
|
86
|
+
*
|
|
87
|
+
* @param ecdhPrivateKey - ECDH private key
|
|
88
|
+
* @param ecdhPublicKey - ECDH public key
|
|
89
|
+
* @param options - Optional derivation parameters
|
|
90
|
+
* @returns Paillier key pair
|
|
91
|
+
*/
|
|
92
|
+
deriveVotingKeysFromECDH(ecdhPrivateKey: PlatformBuffer, ecdhPublicKey: PlatformBuffer, options?: Record<string, unknown>): Promise<KeyPair>;
|
|
93
|
+
/**
|
|
94
|
+
* Generate deterministic Paillier key pair from seed
|
|
95
|
+
*
|
|
96
|
+
* WARNING: For testing only! Production voting keys MUST be derived from
|
|
97
|
+
* ECDH keys using deriveVotingKeysFromECDH().
|
|
98
|
+
*
|
|
99
|
+
* @param seed - Random seed for deterministic generation
|
|
100
|
+
* @param bitLength - Key bit length (default: 3072)
|
|
101
|
+
* @param iterations - Prime test iterations (default: 256)
|
|
102
|
+
* @returns Paillier key pair
|
|
103
|
+
*/
|
|
104
|
+
generateDeterministicKeyPair(seed: PlatformBuffer, bitLength?: number, iterations?: number): Promise<KeyPair>;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Common interface for IsolatedPublicKey implementations
|
|
108
|
+
* Both Web Crypto and Node.js crypto versions must implement this
|
|
109
|
+
*/
|
|
110
|
+
export interface IIsolatedPublicKey extends PublicKey {
|
|
111
|
+
/**
|
|
112
|
+
* Deterministic identifier derived from the public key (SHA-256 of 'n')
|
|
113
|
+
*/
|
|
114
|
+
readonly keyId: PlatformBuffer;
|
|
115
|
+
/**
|
|
116
|
+
* Returns a copy of the keyId
|
|
117
|
+
*/
|
|
118
|
+
getKeyId(): PlatformBuffer;
|
|
119
|
+
/**
|
|
120
|
+
* Returns a copy of the current instance ID
|
|
121
|
+
*/
|
|
122
|
+
getInstanceId(): PlatformBuffer;
|
|
123
|
+
/**
|
|
124
|
+
* Updates the current instance ID to a new random value
|
|
125
|
+
* This invalidates all previously encrypted ciphertexts
|
|
126
|
+
*/
|
|
127
|
+
updateInstanceId(): Promise<void>;
|
|
128
|
+
/**
|
|
129
|
+
* Verifies that the keyId matches the SHA-256 hash of the public key 'n'
|
|
130
|
+
*/
|
|
131
|
+
verifyKeyIdAsync(): Promise<void>;
|
|
132
|
+
/**
|
|
133
|
+
* Encrypts a message and tags it with instance HMAC
|
|
134
|
+
*/
|
|
135
|
+
encryptAsync(m: bigint): Promise<bigint>;
|
|
136
|
+
/**
|
|
137
|
+
* Multiplies a ciphertext by a constant, preserving instance HMAC
|
|
138
|
+
*/
|
|
139
|
+
multiplyAsync(ciphertext: bigint, constant: bigint): Promise<bigint>;
|
|
140
|
+
/**
|
|
141
|
+
* Adds two ciphertexts, preserving instance HMAC
|
|
142
|
+
*/
|
|
143
|
+
additionAsync(a: bigint, b: bigint): Promise<bigint>;
|
|
144
|
+
/**
|
|
145
|
+
* Extracts and validates the instance ID from a tagged ciphertext
|
|
146
|
+
* Returns the instance ID if valid, or zero-filled array if invalid
|
|
147
|
+
*/
|
|
148
|
+
extractInstanceId(ciphertext: bigint): Promise<PlatformBuffer>;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Common interface for IsolatedPrivateKey implementations
|
|
152
|
+
* Both Web Crypto and Node.js crypto versions must implement this
|
|
153
|
+
*/
|
|
154
|
+
export interface IIsolatedPrivateKey extends PrivateKey {
|
|
155
|
+
/**
|
|
156
|
+
* Decrypts a tagged ciphertext after validating instance ID and HMAC
|
|
157
|
+
*/
|
|
158
|
+
decryptAsync(taggedCiphertext: bigint): Promise<bigint>;
|
|
159
|
+
/**
|
|
160
|
+
* Gets a copy of the original keyId
|
|
161
|
+
*/
|
|
162
|
+
getOriginalKeyId(): PlatformBuffer;
|
|
163
|
+
/**
|
|
164
|
+
* Gets a copy of the original instanceId
|
|
165
|
+
*/
|
|
166
|
+
getOriginalInstanceId(): PlatformBuffer;
|
|
167
|
+
/**
|
|
168
|
+
* Gets the original public key reference
|
|
169
|
+
*/
|
|
170
|
+
getOriginalPublicKey(): IIsolatedPublicKey;
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=voting-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"voting-service.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/voting-service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EA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interface for VotingService across ecies-lib and node-ecies-lib
|
|
4
|
+
*
|
|
5
|
+
* This interface defines the shared contract that both browser (Web Crypto)
|
|
6
|
+
* and Node.js (crypto module) implementations must adhere to, ensuring
|
|
7
|
+
* consistent behavior and cross-platform compatibility.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
//# sourceMappingURL=voting-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"voting-service.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/voting-service.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG"}
|