@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,502 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EciesMultiRecipient = void 0;
4
+ const crypto_1 = require("crypto");
5
+ const ecies_lib_1 = require("@digitaldefiance/ecies-lib");
6
+ const single_recipient_1 = require("./single-recipient");
7
+ /**
8
+ * Multiple recipient encryption/decryption functions for ECIES
9
+ */
10
+ class EciesMultiRecipient {
11
+ cryptoCore;
12
+ singleRecipientCore;
13
+ constructor(cryptoCore) {
14
+ this.cryptoCore = cryptoCore;
15
+ this.singleRecipientCore = new single_recipient_1.EciesSingleRecipientCore(cryptoCore.config);
16
+ }
17
+ /**
18
+ * Get the size of the header for a given encryption type
19
+ * @param recipientCount The number of recipients
20
+ * @returns
21
+ */
22
+ getHeaderSize(recipientCount) {
23
+ return (this.cryptoCore.consts.VERSION_SIZE +
24
+ this.cryptoCore.consts.CIPHER_SUITE_SIZE +
25
+ this.cryptoCore.consts.ENCRYPTION_TYPE_SIZE +
26
+ this.cryptoCore.consts.PUBLIC_KEY_LENGTH + // Shared ephemeral public key
27
+ this.cryptoCore.consts.MULTIPLE.DATA_LENGTH_SIZE +
28
+ this.cryptoCore.consts.MULTIPLE.RECIPIENT_COUNT_SIZE +
29
+ recipientCount * this.cryptoCore.consts.MULTIPLE.RECIPIENT_ID_SIZE +
30
+ recipientCount * this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE);
31
+ }
32
+ /**
33
+ * Encrypt a message symmetric key with a public key
34
+ * @param receiverPublicKey The public key of the receiver
35
+ * @param messageSymmetricKey The message to encrypt
36
+ * @param ephemeralPrivateKey The ephemeral private key to use for encryption
37
+ * @param aad Additional Authenticated Data (optional)
38
+ * @returns The encrypted message
39
+ */
40
+ encryptKey(receiverPublicKey, messageSymmetricKey, ephemeralPrivateKey, aad) {
41
+ // Compute shared secret
42
+ let sharedSecret;
43
+ try {
44
+ // Make sure we normalize the receiver's public key
45
+ const normalizedReceiverPublicKey = this.cryptoCore.normalizePublicKey(receiverPublicKey);
46
+ // Create ECDH instance with the ephemeral private key
47
+ const ecdh = (0, crypto_1.createECDH)(this.cryptoCore.config.curveName);
48
+ ecdh.setPrivateKey(ephemeralPrivateKey);
49
+ // Ensure we're using the properly formatted public key (with 0x04 prefix)
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, undefined, undefined, {
58
+ nodeError: error.code,
59
+ });
60
+ }
61
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.SecretComputationFailed, undefined, undefined, {
62
+ error: error.message,
63
+ });
64
+ }
65
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.SecretComputationFailed);
66
+ }
67
+ // Use HKDF to derive the key
68
+ const symKey = this.cryptoCore.deriveSharedKey(sharedSecret, Buffer.alloc(0), // No salt
69
+ Buffer.from('ecies-v2-key-derivation'), // Info
70
+ this.cryptoCore.consts.SYMMETRIC.KEY_SIZE);
71
+ const iv = (0, crypto_1.randomBytes)(this.cryptoCore.consts.IV_SIZE);
72
+ // Create cipher with the derived symmetric key
73
+ const cipher = (0, crypto_1.createCipheriv)(this.cryptoCore.consts.SYMMETRIC_ALGORITHM_CONFIGURATION, symKey, iv);
74
+ // Ensure auto padding is enabled
75
+ cipher.setAutoPadding(true);
76
+ // Set AAD if provided
77
+ if (aad) {
78
+ cipher.setAAD(aad);
79
+ }
80
+ // Encrypt the message
81
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment
82
+ let encrypted = cipher.update(messageSymmetricKey);
83
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
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: iv (16) | authTag (16) | encryptedData (32)
88
+ // Note: Ephemeral public key is now in the main header, not per-recipient
89
+ return Buffer.concat([iv, authTag, encrypted]);
90
+ }
91
+ /**
92
+ * Decrypts symmetric key encrypted with ECIES using a header
93
+ * @param privateKey The private key to decrypt the data
94
+ * @param encryptedKey The data to decrypt
95
+ * @param ephemeralPublicKey The ephemeral public key from the header
96
+ * @param aad Additional Authenticated Data (optional)
97
+ * @returns The decrypted data buffer
98
+ */
99
+ decryptKey(privateKey, encryptedKey, ephemeralPublicKey, aad) {
100
+ if (encryptedKey.length !== this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE) {
101
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEncryptedKeyLength, undefined, undefined, {
102
+ expected: String(this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE),
103
+ actual: String(encryptedKey.length),
104
+ });
105
+ }
106
+ const iv = encryptedKey.subarray(0, this.cryptoCore.consts.IV_SIZE);
107
+ const authTag = encryptedKey.subarray(this.cryptoCore.consts.IV_SIZE, this.cryptoCore.consts.IV_SIZE + this.cryptoCore.consts.AUTH_TAG_SIZE);
108
+ const encrypted = encryptedKey.subarray(this.cryptoCore.consts.IV_SIZE + this.cryptoCore.consts.AUTH_TAG_SIZE);
109
+ // Normalize the public key (ensuring 0x04 prefix)
110
+ const normalizedKey = this.cryptoCore.normalizePublicKey(ephemeralPublicKey);
111
+ // Compute shared secret
112
+ const ecdh = (0, crypto_1.createECDH)(this.cryptoCore.config.curveName);
113
+ ecdh.setPrivateKey(privateKey);
114
+ const sharedSecret = ecdh.computeSecret(normalizedKey);
115
+ // Use HKDF to derive the key
116
+ const symKey = this.cryptoCore.deriveSharedKey(sharedSecret, Buffer.alloc(0), // No salt
117
+ Buffer.from('ecies-v2-key-derivation'), // Info
118
+ this.cryptoCore.consts.SYMMETRIC.KEY_SIZE);
119
+ // Decrypt
120
+ const decipher = (0, crypto_1.createDecipheriv)(this.cryptoCore.consts.SYMMETRIC_ALGORITHM_CONFIGURATION, symKey, iv);
121
+ decipher.setAuthTag(authTag);
122
+ if (aad) {
123
+ decipher.setAAD(aad);
124
+ }
125
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment
126
+ const decrypted = decipher.update(encrypted);
127
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment
128
+ const final = decipher.final();
129
+ const decryptedMessage = Buffer.concat([decrypted, final]);
130
+ if (decryptedMessage.length !== this.cryptoCore.consts.SYMMETRIC.KEY_SIZE) {
131
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidDataLength, undefined, undefined, {
132
+ expected: String(this.cryptoCore.consts.SYMMETRIC.KEY_SIZE),
133
+ actual: String(decryptedMessage.length),
134
+ });
135
+ }
136
+ return decryptedMessage;
137
+ }
138
+ /**
139
+ * Encrypts a message for multiple recipients.
140
+ * @param recipients The recipients to encrypt the message for.
141
+ * @param message The message to encrypt.
142
+ * @param preamble Optional preamble to include in the encrypted message.
143
+ * @param senderPrivateKey Optional sender private key for signing.
144
+ * @returns The encrypted message.
145
+ * @throws EciesError if the number of recipients is greater than 65535.
146
+ */
147
+ encryptMultiple(recipients, message, preamble, senderPrivateKey) {
148
+ if (recipients.length > ecies_lib_1.Constants.UINT16_MAX) {
149
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.TooManyRecipients);
150
+ }
151
+ // Sign-then-Encrypt: If sender key provided, sign the message and prepend signature
152
+ let messageToEncrypt = message;
153
+ if (senderPrivateKey) {
154
+ const signature = this.cryptoCore.sign(senderPrivateKey, message);
155
+ messageToEncrypt = Buffer.concat([signature, message]);
156
+ }
157
+ if (messageToEncrypt.length > this.cryptoCore.consts.MAX_RAW_DATA_SIZE) {
158
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.FileSizeTooLarge);
159
+ }
160
+ const messageTypeBuffer = Buffer.alloc(1);
161
+ messageTypeBuffer.writeUint8(ecies_lib_1.EciesEncryptionTypeEnum.Multiple);
162
+ // Generate a random symmetric key
163
+ const symmetricKey = (0, crypto_1.randomBytes)(this.cryptoCore.consts.SYMMETRIC.KEY_SIZE);
164
+ // Generate ONE ephemeral key pair for all recipients
165
+ const ecdh = (0, crypto_1.createECDH)(this.cryptoCore.config.curveName);
166
+ ecdh.generateKeys();
167
+ const ephemeralPrivateKey = ecdh.getPrivateKey();
168
+ let ephemeralPublicKey = ecdh.getPublicKey(null, 'compressed');
169
+ // Ensure public key has 0x04 prefix
170
+ if (ephemeralPublicKey.length === this.cryptoCore.consts.RAW_PUBLIC_KEY_LENGTH) {
171
+ ephemeralPublicKey = Buffer.concat([
172
+ Buffer.from([this.cryptoCore.consts.PUBLIC_KEY_MAGIC]),
173
+ ephemeralPublicKey,
174
+ ]);
175
+ }
176
+ const encryptionResults = recipients.map((member) => ({
177
+ id: member.id,
178
+ encryptedKey: this.encryptKey(member.publicKey, symmetricKey, ephemeralPrivateKey, member.id),
179
+ }));
180
+ const recipientIds = encryptionResults.map(({ id }) => id);
181
+ const recipientKeys = encryptionResults.map(({ encryptedKey }) => encryptedKey);
182
+ // Calculate header size
183
+ const headerSize = this.calculateECIESMultipleRecipientOverhead(recipients.length, false, recipientKeys);
184
+ // Build the header to use as AAD for message encryption
185
+ // We need to construct a temporary object to build the header
186
+ const tempHeaderData = {
187
+ dataLength: messageToEncrypt.length,
188
+ recipientCount: recipients.length,
189
+ recipientIds,
190
+ recipientKeys,
191
+ encryptedMessage: Buffer.alloc(0), // Placeholder
192
+ headerSize,
193
+ ephemeralPublicKey,
194
+ };
195
+ const headerBytes = this.buildECIESMultipleRecipientHeader(tempHeaderData);
196
+ // Encrypt the message with the symmetric key and Header as AAD
197
+ const iv = (0, crypto_1.randomBytes)(this.cryptoCore.consts.IV_SIZE);
198
+ const cipher = (0, crypto_1.createCipheriv)(this.cryptoCore.consts.SYMMETRIC_ALGORITHM_CONFIGURATION, symmetricKey, iv);
199
+ cipher.setAAD(headerBytes);
200
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment
201
+ const encrypted = cipher.update(messageToEncrypt);
202
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment
203
+ const final = cipher.final();
204
+ const authTag = cipher.getAuthTag();
205
+ const encryptedMessage = Buffer.concat([encrypted, final]);
206
+ const storedMessage = Buffer.concat([
207
+ preamble ?? Buffer.alloc(0),
208
+ iv,
209
+ authTag,
210
+ encryptedMessage,
211
+ ]);
212
+ // Verify the encrypted message size (just the encrypted content)
213
+ if (encryptedMessage.length !== messageToEncrypt.length) {
214
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.MessageLengthMismatch);
215
+ }
216
+ return {
217
+ dataLength: messageToEncrypt.length,
218
+ recipientCount: recipients.length,
219
+ recipientIds,
220
+ recipientKeys,
221
+ encryptedMessage: storedMessage,
222
+ headerSize,
223
+ ephemeralPublicKey,
224
+ };
225
+ }
226
+ /**
227
+ * Decrypts a message encrypted with multiple ECIE for a recipient.
228
+ * @param encryptedData The encrypted data.
229
+ * @param recipient The recipient.
230
+ * @param senderPublicKey Optional sender public key for verification.
231
+ * @returns The decrypted message.
232
+ */
233
+ decryptMultipleECIEForRecipient(encryptedData, recipient, senderPublicKey) {
234
+ if (recipient.privateKey === undefined) {
235
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.PrivateKeyNotLoaded);
236
+ }
237
+ // Find this recipient's encrypted key
238
+ const recipientIndex = encryptedData.recipientIds.findIndex((id) => id.equals(recipient.id));
239
+ if (recipientIndex === -1) {
240
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.RecipientNotFound);
241
+ }
242
+ const encryptedKey = encryptedData.recipientKeys[recipientIndex];
243
+ if (!encryptedData.ephemeralPublicKey) {
244
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEphemeralPublicKey);
245
+ }
246
+ // Decrypt the symmetric key using the detected encryption type
247
+ const symmetricKey = this.decryptKey(Buffer.from(recipient.privateKey.value), encryptedKey, encryptedData.ephemeralPublicKey, recipient.id);
248
+ // Rebuild header to use as AAD
249
+ const headerBytes = this.buildECIESMultipleRecipientHeader(encryptedData);
250
+ // Extract the IV and auth tag from the encrypted message
251
+ const iv = encryptedData.encryptedMessage.subarray(0, this.cryptoCore.consts.IV_SIZE);
252
+ const authTag = encryptedData.encryptedMessage.subarray(this.cryptoCore.consts.IV_SIZE, this.cryptoCore.consts.IV_SIZE + this.cryptoCore.consts.AUTH_TAG_SIZE);
253
+ // Extract the encrypted content (no CRC, AES-GCM provides authentication)
254
+ const encrypted = encryptedData.encryptedMessage.subarray(this.cryptoCore.consts.IV_SIZE + this.cryptoCore.consts.AUTH_TAG_SIZE);
255
+ // Decrypt the content with the symmetric key
256
+ const decipher = (0, crypto_1.createDecipheriv)(this.cryptoCore.consts.SYMMETRIC_ALGORITHM_CONFIGURATION, symmetricKey, iv);
257
+ decipher.setAuthTag(authTag);
258
+ decipher.setAAD(headerBytes);
259
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment
260
+ const decrypted = decipher.update(encrypted);
261
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment
262
+ const final = decipher.final();
263
+ const decryptedMessage = Buffer.concat([decrypted, final]);
264
+ // The decrypted message should match the original data length
265
+ if (decryptedMessage.length !== encryptedData.dataLength) {
266
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidDataLength);
267
+ }
268
+ // If sender public key is provided, verify signature
269
+ if (senderPublicKey) {
270
+ // Expect [Signature (64)][Message]
271
+ if (decryptedMessage.length < 64) {
272
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidSignature);
273
+ }
274
+ const signature = decryptedMessage.subarray(0, 64);
275
+ const message = decryptedMessage.subarray(64);
276
+ const isValid = this.cryptoCore.verify(senderPublicKey, message, signature);
277
+ if (!isValid) {
278
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidSignature);
279
+ }
280
+ return message;
281
+ }
282
+ return decryptedMessage;
283
+ }
284
+ /**
285
+ * Calculate the overhead for a message encrypted for multiple recipients
286
+ * @param recipientCount number of recipients
287
+ * @param includeMessageOverhead whether to include the overhead for the encrypted message
288
+ * @param encryptedKeys optional array of encrypted keys to calculate actual size
289
+ * @returns the overhead size in bytes
290
+ */
291
+ calculateECIESMultipleRecipientOverhead(recipientCount, includeMessageOverhead, encryptedKeys) {
292
+ if (recipientCount < 1) {
293
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidRecipientCount);
294
+ }
295
+ // Calculate encrypted keys size
296
+ let encryptedKeysSize;
297
+ if (encryptedKeys) {
298
+ encryptedKeysSize = encryptedKeys.reduce((total, key) => total + key.length, 0);
299
+ }
300
+ else {
301
+ // Default assumption: all keys use Simple encryption type (more efficient)
302
+ encryptedKeysSize =
303
+ recipientCount * this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE;
304
+ }
305
+ const baseOverhead = this.cryptoCore.consts.VERSION_SIZE +
306
+ this.cryptoCore.consts.CIPHER_SUITE_SIZE +
307
+ this.cryptoCore.consts.ENCRYPTION_TYPE_SIZE +
308
+ this.cryptoCore.consts.MULTIPLE.DATA_LENGTH_SIZE +
309
+ this.cryptoCore.consts.MULTIPLE.RECIPIENT_COUNT_SIZE +
310
+ recipientCount * this.cryptoCore.consts.MULTIPLE.RECIPIENT_ID_SIZE + // recipient ids (dynamic based on ID provider)
311
+ encryptedKeysSize; // actual encrypted keys size
312
+ return includeMessageOverhead
313
+ ? baseOverhead + this.cryptoCore.consts.MULTIPLE.FIXED_OVERHEAD_SIZE
314
+ : baseOverhead;
315
+ }
316
+ /**
317
+ * Builds the header for a message encrypted for multiple recipients
318
+ * @param data The encrypted message data including recipients and encrypted keys
319
+ * @returns The header buffer for the message
320
+ * @throws EciesError if the number of recipients is greater than the maximum allowed
321
+ * @throws EciesError if the number of encrypted keys does not match the number of recipients
322
+ */
323
+ buildECIESMultipleRecipientHeader(data) {
324
+ if (data.recipientIds.length > this.cryptoCore.consts.MULTIPLE.MAX_RECIPIENTS) {
325
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.TooManyRecipients);
326
+ }
327
+ else if (data.recipientIds.length !== data.recipientKeys.length) {
328
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.RecipientKeyCountMismatch);
329
+ }
330
+ else if (data.dataLength < 0 ||
331
+ data.dataLength > this.cryptoCore.consts.MAX_RAW_DATA_SIZE) {
332
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.FileSizeTooLarge);
333
+ }
334
+ if (!data.ephemeralPublicKey) {
335
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEphemeralPublicKey);
336
+ }
337
+ // Create version buffer
338
+ const versionBuffer = Buffer.alloc(this.cryptoCore.consts.VERSION_SIZE);
339
+ versionBuffer.writeUInt8(ecies_lib_1.EciesVersionEnum.V1);
340
+ // Create cipher suite buffer
341
+ const cipherSuiteBuffer = Buffer.alloc(this.cryptoCore.consts.CIPHER_SUITE_SIZE);
342
+ cipherSuiteBuffer.writeUInt8(ecies_lib_1.EciesCipherSuiteEnum.Secp256k1_Aes256Gcm_Sha256);
343
+ // Create encryption type buffer
344
+ const encryptionTypeBuffer = Buffer.alloc(this.cryptoCore.consts.ENCRYPTION_TYPE_SIZE);
345
+ encryptionTypeBuffer.writeUInt8(ecies_lib_1.EciesEncryptionTypeEnum.Multiple);
346
+ // Create data length buffer
347
+ // We use the most significant byte (MSB) to store the recipient ID size
348
+ const recipientIdSize = this.cryptoCore.consts.MULTIPLE.RECIPIENT_ID_SIZE;
349
+ if (recipientIdSize > 255) {
350
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidRecipientCount);
351
+ }
352
+ const dataLengthBigInt = BigInt(data.dataLength);
353
+ const recipientIdSizeBigInt = BigInt(recipientIdSize);
354
+ const combinedLength = (recipientIdSizeBigInt << 56n) | dataLengthBigInt;
355
+ const dataLengthBuffer = Buffer.alloc(this.cryptoCore.consts.MULTIPLE.DATA_LENGTH_SIZE);
356
+ dataLengthBuffer.writeBigUInt64BE(combinedLength);
357
+ // Create recipient count buffer
358
+ const recipientCountBuffer = Buffer.alloc(this.cryptoCore.consts.MULTIPLE.RECIPIENT_COUNT_SIZE);
359
+ recipientCountBuffer.writeUInt16BE(data.recipientIds.length);
360
+ // Create recipients buffer
361
+ const recipientsBuffer = Buffer.alloc(data.recipientIds.length *
362
+ this.cryptoCore.consts.MULTIPLE.RECIPIENT_ID_SIZE);
363
+ data.recipientIds.forEach((recipientId, index) => {
364
+ recipientsBuffer.set(recipientId, index * this.cryptoCore.consts.MULTIPLE.RECIPIENT_ID_SIZE);
365
+ });
366
+ // Validate encrypted key lengths based on their encryption type
367
+ data.recipientKeys.forEach((encryptedKey) => {
368
+ if (encryptedKey.length === 0) {
369
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEncryptedKeyLength);
370
+ }
371
+ if (encryptedKey.length !==
372
+ this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE) {
373
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEncryptedKeyLength, undefined, undefined, {
374
+ expected: String(this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE),
375
+ actual: String(encryptedKey.length),
376
+ });
377
+ }
378
+ });
379
+ // Create encrypted keys buffer with variable-length keys
380
+ const encryptedKeysBuffer = Buffer.concat(data.recipientKeys);
381
+ // Combine all buffers to form the header
382
+ return Buffer.concat([
383
+ versionBuffer,
384
+ cipherSuiteBuffer,
385
+ encryptionTypeBuffer,
386
+ data.ephemeralPublicKey,
387
+ dataLengthBuffer,
388
+ recipientCountBuffer,
389
+ recipientsBuffer,
390
+ encryptedKeysBuffer,
391
+ ]);
392
+ }
393
+ /**
394
+ * Parses a multi-encrypted header.
395
+ * @param data - The data to parse.
396
+ * @returns The parsed header.
397
+ */
398
+ parseMultiEncryptedHeader(data) {
399
+ // Ensure there's enough data to read headers
400
+ // minimum: 1 (ver) + 1 (suite) + 1 (type) + 33 (pubkey) + 8 (len) + 2 (count) = 46
401
+ if (data.length < 46) {
402
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidDataLength);
403
+ }
404
+ let offset = 0;
405
+ // Read Version
406
+ const version = data.readUInt8(offset);
407
+ offset += this.cryptoCore.consts.VERSION_SIZE;
408
+ if (version !== ecies_lib_1.EciesVersionEnum.V1) {
409
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidVersion, undefined, undefined, { version: String(version) });
410
+ }
411
+ // Read CipherSuite
412
+ const cipherSuite = data.readUInt8(offset);
413
+ offset += this.cryptoCore.consts.CIPHER_SUITE_SIZE;
414
+ if (cipherSuite !== ecies_lib_1.EciesCipherSuiteEnum.Secp256k1_Aes256Gcm_Sha256) {
415
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidCipherSuite, undefined, undefined, { cipherSuite: String(cipherSuite) });
416
+ }
417
+ // Read Encryption Type
418
+ const encryptionType = data.readUInt8(offset);
419
+ offset += this.cryptoCore.consts.ENCRYPTION_TYPE_SIZE;
420
+ if (encryptionType !== ecies_lib_1.EciesEncryptionTypeEnum.Multiple) {
421
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEncryptionType, undefined, undefined, { encryptionType: encryptionType.toString(16) });
422
+ }
423
+ // Read Ephemeral Public Key
424
+ const ephemeralPublicKey = data.subarray(offset, offset + this.cryptoCore.consts.PUBLIC_KEY_LENGTH);
425
+ offset += this.cryptoCore.consts.PUBLIC_KEY_LENGTH;
426
+ // Read data length and recipient ID size
427
+ const combinedLength = data.readBigUInt64BE(offset);
428
+ offset += this.cryptoCore.consts.MULTIPLE.DATA_LENGTH_SIZE; // 8 bytes
429
+ // Extract recipient ID size from MSB (top 8 bits)
430
+ const storedRecipientIdSize = Number(combinedLength >> 56n);
431
+ // Extract data length from lower 56 bits
432
+ const dataLength = Number(combinedLength & 0x00ffffffffffffffn);
433
+ if (dataLength <= 0 ||
434
+ dataLength > this.cryptoCore.consts.MAX_RAW_DATA_SIZE) {
435
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidDataLength);
436
+ }
437
+ // Use stored recipient ID size if available (non-legacy), otherwise fallback to config
438
+ const recipientIdSize = storedRecipientIdSize > 0
439
+ ? storedRecipientIdSize
440
+ : this.cryptoCore.consts.MULTIPLE.RECIPIENT_ID_SIZE;
441
+ // Read recipient count
442
+ const recipientCount = data.readUInt16BE(offset);
443
+ if (recipientCount <= 0 ||
444
+ recipientCount > this.cryptoCore.consts.MULTIPLE.MAX_RECIPIENTS) {
445
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidRecipientCount);
446
+ }
447
+ offset += this.cryptoCore.consts.MULTIPLE.RECIPIENT_COUNT_SIZE; // 2 bytes
448
+ // Ensure there's enough data for all recipients
449
+ // Note: We can't use calculateECIESMultipleRecipientOverhead here easily because it assumes fixed ID size
450
+ // But we can calculate manually
451
+ const remainingHeaderSize = recipientCount * recipientIdSize +
452
+ recipientCount * this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE;
453
+ if (data.length < offset + remainingHeaderSize) {
454
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidDataLength);
455
+ }
456
+ // Read recipient IDs
457
+ const recipientIds = [];
458
+ for (let i = 0; i < recipientCount; i++) {
459
+ recipientIds.push(data.subarray(offset, offset + recipientIdSize));
460
+ offset += recipientIdSize;
461
+ }
462
+ // Read encrypted keys with variable lengths based on encryption type
463
+ const recipientKeys = [];
464
+ for (let i = 0; i < recipientCount; i++) {
465
+ if (offset >= data.length) {
466
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidDataLength);
467
+ }
468
+ if (offset + this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE >
469
+ data.length) {
470
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidDataLength, undefined, undefined, {
471
+ required: String(this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE),
472
+ available: String(data.length - offset),
473
+ });
474
+ }
475
+ recipientKeys.push(data.subarray(offset, offset + this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE));
476
+ offset += this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE;
477
+ }
478
+ return {
479
+ dataLength,
480
+ recipientCount,
481
+ recipientIds,
482
+ recipientKeys,
483
+ headerSize: offset,
484
+ ephemeralPublicKey,
485
+ };
486
+ }
487
+ /**
488
+ * Parses a multi-encrypted buffer into its components.
489
+ * @param data - The multi-encrypted buffer to parse.
490
+ * @returns The parsed multi-encrypted buffer.
491
+ */
492
+ parseMultiEncryptedBuffer(data) {
493
+ const header = this.parseMultiEncryptedHeader(data);
494
+ const encryptedMessage = data.subarray(header.headerSize);
495
+ return {
496
+ ...header,
497
+ encryptedMessage,
498
+ };
499
+ }
500
+ }
501
+ exports.EciesMultiRecipient = EciesMultiRecipient;
502
+ //# sourceMappingURL=multi-recipient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multi-recipient.js","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-node-ecies-lib/src/services/ecies/multi-recipient.ts"],"names":[],"mappings":";;;AAAA,mCAKgB;AAEhB,0DAOoC;AASpC,yDAA8D;AAE9D;;GAEG;AACH,MAAa,mBAAmB;IACX,UAAU,CAAkB;IAC5B,mBAAmB,CAA2B;IAEjE,YAAY,UAA2B;QACrC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,mBAAmB,GAAG,IAAI,2CAAwB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAC7E,CAAC;IAED;;;;OAIG;IACI,aAAa,CAAC,cAAsB;QACzC,OAAO,CACL,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,YAAY;YACnC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,iBAAiB;YACxC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,oBAAoB;YAC3C,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,iBAAiB,GAAG,8BAA8B;YACzE,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB;YAChD,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,oBAAoB;YACpD,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,Q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C,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;YAClB,kBAAkB;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;AA/vBD,kDA+vBC"}
@@ -0,0 +1,75 @@
1
+ import { EciesEncryptionType, EciesEncryptionTypeEnum, HexString, IECIESConfig, IECIESConstants, SecureString } from '@digitaldefiance/ecies-lib';
2
+ import { Wallet } from '@ethereumjs/wallet';
3
+ import type { IMember } from '../../interfaces/member';
4
+ import type { IMultiEncryptedMessage } from '../../interfaces/multi-encrypted-message';
5
+ import type { IMultiEncryptedParsedHeader } from '../../interfaces/multi-encrypted-parsed-header';
6
+ import type { ISingleEncryptedParsedHeader } from '../../interfaces/single-encrypted-parsed-header';
7
+ import type { IWalletSeed } from '../../interfaces/wallet-seed';
8
+ import { SignatureBuffer, SignatureString } from '../../types';
9
+ import { EciesCryptoCore } from './crypto-core';
10
+ import { EciesMultiRecipient } from './multi-recipient';
11
+ import { EciesSignature } from './signature';
12
+ import { EciesSingleRecipientCore } from './single-recipient';
13
+ import { EciesUtilities } from './utilities';
14
+ /**
15
+ * Unified ECIES service that integrates all the modular components
16
+ */
17
+ export declare class ECIESService {
18
+ protected readonly _config: IECIESConfig;
19
+ protected readonly cryptoCore: EciesCryptoCore;
20
+ protected readonly signature: EciesSignature;
21
+ protected readonly singleRecipient: EciesSingleRecipientCore;
22
+ protected readonly multiRecipient: EciesMultiRecipient;
23
+ protected readonly utilities: EciesUtilities;
24
+ constructor(config?: Partial<IECIESConfig>, eciesParams?: IECIESConstants);
25
+ get core(): EciesCryptoCore;
26
+ get config(): IECIESConfig;
27
+ /**
28
+ * The name of the elliptic curve used for ECIES encryption/decryption
29
+ */
30
+ get curveName(): string;
31
+ generateNewMnemonic(): SecureString;
32
+ walletFromSeed(seed: Buffer): Wallet;
33
+ walletAndSeedFromMnemonic(mnemonic: SecureString): IWalletSeed;
34
+ walletToSimpleKeyPairBuffer(wallet: Wallet): import("../..").ISimpleKeyPairBuffer;
35
+ seedToSimpleKeyPairBuffer(seed: Buffer): import("../..").ISimpleKeyPairBuffer;
36
+ mnemonicToSimpleKeyPairBuffer(mnemonic: SecureString): import("../..").ISimpleKeyPairBuffer;
37
+ mnemonicToSimpleKeyPair(mnemonic: SecureString): import("../..").ISimpleKeyPairBuffer;
38
+ /**
39
+ * Get compressed public key from private key
40
+ * @param privateKey The private key
41
+ * @returns Compressed public key (33 bytes with prefix)
42
+ */
43
+ getPublicKey(privateKey: Buffer): Buffer;
44
+ encryptSimpleOrSingle(encryptSimple: boolean, receiverPublicKey: Buffer, message: Buffer, preamble?: Buffer): Buffer;
45
+ parseSingleEncryptedHeader(encryptionType: EciesEncryptionTypeEnum, data: Buffer, preambleSize?: number, options?: {
46
+ dataLength?: number;
47
+ }): ISingleEncryptedParsedHeader;
48
+ decryptSimpleOrSingleWithHeader(decryptSimple: boolean, privateKey: Buffer, encryptedData: Buffer, preambleSize?: number, options?: {
49
+ dataLength?: number;
50
+ }): Buffer;
51
+ decryptSimpleOrSingleWithHeaderEx(encryptionType: EciesEncryptionTypeEnum, privateKey: Buffer, encryptedData: Buffer, preambleSize?: number, options?: {
52
+ dataLength?: number;
53
+ }): {
54
+ decrypted: Buffer;
55
+ consumedBytes: number;
56
+ };
57
+ decryptSingleWithComponents(privateKey: Buffer, ephemeralPublicKey: Buffer, iv: Buffer, authTag: Buffer, encrypted: Buffer, aad?: Buffer): {
58
+ decrypted: Buffer;
59
+ ciphertextLength?: number;
60
+ };
61
+ signMessage(privateKey: Buffer, data: Buffer): SignatureBuffer;
62
+ verifyMessage(publicKey: Buffer, data: Buffer, signature: SignatureBuffer): boolean;
63
+ signatureStringToSignatureBuffer(signatureString: HexString): SignatureBuffer;
64
+ signatureBufferToSignatureString(signatureBuffer: SignatureBuffer): SignatureString;
65
+ encryptMultiple(recipients: Array<IMember>, message: Buffer, preamble?: Buffer): Promise<IMultiEncryptedMessage>;
66
+ decryptMultipleECIEForRecipient(encryptedData: IMultiEncryptedMessage, recipient: IMember): Buffer;
67
+ calculateECIESMultipleRecipientOverhead(recipientCount: number, includeMessageOverhead: boolean): number;
68
+ buildECIESMultipleRecipientHeader(data: IMultiEncryptedMessage): Buffer;
69
+ parseMultiEncryptedHeader(data: Buffer): IMultiEncryptedParsedHeader;
70
+ parseMultiEncryptedBuffer(data: Buffer): IMultiEncryptedMessage;
71
+ computeEncryptedLengthFromDataLength(dataLength: number, encryptionMode: EciesEncryptionType, recipientCount?: number): number;
72
+ computeDecryptedLengthFromEncryptedDataLength(encryptedDataLength: number, padding?: number): number;
73
+ encrypt(encryptionType: EciesEncryptionType, recipient: IMember, message: Buffer, preamble?: Buffer): Buffer;
74
+ }
75
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-node-ecies-lib/src/services/ecies/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,EACnB,uBAAuB,EAGvB,SAAS,EACT,YAAY,EACZ,eAAe,EACf,YAAY,EACb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAI5C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AACvF,OAAO,KAAK,EAAE,2BAA2B,EAAE,MA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