@digitaldefiance/node-ecies-lib 4.5.19 → 4.6.3

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 (353) hide show
  1. package/package.json +2 -2
  2. package/src/builders/ecies-builder.d.ts +11 -0
  3. package/src/builders/ecies-builder.d.ts.map +1 -0
  4. package/src/builders/ecies-builder.js +26 -0
  5. package/src/builders/ecies-builder.js.map +1 -0
  6. package/src/builders/index.d.ts +3 -0
  7. package/src/builders/index.d.ts.map +1 -0
  8. package/src/builders/index.js +6 -0
  9. package/src/builders/index.js.map +1 -0
  10. package/src/builders/member-builder.d.ts +47 -0
  11. package/src/builders/member-builder.d.ts.map +1 -0
  12. package/src/builders/member-builder.js +99 -0
  13. package/src/builders/member-builder.js.map +1 -0
  14. package/src/constants.d.ts +38 -0
  15. package/src/constants.d.ts.map +1 -0
  16. package/src/constants.js +191 -0
  17. package/src/constants.js.map +1 -0
  18. package/src/core/errors/crypto-error.d.ts +6 -0
  19. package/src/core/errors/crypto-error.d.ts.map +1 -0
  20. package/src/core/errors/crypto-error.js +15 -0
  21. package/src/core/errors/crypto-error.js.map +1 -0
  22. package/src/core/index.d.ts +3 -0
  23. package/src/core/index.d.ts.map +1 -0
  24. package/src/core/index.js +6 -0
  25. package/src/core/index.js.map +1 -0
  26. package/src/core/types/result.d.ts +8 -0
  27. package/src/core/types/result.d.ts.map +1 -0
  28. package/src/core/types/result.js +3 -0
  29. package/src/core/types/result.js.map +1 -0
  30. package/src/enumerations/index.d.ts +3 -0
  31. package/src/enumerations/index.d.ts.map +1 -0
  32. package/src/enumerations/index.js +6 -0
  33. package/src/enumerations/index.js.map +1 -0
  34. package/src/enumerations/pbkdf2-profile.d.ts +9 -0
  35. package/src/enumerations/pbkdf2-profile.d.ts.map +1 -0
  36. package/src/enumerations/pbkdf2-profile.js +13 -0
  37. package/src/enumerations/pbkdf2-profile.js.map +1 -0
  38. package/src/enumerations/voting-error-type.d.ts +37 -0
  39. package/src/enumerations/voting-error-type.d.ts.map +1 -0
  40. package/src/enumerations/voting-error-type.js +48 -0
  41. package/src/enumerations/voting-error-type.js.map +1 -0
  42. package/src/errors/index.d.ts +2 -0
  43. package/src/errors/index.d.ts.map +1 -0
  44. package/src/errors/index.js +5 -0
  45. package/src/errors/index.js.map +1 -0
  46. package/src/errors/voting.d.ts +16 -0
  47. package/src/errors/voting.d.ts.map +1 -0
  48. package/src/errors/voting.js +27 -0
  49. package/src/errors/voting.js.map +1 -0
  50. package/src/i18n/ecies-i18n-factory.d.ts +28 -0
  51. package/src/i18n/ecies-i18n-factory.d.ts.map +1 -0
  52. package/src/i18n/ecies-i18n-factory.js +90 -0
  53. package/src/i18n/ecies-i18n-factory.js.map +1 -0
  54. package/src/i18n/index.d.ts +3 -0
  55. package/src/i18n/index.d.ts.map +1 -0
  56. package/src/i18n/index.js +8 -0
  57. package/src/i18n/index.js.map +1 -0
  58. package/src/i18n/node-ecies-i18n-setup.d.ts +5 -0
  59. package/src/i18n/node-ecies-i18n-setup.d.ts.map +1 -0
  60. package/src/i18n/node-ecies-i18n-setup.js +48 -0
  61. package/src/i18n/node-ecies-i18n-setup.js.map +1 -0
  62. package/src/i18n/node-keys.d.ts +57 -0
  63. package/src/i18n/node-keys.d.ts.map +1 -0
  64. package/src/i18n/node-keys.js +67 -0
  65. package/src/i18n/node-keys.js.map +1 -0
  66. package/src/i18n/translations/de.d.ts +3 -0
  67. package/src/i18n/translations/de.d.ts.map +1 -0
  68. package/src/i18n/translations/de.js +57 -0
  69. package/src/i18n/translations/de.js.map +1 -0
  70. package/src/i18n/translations/en-GB.d.ts +3 -0
  71. package/src/i18n/translations/en-GB.d.ts.map +1 -0
  72. package/src/i18n/translations/en-GB.js +61 -0
  73. package/src/i18n/translations/en-GB.js.map +1 -0
  74. package/src/i18n/translations/en-US.d.ts +6 -0
  75. package/src/i18n/translations/en-US.d.ts.map +1 -0
  76. package/src/i18n/translations/en-US.js +65 -0
  77. package/src/i18n/translations/en-US.js.map +1 -0
  78. package/src/i18n/translations/es.d.ts +3 -0
  79. package/src/i18n/translations/es.d.ts.map +1 -0
  80. package/src/i18n/translations/es.js +57 -0
  81. package/src/i18n/translations/es.js.map +1 -0
  82. package/src/i18n/translations/fr.d.ts +3 -0
  83. package/src/i18n/translations/fr.d.ts.map +1 -0
  84. package/src/i18n/translations/fr.js +57 -0
  85. package/src/i18n/translations/fr.js.map +1 -0
  86. package/src/i18n/translations/index.d.ts +9 -0
  87. package/src/i18n/translations/index.d.ts.map +1 -0
  88. package/src/i18n/translations/index.js +20 -0
  89. package/src/i18n/translations/index.js.map +1 -0
  90. package/src/i18n/translations/ja.d.ts +3 -0
  91. package/src/i18n/translations/ja.d.ts.map +1 -0
  92. package/src/i18n/translations/ja.js +57 -0
  93. package/src/i18n/translations/ja.js.map +1 -0
  94. package/src/i18n/translations/uk.d.ts +3 -0
  95. package/src/i18n/translations/uk.d.ts.map +1 -0
  96. package/src/i18n/translations/uk.js +57 -0
  97. package/src/i18n/translations/uk.js.map +1 -0
  98. package/src/i18n/translations/zh-cn.d.ts +3 -0
  99. package/src/i18n/translations/zh-cn.d.ts.map +1 -0
  100. package/src/i18n/translations/zh-cn.js +57 -0
  101. package/src/i18n/translations/zh-cn.js.map +1 -0
  102. package/src/i18n-setup.d.ts +26 -0
  103. package/src/i18n-setup.d.ts.map +1 -0
  104. package/src/i18n-setup.js +111 -0
  105. package/src/i18n-setup.js.map +1 -0
  106. package/src/index.d.ts +21 -0
  107. package/src/index.d.ts.map +1 -0
  108. package/src/index.js +36 -0
  109. package/src/index.js.map +1 -0
  110. package/src/interfaces/authenticated-cipher.d.ts +12 -0
  111. package/src/interfaces/authenticated-cipher.d.ts.map +1 -0
  112. package/src/interfaces/authenticated-cipher.js +3 -0
  113. package/src/interfaces/authenticated-cipher.js.map +1 -0
  114. package/src/interfaces/authenticated-decipher.d.ts +11 -0
  115. package/src/interfaces/authenticated-decipher.d.ts.map +1 -0
  116. package/src/interfaces/authenticated-decipher.js +3 -0
  117. package/src/interfaces/authenticated-decipher.js.map +1 -0
  118. package/src/interfaces/backend-member-operational.d.ts +48 -0
  119. package/src/interfaces/backend-member-operational.d.ts.map +1 -0
  120. package/src/interfaces/backend-member-operational.js +3 -0
  121. package/src/interfaces/backend-member-operational.js.map +1 -0
  122. package/src/interfaces/checksum-config.d.ts +5 -0
  123. package/src/interfaces/checksum-config.d.ts.map +1 -0
  124. package/src/interfaces/checksum-config.js +3 -0
  125. package/src/interfaces/checksum-config.js.map +1 -0
  126. package/src/interfaces/checksum-consts.d.ts +11 -0
  127. package/src/interfaces/checksum-consts.d.ts.map +1 -0
  128. package/src/interfaces/checksum-consts.js +3 -0
  129. package/src/interfaces/checksum-consts.js.map +1 -0
  130. package/src/interfaces/constants.d.ts +52 -0
  131. package/src/interfaces/constants.d.ts.map +1 -0
  132. package/src/interfaces/constants.js +3 -0
  133. package/src/interfaces/constants.js.map +1 -0
  134. package/src/interfaces/ecies-consts.d.ts +88 -0
  135. package/src/interfaces/ecies-consts.d.ts.map +1 -0
  136. package/src/interfaces/ecies-consts.js +3 -0
  137. package/src/interfaces/ecies-consts.js.map +1 -0
  138. package/src/interfaces/encrypted-chunk.d.ts +12 -0
  139. package/src/interfaces/encrypted-chunk.d.ts.map +1 -0
  140. package/src/interfaces/encrypted-chunk.js +3 -0
  141. package/src/interfaces/encrypted-chunk.js.map +1 -0
  142. package/src/interfaces/encryption-consts.d.ts +11 -0
  143. package/src/interfaces/encryption-consts.d.ts.map +1 -0
  144. package/src/interfaces/encryption-consts.js +3 -0
  145. package/src/interfaces/encryption-consts.js.map +1 -0
  146. package/src/interfaces/index.d.ts +31 -0
  147. package/src/interfaces/index.d.ts.map +1 -0
  148. package/src/interfaces/index.js +33 -0
  149. package/src/interfaces/index.js.map +1 -0
  150. package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.d.ts +6 -0
  151. package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.d.ts.map +1 -0
  152. package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.js +3 -0
  153. package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.js.map +1 -0
  154. package/src/interfaces/keyring-consts.d.ts +6 -0
  155. package/src/interfaces/keyring-consts.d.ts.map +1 -0
  156. package/src/interfaces/keyring-consts.js +3 -0
  157. package/src/interfaces/keyring-consts.js.map +1 -0
  158. package/src/interfaces/member-with-mnemonic.d.ts +7 -0
  159. package/src/interfaces/member-with-mnemonic.d.ts.map +1 -0
  160. package/src/interfaces/member-with-mnemonic.js +3 -0
  161. package/src/interfaces/member-with-mnemonic.js.map +1 -0
  162. package/src/interfaces/member.d.ts +47 -0
  163. package/src/interfaces/member.d.ts.map +1 -0
  164. package/src/interfaces/member.js +3 -0
  165. package/src/interfaces/member.js.map +1 -0
  166. package/src/interfaces/multi-encrypted-message.d.ts +8 -0
  167. package/src/interfaces/multi-encrypted-message.d.ts.map +1 -0
  168. package/src/interfaces/multi-encrypted-message.js +3 -0
  169. package/src/interfaces/multi-encrypted-message.js.map +1 -0
  170. package/src/interfaces/multi-encrypted-parsed-header.d.ts +27 -0
  171. package/src/interfaces/multi-encrypted-parsed-header.d.ts.map +1 -0
  172. package/src/interfaces/multi-encrypted-parsed-header.js +3 -0
  173. package/src/interfaces/multi-encrypted-parsed-header.js.map +1 -0
  174. package/src/interfaces/multi-recipient-chunk.d.ts +26 -0
  175. package/src/interfaces/multi-recipient-chunk.d.ts.map +1 -0
  176. package/src/interfaces/multi-recipient-chunk.js +15 -0
  177. package/src/interfaces/multi-recipient-chunk.js.map +1 -0
  178. package/src/interfaces/pbkdf-profiles.d.ts +6 -0
  179. package/src/interfaces/pbkdf-profiles.d.ts.map +1 -0
  180. package/src/interfaces/pbkdf-profiles.js +3 -0
  181. package/src/interfaces/pbkdf-profiles.js.map +1 -0
  182. package/src/interfaces/pbkdf2-result.d.ts +6 -0
  183. package/src/interfaces/pbkdf2-result.d.ts.map +1 -0
  184. package/src/interfaces/pbkdf2-result.js +3 -0
  185. package/src/interfaces/pbkdf2-result.js.map +1 -0
  186. package/src/interfaces/signing-key-private-key-info.d.ts +11 -0
  187. package/src/interfaces/signing-key-private-key-info.d.ts.map +1 -0
  188. package/src/interfaces/signing-key-private-key-info.js +3 -0
  189. package/src/interfaces/signing-key-private-key-info.js.map +1 -0
  190. package/src/interfaces/simple-keypair-buffer.d.ts +6 -0
  191. package/src/interfaces/simple-keypair-buffer.d.ts.map +1 -0
  192. package/src/interfaces/simple-keypair-buffer.js +3 -0
  193. package/src/interfaces/simple-keypair-buffer.js.map +1 -0
  194. package/src/interfaces/simple-keypair.d.ts +6 -0
  195. package/src/interfaces/simple-keypair.d.ts.map +1 -0
  196. package/src/interfaces/simple-keypair.js +3 -0
  197. package/src/interfaces/simple-keypair.js.map +1 -0
  198. package/src/interfaces/simple-public-key-only-buffer.d.ts +4 -0
  199. package/src/interfaces/simple-public-key-only-buffer.d.ts.map +1 -0
  200. package/src/interfaces/simple-public-key-only-buffer.js +3 -0
  201. package/src/interfaces/simple-public-key-only-buffer.js.map +1 -0
  202. package/src/interfaces/simple-public-key-only.d.ts +4 -0
  203. package/src/interfaces/simple-public-key-only.d.ts.map +1 -0
  204. package/src/interfaces/simple-public-key-only.js +3 -0
  205. package/src/interfaces/simple-public-key-only.js.map +1 -0
  206. package/src/interfaces/single-encrypted-parsed-header.d.ts +35 -0
  207. package/src/interfaces/single-encrypted-parsed-header.d.ts.map +1 -0
  208. package/src/interfaces/single-encrypted-parsed-header.js +3 -0
  209. package/src/interfaces/single-encrypted-parsed-header.js.map +1 -0
  210. package/src/interfaces/stream-config.d.ts +6 -0
  211. package/src/interfaces/stream-config.d.ts.map +1 -0
  212. package/src/interfaces/stream-config.js +8 -0
  213. package/src/interfaces/stream-config.js.map +1 -0
  214. package/src/interfaces/stream-progress.d.ts +22 -0
  215. package/src/interfaces/stream-progress.d.ts.map +1 -0
  216. package/src/interfaces/stream-progress.js +3 -0
  217. package/src/interfaces/stream-progress.js.map +1 -0
  218. package/src/interfaces/voting-consts.d.ts +86 -0
  219. package/src/interfaces/voting-consts.d.ts.map +1 -0
  220. package/src/interfaces/voting-consts.js +27 -0
  221. package/src/interfaces/voting-consts.js.map +1 -0
  222. package/src/interfaces/wallet-seed.d.ts +7 -0
  223. package/src/interfaces/wallet-seed.d.ts.map +1 -0
  224. package/src/interfaces/wallet-seed.js +3 -0
  225. package/src/interfaces/wallet-seed.js.map +1 -0
  226. package/src/interfaces/wrapped-key-consts.d.ts +7 -0
  227. package/src/interfaces/wrapped-key-consts.d.ts.map +1 -0
  228. package/src/interfaces/wrapped-key-consts.js +3 -0
  229. package/src/interfaces/wrapped-key-consts.js.map +1 -0
  230. package/src/isolated-private.d.ts +62 -0
  231. package/src/isolated-private.d.ts.map +1 -0
  232. package/src/isolated-private.js +139 -0
  233. package/src/isolated-private.js.map +1 -0
  234. package/src/isolated-public.d.ts +118 -0
  235. package/src/isolated-public.d.ts.map +1 -0
  236. package/src/isolated-public.js +317 -0
  237. package/src/isolated-public.js.map +1 -0
  238. package/src/lib/crypto-container.d.ts +13 -0
  239. package/src/lib/crypto-container.d.ts.map +1 -0
  240. package/src/lib/crypto-container.js +32 -0
  241. package/src/lib/crypto-container.js.map +1 -0
  242. package/src/lib/index.d.ts +4 -0
  243. package/src/lib/index.d.ts.map +1 -0
  244. package/src/lib/index.js +7 -0
  245. package/src/lib/index.js.map +1 -0
  246. package/src/lib/invariant-validator.d.ts +69 -0
  247. package/src/lib/invariant-validator.d.ts.map +1 -0
  248. package/src/lib/invariant-validator.js +98 -0
  249. package/src/lib/invariant-validator.js.map +1 -0
  250. package/src/lib/invariants/index.d.ts +8 -0
  251. package/src/lib/invariants/index.d.ts.map +1 -0
  252. package/src/lib/invariants/index.js +12 -0
  253. package/src/lib/invariants/index.js.map +1 -0
  254. package/src/lib/invariants/recipient-id-consistency.d.ts +41 -0
  255. package/src/lib/invariants/recipient-id-consistency.d.ts.map +1 -0
  256. package/src/lib/invariants/recipient-id-consistency.js +75 -0
  257. package/src/lib/invariants/recipient-id-consistency.js.map +1 -0
  258. package/src/member.d.ts +100 -0
  259. package/src/member.d.ts.map +1 -0
  260. package/src/member.js +345 -0
  261. package/src/member.js.map +1 -0
  262. package/src/services/aes-gcm.d.ts +66 -0
  263. package/src/services/aes-gcm.d.ts.map +1 -0
  264. package/src/services/aes-gcm.js +161 -0
  265. package/src/services/aes-gcm.js.map +1 -0
  266. package/src/services/chunk-processor.d.ts +15 -0
  267. package/src/services/chunk-processor.d.ts.map +1 -0
  268. package/src/services/chunk-processor.js +36 -0
  269. package/src/services/chunk-processor.js.map +1 -0
  270. package/src/services/ecies/crypto-core.d.ts +104 -0
  271. package/src/services/ecies/crypto-core.d.ts.map +1 -0
  272. package/src/services/ecies/crypto-core.js +234 -0
  273. package/src/services/ecies/crypto-core.js.map +1 -0
  274. package/src/services/ecies/file.d.ts +30 -0
  275. package/src/services/ecies/file.d.ts.map +1 -0
  276. package/src/services/ecies/file.js +112 -0
  277. package/src/services/ecies/file.js.map +1 -0
  278. package/src/services/ecies/index.d.ts +8 -0
  279. package/src/services/ecies/index.d.ts.map +1 -0
  280. package/src/services/ecies/index.js +11 -0
  281. package/src/services/ecies/index.js.map +1 -0
  282. package/src/services/ecies/multi-recipient.d.ts +84 -0
  283. package/src/services/ecies/multi-recipient.d.ts.map +1 -0
  284. package/src/services/ecies/multi-recipient.js +502 -0
  285. package/src/services/ecies/multi-recipient.js.map +1 -0
  286. package/src/services/ecies/service.d.ts +75 -0
  287. package/src/services/ecies/service.d.ts.map +1 -0
  288. package/src/services/ecies/service.js +152 -0
  289. package/src/services/ecies/service.js.map +1 -0
  290. package/src/services/ecies/signature.d.ts +38 -0
  291. package/src/services/ecies/signature.d.ts.map +1 -0
  292. package/src/services/ecies/signature.js +70 -0
  293. package/src/services/ecies/signature.js.map +1 -0
  294. package/src/services/ecies/single-recipient.d.ts +83 -0
  295. package/src/services/ecies/single-recipient.d.ts.map +1 -0
  296. package/src/services/ecies/single-recipient.js +452 -0
  297. package/src/services/ecies/single-recipient.js.map +1 -0
  298. package/src/services/ecies/utilities.d.ts +33 -0
  299. package/src/services/ecies/utilities.d.ts.map +1 -0
  300. package/src/services/ecies/utilities.js +91 -0
  301. package/src/services/ecies/utilities.js.map +1 -0
  302. package/src/services/encryption-stream.d.ts +33 -0
  303. package/src/services/encryption-stream.d.ts.map +1 -0
  304. package/src/services/encryption-stream.js +211 -0
  305. package/src/services/encryption-stream.js.map +1 -0
  306. package/src/services/index.d.ts +9 -0
  307. package/src/services/index.d.ts.map +1 -0
  308. package/src/services/index.js +14 -0
  309. package/src/services/index.js.map +1 -0
  310. package/src/services/multi-recipient-processor.d.ts +72 -0
  311. package/src/services/multi-recipient-processor.d.ts.map +1 -0
  312. package/src/services/multi-recipient-processor.js +325 -0
  313. package/src/services/multi-recipient-processor.js.map +1 -0
  314. package/src/services/pbkdf2.d.ts +105 -0
  315. package/src/services/pbkdf2.d.ts.map +1 -0
  316. package/src/services/pbkdf2.js +191 -0
  317. package/src/services/pbkdf2.js.map +1 -0
  318. package/src/services/progress-tracker.d.ts +14 -0
  319. package/src/services/progress-tracker.d.ts.map +1 -0
  320. package/src/services/progress-tracker.js +94 -0
  321. package/src/services/progress-tracker.js.map +1 -0
  322. package/src/services/voting.service.d.ts +262 -0
  323. package/src/services/voting.service.d.ts.map +1 -0
  324. package/src/services/voting.service.js +791 -0
  325. package/src/services/voting.service.js.map +1 -0
  326. package/src/test-mocks/index.d.ts +2 -0
  327. package/src/test-mocks/index.d.ts.map +1 -0
  328. package/src/test-mocks/index.js +5 -0
  329. package/src/test-mocks/index.js.map +1 -0
  330. package/src/test-mocks/mock-backend-member.d.ts +76 -0
  331. package/src/test-mocks/mock-backend-member.d.ts.map +1 -0
  332. package/src/test-mocks/mock-backend-member.js +139 -0
  333. package/src/test-mocks/mock-backend-member.js.map +1 -0
  334. package/src/testing.d.ts +2 -0
  335. package/src/testing.d.ts.map +1 -0
  336. package/src/testing.js +6 -0
  337. package/src/testing.js.map +1 -0
  338. package/src/types/id-guards.d.ts +39 -0
  339. package/src/types/id-guards.d.ts.map +1 -0
  340. package/src/types/id-guards.js +91 -0
  341. package/src/types/id-guards.js.map +1 -0
  342. package/src/types/index.d.ts +2 -0
  343. package/src/types/index.d.ts.map +1 -0
  344. package/src/types/index.js +5 -0
  345. package/src/types/index.js.map +1 -0
  346. package/src/types.d.ts +26 -0
  347. package/src/types.d.ts.map +1 -0
  348. package/src/types.js +6 -0
  349. package/src/types.js.map +1 -0
  350. package/src/utils.d.ts +11 -0
  351. package/src/utils.d.ts.map +1 -0
  352. package/src/utils.js +82 -0
  353. package/src/utils.js.map +1 -0
