@laceio/sdk 0.1.1 → 0.1.2-canary.0
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.
- package/dist/{TransactionBuilder-DrB3NVTi.cjs → TransactionBuilder-CCjOn7NA.cjs} +42 -0
- package/dist/{TransactionBuilder-V6aLx4SV.js → TransactionBuilder-CIzdw18M.js} +1 -1
- package/dist/{_polyfill-buffer-patch-BnPVerlG.cjs → _polyfill-buffer-patch-CM8X7JiY.cjs} +21 -2
- package/dist/_polyfill-buffer-patch-yNxN4d5E.js +1467 -0
- package/dist/_web-crypto-random-bytes-Bo-GTcRS.js +197 -0
- package/dist/acc-module-4iIUv6My.cjs +27654 -0
- package/dist/acc-module-Cmj8EsIb.js +27624 -0
- package/dist/account-BOQruszJ.js +6 -0
- package/dist/account-BUOj4pYJ.cjs +11 -0
- package/dist/account-call-7wnopBq0.cjs +5 -0
- package/dist/account-call-B9d_2Xwi.js +4 -0
- package/dist/account-call-Bd4Rpbvt.cjs +323 -0
- package/dist/account-call-C3CkDqEC.js +276 -0
- package/dist/account-guards-BtjTGxDZ.cjs +42 -0
- package/dist/account-guards-D9Lu5T3W.js +36 -0
- package/dist/account-tokens-DvkOFVON.js +16 -0
- package/dist/account-tokens-nwcvwLu4.cjs +21 -0
- package/dist/{activity-type.stable-BJEfeLxL.cjs → activity-type-Ch6ljxBy.cjs} +2 -1
- package/dist/{activity-type.stable-C76_hWd7.js → activity-type-GsJGWs-3.js} +2 -1
- package/dist/address-B9ntKL8K.js +13761 -0
- package/dist/address-BXp-mY8H.cjs +11270 -0
- package/dist/{address-book-address-validator-DIUolI-s.js → address-book-address-validator-0J9XAADH.js} +2 -2
- package/dist/address-book-address-validator-DK0dnsRS.cjs +41 -0
- package/dist/address-book-address-validator-Di_ywo8M.js +39 -0
- package/dist/{address-book-address-validator-DNwQGlOB.cjs → address-book-address-validator-Dte_YQ2L.cjs} +2 -2
- package/dist/artefact-loader-BWWYAD7E.cjs +183 -0
- package/dist/artefact-loader-Dik4HIfv.js +160 -0
- package/dist/auto-dismiss-failure-on-success-C-qoJuid.cjs +37 -0
- package/dist/auto-dismiss-failure-on-success-s8MGDEIu.js +31 -0
- package/dist/bip32-D6wd_QMn.cjs +3851 -0
- package/dist/bitcoin-data-provider-BYPSmuZS.js +21 -0
- package/dist/bitcoin-data-provider-w1oEDSU3.cjs +26 -0
- package/dist/bitcoin.cjs +45 -0
- package/dist/bitcoin.d.ts +29906 -1
- package/dist/bitcoin.js +20 -0
- package/dist/{blockfrost-tx-submit-provider-DPTrapz-.js → blockfrost-tx-submit-provider-CBWQ0wK9.js} +5 -157
- package/dist/{blockfrost-tx-submit-provider-BAIzV5o3.cjs → blockfrost-tx-submit-provider-CLNQ5ycR.cjs} +3 -167
- package/dist/bn-d3nSOIf7.cjs +2553 -0
- package/dist/browser-B1eMbDwh.js +7468 -0
- package/dist/bytes.vo-BB7_4JK6.js +23 -0
- package/dist/bytes.vo-BNRquqaO.cjs +34 -0
- package/dist/cardano-DfPwhwm-.js +3 -0
- package/dist/{cardano-network-id.vo-DSxrFk9S.cjs → cardano-network-id.vo-BEDPn6Li.cjs} +1 -1
- package/dist/{cardano-network-id.vo-CK1tNQDg.js → cardano-network-id.vo-Cfpvbod9.js} +1 -1
- package/dist/cardano.cjs +22 -18
- package/dist/cardano.d.ts +16956 -1716
- package/dist/cardano.js +16 -11
- package/dist/client-DXBLHk7K.cjs +808 -0
- package/dist/codecs-Cswkg7Tm.cjs +4051 -0
- package/dist/codecs-Dc1Krpbt.js +3903 -0
- package/dist/{const-C84qHkjp.js → const-BJfIK_G-.js} +4 -4
- package/dist/const-BhYOdznB.cjs +42 -0
- package/dist/const-BsnjG2_Q.cjs +32071 -0
- package/dist/const-CUnCl5U0.js +13 -0
- package/dist/{const-DXk2tFyv.js → const-CjmfjBP3.js} +1 -1
- package/dist/{const-BDEg2Trq.cjs → const-D-eZIS4n.cjs} +4 -4
- package/dist/const-D0CbQlo4.js +154 -0
- package/dist/{const-BY8B3_0_.cjs → const-iwzZEE_w.cjs} +1 -1
- package/dist/contract-1R86jhSw.js +171 -0
- package/dist/contract-MKLzYVkW.cjs +189 -0
- package/dist/create-add-accounts-Brqk84vF.js +102 -0
- package/dist/create-add-accounts-DzXIh7Ot.cjs +114 -0
- package/dist/{delegation-tx-builder-CRpLP6jH.cjs → delegation-tx-builder-CCjiakoy.cjs} +6 -6
- package/dist/{delegation-tx-builder-CGVqlaFE.js → delegation-tx-builder-DZFjHDS8.js} +5 -5
- package/dist/{deregistration-tx-builder-B-CrUyX6.js → deregistration-tx-builder-Bf6xAYp4.js} +5 -5
- package/dist/{deregistration-tx-builder-DZGwB4cz.cjs → deregistration-tx-builder-CQP35yex.cjs} +6 -6
- package/dist/device-commitment-hex.vo-5wFtQvDS.js +26 -0
- package/dist/device-commitment-hex.vo-CT3RmAug.cjs +31 -0
- package/dist/device-readers-CUHYoYOH.js +145 -0
- package/dist/device-readers-CdxS2btd.cjs +168 -0
- package/dist/device-readers-D_JZeNL2.cjs +8 -0
- package/dist/device-readers-DwSNCGPP.js +4 -0
- package/dist/dist-BMi5ZjEq.cjs +43175 -0
- package/dist/dist-BtIq4XFn.cjs +535 -0
- package/dist/dist-C3SHC_Ho.cjs +1394 -0
- package/dist/dist-CykEjYEX.cjs +3814 -0
- package/dist/dist-Dcsxh3be.cjs +3452 -0
- package/dist/dist-DqJfSlTd.cjs +4413 -0
- package/dist/dist-nTZ70qj7.cjs +1306 -0
- package/dist/{earn-rewards-tx-builder-BDbTDZmD.js → earn-rewards-tx-builder-Bsga3yFb.js} +5 -5
- package/dist/{earn-rewards-tx-builder-D5sUT5v8.cjs → earn-rewards-tx-builder-GuxofYns.cjs} +6 -6
- package/dist/enc-key-circuits-B7BjgUL9.js +13 -0
- package/dist/enc-key-circuits-BLrZrBVI.cjs +24 -0
- package/dist/english-Byb9M0E_.cjs +2057 -0
- package/dist/envelopes-BGoO_v8m.js +1621 -0
- package/dist/envelopes-CH25R-DN.cjs +1722 -0
- package/dist/errors-BIftM8ZN.cjs +688 -0
- package/dist/errors-DSq5wUwt.js +466 -0
- package/dist/esm-HBSUQw3w.js +384 -0
- package/dist/esm-LZuaZjMf.cjs +389 -0
- package/dist/experimental.cjs +7349 -0
- package/dist/experimental.d.ts +86273 -0
- package/dist/experimental.js +7184 -0
- package/dist/gated-call-CDCVZIK-.cjs +5 -0
- package/dist/gated-call-D-tT7P_t.js +722 -0
- package/dist/gated-call-D_VT2quk.js +4 -0
- package/dist/gated-call-DgJm1Mi_.cjs +787 -0
- package/dist/grant-circuits-DswmW3nI.cjs +71 -0
- package/dist/grant-circuits-Jxb5y1HW.js +42 -0
- package/dist/grant-rules-By07_eDi.js +6824 -0
- package/dist/grant-rules-BzVTWXS7.cjs +7099 -0
- package/dist/grant-spend-B3Md9L0n.js +215 -0
- package/dist/grant-spend-oWmzRsjH.cjs +217 -0
- package/dist/grant-status-B2y49iIu.js +2688 -0
- package/dist/grant-status-DOr3t_u8.cjs +2820 -0
- package/dist/grants-2BZ-qEVQ.js +5 -0
- package/dist/grants-BPoLSiMt.cjs +18 -0
- package/dist/grants-BoI5uwSF.cjs +272 -0
- package/dist/grants-CtofFu-e.js +213 -0
- package/dist/{group-cardano-addresses-by-account-B533oVXR.cjs → group-cardano-addresses-by-account-Bp0g4wEY.cjs} +3 -39
- package/dist/{group-cardano-addresses-by-account-RHKoEskR.js → group-cardano-addresses-by-account-SR8MMrZf.js} +5 -35
- package/dist/{guarded-transaction-signer-Bxl6_XNd.cjs → guarded-transaction-signer-MFpPg98D.cjs} +17 -18
- package/dist/{guarded-transaction-signer-CpKLj8Kp.js → guarded-transaction-signer-P6Rp1faj.js} +8 -15
- package/dist/hex-D9ITYbwt.cjs +263 -0
- package/dist/hex-mkXcV3pN.js +191 -0
- package/dist/http-client-B3N-TMxu.cjs +167 -0
- package/dist/http-client-TRlhDZGh.js +155 -0
- package/dist/identity-BMLuufva.cjs +263 -0
- package/dist/identity-DII6f-h7.js +233 -0
- package/dist/in-memory-wallet-integration-B2xzxORj.cjs +20741 -0
- package/dist/in-memory-wallet-integration-CBRiPjLO.js +130 -0
- package/dist/in-memory-wallet-integration-CULUB5Tf.cjs +240 -0
- package/dist/{in-memory-wallet-integration-D-qn65Kx.js → in-memory-wallet-integration-ChIOirMW.js} +5 -2
- package/dist/{in-memory-wallet-integration-Croiuopx.js → in-memory-wallet-integration-CljprQQV.js} +7 -104
- package/dist/{in-memory-wallet-integration-DVh9sRXa.cjs → in-memory-wallet-integration-Cm6P8sk6.cjs} +3 -2
- package/dist/in-memory-wallet-integration-TM9bBphA.js +20738 -0
- package/dist/{in-memory-wallet-integration-CnLYeX4-.cjs → in-memory-wallet-integration-t9I00R_V.cjs} +17 -108
- package/dist/index.cjs +84 -47
- package/dist/index.d.ts +37496 -10033
- package/dist/index.js +52 -24
- package/dist/{init-CLHuAMB-.js → init-0zzs9aqU.js} +4 -4
- package/dist/{init-U8c9yHYx.cjs → init-5KcGcBb5.cjs} +1 -1
- package/dist/init-8v_n8boO.js +1177 -0
- package/dist/{init-CigestoM.js → init-B3-1ghyx.js} +2 -2
- package/dist/init-B8U3ABhS.cjs +107 -0
- package/dist/init-BJn-8_hf.js +141 -0
- package/dist/init-BPU3j8sT.cjs +6 -0
- package/dist/init-BRzH6xu-2.cjs +2797 -0
- package/dist/init-BmzfDaKL.js +1142 -0
- package/dist/{init-C-jErzp5.cjs → init-BopV9ed4.cjs} +2 -2
- package/dist/init-BpHTq2R5.js +105 -0
- package/dist/init-BpSITBfF.js +39 -0
- package/dist/{init-DX4WyB0R.cjs → init-BrdVzxei.cjs} +3 -3
- package/dist/{init-LfyMo-sS.cjs → init-BwkU0ruo.cjs} +2 -2
- package/dist/{init-CB__aLD7.cjs → init-C-G32J12.cjs} +2 -2
- package/dist/init-C00gw1zi.js +422 -0
- package/dist/{init-TkPq_Ny_.js → init-C2RgrfZe.js} +1 -1
- package/dist/{init-DcYY6zMD.js → init-C8URA2OX.js} +1 -1
- package/dist/init-CDkRynJa.js +2796 -0
- package/dist/{init-Cg9XdAru.js → init-CNM5m7M2.js} +4 -4
- package/dist/init-CR7BfztQ.cjs +18 -0
- package/dist/{init-CSHwHnfg.cjs → init-CSDpdu0Q.cjs} +2 -2
- package/dist/{init-aJHl-7AO.js → init-CX0AMQUn.js} +2 -2
- package/dist/{init-FMGDET-9.js → init-CfTbSEKy.js} +259 -60
- package/dist/{init-CR6tpw1B.js → init-Cigr_tKx.js} +47 -43
- package/dist/init-CuW7rHNA.js +3584 -0
- package/dist/{init-CFYsq82V.js → init-CyAY4Lzl.js} +1 -1
- package/dist/init-Cz0rz5fU.cjs +3585 -0
- package/dist/{init-BKhH6mVR.cjs → init-D6BxBs7e.cjs} +1 -1
- package/dist/init-D8OeObDF.cjs +1141 -0
- package/dist/init-D9g1HXYf.cjs +40 -0
- package/dist/{init-CNLGJJRx.js → init-DA7zmptx.js} +1 -1
- package/dist/{init-DkIc5nqF.cjs → init-DFMiP2ZH.cjs} +1 -1
- package/dist/{init-zSzCjoor.js → init-DFjT8YvT.js} +4 -4
- package/dist/init-DGjXwWs2.cjs +143 -0
- package/dist/init-DHrCbpkW.cjs +121 -0
- package/dist/{init-B64zCLxG.cjs → init-DUF4ar8P.cjs} +4 -4
- package/dist/init-DlqJuHhl.js +119 -0
- package/dist/{init-y2Ra0vZP.js → init-Dnsv155v.js} +3 -3
- package/dist/init-DrRdf5sZ.cjs +1176 -0
- package/dist/init-DuYENxci.js +17 -0
- package/dist/{init-D6DBUsD3.cjs → init-Dv3zKj0r.cjs} +4 -4
- package/dist/{init-BtzMZ7Pk.cjs → init-Dy-05ktr.cjs} +1 -1
- package/dist/{init-BsCBAGWf.cjs → init-EP0CUWNK.cjs} +2 -2
- package/dist/{init-BJVU54pI.cjs → init-EhzD7a8i.cjs} +1 -1
- package/dist/{init-w9GEs73W.js → init-Fw89ZmrR.js} +2 -2
- package/dist/init-GsT2AEa4.cjs +424 -0
- package/dist/{init-Rxohwpmu.js → init-NCjgwCZy.js} +2 -2
- package/dist/{init-DxUHsN53.cjs → init-NdhG_VrF.cjs} +6 -6
- package/dist/{init-DDdhguVC.js → init-SZ01tARX2.js} +2 -2
- package/dist/{init-BAJJzBza.js → init-Y3mkB4XS.js} +2 -2
- package/dist/init-c4l6r-o-.js +5 -0
- package/dist/{init-Dku4b2lG.js → init-kEfUTuG2.js} +1 -1
- package/dist/{init-C7IeJwQR.cjs → init-lzHt4Cli.cjs} +256 -59
- package/dist/{init-anYu6XB7.cjs → init-rmt7-fQE.cjs} +2 -2
- package/dist/{init-C4Bkib9u.cjs → init-zU-_9Gsp.cjs} +67 -65
- package/dist/{is-retriable-error-BU0e3hVI.js → is-retriable-error-BUiVJDwH.js} +1 -1
- package/dist/{is-retriable-error-CeeuHqDa.cjs → is-retriable-error-Dpt860if.cjs} +1 -1
- package/dist/jubjub-authoriser-D7zDXu3V.js +86 -0
- package/dist/jubjub-authoriser-Dgu6o3Sv.cjs +87 -0
- package/dist/key-source-5oUBFiC7.cjs +583 -0
- package/dist/key-source-B08HukZg.js +2550 -0
- package/dist/keyDerivation-D3k9XyHg.js +4077 -0
- package/dist/keyDerivation-u0nBA93T.cjs +274 -0
- package/dist/{lace-context-CZcNHr4M.js → lace-context-BZciB9c7.js} +4 -4
- package/dist/{lace-context-fJTDghdp.cjs → lace-context-DgR6vLli.cjs} +4 -4
- package/dist/lib--iqvW4O_.js +2354 -0
- package/dist/lib-Yk6Upl5D.cjs +2359 -0
- package/dist/{libsodium-wrappers-UH0LaOUE.js → libsodium-wrappers-BhbOA8dQ.js} +3 -1647
- package/dist/midnight-account-id.vo-0x9X-r3l.cjs +10 -0
- package/dist/midnight-account-id.vo-DjCAGcqc.js +5 -0
- package/dist/midnight-engine-DpemplKO.js +5 -0
- package/dist/midnight-engine-xU1wotne.cjs +6 -0
- package/dist/midnight-wallet-DIsAlSn6.js +18 -0
- package/dist/midnight-wallet-XTZc2li7.cjs +24 -0
- package/dist/midnight.cjs +1408 -0
- package/dist/midnight.d.ts +28934 -0
- package/dist/midnight.js +1352 -0
- package/dist/modules-cardano-B1nDUWqy.js +995 -0
- package/dist/modules-cardano-BYeYHrRm.cjs +1108 -0
- package/dist/node-relay-DWe1U0w2.cjs +49 -0
- package/dist/node-relay-h4i5IlAQ.js +48 -0
- package/dist/outputs-Bd2yZVjx.js +720 -0
- package/dist/outputs-CJoQBIA2.cjs +990 -0
- package/dist/pbkdf2-CIW-oWrm.cjs +1337 -0
- package/dist/pending-operation-B0_P78Jo.cjs +26 -0
- package/dist/pending-operation-BIS6mpjB.js +21 -0
- package/dist/providers-FjhM47BH.cjs +388 -0
- package/dist/providers-WtiSuxFu.js +365 -0
- package/dist/redacted-BmE2aXqr.js +81 -0
- package/dist/redacted-CRZJLS3w.cjs +86 -0
- package/dist/{retry-config-DC5IMaH7.cjs → retry-config-BaCfVC1H.cjs} +1 -1
- package/dist/{retry-config-BcUmMS--.js → retry-config-Dmgt28wM.js} +1 -1
- package/dist/safe-buffer-B_vMqJWU.js +43 -0
- package/dist/safe-buffer-DYOwEfHB.cjs +48 -0
- package/dist/sdk-Cb-gZnS9.js +1241 -0
- package/dist/sdk-DffwmX8b.cjs +1439 -0
- package/dist/sdk-init-Bln9rFtn.js +4138 -0
- package/dist/sdk-init-CYViTJY_.cjs +3841 -0
- package/dist/{seam-cardano-CATqBEyK.js → seam-cardano-B_etH4F4.js} +1 -1
- package/dist/{bytes.vo-TgiwogWF.js → secret-box-DUR0ACYz.js} +3 -25
- package/dist/{bytes.vo-Ck5u40RA.cjs → secret-box-DrjLZuS1.cjs} +1 -35
- package/dist/send-proof-progress-C-ljq1x5.js +30 -0
- package/dist/send-proof-progress-vmsaSfbz.cjs +47 -0
- package/dist/side-effects-BnqYz7Nl.js +768 -0
- package/dist/side-effects-CngaeXi0.cjs +804 -0
- package/dist/sign-bitcoin-transaction-with-seed-D4z62-jV.js +147 -0
- package/dist/sign-bitcoin-transaction-with-seed-DsLYXnCY.cjs +158 -0
- package/dist/signer-3fk8lZtE.cjs +7 -0
- package/dist/signer-CsL28DrK.cjs +121 -0
- package/dist/signer-DGluibtn.js +92 -0
- package/dist/signer-RqB5pu3K.js +2 -0
- package/dist/signer-factory-BA7WFJVZ.js +282 -0
- package/dist/signer-factory-Cwd6o-lG.cjs +281 -0
- package/dist/{signer-factory-9URFliA5.js → signer-factory-DObB55D4.js} +6 -3
- package/dist/signer-factory-DhZiE03y.cjs +149 -0
- package/dist/{signer-factory-BWGUmnvm.cjs → signer-factory-Ds6G2AZk.cjs} +4 -3
- package/dist/signer-factory-hzSRaIw2.js +148 -0
- package/dist/{slice-CuHUaPZx.cjs → slice-7G2xxYKJ.cjs} +3 -3
- package/dist/{slice-DZmQJNV8.cjs → slice-B4CdYoPu.cjs} +2 -2
- package/dist/slice-BPNuHKfw.js +9091 -0
- package/dist/{slice-DGcNrbPR.cjs → slice-Bg6HEr3K.cjs} +4 -4
- package/dist/{slice-DtaO72qY.cjs → slice-Bs2aMERu.cjs} +3 -3
- package/dist/{slice-HeHCv3bl.cjs → slice-C34iOOUH.cjs} +7 -7
- package/dist/{slice-Do2R2CYW.cjs → slice-C9TT5KhY.cjs} +6 -6
- package/dist/{slice-eIwcwKHI.js → slice-CK07EBCo.js} +4 -4
- package/dist/{slice-CnyWevM9.js → slice-CU80pbiu.js} +3 -3
- package/dist/{slice-CobanYgn.js → slice-CwyYrh1H.js} +2 -2
- package/dist/slice-Czfp6t84.cjs +436 -0
- package/dist/{slice-d0p6-xj5.js → slice-D-9aPKG-.js} +6 -6
- package/dist/{slice-maaskdUn.js → slice-DBpJ2QGf.js} +6 -6
- package/dist/{slice-mxLQ_FeY.cjs → slice-DTZTiJle.cjs} +352 -39
- package/dist/{slice-zJ9XVYjZ.js → slice-Da426sf9.js} +1 -1
- package/dist/{slice-D11m2EKl.cjs → slice-DayJvMRD.cjs} +1 -1
- package/dist/slice-DnBWfA-k.cjs +9109 -0
- package/dist/{slice-oqm_r1cS.cjs → slice-DnG-yvpI.cjs} +2 -2
- package/dist/{slice-BNu73oBa.js → slice-DyNs7oWp.js} +2 -2
- package/dist/{slice-CB4SnzMm.js → slice-GwiiJRoq.js} +3 -3
- package/dist/slice-oWnc7YVD.js +412 -0
- package/dist/{slice-B2PhoWAg.js → slice-qt0uBExh.js} +325 -37
- package/dist/slice-t8Gzj55G2.cjs +106 -0
- package/dist/slice-t8Q1cHm-.js +88 -0
- package/dist/src-BDzYIksE.cjs +20637 -0
- package/dist/src-BFoefPv_.js +20755 -0
- package/dist/store-B1Lq3cEf.cjs +66 -0
- package/dist/store-DuBG8qh5.js +37 -0
- package/dist/submit-Bs77dPn_.cjs +413 -0
- package/dist/submit-DOv8Z0Vf.js +336 -0
- package/dist/submit-bitcoin-tx-D6oYgH5S.js +983 -0
- package/dist/submit-bitcoin-tx-goFuRL7K.cjs +1049 -0
- package/dist/{sync-operation-utils-BYXLO80m.js → sync-operation-utils-31iFLExW.js} +2 -38
- package/dist/{sync-operation-utils-SdPbwFoD.cjs → sync-operation-utils-COIZ66-I.cjs} +1 -67
- package/dist/token-id-mapper-Bnds3xKH.cjs +18 -0
- package/dist/{token-id-mapper-DsPAL6Nh.cjs → token-id-mapper-CVyQJUKY.cjs} +2 -2
- package/dist/token-id-mapper-CnKHQ8DV.js +16 -0
- package/dist/{token-id-mapper-B2ivlLv3.js → token-id-mapper-D29Ggv8h.js} +2 -2
- package/dist/tokens-Cevp7rdU.cjs +62 -0
- package/dist/tokens-Diw4MLRM.js +44 -0
- package/dist/types-B8uiJn-X.js +12 -0
- package/dist/types-BHC12eSa.js +33 -0
- package/dist/types-CJT6XF2c.js +10 -0
- package/dist/types-CLRUYpfe.cjs +23 -0
- package/dist/types-Cc3mC8u0.cjs +50 -0
- package/dist/types-DWbVZpnF.cjs +15 -0
- package/dist/unwrap-provider-result-BZSiwabU.js +32 -0
- package/dist/unwrap-provider-result-ZqfBsTkk.cjs +39 -0
- package/dist/{util-CGzqQ8IV.cjs → util-Bu4W5lF4.cjs} +1 -1
- package/dist/{util-BaLzwa32.js → util-Cp5cZkfK.js} +1 -1
- package/dist/{utils-o8aMjfln.js → utils-BfBEUvWA.js} +2 -2
- package/dist/utils-DFwzEvbv.js +65 -0
- package/dist/{utils-5JvjbqH3.cjs → utils-DsElZgCI.cjs} +7 -1
- package/dist/utils-IXxR-Djh.cjs +112 -0
- package/dist/v8Signatures-CO_Uloy7.cjs +71 -0
- package/dist/{vote-delegation-tx-builder-BpEMSti4.cjs → vote-delegation-tx-builder-BUg1S2Ep.cjs} +6 -6
- package/dist/{vote-delegation-tx-builder-CmKv6GoG.js → vote-delegation-tx-builder-C6FiS7zI.js} +5 -5
- package/dist/watch-CUEvcP-V.js +21997 -0
- package/dist/watch-DMF2s-II.cjs +52281 -0
- package/package.json +96 -4
- package/dist/account-guards.stable-B1DSSh9D.cjs +0 -10
- package/dist/account-guards.stable-JRQ5qx2V.js +0 -5
- package/dist/codecs-B7X9pAsK.cjs +0 -1945
- package/dist/codecs-CC1Xjntz.js +0 -1882
- package/dist/init-Bv53hpLM.js +0 -19
- package/dist/init-CRbjI7p1.js +0 -3494
- package/dist/init-DAna1KCg.cjs +0 -3495
- package/dist/init-DGe47B22.cjs +0 -364
- package/dist/init-DMtyvYfC.cjs +0 -21
- package/dist/init-TkPDD750.js +0 -363
- package/dist/modules-cardano-BDvuL4Xx.js +0 -5248
- package/dist/modules-cardano-D2G3De2P.cjs +0 -5432
- package/dist/slice-CGVHXHDt.cjs +0 -125
- package/dist/slice-DhvF7L6X.js +0 -107
- /package/dist/{account-id.vo-LvCBVn5r.cjs → account-id.vo-DwqFjK5u.cjs} +0 -0
- /package/dist/{account-id.vo-MYSI7YFm.js → account-id.vo-OPz2v-JZ.js} +0 -0
- /package/dist/{actions-DdGbj7c7.cjs → actions-B2BJ4RTy.cjs} +0 -0
- /package/dist/{actions-9QSQR-GB.js → actions-iLXdgL5Y.js} +0 -0
- /package/dist/{apply-vkey-witnesses-ClZbpk5w.js → apply-vkey-witnesses-BKx3lcs0.js} +0 -0
- /package/dist/{apply-vkey-witnesses-CLzVSWxl.cjs → apply-vkey-witnesses-ZnFS0jnJ.cjs} +0 -0
- /package/dist/{asyncoption-Cw07zPH7.js → asyncoption-CruEYOBI.js} +0 -0
- /package/dist/{asyncoption-DYoGuQfP.cjs → asyncoption-i0VbqVTq.cjs} +0 -0
- /package/dist/{bignum.vo-B0rK_PQ1.js → bignum.vo-CEXOIew0.js} +0 -0
- /package/dist/{bignum.vo-DsG3kNiZ.cjs → bignum.vo-hx2kuqlA.cjs} +0 -0
- /package/dist/{bip32ed25519-1ApqeAZk.cjs → bip32ed25519-B7Yat217.cjs} +0 -0
- /package/dist/{bip32ed25519-DetAdGwD.js → bip32ed25519-FQ8qvdcq.js} +0 -0
- /package/dist/{blake2b-DOEVc57D.js → blake2b-BiQTw3GC.js} +0 -0
- /package/dist/{blake2b-B9tftbvG.cjs → blake2b-DEeVUdKR.cjs} +0 -0
- /package/dist/{blockchain-network-id.vo-BXpZhvvQ.cjs → blockchain-network-id.vo-BAKEwGjG.cjs} +0 -0
- /package/dist/{blockchain-network-id.vo-DNRkuT5B.js → blockchain-network-id.vo-CiVykuqG.js} +0 -0
- /package/dist/{blockingWithLatestFrom-C5wp_uA-.js → blockingWithLatestFrom-Cd8c8EPG.js} +0 -0
- /package/dist/{blockingWithLatestFrom-DY8OPg0w.cjs → blockingWithLatestFrom-D8kBPBMX.cjs} +0 -0
- /package/dist/{cardano-network-id-to-network-type-CrZfUcyP.js → cardano-network-id-to-network-type-BWwzeEtM.js} +0 -0
- /package/dist/{cardano-network-id-to-network-type-BDTF-HmK.cjs → cardano-network-id-to-network-type-C0ufJOyE.cjs} +0 -0
- /package/dist/{cardano-tx-id.vo-BPhV-AmZ.cjs → cardano-tx-id.vo-TLjJZHCI.cjs} +0 -0
- /package/dist/{cardano-tx-id.vo-DF9NzZXk.js → cardano-tx-id.vo-eVnKuzlm.js} +0 -0
- /package/dist/{composite-signer-factory-_46QsNBz.js → composite-signer-factory-CR8YHA1y.js} +0 -0
- /package/dist/{composite-signer-factory-BpF1mIYA.cjs → composite-signer-factory-m5cVs9h_.cjs} +0 -0
- /package/dist/{error-CNIquqT5.cjs → error-Cb3EnD0u.cjs} +0 -0
- /package/dist/{error-BCp9NkPi.js → error-DIZOY2Lw.js} +0 -0
- /package/dist/{esm-browser-C93Q-EOI.js → esm-browser-MG97cre9.js} +0 -0
- /package/dist/{esm-browser-DTc9IK3D.cjs → esm-browser-bweqfBlL.cjs} +0 -0
- /package/dist/{feature-flag-key.vo-ofrB6ZVQ.js → feature-flag-key.vo-DN_-4-sG.js} +0 -0
- /package/dist/{feature-flag-key.vo-BPz-ZAp6.cjs → feature-flag-key.vo-RlfHL3hq.cjs} +0 -0
- /package/dist/{first-state-of-status-OROkXcRv.cjs → first-state-of-status-CbT7hPa4.cjs} +0 -0
- /package/dist/{first-state-of-status-DQnMT3ya.js → first-state-of-status-unPynOuM.js} +0 -0
- /package/dist/{init-Es3wHW7D.js → init-829HRYcz.js} +0 -0
- /package/dist/{init-CKipPE_c.js → init-A-VyGSNW2.js} +0 -0
- /package/dist/{init-DFQQ9dTW.cjs → init-Atisw4x2.cjs} +0 -0
- /package/dist/{init-C5CEZ1m0.cjs → init-BFcvPHL-.cjs} +0 -0
- /package/dist/{init-IAk_CkGa.cjs → init-BgNobbNq.cjs} +0 -0
- /package/dist/{init-cqN3uX2j.js → init-atCFur0v.js} +0 -0
- /package/dist/{is-redux-persist-state-CTn3WZVh.cjs → is-redux-persist-state-BCFnSm36.cjs} +0 -0
- /package/dist/{is-redux-persist-state-Cxcd0_bM.js → is-redux-persist-state-yBfq0h_E.js} +0 -0
- /package/dist/{key-value-store-8cMzeNyG.js → key-value-store--W3SrMaw.js} +0 -0
- /package/dist/{key-value-store-DUAepXQf.cjs → key-value-store-C2Xt5Emp.cjs} +0 -0
- /package/dist/{repo-slice-WxetRhMY.cjs → repo-slice-7X4AYYVm.cjs} +0 -0
- /package/dist/{repo-slice-DwyMhCR1.js → repo-slice-RxFm0zDZ.js} +0 -0
- /package/dist/{reselect-CRDqmQY9.cjs → reselect-Bd94u0K-.cjs} +0 -0
- /package/dist/{reselect-C06X06oX.js → reselect-CGoLzEPv.js} +0 -0
- /package/dist/{serializable-B8GahgE1.js → serializable-BHdKIgk3.js} +0 -0
- /package/dist/{serializable-CRdnFaLZ.cjs → serializable-BxHkoPdk.cjs} +0 -0
- /package/dist/{slice-D11FHQuQ.cjs → slice-BiRsDKOK.cjs} +0 -0
- /package/dist/{slice-Be7hj4Iy.js → slice-Bk0Sv05J.js} +0 -0
- /package/dist/{slice-FioKeHtA.cjs → slice-Dqw1ecum.cjs} +0 -0
- /package/dist/{slice-B87b52iM.js → slice-obCSLm1x.js} +0 -0
- /package/dist/{src-vq1wS9sZ.js → src-BlxEp6Mm.js} +0 -0
- /package/dist/{src-BTPIvlDI.cjs → src-Cqp0B2M_.cjs} +0 -0
- /package/dist/{time.vo-CQ8pSXz2.cjs → time.vo-D3wWRw9L.cjs} +0 -0
- /package/dist/{time.vo-DkYYGYp6.js → time.vo-tNheinXm.js} +0 -0
- /package/dist/{toEmpty-CgAl3097.js → toEmpty-8Zax1MPd.js} +0 -0
- /package/dist/{toEmpty-DAMmNB5r.cjs → toEmpty-CYAbupM4.cjs} +0 -0
- /package/dist/{token-id.vo-ClsroxHO.js → token-id.vo-Bvwhr3ZE.js} +0 -0
- /package/dist/{token-id.vo-BxG9TG0O.cjs → token-id.vo-DXv5uS9n.cjs} +0 -0
- /package/dist/{util-DxzlYNS5.js → util-C8a4fA9p.js} +0 -0
- /package/dist/{util-CmdAhheh.cjs → util-CzeB3hfa.cjs} +0 -0
- /package/dist/{util-selector-CcK-GAdE.js → util-selector-BSTsxgne.js} +0 -0
- /package/dist/{util-selector-BcAncU4L.cjs → util-selector-BWPH68_l.cjs} +0 -0
- /package/dist/{while-active-BpppWuCs.js → while-active-B0lWy_6l.js} +0 -0
- /package/dist/{while-active-Dhc2LwOm.cjs → while-active-Dsowp0Fi.cjs} +0 -0
|
@@ -0,0 +1,3903 @@
|
|
|
1
|
+
import { t as __commonJSMin } from "./rolldown-runtime-OvD0k9op.js";
|
|
2
|
+
//#region ../../node_modules/@noble/hashes/esm/_u64.js
|
|
3
|
+
/**
|
|
4
|
+
* Internal helpers for u64. BigUint64Array is too slow as per 2025, so we implement it using Uint32Array.
|
|
5
|
+
* @todo re-check https://issues.chromium.org/issues/42212588
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
9
|
+
const _32n = /* @__PURE__ */ BigInt(32);
|
|
10
|
+
function fromBig(n, le = false) {
|
|
11
|
+
if (le) return {
|
|
12
|
+
h: Number(n & U32_MASK64),
|
|
13
|
+
l: Number(n >> _32n & U32_MASK64)
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
h: Number(n >> _32n & U32_MASK64) | 0,
|
|
17
|
+
l: Number(n & U32_MASK64) | 0
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function split(lst, le = false) {
|
|
21
|
+
const len = lst.length;
|
|
22
|
+
let Ah = new Uint32Array(len);
|
|
23
|
+
let Al = new Uint32Array(len);
|
|
24
|
+
for (let i = 0; i < len; i++) {
|
|
25
|
+
const { h, l } = fromBig(lst[i], le);
|
|
26
|
+
[Ah[i], Al[i]] = [h, l];
|
|
27
|
+
}
|
|
28
|
+
return [Ah, Al];
|
|
29
|
+
}
|
|
30
|
+
const shrSH = (h, _l, s) => h >>> s;
|
|
31
|
+
const shrSL = (h, l, s) => h << 32 - s | l >>> s;
|
|
32
|
+
const rotrSH = (h, l, s) => h >>> s | l << 32 - s;
|
|
33
|
+
const rotrSL = (h, l, s) => h << 32 - s | l >>> s;
|
|
34
|
+
const rotrBH = (h, l, s) => h << 64 - s | l >>> s - 32;
|
|
35
|
+
const rotrBL = (h, l, s) => h >>> s - 32 | l << 64 - s;
|
|
36
|
+
const rotr32H = (_h, l) => l;
|
|
37
|
+
const rotr32L = (h, _l) => h;
|
|
38
|
+
function add(Ah, Al, Bh, Bl) {
|
|
39
|
+
const l = (Al >>> 0) + (Bl >>> 0);
|
|
40
|
+
return {
|
|
41
|
+
h: Ah + Bh + (l / 2 ** 32 | 0) | 0,
|
|
42
|
+
l: l | 0
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
|
|
46
|
+
const add3H = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0;
|
|
47
|
+
const add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
|
|
48
|
+
const add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0;
|
|
49
|
+
const add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
|
|
50
|
+
const add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region ../../node_modules/@noble/hashes/esm/crypto.js
|
|
53
|
+
const crypto = typeof globalThis === "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region ../../node_modules/@noble/hashes/esm/utils.js
|
|
56
|
+
/**
|
|
57
|
+
* Utilities for hex, bytes, CSPRNG.
|
|
58
|
+
* @module
|
|
59
|
+
*/
|
|
60
|
+
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
61
|
+
/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */
|
|
62
|
+
function isBytes(a) {
|
|
63
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
64
|
+
}
|
|
65
|
+
/** Asserts something is positive integer. */
|
|
66
|
+
function anumber(n) {
|
|
67
|
+
if (!Number.isSafeInteger(n) || n < 0) throw new Error("positive integer expected, got " + n);
|
|
68
|
+
}
|
|
69
|
+
/** Asserts something is Uint8Array. */
|
|
70
|
+
function abytes(b, ...lengths) {
|
|
71
|
+
if (!isBytes(b)) throw new Error("Uint8Array expected");
|
|
72
|
+
if (lengths.length > 0 && !lengths.includes(b.length)) throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length);
|
|
73
|
+
}
|
|
74
|
+
/** Asserts something is hash */
|
|
75
|
+
function ahash(h) {
|
|
76
|
+
if (typeof h !== "function" || typeof h.create !== "function") throw new Error("Hash should be wrapped by utils.createHasher");
|
|
77
|
+
anumber(h.outputLen);
|
|
78
|
+
anumber(h.blockLen);
|
|
79
|
+
}
|
|
80
|
+
/** Asserts a hash instance has not been destroyed / finished */
|
|
81
|
+
function aexists(instance, checkFinished = true) {
|
|
82
|
+
if (instance.destroyed) throw new Error("Hash instance has been destroyed");
|
|
83
|
+
if (checkFinished && instance.finished) throw new Error("Hash#digest() has already been called");
|
|
84
|
+
}
|
|
85
|
+
/** Asserts output is properly-sized byte array */
|
|
86
|
+
function aoutput(out, instance) {
|
|
87
|
+
abytes(out);
|
|
88
|
+
const min = instance.outputLen;
|
|
89
|
+
if (out.length < min) throw new Error("digestInto() expects output buffer of length at least " + min);
|
|
90
|
+
}
|
|
91
|
+
/** Cast u8 / u16 / u32 to u8. */
|
|
92
|
+
function u8(arr) {
|
|
93
|
+
return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
94
|
+
}
|
|
95
|
+
/** Cast u8 / u16 / u32 to u32. */
|
|
96
|
+
function u32(arr) {
|
|
97
|
+
return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
98
|
+
}
|
|
99
|
+
/** Zeroize a byte array. Warning: JS provides no guarantees. */
|
|
100
|
+
function clean(...arrays) {
|
|
101
|
+
for (let i = 0; i < arrays.length; i++) arrays[i].fill(0);
|
|
102
|
+
}
|
|
103
|
+
/** Create DataView of an array for easy byte-level manipulation. */
|
|
104
|
+
function createView(arr) {
|
|
105
|
+
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
106
|
+
}
|
|
107
|
+
/** The rotate right (circular right shift) operation for uint32 */
|
|
108
|
+
function rotr(word, shift) {
|
|
109
|
+
return word << 32 - shift | word >>> shift;
|
|
110
|
+
}
|
|
111
|
+
/** Is current platform little-endian? Most are. Big-Endian platform: IBM */
|
|
112
|
+
const isLE = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
113
|
+
/** The byte swap operation for uint32 */
|
|
114
|
+
function byteSwap(word) {
|
|
115
|
+
return word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
|
|
116
|
+
}
|
|
117
|
+
/** Conditionally byte swap if on a big-endian platform */
|
|
118
|
+
const swap8IfBE = isLE ? (n) => n : (n) => byteSwap(n);
|
|
119
|
+
/** In place byte swap for Uint32Array */
|
|
120
|
+
function byteSwap32(arr) {
|
|
121
|
+
for (let i = 0; i < arr.length; i++) arr[i] = byteSwap(arr[i]);
|
|
122
|
+
return arr;
|
|
123
|
+
}
|
|
124
|
+
const swap32IfBE = isLE ? (u) => u : byteSwap32;
|
|
125
|
+
const hasHexBuiltin = typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function";
|
|
126
|
+
const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
|
|
127
|
+
/**
|
|
128
|
+
* Convert byte array to hex string. Uses built-in function, when available.
|
|
129
|
+
* @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'
|
|
130
|
+
*/
|
|
131
|
+
function bytesToHex(bytes) {
|
|
132
|
+
abytes(bytes);
|
|
133
|
+
if (hasHexBuiltin) return bytes.toHex();
|
|
134
|
+
let hex = "";
|
|
135
|
+
for (let i = 0; i < bytes.length; i++) hex += hexes[bytes[i]];
|
|
136
|
+
return hex;
|
|
137
|
+
}
|
|
138
|
+
const asciis = {
|
|
139
|
+
_0: 48,
|
|
140
|
+
_9: 57,
|
|
141
|
+
A: 65,
|
|
142
|
+
F: 70,
|
|
143
|
+
a: 97,
|
|
144
|
+
f: 102
|
|
145
|
+
};
|
|
146
|
+
function asciiToBase16(ch) {
|
|
147
|
+
if (ch >= asciis._0 && ch <= asciis._9) return ch - asciis._0;
|
|
148
|
+
if (ch >= asciis.A && ch <= asciis.F) return ch - (asciis.A - 10);
|
|
149
|
+
if (ch >= asciis.a && ch <= asciis.f) return ch - (asciis.a - 10);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Convert hex string to byte array. Uses built-in function, when available.
|
|
153
|
+
* @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])
|
|
154
|
+
*/
|
|
155
|
+
function hexToBytes(hex) {
|
|
156
|
+
if (typeof hex !== "string") throw new Error("hex string expected, got " + typeof hex);
|
|
157
|
+
if (hasHexBuiltin) return Uint8Array.fromHex(hex);
|
|
158
|
+
const hl = hex.length;
|
|
159
|
+
const al = hl / 2;
|
|
160
|
+
if (hl % 2) throw new Error("hex string expected, got unpadded hex of length " + hl);
|
|
161
|
+
const array = new Uint8Array(al);
|
|
162
|
+
for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
|
|
163
|
+
const n1 = asciiToBase16(hex.charCodeAt(hi));
|
|
164
|
+
const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
|
|
165
|
+
if (n1 === void 0 || n2 === void 0) {
|
|
166
|
+
const char = hex[hi] + hex[hi + 1];
|
|
167
|
+
throw new Error("hex string expected, got non-hex character \"" + char + "\" at index " + hi);
|
|
168
|
+
}
|
|
169
|
+
array[ai] = n1 * 16 + n2;
|
|
170
|
+
}
|
|
171
|
+
return array;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* There is no setImmediate in browser and setTimeout is slow.
|
|
175
|
+
* Call of async fn will return Promise, which will be fullfiled only on
|
|
176
|
+
* next scheduler queue processing step and this is exactly what we need.
|
|
177
|
+
*/
|
|
178
|
+
const nextTick = async () => {};
|
|
179
|
+
/**
|
|
180
|
+
* Converts string to bytes using UTF8 encoding.
|
|
181
|
+
* @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99])
|
|
182
|
+
*/
|
|
183
|
+
function utf8ToBytes(str) {
|
|
184
|
+
if (typeof str !== "string") throw new Error("string expected");
|
|
185
|
+
return new Uint8Array(new TextEncoder().encode(str));
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Normalizes (non-hex) string or Uint8Array to Uint8Array.
|
|
189
|
+
* Warning: when Uint8Array is passed, it would NOT get copied.
|
|
190
|
+
* Keep in mind for future mutable operations.
|
|
191
|
+
*/
|
|
192
|
+
function toBytes(data) {
|
|
193
|
+
if (typeof data === "string") data = utf8ToBytes(data);
|
|
194
|
+
abytes(data);
|
|
195
|
+
return data;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Helper for KDFs: consumes uint8array or string.
|
|
199
|
+
* When string is passed, does utf8 decoding, using TextDecoder.
|
|
200
|
+
*/
|
|
201
|
+
function kdfInputToBytes(data) {
|
|
202
|
+
if (typeof data === "string") data = utf8ToBytes(data);
|
|
203
|
+
abytes(data);
|
|
204
|
+
return data;
|
|
205
|
+
}
|
|
206
|
+
/** Copies several Uint8Arrays into one. */
|
|
207
|
+
function concatBytes(...arrays) {
|
|
208
|
+
let sum = 0;
|
|
209
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
210
|
+
const a = arrays[i];
|
|
211
|
+
abytes(a);
|
|
212
|
+
sum += a.length;
|
|
213
|
+
}
|
|
214
|
+
const res = new Uint8Array(sum);
|
|
215
|
+
for (let i = 0, pad = 0; i < arrays.length; i++) {
|
|
216
|
+
const a = arrays[i];
|
|
217
|
+
res.set(a, pad);
|
|
218
|
+
pad += a.length;
|
|
219
|
+
}
|
|
220
|
+
return res;
|
|
221
|
+
}
|
|
222
|
+
function checkOpts(defaults, opts) {
|
|
223
|
+
if (opts !== void 0 && {}.toString.call(opts) !== "[object Object]") throw new Error("options should be object or undefined");
|
|
224
|
+
return Object.assign(defaults, opts);
|
|
225
|
+
}
|
|
226
|
+
/** For runtime check if class implements interface */
|
|
227
|
+
var Hash = class {};
|
|
228
|
+
/** Wraps hash function, creating an interface on top of it */
|
|
229
|
+
function createHasher(hashCons) {
|
|
230
|
+
const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
|
|
231
|
+
const tmp = hashCons();
|
|
232
|
+
hashC.outputLen = tmp.outputLen;
|
|
233
|
+
hashC.blockLen = tmp.blockLen;
|
|
234
|
+
hashC.create = () => hashCons();
|
|
235
|
+
return hashC;
|
|
236
|
+
}
|
|
237
|
+
function createOptHasher(hashCons) {
|
|
238
|
+
const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
|
|
239
|
+
const tmp = hashCons({});
|
|
240
|
+
hashC.outputLen = tmp.outputLen;
|
|
241
|
+
hashC.blockLen = tmp.blockLen;
|
|
242
|
+
hashC.create = (opts) => hashCons(opts);
|
|
243
|
+
return hashC;
|
|
244
|
+
}
|
|
245
|
+
/** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */
|
|
246
|
+
function randomBytes(bytesLength = 32) {
|
|
247
|
+
if (crypto && typeof crypto.getRandomValues === "function") return crypto.getRandomValues(new Uint8Array(bytesLength));
|
|
248
|
+
if (crypto && typeof crypto.randomBytes === "function") return Uint8Array.from(crypto.randomBytes(bytesLength));
|
|
249
|
+
throw new Error("crypto.getRandomValues must be defined");
|
|
250
|
+
}
|
|
251
|
+
//#endregion
|
|
252
|
+
//#region ../../node_modules/@noble/hashes/esm/_blake.js
|
|
253
|
+
/**
|
|
254
|
+
* Internal blake variable.
|
|
255
|
+
* For BLAKE2b, the two extra permutations for rounds 10 and 11 are SIGMA[10..11] = SIGMA[0..1].
|
|
256
|
+
*/
|
|
257
|
+
const BSIGMA = /* @__PURE__ */ Uint8Array.from([
|
|
258
|
+
0,
|
|
259
|
+
1,
|
|
260
|
+
2,
|
|
261
|
+
3,
|
|
262
|
+
4,
|
|
263
|
+
5,
|
|
264
|
+
6,
|
|
265
|
+
7,
|
|
266
|
+
8,
|
|
267
|
+
9,
|
|
268
|
+
10,
|
|
269
|
+
11,
|
|
270
|
+
12,
|
|
271
|
+
13,
|
|
272
|
+
14,
|
|
273
|
+
15,
|
|
274
|
+
14,
|
|
275
|
+
10,
|
|
276
|
+
4,
|
|
277
|
+
8,
|
|
278
|
+
9,
|
|
279
|
+
15,
|
|
280
|
+
13,
|
|
281
|
+
6,
|
|
282
|
+
1,
|
|
283
|
+
12,
|
|
284
|
+
0,
|
|
285
|
+
2,
|
|
286
|
+
11,
|
|
287
|
+
7,
|
|
288
|
+
5,
|
|
289
|
+
3,
|
|
290
|
+
11,
|
|
291
|
+
8,
|
|
292
|
+
12,
|
|
293
|
+
0,
|
|
294
|
+
5,
|
|
295
|
+
2,
|
|
296
|
+
15,
|
|
297
|
+
13,
|
|
298
|
+
10,
|
|
299
|
+
14,
|
|
300
|
+
3,
|
|
301
|
+
6,
|
|
302
|
+
7,
|
|
303
|
+
1,
|
|
304
|
+
9,
|
|
305
|
+
4,
|
|
306
|
+
7,
|
|
307
|
+
9,
|
|
308
|
+
3,
|
|
309
|
+
1,
|
|
310
|
+
13,
|
|
311
|
+
12,
|
|
312
|
+
11,
|
|
313
|
+
14,
|
|
314
|
+
2,
|
|
315
|
+
6,
|
|
316
|
+
5,
|
|
317
|
+
10,
|
|
318
|
+
4,
|
|
319
|
+
0,
|
|
320
|
+
15,
|
|
321
|
+
8,
|
|
322
|
+
9,
|
|
323
|
+
0,
|
|
324
|
+
5,
|
|
325
|
+
7,
|
|
326
|
+
2,
|
|
327
|
+
4,
|
|
328
|
+
10,
|
|
329
|
+
15,
|
|
330
|
+
14,
|
|
331
|
+
1,
|
|
332
|
+
11,
|
|
333
|
+
12,
|
|
334
|
+
6,
|
|
335
|
+
8,
|
|
336
|
+
3,
|
|
337
|
+
13,
|
|
338
|
+
2,
|
|
339
|
+
12,
|
|
340
|
+
6,
|
|
341
|
+
10,
|
|
342
|
+
0,
|
|
343
|
+
11,
|
|
344
|
+
8,
|
|
345
|
+
3,
|
|
346
|
+
4,
|
|
347
|
+
13,
|
|
348
|
+
7,
|
|
349
|
+
5,
|
|
350
|
+
15,
|
|
351
|
+
14,
|
|
352
|
+
1,
|
|
353
|
+
9,
|
|
354
|
+
12,
|
|
355
|
+
5,
|
|
356
|
+
1,
|
|
357
|
+
15,
|
|
358
|
+
14,
|
|
359
|
+
13,
|
|
360
|
+
4,
|
|
361
|
+
10,
|
|
362
|
+
0,
|
|
363
|
+
7,
|
|
364
|
+
6,
|
|
365
|
+
3,
|
|
366
|
+
9,
|
|
367
|
+
2,
|
|
368
|
+
8,
|
|
369
|
+
11,
|
|
370
|
+
13,
|
|
371
|
+
11,
|
|
372
|
+
7,
|
|
373
|
+
14,
|
|
374
|
+
12,
|
|
375
|
+
1,
|
|
376
|
+
3,
|
|
377
|
+
9,
|
|
378
|
+
5,
|
|
379
|
+
0,
|
|
380
|
+
15,
|
|
381
|
+
4,
|
|
382
|
+
8,
|
|
383
|
+
6,
|
|
384
|
+
2,
|
|
385
|
+
10,
|
|
386
|
+
6,
|
|
387
|
+
15,
|
|
388
|
+
14,
|
|
389
|
+
9,
|
|
390
|
+
11,
|
|
391
|
+
3,
|
|
392
|
+
0,
|
|
393
|
+
8,
|
|
394
|
+
12,
|
|
395
|
+
2,
|
|
396
|
+
13,
|
|
397
|
+
7,
|
|
398
|
+
1,
|
|
399
|
+
4,
|
|
400
|
+
10,
|
|
401
|
+
5,
|
|
402
|
+
10,
|
|
403
|
+
2,
|
|
404
|
+
8,
|
|
405
|
+
4,
|
|
406
|
+
7,
|
|
407
|
+
6,
|
|
408
|
+
1,
|
|
409
|
+
5,
|
|
410
|
+
15,
|
|
411
|
+
11,
|
|
412
|
+
9,
|
|
413
|
+
14,
|
|
414
|
+
3,
|
|
415
|
+
12,
|
|
416
|
+
13,
|
|
417
|
+
0,
|
|
418
|
+
0,
|
|
419
|
+
1,
|
|
420
|
+
2,
|
|
421
|
+
3,
|
|
422
|
+
4,
|
|
423
|
+
5,
|
|
424
|
+
6,
|
|
425
|
+
7,
|
|
426
|
+
8,
|
|
427
|
+
9,
|
|
428
|
+
10,
|
|
429
|
+
11,
|
|
430
|
+
12,
|
|
431
|
+
13,
|
|
432
|
+
14,
|
|
433
|
+
15,
|
|
434
|
+
14,
|
|
435
|
+
10,
|
|
436
|
+
4,
|
|
437
|
+
8,
|
|
438
|
+
9,
|
|
439
|
+
15,
|
|
440
|
+
13,
|
|
441
|
+
6,
|
|
442
|
+
1,
|
|
443
|
+
12,
|
|
444
|
+
0,
|
|
445
|
+
2,
|
|
446
|
+
11,
|
|
447
|
+
7,
|
|
448
|
+
5,
|
|
449
|
+
3,
|
|
450
|
+
11,
|
|
451
|
+
8,
|
|
452
|
+
12,
|
|
453
|
+
0,
|
|
454
|
+
5,
|
|
455
|
+
2,
|
|
456
|
+
15,
|
|
457
|
+
13,
|
|
458
|
+
10,
|
|
459
|
+
14,
|
|
460
|
+
3,
|
|
461
|
+
6,
|
|
462
|
+
7,
|
|
463
|
+
1,
|
|
464
|
+
9,
|
|
465
|
+
4,
|
|
466
|
+
7,
|
|
467
|
+
9,
|
|
468
|
+
3,
|
|
469
|
+
1,
|
|
470
|
+
13,
|
|
471
|
+
12,
|
|
472
|
+
11,
|
|
473
|
+
14,
|
|
474
|
+
2,
|
|
475
|
+
6,
|
|
476
|
+
5,
|
|
477
|
+
10,
|
|
478
|
+
4,
|
|
479
|
+
0,
|
|
480
|
+
15,
|
|
481
|
+
8,
|
|
482
|
+
9,
|
|
483
|
+
0,
|
|
484
|
+
5,
|
|
485
|
+
7,
|
|
486
|
+
2,
|
|
487
|
+
4,
|
|
488
|
+
10,
|
|
489
|
+
15,
|
|
490
|
+
14,
|
|
491
|
+
1,
|
|
492
|
+
11,
|
|
493
|
+
12,
|
|
494
|
+
6,
|
|
495
|
+
8,
|
|
496
|
+
3,
|
|
497
|
+
13,
|
|
498
|
+
2,
|
|
499
|
+
12,
|
|
500
|
+
6,
|
|
501
|
+
10,
|
|
502
|
+
0,
|
|
503
|
+
11,
|
|
504
|
+
8,
|
|
505
|
+
3,
|
|
506
|
+
4,
|
|
507
|
+
13,
|
|
508
|
+
7,
|
|
509
|
+
5,
|
|
510
|
+
15,
|
|
511
|
+
14,
|
|
512
|
+
1,
|
|
513
|
+
9
|
|
514
|
+
]);
|
|
515
|
+
//#endregion
|
|
516
|
+
//#region ../../node_modules/@noble/hashes/esm/_md.js
|
|
517
|
+
/**
|
|
518
|
+
* Internal Merkle-Damgard hash utils.
|
|
519
|
+
* @module
|
|
520
|
+
*/
|
|
521
|
+
/** Polyfill for Safari 14. https://caniuse.com/mdn-javascript_builtins_dataview_setbiguint64 */
|
|
522
|
+
function setBigUint64(view, byteOffset, value, isLE) {
|
|
523
|
+
if (typeof view.setBigUint64 === "function") return view.setBigUint64(byteOffset, value, isLE);
|
|
524
|
+
const _32n = BigInt(32);
|
|
525
|
+
const _u32_max = BigInt(4294967295);
|
|
526
|
+
const wh = Number(value >> _32n & _u32_max);
|
|
527
|
+
const wl = Number(value & _u32_max);
|
|
528
|
+
const h = isLE ? 4 : 0;
|
|
529
|
+
const l = isLE ? 0 : 4;
|
|
530
|
+
view.setUint32(byteOffset + h, wh, isLE);
|
|
531
|
+
view.setUint32(byteOffset + l, wl, isLE);
|
|
532
|
+
}
|
|
533
|
+
/** Choice: a ? b : c */
|
|
534
|
+
function Chi(a, b, c) {
|
|
535
|
+
return a & b ^ ~a & c;
|
|
536
|
+
}
|
|
537
|
+
/** Majority function, true if any two inputs is true. */
|
|
538
|
+
function Maj(a, b, c) {
|
|
539
|
+
return a & b ^ a & c ^ b & c;
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Merkle-Damgard hash construction base class.
|
|
543
|
+
* Could be used to create MD5, RIPEMD, SHA1, SHA2.
|
|
544
|
+
*/
|
|
545
|
+
var HashMD = class extends Hash {
|
|
546
|
+
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
547
|
+
super();
|
|
548
|
+
this.finished = false;
|
|
549
|
+
this.length = 0;
|
|
550
|
+
this.pos = 0;
|
|
551
|
+
this.destroyed = false;
|
|
552
|
+
this.blockLen = blockLen;
|
|
553
|
+
this.outputLen = outputLen;
|
|
554
|
+
this.padOffset = padOffset;
|
|
555
|
+
this.isLE = isLE;
|
|
556
|
+
this.buffer = new Uint8Array(blockLen);
|
|
557
|
+
this.view = createView(this.buffer);
|
|
558
|
+
}
|
|
559
|
+
update(data) {
|
|
560
|
+
aexists(this);
|
|
561
|
+
data = toBytes(data);
|
|
562
|
+
abytes(data);
|
|
563
|
+
const { view, buffer, blockLen } = this;
|
|
564
|
+
const len = data.length;
|
|
565
|
+
for (let pos = 0; pos < len;) {
|
|
566
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
567
|
+
if (take === blockLen) {
|
|
568
|
+
const dataView = createView(data);
|
|
569
|
+
for (; blockLen <= len - pos; pos += blockLen) this.process(dataView, pos);
|
|
570
|
+
continue;
|
|
571
|
+
}
|
|
572
|
+
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
573
|
+
this.pos += take;
|
|
574
|
+
pos += take;
|
|
575
|
+
if (this.pos === blockLen) {
|
|
576
|
+
this.process(view, 0);
|
|
577
|
+
this.pos = 0;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
this.length += data.length;
|
|
581
|
+
this.roundClean();
|
|
582
|
+
return this;
|
|
583
|
+
}
|
|
584
|
+
digestInto(out) {
|
|
585
|
+
aexists(this);
|
|
586
|
+
aoutput(out, this);
|
|
587
|
+
this.finished = true;
|
|
588
|
+
const { buffer, view, blockLen, isLE } = this;
|
|
589
|
+
let { pos } = this;
|
|
590
|
+
buffer[pos++] = 128;
|
|
591
|
+
clean(this.buffer.subarray(pos));
|
|
592
|
+
if (this.padOffset > blockLen - pos) {
|
|
593
|
+
this.process(view, 0);
|
|
594
|
+
pos = 0;
|
|
595
|
+
}
|
|
596
|
+
for (let i = pos; i < blockLen; i++) buffer[i] = 0;
|
|
597
|
+
setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
|
|
598
|
+
this.process(view, 0);
|
|
599
|
+
const oview = createView(out);
|
|
600
|
+
const len = this.outputLen;
|
|
601
|
+
if (len % 4) throw new Error("_sha2: outputLen should be aligned to 32bit");
|
|
602
|
+
const outLen = len / 4;
|
|
603
|
+
const state = this.get();
|
|
604
|
+
if (outLen > state.length) throw new Error("_sha2: outputLen bigger than state");
|
|
605
|
+
for (let i = 0; i < outLen; i++) oview.setUint32(4 * i, state[i], isLE);
|
|
606
|
+
}
|
|
607
|
+
digest() {
|
|
608
|
+
const { buffer, outputLen } = this;
|
|
609
|
+
this.digestInto(buffer);
|
|
610
|
+
const res = buffer.slice(0, outputLen);
|
|
611
|
+
this.destroy();
|
|
612
|
+
return res;
|
|
613
|
+
}
|
|
614
|
+
_cloneInto(to) {
|
|
615
|
+
to || (to = new this.constructor());
|
|
616
|
+
to.set(...this.get());
|
|
617
|
+
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
618
|
+
to.destroyed = destroyed;
|
|
619
|
+
to.finished = finished;
|
|
620
|
+
to.length = length;
|
|
621
|
+
to.pos = pos;
|
|
622
|
+
if (length % blockLen) to.buffer.set(buffer);
|
|
623
|
+
return to;
|
|
624
|
+
}
|
|
625
|
+
clone() {
|
|
626
|
+
return this._cloneInto();
|
|
627
|
+
}
|
|
628
|
+
};
|
|
629
|
+
/**
|
|
630
|
+
* Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53.
|
|
631
|
+
* Check out `test/misc/sha2-gen-iv.js` for recomputation guide.
|
|
632
|
+
*/
|
|
633
|
+
/** Initial SHA256 state. Bits 0..32 of frac part of sqrt of primes 2..19 */
|
|
634
|
+
const SHA256_IV = /* @__PURE__ */ Uint32Array.from([
|
|
635
|
+
1779033703,
|
|
636
|
+
3144134277,
|
|
637
|
+
1013904242,
|
|
638
|
+
2773480762,
|
|
639
|
+
1359893119,
|
|
640
|
+
2600822924,
|
|
641
|
+
528734635,
|
|
642
|
+
1541459225
|
|
643
|
+
]);
|
|
644
|
+
/** Initial SHA512 state. Bits 0..64 of frac part of sqrt of primes 2..19 */
|
|
645
|
+
const SHA512_IV = /* @__PURE__ */ Uint32Array.from([
|
|
646
|
+
1779033703,
|
|
647
|
+
4089235720,
|
|
648
|
+
3144134277,
|
|
649
|
+
2227873595,
|
|
650
|
+
1013904242,
|
|
651
|
+
4271175723,
|
|
652
|
+
2773480762,
|
|
653
|
+
1595750129,
|
|
654
|
+
1359893119,
|
|
655
|
+
2917565137,
|
|
656
|
+
2600822924,
|
|
657
|
+
725511199,
|
|
658
|
+
528734635,
|
|
659
|
+
4215389547,
|
|
660
|
+
1541459225,
|
|
661
|
+
327033209
|
|
662
|
+
]);
|
|
663
|
+
//#endregion
|
|
664
|
+
//#region ../../node_modules/@noble/hashes/esm/blake2.js
|
|
665
|
+
/**
|
|
666
|
+
* blake2b (64-bit) & blake2s (8 to 32-bit) hash functions.
|
|
667
|
+
* b could have been faster, but there is no fast u64 in js, so s is 1.5x faster.
|
|
668
|
+
* @module
|
|
669
|
+
*/
|
|
670
|
+
const B2B_IV = /* @__PURE__ */ Uint32Array.from([
|
|
671
|
+
4089235720,
|
|
672
|
+
1779033703,
|
|
673
|
+
2227873595,
|
|
674
|
+
3144134277,
|
|
675
|
+
4271175723,
|
|
676
|
+
1013904242,
|
|
677
|
+
1595750129,
|
|
678
|
+
2773480762,
|
|
679
|
+
2917565137,
|
|
680
|
+
1359893119,
|
|
681
|
+
725511199,
|
|
682
|
+
2600822924,
|
|
683
|
+
4215389547,
|
|
684
|
+
528734635,
|
|
685
|
+
327033209,
|
|
686
|
+
1541459225
|
|
687
|
+
]);
|
|
688
|
+
const BBUF = /* @__PURE__ */ new Uint32Array(32);
|
|
689
|
+
function G1b(a, b, c, d, msg, x) {
|
|
690
|
+
const Xl = msg[x], Xh = msg[x + 1];
|
|
691
|
+
let Al = BBUF[2 * a], Ah = BBUF[2 * a + 1];
|
|
692
|
+
let Bl = BBUF[2 * b], Bh = BBUF[2 * b + 1];
|
|
693
|
+
let Cl = BBUF[2 * c], Ch = BBUF[2 * c + 1];
|
|
694
|
+
let Dl = BBUF[2 * d], Dh = BBUF[2 * d + 1];
|
|
695
|
+
let ll = add3L(Al, Bl, Xl);
|
|
696
|
+
Ah = add3H(ll, Ah, Bh, Xh);
|
|
697
|
+
Al = ll | 0;
|
|
698
|
+
({Dh, Dl} = {
|
|
699
|
+
Dh: Dh ^ Ah,
|
|
700
|
+
Dl: Dl ^ Al
|
|
701
|
+
});
|
|
702
|
+
({Dh, Dl} = {
|
|
703
|
+
Dh: rotr32H(Dh, Dl),
|
|
704
|
+
Dl: rotr32L(Dh, Dl)
|
|
705
|
+
});
|
|
706
|
+
({h: Ch, l: Cl} = add(Ch, Cl, Dh, Dl));
|
|
707
|
+
({Bh, Bl} = {
|
|
708
|
+
Bh: Bh ^ Ch,
|
|
709
|
+
Bl: Bl ^ Cl
|
|
710
|
+
});
|
|
711
|
+
({Bh, Bl} = {
|
|
712
|
+
Bh: rotrSH(Bh, Bl, 24),
|
|
713
|
+
Bl: rotrSL(Bh, Bl, 24)
|
|
714
|
+
});
|
|
715
|
+
BBUF[2 * a] = Al, BBUF[2 * a + 1] = Ah;
|
|
716
|
+
BBUF[2 * b] = Bl, BBUF[2 * b + 1] = Bh;
|
|
717
|
+
BBUF[2 * c] = Cl, BBUF[2 * c + 1] = Ch;
|
|
718
|
+
BBUF[2 * d] = Dl, BBUF[2 * d + 1] = Dh;
|
|
719
|
+
}
|
|
720
|
+
function G2b(a, b, c, d, msg, x) {
|
|
721
|
+
const Xl = msg[x], Xh = msg[x + 1];
|
|
722
|
+
let Al = BBUF[2 * a], Ah = BBUF[2 * a + 1];
|
|
723
|
+
let Bl = BBUF[2 * b], Bh = BBUF[2 * b + 1];
|
|
724
|
+
let Cl = BBUF[2 * c], Ch = BBUF[2 * c + 1];
|
|
725
|
+
let Dl = BBUF[2 * d], Dh = BBUF[2 * d + 1];
|
|
726
|
+
let ll = add3L(Al, Bl, Xl);
|
|
727
|
+
Ah = add3H(ll, Ah, Bh, Xh);
|
|
728
|
+
Al = ll | 0;
|
|
729
|
+
({Dh, Dl} = {
|
|
730
|
+
Dh: Dh ^ Ah,
|
|
731
|
+
Dl: Dl ^ Al
|
|
732
|
+
});
|
|
733
|
+
({Dh, Dl} = {
|
|
734
|
+
Dh: rotrSH(Dh, Dl, 16),
|
|
735
|
+
Dl: rotrSL(Dh, Dl, 16)
|
|
736
|
+
});
|
|
737
|
+
({h: Ch, l: Cl} = add(Ch, Cl, Dh, Dl));
|
|
738
|
+
({Bh, Bl} = {
|
|
739
|
+
Bh: Bh ^ Ch,
|
|
740
|
+
Bl: Bl ^ Cl
|
|
741
|
+
});
|
|
742
|
+
({Bh, Bl} = {
|
|
743
|
+
Bh: rotrBH(Bh, Bl, 63),
|
|
744
|
+
Bl: rotrBL(Bh, Bl, 63)
|
|
745
|
+
});
|
|
746
|
+
BBUF[2 * a] = Al, BBUF[2 * a + 1] = Ah;
|
|
747
|
+
BBUF[2 * b] = Bl, BBUF[2 * b + 1] = Bh;
|
|
748
|
+
BBUF[2 * c] = Cl, BBUF[2 * c + 1] = Ch;
|
|
749
|
+
BBUF[2 * d] = Dl, BBUF[2 * d + 1] = Dh;
|
|
750
|
+
}
|
|
751
|
+
function checkBlake2Opts(outputLen, opts = {}, keyLen, saltLen, persLen) {
|
|
752
|
+
anumber(keyLen);
|
|
753
|
+
if (outputLen < 0 || outputLen > keyLen) throw new Error("outputLen bigger than keyLen");
|
|
754
|
+
const { key, salt, personalization } = opts;
|
|
755
|
+
if (key !== void 0 && (key.length < 1 || key.length > keyLen)) throw new Error("key length must be undefined or 1.." + keyLen);
|
|
756
|
+
if (salt !== void 0 && salt.length !== saltLen) throw new Error("salt must be undefined or " + saltLen);
|
|
757
|
+
if (personalization !== void 0 && personalization.length !== persLen) throw new Error("personalization must be undefined or " + persLen);
|
|
758
|
+
}
|
|
759
|
+
/** Class, from which others are subclassed. */
|
|
760
|
+
var BLAKE2 = class extends Hash {
|
|
761
|
+
constructor(blockLen, outputLen) {
|
|
762
|
+
super();
|
|
763
|
+
this.finished = false;
|
|
764
|
+
this.destroyed = false;
|
|
765
|
+
this.length = 0;
|
|
766
|
+
this.pos = 0;
|
|
767
|
+
anumber(blockLen);
|
|
768
|
+
anumber(outputLen);
|
|
769
|
+
this.blockLen = blockLen;
|
|
770
|
+
this.outputLen = outputLen;
|
|
771
|
+
this.buffer = new Uint8Array(blockLen);
|
|
772
|
+
this.buffer32 = u32(this.buffer);
|
|
773
|
+
}
|
|
774
|
+
update(data) {
|
|
775
|
+
aexists(this);
|
|
776
|
+
data = toBytes(data);
|
|
777
|
+
abytes(data);
|
|
778
|
+
const { blockLen, buffer, buffer32 } = this;
|
|
779
|
+
const len = data.length;
|
|
780
|
+
const offset = data.byteOffset;
|
|
781
|
+
const buf = data.buffer;
|
|
782
|
+
for (let pos = 0; pos < len;) {
|
|
783
|
+
if (this.pos === blockLen) {
|
|
784
|
+
swap32IfBE(buffer32);
|
|
785
|
+
this.compress(buffer32, 0, false);
|
|
786
|
+
swap32IfBE(buffer32);
|
|
787
|
+
this.pos = 0;
|
|
788
|
+
}
|
|
789
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
790
|
+
const dataOffset = offset + pos;
|
|
791
|
+
if (take === blockLen && !(dataOffset % 4) && pos + take < len) {
|
|
792
|
+
const data32 = new Uint32Array(buf, dataOffset, Math.floor((len - pos) / 4));
|
|
793
|
+
swap32IfBE(data32);
|
|
794
|
+
for (let pos32 = 0; pos + blockLen < len; pos32 += buffer32.length, pos += blockLen) {
|
|
795
|
+
this.length += blockLen;
|
|
796
|
+
this.compress(data32, pos32, false);
|
|
797
|
+
}
|
|
798
|
+
swap32IfBE(data32);
|
|
799
|
+
continue;
|
|
800
|
+
}
|
|
801
|
+
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
802
|
+
this.pos += take;
|
|
803
|
+
this.length += take;
|
|
804
|
+
pos += take;
|
|
805
|
+
}
|
|
806
|
+
return this;
|
|
807
|
+
}
|
|
808
|
+
digestInto(out) {
|
|
809
|
+
aexists(this);
|
|
810
|
+
aoutput(out, this);
|
|
811
|
+
const { pos, buffer32 } = this;
|
|
812
|
+
this.finished = true;
|
|
813
|
+
clean(this.buffer.subarray(pos));
|
|
814
|
+
swap32IfBE(buffer32);
|
|
815
|
+
this.compress(buffer32, 0, true);
|
|
816
|
+
swap32IfBE(buffer32);
|
|
817
|
+
const out32 = u32(out);
|
|
818
|
+
this.get().forEach((v, i) => out32[i] = swap8IfBE(v));
|
|
819
|
+
}
|
|
820
|
+
digest() {
|
|
821
|
+
const { buffer, outputLen } = this;
|
|
822
|
+
this.digestInto(buffer);
|
|
823
|
+
const res = buffer.slice(0, outputLen);
|
|
824
|
+
this.destroy();
|
|
825
|
+
return res;
|
|
826
|
+
}
|
|
827
|
+
_cloneInto(to) {
|
|
828
|
+
const { buffer, length, finished, destroyed, outputLen, pos } = this;
|
|
829
|
+
to || (to = new this.constructor({ dkLen: outputLen }));
|
|
830
|
+
to.set(...this.get());
|
|
831
|
+
to.buffer.set(buffer);
|
|
832
|
+
to.destroyed = destroyed;
|
|
833
|
+
to.finished = finished;
|
|
834
|
+
to.length = length;
|
|
835
|
+
to.pos = pos;
|
|
836
|
+
to.outputLen = outputLen;
|
|
837
|
+
return to;
|
|
838
|
+
}
|
|
839
|
+
clone() {
|
|
840
|
+
return this._cloneInto();
|
|
841
|
+
}
|
|
842
|
+
};
|
|
843
|
+
var BLAKE2b = class extends BLAKE2 {
|
|
844
|
+
constructor(opts = {}) {
|
|
845
|
+
const olen = opts.dkLen === void 0 ? 64 : opts.dkLen;
|
|
846
|
+
super(128, olen);
|
|
847
|
+
this.v0l = B2B_IV[0] | 0;
|
|
848
|
+
this.v0h = B2B_IV[1] | 0;
|
|
849
|
+
this.v1l = B2B_IV[2] | 0;
|
|
850
|
+
this.v1h = B2B_IV[3] | 0;
|
|
851
|
+
this.v2l = B2B_IV[4] | 0;
|
|
852
|
+
this.v2h = B2B_IV[5] | 0;
|
|
853
|
+
this.v3l = B2B_IV[6] | 0;
|
|
854
|
+
this.v3h = B2B_IV[7] | 0;
|
|
855
|
+
this.v4l = B2B_IV[8] | 0;
|
|
856
|
+
this.v4h = B2B_IV[9] | 0;
|
|
857
|
+
this.v5l = B2B_IV[10] | 0;
|
|
858
|
+
this.v5h = B2B_IV[11] | 0;
|
|
859
|
+
this.v6l = B2B_IV[12] | 0;
|
|
860
|
+
this.v6h = B2B_IV[13] | 0;
|
|
861
|
+
this.v7l = B2B_IV[14] | 0;
|
|
862
|
+
this.v7h = B2B_IV[15] | 0;
|
|
863
|
+
checkBlake2Opts(olen, opts, 64, 16, 16);
|
|
864
|
+
let { key, personalization, salt } = opts;
|
|
865
|
+
let keyLength = 0;
|
|
866
|
+
if (key !== void 0) {
|
|
867
|
+
key = toBytes(key);
|
|
868
|
+
keyLength = key.length;
|
|
869
|
+
}
|
|
870
|
+
this.v0l ^= this.outputLen | keyLength << 8 | 16842752;
|
|
871
|
+
if (salt !== void 0) {
|
|
872
|
+
salt = toBytes(salt);
|
|
873
|
+
const slt = u32(salt);
|
|
874
|
+
this.v4l ^= swap8IfBE(slt[0]);
|
|
875
|
+
this.v4h ^= swap8IfBE(slt[1]);
|
|
876
|
+
this.v5l ^= swap8IfBE(slt[2]);
|
|
877
|
+
this.v5h ^= swap8IfBE(slt[3]);
|
|
878
|
+
}
|
|
879
|
+
if (personalization !== void 0) {
|
|
880
|
+
personalization = toBytes(personalization);
|
|
881
|
+
const pers = u32(personalization);
|
|
882
|
+
this.v6l ^= swap8IfBE(pers[0]);
|
|
883
|
+
this.v6h ^= swap8IfBE(pers[1]);
|
|
884
|
+
this.v7l ^= swap8IfBE(pers[2]);
|
|
885
|
+
this.v7h ^= swap8IfBE(pers[3]);
|
|
886
|
+
}
|
|
887
|
+
if (key !== void 0) {
|
|
888
|
+
const tmp = new Uint8Array(this.blockLen);
|
|
889
|
+
tmp.set(key);
|
|
890
|
+
this.update(tmp);
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
get() {
|
|
894
|
+
let { v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h } = this;
|
|
895
|
+
return [
|
|
896
|
+
v0l,
|
|
897
|
+
v0h,
|
|
898
|
+
v1l,
|
|
899
|
+
v1h,
|
|
900
|
+
v2l,
|
|
901
|
+
v2h,
|
|
902
|
+
v3l,
|
|
903
|
+
v3h,
|
|
904
|
+
v4l,
|
|
905
|
+
v4h,
|
|
906
|
+
v5l,
|
|
907
|
+
v5h,
|
|
908
|
+
v6l,
|
|
909
|
+
v6h,
|
|
910
|
+
v7l,
|
|
911
|
+
v7h
|
|
912
|
+
];
|
|
913
|
+
}
|
|
914
|
+
set(v0l, v0h, v1l, v1h, v2l, v2h, v3l, v3h, v4l, v4h, v5l, v5h, v6l, v6h, v7l, v7h) {
|
|
915
|
+
this.v0l = v0l | 0;
|
|
916
|
+
this.v0h = v0h | 0;
|
|
917
|
+
this.v1l = v1l | 0;
|
|
918
|
+
this.v1h = v1h | 0;
|
|
919
|
+
this.v2l = v2l | 0;
|
|
920
|
+
this.v2h = v2h | 0;
|
|
921
|
+
this.v3l = v3l | 0;
|
|
922
|
+
this.v3h = v3h | 0;
|
|
923
|
+
this.v4l = v4l | 0;
|
|
924
|
+
this.v4h = v4h | 0;
|
|
925
|
+
this.v5l = v5l | 0;
|
|
926
|
+
this.v5h = v5h | 0;
|
|
927
|
+
this.v6l = v6l | 0;
|
|
928
|
+
this.v6h = v6h | 0;
|
|
929
|
+
this.v7l = v7l | 0;
|
|
930
|
+
this.v7h = v7h | 0;
|
|
931
|
+
}
|
|
932
|
+
compress(msg, offset, isLast) {
|
|
933
|
+
this.get().forEach((v, i) => BBUF[i] = v);
|
|
934
|
+
BBUF.set(B2B_IV, 16);
|
|
935
|
+
let { h, l } = fromBig(BigInt(this.length));
|
|
936
|
+
BBUF[24] = B2B_IV[8] ^ l;
|
|
937
|
+
BBUF[25] = B2B_IV[9] ^ h;
|
|
938
|
+
if (isLast) {
|
|
939
|
+
BBUF[28] = ~BBUF[28];
|
|
940
|
+
BBUF[29] = ~BBUF[29];
|
|
941
|
+
}
|
|
942
|
+
let j = 0;
|
|
943
|
+
const s = BSIGMA;
|
|
944
|
+
for (let i = 0; i < 12; i++) {
|
|
945
|
+
G1b(0, 4, 8, 12, msg, offset + 2 * s[j++]);
|
|
946
|
+
G2b(0, 4, 8, 12, msg, offset + 2 * s[j++]);
|
|
947
|
+
G1b(1, 5, 9, 13, msg, offset + 2 * s[j++]);
|
|
948
|
+
G2b(1, 5, 9, 13, msg, offset + 2 * s[j++]);
|
|
949
|
+
G1b(2, 6, 10, 14, msg, offset + 2 * s[j++]);
|
|
950
|
+
G2b(2, 6, 10, 14, msg, offset + 2 * s[j++]);
|
|
951
|
+
G1b(3, 7, 11, 15, msg, offset + 2 * s[j++]);
|
|
952
|
+
G2b(3, 7, 11, 15, msg, offset + 2 * s[j++]);
|
|
953
|
+
G1b(0, 5, 10, 15, msg, offset + 2 * s[j++]);
|
|
954
|
+
G2b(0, 5, 10, 15, msg, offset + 2 * s[j++]);
|
|
955
|
+
G1b(1, 6, 11, 12, msg, offset + 2 * s[j++]);
|
|
956
|
+
G2b(1, 6, 11, 12, msg, offset + 2 * s[j++]);
|
|
957
|
+
G1b(2, 7, 8, 13, msg, offset + 2 * s[j++]);
|
|
958
|
+
G2b(2, 7, 8, 13, msg, offset + 2 * s[j++]);
|
|
959
|
+
G1b(3, 4, 9, 14, msg, offset + 2 * s[j++]);
|
|
960
|
+
G2b(3, 4, 9, 14, msg, offset + 2 * s[j++]);
|
|
961
|
+
}
|
|
962
|
+
this.v0l ^= BBUF[0] ^ BBUF[16];
|
|
963
|
+
this.v0h ^= BBUF[1] ^ BBUF[17];
|
|
964
|
+
this.v1l ^= BBUF[2] ^ BBUF[18];
|
|
965
|
+
this.v1h ^= BBUF[3] ^ BBUF[19];
|
|
966
|
+
this.v2l ^= BBUF[4] ^ BBUF[20];
|
|
967
|
+
this.v2h ^= BBUF[5] ^ BBUF[21];
|
|
968
|
+
this.v3l ^= BBUF[6] ^ BBUF[22];
|
|
969
|
+
this.v3h ^= BBUF[7] ^ BBUF[23];
|
|
970
|
+
this.v4l ^= BBUF[8] ^ BBUF[24];
|
|
971
|
+
this.v4h ^= BBUF[9] ^ BBUF[25];
|
|
972
|
+
this.v5l ^= BBUF[10] ^ BBUF[26];
|
|
973
|
+
this.v5h ^= BBUF[11] ^ BBUF[27];
|
|
974
|
+
this.v6l ^= BBUF[12] ^ BBUF[28];
|
|
975
|
+
this.v6h ^= BBUF[13] ^ BBUF[29];
|
|
976
|
+
this.v7l ^= BBUF[14] ^ BBUF[30];
|
|
977
|
+
this.v7h ^= BBUF[15] ^ BBUF[31];
|
|
978
|
+
clean(BBUF);
|
|
979
|
+
}
|
|
980
|
+
destroy() {
|
|
981
|
+
this.destroyed = true;
|
|
982
|
+
clean(this.buffer32);
|
|
983
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
984
|
+
}
|
|
985
|
+
};
|
|
986
|
+
/**
|
|
987
|
+
* Blake2b hash function. 64-bit. 1.5x slower than blake2s in JS.
|
|
988
|
+
* @param msg - message that would be hashed
|
|
989
|
+
* @param opts - dkLen output length, key for MAC mode, salt, personalization
|
|
990
|
+
*/
|
|
991
|
+
const blake2b = /* @__PURE__ */ createOptHasher((opts) => new BLAKE2b(opts));
|
|
992
|
+
//#endregion
|
|
993
|
+
//#region ../../node_modules/@noble/hashes/esm/argon2.js
|
|
994
|
+
/**
|
|
995
|
+
* Argon2 KDF from RFC 9106. Can be used to create a key from password and salt.
|
|
996
|
+
* We suggest to use Scrypt. JS Argon is 2-10x slower than native code because of 64-bitness:
|
|
997
|
+
* * argon uses uint64, but JS doesn't have fast uint64array
|
|
998
|
+
* * uint64 multiplication is 1/3 of time
|
|
999
|
+
* * `P` function would be very nice with u64, because most of value will be in registers,
|
|
1000
|
+
* hovewer with u32 it will require 32 registers, which is too much.
|
|
1001
|
+
* * JS arrays do slow bound checks, so reading from `A2_BUF` slows it down
|
|
1002
|
+
* @module
|
|
1003
|
+
*/
|
|
1004
|
+
const AT = {
|
|
1005
|
+
Argond2d: 0,
|
|
1006
|
+
Argon2i: 1,
|
|
1007
|
+
Argon2id: 2
|
|
1008
|
+
};
|
|
1009
|
+
const ARGON2_SYNC_POINTS = 4;
|
|
1010
|
+
const abytesOrZero = (buf) => {
|
|
1011
|
+
if (buf === void 0) return Uint8Array.of();
|
|
1012
|
+
return kdfInputToBytes(buf);
|
|
1013
|
+
};
|
|
1014
|
+
function mul(a, b) {
|
|
1015
|
+
const aL = a & 65535;
|
|
1016
|
+
const aH = a >>> 16;
|
|
1017
|
+
const bL = b & 65535;
|
|
1018
|
+
const bH = b >>> 16;
|
|
1019
|
+
const ll = Math.imul(aL, bL);
|
|
1020
|
+
const hl = Math.imul(aH, bL);
|
|
1021
|
+
const lh = Math.imul(aL, bH);
|
|
1022
|
+
const hh = Math.imul(aH, bH);
|
|
1023
|
+
const carry = (ll >>> 16) + (hl & 65535) + lh;
|
|
1024
|
+
return {
|
|
1025
|
+
h: hh + (hl >>> 16) + (carry >>> 16) | 0,
|
|
1026
|
+
l: carry << 16 | ll & 65535
|
|
1027
|
+
};
|
|
1028
|
+
}
|
|
1029
|
+
function mul2(a, b) {
|
|
1030
|
+
const { h, l } = mul(a, b);
|
|
1031
|
+
return {
|
|
1032
|
+
h: (h << 1 | l >>> 31) & 4294967295,
|
|
1033
|
+
l: l << 1 & 4294967295
|
|
1034
|
+
};
|
|
1035
|
+
}
|
|
1036
|
+
function blamka(Ah, Al, Bh, Bl) {
|
|
1037
|
+
const { h: Ch, l: Cl } = mul2(Al, Bl);
|
|
1038
|
+
const Rll = add3L(Al, Bl, Cl);
|
|
1039
|
+
return {
|
|
1040
|
+
h: add3H(Rll, Ah, Bh, Ch),
|
|
1041
|
+
l: Rll | 0
|
|
1042
|
+
};
|
|
1043
|
+
}
|
|
1044
|
+
const A2_BUF = new Uint32Array(256);
|
|
1045
|
+
function G(a, b, c, d) {
|
|
1046
|
+
let Al = A2_BUF[2 * a], Ah = A2_BUF[2 * a + 1];
|
|
1047
|
+
let Bl = A2_BUF[2 * b], Bh = A2_BUF[2 * b + 1];
|
|
1048
|
+
let Cl = A2_BUF[2 * c], Ch = A2_BUF[2 * c + 1];
|
|
1049
|
+
let Dl = A2_BUF[2 * d], Dh = A2_BUF[2 * d + 1];
|
|
1050
|
+
({h: Ah, l: Al} = blamka(Ah, Al, Bh, Bl));
|
|
1051
|
+
({Dh, Dl} = {
|
|
1052
|
+
Dh: Dh ^ Ah,
|
|
1053
|
+
Dl: Dl ^ Al
|
|
1054
|
+
});
|
|
1055
|
+
({Dh, Dl} = {
|
|
1056
|
+
Dh: rotr32H(Dh, Dl),
|
|
1057
|
+
Dl: rotr32L(Dh, Dl)
|
|
1058
|
+
});
|
|
1059
|
+
({h: Ch, l: Cl} = blamka(Ch, Cl, Dh, Dl));
|
|
1060
|
+
({Bh, Bl} = {
|
|
1061
|
+
Bh: Bh ^ Ch,
|
|
1062
|
+
Bl: Bl ^ Cl
|
|
1063
|
+
});
|
|
1064
|
+
({Bh, Bl} = {
|
|
1065
|
+
Bh: rotrSH(Bh, Bl, 24),
|
|
1066
|
+
Bl: rotrSL(Bh, Bl, 24)
|
|
1067
|
+
});
|
|
1068
|
+
({h: Ah, l: Al} = blamka(Ah, Al, Bh, Bl));
|
|
1069
|
+
({Dh, Dl} = {
|
|
1070
|
+
Dh: Dh ^ Ah,
|
|
1071
|
+
Dl: Dl ^ Al
|
|
1072
|
+
});
|
|
1073
|
+
({Dh, Dl} = {
|
|
1074
|
+
Dh: rotrSH(Dh, Dl, 16),
|
|
1075
|
+
Dl: rotrSL(Dh, Dl, 16)
|
|
1076
|
+
});
|
|
1077
|
+
({h: Ch, l: Cl} = blamka(Ch, Cl, Dh, Dl));
|
|
1078
|
+
({Bh, Bl} = {
|
|
1079
|
+
Bh: Bh ^ Ch,
|
|
1080
|
+
Bl: Bl ^ Cl
|
|
1081
|
+
});
|
|
1082
|
+
({Bh, Bl} = {
|
|
1083
|
+
Bh: rotrBH(Bh, Bl, 63),
|
|
1084
|
+
Bl: rotrBL(Bh, Bl, 63)
|
|
1085
|
+
});
|
|
1086
|
+
A2_BUF[2 * a] = Al, A2_BUF[2 * a + 1] = Ah;
|
|
1087
|
+
A2_BUF[2 * b] = Bl, A2_BUF[2 * b + 1] = Bh;
|
|
1088
|
+
A2_BUF[2 * c] = Cl, A2_BUF[2 * c + 1] = Ch;
|
|
1089
|
+
A2_BUF[2 * d] = Dl, A2_BUF[2 * d + 1] = Dh;
|
|
1090
|
+
}
|
|
1091
|
+
function P(v00, v01, v02, v03, v04, v05, v06, v07, v08, v09, v10, v11, v12, v13, v14, v15) {
|
|
1092
|
+
G(v00, v04, v08, v12);
|
|
1093
|
+
G(v01, v05, v09, v13);
|
|
1094
|
+
G(v02, v06, v10, v14);
|
|
1095
|
+
G(v03, v07, v11, v15);
|
|
1096
|
+
G(v00, v05, v10, v15);
|
|
1097
|
+
G(v01, v06, v11, v12);
|
|
1098
|
+
G(v02, v07, v08, v13);
|
|
1099
|
+
G(v03, v04, v09, v14);
|
|
1100
|
+
}
|
|
1101
|
+
function block(x, xPos, yPos, outPos, needXor) {
|
|
1102
|
+
for (let i = 0; i < 256; i++) A2_BUF[i] = x[xPos + i] ^ x[yPos + i];
|
|
1103
|
+
for (let i = 0; i < 128; i += 16) P(i, i + 1, i + 2, i + 3, i + 4, i + 5, i + 6, i + 7, i + 8, i + 9, i + 10, i + 11, i + 12, i + 13, i + 14, i + 15);
|
|
1104
|
+
for (let i = 0; i < 16; i += 2) P(i, i + 1, i + 16, i + 17, i + 32, i + 33, i + 48, i + 49, i + 64, i + 65, i + 80, i + 81, i + 96, i + 97, i + 112, i + 113);
|
|
1105
|
+
if (needXor) for (let i = 0; i < 256; i++) x[outPos + i] ^= A2_BUF[i] ^ x[xPos + i] ^ x[yPos + i];
|
|
1106
|
+
else for (let i = 0; i < 256; i++) x[outPos + i] = A2_BUF[i] ^ x[xPos + i] ^ x[yPos + i];
|
|
1107
|
+
clean(A2_BUF);
|
|
1108
|
+
}
|
|
1109
|
+
function Hp(A, dkLen) {
|
|
1110
|
+
const A8 = u8(A);
|
|
1111
|
+
const T = new Uint32Array(1);
|
|
1112
|
+
const T8 = u8(T);
|
|
1113
|
+
T[0] = dkLen;
|
|
1114
|
+
if (dkLen <= 64) return blake2b.create({ dkLen }).update(T8).update(A8).digest();
|
|
1115
|
+
const out = new Uint8Array(dkLen);
|
|
1116
|
+
let V = blake2b.create({}).update(T8).update(A8).digest();
|
|
1117
|
+
let pos = 0;
|
|
1118
|
+
out.set(V.subarray(0, 32));
|
|
1119
|
+
pos += 32;
|
|
1120
|
+
for (; dkLen - pos > 64; pos += 32) {
|
|
1121
|
+
const Vh = blake2b.create({}).update(V);
|
|
1122
|
+
Vh.digestInto(V);
|
|
1123
|
+
Vh.destroy();
|
|
1124
|
+
out.set(V.subarray(0, 32), pos);
|
|
1125
|
+
}
|
|
1126
|
+
out.set(blake2b(V, { dkLen: dkLen - pos }), pos);
|
|
1127
|
+
clean(V, T);
|
|
1128
|
+
return u32(out);
|
|
1129
|
+
}
|
|
1130
|
+
function indexAlpha(r, s, laneLen, segmentLen, index, randL, sameLane = false) {
|
|
1131
|
+
let area;
|
|
1132
|
+
if (r === 0) if (s === 0) area = index - 1;
|
|
1133
|
+
else if (sameLane) area = s * segmentLen + index - 1;
|
|
1134
|
+
else area = s * segmentLen + (index == 0 ? -1 : 0);
|
|
1135
|
+
else if (sameLane) area = laneLen - segmentLen + index - 1;
|
|
1136
|
+
else area = laneLen - segmentLen + (index == 0 ? -1 : 0);
|
|
1137
|
+
return ((r !== 0 && s !== ARGON2_SYNC_POINTS - 1 ? (s + 1) * segmentLen : 0) + (area - 1 - mul(area, mul(randL, randL).h).h)) % laneLen;
|
|
1138
|
+
}
|
|
1139
|
+
const maxUint32 = Math.pow(2, 32);
|
|
1140
|
+
function isU32(num) {
|
|
1141
|
+
return Number.isSafeInteger(num) && num >= 0 && num < maxUint32;
|
|
1142
|
+
}
|
|
1143
|
+
function argon2Opts(opts) {
|
|
1144
|
+
const merged = {
|
|
1145
|
+
version: 19,
|
|
1146
|
+
dkLen: 32,
|
|
1147
|
+
maxmem: maxUint32 - 1,
|
|
1148
|
+
asyncTick: 10
|
|
1149
|
+
};
|
|
1150
|
+
for (let [k, v] of Object.entries(opts)) if (v != null) merged[k] = v;
|
|
1151
|
+
const { dkLen, p, m, t, version, onProgress } = merged;
|
|
1152
|
+
if (!isU32(dkLen) || dkLen < 4) throw new Error("dkLen should be at least 4 bytes");
|
|
1153
|
+
if (!isU32(p) || p < 1 || p >= Math.pow(2, 24)) throw new Error("p should be 1 <= p < 2^24");
|
|
1154
|
+
if (!isU32(m)) throw new Error("m should be 0 <= m < 2^32");
|
|
1155
|
+
if (!isU32(t) || t < 1) throw new Error("t (iterations) should be 1 <= t < 2^32");
|
|
1156
|
+
if (onProgress !== void 0 && typeof onProgress !== "function") throw new Error("progressCb should be function");
|
|
1157
|
+
if (!isU32(m) || m < 8 * p) throw new Error("memory should be at least 8*p bytes");
|
|
1158
|
+
if (version !== 16 && version !== 19) throw new Error("unknown version=" + version);
|
|
1159
|
+
return merged;
|
|
1160
|
+
}
|
|
1161
|
+
function argon2Init(password, salt, type, opts) {
|
|
1162
|
+
password = kdfInputToBytes(password);
|
|
1163
|
+
salt = kdfInputToBytes(salt);
|
|
1164
|
+
abytes(password);
|
|
1165
|
+
abytes(salt);
|
|
1166
|
+
if (!isU32(password.length)) throw new Error("password should be less than 4 GB");
|
|
1167
|
+
if (!isU32(salt.length) || salt.length < 8) throw new Error("salt should be at least 8 bytes and less than 4 GB");
|
|
1168
|
+
if (!Object.values(AT).includes(type)) throw new Error("invalid type");
|
|
1169
|
+
let { p, dkLen, m, t, version, key, personalization, maxmem, onProgress, asyncTick } = argon2Opts(opts);
|
|
1170
|
+
key = abytesOrZero(key);
|
|
1171
|
+
personalization = abytesOrZero(personalization);
|
|
1172
|
+
const h = blake2b.create({});
|
|
1173
|
+
const BUF = new Uint32Array(1);
|
|
1174
|
+
const BUF8 = u8(BUF);
|
|
1175
|
+
for (let item of [
|
|
1176
|
+
p,
|
|
1177
|
+
dkLen,
|
|
1178
|
+
m,
|
|
1179
|
+
t,
|
|
1180
|
+
version,
|
|
1181
|
+
type
|
|
1182
|
+
]) {
|
|
1183
|
+
BUF[0] = item;
|
|
1184
|
+
h.update(BUF8);
|
|
1185
|
+
}
|
|
1186
|
+
for (let i of [
|
|
1187
|
+
password,
|
|
1188
|
+
salt,
|
|
1189
|
+
key,
|
|
1190
|
+
personalization
|
|
1191
|
+
]) {
|
|
1192
|
+
BUF[0] = i.length;
|
|
1193
|
+
h.update(BUF8).update(i);
|
|
1194
|
+
}
|
|
1195
|
+
const H0 = new Uint32Array(18);
|
|
1196
|
+
const H0_8 = u8(H0);
|
|
1197
|
+
h.digestInto(H0_8);
|
|
1198
|
+
const lanes = p;
|
|
1199
|
+
const mP = 4 * p * Math.floor(m / (ARGON2_SYNC_POINTS * p));
|
|
1200
|
+
const laneLen = Math.floor(mP / p);
|
|
1201
|
+
const segmentLen = Math.floor(laneLen / ARGON2_SYNC_POINTS);
|
|
1202
|
+
const memUsed = mP * 256;
|
|
1203
|
+
if (!isU32(maxmem) || memUsed > maxmem) throw new Error("mem should be less than 2**32, got: maxmem=" + maxmem + ", memused=" + memUsed);
|
|
1204
|
+
const B = new Uint32Array(memUsed);
|
|
1205
|
+
for (let l = 0; l < p; l++) {
|
|
1206
|
+
const i = 256 * laneLen * l;
|
|
1207
|
+
H0[17] = l;
|
|
1208
|
+
H0[16] = 0;
|
|
1209
|
+
B.set(Hp(H0, 1024), i);
|
|
1210
|
+
H0[16] = 1;
|
|
1211
|
+
B.set(Hp(H0, 1024), i + 256);
|
|
1212
|
+
}
|
|
1213
|
+
let perBlock = () => {};
|
|
1214
|
+
if (onProgress) {
|
|
1215
|
+
const totalBlock = t * ARGON2_SYNC_POINTS * p * segmentLen;
|
|
1216
|
+
const callbackPer = Math.max(Math.floor(totalBlock / 1e4), 1);
|
|
1217
|
+
let blockCnt = 0;
|
|
1218
|
+
perBlock = () => {
|
|
1219
|
+
blockCnt++;
|
|
1220
|
+
if (onProgress && (!(blockCnt % callbackPer) || blockCnt === totalBlock)) onProgress(blockCnt / totalBlock);
|
|
1221
|
+
};
|
|
1222
|
+
}
|
|
1223
|
+
clean(BUF, H0);
|
|
1224
|
+
return {
|
|
1225
|
+
type,
|
|
1226
|
+
mP,
|
|
1227
|
+
p,
|
|
1228
|
+
t,
|
|
1229
|
+
version,
|
|
1230
|
+
B,
|
|
1231
|
+
laneLen,
|
|
1232
|
+
lanes,
|
|
1233
|
+
segmentLen,
|
|
1234
|
+
dkLen,
|
|
1235
|
+
perBlock,
|
|
1236
|
+
asyncTick
|
|
1237
|
+
};
|
|
1238
|
+
}
|
|
1239
|
+
function argon2Output(B, p, laneLen, dkLen) {
|
|
1240
|
+
const B_final = new Uint32Array(256);
|
|
1241
|
+
for (let l = 0; l < p; l++) for (let j = 0; j < 256; j++) B_final[j] ^= B[256 * (laneLen * l + laneLen - 1) + j];
|
|
1242
|
+
const res = u8(Hp(B_final, dkLen));
|
|
1243
|
+
clean(B_final);
|
|
1244
|
+
return res;
|
|
1245
|
+
}
|
|
1246
|
+
function processBlock(B, address, l, r, s, index, laneLen, segmentLen, lanes, offset, prev, dataIndependent, needXor) {
|
|
1247
|
+
if (offset % laneLen) prev = offset - 1;
|
|
1248
|
+
let randL, randH;
|
|
1249
|
+
if (dataIndependent) {
|
|
1250
|
+
let i128 = index % 128;
|
|
1251
|
+
if (i128 === 0) {
|
|
1252
|
+
address[268]++;
|
|
1253
|
+
block(address, 256, 2 * 256, 0, false);
|
|
1254
|
+
block(address, 0, 2 * 256, 0, false);
|
|
1255
|
+
}
|
|
1256
|
+
randL = address[2 * i128];
|
|
1257
|
+
randH = address[2 * i128 + 1];
|
|
1258
|
+
} else {
|
|
1259
|
+
const T = 256 * prev;
|
|
1260
|
+
randL = B[T];
|
|
1261
|
+
randH = B[T + 1];
|
|
1262
|
+
}
|
|
1263
|
+
const refLane = r === 0 && s === 0 ? l : randH % lanes;
|
|
1264
|
+
const refPos = indexAlpha(r, s, laneLen, segmentLen, index, randL, refLane == l);
|
|
1265
|
+
const refBlock = laneLen * refLane + refPos;
|
|
1266
|
+
block(B, 256 * prev, 256 * refBlock, offset * 256, needXor);
|
|
1267
|
+
}
|
|
1268
|
+
async function argon2Async(type, password, salt, opts) {
|
|
1269
|
+
const { mP, p, t, version, B, laneLen, lanes, segmentLen, dkLen, perBlock, asyncTick } = argon2Init(password, salt, type, opts);
|
|
1270
|
+
const address = new Uint32Array(3 * 256);
|
|
1271
|
+
address[262] = mP;
|
|
1272
|
+
address[264] = t;
|
|
1273
|
+
address[266] = type;
|
|
1274
|
+
let ts = Date.now();
|
|
1275
|
+
for (let r = 0; r < t; r++) {
|
|
1276
|
+
const needXor = r !== 0 && version === 19;
|
|
1277
|
+
address[256] = r;
|
|
1278
|
+
for (let s = 0; s < ARGON2_SYNC_POINTS; s++) {
|
|
1279
|
+
address[260] = s;
|
|
1280
|
+
const dataIndependent = type == AT.Argon2i || type == AT.Argon2id && r === 0 && s < 2;
|
|
1281
|
+
for (let l = 0; l < p; l++) {
|
|
1282
|
+
address[258] = l;
|
|
1283
|
+
address[268] = 0;
|
|
1284
|
+
let startPos = 0;
|
|
1285
|
+
if (r === 0 && s === 0) {
|
|
1286
|
+
startPos = 2;
|
|
1287
|
+
if (dataIndependent) {
|
|
1288
|
+
address[268]++;
|
|
1289
|
+
block(address, 256, 2 * 256, 0, false);
|
|
1290
|
+
block(address, 0, 2 * 256, 0, false);
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
let offset = l * laneLen + s * segmentLen + startPos;
|
|
1294
|
+
let prev = offset % laneLen ? offset - 1 : offset + laneLen - 1;
|
|
1295
|
+
for (let index = startPos; index < segmentLen; index++, offset++, prev++) {
|
|
1296
|
+
perBlock();
|
|
1297
|
+
processBlock(B, address, l, r, s, index, laneLen, segmentLen, lanes, offset, prev, dataIndependent, needXor);
|
|
1298
|
+
const diff = Date.now() - ts;
|
|
1299
|
+
if (!(diff >= 0 && diff < asyncTick)) {
|
|
1300
|
+
await nextTick();
|
|
1301
|
+
ts += diff;
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
clean(address);
|
|
1308
|
+
return argon2Output(B, p, laneLen, dkLen);
|
|
1309
|
+
}
|
|
1310
|
+
/** argon2id async, combining i+d, the most popular version from RFC 9106 */
|
|
1311
|
+
const argon2idAsync = (password, salt, opts) => argon2Async(AT.Argon2id, password, salt, opts);
|
|
1312
|
+
//#endregion
|
|
1313
|
+
//#region ../../node_modules/@noble/hashes/crypto.js
|
|
1314
|
+
var require_crypto = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1315
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1316
|
+
exports.crypto = void 0;
|
|
1317
|
+
exports.crypto = typeof globalThis === "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
|
|
1318
|
+
}));
|
|
1319
|
+
//#endregion
|
|
1320
|
+
//#region ../../node_modules/@noble/hashes/utils.js
|
|
1321
|
+
var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1322
|
+
/**
|
|
1323
|
+
* Utilities for hex, bytes, CSPRNG.
|
|
1324
|
+
* @module
|
|
1325
|
+
*/
|
|
1326
|
+
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
1327
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1328
|
+
exports.wrapXOFConstructorWithOpts = exports.wrapConstructorWithOpts = exports.wrapConstructor = exports.Hash = exports.nextTick = exports.swap32IfBE = exports.byteSwapIfBE = exports.swap8IfBE = exports.isLE = void 0;
|
|
1329
|
+
exports.isBytes = isBytes;
|
|
1330
|
+
exports.anumber = anumber;
|
|
1331
|
+
exports.abytes = abytes;
|
|
1332
|
+
exports.ahash = ahash;
|
|
1333
|
+
exports.aexists = aexists;
|
|
1334
|
+
exports.aoutput = aoutput;
|
|
1335
|
+
exports.u8 = u8;
|
|
1336
|
+
exports.u32 = u32;
|
|
1337
|
+
exports.clean = clean;
|
|
1338
|
+
exports.createView = createView;
|
|
1339
|
+
exports.rotr = rotr;
|
|
1340
|
+
exports.rotl = rotl;
|
|
1341
|
+
exports.byteSwap = byteSwap;
|
|
1342
|
+
exports.byteSwap32 = byteSwap32;
|
|
1343
|
+
exports.bytesToHex = bytesToHex;
|
|
1344
|
+
exports.hexToBytes = hexToBytes;
|
|
1345
|
+
exports.asyncLoop = asyncLoop;
|
|
1346
|
+
exports.utf8ToBytes = utf8ToBytes;
|
|
1347
|
+
exports.bytesToUtf8 = bytesToUtf8;
|
|
1348
|
+
exports.toBytes = toBytes;
|
|
1349
|
+
exports.kdfInputToBytes = kdfInputToBytes;
|
|
1350
|
+
exports.concatBytes = concatBytes;
|
|
1351
|
+
exports.checkOpts = checkOpts;
|
|
1352
|
+
exports.createHasher = createHasher;
|
|
1353
|
+
exports.createOptHasher = createOptHasher;
|
|
1354
|
+
exports.createXOFer = createXOFer;
|
|
1355
|
+
exports.randomBytes = randomBytes;
|
|
1356
|
+
const crypto_1 = require_crypto();
|
|
1357
|
+
/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */
|
|
1358
|
+
function isBytes(a) {
|
|
1359
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
1360
|
+
}
|
|
1361
|
+
/** Asserts something is positive integer. */
|
|
1362
|
+
function anumber(n) {
|
|
1363
|
+
if (!Number.isSafeInteger(n) || n < 0) throw new Error("positive integer expected, got " + n);
|
|
1364
|
+
}
|
|
1365
|
+
/** Asserts something is Uint8Array. */
|
|
1366
|
+
function abytes(b, ...lengths) {
|
|
1367
|
+
if (!isBytes(b)) throw new Error("Uint8Array expected");
|
|
1368
|
+
if (lengths.length > 0 && !lengths.includes(b.length)) throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length);
|
|
1369
|
+
}
|
|
1370
|
+
/** Asserts something is hash */
|
|
1371
|
+
function ahash(h) {
|
|
1372
|
+
if (typeof h !== "function" || typeof h.create !== "function") throw new Error("Hash should be wrapped by utils.createHasher");
|
|
1373
|
+
anumber(h.outputLen);
|
|
1374
|
+
anumber(h.blockLen);
|
|
1375
|
+
}
|
|
1376
|
+
/** Asserts a hash instance has not been destroyed / finished */
|
|
1377
|
+
function aexists(instance, checkFinished = true) {
|
|
1378
|
+
if (instance.destroyed) throw new Error("Hash instance has been destroyed");
|
|
1379
|
+
if (checkFinished && instance.finished) throw new Error("Hash#digest() has already been called");
|
|
1380
|
+
}
|
|
1381
|
+
/** Asserts output is properly-sized byte array */
|
|
1382
|
+
function aoutput(out, instance) {
|
|
1383
|
+
abytes(out);
|
|
1384
|
+
const min = instance.outputLen;
|
|
1385
|
+
if (out.length < min) throw new Error("digestInto() expects output buffer of length at least " + min);
|
|
1386
|
+
}
|
|
1387
|
+
/** Cast u8 / u16 / u32 to u8. */
|
|
1388
|
+
function u8(arr) {
|
|
1389
|
+
return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
1390
|
+
}
|
|
1391
|
+
/** Cast u8 / u16 / u32 to u32. */
|
|
1392
|
+
function u32(arr) {
|
|
1393
|
+
return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
1394
|
+
}
|
|
1395
|
+
/** Zeroize a byte array. Warning: JS provides no guarantees. */
|
|
1396
|
+
function clean(...arrays) {
|
|
1397
|
+
for (let i = 0; i < arrays.length; i++) arrays[i].fill(0);
|
|
1398
|
+
}
|
|
1399
|
+
/** Create DataView of an array for easy byte-level manipulation. */
|
|
1400
|
+
function createView(arr) {
|
|
1401
|
+
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
1402
|
+
}
|
|
1403
|
+
/** The rotate right (circular right shift) operation for uint32 */
|
|
1404
|
+
function rotr(word, shift) {
|
|
1405
|
+
return word << 32 - shift | word >>> shift;
|
|
1406
|
+
}
|
|
1407
|
+
/** The rotate left (circular left shift) operation for uint32 */
|
|
1408
|
+
function rotl(word, shift) {
|
|
1409
|
+
return word << shift | word >>> 32 - shift >>> 0;
|
|
1410
|
+
}
|
|
1411
|
+
/** Is current platform little-endian? Most are. Big-Endian platform: IBM */
|
|
1412
|
+
exports.isLE = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
1413
|
+
/** The byte swap operation for uint32 */
|
|
1414
|
+
function byteSwap(word) {
|
|
1415
|
+
return word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
|
|
1416
|
+
}
|
|
1417
|
+
/** Conditionally byte swap if on a big-endian platform */
|
|
1418
|
+
exports.swap8IfBE = exports.isLE ? (n) => n : (n) => byteSwap(n);
|
|
1419
|
+
/** @deprecated */
|
|
1420
|
+
exports.byteSwapIfBE = exports.swap8IfBE;
|
|
1421
|
+
/** In place byte swap for Uint32Array */
|
|
1422
|
+
function byteSwap32(arr) {
|
|
1423
|
+
for (let i = 0; i < arr.length; i++) arr[i] = byteSwap(arr[i]);
|
|
1424
|
+
return arr;
|
|
1425
|
+
}
|
|
1426
|
+
exports.swap32IfBE = exports.isLE ? (u) => u : byteSwap32;
|
|
1427
|
+
const hasHexBuiltin = typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function";
|
|
1428
|
+
const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
|
|
1429
|
+
/**
|
|
1430
|
+
* Convert byte array to hex string. Uses built-in function, when available.
|
|
1431
|
+
* @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'
|
|
1432
|
+
*/
|
|
1433
|
+
function bytesToHex(bytes) {
|
|
1434
|
+
abytes(bytes);
|
|
1435
|
+
if (hasHexBuiltin) return bytes.toHex();
|
|
1436
|
+
let hex = "";
|
|
1437
|
+
for (let i = 0; i < bytes.length; i++) hex += hexes[bytes[i]];
|
|
1438
|
+
return hex;
|
|
1439
|
+
}
|
|
1440
|
+
const asciis = {
|
|
1441
|
+
_0: 48,
|
|
1442
|
+
_9: 57,
|
|
1443
|
+
A: 65,
|
|
1444
|
+
F: 70,
|
|
1445
|
+
a: 97,
|
|
1446
|
+
f: 102
|
|
1447
|
+
};
|
|
1448
|
+
function asciiToBase16(ch) {
|
|
1449
|
+
if (ch >= asciis._0 && ch <= asciis._9) return ch - asciis._0;
|
|
1450
|
+
if (ch >= asciis.A && ch <= asciis.F) return ch - (asciis.A - 10);
|
|
1451
|
+
if (ch >= asciis.a && ch <= asciis.f) return ch - (asciis.a - 10);
|
|
1452
|
+
}
|
|
1453
|
+
/**
|
|
1454
|
+
* Convert hex string to byte array. Uses built-in function, when available.
|
|
1455
|
+
* @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])
|
|
1456
|
+
*/
|
|
1457
|
+
function hexToBytes(hex) {
|
|
1458
|
+
if (typeof hex !== "string") throw new Error("hex string expected, got " + typeof hex);
|
|
1459
|
+
if (hasHexBuiltin) return Uint8Array.fromHex(hex);
|
|
1460
|
+
const hl = hex.length;
|
|
1461
|
+
const al = hl / 2;
|
|
1462
|
+
if (hl % 2) throw new Error("hex string expected, got unpadded hex of length " + hl);
|
|
1463
|
+
const array = new Uint8Array(al);
|
|
1464
|
+
for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
|
|
1465
|
+
const n1 = asciiToBase16(hex.charCodeAt(hi));
|
|
1466
|
+
const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
|
|
1467
|
+
if (n1 === void 0 || n2 === void 0) {
|
|
1468
|
+
const char = hex[hi] + hex[hi + 1];
|
|
1469
|
+
throw new Error("hex string expected, got non-hex character \"" + char + "\" at index " + hi);
|
|
1470
|
+
}
|
|
1471
|
+
array[ai] = n1 * 16 + n2;
|
|
1472
|
+
}
|
|
1473
|
+
return array;
|
|
1474
|
+
}
|
|
1475
|
+
/**
|
|
1476
|
+
* There is no setImmediate in browser and setTimeout is slow.
|
|
1477
|
+
* Call of async fn will return Promise, which will be fullfiled only on
|
|
1478
|
+
* next scheduler queue processing step and this is exactly what we need.
|
|
1479
|
+
*/
|
|
1480
|
+
const nextTick = async () => {};
|
|
1481
|
+
exports.nextTick = nextTick;
|
|
1482
|
+
/** Returns control to thread each 'tick' ms to avoid blocking. */
|
|
1483
|
+
async function asyncLoop(iters, tick, cb) {
|
|
1484
|
+
let ts = Date.now();
|
|
1485
|
+
for (let i = 0; i < iters; i++) {
|
|
1486
|
+
cb(i);
|
|
1487
|
+
const diff = Date.now() - ts;
|
|
1488
|
+
if (diff >= 0 && diff < tick) continue;
|
|
1489
|
+
await (0, exports.nextTick)();
|
|
1490
|
+
ts += diff;
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
/**
|
|
1494
|
+
* Converts string to bytes using UTF8 encoding.
|
|
1495
|
+
* @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99])
|
|
1496
|
+
*/
|
|
1497
|
+
function utf8ToBytes(str) {
|
|
1498
|
+
if (typeof str !== "string") throw new Error("string expected");
|
|
1499
|
+
return new Uint8Array(new TextEncoder().encode(str));
|
|
1500
|
+
}
|
|
1501
|
+
/**
|
|
1502
|
+
* Converts bytes to string using UTF8 encoding.
|
|
1503
|
+
* @example bytesToUtf8(Uint8Array.from([97, 98, 99])) // 'abc'
|
|
1504
|
+
*/
|
|
1505
|
+
function bytesToUtf8(bytes) {
|
|
1506
|
+
return new TextDecoder().decode(bytes);
|
|
1507
|
+
}
|
|
1508
|
+
/**
|
|
1509
|
+
* Normalizes (non-hex) string or Uint8Array to Uint8Array.
|
|
1510
|
+
* Warning: when Uint8Array is passed, it would NOT get copied.
|
|
1511
|
+
* Keep in mind for future mutable operations.
|
|
1512
|
+
*/
|
|
1513
|
+
function toBytes(data) {
|
|
1514
|
+
if (typeof data === "string") data = utf8ToBytes(data);
|
|
1515
|
+
abytes(data);
|
|
1516
|
+
return data;
|
|
1517
|
+
}
|
|
1518
|
+
/**
|
|
1519
|
+
* Helper for KDFs: consumes uint8array or string.
|
|
1520
|
+
* When string is passed, does utf8 decoding, using TextDecoder.
|
|
1521
|
+
*/
|
|
1522
|
+
function kdfInputToBytes(data) {
|
|
1523
|
+
if (typeof data === "string") data = utf8ToBytes(data);
|
|
1524
|
+
abytes(data);
|
|
1525
|
+
return data;
|
|
1526
|
+
}
|
|
1527
|
+
/** Copies several Uint8Arrays into one. */
|
|
1528
|
+
function concatBytes(...arrays) {
|
|
1529
|
+
let sum = 0;
|
|
1530
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
1531
|
+
const a = arrays[i];
|
|
1532
|
+
abytes(a);
|
|
1533
|
+
sum += a.length;
|
|
1534
|
+
}
|
|
1535
|
+
const res = new Uint8Array(sum);
|
|
1536
|
+
for (let i = 0, pad = 0; i < arrays.length; i++) {
|
|
1537
|
+
const a = arrays[i];
|
|
1538
|
+
res.set(a, pad);
|
|
1539
|
+
pad += a.length;
|
|
1540
|
+
}
|
|
1541
|
+
return res;
|
|
1542
|
+
}
|
|
1543
|
+
function checkOpts(defaults, opts) {
|
|
1544
|
+
if (opts !== void 0 && {}.toString.call(opts) !== "[object Object]") throw new Error("options should be object or undefined");
|
|
1545
|
+
return Object.assign(defaults, opts);
|
|
1546
|
+
}
|
|
1547
|
+
/** For runtime check if class implements interface */
|
|
1548
|
+
var Hash = class {};
|
|
1549
|
+
exports.Hash = Hash;
|
|
1550
|
+
/** Wraps hash function, creating an interface on top of it */
|
|
1551
|
+
function createHasher(hashCons) {
|
|
1552
|
+
const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
|
|
1553
|
+
const tmp = hashCons();
|
|
1554
|
+
hashC.outputLen = tmp.outputLen;
|
|
1555
|
+
hashC.blockLen = tmp.blockLen;
|
|
1556
|
+
hashC.create = () => hashCons();
|
|
1557
|
+
return hashC;
|
|
1558
|
+
}
|
|
1559
|
+
function createOptHasher(hashCons) {
|
|
1560
|
+
const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
|
|
1561
|
+
const tmp = hashCons({});
|
|
1562
|
+
hashC.outputLen = tmp.outputLen;
|
|
1563
|
+
hashC.blockLen = tmp.blockLen;
|
|
1564
|
+
hashC.create = (opts) => hashCons(opts);
|
|
1565
|
+
return hashC;
|
|
1566
|
+
}
|
|
1567
|
+
function createXOFer(hashCons) {
|
|
1568
|
+
const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
|
|
1569
|
+
const tmp = hashCons({});
|
|
1570
|
+
hashC.outputLen = tmp.outputLen;
|
|
1571
|
+
hashC.blockLen = tmp.blockLen;
|
|
1572
|
+
hashC.create = (opts) => hashCons(opts);
|
|
1573
|
+
return hashC;
|
|
1574
|
+
}
|
|
1575
|
+
exports.wrapConstructor = createHasher;
|
|
1576
|
+
exports.wrapConstructorWithOpts = createOptHasher;
|
|
1577
|
+
exports.wrapXOFConstructorWithOpts = createXOFer;
|
|
1578
|
+
/** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */
|
|
1579
|
+
function randomBytes(bytesLength = 32) {
|
|
1580
|
+
if (crypto_1.crypto && typeof crypto_1.crypto.getRandomValues === "function") return crypto_1.crypto.getRandomValues(new Uint8Array(bytesLength));
|
|
1581
|
+
if (crypto_1.crypto && typeof crypto_1.crypto.randomBytes === "function") return Uint8Array.from(crypto_1.crypto.randomBytes(bytesLength));
|
|
1582
|
+
throw new Error("crypto.getRandomValues must be defined");
|
|
1583
|
+
}
|
|
1584
|
+
}));
|
|
1585
|
+
//#endregion
|
|
1586
|
+
//#region ../../node_modules/@noble/hashes/_md.js
|
|
1587
|
+
var require__md = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1588
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1589
|
+
exports.SHA512_IV = exports.SHA384_IV = exports.SHA224_IV = exports.SHA256_IV = exports.HashMD = void 0;
|
|
1590
|
+
exports.setBigUint64 = setBigUint64;
|
|
1591
|
+
exports.Chi = Chi;
|
|
1592
|
+
exports.Maj = Maj;
|
|
1593
|
+
/**
|
|
1594
|
+
* Internal Merkle-Damgard hash utils.
|
|
1595
|
+
* @module
|
|
1596
|
+
*/
|
|
1597
|
+
const utils_ts_1 = require_utils();
|
|
1598
|
+
/** Polyfill for Safari 14. https://caniuse.com/mdn-javascript_builtins_dataview_setbiguint64 */
|
|
1599
|
+
function setBigUint64(view, byteOffset, value, isLE) {
|
|
1600
|
+
if (typeof view.setBigUint64 === "function") return view.setBigUint64(byteOffset, value, isLE);
|
|
1601
|
+
const _32n = BigInt(32);
|
|
1602
|
+
const _u32_max = BigInt(4294967295);
|
|
1603
|
+
const wh = Number(value >> _32n & _u32_max);
|
|
1604
|
+
const wl = Number(value & _u32_max);
|
|
1605
|
+
const h = isLE ? 4 : 0;
|
|
1606
|
+
const l = isLE ? 0 : 4;
|
|
1607
|
+
view.setUint32(byteOffset + h, wh, isLE);
|
|
1608
|
+
view.setUint32(byteOffset + l, wl, isLE);
|
|
1609
|
+
}
|
|
1610
|
+
/** Choice: a ? b : c */
|
|
1611
|
+
function Chi(a, b, c) {
|
|
1612
|
+
return a & b ^ ~a & c;
|
|
1613
|
+
}
|
|
1614
|
+
/** Majority function, true if any two inputs is true. */
|
|
1615
|
+
function Maj(a, b, c) {
|
|
1616
|
+
return a & b ^ a & c ^ b & c;
|
|
1617
|
+
}
|
|
1618
|
+
/**
|
|
1619
|
+
* Merkle-Damgard hash construction base class.
|
|
1620
|
+
* Could be used to create MD5, RIPEMD, SHA1, SHA2.
|
|
1621
|
+
*/
|
|
1622
|
+
var HashMD = class extends utils_ts_1.Hash {
|
|
1623
|
+
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
1624
|
+
super();
|
|
1625
|
+
this.finished = false;
|
|
1626
|
+
this.length = 0;
|
|
1627
|
+
this.pos = 0;
|
|
1628
|
+
this.destroyed = false;
|
|
1629
|
+
this.blockLen = blockLen;
|
|
1630
|
+
this.outputLen = outputLen;
|
|
1631
|
+
this.padOffset = padOffset;
|
|
1632
|
+
this.isLE = isLE;
|
|
1633
|
+
this.buffer = new Uint8Array(blockLen);
|
|
1634
|
+
this.view = (0, utils_ts_1.createView)(this.buffer);
|
|
1635
|
+
}
|
|
1636
|
+
update(data) {
|
|
1637
|
+
(0, utils_ts_1.aexists)(this);
|
|
1638
|
+
data = (0, utils_ts_1.toBytes)(data);
|
|
1639
|
+
(0, utils_ts_1.abytes)(data);
|
|
1640
|
+
const { view, buffer, blockLen } = this;
|
|
1641
|
+
const len = data.length;
|
|
1642
|
+
for (let pos = 0; pos < len;) {
|
|
1643
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
1644
|
+
if (take === blockLen) {
|
|
1645
|
+
const dataView = (0, utils_ts_1.createView)(data);
|
|
1646
|
+
for (; blockLen <= len - pos; pos += blockLen) this.process(dataView, pos);
|
|
1647
|
+
continue;
|
|
1648
|
+
}
|
|
1649
|
+
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
1650
|
+
this.pos += take;
|
|
1651
|
+
pos += take;
|
|
1652
|
+
if (this.pos === blockLen) {
|
|
1653
|
+
this.process(view, 0);
|
|
1654
|
+
this.pos = 0;
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
this.length += data.length;
|
|
1658
|
+
this.roundClean();
|
|
1659
|
+
return this;
|
|
1660
|
+
}
|
|
1661
|
+
digestInto(out) {
|
|
1662
|
+
(0, utils_ts_1.aexists)(this);
|
|
1663
|
+
(0, utils_ts_1.aoutput)(out, this);
|
|
1664
|
+
this.finished = true;
|
|
1665
|
+
const { buffer, view, blockLen, isLE } = this;
|
|
1666
|
+
let { pos } = this;
|
|
1667
|
+
buffer[pos++] = 128;
|
|
1668
|
+
(0, utils_ts_1.clean)(this.buffer.subarray(pos));
|
|
1669
|
+
if (this.padOffset > blockLen - pos) {
|
|
1670
|
+
this.process(view, 0);
|
|
1671
|
+
pos = 0;
|
|
1672
|
+
}
|
|
1673
|
+
for (let i = pos; i < blockLen; i++) buffer[i] = 0;
|
|
1674
|
+
setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
|
|
1675
|
+
this.process(view, 0);
|
|
1676
|
+
const oview = (0, utils_ts_1.createView)(out);
|
|
1677
|
+
const len = this.outputLen;
|
|
1678
|
+
if (len % 4) throw new Error("_sha2: outputLen should be aligned to 32bit");
|
|
1679
|
+
const outLen = len / 4;
|
|
1680
|
+
const state = this.get();
|
|
1681
|
+
if (outLen > state.length) throw new Error("_sha2: outputLen bigger than state");
|
|
1682
|
+
for (let i = 0; i < outLen; i++) oview.setUint32(4 * i, state[i], isLE);
|
|
1683
|
+
}
|
|
1684
|
+
digest() {
|
|
1685
|
+
const { buffer, outputLen } = this;
|
|
1686
|
+
this.digestInto(buffer);
|
|
1687
|
+
const res = buffer.slice(0, outputLen);
|
|
1688
|
+
this.destroy();
|
|
1689
|
+
return res;
|
|
1690
|
+
}
|
|
1691
|
+
_cloneInto(to) {
|
|
1692
|
+
to || (to = new this.constructor());
|
|
1693
|
+
to.set(...this.get());
|
|
1694
|
+
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
1695
|
+
to.destroyed = destroyed;
|
|
1696
|
+
to.finished = finished;
|
|
1697
|
+
to.length = length;
|
|
1698
|
+
to.pos = pos;
|
|
1699
|
+
if (length % blockLen) to.buffer.set(buffer);
|
|
1700
|
+
return to;
|
|
1701
|
+
}
|
|
1702
|
+
clone() {
|
|
1703
|
+
return this._cloneInto();
|
|
1704
|
+
}
|
|
1705
|
+
};
|
|
1706
|
+
exports.HashMD = HashMD;
|
|
1707
|
+
/**
|
|
1708
|
+
* Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53.
|
|
1709
|
+
* Check out `test/misc/sha2-gen-iv.js` for recomputation guide.
|
|
1710
|
+
*/
|
|
1711
|
+
/** Initial SHA256 state. Bits 0..32 of frac part of sqrt of primes 2..19 */
|
|
1712
|
+
exports.SHA256_IV = Uint32Array.from([
|
|
1713
|
+
1779033703,
|
|
1714
|
+
3144134277,
|
|
1715
|
+
1013904242,
|
|
1716
|
+
2773480762,
|
|
1717
|
+
1359893119,
|
|
1718
|
+
2600822924,
|
|
1719
|
+
528734635,
|
|
1720
|
+
1541459225
|
|
1721
|
+
]);
|
|
1722
|
+
/** Initial SHA224 state. Bits 32..64 of frac part of sqrt of primes 23..53 */
|
|
1723
|
+
exports.SHA224_IV = Uint32Array.from([
|
|
1724
|
+
3238371032,
|
|
1725
|
+
914150663,
|
|
1726
|
+
812702999,
|
|
1727
|
+
4144912697,
|
|
1728
|
+
4290775857,
|
|
1729
|
+
1750603025,
|
|
1730
|
+
1694076839,
|
|
1731
|
+
3204075428
|
|
1732
|
+
]);
|
|
1733
|
+
/** Initial SHA384 state. Bits 0..64 of frac part of sqrt of primes 23..53 */
|
|
1734
|
+
exports.SHA384_IV = Uint32Array.from([
|
|
1735
|
+
3418070365,
|
|
1736
|
+
3238371032,
|
|
1737
|
+
1654270250,
|
|
1738
|
+
914150663,
|
|
1739
|
+
2438529370,
|
|
1740
|
+
812702999,
|
|
1741
|
+
355462360,
|
|
1742
|
+
4144912697,
|
|
1743
|
+
1731405415,
|
|
1744
|
+
4290775857,
|
|
1745
|
+
2394180231,
|
|
1746
|
+
1750603025,
|
|
1747
|
+
3675008525,
|
|
1748
|
+
1694076839,
|
|
1749
|
+
1203062813,
|
|
1750
|
+
3204075428
|
|
1751
|
+
]);
|
|
1752
|
+
/** Initial SHA512 state. Bits 0..64 of frac part of sqrt of primes 2..19 */
|
|
1753
|
+
exports.SHA512_IV = Uint32Array.from([
|
|
1754
|
+
1779033703,
|
|
1755
|
+
4089235720,
|
|
1756
|
+
3144134277,
|
|
1757
|
+
2227873595,
|
|
1758
|
+
1013904242,
|
|
1759
|
+
4271175723,
|
|
1760
|
+
2773480762,
|
|
1761
|
+
1595750129,
|
|
1762
|
+
1359893119,
|
|
1763
|
+
2917565137,
|
|
1764
|
+
2600822924,
|
|
1765
|
+
725511199,
|
|
1766
|
+
528734635,
|
|
1767
|
+
4215389547,
|
|
1768
|
+
1541459225,
|
|
1769
|
+
327033209
|
|
1770
|
+
]);
|
|
1771
|
+
}));
|
|
1772
|
+
//#endregion
|
|
1773
|
+
//#region ../../node_modules/@noble/hashes/legacy.js
|
|
1774
|
+
var require_legacy = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1775
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1776
|
+
exports.ripemd160 = exports.RIPEMD160 = exports.md5 = exports.MD5 = exports.sha1 = exports.SHA1 = void 0;
|
|
1777
|
+
/**
|
|
1778
|
+
|
|
1779
|
+
SHA1 (RFC 3174), MD5 (RFC 1321) and RIPEMD160 (RFC 2286) legacy, weak hash functions.
|
|
1780
|
+
Don't use them in a new protocol. What "weak" means:
|
|
1781
|
+
|
|
1782
|
+
- Collisions can be made with 2^18 effort in MD5, 2^60 in SHA1, 2^80 in RIPEMD160.
|
|
1783
|
+
- No practical pre-image attacks (only theoretical, 2^123.4)
|
|
1784
|
+
- HMAC seems kinda ok: https://datatracker.ietf.org/doc/html/rfc6151
|
|
1785
|
+
* @module
|
|
1786
|
+
*/
|
|
1787
|
+
const _md_ts_1 = require__md();
|
|
1788
|
+
const utils_ts_1 = require_utils();
|
|
1789
|
+
/** Initial SHA1 state */
|
|
1790
|
+
const SHA1_IV = /* @__PURE__ */ Uint32Array.from([
|
|
1791
|
+
1732584193,
|
|
1792
|
+
4023233417,
|
|
1793
|
+
2562383102,
|
|
1794
|
+
271733878,
|
|
1795
|
+
3285377520
|
|
1796
|
+
]);
|
|
1797
|
+
const SHA1_W = /* @__PURE__ */ new Uint32Array(80);
|
|
1798
|
+
/** SHA1 legacy hash class. */
|
|
1799
|
+
var SHA1 = class extends _md_ts_1.HashMD {
|
|
1800
|
+
constructor() {
|
|
1801
|
+
super(64, 20, 8, false);
|
|
1802
|
+
this.A = SHA1_IV[0] | 0;
|
|
1803
|
+
this.B = SHA1_IV[1] | 0;
|
|
1804
|
+
this.C = SHA1_IV[2] | 0;
|
|
1805
|
+
this.D = SHA1_IV[3] | 0;
|
|
1806
|
+
this.E = SHA1_IV[4] | 0;
|
|
1807
|
+
}
|
|
1808
|
+
get() {
|
|
1809
|
+
const { A, B, C, D, E } = this;
|
|
1810
|
+
return [
|
|
1811
|
+
A,
|
|
1812
|
+
B,
|
|
1813
|
+
C,
|
|
1814
|
+
D,
|
|
1815
|
+
E
|
|
1816
|
+
];
|
|
1817
|
+
}
|
|
1818
|
+
set(A, B, C, D, E) {
|
|
1819
|
+
this.A = A | 0;
|
|
1820
|
+
this.B = B | 0;
|
|
1821
|
+
this.C = C | 0;
|
|
1822
|
+
this.D = D | 0;
|
|
1823
|
+
this.E = E | 0;
|
|
1824
|
+
}
|
|
1825
|
+
process(view, offset) {
|
|
1826
|
+
for (let i = 0; i < 16; i++, offset += 4) SHA1_W[i] = view.getUint32(offset, false);
|
|
1827
|
+
for (let i = 16; i < 80; i++) SHA1_W[i] = (0, utils_ts_1.rotl)(SHA1_W[i - 3] ^ SHA1_W[i - 8] ^ SHA1_W[i - 14] ^ SHA1_W[i - 16], 1);
|
|
1828
|
+
let { A, B, C, D, E } = this;
|
|
1829
|
+
for (let i = 0; i < 80; i++) {
|
|
1830
|
+
let F, K;
|
|
1831
|
+
if (i < 20) {
|
|
1832
|
+
F = (0, _md_ts_1.Chi)(B, C, D);
|
|
1833
|
+
K = 1518500249;
|
|
1834
|
+
} else if (i < 40) {
|
|
1835
|
+
F = B ^ C ^ D;
|
|
1836
|
+
K = 1859775393;
|
|
1837
|
+
} else if (i < 60) {
|
|
1838
|
+
F = (0, _md_ts_1.Maj)(B, C, D);
|
|
1839
|
+
K = 2400959708;
|
|
1840
|
+
} else {
|
|
1841
|
+
F = B ^ C ^ D;
|
|
1842
|
+
K = 3395469782;
|
|
1843
|
+
}
|
|
1844
|
+
const T = (0, utils_ts_1.rotl)(A, 5) + F + E + K + SHA1_W[i] | 0;
|
|
1845
|
+
E = D;
|
|
1846
|
+
D = C;
|
|
1847
|
+
C = (0, utils_ts_1.rotl)(B, 30);
|
|
1848
|
+
B = A;
|
|
1849
|
+
A = T;
|
|
1850
|
+
}
|
|
1851
|
+
A = A + this.A | 0;
|
|
1852
|
+
B = B + this.B | 0;
|
|
1853
|
+
C = C + this.C | 0;
|
|
1854
|
+
D = D + this.D | 0;
|
|
1855
|
+
E = E + this.E | 0;
|
|
1856
|
+
this.set(A, B, C, D, E);
|
|
1857
|
+
}
|
|
1858
|
+
roundClean() {
|
|
1859
|
+
(0, utils_ts_1.clean)(SHA1_W);
|
|
1860
|
+
}
|
|
1861
|
+
destroy() {
|
|
1862
|
+
this.set(0, 0, 0, 0, 0);
|
|
1863
|
+
(0, utils_ts_1.clean)(this.buffer);
|
|
1864
|
+
}
|
|
1865
|
+
};
|
|
1866
|
+
exports.SHA1 = SHA1;
|
|
1867
|
+
/** SHA1 (RFC 3174) legacy hash function. It was cryptographically broken. */
|
|
1868
|
+
exports.sha1 = (0, utils_ts_1.createHasher)(() => new SHA1());
|
|
1869
|
+
/** Per-round constants */
|
|
1870
|
+
const p32 = /* @__PURE__ */ Math.pow(2, 32);
|
|
1871
|
+
const K = /* @__PURE__ */ Array.from({ length: 64 }, (_, i) => Math.floor(p32 * Math.abs(Math.sin(i + 1))));
|
|
1872
|
+
/** md5 initial state: same as sha1, but 4 u32 instead of 5. */
|
|
1873
|
+
const MD5_IV = /* @__PURE__ */ SHA1_IV.slice(0, 4);
|
|
1874
|
+
const MD5_W = /* @__PURE__ */ new Uint32Array(16);
|
|
1875
|
+
/** MD5 legacy hash class. */
|
|
1876
|
+
var MD5 = class extends _md_ts_1.HashMD {
|
|
1877
|
+
constructor() {
|
|
1878
|
+
super(64, 16, 8, true);
|
|
1879
|
+
this.A = MD5_IV[0] | 0;
|
|
1880
|
+
this.B = MD5_IV[1] | 0;
|
|
1881
|
+
this.C = MD5_IV[2] | 0;
|
|
1882
|
+
this.D = MD5_IV[3] | 0;
|
|
1883
|
+
}
|
|
1884
|
+
get() {
|
|
1885
|
+
const { A, B, C, D } = this;
|
|
1886
|
+
return [
|
|
1887
|
+
A,
|
|
1888
|
+
B,
|
|
1889
|
+
C,
|
|
1890
|
+
D
|
|
1891
|
+
];
|
|
1892
|
+
}
|
|
1893
|
+
set(A, B, C, D) {
|
|
1894
|
+
this.A = A | 0;
|
|
1895
|
+
this.B = B | 0;
|
|
1896
|
+
this.C = C | 0;
|
|
1897
|
+
this.D = D | 0;
|
|
1898
|
+
}
|
|
1899
|
+
process(view, offset) {
|
|
1900
|
+
for (let i = 0; i < 16; i++, offset += 4) MD5_W[i] = view.getUint32(offset, true);
|
|
1901
|
+
let { A, B, C, D } = this;
|
|
1902
|
+
for (let i = 0; i < 64; i++) {
|
|
1903
|
+
let F, g, s;
|
|
1904
|
+
if (i < 16) {
|
|
1905
|
+
F = (0, _md_ts_1.Chi)(B, C, D);
|
|
1906
|
+
g = i;
|
|
1907
|
+
s = [
|
|
1908
|
+
7,
|
|
1909
|
+
12,
|
|
1910
|
+
17,
|
|
1911
|
+
22
|
|
1912
|
+
];
|
|
1913
|
+
} else if (i < 32) {
|
|
1914
|
+
F = (0, _md_ts_1.Chi)(D, B, C);
|
|
1915
|
+
g = (5 * i + 1) % 16;
|
|
1916
|
+
s = [
|
|
1917
|
+
5,
|
|
1918
|
+
9,
|
|
1919
|
+
14,
|
|
1920
|
+
20
|
|
1921
|
+
];
|
|
1922
|
+
} else if (i < 48) {
|
|
1923
|
+
F = B ^ C ^ D;
|
|
1924
|
+
g = (3 * i + 5) % 16;
|
|
1925
|
+
s = [
|
|
1926
|
+
4,
|
|
1927
|
+
11,
|
|
1928
|
+
16,
|
|
1929
|
+
23
|
|
1930
|
+
];
|
|
1931
|
+
} else {
|
|
1932
|
+
F = C ^ (B | ~D);
|
|
1933
|
+
g = 7 * i % 16;
|
|
1934
|
+
s = [
|
|
1935
|
+
6,
|
|
1936
|
+
10,
|
|
1937
|
+
15,
|
|
1938
|
+
21
|
|
1939
|
+
];
|
|
1940
|
+
}
|
|
1941
|
+
F = F + A + K[i] + MD5_W[g];
|
|
1942
|
+
A = D;
|
|
1943
|
+
D = C;
|
|
1944
|
+
C = B;
|
|
1945
|
+
B = B + (0, utils_ts_1.rotl)(F, s[i % 4]);
|
|
1946
|
+
}
|
|
1947
|
+
A = A + this.A | 0;
|
|
1948
|
+
B = B + this.B | 0;
|
|
1949
|
+
C = C + this.C | 0;
|
|
1950
|
+
D = D + this.D | 0;
|
|
1951
|
+
this.set(A, B, C, D);
|
|
1952
|
+
}
|
|
1953
|
+
roundClean() {
|
|
1954
|
+
(0, utils_ts_1.clean)(MD5_W);
|
|
1955
|
+
}
|
|
1956
|
+
destroy() {
|
|
1957
|
+
this.set(0, 0, 0, 0);
|
|
1958
|
+
(0, utils_ts_1.clean)(this.buffer);
|
|
1959
|
+
}
|
|
1960
|
+
};
|
|
1961
|
+
exports.MD5 = MD5;
|
|
1962
|
+
/**
|
|
1963
|
+
* MD5 (RFC 1321) legacy hash function. It was cryptographically broken.
|
|
1964
|
+
* MD5 architecture is similar to SHA1, with some differences:
|
|
1965
|
+
* - Reduced output length: 16 bytes (128 bit) instead of 20
|
|
1966
|
+
* - 64 rounds, instead of 80
|
|
1967
|
+
* - Little-endian: could be faster, but will require more code
|
|
1968
|
+
* - Non-linear index selection: huge speed-up for unroll
|
|
1969
|
+
* - Per round constants: more memory accesses, additional speed-up for unroll
|
|
1970
|
+
*/
|
|
1971
|
+
exports.md5 = (0, utils_ts_1.createHasher)(() => new MD5());
|
|
1972
|
+
const Rho160 = /* @__PURE__ */ Uint8Array.from([
|
|
1973
|
+
7,
|
|
1974
|
+
4,
|
|
1975
|
+
13,
|
|
1976
|
+
1,
|
|
1977
|
+
10,
|
|
1978
|
+
6,
|
|
1979
|
+
15,
|
|
1980
|
+
3,
|
|
1981
|
+
12,
|
|
1982
|
+
0,
|
|
1983
|
+
9,
|
|
1984
|
+
5,
|
|
1985
|
+
2,
|
|
1986
|
+
14,
|
|
1987
|
+
11,
|
|
1988
|
+
8
|
|
1989
|
+
]);
|
|
1990
|
+
const Id160 = Uint8Array.from(new Array(16).fill(0).map((_, i) => i));
|
|
1991
|
+
const Pi160 = Id160.map((i) => (9 * i + 5) % 16);
|
|
1992
|
+
const idxLR = /* @__PURE__ */ (() => {
|
|
1993
|
+
const res = [[Id160], [Pi160]];
|
|
1994
|
+
for (let i = 0; i < 4; i++) for (let j of res) j.push(j[i].map((k) => Rho160[k]));
|
|
1995
|
+
return res;
|
|
1996
|
+
})();
|
|
1997
|
+
const idxL = idxLR[0];
|
|
1998
|
+
const idxR = idxLR[1];
|
|
1999
|
+
const shifts160 = /* @__PURE__ */ [
|
|
2000
|
+
[
|
|
2001
|
+
11,
|
|
2002
|
+
14,
|
|
2003
|
+
15,
|
|
2004
|
+
12,
|
|
2005
|
+
5,
|
|
2006
|
+
8,
|
|
2007
|
+
7,
|
|
2008
|
+
9,
|
|
2009
|
+
11,
|
|
2010
|
+
13,
|
|
2011
|
+
14,
|
|
2012
|
+
15,
|
|
2013
|
+
6,
|
|
2014
|
+
7,
|
|
2015
|
+
9,
|
|
2016
|
+
8
|
|
2017
|
+
],
|
|
2018
|
+
[
|
|
2019
|
+
12,
|
|
2020
|
+
13,
|
|
2021
|
+
11,
|
|
2022
|
+
15,
|
|
2023
|
+
6,
|
|
2024
|
+
9,
|
|
2025
|
+
9,
|
|
2026
|
+
7,
|
|
2027
|
+
12,
|
|
2028
|
+
15,
|
|
2029
|
+
11,
|
|
2030
|
+
13,
|
|
2031
|
+
7,
|
|
2032
|
+
8,
|
|
2033
|
+
7,
|
|
2034
|
+
7
|
|
2035
|
+
],
|
|
2036
|
+
[
|
|
2037
|
+
13,
|
|
2038
|
+
15,
|
|
2039
|
+
14,
|
|
2040
|
+
11,
|
|
2041
|
+
7,
|
|
2042
|
+
7,
|
|
2043
|
+
6,
|
|
2044
|
+
8,
|
|
2045
|
+
13,
|
|
2046
|
+
14,
|
|
2047
|
+
13,
|
|
2048
|
+
12,
|
|
2049
|
+
5,
|
|
2050
|
+
5,
|
|
2051
|
+
6,
|
|
2052
|
+
9
|
|
2053
|
+
],
|
|
2054
|
+
[
|
|
2055
|
+
14,
|
|
2056
|
+
11,
|
|
2057
|
+
12,
|
|
2058
|
+
14,
|
|
2059
|
+
8,
|
|
2060
|
+
6,
|
|
2061
|
+
5,
|
|
2062
|
+
5,
|
|
2063
|
+
15,
|
|
2064
|
+
12,
|
|
2065
|
+
15,
|
|
2066
|
+
14,
|
|
2067
|
+
9,
|
|
2068
|
+
9,
|
|
2069
|
+
8,
|
|
2070
|
+
6
|
|
2071
|
+
],
|
|
2072
|
+
[
|
|
2073
|
+
15,
|
|
2074
|
+
12,
|
|
2075
|
+
13,
|
|
2076
|
+
13,
|
|
2077
|
+
9,
|
|
2078
|
+
5,
|
|
2079
|
+
8,
|
|
2080
|
+
6,
|
|
2081
|
+
14,
|
|
2082
|
+
11,
|
|
2083
|
+
12,
|
|
2084
|
+
11,
|
|
2085
|
+
8,
|
|
2086
|
+
6,
|
|
2087
|
+
5,
|
|
2088
|
+
5
|
|
2089
|
+
]
|
|
2090
|
+
].map((i) => Uint8Array.from(i));
|
|
2091
|
+
const shiftsL160 = /* @__PURE__ */ idxL.map((idx, i) => idx.map((j) => shifts160[i][j]));
|
|
2092
|
+
const shiftsR160 = /* @__PURE__ */ idxR.map((idx, i) => idx.map((j) => shifts160[i][j]));
|
|
2093
|
+
const Kl160 = /* @__PURE__ */ Uint32Array.from([
|
|
2094
|
+
0,
|
|
2095
|
+
1518500249,
|
|
2096
|
+
1859775393,
|
|
2097
|
+
2400959708,
|
|
2098
|
+
2840853838
|
|
2099
|
+
]);
|
|
2100
|
+
const Kr160 = /* @__PURE__ */ Uint32Array.from([
|
|
2101
|
+
1352829926,
|
|
2102
|
+
1548603684,
|
|
2103
|
+
1836072691,
|
|
2104
|
+
2053994217,
|
|
2105
|
+
0
|
|
2106
|
+
]);
|
|
2107
|
+
function ripemd_f(group, x, y, z) {
|
|
2108
|
+
if (group === 0) return x ^ y ^ z;
|
|
2109
|
+
if (group === 1) return x & y | ~x & z;
|
|
2110
|
+
if (group === 2) return (x | ~y) ^ z;
|
|
2111
|
+
if (group === 3) return x & z | y & ~z;
|
|
2112
|
+
return x ^ (y | ~z);
|
|
2113
|
+
}
|
|
2114
|
+
const BUF_160 = /* @__PURE__ */ new Uint32Array(16);
|
|
2115
|
+
var RIPEMD160 = class extends _md_ts_1.HashMD {
|
|
2116
|
+
constructor() {
|
|
2117
|
+
super(64, 20, 8, true);
|
|
2118
|
+
this.h0 = 1732584193;
|
|
2119
|
+
this.h1 = -271733879;
|
|
2120
|
+
this.h2 = -1732584194;
|
|
2121
|
+
this.h3 = 271733878;
|
|
2122
|
+
this.h4 = -1009589776;
|
|
2123
|
+
}
|
|
2124
|
+
get() {
|
|
2125
|
+
const { h0, h1, h2, h3, h4 } = this;
|
|
2126
|
+
return [
|
|
2127
|
+
h0,
|
|
2128
|
+
h1,
|
|
2129
|
+
h2,
|
|
2130
|
+
h3,
|
|
2131
|
+
h4
|
|
2132
|
+
];
|
|
2133
|
+
}
|
|
2134
|
+
set(h0, h1, h2, h3, h4) {
|
|
2135
|
+
this.h0 = h0 | 0;
|
|
2136
|
+
this.h1 = h1 | 0;
|
|
2137
|
+
this.h2 = h2 | 0;
|
|
2138
|
+
this.h3 = h3 | 0;
|
|
2139
|
+
this.h4 = h4 | 0;
|
|
2140
|
+
}
|
|
2141
|
+
process(view, offset) {
|
|
2142
|
+
for (let i = 0; i < 16; i++, offset += 4) BUF_160[i] = view.getUint32(offset, true);
|
|
2143
|
+
let al = this.h0 | 0, ar = al, bl = this.h1 | 0, br = bl, cl = this.h2 | 0, cr = cl, dl = this.h3 | 0, dr = dl, el = this.h4 | 0, er = el;
|
|
2144
|
+
for (let group = 0; group < 5; group++) {
|
|
2145
|
+
const rGroup = 4 - group;
|
|
2146
|
+
const hbl = Kl160[group], hbr = Kr160[group];
|
|
2147
|
+
const rl = idxL[group], rr = idxR[group];
|
|
2148
|
+
const sl = shiftsL160[group], sr = shiftsR160[group];
|
|
2149
|
+
for (let i = 0; i < 16; i++) {
|
|
2150
|
+
const tl = (0, utils_ts_1.rotl)(al + ripemd_f(group, bl, cl, dl) + BUF_160[rl[i]] + hbl, sl[i]) + el | 0;
|
|
2151
|
+
al = el, el = dl, dl = (0, utils_ts_1.rotl)(cl, 10) | 0, cl = bl, bl = tl;
|
|
2152
|
+
}
|
|
2153
|
+
for (let i = 0; i < 16; i++) {
|
|
2154
|
+
const tr = (0, utils_ts_1.rotl)(ar + ripemd_f(rGroup, br, cr, dr) + BUF_160[rr[i]] + hbr, sr[i]) + er | 0;
|
|
2155
|
+
ar = er, er = dr, dr = (0, utils_ts_1.rotl)(cr, 10) | 0, cr = br, br = tr;
|
|
2156
|
+
}
|
|
2157
|
+
}
|
|
2158
|
+
this.set(this.h1 + cl + dr | 0, this.h2 + dl + er | 0, this.h3 + el + ar | 0, this.h4 + al + br | 0, this.h0 + bl + cr | 0);
|
|
2159
|
+
}
|
|
2160
|
+
roundClean() {
|
|
2161
|
+
(0, utils_ts_1.clean)(BUF_160);
|
|
2162
|
+
}
|
|
2163
|
+
destroy() {
|
|
2164
|
+
this.destroyed = true;
|
|
2165
|
+
(0, utils_ts_1.clean)(this.buffer);
|
|
2166
|
+
this.set(0, 0, 0, 0, 0);
|
|
2167
|
+
}
|
|
2168
|
+
};
|
|
2169
|
+
exports.RIPEMD160 = RIPEMD160;
|
|
2170
|
+
/**
|
|
2171
|
+
* RIPEMD-160 - a legacy hash function from 1990s.
|
|
2172
|
+
* * https://homes.esat.kuleuven.be/~bosselae/ripemd160.html
|
|
2173
|
+
* * https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf
|
|
2174
|
+
*/
|
|
2175
|
+
exports.ripemd160 = (0, utils_ts_1.createHasher)(() => new RIPEMD160());
|
|
2176
|
+
}));
|
|
2177
|
+
//#endregion
|
|
2178
|
+
//#region ../../node_modules/@noble/hashes/ripemd160.js
|
|
2179
|
+
var require_ripemd160 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2180
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2181
|
+
exports.ripemd160 = exports.RIPEMD160 = void 0;
|
|
2182
|
+
/**
|
|
2183
|
+
* RIPEMD-160 legacy hash function.
|
|
2184
|
+
* https://homes.esat.kuleuven.be/~bosselae/ripemd160.html
|
|
2185
|
+
* https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf
|
|
2186
|
+
* @module
|
|
2187
|
+
* @deprecated
|
|
2188
|
+
*/
|
|
2189
|
+
const legacy_ts_1 = require_legacy();
|
|
2190
|
+
/** @deprecated Use import from `noble/hashes/legacy` module */
|
|
2191
|
+
exports.RIPEMD160 = legacy_ts_1.RIPEMD160;
|
|
2192
|
+
/** @deprecated Use import from `noble/hashes/legacy` module */
|
|
2193
|
+
exports.ripemd160 = legacy_ts_1.ripemd160;
|
|
2194
|
+
}));
|
|
2195
|
+
//#endregion
|
|
2196
|
+
//#region ../../node_modules/@noble/hashes/sha1.js
|
|
2197
|
+
var require_sha1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2198
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2199
|
+
exports.sha1 = exports.SHA1 = void 0;
|
|
2200
|
+
/**
|
|
2201
|
+
* SHA1 (RFC 3174) legacy hash function.
|
|
2202
|
+
* @module
|
|
2203
|
+
* @deprecated
|
|
2204
|
+
*/
|
|
2205
|
+
const legacy_ts_1 = require_legacy();
|
|
2206
|
+
/** @deprecated Use import from `noble/hashes/legacy` module */
|
|
2207
|
+
exports.SHA1 = legacy_ts_1.SHA1;
|
|
2208
|
+
/** @deprecated Use import from `noble/hashes/legacy` module */
|
|
2209
|
+
exports.sha1 = legacy_ts_1.sha1;
|
|
2210
|
+
}));
|
|
2211
|
+
//#endregion
|
|
2212
|
+
//#region ../../node_modules/@noble/hashes/_u64.js
|
|
2213
|
+
var require__u64 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2214
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2215
|
+
exports.toBig = exports.shrSL = exports.shrSH = exports.rotrSL = exports.rotrSH = exports.rotrBL = exports.rotrBH = exports.rotr32L = exports.rotr32H = exports.rotlSL = exports.rotlSH = exports.rotlBL = exports.rotlBH = exports.add5L = exports.add5H = exports.add4L = exports.add4H = exports.add3L = exports.add3H = void 0;
|
|
2216
|
+
exports.add = add;
|
|
2217
|
+
exports.fromBig = fromBig;
|
|
2218
|
+
exports.split = split;
|
|
2219
|
+
/**
|
|
2220
|
+
* Internal helpers for u64. BigUint64Array is too slow as per 2025, so we implement it using Uint32Array.
|
|
2221
|
+
* @todo re-check https://issues.chromium.org/issues/42212588
|
|
2222
|
+
* @module
|
|
2223
|
+
*/
|
|
2224
|
+
const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
2225
|
+
const _32n = /* @__PURE__ */ BigInt(32);
|
|
2226
|
+
function fromBig(n, le = false) {
|
|
2227
|
+
if (le) return {
|
|
2228
|
+
h: Number(n & U32_MASK64),
|
|
2229
|
+
l: Number(n >> _32n & U32_MASK64)
|
|
2230
|
+
};
|
|
2231
|
+
return {
|
|
2232
|
+
h: Number(n >> _32n & U32_MASK64) | 0,
|
|
2233
|
+
l: Number(n & U32_MASK64) | 0
|
|
2234
|
+
};
|
|
2235
|
+
}
|
|
2236
|
+
function split(lst, le = false) {
|
|
2237
|
+
const len = lst.length;
|
|
2238
|
+
let Ah = new Uint32Array(len);
|
|
2239
|
+
let Al = new Uint32Array(len);
|
|
2240
|
+
for (let i = 0; i < len; i++) {
|
|
2241
|
+
const { h, l } = fromBig(lst[i], le);
|
|
2242
|
+
[Ah[i], Al[i]] = [h, l];
|
|
2243
|
+
}
|
|
2244
|
+
return [Ah, Al];
|
|
2245
|
+
}
|
|
2246
|
+
const toBig = (h, l) => BigInt(h >>> 0) << _32n | BigInt(l >>> 0);
|
|
2247
|
+
exports.toBig = toBig;
|
|
2248
|
+
const shrSH = (h, _l, s) => h >>> s;
|
|
2249
|
+
exports.shrSH = shrSH;
|
|
2250
|
+
const shrSL = (h, l, s) => h << 32 - s | l >>> s;
|
|
2251
|
+
exports.shrSL = shrSL;
|
|
2252
|
+
const rotrSH = (h, l, s) => h >>> s | l << 32 - s;
|
|
2253
|
+
exports.rotrSH = rotrSH;
|
|
2254
|
+
const rotrSL = (h, l, s) => h << 32 - s | l >>> s;
|
|
2255
|
+
exports.rotrSL = rotrSL;
|
|
2256
|
+
const rotrBH = (h, l, s) => h << 64 - s | l >>> s - 32;
|
|
2257
|
+
exports.rotrBH = rotrBH;
|
|
2258
|
+
const rotrBL = (h, l, s) => h >>> s - 32 | l << 64 - s;
|
|
2259
|
+
exports.rotrBL = rotrBL;
|
|
2260
|
+
const rotr32H = (_h, l) => l;
|
|
2261
|
+
exports.rotr32H = rotr32H;
|
|
2262
|
+
const rotr32L = (h, _l) => h;
|
|
2263
|
+
exports.rotr32L = rotr32L;
|
|
2264
|
+
const rotlSH = (h, l, s) => h << s | l >>> 32 - s;
|
|
2265
|
+
exports.rotlSH = rotlSH;
|
|
2266
|
+
const rotlSL = (h, l, s) => l << s | h >>> 32 - s;
|
|
2267
|
+
exports.rotlSL = rotlSL;
|
|
2268
|
+
const rotlBH = (h, l, s) => l << s - 32 | h >>> 64 - s;
|
|
2269
|
+
exports.rotlBH = rotlBH;
|
|
2270
|
+
const rotlBL = (h, l, s) => h << s - 32 | l >>> 64 - s;
|
|
2271
|
+
exports.rotlBL = rotlBL;
|
|
2272
|
+
function add(Ah, Al, Bh, Bl) {
|
|
2273
|
+
const l = (Al >>> 0) + (Bl >>> 0);
|
|
2274
|
+
return {
|
|
2275
|
+
h: Ah + Bh + (l / 2 ** 32 | 0) | 0,
|
|
2276
|
+
l: l | 0
|
|
2277
|
+
};
|
|
2278
|
+
}
|
|
2279
|
+
const add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
|
|
2280
|
+
exports.add3L = add3L;
|
|
2281
|
+
const add3H = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0;
|
|
2282
|
+
exports.add3H = add3H;
|
|
2283
|
+
const add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
|
|
2284
|
+
exports.add4L = add4L;
|
|
2285
|
+
const add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0;
|
|
2286
|
+
exports.add4H = add4H;
|
|
2287
|
+
const add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
|
|
2288
|
+
exports.add5L = add5L;
|
|
2289
|
+
const add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
|
|
2290
|
+
exports.add5H = add5H;
|
|
2291
|
+
exports.default = {
|
|
2292
|
+
fromBig,
|
|
2293
|
+
split,
|
|
2294
|
+
toBig,
|
|
2295
|
+
shrSH,
|
|
2296
|
+
shrSL,
|
|
2297
|
+
rotrSH,
|
|
2298
|
+
rotrSL,
|
|
2299
|
+
rotrBH,
|
|
2300
|
+
rotrBL,
|
|
2301
|
+
rotr32H,
|
|
2302
|
+
rotr32L,
|
|
2303
|
+
rotlSH,
|
|
2304
|
+
rotlSL,
|
|
2305
|
+
rotlBH,
|
|
2306
|
+
rotlBL,
|
|
2307
|
+
add,
|
|
2308
|
+
add3L,
|
|
2309
|
+
add3H,
|
|
2310
|
+
add4L,
|
|
2311
|
+
add4H,
|
|
2312
|
+
add5H,
|
|
2313
|
+
add5L
|
|
2314
|
+
};
|
|
2315
|
+
}));
|
|
2316
|
+
//#endregion
|
|
2317
|
+
//#region ../../node_modules/@noble/hashes/sha2.js
|
|
2318
|
+
var require_sha2 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2319
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2320
|
+
exports.sha512_224 = exports.sha512_256 = exports.sha384 = exports.sha512 = exports.sha224 = exports.sha256 = exports.SHA512_256 = exports.SHA512_224 = exports.SHA384 = exports.SHA512 = exports.SHA224 = exports.SHA256 = void 0;
|
|
2321
|
+
/**
|
|
2322
|
+
* SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256.
|
|
2323
|
+
* SHA256 is the fastest hash implementable in JS, even faster than Blake3.
|
|
2324
|
+
* Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and
|
|
2325
|
+
* [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).
|
|
2326
|
+
* @module
|
|
2327
|
+
*/
|
|
2328
|
+
const _md_ts_1 = require__md();
|
|
2329
|
+
const u64 = require__u64();
|
|
2330
|
+
const utils_ts_1 = require_utils();
|
|
2331
|
+
/**
|
|
2332
|
+
* Round constants:
|
|
2333
|
+
* First 32 bits of fractional parts of the cube roots of the first 64 primes 2..311)
|
|
2334
|
+
*/
|
|
2335
|
+
const SHA256_K = /* @__PURE__ */ Uint32Array.from([
|
|
2336
|
+
1116352408,
|
|
2337
|
+
1899447441,
|
|
2338
|
+
3049323471,
|
|
2339
|
+
3921009573,
|
|
2340
|
+
961987163,
|
|
2341
|
+
1508970993,
|
|
2342
|
+
2453635748,
|
|
2343
|
+
2870763221,
|
|
2344
|
+
3624381080,
|
|
2345
|
+
310598401,
|
|
2346
|
+
607225278,
|
|
2347
|
+
1426881987,
|
|
2348
|
+
1925078388,
|
|
2349
|
+
2162078206,
|
|
2350
|
+
2614888103,
|
|
2351
|
+
3248222580,
|
|
2352
|
+
3835390401,
|
|
2353
|
+
4022224774,
|
|
2354
|
+
264347078,
|
|
2355
|
+
604807628,
|
|
2356
|
+
770255983,
|
|
2357
|
+
1249150122,
|
|
2358
|
+
1555081692,
|
|
2359
|
+
1996064986,
|
|
2360
|
+
2554220882,
|
|
2361
|
+
2821834349,
|
|
2362
|
+
2952996808,
|
|
2363
|
+
3210313671,
|
|
2364
|
+
3336571891,
|
|
2365
|
+
3584528711,
|
|
2366
|
+
113926993,
|
|
2367
|
+
338241895,
|
|
2368
|
+
666307205,
|
|
2369
|
+
773529912,
|
|
2370
|
+
1294757372,
|
|
2371
|
+
1396182291,
|
|
2372
|
+
1695183700,
|
|
2373
|
+
1986661051,
|
|
2374
|
+
2177026350,
|
|
2375
|
+
2456956037,
|
|
2376
|
+
2730485921,
|
|
2377
|
+
2820302411,
|
|
2378
|
+
3259730800,
|
|
2379
|
+
3345764771,
|
|
2380
|
+
3516065817,
|
|
2381
|
+
3600352804,
|
|
2382
|
+
4094571909,
|
|
2383
|
+
275423344,
|
|
2384
|
+
430227734,
|
|
2385
|
+
506948616,
|
|
2386
|
+
659060556,
|
|
2387
|
+
883997877,
|
|
2388
|
+
958139571,
|
|
2389
|
+
1322822218,
|
|
2390
|
+
1537002063,
|
|
2391
|
+
1747873779,
|
|
2392
|
+
1955562222,
|
|
2393
|
+
2024104815,
|
|
2394
|
+
2227730452,
|
|
2395
|
+
2361852424,
|
|
2396
|
+
2428436474,
|
|
2397
|
+
2756734187,
|
|
2398
|
+
3204031479,
|
|
2399
|
+
3329325298
|
|
2400
|
+
]);
|
|
2401
|
+
/** Reusable temporary buffer. "W" comes straight from spec. */
|
|
2402
|
+
const SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
2403
|
+
var SHA256 = class extends _md_ts_1.HashMD {
|
|
2404
|
+
constructor(outputLen = 32) {
|
|
2405
|
+
super(64, outputLen, 8, false);
|
|
2406
|
+
this.A = _md_ts_1.SHA256_IV[0] | 0;
|
|
2407
|
+
this.B = _md_ts_1.SHA256_IV[1] | 0;
|
|
2408
|
+
this.C = _md_ts_1.SHA256_IV[2] | 0;
|
|
2409
|
+
this.D = _md_ts_1.SHA256_IV[3] | 0;
|
|
2410
|
+
this.E = _md_ts_1.SHA256_IV[4] | 0;
|
|
2411
|
+
this.F = _md_ts_1.SHA256_IV[5] | 0;
|
|
2412
|
+
this.G = _md_ts_1.SHA256_IV[6] | 0;
|
|
2413
|
+
this.H = _md_ts_1.SHA256_IV[7] | 0;
|
|
2414
|
+
}
|
|
2415
|
+
get() {
|
|
2416
|
+
const { A, B, C, D, E, F, G, H } = this;
|
|
2417
|
+
return [
|
|
2418
|
+
A,
|
|
2419
|
+
B,
|
|
2420
|
+
C,
|
|
2421
|
+
D,
|
|
2422
|
+
E,
|
|
2423
|
+
F,
|
|
2424
|
+
G,
|
|
2425
|
+
H
|
|
2426
|
+
];
|
|
2427
|
+
}
|
|
2428
|
+
set(A, B, C, D, E, F, G, H) {
|
|
2429
|
+
this.A = A | 0;
|
|
2430
|
+
this.B = B | 0;
|
|
2431
|
+
this.C = C | 0;
|
|
2432
|
+
this.D = D | 0;
|
|
2433
|
+
this.E = E | 0;
|
|
2434
|
+
this.F = F | 0;
|
|
2435
|
+
this.G = G | 0;
|
|
2436
|
+
this.H = H | 0;
|
|
2437
|
+
}
|
|
2438
|
+
process(view, offset) {
|
|
2439
|
+
for (let i = 0; i < 16; i++, offset += 4) SHA256_W[i] = view.getUint32(offset, false);
|
|
2440
|
+
for (let i = 16; i < 64; i++) {
|
|
2441
|
+
const W15 = SHA256_W[i - 15];
|
|
2442
|
+
const W2 = SHA256_W[i - 2];
|
|
2443
|
+
const s0 = (0, utils_ts_1.rotr)(W15, 7) ^ (0, utils_ts_1.rotr)(W15, 18) ^ W15 >>> 3;
|
|
2444
|
+
SHA256_W[i] = ((0, utils_ts_1.rotr)(W2, 17) ^ (0, utils_ts_1.rotr)(W2, 19) ^ W2 >>> 10) + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
|
|
2445
|
+
}
|
|
2446
|
+
let { A, B, C, D, E, F, G, H } = this;
|
|
2447
|
+
for (let i = 0; i < 64; i++) {
|
|
2448
|
+
const sigma1 = (0, utils_ts_1.rotr)(E, 6) ^ (0, utils_ts_1.rotr)(E, 11) ^ (0, utils_ts_1.rotr)(E, 25);
|
|
2449
|
+
const T1 = H + sigma1 + (0, _md_ts_1.Chi)(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
|
|
2450
|
+
const T2 = ((0, utils_ts_1.rotr)(A, 2) ^ (0, utils_ts_1.rotr)(A, 13) ^ (0, utils_ts_1.rotr)(A, 22)) + (0, _md_ts_1.Maj)(A, B, C) | 0;
|
|
2451
|
+
H = G;
|
|
2452
|
+
G = F;
|
|
2453
|
+
F = E;
|
|
2454
|
+
E = D + T1 | 0;
|
|
2455
|
+
D = C;
|
|
2456
|
+
C = B;
|
|
2457
|
+
B = A;
|
|
2458
|
+
A = T1 + T2 | 0;
|
|
2459
|
+
}
|
|
2460
|
+
A = A + this.A | 0;
|
|
2461
|
+
B = B + this.B | 0;
|
|
2462
|
+
C = C + this.C | 0;
|
|
2463
|
+
D = D + this.D | 0;
|
|
2464
|
+
E = E + this.E | 0;
|
|
2465
|
+
F = F + this.F | 0;
|
|
2466
|
+
G = G + this.G | 0;
|
|
2467
|
+
H = H + this.H | 0;
|
|
2468
|
+
this.set(A, B, C, D, E, F, G, H);
|
|
2469
|
+
}
|
|
2470
|
+
roundClean() {
|
|
2471
|
+
(0, utils_ts_1.clean)(SHA256_W);
|
|
2472
|
+
}
|
|
2473
|
+
destroy() {
|
|
2474
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
2475
|
+
(0, utils_ts_1.clean)(this.buffer);
|
|
2476
|
+
}
|
|
2477
|
+
};
|
|
2478
|
+
exports.SHA256 = SHA256;
|
|
2479
|
+
var SHA224 = class extends SHA256 {
|
|
2480
|
+
constructor() {
|
|
2481
|
+
super(28);
|
|
2482
|
+
this.A = _md_ts_1.SHA224_IV[0] | 0;
|
|
2483
|
+
this.B = _md_ts_1.SHA224_IV[1] | 0;
|
|
2484
|
+
this.C = _md_ts_1.SHA224_IV[2] | 0;
|
|
2485
|
+
this.D = _md_ts_1.SHA224_IV[3] | 0;
|
|
2486
|
+
this.E = _md_ts_1.SHA224_IV[4] | 0;
|
|
2487
|
+
this.F = _md_ts_1.SHA224_IV[5] | 0;
|
|
2488
|
+
this.G = _md_ts_1.SHA224_IV[6] | 0;
|
|
2489
|
+
this.H = _md_ts_1.SHA224_IV[7] | 0;
|
|
2490
|
+
}
|
|
2491
|
+
};
|
|
2492
|
+
exports.SHA224 = SHA224;
|
|
2493
|
+
const K512 = u64.split([
|
|
2494
|
+
"0x428a2f98d728ae22",
|
|
2495
|
+
"0x7137449123ef65cd",
|
|
2496
|
+
"0xb5c0fbcfec4d3b2f",
|
|
2497
|
+
"0xe9b5dba58189dbbc",
|
|
2498
|
+
"0x3956c25bf348b538",
|
|
2499
|
+
"0x59f111f1b605d019",
|
|
2500
|
+
"0x923f82a4af194f9b",
|
|
2501
|
+
"0xab1c5ed5da6d8118",
|
|
2502
|
+
"0xd807aa98a3030242",
|
|
2503
|
+
"0x12835b0145706fbe",
|
|
2504
|
+
"0x243185be4ee4b28c",
|
|
2505
|
+
"0x550c7dc3d5ffb4e2",
|
|
2506
|
+
"0x72be5d74f27b896f",
|
|
2507
|
+
"0x80deb1fe3b1696b1",
|
|
2508
|
+
"0x9bdc06a725c71235",
|
|
2509
|
+
"0xc19bf174cf692694",
|
|
2510
|
+
"0xe49b69c19ef14ad2",
|
|
2511
|
+
"0xefbe4786384f25e3",
|
|
2512
|
+
"0x0fc19dc68b8cd5b5",
|
|
2513
|
+
"0x240ca1cc77ac9c65",
|
|
2514
|
+
"0x2de92c6f592b0275",
|
|
2515
|
+
"0x4a7484aa6ea6e483",
|
|
2516
|
+
"0x5cb0a9dcbd41fbd4",
|
|
2517
|
+
"0x76f988da831153b5",
|
|
2518
|
+
"0x983e5152ee66dfab",
|
|
2519
|
+
"0xa831c66d2db43210",
|
|
2520
|
+
"0xb00327c898fb213f",
|
|
2521
|
+
"0xbf597fc7beef0ee4",
|
|
2522
|
+
"0xc6e00bf33da88fc2",
|
|
2523
|
+
"0xd5a79147930aa725",
|
|
2524
|
+
"0x06ca6351e003826f",
|
|
2525
|
+
"0x142929670a0e6e70",
|
|
2526
|
+
"0x27b70a8546d22ffc",
|
|
2527
|
+
"0x2e1b21385c26c926",
|
|
2528
|
+
"0x4d2c6dfc5ac42aed",
|
|
2529
|
+
"0x53380d139d95b3df",
|
|
2530
|
+
"0x650a73548baf63de",
|
|
2531
|
+
"0x766a0abb3c77b2a8",
|
|
2532
|
+
"0x81c2c92e47edaee6",
|
|
2533
|
+
"0x92722c851482353b",
|
|
2534
|
+
"0xa2bfe8a14cf10364",
|
|
2535
|
+
"0xa81a664bbc423001",
|
|
2536
|
+
"0xc24b8b70d0f89791",
|
|
2537
|
+
"0xc76c51a30654be30",
|
|
2538
|
+
"0xd192e819d6ef5218",
|
|
2539
|
+
"0xd69906245565a910",
|
|
2540
|
+
"0xf40e35855771202a",
|
|
2541
|
+
"0x106aa07032bbd1b8",
|
|
2542
|
+
"0x19a4c116b8d2d0c8",
|
|
2543
|
+
"0x1e376c085141ab53",
|
|
2544
|
+
"0x2748774cdf8eeb99",
|
|
2545
|
+
"0x34b0bcb5e19b48a8",
|
|
2546
|
+
"0x391c0cb3c5c95a63",
|
|
2547
|
+
"0x4ed8aa4ae3418acb",
|
|
2548
|
+
"0x5b9cca4f7763e373",
|
|
2549
|
+
"0x682e6ff3d6b2b8a3",
|
|
2550
|
+
"0x748f82ee5defb2fc",
|
|
2551
|
+
"0x78a5636f43172f60",
|
|
2552
|
+
"0x84c87814a1f0ab72",
|
|
2553
|
+
"0x8cc702081a6439ec",
|
|
2554
|
+
"0x90befffa23631e28",
|
|
2555
|
+
"0xa4506cebde82bde9",
|
|
2556
|
+
"0xbef9a3f7b2c67915",
|
|
2557
|
+
"0xc67178f2e372532b",
|
|
2558
|
+
"0xca273eceea26619c",
|
|
2559
|
+
"0xd186b8c721c0c207",
|
|
2560
|
+
"0xeada7dd6cde0eb1e",
|
|
2561
|
+
"0xf57d4f7fee6ed178",
|
|
2562
|
+
"0x06f067aa72176fba",
|
|
2563
|
+
"0x0a637dc5a2c898a6",
|
|
2564
|
+
"0x113f9804bef90dae",
|
|
2565
|
+
"0x1b710b35131c471b",
|
|
2566
|
+
"0x28db77f523047d84",
|
|
2567
|
+
"0x32caab7b40c72493",
|
|
2568
|
+
"0x3c9ebe0a15c9bebc",
|
|
2569
|
+
"0x431d67c49c100d4c",
|
|
2570
|
+
"0x4cc5d4becb3e42b6",
|
|
2571
|
+
"0x597f299cfc657e2a",
|
|
2572
|
+
"0x5fcb6fab3ad6faec",
|
|
2573
|
+
"0x6c44198c4a475817"
|
|
2574
|
+
].map((n) => BigInt(n)));
|
|
2575
|
+
const SHA512_Kh = K512[0];
|
|
2576
|
+
const SHA512_Kl = K512[1];
|
|
2577
|
+
const SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);
|
|
2578
|
+
const SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);
|
|
2579
|
+
var SHA512 = class extends _md_ts_1.HashMD {
|
|
2580
|
+
constructor(outputLen = 64) {
|
|
2581
|
+
super(128, outputLen, 16, false);
|
|
2582
|
+
this.Ah = _md_ts_1.SHA512_IV[0] | 0;
|
|
2583
|
+
this.Al = _md_ts_1.SHA512_IV[1] | 0;
|
|
2584
|
+
this.Bh = _md_ts_1.SHA512_IV[2] | 0;
|
|
2585
|
+
this.Bl = _md_ts_1.SHA512_IV[3] | 0;
|
|
2586
|
+
this.Ch = _md_ts_1.SHA512_IV[4] | 0;
|
|
2587
|
+
this.Cl = _md_ts_1.SHA512_IV[5] | 0;
|
|
2588
|
+
this.Dh = _md_ts_1.SHA512_IV[6] | 0;
|
|
2589
|
+
this.Dl = _md_ts_1.SHA512_IV[7] | 0;
|
|
2590
|
+
this.Eh = _md_ts_1.SHA512_IV[8] | 0;
|
|
2591
|
+
this.El = _md_ts_1.SHA512_IV[9] | 0;
|
|
2592
|
+
this.Fh = _md_ts_1.SHA512_IV[10] | 0;
|
|
2593
|
+
this.Fl = _md_ts_1.SHA512_IV[11] | 0;
|
|
2594
|
+
this.Gh = _md_ts_1.SHA512_IV[12] | 0;
|
|
2595
|
+
this.Gl = _md_ts_1.SHA512_IV[13] | 0;
|
|
2596
|
+
this.Hh = _md_ts_1.SHA512_IV[14] | 0;
|
|
2597
|
+
this.Hl = _md_ts_1.SHA512_IV[15] | 0;
|
|
2598
|
+
}
|
|
2599
|
+
get() {
|
|
2600
|
+
const { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
|
|
2601
|
+
return [
|
|
2602
|
+
Ah,
|
|
2603
|
+
Al,
|
|
2604
|
+
Bh,
|
|
2605
|
+
Bl,
|
|
2606
|
+
Ch,
|
|
2607
|
+
Cl,
|
|
2608
|
+
Dh,
|
|
2609
|
+
Dl,
|
|
2610
|
+
Eh,
|
|
2611
|
+
El,
|
|
2612
|
+
Fh,
|
|
2613
|
+
Fl,
|
|
2614
|
+
Gh,
|
|
2615
|
+
Gl,
|
|
2616
|
+
Hh,
|
|
2617
|
+
Hl
|
|
2618
|
+
];
|
|
2619
|
+
}
|
|
2620
|
+
set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl) {
|
|
2621
|
+
this.Ah = Ah | 0;
|
|
2622
|
+
this.Al = Al | 0;
|
|
2623
|
+
this.Bh = Bh | 0;
|
|
2624
|
+
this.Bl = Bl | 0;
|
|
2625
|
+
this.Ch = Ch | 0;
|
|
2626
|
+
this.Cl = Cl | 0;
|
|
2627
|
+
this.Dh = Dh | 0;
|
|
2628
|
+
this.Dl = Dl | 0;
|
|
2629
|
+
this.Eh = Eh | 0;
|
|
2630
|
+
this.El = El | 0;
|
|
2631
|
+
this.Fh = Fh | 0;
|
|
2632
|
+
this.Fl = Fl | 0;
|
|
2633
|
+
this.Gh = Gh | 0;
|
|
2634
|
+
this.Gl = Gl | 0;
|
|
2635
|
+
this.Hh = Hh | 0;
|
|
2636
|
+
this.Hl = Hl | 0;
|
|
2637
|
+
}
|
|
2638
|
+
process(view, offset) {
|
|
2639
|
+
for (let i = 0; i < 16; i++, offset += 4) {
|
|
2640
|
+
SHA512_W_H[i] = view.getUint32(offset);
|
|
2641
|
+
SHA512_W_L[i] = view.getUint32(offset += 4);
|
|
2642
|
+
}
|
|
2643
|
+
for (let i = 16; i < 80; i++) {
|
|
2644
|
+
const W15h = SHA512_W_H[i - 15] | 0;
|
|
2645
|
+
const W15l = SHA512_W_L[i - 15] | 0;
|
|
2646
|
+
const s0h = u64.rotrSH(W15h, W15l, 1) ^ u64.rotrSH(W15h, W15l, 8) ^ u64.shrSH(W15h, W15l, 7);
|
|
2647
|
+
const s0l = u64.rotrSL(W15h, W15l, 1) ^ u64.rotrSL(W15h, W15l, 8) ^ u64.shrSL(W15h, W15l, 7);
|
|
2648
|
+
const W2h = SHA512_W_H[i - 2] | 0;
|
|
2649
|
+
const W2l = SHA512_W_L[i - 2] | 0;
|
|
2650
|
+
const s1h = u64.rotrSH(W2h, W2l, 19) ^ u64.rotrBH(W2h, W2l, 61) ^ u64.shrSH(W2h, W2l, 6);
|
|
2651
|
+
const s1l = u64.rotrSL(W2h, W2l, 19) ^ u64.rotrBL(W2h, W2l, 61) ^ u64.shrSL(W2h, W2l, 6);
|
|
2652
|
+
const SUMl = u64.add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]);
|
|
2653
|
+
SHA512_W_H[i] = u64.add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]) | 0;
|
|
2654
|
+
SHA512_W_L[i] = SUMl | 0;
|
|
2655
|
+
}
|
|
2656
|
+
let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
|
|
2657
|
+
for (let i = 0; i < 80; i++) {
|
|
2658
|
+
const sigma1h = u64.rotrSH(Eh, El, 14) ^ u64.rotrSH(Eh, El, 18) ^ u64.rotrBH(Eh, El, 41);
|
|
2659
|
+
const sigma1l = u64.rotrSL(Eh, El, 14) ^ u64.rotrSL(Eh, El, 18) ^ u64.rotrBL(Eh, El, 41);
|
|
2660
|
+
const CHIh = Eh & Fh ^ ~Eh & Gh;
|
|
2661
|
+
const CHIl = El & Fl ^ ~El & Gl;
|
|
2662
|
+
const T1ll = u64.add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);
|
|
2663
|
+
const T1h = u64.add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);
|
|
2664
|
+
const T1l = T1ll | 0;
|
|
2665
|
+
const sigma0h = u64.rotrSH(Ah, Al, 28) ^ u64.rotrBH(Ah, Al, 34) ^ u64.rotrBH(Ah, Al, 39);
|
|
2666
|
+
const sigma0l = u64.rotrSL(Ah, Al, 28) ^ u64.rotrBL(Ah, Al, 34) ^ u64.rotrBL(Ah, Al, 39);
|
|
2667
|
+
const MAJh = Ah & Bh ^ Ah & Ch ^ Bh & Ch;
|
|
2668
|
+
const MAJl = Al & Bl ^ Al & Cl ^ Bl & Cl;
|
|
2669
|
+
Hh = Gh | 0;
|
|
2670
|
+
Hl = Gl | 0;
|
|
2671
|
+
Gh = Fh | 0;
|
|
2672
|
+
Gl = Fl | 0;
|
|
2673
|
+
Fh = Eh | 0;
|
|
2674
|
+
Fl = El | 0;
|
|
2675
|
+
({h: Eh, l: El} = u64.add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));
|
|
2676
|
+
Dh = Ch | 0;
|
|
2677
|
+
Dl = Cl | 0;
|
|
2678
|
+
Ch = Bh | 0;
|
|
2679
|
+
Cl = Bl | 0;
|
|
2680
|
+
Bh = Ah | 0;
|
|
2681
|
+
Bl = Al | 0;
|
|
2682
|
+
const All = u64.add3L(T1l, sigma0l, MAJl);
|
|
2683
|
+
Ah = u64.add3H(All, T1h, sigma0h, MAJh);
|
|
2684
|
+
Al = All | 0;
|
|
2685
|
+
}
|
|
2686
|
+
({h: Ah, l: Al} = u64.add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));
|
|
2687
|
+
({h: Bh, l: Bl} = u64.add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));
|
|
2688
|
+
({h: Ch, l: Cl} = u64.add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));
|
|
2689
|
+
({h: Dh, l: Dl} = u64.add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));
|
|
2690
|
+
({h: Eh, l: El} = u64.add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));
|
|
2691
|
+
({h: Fh, l: Fl} = u64.add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));
|
|
2692
|
+
({h: Gh, l: Gl} = u64.add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));
|
|
2693
|
+
({h: Hh, l: Hl} = u64.add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));
|
|
2694
|
+
this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);
|
|
2695
|
+
}
|
|
2696
|
+
roundClean() {
|
|
2697
|
+
(0, utils_ts_1.clean)(SHA512_W_H, SHA512_W_L);
|
|
2698
|
+
}
|
|
2699
|
+
destroy() {
|
|
2700
|
+
(0, utils_ts_1.clean)(this.buffer);
|
|
2701
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
2702
|
+
}
|
|
2703
|
+
};
|
|
2704
|
+
exports.SHA512 = SHA512;
|
|
2705
|
+
var SHA384 = class extends SHA512 {
|
|
2706
|
+
constructor() {
|
|
2707
|
+
super(48);
|
|
2708
|
+
this.Ah = _md_ts_1.SHA384_IV[0] | 0;
|
|
2709
|
+
this.Al = _md_ts_1.SHA384_IV[1] | 0;
|
|
2710
|
+
this.Bh = _md_ts_1.SHA384_IV[2] | 0;
|
|
2711
|
+
this.Bl = _md_ts_1.SHA384_IV[3] | 0;
|
|
2712
|
+
this.Ch = _md_ts_1.SHA384_IV[4] | 0;
|
|
2713
|
+
this.Cl = _md_ts_1.SHA384_IV[5] | 0;
|
|
2714
|
+
this.Dh = _md_ts_1.SHA384_IV[6] | 0;
|
|
2715
|
+
this.Dl = _md_ts_1.SHA384_IV[7] | 0;
|
|
2716
|
+
this.Eh = _md_ts_1.SHA384_IV[8] | 0;
|
|
2717
|
+
this.El = _md_ts_1.SHA384_IV[9] | 0;
|
|
2718
|
+
this.Fh = _md_ts_1.SHA384_IV[10] | 0;
|
|
2719
|
+
this.Fl = _md_ts_1.SHA384_IV[11] | 0;
|
|
2720
|
+
this.Gh = _md_ts_1.SHA384_IV[12] | 0;
|
|
2721
|
+
this.Gl = _md_ts_1.SHA384_IV[13] | 0;
|
|
2722
|
+
this.Hh = _md_ts_1.SHA384_IV[14] | 0;
|
|
2723
|
+
this.Hl = _md_ts_1.SHA384_IV[15] | 0;
|
|
2724
|
+
}
|
|
2725
|
+
};
|
|
2726
|
+
exports.SHA384 = SHA384;
|
|
2727
|
+
/**
|
|
2728
|
+
* Truncated SHA512/256 and SHA512/224.
|
|
2729
|
+
* SHA512_IV is XORed with 0xa5a5a5a5a5a5a5a5, then used as "intermediary" IV of SHA512/t.
|
|
2730
|
+
* Then t hashes string to produce result IV.
|
|
2731
|
+
* See `test/misc/sha2-gen-iv.js`.
|
|
2732
|
+
*/
|
|
2733
|
+
/** SHA512/224 IV */
|
|
2734
|
+
const T224_IV = /* @__PURE__ */ Uint32Array.from([
|
|
2735
|
+
2352822216,
|
|
2736
|
+
424955298,
|
|
2737
|
+
1944164710,
|
|
2738
|
+
2312950998,
|
|
2739
|
+
502970286,
|
|
2740
|
+
855612546,
|
|
2741
|
+
1738396948,
|
|
2742
|
+
1479516111,
|
|
2743
|
+
258812777,
|
|
2744
|
+
2077511080,
|
|
2745
|
+
2011393907,
|
|
2746
|
+
79989058,
|
|
2747
|
+
1067287976,
|
|
2748
|
+
1780299464,
|
|
2749
|
+
286451373,
|
|
2750
|
+
2446758561
|
|
2751
|
+
]);
|
|
2752
|
+
/** SHA512/256 IV */
|
|
2753
|
+
const T256_IV = /* @__PURE__ */ Uint32Array.from([
|
|
2754
|
+
573645204,
|
|
2755
|
+
4230739756,
|
|
2756
|
+
2673172387,
|
|
2757
|
+
3360449730,
|
|
2758
|
+
596883563,
|
|
2759
|
+
1867755857,
|
|
2760
|
+
2520282905,
|
|
2761
|
+
1497426621,
|
|
2762
|
+
2519219938,
|
|
2763
|
+
2827943907,
|
|
2764
|
+
3193839141,
|
|
2765
|
+
1401305490,
|
|
2766
|
+
721525244,
|
|
2767
|
+
746961066,
|
|
2768
|
+
246885852,
|
|
2769
|
+
2177182882
|
|
2770
|
+
]);
|
|
2771
|
+
var SHA512_224 = class extends SHA512 {
|
|
2772
|
+
constructor() {
|
|
2773
|
+
super(28);
|
|
2774
|
+
this.Ah = T224_IV[0] | 0;
|
|
2775
|
+
this.Al = T224_IV[1] | 0;
|
|
2776
|
+
this.Bh = T224_IV[2] | 0;
|
|
2777
|
+
this.Bl = T224_IV[3] | 0;
|
|
2778
|
+
this.Ch = T224_IV[4] | 0;
|
|
2779
|
+
this.Cl = T224_IV[5] | 0;
|
|
2780
|
+
this.Dh = T224_IV[6] | 0;
|
|
2781
|
+
this.Dl = T224_IV[7] | 0;
|
|
2782
|
+
this.Eh = T224_IV[8] | 0;
|
|
2783
|
+
this.El = T224_IV[9] | 0;
|
|
2784
|
+
this.Fh = T224_IV[10] | 0;
|
|
2785
|
+
this.Fl = T224_IV[11] | 0;
|
|
2786
|
+
this.Gh = T224_IV[12] | 0;
|
|
2787
|
+
this.Gl = T224_IV[13] | 0;
|
|
2788
|
+
this.Hh = T224_IV[14] | 0;
|
|
2789
|
+
this.Hl = T224_IV[15] | 0;
|
|
2790
|
+
}
|
|
2791
|
+
};
|
|
2792
|
+
exports.SHA512_224 = SHA512_224;
|
|
2793
|
+
var SHA512_256 = class extends SHA512 {
|
|
2794
|
+
constructor() {
|
|
2795
|
+
super(32);
|
|
2796
|
+
this.Ah = T256_IV[0] | 0;
|
|
2797
|
+
this.Al = T256_IV[1] | 0;
|
|
2798
|
+
this.Bh = T256_IV[2] | 0;
|
|
2799
|
+
this.Bl = T256_IV[3] | 0;
|
|
2800
|
+
this.Ch = T256_IV[4] | 0;
|
|
2801
|
+
this.Cl = T256_IV[5] | 0;
|
|
2802
|
+
this.Dh = T256_IV[6] | 0;
|
|
2803
|
+
this.Dl = T256_IV[7] | 0;
|
|
2804
|
+
this.Eh = T256_IV[8] | 0;
|
|
2805
|
+
this.El = T256_IV[9] | 0;
|
|
2806
|
+
this.Fh = T256_IV[10] | 0;
|
|
2807
|
+
this.Fl = T256_IV[11] | 0;
|
|
2808
|
+
this.Gh = T256_IV[12] | 0;
|
|
2809
|
+
this.Gl = T256_IV[13] | 0;
|
|
2810
|
+
this.Hh = T256_IV[14] | 0;
|
|
2811
|
+
this.Hl = T256_IV[15] | 0;
|
|
2812
|
+
}
|
|
2813
|
+
};
|
|
2814
|
+
exports.SHA512_256 = SHA512_256;
|
|
2815
|
+
/**
|
|
2816
|
+
* SHA2-256 hash function from RFC 4634.
|
|
2817
|
+
*
|
|
2818
|
+
* It is the fastest JS hash, even faster than Blake3.
|
|
2819
|
+
* To break sha256 using birthday attack, attackers need to try 2^128 hashes.
|
|
2820
|
+
* BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.
|
|
2821
|
+
*/
|
|
2822
|
+
exports.sha256 = (0, utils_ts_1.createHasher)(() => new SHA256());
|
|
2823
|
+
/** SHA2-224 hash function from RFC 4634 */
|
|
2824
|
+
exports.sha224 = (0, utils_ts_1.createHasher)(() => new SHA224());
|
|
2825
|
+
/** SHA2-512 hash function from RFC 4634. */
|
|
2826
|
+
exports.sha512 = (0, utils_ts_1.createHasher)(() => new SHA512());
|
|
2827
|
+
/** SHA2-384 hash function from RFC 4634. */
|
|
2828
|
+
exports.sha384 = (0, utils_ts_1.createHasher)(() => new SHA384());
|
|
2829
|
+
/**
|
|
2830
|
+
* SHA2-512/256 "truncated" hash function, with improved resistance to length extension attacks.
|
|
2831
|
+
* See the paper on [truncated SHA512](https://eprint.iacr.org/2010/548.pdf).
|
|
2832
|
+
*/
|
|
2833
|
+
exports.sha512_256 = (0, utils_ts_1.createHasher)(() => new SHA512_256());
|
|
2834
|
+
/**
|
|
2835
|
+
* SHA2-512/224 "truncated" hash function, with improved resistance to length extension attacks.
|
|
2836
|
+
* See the paper on [truncated SHA512](https://eprint.iacr.org/2010/548.pdf).
|
|
2837
|
+
*/
|
|
2838
|
+
exports.sha512_224 = (0, utils_ts_1.createHasher)(() => new SHA512_224());
|
|
2839
|
+
}));
|
|
2840
|
+
//#endregion
|
|
2841
|
+
//#region ../../node_modules/@noble/hashes/sha256.js
|
|
2842
|
+
var require_sha256 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2843
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2844
|
+
exports.sha224 = exports.SHA224 = exports.sha256 = exports.SHA256 = void 0;
|
|
2845
|
+
/**
|
|
2846
|
+
* SHA2-256 a.k.a. sha256. In JS, it is the fastest hash, even faster than Blake3.
|
|
2847
|
+
*
|
|
2848
|
+
* To break sha256 using birthday attack, attackers need to try 2^128 hashes.
|
|
2849
|
+
* BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.
|
|
2850
|
+
*
|
|
2851
|
+
* Check out [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).
|
|
2852
|
+
* @module
|
|
2853
|
+
* @deprecated
|
|
2854
|
+
*/
|
|
2855
|
+
const sha2_ts_1 = require_sha2();
|
|
2856
|
+
/** @deprecated Use import from `noble/hashes/sha2` module */
|
|
2857
|
+
exports.SHA256 = sha2_ts_1.SHA256;
|
|
2858
|
+
/** @deprecated Use import from `noble/hashes/sha2` module */
|
|
2859
|
+
exports.sha256 = sha2_ts_1.sha256;
|
|
2860
|
+
/** @deprecated Use import from `noble/hashes/sha2` module */
|
|
2861
|
+
exports.SHA224 = sha2_ts_1.SHA224;
|
|
2862
|
+
/** @deprecated Use import from `noble/hashes/sha2` module */
|
|
2863
|
+
exports.sha224 = sha2_ts_1.sha224;
|
|
2864
|
+
}));
|
|
2865
|
+
//#endregion
|
|
2866
|
+
//#region ../../node_modules/bs58/node_modules/base-x/src/index.js
|
|
2867
|
+
var require_src = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2868
|
+
function base(ALPHABET) {
|
|
2869
|
+
if (ALPHABET.length >= 255) throw new TypeError("Alphabet too long");
|
|
2870
|
+
var BASE_MAP = new Uint8Array(256);
|
|
2871
|
+
for (var j = 0; j < BASE_MAP.length; j++) BASE_MAP[j] = 255;
|
|
2872
|
+
for (var i = 0; i < ALPHABET.length; i++) {
|
|
2873
|
+
var x = ALPHABET.charAt(i);
|
|
2874
|
+
var xc = x.charCodeAt(0);
|
|
2875
|
+
if (BASE_MAP[xc] !== 255) throw new TypeError(x + " is ambiguous");
|
|
2876
|
+
BASE_MAP[xc] = i;
|
|
2877
|
+
}
|
|
2878
|
+
var BASE = ALPHABET.length;
|
|
2879
|
+
var LEADER = ALPHABET.charAt(0);
|
|
2880
|
+
var FACTOR = Math.log(BASE) / Math.log(256);
|
|
2881
|
+
var iFACTOR = Math.log(256) / Math.log(BASE);
|
|
2882
|
+
function encode(source) {
|
|
2883
|
+
if (source instanceof Uint8Array) {} else if (ArrayBuffer.isView(source)) source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
2884
|
+
else if (Array.isArray(source)) source = Uint8Array.from(source);
|
|
2885
|
+
if (!(source instanceof Uint8Array)) throw new TypeError("Expected Uint8Array");
|
|
2886
|
+
if (source.length === 0) return "";
|
|
2887
|
+
var zeroes = 0;
|
|
2888
|
+
var length = 0;
|
|
2889
|
+
var pbegin = 0;
|
|
2890
|
+
var pend = source.length;
|
|
2891
|
+
while (pbegin !== pend && source[pbegin] === 0) {
|
|
2892
|
+
pbegin++;
|
|
2893
|
+
zeroes++;
|
|
2894
|
+
}
|
|
2895
|
+
var size = (pend - pbegin) * iFACTOR + 1 >>> 0;
|
|
2896
|
+
var b58 = new Uint8Array(size);
|
|
2897
|
+
while (pbegin !== pend) {
|
|
2898
|
+
var carry = source[pbegin];
|
|
2899
|
+
var i = 0;
|
|
2900
|
+
for (var it1 = size - 1; (carry !== 0 || i < length) && it1 !== -1; it1--, i++) {
|
|
2901
|
+
carry += 256 * b58[it1] >>> 0;
|
|
2902
|
+
b58[it1] = carry % BASE >>> 0;
|
|
2903
|
+
carry = carry / BASE >>> 0;
|
|
2904
|
+
}
|
|
2905
|
+
if (carry !== 0) throw new Error("Non-zero carry");
|
|
2906
|
+
length = i;
|
|
2907
|
+
pbegin++;
|
|
2908
|
+
}
|
|
2909
|
+
var it2 = size - length;
|
|
2910
|
+
while (it2 !== size && b58[it2] === 0) it2++;
|
|
2911
|
+
var str = LEADER.repeat(zeroes);
|
|
2912
|
+
for (; it2 < size; ++it2) str += ALPHABET.charAt(b58[it2]);
|
|
2913
|
+
return str;
|
|
2914
|
+
}
|
|
2915
|
+
function decodeUnsafe(source) {
|
|
2916
|
+
if (typeof source !== "string") throw new TypeError("Expected String");
|
|
2917
|
+
if (source.length === 0) return new Uint8Array();
|
|
2918
|
+
var psz = 0;
|
|
2919
|
+
var zeroes = 0;
|
|
2920
|
+
var length = 0;
|
|
2921
|
+
while (source[psz] === LEADER) {
|
|
2922
|
+
zeroes++;
|
|
2923
|
+
psz++;
|
|
2924
|
+
}
|
|
2925
|
+
var size = (source.length - psz) * FACTOR + 1 >>> 0;
|
|
2926
|
+
var b256 = new Uint8Array(size);
|
|
2927
|
+
while (source[psz]) {
|
|
2928
|
+
var charCode = source.charCodeAt(psz);
|
|
2929
|
+
if (charCode > 255) return;
|
|
2930
|
+
var carry = BASE_MAP[charCode];
|
|
2931
|
+
if (carry === 255) return;
|
|
2932
|
+
var i = 0;
|
|
2933
|
+
for (var it3 = size - 1; (carry !== 0 || i < length) && it3 !== -1; it3--, i++) {
|
|
2934
|
+
carry += BASE * b256[it3] >>> 0;
|
|
2935
|
+
b256[it3] = carry % 256 >>> 0;
|
|
2936
|
+
carry = carry / 256 >>> 0;
|
|
2937
|
+
}
|
|
2938
|
+
if (carry !== 0) throw new Error("Non-zero carry");
|
|
2939
|
+
length = i;
|
|
2940
|
+
psz++;
|
|
2941
|
+
}
|
|
2942
|
+
var it4 = size - length;
|
|
2943
|
+
while (it4 !== size && b256[it4] === 0) it4++;
|
|
2944
|
+
var vch = new Uint8Array(zeroes + (size - it4));
|
|
2945
|
+
var j = zeroes;
|
|
2946
|
+
while (it4 !== size) vch[j++] = b256[it4++];
|
|
2947
|
+
return vch;
|
|
2948
|
+
}
|
|
2949
|
+
function decode(string) {
|
|
2950
|
+
var buffer = decodeUnsafe(string);
|
|
2951
|
+
if (buffer) return buffer;
|
|
2952
|
+
throw new Error("Non-base" + BASE + " character");
|
|
2953
|
+
}
|
|
2954
|
+
return {
|
|
2955
|
+
encode,
|
|
2956
|
+
decodeUnsafe,
|
|
2957
|
+
decode
|
|
2958
|
+
};
|
|
2959
|
+
}
|
|
2960
|
+
module.exports = base;
|
|
2961
|
+
}));
|
|
2962
|
+
//#endregion
|
|
2963
|
+
//#region ../../node_modules/bs58/index.js
|
|
2964
|
+
var require_bs58 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2965
|
+
module.exports = require_src()("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
|
|
2966
|
+
}));
|
|
2967
|
+
//#endregion
|
|
2968
|
+
//#region ../../node_modules/bech32/dist/index.js
|
|
2969
|
+
var require_dist = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2970
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2971
|
+
exports.bech32m = exports.bech32 = void 0;
|
|
2972
|
+
const ALPHABET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
|
|
2973
|
+
const ALPHABET_MAP = {};
|
|
2974
|
+
for (let z = 0; z < 32; z++) {
|
|
2975
|
+
const x = ALPHABET.charAt(z);
|
|
2976
|
+
ALPHABET_MAP[x] = z;
|
|
2977
|
+
}
|
|
2978
|
+
function polymodStep(pre) {
|
|
2979
|
+
const b = pre >> 25;
|
|
2980
|
+
return (pre & 33554431) << 5 ^ -(b >> 0 & 1) & 996825010 ^ -(b >> 1 & 1) & 642813549 ^ -(b >> 2 & 1) & 513874426 ^ -(b >> 3 & 1) & 1027748829 ^ -(b >> 4 & 1) & 705979059;
|
|
2981
|
+
}
|
|
2982
|
+
function prefixChk(prefix) {
|
|
2983
|
+
let chk = 1;
|
|
2984
|
+
for (let i = 0; i < prefix.length; ++i) {
|
|
2985
|
+
const c = prefix.charCodeAt(i);
|
|
2986
|
+
if (c < 33 || c > 126) return "Invalid prefix (" + prefix + ")";
|
|
2987
|
+
chk = polymodStep(chk) ^ c >> 5;
|
|
2988
|
+
}
|
|
2989
|
+
chk = polymodStep(chk);
|
|
2990
|
+
for (let i = 0; i < prefix.length; ++i) {
|
|
2991
|
+
const v = prefix.charCodeAt(i);
|
|
2992
|
+
chk = polymodStep(chk) ^ v & 31;
|
|
2993
|
+
}
|
|
2994
|
+
return chk;
|
|
2995
|
+
}
|
|
2996
|
+
function convert(data, inBits, outBits, pad) {
|
|
2997
|
+
let value = 0;
|
|
2998
|
+
let bits = 0;
|
|
2999
|
+
const maxV = (1 << outBits) - 1;
|
|
3000
|
+
const result = [];
|
|
3001
|
+
for (let i = 0; i < data.length; ++i) {
|
|
3002
|
+
value = value << inBits | data[i];
|
|
3003
|
+
bits += inBits;
|
|
3004
|
+
while (bits >= outBits) {
|
|
3005
|
+
bits -= outBits;
|
|
3006
|
+
result.push(value >> bits & maxV);
|
|
3007
|
+
}
|
|
3008
|
+
}
|
|
3009
|
+
if (pad) {
|
|
3010
|
+
if (bits > 0) result.push(value << outBits - bits & maxV);
|
|
3011
|
+
} else {
|
|
3012
|
+
if (bits >= inBits) return "Excess padding";
|
|
3013
|
+
if (value << outBits - bits & maxV) return "Non-zero padding";
|
|
3014
|
+
}
|
|
3015
|
+
return result;
|
|
3016
|
+
}
|
|
3017
|
+
function toWords(bytes) {
|
|
3018
|
+
return convert(bytes, 8, 5, true);
|
|
3019
|
+
}
|
|
3020
|
+
function fromWordsUnsafe(words) {
|
|
3021
|
+
const res = convert(words, 5, 8, false);
|
|
3022
|
+
if (Array.isArray(res)) return res;
|
|
3023
|
+
}
|
|
3024
|
+
function fromWords(words) {
|
|
3025
|
+
const res = convert(words, 5, 8, false);
|
|
3026
|
+
if (Array.isArray(res)) return res;
|
|
3027
|
+
throw new Error(res);
|
|
3028
|
+
}
|
|
3029
|
+
function getLibraryFromEncoding(encoding) {
|
|
3030
|
+
let ENCODING_CONST;
|
|
3031
|
+
if (encoding === "bech32") ENCODING_CONST = 1;
|
|
3032
|
+
else ENCODING_CONST = 734539939;
|
|
3033
|
+
function encode(prefix, words, LIMIT) {
|
|
3034
|
+
LIMIT = LIMIT || 90;
|
|
3035
|
+
if (prefix.length + 7 + words.length > LIMIT) throw new TypeError("Exceeds length limit");
|
|
3036
|
+
prefix = prefix.toLowerCase();
|
|
3037
|
+
let chk = prefixChk(prefix);
|
|
3038
|
+
if (typeof chk === "string") throw new Error(chk);
|
|
3039
|
+
let result = prefix + "1";
|
|
3040
|
+
for (let i = 0; i < words.length; ++i) {
|
|
3041
|
+
const x = words[i];
|
|
3042
|
+
if (x >> 5 !== 0) throw new Error("Non 5-bit word");
|
|
3043
|
+
chk = polymodStep(chk) ^ x;
|
|
3044
|
+
result += ALPHABET.charAt(x);
|
|
3045
|
+
}
|
|
3046
|
+
for (let i = 0; i < 6; ++i) chk = polymodStep(chk);
|
|
3047
|
+
chk ^= ENCODING_CONST;
|
|
3048
|
+
for (let i = 0; i < 6; ++i) {
|
|
3049
|
+
const v = chk >> (5 - i) * 5 & 31;
|
|
3050
|
+
result += ALPHABET.charAt(v);
|
|
3051
|
+
}
|
|
3052
|
+
return result;
|
|
3053
|
+
}
|
|
3054
|
+
function __decode(str, LIMIT) {
|
|
3055
|
+
LIMIT = LIMIT || 90;
|
|
3056
|
+
if (str.length < 8) return str + " too short";
|
|
3057
|
+
if (str.length > LIMIT) return "Exceeds length limit";
|
|
3058
|
+
const lowered = str.toLowerCase();
|
|
3059
|
+
const uppered = str.toUpperCase();
|
|
3060
|
+
if (str !== lowered && str !== uppered) return "Mixed-case string " + str;
|
|
3061
|
+
str = lowered;
|
|
3062
|
+
const split = str.lastIndexOf("1");
|
|
3063
|
+
if (split === -1) return "No separator character for " + str;
|
|
3064
|
+
if (split === 0) return "Missing prefix for " + str;
|
|
3065
|
+
const prefix = str.slice(0, split);
|
|
3066
|
+
const wordChars = str.slice(split + 1);
|
|
3067
|
+
if (wordChars.length < 6) return "Data too short";
|
|
3068
|
+
let chk = prefixChk(prefix);
|
|
3069
|
+
if (typeof chk === "string") return chk;
|
|
3070
|
+
const words = [];
|
|
3071
|
+
for (let i = 0; i < wordChars.length; ++i) {
|
|
3072
|
+
const c = wordChars.charAt(i);
|
|
3073
|
+
const v = ALPHABET_MAP[c];
|
|
3074
|
+
if (v === void 0) return "Unknown character " + c;
|
|
3075
|
+
chk = polymodStep(chk) ^ v;
|
|
3076
|
+
if (i + 6 >= wordChars.length) continue;
|
|
3077
|
+
words.push(v);
|
|
3078
|
+
}
|
|
3079
|
+
if (chk !== ENCODING_CONST) return "Invalid checksum for " + str;
|
|
3080
|
+
return {
|
|
3081
|
+
prefix,
|
|
3082
|
+
words
|
|
3083
|
+
};
|
|
3084
|
+
}
|
|
3085
|
+
function decodeUnsafe(str, LIMIT) {
|
|
3086
|
+
const res = __decode(str, LIMIT);
|
|
3087
|
+
if (typeof res === "object") return res;
|
|
3088
|
+
}
|
|
3089
|
+
function decode(str, LIMIT) {
|
|
3090
|
+
const res = __decode(str, LIMIT);
|
|
3091
|
+
if (typeof res === "object") return res;
|
|
3092
|
+
throw new Error(res);
|
|
3093
|
+
}
|
|
3094
|
+
return {
|
|
3095
|
+
decodeUnsafe,
|
|
3096
|
+
decode,
|
|
3097
|
+
encode,
|
|
3098
|
+
toWords,
|
|
3099
|
+
fromWordsUnsafe,
|
|
3100
|
+
fromWords
|
|
3101
|
+
};
|
|
3102
|
+
}
|
|
3103
|
+
exports.bech32 = getLibraryFromEncoding("bech32");
|
|
3104
|
+
exports.bech32m = getLibraryFromEncoding("bech32m");
|
|
3105
|
+
}));
|
|
3106
|
+
//#endregion
|
|
3107
|
+
//#region ../../node_modules/@noble/hashes/hmac.js
|
|
3108
|
+
var require_hmac = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
3109
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3110
|
+
exports.hmac = exports.HMAC = void 0;
|
|
3111
|
+
/**
|
|
3112
|
+
* HMAC: RFC2104 message authentication code.
|
|
3113
|
+
* @module
|
|
3114
|
+
*/
|
|
3115
|
+
const utils_ts_1 = require_utils();
|
|
3116
|
+
var HMAC = class extends utils_ts_1.Hash {
|
|
3117
|
+
constructor(hash, _key) {
|
|
3118
|
+
super();
|
|
3119
|
+
this.finished = false;
|
|
3120
|
+
this.destroyed = false;
|
|
3121
|
+
(0, utils_ts_1.ahash)(hash);
|
|
3122
|
+
const key = (0, utils_ts_1.toBytes)(_key);
|
|
3123
|
+
this.iHash = hash.create();
|
|
3124
|
+
if (typeof this.iHash.update !== "function") throw new Error("Expected instance of class which extends utils.Hash");
|
|
3125
|
+
this.blockLen = this.iHash.blockLen;
|
|
3126
|
+
this.outputLen = this.iHash.outputLen;
|
|
3127
|
+
const blockLen = this.blockLen;
|
|
3128
|
+
const pad = new Uint8Array(blockLen);
|
|
3129
|
+
pad.set(key.length > blockLen ? hash.create().update(key).digest() : key);
|
|
3130
|
+
for (let i = 0; i < pad.length; i++) pad[i] ^= 54;
|
|
3131
|
+
this.iHash.update(pad);
|
|
3132
|
+
this.oHash = hash.create();
|
|
3133
|
+
for (let i = 0; i < pad.length; i++) pad[i] ^= 106;
|
|
3134
|
+
this.oHash.update(pad);
|
|
3135
|
+
(0, utils_ts_1.clean)(pad);
|
|
3136
|
+
}
|
|
3137
|
+
update(buf) {
|
|
3138
|
+
(0, utils_ts_1.aexists)(this);
|
|
3139
|
+
this.iHash.update(buf);
|
|
3140
|
+
return this;
|
|
3141
|
+
}
|
|
3142
|
+
digestInto(out) {
|
|
3143
|
+
(0, utils_ts_1.aexists)(this);
|
|
3144
|
+
(0, utils_ts_1.abytes)(out, this.outputLen);
|
|
3145
|
+
this.finished = true;
|
|
3146
|
+
this.iHash.digestInto(out);
|
|
3147
|
+
this.oHash.update(out);
|
|
3148
|
+
this.oHash.digestInto(out);
|
|
3149
|
+
this.destroy();
|
|
3150
|
+
}
|
|
3151
|
+
digest() {
|
|
3152
|
+
const out = new Uint8Array(this.oHash.outputLen);
|
|
3153
|
+
this.digestInto(out);
|
|
3154
|
+
return out;
|
|
3155
|
+
}
|
|
3156
|
+
_cloneInto(to) {
|
|
3157
|
+
to || (to = Object.create(Object.getPrototypeOf(this), {}));
|
|
3158
|
+
const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
|
|
3159
|
+
to = to;
|
|
3160
|
+
to.finished = finished;
|
|
3161
|
+
to.destroyed = destroyed;
|
|
3162
|
+
to.blockLen = blockLen;
|
|
3163
|
+
to.outputLen = outputLen;
|
|
3164
|
+
to.oHash = oHash._cloneInto(to.oHash);
|
|
3165
|
+
to.iHash = iHash._cloneInto(to.iHash);
|
|
3166
|
+
return to;
|
|
3167
|
+
}
|
|
3168
|
+
clone() {
|
|
3169
|
+
return this._cloneInto();
|
|
3170
|
+
}
|
|
3171
|
+
destroy() {
|
|
3172
|
+
this.destroyed = true;
|
|
3173
|
+
this.oHash.destroy();
|
|
3174
|
+
this.iHash.destroy();
|
|
3175
|
+
}
|
|
3176
|
+
};
|
|
3177
|
+
exports.HMAC = HMAC;
|
|
3178
|
+
/**
|
|
3179
|
+
* HMAC: RFC2104 message authentication code.
|
|
3180
|
+
* @param hash - function that would be used e.g. sha256
|
|
3181
|
+
* @param key - message key
|
|
3182
|
+
* @param message - message data
|
|
3183
|
+
* @example
|
|
3184
|
+
* import { hmac } from '@noble/hashes/hmac';
|
|
3185
|
+
* import { sha256 } from '@noble/hashes/sha2';
|
|
3186
|
+
* const mac1 = hmac(sha256, 'key', 'message');
|
|
3187
|
+
*/
|
|
3188
|
+
const hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest();
|
|
3189
|
+
exports.hmac = hmac;
|
|
3190
|
+
exports.hmac.create = (hash, key) => new HMAC(hash, key);
|
|
3191
|
+
}));
|
|
3192
|
+
//#endregion
|
|
3193
|
+
//#region ../../node_modules/@noble/hashes/esm/hmac.js
|
|
3194
|
+
/**
|
|
3195
|
+
* HMAC: RFC2104 message authentication code.
|
|
3196
|
+
* @module
|
|
3197
|
+
*/
|
|
3198
|
+
var HMAC = class extends Hash {
|
|
3199
|
+
constructor(hash, _key) {
|
|
3200
|
+
super();
|
|
3201
|
+
this.finished = false;
|
|
3202
|
+
this.destroyed = false;
|
|
3203
|
+
ahash(hash);
|
|
3204
|
+
const key = toBytes(_key);
|
|
3205
|
+
this.iHash = hash.create();
|
|
3206
|
+
if (typeof this.iHash.update !== "function") throw new Error("Expected instance of class which extends utils.Hash");
|
|
3207
|
+
this.blockLen = this.iHash.blockLen;
|
|
3208
|
+
this.outputLen = this.iHash.outputLen;
|
|
3209
|
+
const blockLen = this.blockLen;
|
|
3210
|
+
const pad = new Uint8Array(blockLen);
|
|
3211
|
+
pad.set(key.length > blockLen ? hash.create().update(key).digest() : key);
|
|
3212
|
+
for (let i = 0; i < pad.length; i++) pad[i] ^= 54;
|
|
3213
|
+
this.iHash.update(pad);
|
|
3214
|
+
this.oHash = hash.create();
|
|
3215
|
+
for (let i = 0; i < pad.length; i++) pad[i] ^= 106;
|
|
3216
|
+
this.oHash.update(pad);
|
|
3217
|
+
clean(pad);
|
|
3218
|
+
}
|
|
3219
|
+
update(buf) {
|
|
3220
|
+
aexists(this);
|
|
3221
|
+
this.iHash.update(buf);
|
|
3222
|
+
return this;
|
|
3223
|
+
}
|
|
3224
|
+
digestInto(out) {
|
|
3225
|
+
aexists(this);
|
|
3226
|
+
abytes(out, this.outputLen);
|
|
3227
|
+
this.finished = true;
|
|
3228
|
+
this.iHash.digestInto(out);
|
|
3229
|
+
this.oHash.update(out);
|
|
3230
|
+
this.oHash.digestInto(out);
|
|
3231
|
+
this.destroy();
|
|
3232
|
+
}
|
|
3233
|
+
digest() {
|
|
3234
|
+
const out = new Uint8Array(this.oHash.outputLen);
|
|
3235
|
+
this.digestInto(out);
|
|
3236
|
+
return out;
|
|
3237
|
+
}
|
|
3238
|
+
_cloneInto(to) {
|
|
3239
|
+
to || (to = Object.create(Object.getPrototypeOf(this), {}));
|
|
3240
|
+
const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
|
|
3241
|
+
to = to;
|
|
3242
|
+
to.finished = finished;
|
|
3243
|
+
to.destroyed = destroyed;
|
|
3244
|
+
to.blockLen = blockLen;
|
|
3245
|
+
to.outputLen = outputLen;
|
|
3246
|
+
to.oHash = oHash._cloneInto(to.oHash);
|
|
3247
|
+
to.iHash = iHash._cloneInto(to.iHash);
|
|
3248
|
+
return to;
|
|
3249
|
+
}
|
|
3250
|
+
clone() {
|
|
3251
|
+
return this._cloneInto();
|
|
3252
|
+
}
|
|
3253
|
+
destroy() {
|
|
3254
|
+
this.destroyed = true;
|
|
3255
|
+
this.oHash.destroy();
|
|
3256
|
+
this.iHash.destroy();
|
|
3257
|
+
}
|
|
3258
|
+
};
|
|
3259
|
+
/**
|
|
3260
|
+
* HMAC: RFC2104 message authentication code.
|
|
3261
|
+
* @param hash - function that would be used e.g. sha256
|
|
3262
|
+
* @param key - message key
|
|
3263
|
+
* @param message - message data
|
|
3264
|
+
* @example
|
|
3265
|
+
* import { hmac } from '@noble/hashes/hmac';
|
|
3266
|
+
* import { sha256 } from '@noble/hashes/sha2';
|
|
3267
|
+
* const mac1 = hmac(sha256, 'key', 'message');
|
|
3268
|
+
*/
|
|
3269
|
+
const hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest();
|
|
3270
|
+
hmac.create = (hash, key) => new HMAC(hash, key);
|
|
3271
|
+
//#endregion
|
|
3272
|
+
//#region ../../node_modules/@noble/hashes/esm/hkdf.js
|
|
3273
|
+
/**
|
|
3274
|
+
* HKDF (RFC 5869): extract + expand in one step.
|
|
3275
|
+
* See https://soatok.blog/2021/11/17/understanding-hkdf/.
|
|
3276
|
+
* @module
|
|
3277
|
+
*/
|
|
3278
|
+
/**
|
|
3279
|
+
* HKDF-extract from spec. Less important part. `HKDF-Extract(IKM, salt) -> PRK`
|
|
3280
|
+
* Arguments position differs from spec (IKM is first one, since it is not optional)
|
|
3281
|
+
* @param hash - hash function that would be used (e.g. sha256)
|
|
3282
|
+
* @param ikm - input keying material, the initial key
|
|
3283
|
+
* @param salt - optional salt value (a non-secret random value)
|
|
3284
|
+
*/
|
|
3285
|
+
function extract(hash, ikm, salt) {
|
|
3286
|
+
ahash(hash);
|
|
3287
|
+
if (salt === void 0) salt = new Uint8Array(hash.outputLen);
|
|
3288
|
+
return hmac(hash, toBytes(salt), toBytes(ikm));
|
|
3289
|
+
}
|
|
3290
|
+
const HKDF_COUNTER = /* @__PURE__ */ Uint8Array.from([0]);
|
|
3291
|
+
const EMPTY_BUFFER = /* @__PURE__ */ Uint8Array.of();
|
|
3292
|
+
/**
|
|
3293
|
+
* HKDF-expand from the spec. The most important part. `HKDF-Expand(PRK, info, L) -> OKM`
|
|
3294
|
+
* @param hash - hash function that would be used (e.g. sha256)
|
|
3295
|
+
* @param prk - a pseudorandom key of at least HashLen octets (usually, the output from the extract step)
|
|
3296
|
+
* @param info - optional context and application specific information (can be a zero-length string)
|
|
3297
|
+
* @param length - length of output keying material in bytes
|
|
3298
|
+
*/
|
|
3299
|
+
function expand(hash, prk, info, length = 32) {
|
|
3300
|
+
ahash(hash);
|
|
3301
|
+
anumber(length);
|
|
3302
|
+
const olen = hash.outputLen;
|
|
3303
|
+
if (length > 255 * olen) throw new Error("Length should be <= 255*HashLen");
|
|
3304
|
+
const blocks = Math.ceil(length / olen);
|
|
3305
|
+
if (info === void 0) info = EMPTY_BUFFER;
|
|
3306
|
+
const okm = new Uint8Array(blocks * olen);
|
|
3307
|
+
const HMAC = hmac.create(hash, prk);
|
|
3308
|
+
const HMACTmp = HMAC._cloneInto();
|
|
3309
|
+
const T = new Uint8Array(HMAC.outputLen);
|
|
3310
|
+
for (let counter = 0; counter < blocks; counter++) {
|
|
3311
|
+
HKDF_COUNTER[0] = counter + 1;
|
|
3312
|
+
HMACTmp.update(counter === 0 ? EMPTY_BUFFER : T).update(info).update(HKDF_COUNTER).digestInto(T);
|
|
3313
|
+
okm.set(T, olen * counter);
|
|
3314
|
+
HMAC._cloneInto(HMACTmp);
|
|
3315
|
+
}
|
|
3316
|
+
HMAC.destroy();
|
|
3317
|
+
HMACTmp.destroy();
|
|
3318
|
+
clean(T, HKDF_COUNTER);
|
|
3319
|
+
return okm.slice(0, length);
|
|
3320
|
+
}
|
|
3321
|
+
/**
|
|
3322
|
+
* HKDF (RFC 5869): derive keys from an initial input.
|
|
3323
|
+
* Combines hkdf_extract + hkdf_expand in one step
|
|
3324
|
+
* @param hash - hash function that would be used (e.g. sha256)
|
|
3325
|
+
* @param ikm - input keying material, the initial key
|
|
3326
|
+
* @param salt - optional salt value (a non-secret random value)
|
|
3327
|
+
* @param info - optional context and application specific information (can be a zero-length string)
|
|
3328
|
+
* @param length - length of output keying material in bytes
|
|
3329
|
+
* @example
|
|
3330
|
+
* import { hkdf } from '@noble/hashes/hkdf';
|
|
3331
|
+
* import { sha256 } from '@noble/hashes/sha2';
|
|
3332
|
+
* import { randomBytes } from '@noble/hashes/utils';
|
|
3333
|
+
* const inputKey = randomBytes(32);
|
|
3334
|
+
* const salt = randomBytes(32);
|
|
3335
|
+
* const info = 'application-key';
|
|
3336
|
+
* const hk1 = hkdf(sha256, inputKey, salt, info, 32);
|
|
3337
|
+
*/
|
|
3338
|
+
const hkdf = (hash, ikm, salt, info, length) => expand(hash, extract(hash, ikm, salt), info, length);
|
|
3339
|
+
//#endregion
|
|
3340
|
+
//#region ../../node_modules/@noble/hashes/esm/sha2.js
|
|
3341
|
+
/**
|
|
3342
|
+
* SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256.
|
|
3343
|
+
* SHA256 is the fastest hash implementable in JS, even faster than Blake3.
|
|
3344
|
+
* Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and
|
|
3345
|
+
* [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).
|
|
3346
|
+
* @module
|
|
3347
|
+
*/
|
|
3348
|
+
/**
|
|
3349
|
+
* Round constants:
|
|
3350
|
+
* First 32 bits of fractional parts of the cube roots of the first 64 primes 2..311)
|
|
3351
|
+
*/
|
|
3352
|
+
const SHA256_K = /* @__PURE__ */ Uint32Array.from([
|
|
3353
|
+
1116352408,
|
|
3354
|
+
1899447441,
|
|
3355
|
+
3049323471,
|
|
3356
|
+
3921009573,
|
|
3357
|
+
961987163,
|
|
3358
|
+
1508970993,
|
|
3359
|
+
2453635748,
|
|
3360
|
+
2870763221,
|
|
3361
|
+
3624381080,
|
|
3362
|
+
310598401,
|
|
3363
|
+
607225278,
|
|
3364
|
+
1426881987,
|
|
3365
|
+
1925078388,
|
|
3366
|
+
2162078206,
|
|
3367
|
+
2614888103,
|
|
3368
|
+
3248222580,
|
|
3369
|
+
3835390401,
|
|
3370
|
+
4022224774,
|
|
3371
|
+
264347078,
|
|
3372
|
+
604807628,
|
|
3373
|
+
770255983,
|
|
3374
|
+
1249150122,
|
|
3375
|
+
1555081692,
|
|
3376
|
+
1996064986,
|
|
3377
|
+
2554220882,
|
|
3378
|
+
2821834349,
|
|
3379
|
+
2952996808,
|
|
3380
|
+
3210313671,
|
|
3381
|
+
3336571891,
|
|
3382
|
+
3584528711,
|
|
3383
|
+
113926993,
|
|
3384
|
+
338241895,
|
|
3385
|
+
666307205,
|
|
3386
|
+
773529912,
|
|
3387
|
+
1294757372,
|
|
3388
|
+
1396182291,
|
|
3389
|
+
1695183700,
|
|
3390
|
+
1986661051,
|
|
3391
|
+
2177026350,
|
|
3392
|
+
2456956037,
|
|
3393
|
+
2730485921,
|
|
3394
|
+
2820302411,
|
|
3395
|
+
3259730800,
|
|
3396
|
+
3345764771,
|
|
3397
|
+
3516065817,
|
|
3398
|
+
3600352804,
|
|
3399
|
+
4094571909,
|
|
3400
|
+
275423344,
|
|
3401
|
+
430227734,
|
|
3402
|
+
506948616,
|
|
3403
|
+
659060556,
|
|
3404
|
+
883997877,
|
|
3405
|
+
958139571,
|
|
3406
|
+
1322822218,
|
|
3407
|
+
1537002063,
|
|
3408
|
+
1747873779,
|
|
3409
|
+
1955562222,
|
|
3410
|
+
2024104815,
|
|
3411
|
+
2227730452,
|
|
3412
|
+
2361852424,
|
|
3413
|
+
2428436474,
|
|
3414
|
+
2756734187,
|
|
3415
|
+
3204031479,
|
|
3416
|
+
3329325298
|
|
3417
|
+
]);
|
|
3418
|
+
/** Reusable temporary buffer. "W" comes straight from spec. */
|
|
3419
|
+
const SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
3420
|
+
var SHA256 = class extends HashMD {
|
|
3421
|
+
constructor(outputLen = 32) {
|
|
3422
|
+
super(64, outputLen, 8, false);
|
|
3423
|
+
this.A = SHA256_IV[0] | 0;
|
|
3424
|
+
this.B = SHA256_IV[1] | 0;
|
|
3425
|
+
this.C = SHA256_IV[2] | 0;
|
|
3426
|
+
this.D = SHA256_IV[3] | 0;
|
|
3427
|
+
this.E = SHA256_IV[4] | 0;
|
|
3428
|
+
this.F = SHA256_IV[5] | 0;
|
|
3429
|
+
this.G = SHA256_IV[6] | 0;
|
|
3430
|
+
this.H = SHA256_IV[7] | 0;
|
|
3431
|
+
}
|
|
3432
|
+
get() {
|
|
3433
|
+
const { A, B, C, D, E, F, G, H } = this;
|
|
3434
|
+
return [
|
|
3435
|
+
A,
|
|
3436
|
+
B,
|
|
3437
|
+
C,
|
|
3438
|
+
D,
|
|
3439
|
+
E,
|
|
3440
|
+
F,
|
|
3441
|
+
G,
|
|
3442
|
+
H
|
|
3443
|
+
];
|
|
3444
|
+
}
|
|
3445
|
+
set(A, B, C, D, E, F, G, H) {
|
|
3446
|
+
this.A = A | 0;
|
|
3447
|
+
this.B = B | 0;
|
|
3448
|
+
this.C = C | 0;
|
|
3449
|
+
this.D = D | 0;
|
|
3450
|
+
this.E = E | 0;
|
|
3451
|
+
this.F = F | 0;
|
|
3452
|
+
this.G = G | 0;
|
|
3453
|
+
this.H = H | 0;
|
|
3454
|
+
}
|
|
3455
|
+
process(view, offset) {
|
|
3456
|
+
for (let i = 0; i < 16; i++, offset += 4) SHA256_W[i] = view.getUint32(offset, false);
|
|
3457
|
+
for (let i = 16; i < 64; i++) {
|
|
3458
|
+
const W15 = SHA256_W[i - 15];
|
|
3459
|
+
const W2 = SHA256_W[i - 2];
|
|
3460
|
+
const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
|
|
3461
|
+
SHA256_W[i] = (rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10) + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
|
|
3462
|
+
}
|
|
3463
|
+
let { A, B, C, D, E, F, G, H } = this;
|
|
3464
|
+
for (let i = 0; i < 64; i++) {
|
|
3465
|
+
const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
|
|
3466
|
+
const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
|
|
3467
|
+
const T2 = (rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22)) + Maj(A, B, C) | 0;
|
|
3468
|
+
H = G;
|
|
3469
|
+
G = F;
|
|
3470
|
+
F = E;
|
|
3471
|
+
E = D + T1 | 0;
|
|
3472
|
+
D = C;
|
|
3473
|
+
C = B;
|
|
3474
|
+
B = A;
|
|
3475
|
+
A = T1 + T2 | 0;
|
|
3476
|
+
}
|
|
3477
|
+
A = A + this.A | 0;
|
|
3478
|
+
B = B + this.B | 0;
|
|
3479
|
+
C = C + this.C | 0;
|
|
3480
|
+
D = D + this.D | 0;
|
|
3481
|
+
E = E + this.E | 0;
|
|
3482
|
+
F = F + this.F | 0;
|
|
3483
|
+
G = G + this.G | 0;
|
|
3484
|
+
H = H + this.H | 0;
|
|
3485
|
+
this.set(A, B, C, D, E, F, G, H);
|
|
3486
|
+
}
|
|
3487
|
+
roundClean() {
|
|
3488
|
+
clean(SHA256_W);
|
|
3489
|
+
}
|
|
3490
|
+
destroy() {
|
|
3491
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
3492
|
+
clean(this.buffer);
|
|
3493
|
+
}
|
|
3494
|
+
};
|
|
3495
|
+
const K512 = split([
|
|
3496
|
+
"0x428a2f98d728ae22",
|
|
3497
|
+
"0x7137449123ef65cd",
|
|
3498
|
+
"0xb5c0fbcfec4d3b2f",
|
|
3499
|
+
"0xe9b5dba58189dbbc",
|
|
3500
|
+
"0x3956c25bf348b538",
|
|
3501
|
+
"0x59f111f1b605d019",
|
|
3502
|
+
"0x923f82a4af194f9b",
|
|
3503
|
+
"0xab1c5ed5da6d8118",
|
|
3504
|
+
"0xd807aa98a3030242",
|
|
3505
|
+
"0x12835b0145706fbe",
|
|
3506
|
+
"0x243185be4ee4b28c",
|
|
3507
|
+
"0x550c7dc3d5ffb4e2",
|
|
3508
|
+
"0x72be5d74f27b896f",
|
|
3509
|
+
"0x80deb1fe3b1696b1",
|
|
3510
|
+
"0x9bdc06a725c71235",
|
|
3511
|
+
"0xc19bf174cf692694",
|
|
3512
|
+
"0xe49b69c19ef14ad2",
|
|
3513
|
+
"0xefbe4786384f25e3",
|
|
3514
|
+
"0x0fc19dc68b8cd5b5",
|
|
3515
|
+
"0x240ca1cc77ac9c65",
|
|
3516
|
+
"0x2de92c6f592b0275",
|
|
3517
|
+
"0x4a7484aa6ea6e483",
|
|
3518
|
+
"0x5cb0a9dcbd41fbd4",
|
|
3519
|
+
"0x76f988da831153b5",
|
|
3520
|
+
"0x983e5152ee66dfab",
|
|
3521
|
+
"0xa831c66d2db43210",
|
|
3522
|
+
"0xb00327c898fb213f",
|
|
3523
|
+
"0xbf597fc7beef0ee4",
|
|
3524
|
+
"0xc6e00bf33da88fc2",
|
|
3525
|
+
"0xd5a79147930aa725",
|
|
3526
|
+
"0x06ca6351e003826f",
|
|
3527
|
+
"0x142929670a0e6e70",
|
|
3528
|
+
"0x27b70a8546d22ffc",
|
|
3529
|
+
"0x2e1b21385c26c926",
|
|
3530
|
+
"0x4d2c6dfc5ac42aed",
|
|
3531
|
+
"0x53380d139d95b3df",
|
|
3532
|
+
"0x650a73548baf63de",
|
|
3533
|
+
"0x766a0abb3c77b2a8",
|
|
3534
|
+
"0x81c2c92e47edaee6",
|
|
3535
|
+
"0x92722c851482353b",
|
|
3536
|
+
"0xa2bfe8a14cf10364",
|
|
3537
|
+
"0xa81a664bbc423001",
|
|
3538
|
+
"0xc24b8b70d0f89791",
|
|
3539
|
+
"0xc76c51a30654be30",
|
|
3540
|
+
"0xd192e819d6ef5218",
|
|
3541
|
+
"0xd69906245565a910",
|
|
3542
|
+
"0xf40e35855771202a",
|
|
3543
|
+
"0x106aa07032bbd1b8",
|
|
3544
|
+
"0x19a4c116b8d2d0c8",
|
|
3545
|
+
"0x1e376c085141ab53",
|
|
3546
|
+
"0x2748774cdf8eeb99",
|
|
3547
|
+
"0x34b0bcb5e19b48a8",
|
|
3548
|
+
"0x391c0cb3c5c95a63",
|
|
3549
|
+
"0x4ed8aa4ae3418acb",
|
|
3550
|
+
"0x5b9cca4f7763e373",
|
|
3551
|
+
"0x682e6ff3d6b2b8a3",
|
|
3552
|
+
"0x748f82ee5defb2fc",
|
|
3553
|
+
"0x78a5636f43172f60",
|
|
3554
|
+
"0x84c87814a1f0ab72",
|
|
3555
|
+
"0x8cc702081a6439ec",
|
|
3556
|
+
"0x90befffa23631e28",
|
|
3557
|
+
"0xa4506cebde82bde9",
|
|
3558
|
+
"0xbef9a3f7b2c67915",
|
|
3559
|
+
"0xc67178f2e372532b",
|
|
3560
|
+
"0xca273eceea26619c",
|
|
3561
|
+
"0xd186b8c721c0c207",
|
|
3562
|
+
"0xeada7dd6cde0eb1e",
|
|
3563
|
+
"0xf57d4f7fee6ed178",
|
|
3564
|
+
"0x06f067aa72176fba",
|
|
3565
|
+
"0x0a637dc5a2c898a6",
|
|
3566
|
+
"0x113f9804bef90dae",
|
|
3567
|
+
"0x1b710b35131c471b",
|
|
3568
|
+
"0x28db77f523047d84",
|
|
3569
|
+
"0x32caab7b40c72493",
|
|
3570
|
+
"0x3c9ebe0a15c9bebc",
|
|
3571
|
+
"0x431d67c49c100d4c",
|
|
3572
|
+
"0x4cc5d4becb3e42b6",
|
|
3573
|
+
"0x597f299cfc657e2a",
|
|
3574
|
+
"0x5fcb6fab3ad6faec",
|
|
3575
|
+
"0x6c44198c4a475817"
|
|
3576
|
+
].map((n) => BigInt(n)));
|
|
3577
|
+
const SHA512_Kh = K512[0];
|
|
3578
|
+
const SHA512_Kl = K512[1];
|
|
3579
|
+
const SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);
|
|
3580
|
+
const SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);
|
|
3581
|
+
var SHA512 = class extends HashMD {
|
|
3582
|
+
constructor(outputLen = 64) {
|
|
3583
|
+
super(128, outputLen, 16, false);
|
|
3584
|
+
this.Ah = SHA512_IV[0] | 0;
|
|
3585
|
+
this.Al = SHA512_IV[1] | 0;
|
|
3586
|
+
this.Bh = SHA512_IV[2] | 0;
|
|
3587
|
+
this.Bl = SHA512_IV[3] | 0;
|
|
3588
|
+
this.Ch = SHA512_IV[4] | 0;
|
|
3589
|
+
this.Cl = SHA512_IV[5] | 0;
|
|
3590
|
+
this.Dh = SHA512_IV[6] | 0;
|
|
3591
|
+
this.Dl = SHA512_IV[7] | 0;
|
|
3592
|
+
this.Eh = SHA512_IV[8] | 0;
|
|
3593
|
+
this.El = SHA512_IV[9] | 0;
|
|
3594
|
+
this.Fh = SHA512_IV[10] | 0;
|
|
3595
|
+
this.Fl = SHA512_IV[11] | 0;
|
|
3596
|
+
this.Gh = SHA512_IV[12] | 0;
|
|
3597
|
+
this.Gl = SHA512_IV[13] | 0;
|
|
3598
|
+
this.Hh = SHA512_IV[14] | 0;
|
|
3599
|
+
this.Hl = SHA512_IV[15] | 0;
|
|
3600
|
+
}
|
|
3601
|
+
get() {
|
|
3602
|
+
const { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
|
|
3603
|
+
return [
|
|
3604
|
+
Ah,
|
|
3605
|
+
Al,
|
|
3606
|
+
Bh,
|
|
3607
|
+
Bl,
|
|
3608
|
+
Ch,
|
|
3609
|
+
Cl,
|
|
3610
|
+
Dh,
|
|
3611
|
+
Dl,
|
|
3612
|
+
Eh,
|
|
3613
|
+
El,
|
|
3614
|
+
Fh,
|
|
3615
|
+
Fl,
|
|
3616
|
+
Gh,
|
|
3617
|
+
Gl,
|
|
3618
|
+
Hh,
|
|
3619
|
+
Hl
|
|
3620
|
+
];
|
|
3621
|
+
}
|
|
3622
|
+
set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl) {
|
|
3623
|
+
this.Ah = Ah | 0;
|
|
3624
|
+
this.Al = Al | 0;
|
|
3625
|
+
this.Bh = Bh | 0;
|
|
3626
|
+
this.Bl = Bl | 0;
|
|
3627
|
+
this.Ch = Ch | 0;
|
|
3628
|
+
this.Cl = Cl | 0;
|
|
3629
|
+
this.Dh = Dh | 0;
|
|
3630
|
+
this.Dl = Dl | 0;
|
|
3631
|
+
this.Eh = Eh | 0;
|
|
3632
|
+
this.El = El | 0;
|
|
3633
|
+
this.Fh = Fh | 0;
|
|
3634
|
+
this.Fl = Fl | 0;
|
|
3635
|
+
this.Gh = Gh | 0;
|
|
3636
|
+
this.Gl = Gl | 0;
|
|
3637
|
+
this.Hh = Hh | 0;
|
|
3638
|
+
this.Hl = Hl | 0;
|
|
3639
|
+
}
|
|
3640
|
+
process(view, offset) {
|
|
3641
|
+
for (let i = 0; i < 16; i++, offset += 4) {
|
|
3642
|
+
SHA512_W_H[i] = view.getUint32(offset);
|
|
3643
|
+
SHA512_W_L[i] = view.getUint32(offset += 4);
|
|
3644
|
+
}
|
|
3645
|
+
for (let i = 16; i < 80; i++) {
|
|
3646
|
+
const W15h = SHA512_W_H[i - 15] | 0;
|
|
3647
|
+
const W15l = SHA512_W_L[i - 15] | 0;
|
|
3648
|
+
const s0h = rotrSH(W15h, W15l, 1) ^ rotrSH(W15h, W15l, 8) ^ shrSH(W15h, W15l, 7);
|
|
3649
|
+
const s0l = rotrSL(W15h, W15l, 1) ^ rotrSL(W15h, W15l, 8) ^ shrSL(W15h, W15l, 7);
|
|
3650
|
+
const W2h = SHA512_W_H[i - 2] | 0;
|
|
3651
|
+
const W2l = SHA512_W_L[i - 2] | 0;
|
|
3652
|
+
const s1h = rotrSH(W2h, W2l, 19) ^ rotrBH(W2h, W2l, 61) ^ shrSH(W2h, W2l, 6);
|
|
3653
|
+
const SUMl = add4L(s0l, rotrSL(W2h, W2l, 19) ^ rotrBL(W2h, W2l, 61) ^ shrSL(W2h, W2l, 6), SHA512_W_L[i - 7], SHA512_W_L[i - 16]);
|
|
3654
|
+
SHA512_W_H[i] = add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]) | 0;
|
|
3655
|
+
SHA512_W_L[i] = SUMl | 0;
|
|
3656
|
+
}
|
|
3657
|
+
let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
|
|
3658
|
+
for (let i = 0; i < 80; i++) {
|
|
3659
|
+
const sigma1h = rotrSH(Eh, El, 14) ^ rotrSH(Eh, El, 18) ^ rotrBH(Eh, El, 41);
|
|
3660
|
+
const sigma1l = rotrSL(Eh, El, 14) ^ rotrSL(Eh, El, 18) ^ rotrBL(Eh, El, 41);
|
|
3661
|
+
const CHIh = Eh & Fh ^ ~Eh & Gh;
|
|
3662
|
+
const CHIl = El & Fl ^ ~El & Gl;
|
|
3663
|
+
const T1ll = add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);
|
|
3664
|
+
const T1h = add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);
|
|
3665
|
+
const T1l = T1ll | 0;
|
|
3666
|
+
const sigma0h = rotrSH(Ah, Al, 28) ^ rotrBH(Ah, Al, 34) ^ rotrBH(Ah, Al, 39);
|
|
3667
|
+
const sigma0l = rotrSL(Ah, Al, 28) ^ rotrBL(Ah, Al, 34) ^ rotrBL(Ah, Al, 39);
|
|
3668
|
+
const MAJh = Ah & Bh ^ Ah & Ch ^ Bh & Ch;
|
|
3669
|
+
const MAJl = Al & Bl ^ Al & Cl ^ Bl & Cl;
|
|
3670
|
+
Hh = Gh | 0;
|
|
3671
|
+
Hl = Gl | 0;
|
|
3672
|
+
Gh = Fh | 0;
|
|
3673
|
+
Gl = Fl | 0;
|
|
3674
|
+
Fh = Eh | 0;
|
|
3675
|
+
Fl = El | 0;
|
|
3676
|
+
({h: Eh, l: El} = add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));
|
|
3677
|
+
Dh = Ch | 0;
|
|
3678
|
+
Dl = Cl | 0;
|
|
3679
|
+
Ch = Bh | 0;
|
|
3680
|
+
Cl = Bl | 0;
|
|
3681
|
+
Bh = Ah | 0;
|
|
3682
|
+
Bl = Al | 0;
|
|
3683
|
+
const All = add3L(T1l, sigma0l, MAJl);
|
|
3684
|
+
Ah = add3H(All, T1h, sigma0h, MAJh);
|
|
3685
|
+
Al = All | 0;
|
|
3686
|
+
}
|
|
3687
|
+
({h: Ah, l: Al} = add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));
|
|
3688
|
+
({h: Bh, l: Bl} = add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));
|
|
3689
|
+
({h: Ch, l: Cl} = add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));
|
|
3690
|
+
({h: Dh, l: Dl} = add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));
|
|
3691
|
+
({h: Eh, l: El} = add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));
|
|
3692
|
+
({h: Fh, l: Fl} = add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));
|
|
3693
|
+
({h: Gh, l: Gl} = add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));
|
|
3694
|
+
({h: Hh, l: Hl} = add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));
|
|
3695
|
+
this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);
|
|
3696
|
+
}
|
|
3697
|
+
roundClean() {
|
|
3698
|
+
clean(SHA512_W_H, SHA512_W_L);
|
|
3699
|
+
}
|
|
3700
|
+
destroy() {
|
|
3701
|
+
clean(this.buffer);
|
|
3702
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
3703
|
+
}
|
|
3704
|
+
};
|
|
3705
|
+
/**
|
|
3706
|
+
* SHA2-256 hash function from RFC 4634.
|
|
3707
|
+
*
|
|
3708
|
+
* It is the fastest JS hash, even faster than Blake3.
|
|
3709
|
+
* To break sha256 using birthday attack, attackers need to try 2^128 hashes.
|
|
3710
|
+
* BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.
|
|
3711
|
+
*/
|
|
3712
|
+
const sha256 = /* @__PURE__ */ createHasher(() => new SHA256());
|
|
3713
|
+
/** SHA2-512 hash function from RFC 4634. */
|
|
3714
|
+
const sha512 = /* @__PURE__ */ createHasher(() => new SHA512());
|
|
3715
|
+
//#endregion
|
|
3716
|
+
//#region ../../node_modules/@noble/hashes/esm/pbkdf2.js
|
|
3717
|
+
/**
|
|
3718
|
+
* PBKDF (RFC 2898). Can be used to create a key from password and salt.
|
|
3719
|
+
* @module
|
|
3720
|
+
*/
|
|
3721
|
+
function pbkdf2Init(hash, _password, _salt, _opts) {
|
|
3722
|
+
ahash(hash);
|
|
3723
|
+
const { c, dkLen, asyncTick } = checkOpts({
|
|
3724
|
+
dkLen: 32,
|
|
3725
|
+
asyncTick: 10
|
|
3726
|
+
}, _opts);
|
|
3727
|
+
anumber(c);
|
|
3728
|
+
anumber(dkLen);
|
|
3729
|
+
anumber(asyncTick);
|
|
3730
|
+
if (c < 1) throw new Error("iterations (c) should be >= 1");
|
|
3731
|
+
const password = kdfInputToBytes(_password);
|
|
3732
|
+
const salt = kdfInputToBytes(_salt);
|
|
3733
|
+
const DK = new Uint8Array(dkLen);
|
|
3734
|
+
const PRF = hmac.create(hash, password);
|
|
3735
|
+
return {
|
|
3736
|
+
c,
|
|
3737
|
+
dkLen,
|
|
3738
|
+
asyncTick,
|
|
3739
|
+
DK,
|
|
3740
|
+
PRF,
|
|
3741
|
+
PRFSalt: PRF._cloneInto().update(salt)
|
|
3742
|
+
};
|
|
3743
|
+
}
|
|
3744
|
+
function pbkdf2Output(PRF, PRFSalt, DK, prfW, u) {
|
|
3745
|
+
PRF.destroy();
|
|
3746
|
+
PRFSalt.destroy();
|
|
3747
|
+
if (prfW) prfW.destroy();
|
|
3748
|
+
clean(u);
|
|
3749
|
+
return DK;
|
|
3750
|
+
}
|
|
3751
|
+
/**
|
|
3752
|
+
* PBKDF2-HMAC: RFC 2898 key derivation function
|
|
3753
|
+
* @param hash - hash function that would be used e.g. sha256
|
|
3754
|
+
* @param password - password from which a derived key is generated
|
|
3755
|
+
* @param salt - cryptographic salt
|
|
3756
|
+
* @param opts - {c, dkLen} where c is work factor and dkLen is output message size
|
|
3757
|
+
* @example
|
|
3758
|
+
* const key = pbkdf2(sha256, 'password', 'salt', { dkLen: 32, c: Math.pow(2, 18) });
|
|
3759
|
+
*/
|
|
3760
|
+
function pbkdf2(hash, password, salt, opts) {
|
|
3761
|
+
const { c, dkLen, DK, PRF, PRFSalt } = pbkdf2Init(hash, password, salt, opts);
|
|
3762
|
+
let prfW;
|
|
3763
|
+
const arr = new Uint8Array(4);
|
|
3764
|
+
const view = createView(arr);
|
|
3765
|
+
const u = new Uint8Array(PRF.outputLen);
|
|
3766
|
+
for (let ti = 1, pos = 0; pos < dkLen; ti++, pos += PRF.outputLen) {
|
|
3767
|
+
const Ti = DK.subarray(pos, pos + PRF.outputLen);
|
|
3768
|
+
view.setInt32(0, ti, false);
|
|
3769
|
+
(prfW = PRFSalt._cloneInto(prfW)).update(arr).digestInto(u);
|
|
3770
|
+
Ti.set(u.subarray(0, Ti.length));
|
|
3771
|
+
for (let ui = 1; ui < c; ui++) {
|
|
3772
|
+
PRF._cloneInto(prfW).update(u).digestInto(u);
|
|
3773
|
+
for (let i = 0; i < Ti.length; i++) Ti[i] ^= u[i];
|
|
3774
|
+
}
|
|
3775
|
+
}
|
|
3776
|
+
return pbkdf2Output(PRF, PRFSalt, DK, prfW, u);
|
|
3777
|
+
}
|
|
3778
|
+
//#endregion
|
|
3779
|
+
//#region ../../node_modules/@noble/hashes/sha512.js
|
|
3780
|
+
var require_sha512 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
3781
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3782
|
+
exports.sha512_256 = exports.SHA512_256 = exports.sha512_224 = exports.SHA512_224 = exports.sha384 = exports.SHA384 = exports.sha512 = exports.SHA512 = void 0;
|
|
3783
|
+
/**
|
|
3784
|
+
* SHA2-512 a.k.a. sha512 and sha384. It is slower than sha256 in js because u64 operations are slow.
|
|
3785
|
+
*
|
|
3786
|
+
* Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and
|
|
3787
|
+
* [the paper on truncated SHA512/256](https://eprint.iacr.org/2010/548.pdf).
|
|
3788
|
+
* @module
|
|
3789
|
+
* @deprecated
|
|
3790
|
+
*/
|
|
3791
|
+
const sha2_ts_1 = require_sha2();
|
|
3792
|
+
/** @deprecated Use import from `noble/hashes/sha2` module */
|
|
3793
|
+
exports.SHA512 = sha2_ts_1.SHA512;
|
|
3794
|
+
/** @deprecated Use import from `noble/hashes/sha2` module */
|
|
3795
|
+
exports.sha512 = sha2_ts_1.sha512;
|
|
3796
|
+
/** @deprecated Use import from `noble/hashes/sha2` module */
|
|
3797
|
+
exports.SHA384 = sha2_ts_1.SHA384;
|
|
3798
|
+
/** @deprecated Use import from `noble/hashes/sha2` module */
|
|
3799
|
+
exports.sha384 = sha2_ts_1.sha384;
|
|
3800
|
+
/** @deprecated Use import from `noble/hashes/sha2` module */
|
|
3801
|
+
exports.SHA512_224 = sha2_ts_1.SHA512_224;
|
|
3802
|
+
/** @deprecated Use import from `noble/hashes/sha2` module */
|
|
3803
|
+
exports.sha512_224 = sha2_ts_1.sha512_224;
|
|
3804
|
+
/** @deprecated Use import from `noble/hashes/sha2` module */
|
|
3805
|
+
exports.SHA512_256 = sha2_ts_1.SHA512_256;
|
|
3806
|
+
/** @deprecated Use import from `noble/hashes/sha2` module */
|
|
3807
|
+
exports.sha512_256 = sha2_ts_1.sha512_256;
|
|
3808
|
+
}));
|
|
3809
|
+
//#endregion
|
|
3810
|
+
//#region ../../node_modules/@noble/hashes/pbkdf2.js
|
|
3811
|
+
var require_pbkdf2 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
3812
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3813
|
+
exports.pbkdf2 = pbkdf2;
|
|
3814
|
+
exports.pbkdf2Async = pbkdf2Async;
|
|
3815
|
+
/**
|
|
3816
|
+
* PBKDF (RFC 2898). Can be used to create a key from password and salt.
|
|
3817
|
+
* @module
|
|
3818
|
+
*/
|
|
3819
|
+
const hmac_ts_1 = require_hmac();
|
|
3820
|
+
const utils_ts_1 = require_utils();
|
|
3821
|
+
function pbkdf2Init(hash, _password, _salt, _opts) {
|
|
3822
|
+
(0, utils_ts_1.ahash)(hash);
|
|
3823
|
+
const { c, dkLen, asyncTick } = (0, utils_ts_1.checkOpts)({
|
|
3824
|
+
dkLen: 32,
|
|
3825
|
+
asyncTick: 10
|
|
3826
|
+
}, _opts);
|
|
3827
|
+
(0, utils_ts_1.anumber)(c);
|
|
3828
|
+
(0, utils_ts_1.anumber)(dkLen);
|
|
3829
|
+
(0, utils_ts_1.anumber)(asyncTick);
|
|
3830
|
+
if (c < 1) throw new Error("iterations (c) should be >= 1");
|
|
3831
|
+
const password = (0, utils_ts_1.kdfInputToBytes)(_password);
|
|
3832
|
+
const salt = (0, utils_ts_1.kdfInputToBytes)(_salt);
|
|
3833
|
+
const DK = new Uint8Array(dkLen);
|
|
3834
|
+
const PRF = hmac_ts_1.hmac.create(hash, password);
|
|
3835
|
+
return {
|
|
3836
|
+
c,
|
|
3837
|
+
dkLen,
|
|
3838
|
+
asyncTick,
|
|
3839
|
+
DK,
|
|
3840
|
+
PRF,
|
|
3841
|
+
PRFSalt: PRF._cloneInto().update(salt)
|
|
3842
|
+
};
|
|
3843
|
+
}
|
|
3844
|
+
function pbkdf2Output(PRF, PRFSalt, DK, prfW, u) {
|
|
3845
|
+
PRF.destroy();
|
|
3846
|
+
PRFSalt.destroy();
|
|
3847
|
+
if (prfW) prfW.destroy();
|
|
3848
|
+
(0, utils_ts_1.clean)(u);
|
|
3849
|
+
return DK;
|
|
3850
|
+
}
|
|
3851
|
+
/**
|
|
3852
|
+
* PBKDF2-HMAC: RFC 2898 key derivation function
|
|
3853
|
+
* @param hash - hash function that would be used e.g. sha256
|
|
3854
|
+
* @param password - password from which a derived key is generated
|
|
3855
|
+
* @param salt - cryptographic salt
|
|
3856
|
+
* @param opts - {c, dkLen} where c is work factor and dkLen is output message size
|
|
3857
|
+
* @example
|
|
3858
|
+
* const key = pbkdf2(sha256, 'password', 'salt', { dkLen: 32, c: Math.pow(2, 18) });
|
|
3859
|
+
*/
|
|
3860
|
+
function pbkdf2(hash, password, salt, opts) {
|
|
3861
|
+
const { c, dkLen, DK, PRF, PRFSalt } = pbkdf2Init(hash, password, salt, opts);
|
|
3862
|
+
let prfW;
|
|
3863
|
+
const arr = new Uint8Array(4);
|
|
3864
|
+
const view = (0, utils_ts_1.createView)(arr);
|
|
3865
|
+
const u = new Uint8Array(PRF.outputLen);
|
|
3866
|
+
for (let ti = 1, pos = 0; pos < dkLen; ti++, pos += PRF.outputLen) {
|
|
3867
|
+
const Ti = DK.subarray(pos, pos + PRF.outputLen);
|
|
3868
|
+
view.setInt32(0, ti, false);
|
|
3869
|
+
(prfW = PRFSalt._cloneInto(prfW)).update(arr).digestInto(u);
|
|
3870
|
+
Ti.set(u.subarray(0, Ti.length));
|
|
3871
|
+
for (let ui = 1; ui < c; ui++) {
|
|
3872
|
+
PRF._cloneInto(prfW).update(u).digestInto(u);
|
|
3873
|
+
for (let i = 0; i < Ti.length; i++) Ti[i] ^= u[i];
|
|
3874
|
+
}
|
|
3875
|
+
}
|
|
3876
|
+
return pbkdf2Output(PRF, PRFSalt, DK, prfW, u);
|
|
3877
|
+
}
|
|
3878
|
+
/**
|
|
3879
|
+
* PBKDF2-HMAC: RFC 2898 key derivation function. Async version.
|
|
3880
|
+
* @example
|
|
3881
|
+
* await pbkdf2Async(sha256, 'password', 'salt', { dkLen: 32, c: 500_000 });
|
|
3882
|
+
*/
|
|
3883
|
+
async function pbkdf2Async(hash, password, salt, opts) {
|
|
3884
|
+
const { c, dkLen, asyncTick, DK, PRF, PRFSalt } = pbkdf2Init(hash, password, salt, opts);
|
|
3885
|
+
let prfW;
|
|
3886
|
+
const arr = new Uint8Array(4);
|
|
3887
|
+
const view = (0, utils_ts_1.createView)(arr);
|
|
3888
|
+
const u = new Uint8Array(PRF.outputLen);
|
|
3889
|
+
for (let ti = 1, pos = 0; pos < dkLen; ti++, pos += PRF.outputLen) {
|
|
3890
|
+
const Ti = DK.subarray(pos, pos + PRF.outputLen);
|
|
3891
|
+
view.setInt32(0, ti, false);
|
|
3892
|
+
(prfW = PRFSalt._cloneInto(prfW)).update(arr).digestInto(u);
|
|
3893
|
+
Ti.set(u.subarray(0, Ti.length));
|
|
3894
|
+
await (0, utils_ts_1.asyncLoop)(c - 1, asyncTick, () => {
|
|
3895
|
+
PRF._cloneInto(prfW).update(u).digestInto(u);
|
|
3896
|
+
for (let i = 0; i < Ti.length; i++) Ti[i] ^= u[i];
|
|
3897
|
+
});
|
|
3898
|
+
}
|
|
3899
|
+
return pbkdf2Output(PRF, PRFSalt, DK, prfW, u);
|
|
3900
|
+
}
|
|
3901
|
+
}));
|
|
3902
|
+
//#endregion
|
|
3903
|
+
export { utf8ToBytes as S, abytes as _, sha512 as a, hexToBytes as b, require_hmac as c, require_sha256 as d, require_sha2 as f, argon2idAsync as g, require_utils as h, sha256 as i, require_dist as l, require_ripemd160 as m, require_sha512 as n, hkdf as o, require_sha1 as p, pbkdf2 as r, hmac as s, require_pbkdf2 as t, require_bs58 as u, bytesToHex as v, randomBytes as x, concatBytes as y };
|