@digitaldefiance/ecies-lib 3.7.5 → 4.0.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 +40 -0
- package/package.json +1 -1
- package/src/constants.d.ts.map +1 -1
- package/src/constants.js +29 -15
- package/src/constants.js.map +1 -1
- package/src/enumerations/ecies-cipher-suite.d.ts +4 -0
- package/src/enumerations/ecies-cipher-suite.d.ts.map +1 -0
- package/src/enumerations/ecies-cipher-suite.js +6 -0
- package/src/enumerations/ecies-cipher-suite.js.map +1 -0
- package/src/enumerations/ecies-error-type.d.ts +3 -1
- package/src/enumerations/ecies-error-type.d.ts.map +1 -1
- package/src/enumerations/ecies-error-type.js +2 -0
- package/src/enumerations/ecies-error-type.js.map +1 -1
- package/src/enumerations/ecies-string-key.d.ts +7 -1
- package/src/enumerations/ecies-string-key.d.ts.map +1 -1
- package/src/enumerations/ecies-string-key.js +6 -0
- package/src/enumerations/ecies-string-key.js.map +1 -1
- package/src/enumerations/ecies-version.d.ts +4 -0
- package/src/enumerations/ecies-version.d.ts.map +1 -0
- package/src/enumerations/ecies-version.js +5 -0
- package/src/enumerations/ecies-version.js.map +1 -0
- package/src/enumerations/index.d.ts +2 -0
- package/src/enumerations/index.d.ts.map +1 -1
- package/src/enumerations/index.js +2 -0
- package/src/enumerations/index.js.map +1 -1
- package/src/errors/ecies.d.ts.map +1 -1
- package/src/errors/ecies.js +7 -1
- package/src/errors/ecies.js.map +1 -1
- package/src/interfaces/ecies-consts.d.ts +3 -0
- package/src/interfaces/ecies-consts.d.ts.map +1 -1
- package/src/interfaces/multi-recipient-chunk.js +2 -2
- package/src/interfaces/multi-recipient-chunk.js.map +1 -1
- package/src/member.d.ts.map +1 -1
- package/src/member.js +9 -16
- package/src/member.js.map +1 -1
- package/src/services/aes-gcm.d.ts +2 -2
- package/src/services/aes-gcm.d.ts.map +1 -1
- package/src/services/aes-gcm.js +9 -3
- package/src/services/aes-gcm.js.map +1 -1
- package/src/services/ecies/crypto-core.d.ts +21 -0
- package/src/services/ecies/crypto-core.d.ts.map +1 -1
- package/src/services/ecies/crypto-core.js +60 -10
- package/src/services/ecies/crypto-core.js.map +1 -1
- package/src/services/ecies/interfaces.d.ts +2 -0
- package/src/services/ecies/interfaces.d.ts.map +1 -1
- package/src/services/ecies/multi-recipient.d.ts +9 -5
- package/src/services/ecies/multi-recipient.d.ts.map +1 -1
- package/src/services/ecies/multi-recipient.js +151 -46
- package/src/services/ecies/multi-recipient.js.map +1 -1
- package/src/services/ecies/service.d.ts +8 -0
- package/src/services/ecies/service.d.ts.map +1 -1
- package/src/services/ecies/service.js +12 -0
- package/src/services/ecies/service.js.map +1 -1
- package/src/services/ecies/single-recipient.d.ts.map +1 -1
- package/src/services/ecies/single-recipient.js +28 -10
- package/src/services/ecies/single-recipient.js.map +1 -1
- package/src/services/multi-recipient-processor.d.ts +2 -2
- package/src/services/multi-recipient-processor.d.ts.map +1 -1
- package/src/services/multi-recipient-processor.js +78 -36
- package/src/services/multi-recipient-processor.js.map +1 -1
- package/src/translations/de.d.ts.map +1 -1
- package/src/translations/de.js +8 -2
- package/src/translations/de.js.map +1 -1
- package/src/translations/en-US.d.ts.map +1 -1
- package/src/translations/en-US.js +6 -0
- package/src/translations/en-US.js.map +1 -1
- package/src/translations/es.d.ts.map +1 -1
- package/src/translations/es.js +6 -0
- package/src/translations/es.js.map +1 -1
- package/src/translations/fr.d.ts.map +1 -1
- package/src/translations/fr.js +6 -0
- package/src/translations/fr.js.map +1 -1
- package/src/translations/ja.d.ts.map +1 -1
- package/src/translations/ja.js +6 -0
- package/src/translations/ja.js.map +1 -1
- package/src/translations/uk.d.ts.map +1 -1
- package/src/translations/uk.js +8 -2
- package/src/translations/uk.js.map +1 -1
- package/src/translations/zh-cn.d.ts.map +1 -1
- package/src/translations/zh-cn.js +6 -0
- package/src/translations/zh-cn.js.map +1 -1
|
@@ -4,6 +4,9 @@ import { AESGCMService } from '../aes-gcm';
|
|
|
4
4
|
import { EciesCryptoCore } from './crypto-core';
|
|
5
5
|
import { EciesComponentId, getEciesI18nEngine } from '../../i18n-setup';
|
|
6
6
|
import { EciesStringKey } from '../../enumerations';
|
|
7
|
+
import { EciesVersionEnum } from '../../enumerations/ecies-version';
|
|
8
|
+
import { EciesCipherSuiteEnum } from '../../enumerations/ecies-cipher-suite';
|
|
9
|
+
import { EciesEncryptionTypeEnum } from '../../enumerations/ecies-encryption-type';
|
|
7
10
|
/**
|
|
8
11
|
* Browser-compatible multi-recipient ECIES encryption/decryption
|
|
9
12
|
*/
|
|
@@ -18,7 +21,11 @@ export class EciesMultiRecipient {
|
|
|
18
21
|
* Get the header size for multi-recipient encryption
|
|
19
22
|
*/
|
|
20
23
|
getHeaderSize(recipientCount) {
|
|
21
|
-
return (this.eciesConsts.
|
|
24
|
+
return (this.eciesConsts.VERSION_SIZE +
|
|
25
|
+
this.eciesConsts.CIPHER_SUITE_SIZE +
|
|
26
|
+
this.eciesConsts.ENCRYPTION_TYPE_SIZE +
|
|
27
|
+
this.eciesConsts.PUBLIC_KEY_LENGTH + // Shared ephemeral public key
|
|
28
|
+
this.eciesConsts.MULTIPLE.DATA_LENGTH_SIZE +
|
|
22
29
|
this.eciesConsts.MULTIPLE.RECIPIENT_COUNT_SIZE +
|
|
23
30
|
recipientCount * this.eciesConsts.MULTIPLE.RECIPIENT_ID_SIZE +
|
|
24
31
|
recipientCount * this.eciesConsts.MULTIPLE.ENCRYPTED_KEY_SIZE);
|
|
@@ -27,41 +34,49 @@ export class EciesMultiRecipient {
|
|
|
27
34
|
* Encrypt a message symmetric key with a public key
|
|
28
35
|
* @param receiverPublicKey The public key of the receiver
|
|
29
36
|
* @param messageSymmetricKey The message to encrypt
|
|
30
|
-
* @
|
|
37
|
+
* @param ephemeralPrivateKey The ephemeral private key to use for encryption
|
|
38
|
+
* @param aad Additional Authenticated Data (optional)
|
|
39
|
+
* @returns The encrypted message (IV + Tag + EncryptedKey)
|
|
31
40
|
*/
|
|
32
|
-
async encryptKey(receiverPublicKey, messageSymmetricKey) {
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
const symKey =
|
|
36
|
-
|
|
41
|
+
async encryptKey(receiverPublicKey, messageSymmetricKey, ephemeralPrivateKey, aad) {
|
|
42
|
+
const sharedSecret = await this.cryptoCore.computeSharedSecret(ephemeralPrivateKey, receiverPublicKey);
|
|
43
|
+
// Use HKDF to derive the key
|
|
44
|
+
const symKey = this.cryptoCore.deriveSharedKey(sharedSecret, new Uint8Array(0), // No salt
|
|
45
|
+
new TextEncoder().encode('ecies-v2-key-derivation'), // Info
|
|
46
|
+
this.eciesConsts.SYMMETRIC.KEY_SIZE);
|
|
47
|
+
const encryptResult = await AESGCMService.encrypt(messageSymmetricKey, symKey, true, this.eciesConsts, aad);
|
|
37
48
|
const { encrypted, iv } = encryptResult;
|
|
38
49
|
const authTag = encryptResult.tag;
|
|
39
50
|
if (!authTag) {
|
|
40
51
|
const engine = getEciesI18nEngine();
|
|
41
52
|
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_ECIESError_AuthenticationTagIsRequiredForKeyEncryption));
|
|
42
53
|
}
|
|
43
|
-
return concatUint8Arrays(
|
|
54
|
+
return concatUint8Arrays(iv, authTag, encrypted);
|
|
44
55
|
}
|
|
45
56
|
/**
|
|
46
57
|
* Decrypts symmetric key encrypted with ECIES
|
|
47
58
|
* @param privateKey The private key to decrypt the data
|
|
48
59
|
* @param encryptedKey The data to decrypt
|
|
60
|
+
* @param ephemeralPublicKey The ephemeral public key from the header
|
|
61
|
+
* @param aad Additional Authenticated Data (optional)
|
|
49
62
|
* @returns The decrypted data buffer
|
|
50
63
|
*/
|
|
51
|
-
async decryptKey(privateKey, encryptedKey) {
|
|
64
|
+
async decryptKey(privateKey, encryptedKey, ephemeralPublicKey, aad) {
|
|
52
65
|
if (encryptedKey.length !== this.eciesConsts.MULTIPLE.ENCRYPTED_KEY_SIZE) {
|
|
53
66
|
const engine = getEciesI18nEngine();
|
|
54
67
|
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_ECIESError_InvalidEncryptedKeyLengthTemplate, { keySize: this.eciesConsts.MULTIPLE.ENCRYPTED_KEY_SIZE, encryptedKeyLength: encryptedKey.length }));
|
|
55
68
|
}
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
const encrypted = encryptedKey.slice(this.eciesConsts.PUBLIC_KEY_LENGTH + this.eciesConsts.IV_SIZE + this.eciesConsts.AUTH_TAG_SIZE);
|
|
69
|
+
const iv = encryptedKey.slice(0, this.eciesConsts.IV_SIZE);
|
|
70
|
+
const authTag = encryptedKey.slice(this.eciesConsts.IV_SIZE, this.eciesConsts.IV_SIZE + this.eciesConsts.AUTH_TAG_SIZE);
|
|
71
|
+
const encrypted = encryptedKey.slice(this.eciesConsts.IV_SIZE + this.eciesConsts.AUTH_TAG_SIZE);
|
|
60
72
|
const sharedSecret = await this.cryptoCore.computeSharedSecret(privateKey, ephemeralPublicKey);
|
|
61
|
-
|
|
73
|
+
// Use HKDF to derive the key
|
|
74
|
+
const symKey = this.cryptoCore.deriveSharedKey(sharedSecret, new Uint8Array(0), // No salt
|
|
75
|
+
new TextEncoder().encode('ecies-v2-key-derivation'), // Info
|
|
76
|
+
this.eciesConsts.SYMMETRIC.KEY_SIZE);
|
|
62
77
|
const encryptedWithTag = AESGCMService.combineEncryptedDataAndTag(encrypted, authTag);
|
|
63
78
|
try {
|
|
64
|
-
const decrypted = await AESGCMService.decrypt(iv, encryptedWithTag, symKey, true, this.eciesConsts);
|
|
79
|
+
const decrypted = await AESGCMService.decrypt(iv, encryptedWithTag, symKey, true, this.eciesConsts, aad);
|
|
65
80
|
if (decrypted.length !== this.eciesConsts.SYMMETRIC.KEY_SIZE) {
|
|
66
81
|
const engine = getEciesI18nEngine();
|
|
67
82
|
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_ECIESError_InvalidDataLength));
|
|
@@ -77,48 +92,71 @@ export class EciesMultiRecipient {
|
|
|
77
92
|
/**
|
|
78
93
|
* Encrypt a message for multiple recipients
|
|
79
94
|
*/
|
|
80
|
-
async encryptMultiple(recipients, message, preamble = new Uint8Array(0)) {
|
|
95
|
+
async encryptMultiple(recipients, message, preamble = new Uint8Array(0), senderPrivateKey) {
|
|
81
96
|
const engine = getEciesI18nEngine();
|
|
82
97
|
if (recipients.length > this.eciesConsts.MULTIPLE.MAX_RECIPIENTS) {
|
|
83
98
|
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_ECIESError_TooManyRecipientsTemplate, { recipientsCount: recipients.length }));
|
|
84
99
|
}
|
|
85
|
-
|
|
86
|
-
|
|
100
|
+
// Sign-then-Encrypt: If sender key provided, sign the message and prepend signature
|
|
101
|
+
let messageToEncrypt = message;
|
|
102
|
+
if (senderPrivateKey) {
|
|
103
|
+
const signature = this.cryptoCore.sign(senderPrivateKey, message);
|
|
104
|
+
messageToEncrypt = concatUint8Arrays(signature, message);
|
|
105
|
+
}
|
|
106
|
+
if (messageToEncrypt.length > this.eciesConsts.MAX_RAW_DATA_SIZE) {
|
|
107
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_ECIESError_MessageTooLargeTemplate, { length: messageToEncrypt.length }));
|
|
87
108
|
}
|
|
88
109
|
// Generate symmetric key
|
|
89
110
|
const symmetricKey = crypto.getRandomValues(new Uint8Array(this.eciesConsts.SYMMETRIC.KEY_SIZE));
|
|
90
|
-
//
|
|
91
|
-
const
|
|
92
|
-
const { encrypted, iv } = encryptResult;
|
|
93
|
-
const authTag = encryptResult.tag;
|
|
94
|
-
if (!authTag) {
|
|
95
|
-
const engine = getEciesI18nEngine();
|
|
96
|
-
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_ECIESError_AuthenticationTagIsRequiredForMultiRecipientECIESEncryption));
|
|
97
|
-
}
|
|
98
|
-
// Create stored message: preamble + iv + authTag + encrypted
|
|
99
|
-
const storedMessage = concatUint8Arrays(preamble, iv, authTag, encrypted);
|
|
111
|
+
// Generate ONE ephemeral key pair for all recipients
|
|
112
|
+
const ephemeralKeyPair = await this.cryptoCore.generateEphemeralKeyPair();
|
|
100
113
|
// Encrypt symmetric key for each recipient
|
|
101
114
|
const recipientIds = [];
|
|
102
115
|
const recipientKeys = [];
|
|
103
116
|
for (const recipient of recipients) {
|
|
104
|
-
|
|
117
|
+
// Use Recipient ID as AAD for key encryption to bind key to recipient
|
|
118
|
+
const encryptedKey = await this.encryptKey(recipient.publicKey, symmetricKey, ephemeralKeyPair.privateKey, recipient.id);
|
|
105
119
|
recipientIds.push(recipient.id);
|
|
106
120
|
recipientKeys.push(encryptedKey);
|
|
107
121
|
}
|
|
108
122
|
const headerSize = this.getHeaderSize(recipients.length);
|
|
123
|
+
// Build the header to use as AAD for message encryption
|
|
124
|
+
// We need to construct a temporary object to build the header
|
|
125
|
+
const tempHeaderData = {
|
|
126
|
+
dataLength: messageToEncrypt.length,
|
|
127
|
+
recipientCount: recipients.length,
|
|
128
|
+
recipientIds,
|
|
129
|
+
recipientKeys,
|
|
130
|
+
encryptedMessage: new Uint8Array(0), // Placeholder
|
|
131
|
+
headerSize,
|
|
132
|
+
ephemeralPublicKey: ephemeralKeyPair.publicKey,
|
|
133
|
+
};
|
|
134
|
+
const headerBytes = this.buildHeader(tempHeaderData);
|
|
135
|
+
// Encrypt message with symmetric key, using Header as AAD
|
|
136
|
+
const encryptResult = await AESGCMService.encrypt(messageToEncrypt, symmetricKey, true, this.eciesConsts, headerBytes // Bind header to ciphertext
|
|
137
|
+
);
|
|
138
|
+
const { encrypted, iv } = encryptResult;
|
|
139
|
+
const authTag = encryptResult.tag;
|
|
140
|
+
if (!authTag) {
|
|
141
|
+
const engine = getEciesI18nEngine();
|
|
142
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_ECIESError_AuthenticationTagIsRequiredForMultiRecipientECIESEncryption));
|
|
143
|
+
}
|
|
144
|
+
// Create stored message: preamble + iv + authTag + encrypted
|
|
145
|
+
const storedMessage = concatUint8Arrays(preamble, iv, authTag, encrypted);
|
|
109
146
|
return {
|
|
110
|
-
dataLength:
|
|
147
|
+
dataLength: messageToEncrypt.length,
|
|
111
148
|
recipientCount: recipients.length,
|
|
112
149
|
recipientIds,
|
|
113
150
|
recipientKeys,
|
|
114
151
|
encryptedMessage: storedMessage,
|
|
115
152
|
headerSize,
|
|
153
|
+
ephemeralPublicKey: ephemeralKeyPair.publicKey,
|
|
116
154
|
};
|
|
117
155
|
}
|
|
118
156
|
/**
|
|
119
157
|
* Decrypt a multi-recipient message for a specific recipient
|
|
120
158
|
*/
|
|
121
|
-
async decryptMultipleForRecipient(encryptedData, recipientId, privateKey) {
|
|
159
|
+
async decryptMultipleForRecipient(encryptedData, recipientId, privateKey, senderPublicKey) {
|
|
122
160
|
// Find recipient's encrypted key
|
|
123
161
|
const recipientIndex = encryptedData.recipientIds.findIndex((id) => this.arraysEqual(id, recipientId));
|
|
124
162
|
if (recipientIndex === -1) {
|
|
@@ -126,8 +164,15 @@ export class EciesMultiRecipient {
|
|
|
126
164
|
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_ECIESError_RecipientNotFound));
|
|
127
165
|
}
|
|
128
166
|
const encryptedKey = encryptedData.recipientKeys[recipientIndex];
|
|
129
|
-
// Decrypt the symmetric key
|
|
130
|
-
|
|
167
|
+
// Decrypt the symmetric key using the shared ephemeral public key
|
|
168
|
+
if (!encryptedData.ephemeralPublicKey) {
|
|
169
|
+
const engine = getEciesI18nEngine();
|
|
170
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_ECIESError_MissingEphemeralPublicKey));
|
|
171
|
+
}
|
|
172
|
+
// Use Recipient ID as AAD for key decryption
|
|
173
|
+
const symmetricKey = await this.decryptKey(privateKey, encryptedKey, encryptedData.ephemeralPublicKey, recipientId);
|
|
174
|
+
// Rebuild header to use as AAD
|
|
175
|
+
const headerBytes = this.buildHeader(encryptedData);
|
|
131
176
|
// Extract components from encrypted message
|
|
132
177
|
let offset = 0;
|
|
133
178
|
const iv = encryptedData.encryptedMessage.slice(offset, offset + this.eciesConsts.IV_SIZE);
|
|
@@ -136,14 +181,28 @@ export class EciesMultiRecipient {
|
|
|
136
181
|
offset += this.eciesConsts.AUTH_TAG_SIZE;
|
|
137
182
|
const encrypted = encryptedData.encryptedMessage.slice(offset);
|
|
138
183
|
// AES-GCM provides authentication via auth tag (no separate CRC needed)
|
|
139
|
-
// Decrypt with symmetric key
|
|
184
|
+
// Decrypt with symmetric key and Header as AAD
|
|
140
185
|
const encryptedWithTag = AESGCMService.combineEncryptedDataAndTag(encrypted, authTag);
|
|
141
|
-
const decrypted = await AESGCMService.decrypt(iv, encryptedWithTag, symmetricKey, true, this.eciesConsts);
|
|
186
|
+
const decrypted = await AESGCMService.decrypt(iv, encryptedWithTag, symmetricKey, true, this.eciesConsts, headerBytes);
|
|
142
187
|
// Verify length
|
|
143
188
|
if (decrypted.length !== encryptedData.dataLength) {
|
|
144
189
|
const engine = getEciesI18nEngine();
|
|
145
190
|
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_ECIESError_DecryptedDataLengthMismatch));
|
|
146
191
|
}
|
|
192
|
+
// If sender public key is provided, verify signature
|
|
193
|
+
if (senderPublicKey) {
|
|
194
|
+
// Expect [Signature (64)][Message]
|
|
195
|
+
if (decrypted.length < 64) {
|
|
196
|
+
throw new Error('Decrypted data too short to contain signature');
|
|
197
|
+
}
|
|
198
|
+
const signature = decrypted.slice(0, 64);
|
|
199
|
+
const message = decrypted.slice(64);
|
|
200
|
+
const isValid = this.cryptoCore.verify(senderPublicKey, message, signature);
|
|
201
|
+
if (!isValid) {
|
|
202
|
+
throw new Error('Invalid sender signature');
|
|
203
|
+
}
|
|
204
|
+
return message;
|
|
205
|
+
}
|
|
147
206
|
return decrypted;
|
|
148
207
|
}
|
|
149
208
|
/**
|
|
@@ -158,9 +217,27 @@ export class EciesMultiRecipient {
|
|
|
158
217
|
const engine = getEciesI18nEngine();
|
|
159
218
|
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_ECIESError_InvalidDataLength));
|
|
160
219
|
}
|
|
220
|
+
const versionArray = new Uint8Array([EciesVersionEnum.V1]);
|
|
221
|
+
const cipherSuiteArray = new Uint8Array([EciesCipherSuiteEnum.Secp256k1_Aes256Gcm_Sha256]);
|
|
222
|
+
const encryptionTypeArray = new Uint8Array([EciesEncryptionTypeEnum.Multiple]);
|
|
223
|
+
if (!data.ephemeralPublicKey) {
|
|
224
|
+
const engine = getEciesI18nEngine();
|
|
225
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_ECIESError_MissingEphemeralPublicKey));
|
|
226
|
+
}
|
|
161
227
|
// Data length (8 bytes)
|
|
228
|
+
// We use the most significant byte (MSB) to store the recipient ID size
|
|
229
|
+
// This allows parsing the header without knowing the configured ID provider
|
|
230
|
+
// Max data size is 2^53-1, so the top byte is always 0 for valid data lengths
|
|
231
|
+
const recipientIdSize = this.eciesConsts.MULTIPLE.RECIPIENT_ID_SIZE;
|
|
232
|
+
if (recipientIdSize > 255) {
|
|
233
|
+
const engine = getEciesI18nEngine();
|
|
234
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_ECIESError_RecipientIdSizeTooLargeTemplate, { size: recipientIdSize }));
|
|
235
|
+
}
|
|
236
|
+
const dataLengthBigInt = BigInt(data.dataLength);
|
|
237
|
+
const recipientIdSizeBigInt = BigInt(recipientIdSize);
|
|
238
|
+
const combinedLength = (recipientIdSizeBigInt << 56n) | dataLengthBigInt;
|
|
162
239
|
const dataLengthUint8Array = new Uint8Array(8);
|
|
163
|
-
new DataView(dataLengthUint8Array.buffer).setBigUint64(0,
|
|
240
|
+
new DataView(dataLengthUint8Array.buffer).setBigUint64(0, combinedLength, false);
|
|
164
241
|
// Recipient count (2 bytes)
|
|
165
242
|
const recipientCountUint8Array = new Uint8Array(2);
|
|
166
243
|
new DataView(recipientCountUint8Array.buffer).setUint16(0, data.recipientIds.length, false);
|
|
@@ -168,38 +245,65 @@ export class EciesMultiRecipient {
|
|
|
168
245
|
const recipientIdsUint8Array = concatUint8Arrays(...data.recipientIds);
|
|
169
246
|
// Encrypted keys
|
|
170
247
|
const encryptedKeysUint8Array = concatUint8Arrays(...data.recipientKeys);
|
|
171
|
-
return concatUint8Arrays(dataLengthUint8Array, recipientCountUint8Array, recipientIdsUint8Array, encryptedKeysUint8Array);
|
|
248
|
+
return concatUint8Arrays(versionArray, cipherSuiteArray, encryptionTypeArray, data.ephemeralPublicKey, dataLengthUint8Array, recipientCountUint8Array, recipientIdsUint8Array, encryptedKeysUint8Array);
|
|
172
249
|
}
|
|
173
250
|
/**
|
|
174
251
|
* Parse multi-recipient header
|
|
175
252
|
*/
|
|
176
253
|
parseHeader(data) {
|
|
177
|
-
|
|
178
|
-
|
|
254
|
+
const engine = getEciesI18nEngine();
|
|
255
|
+
// minimum: 1 (ver) + 1 (suite) + 1 (type) + 33 (pubkey) + 8 (len) + 2 (count) = 46
|
|
256
|
+
if (data.length < 46) {
|
|
179
257
|
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_ECIESError_DataTooShortForMultiRecipientHeader));
|
|
180
|
-
// minimum: 8 + 2
|
|
181
258
|
}
|
|
182
259
|
let offset = 0;
|
|
183
260
|
const view = new DataView(data.buffer, data.byteOffset);
|
|
184
|
-
// Read
|
|
185
|
-
const
|
|
261
|
+
// Read Version
|
|
262
|
+
const version = data[offset];
|
|
263
|
+
offset += this.eciesConsts.VERSION_SIZE;
|
|
264
|
+
if (version !== EciesVersionEnum.V1) {
|
|
265
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_ECIESError_InvalidVersionTemplate, { version }));
|
|
266
|
+
}
|
|
267
|
+
// Read CipherSuite
|
|
268
|
+
const cipherSuite = data[offset];
|
|
269
|
+
offset += this.eciesConsts.CIPHER_SUITE_SIZE;
|
|
270
|
+
if (cipherSuite !== EciesCipherSuiteEnum.Secp256k1_Aes256Gcm_Sha256) {
|
|
271
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_ECIESError_InvalidCipherSuiteTemplate, { cipherSuite }));
|
|
272
|
+
}
|
|
273
|
+
// Read Encryption Type
|
|
274
|
+
const encryptionType = data[offset];
|
|
275
|
+
offset += this.eciesConsts.ENCRYPTION_TYPE_SIZE;
|
|
276
|
+
if (encryptionType !== EciesEncryptionTypeEnum.Multiple) {
|
|
277
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_ECIESError_InvalidEncryptionTypeTemplate, { encryptionType: encryptionType.toString(16) }));
|
|
278
|
+
}
|
|
279
|
+
// Read Ephemeral Public Key
|
|
280
|
+
const ephemeralPublicKey = data.slice(offset, offset + this.eciesConsts.PUBLIC_KEY_LENGTH);
|
|
281
|
+
offset += this.eciesConsts.PUBLIC_KEY_LENGTH;
|
|
282
|
+
// Read data length and recipient ID size
|
|
283
|
+
const combinedLength = view.getBigUint64(offset, false);
|
|
186
284
|
offset += 8;
|
|
285
|
+
// Extract recipient ID size from MSB (top 8 bits)
|
|
286
|
+
const storedRecipientIdSize = Number(combinedLength >> 56n);
|
|
287
|
+
// Extract data length from lower 56 bits
|
|
288
|
+
const dataLength = Number(combinedLength & 0x00ffffffffffffffn);
|
|
187
289
|
if (dataLength <= 0 || dataLength > this.eciesConsts.MAX_RAW_DATA_SIZE) {
|
|
188
|
-
const engine = getEciesI18nEngine();
|
|
189
290
|
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_ECIESError_InvalidDataLength));
|
|
190
291
|
}
|
|
292
|
+
// Use stored recipient ID size if available (non-legacy), otherwise fallback to config
|
|
293
|
+
const recipientIdSize = storedRecipientIdSize > 0
|
|
294
|
+
? storedRecipientIdSize
|
|
295
|
+
: this.eciesConsts.MULTIPLE.RECIPIENT_ID_SIZE;
|
|
191
296
|
// Read recipient count
|
|
192
297
|
const recipientCount = view.getUint16(offset, false);
|
|
193
298
|
offset += 2;
|
|
194
299
|
if (recipientCount <= 0 || recipientCount > this.eciesConsts.MULTIPLE.MAX_RECIPIENTS) {
|
|
195
|
-
const engine = getEciesI18nEngine();
|
|
196
300
|
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_ECIESError_InvalidRecipientCount));
|
|
197
301
|
}
|
|
198
302
|
// Read recipient IDs
|
|
199
303
|
const recipientIds = [];
|
|
200
304
|
for (let i = 0; i < recipientCount; i++) {
|
|
201
|
-
recipientIds.push(data.slice(offset, offset +
|
|
202
|
-
offset +=
|
|
305
|
+
recipientIds.push(data.slice(offset, offset + recipientIdSize));
|
|
306
|
+
offset += recipientIdSize;
|
|
203
307
|
}
|
|
204
308
|
// Read encrypted keys
|
|
205
309
|
const recipientKeys = [];
|
|
@@ -213,6 +317,7 @@ export class EciesMultiRecipient {
|
|
|
213
317
|
recipientIds,
|
|
214
318
|
recipientKeys,
|
|
215
319
|
headerSize: offset,
|
|
320
|
+
ephemeralPublicKey,
|
|
216
321
|
};
|
|
217
322
|
}
|
|
218
323
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multi-recipient.js","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-ecies-lib/src/services/ecies/multi-recipient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAMhD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD;;GAEG;AACH,MAAM,OAAO,mBAAmB;IACX,UAAU,CAAkB;IAC5B,WAAW,CAAkB;IAEhD,YAAY,MAAoB,EAAE,cAA+B,SAAS,CAAC,KAAK;QAC9E,IAAI,CAAC,UAAU,GAAG,IAAI,eAAe,CAAC,MAAM,EAAE,WAAW,CA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B,CAAC;QACxD,CAAC;QAED,sBAAsB;QACtB,MAAM,aAAa,GAAiB,EAAE,CAAC;QACvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,cAAc,EAAE,CAAC,EAAE,EAAE,CAAC;YACxC,aAAa,CAAC,IAAI,CAChB,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAC1E,CAAC;YACF,MAAM,IAAI,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,kBAAkB,CAAC;QACzD,CAAC;QAED,OAAO;YACL,UAAU;YACV,cAAc;YACd,YAAY;YACZ,aAAa;YACb,UAAU,EAAE,MAAM;SACnB,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,YAAY,CAAC,IAAgB;QAClC,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACtC,MAAM,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAEvD,OAAO;YACL,GAAG,MAAM;YACT,gBAAgB;SACjB,CAAC;IACJ,CAAC;IAEO,WAAW,CAAC,CAAa,EAAE,CAAa;QAC9C,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;YAAE,OAAO,KAAK,CAAC;QACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAClC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAAE,OAAO,KAAK,CAAC;QAClC,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
1
|
+
{"version":3,"file":"multi-recipient.js","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-ecies-lib/src/services/ecies/multi-recipient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,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|
|
|
108
108
|
* @returns
|
|
109
109
|
*/
|
|
110
110
|
encryptMultiple(recipients: Array<IMultiRecipient>, message: Uint8Array, preamble?: Uint8Array): Promise<IMultiEncryptedMessage>;
|
|
111
|
+
/**
|
|
112
|
+
* Encrypt a symmetric key for a recipient using an ephemeral private key
|
|
113
|
+
*/
|
|
114
|
+
encryptKey(receiverPublicKey: Uint8Array, messageSymmetricKey: Uint8Array, ephemeralPrivateKey: Uint8Array, aad?: Uint8Array): Promise<Uint8Array>;
|
|
115
|
+
/**
|
|
116
|
+
* Decrypt a symmetric key using an ephemeral public key
|
|
117
|
+
*/
|
|
118
|
+
decryptKey(privateKey: Uint8Array, encryptedKey: Uint8Array, ephemeralPublicKey: Uint8Array, aad?: Uint8Array): Promise<Uint8Array>;
|
|
111
119
|
}
|
|
112
120
|
//# sourceMappingURL=service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-ecies-lib/src/services/ecies/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACxB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACpG,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAG1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,C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UAAU,EAC9B,OAAO,EAAE,UAAU,EACnB,QAAQ,CAAC,EAAE,UAAU,GACpB,OAAO,CAAC,UAAU,CAAC;IAgBtB;;;;;;OAMG;IACU,eAAe,CAC1B,UAAU,EAAE,KAAK,CAAC,eAAe,CAAC,EAClC,OAAO,EAAE,UAAU,EACnB,QAAQ,CAAC,EAAE,UAAU,GACpB,OAAO,CAAC,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-ecies-lib/src/services/ecies/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACxB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACpG,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAG1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;GAGG;AACH,qBAAa,YAAY;IACvB,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IACzC,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,eAAe,CAAC;IAC/C,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC;IAC7C,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,oBAAoB,CAAC;IACzD,SAAS,CAAC,QAAQ,CAAC,cAAc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,UAAU,EAC7B,mBAAmB,EAAE,UAAU,EAC/B,mBAAmB,EAAE,UAAU,EAC/B,GAAG,CAAC,EAAE,UAAU,GACf,OAAO,CAAC,UAAU,CAAC;IAStB;;OAEG;IACU,UAAU,CACrB,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,UAAU,EACxB,kBAAkB,EAAE,UAAU,EAC9B,GAAG,CAAC,EAAE,UAAU,GACf,OAAO,CAAC,UAAU,CAAC;CAQrB"}
|
|
@@ -194,5 +194,17 @@ export class ECIESService {
|
|
|
194
194
|
async encryptMultiple(recipients, message, preamble) {
|
|
195
195
|
return this.multiRecipient.encryptMultiple(recipients, message, preamble);
|
|
196
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* Encrypt a symmetric key for a recipient using an ephemeral private key
|
|
199
|
+
*/
|
|
200
|
+
async encryptKey(receiverPublicKey, messageSymmetricKey, ephemeralPrivateKey, aad) {
|
|
201
|
+
return this.multiRecipient.encryptKey(receiverPublicKey, messageSymmetricKey, ephemeralPrivateKey, aad);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Decrypt a symmetric key using an ephemeral public key
|
|
205
|
+
*/
|
|
206
|
+
async decryptKey(privateKey, encryptedKey, ephemeralPublicKey, aad) {
|
|
207
|
+
return this.multiRecipient.decryptKey(privateKey, encryptedKey, ephemeralPublicKey, aad);
|
|
208
|
+
}
|
|
197
209
|
}
|
|
198
210
|
//# sourceMappingURL=service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-ecies-lib/src/services/ecies/service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAEL,uBAAuB,GACxB,MAAM,0CAA0C,CAAC;AAIlD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;A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nB,QAAqB;QAEnB,OAAO,IAAI,CAAC,cAAc,CAAC,eAAe,CACxC,UAAU,EACV,OAAO,EACP,QAAQ,CACT,CAAC;IACJ,CAAC;
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-ecies-lib/src/services/ecies/service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAEL,uBAAuB,GACxB,MAAM,0CAA0C,CAAC;AAIlD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;GAGG;AACH,MAAM,OAAO,YAAY;IACJ,OAAO,CAAe;IACtB,UAAU,CAAkB;IAC5B,SAAS,CAAiB;IAC1B,eAAe,CAAuB;IACtC,cAAc,CAAsB;IACpC,WAAW,CAAkB;IAEhD,YAAY,MAA8B,EAAE,cAA+B,SAAS,CAAC,KAAK;QACxF,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG;YACb,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,UAAU;YACtC,wBAAwB,EAAE,IAAI,CAAC,WAAW,CAAC,2BAA2B;YACtE,gBAAgB,EAAE,IAAI,CAAC,WAAW,CAAC,iBAAiB;YACpD,kBAAkB,EAAE,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,SAAS;YACxD,gBAAgB,EAAE,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,QAAQ;YACrD,gBAAgB,EAAE,IAAI,CA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C9B,OAAmB,EACnB,QAAqB;QAErB,IAAI,cAAc,KAAK,uBAAuB,CAAC,QAAQ,EAAE,CAAC;YACxD,MAAM,IAAI,KAAK,CACb,kBAAkB,EAAE,CAAC,SAAS,CAC5B,gBAAgB,EAChB,cAAc,CAAC,wEAAwE,CACxF,CACF,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,eAAe,CAAC,OAAO,CACjC,cAAc,KAAK,uBAAuB,CAAC,MAAM,EACjD,kBAAkB,EAClB,OAAO,EACP,QAAQ,CACT,CAAC;IACJ,CAAC;IACD;;;;;;OAMG;IACI,KAAK,CAAC,eAAe,CAC1B,UAAkC,EAClC,OAAmB,EACnB,QAAqB;QAEnB,OAAO,IAAI,CAAC,cAAc,CAAC,eAAe,CACxC,UAAU,EACV,OAAO,EACP,QAAQ,CACT,CAAC;IACJ,CAAC;IAED;;KAEC;IACI,KAAK,CAAC,UAAU,CACrB,iBAA6B,EAC7B,mBAA+B,EAC/B,mBAA+B,EAC/B,GAAgB;QAEhB,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CACnC,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,GAAG,CACJ,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,UAAU,CACrB,UAAsB,EACtB,YAAwB,EACxB,kBAA8B,EAC9B,GAAgB;QAEhB,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CACnC,UAAU,EACV,YAAY,EACZ,kBAAkB,EAClB,GAAG,CACJ,CAAC;IACJ,CAAC;CACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"single-recipient.d.ts","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-ecies-lib/src/services/ecies/single-recipient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAEL,uBAAuB,EACxB,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"single-recipient.d.ts","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-ecies-lib/src/services/ecies/single-recipient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAEL,uBAAuB,EACxB,MAAM,0CAA0C,CAAC;AAGlD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAG7D,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC;AAI/E;;GAEG;AACH,qBAAa,oBAAoB;IAC/B,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,eAAe,CAAC;IAC/C,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IACxC,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,eAAe,CAAC;gBAEpC,MAAM,EAAE,YAAY,EAAE,WAAW,GAAE,eAAiC;IAMhF;;OAEG;IACU,OAAO,CAClB,aAAa,EAAE,OAAO,EACtB,iBAAiB,EAAE,UAAU,EAC7B,OAAO,EAAE,UAAU,EACnB,QAAQ,GAAE,UAA8B,GACvC,OAAO,CAAC,UAAU,CAAC;IA+FtB;;OAEG;IACI,qBAAqB,CAC1B,cAAc,EAAE,uBAAuB,GAAG,SAAS,EACnD,IAAI,EAAE,UAAU,EAChB,YAAY,GAAE,MAAU,EACxB,OAAO,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,GAChC;QACD,MAAM,EAAE,4BAA4B,CAAC;QACrC,IAAI,EAAE,UAAU,CAAC;QACjB,SAAS,EAAE,UAAU,CAAC;KACvB;IAyID;;OAEG;IACU,iBAAiB,CAC5B,cAAc,EAAE,uBAAuB,GAAG,SAAS,EACnD,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,UAAU,EACzB,YAAY,GAAE,MAAU,EACxB,OAAO,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,GAChC,OAAO,CAAC,UAAU,CAAC;IAWtB;;OAEG;IACU,mBAAmB,CAC9B,cAAc,EAAE,uBAAuB,GAAG,SAAS,EACnD,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,UAAU,EACzB,YAAY,GAAE,MAAU,EACxB,OAAO,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,GAChC,OAAO,CAAC,iBAAiB,CAAC;IAsB7B;;OAEG;IACU,qBAAqB,CAChC,UAAU,EAAE,UAAU,EACtB,kBAAkB,EAAE,UAAU,EAC9B,EAAE,EAAE,UAAU,EACd,OAAO,EAAE,UAAU,EACnB,SAAS,EAAE,UAAU,GACpB,OAAO,CAAC,UAAU,CAAC;IAoEtB,OAAO,CAAC,WAAW;CAUpB"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Constants } from '../../constants';
|
|
2
2
|
import { EciesEncryptionTypeEnum, } from '../../enumerations/ecies-encryption-type';
|
|
3
|
+
import { EciesVersionEnum } from '../../enumerations/ecies-version';
|
|
4
|
+
import { EciesCipherSuiteEnum } from '../../enumerations/ecies-cipher-suite';
|
|
3
5
|
import { AESGCMService } from '../aes-gcm';
|
|
4
6
|
import { EciesCryptoCore } from './crypto-core';
|
|
5
7
|
import { EciesComponentId, getEciesI18nEngine } from '../../i18n-setup';
|
|
@@ -28,6 +30,8 @@ export class EciesSingleRecipient {
|
|
|
28
30
|
? this.eciesConsts.ENCRYPTION_TYPE.SIMPLE
|
|
29
31
|
: this.eciesConsts.ENCRYPTION_TYPE.SINGLE,
|
|
30
32
|
]);
|
|
33
|
+
const versionArray = new Uint8Array([EciesVersionEnum.V1]);
|
|
34
|
+
const cipherSuiteArray = new Uint8Array([EciesCipherSuiteEnum.Secp256k1_Aes256Gcm_Sha256]);
|
|
31
35
|
if (message.length > this.eciesConsts.MAX_RAW_DATA_SIZE) {
|
|
32
36
|
const engine = getEciesI18nEngine();
|
|
33
37
|
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_ECIESError_MessageLengthExceedsMaximumAllowedSizeTemplate, { messageLength: message.length }));
|
|
@@ -60,8 +64,10 @@ export class EciesSingleRecipient {
|
|
|
60
64
|
const view = new DataView(lengthArray.buffer);
|
|
61
65
|
view.setBigUint64(0, BigInt(message.length), false); // big-endian
|
|
62
66
|
}
|
|
63
|
-
// Format: [preamble] | type (1) | ephemeralPublicKey (65) | iv (16) | authTag (16) | length (8) | encryptedData
|
|
67
|
+
// Format: [preamble] | version (1) | cipherSuite (1) | type (1) | ephemeralPublicKey (65) | iv (16) | authTag (16) | length (8) | encryptedData
|
|
64
68
|
const result = new Uint8Array(preamble.length +
|
|
69
|
+
versionArray.length +
|
|
70
|
+
cipherSuiteArray.length +
|
|
65
71
|
encryptionTypeArray.length +
|
|
66
72
|
ephemeralPublicKey.length +
|
|
67
73
|
iv.length +
|
|
@@ -71,6 +77,10 @@ export class EciesSingleRecipient {
|
|
|
71
77
|
let offset = 0;
|
|
72
78
|
result.set(preamble, offset);
|
|
73
79
|
offset += preamble.length;
|
|
80
|
+
result.set(versionArray, offset);
|
|
81
|
+
offset += versionArray.length;
|
|
82
|
+
result.set(cipherSuiteArray, offset);
|
|
83
|
+
offset += cipherSuiteArray.length;
|
|
74
84
|
result.set(encryptionTypeArray, offset);
|
|
75
85
|
offset += encryptionTypeArray.length;
|
|
76
86
|
result.set(ephemeralPublicKey, offset);
|
|
@@ -88,10 +98,24 @@ export class EciesSingleRecipient {
|
|
|
88
98
|
* Parse encrypted message header
|
|
89
99
|
*/
|
|
90
100
|
parseEncryptedMessage(encryptionType, data, preambleSize = 0, options) {
|
|
91
|
-
// Read encryption type from first byte after preamble
|
|
92
|
-
const actualEncryptionTypeByte = data[preambleSize];
|
|
93
|
-
let actualEncryptionType;
|
|
94
101
|
const engine = getEciesI18nEngine();
|
|
102
|
+
let offset = preambleSize;
|
|
103
|
+
const preamble = data.slice(0, preambleSize);
|
|
104
|
+
// Read Version
|
|
105
|
+
const version = data[offset];
|
|
106
|
+
offset += this.eciesConsts.VERSION_SIZE;
|
|
107
|
+
if (version !== EciesVersionEnum.V1) {
|
|
108
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_ECIESError_InvalidVersionTemplate, { version }));
|
|
109
|
+
}
|
|
110
|
+
// Read CipherSuite
|
|
111
|
+
const cipherSuite = data[offset];
|
|
112
|
+
offset += this.eciesConsts.CIPHER_SUITE_SIZE;
|
|
113
|
+
if (cipherSuite !== EciesCipherSuiteEnum.Secp256k1_Aes256Gcm_Sha256) {
|
|
114
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_ECIESError_InvalidCipherSuiteTemplate, { cipherSuite }));
|
|
115
|
+
}
|
|
116
|
+
// Read encryption type from first byte after preamble and version/suite
|
|
117
|
+
const actualEncryptionTypeByte = data[offset];
|
|
118
|
+
let actualEncryptionType;
|
|
95
119
|
switch (actualEncryptionTypeByte) {
|
|
96
120
|
case this.eciesConsts.ENCRYPTION_TYPE.SIMPLE:
|
|
97
121
|
actualEncryptionType = EciesEncryptionTypeEnum.Simple;
|
|
@@ -108,7 +132,6 @@ export class EciesSingleRecipient {
|
|
|
108
132
|
}
|
|
109
133
|
if (encryptionType !== undefined &&
|
|
110
134
|
actualEncryptionType !== encryptionType) {
|
|
111
|
-
const engine = getEciesI18nEngine();
|
|
112
135
|
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_ECIESError_EncryptionTypeMismatchTemplate, { encryptionType, actualEncryptionType }));
|
|
113
136
|
}
|
|
114
137
|
const includeLengthAndCrc = actualEncryptionType === EciesEncryptionTypeEnum.Single;
|
|
@@ -116,11 +139,8 @@ export class EciesSingleRecipient {
|
|
|
116
139
|
? this.eciesConsts.SINGLE.FIXED_OVERHEAD_SIZE
|
|
117
140
|
: this.eciesConsts.SIMPLE.FIXED_OVERHEAD_SIZE;
|
|
118
141
|
if (data.length < requiredSize) {
|
|
119
|
-
const engine = getEciesI18nEngine();
|
|
120
142
|
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_ECIESError_DataTooShortTemplate, { requiredSize, dataLength: data.length }));
|
|
121
143
|
}
|
|
122
|
-
let offset = preambleSize;
|
|
123
|
-
const preamble = data.slice(0, preambleSize);
|
|
124
144
|
// Skip encryption type byte
|
|
125
145
|
offset += 1;
|
|
126
146
|
// Extract header components
|
|
@@ -143,13 +163,11 @@ export class EciesSingleRecipient {
|
|
|
143
163
|
: options?.dataLength ?? -1;
|
|
144
164
|
// Validate data length is reasonable
|
|
145
165
|
if (includeLengthAndCrc && (dataLength < 0 || dataLength > this.eciesConsts.MAX_RAW_DATA_SIZE)) {
|
|
146
|
-
const engine = getEciesI18nEngine();
|
|
147
166
|
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_ECIESError_InvalidDataLength));
|
|
148
167
|
}
|
|
149
168
|
if (includeLengthAndCrc &&
|
|
150
169
|
options?.dataLength !== undefined &&
|
|
151
170
|
dataLength !== options.dataLength) {
|
|
152
|
-
const engine = getEciesI18nEngine();
|
|
153
171
|
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_ECIESError_DataLengthMismatchTemplate, { expectedDataLength: dataLength, receivedDataLength: options.dataLength }));
|
|
154
172
|
}
|
|
155
173
|
// No CRC in Single encryption (AES-GCM provides authentication)
|