@pezkuwi/util-crypto 14.0.2 → 14.0.4

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 (762) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +4 -4
  3. package/address/addressToEvm.d.ts +5 -0
  4. package/address/addressToEvm.js +8 -0
  5. package/address/check.d.ts +8 -0
  6. package/address/check.js +26 -0
  7. package/address/checksum.d.ts +1 -0
  8. package/address/checksum.js +16 -0
  9. package/address/decode.d.ts +2 -0
  10. package/address/decode.js +29 -0
  11. package/address/defaults.d.ts +6 -0
  12. package/address/defaults.js +8 -0
  13. package/address/derive.d.ts +8 -0
  14. package/address/derive.js +24 -0
  15. package/address/encode.d.ts +2 -0
  16. package/address/encode.js +23 -0
  17. package/address/encodeDerived.d.ts +9 -0
  18. package/address/encodeDerived.js +12 -0
  19. package/address/encodeMulti.d.ts +9 -0
  20. package/address/encodeMulti.js +11 -0
  21. package/address/eq.d.ts +15 -0
  22. package/{src/address/eq.ts → address/eq.js} +2 -7
  23. package/address/evmToAddress.d.ts +7 -0
  24. package/address/evmToAddress.js +14 -0
  25. package/{src/address/index.ts → address/index.d.ts} +0 -5
  26. package/address/index.js +16 -0
  27. package/address/is.d.ts +2 -0
  28. package/address/is.js +9 -0
  29. package/address/keyDerived.d.ts +2 -0
  30. package/address/keyDerived.js +8 -0
  31. package/address/keyMulti.d.ts +2 -0
  32. package/address/keyMulti.js +8 -0
  33. package/address/setSS58Format.d.ts +6 -0
  34. package/address/setSS58Format.js +11 -0
  35. package/address/sort.d.ts +2 -0
  36. package/address/sort.js +7 -0
  37. package/address/sshash.d.ts +1 -0
  38. package/address/sshash.js +6 -0
  39. package/address/types.d.ts +1 -0
  40. package/address/types.js +1 -0
  41. package/address/util.d.ts +1 -0
  42. package/address/util.js +4 -0
  43. package/address/validate.d.ts +2 -0
  44. package/address/validate.js +4 -0
  45. package/base32/bs32.d.ts +26 -0
  46. package/{src/base32/bs32.ts → base32/bs32.js} +8 -21
  47. package/base32/helpers.d.ts +25 -0
  48. package/base32/helpers.js +61 -0
  49. package/{src/base32/index.ts → base32/index.d.ts} +0 -4
  50. package/base32/index.js +4 -0
  51. package/base58/bs58.d.ts +26 -0
  52. package/{src/base58/bs58.ts → base58/bs58.js} +4 -13
  53. package/{src/base58/index.ts → base58/index.d.ts} +0 -4
  54. package/base58/index.js +4 -0
  55. package/base64/bs64.d.ts +26 -0
  56. package/{src/base64/bs64.ts → base64/bs64.js} +4 -13
  57. package/{src/base64/index.ts → base64/index.d.ts} +0 -4
  58. package/base64/index.js +6 -0
  59. package/base64/pad.d.ts +5 -0
  60. package/base64/pad.js +7 -0
  61. package/base64/trim.d.ts +5 -0
  62. package/base64/trim.js +10 -0
  63. package/blake2/asU8a.d.ts +20 -0
  64. package/{src/blake2/asU8a.ts → blake2/asU8a.js} +8 -16
  65. package/{src/blake2/index.ts → blake2/index.d.ts} +0 -4
  66. package/blake2/index.js +4 -0
  67. package/bn.d.ts +30 -0
  68. package/{src/bn.ts → bn.js} +0 -7
  69. package/bridge.d.ts +82 -0
  70. package/bridge.js +168 -0
  71. package/bundle-polkadot-util-crypto.js +11813 -0
  72. package/{src/bundle.ts → bundle.d.ts} +0 -7
  73. package/bundle.js +26 -0
  74. package/bundleInit.d.ts +1 -0
  75. package/bundleInit.js +5 -0
  76. package/cjs/address/addressToEvm.d.ts +5 -0
  77. package/cjs/address/addressToEvm.js +11 -0
  78. package/cjs/address/check.d.ts +8 -0
  79. package/cjs/address/check.js +29 -0
  80. package/cjs/address/checksum.d.ts +1 -0
  81. package/cjs/address/checksum.js +19 -0
  82. package/cjs/address/decode.d.ts +2 -0
  83. package/cjs/address/decode.js +32 -0
  84. package/cjs/address/defaults.d.ts +6 -0
  85. package/cjs/address/defaults.js +11 -0
  86. package/cjs/address/derive.d.ts +8 -0
  87. package/cjs/address/derive.js +27 -0
  88. package/cjs/address/encode.d.ts +2 -0
  89. package/cjs/address/encode.js +26 -0
  90. package/cjs/address/encodeDerived.d.ts +9 -0
  91. package/cjs/address/encodeDerived.js +15 -0
  92. package/cjs/address/encodeMulti.d.ts +9 -0
  93. package/cjs/address/encodeMulti.js +14 -0
  94. package/cjs/address/eq.d.ts +15 -0
  95. package/cjs/address/eq.js +22 -0
  96. package/cjs/address/evmToAddress.d.ts +7 -0
  97. package/cjs/address/evmToAddress.js +17 -0
  98. package/cjs/address/index.d.ts +16 -0
  99. package/cjs/address/index.js +35 -0
  100. package/cjs/address/is.d.ts +2 -0
  101. package/cjs/address/is.js +12 -0
  102. package/cjs/address/keyDerived.d.ts +2 -0
  103. package/cjs/address/keyDerived.js +11 -0
  104. package/cjs/address/keyMulti.d.ts +2 -0
  105. package/cjs/address/keyMulti.js +11 -0
  106. package/cjs/address/setSS58Format.d.ts +6 -0
  107. package/cjs/address/setSS58Format.js +14 -0
  108. package/cjs/address/sort.d.ts +2 -0
  109. package/cjs/address/sort.js +10 -0
  110. package/cjs/address/sshash.d.ts +1 -0
  111. package/cjs/address/sshash.js +9 -0
  112. package/cjs/address/types.d.ts +1 -0
  113. package/cjs/address/types.js +2 -0
  114. package/cjs/address/util.d.ts +1 -0
  115. package/cjs/address/util.js +7 -0
  116. package/cjs/address/validate.d.ts +2 -0
  117. package/cjs/address/validate.js +7 -0
  118. package/cjs/base32/bs32.d.ts +26 -0
  119. package/cjs/base32/bs32.js +43 -0
  120. package/cjs/base32/helpers.d.ts +25 -0
  121. package/cjs/base32/helpers.js +67 -0
  122. package/cjs/base32/index.d.ts +4 -0
  123. package/cjs/base32/index.js +11 -0
  124. package/cjs/base58/bs58.d.ts +26 -0
  125. package/cjs/base58/bs58.js +37 -0
  126. package/cjs/base58/index.d.ts +4 -0
  127. package/cjs/base58/index.js +11 -0
  128. package/cjs/base64/bs64.d.ts +26 -0
  129. package/cjs/base64/bs64.js +37 -0
  130. package/cjs/base64/index.d.ts +6 -0
  131. package/cjs/base64/index.js +15 -0
  132. package/cjs/base64/pad.d.ts +5 -0
  133. package/cjs/base64/pad.js +10 -0
  134. package/cjs/base64/trim.d.ts +5 -0
  135. package/cjs/base64/trim.js +13 -0
  136. package/cjs/blake2/asU8a.d.ts +20 -0
  137. package/cjs/blake2/asU8a.js +36 -0
  138. package/cjs/blake2/index.d.ts +4 -0
  139. package/cjs/blake2/index.js +9 -0
  140. package/cjs/bn.d.ts +30 -0
  141. package/cjs/bn.js +11 -0
  142. package/cjs/bridge.d.ts +82 -0
  143. package/cjs/bridge.js +172 -0
  144. package/cjs/bundle.d.ts +26 -0
  145. package/cjs/bundle.js +31 -0
  146. package/cjs/bundleInit.d.ts +1 -0
  147. package/cjs/bundleInit.js +7 -0
  148. package/cjs/crypto.d.ts +3 -0
  149. package/cjs/crypto.js +16 -0
  150. package/cjs/ed25519/deriveHard.d.ts +1 -0
  151. package/cjs/ed25519/deriveHard.js +12 -0
  152. package/{src/ed25519/index.ts → cjs/ed25519/index.d.ts} +0 -3
  153. package/cjs/ed25519/index.js +20 -0
  154. package/cjs/ed25519/pair/fromRandom.d.ts +16 -0
  155. package/cjs/ed25519/pair/fromRandom.js +22 -0
  156. package/cjs/ed25519/pair/fromSecret.d.ts +16 -0
  157. package/{src/ed25519/pair/fromSecret.ts → cjs/ed25519/pair/fromSecret.js} +11 -14
  158. package/cjs/ed25519/pair/fromSeed.d.ts +16 -0
  159. package/cjs/ed25519/pair/fromSeed.js +34 -0
  160. package/cjs/ed25519/pair/fromString.d.ts +16 -0
  161. package/cjs/ed25519/pair/fromString.js +23 -0
  162. package/cjs/ed25519/sign.d.ts +16 -0
  163. package/cjs/ed25519/sign.js +33 -0
  164. package/cjs/ed25519/verify.d.ts +15 -0
  165. package/cjs/ed25519/verify.js +39 -0
  166. package/cjs/ethereum/encode.d.ts +2 -0
  167. package/cjs/ethereum/encode.js +28 -0
  168. package/{src/ethereum/index.ts → cjs/ethereum/index.d.ts} +0 -3
  169. package/cjs/ethereum/index.js +9 -0
  170. package/cjs/ethereum/isAddress.d.ts +1 -0
  171. package/cjs/ethereum/isAddress.js +14 -0
  172. package/cjs/ethereum/isChecksum.d.ts +1 -0
  173. package/cjs/ethereum/isChecksum.js +20 -0
  174. package/cjs/hd/ethereum/index.d.ts +2 -0
  175. package/cjs/hd/ethereum/index.js +47 -0
  176. package/{src/hd/index.ts → cjs/hd/index.d.ts} +0 -3
  177. package/cjs/hd/index.js +9 -0
  178. package/cjs/hd/ledger/derivePrivate.d.ts +1 -0
  179. package/cjs/hd/ledger/derivePrivate.js +15 -0
  180. package/cjs/hd/ledger/index.d.ts +2 -0
  181. package/cjs/hd/ledger/index.js +33 -0
  182. package/cjs/hd/ledger/master.d.ts +1 -0
  183. package/cjs/hd/ledger/master.js +19 -0
  184. package/cjs/hd/validatePath.d.ts +2 -0
  185. package/cjs/hd/validatePath.js +20 -0
  186. package/cjs/helpers.d.ts +12 -0
  187. package/cjs/helpers.js +24 -0
  188. package/cjs/hmac/index.d.ts +1 -0
  189. package/cjs/hmac/index.js +7 -0
  190. package/cjs/hmac/shaAsU8a.d.ts +15 -0
  191. package/cjs/hmac/shaAsU8a.js +40 -0
  192. package/cjs/index.d.ts +2 -0
  193. package/cjs/index.js +5 -0
  194. package/cjs/init.d.ts +10 -0
  195. package/cjs/init.js +43 -0
  196. package/cjs/json/constants.d.ts +6 -0
  197. package/cjs/json/constants.js +8 -0
  198. package/cjs/json/decrypt.d.ts +2 -0
  199. package/cjs/json/decrypt.js +16 -0
  200. package/cjs/json/decryptData.d.ts +2 -0
  201. package/cjs/json/decryptData.js +32 -0
  202. package/cjs/json/encrypt.d.ts +2 -0
  203. package/cjs/json/encrypt.js +18 -0
  204. package/cjs/json/encryptFormat.d.ts +2 -0
  205. package/cjs/json/encryptFormat.js +17 -0
  206. package/{src/json/index.ts → cjs/json/index.d.ts} +0 -3
  207. package/cjs/json/index.js +11 -0
  208. package/cjs/json/types.d.ts +16 -0
  209. package/cjs/json/types.js +2 -0
  210. package/cjs/keccak/asU8a.d.ts +30 -0
  211. package/cjs/keccak/asU8a.js +36 -0
  212. package/{src/keccak/index.ts → cjs/keccak/index.d.ts} +0 -4
  213. package/cjs/keccak/index.js +11 -0
  214. package/cjs/key/DeriveJunction.d.ts +12 -0
  215. package/cjs/key/DeriveJunction.js +62 -0
  216. package/cjs/key/extractPath.d.ts +9 -0
  217. package/cjs/key/extractPath.js +26 -0
  218. package/cjs/key/extractSuri.d.ts +11 -0
  219. package/cjs/key/extractSuri.js +25 -0
  220. package/cjs/key/fromPath.d.ts +3 -0
  221. package/cjs/key/fromPath.js +21 -0
  222. package/cjs/key/hdkdDerive.d.ts +3 -0
  223. package/cjs/key/hdkdDerive.js +11 -0
  224. package/cjs/key/hdkdEcdsa.d.ts +1 -0
  225. package/cjs/key/hdkdEcdsa.js +7 -0
  226. package/cjs/key/hdkdEd25519.d.ts +1 -0
  227. package/cjs/key/hdkdEd25519.js +6 -0
  228. package/cjs/key/hdkdSr25519.d.ts +3 -0
  229. package/cjs/key/hdkdSr25519.js +10 -0
  230. package/{src/key/index.ts → cjs/key/index.d.ts} +0 -3
  231. package/cjs/key/index.js +18 -0
  232. package/cjs/mnemonic/bip39.d.ts +5 -0
  233. package/cjs/mnemonic/bip39.js +90 -0
  234. package/cjs/mnemonic/generate.d.ts +13 -0
  235. package/cjs/mnemonic/generate.js +23 -0
  236. package/{src/mnemonic/index.ts → cjs/mnemonic/index.d.ts} +0 -3
  237. package/cjs/mnemonic/index.js +16 -0
  238. package/cjs/mnemonic/toEntropy.d.ts +1 -0
  239. package/cjs/mnemonic/toEntropy.js +11 -0
  240. package/cjs/mnemonic/toLegacySeed.d.ts +18 -0
  241. package/cjs/mnemonic/toLegacySeed.js +37 -0
  242. package/cjs/mnemonic/toMiniSecret.d.ts +1 -0
  243. package/cjs/mnemonic/toMiniSecret.js +20 -0
  244. package/cjs/mnemonic/validate.d.ts +14 -0
  245. package/cjs/mnemonic/validate.js +24 -0
  246. package/cjs/mnemonic/wordlists/en.d.ts +2 -0
  247. package/cjs/mnemonic/wordlists/en.js +3 -0
  248. package/cjs/mnemonic/wordlists/es.d.ts +2 -0
  249. package/cjs/mnemonic/wordlists/es.js +3 -0
  250. package/cjs/mnemonic/wordlists/fr.d.ts +2 -0
  251. package/cjs/mnemonic/wordlists/fr.js +3 -0
  252. package/{src/mnemonic/wordlists/index.ts → cjs/mnemonic/wordlists/index.d.ts} +0 -3
  253. package/cjs/mnemonic/wordlists/index.js +20 -0
  254. package/cjs/mnemonic/wordlists/it.d.ts +2 -0
  255. package/cjs/mnemonic/wordlists/it.js +3 -0
  256. package/cjs/mnemonic/wordlists/jp.d.ts +2 -0
  257. package/cjs/mnemonic/wordlists/jp.js +3 -0
  258. package/cjs/mnemonic/wordlists/ko.d.ts +2 -0
  259. package/cjs/mnemonic/wordlists/ko.js +3 -0
  260. package/cjs/mnemonic/wordlists/zh-s.d.ts +2 -0
  261. package/cjs/mnemonic/wordlists/zh-s.js +3 -0
  262. package/cjs/mnemonic/wordlists/zh-t.d.ts +2 -0
  263. package/cjs/mnemonic/wordlists/zh-t.js +3 -0
  264. package/cjs/nacl/decrypt.d.ts +15 -0
  265. package/cjs/nacl/decrypt.js +21 -0
  266. package/cjs/nacl/encrypt.d.ts +20 -0
  267. package/cjs/nacl/encrypt.js +25 -0
  268. package/{src/nacl/index.ts → cjs/nacl/index.d.ts} +0 -3
  269. package/cjs/nacl/index.js +10 -0
  270. package/cjs/nacl/tweetnacl.d.ts +2 -0
  271. package/cjs/nacl/tweetnacl.js +238 -0
  272. package/cjs/networks.d.ts +1 -0
  273. package/cjs/networks.js +7 -0
  274. package/cjs/package.json +3 -0
  275. package/cjs/packageDetect.d.ts +1 -0
  276. package/cjs/packageDetect.js +8 -0
  277. package/cjs/packageInfo.d.ts +6 -0
  278. package/cjs/packageInfo.js +4 -0
  279. package/cjs/pbkdf2/encode.d.ts +7 -0
  280. package/cjs/pbkdf2/encode.js +19 -0
  281. package/cjs/pbkdf2/index.d.ts +1 -0
  282. package/cjs/pbkdf2/index.js +5 -0
  283. package/cjs/random/asNumber.d.ts +15 -0
  284. package/cjs/random/asNumber.js +23 -0
  285. package/cjs/random/asU8a.d.ts +20 -0
  286. package/cjs/random/asU8a.js +28 -0
  287. package/{src/random/index.ts → cjs/random/index.d.ts} +0 -4
  288. package/cjs/random/index.js +11 -0
  289. package/cjs/scrypt/defaults.d.ts +3 -0
  290. package/cjs/scrypt/defaults.js +16 -0
  291. package/cjs/scrypt/encode.d.ts +8 -0
  292. package/cjs/scrypt/encode.js +18 -0
  293. package/cjs/scrypt/fromU8a.d.ts +7 -0
  294. package/cjs/scrypt/fromU8a.js +27 -0
  295. package/{src/scrypt/index.ts → cjs/scrypt/index.d.ts} +0 -3
  296. package/cjs/scrypt/index.js +9 -0
  297. package/cjs/scrypt/toU8a.d.ts +2 -0
  298. package/cjs/scrypt/toU8a.js +8 -0
  299. package/cjs/scrypt/types.d.ts +6 -0
  300. package/cjs/scrypt/types.js +2 -0
  301. package/cjs/secp256k1/compress.d.ts +1 -0
  302. package/cjs/secp256k1/compress.js +17 -0
  303. package/cjs/secp256k1/deriveHard.d.ts +1 -0
  304. package/cjs/secp256k1/deriveHard.js +13 -0
  305. package/cjs/secp256k1/expand.d.ts +1 -0
  306. package/cjs/secp256k1/expand.js +20 -0
  307. package/cjs/secp256k1/hasher.d.ts +2 -0
  308. package/cjs/secp256k1/hasher.js +10 -0
  309. package/{src/secp256k1/index.ts → cjs/secp256k1/index.d.ts} +0 -3
  310. package/cjs/secp256k1/index.js +17 -0
  311. package/cjs/secp256k1/pair/fromSeed.d.ts +6 -0
  312. package/cjs/secp256k1/pair/fromSeed.js +34 -0
  313. package/cjs/secp256k1/recover.d.ts +6 -0
  314. package/cjs/secp256k1/recover.js +29 -0
  315. package/cjs/secp256k1/sign.d.ts +7 -0
  316. package/cjs/secp256k1/sign.js +23 -0
  317. package/cjs/secp256k1/tweakAdd.d.ts +1 -0
  318. package/cjs/secp256k1/tweakAdd.js +48 -0
  319. package/cjs/secp256k1/types.d.ts +1 -0
  320. package/cjs/secp256k1/types.js +2 -0
  321. package/cjs/secp256k1/verify.d.ts +6 -0
  322. package/cjs/secp256k1/verify.js +23 -0
  323. package/cjs/sha/asU8a.d.ts +15 -0
  324. package/cjs/sha/asU8a.js +22 -0
  325. package/{src/sha/index.ts → cjs/sha/index.d.ts} +0 -4
  326. package/cjs/sha/index.js +10 -0
  327. package/cjs/signature/index.d.ts +4 -0
  328. package/cjs/signature/index.js +8 -0
  329. package/cjs/signature/verify.d.ts +2 -0
  330. package/cjs/signature/verify.js +81 -0
  331. package/cjs/sr25519/agreement.d.ts +5 -0
  332. package/cjs/sr25519/agreement.js +20 -0
  333. package/cjs/sr25519/derive.d.ts +2 -0
  334. package/cjs/sr25519/derive.js +16 -0
  335. package/cjs/sr25519/deriveHard.d.ts +1 -0
  336. package/cjs/sr25519/deriveHard.js +7 -0
  337. package/cjs/sr25519/derivePublic.d.ts +1 -0
  338. package/cjs/sr25519/derivePublic.js +16 -0
  339. package/cjs/sr25519/deriveSoft.d.ts +1 -0
  340. package/cjs/sr25519/deriveSoft.js +7 -0
  341. package/{src/sr25519/index.ts → cjs/sr25519/index.d.ts} +0 -3
  342. package/cjs/sr25519/index.js +21 -0
  343. package/cjs/sr25519/pair/fromSeed.d.ts +6 -0
  344. package/cjs/sr25519/pair/fromSeed.js +22 -0
  345. package/cjs/sr25519/pair/fromU8a.d.ts +2 -0
  346. package/cjs/sr25519/pair/fromU8a.js +17 -0
  347. package/cjs/sr25519/pair/toU8a.d.ts +2 -0
  348. package/cjs/sr25519/pair/toU8a.js +7 -0
  349. package/cjs/sr25519/sign.d.ts +6 -0
  350. package/cjs/sr25519/sign.js +19 -0
  351. package/cjs/sr25519/verify.d.ts +5 -0
  352. package/cjs/sr25519/verify.js +21 -0
  353. package/cjs/sr25519/vrfSign.d.ts +6 -0
  354. package/cjs/sr25519/vrfSign.js +19 -0
  355. package/cjs/sr25519/vrfVerify.d.ts +5 -0
  356. package/cjs/sr25519/vrfVerify.js +22 -0
  357. package/cjs/types.d.ts +26 -0
  358. package/cjs/types.js +5 -0
  359. package/cjs/wbg.d.ts +36 -0
  360. package/cjs/wbg.js +65 -0
  361. package/cjs/xxhash/asU8a.d.ts +20 -0
  362. package/cjs/xxhash/asU8a.js +39 -0
  363. package/{src/xxhash/index.ts → cjs/xxhash/index.d.ts} +0 -4
  364. package/cjs/xxhash/index.js +9 -0
  365. package/cjs/xxhash/xxhash64.d.ts +1 -0
  366. package/cjs/xxhash/xxhash64.js +103 -0
  367. package/crypto.d.ts +3 -0
  368. package/crypto.js +12 -0
  369. package/ed25519/deriveHard.d.ts +1 -0
  370. package/ed25519/deriveHard.js +9 -0
  371. package/ed25519/index.d.ts +10 -0
  372. package/ed25519/index.js +10 -0
  373. package/ed25519/pair/fromRandom.d.ts +16 -0
  374. package/{src/ed25519/pair/fromRandom.ts → ed25519/pair/fromRandom.js} +2 -8
  375. package/ed25519/pair/fromSecret.d.ts +16 -0
  376. package/ed25519/pair/fromSecret.js +23 -0
  377. package/ed25519/pair/fromSeed.d.ts +16 -0
  378. package/{src/ed25519/pair/fromSeed.ts → ed25519/pair/fromSeed.js} +11 -21
  379. package/ed25519/pair/fromString.d.ts +16 -0
  380. package/{src/ed25519/pair/fromString.ts → ed25519/pair/fromString.js} +2 -13
  381. package/ed25519/sign.d.ts +16 -0
  382. package/ed25519/sign.js +30 -0
  383. package/ed25519/verify.d.ts +15 -0
  384. package/ed25519/verify.js +36 -0
  385. package/ethereum/encode.d.ts +2 -0
  386. package/ethereum/encode.js +25 -0
  387. package/ethereum/index.d.ts +3 -0
  388. package/ethereum/index.js +3 -0
  389. package/ethereum/isAddress.d.ts +1 -0
  390. package/ethereum/isAddress.js +11 -0
  391. package/ethereum/isChecksum.d.ts +1 -0
  392. package/ethereum/isChecksum.js +17 -0
  393. package/hd/ethereum/index.d.ts +2 -0
  394. package/hd/ethereum/index.js +44 -0
  395. package/hd/index.d.ts +3 -0
  396. package/hd/index.js +3 -0
  397. package/hd/ledger/derivePrivate.d.ts +1 -0
  398. package/hd/ledger/derivePrivate.js +12 -0
  399. package/hd/ledger/index.d.ts +2 -0
  400. package/hd/ledger/index.js +30 -0
  401. package/hd/ledger/master.d.ts +1 -0
  402. package/hd/ledger/master.js +16 -0
  403. package/hd/validatePath.d.ts +2 -0
  404. package/hd/validatePath.js +16 -0
  405. package/helpers.d.ts +12 -0
  406. package/helpers.js +19 -0
  407. package/hmac/index.d.ts +1 -0
  408. package/hmac/index.js +1 -0
  409. package/hmac/shaAsU8a.d.ts +15 -0
  410. package/{src/hmac/shaAsU8a.ts → hmac/shaAsU8a.js} +11 -23
  411. package/index.d.ts +2 -0
  412. package/index.js +2 -0
  413. package/init.d.ts +10 -0
  414. package/init.js +40 -0
  415. package/json/constants.d.ts +6 -0
  416. package/json/constants.js +5 -0
  417. package/json/decrypt.d.ts +2 -0
  418. package/json/decrypt.js +13 -0
  419. package/json/decryptData.d.ts +2 -0
  420. package/json/decryptData.js +29 -0
  421. package/json/encrypt.d.ts +2 -0
  422. package/json/encrypt.js +15 -0
  423. package/json/encryptFormat.d.ts +2 -0
  424. package/json/encryptFormat.js +14 -0
  425. package/json/index.d.ts +4 -0
  426. package/json/index.js +4 -0
  427. package/json/types.d.ts +16 -0
  428. package/json/types.js +1 -0
  429. package/keccak/asU8a.d.ts +30 -0
  430. package/{src/keccak/asU8a.ts → keccak/asU8a.js} +1 -13
  431. package/keccak/index.d.ts +4 -0
  432. package/keccak/index.js +4 -0
  433. package/key/DeriveJunction.d.ts +12 -0
  434. package/key/DeriveJunction.js +58 -0
  435. package/key/extractPath.d.ts +9 -0
  436. package/key/extractPath.js +23 -0
  437. package/key/extractSuri.d.ts +11 -0
  438. package/key/extractSuri.js +22 -0
  439. package/key/fromPath.d.ts +3 -0
  440. package/key/fromPath.js +18 -0
  441. package/key/hdkdDerive.d.ts +3 -0
  442. package/key/hdkdDerive.js +8 -0
  443. package/key/hdkdEcdsa.d.ts +1 -0
  444. package/{src/key/hdkdEcdsa.ts → key/hdkdEcdsa.js} +0 -4
  445. package/key/hdkdEd25519.d.ts +1 -0
  446. package/{src/key/hdkdEd25519.ts → key/hdkdEd25519.js} +0 -4
  447. package/key/hdkdSr25519.d.ts +3 -0
  448. package/key/hdkdSr25519.js +7 -0
  449. package/key/index.d.ts +9 -0
  450. package/key/index.js +9 -0
  451. package/mnemonic/bip39.d.ts +5 -0
  452. package/mnemonic/bip39.js +82 -0
  453. package/mnemonic/generate.d.ts +13 -0
  454. package/{src/mnemonic/generate.ts → mnemonic/generate.js} +4 -9
  455. package/mnemonic/index.d.ts +8 -0
  456. package/mnemonic/index.js +8 -0
  457. package/mnemonic/toEntropy.d.ts +1 -0
  458. package/mnemonic/toEntropy.js +8 -0
  459. package/mnemonic/toLegacySeed.d.ts +18 -0
  460. package/{src/mnemonic/toLegacySeed.ts → mnemonic/toLegacySeed.js} +12 -17
  461. package/mnemonic/toMiniSecret.d.ts +1 -0
  462. package/mnemonic/toMiniSecret.js +17 -0
  463. package/mnemonic/validate.d.ts +14 -0
  464. package/{src/mnemonic/validate.ts → mnemonic/validate.js} +4 -9
  465. package/mnemonic/wordlists/en.d.ts +2 -0
  466. package/{src/mnemonic/wordlists/en.ts → mnemonic/wordlists/en.js} +0 -6
  467. package/mnemonic/wordlists/es.d.ts +2 -0
  468. package/{src/mnemonic/wordlists/es.ts → mnemonic/wordlists/es.js} +0 -6
  469. package/mnemonic/wordlists/fr.d.ts +2 -0
  470. package/{src/mnemonic/wordlists/fr.ts → mnemonic/wordlists/fr.js} +0 -6
  471. package/mnemonic/wordlists/index.d.ts +8 -0
  472. package/mnemonic/wordlists/index.js +8 -0
  473. package/mnemonic/wordlists/it.d.ts +2 -0
  474. package/{src/mnemonic/wordlists/it.ts → mnemonic/wordlists/it.js} +0 -6
  475. package/mnemonic/wordlists/jp.d.ts +2 -0
  476. package/{src/mnemonic/wordlists/jp.ts → mnemonic/wordlists/jp.js} +0 -6
  477. package/mnemonic/wordlists/ko.d.ts +2 -0
  478. package/{src/mnemonic/wordlists/ko.ts → mnemonic/wordlists/ko.js} +0 -6
  479. package/mnemonic/wordlists/zh-s.d.ts +2 -0
  480. package/{src/mnemonic/wordlists/zh-s.ts → mnemonic/wordlists/zh-s.js} +0 -6
  481. package/mnemonic/wordlists/zh-t.d.ts +2 -0
  482. package/{src/mnemonic/wordlists/zh-t.ts → mnemonic/wordlists/zh-t.js} +0 -6
  483. package/nacl/decrypt.d.ts +15 -0
  484. package/{src/nacl/decrypt.ts → nacl/decrypt.js} +2 -6
  485. package/nacl/encrypt.d.ts +20 -0
  486. package/{src/nacl/encrypt.ts → nacl/encrypt.js} +5 -14
  487. package/nacl/index.d.ts +5 -0
  488. package/nacl/index.js +5 -0
  489. package/nacl/tweetnacl.d.ts +2 -0
  490. package/nacl/tweetnacl.js +234 -0
  491. package/networks.d.ts +1 -0
  492. package/networks.js +1 -0
  493. package/package.json +2022 -10
  494. package/packageDetect.d.ts +1 -0
  495. package/{src/packageDetect.ts → packageDetect.js} +0 -8
  496. package/packageInfo.d.ts +6 -0
  497. package/packageInfo.js +1 -0
  498. package/pbkdf2/encode.d.ts +7 -0
  499. package/pbkdf2/encode.js +16 -0
  500. package/pbkdf2/index.d.ts +1 -0
  501. package/pbkdf2/index.js +1 -0
  502. package/random/asNumber.d.ts +15 -0
  503. package/{src/random/asNumber.ts → random/asNumber.js} +2 -10
  504. package/random/asU8a.d.ts +20 -0
  505. package/{src/random/asU8a.ts → random/asU8a.js} +2 -8
  506. package/random/index.d.ts +5 -0
  507. package/random/index.js +5 -0
  508. package/scrypt/defaults.d.ts +3 -0
  509. package/scrypt/defaults.js +13 -0
  510. package/scrypt/encode.d.ts +8 -0
  511. package/scrypt/encode.js +15 -0
  512. package/scrypt/fromU8a.d.ts +7 -0
  513. package/scrypt/fromU8a.js +24 -0
  514. package/scrypt/index.d.ts +3 -0
  515. package/scrypt/index.js +3 -0
  516. package/scrypt/toU8a.d.ts +2 -0
  517. package/scrypt/toU8a.js +5 -0
  518. package/scrypt/types.d.ts +6 -0
  519. package/scrypt/types.js +1 -0
  520. package/secp256k1/compress.d.ts +1 -0
  521. package/secp256k1/compress.js +14 -0
  522. package/secp256k1/deriveHard.d.ts +1 -0
  523. package/secp256k1/deriveHard.js +10 -0
  524. package/secp256k1/expand.d.ts +1 -0
  525. package/secp256k1/expand.js +17 -0
  526. package/secp256k1/hasher.d.ts +2 -0
  527. package/secp256k1/hasher.js +7 -0
  528. package/secp256k1/index.d.ts +7 -0
  529. package/secp256k1/index.js +7 -0
  530. package/secp256k1/pair/fromSeed.d.ts +6 -0
  531. package/secp256k1/pair/fromSeed.js +31 -0
  532. package/secp256k1/recover.d.ts +6 -0
  533. package/secp256k1/recover.js +26 -0
  534. package/secp256k1/sign.d.ts +7 -0
  535. package/secp256k1/sign.js +20 -0
  536. package/secp256k1/tweakAdd.d.ts +1 -0
  537. package/secp256k1/tweakAdd.js +45 -0
  538. package/secp256k1/types.d.ts +1 -0
  539. package/secp256k1/types.js +1 -0
  540. package/secp256k1/verify.d.ts +6 -0
  541. package/secp256k1/verify.js +20 -0
  542. package/sha/asU8a.d.ts +15 -0
  543. package/{src/sha/asU8a.ts → sha/asU8a.js} +1 -12
  544. package/sha/index.d.ts +4 -0
  545. package/sha/index.js +4 -0
  546. package/signature/index.d.ts +4 -0
  547. package/signature/index.js +4 -0
  548. package/signature/verify.d.ts +2 -0
  549. package/signature/verify.js +78 -0
  550. package/sr25519/agreement.d.ts +5 -0
  551. package/sr25519/agreement.js +17 -0
  552. package/sr25519/derive.d.ts +2 -0
  553. package/sr25519/derive.js +12 -0
  554. package/sr25519/deriveHard.d.ts +1 -0
  555. package/{src/sr25519/deriveHard.ts → sr25519/deriveHard.js} +0 -6
  556. package/sr25519/derivePublic.d.ts +1 -0
  557. package/sr25519/derivePublic.js +12 -0
  558. package/sr25519/deriveSoft.d.ts +1 -0
  559. package/{src/sr25519/deriveSoft.ts → sr25519/deriveSoft.js} +0 -6
  560. package/sr25519/index.d.ts +9 -0
  561. package/sr25519/index.js +9 -0
  562. package/sr25519/pair/fromSeed.d.ts +6 -0
  563. package/sr25519/pair/fromSeed.js +18 -0
  564. package/sr25519/pair/fromU8a.d.ts +2 -0
  565. package/sr25519/pair/fromU8a.js +14 -0
  566. package/sr25519/pair/toU8a.d.ts +2 -0
  567. package/sr25519/pair/toU8a.js +4 -0
  568. package/sr25519/sign.d.ts +6 -0
  569. package/sr25519/sign.js +15 -0
  570. package/sr25519/verify.d.ts +5 -0
  571. package/sr25519/verify.js +17 -0
  572. package/sr25519/vrfSign.d.ts +6 -0
  573. package/sr25519/vrfSign.js +15 -0
  574. package/sr25519/vrfVerify.d.ts +5 -0
  575. package/sr25519/vrfVerify.js +18 -0
  576. package/types.d.ts +26 -0
  577. package/types.js +2 -0
  578. package/wbg.d.ts +36 -0
  579. package/wbg.js +61 -0
  580. package/xxhash/asU8a.d.ts +20 -0
  581. package/{src/xxhash/asU8a.ts → xxhash/asU8a.js} +11 -21
  582. package/xxhash/index.d.ts +4 -0
  583. package/xxhash/index.js +4 -0
  584. package/xxhash/xxhash64.d.ts +1 -0
  585. package/xxhash/xxhash64.js +100 -0
  586. package/src/address/addressToEvm.spec.ts +0 -16
  587. package/src/address/addressToEvm.ts +0 -12
  588. package/src/address/check.spec.ts +0 -44
  589. package/src/address/check.ts +0 -34
  590. package/src/address/checksum.spec.ts +0 -45
  591. package/src/address/checksum.ts +0 -25
  592. package/src/address/decode.spec.ts +0 -138
  593. package/src/address/decode.ts +0 -41
  594. package/src/address/defaults.ts +0 -12
  595. package/src/address/derive.spec.ts +0 -26
  596. package/src/address/derive.ts +0 -36
  597. package/src/address/encode.spec.ts +0 -177
  598. package/src/address/encode.ts +0 -43
  599. package/src/address/encodeDerived.spec.ts +0 -14
  600. package/src/address/encodeDerived.ts +0 -19
  601. package/src/address/encodeMulti.spec.ts +0 -18
  602. package/src/address/encodeMulti.ts +0 -18
  603. package/src/address/eq.spec.ts +0 -45
  604. package/src/address/evmToAddress.spec.ts +0 -20
  605. package/src/address/evmToAddress.ts +0 -24
  606. package/src/address/is.spec.ts +0 -113
  607. package/src/address/is.ts +0 -14
  608. package/src/address/keyDerived.spec.ts +0 -24
  609. package/src/address/keyDerived.ts +0 -22
  610. package/src/address/keyMulti.spec.ts +0 -20
  611. package/src/address/keyMulti.ts +0 -23
  612. package/src/address/setSS58Format.spec.ts +0 -21
  613. package/src/address/setSS58Format.ts +0 -20
  614. package/src/address/sort.spec.ts +0 -22
  615. package/src/address/sort.ts +0 -17
  616. package/src/address/sshash.ts +0 -12
  617. package/src/address/types.ts +0 -6
  618. package/src/address/util.ts +0 -8
  619. package/src/address/validate.spec.ts +0 -113
  620. package/src/address/validate.ts +0 -10
  621. package/src/base32/decode.spec.ts +0 -34
  622. package/src/base32/encode.spec.ts +0 -30
  623. package/src/base32/helpers.ts +0 -93
  624. package/src/base32/is.spec.ts +0 -32
  625. package/src/base32/validate.spec.ts +0 -44
  626. package/src/base58/decode.spec.ts +0 -31
  627. package/src/base58/encode.spec.ts +0 -26
  628. package/src/base58/validate.spec.ts +0 -20
  629. package/src/base64/decode.spec.ts +0 -42
  630. package/src/base64/encode.spec.ts +0 -14
  631. package/src/base64/pad.spec.ts +0 -14
  632. package/src/base64/pad.ts +0 -10
  633. package/src/base64/trim.spec.ts +0 -14
  634. package/src/base64/trim.ts +0 -14
  635. package/src/base64/validate.spec.ts +0 -32
  636. package/src/blake2/asHex.spec.ts +0 -57
  637. package/src/blake2/asU8a.spec.ts +0 -74
  638. package/src/bundleInit.ts +0 -11
  639. package/src/crypto.spec.ts +0 -18
  640. package/src/crypto.ts +0 -18
  641. package/src/ed25519/deriveHard.ts +0 -18
  642. package/src/ed25519/pair/fromRandom.spec.ts +0 -28
  643. package/src/ed25519/pair/fromSecret.spec.ts +0 -33
  644. package/src/ed25519/pair/fromSeed.spec.ts +0 -42
  645. package/src/ed25519/pair/fromString.spec.ts +0 -17
  646. package/src/ed25519/sign.spec.ts +0 -40
  647. package/src/ed25519/sign.ts +0 -38
  648. package/src/ed25519/verify.spec.ts +0 -84
  649. package/src/ed25519/verify.ts +0 -41
  650. package/src/ethereum/encode.spec.ts +0 -59
  651. package/src/ethereum/encode.ts +0 -39
  652. package/src/ethereum/isAddress.spec.ts +0 -34
  653. package/src/ethereum/isAddress.ts +0 -16
  654. package/src/ethereum/isChecksum.ts +0 -27
  655. package/src/ethereum/isCheksum.spec.ts +0 -30
  656. package/src/hd/ethereum/index.spec.ts +0 -54
  657. package/src/hd/ethereum/index.ts +0 -69
  658. package/src/hd/ledger/derivePrivate.ts +0 -34
  659. package/src/hd/ledger/index.spec.ts +0 -64
  660. package/src/hd/ledger/index.ts +0 -42
  661. package/src/hd/ledger/master.spec.ts +0 -19
  662. package/src/hd/ledger/master.ts +0 -26
  663. package/src/hd/validatePath.spec.ts +0 -30
  664. package/src/hd/validatePath.ts +0 -24
  665. package/src/helpers.ts +0 -38
  666. package/src/hmac/index.ts +0 -4
  667. package/src/hmac/shaAsU8a.spec.ts +0 -45
  668. package/src/index.ts +0 -6
  669. package/src/json/constants.ts +0 -11
  670. package/src/json/decrypt.ts +0 -25
  671. package/src/json/decryptData.ts +0 -45
  672. package/src/json/encrypt.ts +0 -25
  673. package/src/json/encryptFormat.ts +0 -20
  674. package/src/json/types.ts +0 -22
  675. package/src/keccak/asHex.spec.ts +0 -30
  676. package/src/keccak/asU8a.spec.ts +0 -56
  677. package/src/key/DeriveJunction.ts +0 -79
  678. package/src/key/extractPath.spec.ts +0 -51
  679. package/src/key/extractPath.ts +0 -37
  680. package/src/key/extractSuri.spec.ts +0 -147
  681. package/src/key/extractSuri.ts +0 -40
  682. package/src/key/fromPath.ts +0 -28
  683. package/src/key/hdkdDerive.ts +0 -17
  684. package/src/key/hdkdSr25519.ts +0 -14
  685. package/src/mnemonic/bip39.spec.ts +0 -80
  686. package/src/mnemonic/bip39.ts +0 -127
  687. package/src/mnemonic/generate.spec.ts +0 -58
  688. package/src/mnemonic/toEntropy.spec.ts +0 -36
  689. package/src/mnemonic/toEntropy.ts +0 -13
  690. package/src/mnemonic/toLegacySeed.spec.ts +0 -52
  691. package/src/mnemonic/toMiniSecret.spec.ts +0 -67
  692. package/src/mnemonic/toMiniSecret.ts +0 -23
  693. package/src/mnemonic/toMiniSecretCmp.spec.ts +0 -64
  694. package/src/mnemonic/validate.spec.ts +0 -39
  695. package/src/mod.ts +0 -4
  696. package/src/nacl/decrypt.spec.ts +0 -26
  697. package/src/nacl/encrypt.spec.ts +0 -20
  698. package/src/nacl/tweetnacl-secretbox-data.spec.ts +0 -4629
  699. package/src/nacl/tweetnacl-secretbox.spec.ts +0 -161
  700. package/src/nacl/tweetnacl.ts +0 -1159
  701. package/src/networks.ts +0 -5
  702. package/src/packageInfo.ts +0 -6
  703. package/src/pbkdf2/encode.spec.ts +0 -54
  704. package/src/pbkdf2/encode.ts +0 -29
  705. package/src/pbkdf2/index.ts +0 -4
  706. package/src/random/asHex.spec.ts +0 -38
  707. package/src/random/asNumber.spec.ts +0 -16
  708. package/src/random/asU8a.spec.ts +0 -36
  709. package/src/scrypt/defaults.ts +0 -19
  710. package/src/scrypt/encode.spec.ts +0 -43
  711. package/src/scrypt/encode.ts +0 -30
  712. package/src/scrypt/fromU8a.ts +0 -44
  713. package/src/scrypt/toU8a.ts +0 -17
  714. package/src/scrypt/types.ts +0 -9
  715. package/src/secp256k1/compress.spec.ts +0 -47
  716. package/src/secp256k1/compress.ts +0 -21
  717. package/src/secp256k1/deriveHard.ts +0 -17
  718. package/src/secp256k1/expand.spec.ts +0 -47
  719. package/src/secp256k1/expand.ts +0 -30
  720. package/src/secp256k1/hasher.spec.ts +0 -24
  721. package/src/secp256k1/hasher.ts +0 -13
  722. package/src/secp256k1/pair/fromSeed.spec.ts +0 -75
  723. package/src/secp256k1/pair/fromSeed.ts +0 -42
  724. package/src/secp256k1/recover.spec.ts +0 -35
  725. package/src/secp256k1/recover.ts +0 -36
  726. package/src/secp256k1/sign.spec.ts +0 -39
  727. package/src/secp256k1/sign.ts +0 -37
  728. package/src/secp256k1/signVerify.spec.ts +0 -94
  729. package/src/secp256k1/tweakAdd.spec.ts +0 -35
  730. package/src/secp256k1/tweakAdd.ts +0 -65
  731. package/src/secp256k1/types.ts +0 -4
  732. package/src/secp256k1/verify.spec.ts +0 -81
  733. package/src/secp256k1/verify.ts +0 -32
  734. package/src/sha/asU8a256.spec.ts +0 -55
  735. package/src/sha/asU8a512.spec.ts +0 -33
  736. package/src/signature/index.ts +0 -8
  737. package/src/signature/verify.spec.ts +0 -230
  738. package/src/signature/verify.ts +0 -114
  739. package/src/sr25519/agreement.spec.ts +0 -31
  740. package/src/sr25519/agreement.ts +0 -23
  741. package/src/sr25519/derive.ts +0 -21
  742. package/src/sr25519/derivePublic.ts +0 -18
  743. package/src/sr25519/pair/fromSeed.spec.ts +0 -35
  744. package/src/sr25519/pair/fromSeed.ts +0 -28
  745. package/src/sr25519/pair/fromU8a.ts +0 -23
  746. package/src/sr25519/pair/testing.spec.ts +0 -161
  747. package/src/sr25519/pair/toU8a.ts +0 -10
  748. package/src/sr25519/sign.spec.ts +0 -28
  749. package/src/sr25519/sign.ts +0 -22
  750. package/src/sr25519/verify.spec.ts +0 -42
  751. package/src/sr25519/verify.ts +0 -23
  752. package/src/sr25519/vrfSign.ts +0 -24
  753. package/src/sr25519/vrfSignVerify.spec.ts +0 -73
  754. package/src/sr25519/vrfVerify.ts +0 -25
  755. package/src/test/index.ts +0 -8
  756. package/src/test/performance.ts +0 -17
  757. package/src/types.ts +0 -33
  758. package/src/xxhash/asHex.spec.ts +0 -36
  759. package/src/xxhash/asU8a.spec.ts +0 -48
  760. package/src/xxhash/xxhash64.ts +0 -155
  761. package/tsconfig.build.json +0 -18
  762. package/tsconfig.spec.json +0 -20
