@digitaldefiance/node-ecies-lib 4.4.1 → 4.4.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 (386) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +5 -0
  3. package/package.json +11 -7
  4. package/src/builders/ecies-builder.ts +27 -0
  5. package/src/builders/{index.d.ts → index.ts} +0 -1
  6. package/src/builders/member-builder.ts +158 -0
  7. package/src/constants.ts +251 -0
  8. package/src/core/errors/crypto-error.ts +10 -0
  9. package/src/core/{index.d.ts → index.ts} +0 -1
  10. package/src/core/types/result.ts +3 -0
  11. package/src/enumerations/index.ts +2 -0
  12. package/src/enumerations/pbkdf2-profile.ts +8 -0
  13. package/src/i18n/ecies-i18n-factory.ts +111 -0
  14. package/src/i18n/{index.d.ts → index.ts} +3 -1
  15. package/src/i18n/node-ecies-i18n-setup.ts +56 -0
  16. package/src/i18n/node-keys.ts +69 -0
  17. package/src/i18n/translations/de.ts +54 -0
  18. package/src/i18n/translations/en-GB.ts +83 -0
  19. package/src/i18n/translations/en-US.ts +88 -0
  20. package/src/i18n/translations/es.ts +54 -0
  21. package/src/i18n/translations/fr.ts +54 -0
  22. package/src/i18n/translations/{index.d.ts → index.ts} +0 -1
  23. package/src/i18n/translations/ja.ts +54 -0
  24. package/src/i18n/translations/uk.ts +54 -0
  25. package/src/i18n/translations/zh-cn.ts +54 -0
  26. package/src/{index.d.ts → index.ts} +5 -1
  27. package/src/interfaces/authenticated-cipher.ts +10 -0
  28. package/src/interfaces/authenticated-decipher.ts +9 -0
  29. package/src/interfaces/backend-member-operational.ts +75 -0
  30. package/src/interfaces/checksum-config.ts +4 -0
  31. package/src/interfaces/checksum-consts.ts +13 -0
  32. package/src/interfaces/constants.ts +54 -0
  33. package/src/interfaces/ecies-consts.ts +99 -0
  34. package/src/interfaces/encrypted-chunk.ts +12 -0
  35. package/src/interfaces/encryption-consts.ts +10 -0
  36. package/src/interfaces/{index.d.ts → index.ts} +0 -1
  37. package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.ts +7 -0
  38. package/src/interfaces/keyring-consts.ts +5 -0
  39. package/src/interfaces/{member-with-mnemonic.d.ts → member-with-mnemonic.ts} +3 -3
  40. package/src/interfaces/member.ts +76 -0
  41. package/src/interfaces/{multi-encrypted-message.d.ts → multi-encrypted-message.ts} +5 -5
  42. package/src/interfaces/multi-encrypted-parsed-header.ts +28 -0
  43. package/src/interfaces/multi-recipient-chunk.ts +35 -0
  44. package/src/interfaces/{pbkdf-profiles.d.ts → pbkdf-profiles.ts} +2 -2
  45. package/src/interfaces/pbkdf2-result.ts +5 -0
  46. package/src/interfaces/signing-key-private-key-info.ts +12 -0
  47. package/src/interfaces/{simple-keypair-buffer.d.ts → simple-keypair-buffer.ts} +3 -3
  48. package/src/interfaces/{simple-keypair.d.ts → simple-keypair.ts} +3 -3
  49. package/src/interfaces/simple-public-key-only-buffer.ts +3 -0
  50. package/src/interfaces/simple-public-key-only.ts +3 -0
  51. package/src/interfaces/single-encrypted-parsed-header.ts +35 -0
  52. package/src/interfaces/stream-config.ts +9 -0
  53. package/src/interfaces/stream-progress.ts +7 -0
  54. package/src/interfaces/{wallet-seed.d.ts → wallet-seed.ts} +3 -3
  55. package/src/interfaces/wrapped-key-consts.ts +6 -0
  56. package/src/lib/crypto-container.ts +32 -0
  57. package/src/lib/{index.d.ts → index.ts} +0 -1
  58. package/src/lib/invariant-validator.ts +124 -0
  59. package/src/lib/invariants/{index.d.ts → index.ts} +2 -2
  60. package/src/lib/invariants/recipient-id-consistency.ts +77 -0
  61. package/src/member.ts +511 -0
  62. package/src/services/aes-gcm.ts +260 -0
  63. package/src/services/chunk-processor.ts +47 -0
  64. package/src/services/ecies/crypto-core.ts +319 -0
  65. package/src/services/ecies/file.ts +171 -0
  66. package/src/services/ecies/{index.d.ts → index.ts} +0 -1
  67. package/src/services/ecies/multi-recipient.ts +782 -0
  68. package/src/services/ecies/service.ts +316 -0
  69. package/src/services/ecies/signature.ts +91 -0
  70. package/src/services/ecies/single-recipient.ts +743 -0
  71. package/src/services/ecies/utilities.ts +128 -0
  72. package/src/services/encryption-stream.ts +432 -0
  73. package/src/services/{index.d.ts → index.ts} +0 -1
  74. package/src/services/multi-recipient-processor.ts +505 -0
  75. package/src/services/pbkdf2.ts +304 -0
  76. package/src/services/progress-tracker.ts +43 -0
  77. package/src/test-mocks/index.ts +1 -0
  78. package/src/test-mocks/mock-backend-member.ts +195 -0
  79. package/src/testing.ts +2 -0
  80. package/src/types/id-guards.ts +91 -0
  81. package/src/types/index.ts +1 -0
  82. package/src/{types.d.ts → types.ts} +28 -9
  83. package/src/utils.ts +124 -0
  84. package/src/builders/ecies-builder.d.ts +0 -11
  85. package/src/builders/ecies-builder.d.ts.map +0 -1
  86. package/src/builders/ecies-builder.js +0 -26
  87. package/src/builders/ecies-builder.js.map +0 -1
  88. package/src/builders/index.d.ts.map +0 -1
  89. package/src/builders/index.js +0 -6
  90. package/src/builders/index.js.map +0 -1
  91. package/src/builders/member-builder.d.ts +0 -47
  92. package/src/builders/member-builder.d.ts.map +0 -1
  93. package/src/builders/member-builder.js +0 -99
  94. package/src/builders/member-builder.js.map +0 -1
  95. package/src/constants.d.ts +0 -38
  96. package/src/constants.d.ts.map +0 -1
  97. package/src/constants.js +0 -183
  98. package/src/constants.js.map +0 -1
  99. package/src/core/errors/crypto-error.d.ts +0 -6
  100. package/src/core/errors/crypto-error.d.ts.map +0 -1
  101. package/src/core/errors/crypto-error.js +0 -15
  102. package/src/core/errors/crypto-error.js.map +0 -1
  103. package/src/core/index.d.ts.map +0 -1
  104. package/src/core/index.js +0 -6
  105. package/src/core/index.js.map +0 -1
  106. package/src/core/types/result.d.ts +0 -8
  107. package/src/core/types/result.d.ts.map +0 -1
  108. package/src/core/types/result.js +0 -3
  109. package/src/core/types/result.js.map +0 -1
  110. package/src/enumerations/index.d.ts +0 -2
  111. package/src/enumerations/index.d.ts.map +0 -1
  112. package/src/enumerations/index.js +0 -5
  113. package/src/enumerations/index.js.map +0 -1
  114. package/src/enumerations/pbkdf2-profile.d.ts +0 -9
  115. package/src/enumerations/pbkdf2-profile.d.ts.map +0 -1
  116. package/src/enumerations/pbkdf2-profile.js +0 -13
  117. package/src/enumerations/pbkdf2-profile.js.map +0 -1
  118. package/src/i18n/ecies-i18n-factory.d.ts +0 -28
  119. package/src/i18n/ecies-i18n-factory.d.ts.map +0 -1
  120. package/src/i18n/ecies-i18n-factory.js +0 -89
  121. package/src/i18n/ecies-i18n-factory.js.map +0 -1
  122. package/src/i18n/index.d.ts.map +0 -1
  123. package/src/i18n/index.js +0 -8
  124. package/src/i18n/index.js.map +0 -1
  125. package/src/i18n/node-ecies-i18n-setup.d.ts +0 -5
  126. package/src/i18n/node-ecies-i18n-setup.d.ts.map +0 -1
  127. package/src/i18n/node-ecies-i18n-setup.js +0 -46
  128. package/src/i18n/node-ecies-i18n-setup.js.map +0 -1
  129. package/src/i18n/node-keys.d.ts +0 -57
  130. package/src/i18n/node-keys.d.ts.map +0 -1
  131. package/src/i18n/node-keys.js +0 -67
  132. package/src/i18n/node-keys.js.map +0 -1
  133. package/src/i18n/translations/de.d.ts +0 -3
  134. package/src/i18n/translations/de.d.ts.map +0 -1
  135. package/src/i18n/translations/de.js +0 -57
  136. package/src/i18n/translations/de.js.map +0 -1
  137. package/src/i18n/translations/en-GB.d.ts +0 -3
  138. package/src/i18n/translations/en-GB.d.ts.map +0 -1
  139. package/src/i18n/translations/en-GB.js +0 -61
  140. package/src/i18n/translations/en-GB.js.map +0 -1
  141. package/src/i18n/translations/en-US.d.ts +0 -6
  142. package/src/i18n/translations/en-US.d.ts.map +0 -1
  143. package/src/i18n/translations/en-US.js +0 -65
  144. package/src/i18n/translations/en-US.js.map +0 -1
  145. package/src/i18n/translations/es.d.ts +0 -3
  146. package/src/i18n/translations/es.d.ts.map +0 -1
  147. package/src/i18n/translations/es.js +0 -57
  148. package/src/i18n/translations/es.js.map +0 -1
  149. package/src/i18n/translations/fr.d.ts +0 -3
  150. package/src/i18n/translations/fr.d.ts.map +0 -1
  151. package/src/i18n/translations/fr.js +0 -57
  152. package/src/i18n/translations/fr.js.map +0 -1
  153. package/src/i18n/translations/index.d.ts.map +0 -1
  154. package/src/i18n/translations/index.js +0 -20
  155. package/src/i18n/translations/index.js.map +0 -1
  156. package/src/i18n/translations/ja.d.ts +0 -3
  157. package/src/i18n/translations/ja.d.ts.map +0 -1
  158. package/src/i18n/translations/ja.js +0 -57
  159. package/src/i18n/translations/ja.js.map +0 -1
  160. package/src/i18n/translations/uk.d.ts +0 -3
  161. package/src/i18n/translations/uk.d.ts.map +0 -1
  162. package/src/i18n/translations/uk.js +0 -57
  163. package/src/i18n/translations/uk.js.map +0 -1
  164. package/src/i18n/translations/zh-cn.d.ts +0 -3
  165. package/src/i18n/translations/zh-cn.d.ts.map +0 -1
  166. package/src/i18n/translations/zh-cn.js +0 -57
  167. package/src/i18n/translations/zh-cn.js.map +0 -1
  168. package/src/index.d.ts.map +0 -1
  169. package/src/index.js +0 -31
  170. package/src/index.js.map +0 -1
  171. package/src/interfaces/authenticated-cipher.d.ts +0 -12
  172. package/src/interfaces/authenticated-cipher.d.ts.map +0 -1
  173. package/src/interfaces/authenticated-cipher.js +0 -3
  174. package/src/interfaces/authenticated-cipher.js.map +0 -1
  175. package/src/interfaces/authenticated-decipher.d.ts +0 -11
  176. package/src/interfaces/authenticated-decipher.d.ts.map +0 -1
  177. package/src/interfaces/authenticated-decipher.js +0 -3
  178. package/src/interfaces/authenticated-decipher.js.map +0 -1
  179. package/src/interfaces/backend-member-operational.d.ts +0 -48
  180. package/src/interfaces/backend-member-operational.d.ts.map +0 -1
  181. package/src/interfaces/backend-member-operational.js +0 -3
  182. package/src/interfaces/backend-member-operational.js.map +0 -1
  183. package/src/interfaces/checksum-config.d.ts +0 -5
  184. package/src/interfaces/checksum-config.d.ts.map +0 -1
  185. package/src/interfaces/checksum-config.js +0 -3
  186. package/src/interfaces/checksum-config.js.map +0 -1
  187. package/src/interfaces/checksum-consts.d.ts +0 -11
  188. package/src/interfaces/checksum-consts.d.ts.map +0 -1
  189. package/src/interfaces/checksum-consts.js +0 -3
  190. package/src/interfaces/checksum-consts.js.map +0 -1
  191. package/src/interfaces/constants.d.ts +0 -52
  192. package/src/interfaces/constants.d.ts.map +0 -1
  193. package/src/interfaces/constants.js +0 -3
  194. package/src/interfaces/constants.js.map +0 -1
  195. package/src/interfaces/ecies-consts.d.ts +0 -88
  196. package/src/interfaces/ecies-consts.d.ts.map +0 -1
  197. package/src/interfaces/ecies-consts.js +0 -3
  198. package/src/interfaces/ecies-consts.js.map +0 -1
  199. package/src/interfaces/encrypted-chunk.d.ts +0 -12
  200. package/src/interfaces/encrypted-chunk.d.ts.map +0 -1
  201. package/src/interfaces/encrypted-chunk.js +0 -3
  202. package/src/interfaces/encrypted-chunk.js.map +0 -1
  203. package/src/interfaces/encryption-consts.d.ts +0 -11
  204. package/src/interfaces/encryption-consts.d.ts.map +0 -1
  205. package/src/interfaces/encryption-consts.js +0 -3
  206. package/src/interfaces/encryption-consts.js.map +0 -1
  207. package/src/interfaces/index.d.ts.map +0 -1
  208. package/src/interfaces/index.js +0 -30
  209. package/src/interfaces/index.js.map +0 -1
  210. package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.d.ts +0 -6
  211. package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.d.ts.map +0 -1
  212. package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.js +0 -3
  213. package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.js.map +0 -1
  214. package/src/interfaces/keyring-consts.d.ts +0 -6
  215. package/src/interfaces/keyring-consts.d.ts.map +0 -1
  216. package/src/interfaces/keyring-consts.js +0 -3
  217. package/src/interfaces/keyring-consts.js.map +0 -1
  218. package/src/interfaces/member-with-mnemonic.d.ts.map +0 -1
  219. package/src/interfaces/member-with-mnemonic.js +0 -3
  220. package/src/interfaces/member-with-mnemonic.js.map +0 -1
  221. package/src/interfaces/member.d.ts +0 -47
  222. package/src/interfaces/member.d.ts.map +0 -1
  223. package/src/interfaces/member.js +0 -3
  224. package/src/interfaces/member.js.map +0 -1
  225. package/src/interfaces/multi-encrypted-message.d.ts.map +0 -1
  226. package/src/interfaces/multi-encrypted-message.js +0 -3
  227. package/src/interfaces/multi-encrypted-message.js.map +0 -1
  228. package/src/interfaces/multi-encrypted-parsed-header.d.ts +0 -27
  229. package/src/interfaces/multi-encrypted-parsed-header.d.ts.map +0 -1
  230. package/src/interfaces/multi-encrypted-parsed-header.js +0 -3
  231. package/src/interfaces/multi-encrypted-parsed-header.js.map +0 -1
  232. package/src/interfaces/multi-recipient-chunk.d.ts +0 -26
  233. package/src/interfaces/multi-recipient-chunk.d.ts.map +0 -1
  234. package/src/interfaces/multi-recipient-chunk.js +0 -13
  235. package/src/interfaces/multi-recipient-chunk.js.map +0 -1
  236. package/src/interfaces/pbkdf-profiles.d.ts.map +0 -1
  237. package/src/interfaces/pbkdf-profiles.js +0 -3
  238. package/src/interfaces/pbkdf-profiles.js.map +0 -1
  239. package/src/interfaces/pbkdf2-result.d.ts +0 -6
  240. package/src/interfaces/pbkdf2-result.d.ts.map +0 -1
  241. package/src/interfaces/pbkdf2-result.js +0 -3
  242. package/src/interfaces/pbkdf2-result.js.map +0 -1
  243. package/src/interfaces/signing-key-private-key-info.d.ts +0 -11
  244. package/src/interfaces/signing-key-private-key-info.d.ts.map +0 -1
  245. package/src/interfaces/signing-key-private-key-info.js +0 -3
  246. package/src/interfaces/signing-key-private-key-info.js.map +0 -1
  247. package/src/interfaces/simple-keypair-buffer.d.ts.map +0 -1
  248. package/src/interfaces/simple-keypair-buffer.js +0 -3
  249. package/src/interfaces/simple-keypair-buffer.js.map +0 -1
  250. package/src/interfaces/simple-keypair.d.ts.map +0 -1
  251. package/src/interfaces/simple-keypair.js +0 -3
  252. package/src/interfaces/simple-keypair.js.map +0 -1
  253. package/src/interfaces/simple-public-key-only-buffer.d.ts +0 -4
  254. package/src/interfaces/simple-public-key-only-buffer.d.ts.map +0 -1
  255. package/src/interfaces/simple-public-key-only-buffer.js +0 -3
  256. package/src/interfaces/simple-public-key-only-buffer.js.map +0 -1
  257. package/src/interfaces/simple-public-key-only.d.ts +0 -4
  258. package/src/interfaces/simple-public-key-only.d.ts.map +0 -1
  259. package/src/interfaces/simple-public-key-only.js +0 -3
  260. package/src/interfaces/simple-public-key-only.js.map +0 -1
  261. package/src/interfaces/single-encrypted-parsed-header.d.ts +0 -35
  262. package/src/interfaces/single-encrypted-parsed-header.d.ts.map +0 -1
  263. package/src/interfaces/single-encrypted-parsed-header.js +0 -3
  264. package/src/interfaces/single-encrypted-parsed-header.js.map +0 -1
  265. package/src/interfaces/stream-config.d.ts +0 -6
  266. package/src/interfaces/stream-config.d.ts.map +0 -1
  267. package/src/interfaces/stream-config.js +0 -8
  268. package/src/interfaces/stream-config.js.map +0 -1
  269. package/src/interfaces/stream-progress.d.ts +0 -8
  270. package/src/interfaces/stream-progress.d.ts.map +0 -1
  271. package/src/interfaces/stream-progress.js +0 -3
  272. package/src/interfaces/stream-progress.js.map +0 -1
  273. package/src/interfaces/wallet-seed.d.ts.map +0 -1
  274. package/src/interfaces/wallet-seed.js +0 -3
  275. package/src/interfaces/wallet-seed.js.map +0 -1
  276. package/src/interfaces/wrapped-key-consts.d.ts +0 -7
  277. package/src/interfaces/wrapped-key-consts.d.ts.map +0 -1
  278. package/src/interfaces/wrapped-key-consts.js +0 -3
  279. package/src/interfaces/wrapped-key-consts.js.map +0 -1
  280. package/src/lib/crypto-container.d.ts +0 -13
  281. package/src/lib/crypto-container.d.ts.map +0 -1
  282. package/src/lib/crypto-container.js +0 -29
  283. package/src/lib/crypto-container.js.map +0 -1
  284. package/src/lib/index.d.ts.map +0 -1
  285. package/src/lib/index.js +0 -7
  286. package/src/lib/index.js.map +0 -1
  287. package/src/lib/invariant-validator.d.ts +0 -62
  288. package/src/lib/invariant-validator.d.ts.map +0 -1
  289. package/src/lib/invariant-validator.js +0 -108
  290. package/src/lib/invariant-validator.js.map +0 -1
  291. package/src/lib/invariants/index.d.ts.map +0 -1
  292. package/src/lib/invariants/index.js +0 -12
  293. package/src/lib/invariants/index.js.map +0 -1
  294. package/src/lib/invariants/recipient-id-consistency.d.ts +0 -22
  295. package/src/lib/invariants/recipient-id-consistency.d.ts.map +0 -1
  296. package/src/lib/invariants/recipient-id-consistency.js +0 -62
  297. package/src/lib/invariants/recipient-id-consistency.js.map +0 -1
  298. package/src/member.d.ts +0 -81
  299. package/src/member.d.ts.map +0 -1
  300. package/src/member.js +0 -285
  301. package/src/member.js.map +0 -1
  302. package/src/services/aes-gcm.d.ts +0 -66
  303. package/src/services/aes-gcm.d.ts.map +0 -1
  304. package/src/services/aes-gcm.js +0 -158
  305. package/src/services/aes-gcm.js.map +0 -1
  306. package/src/services/chunk-processor.d.ts +0 -15
  307. package/src/services/chunk-processor.d.ts.map +0 -1
  308. package/src/services/chunk-processor.js +0 -36
  309. package/src/services/chunk-processor.js.map +0 -1
  310. package/src/services/ecies/crypto-core.d.ts +0 -104
  311. package/src/services/ecies/crypto-core.d.ts.map +0 -1
  312. package/src/services/ecies/crypto-core.js +0 -237
  313. package/src/services/ecies/crypto-core.js.map +0 -1
  314. package/src/services/ecies/file.d.ts +0 -30
  315. package/src/services/ecies/file.d.ts.map +0 -1
  316. package/src/services/ecies/file.js +0 -112
  317. package/src/services/ecies/file.js.map +0 -1
  318. package/src/services/ecies/index.d.ts.map +0 -1
  319. package/src/services/ecies/index.js +0 -11
  320. package/src/services/ecies/index.js.map +0 -1
  321. package/src/services/ecies/multi-recipient.d.ts +0 -84
  322. package/src/services/ecies/multi-recipient.d.ts.map +0 -1
  323. package/src/services/ecies/multi-recipient.js +0 -496
  324. package/src/services/ecies/multi-recipient.js.map +0 -1
  325. package/src/services/ecies/service.d.ts +0 -69
  326. package/src/services/ecies/service.d.ts.map +0 -1
  327. package/src/services/ecies/service.js +0 -144
  328. package/src/services/ecies/service.js.map +0 -1
  329. package/src/services/ecies/signature.d.ts +0 -38
  330. package/src/services/ecies/signature.d.ts.map +0 -1
  331. package/src/services/ecies/signature.js +0 -69
  332. package/src/services/ecies/signature.js.map +0 -1
  333. package/src/services/ecies/single-recipient.d.ts +0 -83
  334. package/src/services/ecies/single-recipient.d.ts.map +0 -1
  335. package/src/services/ecies/single-recipient.js +0 -447
  336. package/src/services/ecies/single-recipient.js.map +0 -1
  337. package/src/services/ecies/utilities.d.ts +0 -33
  338. package/src/services/ecies/utilities.d.ts.map +0 -1
  339. package/src/services/ecies/utilities.js +0 -91
  340. package/src/services/ecies/utilities.js.map +0 -1
  341. package/src/services/encryption-stream.d.ts +0 -33
  342. package/src/services/encryption-stream.d.ts.map +0 -1
  343. package/src/services/encryption-stream.js +0 -207
  344. package/src/services/encryption-stream.js.map +0 -1
  345. package/src/services/index.d.ts.map +0 -1
  346. package/src/services/index.js +0 -11
  347. package/src/services/index.js.map +0 -1
  348. package/src/services/multi-recipient-processor.d.ts +0 -72
  349. package/src/services/multi-recipient-processor.d.ts.map +0 -1
  350. package/src/services/multi-recipient-processor.js +0 -322
  351. package/src/services/multi-recipient-processor.js.map +0 -1
  352. package/src/services/pbkdf2.d.ts +0 -105
  353. package/src/services/pbkdf2.d.ts.map +0 -1
  354. package/src/services/pbkdf2.js +0 -189
  355. package/src/services/pbkdf2.js.map +0 -1
  356. package/src/services/progress-tracker.d.ts +0 -9
  357. package/src/services/progress-tracker.d.ts.map +0 -1
  358. package/src/services/progress-tracker.js +0 -41
  359. package/src/services/progress-tracker.js.map +0 -1
  360. package/src/test-mocks/index.d.ts +0 -2
  361. package/src/test-mocks/index.d.ts.map +0 -1
  362. package/src/test-mocks/index.js +0 -5
  363. package/src/test-mocks/index.js.map +0 -1
  364. package/src/test-mocks/mock-backend-member.d.ts +0 -71
  365. package/src/test-mocks/mock-backend-member.d.ts.map +0 -1
  366. package/src/test-mocks/mock-backend-member.js +0 -133
  367. package/src/test-mocks/mock-backend-member.js.map +0 -1
  368. package/src/testing.d.ts +0 -2
  369. package/src/testing.d.ts.map +0 -1
  370. package/src/testing.js +0 -6
  371. package/src/testing.js.map +0 -1
  372. package/src/types/id-guards.d.ts +0 -39
  373. package/src/types/id-guards.d.ts.map +0 -1
  374. package/src/types/id-guards.js +0 -91
  375. package/src/types/id-guards.js.map +0 -1
  376. package/src/types/index.d.ts +0 -2
  377. package/src/types/index.d.ts.map +0 -1
  378. package/src/types/index.js +0 -5
  379. package/src/types/index.js.map +0 -1
  380. package/src/types.d.ts.map +0 -1
  381. package/src/types.js +0 -6
  382. package/src/types.js.map +0 -1
  383. package/src/utils.d.ts +0 -11
  384. package/src/utils.d.ts.map +0 -1
  385. package/src/utils.js +0 -82
  386. package/src/utils.js.map +0 -1
