@cedros/login-react 0.0.11 → 0.0.13
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/README.md +68 -0
- package/dist/AdminDepositList-Cx0xRwES.js +305 -0
- package/dist/AdminDepositList-Cx0xRwES.js.map +1 -0
- package/dist/AdminDepositList-UEcyRZkA.cjs +1 -0
- package/dist/AdminDepositList-UEcyRZkA.cjs.map +1 -0
- package/dist/AdminUserDetail-BzEIdNJh.cjs +1 -0
- package/dist/AdminUserDetail-BzEIdNJh.cjs.map +1 -0
- package/dist/AdminUserDetail-DHFDzY8B.js +1195 -0
- package/dist/AdminUserDetail-DHFDzY8B.js.map +1 -0
- package/dist/AdminWithdrawalHistory-0yxtMh6q.cjs +1 -0
- package/dist/AdminWithdrawalHistory-0yxtMh6q.cjs.map +1 -0
- package/dist/AdminWithdrawalHistory-BGjfrIe3.js +904 -0
- package/dist/AdminWithdrawalHistory-BGjfrIe3.js.map +1 -0
- package/dist/AuthenticationSettings-5Vi7Ib_A.cjs +1 -0
- package/dist/AuthenticationSettings-5Vi7Ib_A.cjs.map +1 -0
- package/dist/AuthenticationSettings-BPAh1my6.cjs +1 -0
- package/dist/AuthenticationSettings-BPAh1my6.cjs.map +1 -0
- package/dist/AuthenticationSettings-CJg8CJY9.js +9 -0
- package/dist/AuthenticationSettings-CJg8CJY9.js.map +1 -0
- package/dist/AuthenticationSettings-CR_i6TTS.js +495 -0
- package/dist/AuthenticationSettings-CR_i6TTS.js.map +1 -0
- package/dist/AutosaveStatus-CYkC2aI_.cjs +1 -0
- package/dist/AutosaveStatus-CYkC2aI_.cjs.map +1 -0
- package/dist/AutosaveStatus-N4uNS6-2.js +1497 -0
- package/dist/AutosaveStatus-N4uNS6-2.js.map +1 -0
- package/dist/CreditSystemSettings-BnAOK_tT.cjs +1 -0
- package/dist/CreditSystemSettings-BnAOK_tT.cjs.map +1 -0
- package/dist/CreditSystemSettings-CIf_SfJq.js +210 -0
- package/dist/CreditSystemSettings-CIf_SfJq.js.map +1 -0
- package/dist/CreditSystemSettings-CePYGgev.js +9 -0
- package/dist/CreditSystemSettings-CePYGgev.js.map +1 -0
- package/dist/CreditSystemSettings-Ck5WIMp3.cjs +1 -0
- package/dist/CreditSystemSettings-Ck5WIMp3.cjs.map +1 -0
- package/dist/{DepositsSection-BH5K162Q.js → DepositsSection-DA89uR9A.js} +5 -5
- package/dist/{DepositsSection-BH5K162Q.js.map → DepositsSection-DA89uR9A.js.map} +1 -1
- package/dist/DepositsSection-i6XdhLNs.cjs +1 -0
- package/dist/{DepositsSection-DpRn0koq.cjs.map → DepositsSection-i6XdhLNs.cjs.map} +1 -1
- package/dist/EmailRegisterForm-BrDL3BZy.js +927 -0
- package/dist/EmailRegisterForm-BrDL3BZy.js.map +1 -0
- package/dist/EmailRegisterForm-CxktR-4J.cjs +1 -0
- package/dist/EmailRegisterForm-CxktR-4J.cjs.map +1 -0
- package/dist/EmailSettings-B8xwgd6_.cjs +1 -0
- package/dist/EmailSettings-B8xwgd6_.cjs.map +1 -0
- package/dist/{AuthenticationSettings-DlVILxY4.js → EmailSettings-Bna7Z53E.js} +3 -3
- package/dist/EmailSettings-Bna7Z53E.js.map +1 -0
- package/dist/EmailSettings-DZywTTRq.cjs +1 -0
- package/dist/EmailSettings-DZywTTRq.cjs.map +1 -0
- package/dist/EmailSettings-DbMDfVaM.js +17 -0
- package/dist/EmailSettings-DbMDfVaM.js.map +1 -0
- package/dist/{EmbeddedWalletSettings-Bff6raAT.js → EmbeddedWalletSettings-ANbhj3Lt.js} +3 -3
- package/dist/EmbeddedWalletSettings-ANbhj3Lt.js.map +1 -0
- package/dist/EmbeddedWalletSettings-BEztqO19.js +79 -0
- package/dist/EmbeddedWalletSettings-BEztqO19.js.map +1 -0
- package/dist/EmbeddedWalletSettings-D6M7pwgk.cjs +1 -0
- package/dist/EmbeddedWalletSettings-D6M7pwgk.cjs.map +1 -0
- package/dist/EmbeddedWalletSettings-DivEPn39.cjs +1 -0
- package/dist/EmbeddedWalletSettings-DivEPn39.cjs.map +1 -0
- package/dist/ErrorMessage-CHbYbVi2.cjs +1 -0
- package/dist/ErrorMessage-CHbYbVi2.cjs.map +1 -0
- package/dist/ErrorMessage-CcEK0pYO.js +64 -0
- package/dist/ErrorMessage-CcEK0pYO.js.map +1 -0
- package/dist/{GoogleLoginButton-BzHr545L.js → GoogleLoginButton-B3uRMJ_n.js} +4 -3
- package/dist/{GoogleLoginButton-BzHr545L.js.map → GoogleLoginButton-B3uRMJ_n.js.map} +1 -1
- package/dist/GoogleLoginButton-BydKswn4.cjs +1 -0
- package/dist/{GoogleLoginButton-DoAdOqb3.cjs.map → GoogleLoginButton-BydKswn4.cjs.map} +1 -1
- package/dist/LoadingSpinner-6vml-zwr.js +79 -0
- package/dist/LoadingSpinner-6vml-zwr.js.map +1 -0
- package/dist/LoadingSpinner-d6sSxgQN.cjs +1 -0
- package/dist/LoadingSpinner-d6sSxgQN.cjs.map +1 -0
- package/dist/PermissionsSection-BGaj_sI7.js +1026 -0
- package/dist/PermissionsSection-BGaj_sI7.js.map +1 -0
- package/dist/PermissionsSection-CKXXDfqi.cjs +1 -0
- package/dist/PermissionsSection-CKXXDfqi.cjs.map +1 -0
- package/dist/ServerSettings-B2RKhJtZ.js +84 -0
- package/dist/ServerSettings-B2RKhJtZ.js.map +1 -0
- package/dist/ServerSettings-BZXlm1BX.cjs +1 -0
- package/dist/ServerSettings-BZXlm1BX.cjs.map +1 -0
- package/dist/{ServerSettings-UIVR0R4l.js → ServerSettings-Bqm4-bt2.js} +3 -3
- package/dist/ServerSettings-Bqm4-bt2.js.map +1 -0
- package/dist/ServerSettings-DZUKo6By.cjs +1 -0
- package/dist/ServerSettings-DZUKo6By.cjs.map +1 -0
- package/dist/SettingsPageLayout-COSYLMu7.cjs +1 -0
- package/dist/SettingsPageLayout-COSYLMu7.cjs.map +1 -0
- package/dist/SettingsPageLayout-DpgNEkuu.js +50 -0
- package/dist/SettingsPageLayout-DpgNEkuu.js.map +1 -0
- package/dist/{SolanaLoginButton-C-CfZxAZ.js → SolanaLoginButton-C_u9OppS.js} +5 -4
- package/dist/{SolanaLoginButton-C-CfZxAZ.js.map → SolanaLoginButton-C_u9OppS.js.map} +1 -1
- package/dist/SolanaLoginButton-fAW7kRUu.cjs +1 -0
- package/dist/{SolanaLoginButton-CPzms0kf.cjs.map → SolanaLoginButton-fAW7kRUu.cjs.map} +1 -1
- package/dist/StatsBar-BX-hHtTq.js +66 -0
- package/dist/StatsBar-BX-hHtTq.js.map +1 -0
- package/dist/StatsBar-DTUZCwDD.cjs +1 -0
- package/dist/StatsBar-DTUZCwDD.cjs.map +1 -0
- package/dist/{TeamSection-DnJudC38.js → TeamSection-CvrCoa9D.js} +27 -26
- package/dist/TeamSection-CvrCoa9D.js.map +1 -0
- package/dist/TeamSection-DlUD5kp5.cjs +1 -0
- package/dist/TeamSection-DlUD5kp5.cjs.map +1 -0
- package/dist/UsersSection-C2U8Tb7V.cjs +1 -0
- package/dist/{UsersSection-Ce7xVKfp.cjs.map → UsersSection-C2U8Tb7V.cjs.map} +1 -1
- package/dist/{UsersSection-mOOjcUEv.js → UsersSection-Dbh9PTSA.js} +17 -15
- package/dist/{UsersSection-mOOjcUEv.js.map → UsersSection-Dbh9PTSA.js.map} +1 -1
- package/dist/WebhookSettings-BT5q6AZ8.js +17 -0
- package/dist/WebhookSettings-BT5q6AZ8.js.map +1 -0
- package/dist/WebhookSettings-BWl_wsvg.cjs +1 -0
- package/dist/WebhookSettings-BWl_wsvg.cjs.map +1 -0
- package/dist/WebhookSettings-DXNH5bal.cjs +1 -0
- package/dist/WebhookSettings-DXNH5bal.cjs.map +1 -0
- package/dist/{WebhookSettings-D0i0JhQD.js → WebhookSettings-bUg2u_p0.js} +4 -4
- package/dist/WebhookSettings-bUg2u_p0.js.map +1 -0
- package/dist/WithdrawalsSection-BL_LOUq8.cjs +1 -0
- package/dist/{WithdrawalsSection-igRQJfjj.cjs.map → WithdrawalsSection-BL_LOUq8.cjs.map} +1 -1
- package/dist/WithdrawalsSection-CN-lLnqX.js +20 -0
- package/dist/{WithdrawalsSection-Grebjjks.js.map → WithdrawalsSection-CN-lLnqX.js.map} +1 -1
- package/dist/admin-only.cjs +1 -0
- package/dist/admin-only.cjs.map +1 -0
- package/dist/{admin/types.d.ts → admin-only.d.ts} +228 -167
- package/dist/admin-only.js +8 -0
- package/dist/admin-only.js.map +1 -0
- package/dist/apiClient-B2JxVPlH.js +216 -0
- package/dist/apiClient-B2JxVPlH.js.map +1 -0
- package/dist/apiClient-CTTKhsYb.cjs +1 -0
- package/dist/apiClient-CTTKhsYb.cjs.map +1 -0
- package/dist/assets/argon2Worker-Bi5TuQvD.js.map +1 -1
- package/dist/email-only.cjs +1 -1
- package/dist/email-only.d.ts +634 -16
- package/dist/email-only.js +16 -13
- package/dist/email-only.js.map +1 -1
- package/dist/google-only.cjs +1 -1
- package/dist/google-only.d.ts +543 -13
- package/dist/google-only.js +11 -8
- package/dist/google-only.js.map +1 -1
- package/dist/index.cjs +2061 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5007 -144
- package/dist/index.js +13507 -116
- package/dist/index.js.map +1 -1
- package/dist/login-react.css +1 -1
- package/dist/plugin-5qRh-YhX.js +596 -0
- package/dist/plugin-5qRh-YhX.js.map +1 -0
- package/dist/plugin-BtYBW6JY.cjs +1 -0
- package/dist/plugin-BtYBW6JY.cjs.map +1 -0
- package/dist/sanitization-Bo_tn-L2.cjs +1 -0
- package/dist/sanitization-Bo_tn-L2.cjs.map +1 -0
- package/dist/sanitization-CQ-H1MSg.js +39 -0
- package/dist/sanitization-CQ-H1MSg.js.map +1 -0
- package/dist/shamir-AeLLfw0p.cjs +1 -0
- package/dist/shamir-AeLLfw0p.cjs.map +1 -0
- package/dist/{solanaKeypair-BlXol3nh.js → shamir-B0wConeK.js} +765 -757
- package/dist/shamir-B0wConeK.js.map +1 -0
- package/dist/silentWalletEnroll-B8pgdKZO.cjs +1 -0
- package/dist/silentWalletEnroll-B8pgdKZO.cjs.map +1 -0
- package/dist/silentWalletEnroll-DR2kPw7W.js +41 -0
- package/dist/silentWalletEnroll-DR2kPw7W.js.map +1 -0
- package/dist/solana-only.cjs +1 -1
- package/dist/solana-only.d.ts +594 -13
- package/dist/solana-only.js +12 -9
- package/dist/solana-only.js.map +1 -1
- package/dist/style.d.ts +1 -0
- package/dist/useAdminDeposits-BDY5KJ0-.js +151 -0
- package/dist/useAdminDeposits-BDY5KJ0-.js.map +1 -0
- package/dist/useAdminDeposits-Dvx3_UUE.cjs +1 -0
- package/dist/useAdminDeposits-Dvx3_UUE.cjs.map +1 -0
- package/dist/{ErrorMessage-DU2VBb85.js → useAuth-Bge6KaWN.js} +954 -1226
- package/dist/useAuth-Bge6KaWN.js.map +1 -0
- package/dist/useAuth-DhIDTLRd.cjs +1 -0
- package/dist/useAuth-DhIDTLRd.cjs.map +1 -0
- package/dist/useOrgs-Be3KH4ib.js +215 -0
- package/dist/useOrgs-Be3KH4ib.js.map +1 -0
- package/dist/useOrgs-CVbacmaQ.cjs +1 -0
- package/dist/useOrgs-CVbacmaQ.cjs.map +1 -0
- package/dist/useSystemSettings-D9Cr7ZTl.cjs +1 -0
- package/dist/useSystemSettings-D9Cr7ZTl.cjs.map +1 -0
- package/dist/useSystemSettings-DN5YqfNq.js +97 -0
- package/dist/useSystemSettings-DN5YqfNq.js.map +1 -0
- package/dist/{validation-BebL7hMF.js → validation-B8kMV3BL.js} +1 -1
- package/dist/{validation-BebL7hMF.js.map → validation-B8kMV3BL.js.map} +1 -1
- package/dist/{validation-BeXIfuHB.cjs → validation-BuGQrA-K.cjs} +1 -1
- package/dist/{validation-BeXIfuHB.cjs.map → validation-BuGQrA-K.cjs.map} +1 -1
- package/package.json +11 -1
- package/dist/AuthenticationSettings-D8oXHkM6.cjs +0 -1
- package/dist/AuthenticationSettings-D8oXHkM6.cjs.map +0 -1
- package/dist/AuthenticationSettings-DlVILxY4.js.map +0 -1
- package/dist/CreditSystemSettings-Bv6u9lTs.js +0 -9
- package/dist/CreditSystemSettings-Bv6u9lTs.js.map +0 -1
- package/dist/CreditSystemSettings-D45pwDZM.cjs +0 -1
- package/dist/CreditSystemSettings-D45pwDZM.cjs.map +0 -1
- package/dist/DepositsSection-DpRn0koq.cjs +0 -1
- package/dist/EmailRegisterForm-C0PStlj5.js +0 -961
- package/dist/EmailRegisterForm-C0PStlj5.js.map +0 -1
- package/dist/EmailRegisterForm-DaPLGws2.cjs +0 -1
- package/dist/EmailRegisterForm-DaPLGws2.cjs.map +0 -1
- package/dist/EmailSettings-DdjoMO_c.cjs +0 -1
- package/dist/EmailSettings-DdjoMO_c.cjs.map +0 -1
- package/dist/EmailSettings-khmiWqhx.js +0 -9
- package/dist/EmailSettings-khmiWqhx.js.map +0 -1
- package/dist/EmbeddedWalletSettings-Bff6raAT.js.map +0 -1
- package/dist/EmbeddedWalletSettings-C5qkJtAr.cjs +0 -1
- package/dist/EmbeddedWalletSettings-C5qkJtAr.cjs.map +0 -1
- package/dist/ErrorMessage-BXHiYibN.cjs +0 -1
- package/dist/ErrorMessage-BXHiYibN.cjs.map +0 -1
- package/dist/ErrorMessage-DU2VBb85.js.map +0 -1
- package/dist/GoogleLoginButton-DoAdOqb3.cjs +0 -1
- package/dist/ServerSettings-BpZhkxh6.cjs +0 -1
- package/dist/ServerSettings-BpZhkxh6.cjs.map +0 -1
- package/dist/ServerSettings-UIVR0R4l.js.map +0 -1
- package/dist/SolanaLoginButton-CPzms0kf.cjs +0 -1
- package/dist/TeamSection-BoGqQhD5.cjs +0 -1
- package/dist/TeamSection-BoGqQhD5.cjs.map +0 -1
- package/dist/TeamSection-DnJudC38.js.map +0 -1
- package/dist/UsersSection-Ce7xVKfp.cjs +0 -1
- package/dist/WebhookSettings-Cx-BxzNQ.cjs +0 -1
- package/dist/WebhookSettings-Cx-BxzNQ.cjs.map +0 -1
- package/dist/WebhookSettings-D0i0JhQD.js.map +0 -1
- package/dist/WithdrawalsSection-Grebjjks.js +0 -20
- package/dist/WithdrawalsSection-igRQJfjj.cjs +0 -1
- package/dist/admin/AdminShell.d.ts +0 -38
- package/dist/admin/icons.d.ts +0 -2
- package/dist/admin/index.d.ts +0 -10
- package/dist/admin/plugin.d.ts +0 -3
- package/dist/admin/sections/AuthenticationSettings.d.ts +0 -3
- package/dist/admin/sections/CreditSystemSettings.d.ts +0 -3
- package/dist/admin/sections/DepositsSection.d.ts +0 -3
- package/dist/admin/sections/EmailSettings.d.ts +0 -3
- package/dist/admin/sections/EmbeddedWalletSettings.d.ts +0 -3
- package/dist/admin/sections/FeatureSettings.d.ts +0 -3
- package/dist/admin/sections/InvitesSection.d.ts +0 -3
- package/dist/admin/sections/MembersSection.d.ts +0 -3
- package/dist/admin/sections/ServerSettings.d.ts +0 -3
- package/dist/admin/sections/SettingsSections.d.ts +0 -7
- package/dist/admin/sections/TeamSection.d.ts +0 -3
- package/dist/admin/sections/UsersSection.d.ts +0 -3
- package/dist/admin/sections/WebhookSettings.d.ts +0 -3
- package/dist/admin/sections/WithdrawalsSection.d.ts +0 -3
- package/dist/components/LoginButton.d.ts +0 -23
- package/dist/components/LoginForm.d.ts +0 -9
- package/dist/components/LoginModal.d.ts +0 -9
- package/dist/components/admin/AdminUserDetail.d.ts +0 -23
- package/dist/components/admin/AdminUserList.d.ts +0 -21
- package/dist/components/admin/CedrosAdminDashboard.d.ts +0 -52
- package/dist/components/admin/PermissionsSection.d.ts +0 -7
- package/dist/components/admin/ProfileDropdown.d.ts +0 -34
- package/dist/components/admin/SetupWizard.d.ts +0 -30
- package/dist/components/admin/StatsBar.d.ts +0 -17
- package/dist/components/admin/SystemSettings.d.ts +0 -19
- package/dist/components/admin/settings/AuthenticationSettings.d.ts +0 -4
- package/dist/components/admin/settings/AutosaveStatus.d.ts +0 -6
- package/dist/components/admin/settings/CreditSystemSettings.d.ts +0 -6
- package/dist/components/admin/settings/EmailSettings.d.ts +0 -4
- package/dist/components/admin/settings/EmbeddedWalletSettings.d.ts +0 -4
- package/dist/components/admin/settings/FeatureSettings.d.ts +0 -4
- package/dist/components/admin/settings/MessagingSettings.d.ts +0 -4
- package/dist/components/admin/settings/SecuritySettings.d.ts +0 -4
- package/dist/components/admin/settings/ServerSettings.d.ts +0 -4
- package/dist/components/admin/settings/SettingsPageLayout.d.ts +0 -16
- package/dist/components/admin/settings/SsoProvidersSettings.d.ts +0 -4
- package/dist/components/admin/settings/WebhookSettings.d.ts +0 -4
- package/dist/components/admin/settings/index.d.ts +0 -31
- package/dist/components/admin/settings/settingsInputs.d.ts +0 -79
- package/dist/components/admin/settings/settingsMetadata.d.ts +0 -18
- package/dist/components/apple/AppleLoginButton.d.ts +0 -29
- package/dist/components/deposit/CreditBalance.d.ts +0 -19
- package/dist/components/deposit/DepositFlow.d.ts +0 -118
- package/dist/components/deposit/FeeConfigDisplay.d.ts +0 -15
- package/dist/components/deposit/History.d.ts +0 -21
- package/dist/components/deposit/TieredAmountSlider.d.ts +0 -19
- package/dist/components/deposit/TokenSelector.d.ts +0 -23
- package/dist/components/deposit/admin/AdminDepositList.d.ts +0 -21
- package/dist/components/deposit/admin/AdminDepositStats.d.ts +0 -15
- package/dist/components/deposit/admin/AdminPrivacyPeriodDeposits.d.ts +0 -19
- package/dist/components/deposit/admin/AdminWithdrawalHistory.d.ts +0 -19
- package/dist/components/deposit/admin/AdminWithdrawalQueue.d.ts +0 -23
- package/dist/components/deposit/admin/AdminWithdrawalStats.d.ts +0 -10
- package/dist/components/deposit/admin/FeatureDisabledMessage.d.ts +0 -15
- package/dist/components/deposit/admin/PrivacySystemStatus.d.ts +0 -15
- package/dist/components/deposit/admin/featureDisabled.d.ts +0 -14
- package/dist/components/deposit/admin/index.d.ts +0 -22
- package/dist/components/deposit/index.d.ts +0 -12
- package/dist/components/deposit/tierUtils.d.ts +0 -8
- package/dist/components/deposit/tokens.d.ts +0 -19
- package/dist/components/email/EmailLoginForm.d.ts +0 -11
- package/dist/components/email/EmailRegisterForm.d.ts +0 -14
- package/dist/components/email/ForgotPasswordForm.d.ts +0 -17
- package/dist/components/email/PasswordInput.d.ts +0 -14
- package/dist/components/email/ResetPasswordForm.d.ts +0 -22
- package/dist/components/google/GoogleLoginButton.d.ts +0 -12
- package/dist/components/invites/InviteForm.d.ts +0 -38
- package/dist/components/invites/InviteList.d.ts +0 -40
- package/dist/components/members/MemberList.d.ts +0 -47
- package/dist/components/org/CreateOrgForm.d.ts +0 -7
- package/dist/components/org/OrgAvatar.d.ts +0 -7
- package/dist/components/org/OrgListView.d.ts +0 -9
- package/dist/components/org/OrgSelector.d.ts +0 -52
- package/dist/components/org/OrgSwitcher.d.ts +0 -47
- package/dist/components/org/icons.d.ts +0 -8
- package/dist/components/profile/UserProfileSettings.d.ts +0 -35
- package/dist/components/profile/index.d.ts +0 -2
- package/dist/components/sessions/SessionList.d.ts +0 -33
- package/dist/components/shared/ErrorBoundary.d.ts +0 -38
- package/dist/components/shared/ErrorMessage.d.ts +0 -14
- package/dist/components/shared/LoadingSpinner.d.ts +0 -16
- package/dist/components/solana/SolanaLoginButton.d.ts +0 -49
- package/dist/components/templates/FullPageLayout.d.ts +0 -40
- package/dist/components/templates/SplitPageLayout.d.ts +0 -44
- package/dist/components/templates/index.d.ts +0 -4
- package/dist/components/totp/OtpInput.d.ts +0 -32
- package/dist/components/totp/QrCode.d.ts +0 -21
- package/dist/components/totp/TotpSettings.d.ts +0 -38
- package/dist/components/totp/TotpSetup.d.ts +0 -23
- package/dist/components/totp/TotpVerify.d.ts +0 -25
- package/dist/components/totp/index.d.ts +0 -10
- package/dist/components/wallet/CapabilityWarning.d.ts +0 -11
- package/dist/components/wallet/PasskeyPrompt.d.ts +0 -34
- package/dist/components/wallet/RecoveryPhraseDisplay.d.ts +0 -18
- package/dist/components/wallet/RecoveryPhraseInput.d.ts +0 -21
- package/dist/components/wallet/WalletAddressRow.d.ts +0 -10
- package/dist/components/wallet/WalletEnrollment.d.ts +0 -15
- package/dist/components/wallet/WalletManager.d.ts +0 -9
- package/dist/components/wallet/WalletRecovery.d.ts +0 -19
- package/dist/components/wallet/WalletStatus.d.ts +0 -28
- package/dist/components/wallet/WalletUnlock.d.ts +0 -23
- package/dist/components/wallet/index.d.ts +0 -23
- package/dist/components/webauthn/PasskeyLoginButton.d.ts +0 -8
- package/dist/context/CedrosLoginContext.d.ts +0 -24
- package/dist/context/CedrosLoginProvider.d.ts +0 -17
- package/dist/context/EmbeddedWalletExposure.d.ts +0 -19
- package/dist/context/useCedrosLogin.d.ts +0 -12
- package/dist/crypto/aesGcm.d.ts +0 -89
- package/dist/crypto/argon2.d.ts +0 -65
- package/dist/crypto/argon2Worker.d.ts +0 -1
- package/dist/crypto/argon2WorkerClient.d.ts +0 -28
- package/dist/crypto/bip39.d.ts +0 -106
- package/dist/crypto/capabilities.d.ts +0 -35
- package/dist/crypto/entropy.d.ts +0 -56
- package/dist/crypto/hkdf.d.ts +0 -38
- package/dist/crypto/index.d.ts +0 -30
- package/dist/crypto/secureWipe.d.ts +0 -71
- package/dist/crypto/shamir.d.ts +0 -52
- package/dist/crypto/solanaKeypair.d.ts +0 -63
- package/dist/crypto/types.d.ts +0 -134
- package/dist/crypto/webauthnPrf.d.ts +0 -108
- package/dist/hooks/useAdminDeposits.d.ts +0 -10
- package/dist/hooks/useAdminUsers.d.ts +0 -28
- package/dist/hooks/useAppleAuth.d.ts +0 -52
- package/dist/hooks/useAuth.d.ts +0 -34
- package/dist/hooks/useAuthSession.d.ts +0 -19
- package/dist/hooks/useAuthorize.d.ts +0 -62
- package/dist/hooks/useCredits.d.ts +0 -11
- package/dist/hooks/useDashboardPermissions.d.ts +0 -45
- package/dist/hooks/useDeposit.d.ts +0 -16
- package/dist/hooks/useEmailAuth.d.ts +0 -60
- package/dist/hooks/useGoogleAuth.d.ts +0 -67
- package/dist/hooks/useInstantLink.d.ts +0 -42
- package/dist/hooks/useInvites.d.ts +0 -57
- package/dist/hooks/useMembers.d.ts +0 -52
- package/dist/hooks/useOrgs.d.ts +0 -49
- package/dist/hooks/usePasswordReset.d.ts +0 -32
- package/dist/hooks/usePendingRecovery.d.ts +0 -34
- package/dist/hooks/useProfile.d.ts +0 -35
- package/dist/hooks/useRateLimiter.d.ts +0 -58
- package/dist/hooks/useServerFeatures.d.ts +0 -55
- package/dist/hooks/useSessions.d.ts +0 -45
- package/dist/hooks/useSettingsAutosave.d.ts +0 -29
- package/dist/hooks/useSetup.d.ts +0 -25
- package/dist/hooks/useSolanaAuth.d.ts +0 -30
- package/dist/hooks/useSsoProviders.d.ts +0 -52
- package/dist/hooks/useSystemSettings.d.ts +0 -47
- package/dist/hooks/useThemeManager.d.ts +0 -11
- package/dist/hooks/useTotp.d.ts +0 -52
- package/dist/hooks/useTotpVerify.d.ts +0 -38
- package/dist/hooks/useTransactionSigning.d.ts +0 -45
- package/dist/hooks/useWallet.d.ts +0 -10
- package/dist/hooks/useWalletDiscovery.d.ts +0 -24
- package/dist/hooks/useWalletEnrollment.d.ts +0 -9
- package/dist/hooks/useWalletMaterial.d.ts +0 -10
- package/dist/hooks/useWalletRecovery.d.ts +0 -9
- package/dist/hooks/useWalletSigning.d.ts +0 -31
- package/dist/hooks/useWebAuthn.d.ts +0 -25
- package/dist/i18n/I18nProvider.d.ts +0 -16
- package/dist/i18n/context.d.ts +0 -6
- package/dist/i18n/index.d.ts +0 -5
- package/dist/i18n/translations.d.ts +0 -66
- package/dist/i18n/useI18n.d.ts +0 -9
- package/dist/index-BI9Bj9DF.js +0 -19650
- package/dist/index-BI9Bj9DF.js.map +0 -1
- package/dist/index-CDRTfEJz.cjs +0 -2061
- package/dist/index-CDRTfEJz.cjs.map +0 -1
- package/dist/silentWalletEnroll-C3JRAD9_.js +0 -42
- package/dist/silentWalletEnroll-C3JRAD9_.js.map +0 -1
- package/dist/silentWalletEnroll-DRYQAQfg.cjs +0 -1
- package/dist/silentWalletEnroll-DRYQAQfg.cjs.map +0 -1
- package/dist/solanaKeypair-BlXol3nh.js.map +0 -1
- package/dist/solanaKeypair-C-lIR1JY.cjs +0 -1
- package/dist/solanaKeypair-C-lIR1JY.cjs.map +0 -1
- package/dist/types/adminUser.d.ts +0 -168
- package/dist/types/auth.d.ts +0 -122
- package/dist/types/config.d.ts +0 -266
- package/dist/types/deposit.d.ts +0 -490
- package/dist/types/index.d.ts +0 -13
- package/dist/types/invite.d.ts +0 -71
- package/dist/types/member.d.ts +0 -45
- package/dist/types/org.d.ts +0 -133
- package/dist/types/profile.d.ts +0 -56
- package/dist/types/session.d.ts +0 -28
- package/dist/types/setup.d.ts +0 -47
- package/dist/types/systemSettings.d.ts +0 -85
- package/dist/types/totp.d.ts +0 -52
- package/dist/types/wallet.d.ts +0 -309
- package/dist/utils/adminUserApi.d.ts +0 -60
- package/dist/utils/apiClient.d.ts +0 -78
- package/dist/utils/cryptoShim.d.ts +0 -17
- package/dist/utils/csrf.d.ts +0 -1
- package/dist/utils/deviceDetection.d.ts +0 -17
- package/dist/utils/embeddedWallet.d.ts +0 -75
- package/dist/utils/inviteApi.d.ts +0 -31
- package/dist/utils/memberApi.d.ts +0 -23
- package/dist/utils/orgApi.d.ts +0 -36
- package/dist/utils/profileApi.d.ts +0 -26
- package/dist/utils/sanitization.d.ts +0 -66
- package/dist/utils/sessionApi.d.ts +0 -16
- package/dist/utils/setupApi.d.ts +0 -21
- package/dist/utils/silentWalletEnroll.d.ts +0 -41
- package/dist/utils/systemSettingsApi.d.ts +0 -18
- package/dist/utils/tabSync.d.ts +0 -46
- package/dist/utils/tokenManager.d.ts +0 -107
- package/dist/utils/unlockCredential.d.ts +0 -5
- package/dist/utils/validation.d.ts +0 -48
- package/dist/utils/walletDetection.d.ts +0 -23
- package/dist/utils/webauthnJson.d.ts +0 -21
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { D as Be,
|
|
2
|
-
let P = null,
|
|
1
|
+
import { D as Be, v as ve, d as Se, e as ee, f as ht, h as Ae } from "./useAuth-Bge6KaWN.js";
|
|
2
|
+
let P = null, Re = 0;
|
|
3
3
|
const et = /* @__PURE__ */ new Map();
|
|
4
|
-
function
|
|
4
|
+
function Ie() {
|
|
5
5
|
return typeof Worker > "u" ? null : (P || (P = new Worker(new URL(
|
|
6
6
|
/* @vite-ignore */
|
|
7
7
|
"" + new URL("assets/argon2Worker-Bi5TuQvD.js", import.meta.url).href,
|
|
@@ -28,13 +28,14 @@ function Re() {
|
|
|
28
28
|
et.clear(), P?.terminate(), P = null;
|
|
29
29
|
}), P);
|
|
30
30
|
}
|
|
31
|
-
async function
|
|
32
|
-
|
|
31
|
+
async function sr(e, t, n = Be) {
|
|
32
|
+
ve(n);
|
|
33
|
+
const o = Ie();
|
|
33
34
|
return o ? new Promise((r, s) => {
|
|
34
|
-
const
|
|
35
|
-
et.set(
|
|
35
|
+
const c = Re++;
|
|
36
|
+
et.set(c, { resolve: r, reject: s });
|
|
36
37
|
const u = {
|
|
37
|
-
id:
|
|
38
|
+
id: c,
|
|
38
39
|
password: e,
|
|
39
40
|
salt: t,
|
|
40
41
|
params: n
|
|
@@ -42,10 +43,10 @@ async function rr(e, t, n = Be) {
|
|
|
42
43
|
o.postMessage(u);
|
|
43
44
|
}) : Se(e, t, n);
|
|
44
45
|
}
|
|
45
|
-
function
|
|
46
|
+
function _e(e) {
|
|
46
47
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
47
48
|
}
|
|
48
|
-
function
|
|
49
|
+
function Ne(e) {
|
|
49
50
|
if (Object.prototype.hasOwnProperty.call(e, "__esModule")) return e;
|
|
50
51
|
var t = e.default;
|
|
51
52
|
if (typeof t == "function") {
|
|
@@ -70,21 +71,21 @@ function _e(e) {
|
|
|
70
71
|
}), n;
|
|
71
72
|
}
|
|
72
73
|
var it = { exports: {} };
|
|
73
|
-
const
|
|
74
|
+
const Oe = globalThis.crypto, Te = globalThis.crypto, Ce = globalThis.crypto.subtle, Le = globalThis.crypto.getRandomValues.bind(globalThis.crypto), He = globalThis.crypto.randomUUID.bind(globalThis.crypto), Ue = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
74
75
|
__proto__: null,
|
|
75
|
-
default:
|
|
76
|
-
getRandomValues:
|
|
77
|
-
randomUUID:
|
|
78
|
-
subtle:
|
|
79
|
-
webcrypto:
|
|
80
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
81
|
-
var
|
|
82
|
-
function
|
|
76
|
+
default: Oe,
|
|
77
|
+
getRandomValues: Le,
|
|
78
|
+
randomUUID: He,
|
|
79
|
+
subtle: Ce,
|
|
80
|
+
webcrypto: Te
|
|
81
|
+
}, Symbol.toStringTag, { value: "Module" })), De = /* @__PURE__ */ Ne(Ue);
|
|
82
|
+
var qe = it.exports, Ut;
|
|
83
|
+
function Me() {
|
|
83
84
|
return Ut || (Ut = 1, (function(e, t) {
|
|
84
85
|
(function(n, o) {
|
|
85
|
-
e.exports = o(
|
|
86
|
-
})(
|
|
87
|
-
var o, r, s,
|
|
86
|
+
e.exports = o(De);
|
|
87
|
+
})(qe, function(n) {
|
|
88
|
+
var o, r, s, c, u;
|
|
88
89
|
function i() {
|
|
89
90
|
o = {
|
|
90
91
|
bits: 8,
|
|
@@ -133,7 +134,7 @@ function qe() {
|
|
|
133
134
|
5,
|
|
134
135
|
83
|
|
135
136
|
]
|
|
136
|
-
}, r = {}, s = new Array(1024).join("0"),
|
|
137
|
+
}, r = {}, s = new Array(1024).join("0"), c = !0, u = [
|
|
137
138
|
"nodeCryptoRandomBytes",
|
|
138
139
|
"browserCryptoGetRandomValues",
|
|
139
140
|
"testRandom"
|
|
@@ -142,117 +143,117 @@ function qe() {
|
|
|
142
143
|
function x() {
|
|
143
144
|
return !!(r && r.rng && typeof r.rng == "function");
|
|
144
145
|
}
|
|
145
|
-
function
|
|
146
|
-
var
|
|
146
|
+
function m(a, h) {
|
|
147
|
+
var f;
|
|
147
148
|
if (h === 0 || h === 1)
|
|
148
|
-
return
|
|
149
|
+
return a;
|
|
149
150
|
if (h && h > 1024)
|
|
150
151
|
throw new Error(
|
|
151
152
|
"Padding must be multiples of no larger than 1024 bits."
|
|
152
153
|
);
|
|
153
|
-
return h = h || r.bits,
|
|
154
|
-
-(h -
|
|
155
|
-
) :
|
|
154
|
+
return h = h || r.bits, a && (f = a.length % h), f ? (s + a).slice(
|
|
155
|
+
-(h - f + a.length)
|
|
156
|
+
) : a;
|
|
156
157
|
}
|
|
157
|
-
function w(
|
|
158
|
-
var h = "",
|
|
159
|
-
for (l =
|
|
160
|
-
if (
|
|
158
|
+
function w(a) {
|
|
159
|
+
var h = "", f, l;
|
|
160
|
+
for (l = a.length - 1; l >= 0; l--) {
|
|
161
|
+
if (f = parseInt(a[l], 16), isNaN(f))
|
|
161
162
|
throw new Error("Invalid hex character.");
|
|
162
|
-
h =
|
|
163
|
+
h = m(f.toString(2), 4) + h;
|
|
163
164
|
}
|
|
164
165
|
return h;
|
|
165
166
|
}
|
|
166
|
-
function
|
|
167
|
-
var h = "",
|
|
168
|
-
for (
|
|
169
|
-
if (
|
|
167
|
+
function v(a) {
|
|
168
|
+
var h = "", f, l;
|
|
169
|
+
for (a = m(a, 4), l = a.length; l >= 4; l -= 4) {
|
|
170
|
+
if (f = parseInt(a.slice(l - 4, l), 2), isNaN(f))
|
|
170
171
|
throw new Error("Invalid binary character.");
|
|
171
|
-
h =
|
|
172
|
+
h = f.toString(16) + h;
|
|
172
173
|
}
|
|
173
174
|
return h;
|
|
174
175
|
}
|
|
175
176
|
function I() {
|
|
176
177
|
return !!(n && typeof n == "object" && (typeof n.getRandomValues == "function" || typeof n.getRandomValues == "object") && (typeof Uint32Array == "function" || typeof Uint32Array == "object"));
|
|
177
178
|
}
|
|
178
|
-
function
|
|
179
|
+
function S() {
|
|
179
180
|
return typeof n == "object" && typeof n.randomBytes == "function";
|
|
180
181
|
}
|
|
181
|
-
function O(
|
|
182
|
-
function h(b, g,
|
|
182
|
+
function O(a) {
|
|
183
|
+
function h(b, g, y, B) {
|
|
183
184
|
var R = 0, C, L = "", q;
|
|
184
185
|
for (g && (C = g.length - 1); R < C || L.length < b; )
|
|
185
|
-
q = Math.abs(parseInt(g[R],
|
|
186
|
+
q = Math.abs(parseInt(g[R], y)), L = L + m(q.toString(2), B), R++;
|
|
186
187
|
return L = L.substr(-b), (L.match(/0/g) || []).length === L.length ? null : L;
|
|
187
188
|
}
|
|
188
|
-
function
|
|
189
|
-
var g,
|
|
190
|
-
for (B = 16, R = 4,
|
|
191
|
-
g = n.randomBytes(
|
|
189
|
+
function f(b) {
|
|
190
|
+
var g, y, B, R, C = null;
|
|
191
|
+
for (B = 16, R = 4, y = Math.ceil(b / 8); C === null; )
|
|
192
|
+
g = n.randomBytes(y), C = h(b, g.toString("hex"), B, R);
|
|
192
193
|
return C;
|
|
193
194
|
}
|
|
194
195
|
function l(b) {
|
|
195
|
-
var g,
|
|
196
|
-
for (
|
|
196
|
+
var g, y, B, R = null;
|
|
197
|
+
for (y = 10, B = 32, g = Math.ceil(b / 32); R === null; )
|
|
197
198
|
R = h(
|
|
198
199
|
b,
|
|
199
200
|
n.getRandomValues(new Uint32Array(g)),
|
|
200
|
-
|
|
201
|
+
y,
|
|
201
202
|
B
|
|
202
203
|
);
|
|
203
204
|
return R;
|
|
204
205
|
}
|
|
205
206
|
function d(b) {
|
|
206
|
-
var g,
|
|
207
|
-
R = 10, C = 32,
|
|
207
|
+
var g, y, B, R, C, L = null;
|
|
208
|
+
R = 10, C = 32, y = Math.ceil(b / 32), B = 123456789, g = new Uint32Array(y);
|
|
208
209
|
for (var q = 0; q < g.length; q++)
|
|
209
210
|
g[q] = B;
|
|
210
211
|
for (; L === null; )
|
|
211
212
|
L = h(b, g, R, C);
|
|
212
213
|
return L;
|
|
213
214
|
}
|
|
214
|
-
if (
|
|
215
|
-
return r.typeCSPRNG =
|
|
216
|
-
if (
|
|
217
|
-
return r.typeCSPRNG =
|
|
218
|
-
if (
|
|
219
|
-
return r.typeCSPRNG =
|
|
220
|
-
if (
|
|
221
|
-
return r.typeCSPRNG = "nodeCryptoRandomBytes",
|
|
215
|
+
if (a && a === "testRandom")
|
|
216
|
+
return r.typeCSPRNG = a, d;
|
|
217
|
+
if (a && a === "nodeCryptoRandomBytes")
|
|
218
|
+
return r.typeCSPRNG = a, f;
|
|
219
|
+
if (a && a === "browserCryptoGetRandomValues")
|
|
220
|
+
return r.typeCSPRNG = a, l;
|
|
221
|
+
if (S())
|
|
222
|
+
return r.typeCSPRNG = "nodeCryptoRandomBytes", f;
|
|
222
223
|
if (I())
|
|
223
224
|
return r.typeCSPRNG = "browserCryptoGetRandomValues", l;
|
|
224
225
|
}
|
|
225
|
-
function _(
|
|
226
|
-
var
|
|
227
|
-
for (h && (
|
|
228
|
-
|
|
229
|
-
return
|
|
226
|
+
function _(a, h) {
|
|
227
|
+
var f = [], l;
|
|
228
|
+
for (h && (a = m(a, h)), l = a.length; l > r.bits; l -= r.bits)
|
|
229
|
+
f.push(parseInt(a.slice(l - r.bits, l), 2));
|
|
230
|
+
return f.push(parseInt(a.slice(0, l), 2)), f;
|
|
230
231
|
}
|
|
231
|
-
function E(
|
|
232
|
-
var
|
|
232
|
+
function E(a, h) {
|
|
233
|
+
var f = r.logs[a], l = 0, d;
|
|
233
234
|
for (d = h.length - 1; d >= 0; d--)
|
|
234
|
-
l !== 0 ? l = r.exps[(
|
|
235
|
+
l !== 0 ? l = r.exps[(f + r.logs[l]) % r.maxShares] ^ h[d] : l = h[d];
|
|
235
236
|
return l;
|
|
236
237
|
}
|
|
237
|
-
function A(
|
|
238
|
-
var l = 0, d, b, g,
|
|
238
|
+
function A(a, h, f) {
|
|
239
|
+
var l = 0, d, b, g, y;
|
|
239
240
|
for (g = 0, d = h.length; g < d; g++)
|
|
240
|
-
if (
|
|
241
|
-
for (b = r.logs[
|
|
242
|
-
if (g !==
|
|
243
|
-
if (
|
|
241
|
+
if (f[g]) {
|
|
242
|
+
for (b = r.logs[f[g]], y = 0; y < d; y++)
|
|
243
|
+
if (g !== y) {
|
|
244
|
+
if (a === h[y]) {
|
|
244
245
|
b = -1;
|
|
245
246
|
break;
|
|
246
247
|
}
|
|
247
|
-
b = (b + r.logs[
|
|
248
|
+
b = (b + r.logs[a ^ h[y]] - r.logs[h[g] ^ h[y]] + r.maxShares) % r.maxShares;
|
|
248
249
|
}
|
|
249
250
|
l = b === -1 ? l : l ^ r.exps[b];
|
|
250
251
|
}
|
|
251
252
|
return l;
|
|
252
253
|
}
|
|
253
|
-
function p(
|
|
254
|
-
var l = [], d = [
|
|
255
|
-
for (b = 1; b <
|
|
254
|
+
function p(a, h, f) {
|
|
255
|
+
var l = [], d = [a], b, g;
|
|
256
|
+
for (b = 1; b < f; b++)
|
|
256
257
|
d[b] = parseInt(r.rng(r.bits), 2);
|
|
257
258
|
for (b = 1, g = h + 1; b < g; b++)
|
|
258
259
|
l[b - 1] = {
|
|
@@ -261,150 +262,150 @@ function qe() {
|
|
|
261
262
|
};
|
|
262
263
|
return l;
|
|
263
264
|
}
|
|
264
|
-
function N(
|
|
265
|
-
var l, d, b, g,
|
|
266
|
-
if (h = parseInt(h, r.radix),
|
|
265
|
+
function N(a, h, f) {
|
|
266
|
+
var l, d, b, g, y;
|
|
267
|
+
if (h = parseInt(h, r.radix), a = parseInt(a, 10) || r.bits, l = a.toString(36).toUpperCase(), b = Math.pow(2, a) - 1, g = b.toString(r.radix).length, d = m(h.toString(r.radix), g), typeof h != "number" || h % 1 !== 0 || h < 1 || h > b)
|
|
267
268
|
throw new Error(
|
|
268
269
|
"Share id must be an integer between 1 and " + b + ", inclusive."
|
|
269
270
|
);
|
|
270
|
-
return
|
|
271
|
+
return y = l + d + f, y;
|
|
271
272
|
}
|
|
272
273
|
var T = {
|
|
273
|
-
init: function(
|
|
274
|
-
var
|
|
275
|
-
if (i(),
|
|
274
|
+
init: function(a, h) {
|
|
275
|
+
var f = [], l = [], d = 1, b, g;
|
|
276
|
+
if (i(), a && (typeof a != "number" || a % 1 !== 0 || a < o.minBits || a > o.maxBits))
|
|
276
277
|
throw new Error(
|
|
277
278
|
"Number of bits must be an integer between " + o.minBits + " and " + o.maxBits + ", inclusive."
|
|
278
279
|
);
|
|
279
280
|
if (h && u.indexOf(h) === -1)
|
|
280
281
|
throw new Error("Invalid RNG type argument : '" + h + "'");
|
|
281
|
-
for (r.radix = o.radix, r.bits =
|
|
282
|
-
l[g] = d,
|
|
283
|
-
if (r.logs =
|
|
282
|
+
for (r.radix = o.radix, r.bits = a || o.bits, r.size = Math.pow(2, r.bits), r.maxShares = r.size - 1, b = o.primitivePolynomials[r.bits], g = 0; g < r.size; g++)
|
|
283
|
+
l[g] = d, f[d] = g, d = d << 1, d >= r.size && (d = d ^ b, d = d & r.maxShares);
|
|
284
|
+
if (r.logs = f, r.exps = l, h && this.setRNG(h), x() || this.setRNG(), !x() || !r.bits || !r.size || !r.maxShares || !r.logs || !r.exps || r.logs.length !== r.size || r.exps.length !== r.size)
|
|
284
285
|
throw new Error("Initialization failed.");
|
|
285
286
|
},
|
|
286
287
|
// Evaluates the Lagrange interpolation polynomial at x=`at` for
|
|
287
288
|
// individual config.bits-length segments of each share in the `shares`
|
|
288
289
|
// Array. Each share is expressed in base `inputRadix`. The output
|
|
289
290
|
// is expressed in base `outputRadix'.
|
|
290
|
-
combine: function(
|
|
291
|
-
var
|
|
292
|
-
for (h = h || 0,
|
|
293
|
-
if (B = this.extractShareComponents(f
|
|
294
|
-
|
|
295
|
-
else if (B.bits !==
|
|
291
|
+
combine: function(a, h) {
|
|
292
|
+
var f, l, d, b, g = "", y, B, R, C = [], L = [];
|
|
293
|
+
for (h = h || 0, f = 0, d = a.length; f < d; f++) {
|
|
294
|
+
if (B = this.extractShareComponents(a[f]), y === void 0)
|
|
295
|
+
y = B.bits;
|
|
296
|
+
else if (B.bits !== y)
|
|
296
297
|
throw new Error(
|
|
297
298
|
"Mismatched shares: Different bit settings."
|
|
298
299
|
);
|
|
299
|
-
if (r.bits !==
|
|
300
|
+
if (r.bits !== y && this.init(y), C.indexOf(B.id) === -1)
|
|
300
301
|
for (C.push(B.id), R = _(w(B.data)), l = 0, b = R.length; l < b; l++)
|
|
301
302
|
L[l] = L[l] || [], L[l][C.length - 1] = R[l];
|
|
302
303
|
}
|
|
303
|
-
for (
|
|
304
|
-
g =
|
|
305
|
-
return
|
|
304
|
+
for (f = 0, d = L.length; f < d; f++)
|
|
305
|
+
g = m(A(h, C, L[f]).toString(2)) + g;
|
|
306
|
+
return v(
|
|
306
307
|
h >= 1 ? g : g.slice(g.indexOf("1") + 1)
|
|
307
308
|
);
|
|
308
309
|
},
|
|
309
310
|
getConfig: function() {
|
|
310
|
-
var
|
|
311
|
-
return
|
|
311
|
+
var a = {};
|
|
312
|
+
return a.radix = r.radix, a.bits = r.bits, a.maxShares = r.maxShares, a.hasCSPRNG = x(), a.typeCSPRNG = r.typeCSPRNG, a;
|
|
312
313
|
},
|
|
313
314
|
// Given a public share, extract the bits (Integer), share ID (Integer), and share data (Hex)
|
|
314
315
|
// and return an Object containing those components.
|
|
315
|
-
extractShareComponents: function(
|
|
316
|
-
var h,
|
|
317
|
-
if (h = parseInt(
|
|
316
|
+
extractShareComponents: function(a) {
|
|
317
|
+
var h, f, l, d, b = {}, g, y;
|
|
318
|
+
if (h = parseInt(a.substr(0, 1), 36), h && (typeof h != "number" || h % 1 !== 0 || h < o.minBits || h > o.maxBits))
|
|
318
319
|
throw new Error(
|
|
319
320
|
"Invalid share : Number of bits must be an integer between " + o.minBits + " and " + o.maxBits + ", inclusive."
|
|
320
321
|
);
|
|
321
|
-
if (d = Math.pow(2, h) - 1, l = (Math.pow(2, h) - 1).toString(r.radix).length, g = "^([a-kA-K3-9]{1})([a-fA-F0-9]{" + l + "})([a-fA-F0-9]+)$",
|
|
322
|
+
if (d = Math.pow(2, h) - 1, l = (Math.pow(2, h) - 1).toString(r.radix).length, g = "^([a-kA-K3-9]{1})([a-fA-F0-9]{" + l + "})([a-fA-F0-9]+)$", y = new RegExp(g).exec(a), y && (f = parseInt(y[2], r.radix)), typeof f != "number" || f % 1 !== 0 || f < 1 || f > d)
|
|
322
323
|
throw new Error(
|
|
323
324
|
"Invalid share : Share id must be an integer between 1 and " + r.maxShares + ", inclusive."
|
|
324
325
|
);
|
|
325
|
-
if (
|
|
326
|
-
return b.bits = h, b.id =
|
|
327
|
-
throw new Error("The share data provided is invalid : " +
|
|
326
|
+
if (y && y[3])
|
|
327
|
+
return b.bits = h, b.id = f, b.data = y[3], b;
|
|
328
|
+
throw new Error("The share data provided is invalid : " + a);
|
|
328
329
|
},
|
|
329
330
|
// Set the PRNG to use. If no RNG function is supplied, pick a default using getRNG()
|
|
330
|
-
setRNG: function(
|
|
331
|
-
var h = "Random number generator is invalid ",
|
|
332
|
-
if (
|
|
333
|
-
throw new Error("Invalid RNG type argument : '" +
|
|
334
|
-
if (
|
|
335
|
-
if (
|
|
336
|
-
throw new Error(h + "(Not a function)." +
|
|
337
|
-
if (
|
|
331
|
+
setRNG: function(a) {
|
|
332
|
+
var h = "Random number generator is invalid ", f = " Supply an CSPRNG of the form function(bits){} that returns a string containing 'bits' number of random 1's and 0's.";
|
|
333
|
+
if (a && typeof a == "string" && u.indexOf(a) === -1)
|
|
334
|
+
throw new Error("Invalid RNG type argument : '" + a + "'");
|
|
335
|
+
if (a || (a = O()), a && typeof a == "string" && (a = O(a)), c) {
|
|
336
|
+
if (a && typeof a != "function")
|
|
337
|
+
throw new Error(h + "(Not a function)." + f);
|
|
338
|
+
if (a && typeof a(r.bits) != "string")
|
|
338
339
|
throw new Error(
|
|
339
|
-
h + "(Output is not a string)." +
|
|
340
|
+
h + "(Output is not a string)." + f
|
|
340
341
|
);
|
|
341
|
-
if (
|
|
342
|
+
if (a && !parseInt(a(r.bits), 2))
|
|
342
343
|
throw new Error(
|
|
343
|
-
h + "(Binary string output not parseable to an Integer)." +
|
|
344
|
+
h + "(Binary string output not parseable to an Integer)." + f
|
|
344
345
|
);
|
|
345
|
-
if (
|
|
346
|
+
if (a && a(r.bits).length > r.bits)
|
|
346
347
|
throw new Error(
|
|
347
|
-
h + "(Output length is greater than config.bits)." +
|
|
348
|
+
h + "(Output length is greater than config.bits)." + f
|
|
348
349
|
);
|
|
349
|
-
if (
|
|
350
|
+
if (a && a(r.bits).length < r.bits)
|
|
350
351
|
throw new Error(
|
|
351
|
-
h + "(Output length is less than config.bits)." +
|
|
352
|
+
h + "(Output length is less than config.bits)." + f
|
|
352
353
|
);
|
|
353
354
|
}
|
|
354
|
-
return r.rng =
|
|
355
|
+
return r.rng = a, !0;
|
|
355
356
|
},
|
|
356
357
|
// Converts a given UTF16 character string to the HEX representation.
|
|
357
358
|
// Each character of the input string is represented by
|
|
358
359
|
// `bytesPerChar` bytes in the output string which defaults to 2.
|
|
359
|
-
str2hex: function(
|
|
360
|
-
var
|
|
361
|
-
if (typeof
|
|
360
|
+
str2hex: function(a, h) {
|
|
361
|
+
var f, l, d = "", b, g, y, B;
|
|
362
|
+
if (typeof a != "string")
|
|
362
363
|
throw new Error("Input must be a character string.");
|
|
363
364
|
if (h || (h = o.bytesPerChar), typeof h != "number" || h < 1 || h > o.maxBytesPerChar || h % 1 !== 0)
|
|
364
365
|
throw new Error(
|
|
365
366
|
"Bytes per character must be an integer between 1 and " + o.maxBytesPerChar + ", inclusive."
|
|
366
367
|
);
|
|
367
|
-
for (
|
|
368
|
-
if (g =
|
|
369
|
-
throw new Error("Invalid character: " +
|
|
368
|
+
for (f = 2 * h, l = Math.pow(16, f) - 1, y = 0, B = a.length; y < B; y++) {
|
|
369
|
+
if (g = a[y].charCodeAt(), isNaN(g))
|
|
370
|
+
throw new Error("Invalid character: " + a[y]);
|
|
370
371
|
if (g > l)
|
|
371
372
|
throw b = Math.ceil(Math.log(g + 1) / Math.log(256)), new Error(
|
|
372
373
|
"Invalid character code (" + g + "). Maximum allowable is 256^bytes-1 (" + l + "). To convert this character, use at least " + b + " bytes."
|
|
373
374
|
);
|
|
374
|
-
d =
|
|
375
|
+
d = m(g.toString(16), f) + d;
|
|
375
376
|
}
|
|
376
377
|
return d;
|
|
377
378
|
},
|
|
378
379
|
// Converts a given HEX number string to a UTF16 character string.
|
|
379
|
-
hex2str: function(
|
|
380
|
-
var
|
|
381
|
-
if (typeof
|
|
380
|
+
hex2str: function(a, h) {
|
|
381
|
+
var f, l = "", d, b;
|
|
382
|
+
if (typeof a != "string")
|
|
382
383
|
throw new Error("Input must be a hexadecimal string.");
|
|
383
384
|
if (h = h || o.bytesPerChar, typeof h != "number" || h % 1 !== 0 || h < 1 || h > o.maxBytesPerChar)
|
|
384
385
|
throw new Error(
|
|
385
386
|
"Bytes per character must be an integer between 1 and " + o.maxBytesPerChar + ", inclusive."
|
|
386
387
|
);
|
|
387
|
-
for (
|
|
388
|
+
for (f = 2 * h, a = m(a, f), d = 0, b = a.length; d < b; d += f)
|
|
388
389
|
l = String.fromCharCode(
|
|
389
|
-
parseInt(
|
|
390
|
+
parseInt(a.slice(d, d + f), 16)
|
|
390
391
|
) + l;
|
|
391
392
|
return l;
|
|
392
393
|
},
|
|
393
394
|
// Generates a random bits-length number string using the PRNG
|
|
394
|
-
random: function(
|
|
395
|
-
if (typeof
|
|
395
|
+
random: function(a) {
|
|
396
|
+
if (typeof a != "number" || a % 1 !== 0 || a < 2 || a > 65536)
|
|
396
397
|
throw new Error(
|
|
397
398
|
"Number of bits must be an Integer between 1 and 65536."
|
|
398
399
|
);
|
|
399
|
-
return
|
|
400
|
+
return v(r.rng(a));
|
|
400
401
|
},
|
|
401
402
|
// Divides a `secret` number String str expressed in radix `inputRadix` (optional, default 16)
|
|
402
403
|
// into `numShares` shares, each expressed in radix `outputRadix` (optional, default to `inputRadix`),
|
|
403
404
|
// requiring `threshold` number of shares to reconstruct the secret.
|
|
404
405
|
// Optionally, zero-pads the secret to a length that is a multiple of padLength before sharing.
|
|
405
|
-
share: function(
|
|
406
|
-
var d, b, g = new Array(h),
|
|
407
|
-
if (l = l || 128, typeof
|
|
406
|
+
share: function(a, h, f, l) {
|
|
407
|
+
var d, b, g = new Array(h), y = new Array(h), B, R, C;
|
|
408
|
+
if (l = l || 128, typeof a != "string")
|
|
408
409
|
throw new Error("Secret must be a string.");
|
|
409
410
|
if (typeof h != "number" || h % 1 !== 0 || h < 2)
|
|
410
411
|
throw new Error(
|
|
@@ -414,42 +415,42 @@ function qe() {
|
|
|
414
415
|
throw d = Math.ceil(Math.log(h + 1) / Math.LN2), new Error(
|
|
415
416
|
"Number of shares must be an integer between 2 and 2^bits-1 (" + r.maxShares + "), inclusive. To create " + h + " shares, use at least " + d + " bits."
|
|
416
417
|
);
|
|
417
|
-
if (typeof
|
|
418
|
+
if (typeof f != "number" || f % 1 !== 0 || f < 2)
|
|
418
419
|
throw new Error(
|
|
419
420
|
"Threshold number of shares must be an integer between 2 and 2^bits-1 (" + r.maxShares + "), inclusive."
|
|
420
421
|
);
|
|
421
|
-
if (
|
|
422
|
-
throw d = Math.ceil(Math.log(
|
|
423
|
-
"Threshold number of shares must be an integer between 2 and 2^bits-1 (" + r.maxShares + "), inclusive. To use a threshold of " +
|
|
422
|
+
if (f > r.maxShares)
|
|
423
|
+
throw d = Math.ceil(Math.log(f + 1) / Math.LN2), new Error(
|
|
424
|
+
"Threshold number of shares must be an integer between 2 and 2^bits-1 (" + r.maxShares + "), inclusive. To use a threshold of " + f + ", use at least " + d + " bits."
|
|
424
425
|
);
|
|
425
|
-
if (
|
|
426
|
+
if (f > h)
|
|
426
427
|
throw new Error(
|
|
427
|
-
"Threshold number of shares was " +
|
|
428
|
+
"Threshold number of shares was " + f + " but must be less than or equal to the " + h + " shares specified as the total to generate."
|
|
428
429
|
);
|
|
429
430
|
if (typeof l != "number" || l % 1 !== 0 || l < 0 || l > 1024)
|
|
430
431
|
throw new Error(
|
|
431
432
|
"Zero-pad length must be an integer between 0 and 1024 inclusive."
|
|
432
433
|
);
|
|
433
|
-
for (
|
|
434
|
-
for (b = p(
|
|
435
|
-
g[R] = g[R] || b[R].x.toString(r.radix),
|
|
434
|
+
for (a = "1" + w(a), a = _(a, l), B = 0, C = a.length; B < C; B++)
|
|
435
|
+
for (b = p(a[B], h, f), R = 0; R < h; R++)
|
|
436
|
+
g[R] = g[R] || b[R].x.toString(r.radix), y[R] = m(b[R].y.toString(2)) + (y[R] || "");
|
|
436
437
|
for (B = 0; B < h; B++)
|
|
437
438
|
g[B] = N(
|
|
438
439
|
r.bits,
|
|
439
440
|
g[B],
|
|
440
|
-
|
|
441
|
+
v(y[B])
|
|
441
442
|
);
|
|
442
443
|
return g;
|
|
443
444
|
},
|
|
444
445
|
// Generate a new share with id `id` (a number between 1 and 2^bits-1)
|
|
445
446
|
// `id` can be a Number or a String in the default radix (16)
|
|
446
|
-
newShare: function(
|
|
447
|
-
var
|
|
448
|
-
if (
|
|
449
|
-
return
|
|
450
|
-
|
|
447
|
+
newShare: function(a, h) {
|
|
448
|
+
var f, l;
|
|
449
|
+
if (a && typeof a == "string" && (a = parseInt(a, r.radix)), l = a.toString(r.radix), a && l && h && h[0])
|
|
450
|
+
return f = this.extractShareComponents(h[0]), N(
|
|
451
|
+
f.bits,
|
|
451
452
|
l,
|
|
452
|
-
this.combine(h,
|
|
453
|
+
this.combine(h, a)
|
|
453
454
|
);
|
|
454
455
|
throw new Error(
|
|
455
456
|
"Invalid 'id' or 'shares' Array argument to newShare()."
|
|
@@ -458,11 +459,11 @@ function qe() {
|
|
|
458
459
|
/* test-code */
|
|
459
460
|
// export private functions so they can be unit tested directly.
|
|
460
461
|
_reset: i,
|
|
461
|
-
_padLeft:
|
|
462
|
+
_padLeft: m,
|
|
462
463
|
_hex2bin: w,
|
|
463
|
-
_bin2hex:
|
|
464
|
+
_bin2hex: v,
|
|
464
465
|
_hasCryptoGetRandomValues: I,
|
|
465
|
-
_hasCryptoRandomBytes:
|
|
466
|
+
_hasCryptoRandomBytes: S,
|
|
466
467
|
_getRNG: O,
|
|
467
468
|
_isSetRNG: x,
|
|
468
469
|
_splitNumStringToIntArray: _,
|
|
@@ -476,271 +477,9 @@ function qe() {
|
|
|
476
477
|
});
|
|
477
478
|
})(it)), it.exports;
|
|
478
479
|
}
|
|
479
|
-
var
|
|
480
|
-
const
|
|
481
|
-
function or(e) {
|
|
482
|
-
if (e.length !== 16)
|
|
483
|
-
throw new Error(`Invalid seed length: expected 16, got ${e.length}`);
|
|
484
|
-
const t = ne(e), n = ee.share(t, $e, Ge);
|
|
485
|
-
if (n.length !== 3)
|
|
486
|
-
throw new Error(`Unexpected share count: ${n.length}`);
|
|
487
|
-
const o = lt(n[0]), r = lt(n[1]), s = lt(n[2]);
|
|
488
|
-
return {
|
|
489
|
-
shareA: ht(o),
|
|
490
|
-
shareB: ht(r),
|
|
491
|
-
shareC: ht(s)
|
|
492
|
-
};
|
|
493
|
-
}
|
|
494
|
-
function sr(e, t) {
|
|
495
|
-
const n = Ht(e), o = Ht(t);
|
|
496
|
-
try {
|
|
497
|
-
const r = ee.combine([n, o]), s = re(r);
|
|
498
|
-
if (s.length !== 16)
|
|
499
|
-
throw new Error(`Reconstructed seed has wrong length: ${s.length}`);
|
|
500
|
-
return ve(s);
|
|
501
|
-
} catch {
|
|
502
|
-
throw new Error("Failed to reconstruct seed from shares");
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
function ne(e) {
|
|
506
|
-
return Array.from(e).map((t) => t.toString(16).padStart(2, "0")).join("");
|
|
507
|
-
}
|
|
480
|
+
var Ge = Me();
|
|
481
|
+
const ne = /* @__PURE__ */ _e(Ge);
|
|
508
482
|
function re(e) {
|
|
509
|
-
if (!/^[0-9a-fA-F]*$/.test(e))
|
|
510
|
-
throw new Error("Invalid hex string: contains non-hex characters");
|
|
511
|
-
if (e.length % 2 !== 0)
|
|
512
|
-
throw new Error(`Invalid hex string: length ${e.length} is odd (must be even)`);
|
|
513
|
-
const t = new Uint8Array(e.length / 2);
|
|
514
|
-
for (let n = 0; n < t.length; n++)
|
|
515
|
-
t[n] = parseInt(e.substr(n * 2, 2), 16);
|
|
516
|
-
return t;
|
|
517
|
-
}
|
|
518
|
-
function lt(e) {
|
|
519
|
-
const t = e.length % 2 === 0 ? e : "0" + e;
|
|
520
|
-
return re(t);
|
|
521
|
-
}
|
|
522
|
-
function Ht(e) {
|
|
523
|
-
const t = ne(e);
|
|
524
|
-
return t.startsWith("0") && !t.startsWith("00") ? t.substring(1) : t;
|
|
525
|
-
}
|
|
526
|
-
function Ze(e) {
|
|
527
|
-
return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
|
|
528
|
-
}
|
|
529
|
-
function At(e, ...t) {
|
|
530
|
-
if (!Ze(e))
|
|
531
|
-
throw new Error("Uint8Array expected");
|
|
532
|
-
if (t.length > 0 && !t.includes(e.length))
|
|
533
|
-
throw new Error("Uint8Array expected of length " + t + ", got length=" + e.length);
|
|
534
|
-
}
|
|
535
|
-
function Dt(e, t = !0) {
|
|
536
|
-
if (e.destroyed)
|
|
537
|
-
throw new Error("Hash instance has been destroyed");
|
|
538
|
-
if (t && e.finished)
|
|
539
|
-
throw new Error("Hash#digest() has already been called");
|
|
540
|
-
}
|
|
541
|
-
function je(e, t) {
|
|
542
|
-
At(e);
|
|
543
|
-
const n = t.outputLen;
|
|
544
|
-
if (e.length < n)
|
|
545
|
-
throw new Error("digestInto() expects output buffer of length at least " + n);
|
|
546
|
-
}
|
|
547
|
-
function yt(...e) {
|
|
548
|
-
for (let t = 0; t < e.length; t++)
|
|
549
|
-
e[t].fill(0);
|
|
550
|
-
}
|
|
551
|
-
function dt(e) {
|
|
552
|
-
return new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
553
|
-
}
|
|
554
|
-
function Z(e, t) {
|
|
555
|
-
return e << 32 - t | e >>> t;
|
|
556
|
-
}
|
|
557
|
-
function Ve(e) {
|
|
558
|
-
if (typeof e != "string")
|
|
559
|
-
throw new Error("string expected");
|
|
560
|
-
return new Uint8Array(new TextEncoder().encode(e));
|
|
561
|
-
}
|
|
562
|
-
function oe(e) {
|
|
563
|
-
return typeof e == "string" && (e = Ve(e)), At(e), e;
|
|
564
|
-
}
|
|
565
|
-
class ke {
|
|
566
|
-
}
|
|
567
|
-
function Ye(e) {
|
|
568
|
-
const t = (o) => e().update(oe(o)).digest(), n = e();
|
|
569
|
-
return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = () => e(), t;
|
|
570
|
-
}
|
|
571
|
-
function ze(e, t, n, o) {
|
|
572
|
-
if (typeof e.setBigUint64 == "function")
|
|
573
|
-
return e.setBigUint64(t, n, o);
|
|
574
|
-
const r = BigInt(32), s = BigInt(4294967295), a = Number(n >> r & s), u = Number(n & s), i = o ? 4 : 0, x = o ? 0 : 4;
|
|
575
|
-
e.setUint32(t + i, a, o), e.setUint32(t + x, u, o);
|
|
576
|
-
}
|
|
577
|
-
function Ke(e, t, n) {
|
|
578
|
-
return e & t ^ ~e & n;
|
|
579
|
-
}
|
|
580
|
-
function Xe(e, t, n) {
|
|
581
|
-
return e & t ^ e & n ^ t & n;
|
|
582
|
-
}
|
|
583
|
-
let We = class extends ke {
|
|
584
|
-
constructor(t, n, o, r) {
|
|
585
|
-
super(), this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.blockLen = t, this.outputLen = n, this.padOffset = o, this.isLE = r, this.buffer = new Uint8Array(t), this.view = dt(this.buffer);
|
|
586
|
-
}
|
|
587
|
-
update(t) {
|
|
588
|
-
Dt(this), t = oe(t), At(t);
|
|
589
|
-
const { view: n, buffer: o, blockLen: r } = this, s = t.length;
|
|
590
|
-
for (let a = 0; a < s; ) {
|
|
591
|
-
const u = Math.min(r - this.pos, s - a);
|
|
592
|
-
if (u === r) {
|
|
593
|
-
const i = dt(t);
|
|
594
|
-
for (; r <= s - a; a += r)
|
|
595
|
-
this.process(i, a);
|
|
596
|
-
continue;
|
|
597
|
-
}
|
|
598
|
-
o.set(t.subarray(a, a + u), this.pos), this.pos += u, a += u, this.pos === r && (this.process(n, 0), this.pos = 0);
|
|
599
|
-
}
|
|
600
|
-
return this.length += t.length, this.roundClean(), this;
|
|
601
|
-
}
|
|
602
|
-
digestInto(t) {
|
|
603
|
-
Dt(this), je(t, this), this.finished = !0;
|
|
604
|
-
const { buffer: n, view: o, blockLen: r, isLE: s } = this;
|
|
605
|
-
let { pos: a } = this;
|
|
606
|
-
n[a++] = 128, yt(this.buffer.subarray(a)), this.padOffset > r - a && (this.process(o, 0), a = 0);
|
|
607
|
-
for (let w = a; w < r; w++)
|
|
608
|
-
n[w] = 0;
|
|
609
|
-
ze(o, r - 8, BigInt(this.length * 8), s), this.process(o, 0);
|
|
610
|
-
const u = dt(t), i = this.outputLen;
|
|
611
|
-
if (i % 4)
|
|
612
|
-
throw new Error("_sha2: outputLen should be aligned to 32bit");
|
|
613
|
-
const x = i / 4, y = this.get();
|
|
614
|
-
if (x > y.length)
|
|
615
|
-
throw new Error("_sha2: outputLen bigger than state");
|
|
616
|
-
for (let w = 0; w < x; w++)
|
|
617
|
-
u.setUint32(4 * w, y[w], s);
|
|
618
|
-
}
|
|
619
|
-
digest() {
|
|
620
|
-
const { buffer: t, outputLen: n } = this;
|
|
621
|
-
this.digestInto(t);
|
|
622
|
-
const o = t.slice(0, n);
|
|
623
|
-
return this.destroy(), o;
|
|
624
|
-
}
|
|
625
|
-
_cloneInto(t) {
|
|
626
|
-
t || (t = new this.constructor()), t.set(...this.get());
|
|
627
|
-
const { blockLen: n, buffer: o, length: r, finished: s, destroyed: a, pos: u } = this;
|
|
628
|
-
return t.destroyed = a, t.finished = s, t.length = r, t.pos = u, r % n && t.buffer.set(o), t;
|
|
629
|
-
}
|
|
630
|
-
clone() {
|
|
631
|
-
return this._cloneInto();
|
|
632
|
-
}
|
|
633
|
-
};
|
|
634
|
-
const Y = /* @__PURE__ */ Uint32Array.from([
|
|
635
|
-
1779033703,
|
|
636
|
-
3144134277,
|
|
637
|
-
1013904242,
|
|
638
|
-
2773480762,
|
|
639
|
-
1359893119,
|
|
640
|
-
2600822924,
|
|
641
|
-
528734635,
|
|
642
|
-
1541459225
|
|
643
|
-
]), Pe = /* @__PURE__ */ Uint32Array.from([
|
|
644
|
-
1116352408,
|
|
645
|
-
1899447441,
|
|
646
|
-
3049323471,
|
|
647
|
-
3921009573,
|
|
648
|
-
961987163,
|
|
649
|
-
1508970993,
|
|
650
|
-
2453635748,
|
|
651
|
-
2870763221,
|
|
652
|
-
3624381080,
|
|
653
|
-
310598401,
|
|
654
|
-
607225278,
|
|
655
|
-
1426881987,
|
|
656
|
-
1925078388,
|
|
657
|
-
2162078206,
|
|
658
|
-
2614888103,
|
|
659
|
-
3248222580,
|
|
660
|
-
3835390401,
|
|
661
|
-
4022224774,
|
|
662
|
-
264347078,
|
|
663
|
-
604807628,
|
|
664
|
-
770255983,
|
|
665
|
-
1249150122,
|
|
666
|
-
1555081692,
|
|
667
|
-
1996064986,
|
|
668
|
-
2554220882,
|
|
669
|
-
2821834349,
|
|
670
|
-
2952996808,
|
|
671
|
-
3210313671,
|
|
672
|
-
3336571891,
|
|
673
|
-
3584528711,
|
|
674
|
-
113926993,
|
|
675
|
-
338241895,
|
|
676
|
-
666307205,
|
|
677
|
-
773529912,
|
|
678
|
-
1294757372,
|
|
679
|
-
1396182291,
|
|
680
|
-
1695183700,
|
|
681
|
-
1986661051,
|
|
682
|
-
2177026350,
|
|
683
|
-
2456956037,
|
|
684
|
-
2730485921,
|
|
685
|
-
2820302411,
|
|
686
|
-
3259730800,
|
|
687
|
-
3345764771,
|
|
688
|
-
3516065817,
|
|
689
|
-
3600352804,
|
|
690
|
-
4094571909,
|
|
691
|
-
275423344,
|
|
692
|
-
430227734,
|
|
693
|
-
506948616,
|
|
694
|
-
659060556,
|
|
695
|
-
883997877,
|
|
696
|
-
958139571,
|
|
697
|
-
1322822218,
|
|
698
|
-
1537002063,
|
|
699
|
-
1747873779,
|
|
700
|
-
1955562222,
|
|
701
|
-
2024104815,
|
|
702
|
-
2227730452,
|
|
703
|
-
2361852424,
|
|
704
|
-
2428436474,
|
|
705
|
-
2756734187,
|
|
706
|
-
3204031479,
|
|
707
|
-
3329325298
|
|
708
|
-
]), z = /* @__PURE__ */ new Uint32Array(64);
|
|
709
|
-
class Fe extends We {
|
|
710
|
-
constructor(t = 32) {
|
|
711
|
-
super(64, t, 8, !1), this.A = Y[0] | 0, this.B = Y[1] | 0, this.C = Y[2] | 0, this.D = Y[3] | 0, this.E = Y[4] | 0, this.F = Y[5] | 0, this.G = Y[6] | 0, this.H = Y[7] | 0;
|
|
712
|
-
}
|
|
713
|
-
get() {
|
|
714
|
-
const { A: t, B: n, C: o, D: r, E: s, F: a, G: u, H: i } = this;
|
|
715
|
-
return [t, n, o, r, s, a, u, i];
|
|
716
|
-
}
|
|
717
|
-
// prettier-ignore
|
|
718
|
-
set(t, n, o, r, s, a, u, i) {
|
|
719
|
-
this.A = t | 0, this.B = n | 0, this.C = o | 0, this.D = r | 0, this.E = s | 0, this.F = a | 0, this.G = u | 0, this.H = i | 0;
|
|
720
|
-
}
|
|
721
|
-
process(t, n) {
|
|
722
|
-
for (let w = 0; w < 16; w++, n += 4)
|
|
723
|
-
z[w] = t.getUint32(n, !1);
|
|
724
|
-
for (let w = 16; w < 64; w++) {
|
|
725
|
-
const S = z[w - 15], I = z[w - 2], v = Z(S, 7) ^ Z(S, 18) ^ S >>> 3, O = Z(I, 17) ^ Z(I, 19) ^ I >>> 10;
|
|
726
|
-
z[w] = O + z[w - 7] + v + z[w - 16] | 0;
|
|
727
|
-
}
|
|
728
|
-
let { A: o, B: r, C: s, D: a, E: u, F: i, G: x, H: y } = this;
|
|
729
|
-
for (let w = 0; w < 64; w++) {
|
|
730
|
-
const S = Z(u, 6) ^ Z(u, 11) ^ Z(u, 25), I = y + S + Ke(u, i, x) + Pe[w] + z[w] | 0, O = (Z(o, 2) ^ Z(o, 13) ^ Z(o, 22)) + Xe(o, r, s) | 0;
|
|
731
|
-
y = x, x = i, i = u, u = a + I | 0, a = s, s = r, r = o, o = I + O | 0;
|
|
732
|
-
}
|
|
733
|
-
o = o + this.A | 0, r = r + this.B | 0, s = s + this.C | 0, a = a + this.D | 0, u = u + this.E | 0, i = i + this.F | 0, x = x + this.G | 0, y = y + this.H | 0, this.set(o, r, s, a, u, i, x, y);
|
|
734
|
-
}
|
|
735
|
-
roundClean() {
|
|
736
|
-
yt(z);
|
|
737
|
-
}
|
|
738
|
-
destroy() {
|
|
739
|
-
this.set(0, 0, 0, 0, 0, 0, 0, 0), yt(this.buffer);
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
const Qe = /* @__PURE__ */ Ye(() => new Fe());
|
|
743
|
-
function se(e) {
|
|
744
483
|
return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
|
|
745
484
|
}
|
|
746
485
|
function Rt(e, t = "") {
|
|
@@ -750,43 +489,43 @@ function Rt(e, t = "") {
|
|
|
750
489
|
}
|
|
751
490
|
}
|
|
752
491
|
function D(e, t, n = "") {
|
|
753
|
-
const o =
|
|
492
|
+
const o = re(e), r = e?.length, s = t !== void 0;
|
|
754
493
|
if (!o || s && r !== t) {
|
|
755
|
-
const
|
|
756
|
-
throw new Error(
|
|
494
|
+
const c = n && `"${n}" `, u = s ? ` of length ${t}` : "", i = o ? `length=${r}` : `type=${typeof e}`;
|
|
495
|
+
throw new Error(c + "expected Uint8Array" + u + ", got " + i);
|
|
757
496
|
}
|
|
758
497
|
return e;
|
|
759
498
|
}
|
|
760
|
-
function
|
|
499
|
+
function Dt(e, t = !0) {
|
|
761
500
|
if (e.destroyed)
|
|
762
501
|
throw new Error("Hash instance has been destroyed");
|
|
763
502
|
if (t && e.finished)
|
|
764
503
|
throw new Error("Hash#digest() has already been called");
|
|
765
504
|
}
|
|
766
|
-
function
|
|
505
|
+
function $e(e, t) {
|
|
767
506
|
D(e, void 0, "digestInto() output");
|
|
768
507
|
const n = t.outputLen;
|
|
769
508
|
if (e.length < n)
|
|
770
509
|
throw new Error('"digestInto() output" expected to be of length >=' + n);
|
|
771
510
|
}
|
|
772
|
-
function
|
|
511
|
+
function mt(...e) {
|
|
773
512
|
for (let t = 0; t < e.length; t++)
|
|
774
513
|
e[t].fill(0);
|
|
775
514
|
}
|
|
776
|
-
function
|
|
515
|
+
function lt(e) {
|
|
777
516
|
return new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
778
517
|
}
|
|
779
|
-
const
|
|
518
|
+
const oe = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", Ze = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
|
|
780
519
|
function It(e) {
|
|
781
|
-
if (D(e),
|
|
520
|
+
if (D(e), oe)
|
|
782
521
|
return e.toHex();
|
|
783
522
|
let t = "";
|
|
784
523
|
for (let n = 0; n < e.length; n++)
|
|
785
|
-
t +=
|
|
524
|
+
t += Ze[e[n]];
|
|
786
525
|
return t;
|
|
787
526
|
}
|
|
788
527
|
const V = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
|
789
|
-
function
|
|
528
|
+
function qt(e) {
|
|
790
529
|
if (e >= V._0 && e <= V._9)
|
|
791
530
|
return e - V._0;
|
|
792
531
|
if (e >= V.A && e <= V.F)
|
|
@@ -794,26 +533,26 @@ function Mt(e) {
|
|
|
794
533
|
if (e >= V.a && e <= V.f)
|
|
795
534
|
return e - (V.a - 10);
|
|
796
535
|
}
|
|
797
|
-
function
|
|
536
|
+
function se(e) {
|
|
798
537
|
if (typeof e != "string")
|
|
799
538
|
throw new Error("hex string expected, got " + typeof e);
|
|
800
|
-
if (
|
|
539
|
+
if (oe)
|
|
801
540
|
return Uint8Array.fromHex(e);
|
|
802
541
|
const t = e.length, n = t / 2;
|
|
803
542
|
if (t % 2)
|
|
804
543
|
throw new Error("hex string expected, got unpadded hex of length " + t);
|
|
805
544
|
const o = new Uint8Array(n);
|
|
806
545
|
for (let r = 0, s = 0; r < n; r++, s += 2) {
|
|
807
|
-
const
|
|
808
|
-
if (
|
|
546
|
+
const c = qt(e.charCodeAt(s)), u = qt(e.charCodeAt(s + 1));
|
|
547
|
+
if (c === void 0 || u === void 0) {
|
|
809
548
|
const i = e[s] + e[s + 1];
|
|
810
549
|
throw new Error('hex string expected, got non-hex character "' + i + '" at index ' + s);
|
|
811
550
|
}
|
|
812
|
-
o[r] =
|
|
551
|
+
o[r] = c * 16 + u;
|
|
813
552
|
}
|
|
814
553
|
return o;
|
|
815
554
|
}
|
|
816
|
-
function
|
|
555
|
+
function Mt(...e) {
|
|
817
556
|
let t = 0;
|
|
818
557
|
for (let o = 0; o < e.length; o++) {
|
|
819
558
|
const r = e[o];
|
|
@@ -826,20 +565,20 @@ function Gt(...e) {
|
|
|
826
565
|
}
|
|
827
566
|
return n;
|
|
828
567
|
}
|
|
829
|
-
function
|
|
568
|
+
function je(e, t = {}) {
|
|
830
569
|
const n = (r, s) => e(s).update(r).digest(), o = e(void 0);
|
|
831
570
|
return n.outputLen = o.outputLen, n.blockLen = o.blockLen, n.create = (r) => e(r), Object.assign(n, t), Object.freeze(n);
|
|
832
571
|
}
|
|
833
|
-
function
|
|
572
|
+
function Ve(e = 32) {
|
|
834
573
|
const t = typeof globalThis == "object" ? globalThis.crypto : null;
|
|
835
574
|
if (typeof t?.getRandomValues != "function")
|
|
836
575
|
throw new Error("crypto.getRandomValues must be defined");
|
|
837
576
|
return t.getRandomValues(new Uint8Array(e));
|
|
838
577
|
}
|
|
839
|
-
const
|
|
578
|
+
const ke = (e) => ({
|
|
840
579
|
oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, e])
|
|
841
580
|
});
|
|
842
|
-
class
|
|
581
|
+
let Ke = class {
|
|
843
582
|
blockLen;
|
|
844
583
|
outputLen;
|
|
845
584
|
padOffset;
|
|
@@ -852,39 +591,39 @@ class on {
|
|
|
852
591
|
pos = 0;
|
|
853
592
|
destroyed = !1;
|
|
854
593
|
constructor(t, n, o, r) {
|
|
855
|
-
this.blockLen = t, this.outputLen = n, this.padOffset = o, this.isLE = r, this.buffer = new Uint8Array(t), this.view =
|
|
594
|
+
this.blockLen = t, this.outputLen = n, this.padOffset = o, this.isLE = r, this.buffer = new Uint8Array(t), this.view = lt(this.buffer);
|
|
856
595
|
}
|
|
857
596
|
update(t) {
|
|
858
|
-
|
|
597
|
+
Dt(this), D(t);
|
|
859
598
|
const { view: n, buffer: o, blockLen: r } = this, s = t.length;
|
|
860
|
-
for (let
|
|
861
|
-
const u = Math.min(r - this.pos, s -
|
|
599
|
+
for (let c = 0; c < s; ) {
|
|
600
|
+
const u = Math.min(r - this.pos, s - c);
|
|
862
601
|
if (u === r) {
|
|
863
|
-
const i =
|
|
864
|
-
for (; r <= s -
|
|
865
|
-
this.process(i,
|
|
602
|
+
const i = lt(t);
|
|
603
|
+
for (; r <= s - c; c += r)
|
|
604
|
+
this.process(i, c);
|
|
866
605
|
continue;
|
|
867
606
|
}
|
|
868
|
-
o.set(t.subarray(
|
|
607
|
+
o.set(t.subarray(c, c + u), this.pos), this.pos += u, c += u, this.pos === r && (this.process(n, 0), this.pos = 0);
|
|
869
608
|
}
|
|
870
609
|
return this.length += t.length, this.roundClean(), this;
|
|
871
610
|
}
|
|
872
611
|
digestInto(t) {
|
|
873
|
-
|
|
612
|
+
Dt(this), $e(t, this), this.finished = !0;
|
|
874
613
|
const { buffer: n, view: o, blockLen: r, isLE: s } = this;
|
|
875
|
-
let { pos:
|
|
876
|
-
n[
|
|
877
|
-
for (let w =
|
|
614
|
+
let { pos: c } = this;
|
|
615
|
+
n[c++] = 128, mt(this.buffer.subarray(c)), this.padOffset > r - c && (this.process(o, 0), c = 0);
|
|
616
|
+
for (let w = c; w < r; w++)
|
|
878
617
|
n[w] = 0;
|
|
879
618
|
o.setBigUint64(r - 8, BigInt(this.length * 8), s), this.process(o, 0);
|
|
880
|
-
const u =
|
|
619
|
+
const u = lt(t), i = this.outputLen;
|
|
881
620
|
if (i % 4)
|
|
882
621
|
throw new Error("_sha2: outputLen must be aligned to 32bit");
|
|
883
|
-
const x = i / 4,
|
|
884
|
-
if (x >
|
|
622
|
+
const x = i / 4, m = this.get();
|
|
623
|
+
if (x > m.length)
|
|
885
624
|
throw new Error("_sha2: outputLen bigger than state");
|
|
886
625
|
for (let w = 0; w < x; w++)
|
|
887
|
-
u.setUint32(4 * w,
|
|
626
|
+
u.setUint32(4 * w, m[w], s);
|
|
888
627
|
}
|
|
889
628
|
digest() {
|
|
890
629
|
const { buffer: t, outputLen: n } = this;
|
|
@@ -894,13 +633,13 @@ class on {
|
|
|
894
633
|
}
|
|
895
634
|
_cloneInto(t) {
|
|
896
635
|
t ||= new this.constructor(), t.set(...this.get());
|
|
897
|
-
const { blockLen: n, buffer: o, length: r, finished: s, destroyed:
|
|
898
|
-
return t.destroyed =
|
|
636
|
+
const { blockLen: n, buffer: o, length: r, finished: s, destroyed: c, pos: u } = this;
|
|
637
|
+
return t.destroyed = c, t.finished = s, t.length = r, t.pos = u, r % n && t.buffer.set(o), t;
|
|
899
638
|
}
|
|
900
639
|
clone() {
|
|
901
640
|
return this._cloneInto();
|
|
902
641
|
}
|
|
903
|
-
}
|
|
642
|
+
};
|
|
904
643
|
const M = /* @__PURE__ */ Uint32Array.from([
|
|
905
644
|
1779033703,
|
|
906
645
|
4089235720,
|
|
@@ -918,25 +657,25 @@ const M = /* @__PURE__ */ Uint32Array.from([
|
|
|
918
657
|
4215389547,
|
|
919
658
|
1541459225,
|
|
920
659
|
327033209
|
|
921
|
-
]), rt = /* @__PURE__ */ BigInt(2 ** 32 - 1),
|
|
922
|
-
function
|
|
923
|
-
return t ? { h: Number(e & rt), l: Number(e >>
|
|
660
|
+
]), rt = /* @__PURE__ */ BigInt(2 ** 32 - 1), Gt = /* @__PURE__ */ BigInt(32);
|
|
661
|
+
function Ye(e, t = !1) {
|
|
662
|
+
return t ? { h: Number(e & rt), l: Number(e >> Gt & rt) } : { h: Number(e >> Gt & rt) | 0, l: Number(e & rt) | 0 };
|
|
924
663
|
}
|
|
925
|
-
function
|
|
664
|
+
function ze(e, t = !1) {
|
|
926
665
|
const n = e.length;
|
|
927
666
|
let o = new Uint32Array(n), r = new Uint32Array(n);
|
|
928
667
|
for (let s = 0; s < n; s++) {
|
|
929
|
-
const { h:
|
|
930
|
-
[o[s], r[s]] = [
|
|
668
|
+
const { h: c, l: u } = Ye(e[s], t);
|
|
669
|
+
[o[s], r[s]] = [c, u];
|
|
931
670
|
}
|
|
932
671
|
return [o, r];
|
|
933
672
|
}
|
|
934
|
-
const
|
|
673
|
+
const $t = (e, t, n) => e >>> n, Zt = (e, t, n) => e << 32 - n | t >>> n, J = (e, t, n) => e >>> n | t << 32 - n, tt = (e, t, n) => e << 32 - n | t >>> n, ot = (e, t, n) => e << 64 - n | t >>> n - 32, st = (e, t, n) => e >>> n - 32 | t << 64 - n;
|
|
935
674
|
function k(e, t, n, o) {
|
|
936
675
|
const r = (t >>> 0) + (o >>> 0);
|
|
937
676
|
return { h: e + n + (r / 2 ** 32 | 0) | 0, l: r | 0 };
|
|
938
677
|
}
|
|
939
|
-
const
|
|
678
|
+
const Xe = (e, t, n) => (e >>> 0) + (t >>> 0) + (n >>> 0), We = (e, t, n, o) => t + n + o + (e / 2 ** 32 | 0) | 0, Pe = (e, t, n, o) => (e >>> 0) + (t >>> 0) + (n >>> 0) + (o >>> 0), Fe = (e, t, n, o, r) => t + n + o + r + (e / 2 ** 32 | 0) | 0, Qe = (e, t, n, o, r) => (e >>> 0) + (t >>> 0) + (n >>> 0) + (o >>> 0) + (r >>> 0), Je = (e, t, n, o, r, s) => t + n + o + r + s + (e / 2 ** 32 | 0) | 0, ie = ze([
|
|
940
679
|
"0x428a2f98d728ae22",
|
|
941
680
|
"0x7137449123ef65cd",
|
|
942
681
|
"0xb5c0fbcfec4d3b2f",
|
|
@@ -1017,44 +756,44 @@ const fn = (e, t, n) => (e >>> 0) + (t >>> 0) + (n >>> 0), an = (e, t, n, o) =>
|
|
|
1017
756
|
"0x597f299cfc657e2a",
|
|
1018
757
|
"0x5fcb6fab3ad6faec",
|
|
1019
758
|
"0x6c44198c4a475817"
|
|
1020
|
-
].map((e) => BigInt(e))),
|
|
1021
|
-
class
|
|
759
|
+
].map((e) => BigInt(e))), tn = ie[0], en = ie[1], K = /* @__PURE__ */ new Uint32Array(80), Y = /* @__PURE__ */ new Uint32Array(80);
|
|
760
|
+
class nn extends Ke {
|
|
1022
761
|
constructor(t) {
|
|
1023
762
|
super(128, t, 16, !1);
|
|
1024
763
|
}
|
|
1025
764
|
// prettier-ignore
|
|
1026
765
|
get() {
|
|
1027
|
-
const { Ah: t, Al: n, Bh: o, Bl: r, Ch: s, Cl:
|
|
1028
|
-
return [t, n, o, r, s,
|
|
766
|
+
const { Ah: t, Al: n, Bh: o, Bl: r, Ch: s, Cl: c, Dh: u, Dl: i, Eh: x, El: m, Fh: w, Fl: v, Gh: I, Gl: S, Hh: O, Hl: _ } = this;
|
|
767
|
+
return [t, n, o, r, s, c, u, i, x, m, w, v, I, S, O, _];
|
|
1029
768
|
}
|
|
1030
769
|
// prettier-ignore
|
|
1031
|
-
set(t, n, o, r, s,
|
|
1032
|
-
this.Ah = t | 0, this.Al = n | 0, this.Bh = o | 0, this.Bl = r | 0, this.Ch = s | 0, this.Cl =
|
|
770
|
+
set(t, n, o, r, s, c, u, i, x, m, w, v, I, S, O, _) {
|
|
771
|
+
this.Ah = t | 0, this.Al = n | 0, this.Bh = o | 0, this.Bl = r | 0, this.Ch = s | 0, this.Cl = c | 0, this.Dh = u | 0, this.Dl = i | 0, this.Eh = x | 0, this.El = m | 0, this.Fh = w | 0, this.Fl = v | 0, this.Gh = I | 0, this.Gl = S | 0, this.Hh = O | 0, this.Hl = _ | 0;
|
|
1033
772
|
}
|
|
1034
773
|
process(t, n) {
|
|
1035
774
|
for (let p = 0; p < 16; p++, n += 4)
|
|
1036
|
-
K[p] = t.getUint32(n),
|
|
775
|
+
K[p] = t.getUint32(n), Y[p] = t.getUint32(n += 4);
|
|
1037
776
|
for (let p = 16; p < 80; p++) {
|
|
1038
|
-
const N = K[p - 15] | 0, T =
|
|
1039
|
-
K[p] =
|
|
777
|
+
const N = K[p - 15] | 0, T = Y[p - 15] | 0, a = J(N, T, 1) ^ J(N, T, 8) ^ $t(N, T, 7), h = tt(N, T, 1) ^ tt(N, T, 8) ^ Zt(N, T, 7), f = K[p - 2] | 0, l = Y[p - 2] | 0, d = J(f, l, 19) ^ ot(f, l, 61) ^ $t(f, l, 6), b = tt(f, l, 19) ^ st(f, l, 61) ^ Zt(f, l, 6), g = Pe(h, b, Y[p - 7], Y[p - 16]), y = Fe(g, a, d, K[p - 7], K[p - 16]);
|
|
778
|
+
K[p] = y | 0, Y[p] = g | 0;
|
|
1040
779
|
}
|
|
1041
|
-
let { Ah: o, Al: r, Bh: s, Bl:
|
|
780
|
+
let { Ah: o, Al: r, Bh: s, Bl: c, Ch: u, Cl: i, Dh: x, Dl: m, Eh: w, El: v, Fh: I, Fl: S, Gh: O, Gl: _, Hh: E, Hl: A } = this;
|
|
1042
781
|
for (let p = 0; p < 80; p++) {
|
|
1043
|
-
const N = J(w,
|
|
1044
|
-
E = O | 0, A = _ | 0, O = I | 0, _ =
|
|
1045
|
-
const R =
|
|
1046
|
-
o =
|
|
782
|
+
const N = J(w, v, 14) ^ J(w, v, 18) ^ ot(w, v, 41), T = tt(w, v, 14) ^ tt(w, v, 18) ^ st(w, v, 41), a = w & I ^ ~w & O, h = v & S ^ ~v & _, f = Qe(A, T, h, en[p], Y[p]), l = Je(f, E, N, a, tn[p], K[p]), d = f | 0, b = J(o, r, 28) ^ ot(o, r, 34) ^ ot(o, r, 39), g = tt(o, r, 28) ^ st(o, r, 34) ^ st(o, r, 39), y = o & s ^ o & u ^ s & u, B = r & c ^ r & i ^ c & i;
|
|
783
|
+
E = O | 0, A = _ | 0, O = I | 0, _ = S | 0, I = w | 0, S = v | 0, { h: w, l: v } = k(x | 0, m | 0, l | 0, d | 0), x = u | 0, m = i | 0, u = s | 0, i = c | 0, s = o | 0, c = r | 0;
|
|
784
|
+
const R = Xe(d, g, B);
|
|
785
|
+
o = We(R, l, b, y), r = R | 0;
|
|
1047
786
|
}
|
|
1048
|
-
({ h: o, l: r } = k(this.Ah | 0, this.Al | 0, o | 0, r | 0)), { h: s, l:
|
|
787
|
+
({ h: o, l: r } = k(this.Ah | 0, this.Al | 0, o | 0, r | 0)), { h: s, l: c } = k(this.Bh | 0, this.Bl | 0, s | 0, c | 0), { h: u, l: i } = k(this.Ch | 0, this.Cl | 0, u | 0, i | 0), { h: x, l: m } = k(this.Dh | 0, this.Dl | 0, x | 0, m | 0), { h: w, l: v } = k(this.Eh | 0, this.El | 0, w | 0, v | 0), { h: I, l: S } = k(this.Fh | 0, this.Fl | 0, I | 0, S | 0), { h: O, l: _ } = k(this.Gh | 0, this.Gl | 0, O | 0, _ | 0), { h: E, l: A } = k(this.Hh | 0, this.Hl | 0, E | 0, A | 0), this.set(o, r, s, c, u, i, x, m, w, v, I, S, O, _, E, A);
|
|
1049
788
|
}
|
|
1050
789
|
roundClean() {
|
|
1051
|
-
|
|
790
|
+
mt(K, Y);
|
|
1052
791
|
}
|
|
1053
792
|
destroy() {
|
|
1054
|
-
|
|
793
|
+
mt(this.buffer), this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
1055
794
|
}
|
|
1056
795
|
}
|
|
1057
|
-
class
|
|
796
|
+
class rn extends nn {
|
|
1058
797
|
Ah = M[0] | 0;
|
|
1059
798
|
Al = M[1] | 0;
|
|
1060
799
|
Bh = M[2] | 0;
|
|
@@ -1075,19 +814,19 @@ class xn extends wn {
|
|
|
1075
814
|
super(64);
|
|
1076
815
|
}
|
|
1077
816
|
}
|
|
1078
|
-
const
|
|
1079
|
-
() => new
|
|
1080
|
-
/* @__PURE__ */
|
|
817
|
+
const on = /* @__PURE__ */ je(
|
|
818
|
+
() => new rn(),
|
|
819
|
+
/* @__PURE__ */ ke(3)
|
|
1081
820
|
);
|
|
1082
|
-
const
|
|
1083
|
-
function
|
|
821
|
+
const ce = /* @__PURE__ */ BigInt(0), jt = /* @__PURE__ */ BigInt(1);
|
|
822
|
+
function Et(e, t = "") {
|
|
1084
823
|
if (typeof e != "boolean") {
|
|
1085
824
|
const n = t && `"${t}" `;
|
|
1086
825
|
throw new Error(n + "expected boolean, got type=" + typeof e);
|
|
1087
826
|
}
|
|
1088
827
|
return e;
|
|
1089
828
|
}
|
|
1090
|
-
function
|
|
829
|
+
function sn(e) {
|
|
1091
830
|
if (typeof e == "bigint") {
|
|
1092
831
|
if (!ct(e))
|
|
1093
832
|
throw new Error("positive bigint expected, got " + e);
|
|
@@ -1095,54 +834,54 @@ function mn(e) {
|
|
|
1095
834
|
Rt(e);
|
|
1096
835
|
return e;
|
|
1097
836
|
}
|
|
1098
|
-
function
|
|
837
|
+
function fe(e) {
|
|
1099
838
|
if (typeof e != "string")
|
|
1100
839
|
throw new Error("hex string expected, got " + typeof e);
|
|
1101
|
-
return e === "" ?
|
|
840
|
+
return e === "" ? ce : BigInt("0x" + e);
|
|
1102
841
|
}
|
|
1103
|
-
function
|
|
1104
|
-
return
|
|
842
|
+
function cn(e) {
|
|
843
|
+
return fe(It(e));
|
|
1105
844
|
}
|
|
1106
845
|
function ft(e) {
|
|
1107
|
-
return
|
|
846
|
+
return fe(It(Bt(D(e)).reverse()));
|
|
1108
847
|
}
|
|
1109
|
-
function
|
|
1110
|
-
Rt(t), e =
|
|
1111
|
-
const n =
|
|
848
|
+
function ae(e, t) {
|
|
849
|
+
Rt(t), e = sn(e);
|
|
850
|
+
const n = se(e.toString(16).padStart(t * 2, "0"));
|
|
1112
851
|
if (n.length !== t)
|
|
1113
852
|
throw new Error("number too large");
|
|
1114
853
|
return n;
|
|
1115
854
|
}
|
|
1116
|
-
function
|
|
1117
|
-
return
|
|
855
|
+
function fn(e, t) {
|
|
856
|
+
return ae(e, t).reverse();
|
|
1118
857
|
}
|
|
1119
|
-
function
|
|
858
|
+
function Bt(e) {
|
|
1120
859
|
return Uint8Array.from(e);
|
|
1121
860
|
}
|
|
1122
|
-
const ct = (e) => typeof e == "bigint" &&
|
|
1123
|
-
function
|
|
861
|
+
const ct = (e) => typeof e == "bigint" && ce <= e;
|
|
862
|
+
function an(e, t, n) {
|
|
1124
863
|
return ct(e) && ct(t) && ct(n) && t <= e && e < n;
|
|
1125
864
|
}
|
|
1126
|
-
function
|
|
1127
|
-
if (!
|
|
865
|
+
function Vt(e, t, n, o) {
|
|
866
|
+
if (!an(t, n, o))
|
|
1128
867
|
throw new Error("expected valid " + e + ": " + n + " <= n < " + o + ", got " + t);
|
|
1129
868
|
}
|
|
1130
|
-
const
|
|
869
|
+
const un = (e) => (jt << BigInt(e)) - jt;
|
|
1131
870
|
function _t(e, t = {}, n = {}) {
|
|
1132
871
|
if (!e || typeof e != "object")
|
|
1133
872
|
throw new Error("expected valid options object");
|
|
1134
|
-
function o(s,
|
|
873
|
+
function o(s, c, u) {
|
|
1135
874
|
const i = e[s];
|
|
1136
875
|
if (u && i === void 0)
|
|
1137
876
|
return;
|
|
1138
877
|
const x = typeof i;
|
|
1139
|
-
if (x !==
|
|
1140
|
-
throw new Error(`param "${s}" is invalid: expected ${
|
|
878
|
+
if (x !== c || i === null)
|
|
879
|
+
throw new Error(`param "${s}" is invalid: expected ${c}, got ${x}`);
|
|
1141
880
|
}
|
|
1142
|
-
const r = (s,
|
|
881
|
+
const r = (s, c) => Object.entries(s).forEach(([u, i]) => o(u, i, c));
|
|
1143
882
|
r(t, !1), r(n, !0);
|
|
1144
883
|
}
|
|
1145
|
-
function
|
|
884
|
+
function kt(e) {
|
|
1146
885
|
const t = /* @__PURE__ */ new WeakMap();
|
|
1147
886
|
return (n, ...o) => {
|
|
1148
887
|
const r = t.get(n);
|
|
@@ -1152,91 +891,91 @@ function Yt(e) {
|
|
|
1152
891
|
return t.set(n, s), s;
|
|
1153
892
|
};
|
|
1154
893
|
}
|
|
1155
|
-
const $ = /* @__PURE__ */ BigInt(0), G = /* @__PURE__ */ BigInt(1), F = /* @__PURE__ */ BigInt(2),
|
|
1156
|
-
function
|
|
894
|
+
const $ = /* @__PURE__ */ BigInt(0), G = /* @__PURE__ */ BigInt(1), F = /* @__PURE__ */ BigInt(2), ue = /* @__PURE__ */ BigInt(3), he = /* @__PURE__ */ BigInt(4), le = /* @__PURE__ */ BigInt(5), hn = /* @__PURE__ */ BigInt(7), de = /* @__PURE__ */ BigInt(8), ln = /* @__PURE__ */ BigInt(9), be = /* @__PURE__ */ BigInt(16);
|
|
895
|
+
function H(e, t) {
|
|
1157
896
|
const n = e % t;
|
|
1158
897
|
return n >= $ ? n : t + n;
|
|
1159
898
|
}
|
|
1160
|
-
function
|
|
899
|
+
function Z(e, t, n) {
|
|
1161
900
|
let o = e;
|
|
1162
901
|
for (; t-- > $; )
|
|
1163
902
|
o *= o, o %= n;
|
|
1164
903
|
return o;
|
|
1165
904
|
}
|
|
1166
|
-
function
|
|
905
|
+
function Kt(e, t) {
|
|
1167
906
|
if (e === $)
|
|
1168
907
|
throw new Error("invert: expected non-zero number");
|
|
1169
908
|
if (t <= $)
|
|
1170
909
|
throw new Error("invert: expected positive modulus, got " + t);
|
|
1171
|
-
let n =
|
|
910
|
+
let n = H(e, t), o = t, r = $, s = G;
|
|
1172
911
|
for (; n !== $; ) {
|
|
1173
912
|
const u = o / n, i = o % n, x = r - s * u;
|
|
1174
913
|
o = n, n = i, r = s, s = x;
|
|
1175
914
|
}
|
|
1176
915
|
if (o !== G)
|
|
1177
916
|
throw new Error("invert: does not exist");
|
|
1178
|
-
return
|
|
917
|
+
return H(r, t);
|
|
1179
918
|
}
|
|
1180
919
|
function Nt(e, t, n) {
|
|
1181
920
|
if (!e.eql(e.sqr(t), n))
|
|
1182
921
|
throw new Error("Cannot find square root");
|
|
1183
922
|
}
|
|
1184
|
-
function
|
|
1185
|
-
const n = (e.ORDER + G) /
|
|
923
|
+
function ge(e, t) {
|
|
924
|
+
const n = (e.ORDER + G) / he, o = e.pow(t, n);
|
|
1186
925
|
return Nt(e, o, t), o;
|
|
1187
926
|
}
|
|
1188
|
-
function
|
|
1189
|
-
const n = (e.ORDER -
|
|
927
|
+
function dn(e, t) {
|
|
928
|
+
const n = (e.ORDER - le) / de, o = e.mul(t, F), r = e.pow(o, n), s = e.mul(t, r), c = e.mul(e.mul(s, F), r), u = e.mul(s, e.sub(c, e.ONE));
|
|
1190
929
|
return Nt(e, u, t), u;
|
|
1191
930
|
}
|
|
1192
|
-
function
|
|
1193
|
-
const t = Ot(e), n =
|
|
931
|
+
function bn(e) {
|
|
932
|
+
const t = Ot(e), n = we(e), o = n(t, t.neg(t.ONE)), r = n(t, o), s = n(t, t.neg(o)), c = (e + hn) / be;
|
|
1194
933
|
return (u, i) => {
|
|
1195
|
-
let x = u.pow(i,
|
|
1196
|
-
const w = u.mul(x, r),
|
|
1197
|
-
x = u.cmov(x,
|
|
1198
|
-
const O = u.eql(u.sqr(
|
|
934
|
+
let x = u.pow(i, c), m = u.mul(x, o);
|
|
935
|
+
const w = u.mul(x, r), v = u.mul(x, s), I = u.eql(u.sqr(m), i), S = u.eql(u.sqr(w), i);
|
|
936
|
+
x = u.cmov(x, m, I), m = u.cmov(v, w, S);
|
|
937
|
+
const O = u.eql(u.sqr(m), i), _ = u.cmov(x, m, O);
|
|
1199
938
|
return Nt(u, _, i), _;
|
|
1200
939
|
};
|
|
1201
940
|
}
|
|
1202
|
-
function
|
|
1203
|
-
if (e <
|
|
941
|
+
function we(e) {
|
|
942
|
+
if (e < ue)
|
|
1204
943
|
throw new Error("sqrt is not defined for small field");
|
|
1205
944
|
let t = e - G, n = 0;
|
|
1206
945
|
for (; t % F === $; )
|
|
1207
946
|
t /= F, n++;
|
|
1208
947
|
let o = F;
|
|
1209
948
|
const r = Ot(e);
|
|
1210
|
-
for (;
|
|
949
|
+
for (; Yt(r, o) === 1; )
|
|
1211
950
|
if (o++ > 1e3)
|
|
1212
951
|
throw new Error("Cannot find square root: probably non-prime P");
|
|
1213
952
|
if (n === 1)
|
|
1214
|
-
return
|
|
953
|
+
return ge;
|
|
1215
954
|
let s = r.pow(o, t);
|
|
1216
|
-
const
|
|
955
|
+
const c = (t + G) / F;
|
|
1217
956
|
return function(i, x) {
|
|
1218
957
|
if (i.is0(x))
|
|
1219
958
|
return x;
|
|
1220
|
-
if (
|
|
959
|
+
if (Yt(i, x) !== 1)
|
|
1221
960
|
throw new Error("Cannot find square root");
|
|
1222
|
-
let
|
|
1223
|
-
for (; !i.eql(
|
|
1224
|
-
if (i.is0(
|
|
961
|
+
let m = n, w = i.mul(i.ONE, s), v = i.pow(x, t), I = i.pow(x, c);
|
|
962
|
+
for (; !i.eql(v, i.ONE); ) {
|
|
963
|
+
if (i.is0(v))
|
|
1225
964
|
return i.ZERO;
|
|
1226
|
-
let
|
|
965
|
+
let S = 1, O = i.sqr(v);
|
|
1227
966
|
for (; !i.eql(O, i.ONE); )
|
|
1228
|
-
if (
|
|
967
|
+
if (S++, O = i.sqr(O), S === m)
|
|
1229
968
|
throw new Error("Cannot find square root");
|
|
1230
|
-
const _ = G << BigInt(
|
|
1231
|
-
|
|
969
|
+
const _ = G << BigInt(m - S - 1), E = i.pow(w, _);
|
|
970
|
+
m = S, w = i.sqr(E), v = i.mul(v, w), I = i.mul(I, E);
|
|
1232
971
|
}
|
|
1233
972
|
return I;
|
|
1234
973
|
};
|
|
1235
974
|
}
|
|
1236
|
-
function
|
|
1237
|
-
return e %
|
|
975
|
+
function gn(e) {
|
|
976
|
+
return e % he === ue ? ge : e % de === le ? dn : e % be === ln ? bn(e) : we(e);
|
|
1238
977
|
}
|
|
1239
|
-
const
|
|
978
|
+
const wn = (e, t) => (H(e, t) & G) === G, xn = [
|
|
1240
979
|
"create",
|
|
1241
980
|
"isValid",
|
|
1242
981
|
"is0",
|
|
@@ -1255,15 +994,15 @@ const Nn = (e, t) => (U(e, t) & G) === G, On = [
|
|
|
1255
994
|
"mulN",
|
|
1256
995
|
"sqrN"
|
|
1257
996
|
];
|
|
1258
|
-
function
|
|
997
|
+
function pn(e) {
|
|
1259
998
|
const t = {
|
|
1260
999
|
ORDER: "bigint",
|
|
1261
1000
|
BYTES: "number",
|
|
1262
1001
|
BITS: "number"
|
|
1263
|
-
}, n =
|
|
1002
|
+
}, n = xn.reduce((o, r) => (o[r] = "function", o), t);
|
|
1264
1003
|
return _t(e, n), e;
|
|
1265
1004
|
}
|
|
1266
|
-
function
|
|
1005
|
+
function yn(e, t, n) {
|
|
1267
1006
|
if (n < $)
|
|
1268
1007
|
throw new Error("invalid exponent, negatives unsupported");
|
|
1269
1008
|
if (n === $)
|
|
@@ -1275,22 +1014,22 @@ function Cn(e, t, n) {
|
|
|
1275
1014
|
n & G && (o = e.mul(o, r)), r = e.sqr(r), n >>= G;
|
|
1276
1015
|
return o;
|
|
1277
1016
|
}
|
|
1278
|
-
function
|
|
1279
|
-
const o = new Array(t.length).fill(n ? e.ZERO : void 0), r = t.reduce((
|
|
1280
|
-
return t.reduceRight((
|
|
1017
|
+
function xe(e, t, n = !1) {
|
|
1018
|
+
const o = new Array(t.length).fill(n ? e.ZERO : void 0), r = t.reduce((c, u, i) => e.is0(u) ? c : (o[i] = c, e.mul(c, u)), e.ONE), s = e.inv(r);
|
|
1019
|
+
return t.reduceRight((c, u, i) => e.is0(u) ? c : (o[i] = e.mul(c, o[i]), e.mul(c, u)), s), o;
|
|
1281
1020
|
}
|
|
1282
|
-
function
|
|
1283
|
-
const n = (e.ORDER - G) / F, o = e.pow(t, n), r = e.eql(o, e.ONE), s = e.eql(o, e.ZERO),
|
|
1284
|
-
if (!r && !s && !
|
|
1021
|
+
function Yt(e, t) {
|
|
1022
|
+
const n = (e.ORDER - G) / F, o = e.pow(t, n), r = e.eql(o, e.ONE), s = e.eql(o, e.ZERO), c = e.eql(o, e.neg(e.ONE));
|
|
1023
|
+
if (!r && !s && !c)
|
|
1285
1024
|
throw new Error("invalid Legendre symbol result");
|
|
1286
1025
|
return r ? 1 : s ? 0 : -1;
|
|
1287
1026
|
}
|
|
1288
|
-
function
|
|
1027
|
+
function mn(e, t) {
|
|
1289
1028
|
t !== void 0 && Rt(t);
|
|
1290
1029
|
const n = t !== void 0 ? t : e.toString(2).length, o = Math.ceil(n / 8);
|
|
1291
1030
|
return { nBitLength: n, nByteLength: o };
|
|
1292
1031
|
}
|
|
1293
|
-
class
|
|
1032
|
+
class En {
|
|
1294
1033
|
ORDER;
|
|
1295
1034
|
BITS;
|
|
1296
1035
|
BYTES;
|
|
@@ -1306,13 +1045,13 @@ class Un {
|
|
|
1306
1045
|
throw new Error("invalid field: expected ORDER > 0, got " + t);
|
|
1307
1046
|
let o;
|
|
1308
1047
|
this.isLE = !1, n != null && typeof n == "object" && (typeof n.BITS == "number" && (o = n.BITS), typeof n.sqrt == "function" && (this.sqrt = n.sqrt), typeof n.isLE == "boolean" && (this.isLE = n.isLE), n.allowedLengths && (this._lengths = n.allowedLengths?.slice()), typeof n.modFromBytes == "boolean" && (this._mod = n.modFromBytes));
|
|
1309
|
-
const { nBitLength: r, nByteLength: s } =
|
|
1048
|
+
const { nBitLength: r, nByteLength: s } = mn(t, o);
|
|
1310
1049
|
if (s > 2048)
|
|
1311
1050
|
throw new Error("invalid field: expected ORDER of <= 2048 bytes");
|
|
1312
1051
|
this.ORDER = t, this.BITS = r, this.BYTES = s, this._sqrt = void 0, Object.preventExtensions(this);
|
|
1313
1052
|
}
|
|
1314
1053
|
create(t) {
|
|
1315
|
-
return
|
|
1054
|
+
return H(t, this.ORDER);
|
|
1316
1055
|
}
|
|
1317
1056
|
isValid(t) {
|
|
1318
1057
|
if (typeof t != "bigint")
|
|
@@ -1330,28 +1069,28 @@ class Un {
|
|
|
1330
1069
|
return (t & G) === G;
|
|
1331
1070
|
}
|
|
1332
1071
|
neg(t) {
|
|
1333
|
-
return
|
|
1072
|
+
return H(-t, this.ORDER);
|
|
1334
1073
|
}
|
|
1335
1074
|
eql(t, n) {
|
|
1336
1075
|
return t === n;
|
|
1337
1076
|
}
|
|
1338
1077
|
sqr(t) {
|
|
1339
|
-
return
|
|
1078
|
+
return H(t * t, this.ORDER);
|
|
1340
1079
|
}
|
|
1341
1080
|
add(t, n) {
|
|
1342
|
-
return
|
|
1081
|
+
return H(t + n, this.ORDER);
|
|
1343
1082
|
}
|
|
1344
1083
|
sub(t, n) {
|
|
1345
|
-
return
|
|
1084
|
+
return H(t - n, this.ORDER);
|
|
1346
1085
|
}
|
|
1347
1086
|
mul(t, n) {
|
|
1348
|
-
return
|
|
1087
|
+
return H(t * n, this.ORDER);
|
|
1349
1088
|
}
|
|
1350
1089
|
pow(t, n) {
|
|
1351
|
-
return
|
|
1090
|
+
return yn(this, t, n);
|
|
1352
1091
|
}
|
|
1353
1092
|
div(t, n) {
|
|
1354
|
-
return
|
|
1093
|
+
return H(t * Kt(n, this.ORDER), this.ORDER);
|
|
1355
1094
|
}
|
|
1356
1095
|
// Same as above, but doesn't normalize
|
|
1357
1096
|
sqrN(t) {
|
|
@@ -1367,17 +1106,17 @@ class Un {
|
|
|
1367
1106
|
return t * n;
|
|
1368
1107
|
}
|
|
1369
1108
|
inv(t) {
|
|
1370
|
-
return
|
|
1109
|
+
return Kt(t, this.ORDER);
|
|
1371
1110
|
}
|
|
1372
1111
|
sqrt(t) {
|
|
1373
|
-
return this._sqrt || (this._sqrt =
|
|
1112
|
+
return this._sqrt || (this._sqrt = gn(this.ORDER)), this._sqrt(this, t);
|
|
1374
1113
|
}
|
|
1375
1114
|
toBytes(t) {
|
|
1376
|
-
return this.isLE ?
|
|
1115
|
+
return this.isLE ? fn(t, this.BYTES) : ae(t, this.BYTES);
|
|
1377
1116
|
}
|
|
1378
1117
|
fromBytes(t, n = !1) {
|
|
1379
1118
|
D(t);
|
|
1380
|
-
const { _lengths: o, BYTES: r, isLE: s, ORDER:
|
|
1119
|
+
const { _lengths: o, BYTES: r, isLE: s, ORDER: c, _mod: u } = this;
|
|
1381
1120
|
if (o) {
|
|
1382
1121
|
if (!o.includes(t.length) || t.length > r)
|
|
1383
1122
|
throw new Error("Field.fromBytes: expected " + o + " bytes, got " + t.length);
|
|
@@ -1386,14 +1125,14 @@ class Un {
|
|
|
1386
1125
|
}
|
|
1387
1126
|
if (t.length !== r)
|
|
1388
1127
|
throw new Error("Field.fromBytes: expected " + r + " bytes, got " + t.length);
|
|
1389
|
-
let i = s ? ft(t) :
|
|
1390
|
-
if (u && (i =
|
|
1128
|
+
let i = s ? ft(t) : cn(t);
|
|
1129
|
+
if (u && (i = H(i, c)), !n && !this.isValid(i))
|
|
1391
1130
|
throw new Error("invalid field element: outside of range 0..ORDER");
|
|
1392
1131
|
return i;
|
|
1393
1132
|
}
|
|
1394
1133
|
// TODO: we don't need it here, move out to separate fn
|
|
1395
1134
|
invertBatch(t) {
|
|
1396
|
-
return
|
|
1135
|
+
return xe(this, t);
|
|
1397
1136
|
}
|
|
1398
1137
|
// We can't move this out because Fp6, Fp12 implement it
|
|
1399
1138
|
// and it's unclear what to return in there.
|
|
@@ -1402,42 +1141,42 @@ class Un {
|
|
|
1402
1141
|
}
|
|
1403
1142
|
}
|
|
1404
1143
|
function Ot(e, t = {}) {
|
|
1405
|
-
return new
|
|
1144
|
+
return new En(e, t);
|
|
1406
1145
|
}
|
|
1407
1146
|
const at = /* @__PURE__ */ BigInt(0), vt = /* @__PURE__ */ BigInt(1);
|
|
1408
|
-
function
|
|
1147
|
+
function zt(e, t) {
|
|
1409
1148
|
const n = t.negate();
|
|
1410
1149
|
return e ? n : t;
|
|
1411
1150
|
}
|
|
1412
|
-
function
|
|
1413
|
-
const n =
|
|
1151
|
+
function dt(e, t) {
|
|
1152
|
+
const n = xe(e.Fp, t.map((o) => o.Z));
|
|
1414
1153
|
return t.map((o, r) => e.fromAffine(o.toAffine(n[r])));
|
|
1415
1154
|
}
|
|
1416
|
-
function
|
|
1155
|
+
function pe(e, t) {
|
|
1417
1156
|
if (!Number.isSafeInteger(e) || e <= 0 || e > t)
|
|
1418
1157
|
throw new Error("invalid window size, expected [1.." + t + "], got W=" + e);
|
|
1419
1158
|
}
|
|
1420
|
-
function
|
|
1421
|
-
|
|
1422
|
-
const n = Math.ceil(t / e) + 1, o = 2 ** (e - 1), r = 2 ** e, s =
|
|
1423
|
-
return { windows: n, windowSize: o, mask: s, maxNumber: r, shiftBy:
|
|
1159
|
+
function bt(e, t) {
|
|
1160
|
+
pe(e, t);
|
|
1161
|
+
const n = Math.ceil(t / e) + 1, o = 2 ** (e - 1), r = 2 ** e, s = un(e), c = BigInt(e);
|
|
1162
|
+
return { windows: n, windowSize: o, mask: s, maxNumber: r, shiftBy: c };
|
|
1424
1163
|
}
|
|
1425
|
-
function
|
|
1426
|
-
const { windowSize: o, mask: r, maxNumber: s, shiftBy:
|
|
1427
|
-
let u = Number(e & r), i = e >>
|
|
1164
|
+
function Xt(e, t, n) {
|
|
1165
|
+
const { windowSize: o, mask: r, maxNumber: s, shiftBy: c } = n;
|
|
1166
|
+
let u = Number(e & r), i = e >> c;
|
|
1428
1167
|
u > o && (u -= s, i += vt);
|
|
1429
|
-
const x = t * o,
|
|
1430
|
-
return { nextN: i, offset:
|
|
1168
|
+
const x = t * o, m = x + Math.abs(u) - 1, w = u === 0, v = u < 0, I = t % 2 !== 0;
|
|
1169
|
+
return { nextN: i, offset: m, isZero: w, isNeg: v, isNegF: I, offsetF: x };
|
|
1431
1170
|
}
|
|
1432
|
-
const
|
|
1433
|
-
function
|
|
1434
|
-
return
|
|
1171
|
+
const gt = /* @__PURE__ */ new WeakMap(), ye = /* @__PURE__ */ new WeakMap();
|
|
1172
|
+
function wt(e) {
|
|
1173
|
+
return ye.get(e) || 1;
|
|
1435
1174
|
}
|
|
1436
|
-
function
|
|
1175
|
+
function Wt(e) {
|
|
1437
1176
|
if (e !== at)
|
|
1438
1177
|
throw new Error("invalid wNAF");
|
|
1439
1178
|
}
|
|
1440
|
-
class
|
|
1179
|
+
class Bn {
|
|
1441
1180
|
BASE;
|
|
1442
1181
|
ZERO;
|
|
1443
1182
|
Fn;
|
|
@@ -1466,13 +1205,13 @@ class Hn {
|
|
|
1466
1205
|
* @returns precomputed point tables flattened to a single array
|
|
1467
1206
|
*/
|
|
1468
1207
|
precomputeWindow(t, n) {
|
|
1469
|
-
const { windows: o, windowSize: r } =
|
|
1470
|
-
let
|
|
1208
|
+
const { windows: o, windowSize: r } = bt(n, this.bits), s = [];
|
|
1209
|
+
let c = t, u = c;
|
|
1471
1210
|
for (let i = 0; i < o; i++) {
|
|
1472
|
-
u =
|
|
1211
|
+
u = c, s.push(u);
|
|
1473
1212
|
for (let x = 1; x < r; x++)
|
|
1474
|
-
u = u.add(
|
|
1475
|
-
|
|
1213
|
+
u = u.add(c), s.push(u);
|
|
1214
|
+
c = u.double();
|
|
1476
1215
|
}
|
|
1477
1216
|
return s;
|
|
1478
1217
|
}
|
|
@@ -1486,12 +1225,12 @@ class Hn {
|
|
|
1486
1225
|
if (!this.Fn.isValid(o))
|
|
1487
1226
|
throw new Error("invalid scalar");
|
|
1488
1227
|
let r = this.ZERO, s = this.BASE;
|
|
1489
|
-
const
|
|
1490
|
-
for (let u = 0; u <
|
|
1491
|
-
const { nextN: i, offset: x, isZero:
|
|
1492
|
-
o = i,
|
|
1228
|
+
const c = bt(t, this.bits);
|
|
1229
|
+
for (let u = 0; u < c.windows; u++) {
|
|
1230
|
+
const { nextN: i, offset: x, isZero: m, isNeg: w, isNegF: v, offsetF: I } = Xt(o, u, c);
|
|
1231
|
+
o = i, m ? s = s.add(zt(v, n[I])) : r = r.add(zt(w, n[x]));
|
|
1493
1232
|
}
|
|
1494
|
-
return
|
|
1233
|
+
return Wt(o), { p: r, f: s };
|
|
1495
1234
|
}
|
|
1496
1235
|
/**
|
|
1497
1236
|
* Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form.
|
|
@@ -1499,47 +1238,47 @@ class Hn {
|
|
|
1499
1238
|
* @returns point
|
|
1500
1239
|
*/
|
|
1501
1240
|
wNAFUnsafe(t, n, o, r = this.ZERO) {
|
|
1502
|
-
const s =
|
|
1503
|
-
for (let
|
|
1504
|
-
const { nextN: u, offset: i, isZero: x, isNeg:
|
|
1241
|
+
const s = bt(t, this.bits);
|
|
1242
|
+
for (let c = 0; c < s.windows && o !== at; c++) {
|
|
1243
|
+
const { nextN: u, offset: i, isZero: x, isNeg: m } = Xt(o, c, s);
|
|
1505
1244
|
if (o = u, !x) {
|
|
1506
1245
|
const w = n[i];
|
|
1507
|
-
r = r.add(
|
|
1246
|
+
r = r.add(m ? w.negate() : w);
|
|
1508
1247
|
}
|
|
1509
1248
|
}
|
|
1510
|
-
return
|
|
1249
|
+
return Wt(o), r;
|
|
1511
1250
|
}
|
|
1512
1251
|
getPrecomputes(t, n, o) {
|
|
1513
|
-
let r =
|
|
1514
|
-
return r || (r = this.precomputeWindow(n, t), t !== 1 && (typeof o == "function" && (r = o(r)),
|
|
1252
|
+
let r = gt.get(n);
|
|
1253
|
+
return r || (r = this.precomputeWindow(n, t), t !== 1 && (typeof o == "function" && (r = o(r)), gt.set(n, r))), r;
|
|
1515
1254
|
}
|
|
1516
1255
|
cached(t, n, o) {
|
|
1517
|
-
const r =
|
|
1256
|
+
const r = wt(t);
|
|
1518
1257
|
return this.wNAF(r, this.getPrecomputes(r, t, o), n);
|
|
1519
1258
|
}
|
|
1520
1259
|
unsafe(t, n, o, r) {
|
|
1521
|
-
const s =
|
|
1260
|
+
const s = wt(t);
|
|
1522
1261
|
return s === 1 ? this._unsafeLadder(t, n, r) : this.wNAFUnsafe(s, this.getPrecomputes(s, t, o), n, r);
|
|
1523
1262
|
}
|
|
1524
1263
|
// We calculate precomputes for elliptic curve point multiplication
|
|
1525
1264
|
// using windowed method. This specifies window size and
|
|
1526
1265
|
// stores precomputed values. Usually only base point would be precomputed.
|
|
1527
1266
|
createCache(t, n) {
|
|
1528
|
-
|
|
1267
|
+
pe(n, this.bits), ye.set(t, n), gt.delete(t);
|
|
1529
1268
|
}
|
|
1530
1269
|
hasCache(t) {
|
|
1531
|
-
return
|
|
1270
|
+
return wt(t) !== 1;
|
|
1532
1271
|
}
|
|
1533
1272
|
}
|
|
1534
|
-
function
|
|
1273
|
+
function Pt(e, t, n) {
|
|
1535
1274
|
if (t) {
|
|
1536
1275
|
if (t.ORDER !== e)
|
|
1537
1276
|
throw new Error("Field.ORDER must match order: Fp == p, Fn == n");
|
|
1538
|
-
return
|
|
1277
|
+
return pn(t), t;
|
|
1539
1278
|
} else
|
|
1540
1279
|
return Ot(e, { isLE: n });
|
|
1541
1280
|
}
|
|
1542
|
-
function
|
|
1281
|
+
function vn(e, t, n = {}, o) {
|
|
1543
1282
|
if (o === void 0 && (o = e === "edwards"), !t || typeof t != "object")
|
|
1544
1283
|
throw new Error(`expected valid ${e} CURVE object`);
|
|
1545
1284
|
for (const i of ["p", "n", "h"]) {
|
|
@@ -1547,71 +1286,71 @@ function Dn(e, t, n = {}, o) {
|
|
|
1547
1286
|
if (!(typeof x == "bigint" && x > at))
|
|
1548
1287
|
throw new Error(`CURVE.${i} must be positive bigint`);
|
|
1549
1288
|
}
|
|
1550
|
-
const r =
|
|
1289
|
+
const r = Pt(t.p, n.Fp, o), s = Pt(t.n, n.Fn, o), u = ["Gx", "Gy", "a", "d"];
|
|
1551
1290
|
for (const i of u)
|
|
1552
1291
|
if (!r.isValid(t[i]))
|
|
1553
1292
|
throw new Error(`CURVE.${i} must be valid field element of CURVE.Fp`);
|
|
1554
1293
|
return t = Object.freeze(Object.assign({}, t)), { CURVE: t, Fp: r, Fn: s };
|
|
1555
1294
|
}
|
|
1556
|
-
function
|
|
1295
|
+
function Sn(e, t) {
|
|
1557
1296
|
return function(o) {
|
|
1558
1297
|
const r = e(o);
|
|
1559
1298
|
return { secretKey: r, publicKey: t(r) };
|
|
1560
1299
|
};
|
|
1561
1300
|
}
|
|
1562
|
-
const
|
|
1563
|
-
function
|
|
1564
|
-
const r = e.sqr(n), s = e.sqr(o),
|
|
1565
|
-
return e.eql(
|
|
1301
|
+
const z = BigInt(0), U = BigInt(1), xt = BigInt(2), An = BigInt(8);
|
|
1302
|
+
function Rn(e, t, n, o) {
|
|
1303
|
+
const r = e.sqr(n), s = e.sqr(o), c = e.add(e.mul(t.a, r), s), u = e.add(e.ONE, e.mul(t.d, e.mul(r, s)));
|
|
1304
|
+
return e.eql(c, u);
|
|
1566
1305
|
}
|
|
1567
|
-
function
|
|
1568
|
-
const n =
|
|
1306
|
+
function In(e, t = {}) {
|
|
1307
|
+
const n = vn("edwards", e, t, t.FpFnLE), { Fp: o, Fn: r } = n;
|
|
1569
1308
|
let s = n.CURVE;
|
|
1570
|
-
const { h:
|
|
1309
|
+
const { h: c } = s;
|
|
1571
1310
|
_t(t, {}, { uvRatio: "function" });
|
|
1572
|
-
const u =
|
|
1311
|
+
const u = xt << BigInt(r.BYTES * 8) - U, i = (_) => o.create(_), x = t.uvRatio || ((_, E) => {
|
|
1573
1312
|
try {
|
|
1574
1313
|
return { isValid: !0, value: o.sqrt(o.div(_, E)) };
|
|
1575
1314
|
} catch {
|
|
1576
|
-
return { isValid: !1, value:
|
|
1315
|
+
return { isValid: !1, value: z };
|
|
1577
1316
|
}
|
|
1578
1317
|
});
|
|
1579
|
-
if (!
|
|
1318
|
+
if (!Rn(o, s, s.Gx, s.Gy))
|
|
1580
1319
|
throw new Error("bad curve params: generator point");
|
|
1581
|
-
function
|
|
1582
|
-
const p = A ?
|
|
1583
|
-
return
|
|
1320
|
+
function m(_, E, A = !1) {
|
|
1321
|
+
const p = A ? U : z;
|
|
1322
|
+
return Vt("coordinate " + _, E, p, u), E;
|
|
1584
1323
|
}
|
|
1585
1324
|
function w(_) {
|
|
1586
|
-
if (!(_ instanceof
|
|
1325
|
+
if (!(_ instanceof S))
|
|
1587
1326
|
throw new Error("EdwardsPoint expected");
|
|
1588
1327
|
}
|
|
1589
|
-
const
|
|
1328
|
+
const v = kt((_, E) => {
|
|
1590
1329
|
const { X: A, Y: p, Z: N } = _, T = _.is0();
|
|
1591
|
-
E == null && (E = T ?
|
|
1592
|
-
const
|
|
1330
|
+
E == null && (E = T ? An : o.inv(N));
|
|
1331
|
+
const a = i(A * E), h = i(p * E), f = o.mul(N, E);
|
|
1593
1332
|
if (T)
|
|
1594
|
-
return { x:
|
|
1595
|
-
if (
|
|
1333
|
+
return { x: z, y: U };
|
|
1334
|
+
if (f !== U)
|
|
1596
1335
|
throw new Error("invZ was invalid");
|
|
1597
|
-
return { x:
|
|
1598
|
-
}), I =
|
|
1336
|
+
return { x: a, y: h };
|
|
1337
|
+
}), I = kt((_) => {
|
|
1599
1338
|
const { a: E, d: A } = s;
|
|
1600
1339
|
if (_.is0())
|
|
1601
1340
|
throw new Error("bad point: ZERO");
|
|
1602
|
-
const { X: p, Y: N, Z: T, T:
|
|
1603
|
-
if (g !==
|
|
1341
|
+
const { X: p, Y: N, Z: T, T: a } = _, h = i(p * p), f = i(N * N), l = i(T * T), d = i(l * l), b = i(h * E), g = i(l * i(b + f)), y = i(d + i(A * i(h * f)));
|
|
1342
|
+
if (g !== y)
|
|
1604
1343
|
throw new Error("bad point: equation left != right (1)");
|
|
1605
|
-
const B = i(p * N), R = i(T *
|
|
1344
|
+
const B = i(p * N), R = i(T * a);
|
|
1606
1345
|
if (B !== R)
|
|
1607
1346
|
throw new Error("bad point: equation left != right (2)");
|
|
1608
1347
|
return !0;
|
|
1609
1348
|
});
|
|
1610
|
-
class
|
|
1349
|
+
class S {
|
|
1611
1350
|
// base / generator point
|
|
1612
|
-
static BASE = new
|
|
1351
|
+
static BASE = new S(s.Gx, s.Gy, U, i(s.Gx * s.Gy));
|
|
1613
1352
|
// zero / infinity / identity point
|
|
1614
|
-
static ZERO = new
|
|
1353
|
+
static ZERO = new S(z, U, U, z);
|
|
1615
1354
|
// 0, 1, 1, 0
|
|
1616
1355
|
// math field
|
|
1617
1356
|
static Fp = o;
|
|
@@ -1622,36 +1361,36 @@ function $n(e, t = {}) {
|
|
|
1622
1361
|
Z;
|
|
1623
1362
|
T;
|
|
1624
1363
|
constructor(E, A, p, N) {
|
|
1625
|
-
this.X =
|
|
1364
|
+
this.X = m("x", E), this.Y = m("y", A), this.Z = m("z", p, !0), this.T = m("t", N), Object.freeze(this);
|
|
1626
1365
|
}
|
|
1627
1366
|
static CURVE() {
|
|
1628
1367
|
return s;
|
|
1629
1368
|
}
|
|
1630
1369
|
static fromAffine(E) {
|
|
1631
|
-
if (E instanceof
|
|
1370
|
+
if (E instanceof S)
|
|
1632
1371
|
throw new Error("extended point not allowed");
|
|
1633
1372
|
const { x: A, y: p } = E || {};
|
|
1634
|
-
return
|
|
1373
|
+
return m("x", A), m("y", p), new S(A, p, U, i(A * p));
|
|
1635
1374
|
}
|
|
1636
1375
|
// Uses algo from RFC8032 5.1.3.
|
|
1637
1376
|
static fromBytes(E, A = !1) {
|
|
1638
1377
|
const p = o.BYTES, { a: N, d: T } = s;
|
|
1639
|
-
E =
|
|
1640
|
-
const
|
|
1641
|
-
|
|
1642
|
-
const
|
|
1643
|
-
|
|
1644
|
-
const d = i(
|
|
1645
|
-
let { isValid:
|
|
1646
|
-
if (!
|
|
1378
|
+
E = Bt(D(E, p, "point")), Et(A, "zip215");
|
|
1379
|
+
const a = Bt(E), h = E[p - 1];
|
|
1380
|
+
a[p - 1] = h & -129;
|
|
1381
|
+
const f = ft(a), l = A ? u : o.ORDER;
|
|
1382
|
+
Vt("point.y", f, z, l);
|
|
1383
|
+
const d = i(f * f), b = i(d - U), g = i(T * d - N);
|
|
1384
|
+
let { isValid: y, value: B } = x(b, g);
|
|
1385
|
+
if (!y)
|
|
1647
1386
|
throw new Error("bad point: invalid y coordinate");
|
|
1648
|
-
const R = (B &
|
|
1649
|
-
if (!A && B ===
|
|
1387
|
+
const R = (B & U) === U, C = (h & 128) !== 0;
|
|
1388
|
+
if (!A && B === z && C)
|
|
1650
1389
|
throw new Error("bad point: x=0 and x_0=1");
|
|
1651
|
-
return C !== R && (B = i(-B)),
|
|
1390
|
+
return C !== R && (B = i(-B)), S.fromAffine({ x: B, y: f });
|
|
1652
1391
|
}
|
|
1653
1392
|
static fromHex(E, A = !1) {
|
|
1654
|
-
return
|
|
1393
|
+
return S.fromBytes(se(E), A);
|
|
1655
1394
|
}
|
|
1656
1395
|
get x() {
|
|
1657
1396
|
return this.toAffine().x;
|
|
@@ -1660,7 +1399,7 @@ function $n(e, t = {}) {
|
|
|
1660
1399
|
return this.toAffine().y;
|
|
1661
1400
|
}
|
|
1662
1401
|
precompute(E = 8, A = !0) {
|
|
1663
|
-
return O.createCache(this, E), A || this.multiply(
|
|
1402
|
+
return O.createCache(this, E), A || this.multiply(xt), this;
|
|
1664
1403
|
}
|
|
1665
1404
|
// Useful in fromAffine() - not for fromBytes(), which always created valid points.
|
|
1666
1405
|
assertValidity() {
|
|
@@ -1669,29 +1408,29 @@ function $n(e, t = {}) {
|
|
|
1669
1408
|
// Compare one point to another.
|
|
1670
1409
|
equals(E) {
|
|
1671
1410
|
w(E);
|
|
1672
|
-
const { X: A, Y: p, Z: N } = this, { X: T, Y:
|
|
1673
|
-
return
|
|
1411
|
+
const { X: A, Y: p, Z: N } = this, { X: T, Y: a, Z: h } = E, f = i(A * h), l = i(T * N), d = i(p * h), b = i(a * N);
|
|
1412
|
+
return f === l && d === b;
|
|
1674
1413
|
}
|
|
1675
1414
|
is0() {
|
|
1676
|
-
return this.equals(
|
|
1415
|
+
return this.equals(S.ZERO);
|
|
1677
1416
|
}
|
|
1678
1417
|
negate() {
|
|
1679
|
-
return new
|
|
1418
|
+
return new S(i(-this.X), this.Y, this.Z, i(-this.T));
|
|
1680
1419
|
}
|
|
1681
1420
|
// Fast algo for doubling Extended Point.
|
|
1682
1421
|
// https://hyperelliptic.org/EFD/g1p/auto-twisted-extended.html#doubling-dbl-2008-hwcd
|
|
1683
1422
|
// Cost: 4M + 4S + 1*a + 6add + 1*2.
|
|
1684
1423
|
double() {
|
|
1685
|
-
const { a: E } = s, { X: A, Y: p, Z: N } = this, T = i(A * A),
|
|
1686
|
-
return new
|
|
1424
|
+
const { a: E } = s, { X: A, Y: p, Z: N } = this, T = i(A * A), a = i(p * p), h = i(xt * i(N * N)), f = i(E * T), l = A + p, d = i(i(l * l) - T - a), b = f + a, g = b - h, y = f - a, B = i(d * g), R = i(b * y), C = i(d * y), L = i(g * b);
|
|
1425
|
+
return new S(B, R, L, C);
|
|
1687
1426
|
}
|
|
1688
1427
|
// Fast algo for adding 2 Extended Points.
|
|
1689
1428
|
// https://hyperelliptic.org/EFD/g1p/auto-twisted-extended.html#addition-add-2008-hwcd
|
|
1690
1429
|
// Cost: 9M + 1*a + 1*d + 7add.
|
|
1691
1430
|
add(E) {
|
|
1692
1431
|
w(E);
|
|
1693
|
-
const { a: A, d: p } = s, { X: N, Y: T, Z:
|
|
1694
|
-
return new
|
|
1432
|
+
const { a: A, d: p } = s, { X: N, Y: T, Z: a, T: h } = this, { X: f, Y: l, Z: d, T: b } = E, g = i(N * f), y = i(T * l), B = i(h * p * b), R = i(a * d), C = i((N + T) * (f + l) - g - y), L = R - B, q = R + B, Q = i(y - A * g), nt = i(C * L), ut = i(q * Q), Lt = i(C * Q), Ht = i(L * q);
|
|
1433
|
+
return new S(nt, ut, Ht, Lt);
|
|
1695
1434
|
}
|
|
1696
1435
|
subtract(E) {
|
|
1697
1436
|
return this.add(E.negate());
|
|
@@ -1700,25 +1439,25 @@ function $n(e, t = {}) {
|
|
|
1700
1439
|
multiply(E) {
|
|
1701
1440
|
if (!r.isValidNot0(E))
|
|
1702
1441
|
throw new Error("invalid scalar: expected 1 <= sc < curve.n");
|
|
1703
|
-
const { p: A, f: p } = O.cached(this, E, (N) =>
|
|
1704
|
-
return
|
|
1442
|
+
const { p: A, f: p } = O.cached(this, E, (N) => dt(S, N));
|
|
1443
|
+
return dt(S, [A, p])[0];
|
|
1705
1444
|
}
|
|
1706
1445
|
// Non-constant-time multiplication. Uses double-and-add algorithm.
|
|
1707
1446
|
// It's faster, but should only be used when you don't care about
|
|
1708
1447
|
// an exposed private key e.g. sig verification.
|
|
1709
1448
|
// Does NOT allow scalars higher than CURVE.n.
|
|
1710
1449
|
// Accepts optional accumulator to merge with multiply (important for sparse scalars)
|
|
1711
|
-
multiplyUnsafe(E, A =
|
|
1450
|
+
multiplyUnsafe(E, A = S.ZERO) {
|
|
1712
1451
|
if (!r.isValid(E))
|
|
1713
1452
|
throw new Error("invalid scalar: expected 0 <= sc < curve.n");
|
|
1714
|
-
return E ===
|
|
1453
|
+
return E === z ? S.ZERO : this.is0() || E === U ? this : O.unsafe(this, E, (p) => dt(S, p), A);
|
|
1715
1454
|
}
|
|
1716
1455
|
// Checks if point is of small order.
|
|
1717
1456
|
// If you add something to small order point, you will have "dirty"
|
|
1718
1457
|
// point with torsion component.
|
|
1719
1458
|
// Multiplies point by cofactor and checks if the result is 0.
|
|
1720
1459
|
isSmallOrder() {
|
|
1721
|
-
return this.multiplyUnsafe(
|
|
1460
|
+
return this.multiplyUnsafe(c).is0();
|
|
1722
1461
|
}
|
|
1723
1462
|
// Multiplies point by curve order and checks if the result is 0.
|
|
1724
1463
|
// Returns `false` is the point is dirty.
|
|
@@ -1728,14 +1467,14 @@ function $n(e, t = {}) {
|
|
|
1728
1467
|
// Converts Extended point to default (x, y) coordinates.
|
|
1729
1468
|
// Can accept precomputed Z^-1 - for example, from invertBatch.
|
|
1730
1469
|
toAffine(E) {
|
|
1731
|
-
return
|
|
1470
|
+
return v(this, E);
|
|
1732
1471
|
}
|
|
1733
1472
|
clearCofactor() {
|
|
1734
|
-
return
|
|
1473
|
+
return c === U ? this : this.multiplyUnsafe(c);
|
|
1735
1474
|
}
|
|
1736
1475
|
toBytes() {
|
|
1737
1476
|
const { x: E, y: A } = this.toAffine(), p = o.toBytes(A);
|
|
1738
|
-
return p[p.length - 1] |= E &
|
|
1477
|
+
return p[p.length - 1] |= E & U ? 128 : 0, p;
|
|
1739
1478
|
}
|
|
1740
1479
|
toHex() {
|
|
1741
1480
|
return It(this.toBytes());
|
|
@@ -1744,10 +1483,10 @@ function $n(e, t = {}) {
|
|
|
1744
1483
|
return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
|
|
1745
1484
|
}
|
|
1746
1485
|
}
|
|
1747
|
-
const O = new
|
|
1748
|
-
return
|
|
1486
|
+
const O = new Bn(S, r.BITS);
|
|
1487
|
+
return S.BASE.precompute(8), S;
|
|
1749
1488
|
}
|
|
1750
|
-
function
|
|
1489
|
+
function _n(e, t, n = {}) {
|
|
1751
1490
|
if (typeof t != "function")
|
|
1752
1491
|
throw new Error('"hash" function param is required');
|
|
1753
1492
|
_t(n, {}, {
|
|
@@ -1757,53 +1496,53 @@ function Zn(e, t, n = {}) {
|
|
|
1757
1496
|
prehash: "function",
|
|
1758
1497
|
mapToCurve: "function"
|
|
1759
1498
|
});
|
|
1760
|
-
const { prehash: o } = n, { BASE: r, Fp: s, Fn:
|
|
1761
|
-
if (
|
|
1499
|
+
const { prehash: o } = n, { BASE: r, Fp: s, Fn: c } = e, u = n.randomBytes || Ve, i = n.adjustScalarBytes || ((f) => f), x = n.domain || ((f, l, d) => {
|
|
1500
|
+
if (Et(d, "phflag"), l.length || d)
|
|
1762
1501
|
throw new Error("Contexts/pre-hash are not supported");
|
|
1763
|
-
return
|
|
1502
|
+
return f;
|
|
1764
1503
|
});
|
|
1765
|
-
function
|
|
1766
|
-
return
|
|
1504
|
+
function m(f) {
|
|
1505
|
+
return c.create(ft(f));
|
|
1767
1506
|
}
|
|
1768
|
-
function w(
|
|
1507
|
+
function w(f) {
|
|
1769
1508
|
const l = p.secretKey;
|
|
1770
|
-
D(
|
|
1771
|
-
const d = D(t(
|
|
1772
|
-
return { head: b, prefix: g, scalar:
|
|
1509
|
+
D(f, p.secretKey, "secretKey");
|
|
1510
|
+
const d = D(t(f), 2 * l, "hashedSecretKey"), b = i(d.slice(0, l)), g = d.slice(l, 2 * l), y = m(b);
|
|
1511
|
+
return { head: b, prefix: g, scalar: y };
|
|
1773
1512
|
}
|
|
1774
|
-
function
|
|
1775
|
-
const { head: l, prefix: d, scalar: b } = w(
|
|
1776
|
-
return { head: l, prefix: d, scalar: b, point: g, pointBytes:
|
|
1513
|
+
function v(f) {
|
|
1514
|
+
const { head: l, prefix: d, scalar: b } = w(f), g = r.multiply(b), y = g.toBytes();
|
|
1515
|
+
return { head: l, prefix: d, scalar: b, point: g, pointBytes: y };
|
|
1777
1516
|
}
|
|
1778
|
-
function I(
|
|
1779
|
-
return
|
|
1517
|
+
function I(f) {
|
|
1518
|
+
return v(f).pointBytes;
|
|
1780
1519
|
}
|
|
1781
|
-
function
|
|
1782
|
-
const d =
|
|
1783
|
-
return
|
|
1520
|
+
function S(f = Uint8Array.of(), ...l) {
|
|
1521
|
+
const d = Mt(...l);
|
|
1522
|
+
return m(t(x(d, D(f, void 0, "context"), !!o)));
|
|
1784
1523
|
}
|
|
1785
|
-
function O(
|
|
1786
|
-
|
|
1787
|
-
const { prefix: b, scalar: g, pointBytes:
|
|
1788
|
-
if (!
|
|
1524
|
+
function O(f, l, d = {}) {
|
|
1525
|
+
f = D(f, void 0, "message"), o && (f = o(f));
|
|
1526
|
+
const { prefix: b, scalar: g, pointBytes: y } = v(l), B = S(d.context, b, f), R = r.multiply(B).toBytes(), C = S(d.context, R, y, f), L = c.create(B + C * g);
|
|
1527
|
+
if (!c.isValid(L))
|
|
1789
1528
|
throw new Error("sign failed: invalid s");
|
|
1790
|
-
const q =
|
|
1529
|
+
const q = Mt(R, c.toBytes(L));
|
|
1791
1530
|
return D(q, p.signature, "result");
|
|
1792
1531
|
}
|
|
1793
1532
|
const _ = { zip215: !0 };
|
|
1794
|
-
function E(
|
|
1795
|
-
const { context: g, zip215:
|
|
1796
|
-
|
|
1797
|
-
const R = B / 2, C =
|
|
1533
|
+
function E(f, l, d, b = _) {
|
|
1534
|
+
const { context: g, zip215: y } = b, B = p.signature;
|
|
1535
|
+
f = D(f, B, "signature"), l = D(l, void 0, "message"), d = D(d, p.publicKey, "publicKey"), y !== void 0 && Et(y, "zip215"), o && (l = o(l));
|
|
1536
|
+
const R = B / 2, C = f.subarray(0, R), L = ft(f.subarray(R, B));
|
|
1798
1537
|
let q, Q, nt;
|
|
1799
1538
|
try {
|
|
1800
|
-
q = e.fromBytes(d,
|
|
1539
|
+
q = e.fromBytes(d, y), Q = e.fromBytes(C, y), nt = r.multiplyUnsafe(L);
|
|
1801
1540
|
} catch {
|
|
1802
1541
|
return !1;
|
|
1803
1542
|
}
|
|
1804
|
-
if (!
|
|
1543
|
+
if (!y && q.isSmallOrder())
|
|
1805
1544
|
return !1;
|
|
1806
|
-
const ut =
|
|
1545
|
+
const ut = S(g, Q.toBytes(), q.toBytes(), l);
|
|
1807
1546
|
return Q.add(q.multiplyUnsafe(ut)).subtract(nt).clearCofactor().is0();
|
|
1808
1547
|
}
|
|
1809
1548
|
const A = s.BYTES, p = {
|
|
@@ -1812,24 +1551,24 @@ function Zn(e, t, n = {}) {
|
|
|
1812
1551
|
signature: 2 * A,
|
|
1813
1552
|
seed: A
|
|
1814
1553
|
};
|
|
1815
|
-
function N(
|
|
1816
|
-
return D(
|
|
1554
|
+
function N(f = u(p.seed)) {
|
|
1555
|
+
return D(f, p.seed, "seed");
|
|
1817
1556
|
}
|
|
1818
|
-
function T(
|
|
1819
|
-
return
|
|
1557
|
+
function T(f) {
|
|
1558
|
+
return re(f) && f.length === c.BYTES;
|
|
1820
1559
|
}
|
|
1821
|
-
function f
|
|
1560
|
+
function a(f, l) {
|
|
1822
1561
|
try {
|
|
1823
|
-
return !!e.fromBytes(
|
|
1562
|
+
return !!e.fromBytes(f, l);
|
|
1824
1563
|
} catch {
|
|
1825
1564
|
return !1;
|
|
1826
1565
|
}
|
|
1827
1566
|
}
|
|
1828
1567
|
const h = {
|
|
1829
|
-
getExtendedPublicKey:
|
|
1568
|
+
getExtendedPublicKey: v,
|
|
1830
1569
|
randomSecretKey: N,
|
|
1831
1570
|
isValidSecretKey: T,
|
|
1832
|
-
isValidPublicKey:
|
|
1571
|
+
isValidPublicKey: a,
|
|
1833
1572
|
/**
|
|
1834
1573
|
* Converts ed public key to x public key. Uses formula:
|
|
1835
1574
|
* - ed25519:
|
|
@@ -1839,22 +1578,22 @@ function Zn(e, t, n = {}) {
|
|
|
1839
1578
|
* - `(u, v) = ((y-1)/(y+1), sqrt(156324)*u/x)`
|
|
1840
1579
|
* - `(x, y) = (sqrt(156324)*u/v, (1+u)/(1-u))`
|
|
1841
1580
|
*/
|
|
1842
|
-
toMontgomery(
|
|
1843
|
-
const { y: l } = e.fromBytes(
|
|
1581
|
+
toMontgomery(f) {
|
|
1582
|
+
const { y: l } = e.fromBytes(f), d = p.publicKey, b = d === 32;
|
|
1844
1583
|
if (!b && d !== 57)
|
|
1845
1584
|
throw new Error("only defined for 25519 and 448");
|
|
1846
|
-
const g = b ? s.div(
|
|
1585
|
+
const g = b ? s.div(U + l, U - l) : s.div(l - U, l + U);
|
|
1847
1586
|
return s.toBytes(g);
|
|
1848
1587
|
},
|
|
1849
|
-
toMontgomerySecret(
|
|
1588
|
+
toMontgomerySecret(f) {
|
|
1850
1589
|
const l = p.secretKey;
|
|
1851
|
-
D(
|
|
1852
|
-
const d = t(
|
|
1590
|
+
D(f, l);
|
|
1591
|
+
const d = t(f.subarray(0, l));
|
|
1853
1592
|
return i(d).subarray(0, l);
|
|
1854
1593
|
}
|
|
1855
1594
|
};
|
|
1856
1595
|
return Object.freeze({
|
|
1857
|
-
keygen:
|
|
1596
|
+
keygen: Sn(N, I),
|
|
1858
1597
|
getPublicKey: I,
|
|
1859
1598
|
sign: O,
|
|
1860
1599
|
verify: E,
|
|
@@ -1863,50 +1602,267 @@ function Zn(e, t, n = {}) {
|
|
|
1863
1602
|
lengths: p
|
|
1864
1603
|
});
|
|
1865
1604
|
}
|
|
1866
|
-
const
|
|
1605
|
+
const Nn = BigInt(1), Ft = BigInt(2), On = BigInt(5), Tn = BigInt(8), Tt = BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"), Cn = {
|
|
1867
1606
|
p: Tt,
|
|
1868
1607
|
n: BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),
|
|
1869
|
-
h:
|
|
1608
|
+
h: Tn,
|
|
1870
1609
|
a: BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),
|
|
1871
1610
|
d: BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),
|
|
1872
1611
|
Gx: BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),
|
|
1873
1612
|
Gy: BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")
|
|
1874
1613
|
};
|
|
1875
|
-
function
|
|
1876
|
-
const t = BigInt(10), n = BigInt(20), o = BigInt(40), r = BigInt(80), s = Tt, u = e * e % s * e % s, i =
|
|
1877
|
-
return { pow_p_5_8:
|
|
1614
|
+
function Ln(e) {
|
|
1615
|
+
const t = BigInt(10), n = BigInt(20), o = BigInt(40), r = BigInt(80), s = Tt, u = e * e % s * e % s, i = Z(u, Ft, s) * u % s, x = Z(i, Nn, s) * e % s, m = Z(x, On, s) * x % s, w = Z(m, t, s) * m % s, v = Z(w, n, s) * w % s, I = Z(v, o, s) * v % s, S = Z(I, r, s) * I % s, O = Z(S, r, s) * I % s, _ = Z(O, t, s) * m % s;
|
|
1616
|
+
return { pow_p_5_8: Z(_, Ft, s) * e % s, b2: u };
|
|
1878
1617
|
}
|
|
1879
|
-
function
|
|
1618
|
+
function Hn(e) {
|
|
1880
1619
|
return e[0] &= 248, e[31] &= 127, e[31] |= 64, e;
|
|
1881
1620
|
}
|
|
1882
|
-
const
|
|
1883
|
-
function
|
|
1884
|
-
const n = Tt, o =
|
|
1885
|
-
let
|
|
1886
|
-
const u =
|
|
1887
|
-
return
|
|
1621
|
+
const Qt = /* @__PURE__ */ BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");
|
|
1622
|
+
function Un(e, t) {
|
|
1623
|
+
const n = Tt, o = H(t * t * t, n), r = H(o * o * t, n), s = Ln(e * r).pow_p_5_8;
|
|
1624
|
+
let c = H(e * o * s, n);
|
|
1625
|
+
const u = H(t * c * c, n), i = c, x = H(c * Qt, n), m = u === e, w = u === H(-e, n), v = u === H(-e * Qt, n);
|
|
1626
|
+
return m && (c = i), (w || v) && (c = x), wn(c, n) && (c = H(-c, n)), { isValid: m || w, value: c };
|
|
1888
1627
|
}
|
|
1889
|
-
const
|
|
1890
|
-
function
|
|
1891
|
-
return
|
|
1628
|
+
const Dn = /* @__PURE__ */ In(Cn, { uvRatio: Un });
|
|
1629
|
+
function qn(e) {
|
|
1630
|
+
return _n(Dn, on, Object.assign({ adjustScalarBytes: Hn }, e));
|
|
1892
1631
|
}
|
|
1893
|
-
const
|
|
1894
|
-
function
|
|
1632
|
+
const Mn = /* @__PURE__ */ qn({});
|
|
1633
|
+
function Gn(e) {
|
|
1634
|
+
return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
|
|
1635
|
+
}
|
|
1636
|
+
function Ct(e, ...t) {
|
|
1637
|
+
if (!Gn(e))
|
|
1638
|
+
throw new Error("Uint8Array expected");
|
|
1639
|
+
if (t.length > 0 && !t.includes(e.length))
|
|
1640
|
+
throw new Error("Uint8Array expected of length " + t + ", got length=" + e.length);
|
|
1641
|
+
}
|
|
1642
|
+
function Jt(e, t = !0) {
|
|
1643
|
+
if (e.destroyed)
|
|
1644
|
+
throw new Error("Hash instance has been destroyed");
|
|
1645
|
+
if (t && e.finished)
|
|
1646
|
+
throw new Error("Hash#digest() has already been called");
|
|
1647
|
+
}
|
|
1648
|
+
function $n(e, t) {
|
|
1649
|
+
Ct(e);
|
|
1650
|
+
const n = t.outputLen;
|
|
1651
|
+
if (e.length < n)
|
|
1652
|
+
throw new Error("digestInto() expects output buffer of length at least " + n);
|
|
1653
|
+
}
|
|
1654
|
+
function St(...e) {
|
|
1655
|
+
for (let t = 0; t < e.length; t++)
|
|
1656
|
+
e[t].fill(0);
|
|
1657
|
+
}
|
|
1658
|
+
function pt(e) {
|
|
1659
|
+
return new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
1660
|
+
}
|
|
1661
|
+
function j(e, t) {
|
|
1662
|
+
return e << 32 - t | e >>> t;
|
|
1663
|
+
}
|
|
1664
|
+
function Zn(e) {
|
|
1665
|
+
if (typeof e != "string")
|
|
1666
|
+
throw new Error("string expected");
|
|
1667
|
+
return new Uint8Array(new TextEncoder().encode(e));
|
|
1668
|
+
}
|
|
1669
|
+
function me(e) {
|
|
1670
|
+
return typeof e == "string" && (e = Zn(e)), Ct(e), e;
|
|
1671
|
+
}
|
|
1672
|
+
class jn {
|
|
1673
|
+
}
|
|
1674
|
+
function Vn(e) {
|
|
1675
|
+
const t = (o) => e().update(me(o)).digest(), n = e();
|
|
1676
|
+
return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = () => e(), t;
|
|
1677
|
+
}
|
|
1678
|
+
function kn(e, t, n, o) {
|
|
1679
|
+
if (typeof e.setBigUint64 == "function")
|
|
1680
|
+
return e.setBigUint64(t, n, o);
|
|
1681
|
+
const r = BigInt(32), s = BigInt(4294967295), c = Number(n >> r & s), u = Number(n & s), i = o ? 4 : 0, x = o ? 0 : 4;
|
|
1682
|
+
e.setUint32(t + i, c, o), e.setUint32(t + x, u, o);
|
|
1683
|
+
}
|
|
1684
|
+
function Kn(e, t, n) {
|
|
1685
|
+
return e & t ^ ~e & n;
|
|
1686
|
+
}
|
|
1687
|
+
function Yn(e, t, n) {
|
|
1688
|
+
return e & t ^ e & n ^ t & n;
|
|
1689
|
+
}
|
|
1690
|
+
class zn extends jn {
|
|
1691
|
+
constructor(t, n, o, r) {
|
|
1692
|
+
super(), this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.blockLen = t, this.outputLen = n, this.padOffset = o, this.isLE = r, this.buffer = new Uint8Array(t), this.view = pt(this.buffer);
|
|
1693
|
+
}
|
|
1694
|
+
update(t) {
|
|
1695
|
+
Jt(this), t = me(t), Ct(t);
|
|
1696
|
+
const { view: n, buffer: o, blockLen: r } = this, s = t.length;
|
|
1697
|
+
for (let c = 0; c < s; ) {
|
|
1698
|
+
const u = Math.min(r - this.pos, s - c);
|
|
1699
|
+
if (u === r) {
|
|
1700
|
+
const i = pt(t);
|
|
1701
|
+
for (; r <= s - c; c += r)
|
|
1702
|
+
this.process(i, c);
|
|
1703
|
+
continue;
|
|
1704
|
+
}
|
|
1705
|
+
o.set(t.subarray(c, c + u), this.pos), this.pos += u, c += u, this.pos === r && (this.process(n, 0), this.pos = 0);
|
|
1706
|
+
}
|
|
1707
|
+
return this.length += t.length, this.roundClean(), this;
|
|
1708
|
+
}
|
|
1709
|
+
digestInto(t) {
|
|
1710
|
+
Jt(this), $n(t, this), this.finished = !0;
|
|
1711
|
+
const { buffer: n, view: o, blockLen: r, isLE: s } = this;
|
|
1712
|
+
let { pos: c } = this;
|
|
1713
|
+
n[c++] = 128, St(this.buffer.subarray(c)), this.padOffset > r - c && (this.process(o, 0), c = 0);
|
|
1714
|
+
for (let w = c; w < r; w++)
|
|
1715
|
+
n[w] = 0;
|
|
1716
|
+
kn(o, r - 8, BigInt(this.length * 8), s), this.process(o, 0);
|
|
1717
|
+
const u = pt(t), i = this.outputLen;
|
|
1718
|
+
if (i % 4)
|
|
1719
|
+
throw new Error("_sha2: outputLen should be aligned to 32bit");
|
|
1720
|
+
const x = i / 4, m = this.get();
|
|
1721
|
+
if (x > m.length)
|
|
1722
|
+
throw new Error("_sha2: outputLen bigger than state");
|
|
1723
|
+
for (let w = 0; w < x; w++)
|
|
1724
|
+
u.setUint32(4 * w, m[w], s);
|
|
1725
|
+
}
|
|
1726
|
+
digest() {
|
|
1727
|
+
const { buffer: t, outputLen: n } = this;
|
|
1728
|
+
this.digestInto(t);
|
|
1729
|
+
const o = t.slice(0, n);
|
|
1730
|
+
return this.destroy(), o;
|
|
1731
|
+
}
|
|
1732
|
+
_cloneInto(t) {
|
|
1733
|
+
t || (t = new this.constructor()), t.set(...this.get());
|
|
1734
|
+
const { blockLen: n, buffer: o, length: r, finished: s, destroyed: c, pos: u } = this;
|
|
1735
|
+
return t.destroyed = c, t.finished = s, t.length = r, t.pos = u, r % n && t.buffer.set(o), t;
|
|
1736
|
+
}
|
|
1737
|
+
clone() {
|
|
1738
|
+
return this._cloneInto();
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
const X = /* @__PURE__ */ Uint32Array.from([
|
|
1742
|
+
1779033703,
|
|
1743
|
+
3144134277,
|
|
1744
|
+
1013904242,
|
|
1745
|
+
2773480762,
|
|
1746
|
+
1359893119,
|
|
1747
|
+
2600822924,
|
|
1748
|
+
528734635,
|
|
1749
|
+
1541459225
|
|
1750
|
+
]), Xn = /* @__PURE__ */ Uint32Array.from([
|
|
1751
|
+
1116352408,
|
|
1752
|
+
1899447441,
|
|
1753
|
+
3049323471,
|
|
1754
|
+
3921009573,
|
|
1755
|
+
961987163,
|
|
1756
|
+
1508970993,
|
|
1757
|
+
2453635748,
|
|
1758
|
+
2870763221,
|
|
1759
|
+
3624381080,
|
|
1760
|
+
310598401,
|
|
1761
|
+
607225278,
|
|
1762
|
+
1426881987,
|
|
1763
|
+
1925078388,
|
|
1764
|
+
2162078206,
|
|
1765
|
+
2614888103,
|
|
1766
|
+
3248222580,
|
|
1767
|
+
3835390401,
|
|
1768
|
+
4022224774,
|
|
1769
|
+
264347078,
|
|
1770
|
+
604807628,
|
|
1771
|
+
770255983,
|
|
1772
|
+
1249150122,
|
|
1773
|
+
1555081692,
|
|
1774
|
+
1996064986,
|
|
1775
|
+
2554220882,
|
|
1776
|
+
2821834349,
|
|
1777
|
+
2952996808,
|
|
1778
|
+
3210313671,
|
|
1779
|
+
3336571891,
|
|
1780
|
+
3584528711,
|
|
1781
|
+
113926993,
|
|
1782
|
+
338241895,
|
|
1783
|
+
666307205,
|
|
1784
|
+
773529912,
|
|
1785
|
+
1294757372,
|
|
1786
|
+
1396182291,
|
|
1787
|
+
1695183700,
|
|
1788
|
+
1986661051,
|
|
1789
|
+
2177026350,
|
|
1790
|
+
2456956037,
|
|
1791
|
+
2730485921,
|
|
1792
|
+
2820302411,
|
|
1793
|
+
3259730800,
|
|
1794
|
+
3345764771,
|
|
1795
|
+
3516065817,
|
|
1796
|
+
3600352804,
|
|
1797
|
+
4094571909,
|
|
1798
|
+
275423344,
|
|
1799
|
+
430227734,
|
|
1800
|
+
506948616,
|
|
1801
|
+
659060556,
|
|
1802
|
+
883997877,
|
|
1803
|
+
958139571,
|
|
1804
|
+
1322822218,
|
|
1805
|
+
1537002063,
|
|
1806
|
+
1747873779,
|
|
1807
|
+
1955562222,
|
|
1808
|
+
2024104815,
|
|
1809
|
+
2227730452,
|
|
1810
|
+
2361852424,
|
|
1811
|
+
2428436474,
|
|
1812
|
+
2756734187,
|
|
1813
|
+
3204031479,
|
|
1814
|
+
3329325298
|
|
1815
|
+
]), W = /* @__PURE__ */ new Uint32Array(64);
|
|
1816
|
+
class Wn extends zn {
|
|
1817
|
+
constructor(t = 32) {
|
|
1818
|
+
super(64, t, 8, !1), this.A = X[0] | 0, this.B = X[1] | 0, this.C = X[2] | 0, this.D = X[3] | 0, this.E = X[4] | 0, this.F = X[5] | 0, this.G = X[6] | 0, this.H = X[7] | 0;
|
|
1819
|
+
}
|
|
1820
|
+
get() {
|
|
1821
|
+
const { A: t, B: n, C: o, D: r, E: s, F: c, G: u, H: i } = this;
|
|
1822
|
+
return [t, n, o, r, s, c, u, i];
|
|
1823
|
+
}
|
|
1824
|
+
// prettier-ignore
|
|
1825
|
+
set(t, n, o, r, s, c, u, i) {
|
|
1826
|
+
this.A = t | 0, this.B = n | 0, this.C = o | 0, this.D = r | 0, this.E = s | 0, this.F = c | 0, this.G = u | 0, this.H = i | 0;
|
|
1827
|
+
}
|
|
1828
|
+
process(t, n) {
|
|
1829
|
+
for (let w = 0; w < 16; w++, n += 4)
|
|
1830
|
+
W[w] = t.getUint32(n, !1);
|
|
1831
|
+
for (let w = 16; w < 64; w++) {
|
|
1832
|
+
const v = W[w - 15], I = W[w - 2], S = j(v, 7) ^ j(v, 18) ^ v >>> 3, O = j(I, 17) ^ j(I, 19) ^ I >>> 10;
|
|
1833
|
+
W[w] = O + W[w - 7] + S + W[w - 16] | 0;
|
|
1834
|
+
}
|
|
1835
|
+
let { A: o, B: r, C: s, D: c, E: u, F: i, G: x, H: m } = this;
|
|
1836
|
+
for (let w = 0; w < 64; w++) {
|
|
1837
|
+
const v = j(u, 6) ^ j(u, 11) ^ j(u, 25), I = m + v + Kn(u, i, x) + Xn[w] + W[w] | 0, O = (j(o, 2) ^ j(o, 13) ^ j(o, 22)) + Yn(o, r, s) | 0;
|
|
1838
|
+
m = x, x = i, i = u, u = c + I | 0, c = s, s = r, r = o, o = I + O | 0;
|
|
1839
|
+
}
|
|
1840
|
+
o = o + this.A | 0, r = r + this.B | 0, s = s + this.C | 0, c = c + this.D | 0, u = u + this.E | 0, i = i + this.F | 0, x = x + this.G | 0, m = m + this.H | 0, this.set(o, r, s, c, u, i, x, m);
|
|
1841
|
+
}
|
|
1842
|
+
roundClean() {
|
|
1843
|
+
St(W);
|
|
1844
|
+
}
|
|
1845
|
+
destroy() {
|
|
1846
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0), St(this.buffer);
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
const Pn = /* @__PURE__ */ Vn(() => new Wn()), Fn = Pn, Qn = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
1850
|
+
function Jn(e) {
|
|
1895
1851
|
if (e.length !== 16)
|
|
1896
1852
|
throw new Error(`Invalid seed length: expected 16, got ${e.length}`);
|
|
1897
|
-
const t =
|
|
1898
|
-
return o.set(t, 0), o.set(n, 32),
|
|
1853
|
+
const t = Fn(e), n = Mn.getPublicKey(t), o = new Uint8Array(64);
|
|
1854
|
+
return o.set(t, 0), o.set(n, 32), ee(t), { publicKey: n, secretKey: o };
|
|
1899
1855
|
}
|
|
1900
1856
|
function cr(e) {
|
|
1901
|
-
const t =
|
|
1902
|
-
return
|
|
1857
|
+
const t = Jn(e), n = t.publicKey;
|
|
1858
|
+
return ee(t.secretKey), n;
|
|
1903
1859
|
}
|
|
1904
1860
|
function fr(e) {
|
|
1905
1861
|
if (e.length !== 32)
|
|
1906
1862
|
throw new Error(`Invalid public key length: expected 32, got ${e.length}`);
|
|
1907
|
-
return
|
|
1863
|
+
return tr(e);
|
|
1908
1864
|
}
|
|
1909
|
-
function
|
|
1865
|
+
function tr(e) {
|
|
1910
1866
|
let t = 0;
|
|
1911
1867
|
for (let r = 0; r < e.length && e[r] === 0; r++)
|
|
1912
1868
|
t++;
|
|
@@ -1916,17 +1872,69 @@ function er(e) {
|
|
|
1916
1872
|
let o = "";
|
|
1917
1873
|
for (; n > 0n; ) {
|
|
1918
1874
|
const r = Number(n % 58n);
|
|
1919
|
-
o =
|
|
1875
|
+
o = Qn[r] + o, n = n / 58n;
|
|
1920
1876
|
}
|
|
1921
1877
|
return "1".repeat(t) + o;
|
|
1922
1878
|
}
|
|
1879
|
+
const er = 2, nr = 3;
|
|
1880
|
+
function ar(e) {
|
|
1881
|
+
if (e.length !== 16)
|
|
1882
|
+
throw new Error(`Invalid seed length: expected 16, got ${e.length}`);
|
|
1883
|
+
const t = At(e), n = ne.share(t, nr, er);
|
|
1884
|
+
if (n.length !== 3)
|
|
1885
|
+
throw new Error(`Unexpected share count: ${n.length}`);
|
|
1886
|
+
const o = yt(n[0]), r = yt(n[1]), s = yt(n[2]);
|
|
1887
|
+
return {
|
|
1888
|
+
shareA: ht(o),
|
|
1889
|
+
shareB: ht(r),
|
|
1890
|
+
shareC: ht(s)
|
|
1891
|
+
};
|
|
1892
|
+
}
|
|
1893
|
+
function ur(e, t, n) {
|
|
1894
|
+
const o = te(e), r = te(t);
|
|
1895
|
+
try {
|
|
1896
|
+
const s = ne.combine([o, r]), c = Ee(s);
|
|
1897
|
+
if (c.length !== 16)
|
|
1898
|
+
throw new Error(`Reconstructed seed has wrong length: ${c.length}`);
|
|
1899
|
+
return Ae(c);
|
|
1900
|
+
} catch (s) {
|
|
1901
|
+
throw s instanceof Error && s.message.startsWith("Reconstructed seed") || s instanceof Error && s.message.startsWith("Invalid expectedPublicKey") || s instanceof Error && s.message.startsWith("Reconstructed seed does not match") ? s : new Error("Failed to reconstruct seed from shares");
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
function At(e) {
|
|
1905
|
+
return Array.from(e).map((t) => t.toString(16).padStart(2, "0")).join("");
|
|
1906
|
+
}
|
|
1907
|
+
function Ee(e) {
|
|
1908
|
+
if (!/^[0-9a-fA-F]*$/.test(e))
|
|
1909
|
+
throw new Error("Invalid hex string: contains non-hex characters");
|
|
1910
|
+
if (e.length % 2 !== 0)
|
|
1911
|
+
throw new Error(`Invalid hex string: length ${e.length} is odd (must be even)`);
|
|
1912
|
+
const t = new Uint8Array(e.length / 2);
|
|
1913
|
+
for (let n = 0; n < t.length; n++)
|
|
1914
|
+
t[n] = parseInt(e.substr(n * 2, 2), 16);
|
|
1915
|
+
return t;
|
|
1916
|
+
}
|
|
1917
|
+
function yt(e) {
|
|
1918
|
+
const t = e.length % 2 !== 0, n = t ? "0" + e : e, o = Ee(n), r = new Uint8Array(1 + o.length);
|
|
1919
|
+
return r[0] = t ? 1 : 0, r.set(o, 1), r;
|
|
1920
|
+
}
|
|
1921
|
+
function te(e) {
|
|
1922
|
+
const t = e[0];
|
|
1923
|
+
if (t === 0 || t === 1) {
|
|
1924
|
+
const o = t === 1, r = e.subarray(1), s = At(r), c = o ? s.substring(1) : s;
|
|
1925
|
+
if (/^[0-9a-f]/.test(c))
|
|
1926
|
+
return c;
|
|
1927
|
+
}
|
|
1928
|
+
const n = At(e);
|
|
1929
|
+
return n.startsWith("0") && !n.startsWith("00") ? n.substring(1) : n;
|
|
1930
|
+
}
|
|
1923
1931
|
export {
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1932
|
+
sr as a,
|
|
1933
|
+
Ct as b,
|
|
1934
|
+
Pn as c,
|
|
1935
|
+
ur as d,
|
|
1936
|
+
_e as e,
|
|
1929
1937
|
cr as g,
|
|
1930
1938
|
fr as p,
|
|
1931
|
-
|
|
1939
|
+
ar as s
|
|
1932
1940
|
};
|