@@ -0,0 +1 @@
1
+ export {};
@@ -1,14 +1,6 @@
1
- // Copyright 2017-2025 @polkadot/util-crypto authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- // Do not edit, auto-generated by @polkadot/dev
5
- // (packageInfo imports will be kept as-is, user-editable)
6
-
7
1
  import { packageInfo as netInfo } from '@pezkuwi/networks/packageInfo';
8
2
  import { detectPackage } from '@pezkuwi/util';
9
3
  import { packageInfo as utilInfo } from '@pezkuwi/util/packageInfo';
10
4
  import { packageInfo as randomInfo } from '@pezkuwi/x-randomvalues';
11
-
12
5
  import { packageInfo } from './packageInfo.js';
13
-
14
6
  detectPackage(packageInfo, null, [netInfo, randomInfo, utilInfo]);
@@ -0,0 +1,6 @@
1
+ export declare const packageInfo: {
2
+ name: string;
3
+ path: string;
4
+ type: string;
5
+ version: string;
6
+ };
package/packageInfo.js ADDED
@@ -0,0 +1 @@
1
+ export const packageInfo = { name: '@pezkuwi/util-crypto', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '14.0.1' };
@@ -0,0 +1,7 @@
1
+ interface Result {
2
+ password: Uint8Array;
3
+ rounds: number;
4
+ salt: Uint8Array;
5
+ }
6
+ export declare function pbkdf2Encode(passphrase?: string | Uint8Array, salt?: Uint8Array, rounds?: number, onlyJs?: boolean): Result;
7
+ export {};
@@ -0,0 +1,16 @@
1
+ import { pbkdf2 as pbkdf2Js } from '@noble/hashes/pbkdf2';
2
+ import { sha512 } from '@noble/hashes/sha512';
3
+ import { hasBigInt, u8aToU8a } from '@pezkuwi/util';
4
+ import { isReady, pbkdf2 } from '@pezkuwi/wasm-crypto';
5
+ import { randomAsU8a } from '../random/asU8a.js';
6
+ export function pbkdf2Encode(passphrase, salt = randomAsU8a(), rounds = 2048, onlyJs) {
7
+ const u8aPass = u8aToU8a(passphrase);
8
+ const u8aSalt = u8aToU8a(salt);
9
+ return {
10
+ password: !hasBigInt || (!onlyJs && isReady())
11
+ ? pbkdf2(u8aPass, u8aSalt, rounds)
12
+ : pbkdf2Js(sha512, u8aPass, u8aSalt, { c: rounds, dkLen: 64 }),
13
+ rounds,
14
+ salt
15
+ };
16
+ }
@@ -0,0 +1 @@
1
+ export { pbkdf2Encode } from './encode.js';
@@ -0,0 +1 @@
1
+ export { pbkdf2Encode } from './encode.js';
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @name randomAsNumber
3
+ * @summary Creates a random number from random bytes.
4
+ * @description
5
+ * Returns a random number generated from the secure bytes.
6
+ * @example
7
+ * <BR>
8
+ *
9
+ * ```javascript
10
+ * import { randomAsNumber } from '@polkadot/util-crypto';
11
+ *
12
+ * randomAsNumber(); // => <random number>
13
+ * ```
14
+ */
15
+ export declare function randomAsNumber(): number;
@@ -1,12 +1,6 @@
1
- // Copyright 2017-2025 @polkadot/util-crypto authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
1
  import { BN, hexToBn } from '@pezkuwi/util';
