@digitaldefiance/node-ecies-lib 1.1.21 → 1.1.22

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.
Files changed (211) hide show
  1. package/README.md +4 -0
  2. package/package.json +14 -35
  3. package/src/constants.ts +182 -0
  4. package/src/enumerations/index.ts +1 -0
  5. package/src/enumerations/pbkdf2-profile.ts +8 -0
  6. package/src/i18n/ecies-i18n-factory.ts +435 -0
  7. package/{dist/i18n/index.d.ts → src/i18n/index.ts} +0 -1
  8. package/{dist/index.d.ts → src/index.ts} +0 -1
  9. package/src/interfaces/authenticated-cipher.ts +9 -0
  10. package/src/interfaces/authenticated-decipher.ts +8 -0
  11. package/src/interfaces/checksum-config.ts +4 -0
  12. package/src/interfaces/checksum-consts.ts +13 -0
  13. package/src/interfaces/constants.ts +43 -0
  14. package/src/interfaces/ecies-consts.ts +99 -0
  15. package/src/interfaces/encryption-consts.ts +10 -0
  16. package/{dist/interfaces/index.d.ts → src/interfaces/index.ts} +0 -1
  17. package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.ts +7 -0
  18. package/src/interfaces/keyring-consts.ts +5 -0
  19. package/src/interfaces/member-operational.ts +52 -0
  20. package/{dist/interfaces/member-with-mnemonic.d.ts → src/interfaces/member-with-mnemonic.ts} +3 -3
  21. package/{dist/interfaces/multi-encrypted-message.d.ts → src/interfaces/multi-encrypted-message.ts} +5 -5
  22. package/src/interfaces/multi-encrypted-parsed-header.ts +24 -0
  23. package/{dist/interfaces/pbkdf-profiles.d.ts → src/interfaces/pbkdf-profiles.ts} +2 -2
  24. package/src/interfaces/pbkdf2-result.ts +5 -0
  25. package/src/interfaces/signing-key-private-key-info.ts +12 -0
  26. package/{dist/interfaces/simple-keypair-buffer.d.ts → src/interfaces/simple-keypair-buffer.ts} +3 -3
  27. package/{dist/interfaces/simple-keypair.d.ts → src/interfaces/simple-keypair.ts} +3 -3
  28. package/src/interfaces/simple-public-key-only-buffer.ts +3 -0
  29. package/src/interfaces/simple-public-key-only.ts +3 -0
  30. package/src/interfaces/single-encrypted-parsed-header.ts +35 -0
  31. package/{dist/interfaces/wallet-seed.d.ts → src/interfaces/wallet-seed.ts} +3 -3
  32. package/src/interfaces/wrapped-key-consts.ts +6 -0
  33. package/src/member.ts +463 -0
  34. package/src/services/aes-gcm.ts +160 -0
  35. package/src/services/ecies/crypto-core.ts +213 -0
  36. package/src/services/ecies/file.ts +174 -0
  37. package/{dist/services/ecies/index.d.ts → src/services/ecies/index.ts} +0 -1
  38. package/src/services/ecies/multi-recipient.ts +583 -0
  39. package/src/services/ecies/service.ts +351 -0
  40. package/src/services/ecies/signature.ts +91 -0
  41. package/src/services/ecies/single-recipient.ts +676 -0
  42. package/src/services/ecies/utilities.ts +111 -0
  43. package/src/services/index.ts +3 -0
  44. package/src/services/pbkdf2.ts +307 -0
  45. package/{dist/types.d.ts → src/types.ts} +26 -9
  46. package/src/utils.ts +104 -0
  47. package/dist/constants.d.ts +0 -32
  48. package/dist/constants.d.ts.map +0 -1
  49. package/dist/constants.js +0 -137
  50. package/dist/constants.js.map +0 -1
  51. package/dist/enumerations/index.d.ts +0 -2
  52. package/dist/enumerations/index.d.ts.map +0 -1
  53. package/dist/enumerations/index.js +0 -18
  54. package/dist/enumerations/index.js.map +0 -1
  55. package/dist/enumerations/pbkdf2-profile.d.ts +0 -9
  56. package/dist/enumerations/pbkdf2-profile.d.ts.map +0 -1
  57. package/dist/enumerations/pbkdf2-profile.js +0 -13
  58. package/dist/enumerations/pbkdf2-profile.js.map +0 -1
  59. package/dist/i18n/ecies-i18n-factory.d.ts +0 -54
  60. package/dist/i18n/ecies-i18n-factory.d.ts.map +0 -1
  61. package/dist/i18n/ecies-i18n-factory.js +0 -333
  62. package/dist/i18n/ecies-i18n-factory.js.map +0 -1
  63. package/dist/i18n/index.d.ts.map +0 -1
  64. package/dist/i18n/index.js +0 -18
  65. package/dist/i18n/index.js.map +0 -1
  66. package/dist/index.d.ts.map +0 -1
  67. package/dist/index.js +0 -24
  68. package/dist/index.js.map +0 -1
  69. package/dist/interfaces/authenticated-cipher.d.ts +0 -10
  70. package/dist/interfaces/authenticated-cipher.d.ts.map +0 -1
  71. package/dist/interfaces/authenticated-cipher.js +0 -3
  72. package/dist/interfaces/authenticated-cipher.js.map +0 -1
  73. package/dist/interfaces/authenticated-decipher.d.ts +0 -9
  74. package/dist/interfaces/authenticated-decipher.d.ts.map +0 -1
  75. package/dist/interfaces/authenticated-decipher.js +0 -3
  76. package/dist/interfaces/authenticated-decipher.js.map +0 -1
  77. package/dist/interfaces/checksum-config.d.ts +0 -5
  78. package/dist/interfaces/checksum-config.d.ts.map +0 -1
  79. package/dist/interfaces/checksum-config.js +0 -3
  80. package/dist/interfaces/checksum-config.js.map +0 -1
  81. package/dist/interfaces/checksum-consts.d.ts +0 -11
  82. package/dist/interfaces/checksum-consts.d.ts.map +0 -1
  83. package/dist/interfaces/checksum-consts.js +0 -3
  84. package/dist/interfaces/checksum-consts.js.map +0 -1
  85. package/dist/interfaces/constants.d.ts +0 -43
  86. package/dist/interfaces/constants.d.ts.map +0 -1
  87. package/dist/interfaces/constants.js +0 -3
  88. package/dist/interfaces/constants.js.map +0 -1
  89. package/dist/interfaces/ecies-consts.d.ts +0 -88
  90. package/dist/interfaces/ecies-consts.d.ts.map +0 -1
  91. package/dist/interfaces/ecies-consts.js +0 -3
  92. package/dist/interfaces/ecies-consts.js.map +0 -1
  93. package/dist/interfaces/encryption-consts.d.ts +0 -11
  94. package/dist/interfaces/encryption-consts.d.ts.map +0 -1
  95. package/dist/interfaces/encryption-consts.js +0 -3
  96. package/dist/interfaces/encryption-consts.js.map +0 -1
  97. package/dist/interfaces/index.d.ts.map +0 -1
  98. package/dist/interfaces/index.js +0 -34
  99. package/dist/interfaces/index.js.map +0 -1
  100. package/dist/interfaces/keypair-buffer-with-un-encrypted-private-key.d.ts +0 -6
  101. package/dist/interfaces/keypair-buffer-with-un-encrypted-private-key.d.ts.map +0 -1
  102. package/dist/interfaces/keypair-buffer-with-un-encrypted-private-key.js +0 -3
  103. package/dist/interfaces/keypair-buffer-with-un-encrypted-private-key.js.map +0 -1
  104. package/dist/interfaces/keyring-consts.d.ts +0 -6
  105. package/dist/interfaces/keyring-consts.d.ts.map +0 -1
  106. package/dist/interfaces/keyring-consts.js +0 -3
  107. package/dist/interfaces/keyring-consts.js.map +0 -1
  108. package/dist/interfaces/member-operational.d.ts +0 -36
  109. package/dist/interfaces/member-operational.d.ts.map +0 -1
  110. package/dist/interfaces/member-operational.js +0 -3
  111. package/dist/interfaces/member-operational.js.map +0 -1
  112. package/dist/interfaces/member-with-mnemonic.d.ts.map +0 -1
  113. package/dist/interfaces/member-with-mnemonic.js +0 -3
  114. package/dist/interfaces/member-with-mnemonic.js.map +0 -1
  115. package/dist/interfaces/multi-encrypted-message.d.ts.map +0 -1
  116. package/dist/interfaces/multi-encrypted-message.js +0 -3
  117. package/dist/interfaces/multi-encrypted-message.js.map +0 -1
  118. package/dist/interfaces/multi-encrypted-parsed-header.d.ts +0 -24
  119. package/dist/interfaces/multi-encrypted-parsed-header.d.ts.map +0 -1
  120. package/dist/interfaces/multi-encrypted-parsed-header.js +0 -3
  121. package/dist/interfaces/multi-encrypted-parsed-header.js.map +0 -1
  122. package/dist/interfaces/pbkdf-profiles.d.ts.map +0 -1
  123. package/dist/interfaces/pbkdf-profiles.js +0 -3
  124. package/dist/interfaces/pbkdf-profiles.js.map +0 -1
  125. package/dist/interfaces/pbkdf2-result.d.ts +0 -6
  126. package/dist/interfaces/pbkdf2-result.d.ts.map +0 -1
  127. package/dist/interfaces/pbkdf2-result.js +0 -3
  128. package/dist/interfaces/pbkdf2-result.js.map +0 -1
  129. package/dist/interfaces/signing-key-private-key-info.d.ts +0 -11
  130. package/dist/interfaces/signing-key-private-key-info.d.ts.map +0 -1
  131. package/dist/interfaces/signing-key-private-key-info.js +0 -3
  132. package/dist/interfaces/signing-key-private-key-info.js.map +0 -1
  133. package/dist/interfaces/simple-keypair-buffer.d.ts.map +0 -1
  134. package/dist/interfaces/simple-keypair-buffer.js +0 -3
  135. package/dist/interfaces/simple-keypair-buffer.js.map +0 -1
  136. package/dist/interfaces/simple-keypair.d.ts.map +0 -1
  137. package/dist/interfaces/simple-keypair.js +0 -3
  138. package/dist/interfaces/simple-keypair.js.map +0 -1
  139. package/dist/interfaces/simple-public-key-only-buffer.d.ts +0 -4
  140. package/dist/interfaces/simple-public-key-only-buffer.d.ts.map +0 -1
  141. package/dist/interfaces/simple-public-key-only-buffer.js +0 -3
  142. package/dist/interfaces/simple-public-key-only-buffer.js.map +0 -1
  143. package/dist/interfaces/simple-public-key-only.d.ts +0 -4
  144. package/dist/interfaces/simple-public-key-only.d.ts.map +0 -1
  145. package/dist/interfaces/simple-public-key-only.js +0 -3
  146. package/dist/interfaces/simple-public-key-only.js.map +0 -1
  147. package/dist/interfaces/single-encrypted-parsed-header.d.ts +0 -35
  148. package/dist/interfaces/single-encrypted-parsed-header.d.ts.map +0 -1
  149. package/dist/interfaces/single-encrypted-parsed-header.js +0 -3
  150. package/dist/interfaces/single-encrypted-parsed-header.js.map +0 -1
  151. package/dist/interfaces/wallet-seed.d.ts.map +0 -1
  152. package/dist/interfaces/wallet-seed.js +0 -3
  153. package/dist/interfaces/wallet-seed.js.map +0 -1
  154. package/dist/interfaces/wrapped-key-consts.d.ts +0 -7
  155. package/dist/interfaces/wrapped-key-consts.d.ts.map +0 -1
  156. package/dist/interfaces/wrapped-key-consts.js +0 -3
  157. package/dist/interfaces/wrapped-key-consts.js.map +0 -1
  158. package/dist/member.d.ts +0 -74
  159. package/dist/member.d.ts.map +0 -1
  160. package/dist/member.js +0 -273
  161. package/dist/member.js.map +0 -1
  162. package/dist/services/aes-gcm.d.ts +0 -66
  163. package/dist/services/aes-gcm.d.ts.map +0 -1
  164. package/dist/services/aes-gcm.js +0 -115
  165. package/dist/services/aes-gcm.js.map +0 -1
  166. package/dist/services/ecies/crypto-core.d.ts +0 -83
  167. package/dist/services/ecies/crypto-core.d.ts.map +0 -1
  168. package/dist/services/ecies/crypto-core.js +0 -166
  169. package/dist/services/ecies/crypto-core.js.map +0 -1
  170. package/dist/services/ecies/file.d.ts +0 -30
  171. package/dist/services/ecies/file.d.ts.map +0 -1
  172. package/dist/services/ecies/file.js +0 -144
  173. package/dist/services/ecies/file.js.map +0 -1
  174. package/dist/services/ecies/index.d.ts.map +0 -1
  175. package/dist/services/ecies/index.js +0 -24
  176. package/dist/services/ecies/index.js.map +0 -1
  177. package/dist/services/ecies/multi-recipient.d.ts +0 -82
  178. package/dist/services/ecies/multi-recipient.d.ts.map +0 -1
  179. package/dist/services/ecies/multi-recipient.js +0 -360
  180. package/dist/services/ecies/multi-recipient.js.map +0 -1
  181. package/dist/services/ecies/service.d.ts +0 -70
  182. package/dist/services/ecies/service.d.ts.map +0 -1
  183. package/dist/services/ecies/service.js +0 -167
  184. package/dist/services/ecies/service.js.map +0 -1
  185. package/dist/services/ecies/signature.d.ts +0 -38
  186. package/dist/services/ecies/signature.d.ts.map +0 -1
  187. package/dist/services/ecies/signature.js +0 -69
  188. package/dist/services/ecies/signature.js.map +0 -1
  189. package/dist/services/ecies/single-recipient.d.ts +0 -85
  190. package/dist/services/ecies/single-recipient.d.ts.map +0 -1
  191. package/dist/services/ecies/single-recipient.js +0 -399
  192. package/dist/services/ecies/single-recipient.js.map +0 -1
  193. package/dist/services/ecies/utilities.d.ts +0 -22
  194. package/dist/services/ecies/utilities.d.ts.map +0 -1
  195. package/dist/services/ecies/utilities.js +0 -75
  196. package/dist/services/ecies/utilities.js.map +0 -1
  197. package/dist/services/index.d.ts +0 -4
  198. package/dist/services/index.d.ts.map +0 -1
  199. package/dist/services/index.js +0 -20
  200. package/dist/services/index.js.map +0 -1
  201. package/dist/services/pbkdf2.d.ts +0 -106
  202. package/dist/services/pbkdf2.d.ts.map +0 -1
  203. package/dist/services/pbkdf2.js +0 -195
  204. package/dist/services/pbkdf2.js.map +0 -1
  205. package/dist/types.d.ts.map +0 -1
  206. package/dist/types.js +0 -3
  207. package/dist/types.js.map +0 -1
  208. package/dist/utils.d.ts +0 -11
  209. package/dist/utils.d.ts.map +0 -1
  210. package/dist/utils.js +0 -82
  211. package/dist/utils.js.map +0 -1
