@digitaldefiance/ecies-lib 4.5.18 → 4.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/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 -0
- package/src/index.d.ts.map +1 -1
- package/src/index.js +2 -0
- 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 +259 -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 +5 -0
- package/src/interfaces/index.d.ts.map +1 -1
- package/src/interfaces/index.js +5 -0
- package/src/interfaces/index.js.map +1 -1
- package/src/interfaces/isolated-keys.d.ts +83 -0
- package/src/interfaces/isolated-keys.d.ts.map +1 -0
- package/src/interfaces/isolated-keys.js +8 -0
- package/src/interfaces/isolated-keys.js.map +1 -0
- package/src/interfaces/member.d.ts +25 -21
- 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 +131 -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 +67 -0
- package/src/isolated-private.d.ts.map +1 -0
- package/src/isolated-private.js +155 -0
- package/src/isolated-private.js.map +1 -0
- package/src/isolated-public.d.ts +138 -0
- package/src/isolated-public.d.ts.map +1 -0
- package/src/isolated-public.js +362 -0
- package/src/isolated-public.js.map +1 -0
- package/src/services/index.d.ts +1 -1
- package/src/services/index.d.ts.map +1 -1
- package/src/services/index.js +1 -11
- package/src/services/index.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 +230 -27
- package/src/services/voting.service.js.map +1 -1
|
@@ -0,0 +1,259 @@
|
|
|
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
|
+
/**
|
|
11
|
+
* ECIES encryption options
|
|
12
|
+
*/
|
|
13
|
+
export interface IEciesEncryptionOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Encryption type to use
|
|
16
|
+
*/
|
|
17
|
+
encryptionType?: EciesEncryptionType;
|
|
18
|
+
/**
|
|
19
|
+
* Additional authenticated data for AES-GCM
|
|
20
|
+
*/
|
|
21
|
+
aad?: PlatformBuffer;
|
|
22
|
+
/**
|
|
23
|
+
* Custom ephemeral key pair (for testing)
|
|
24
|
+
*/
|
|
25
|
+
ephemeralKeyPair?: {
|
|
26
|
+
privateKey: PlatformBuffer;
|
|
27
|
+
publicKey: PlatformBuffer;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Common interface for ECIES encryption/decryption operations
|
|
32
|
+
*/
|
|
33
|
+
export interface IEciesService {
|
|
34
|
+
/**
|
|
35
|
+
* Encrypt data for a single recipient
|
|
36
|
+
*
|
|
37
|
+
* @param recipientPublicKey - Recipient's public key (compressed or uncompressed)
|
|
38
|
+
* @param plaintext - Data to encrypt
|
|
39
|
+
* @param options - Encryption options
|
|
40
|
+
* @returns Encrypted data with ephemeral public key and MAC
|
|
41
|
+
*/
|
|
42
|
+
encrypt(recipientPublicKey: PlatformBuffer, plaintext: PlatformBuffer, options?: IEciesEncryptionOptions): Promise<PlatformBuffer>;
|
|
43
|
+
/**
|
|
44
|
+
* Decrypt data encrypted for this recipient
|
|
45
|
+
*
|
|
46
|
+
* @param recipientPrivateKey - Recipient's private key
|
|
47
|
+
* @param ciphertext - Encrypted data
|
|
48
|
+
* @param options - Decryption options
|
|
49
|
+
* @returns Decrypted plaintext
|
|
50
|
+
*/
|
|
51
|
+
decrypt(recipientPrivateKey: PlatformBuffer, ciphertext: PlatformBuffer, options?: Partial<IEciesEncryptionOptions>): Promise<PlatformBuffer>;
|
|
52
|
+
/**
|
|
53
|
+
* Encrypt data for multiple recipients
|
|
54
|
+
*
|
|
55
|
+
* @param recipientPublicKeys - Array of recipient public keys
|
|
56
|
+
* @param plaintext - Data to encrypt
|
|
57
|
+
* @param options - Encryption options
|
|
58
|
+
* @returns Encrypted data structure for all recipients
|
|
59
|
+
*/
|
|
60
|
+
encryptMultiRecipient(recipientPublicKeys: PlatformBuffer[], plaintext: PlatformBuffer, options?: IEciesEncryptionOptions): Promise<PlatformBuffer>;
|
|
61
|
+
/**
|
|
62
|
+
* Decrypt multi-recipient encrypted data
|
|
63
|
+
*
|
|
64
|
+
* @param recipientPrivateKey - Recipient's private key
|
|
65
|
+
* @param ciphertext - Multi-recipient encrypted data
|
|
66
|
+
* @param recipientIndex - Index of this recipient in the recipient list
|
|
67
|
+
* @param options - Decryption options
|
|
68
|
+
* @returns Decrypted plaintext
|
|
69
|
+
*/
|
|
70
|
+
decryptMultiRecipient(recipientPrivateKey: PlatformBuffer, ciphertext: PlatformBuffer, recipientIndex: number, options?: Partial<IEciesEncryptionOptions>): Promise<PlatformBuffer>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Common interface for cryptographic core operations
|
|
74
|
+
*/
|
|
75
|
+
export interface ICryptoCoreService {
|
|
76
|
+
/**
|
|
77
|
+
* Generate a random ECDH key pair
|
|
78
|
+
*
|
|
79
|
+
* @param curveName - Elliptic curve to use (default: 'secp256k1')
|
|
80
|
+
* @returns Key pair with private and public keys
|
|
81
|
+
*/
|
|
82
|
+
generateKeyPair(curveName?: string): Promise<{
|
|
83
|
+
privateKey: PlatformBuffer;
|
|
84
|
+
publicKey: PlatformBuffer;
|
|
85
|
+
}>;
|
|
86
|
+
/**
|
|
87
|
+
* Derive public key from private key
|
|
88
|
+
*
|
|
89
|
+
* @param privateKey - ECDH private key
|
|
90
|
+
* @param curveName - Elliptic curve to use (default: 'secp256k1')
|
|
91
|
+
* @param compressed - Whether to return compressed public key
|
|
92
|
+
* @returns Public key
|
|
93
|
+
*/
|
|
94
|
+
derivePublicKey(privateKey: PlatformBuffer, curveName?: string, compressed?: boolean): Promise<PlatformBuffer>;
|
|
95
|
+
/**
|
|
96
|
+
* Perform ECDH key agreement
|
|
97
|
+
*
|
|
98
|
+
* @param privateKey - Our private key
|
|
99
|
+
* @param publicKey - Their public key
|
|
100
|
+
* @param curveName - Elliptic curve to use (default: 'secp256k1')
|
|
101
|
+
* @returns Shared secret
|
|
102
|
+
*/
|
|
103
|
+
deriveSharedSecret(privateKey: PlatformBuffer, publicKey: PlatformBuffer, curveName?: string): Promise<PlatformBuffer>;
|
|
104
|
+
/**
|
|
105
|
+
* Sign data with ECDSA
|
|
106
|
+
*
|
|
107
|
+
* @param privateKey - Signing key
|
|
108
|
+
* @param data - Data to sign
|
|
109
|
+
* @param curveName - Elliptic curve to use (default: 'secp256k1')
|
|
110
|
+
* @returns Signature
|
|
111
|
+
*/
|
|
112
|
+
sign(privateKey: PlatformBuffer, data: PlatformBuffer, curveName?: string): Promise<PlatformBuffer>;
|
|
113
|
+
/**
|
|
114
|
+
* Verify ECDSA signature
|
|
115
|
+
*
|
|
116
|
+
* @param publicKey - Verification key
|
|
117
|
+
* @param data - Original data
|
|
118
|
+
* @param signature - Signature to verify
|
|
119
|
+
* @param curveName - Elliptic curve to use (default: 'secp256k1')
|
|
120
|
+
* @returns True if signature is valid
|
|
121
|
+
*/
|
|
122
|
+
verify(publicKey: PlatformBuffer, data: PlatformBuffer, signature: PlatformBuffer, curveName?: string): Promise<boolean>;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Common interface for PBKDF2 key derivation
|
|
126
|
+
*/
|
|
127
|
+
export interface IPbkdf2Service {
|
|
128
|
+
/**
|
|
129
|
+
* Derive a key from a password using PBKDF2
|
|
130
|
+
*
|
|
131
|
+
* @param password - Password to derive from
|
|
132
|
+
* @param salt - Salt value
|
|
133
|
+
* @param iterations - Number of iterations
|
|
134
|
+
* @param keyLength - Desired key length in bytes
|
|
135
|
+
* @param hashAlgorithm - Hash algorithm (default: 'sha256')
|
|
136
|
+
* @returns Derived key
|
|
137
|
+
*/
|
|
138
|
+
derive(password: string | PlatformBuffer, salt: PlatformBuffer, iterations: number, keyLength: number, hashAlgorithm?: string): Promise<PlatformBuffer>;
|
|
139
|
+
/**
|
|
140
|
+
* Generate a random salt
|
|
141
|
+
*
|
|
142
|
+
* @param length - Salt length in bytes (default: 32)
|
|
143
|
+
* @returns Random salt
|
|
144
|
+
*/
|
|
145
|
+
generateSalt(length?: number): PlatformBuffer;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Common interface for AES-GCM encryption
|
|
149
|
+
*/
|
|
150
|
+
export interface IAesGcmService {
|
|
151
|
+
/**
|
|
152
|
+
* Encrypt data with AES-GCM
|
|
153
|
+
*
|
|
154
|
+
* @param key - Encryption key (16, 24, or 32 bytes)
|
|
155
|
+
* @param plaintext - Data to encrypt
|
|
156
|
+
* @param aad - Additional authenticated data (optional)
|
|
157
|
+
* @returns IV (12 bytes) + ciphertext + auth tag (16 bytes)
|
|
158
|
+
*/
|
|
159
|
+
encrypt(key: PlatformBuffer, plaintext: PlatformBuffer, aad?: PlatformBuffer): Promise<PlatformBuffer>;
|
|
160
|
+
/**
|
|
161
|
+
* Decrypt AES-GCM encrypted data
|
|
162
|
+
*
|
|
163
|
+
* @param key - Decryption key
|
|
164
|
+
* @param ciphertext - IV + encrypted data + auth tag
|
|
165
|
+
* @param aad - Additional authenticated data (optional)
|
|
166
|
+
* @returns Decrypted plaintext
|
|
167
|
+
*/
|
|
168
|
+
decrypt(key: PlatformBuffer, ciphertext: PlatformBuffer, aad?: PlatformBuffer): Promise<PlatformBuffer>;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Common interface for checksum/hashing operations
|
|
172
|
+
*/
|
|
173
|
+
export interface IChecksumService {
|
|
174
|
+
/**
|
|
175
|
+
* Compute SHA-256 hash
|
|
176
|
+
*
|
|
177
|
+
* @param data - Data to hash
|
|
178
|
+
* @returns SHA-256 hash (32 bytes)
|
|
179
|
+
*/
|
|
180
|
+
sha256(data: PlatformBuffer): Promise<PlatformBuffer>;
|
|
181
|
+
/**
|
|
182
|
+
* Compute SHA-512 hash
|
|
183
|
+
*
|
|
184
|
+
* @param data - Data to hash
|
|
185
|
+
* @returns SHA-512 hash (64 bytes)
|
|
186
|
+
*/
|
|
187
|
+
sha512(data: PlatformBuffer): Promise<PlatformBuffer>;
|
|
188
|
+
/**
|
|
189
|
+
* Compute HMAC with SHA-256
|
|
190
|
+
*
|
|
191
|
+
* @param key - HMAC key
|
|
192
|
+
* @param data - Data to authenticate
|
|
193
|
+
* @returns HMAC tag (32 bytes)
|
|
194
|
+
*/
|
|
195
|
+
hmacSha256(key: PlatformBuffer, data: PlatformBuffer): Promise<PlatformBuffer>;
|
|
196
|
+
/**
|
|
197
|
+
* Compute HMAC with SHA-512
|
|
198
|
+
*
|
|
199
|
+
* @param key - HMAC key
|
|
200
|
+
* @param data - Data to authenticate
|
|
201
|
+
* @returns HMAC tag (64 bytes)
|
|
202
|
+
*/
|
|
203
|
+
hmacSha512(key: PlatformBuffer, data: PlatformBuffer): Promise<PlatformBuffer>;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Platform-specific random number generation
|
|
207
|
+
*/
|
|
208
|
+
export interface IRandomService {
|
|
209
|
+
/**
|
|
210
|
+
* Generate cryptographically secure random bytes
|
|
211
|
+
*
|
|
212
|
+
* @param length - Number of bytes to generate
|
|
213
|
+
* @returns Random bytes
|
|
214
|
+
*/
|
|
215
|
+
randomBytes(length: number): PlatformBuffer;
|
|
216
|
+
/**
|
|
217
|
+
* Generate a random integer in range [0, max)
|
|
218
|
+
*
|
|
219
|
+
* @param max - Upper bound (exclusive)
|
|
220
|
+
* @returns Random integer
|
|
221
|
+
*/
|
|
222
|
+
randomInt(max: number): number;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Root interface combining all service interfaces
|
|
226
|
+
* Both ecies-lib and node-ecies-lib should provide implementations
|
|
227
|
+
* that conform to these contracts
|
|
228
|
+
*/
|
|
229
|
+
export interface IEciesLibrary {
|
|
230
|
+
/**
|
|
231
|
+
* Core ECIES encryption/decryption operations
|
|
232
|
+
*/
|
|
233
|
+
ecies: IEciesService;
|
|
234
|
+
/**
|
|
235
|
+
* Low-level cryptographic primitives
|
|
236
|
+
*/
|
|
237
|
+
cryptoCore: ICryptoCoreService;
|
|
238
|
+
/**
|
|
239
|
+
* PBKDF2 key derivation
|
|
240
|
+
*/
|
|
241
|
+
pbkdf2: IPbkdf2Service;
|
|
242
|
+
/**
|
|
243
|
+
* AES-GCM symmetric encryption
|
|
244
|
+
*/
|
|
245
|
+
aesGcm: IAesGcmService;
|
|
246
|
+
/**
|
|
247
|
+
* Checksum and hashing operations
|
|
248
|
+
*/
|
|
249
|
+
checksum: IChecksumService;
|
|
250
|
+
/**
|
|
251
|
+
* Voting system (Paillier homomorphic encryption)
|
|
252
|
+
*/
|
|
253
|
+
voting: IVotingService;
|
|
254
|
+
/**
|
|
255
|
+
* Cryptographically secure random number generation
|
|
256
|
+
*/
|
|
257
|
+
random: IRandomService;
|
|
258
|
+
}
|
|
259
|
+
//# 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;AAEvD;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,cAAc,CAAC,EAAE,mBAAmB,CAAC;IAErC;;OAEG;IACH,GAAG,CAAC,EAAE,cAAc,CAAC;IAErB;;OAEG;IACH,gBAAgB,CAAC,EAAE;QACjB,UAAU,EAAE,cAAc,CAAC;QAC3B,SAAS,EAAE,cAAc,CAAC;KAC3B,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;;OAOG;IACH,OAAO,CACL,kBAAkB,EAAE,cAAc,EAClC,SAAS,EAAE,cAAc,EACzB,OAA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E,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,8 @@ 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';
|
|
18
|
+
export * from './voting-service';
|
|
19
|
+
export * from './isolated-keys';
|
|
15
20
|
//# 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;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC"}
|
package/src/interfaces/index.js
CHANGED
|
@@ -7,10 +7,15 @@ 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);
|
|
19
|
+
tslib_1.__exportStar(require("./voting-service"), exports);
|
|
20
|
+
tslib_1.__exportStar(require("./isolated-keys"), exports);
|
|
16
21
|
//# 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;AAChC,2DAAiC;AACjC,0DAAgC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared interfaces for IsolatedPublicKey and IsolatedPrivateKey
|
|
3
|
+
* These interfaces define the common API that both ecies-lib (Uint8Array)
|
|
4
|
+
* and node-ecies-lib (Buffer) must implement.
|
|
5
|
+
*/
|
|
6
|
+
import type { PrivateKey, PublicKey } from 'paillier-bigint';
|
|
7
|
+
/**
|
|
8
|
+
* Async/Sync mode flag for conditional return types
|
|
9
|
+
*/
|
|
10
|
+
export type AsyncMode = 'async' | 'sync';
|
|
11
|
+
/**
|
|
12
|
+
* Conditional return type based on async mode
|
|
13
|
+
*/
|
|
14
|
+
export type MaybePromise<T, TMode extends AsyncMode> = TMode extends 'async' ? Promise<T> : T;
|
|
15
|
+
/**
|
|
16
|
+
* Common interface for IsolatedPublicKey implementations
|
|
17
|
+
* @template TBuffer - The buffer type (Uint8Array for browser, Buffer for Node.js)
|
|
18
|
+
* @template TMode - 'async' for browser (ecies-lib), 'sync' for Node.js (node-ecies-lib)
|
|
19
|
+
*/
|
|
20
|
+
export interface IIsolatedPublicKey<TBuffer extends Uint8Array | Buffer = Uint8Array, TMode extends AsyncMode = 'async'> extends PublicKey {
|
|
21
|
+
/**
|
|
22
|
+
* Deterministic identifier derived from the public key (SHA-256 of 'n')
|
|
23
|
+
*/
|
|
24
|
+
readonly keyId: TBuffer;
|
|
25
|
+
/**
|
|
26
|
+
* Returns a copy of the keyId
|
|
27
|
+
*/
|
|
28
|
+
getKeyId(): TBuffer;
|
|
29
|
+
/**
|
|
30
|
+
* Returns a copy of the current instance ID
|
|
31
|
+
*/
|
|
32
|
+
getInstanceId(): TBuffer;
|
|
33
|
+
/**
|
|
34
|
+
* Updates the current instance ID to a new random value
|
|
35
|
+
* This invalidates all previously encrypted ciphertexts
|
|
36
|
+
*/
|
|
37
|
+
updateInstanceId(): MaybePromise<void, TMode>;
|
|
38
|
+
/**
|
|
39
|
+
* Verifies that the keyId matches the SHA-256 hash of the public key 'n'
|
|
40
|
+
*/
|
|
41
|
+
verifyKeyId(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Encrypts a message and tags it with instance HMAC
|
|
44
|
+
*/
|
|
45
|
+
encryptIsolated(m: bigint): MaybePromise<bigint, TMode>;
|
|
46
|
+
/**
|
|
47
|
+
* Multiplies a ciphertext by a constant, preserving instance HMAC
|
|
48
|
+
*/
|
|
49
|
+
multiplyIsolated(ciphertext: bigint, constant: bigint): MaybePromise<bigint, TMode>;
|
|
50
|
+
/**
|
|
51
|
+
* Adds two ciphertexts, preserving instance HMAC
|
|
52
|
+
*/
|
|
53
|
+
additionIsolated(a: bigint, b: bigint): MaybePromise<bigint, TMode>;
|
|
54
|
+
/**
|
|
55
|
+
* Extracts and validates the instance ID from a tagged ciphertext
|
|
56
|
+
* Returns the instance ID if valid, or zero-filled array if invalid
|
|
57
|
+
*/
|
|
58
|
+
extractInstanceId(ciphertext: bigint): MaybePromise<TBuffer, TMode>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Common interface for IsolatedPrivateKey implementations
|
|
62
|
+
* @template TBuffer - The buffer type (Uint8Array for browser, Buffer for Node.js)
|
|
63
|
+
* @template TMode - 'async' for browser (ecies-lib), 'sync' for Node.js (node-ecies-lib)
|
|
64
|
+
*/
|
|
65
|
+
export interface IIsolatedPrivateKey<TBuffer extends Uint8Array | Buffer = Uint8Array, TMode extends AsyncMode = 'async'> extends PrivateKey {
|
|
66
|
+
/**
|
|
67
|
+
* Decrypts a tagged ciphertext after validating instance ID and HMAC
|
|
68
|
+
*/
|
|
69
|
+
decryptIsolated(taggedCiphertext: bigint): MaybePromise<bigint, TMode>;
|
|
70
|
+
/**
|
|
71
|
+
* Gets a copy of the original keyId
|
|
72
|
+
*/
|
|
73
|
+
getOriginalKeyId(): TBuffer;
|
|
74
|
+
/**
|
|
75
|
+
* Gets a copy of the original instanceId
|
|
76
|
+
*/
|
|
77
|
+
getOriginalInstanceId(): TBuffer;
|
|
78
|
+
/**
|
|
79
|
+
* Gets the original public key reference
|
|
80
|
+
*/
|
|
81
|
+
getOriginalPublicKey(): IIsolatedPublicKey<TBuffer, TMode>;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=isolated-keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isolated-keys.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/isolated-keys.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE7D;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;AAEzC;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,EAAE,KAAK,SAAS,SAAS,IAAI,KAAK,SAAS,OAAO,GACxE,OAAO,CAAC,CAAC,CAAC,GACV,CAAC,CAAC;AAEN;;;;GAIG;AACH,MAAM,WAAW,kBAAkB,CACjC,OAAO,SAAS,UAAU,GAAG,MAAM,GAAG,UAAU,EAChD,KAAK,SAAS,SAAS,GAAG,OAAO,CACjC,SAAQ,SAAS;IACjB;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAExB;;OAEG;IACH,QAAQ,IAAI,OAAO,CAAC;IAEpB;;OAEG;IACH,aAAa,IAAI,OAAO,CAAC;IAEzB;;;OAGG;IACH,gBAAgB,IAAI,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAE9C;;OAEG;IACH,WAAW,IAAI,IAAI,CAAC;IAEpB;;OAEG;IACH,eAAe,CAAC,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAExD;;OAEG;IACH,gBAAgB,CACd,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAE/B;;OAEG;IACH,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAEpE;;;OAGG;IACH,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;CACrE;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB,CAClC,OAAO,SAAS,UAAU,GAAG,MAAM,GAAG,UAAU,EAChD,KAAK,SAAS,SAAS,GAAG,OAAO,CACjC,SAAQ,UAAU;IAClB;;OAEG;IACH,eAAe,CAAC,gBAAgB,EAAE,MAAM,GAAG,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAEvE;;OAEG;IACH,gBAAgB,IAAI,OAAO,CAAC;IAE5B;;OAEG;IACH,qBAAqB,IAAI,OAAO,CAAC;IAEjC;;OAEG;IACH,oBAAoB,IAAI,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;CAC5D"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared interfaces for IsolatedPublicKey and IsolatedPrivateKey
|
|
4
|
+
* These interfaces define the common API that both ecies-lib (Uint8Array)
|
|
5
|
+
* and node-ecies-lib (Buffer) must implement.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
//# sourceMappingURL=isolated-keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isolated-keys.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/isolated-keys.ts"],"names":[],"mappings":";AAAA;;;;GAIG"}
|
|
@@ -4,21 +4,25 @@ import type { EmailString } from '../email-string';
|
|
|
4
4
|
import type { MemberType } from '../enumerations/member-type';
|
|
5
5
|
import type { SecureBuffer } from '../secure-buffer';
|
|
6
6
|
import type { SecureString } from '../secure-string';
|
|
7
|
-
import type { SignatureUint8Array } from '../types';
|
|
8
7
|
import type { IECIESConstants } from './ecies-consts';
|
|
9
8
|
import type { IEncryptedChunk } from './encrypted-chunk';
|
|
9
|
+
import type { PlatformBuffer } from './platform-buffer';
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
* This interface defines the contract for member operations
|
|
13
|
-
*
|
|
11
|
+
* Generic interface representing a member with cryptographic capabilities.
|
|
12
|
+
* This interface defines the contract for member operations across both
|
|
13
|
+
* ecies-lib (Uint8Array) and node-ecies-lib (Buffer) implementations.
|
|
14
|
+
*
|
|
15
|
+
* @template TBuffer - The buffer type (Uint8Array for browser, Buffer for Node.js)
|
|
16
|
+
* @template TID - The ID type (Uint8Array for browser, Buffer/string/ObjectId for Node.js)
|
|
17
|
+
* @template TSignature - The signature type (SignatureUint8Array for browser, SignatureBuffer for Node.js)
|
|
14
18
|
*/
|
|
15
|
-
export interface IMember {
|
|
16
|
-
readonly id:
|
|
19
|
+
export interface IMember<TBuffer extends PlatformBuffer = Uint8Array, TID extends string | TBuffer = TBuffer, TSignature extends TBuffer = TBuffer> {
|
|
20
|
+
readonly id: TID;
|
|
17
21
|
readonly type: MemberType;
|
|
18
22
|
readonly name: string;
|
|
19
23
|
readonly email: EmailString;
|
|
20
|
-
readonly publicKey:
|
|
21
|
-
readonly creatorId:
|
|
24
|
+
readonly publicKey: TBuffer;
|
|
25
|
+
readonly creatorId: TID;
|
|
22
26
|
readonly dateCreated: Date;
|
|
23
27
|
readonly dateUpdated: Date;
|
|
24
28
|
readonly privateKey: SecureBuffer | undefined;
|
|
@@ -32,30 +36,30 @@ export interface IMember {
|
|
|
32
36
|
unloadWalletAndPrivateKey(): void;
|
|
33
37
|
loadWallet(mnemonic: SecureString, eciesParams?: IECIESConstants): void;
|
|
34
38
|
loadPrivateKey(privateKey: SecureBuffer): void;
|
|
35
|
-
loadVotingKeys
|
|
36
|
-
deriveVotingKeys
|
|
37
|
-
unloadVotingPrivateKey
|
|
38
|
-
sign(data:
|
|
39
|
-
signData(data:
|
|
40
|
-
verify(signature:
|
|
41
|
-
verifySignature(data:
|
|
42
|
-
encryptDataStream(source: AsyncIterable<
|
|
43
|
-
recipientPublicKey?:
|
|
39
|
+
loadVotingKeys(votingPublicKey: PublicKey, votingPrivateKey?: PrivateKey): void;
|
|
40
|
+
deriveVotingKeys(options?: Record<string, unknown>): Promise<void>;
|
|
41
|
+
unloadVotingPrivateKey(): void;
|
|
42
|
+
sign(data: TBuffer): TSignature;
|
|
43
|
+
signData(data: TBuffer): TSignature;
|
|
44
|
+
verify(signature: TSignature, data: TBuffer): boolean;
|
|
45
|
+
verifySignature(data: TBuffer, signature: TBuffer, publicKey: TBuffer): boolean;
|
|
46
|
+
encryptDataStream(source: AsyncIterable<TBuffer> | ReadableStream<TBuffer>, options?: {
|
|
47
|
+
recipientPublicKey?: TBuffer;
|
|
44
48
|
onProgress?: (progress: {
|
|
45
49
|
bytesProcessed: number;
|
|
46
50
|
chunksProcessed: number;
|
|
47
51
|
}) => void;
|
|
48
52
|
signal?: AbortSignal;
|
|
49
53
|
}): AsyncGenerator<IEncryptedChunk, void, unknown>;
|
|
50
|
-
decryptDataStream(source: AsyncIterable<
|
|
54
|
+
decryptDataStream(source: AsyncIterable<TBuffer> | ReadableStream<TBuffer>, options?: {
|
|
51
55
|
onProgress?: (progress: {
|
|
52
56
|
bytesProcessed: number;
|
|
53
57
|
chunksProcessed: number;
|
|
54
58
|
}) => void;
|
|
55
59
|
signal?: AbortSignal;
|
|
56
|
-
}): AsyncGenerator<
|
|
57
|
-
encryptData(data: string |
|
|
58
|
-
decryptData(encryptedData:
|
|
60
|
+
}): AsyncGenerator<TBuffer, void, unknown>;
|
|
61
|
+
encryptData(data: string | TBuffer, recipientPublicKey?: TBuffer): Promise<TBuffer> | TBuffer;
|
|
62
|
+
decryptData(encryptedData: TBuffer): Promise<TBuffer> | TBuffer;
|
|
59
63
|
toJson(): string;
|
|
60
64
|
dispose(): void;
|
|
61
65
|
}
|
|
@@ -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;
|
|
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,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cAAc,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAE1C,WAAW,CACT,IAAI,EAAE,MAAM,GAAG,OAAO,EACtB,kBAAkB,CAAC,EAAE,OAAO,GAC3B,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IAE9B,WAAW,CAAC,aAAa,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IAGhE,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":""}
|