@@ -1,84 +0,0 @@
1
- import type { IMember } from '../../interfaces/member';
2
- import { IMultiEncryptedMessage } from '../../interfaces/multi-encrypted-message';
3
- import { IMultiEncryptedParsedHeader } from '../../interfaces/multi-encrypted-parsed-header';
4
- import { EciesCryptoCore } from './crypto-core';
5
- import { EciesSingleRecipientCore } from './single-recipient';
6
- /**
7
- * Multiple recipient encryption/decryption functions for ECIES
8
- */
9
- export declare class EciesMultiRecipient {
10
- protected readonly cryptoCore: EciesCryptoCore;
11
- protected readonly singleRecipientCore: EciesSingleRecipientCore;
12
- constructor(cryptoCore: EciesCryptoCore);
13
- /**
14
- * Get the size of the header for a given encryption type
15
- * @param recipientCount The number of recipients
16
- * @returns
17
- */
18
- getHeaderSize(recipientCount: number): number;
19
- /**
20
- * Encrypt a message symmetric key with a public key
21
- * @param receiverPublicKey The public key of the receiver
22
- * @param messageSymmetricKey The message to encrypt
23
- * @param ephemeralPrivateKey The ephemeral private key to use for encryption
24
- * @param aad Additional Authenticated Data (optional)
25
- * @returns The encrypted message
26
- */
27
- encryptKey(receiverPublicKey: Buffer, messageSymmetricKey: Buffer, ephemeralPrivateKey: Buffer, aad?: Buffer): Buffer;
28
- /**
29
- * Decrypts symmetric key encrypted with ECIES using a header
30
- * @param privateKey The private key to decrypt the data
31
- * @param encryptedKey The data to decrypt
32
- * @param ephemeralPublicKey The ephemeral public key from the header
33
- * @param aad Additional Authenticated Data (optional)
34
- * @returns The decrypted data buffer
35
- */
36
- decryptKey(privateKey: Buffer, encryptedKey: Buffer, ephemeralPublicKey: Buffer, aad?: Buffer): Buffer;
37
- /**
38
- * Encrypts a message for multiple recipients.
39
- * @param recipients The recipients to encrypt the message for.
40
- * @param message The message to encrypt.
41
- * @param preamble Optional preamble to include in the encrypted message.
42
- * @param senderPrivateKey Optional sender private key for signing.
43
- * @returns The encrypted message.
44
- * @throws EciesError if the number of recipients is greater than 65535.
45
- */
46
- encryptMultiple(recipients: IMember[], message: Buffer, preamble?: Buffer, senderPrivateKey?: Buffer): IMultiEncryptedMessage;
47
- /**
48
- * Decrypts a message encrypted with multiple ECIE for a recipient.
49
- * @param encryptedData The encrypted data.
50
- * @param recipient The recipient.
51
- * @param senderPublicKey Optional sender public key for verification.
52
- * @returns The decrypted message.
53
- */
54
- decryptMultipleECIEForRecipient(encryptedData: IMultiEncryptedMessage, recipient: IMember, senderPublicKey?: Buffer): Buffer;
55
- /**
56
- * Calculate the overhead for a message encrypted for multiple recipients
57
- * @param recipientCount number of recipients
58
- * @param includeMessageOverhead whether to include the overhead for the encrypted message
59
- * @param encryptedKeys optional array of encrypted keys to calculate actual size
60
- * @returns the overhead size in bytes
61
- */
62
- calculateECIESMultipleRecipientOverhead(recipientCount: number, includeMessageOverhead: boolean, encryptedKeys?: Buffer[]): number;
63
- /**
64
- * Builds the header for a message encrypted for multiple recipients
65
- * @param data The encrypted message data including recipients and encrypted keys
66
- * @returns The header buffer for the message
67
- * @throws EciesError if the number of recipients is greater than the maximum allowed
68
- * @throws EciesError if the number of encrypted keys does not match the number of recipients
69
- */
70
- buildECIESMultipleRecipientHeader(data: IMultiEncryptedMessage): Buffer;
71
- /**
72
- * Parses a multi-encrypted header.
73
- * @param data - The data to parse.
74
- * @returns The parsed header.
75
- */
76
- parseMultiEncryptedHeader(data: Buffer): IMultiEncryptedParsedHeader;
77
- /**
78
- * Parses a multi-encrypted buffer into its components.
79
- * @param data - The multi-encrypted buffer to parse.
80
- * @returns The parsed multi-encrypted buffer.
81
- */
82
- parseMultiEncryptedBuffer(data: Buffer): IMultiEncryptedMessage;
83
- }
84
- //# sourceMappingURL=multi-recipient.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"multi-recipient.d.ts","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-node-ecies-lib/src/services/ecies/multi-recipient.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAClF,OAAO,EAAE,2BAA2B,EAAE,MAAM,gDAAgD,CAAC;AAC7F,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D;;GAEG;AACH,qBAAa,mBAAmB;IAC9B,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,eAAe,CAAC;IAC/C,SAAS,CAAC,QAAQ,CAAC,mBAAmB,EAAE,wBAAwB,CAAC;gBAErD,UAAU,EAAE,eAAe;IAKvC;;;;OAIG;IACI,aAAa,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM;IAapD;;;;;;;OAOG;IACI,UAAU,CACf,iBAAiB,EAAE,MAAM,EACzB,mBAAmB,EAAE,MAAM,EAC3B,mBAAmB,EAAE,MAAM,EAC3B,GAAG,CAAC,EAAE,MAAM,GACX,MAAM;IA+ET;;;;;;;OAOG;IACI,UAAU,CACf,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,kBAAkB,EAAE,MAAM,EAC1B,GAAG,CAAC,EAAE,MAAM,GACX,MAAM;IAuET;;;;;;;;OAQG;IACI,eAAe,CACpB,UAAU,EAAE,OAAO,EAAE,EACrB,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,EACjB,gBAAgB,CAAC,EAAE,MAAM,GACxB,sBAAsB;IAiHzB;;;;;;OAMG;IACI,+BAA+B,CACpC,aAAa,EAAE,sBAAsB,EACrC,SAAS,EAAE,OAAO,EAClB,eAAe,CAAC,EAAE,MAAM,GACvB,MAAM;IAwFT;;;;;;OAMG;IACI,uCAAuC,CAC5C,cAAc,EAAE,MAAM,EACtB,sBAAsB,EAAE,OAAO,EAC/B,aAAa,CAAC,EAAE,MAAM,EAAE,GACvB,MAAM;IAgCT;;;;;;OAMG;IACI,iCAAiC,CACtC,IAAI,EAAE,sBAAsB,GAC3B,MAAM;IA8GT;;;;OAIG;IACI,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,2BAA2B;IAkJ3E;;;;OAIG;IACI,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,sBAAsB;CASvE"}
@@ -1,496 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EciesMultiRecipient = void 0;
4
- const ecies_lib_1 = require("@digitaldefiance/ecies-lib");
5
- const crypto_1 = require("crypto");
6
- const 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
- let encrypted = cipher.update(messageSymmetricKey);
82
- encrypted = Buffer.concat([encrypted, cipher.final()]);
83
- // Get and explicitly set the authentication tag to max tag length for consistency
84
- const authTag = cipher.getAuthTag();
85
- // Format: iv (16) | authTag (16) | encryptedData (32)
86
- // Note: Ephemeral public key is now in the main header, not per-recipient
87
- return Buffer.concat([iv, authTag, encrypted]);
88
- }
89
- /**
90
- * Decrypts symmetric key encrypted with ECIES using a header
91
- * @param privateKey The private key to decrypt the data
92
- * @param encryptedKey The data to decrypt
93
- * @param ephemeralPublicKey The ephemeral public key from the header
94
- * @param aad Additional Authenticated Data (optional)
95
- * @returns The decrypted data buffer
96
- */
97
- decryptKey(privateKey, encryptedKey, ephemeralPublicKey, aad) {
98
- if (encryptedKey.length !== this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE) {
99
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEncryptedKeyLength, undefined, undefined, {
100
- expected: String(this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE),
101
- actual: String(encryptedKey.length),
102
- });
103
- }
104
- const iv = encryptedKey.subarray(0, this.cryptoCore.consts.IV_SIZE);
105
- const authTag = encryptedKey.subarray(this.cryptoCore.consts.IV_SIZE, this.cryptoCore.consts.IV_SIZE + this.cryptoCore.consts.AUTH_TAG_SIZE);
106
- const encrypted = encryptedKey.subarray(this.cryptoCore.consts.IV_SIZE + this.cryptoCore.consts.AUTH_TAG_SIZE);
107
- // Normalize the public key (ensuring 0x04 prefix)
108
- const normalizedKey = this.cryptoCore.normalizePublicKey(ephemeralPublicKey);
109
- // Compute shared secret
110
- const ecdh = (0, crypto_1.createECDH)(this.cryptoCore.config.curveName);
111
- ecdh.setPrivateKey(privateKey);
112
- const sharedSecret = ecdh.computeSecret(normalizedKey);
113
- // Use HKDF to derive the key
114
- const symKey = this.cryptoCore.deriveSharedKey(sharedSecret, Buffer.alloc(0), // No salt
115
- Buffer.from('ecies-v2-key-derivation'), // Info
116
- this.cryptoCore.consts.SYMMETRIC.KEY_SIZE);
117
- // Decrypt
118
- const decipher = (0, crypto_1.createDecipheriv)(this.cryptoCore.consts.SYMMETRIC_ALGORITHM_CONFIGURATION, symKey, iv);
119
- decipher.setAuthTag(authTag);
120
- if (aad) {
121
- decipher.setAAD(aad);
122
- }
123
- const decrypted = decipher.update(encrypted);
124
- const final = decipher.final();
125
- const decryptedMessage = Buffer.concat([decrypted, final]);
126
- if (decryptedMessage.length !== this.cryptoCore.consts.SYMMETRIC.KEY_SIZE) {
127
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidDataLength, undefined, undefined, {
128
- expected: String(this.cryptoCore.consts.SYMMETRIC.KEY_SIZE),
129
- actual: String(decryptedMessage.length),
130
- });
131
- }
132
- return decryptedMessage;
133
- }
134
- /**
135
- * Encrypts a message for multiple recipients.
136
- * @param recipients The recipients to encrypt the message for.
137
- * @param message The message to encrypt.
138
- * @param preamble Optional preamble to include in the encrypted message.
139
- * @param senderPrivateKey Optional sender private key for signing.
140
- * @returns The encrypted message.
141
- * @throws EciesError if the number of recipients is greater than 65535.
142
- */
143
- encryptMultiple(recipients, message, preamble, senderPrivateKey) {
144
- if (recipients.length > ecies_lib_1.Constants.UINT16_MAX) {
145
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.TooManyRecipients);
146
- }
147
- // Sign-then-Encrypt: If sender key provided, sign the message and prepend signature
148
- let messageToEncrypt = message;
149
- if (senderPrivateKey) {
150
- const signature = this.cryptoCore.sign(senderPrivateKey, message);
151
- messageToEncrypt = Buffer.concat([signature, message]);
152
- }
153
- if (messageToEncrypt.length > this.cryptoCore.consts.MAX_RAW_DATA_SIZE) {
154
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.FileSizeTooLarge);
155
- }
156
- const messageTypeBuffer = Buffer.alloc(1);
157
- messageTypeBuffer.writeUint8(ecies_lib_1.EciesEncryptionTypeEnum.Multiple);
158
- // Generate a random symmetric key
159
- const symmetricKey = (0, crypto_1.randomBytes)(this.cryptoCore.consts.SYMMETRIC.KEY_SIZE);
160
- // Generate ONE ephemeral key pair for all recipients
161
- const ecdh = (0, crypto_1.createECDH)(this.cryptoCore.config.curveName);
162
- ecdh.generateKeys();
163
- const ephemeralPrivateKey = ecdh.getPrivateKey();
164
- let ephemeralPublicKey = ecdh.getPublicKey(null, 'compressed');
165
- // Ensure public key has 0x04 prefix
166
- if (ephemeralPublicKey.length === this.cryptoCore.consts.RAW_PUBLIC_KEY_LENGTH) {
167
- ephemeralPublicKey = Buffer.concat([
168
- Buffer.from([this.cryptoCore.consts.PUBLIC_KEY_MAGIC]),
169
- ephemeralPublicKey,
170
- ]);
171
- }
172
- const encryptionResults = recipients.map((member) => ({
173
- id: member.id,
174
- encryptedKey: this.encryptKey(member.publicKey, symmetricKey, ephemeralPrivateKey, member.id // Use Recipient ID as AAD
175
- ),
176
- }));
177
- const recipientIds = encryptionResults.map(({ id }) => id);
178
- const recipientKeys = encryptionResults.map(({ encryptedKey }) => encryptedKey);
179
- // Calculate header size
180
- const headerSize = this.calculateECIESMultipleRecipientOverhead(recipients.length, false, recipientKeys);
181
- // Build the header to use as AAD for message encryption
182
- // We need to construct a temporary object to build the header
183
- const tempHeaderData = {
184
- dataLength: messageToEncrypt.length,
185
- recipientCount: recipients.length,
186
- recipientIds,
187
- recipientKeys,
188
- encryptedMessage: Buffer.alloc(0), // Placeholder
189
- headerSize,
190
- ephemeralPublicKey,
191
- };
192
- const headerBytes = this.buildECIESMultipleRecipientHeader(tempHeaderData);
193
- // Encrypt the message with the symmetric key and Header as AAD
194
- const iv = (0, crypto_1.randomBytes)(this.cryptoCore.consts.IV_SIZE);
195
- const cipher = (0, crypto_1.createCipheriv)(this.cryptoCore.consts.SYMMETRIC_ALGORITHM_CONFIGURATION, symmetricKey, iv);
196
- cipher.setAAD(headerBytes);
197
- const encrypted = cipher.update(messageToEncrypt);
198
- const final = cipher.final();
199
- const authTag = cipher.getAuthTag();
200
- const encryptedMessage = Buffer.concat([encrypted, final]);
201
- const storedMessage = Buffer.concat([
202
- preamble ?? Buffer.alloc(0),
203
- iv,
204
- authTag,
205
- encryptedMessage,
206
- ]);
207
- // Verify the encrypted message size (just the encrypted content)
208
- if (encryptedMessage.length !== messageToEncrypt.length) {
209
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.MessageLengthMismatch);
210
- }
211
- return {
212
- dataLength: messageToEncrypt.length,
213
- recipientCount: recipients.length,
214
- recipientIds,
215
- recipientKeys,
216
- encryptedMessage: storedMessage,
217
- headerSize,
218
- ephemeralPublicKey,
219
- };
220
- }
221
- /**
222
- * Decrypts a message encrypted with multiple ECIE for a recipient.
223
- * @param encryptedData The encrypted data.
224
- * @param recipient The recipient.
225
- * @param senderPublicKey Optional sender public key for verification.
226
- * @returns The decrypted message.
227
- */
228
- decryptMultipleECIEForRecipient(encryptedData, recipient, senderPublicKey) {
229
- if (recipient.privateKey === undefined) {
230
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.PrivateKeyNotLoaded);
231
- }
232
- // Find this recipient's encrypted key
233
- const recipientIndex = encryptedData.recipientIds.findIndex((id) => id.equals(recipient.id));
234
- if (recipientIndex === -1) {
235
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.RecipientNotFound);
236
- }
237
- const encryptedKey = encryptedData.recipientKeys[recipientIndex];
238
- if (!encryptedData.ephemeralPublicKey) {
239
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.MissingEphemeralPublicKey);
240
- }
241
- // Decrypt the symmetric key using the detected encryption type
242
- const symmetricKey = this.decryptKey(Buffer.from(recipient.privateKey.value), encryptedKey, encryptedData.ephemeralPublicKey, recipient.id // Use Recipient ID as AAD
243
- );
244
- // Rebuild header to use as AAD
245
- const headerBytes = this.buildECIESMultipleRecipientHeader(encryptedData);
246
- // Extract the IV and auth tag from the encrypted message
247
- const iv = encryptedData.encryptedMessage.subarray(0, this.cryptoCore.consts.IV_SIZE);
248
- const authTag = encryptedData.encryptedMessage.subarray(this.cryptoCore.consts.IV_SIZE, this.cryptoCore.consts.IV_SIZE + this.cryptoCore.consts.AUTH_TAG_SIZE);
249
- // Extract the encrypted content (no CRC, AES-GCM provides authentication)
250
- const encrypted = encryptedData.encryptedMessage.subarray(this.cryptoCore.consts.IV_SIZE + this.cryptoCore.consts.AUTH_TAG_SIZE);
251
- // Decrypt the content with the symmetric key
252
- const decipher = (0, crypto_1.createDecipheriv)(this.cryptoCore.consts.SYMMETRIC_ALGORITHM_CONFIGURATION, symmetricKey, iv);
253
- decipher.setAuthTag(authTag);
254
- decipher.setAAD(headerBytes);
255
- const decrypted = decipher.update(encrypted);
256
- const final = decipher.final();
257
- const decryptedMessage = Buffer.concat([decrypted, final]);
258
- // The decrypted message should match the original data length
259
- if (decryptedMessage.length !== encryptedData.dataLength) {
260
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidDataLength);
261
- }
262
- // If sender public key is provided, verify signature
263
- if (senderPublicKey) {
264
- // Expect [Signature (64)][Message]
265
- if (decryptedMessage.length < 64) {
266
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidSignature);
267
- }
268
- const signature = decryptedMessage.subarray(0, 64);
269
- const message = decryptedMessage.subarray(64);
270
- const isValid = this.cryptoCore.verify(senderPublicKey, message, signature);
271
- if (!isValid) {
272
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidSignature);
273
- }
274
- return message;
275
- }
276
- return decryptedMessage;
277
- }
278
- /**
279
- * Calculate the overhead for a message encrypted for multiple recipients
280
- * @param recipientCount number of recipients
281
- * @param includeMessageOverhead whether to include the overhead for the encrypted message
282
- * @param encryptedKeys optional array of encrypted keys to calculate actual size
283
- * @returns the overhead size in bytes
284
- */
285
- calculateECIESMultipleRecipientOverhead(recipientCount, includeMessageOverhead, encryptedKeys) {
286
- if (recipientCount < 1) {
287
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidRecipientCount);
288
- }
289
- // Calculate encrypted keys size
290
- let encryptedKeysSize;
291
- if (encryptedKeys) {
292
- encryptedKeysSize = encryptedKeys.reduce((total, key) => total + key.length, 0);
293
- }
294
- else {
295
- // Default assumption: all keys use Simple encryption type (more efficient)
296
- encryptedKeysSize =
297
- recipientCount * this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE;
298
- }
299
- const baseOverhead = this.cryptoCore.consts.VERSION_SIZE +
300
- this.cryptoCore.consts.CIPHER_SUITE_SIZE +
301
- this.cryptoCore.consts.ENCRYPTION_TYPE_SIZE +
302
- this.cryptoCore.consts.MULTIPLE.DATA_LENGTH_SIZE +
303
- this.cryptoCore.consts.MULTIPLE.RECIPIENT_COUNT_SIZE +
304
- recipientCount * this.cryptoCore.consts.MULTIPLE.RECIPIENT_ID_SIZE + // recipient ids (dynamic based on ID provider)
305
- encryptedKeysSize; // actual encrypted keys size
306
- return includeMessageOverhead
307
- ? baseOverhead + this.cryptoCore.consts.MULTIPLE.FIXED_OVERHEAD_SIZE
308
- : baseOverhead;
309
- }
310
- /**
311
- * Builds the header for a message encrypted for multiple recipients
312
- * @param data The encrypted message data including recipients and encrypted keys
313
- * @returns The header buffer for the message
314
- * @throws EciesError if the number of recipients is greater than the maximum allowed
315
- * @throws EciesError if the number of encrypted keys does not match the number of recipients
316
- */
317
- buildECIESMultipleRecipientHeader(data) {
318
- if (data.recipientIds.length > this.cryptoCore.consts.MULTIPLE.MAX_RECIPIENTS) {
319
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.TooManyRecipients);
320
- }
321
- else if (data.recipientIds.length !== data.recipientKeys.length) {
322
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.RecipientKeyCountMismatch);
323
- }
324
- else if (data.dataLength < 0 ||
325
- data.dataLength > this.cryptoCore.consts.MAX_RAW_DATA_SIZE) {
326
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.FileSizeTooLarge);
327
- }
328
- if (!data.ephemeralPublicKey) {
329
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.MissingEphemeralPublicKey);
330
- }
331
- // Create version buffer
332
- const versionBuffer = Buffer.alloc(this.cryptoCore.consts.VERSION_SIZE);
333
- versionBuffer.writeUInt8(ecies_lib_1.EciesVersionEnum.V1);
334
- // Create cipher suite buffer
335
- const cipherSuiteBuffer = Buffer.alloc(this.cryptoCore.consts.CIPHER_SUITE_SIZE);
336
- cipherSuiteBuffer.writeUInt8(ecies_lib_1.EciesCipherSuiteEnum.Secp256k1_Aes256Gcm_Sha256);
337
- // Create encryption type buffer
338
- const encryptionTypeBuffer = Buffer.alloc(this.cryptoCore.consts.ENCRYPTION_TYPE_SIZE);
339
- encryptionTypeBuffer.writeUInt8(ecies_lib_1.EciesEncryptionTypeEnum.Multiple);
340
- // Create data length buffer
341
- // We use the most significant byte (MSB) to store the recipient ID size
342
- const recipientIdSize = this.cryptoCore.consts.MULTIPLE.RECIPIENT_ID_SIZE;
343
- if (recipientIdSize > 255) {
344
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.RecipientIdSizeTooLarge);
345
- }
346
- const dataLengthBigInt = BigInt(data.dataLength);
347
- const recipientIdSizeBigInt = BigInt(recipientIdSize);
348
- const combinedLength = (recipientIdSizeBigInt << 56n) | dataLengthBigInt;
349
- const dataLengthBuffer = Buffer.alloc(this.cryptoCore.consts.MULTIPLE.DATA_LENGTH_SIZE);
350
- dataLengthBuffer.writeBigUInt64BE(combinedLength);
351
- // Create recipient count buffer
352
- const recipientCountBuffer = Buffer.alloc(this.cryptoCore.consts.MULTIPLE.RECIPIENT_COUNT_SIZE);
353
- recipientCountBuffer.writeUInt16BE(data.recipientIds.length);
354
- // Create recipients buffer
355
- const recipientsBuffer = Buffer.alloc(data.recipientIds.length *
356
- this.cryptoCore.consts.MULTIPLE.RECIPIENT_ID_SIZE);
357
- data.recipientIds.forEach((recipientId, index) => {
358
- recipientsBuffer.set(recipientId, index * this.cryptoCore.consts.MULTIPLE.RECIPIENT_ID_SIZE);
359
- });
360
- // Validate encrypted key lengths based on their encryption type
361
- data.recipientKeys.forEach((encryptedKey) => {
362
- if (encryptedKey.length === 0) {
363
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEncryptedKeyLength);
364
- }
365
- if (encryptedKey.length !==
366
- this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE) {
367
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEncryptedKeyLength, undefined, undefined, {
368
- expected: String(this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE),
369
- actual: String(encryptedKey.length),
370
- });
371
- }
372
- });
373
- // Create encrypted keys buffer with variable-length keys
374
- const encryptedKeysBuffer = Buffer.concat(data.recipientKeys);
375
- // Combine all buffers to form the header
376
- return Buffer.concat([
377
- versionBuffer,
378
- cipherSuiteBuffer,
379
- encryptionTypeBuffer,
380
- data.ephemeralPublicKey,
381
- dataLengthBuffer,
382
- recipientCountBuffer,
383
- recipientsBuffer,
384
- encryptedKeysBuffer,
385
- ]);
386
- }
387
- /**
388
- * Parses a multi-encrypted header.
389
- * @param data - The data to parse.
390
- * @returns The parsed header.
391
- */
392
- parseMultiEncryptedHeader(data) {
393
- // Ensure there's enough data to read headers
394
- // minimum: 1 (ver) + 1 (suite) + 1 (type) + 33 (pubkey) + 8 (len) + 2 (count) = 46
395
- if (data.length < 46) {
396
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidDataLength);
397
- }
398
- let offset = 0;
399
- // Read Version
400
- const version = data.readUInt8(offset);
401
- offset += this.cryptoCore.consts.VERSION_SIZE;
402
- if (version !== ecies_lib_1.EciesVersionEnum.V1) {
403
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidVersion, undefined, undefined, { version: String(version) });
404
- }
405
- // Read CipherSuite
406
- const cipherSuite = data.readUInt8(offset);
407
- offset += this.cryptoCore.consts.CIPHER_SUITE_SIZE;
408
- if (cipherSuite !== ecies_lib_1.EciesCipherSuiteEnum.Secp256k1_Aes256Gcm_Sha256) {
409
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidCipherSuite, undefined, undefined, { cipherSuite: String(cipherSuite) });
410
- }
411
- // Read Encryption Type
412
- const encryptionType = data.readUInt8(offset);
413
- offset += this.cryptoCore.consts.ENCRYPTION_TYPE_SIZE;
414
- if (encryptionType !== ecies_lib_1.EciesEncryptionTypeEnum.Multiple) {
415
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEncryptionType, undefined, undefined, { encryptionType: encryptionType.toString(16) });
416
- }
417
- // Read Ephemeral Public Key
418
- const ephemeralPublicKey = data.subarray(offset, offset + this.cryptoCore.consts.PUBLIC_KEY_LENGTH);
419
- offset += this.cryptoCore.consts.PUBLIC_KEY_LENGTH;
420
- // Read data length and recipient ID size
421
- const combinedLength = data.readBigUInt64BE(offset);
422
- offset += this.cryptoCore.consts.MULTIPLE.DATA_LENGTH_SIZE; // 8 bytes
423
- // Extract recipient ID size from MSB (top 8 bits)
424
- const storedRecipientIdSize = Number(combinedLength >> 56n);
425
- // Extract data length from lower 56 bits
426
- const dataLength = Number(combinedLength & 0x00ffffffffffffffn);
427
- if (dataLength <= 0 ||
428
- dataLength > this.cryptoCore.consts.MAX_RAW_DATA_SIZE) {
429
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidDataLength);
430
- }
431
- // Use stored recipient ID size if available (non-legacy), otherwise fallback to config
432
- const recipientIdSize = storedRecipientIdSize > 0
433
- ? storedRecipientIdSize
434
- : this.cryptoCore.consts.MULTIPLE.RECIPIENT_ID_SIZE;
435
- // Read recipient count
436
- const recipientCount = data.readUInt16BE(offset);
437
- if (recipientCount <= 0 ||
438
- recipientCount > this.cryptoCore.consts.MULTIPLE.MAX_RECIPIENTS) {
439
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidRecipientCount);
440
- }
441
- offset += this.cryptoCore.consts.MULTIPLE.RECIPIENT_COUNT_SIZE; // 2 bytes
442
- // Ensure there's enough data for all recipients
443
- // Note: We can't use calculateECIESMultipleRecipientOverhead here easily because it assumes fixed ID size
444
- // But we can calculate manually
445
- const remainingHeaderSize = recipientCount * recipientIdSize +
446
- recipientCount * this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE;
447
- if (data.length < offset + remainingHeaderSize) {
448
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidDataLength);
449
- }
450
- // Read recipient IDs
451
- const recipientIds = [];
452
- for (let i = 0; i < recipientCount; i++) {
453
- recipientIds.push(data.subarray(offset, offset + recipientIdSize));
454
- offset += recipientIdSize;
455
- }
456
- // Read encrypted keys with variable lengths based on encryption type
457
- const recipientKeys = [];
458
- for (let i = 0; i < recipientCount; i++) {
459
- if (offset >= data.length) {
460
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidDataLength);
461
- }
462
- if (offset + this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE >
463
- data.length) {
464
- throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidDataLength, undefined, undefined, {
465
- required: String(this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE),
466
- available: String(data.length - offset),
467
- });
468
- }
469
- recipientKeys.push(data.subarray(offset, offset + this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE));
470
- offset += this.cryptoCore.consts.MULTIPLE.ENCRYPTED_KEY_SIZE;
471
- }
472
- return {
473
- dataLength,
474
- recipientCount,
475
- recipientIds,
476
- recipientKeys,
477
- headerSize: offset,
478
- ephemeralPublicKey,
479
- };
480
- }
481
- /**
482
- * Parses a multi-encrypted buffer into its components.
483
- * @param data - The multi-encrypted buffer to parse.
484
- * @returns The parsed multi-encrypted buffer.
485
- */
486
- parseMultiEncryptedBuffer(data) {
487
- const header = this.parseMultiEncryptedHeader(data);
488
- const encryptedMessage = data.subarray(header.headerSize);
489
- return {
490
- ...header,
491
- encryptedMessage,
492
- };
493
- }
494
- }
495
- exports.EciesMultiRecipient = EciesMultiRecipient;
496
- //# sourceMappingURL=multi-recipient.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"multi-recipient.js","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-node-ecies-lib/src/services/ecies/multi-recipient.ts"],"names":[],"mappings":";;;AAAA,0DAOoC;AACpC,mCAKgB;AAOhB,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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