@@ -1,82 +0,0 @@
1
- import { PluginI18nEngine, CoreLanguageCode } from '@digitaldefiance/i18n-lib';
2
- import { IMultiEncryptedMessage } from '../../interfaces/multi-encrypted-message';
3
- import { IMultiEncryptedParsedHeader } from '../../interfaces/multi-encrypted-parsed-header';
4
- import { Member } from '../../member';
5
- import { EciesCryptoCore } from './crypto-core';
6
- import { EciesSingleRecipientCore } from './single-recipient';
7
- /**
8
- * Multiple recipient encryption/decryption functions for ECIES
9
- */
10
- export declare class EciesMultiRecipient {
11
- protected readonly cryptoCore: EciesCryptoCore;
12
- protected readonly singleRecipientCore: EciesSingleRecipientCore;
13
- protected readonly engine: PluginI18nEngine<CoreLanguageCode>;
14
- constructor(cryptoCore: EciesCryptoCore, engine?: PluginI18nEngine<CoreLanguageCode>);
15
- /**
16
- * Get the size of the header for a given encryption type
17
- * @param encryptionType The encryption type (single, simple, etc.)
18
- * @param options Optional encryption options
19
- * @param options.recipientCount The number of recipients
20
- * @returns
21
- */
22
- getHeaderSize(recipientCount: number): number;
23
- /**
24
- * Encrypt a message symmetric key with a public key
25
- * @param receiverPublicKey The public key of the receiver
26
- * @param messageSymmetricKey The message to encrypt
27
- * @returns The encrypted message
28
- */
29
- encryptKey(receiverPublicKey: Buffer, messageSymmetricKey: Buffer): Buffer;
30
- /**
31
- * Decrypts symmetric key encrypted with ECIES using a header
32
- * @param privateKey The private key to decrypt the data
33
- * @param encryptedKey The data to decrypt
34
- * @returns The decrypted data buffer
35
- */
36
- decryptKey(privateKey: Buffer, encryptedKey: Buffer): Buffer;
37
- /**
38
- * Encrypts a message for multiple recipients.
39
- * @param recipients The recipients to encrypt the message for.
40
- * @param message The message to encrypt.
41
- * @param preamble Optional preamble to include in the encrypted message.
42
- * @returns The encrypted message.
43
- * @throws EciesError if the number of recipients is greater than 65535.
44
- */
45
- encryptMultiple(recipients: Member[], message: Buffer, preamble?: Buffer): IMultiEncryptedMessage;
46
- /**
47
- * Decrypts a message encrypted with multiple ECIE for a recipient.
48
- * @param encryptedData The encrypted data.
49
- * @param recipient The recipient.
50
- * @returns The decrypted message.
51
- */
52
- decryptMultipleECIEForRecipient(encryptedData: IMultiEncryptedMessage, recipient: Member): Buffer;
53
- /**
54
- * Calculate the overhead for a message encrypted for multiple recipients
55
- * @param recipientCount number of recipients
56
- * @param includeMessageOverhead whether to include the overhead for the encrypted message
57
- * @param encryptedKeys optional array of encrypted keys to calculate actual size
58
- * @returns the overhead size in bytes
59
- */
60
- calculateECIESMultipleRecipientOverhead(recipientCount: number, includeMessageOverhead: boolean, encryptedKeys?: Buffer[]): number;
61
- /**
62
- * Builds the header for a message encrypted for multiple recipients
63
- * @param data The encrypted message data including recipients and encrypted keys
64
- * @returns The header buffer for the message
65
- * @throws EciesError if the number of recipients is greater than the maximum allowed
66
- * @throws EciesError if the number of encrypted keys does not match the number of recipients
67
- */
68
- buildECIESMultipleRecipientHeader(data: IMultiEncryptedMessage): Buffer;
69
- /**
70
- * Parses a multi-encrypted header.
71
- * @param data - The data to parse.
72
- * @returns The parsed header.
73
- */
74
- parseMultiEncryptedHeader(data: Buffer): IMultiEncryptedParsedHeader;
75
- /**
76
- * Parses a multi-encrypted buffer into its components.
77
- * @param data - The multi-encrypted buffer to parse.
78
- * @returns The parsed multi-encrypted buffer.
79
- */
80
- parseMultiEncryptedBuffer(data: Buffer): IMultiEncryptedMessage;
81
- }
82
- //# sourceMappingURL=multi-recipient.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"multi-recipient.d.ts","sourceRoot":"","sources":["../../../src/services/ecies/multi-recipient.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAa/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CA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yB,CAAC,IAAI,EAAE,MAAM,GAAG,2BAA2B;IAkF3E;;;;OAIG;IACI,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,sBAAsB;CASvE"}
@@ -1,360 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EciesMultiRecipient = void 0;
4
- const ecies_lib_1 = require("@digitaldefiance/ecies-lib");
5
- const crypto_1 = require("crypto");
6
- const mongodb_1 = require("mongodb");
7
- const constants_1 = require("../../constants");
8
- const ecies_i18n_factory_1 = require("../../i18n/ecies-i18n-factory");
9
- const single_recipient_1 = require("./single-recipient");
10
- /**
11
- * Multiple recipient encryption/decryption functions for ECIES
12
- */
13
- class EciesMultiRecipient {
14
- cryptoCore;
15
- singleRecipientCore;
16
- engine;
17
- constructor(cryptoCore, engine) {
18
- this.cryptoCore = cryptoCore;
19
- this.engine = engine || (0, ecies_i18n_factory_1.createEciesTranslationEngine)();
20
- this.singleRecipientCore = new single_recipient_1.EciesSingleRecipientCore(cryptoCore.config, this.engine);
21
- }
22
- /**
23
- * Get the size of the header for a given encryption type
24
- * @param encryptionType The encryption type (single, simple, etc.)
25
- * @param options Optional encryption options
26
- * @param options.recipientCount The number of recipients
27
- * @returns
28
- */
29
- getHeaderSize(recipientCount) {
30
- return (this.cryptoCore.consts.MULTIPLE.FIXED_OVERHEAD_SIZE +
31
- recipientCount * this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE);
32
- }
33
- /**
34
- * Encrypt a message symmetric key with a public key
35
- * @param receiverPublicKey The public key of the receiver
36
- * @param messageSymmetricKey The message to encrypt
37
- * @returns The encrypted message
38
- */
39
- encryptKey(receiverPublicKey, messageSymmetricKey) {
40
- // Generate ephemeral ECDH key pair
41
- const ecdh = (0, crypto_1.createECDH)(this.cryptoCore.config.curveName);
42
- ecdh.generateKeys();
43
- // Compute shared secret
44
- let sharedSecret;
45
- try {
46
- // Make sure we normalize the receiver's public key
47
- const normalizedReceiverPublicKey = this.cryptoCore.normalizePublicKey(receiverPublicKey);
48
- // Ensure we're using the properly formatted public key (with 0x04 prefix)
49
- // Our debugging shows only the full format with prefix works correctly
50
- sharedSecret = ecdh.computeSecret(normalizedReceiverPublicKey);
51
- }
52
- catch (error) {
53
- console.error('[ERROR][encrypt] Failed to compute shared secret:', error);
54
- if (error instanceof Error) {
55
- if ('code' in error &&
56
- error.code === 'ERR_CRYPTO_ECDH_INVALID_PUBLIC_KEY') {
57
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidRecipientPublicKey, this.engine, undefined, undefined, {
58
- nodeError: error.code,
59
- });
60
- }
61
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.SecretComputationFailed, this.engine, undefined, undefined, {
62
- error: error.message,
63
- });
64
- }
65
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.SecretComputationFailed, this.engine);
66
- }
67
- // Get the ephemeral public key and ensure it has the 0x04 prefix
68
- let ephemeralPublicKey = ecdh.getPublicKey();
69
- if (ephemeralPublicKey.length === this.cryptoCore.consts.RAW_PUBLIC_KEY_LENGTH) {
70
- ephemeralPublicKey = Buffer.concat([
71
- Buffer.from([this.cryptoCore.consts.PUBLIC_KEY_MAGIC]),
72
- ephemeralPublicKey,
73
- ]);
74
- }
75
- // Get the key from the shared secret (always use first 32 bytes)
76
- const symKey = sharedSecret.subarray(0, this.cryptoCore.consts.SYMMETRIC.KEY_SIZE);
77
- const iv = (0, crypto_1.randomBytes)(this.cryptoCore.consts.IV_SIZE);
78
- // Create cipher with the derived symmetric key
79
- const cipher = (0, crypto_1.createCipheriv)(this.cryptoCore.consts.SYMMETRIC_ALGORITHM_CONFIGURATION, symKey, iv);
80
- // Ensure auto padding is enabled
81
- cipher.setAutoPadding(true);
82
- // Encrypt the message
83
- let encrypted = cipher.update(messageSymmetricKey);
84
- encrypted = Buffer.concat([encrypted, cipher.final()]);
85
- // Get and explicitly set the authentication tag to max tag length for consistency
86
- const authTag = cipher.getAuthTag();
87
- // Format:ephemeralPublicKey (65) | iv (16) | authTag (16) | encryptedData (this.cryptoCore.consts.SYMMETRIC.KEY_SIZE = 32)
88
- return Buffer.concat([ephemeralPublicKey, iv, authTag, encrypted]);
89
- }
90
- /**
91
- * Decrypts symmetric key encrypted with ECIES using a header
92
- * @param privateKey The private key to decrypt the data
93
- * @param encryptedKey The data to decrypt
94
- * @returns The decrypted data buffer
95
- */
96
- decryptKey(privateKey, encryptedKey) {
97
- if (encryptedKey.length !== this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE) {
98
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEncryptedKeyLength, this.engine, undefined, undefined, {
99
- expected: String(this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE),
100
- actual: String(encryptedKey.length),
101
- });
102
- }
103
- const ephemeralPublicKey = encryptedKey.subarray(0, this.cryptoCore.consts.PUBLIC_KEY_LENGTH);
104
- const iv = encryptedKey.subarray(this.cryptoCore.consts.PUBLIC_KEY_LENGTH, this.cryptoCore.consts.PUBLIC_KEY_LENGTH + this.cryptoCore.consts.IV_SIZE);
105
- const authTag = encryptedKey.subarray(this.cryptoCore.consts.PUBLIC_KEY_LENGTH + this.cryptoCore.consts.IV_SIZE, this.cryptoCore.consts.PUBLIC_KEY_LENGTH + this.cryptoCore.consts.IV_SIZE + this.cryptoCore.consts.AUTH_TAG_SIZE);
106
- const encrypted = encryptedKey.subarray(this.cryptoCore.consts.PUBLIC_KEY_LENGTH + this.cryptoCore.consts.IV_SIZE + this.cryptoCore.consts.AUTH_TAG_SIZE, this.cryptoCore.consts.PUBLIC_KEY_LENGTH +
107
- this.cryptoCore.consts.IV_SIZE +
108
- this.cryptoCore.consts.AUTH_TAG_SIZE +
109
- this.cryptoCore.consts.SYMMETRIC.KEY_SIZE);
110
- // Normalize the public key (ensuring 0x04 prefix)
111
- const normalizedKey = this.cryptoCore.normalizePublicKey(ephemeralPublicKey);
112
- // Decrypt using components with the normalized key
113
- const decrypted = this.singleRecipientCore.decryptWithComponents(privateKey, normalizedKey, iv, authTag, encrypted);
114
- if (decrypted.length !== this.cryptoCore.consts.SYMMETRIC.KEY_SIZE) {
115
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidDataLength, this.engine, undefined, undefined, {
116
- expected: String(this.cryptoCore.consts.SYMMETRIC.KEY_SIZE),
117
- actual: String(decrypted.length),
118
- });
119
- }
120
- return decrypted;
121
- }
122
- /**
123
- * Encrypts a message for multiple recipients.
124
- * @param recipients The recipients to encrypt the message for.
125
- * @param message The message to encrypt.
126
- * @param preamble Optional preamble to include in the encrypted message.
127
- * @returns The encrypted message.
128
- * @throws EciesError if the number of recipients is greater than 65535.
129
- */
130
- encryptMultiple(recipients, message, preamble) {
131
- if (recipients.length > ecies_lib_1.Constants.UINT16_MAX) {
132
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.TooManyRecipients, this.engine);
133
- }
134
- const messageTypeBuffer = Buffer.alloc(1);
135
- messageTypeBuffer.writeUint8(ecies_lib_1.EciesEncryptionTypeEnum.Multiple);
136
- // Generate a random symmetric key
137
- const symmetricKey = (0, crypto_1.randomBytes)(this.cryptoCore.consts.SYMMETRIC.KEY_SIZE);
138
- const iv = (0, crypto_1.randomBytes)(this.cryptoCore.consts.IV_SIZE);
139
- // Encrypt the message with the symmetric key
140
- const cipher = (0, crypto_1.createCipheriv)(this.cryptoCore.consts.SYMMETRIC_ALGORITHM_CONFIGURATION, symmetricKey, iv);
141
- const encrypted = cipher.update(message);
142
- const final = cipher.final();
143
- const authTag = cipher.getAuthTag();
144
- const encryptedMessage = Buffer.concat([encrypted, final]);
145
- const storedMessage = Buffer.concat([
146
- preamble ?? Buffer.alloc(0),
147
- iv,
148
- authTag,
149
- encryptedMessage,
150
- ]);
151
- const encryptionResults = recipients.map((member) => ({
152
- id: member.id,
153
- encryptedKey: this.encryptKey(member.publicKey, symmetricKey),
154
- }));
155
- const recipientIds = encryptionResults.map(({ id }) => id);
156
- const recipientKeys = encryptionResults.map(({ encryptedKey }) => encryptedKey);
157
- // Verify the encrypted message size (just the encrypted content)
158
- if (encryptedMessage.length !== message.length) {
159
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.MessageLengthMismatch, this.engine);
160
- }
161
- const headerSize = this.calculateECIESMultipleRecipientOverhead(recipients.length, false, recipientKeys);
162
- return {
163
- dataLength: message.length,
164
- recipientCount: recipients.length,
165
- recipientIds,
166
- recipientKeys,
167
- encryptedMessage: storedMessage,
168
- headerSize,
169
- };
170
- }
171
- /**
172
- * Decrypts a message encrypted with multiple ECIE for a recipient.
173
- * @param encryptedData The encrypted data.
174
- * @param recipient The recipient.
175
- * @returns The decrypted message.
176
- */
177
- decryptMultipleECIEForRecipient(encryptedData, recipient) {
178
- if (recipient.privateKey === undefined) {
179
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.PrivateKeyNotLoaded, this.engine);
180
- }
181
- // Find this recipient's encrypted key
182
- const recipientIndex = encryptedData.recipientIds.findIndex((id) => id.equals(recipient.id));
183
- if (recipientIndex === -1) {
184
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.RecipientNotFound, this.engine);
185
- }
186
- const encryptedKey = encryptedData.recipientKeys[recipientIndex];
187
- // Decrypt the symmetric key using the detected encryption type
188
- const symmetricKey = this.decryptKey(Buffer.from(recipient.privateKey.value), encryptedKey);
189
- // Extract the IV and auth tag from the encrypted message
190
- const iv = encryptedData.encryptedMessage.subarray(0, this.cryptoCore.consts.IV_SIZE);
191
- const authTag = encryptedData.encryptedMessage.subarray(this.cryptoCore.consts.IV_SIZE, this.cryptoCore.consts.IV_SIZE + this.cryptoCore.consts.AUTH_TAG_SIZE);
192
- // Extract the encrypted content (no CRC, AES-GCM provides authentication)
193
- const encrypted = encryptedData.encryptedMessage.subarray(this.cryptoCore.consts.IV_SIZE + this.cryptoCore.consts.AUTH_TAG_SIZE);
194
- // Decrypt the content with the symmetric key
195
- const decipher = (0, crypto_1.createDecipheriv)(this.cryptoCore.consts.SYMMETRIC_ALGORITHM_CONFIGURATION, symmetricKey, iv);
196
- decipher.setAuthTag(authTag);
197
- const decrypted = decipher.update(encrypted);
198
- const final = decipher.final();
199
- const decryptedMessage = Buffer.concat([decrypted, final]);
200
- // AES-GCM provides authentication via auth tag (no separate CRC needed)
201
- // The decrypted message should match the original data length
202
- if (decryptedMessage.length !== encryptedData.dataLength) {
203
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidDataLength, this.engine);
204
- }
205
- return decryptedMessage;
206
- }
207
- /**
208
- * Calculate the overhead for a message encrypted for multiple recipients
209
- * @param recipientCount number of recipients
210
- * @param includeMessageOverhead whether to include the overhead for the encrypted message
211
- * @param encryptedKeys optional array of encrypted keys to calculate actual size
212
- * @returns the overhead size in bytes
213
- */
214
- calculateECIESMultipleRecipientOverhead(recipientCount, includeMessageOverhead, encryptedKeys) {
215
- if (recipientCount < 2) {
216
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidRecipientCount, this.engine);
217
- }
218
- // Calculate encrypted keys size
219
- let encryptedKeysSize;
220
- if (encryptedKeys) {
221
- encryptedKeysSize = encryptedKeys.reduce((total, key) => total + key.length, 0);
222
- }
223
- else {
224
- // Default assumption: all keys use Simple encryption type (more efficient)
225
- encryptedKeysSize = recipientCount * this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE;
226
- }
227
- const baseOverhead = this.cryptoCore.consts.MULTIPLE.DATA_LENGTH_SIZE +
228
- this.cryptoCore.consts.MULTIPLE.RECIPIENT_COUNT_SIZE +
229
- recipientCount * constants_1.Constants.OBJECT_ID_LENGTH + // recipient ids
230
- encryptedKeysSize; // actual encrypted keys size
231
- return includeMessageOverhead
232
- ? baseOverhead + this.cryptoCore.consts.MULTIPLE.FIXED_OVERHEAD_SIZE
233
- : baseOverhead;
234
- }
235
- /**
236
- * Builds the header for a message encrypted for multiple recipients
237
- * @param data The encrypted message data including recipients and encrypted keys
238
- * @returns The header buffer for the message
239
- * @throws EciesError if the number of recipients is greater than the maximum allowed
240
- * @throws EciesError if the number of encrypted keys does not match the number of recipients
241
- */
242
- buildECIESMultipleRecipientHeader(data) {
243
- if (data.recipientIds.length > this.cryptoCore.consts.MULTIPLE.MAX_RECIPIENTS) {
244
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.TooManyRecipients, this.engine);
245
- }
246
- else if (data.recipientIds.length !== data.recipientKeys.length) {
247
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.RecipientKeyCountMismatch, this.engine);
248
- }
249
- else if (data.dataLength < 0 ||
250
- data.dataLength > this.cryptoCore.consts.MAX_RAW_DATA_SIZE) {
251
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.FileSizeTooLarge, this.engine);
252
- }
253
- // Create data length buffer
254
- const dataLengthBuffer = Buffer.alloc(this.cryptoCore.consts.MULTIPLE.DATA_LENGTH_SIZE);
255
- dataLengthBuffer.writeBigUInt64BE(BigInt(data.dataLength));
256
- // Create recipient count buffer
257
- const recipientCountBuffer = Buffer.alloc(this.cryptoCore.consts.MULTIPLE.RECIPIENT_COUNT_SIZE);
258
- recipientCountBuffer.writeUInt16BE(data.recipientIds.length);
259
- // Create recipients buffer
260
- const recipientsBuffer = Buffer.alloc(data.recipientIds.length * constants_1.Constants.OBJECT_ID_LENGTH);
261
- data.recipientIds.forEach((recipientId, index) => {
262
- recipientsBuffer.set(Buffer.from(recipientId.toHexString(), 'hex'), index * constants_1.Constants.OBJECT_ID_LENGTH);
263
- });
264
- // Validate encrypted key lengths based on their encryption type
265
- data.recipientKeys.forEach((encryptedKey) => {
266
- if (encryptedKey.length === 0) {
267
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEncryptedKeyLength, this.engine);
268
- }
269
- if (encryptedKey.length !== this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE) {
270
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEncryptedKeyLength, this.engine, undefined, undefined, {
271
- expected: String(this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE),
272
- actual: String(encryptedKey.length),
273
- });
274
- }
275
- });
276
- // Create encrypted keys buffer with variable-length keys
277
- const encryptedKeysBuffer = Buffer.concat(data.recipientKeys);
278
- // Combine all buffers to form the header
279
- return Buffer.concat([
280
- dataLengthBuffer,
281
- recipientCountBuffer,
282
- recipientsBuffer,
283
- encryptedKeysBuffer,
284
- ]);
285
- }
286
- /**
287
- * Parses a multi-encrypted header.
288
- * @param data - The data to parse.
289
- * @returns The parsed header.
290
- */
291
- parseMultiEncryptedHeader(data) {
292
- // Ensure there's enough data to read headers
293
- if (data.length < this.cryptoCore.consts.MULTIPLE.FIXED_OVERHEAD_SIZE) {
294
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidDataLength, this.engine);
295
- }
296
- let offset = 0;
297
- // Read data length
298
- const dataLength = Number(data.readBigUInt64BE(offset));
299
- if (dataLength <= 0 || dataLength > this.cryptoCore.consts.MAX_RAW_DATA_SIZE) {
300
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidDataLength, this.engine);
301
- }
302
- offset += this.cryptoCore.consts.MULTIPLE.DATA_LENGTH_SIZE; // 8 bytes
303
- // Read recipient count
304
- const recipientCount = data.readUInt16BE(offset);
305
- if (recipientCount <= 0 || recipientCount > this.cryptoCore.consts.MULTIPLE.MAX_RECIPIENTS) {
306
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidRecipientCount, this.engine);
307
- }
308
- offset += this.cryptoCore.consts.MULTIPLE.RECIPIENT_COUNT_SIZE; // 2 bytes
309
- // Ensure there's enough data for all recipients
310
- const requiredLength = this.calculateECIESMultipleRecipientOverhead(recipientCount, false);
311
- if (data.length < requiredLength) {
312
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidDataLength, this.engine);
313
- }
314
- // Read recipient IDs
315
- const recipientIds = [];
316
- for (let i = 0; i < recipientCount; i++) {
317
- recipientIds.push(new mongodb_1.ObjectId(data
318
- .subarray(offset, offset + constants_1.Constants.OBJECT_ID_LENGTH)
319
- .toString('hex')));
320
- offset += constants_1.Constants.OBJECT_ID_LENGTH;
321
- }
322
- // Read encrypted keys with variable lengths based on encryption type
323
- const recipientKeys = [];
324
- for (let i = 0; i < recipientCount; i++) {
325
- if (offset >= data.length) {
326
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidDataLength, this.engine);
327
- }
328
- if (offset + this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE > data.length) {
329
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidDataLength, this.engine, undefined, undefined, {
330
- required: String(this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE),
331
- available: String(data.length - offset),
332
- });
333
- }
334
- recipientKeys.push(data.subarray(offset, offset + this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE));
335
- offset += this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE;
336
- }
337
- return {
338
- dataLength,
339
- recipientCount,
340
- recipientIds,
341
- recipientKeys,
342
- headerSize: offset,
343
- };
344
- }
345
- /**
346
- * Parses a multi-encrypted buffer into its components.
347
- * @param data - The multi-encrypted buffer to parse.
348
- * @returns The parsed multi-encrypted buffer.
349
- */
350
- parseMultiEncryptedBuffer(data) {
351
- const header = this.parseMultiEncryptedHeader(data);
352
- const encryptedMessage = data.subarray(header.headerSize);
353
- return {
354
- ...header,
355
- encryptedMessage,
356
- };
357
- }
358
- }
359
- exports.EciesMultiRecipient = EciesMultiRecipient;
360
- //# sourceMappingURL=multi-recipient.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"multi-recipient.js","sourceRoot":"","sources":["../../../src/services/ecies/multi-recipient.ts"],"names":[],"mappings":";;;AAAA,0DAMoC;AAGpC,mCAKgB;AAChB,qCAAmC;AAEnC,+CAA4C;AAC5C,sEAA6E;AAM7E,yDAA8D;AAE9D;;GAEG;AACH,MAAa,mBAAmB;IACX,UAAU,CAAkB;IAC5B,mBAAmB,CAA2B;IAC9C,MAAM,CAAqC;IAE9D,YACE,UAA2B,EAC3B,MAA2C;QAE3C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,IAAA,iDAA4B,GAAE,CAAC;QACvD,IAAI,CAAC,mBAAmB,GAAG,IAAI,2CAAwB,CACrD,UAAU,CAAC,MAAM,EACjB,IAAI,CAAC,MAAM,CACZ,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACI,aAAa,CAAC,cAAsB;QACzC,OAAO,CACL,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB;YACnD,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CACpE,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACI,UAAU,CACf,iBAAyB,EACzB,mBAA2B;QAE3B,mCAAmC;QACnC,MAAM,IAAI,GAAG,IAAA,mBAAU,EAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAC1D,IAAI,CAAC,YAAY,EAAE,CAAC;QAEpB,wBAAwB;QACxB,IAAI,YAAoB,CAAC;QACzB,IAAI,CAAC;YACH,mDAAmD;YACnD,MAAM,2BAA2B,GAC/B,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,CAAC;YAExD,0EAA0E;YAC1E,uEAA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AAC,MAAM,EAAE,CAAC;gBAC9E,MAAM,IAAI,sBAAU,CAClB,8BAAkB,CAAC,iBAAiB,EACpC,IAAI,CAAC,MAAM,EACX,SAAS,EACT,SAAS,EACT;oBACE,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC;oBACpE,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;iBACxC,CACF,CAAC;YACJ,CAAC;YAED,aAAa,CAAC,IAAI,CAChB,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CACnF,CAAC;YACF,MAAM,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC;QAC/D,CAAC;QAED,OAAO;YACL,UAAU;YACV,cAAc;YACd,YAAY;YACZ,aAAa;YACb,UAAU,EAAE,MAAM;SACnB,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACI,yBAAyB,CAAC,IAAY;QAC3C,MAAM,MAAM,GAAG,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,CAAC;QACpD,MAAM,gBAAgB,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAE1D,OAAO;YACL,GAAG,MAAM;YACT,gBAAgB;SACjB,CAAC;IACJ,CAAC;CACF;AAziBD,kDAyiBC"}
@@ -1,70 +0,0 @@
1
- import { EciesEncryptionType, EciesEncryptionTypeEnum, HexString, IECIESConfig, IECIESConstants, SecureString } from '@digitaldefiance/ecies-lib';
2
- import { Wallet } from '@ethereumjs/wallet';
3
- import { Member } from '../../member';
4
- import { PluginI18nEngine, CoreLanguageCode } from '@digitaldefiance/i18n-lib';
5
- import { IWalletSeed } from 'src/interfaces';
6
- import { IMultiEncryptedMessage } from '../../interfaces/multi-encrypted-message';
7
- import { IMultiEncryptedParsedHeader } from '../../interfaces/multi-encrypted-parsed-header';
8
- import { ISingleEncryptedParsedHeader } from '../../interfaces/single-encrypted-parsed-header';
9
- import { SignatureBuffer, SignatureString } from '../../types';
10
- import { EciesCryptoCore } from './crypto-core';
11
- import { EciesMultiRecipient } from './multi-recipient';
12
- import { EciesSignature } from './signature';
13
- import { EciesSingleRecipientCore } from './single-recipient';
14
- import { EciesUtilities } from './utilities';
15
- /**
16
- * Unified ECIES service that integrates all the modular components
17
- */
18
- export declare class ECIESService {
19
- protected readonly _config: IECIESConfig;
20
- protected readonly cryptoCore: EciesCryptoCore;
21
- protected readonly signature: EciesSignature;
22
- protected readonly singleRecipient: EciesSingleRecipientCore;
23
- protected readonly multiRecipient: EciesMultiRecipient;
24
- protected readonly utilities: EciesUtilities;
25
- protected readonly engine: PluginI18nEngine<CoreLanguageCode>;
26
- constructor(engineOrConfig?: PluginI18nEngine<CoreLanguageCode> | Partial<IECIESConfig>, config?: Partial<IECIESConfig>, eciesParams?: IECIESConstants);
27
- get core(): EciesCryptoCore;
28
- get config(): IECIESConfig;
29
- /**
30
- * The name of the elliptic curve used for ECIES encryption/decryption
31
- */
32
- get curveName(): string;
33
- generateNewMnemonic(): SecureString;
34
- walletFromSeed(seed: Buffer): Wallet;
35
- walletAndSeedFromMnemonic(mnemonic: SecureString): IWalletSeed;
36
- walletToSimpleKeyPairBuffer(wallet: Wallet): import("src/interfaces").ISimpleKeyPairBuffer;
37
- seedToSimpleKeyPairBuffer(seed: Buffer): import("src/interfaces").ISimpleKeyPairBuffer;
38
- mnemonicToSimpleKeyPairBuffer(mnemonic: SecureString): import("src/interfaces").ISimpleKeyPairBuffer;
39
- encryptSimpleOrSingle(encryptSimple: boolean, receiverPublicKey: Buffer, message: Buffer, preamble?: Buffer): Buffer;
40
- parseSingleEncryptedHeader(encryptionType: EciesEncryptionTypeEnum, data: Buffer, preambleSize?: number, options?: {
41
- dataLength?: number;
42
- }): ISingleEncryptedParsedHeader;
43
- decryptSimpleOrSingleWithHeader(decryptSimple: boolean, privateKey: Buffer, encryptedData: Buffer, preambleSize?: number, options?: {
44
- dataLength?: number;
45
- }): Buffer;
46
- decryptSimpleOrSingleWithHeaderEx(encryptionType: EciesEncryptionTypeEnum, privateKey: Buffer, encryptedData: Buffer, preambleSize?: number, options?: {
47
- dataLength?: number;
48
- }): {
49
- decrypted: Buffer;
50
- consumedBytes: number;
51
- };
52
- decryptSingleWithComponents(privateKey: Buffer, ephemeralPublicKey: Buffer, iv: Buffer, authTag: Buffer, encrypted: Buffer): {
53
- decrypted: Buffer;
54
- ciphertextLength?: number;
55
- };
56
- signMessage(privateKey: Buffer, data: Buffer): SignatureBuffer;
57
- verifyMessage(publicKey: Buffer, data: Buffer, signature: SignatureBuffer): boolean;
58
- signatureStringToSignatureBuffer(signatureString: HexString): SignatureBuffer;
59
- signatureBufferToSignatureString(signatureBuffer: SignatureBuffer): SignatureString;
60
- encryptMultiple(recipients: Member[], message: Buffer): IMultiEncryptedMessage;
61
- decryptMultipleECIEForRecipient(encryptedData: IMultiEncryptedMessage, recipient: Member): Buffer;
62
- calculateECIESMultipleRecipientOverhead(recipientCount: number, includeMessageOverhead: boolean): number;
63
- buildECIESMultipleRecipientHeader(data: IMultiEncryptedMessage): Buffer;
64
- parseMultiEncryptedHeader(data: Buffer): IMultiEncryptedParsedHeader;
65
- parseMultiEncryptedBuffer(data: Buffer): IMultiEncryptedMessage;
66
- computeEncryptedLengthFromDataLength(dataLength: number, encryptionMode: EciesEncryptionType, recipientCount?: number): number;
67
- computeDecryptedLengthFromEncryptedDataLength(encryptedDataLength: number, padding?: number): number;
68
- encrypt(encryptionType: EciesEncryptionType, recipients: Member[], message: Buffer, preamble?: Buffer): Buffer;
69
- }
70
- //# sourceMappingURL=service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/services/ecies/service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBA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