5
-
6
2
  import { randomAsHex } from './asU8a.js';
7
-
8
3
  const BN_53 = new BN(0b11111111111111111111111111111111111111111111111111111);
9
-
10
4
  /**
11
5
  * @name randomAsNumber
12
6
  * @summary Creates a random number from random bytes.
@@ -21,8 +15,6 @@ const BN_53 = new BN(0b11111111111111111111111111111111111111111111111111111);
21
15
  * randomAsNumber(); // => <random number>
22
16
  * ```
23
17
  */
24
- export function randomAsNumber (): number {
25
- return hexToBn(
26
- randomAsHex(8)
27
- ).and(BN_53).toNumber();
18
+ export function randomAsNumber() {
19
+ return hexToBn(randomAsHex(8)).and(BN_53).toNumber();
28
20
  }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @name randomAsU8a
3
+ * @summary Creates a Uint8Array filled with random bytes.
4
+ * @description
5
+ * Returns a `Uint8Array` with the specified (optional) length filled with random bytes.
6
+ * @example
7
+ * <BR>
8
+ *
9
+ * ```javascript
10
+ * import { randomAsU8a } from '@polkadot/util-crypto';
11
+ *
12
+ * randomAsU8a(); // => Uint8Array([...])
13
+ * ```
14
+ */
15
+ export declare function randomAsU8a(length?: number): Uint8Array;
16
+ /**
17
+ * @name randomAsHex
18
+ * @description Creates a hex string filled with random bytes.
19
+ */
20
+ export declare const randomAsHex: (length?: number | undefined) => import("@polkadot/util/types").HexString;
@@ -1,10 +1,5 @@
1
- // Copyright 2017-2025 @polkadot/util-crypto authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
1
  import { getRandomValues } from '@pezkuwi/x-randomvalues';
5
-
6
2
  import { createAsHex } from '../helpers.js';
7
-
8
3
  /**
9
4
  * @name randomAsU8a
10
5
  * @summary Creates a Uint8Array filled with random bytes.
@@ -19,10 +14,9 @@ import { createAsHex } from '../helpers.js';
19
14
  * randomAsU8a(); // => Uint8Array([...])
20
15
  * ```
21
16
  */
22
- export function randomAsU8a (length = 32): Uint8Array {
23
- return getRandomValues(new Uint8Array(length));
17
+ export function randomAsU8a(length = 32) {
18
+ return getRandomValues(new Uint8Array(length));
24
19
  }
25
-
26
20
  /**
27
21
  * @name randomAsHex
28
22
  * @description Creates a hex string filled with random bytes.
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @summary Returns a sequence of secure random bytes in a variety of formats
3
+ */
4
+ export { randomAsNumber } from './asNumber.js';
5
+ export { randomAsHex, randomAsU8a } from './asU8a.js';
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @summary Returns a sequence of secure random bytes in a variety of formats
3
+ */
4
+ export { randomAsNumber } from './asNumber.js';
5
+ export { randomAsHex, randomAsU8a } from './asU8a.js';
@@ -0,0 +1,3 @@
1
+ import type { ScryptParams } from './types.js';
2
+ export declare const ALLOWED_PARAMS: ScryptParams[];
3
+ export declare const DEFAULT_PARAMS: ScryptParams;
@@ -0,0 +1,13 @@
1
+ export const ALLOWED_PARAMS = [
2
+ { N: 1 << 13, p: 10, r: 8 },
3
+ { N: 1 << 14, p: 5, r: 8 },
4
+ { N: 1 << 15, p: 3, r: 8 },
5
+ { N: 1 << 15, p: 1, r: 8 },
6
+ { N: 1 << 16, p: 2, r: 8 },
7
+ { N: 1 << 17, p: 1, r: 8 }
8
+ ];
9
+ export const DEFAULT_PARAMS = {
10
+ N: 1 << 17,
11
+ p: 1,
12
+ r: 8
13
+ };
@@ -0,0 +1,8 @@
1
+ import type { ScryptParams } from './types.js';
2
+ interface Result {
3
+ params: ScryptParams;
4
+ password: Uint8Array;
5
+ salt: Uint8Array;
6
+ }
7
+ export declare function scryptEncode(passphrase?: string | Uint8Array, salt?: Uint8Array, params?: ScryptParams, onlyJs?: boolean): Result;
8
+ export {};
@@ -0,0 +1,15 @@
1
+ import { scrypt as scryptJs } from '@noble/hashes/scrypt';
2
+ import { hasBigInt, objectSpread, u8aToU8a } from '@pezkuwi/util';
3
+ import { isReady, scrypt } from '@pezkuwi/wasm-crypto';
4
+ import { randomAsU8a } from '../random/asU8a.js';
5
+ import { DEFAULT_PARAMS } from './defaults.js';
6
+ export function scryptEncode(passphrase, salt = randomAsU8a(), params = DEFAULT_PARAMS, onlyJs) {
7
+ const u8a = u8aToU8a(passphrase);
8
+ return {
9
+ params,
10
+ password: !hasBigInt || (!onlyJs && isReady())
11
+ ? scrypt(u8a, salt, Math.log2(params.N), params.r, params.p)
12
+ : scryptJs(u8a, salt, objectSpread({ dkLen: 64 }, params)),
13
+ salt
14
+ };
15
+ }
@@ -0,0 +1,7 @@
1
+ import type { ScryptParams } from './types.js';
2
+ interface Result {
3
+ params: ScryptParams;
4
+ salt: Uint8Array;
5
+ }
6
+ export declare function scryptFromU8a(data: Uint8Array): Result;
7
+ export {};
@@ -0,0 +1,24 @@
1
+ import { u8aToBn } from '@pezkuwi/util';
2
+ import { BN_LE_OPTS } from '../bn.js';
3
+ import { ALLOWED_PARAMS } from './defaults.js';
4
+ export function scryptFromU8a(data) {
5
+ if (!(data instanceof Uint8Array)) {
6
+ throw new Error('Expected input to be a Uint8Array');
7
+ }
8
+ // Ensure the input is exactly 44 bytes: 32 for salt + 3 * 4 for N, p, r
9
+ if (data.length < 32 + 12) {
10
+ throw new Error(`Invalid input length: expected 44 bytes, found ${data.length}`);
11
+ }
12
+ const salt = data.subarray(0, 32);
13
+ const N = u8aToBn(data.subarray(32, 36), BN_LE_OPTS).toNumber();
14
+ const p = u8aToBn(data.subarray(36, 40), BN_LE_OPTS).toNumber();
15
+ const r = u8aToBn(data.subarray(40, 44), BN_LE_OPTS).toNumber();
16
+ if (N > (1 << 20) || p > 4 || r > 16) {
17
+ throw new Error('Scrypt parameters exceed safe limits');
18
+ }
19
+ const isAllowed = ALLOWED_PARAMS.some((preset) => preset.N === N && preset.p === p && preset.r === r);
20
+ if (!isAllowed) {
21
+ throw new Error('Invalid injected scrypt params found');
22
+ }
23
+ return { params: { N, p, r }, salt };
24
+ }
@@ -0,0 +1,3 @@
1
+ export { scryptEncode } from './encode.js';
2
+ export { scryptFromU8a } from './fromU8a.js';
3
+ export { scryptToU8a } from './toU8a.js';
@@ -0,0 +1,3 @@
1
+ export { scryptEncode } from './encode.js';
2
+ export { scryptFromU8a } from './fromU8a.js';
3
+ export { scryptToU8a } from './toU8a.js';
@@ -0,0 +1,2 @@
1
+ import type { ScryptParams } from './types.js';
2
+ export declare function scryptToU8a(salt: Uint8Array, { N, p, r }: ScryptParams): Uint8Array;
@@ -0,0 +1,5 @@
1
+ import { bnToU8a, u8aConcat } from '@pezkuwi/util';
2
+ import { BN_LE_32_OPTS } from '../bn.js';
3
+ export function scryptToU8a(salt, { N, p, r }) {
4
+ return u8aConcat(salt, bnToU8a(N, BN_LE_32_OPTS), bnToU8a(p, BN_LE_32_OPTS), bnToU8a(r, BN_LE_32_OPTS));
5
+ }
@@ -0,0 +1,6 @@
1
+ /** The params that control scrypt generation */
2
+ export interface ScryptParams {
3
+ N: number;
4
+ p: number;
5
+ r: number;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare function secp256k1Compress(publicKey: Uint8Array, onlyJs?: boolean): Uint8Array;
@@ -0,0 +1,14 @@
1
+ import { secp256k1 } from '@noble/curves/secp256k1';
2
+ import { hasBigInt } from '@pezkuwi/util';
3
+ import { isReady, secp256k1Compress as wasm } from '@pezkuwi/wasm-crypto';
4
+ export function secp256k1Compress(publicKey, onlyJs) {
5
+ if (![33, 65].includes(publicKey.length)) {
6
+ throw new Error(`Invalid publicKey provided, received ${publicKey.length} bytes input`);
7
+ }
8
+ if (publicKey.length === 33) {
9
+ return publicKey;
10
+ }
11
+ return !hasBigInt || (!onlyJs && isReady())
12
+ ? wasm(publicKey)
13
+ : secp256k1.ProjectivePoint.fromHex(publicKey).toRawBytes(true);
14
+ }
@@ -0,0 +1 @@
1
+ export declare function secp256k1DeriveHard(seed: Uint8Array, chainCode: Uint8Array): Uint8Array;
@@ -0,0 +1,10 @@
1
+ import { compactAddLength, isU8a, stringToU8a, u8aConcat } from '@pezkuwi/util';
2
+ import { blake2AsU8a } from '../blake2/asU8a.js';
3
+ const HDKD = compactAddLength(stringToU8a('Secp256k1HDKD'));
4
+ export function secp256k1DeriveHard(seed, chainCode) {
5
+ if (!isU8a(chainCode) || chainCode.length !== 32) {
6
+ throw new Error('Invalid chainCode passed to derive');
7
+ }
8
+ // NOTE This is specific to the Substrate HDD derivation, so always use the blake2 hasher
9
+ return blake2AsU8a(u8aConcat(HDKD, seed, chainCode), 256);
10
+ }
@@ -0,0 +1 @@
1
+ export declare function secp256k1Expand(publicKey: Uint8Array, onlyJs?: boolean): Uint8Array;
@@ -0,0 +1,17 @@
1
+ import { secp256k1 } from '@noble/curves/secp256k1';
2
+ import { bnToU8a, hasBigInt, u8aConcat } from '@pezkuwi/util';
3
+ import { isReady, secp256k1Expand as wasm } from '@pezkuwi/wasm-crypto';
4
+ import { BN_BE_256_OPTS } from '../bn.js';
5
+ export function secp256k1Expand(publicKey, onlyJs) {
6
+ if (![33, 65].includes(publicKey.length)) {
7
+ throw new Error(`Invalid publicKey provided, received ${publicKey.length} bytes input`);
8
+ }
9
+ if (publicKey.length === 65) {
10
+ return publicKey.subarray(1);
11
+ }
12
+ if (!hasBigInt || (!onlyJs && isReady())) {
13
+ return wasm(publicKey).subarray(1);
14
+ }
15
+ const { px, py } = secp256k1.ProjectivePoint.fromHex(publicKey);
16
+ return u8aConcat(bnToU8a(px, BN_BE_256_OPTS), bnToU8a(py, BN_BE_256_OPTS));
17
+ }
@@ -0,0 +1,2 @@
1
+ import type { HashType } from './types.js';
2
+ export declare function hasher(hashType: HashType, data: Uint8Array | string, onlyJs?: boolean): Uint8Array;
@@ -0,0 +1,7 @@
1
+ import { blake2AsU8a } from '../blake2/index.js';
2
+ import { keccakAsU8a } from '../keccak/index.js';
3
+ export function hasher(hashType, data, onlyJs) {
4
+ return hashType === 'keccak'
5
+ ? keccakAsU8a(data, undefined, onlyJs)
6
+ : blake2AsU8a(data, undefined, undefined, onlyJs);
7
+ }
@@ -0,0 +1,7 @@
1
+ export { secp256k1Compress } from './compress.js';
2
+ export { secp256k1Expand } from './expand.js';
3
+ export { secp256k1PairFromSeed } from './pair/fromSeed.js';
4
+ export { secp256k1Recover } from './recover.js';
5
+ export { secp256k1Sign } from './sign.js';
6
+ export { secp256k1PrivateKeyTweakAdd } from './tweakAdd.js';
7
+ export { secp256k1Verify } from './verify.js';
@@ -0,0 +1,7 @@
1
+ export { secp256k1Compress } from './compress.js';
2
+ export { secp256k1Expand } from './expand.js';
3
+ export { secp256k1PairFromSeed } from './pair/fromSeed.js';
4
+ export { secp256k1Recover } from './recover.js';
5
+ export { secp256k1Sign } from './sign.js';
6
+ export { secp256k1PrivateKeyTweakAdd } from './tweakAdd.js';
7
+ export { secp256k1Verify } from './verify.js';
@@ -0,0 +1,6 @@
1
+ import type { Keypair } from '../../types.js';
2
+ /**
3
+ * @name secp256k1PairFromSeed
4
+ * @description Returns a object containing a `publicKey` & `secretKey` generated from the supplied seed.
5
+ */
6
+ export declare function secp256k1PairFromSeed(seed: Uint8Array, onlyJs?: boolean): Keypair;
@@ -0,0 +1,31 @@
1
+ import { secp256k1 } from '@noble/curves/secp256k1';
2
+ import { hasBigInt, u8aEmpty } from '@pezkuwi/util';
3
+ import { isReady, secp256k1FromSeed } from '@pezkuwi/wasm-crypto';
4
+ /**
5
+ * @name secp256k1PairFromSeed
6
+ * @description Returns a object containing a `publicKey` & `secretKey` generated from the supplied seed.
7
+ */
8
+ export function secp256k1PairFromSeed(seed, onlyJs) {
9
+ if (seed.length !== 32) {
10
+ throw new Error('Expected valid 32-byte private key as a seed');
11
+ }
12
+ if (!hasBigInt || (!onlyJs && isReady())) {
13
+ const full = secp256k1FromSeed(seed);
14
+ const publicKey = full.slice(32);
15
+ // There is an issue with the secp256k1 when running in an ASM.js environment where
16
+ // it seems that the lazy static section yields invalid results on the _first_ run.
17
+ // If this happens, fail outright, we cannot allow invalid return values
18
+ // https://github.com/polkadot-js/wasm/issues/307
19
+ if (u8aEmpty(publicKey)) {
20
+ throw new Error('Invalid publicKey generated from WASM interface');
21
+ }
22
+ return {
23
+ publicKey,
24
+ secretKey: full.slice(0, 32)
25
+ };
26
+ }
27
+ return {
28
+ publicKey: secp256k1.getPublicKey(seed, true),
29
+ secretKey: seed
30
+ };
31
+ }
@@ -0,0 +1,6 @@
1
+ import type { HashType } from './types.js';
2
+ /**
3
+ * @name secp256k1Recover
4
+ * @description Recovers a publicKey from the supplied signature
5
+ */
6
+ export declare function secp256k1Recover(msgHash: string | Uint8Array, signature: string | Uint8Array, recovery: number, hashType?: HashType, onlyJs?: boolean): Uint8Array;
@@ -0,0 +1,26 @@
1
+ import { secp256k1 } from '@noble/curves/secp256k1';
2
+ import { hasBigInt, u8aToU8a } from '@pezkuwi/util';
3
+ import { isReady, secp256k1Recover as wasm } from '@pezkuwi/wasm-crypto';
4
+ import { secp256k1Compress } from './compress.js';
5
+ import { secp256k1Expand } from './expand.js';
6
+ /**
7
+ * @name secp256k1Recover
8
+ * @description Recovers a publicKey from the supplied signature
9
+ */
10
+ export function secp256k1Recover(msgHash, signature, recovery, hashType = 'blake2', onlyJs) {
11
+ const sig = u8aToU8a(signature).subarray(0, 64);
12
+ const msg = u8aToU8a(msgHash);
13
+ const publicKey = !hasBigInt || (!onlyJs && isReady())
14
+ ? wasm(msg, sig, recovery)
15
+ : secp256k1.Signature
16
+ .fromCompact(sig)
17
+ .addRecoveryBit(recovery)
18
+ .recoverPublicKey(msg)
19
+ .toRawBytes();
20
+ if (!publicKey) {
21
+ throw new Error('Unable to recover publicKey from signature');
22
+ }
23
+ return hashType === 'keccak'
24
+ ? secp256k1Expand(publicKey, onlyJs)
25
+ : secp256k1Compress(publicKey, onlyJs);
26
+ }
@@ -0,0 +1,7 @@
1
+ import type { Keypair } from '../types.js';
2
+ import type { HashType } from './types.js';
3
+ /**
4
+ * @name secp256k1Sign
5
+ * @description Returns message signature of `message`, using the supplied pair
6
+ */
7
+ export declare function secp256k1Sign(message: Uint8Array | string, { secretKey }: Partial<Keypair>, hashType?: HashType, onlyJs?: boolean): Uint8Array;
@@ -0,0 +1,20 @@
1
+ import { secp256k1 } from '@noble/curves/secp256k1';
2
+ import { bnToU8a, hasBigInt, u8aConcat } from '@pezkuwi/util';
3
+ import { isReady, secp256k1Sign as wasm } from '@pezkuwi/wasm-crypto';
4
+ import { BN_BE_256_OPTS } from '../bn.js';
5
+ import { hasher } from './hasher.js';
6
+ /**
7
+ * @name secp256k1Sign
8
+ * @description Returns message signature of `message`, using the supplied pair
9
+ */
10
+ export function secp256k1Sign(message, { secretKey }, hashType = 'blake2', onlyJs) {
11
+ if (secretKey?.length !== 32) {
12
+ throw new Error('Expected valid secp256k1 secretKey, 32-bytes');
13
+ }
14
+ const data = hasher(hashType, message, onlyJs);
15
+ if (!hasBigInt || (!onlyJs && isReady())) {
16
+ return wasm(data, secretKey);
17
+ }
18
+ const signature = secp256k1.sign(data, secretKey, { lowS: true });
19
+ return u8aConcat(bnToU8a(signature.r, BN_BE_256_OPTS), bnToU8a(signature.s, BN_BE_256_OPTS), new Uint8Array([signature.recovery || 0]));
20
+ }
@@ -0,0 +1 @@
1
+ export declare function secp256k1PrivateKeyTweakAdd(seckey: Uint8Array, tweak: Uint8Array, onlyBn?: boolean): Uint8Array;
@@ -0,0 +1,45 @@
1
+ import { _0n, BN, bnToU8a, hasBigInt, isU8a, nToU8a, u8aToBigInt } from '@pezkuwi/util';
2
+ import { BigInt } from '@pezkuwi/x-bigint';
3
+ import { BN_BE_256_OPTS, BN_BE_OPTS } from '../bn.js';
4
+ const N = 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141'.replace(/ /g, '');
5
+ const N_BI = BigInt(`0x${N}`);
6
+ const N_BN = new BN(N, 'hex');
7
+ function addBi(seckey, tweak) {
8
+ let res = u8aToBigInt(tweak, BN_BE_OPTS);
9
+ if (res >= N_BI) {
10
+ throw new Error('Tweak parameter is out of range');
11
+ }
12
+ res += u8aToBigInt(seckey, BN_BE_OPTS);
13
+ if (res >= N_BI) {
14
+ res -= N_BI;
15
+ }
16
+ if (res === _0n) {
17
+ throw new Error('Invalid resulting private key');
18
+ }
19
+ return nToU8a(res, BN_BE_256_OPTS);
20
+ }
21
+ function addBn(seckey, tweak) {
22
+ const res = new BN(tweak);
23
+ if (res.cmp(N_BN) >= 0) {
24
+ throw new Error('Tweak parameter is out of range');
25
+ }
26
+ res.iadd(new BN(seckey));
27
+ if (res.cmp(N_BN) >= 0) {
28
+ res.isub(N_BN);
29
+ }
30
+ if (res.isZero()) {
31
+ throw new Error('Invalid resulting private key');
32
+ }
33
+ return bnToU8a(res, BN_BE_256_OPTS);
34
+ }
35
+ export function secp256k1PrivateKeyTweakAdd(seckey, tweak, onlyBn) {
36
+ if (!isU8a(seckey) || seckey.length !== 32) {
37
+ throw new Error('Expected seckey to be an Uint8Array with length 32');
38
+ }
39
+ else if (!isU8a(tweak) || tweak.length !== 32) {
40
+ throw new Error('Expected tweak to be an Uint8Array with length 32');
41
+ }
42
+ return !hasBigInt || onlyBn
43
+ ? addBn(seckey, tweak)
44
+ : addBi(seckey, tweak);
45
+ }
@@ -0,0 +1 @@
1
+ export type HashType = 'blake2' | 'keccak';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { HashType } from './types.js';
2
+ /**
3
+ * @name secp256k1Verify
4
+ * @description Verifies the signature of `message`, using the supplied pair
5
+ */
6
+ export declare function secp256k1Verify(msgHash: string | Uint8Array, signature: string | Uint8Array, address: string | Uint8Array, hashType?: HashType, onlyJs?: boolean): boolean;
@@ -0,0 +1,20 @@
1
+ import { u8aEq, u8aToU8a } from '@pezkuwi/util';
2
+ import { hasher } from './hasher.js';
3
+ import { secp256k1Recover } from './recover.js';
4
+ /**
5
+ * @name secp256k1Verify
6
+ * @description Verifies the signature of `message`, using the supplied pair
7
+ */
8
+ export function secp256k1Verify(msgHash, signature, address, hashType = 'blake2', onlyJs) {
9
+ const sig = u8aToU8a(signature);
10
+ if (sig.length !== 65) {
11
+ throw new Error(`Expected signature with 65 bytes, ${sig.length} found instead`);
12
+ }
13
+ const publicKey = secp256k1Recover(hasher(hashType, msgHash), sig, sig[64], hashType, onlyJs);
14
+ const signerAddr = hasher(hashType, publicKey, onlyJs);
15
+ const inputAddr = u8aToU8a(address);
16
+ // for Ethereum (keccak) the last 20 bytes is the address
17
+ return u8aEq(publicKey, inputAddr) || (hashType === 'keccak'
18
+ ? u8aEq(signerAddr.slice(-20), inputAddr.slice(-20))
19
+ : u8aEq(signerAddr, inputAddr));
20
+ }
package/sha/asU8a.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @name shaAsU8a
3
+ * @summary Creates a sha Uint8Array from the input.
4
+ */
5
+ export declare const shaAsU8a: (value: string | Uint8Array, bitLength?: 256 | 512, onlyJs?: boolean) => Uint8Array;
6
+ /**
7
+ * @name sha256AsU8a
8
+ * @summary Creates a sha256 Uint8Array from the input.
9
+ */
10
+ export declare const sha256AsU8a: (data: string | Uint8Array, onlyJs?: boolean) => Uint8Array;
11
+ /**
12
+ * @name sha512AsU8a
13
+ * @summary Creates a sha512 Uint8Array from the input.
14
+ */
15
+ export declare const sha512AsU8a: (data: string | Uint8Array, onlyJs?: boolean) => Uint8Array;
@@ -1,28 +1,17 @@
1
- // Copyright 2017-2025 @polkadot/util-crypto authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
1
  import { sha256 as sha256Js } from '@noble/hashes/sha256';
5
2
  import { sha512 as sha512Js } from '@noble/hashes/sha512';
6
-
7
3
  import { sha256, sha512 } from '@pezkuwi/wasm-crypto';
8
-
9
4
  import { createBitHasher, createDualHasher } from '../helpers.js';
10
-
11
5
  /**
12
6
  * @name shaAsU8a
13
7
  * @summary Creates a sha Uint8Array from the input.
14
8
  */
15
- export const shaAsU8a = /*#__PURE__*/ createDualHasher(
16
- { 256: sha256, 512: sha512 },
17
- { 256: sha256Js, 512: sha512Js }
18
- );
19
-
9
+ export const shaAsU8a = /*#__PURE__*/ createDualHasher({ 256: sha256, 512: sha512 }, { 256: sha256Js, 512: sha512Js });
20
10
  /**
21
11
  * @name sha256AsU8a
22
12
  * @summary Creates a sha256 Uint8Array from the input.
23
13
  */
24
14
  export const sha256AsU8a = /*#__PURE__*/ createBitHasher(256, shaAsU8a);
25
-
26
15
  /**
27
16
  * @name sha512AsU8a
28
17
  * @summary Creates a sha512 Uint8Array from the input.
package/sha/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @summary Implements Sha-256/512 hashing functions for a variety of input and outputs
3
+ */
4
+ export { sha256AsU8a, sha512AsU8a, shaAsU8a } from './asU8a.js';
package/sha/index.js ADDED
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @summary Implements Sha-256/512 hashing functions for a variety of input and outputs
3
+ */
4
+ export { sha256AsU8a, sha512AsU8a, shaAsU8a } from './asU8a.js';
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @summary Utilities for working with signatures
3
+ */
4
+ export { signatureVerify } from './verify.js';
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @summary Utilities for working with signatures
3
+ */
4
+ export { signatureVerify } from './verify.js';
@@ -0,0 +1,2 @@
1
+ import type { VerifyResult } from '../types.js';
2
+ export declare function signatureVerify(message: string | Uint8Array, signature: string | Uint8Array, addressOrPublicKey: string | Uint8Array): VerifyResult;