@@ -0,0 +1,452 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EciesSingleRecipientCore = void 0;
4
+ const crypto_1 = require("crypto");
5
+ const ecies_lib_1 = require("@digitaldefiance/ecies-lib");
6
+ const ecies_i18n_factory_1 = require("../../i18n/ecies-i18n-factory");
7
+ const crypto_core_1 = require("./crypto-core");
8
+ class EciesSingleRecipientCore {
9
+ cryptoCore;
10
+ config;
11
+ constructor(config) {
12
+ this.config = config;
13
+ this.cryptoCore = new crypto_core_1.EciesCryptoCore(config);
14
+ }
15
+ /**
16
+ * Get the size of the header for a given encryption type
17
+ * @param encryptionType The encryption type (single, simple, etc.)
18
+ * @returns
19
+ */
20
+ getHeaderSize(encryptionType) {
21
+ switch (encryptionType) {
22
+ case 'simple':
23
+ return this.cryptoCore.consts.SIMPLE.FIXED_OVERHEAD_SIZE;
24
+ case 'single':
25
+ return this.cryptoCore.consts.SINGLE.FIXED_OVERHEAD_SIZE;
26
+ default:
27
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEncryptionType);
28
+ }
29
+ }
30
+ /**
31
+ * Encrypt a message with a public key
32
+ * @param encryptSimple Whether to simple encrypt (without crc, length)
33
+ * @param receiverPublicKey The public key of the receiver
34
+ * @param message The message to encrypt
35
+ * @param preamble Optional preamble to prepend to the encrypted message
36
+ * @param options Optional encryption options
37
+ * @param options.recipientCount The number of recipients for multiple encryption mode
38
+ * @returns The encrypted message
39
+ */
40
+ encrypt(encryptSimple, receiverPublicKey, message, preamble = Buffer.alloc(0)) {
41
+ // Security fix 4: Message size validation
42
+ if (message.length === 0) {
43
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.CannotEncryptEmptyData);
44
+ }
45
+ if (message.length > 0x7fffffff) {
46
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.MessageTooLarge);
47
+ }
48
+ const encryptionType = encryptSimple
49
+ ? 'simple'
50
+ : 'single';
51
+ const encryptionTypeBuffer = Buffer.alloc(1);
52
+ encryptionTypeBuffer.writeUint8(ecies_lib_1.EciesEncryptionTypeMap[encryptionType]);
53
+ const versionBuffer = Buffer.alloc(1);
54
+ versionBuffer.writeUint8(ecies_lib_1.EciesVersionEnum.V1);
55
+ const cipherSuiteBuffer = Buffer.alloc(1);
56
+ cipherSuiteBuffer.writeUint8(ecies_lib_1.EciesCipherSuiteEnum.Secp256k1_Aes256Gcm_Sha256);
57
+ if (message.length > this.cryptoCore.consts.MAX_RAW_DATA_SIZE) {
58
+ const pluginEngine = (0, ecies_i18n_factory_1.getEciesPluginI18nEngine)();
59
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidDataLength, undefined, undefined, {
60
+ error: pluginEngine.translate(ecies_i18n_factory_1.NodeEciesComponentId, ecies_i18n_factory_1.NodeEciesStringKey.Error_MessageLengthExceedsMaximumAllowedSize),
61
+ maxLength: String(ecies_lib_1.UINT32_MAX),
62
+ messageLength: String(message.length),
63
+ });
64
+ }
65
+ // Generate ephemeral ECDH key pair
66
+ // Use cryptoCore to generate keys to ensure compatibility with computeSharedSecret
67
+ const ephemeralPrivateKey = this.cryptoCore.generatePrivateKey();
68
+ const ephemeralPublicKey = this.cryptoCore.getPublicKey(ephemeralPrivateKey);
69
+ // Compute shared secret
70
+ let sharedSecret;
71
+ try {
72
+ // Make sure we normalize the receiver's public key
73
+ const normalizedReceiverPublicKey = this.cryptoCore.normalizePublicKey(receiverPublicKey);
74
+ // Use cryptoCore to compute shared secret (handles compressed keys better)
75
+ sharedSecret = this.cryptoCore.computeSharedSecret(ephemeralPrivateKey, normalizedReceiverPublicKey);
76
+ }
77
+ catch (error) {
78
+ if (process.env.NODE_ENV !== 'test') {
79
+ console.error('[ERROR][encrypt] Failed to compute shared secret:', error);
80
+ }
81
+ if (error instanceof Error) {
82
+ if ('code' in error &&
83
+ error.code ===
84
+ 'ERR_CRYPTO_ECDH_INVALID_PUBLIC_KEY') {
85
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidRecipientPublicKey, undefined, undefined, {
86
+ nodeError: error.code,
87
+ });
88
+ }
89
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.SecretComputationFailed, undefined, undefined, {
90
+ error: error.message,
91
+ });
92
+ }
93
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.SecretComputationFailed);
94
+ }
95
+ // Get the ephemeral public key and ensure it has the 0x04 prefix
96
+ // ephemeralPublicKey is already set above and is compressed.
97
+ // Generate random IV
98
+ const iv = (0, crypto_1.randomBytes)(this.cryptoCore.consts.IV_SIZE);
99
+ // Use HKDF to derive the key
100
+ const symKey = this.cryptoCore.deriveSharedKey(sharedSecret, Buffer.alloc(0), // No salt
101
+ Buffer.from('ecies-v2-key-derivation'), // Info
102
+ this.cryptoCore.consts.SYMMETRIC.KEY_SIZE);
103
+ // Create cipher with the derived symmetric key
104
+ const cipher = (0, crypto_1.createCipheriv)(this.cryptoCore.consts.SYMMETRIC_ALGORITHM_CONFIGURATION, symKey, iv);
105
+ // Ensure auto padding is enabled
106
+ cipher.setAutoPadding(true);
107
+ // Construct AAD
108
+ // AAD = Preamble + Version + CipherSuite + EncryptionType + EphemeralPublicKey
109
+ // We don't include IV in AAD as it's already authenticated by GCM mechanism
110
+ // We don't include Length in AAD because it's variable/optional and might complicate things?
111
+ // Actually, let's include what we can.
112
+ // For now, let's stick to the metadata that identifies the context.
113
+ const aad = Buffer.concat([
114
+ preamble,
115
+ versionBuffer,
116
+ cipherSuiteBuffer,
117
+ encryptionTypeBuffer,
118
+ ephemeralPublicKey,
119
+ ]);
120
+ cipher.setAAD(aad);
121
+ // Encrypt the message
122
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment
123
+ let encrypted = cipher.update(message);
124
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
125
+ encrypted = Buffer.concat([encrypted, cipher.final()]);
126
+ // Get and explicitly set the authentication tag to max tag length for consistency
127
+ const authTag = cipher.getAuthTag();
128
+ // Add a length prefix to the encrypted data to ensure we can extract the exact number of bytes during decryption
129
+ const lengthBuffer = encryptionType === 'simple' ? Buffer.alloc(0) : Buffer.alloc(ecies_lib_1.UINT64_SIZE);
130
+ if (encryptionType === 'single') {
131
+ lengthBuffer.writeBigUInt64BE(BigInt(encrypted.length));
132
+ }
133
+ // Security fix 5: Encrypted size validation
134
+ const maxExpectedSize = message.length + 1024;
135
+ if (encrypted.length > maxExpectedSize) {
136
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.EncryptedSizeExceedsExpected);
137
+ }
138
+ // Format: [optional preamble] | version (1) | cipherSuite (1) | type (1) | ephemeralPublicKey (65) | iv (16) | authTag (16) | length (8) | encryptedData
139
+ return Buffer.concat([
140
+ preamble,
141
+ versionBuffer,
142
+ cipherSuiteBuffer,
143
+ encryptionTypeBuffer,
144
+ ephemeralPublicKey,
145
+ iv,
146
+ authTag,
147
+ lengthBuffer,
148
+ encrypted,
149
+ ]);
150
+ }
151
+ /**
152
+ * Parse the header from encrypted data
153
+ * @param encryptionType The type of encryption (single, simple, etc.) or undefined if not known
154
+ * @param data The encrypted data
155
+ * @param preambleSize The size of the preamble, if any
156
+ * @param options Optional parsing options
157
+ * @param options.dataLength The expected length of the data
158
+ * @returns The parsed header components
159
+ */
160
+ parseEncryptedMessage(encryptionType, data, preambleSize = 0, options) {
161
+ let offset = 0;
162
+ const preamble = data.subarray(0, preambleSize);
163
+ offset += preambleSize;
164
+ // Read Version
165
+ const version = data.readUInt8(offset);
166
+ offset += this.cryptoCore.consts.VERSION_SIZE;
167
+ if (version !== ecies_lib_1.EciesVersionEnum.V1) {
168
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidVersion, undefined, undefined, { version: String(version) });
169
+ }
170
+ // Read CipherSuite
171
+ const cipherSuite = data.readUInt8(offset);
172
+ offset += this.cryptoCore.consts.CIPHER_SUITE_SIZE;
173
+ if (cipherSuite !== ecies_lib_1.EciesCipherSuiteEnum.Secp256k1_Aes256Gcm_Sha256) {
174
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidCipherSuite, undefined, undefined, { cipherSuite: String(cipherSuite) });
175
+ }
176
+ // read the encryption type from the first byte after the preamble and version/suite
177
+ const actualEncryptionTypeEnum = (0, ecies_lib_1.ensureEciesEncryptionTypeEnum)(data.readUInt8(offset));
178
+ // if a type is provided, ensure it matches the actual type
179
+ if (encryptionType !== undefined &&
180
+ actualEncryptionTypeEnum !== encryptionType) {
181
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEncryptionType, undefined, undefined, {
182
+ expected: (0, ecies_lib_1.encryptionTypeToString)(encryptionType),
183
+ actual: (0, ecies_lib_1.encryptionTypeToString)(actualEncryptionTypeEnum),
184
+ });
185
+ }
186
+ if (actualEncryptionTypeEnum === ecies_lib_1.EciesEncryptionTypeEnum.Multiple) {
187
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEncryptionType, undefined, undefined, {
188
+ expected: 'single or simple',
189
+ actual: (0, ecies_lib_1.encryptionTypeToString)(actualEncryptionTypeEnum),
190
+ });
191
+ }
192
+ const includeLengthAndCrc = actualEncryptionTypeEnum === ecies_lib_1.EciesEncryptionTypeEnum.Single;
193
+ // Security fix 6: Minimum encrypted data size
194
+ const minSize = includeLengthAndCrc
195
+ ? this.cryptoCore.consts.SINGLE.FIXED_OVERHEAD_SIZE
196
+ : this.cryptoCore.consts.SIMPLE.FIXED_OVERHEAD_SIZE;
197
+ if (data.length < minSize) {
198
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEncryptedDataLength);
199
+ }
200
+ // skip the already-read encryption type
201
+ offset += 1;
202
+ // Extract components from the header
203
+ const ephemeralPublicKey = data.subarray(offset, offset + this.cryptoCore.consts.PUBLIC_KEY_LENGTH);
204
+ offset += this.cryptoCore.consts.PUBLIC_KEY_LENGTH;
205
+ // Make sure we normalize the ephemeral public key
206
+ const normalizedKey = this.cryptoCore.normalizePublicKey(ephemeralPublicKey);
207
+ const iv = data.subarray(offset, offset + this.cryptoCore.consts.IV_SIZE);
208
+ offset += this.cryptoCore.consts.IV_SIZE;
209
+ const authTag = data.subarray(offset, offset + this.cryptoCore.consts.AUTH_TAG_SIZE);
210
+ offset += this.cryptoCore.consts.AUTH_TAG_SIZE;
211
+ // Extract the length prefix (4 bytes) after the header components
212
+ const dataLengthBuffer = includeLengthAndCrc
213
+ ? data.subarray(offset, offset + this.cryptoCore.consts.SINGLE.DATA_LENGTH_SIZE)
214
+ : Buffer.alloc(0);
215
+ if (includeLengthAndCrc) {
216
+ offset += this.cryptoCore.consts.SINGLE.DATA_LENGTH_SIZE;
217
+ }
218
+ const dataLength = includeLengthAndCrc
219
+ ? Number(dataLengthBuffer.readBigUInt64BE(0))
220
+ : (options?.dataLength ?? -1);
221
+ if (includeLengthAndCrc &&
222
+ options?.dataLength !== undefined &&
223
+ dataLength !== options.dataLength) {
224
+ const pluginEngine = (0, ecies_i18n_factory_1.getEciesPluginI18nEngine)();
225
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEncryptedDataLength, undefined, undefined, {
226
+ error: pluginEngine.translate(ecies_i18n_factory_1.NodeEciesComponentId, ecies_i18n_factory_1.NodeEciesStringKey.Error_EncryptedDataLengthMismatch),
227
+ expected: String(dataLength),
228
+ actual: String(options.dataLength),
229
+ });
230
+ }
231
+ // No CRC in Single encryption (AES-GCM provides authentication)
232
+ const encryptedData = dataLength > 0
233
+ ? data.subarray(offset, offset + dataLength)
234
+ : data.subarray(offset);
235
+ if (includeLengthAndCrc) {
236
+ offset += dataLength;
237
+ }
238
+ if (includeLengthAndCrc && encryptedData.length !== dataLength) {
239
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEncryptedDataLength, undefined, undefined, {
240
+ expected: String(dataLength),
241
+ actual: String(encryptedData.length),
242
+ });
243
+ }
244
+ const remainder = includeLengthAndCrc
245
+ ? data.subarray(offset)
246
+ : Buffer.alloc(0);
247
+ // No CRC validation needed (AES-GCM provides authentication)
248
+ // Security fix 7: Component extraction validation
249
+ if (normalizedKey.length !== this.cryptoCore.consts.PUBLIC_KEY_LENGTH) {
250
+ const pluginEngine = (0, ecies_i18n_factory_1.getEciesPluginI18nEngine)();
251
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEphemeralPublicKey, undefined, undefined, {
252
+ error: pluginEngine.translate(ecies_i18n_factory_1.NodeEciesComponentId, ecies_i18n_factory_1.NodeEciesStringKey.Error_EphemeralPublicKeyLengthMismatch),
253
+ expected: String(this.cryptoCore.consts.PUBLIC_KEY_LENGTH),
254
+ actual: String(normalizedKey.length),
255
+ });
256
+ }
257
+ if (iv.length !== this.cryptoCore.consts.IV_SIZE) {
258
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidIVLength, undefined, undefined, {
259
+ expected: String(this.cryptoCore.consts.IV_SIZE),
260
+ actual: String(iv.length),
261
+ });
262
+ }
263
+ if (authTag.length !== this.cryptoCore.consts.AUTH_TAG_SIZE) {
264
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidAuthTagLength, undefined, undefined, {
265
+ expected: String(this.cryptoCore.consts.AUTH_TAG_SIZE),
266
+ actual: String(authTag.length),
267
+ });
268
+ }
269
+ return {
270
+ header: {
271
+ preamble,
272
+ encryptionType: actualEncryptionTypeEnum,
273
+ ephemeralPublicKey: normalizedKey,
274
+ iv,
275
+ authTag,
276
+ dataLength,
277
+ headerSize: includeLengthAndCrc
278
+ ? this.cryptoCore.consts.SINGLE.FIXED_OVERHEAD_SIZE
279
+ : this.cryptoCore.consts.SIMPLE.FIXED_OVERHEAD_SIZE,
280
+ },
281
+ data: encryptedData,
282
+ remainder,
283
+ };
284
+ }
285
+ /**
286
+ * Decrypts data encrypted with ECIES using a header
287
+ * This method maintains backward compatibility with the original implementation
288
+ * by returning just the Buffer. For detailed information, use decryptSingleWithHeaderEx
289
+ * @param encryptionType The type of encryption (single, simple, etc.)
290
+ * @param privateKey The private key to decrypt the data
291
+ * @param encryptedData The data to decrypt
292
+ * @param preambleSize The size of the preamble, if any
293
+ * @param options Optional decryption options
294
+ * @param options.dataLength The expected length of the data
295
+ * @returns The decrypted data buffer
296
+ */
297
+ decryptWithHeader(encryptionType, privateKey, encryptedData, preambleSize = 0, options) {
298
+ try {
299
+ // Call the extended version and return only the decrypted buffer for backward compatibility
300
+ const result = this.decryptWithHeaderEx(encryptionType, privateKey, encryptedData, preambleSize, options);
301
+ return result.decrypted;
302
+ }
303
+ catch (error) {
304
+ if (error instanceof ecies_lib_1.ECIESError) {
305
+ throw error;
306
+ }
307
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.DecryptionFailed, undefined, undefined, {
308
+ error: error instanceof Error ? error.message : String(error),
309
+ });
310
+ }
311
+ }
312
+ /**
313
+ * Extended version of decryptSingleWithHeader that provides more detailed information
314
+ * @param encryptionType The type of encryption (single, simple, etc.)
315
+ * @param privateKey The private key to decrypt the data
316
+ * @param encryptedData The data to decrypt
317
+ * @param preambleSize The size of the preamble, if any
318
+ * @param options Optional decryption options
319
+ * @param options.dataLength The expected length of the data
320
+ * @returns The decrypted data and the number of bytes consumed from the input buffer
321
+ */
322
+ decryptWithHeaderEx(encryptionType, privateKey, encryptedData, preambleSize = 0, options) {
323
+ try {
324
+ const { data, header } = this.parseEncryptedMessage(encryptionType, encryptedData, preambleSize, options);
325
+ // Normalize the public key (ensuring 0x04 prefix)
326
+ const normalizedKey = this.cryptoCore.normalizePublicKey(header.ephemeralPublicKey);
327
+ // Construct AAD
328
+ const versionBuffer = Buffer.alloc(1);
329
+ versionBuffer.writeUint8(ecies_lib_1.EciesVersionEnum.V1);
330
+ const cipherSuiteBuffer = Buffer.alloc(1);
331
+ cipherSuiteBuffer.writeUint8(ecies_lib_1.EciesCipherSuiteEnum.Secp256k1_Aes256Gcm_Sha256);
332
+ const encryptionTypeBuffer = Buffer.alloc(1);
333
+ encryptionTypeBuffer.writeUint8(header.encryptionType);
334
+ const aad = Buffer.concat([
335
+ header.preamble ?? Buffer.alloc(preambleSize),
336
+ versionBuffer,
337
+ cipherSuiteBuffer,
338
+ encryptionTypeBuffer,
339
+ normalizedKey,
340
+ ]);
341
+ // Decrypt using components with the normalized key
342
+ const decrypted = this.decryptWithComponents(privateKey, normalizedKey, header.iv, header.authTag, data, aad);
343
+ return {
344
+ decrypted,
345
+ consumedBytes: header.dataLength + header.headerSize,
346
+ };
347
+ }
348
+ catch (error) {
349
+ if (error instanceof ecies_lib_1.ECIESError) {
350
+ throw error;
351
+ }
352
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.DecryptionFailed, undefined, undefined, {
353
+ error: error instanceof Error ? error.message : String(error),
354
+ });
355
+ }
356
+ }
357
+ /**
358
+ * Decrypts data encrypted with ECIES using components
359
+ * @param privateKey The private key to decrypt the data
360
+ * @param ephemeralPublicKey The ephemeral public key used to encrypt the data
361
+ * @param iv The initialization vector used to encrypt the data
362
+ * @param authTag The authentication tag used to encrypt the data
363
+ * @param encrypted The encrypted data
364
+ * @returns The decrypted data
365
+ */
366
+ decryptWithComponents(privateKey, ephemeralPublicKey, iv, authTag, encrypted, aad) {
367
+ try {
368
+ // Ensure the ephemeral public key has the correct format
369
+ const normalizedEphemeralKey = this.cryptoCore.normalizePublicKey(ephemeralPublicKey);
370
+ // Use cryptoCore to compute shared secret (handles compressed keys better)
371
+ let sharedSecret;
372
+ try {
373
+ sharedSecret = this.cryptoCore.computeSharedSecret(privateKey, normalizedEphemeralKey);
374
+ }
375
+ catch (err) {
376
+ if (process.env.NODE_ENV !== 'test') {
377
+ console.error('[ERROR][decrypt] Failed to compute shared secret:', err);
378
+ }
379
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.DecryptionFailed, undefined, undefined, {
380
+ originalError: err instanceof Error ? err.message : String(err),
381
+ stage: 'shared_secret_computation',
382
+ });
383
+ }
384
+ // Use HKDF to derive the key
385
+ const symKey = this.cryptoCore.deriveSharedKey(sharedSecret, Buffer.alloc(0), // No salt
386
+ Buffer.from('ecies-v2-key-derivation'), // Info
387
+ this.cryptoCore.consts.SYMMETRIC.KEY_SIZE);
388
+ // Create decipher with shared secret-derived key
389
+ const decipher = (0, crypto_1.createDecipheriv)(this.cryptoCore.consts.SYMMETRIC_ALGORITHM_CONFIGURATION, symKey, iv);
390
+ // Validate the tag and IV
391
+ if (authTag.length !== this.cryptoCore.consts.AUTH_TAG_SIZE) {
392
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.DecryptionFailed, undefined, undefined, {
393
+ expected: String(this.cryptoCore.consts.AUTH_TAG_SIZE),
394
+ actual: String(authTag.length),
395
+ stage: 'auth_tag_validation',
396
+ });
397
+ }
398
+ if (iv.length !== this.cryptoCore.consts.IV_SIZE) {
399
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.DecryptionFailed, undefined, undefined, {
400
+ expected: String(this.cryptoCore.consts.IV_SIZE),
401
+ actual: String(iv.length),
402
+ stage: 'iv_validation',
403
+ });
404
+ }
405
+ // Set the authentication tag for GCM mode
406
+ decipher.setAuthTag(authTag);
407
+ if (aad) {
408
+ decipher.setAAD(aad);
409
+ }
410
+ // Decrypt the data
411
+ try {
412
+ // Handle edge case where encrypted data might be empty or malformed
413
+ const pluginEngine = (0, ecies_i18n_factory_1.getEciesPluginI18nEngine)();
414
+ if (encrypted.length === 0) {
415
+ throw new Error(pluginEngine.translate(ecies_i18n_factory_1.NodeEciesComponentId, ecies_i18n_factory_1.NodeEciesStringKey.Error_EncryptedDataIsEmpty));
416
+ }
417
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment
418
+ const firstPart = decipher.update(encrypted);
419
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment
420
+ const finalPart = decipher.final();
421
+ const result = Buffer.concat([firstPart, finalPart]);
422
+ // Security fix 8: Decrypted data validation
423
+ if (result.length === 0) {
424
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.DecryptionFailed);
425
+ }
426
+ return result;
427
+ }
428
+ catch (err) {
429
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.DecryptionFailed, undefined, undefined, {
430
+ error: err instanceof Error ? err.message : String(err),
431
+ stage: 'decipher_operation',
432
+ });
433
+ }
434
+ }
435
+ catch (error) {
436
+ if (error instanceof ecies_lib_1.ECIESError) {
437
+ throw error;
438
+ }
439
+ // Wrap non-EciesError in an EciesError
440
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.DecryptionFailed, undefined, undefined, {
441
+ error: error instanceof Error ? error.message : String(error),
442
+ privateKeyLength: String(privateKey.length),
443
+ ephemeralPublicKeyLength: String(ephemeralPublicKey.length),
444
+ ivLength: String(iv.length),
445
+ authTagLength: String(authTag.length),
446
+ encryptedLength: String(encrypted.length),
447
+ });
448
+ }
449
+ }
450
+ }
451
+ exports.EciesSingleRecipientCore = EciesSingleRecipientCore;
452
+ //# sourceMappingURL=single-recipient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"single-recipient.js","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-node-ecies-lib/src/services/ecies/single-recipient.ts"],"names":[],"mappings":";;;AAAA,mCAAuE;AAEvE,0DAaoC;AAEpC,sEAIuC;AAKvC,+CAAgD;AAEhD,MAAa,wBAAwB;IAChB,UAAU,CAAkB;IAC5B,MAAM,CAAe;IAExC,YAAY,MAAoB;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,IAAI,6BAAe,CAAC,MAAM,CAAC,CAAC;IAChD,CAAC;IAED;;;;OAIG;IACI,aAAa,CAAC,cAAmC;QACtD,QAAQ,cAAc,EAAE,CAAC;YACvB,KAAK,QAAQ;gBACX,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC;YAC3D,KAAK,QAAQ;gBACX,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC;YAC3D;gBACE,MAAM,IAAI,sBAAU,CAAC,8BAAkB,CAAC,qBAAqB,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;IAED;;;;;;;;;OASG;IACI,OAAO,CACZ,aAAsB,EACtB,iBAAyB,EACzB,OAAe,EACf,WAAmB,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAElC,0CAA0C;QAC1C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,sBAAU,CAAC,8BAAkB,CAAC,sBAAsB,CAAC,CAAC;QAClE,CAAC;QACD,IAAI,OAAO,CAAC,MAAM,GAAG,UAAU,EAAE,CAAC;YAChC,MAAM,IAAI,sBAAU,CAAC,8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,CAAC;IACH,CAAC;CACF;AAntBD,4DAmtBC"}
@@ -0,0 +1,33 @@
1
+ import { EciesEncryptionType, IConstants as IBaseConstants } from '@digitaldefiance/ecies-lib';
2
+ /**
3
+ * Utility functions for ECIES operations
4
+ */
5
+ export declare class EciesUtilities {
6
+ /**
7
+ * Computes the encrypted length from the data length.
8
+ * @param dataLength - The length of the data.
9
+ * @param encryptionMode - The encryption mode (simple, single, multiple).
10
+ * @param recipientCount - The number of recipients for multiple encryption mode.
11
+ * @param constants - The constants to use for calculations.
12
+ * @returns The encrypted length details.
13
+ */
14
+ computeEncryptedLengthFromDataLength(dataLength: number, encryptionMode: EciesEncryptionType, recipientCount?: number, constants?: IBaseConstants): number;
15
+ /**
16
+ * Calculates the overhead for multiple recipient encryption.
17
+ * This is a pure calculation that doesn't require service instantiation.
18
+ * Matches the logic in EciesMultiRecipient.calculateECIESMultipleRecipientOverhead.
19
+ * @param recipientCount - The number of recipients.
20
+ * @param includeMessageOverhead - Whether to include message overhead.
21
+ * @param eciesConstants - The ECIES constants to use.
22
+ * @returns The overhead in bytes.
23
+ */
24
+ private calculateMultipleRecipientOverhead;
25
+ /**
26
+ * Computes the decrypted length from the encrypted data length.
27
+ * @param encryptedDataLength - The length of the encrypted data.
28
+ * @param padding - Optional padding value.
29
+ * @returns The decrypted length.
30
+ */
31
+ computeDecryptedLengthFromEncryptedDataLength(encryptedDataLength: number, padding?: number, constants?: IBaseConstants): number;
32
+ }
33
+ //# sourceMappingURL=utilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-node-ecies-lib/src/services/ecies/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EAGnB,UAAU,IAAI,cAAc,EAE7B,MAAM,4BAA4B,CAAC;AAIpC;;GAEG;AACH,qBAAa,cAAc;IACzB;;;;;;;OAOG;IACI,oCAAoC,CACzC,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,mBAAmB,EACnC,cAAc,CAAC,EAAE,MAAM,EACvB,SAAS,GAAE,cAA8C,GACxD,MAAM;IA4BT;;;;;;;;OAQG;IACH,OAAO,CAAC,kCAAkC;IA4B1C;;;;;OAKG;IACI,6CAA6C,CAClD,mBAAmB,EAAE,MAAM,EAC3B,OAAO,CAAC,EAAE,MAAM,EAChB,SAAS,GAAE,cAA8C,GACxD,MAAM;CA0BV"}
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EciesUtilities = void 0;
4
+ const ecies_lib_1 = require("@digitaldefiance/ecies-lib");
5
+ const constants_1 = require("../../constants");
6
+ /**
7
+ * Utility functions for ECIES operations
8
+ */
9
+ class EciesUtilities {
10
+ /**
11
+ * Computes the encrypted length from the data length.
12
+ * @param dataLength - The length of the data.
13
+ * @param encryptionMode - The encryption mode (simple, single, multiple).
14
+ * @param recipientCount - The number of recipients for multiple encryption mode.
15
+ * @param constants - The constants to use for calculations.
16
+ * @returns The encrypted length details.
17
+ */
18
+ computeEncryptedLengthFromDataLength(dataLength, encryptionMode, recipientCount, constants = (0, constants_1.getNodeRuntimeConfiguration)()) {
19
+ if (dataLength < 0) {
20
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidDataLength);
21
+ }
22
+ const eciesDefaults = constants.ECIES;
23
+ switch (encryptionMode) {
24
+ case 'simple':
25
+ // type (1) + public key (65) + IV (16) + auth tag (16) = 98
26
+ return dataLength + eciesDefaults.SIMPLE.FIXED_OVERHEAD_SIZE;
27
+ case 'single':
28
+ // type (1) + public key (65) + IV (16) + auth tag (16) + data length (4) + crc16 (2) = 104
29
+ return dataLength + eciesDefaults.SINGLE.FIXED_OVERHEAD_SIZE;
30
+ case 'multiple':
31
+ // Calculate multiple recipient overhead without instantiating service
32
+ return (dataLength +
33
+ this.calculateMultipleRecipientOverhead(recipientCount ?? 1, true, eciesDefaults));
34
+ default:
35
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEncryptionType);
36
+ }
37
+ }
38
+ /**
39
+ * Calculates the overhead for multiple recipient encryption.
40
+ * This is a pure calculation that doesn't require service instantiation.
41
+ * Matches the logic in EciesMultiRecipient.calculateECIESMultipleRecipientOverhead.
42
+ * @param recipientCount - The number of recipients.
43
+ * @param includeMessageOverhead - Whether to include message overhead.
44
+ * @param eciesConstants - The ECIES constants to use.
45
+ * @returns The overhead in bytes.
46
+ */
47
+ calculateMultipleRecipientOverhead(recipientCount, includeMessageOverhead, eciesConstants) {
48
+ if (recipientCount < 1) {
49
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidRecipientCount);
50
+ }
51
+ // Calculate encrypted keys size (default assumption: all keys use Simple encryption type)
52
+ const encryptedKeysSize = recipientCount * eciesConstants.MULTIPLE.ENCRYPTED_KEY_SIZE;
53
+ // Base overhead calculation
54
+ const baseOverhead = eciesConstants.VERSION_SIZE +
55
+ eciesConstants.CIPHER_SUITE_SIZE +
56
+ eciesConstants.ENCRYPTION_TYPE_SIZE +
57
+ eciesConstants.MULTIPLE.DATA_LENGTH_SIZE +
58
+ eciesConstants.MULTIPLE.RECIPIENT_COUNT_SIZE +
59
+ recipientCount * eciesConstants.MULTIPLE.RECIPIENT_ID_SIZE + // recipient ids (dynamic based on ID provider)
60
+ encryptedKeysSize; // actual encrypted keys size
61
+ return includeMessageOverhead
62
+ ? baseOverhead + eciesConstants.MULTIPLE.FIXED_OVERHEAD_SIZE
63
+ : baseOverhead;
64
+ }
65
+ /**
66
+ * Computes the decrypted length from the encrypted data length.
67
+ * @param encryptedDataLength - The length of the encrypted data.
68
+ * @param padding - Optional padding value.
69
+ * @returns The decrypted length.
70
+ */
71
+ computeDecryptedLengthFromEncryptedDataLength(encryptedDataLength, padding, constants = (0, constants_1.getNodeRuntimeConfiguration)()) {
72
+ if (encryptedDataLength < 0) {
73
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEncryptedDataLength);
74
+ }
75
+ const { ECIES: eciesDefaults } = constants;
76
+ const overhead = eciesDefaults.SINGLE.FIXED_OVERHEAD_SIZE;
77
+ const actualPadding = padding !== undefined ? padding : 0;
78
+ const decryptedLength = encryptedDataLength - overhead - actualPadding;
79
+ if (decryptedLength < 0) {
80
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEncryptedDataLength, undefined, undefined, {
81
+ encryptedDataLength: String(encryptedDataLength),
82
+ overhead: String(overhead),
83
+ padding: String(actualPadding),
84
+ computedLength: String(decryptedLength),
85
+ });
86
+ }
87
+ return decryptedLength;
88
+ }
89
+ }
90
+ exports.EciesUtilities = EciesUtilities;
91
+ //# sourceMappingURL=utilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-node-ecies-lib/src/services/ecies/utilities.ts"],"names":[],"mappings":";;;AAAA,0DAMoC;AAEpC,+CAA8D;AAE9D;;GAEG;AACH,MAAa,cAAc;IACzB;;;;;;;OAOG;IACI,oCAAoC,CACzC,UAAkB,EAClB,cAAmC,EACnC,cAAuB,EACvB,YAA4B,IAAA,uCAA2B,GAAE;QAEzD,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;YACnB,MAAM,IAAI,sBAAU,CAAC,8BAAkB,CAAC,iBAAiB,CAAC,CAAC;QAC7D,CAAC;QACD,MAAM,aAAa,GAAoB,SAAS,CAAC,KAAK,CAAC;QAEvD,QAAQ,cAAc,EAAE,CAAC;YACvB,KAAK,QAAQ;gBACX,4DAA4D;gBAC5D,OAAO,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,mBAAmB,CAAC;YAC/D,KAAK,QAAQ;gBACX,2FAA2F;gBAC3F,OAAO,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,mBAAmB,CAAC;YAC/D,KAAK,UAAU;gBACb,sEAAsE;gB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C,MAAM,CAAC,mBAAmB,CAAC;QAC1D,MAAM,aAAa,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QAE1D,MAAM,eAAe,GAAG,mBAAmB,GAAG,QAAQ,GAAG,aAAa,CAAC;QACvE,IAAI,eAAe,GAAG,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,sBAAU,CAClB,8BAAkB,CAAC,0BAA0B,EAC7C,SAAS,EACT,SAAS,EACT;gBACE,mBAAmB,EAAE,MAAM,CAAC,mBAAmB,CAAC;gBAChD,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;gBAC1B,OAAO,EAAE,MAAM,CAAC,aAAa,CAAC;gBAC9B,cAAc,EAAE,MAAM,CAAC,eAAe,CAAC;aACxC,CACF,CAAC;QACJ,CAAC;QAED,OAAO,eAAe,CAAC;IACzB,CAAC;CACF;AAnHD,wCAmHC"}
@@ -0,0 +1,33 @@
1
+ import { IEncryptedChunk } from '../interfaces/encrypted-chunk';
2
+ import { IMultiRecipientChunk } from '../interfaces/multi-recipient-chunk';
3
+ import { IStreamConfig } from '../interfaces/stream-config';
4
+ import { IStreamProgress } from '../interfaces/stream-progress';
5
+ import { ChunkProcessor } from './chunk-processor';
6
+ import { ECIESService } from './ecies/service';
7
+ import { MultiRecipientProcessor } from './multi-recipient-processor';
8
+ export interface IEncryptStreamOptions {
9
+ chunkSize?: number;
10
+ signal?: AbortSignal;
11
+ includeChecksums?: boolean;
12
+ onProgress?: (progress: IStreamProgress) => void;
13
+ }
14
+ export interface IDecryptStreamOptions {
15
+ signal?: AbortSignal;
16
+ onProgress?: (progress: IStreamProgress) => void;
17
+ }
18
+ export declare class EncryptionStream {
19
+ private readonly ecies;
20
+ private readonly config;
21
+ private readonly processor;
22
+ private readonly multiRecipientProcessor;
23
+ private readonly engine;
24
+ constructor(ecies: ECIESService, config?: IStreamConfig, processor?: ChunkProcessor, multiRecipientProcessor?: MultiRecipientProcessor);
25
+ encryptStream(source: AsyncIterable<Buffer>, publicKey: Buffer, options?: IEncryptStreamOptions): AsyncGenerator<IEncryptedChunk, void, unknown>;
26
+ encryptStreamMultiple(source: AsyncIterable<Buffer>, recipients: Array<{
27
+ id: Buffer;
28
+ publicKey: Buffer;
29
+ }>, options?: IEncryptStreamOptions): AsyncGenerator<IMultiRecipientChunk, void, unknown>;
30
+ decryptStream(source: AsyncIterable<Buffer>, privateKey: Buffer, options?: IDecryptStreamOptions): AsyncGenerator<Buffer, void, unknown>;
31
+ decryptStreamMultiple(source: AsyncIterable<Buffer>, recipientId: Buffer, privateKey: Buffer, options?: IDecryptStreamOptions): AsyncGenerator<Buffer, void, unknown>;
32
+ }
33
+ //# sourceMappingURL=encryption-stream.d.ts.map