@pezkuwi/util-crypto 14.0.10 → 14.0.12

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 (593) hide show
  1. package/address/addressToEvm.d.ts +5 -0
  2. package/address/addressToEvm.js +8 -0
  3. package/address/check.d.ts +8 -0
  4. package/address/check.js +26 -0
  5. package/address/checksum.d.ts +1 -0
  6. package/address/checksum.js +16 -0
  7. package/address/decode.d.ts +2 -0
  8. package/address/decode.js +29 -0
  9. package/address/defaults.d.ts +6 -0
  10. package/address/defaults.js +8 -0
  11. package/address/derive.d.ts +8 -0
  12. package/address/derive.js +24 -0
  13. package/address/encode.d.ts +2 -0
  14. package/address/encode.js +23 -0
  15. package/address/encodeDerived.d.ts +9 -0
  16. package/address/encodeDerived.js +12 -0
  17. package/address/encodeMulti.d.ts +9 -0
  18. package/address/encodeMulti.js +11 -0
  19. package/address/eq.d.ts +15 -0
  20. package/address/eq.js +19 -0
  21. package/address/evmToAddress.d.ts +7 -0
  22. package/address/evmToAddress.js +14 -0
  23. package/address/index.d.ts +16 -0
  24. package/address/index.js +16 -0
  25. package/address/is.d.ts +2 -0
  26. package/address/is.js +9 -0
  27. package/address/keyDerived.d.ts +2 -0
  28. package/address/keyDerived.js +8 -0
  29. package/address/keyMulti.d.ts +2 -0
  30. package/address/keyMulti.js +8 -0
  31. package/address/setSS58Format.d.ts +6 -0
  32. package/address/setSS58Format.js +11 -0
  33. package/address/sort.d.ts +2 -0
  34. package/address/sort.js +7 -0
  35. package/address/sshash.d.ts +1 -0
  36. package/address/sshash.js +6 -0
  37. package/address/types.d.ts +1 -0
  38. package/address/types.js +1 -0
  39. package/address/util.d.ts +1 -0
  40. package/address/util.js +4 -0
  41. package/address/validate.d.ts +2 -0
  42. package/address/validate.js +4 -0
  43. package/base32/bs32.d.ts +26 -0
  44. package/base32/bs32.js +40 -0
  45. package/base32/helpers.d.ts +25 -0
  46. package/base32/helpers.js +61 -0
  47. package/base32/index.d.ts +4 -0
  48. package/base32/index.js +4 -0
  49. package/base58/bs58.d.ts +26 -0
  50. package/base58/bs58.js +34 -0
  51. package/base58/index.d.ts +4 -0
  52. package/base58/index.js +4 -0
  53. package/base64/bs64.d.ts +26 -0
  54. package/base64/bs64.js +34 -0
  55. package/base64/index.d.ts +6 -0
  56. package/base64/index.js +6 -0
  57. package/base64/pad.d.ts +5 -0
  58. package/base64/pad.js +7 -0
  59. package/base64/trim.d.ts +5 -0
  60. package/base64/trim.js +10 -0
  61. package/blake2/asU8a.d.ts +20 -0
  62. package/blake2/asU8a.js +32 -0
  63. package/blake2/index.d.ts +4 -0
  64. package/blake2/index.js +4 -0
  65. package/bn.d.ts +30 -0
  66. package/bn.js +8 -0
  67. package/build/blake2/asU8a.d.ts +1 -1
  68. package/build/bundle-pezkuwi-util-crypto.js +8749 -8246
  69. package/build/cjs/blake2/asU8a.d.ts +1 -1
  70. package/build/cjs/keccak/asU8a.d.ts +1 -1
  71. package/build/cjs/packageInfo.js +1 -1
  72. package/build/cjs/scrypt/encode.d.ts +1 -1
  73. package/build/cjs/xxhash/asU8a.d.ts +1 -1
  74. package/build/keccak/asU8a.d.ts +1 -1
  75. package/build/package.json +9 -9
  76. package/build/packageInfo.js +1 -1
  77. package/build/scrypt/encode.d.ts +1 -1
  78. package/build/xxhash/asU8a.d.ts +1 -1
  79. package/build-deno/packageInfo.ts +1 -1
  80. package/build-tsc/blake2/asU8a.d.ts +1 -1
  81. package/build-tsc/keccak/asU8a.d.ts +1 -1
  82. package/build-tsc/scrypt/encode.d.ts +1 -1
  83. package/build-tsc/xxhash/asU8a.d.ts +1 -1
  84. package/build-tsc-cjs/packageInfo.js +1 -1
  85. package/build-tsc-esm/packageInfo.js +1 -1
  86. package/bundle-pezkuwi-util-crypto.js +8251 -0
  87. package/bundle.d.ts +26 -0
  88. package/bundle.js +26 -0
  89. package/bundleInit.d.ts +1 -0
  90. package/bundleInit.js +5 -0
  91. package/cjs/address/addressToEvm.d.ts +5 -0
  92. package/cjs/address/addressToEvm.js +11 -0
  93. package/cjs/address/check.d.ts +8 -0
  94. package/cjs/address/check.js +29 -0
  95. package/cjs/address/checksum.d.ts +1 -0
  96. package/cjs/address/checksum.js +19 -0
  97. package/cjs/address/decode.d.ts +2 -0
  98. package/cjs/address/decode.js +32 -0
  99. package/cjs/address/defaults.d.ts +6 -0
  100. package/cjs/address/defaults.js +11 -0
  101. package/cjs/address/derive.d.ts +8 -0
  102. package/cjs/address/derive.js +27 -0
  103. package/cjs/address/encode.d.ts +2 -0
  104. package/cjs/address/encode.js +26 -0
  105. package/cjs/address/encodeDerived.d.ts +9 -0
  106. package/cjs/address/encodeDerived.js +15 -0
  107. package/cjs/address/encodeMulti.d.ts +9 -0
  108. package/cjs/address/encodeMulti.js +14 -0
  109. package/cjs/address/eq.d.ts +15 -0
  110. package/cjs/address/eq.js +22 -0
  111. package/cjs/address/evmToAddress.d.ts +7 -0
  112. package/cjs/address/evmToAddress.js +17 -0
  113. package/cjs/address/index.d.ts +16 -0
  114. package/cjs/address/index.js +35 -0
  115. package/cjs/address/is.d.ts +2 -0
  116. package/cjs/address/is.js +12 -0
  117. package/cjs/address/keyDerived.d.ts +2 -0
  118. package/cjs/address/keyDerived.js +11 -0
  119. package/cjs/address/keyMulti.d.ts +2 -0
  120. package/cjs/address/keyMulti.js +11 -0
  121. package/cjs/address/setSS58Format.d.ts +6 -0
  122. package/cjs/address/setSS58Format.js +14 -0
  123. package/cjs/address/sort.d.ts +2 -0
  124. package/cjs/address/sort.js +10 -0
  125. package/cjs/address/sshash.d.ts +1 -0
  126. package/cjs/address/sshash.js +9 -0
  127. package/cjs/address/types.d.ts +1 -0
  128. package/cjs/address/types.js +2 -0
  129. package/cjs/address/util.d.ts +1 -0
  130. package/cjs/address/util.js +7 -0
  131. package/cjs/address/validate.d.ts +2 -0
  132. package/cjs/address/validate.js +7 -0
  133. package/cjs/base32/bs32.d.ts +26 -0
  134. package/cjs/base32/bs32.js +43 -0
  135. package/cjs/base32/helpers.d.ts +25 -0
  136. package/cjs/base32/helpers.js +67 -0
  137. package/cjs/base32/index.d.ts +4 -0
  138. package/cjs/base32/index.js +11 -0
  139. package/cjs/base58/bs58.d.ts +26 -0
  140. package/cjs/base58/bs58.js +37 -0
  141. package/cjs/base58/index.d.ts +4 -0
  142. package/cjs/base58/index.js +11 -0
  143. package/cjs/base64/bs64.d.ts +26 -0
  144. package/cjs/base64/bs64.js +37 -0
  145. package/cjs/base64/index.d.ts +6 -0
  146. package/cjs/base64/index.js +15 -0
  147. package/cjs/base64/pad.d.ts +5 -0
  148. package/cjs/base64/pad.js +10 -0
  149. package/cjs/base64/trim.d.ts +5 -0
  150. package/cjs/base64/trim.js +13 -0
  151. package/cjs/blake2/asU8a.d.ts +20 -0
  152. package/cjs/blake2/asU8a.js +36 -0
  153. package/cjs/blake2/index.d.ts +4 -0
  154. package/cjs/blake2/index.js +9 -0
  155. package/cjs/bn.d.ts +30 -0
  156. package/cjs/bn.js +11 -0
  157. package/cjs/bundle.d.ts +26 -0
  158. package/cjs/bundle.js +31 -0
  159. package/cjs/bundleInit.d.ts +1 -0
  160. package/cjs/bundleInit.js +7 -0
  161. package/cjs/crypto.d.ts +3 -0
  162. package/cjs/crypto.js +16 -0
  163. package/cjs/ed25519/deriveHard.d.ts +1 -0
  164. package/cjs/ed25519/deriveHard.js +12 -0
  165. package/cjs/ed25519/index.d.ts +10 -0
  166. package/cjs/ed25519/index.js +20 -0
  167. package/cjs/ed25519/pair/fromRandom.d.ts +16 -0
  168. package/cjs/ed25519/pair/fromRandom.js +22 -0
  169. package/cjs/ed25519/pair/fromSecret.d.ts +16 -0
  170. package/cjs/ed25519/pair/fromSecret.js +26 -0
  171. package/cjs/ed25519/pair/fromSeed.d.ts +16 -0
  172. package/cjs/ed25519/pair/fromSeed.js +34 -0
  173. package/cjs/ed25519/pair/fromString.d.ts +16 -0
  174. package/cjs/ed25519/pair/fromString.js +23 -0
  175. package/cjs/ed25519/sign.d.ts +16 -0
  176. package/cjs/ed25519/sign.js +33 -0
  177. package/cjs/ed25519/verify.d.ts +15 -0
  178. package/cjs/ed25519/verify.js +39 -0
  179. package/cjs/ethereum/encode.d.ts +2 -0
  180. package/cjs/ethereum/encode.js +28 -0
  181. package/cjs/ethereum/index.d.ts +3 -0
  182. package/cjs/ethereum/index.js +9 -0
  183. package/cjs/ethereum/isAddress.d.ts +1 -0
  184. package/cjs/ethereum/isAddress.js +14 -0
  185. package/cjs/ethereum/isChecksum.d.ts +1 -0
  186. package/cjs/ethereum/isChecksum.js +20 -0
  187. package/cjs/hd/ethereum/index.d.ts +2 -0
  188. package/cjs/hd/ethereum/index.js +47 -0
  189. package/cjs/hd/index.d.ts +3 -0
  190. package/cjs/hd/index.js +9 -0
  191. package/cjs/hd/ledger/derivePrivate.d.ts +1 -0
  192. package/cjs/hd/ledger/derivePrivate.js +15 -0
  193. package/cjs/hd/ledger/index.d.ts +2 -0
  194. package/cjs/hd/ledger/index.js +33 -0
  195. package/cjs/hd/ledger/master.d.ts +1 -0
  196. package/cjs/hd/ledger/master.js +19 -0
  197. package/cjs/hd/validatePath.d.ts +2 -0
  198. package/cjs/hd/validatePath.js +20 -0
  199. package/cjs/helpers.d.ts +12 -0
  200. package/cjs/helpers.js +24 -0
  201. package/cjs/hmac/index.d.ts +1 -0
  202. package/cjs/hmac/index.js +7 -0
  203. package/cjs/hmac/shaAsU8a.d.ts +15 -0
  204. package/cjs/hmac/shaAsU8a.js +40 -0
  205. package/cjs/index.d.ts +2 -0
  206. package/cjs/index.js +5 -0
  207. package/cjs/json/constants.d.ts +6 -0
  208. package/cjs/json/constants.js +8 -0
  209. package/cjs/json/decrypt.d.ts +2 -0
  210. package/cjs/json/decrypt.js +16 -0
  211. package/cjs/json/decryptData.d.ts +2 -0
  212. package/cjs/json/decryptData.js +32 -0
  213. package/cjs/json/encrypt.d.ts +2 -0
  214. package/cjs/json/encrypt.js +18 -0
  215. package/cjs/json/encryptFormat.d.ts +2 -0
  216. package/cjs/json/encryptFormat.js +17 -0
  217. package/cjs/json/index.d.ts +4 -0
  218. package/cjs/json/index.js +11 -0
  219. package/cjs/json/types.d.ts +16 -0
  220. package/cjs/json/types.js +2 -0
  221. package/cjs/keccak/asU8a.d.ts +30 -0
  222. package/cjs/keccak/asU8a.js +36 -0
  223. package/cjs/keccak/index.d.ts +4 -0
  224. package/cjs/keccak/index.js +11 -0
  225. package/cjs/key/DeriveJunction.d.ts +12 -0
  226. package/cjs/key/DeriveJunction.js +62 -0
  227. package/cjs/key/extractPath.d.ts +9 -0
  228. package/cjs/key/extractPath.js +26 -0
  229. package/cjs/key/extractSuri.d.ts +11 -0
  230. package/cjs/key/extractSuri.js +25 -0
  231. package/cjs/key/fromPath.d.ts +3 -0
  232. package/cjs/key/fromPath.js +21 -0
  233. package/cjs/key/hdkdDerive.d.ts +3 -0
  234. package/cjs/key/hdkdDerive.js +11 -0
  235. package/cjs/key/hdkdEcdsa.d.ts +1 -0
  236. package/cjs/key/hdkdEcdsa.js +7 -0
  237. package/cjs/key/hdkdEd25519.d.ts +1 -0
  238. package/cjs/key/hdkdEd25519.js +6 -0
  239. package/cjs/key/hdkdSr25519.d.ts +3 -0
  240. package/cjs/key/hdkdSr25519.js +10 -0
  241. package/cjs/key/index.d.ts +9 -0
  242. package/cjs/key/index.js +18 -0
  243. package/cjs/mnemonic/bip39.d.ts +5 -0
  244. package/cjs/mnemonic/bip39.js +90 -0
  245. package/cjs/mnemonic/generate.d.ts +13 -0
  246. package/cjs/mnemonic/generate.js +23 -0
  247. package/cjs/mnemonic/index.d.ts +8 -0
  248. package/cjs/mnemonic/index.js +16 -0
  249. package/cjs/mnemonic/toEntropy.d.ts +1 -0
  250. package/cjs/mnemonic/toEntropy.js +11 -0
  251. package/cjs/mnemonic/toLegacySeed.d.ts +18 -0
  252. package/cjs/mnemonic/toLegacySeed.js +37 -0
  253. package/cjs/mnemonic/toMiniSecret.d.ts +1 -0
  254. package/cjs/mnemonic/toMiniSecret.js +20 -0
  255. package/cjs/mnemonic/validate.d.ts +14 -0
  256. package/cjs/mnemonic/validate.js +24 -0
  257. package/cjs/mnemonic/wordlists/en.d.ts +2 -0
  258. package/cjs/mnemonic/wordlists/en.js +3 -0
  259. package/cjs/mnemonic/wordlists/es.d.ts +2 -0
  260. package/cjs/mnemonic/wordlists/es.js +3 -0
  261. package/cjs/mnemonic/wordlists/fr.d.ts +2 -0
  262. package/cjs/mnemonic/wordlists/fr.js +3 -0
  263. package/cjs/mnemonic/wordlists/index.d.ts +8 -0
  264. package/cjs/mnemonic/wordlists/index.js +20 -0
  265. package/cjs/mnemonic/wordlists/it.d.ts +2 -0
  266. package/cjs/mnemonic/wordlists/it.js +3 -0
  267. package/cjs/mnemonic/wordlists/jp.d.ts +2 -0
  268. package/cjs/mnemonic/wordlists/jp.js +3 -0
  269. package/cjs/mnemonic/wordlists/ko.d.ts +2 -0
  270. package/cjs/mnemonic/wordlists/ko.js +3 -0
  271. package/cjs/mnemonic/wordlists/zh-s.d.ts +2 -0
  272. package/cjs/mnemonic/wordlists/zh-s.js +3 -0
  273. package/cjs/mnemonic/wordlists/zh-t.d.ts +2 -0
  274. package/cjs/mnemonic/wordlists/zh-t.js +3 -0
  275. package/cjs/nacl/decrypt.d.ts +15 -0
  276. package/cjs/nacl/decrypt.js +21 -0
  277. package/cjs/nacl/encrypt.d.ts +20 -0
  278. package/cjs/nacl/encrypt.js +25 -0
  279. package/cjs/nacl/index.d.ts +5 -0
  280. package/cjs/nacl/index.js +10 -0
  281. package/cjs/nacl/tweetnacl.d.ts +2 -0
  282. package/cjs/nacl/tweetnacl.js +238 -0
  283. package/cjs/networks.d.ts +1 -0
  284. package/cjs/networks.js +7 -0
  285. package/cjs/package.json +3 -0
  286. package/cjs/packageDetect.d.ts +1 -0
  287. package/cjs/packageDetect.js +8 -0
  288. package/cjs/packageInfo.d.ts +6 -0
  289. package/cjs/packageInfo.js +4 -0
  290. package/cjs/pbkdf2/encode.d.ts +7 -0
  291. package/cjs/pbkdf2/encode.js +19 -0
  292. package/cjs/pbkdf2/index.d.ts +1 -0
  293. package/cjs/pbkdf2/index.js +5 -0
  294. package/cjs/random/asNumber.d.ts +15 -0
  295. package/cjs/random/asNumber.js +23 -0
  296. package/cjs/random/asU8a.d.ts +20 -0
  297. package/cjs/random/asU8a.js +28 -0
  298. package/cjs/random/index.d.ts +5 -0
  299. package/cjs/random/index.js +11 -0
  300. package/cjs/scrypt/defaults.d.ts +3 -0
  301. package/cjs/scrypt/defaults.js +16 -0
  302. package/cjs/scrypt/encode.d.ts +8 -0
  303. package/cjs/scrypt/encode.js +18 -0
  304. package/cjs/scrypt/fromU8a.d.ts +7 -0
  305. package/cjs/scrypt/fromU8a.js +27 -0
  306. package/cjs/scrypt/index.d.ts +3 -0
  307. package/cjs/scrypt/index.js +9 -0
  308. package/cjs/scrypt/toU8a.d.ts +2 -0
  309. package/cjs/scrypt/toU8a.js +8 -0
  310. package/cjs/scrypt/types.d.ts +6 -0
  311. package/cjs/scrypt/types.js +2 -0
  312. package/cjs/secp256k1/compress.d.ts +1 -0
  313. package/cjs/secp256k1/compress.js +17 -0
  314. package/cjs/secp256k1/deriveHard.d.ts +1 -0
  315. package/cjs/secp256k1/deriveHard.js +13 -0
  316. package/cjs/secp256k1/expand.d.ts +1 -0
  317. package/cjs/secp256k1/expand.js +20 -0
  318. package/cjs/secp256k1/hasher.d.ts +2 -0
  319. package/cjs/secp256k1/hasher.js +10 -0
  320. package/cjs/secp256k1/index.d.ts +7 -0
  321. package/cjs/secp256k1/index.js +17 -0
  322. package/cjs/secp256k1/pair/fromSeed.d.ts +6 -0
  323. package/cjs/secp256k1/pair/fromSeed.js +34 -0
  324. package/cjs/secp256k1/recover.d.ts +6 -0
  325. package/cjs/secp256k1/recover.js +29 -0
  326. package/cjs/secp256k1/sign.d.ts +7 -0
  327. package/cjs/secp256k1/sign.js +23 -0
  328. package/cjs/secp256k1/tweakAdd.d.ts +1 -0
  329. package/cjs/secp256k1/tweakAdd.js +48 -0
  330. package/cjs/secp256k1/types.d.ts +1 -0
  331. package/cjs/secp256k1/types.js +2 -0
  332. package/cjs/secp256k1/verify.d.ts +6 -0
  333. package/cjs/secp256k1/verify.js +23 -0
  334. package/cjs/sha/asU8a.d.ts +15 -0
  335. package/cjs/sha/asU8a.js +22 -0
  336. package/cjs/sha/index.d.ts +4 -0
  337. package/cjs/sha/index.js +10 -0
  338. package/cjs/signature/index.d.ts +4 -0
  339. package/cjs/signature/index.js +8 -0
  340. package/cjs/signature/verify.d.ts +2 -0
  341. package/cjs/signature/verify.js +81 -0
  342. package/cjs/sr25519/agreement.d.ts +5 -0
  343. package/cjs/sr25519/agreement.js +20 -0
  344. package/cjs/sr25519/derive.d.ts +2 -0
  345. package/cjs/sr25519/derive.js +16 -0
  346. package/cjs/sr25519/deriveHard.d.ts +1 -0
  347. package/cjs/sr25519/deriveHard.js +7 -0
  348. package/cjs/sr25519/derivePublic.d.ts +1 -0
  349. package/cjs/sr25519/derivePublic.js +16 -0
  350. package/cjs/sr25519/deriveSoft.d.ts +1 -0
  351. package/cjs/sr25519/deriveSoft.js +7 -0
  352. package/cjs/sr25519/index.d.ts +9 -0
  353. package/cjs/sr25519/index.js +21 -0
  354. package/cjs/sr25519/pair/fromSeed.d.ts +6 -0
  355. package/cjs/sr25519/pair/fromSeed.js +22 -0
  356. package/cjs/sr25519/pair/fromU8a.d.ts +2 -0
  357. package/cjs/sr25519/pair/fromU8a.js +17 -0
  358. package/cjs/sr25519/pair/toU8a.d.ts +2 -0
  359. package/cjs/sr25519/pair/toU8a.js +7 -0
  360. package/cjs/sr25519/sign.d.ts +6 -0
  361. package/cjs/sr25519/sign.js +19 -0
  362. package/cjs/sr25519/verify.d.ts +5 -0
  363. package/cjs/sr25519/verify.js +21 -0
  364. package/cjs/sr25519/vrfSign.d.ts +6 -0
  365. package/cjs/sr25519/vrfSign.js +19 -0
  366. package/cjs/sr25519/vrfVerify.d.ts +5 -0
  367. package/cjs/sr25519/vrfVerify.js +22 -0
  368. package/cjs/types.d.ts +26 -0
  369. package/cjs/types.js +5 -0
  370. package/cjs/xxhash/asU8a.d.ts +20 -0
  371. package/cjs/xxhash/asU8a.js +39 -0
  372. package/cjs/xxhash/index.d.ts +4 -0
  373. package/cjs/xxhash/index.js +9 -0
  374. package/cjs/xxhash/xxhash64.d.ts +1 -0
  375. package/cjs/xxhash/xxhash64.js +103 -0
  376. package/crypto.d.ts +3 -0
  377. package/crypto.js +12 -0
  378. package/ed25519/deriveHard.d.ts +1 -0
  379. package/ed25519/deriveHard.js +9 -0
  380. package/ed25519/index.d.ts +10 -0
  381. package/ed25519/index.js +10 -0
  382. package/ed25519/pair/fromRandom.d.ts +16 -0
  383. package/ed25519/pair/fromRandom.js +19 -0
  384. package/ed25519/pair/fromSecret.d.ts +16 -0
  385. package/ed25519/pair/fromSecret.js +23 -0
  386. package/ed25519/pair/fromSeed.d.ts +16 -0
  387. package/ed25519/pair/fromSeed.js +31 -0
  388. package/ed25519/pair/fromString.d.ts +16 -0
  389. package/ed25519/pair/fromString.js +20 -0
  390. package/ed25519/sign.d.ts +16 -0
  391. package/ed25519/sign.js +30 -0
  392. package/ed25519/verify.d.ts +15 -0
  393. package/ed25519/verify.js +36 -0
  394. package/ethereum/encode.d.ts +2 -0
  395. package/ethereum/encode.js +25 -0
  396. package/ethereum/index.d.ts +3 -0
  397. package/ethereum/index.js +3 -0
  398. package/ethereum/isAddress.d.ts +1 -0
  399. package/ethereum/isAddress.js +11 -0
  400. package/ethereum/isChecksum.d.ts +1 -0
  401. package/ethereum/isChecksum.js +17 -0
  402. package/hd/ethereum/index.d.ts +2 -0
  403. package/hd/ethereum/index.js +44 -0
  404. package/hd/index.d.ts +3 -0
  405. package/hd/index.js +3 -0
  406. package/hd/ledger/derivePrivate.d.ts +1 -0
  407. package/hd/ledger/derivePrivate.js +12 -0
  408. package/hd/ledger/index.d.ts +2 -0
  409. package/hd/ledger/index.js +30 -0
  410. package/hd/ledger/master.d.ts +1 -0
  411. package/hd/ledger/master.js +16 -0
  412. package/hd/validatePath.d.ts +2 -0
  413. package/hd/validatePath.js +16 -0
  414. package/helpers.d.ts +12 -0
  415. package/helpers.js +19 -0
  416. package/hmac/index.d.ts +1 -0
  417. package/hmac/index.js +1 -0
  418. package/hmac/shaAsU8a.d.ts +15 -0
  419. package/hmac/shaAsU8a.js +36 -0
  420. package/index.d.ts +2 -0
  421. package/index.js +2 -0
  422. package/json/constants.d.ts +6 -0
  423. package/json/constants.js +5 -0
  424. package/json/decrypt.d.ts +2 -0
  425. package/json/decrypt.js +13 -0
  426. package/json/decryptData.d.ts +2 -0
  427. package/json/decryptData.js +29 -0
  428. package/json/encrypt.d.ts +2 -0
  429. package/json/encrypt.js +15 -0
  430. package/json/encryptFormat.d.ts +2 -0
  431. package/json/encryptFormat.js +14 -0
  432. package/json/index.d.ts +4 -0
  433. package/json/index.js +4 -0
  434. package/json/types.d.ts +16 -0
  435. package/json/types.js +1 -0
  436. package/keccak/asU8a.d.ts +30 -0
  437. package/keccak/asU8a.js +33 -0
  438. package/keccak/index.d.ts +4 -0
  439. package/keccak/index.js +4 -0
  440. package/key/DeriveJunction.d.ts +12 -0
  441. package/key/DeriveJunction.js +58 -0
  442. package/key/extractPath.d.ts +9 -0
  443. package/key/extractPath.js +23 -0
  444. package/key/extractSuri.d.ts +11 -0
  445. package/key/extractSuri.js +22 -0
  446. package/key/fromPath.d.ts +3 -0
  447. package/key/fromPath.js +18 -0
  448. package/key/hdkdDerive.d.ts +3 -0
  449. package/key/hdkdDerive.js +8 -0
  450. package/key/hdkdEcdsa.d.ts +1 -0
  451. package/key/hdkdEcdsa.js +4 -0
  452. package/key/hdkdEd25519.d.ts +1 -0
  453. package/key/hdkdEd25519.js +3 -0
  454. package/key/hdkdSr25519.d.ts +3 -0
  455. package/key/hdkdSr25519.js +7 -0
  456. package/key/index.d.ts +9 -0
  457. package/key/index.js +9 -0
  458. package/mnemonic/bip39.d.ts +5 -0
  459. package/mnemonic/bip39.js +82 -0
  460. package/mnemonic/generate.d.ts +13 -0
  461. package/mnemonic/generate.js +20 -0
  462. package/mnemonic/index.d.ts +8 -0
  463. package/mnemonic/index.js +8 -0
  464. package/mnemonic/toEntropy.d.ts +1 -0
  465. package/mnemonic/toEntropy.js +8 -0
  466. package/mnemonic/toLegacySeed.d.ts +18 -0
  467. package/mnemonic/toLegacySeed.js +34 -0
  468. package/mnemonic/toMiniSecret.d.ts +1 -0
  469. package/mnemonic/toMiniSecret.js +17 -0
  470. package/mnemonic/validate.d.ts +14 -0
  471. package/mnemonic/validate.js +21 -0
  472. package/mnemonic/wordlists/en.d.ts +2 -0
  473. package/mnemonic/wordlists/en.js +1 -0
  474. package/mnemonic/wordlists/es.d.ts +2 -0
  475. package/mnemonic/wordlists/es.js +1 -0
  476. package/mnemonic/wordlists/fr.d.ts +2 -0
  477. package/mnemonic/wordlists/fr.js +1 -0
  478. package/mnemonic/wordlists/index.d.ts +8 -0
  479. package/mnemonic/wordlists/index.js +8 -0
  480. package/mnemonic/wordlists/it.d.ts +2 -0
  481. package/mnemonic/wordlists/it.js +1 -0
  482. package/mnemonic/wordlists/jp.d.ts +2 -0
  483. package/mnemonic/wordlists/jp.js +1 -0
  484. package/mnemonic/wordlists/ko.d.ts +2 -0
  485. package/mnemonic/wordlists/ko.js +1 -0
  486. package/mnemonic/wordlists/zh-s.d.ts +2 -0
  487. package/mnemonic/wordlists/zh-s.js +1 -0
  488. package/mnemonic/wordlists/zh-t.d.ts +2 -0
  489. package/mnemonic/wordlists/zh-t.js +1 -0
  490. package/nacl/decrypt.d.ts +15 -0
  491. package/nacl/decrypt.js +18 -0
  492. package/nacl/encrypt.d.ts +20 -0
  493. package/nacl/encrypt.js +22 -0
  494. package/nacl/index.d.ts +5 -0
  495. package/nacl/index.js +5 -0
  496. package/nacl/tweetnacl.d.ts +2 -0
  497. package/nacl/tweetnacl.js +234 -0
  498. package/networks.d.ts +1 -0
  499. package/networks.js +1 -0
  500. package/package.json +2023 -11
  501. package/packageDetect.d.ts +1 -0
  502. package/packageDetect.js +6 -0
  503. package/packageInfo.d.ts +6 -0
  504. package/packageInfo.js +1 -0
  505. package/pbkdf2/encode.d.ts +7 -0
  506. package/pbkdf2/encode.js +16 -0
  507. package/pbkdf2/index.d.ts +1 -0
  508. package/pbkdf2/index.js +1 -0
  509. package/random/asNumber.d.ts +15 -0
  510. package/random/asNumber.js +20 -0
  511. package/random/asU8a.d.ts +20 -0
  512. package/random/asU8a.js +24 -0
  513. package/random/index.d.ts +5 -0
  514. package/random/index.js +5 -0
  515. package/scrypt/defaults.d.ts +3 -0
  516. package/scrypt/defaults.js +13 -0
  517. package/scrypt/encode.d.ts +8 -0
  518. package/scrypt/encode.js +15 -0
  519. package/scrypt/fromU8a.d.ts +7 -0
  520. package/scrypt/fromU8a.js +24 -0
  521. package/scrypt/index.d.ts +3 -0
  522. package/scrypt/index.js +3 -0
  523. package/scrypt/toU8a.d.ts +2 -0
  524. package/scrypt/toU8a.js +5 -0
  525. package/scrypt/types.d.ts +6 -0
  526. package/scrypt/types.js +1 -0
  527. package/secp256k1/compress.d.ts +1 -0
  528. package/secp256k1/compress.js +14 -0
  529. package/secp256k1/deriveHard.d.ts +1 -0
  530. package/secp256k1/deriveHard.js +10 -0
  531. package/secp256k1/expand.d.ts +1 -0
  532. package/secp256k1/expand.js +17 -0
  533. package/secp256k1/hasher.d.ts +2 -0
  534. package/secp256k1/hasher.js +7 -0
  535. package/secp256k1/index.d.ts +7 -0
  536. package/secp256k1/index.js +7 -0
  537. package/secp256k1/pair/fromSeed.d.ts +6 -0
  538. package/secp256k1/pair/fromSeed.js +31 -0
  539. package/secp256k1/recover.d.ts +6 -0
  540. package/secp256k1/recover.js +26 -0
  541. package/secp256k1/sign.d.ts +7 -0
  542. package/secp256k1/sign.js +20 -0
  543. package/secp256k1/tweakAdd.d.ts +1 -0
  544. package/secp256k1/tweakAdd.js +45 -0
  545. package/secp256k1/types.d.ts +1 -0
  546. package/secp256k1/types.js +1 -0
  547. package/secp256k1/verify.d.ts +6 -0
  548. package/secp256k1/verify.js +20 -0
  549. package/sha/asU8a.d.ts +15 -0
  550. package/sha/asU8a.js +19 -0
  551. package/sha/index.d.ts +4 -0
  552. package/sha/index.js +4 -0
  553. package/signature/index.d.ts +4 -0
  554. package/signature/index.js +4 -0
  555. package/signature/verify.d.ts +2 -0
  556. package/signature/verify.js +78 -0
  557. package/sr25519/agreement.d.ts +5 -0
  558. package/sr25519/agreement.js +17 -0
  559. package/sr25519/derive.d.ts +2 -0
  560. package/sr25519/derive.js +12 -0
  561. package/sr25519/deriveHard.d.ts +1 -0
  562. package/sr25519/deriveHard.js +3 -0
  563. package/sr25519/derivePublic.d.ts +1 -0
  564. package/sr25519/derivePublic.js +12 -0
  565. package/sr25519/deriveSoft.d.ts +1 -0
  566. package/sr25519/deriveSoft.js +3 -0
  567. package/sr25519/index.d.ts +9 -0
  568. package/sr25519/index.js +9 -0
  569. package/sr25519/pair/fromSeed.d.ts +6 -0
  570. package/sr25519/pair/fromSeed.js +18 -0
  571. package/sr25519/pair/fromU8a.d.ts +2 -0
  572. package/sr25519/pair/fromU8a.js +14 -0
  573. package/sr25519/pair/toU8a.d.ts +2 -0
  574. package/sr25519/pair/toU8a.js +4 -0
  575. package/sr25519/sign.d.ts +6 -0
  576. package/sr25519/sign.js +15 -0
  577. package/sr25519/verify.d.ts +5 -0
  578. package/sr25519/verify.js +17 -0
  579. package/sr25519/vrfSign.d.ts +6 -0
  580. package/sr25519/vrfSign.js +15 -0
  581. package/sr25519/vrfVerify.d.ts +5 -0
  582. package/sr25519/vrfVerify.js +18 -0
  583. package/src/packageInfo.ts +1 -1
  584. package/tsconfig.build.tsbuildinfo +1 -1
  585. package/tsconfig.spec.tsbuildinfo +1 -1
  586. package/types.d.ts +26 -0
  587. package/types.js +2 -0
  588. package/xxhash/asU8a.d.ts +20 -0
  589. package/xxhash/asU8a.js +35 -0
  590. package/xxhash/index.d.ts +4 -0
  591. package/xxhash/index.js +4 -0
  592. package/xxhash/xxhash64.d.ts +1 -0
  593. package/xxhash/xxhash64.js +100 -0
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sr25519VrfVerify = exports.sr25519VrfSign = exports.sr25519Verify = exports.sr25519Sign = exports.sr25519PairFromSeed = exports.sr25519DeriveSoft = exports.sr25519DerivePublic = exports.sr25519DeriveHard = exports.sr25519Agreement = void 0;
4
+ var agreement_js_1 = require("./agreement.js");
5
+ Object.defineProperty(exports, "sr25519Agreement", { enumerable: true, get: function () { return agreement_js_1.sr25519Agreement; } });
6
+ var deriveHard_js_1 = require("./deriveHard.js");
7
+ Object.defineProperty(exports, "sr25519DeriveHard", { enumerable: true, get: function () { return deriveHard_js_1.sr25519DeriveHard; } });
8
+ var derivePublic_js_1 = require("./derivePublic.js");
9
+ Object.defineProperty(exports, "sr25519DerivePublic", { enumerable: true, get: function () { return derivePublic_js_1.sr25519DerivePublic; } });
10
+ var deriveSoft_js_1 = require("./deriveSoft.js");
11
+ Object.defineProperty(exports, "sr25519DeriveSoft", { enumerable: true, get: function () { return deriveSoft_js_1.sr25519DeriveSoft; } });
12
+ var fromSeed_js_1 = require("./pair/fromSeed.js");
13
+ Object.defineProperty(exports, "sr25519PairFromSeed", { enumerable: true, get: function () { return fromSeed_js_1.sr25519PairFromSeed; } });
14
+ var sign_js_1 = require("./sign.js");
15
+ Object.defineProperty(exports, "sr25519Sign", { enumerable: true, get: function () { return sign_js_1.sr25519Sign; } });
16
+ var verify_js_1 = require("./verify.js");
17
+ Object.defineProperty(exports, "sr25519Verify", { enumerable: true, get: function () { return verify_js_1.sr25519Verify; } });
18
+ var vrfSign_js_1 = require("./vrfSign.js");
19
+ Object.defineProperty(exports, "sr25519VrfSign", { enumerable: true, get: function () { return vrfSign_js_1.sr25519VrfSign; } });
20
+ var vrfVerify_js_1 = require("./vrfVerify.js");
21
+ Object.defineProperty(exports, "sr25519VrfVerify", { enumerable: true, get: function () { return vrfVerify_js_1.sr25519VrfVerify; } });
@@ -0,0 +1,6 @@
1
+ import type { Keypair } from '../../types.js';
2
+ /**
3
+ * @name sr25519PairFromSeed
4
+ * @description Returns a object containing a `publicKey` & `secretKey` generated from the supplied seed.
5
+ */
6
+ export declare function sr25519PairFromSeed(seed: string | Uint8Array): Keypair;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sr25519PairFromSeed = sr25519PairFromSeed;
4
+ const tslib_1 = require("tslib");
5
+ const sr25519 = tslib_1.__importStar(require("@scure/sr25519"));
6
+ const util_1 = require("@pezkuwi/util");
7
+ /**
8
+ * @name sr25519PairFromSeed
9
+ * @description Returns a object containing a `publicKey` & `secretKey` generated from the supplied seed.
10
+ */
11
+ function sr25519PairFromSeed(seed) {
12
+ const seedU8a = (0, util_1.u8aToU8a)(seed);
13
+ if (seedU8a.length !== 32) {
14
+ throw new Error(`Expected a seed matching 32 bytes, found ${seedU8a.length}`);
15
+ }
16
+ const sec = sr25519.secretFromSeed(seedU8a);
17
+ const pub = sr25519.getPublicKey(sec);
18
+ return {
19
+ publicKey: pub,
20
+ secretKey: sec
21
+ };
22
+ }
@@ -0,0 +1,2 @@
1
+ import type { Keypair } from '../../types.js';
2
+ export declare function sr25519PairFromU8a(full: string | Uint8Array): Keypair;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sr25519PairFromU8a = sr25519PairFromU8a;
4
+ const util_1 = require("@pezkuwi/util");
5
+ const SEC_LEN = 64;
6
+ const PUB_LEN = 32;
7
+ const TOT_LEN = SEC_LEN + PUB_LEN;
8
+ function sr25519PairFromU8a(full) {
9
+ const fullU8a = (0, util_1.u8aToU8a)(full);
10
+ if (fullU8a.length !== TOT_LEN) {
11
+ throw new Error(`Expected keypair with ${TOT_LEN} bytes, found ${fullU8a.length}`);
12
+ }
13
+ return {
14
+ publicKey: fullU8a.slice(SEC_LEN, TOT_LEN),
15
+ secretKey: fullU8a.slice(0, SEC_LEN)
16
+ };
17
+ }
@@ -0,0 +1,2 @@
1
+ import type { Keypair } from '../../types.js';
2
+ export declare function sr25519KeypairToU8a({ publicKey, secretKey }: Keypair): Uint8Array;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sr25519KeypairToU8a = sr25519KeypairToU8a;
4
+ const util_1 = require("@pezkuwi/util");
5
+ function sr25519KeypairToU8a({ publicKey, secretKey }) {
6
+ return (0, util_1.u8aConcat)(secretKey, publicKey).slice();
7
+ }
@@ -0,0 +1,6 @@
1
+ import type { Keypair } from '../types.js';
2
+ /**
3
+ * @name sr25519Sign
4
+ * @description Returns message signature of `message`, using the supplied pair
5
+ */
6
+ export declare function sr25519Sign(message: string | Uint8Array, { publicKey, secretKey }: Partial<Keypair>): Uint8Array;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sr25519Sign = sr25519Sign;
4
+ const tslib_1 = require("tslib");
5
+ const sr25519 = tslib_1.__importStar(require("@scure/sr25519"));
6
+ const util_1 = require("@pezkuwi/util");
7
+ /**
8
+ * @name sr25519Sign
9
+ * @description Returns message signature of `message`, using the supplied pair
10
+ */
11
+ function sr25519Sign(message, { publicKey, secretKey }) {
12
+ if (publicKey?.length !== 32) {
13
+ throw new Error('Expected a valid publicKey, 32-bytes');
14
+ }
15
+ else if (secretKey?.length !== 64) {
16
+ throw new Error('Expected a valid secretKey, 64-bytes');
17
+ }
18
+ return sr25519.sign(secretKey, (0, util_1.u8aToU8a)(message));
19
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @name sr25519Verify
3
+ * @description Verifies the signature of `message`, using the supplied pair
4
+ */
5
+ export declare function sr25519Verify(message: string | Uint8Array, signature: string | Uint8Array, publicKey: string | Uint8Array): boolean;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sr25519Verify = sr25519Verify;
4
+ const tslib_1 = require("tslib");
5
+ const sr25519 = tslib_1.__importStar(require("@scure/sr25519"));
6
+ const util_1 = require("@pezkuwi/util");
7
+ /**
8
+ * @name sr25519Verify
9
+ * @description Verifies the signature of `message`, using the supplied pair
10
+ */
11
+ function sr25519Verify(message, signature, publicKey) {
12
+ const publicKeyU8a = (0, util_1.u8aToU8a)(publicKey);
13
+ const signatureU8a = (0, util_1.u8aToU8a)(signature);
14
+ if (publicKeyU8a.length !== 32) {
15
+ throw new Error(`Invalid publicKey, received ${publicKeyU8a.length} bytes, expected 32`);
16
+ }
17
+ else if (signatureU8a.length !== 64) {
18
+ throw new Error(`Invalid signature, received ${signatureU8a.length} bytes, expected 64`);
19
+ }
20
+ return sr25519.verify((0, util_1.u8aToU8a)(message), signatureU8a, publicKeyU8a);
21
+ }
@@ -0,0 +1,6 @@
1
+ import type { Keypair } from '../types.js';
2
+ /**
3
+ * @name sr25519VrfSign
4
+ * @description Sign with sr25519 vrf signing (deterministic)
5
+ */
6
+ export declare function sr25519VrfSign(message: string | Uint8Array, { secretKey }: Partial<Keypair>, context?: string | Uint8Array, extra?: string | Uint8Array): Uint8Array;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sr25519VrfSign = sr25519VrfSign;
4
+ const tslib_1 = require("tslib");
5
+ const utils_1 = require("@noble/hashes/utils");
6
+ const sr25519 = tslib_1.__importStar(require("@scure/sr25519"));
7
+ const util_1 = require("@pezkuwi/util");
8
+ const EMPTY_U8A = new Uint8Array();
9
+ /**
10
+ * @name sr25519VrfSign
11
+ * @description Sign with sr25519 vrf signing (deterministic)
12
+ */
13
+ function sr25519VrfSign(message, { secretKey }, context = EMPTY_U8A, extra = EMPTY_U8A) {
14
+ if (secretKey?.length !== 64) {
15
+ throw new Error('Invalid secretKey, expected 64-bytes');
16
+ }
17
+ return sr25519.vrf.sign((0, util_1.u8aToU8a)(message), secretKey, (0, util_1.u8aToU8a)(context), (0, util_1.u8aToU8a)(extra), utils_1.randomBytes);
18
+ // return vrfSign(secretKey, u8aToU8a(context), u8aToU8a(message), u8aToU8a(extra));
19
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @name sr25519VrfVerify
3
+ * @description Verify with sr25519 vrf verification
4
+ */
5
+ export declare function sr25519VrfVerify(message: string | Uint8Array, signOutput: string | Uint8Array, publicKey: string | Uint8Array, context?: string | Uint8Array, extra?: string | Uint8Array): boolean;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sr25519VrfVerify = sr25519VrfVerify;
4
+ const tslib_1 = require("tslib");
5
+ const sr25519 = tslib_1.__importStar(require("@scure/sr25519"));
6
+ const util_1 = require("@pezkuwi/util");
7
+ const EMPTY_U8A = new Uint8Array();
8
+ /**
9
+ * @name sr25519VrfVerify
10
+ * @description Verify with sr25519 vrf verification
11
+ */
12
+ function sr25519VrfVerify(message, signOutput, publicKey, context = EMPTY_U8A, extra = EMPTY_U8A) {
13
+ const publicKeyU8a = (0, util_1.u8aToU8a)(publicKey);
14
+ const proofU8a = (0, util_1.u8aToU8a)(signOutput);
15
+ if (publicKeyU8a.length !== 32) {
16
+ throw new Error('Invalid publicKey, expected 32-bytes');
17
+ }
18
+ else if (proofU8a.length !== 96) {
19
+ throw new Error('Invalid vrfSign output, expected 96 bytes');
20
+ }
21
+ return sr25519.vrf.verify((0, util_1.u8aToU8a)(message), proofU8a, publicKeyU8a, (0, util_1.u8aToU8a)(context), (0, util_1.u8aToU8a)(extra));
22
+ }
package/cjs/types.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ export * from './address/types.js';
2
+ export * from './json/types.js';
3
+ export interface Keypair {
4
+ /** The publicKey for this pair */
5
+ publicKey: Uint8Array;
6
+ /** The secretKey for this pair */
7
+ secretKey: Uint8Array;
8
+ }
9
+ export interface Seedpair {
10
+ /** The publicKey for this pair */
11
+ publicKey: Uint8Array;
12
+ /** The seed used to construct the pair */
13
+ seed: Uint8Array;
14
+ }
15
+ /** The supported types of pairs */
16
+ export type KeypairType = 'ed25519' | 'sr25519' | 'ecdsa' | 'ethereum';
17
+ export interface VerifyResult {
18
+ /** The detected crypto interface, or 'none' if not detected */
19
+ crypto: 'none' | KeypairType;
20
+ /** The validity for this result, false if invalid */
21
+ isValid: boolean;
22
+ /** Flag to indicate if the passed data was wrapped in <Bytes>...</Bytes> */
23
+ isWrapped: boolean;
24
+ /** The extracted publicKey */
25
+ publicKey: Uint8Array;
26
+ }
package/cjs/types.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./address/types.js"), exports);
5
+ tslib_1.__exportStar(require("./json/types.js"), exports);
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @name xxhashAsU8a
3
+ * @summary Creates a xxhash64 u8a from the input.
4
+ * @description
5
+ * From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash64 and return the result as a `Uint8Array` with the specified `bitLength`.
6
+ * @example
7
+ * <BR>
8
+ *
9
+ * ```javascript
10
+ * import { xxhashAsU8a } from '@pezkuwi/util-crypto';
11
+ *
12
+ * xxhashAsU8a('abc'); // => 0x44bc2cf5ad770999
13
+ * ```
14
+ */
15
+ export declare function xxhashAsU8a(data: string | Uint8Array, bitLength?: 64 | 128 | 192 | 256 | 320 | 384 | 448 | 512, onlyJs?: boolean): Uint8Array;
16
+ /**
17
+ * @name xxhashAsHex
18
+ * @description Creates a xxhash64 hex from the input.
19
+ */
20
+ export declare const xxhashAsHex: (data: string | Uint8Array, bitLength?: 256 | 512 | 64 | 128 | 384 | 320 | 192 | 448 | undefined, onlyJs?: boolean | undefined) => import("@pezkuwi/util/types").HexString;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.xxhashAsHex = void 0;
4
+ exports.xxhashAsU8a = xxhashAsU8a;
5
+ const util_1 = require("@pezkuwi/util");
6
+ const wasm_crypto_1 = require("@pezkuwi/wasm-crypto");
7
+ const helpers_js_1 = require("../helpers.js");
8
+ const xxhash64_js_1 = require("./xxhash64.js");
9
+ /**
10
+ * @name xxhashAsU8a
11
+ * @summary Creates a xxhash64 u8a from the input.
12
+ * @description
13
+ * From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash64 and return the result as a `Uint8Array` with the specified `bitLength`.
14
+ * @example
15
+ * <BR>
16
+ *
17
+ * ```javascript
18
+ * import { xxhashAsU8a } from '@pezkuwi/util-crypto';
19
+ *
20
+ * xxhashAsU8a('abc'); // => 0x44bc2cf5ad770999
21
+ * ```
22
+ */
23
+ function xxhashAsU8a(data, bitLength = 64, onlyJs) {
24
+ const rounds = Math.ceil(bitLength / 64);
25
+ const u8a = (0, util_1.u8aToU8a)(data);
26
+ if (!util_1.hasBigInt || (!onlyJs && (0, wasm_crypto_1.isReady)())) {
27
+ return (0, wasm_crypto_1.twox)(u8a, rounds);
28
+ }
29
+ const result = new Uint8Array(rounds * 8);
30
+ for (let seed = 0; seed < rounds; seed++) {
31
+ result.set((0, xxhash64_js_1.xxhash64)(u8a, seed).reverse(), seed * 8);
32
+ }
33
+ return result;
34
+ }
35
+ /**
36
+ * @name xxhashAsHex
37
+ * @description Creates a xxhash64 hex from the input.
38
+ */
39
+ exports.xxhashAsHex = (0, helpers_js_1.createAsHex)(xxhashAsU8a);
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @summary Create xxhash64 values with specified bitlengths
3
+ */
4
+ export { xxhashAsHex, xxhashAsU8a } from './asU8a.js';
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.xxhashAsU8a = exports.xxhashAsHex = void 0;
4
+ /**
5
+ * @summary Create xxhash64 values with specified bitlengths
6
+ */
7
+ var asU8a_js_1 = require("./asU8a.js");
8
+ Object.defineProperty(exports, "xxhashAsHex", { enumerable: true, get: function () { return asU8a_js_1.xxhashAsHex; } });
9
+ Object.defineProperty(exports, "xxhashAsU8a", { enumerable: true, get: function () { return asU8a_js_1.xxhashAsU8a; } });
@@ -0,0 +1 @@
1
+ export declare function xxhash64(input: Uint8Array, initSeed: bigint | number): Uint8Array;
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.xxhash64 = xxhash64;
4
+ const util_1 = require("@pezkuwi/util");
5
+ const x_bigint_1 = require("@pezkuwi/x-bigint");
6
+ const P64_1 = (0, x_bigint_1.BigInt)('11400714785074694791');
7
+ const P64_2 = (0, x_bigint_1.BigInt)('14029467366897019727');
8
+ const P64_3 = (0, x_bigint_1.BigInt)('1609587929392839161');
9
+ const P64_4 = (0, x_bigint_1.BigInt)('9650029242287828579');
10
+ const P64_5 = (0, x_bigint_1.BigInt)('2870177450012600261');
11
+ const U64 = (0, x_bigint_1.BigInt)('0xffffffffffffffff');
12
+ const _7n = (0, x_bigint_1.BigInt)(7);
13
+ const _11n = (0, x_bigint_1.BigInt)(11);
14
+ const _12n = (0, x_bigint_1.BigInt)(12);
15
+ const _16n = (0, x_bigint_1.BigInt)(16);
16
+ const _18n = (0, x_bigint_1.BigInt)(18);
17
+ const _23n = (0, x_bigint_1.BigInt)(23);
18
+ const _27n = (0, x_bigint_1.BigInt)(27);
19
+ const _29n = (0, x_bigint_1.BigInt)(29);
20
+ const _31n = (0, x_bigint_1.BigInt)(31);
21
+ const _32n = (0, x_bigint_1.BigInt)(32);
22
+ const _33n = (0, x_bigint_1.BigInt)(33);
23
+ const _64n = (0, x_bigint_1.BigInt)(64);
24
+ const _256n = (0, x_bigint_1.BigInt)(256);
25
+ function rotl(a, b) {
26
+ const c = a & U64;
27
+ return ((c << b) | (c >> (_64n - b))) & U64;
28
+ }
29
+ function fromU8a(u8a, p, count) {
30
+ const bigints = new Array(count);
31
+ let offset = 0;
32
+ for (let i = 0; i < count; i++, offset += 2) {
33
+ bigints[i] = (0, x_bigint_1.BigInt)(u8a[p + offset] | (u8a[p + 1 + offset] << 8));
34
+ }
35
+ let result = util_1._0n;
36
+ for (let i = count - 1; i >= 0; i--) {
37
+ result = (result << _16n) + bigints[i];
38
+ }
39
+ return result;
40
+ }
41
+ function init(seed, input) {
42
+ const state = {
43
+ seed,
44
+ u8a: new Uint8Array(32),
45
+ u8asize: 0,
46
+ v1: seed + P64_1 + P64_2,
47
+ v2: seed + P64_2,
48
+ v3: seed,
49
+ v4: seed - P64_1
50
+ };
51
+ if (input.length < 32) {
52
+ state.u8a.set(input);
53
+ state.u8asize = input.length;
54
+ return state;
55
+ }
56
+ const limit = input.length - 32;
57
+ let p = 0;
58
+ if (limit >= 0) {
59
+ const adjustV = (v) => P64_1 * rotl(v + P64_2 * fromU8a(input, p, 4), _31n);
60
+ do {
61
+ state.v1 = adjustV(state.v1);
62
+ p += 8;
63
+ state.v2 = adjustV(state.v2);
64
+ p += 8;
65
+ state.v3 = adjustV(state.v3);
66
+ p += 8;
67
+ state.v4 = adjustV(state.v4);
68
+ p += 8;
69
+ } while (p <= limit);
70
+ }
71
+ if (p < input.length) {
72
+ state.u8a.set(input.subarray(p, input.length));
73
+ state.u8asize = input.length - p;
74
+ }
75
+ return state;
76
+ }
77
+ function xxhash64(input, initSeed) {
78
+ const { seed, u8a, u8asize, v1, v2, v3, v4 } = init((0, x_bigint_1.BigInt)(initSeed), input);
79
+ let p = 0;
80
+ let h64 = U64 & ((0, x_bigint_1.BigInt)(input.length) + (input.length >= 32
81
+ ? (((((((((rotl(v1, util_1._1n) + rotl(v2, _7n) + rotl(v3, _12n) + rotl(v4, _18n)) ^ (P64_1 * rotl(v1 * P64_2, _31n))) * P64_1 + P64_4) ^ (P64_1 * rotl(v2 * P64_2, _31n))) * P64_1 + P64_4) ^ (P64_1 * rotl(v3 * P64_2, _31n))) * P64_1 + P64_4) ^ (P64_1 * rotl(v4 * P64_2, _31n))) * P64_1 + P64_4)
82
+ : (seed + P64_5)));
83
+ while (p <= (u8asize - 8)) {
84
+ h64 = U64 & (P64_4 + P64_1 * rotl(h64 ^ (P64_1 * rotl(P64_2 * fromU8a(u8a, p, 4), _31n)), _27n));
85
+ p += 8;
86
+ }
87
+ if ((p + 4) <= u8asize) {
88
+ h64 = U64 & (P64_3 + P64_2 * rotl(h64 ^ (P64_1 * fromU8a(u8a, p, 2)), _23n));
89
+ p += 4;
90
+ }
91
+ while (p < u8asize) {
92
+ h64 = U64 & (P64_1 * rotl(h64 ^ (P64_5 * (0, x_bigint_1.BigInt)(u8a[p++])), _11n));
93
+ }
94
+ h64 = U64 & (P64_2 * (h64 ^ (h64 >> _33n)));
95
+ h64 = U64 & (P64_3 * (h64 ^ (h64 >> _29n)));
96
+ h64 = U64 & (h64 ^ (h64 >> _32n));
97
+ const result = new Uint8Array(8);
98
+ for (let i = 7; i >= 0; i--) {
99
+ result[i] = Number(h64 % _256n);
100
+ h64 = h64 / _256n;
101
+ }
102
+ return result;
103
+ }
package/crypto.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { isReady } from '@pezkuwi/wasm-crypto';
2
+ export declare const cryptoIsReady: typeof isReady;
3
+ export declare function cryptoWaitReady(): Promise<boolean>;
package/crypto.js ADDED
@@ -0,0 +1,12 @@
1
+ import { isReady, waitReady } from '@pezkuwi/wasm-crypto';
2
+ export const cryptoIsReady = isReady;
3
+ export function cryptoWaitReady() {
4
+ return waitReady()
5
+ .then(() => {
6
+ if (!isReady()) {
7
+ throw new Error('Unable to initialize @pezkuwi/util-crypto');
8
+ }
9
+ return true;
10
+ })
11
+ .catch(() => false);
12
+ }
@@ -0,0 +1 @@
1
+ export declare function ed25519DeriveHard(seed: Uint8Array, chainCode: Uint8Array): Uint8Array;
@@ -0,0 +1,9 @@
1
+ import { compactAddLength, isU8a, stringToU8a, u8aConcat } from '@pezkuwi/util';
2
+ import { blake2AsU8a } from '../blake2/asU8a.js';
3
+ const HDKD = compactAddLength(stringToU8a('Ed25519HDKD'));
4
+ export function ed25519DeriveHard(seed, chainCode) {
5
+ if (!isU8a(chainCode) || chainCode.length !== 32) {
6
+ throw new Error('Invalid chainCode passed to derive');
7
+ }
8
+ return blake2AsU8a(u8aConcat(HDKD, seed, chainCode));
9
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @summary Implements ed25519 operations
3
+ */
4
+ export { ed25519DeriveHard } from './deriveHard.js';
5
+ export { ed25519PairFromRandom } from './pair/fromRandom.js';
6
+ export { ed25519PairFromSecret } from './pair/fromSecret.js';
7
+ export { ed25519PairFromSeed } from './pair/fromSeed.js';
8
+ export { ed25519PairFromString } from './pair/fromString.js';
9
+ export { ed25519Sign } from './sign.js';
10
+ export { ed25519Verify } from './verify.js';
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @summary Implements ed25519 operations
3
+ */
4
+ export { ed25519DeriveHard } from './deriveHard.js';
5
+ export { ed25519PairFromRandom } from './pair/fromRandom.js';
6
+ export { ed25519PairFromSecret } from './pair/fromSecret.js';
7
+ export { ed25519PairFromSeed } from './pair/fromSeed.js';
8
+ export { ed25519PairFromString } from './pair/fromString.js';
9
+ export { ed25519Sign } from './sign.js';
10
+ export { ed25519Verify } from './verify.js';
@@ -0,0 +1,16 @@
1
+ import type { Keypair } from '../../types.js';
2
+ /**
3
+ * @name ed25519PairFromRandom
4
+ * @summary Creates a new public/secret keypair.
5
+ * @description
6
+ * Returns a new generate object containing a `publicKey` & `secretKey`.
7
+ * @example
8
+ * <BR>
9
+ *
10
+ * ```javascript
11
+ * import { ed25519PairFromRandom } from '@pezkuwi/util-crypto';
12
+ *
13
+ * ed25519PairFromRandom(); // => { secretKey: [...], publicKey: [...] }
14
+ * ```
15
+ */
16
+ export declare function ed25519PairFromRandom(): Keypair;
@@ -0,0 +1,19 @@
1
+ import { randomAsU8a } from '../../random/index.js';
2
+ import { ed25519PairFromSeed } from './fromSeed.js';
3
+ /**
4
+ * @name ed25519PairFromRandom
5
+ * @summary Creates a new public/secret keypair.
6
+ * @description
7
+ * Returns a new generate object containing a `publicKey` & `secretKey`.
8
+ * @example
9
+ * <BR>
10
+ *
11
+ * ```javascript
12
+ * import { ed25519PairFromRandom } from '@pezkuwi/util-crypto';
13
+ *
14
+ * ed25519PairFromRandom(); // => { secretKey: [...], publicKey: [...] }
15
+ * ```
16
+ */
17
+ export function ed25519PairFromRandom() {
18
+ return ed25519PairFromSeed(randomAsU8a());
19
+ }
@@ -0,0 +1,16 @@
1
+ import type { Keypair } from '../../types.js';
2
+ /**
3
+ * @name ed25519PairFromSecret
4
+ * @summary Creates a new public/secret keypair from a secret.
5
+ * @description
6
+ * Returns a object containing a `publicKey` & `secretKey` generated from the supplied secret.
7
+ * @example
8
+ * <BR>
9
+ *
10
+ * ```javascript
11
+ * import { ed25519PairFromSecret } from '@pezkuwi/util-crypto';
12
+ *
13
+ * ed25519PairFromSecret(...); // => { secretKey: [...], publicKey: [...] }
14
+ * ```
15
+ */
16
+ export declare function ed25519PairFromSecret(secretKey: Uint8Array): Keypair;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @name ed25519PairFromSecret
3
+ * @summary Creates a new public/secret keypair from a secret.
4
+ * @description
5
+ * Returns a object containing a `publicKey` & `secretKey` generated from the supplied secret.
6
+ * @example
7
+ * <BR>
8
+ *
9
+ * ```javascript
10
+ * import { ed25519PairFromSecret } from '@pezkuwi/util-crypto';
11
+ *
12
+ * ed25519PairFromSecret(...); // => { secretKey: [...], publicKey: [...] }
13
+ * ```
14
+ */
15
+ export function ed25519PairFromSecret(secretKey) {
16
+ if (secretKey.length !== 64) {
17
+ throw new Error('Invalid secretKey provided');
18
+ }
19
+ return {
20
+ publicKey: secretKey.slice(32),
21
+ secretKey
22
+ };
23
+ }
@@ -0,0 +1,16 @@
1
+ import type { Keypair } from '../../types.js';
2
+ /**
3
+ * @name ed25519PairFromSeed
4
+ * @summary Creates a new public/secret keypair from a seed.
5
+ * @description
6
+ * Returns a object containing a `publicKey` & `secretKey` generated from the supplied seed.
7
+ * @example
8
+ * <BR>
9
+ *
10
+ * ```javascript
11
+ * import { ed25519PairFromSeed } from '@pezkuwi/util-crypto';
12
+ *
13
+ * ed25519PairFromSeed(...); // => { secretKey: [...], publicKey: [...] }
14
+ * ```
15
+ */
16
+ export declare function ed25519PairFromSeed(seed: Uint8Array, onlyJs?: boolean): Keypair;
@@ -0,0 +1,31 @@
1
+ import { ed25519 } from '@noble/curves/ed25519';
2
+ import { hasBigInt, u8aConcatStrict } from '@pezkuwi/util';
3
+ import { ed25519KeypairFromSeed, isReady } from '@pezkuwi/wasm-crypto';
4
+ /**
5
+ * @name ed25519PairFromSeed
6
+ * @summary Creates a new public/secret keypair from a seed.
7
+ * @description
8
+ * Returns a object containing a `publicKey` & `secretKey` generated from the supplied seed.
9
+ * @example
10
+ * <BR>
11
+ *
12
+ * ```javascript
13
+ * import { ed25519PairFromSeed } from '@pezkuwi/util-crypto';
14
+ *
15
+ * ed25519PairFromSeed(...); // => { secretKey: [...], publicKey: [...] }
16
+ * ```
17
+ */
18
+ export function ed25519PairFromSeed(seed, onlyJs) {
19
+ if (!hasBigInt || (!onlyJs && isReady())) {
20
+ const full = ed25519KeypairFromSeed(seed);
21
+ return {
22
+ publicKey: full.slice(32),
23
+ secretKey: full.slice(0, 64)
24
+ };
25
+ }
26
+ const publicKey = ed25519.getPublicKey(seed);
27
+ return {
28
+ publicKey,
29
+ secretKey: u8aConcatStrict([seed, publicKey])
30
+ };
31
+ }
@@ -0,0 +1,16 @@
1
+ import type { Keypair } from '../../types.js';
2
+ /**
3
+ * @name ed25519PairFromString
4
+ * @summary Creates a new public/secret keypair from a string.
5
+ * @description
6
+ * Returns a object containing a `publicKey` & `secretKey` generated from the supplied string. The string is hashed and the value used as the input seed.
7
+ * @example
8
+ * <BR>
9
+ *
10
+ * ```javascript
11
+ * import { ed25519PairFromString } from '@pezkuwi/util-crypto';
12
+ *
13
+ * ed25519PairFromString('test'); // => { secretKey: [...], publicKey: [...] }
14
+ * ```
15
+ */
16
+ export declare function ed25519PairFromString(value: string): Keypair;
@@ -0,0 +1,20 @@
1
+ import { stringToU8a } from '@pezkuwi/util';
2
+ import { blake2AsU8a } from '../../blake2/asU8a.js';
3
+ import { ed25519PairFromSeed } from './fromSeed.js';
4
+ /**
5
+ * @name ed25519PairFromString
6
+ * @summary Creates a new public/secret keypair from a string.
7
+ * @description
8
+ * Returns a object containing a `publicKey` & `secretKey` generated from the supplied string. The string is hashed and the value used as the input seed.
9
+ * @example
10
+ * <BR>
11
+ *
12
+ * ```javascript
13
+ * import { ed25519PairFromString } from '@pezkuwi/util-crypto';
14
+ *
15
+ * ed25519PairFromString('test'); // => { secretKey: [...], publicKey: [...] }
16
+ * ```
17
+ */
18
+ export function ed25519PairFromString(value) {
19
+ return ed25519PairFromSeed(blake2AsU8a(stringToU8a(value)));
20
+ }