@btc-vision/transaction 1.8.6 → 1.8.7-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/index.js +1448 -1266
- package/browser/noble-curves.js +2179 -1307
- package/browser/noble-hashes.js +282 -261
- package/browser/rolldown-runtime.js +7 -7
- package/browser/src/_version.d.ts +1 -0
- package/browser/{abi → src/abi}/ABICoder.d.ts +0 -1
- package/browser/{abi → src/abi}/ABIDataTypes.d.ts +0 -1
- package/browser/{abi → src/abi}/AbiTypes.d.ts +0 -1
- package/browser/{abi → src/abi}/TupleUtils.d.ts +0 -1
- package/browser/{branded → src/branded}/Branded.d.ts +0 -1
- package/browser/{buffer → src/buffer}/BinaryReader.d.ts +0 -1
- package/browser/{buffer → src/buffer}/BinaryWriter.d.ts +0 -1
- package/browser/{bytecode → src/bytecode}/Compressor.d.ts +0 -1
- package/browser/{chain → src/chain}/ChainData.d.ts +1 -2
- package/browser/{consensus → src/consensus}/Consensus.d.ts +0 -1
- package/browser/{consensus → src/consensus}/ConsensusConfig.d.ts +0 -1
- package/browser/{consensus → src/consensus}/IConsensusConfig.d.ts +0 -1
- package/browser/{consensus → src/consensus}/metadata/RoswellConsensus.d.ts +0 -1
- package/browser/{crypto → src/crypto}/crypto.d.ts +1 -2
- package/browser/{deterministic → src/deterministic}/AddressMap.d.ts +0 -1
- package/browser/{deterministic → src/deterministic}/AddressSet.d.ts +0 -1
- package/browser/{deterministic → src/deterministic}/CustomMap.d.ts +0 -1
- package/browser/{deterministic → src/deterministic}/DeterministicMap.d.ts +0 -1
- package/browser/{deterministic → src/deterministic}/DeterministicSet.d.ts +0 -1
- package/browser/{deterministic → src/deterministic}/ExtendedAddressMap.d.ts +0 -1
- package/browser/{deterministic → src/deterministic}/FastMap.d.ts +0 -1
- package/browser/{ecc → src/ecc}/backend.d.ts +1 -2
- package/browser/{epoch → src/epoch}/ChallengeSolution.d.ts +0 -1
- package/browser/{epoch → src/epoch}/interfaces/IChallengeSolution.d.ts +0 -1
- package/browser/{epoch → src/epoch}/validator/EpochValidator.d.ts +0 -1
- package/browser/{event → src/event}/NetEvent.d.ts +0 -1
- package/browser/{generators → src/generators}/AddressGenerator.d.ts +1 -2
- package/browser/{generators → src/generators}/Features.d.ts +0 -1
- package/browser/{generators → src/generators}/Generator.d.ts +1 -2
- package/browser/{generators → src/generators}/MLDSAData.d.ts +1 -2
- package/browser/{generators → src/generators}/builders/CalldataGenerator.d.ts +1 -2
- package/browser/{generators → src/generators}/builders/CustomGenerator.d.ts +1 -2
- package/browser/{generators → src/generators}/builders/DeploymentGenerator.d.ts +1 -2
- package/browser/{generators → src/generators}/builders/HashCommitmentGenerator.d.ts +1 -2
- package/browser/{generators → src/generators}/builders/LegacyCalldataGenerator.d.ts +1 -2
- package/browser/{generators → src/generators}/builders/MultiSignGenerator.d.ts +1 -2
- package/browser/{generators → src/generators}/builders/P2WDAGenerator.d.ts +1 -2
- package/browser/{index.d.ts → src/index.d.ts} +0 -1
- package/browser/{keypair → src/keypair}/Address.d.ts +2 -3
- package/browser/{keypair → src/keypair}/AddressVerificator.d.ts +2 -3
- package/browser/{keypair → src/keypair}/EcKeyPair.d.ts +2 -3
- package/browser/{keypair → src/keypair}/MessageSigner.d.ts +2 -3
- package/browser/{keypair → src/keypair}/Secp256k1PointDeriver.d.ts +0 -1
- package/browser/{keypair → src/keypair}/Wallet.d.ts +2 -3
- package/browser/{keypair → src/keypair}/interfaces/IWallet.d.ts +0 -1
- package/browser/{metadata → src/metadata}/ContractBaseMetadata.d.ts +1 -2
- package/browser/{mnemonic → src/mnemonic}/BIPStandard.d.ts +0 -1
- package/browser/{mnemonic → src/mnemonic}/Mnemonic.d.ts +2 -3
- package/browser/{mnemonic → src/mnemonic}/MnemonicStrength.d.ts +0 -1
- package/browser/{network → src/network}/ChainId.d.ts +0 -1
- package/browser/{opnet.d.ts → src/opnet.d.ts} +2 -2
- package/browser/{p2wda → src/p2wda}/P2WDADetector.d.ts +1 -2
- package/browser/{polyfill → src/polyfill}/disposable.d.ts +0 -1
- package/browser/{signer → src/signer}/AddressRotation.d.ts +0 -1
- package/browser/{signer → src/signer}/IRotationSigner.d.ts +1 -2
- package/browser/{signer → src/signer}/ParallelSignerAdapter.d.ts +1 -2
- package/browser/{signer → src/signer}/SignerUtils.d.ts +1 -2
- package/browser/{signer → src/signer}/TweakedSigner.d.ts +1 -2
- package/browser/{transaction → src/transaction}/ContractAddress.d.ts +0 -1
- package/browser/{transaction → src/transaction}/TransactionFactory.d.ts +1 -2
- package/browser/{transaction → src/transaction}/browser/BrowserSignerBase.d.ts +1 -2
- package/browser/{transaction → src/transaction}/browser/WalletNetworks.d.ts +0 -1
- package/browser/{transaction → src/transaction}/browser/Web3Provider.d.ts +0 -1
- package/browser/{transaction → src/transaction}/browser/extensions/UnisatSigner.d.ts +1 -2
- package/browser/{transaction → src/transaction}/browser/extensions/XverseSigner.d.ts +1 -2
- package/browser/{transaction → src/transaction}/browser/types/OPWallet.d.ts +0 -1
- package/browser/{transaction → src/transaction}/browser/types/Unisat.d.ts +0 -1
- package/browser/{transaction → src/transaction}/browser/types/Xverse.d.ts +0 -1
- package/browser/{transaction → src/transaction}/builders/CancelTransaction.d.ts +1 -2
- package/browser/src/transaction/builders/ChallengeSolutionTransaction.d.ts +1 -0
- package/browser/{transaction → src/transaction}/builders/ConsolidatedInteractionTransaction.d.ts +0 -1
- package/browser/{transaction → src/transaction}/builders/CustomScriptTransaction.d.ts +1 -2
- package/browser/{transaction → src/transaction}/builders/DeploymentTransaction.d.ts +1 -2
- package/browser/{transaction → src/transaction}/builders/FundingTransaction.d.ts +1 -2
- package/browser/{transaction → src/transaction}/builders/InteractionTransaction.d.ts +1 -2
- package/browser/{transaction → src/transaction}/builders/InteractionTransactionP2WDA.d.ts +1 -2
- package/browser/{transaction → src/transaction}/builders/MultiSignTransaction.d.ts +1 -2
- package/browser/{transaction → src/transaction}/builders/SharedInteractionTransaction.d.ts +1 -2
- package/browser/{transaction → src/transaction}/builders/TransactionBuilder.d.ts +1 -2
- package/browser/{transaction → src/transaction}/enums/TransactionType.d.ts +0 -1
- package/browser/{transaction → src/transaction}/interfaces/ICancelTransactionParameters.d.ts +0 -1
- package/browser/{transaction → src/transaction}/interfaces/IConsolidatedTransactionParameters.d.ts +0 -1
- package/browser/{transaction → src/transaction}/interfaces/ICustomTransactionParameters.d.ts +1 -2
- package/browser/{transaction → src/transaction}/interfaces/ITransactionParameters.d.ts +1 -2
- package/browser/{transaction → src/transaction}/interfaces/ITransactionResponses.d.ts +0 -1
- package/browser/{transaction → src/transaction}/interfaces/ITweakedTransactionData.d.ts +2 -3
- package/browser/{transaction → src/transaction}/interfaces/IWeb3ProviderTypes.d.ts +1 -2
- package/browser/{transaction → src/transaction}/interfaces/Tap.d.ts +1 -2
- package/browser/src/transaction/mineable/CSVMultisigProvider.d.ts +102 -0
- package/browser/{transaction → src/transaction}/mineable/IP2WSHAddress.d.ts +0 -1
- package/browser/{transaction → src/transaction}/mineable/TimelockGenerator.d.ts +1 -2
- package/browser/{transaction → src/transaction}/offline/OfflineTransactionManager.d.ts +1 -2
- package/browser/{transaction → src/transaction}/offline/TransactionReconstructor.d.ts +2 -3
- package/browser/{transaction → src/transaction}/offline/TransactionSerializer.d.ts +0 -1
- package/browser/{transaction → src/transaction}/offline/TransactionStateCapture.d.ts +0 -1
- package/browser/{transaction → src/transaction}/offline/interfaces/ISerializableState.d.ts +0 -1
- package/browser/{transaction → src/transaction}/offline/interfaces/ITypeSpecificData.d.ts +0 -1
- package/browser/{transaction → src/transaction}/psbt/PSBTTypes.d.ts +0 -1
- package/browser/{transaction → src/transaction}/shared/P2MR_MS.d.ts +1 -2
- package/browser/{transaction → src/transaction}/shared/P2TR_MS.d.ts +1 -2
- package/browser/{transaction → src/transaction}/shared/TweakedTransaction.d.ts +21 -3
- package/browser/{transaction → src/transaction}/utils/WitnessUtils.d.ts +0 -1
- package/browser/{utils → src/utils}/BitcoinUtils.d.ts +0 -1
- package/browser/{utils → src/utils}/BufferHelper.d.ts +0 -1
- package/browser/{utils → src/utils}/StringToBuffer.d.ts +0 -1
- package/browser/{utils → src/utils}/lengths.d.ts +0 -1
- package/browser/{utils → src/utils}/types.d.ts +0 -1
- package/browser/{utxo → src/utxo}/OPNetLimitedProvider.d.ts +1 -2
- package/browser/{utxo → src/utxo}/interfaces/BroadcastResponse.d.ts +0 -1
- package/browser/{utxo → src/utxo}/interfaces/IUTXO.d.ts +0 -1
- package/browser/{verification → src/verification}/TapscriptVerificator.d.ts +1 -2
- package/browser/vendors.js +13 -13
- package/build/_version.d.ts +1 -2
- package/build/_version.js +1 -2
- package/build/abi/ABICoder.d.ts +0 -1
- package/build/abi/ABICoder.js +0 -1
- package/build/abi/ABIDataTypes.d.ts +0 -1
- package/build/abi/ABIDataTypes.js +0 -1
- package/build/abi/AbiTypes.d.ts +0 -1
- package/build/abi/AbiTypes.js +0 -1
- package/build/abi/TupleUtils.d.ts +0 -1
- package/build/abi/TupleUtils.js +0 -1
- package/build/branded/Branded.d.ts +0 -1
- package/build/branded/Branded.js +0 -1
- package/build/buffer/BinaryReader.d.ts +0 -1
- package/build/buffer/BinaryReader.js +0 -1
- package/build/buffer/BinaryWriter.d.ts +0 -1
- package/build/buffer/BinaryWriter.js +0 -1
- package/build/bytecode/Compressor.d.ts +0 -1
- package/build/bytecode/Compressor.js +0 -1
- package/build/chain/ChainData.d.ts +0 -1
- package/build/chain/ChainData.js +0 -1
- package/build/consensus/Consensus.d.ts +0 -1
- package/build/consensus/Consensus.js +0 -1
- package/build/consensus/ConsensusConfig.d.ts +0 -1
- package/build/consensus/ConsensusConfig.js +0 -1
- package/build/consensus/IConsensusConfig.d.ts +0 -1
- package/build/consensus/IConsensusConfig.js +0 -1
- package/build/consensus/metadata/RoswellConsensus.d.ts +0 -1
- package/build/consensus/metadata/RoswellConsensus.js +0 -1
- package/build/crypto/crypto.d.ts +0 -1
- package/build/crypto/crypto.js +0 -1
- package/build/deterministic/AddressMap.d.ts +0 -1
- package/build/deterministic/AddressMap.js +0 -1
- package/build/deterministic/AddressSet.d.ts +0 -1
- package/build/deterministic/AddressSet.js +0 -1
- package/build/deterministic/CustomMap.d.ts +0 -1
- package/build/deterministic/CustomMap.js +0 -1
- package/build/deterministic/DeterministicMap.d.ts +0 -1
- package/build/deterministic/DeterministicMap.js +0 -1
- package/build/deterministic/DeterministicSet.d.ts +0 -1
- package/build/deterministic/DeterministicSet.js +0 -1
- package/build/deterministic/ExtendedAddressMap.d.ts +0 -1
- package/build/deterministic/ExtendedAddressMap.js +0 -1
- package/build/deterministic/FastMap.d.ts +0 -1
- package/build/deterministic/FastMap.js +0 -1
- package/build/ecc/backend.d.ts +0 -1
- package/build/ecc/backend.js +0 -1
- package/build/epoch/ChallengeSolution.d.ts +0 -1
- package/build/epoch/ChallengeSolution.js +0 -1
- package/build/epoch/interfaces/IChallengeSolution.d.ts +0 -1
- package/build/epoch/interfaces/IChallengeSolution.js +0 -1
- package/build/epoch/validator/EpochValidator.d.ts +0 -1
- package/build/epoch/validator/EpochValidator.js +0 -1
- package/build/event/NetEvent.d.ts +0 -1
- package/build/event/NetEvent.js +0 -1
- package/build/generators/AddressGenerator.d.ts +0 -1
- package/build/generators/AddressGenerator.js +0 -1
- package/build/generators/Features.d.ts +0 -1
- package/build/generators/Features.js +0 -1
- package/build/generators/Generator.d.ts +0 -1
- package/build/generators/Generator.js +0 -1
- package/build/generators/MLDSAData.d.ts +0 -1
- package/build/generators/MLDSAData.js +0 -1
- package/build/generators/builders/CalldataGenerator.d.ts +0 -1
- package/build/generators/builders/CalldataGenerator.js +0 -1
- package/build/generators/builders/CustomGenerator.d.ts +0 -1
- package/build/generators/builders/CustomGenerator.js +0 -1
- package/build/generators/builders/DeploymentGenerator.d.ts +0 -1
- package/build/generators/builders/DeploymentGenerator.js +0 -1
- package/build/generators/builders/HashCommitmentGenerator.d.ts +0 -1
- package/build/generators/builders/HashCommitmentGenerator.js +0 -1
- package/build/generators/builders/LegacyCalldataGenerator.d.ts +0 -1
- package/build/generators/builders/LegacyCalldataGenerator.js +0 -1
- package/build/generators/builders/MultiSignGenerator.d.ts +0 -1
- package/build/generators/builders/MultiSignGenerator.js +0 -1
- package/build/generators/builders/P2WDAGenerator.d.ts +0 -1
- package/build/generators/builders/P2WDAGenerator.js +0 -1
- package/build/index.d.ts +0 -1
- package/build/index.js +0 -1
- package/build/keypair/Address.d.ts +0 -1
- package/build/keypair/Address.js +0 -1
- package/build/keypair/AddressVerificator.d.ts +0 -1
- package/build/keypair/AddressVerificator.js +0 -1
- package/build/keypair/EcKeyPair.d.ts +0 -1
- package/build/keypair/EcKeyPair.js +0 -1
- package/build/keypair/MessageSigner.d.ts +0 -1
- package/build/keypair/MessageSigner.js +0 -1
- package/build/keypair/Secp256k1PointDeriver.d.ts +0 -1
- package/build/keypair/Secp256k1PointDeriver.js +0 -1
- package/build/keypair/Wallet.d.ts +0 -1
- package/build/keypair/Wallet.js +0 -1
- package/build/keypair/interfaces/IWallet.d.ts +0 -1
- package/build/keypair/interfaces/IWallet.js +0 -1
- package/build/metadata/ContractBaseMetadata.d.ts +0 -1
- package/build/metadata/ContractBaseMetadata.js +0 -1
- package/build/mnemonic/BIPStandard.d.ts +0 -1
- package/build/mnemonic/BIPStandard.js +0 -1
- package/build/mnemonic/Mnemonic.d.ts +0 -1
- package/build/mnemonic/Mnemonic.js +0 -1
- package/build/mnemonic/MnemonicStrength.d.ts +0 -1
- package/build/mnemonic/MnemonicStrength.js +0 -1
- package/build/network/ChainId.d.ts +0 -1
- package/build/network/ChainId.js +0 -1
- package/build/opnet.d.ts +1 -1
- package/build/opnet.js +1 -1
- package/build/p2wda/P2WDADetector.d.ts +0 -1
- package/build/p2wda/P2WDADetector.js +0 -1
- package/build/polyfill/disposable.d.ts +0 -1
- package/build/polyfill/disposable.js +0 -1
- package/build/signer/AddressRotation.d.ts +0 -1
- package/build/signer/AddressRotation.js +0 -1
- package/build/signer/IRotationSigner.d.ts +0 -1
- package/build/signer/IRotationSigner.js +0 -1
- package/build/signer/ParallelSignerAdapter.d.ts +0 -1
- package/build/signer/ParallelSignerAdapter.js +0 -1
- package/build/signer/SignerUtils.d.ts +0 -1
- package/build/signer/SignerUtils.js +0 -1
- package/build/signer/TweakedSigner.d.ts +0 -1
- package/build/signer/TweakedSigner.js +0 -1
- package/build/transaction/ContractAddress.d.ts +0 -1
- package/build/transaction/ContractAddress.js +0 -1
- package/build/transaction/TransactionFactory.d.ts +0 -1
- package/build/transaction/TransactionFactory.js +0 -1
- package/build/transaction/browser/BrowserSignerBase.d.ts +0 -1
- package/build/transaction/browser/BrowserSignerBase.js +0 -1
- package/build/transaction/browser/WalletNetworks.d.ts +0 -1
- package/build/transaction/browser/WalletNetworks.js +0 -1
- package/build/transaction/browser/Web3Provider.d.ts +0 -1
- package/build/transaction/browser/Web3Provider.js +0 -1
- package/build/transaction/browser/extensions/UnisatSigner.d.ts +0 -1
- package/build/transaction/browser/extensions/UnisatSigner.js +0 -1
- package/build/transaction/browser/extensions/XverseSigner.d.ts +0 -1
- package/build/transaction/browser/extensions/XverseSigner.js +0 -1
- package/build/transaction/browser/types/OPWallet.d.ts +0 -1
- package/build/transaction/browser/types/OPWallet.js +0 -1
- package/build/transaction/browser/types/Unisat.d.ts +0 -1
- package/build/transaction/browser/types/Unisat.js +0 -1
- package/build/transaction/browser/types/Xverse.d.ts +0 -1
- package/build/transaction/browser/types/Xverse.js +0 -1
- package/build/transaction/builders/CancelTransaction.d.ts +0 -1
- package/build/transaction/builders/CancelTransaction.js +0 -1
- package/build/transaction/builders/ChallengeSolutionTransaction.d.ts +0 -1
- package/build/transaction/builders/ChallengeSolutionTransaction.js +0 -1
- package/build/transaction/builders/ConsolidatedInteractionTransaction.d.ts +0 -1
- package/build/transaction/builders/ConsolidatedInteractionTransaction.js +0 -1
- package/build/transaction/builders/CustomScriptTransaction.d.ts +0 -1
- package/build/transaction/builders/CustomScriptTransaction.js +0 -1
- package/build/transaction/builders/DeploymentTransaction.d.ts +0 -1
- package/build/transaction/builders/DeploymentTransaction.js +0 -1
- package/build/transaction/builders/FundingTransaction.d.ts +0 -1
- package/build/transaction/builders/FundingTransaction.js +0 -1
- package/build/transaction/builders/InteractionTransaction.d.ts +0 -1
- package/build/transaction/builders/InteractionTransaction.js +0 -1
- package/build/transaction/builders/InteractionTransactionP2WDA.d.ts +0 -1
- package/build/transaction/builders/InteractionTransactionP2WDA.js +0 -1
- package/build/transaction/builders/MultiSignTransaction.d.ts +0 -1
- package/build/transaction/builders/MultiSignTransaction.js +0 -1
- package/build/transaction/builders/SharedInteractionTransaction.d.ts +0 -1
- package/build/transaction/builders/SharedInteractionTransaction.js +0 -1
- package/build/transaction/builders/TransactionBuilder.d.ts +0 -1
- package/build/transaction/builders/TransactionBuilder.js +7 -1
- package/build/transaction/enums/TransactionType.d.ts +0 -1
- package/build/transaction/enums/TransactionType.js +0 -1
- package/build/transaction/interfaces/ICancelTransactionParameters.d.ts +0 -1
- package/build/transaction/interfaces/ICancelTransactionParameters.js +0 -1
- package/build/transaction/interfaces/IConsolidatedTransactionParameters.d.ts +0 -1
- package/build/transaction/interfaces/IConsolidatedTransactionParameters.js +0 -1
- package/build/transaction/interfaces/ICustomTransactionParameters.d.ts +0 -1
- package/build/transaction/interfaces/ICustomTransactionParameters.js +0 -1
- package/build/transaction/interfaces/ITransactionParameters.d.ts +0 -1
- package/build/transaction/interfaces/ITransactionParameters.js +0 -1
- package/build/transaction/interfaces/ITransactionResponses.d.ts +0 -1
- package/build/transaction/interfaces/ITransactionResponses.js +0 -1
- package/build/transaction/interfaces/ITweakedTransactionData.d.ts +0 -1
- package/build/transaction/interfaces/ITweakedTransactionData.js +0 -1
- package/build/transaction/interfaces/IWeb3ProviderTypes.d.ts +0 -1
- package/build/transaction/interfaces/IWeb3ProviderTypes.js +0 -1
- package/build/transaction/interfaces/Tap.d.ts +0 -1
- package/build/transaction/interfaces/Tap.js +0 -1
- package/build/transaction/mineable/CSVMultisigProvider.d.ts +102 -0
- package/build/transaction/mineable/CSVMultisigProvider.js +348 -0
- package/build/transaction/mineable/IP2WSHAddress.d.ts +0 -1
- package/build/transaction/mineable/IP2WSHAddress.js +0 -1
- package/build/transaction/mineable/TimelockGenerator.d.ts +0 -1
- package/build/transaction/mineable/TimelockGenerator.js +0 -1
- package/build/transaction/offline/OfflineTransactionManager.d.ts +0 -1
- package/build/transaction/offline/OfflineTransactionManager.js +0 -1
- package/build/transaction/offline/TransactionReconstructor.d.ts +0 -1
- package/build/transaction/offline/TransactionReconstructor.js +0 -1
- package/build/transaction/offline/TransactionSerializer.d.ts +0 -1
- package/build/transaction/offline/TransactionSerializer.js +0 -1
- package/build/transaction/offline/TransactionStateCapture.d.ts +0 -1
- package/build/transaction/offline/TransactionStateCapture.js +0 -1
- package/build/transaction/offline/interfaces/ISerializableState.d.ts +0 -1
- package/build/transaction/offline/interfaces/ISerializableState.js +0 -1
- package/build/transaction/offline/interfaces/ITypeSpecificData.d.ts +0 -1
- package/build/transaction/offline/interfaces/ITypeSpecificData.js +0 -1
- package/build/transaction/psbt/PSBTTypes.d.ts +0 -1
- package/build/transaction/psbt/PSBTTypes.js +0 -1
- package/build/transaction/shared/P2MR_MS.d.ts +0 -1
- package/build/transaction/shared/P2MR_MS.js +0 -1
- package/build/transaction/shared/P2TR_MS.d.ts +0 -1
- package/build/transaction/shared/P2TR_MS.js +0 -1
- package/build/transaction/shared/TweakedTransaction.d.ts +19 -1
- package/build/transaction/shared/TweakedTransaction.js +69 -7
- package/build/transaction/utils/WitnessUtils.d.ts +0 -1
- package/build/transaction/utils/WitnessUtils.js +0 -1
- package/build/utils/BitcoinUtils.d.ts +0 -1
- package/build/utils/BitcoinUtils.js +0 -1
- package/build/utils/BufferHelper.d.ts +0 -1
- package/build/utils/BufferHelper.js +0 -1
- package/build/utils/StringToBuffer.d.ts +0 -1
- package/build/utils/StringToBuffer.js +0 -1
- package/build/utils/lengths.d.ts +0 -1
- package/build/utils/lengths.js +0 -1
- package/build/utils/types.d.ts +0 -1
- package/build/utils/types.js +0 -1
- package/build/utxo/OPNetLimitedProvider.d.ts +0 -1
- package/build/utxo/OPNetLimitedProvider.js +0 -1
- package/build/utxo/interfaces/BroadcastResponse.d.ts +0 -1
- package/build/utxo/interfaces/BroadcastResponse.js +0 -1
- package/build/utxo/interfaces/IUTXO.d.ts +0 -1
- package/build/utxo/interfaces/IUTXO.js +0 -1
- package/build/verification/TapscriptVerificator.d.ts +0 -1
- package/build/verification/TapscriptVerificator.js +0 -1
- package/eslint.config.js +5 -0
- package/package.json +20 -17
- package/src/_version.ts +1 -1
- package/src/keypair/Address.ts +1 -1
- package/src/opnet.ts +1 -0
- package/src/transaction/builders/TransactionBuilder.ts +10 -0
- package/src/transaction/mineable/CSVMultisigProvider.ts +465 -0
- package/src/transaction/shared/TweakedTransaction.ts +90 -5
- package/test/csv-multisig-spend.test.ts +363 -0
- package/test/web3-provider-types.test.ts +349 -0
- package/test/zero-amount-funding.test.ts +311 -0
- package/tsconfig.base.json +2 -2
- package/tsconfig.build.json +4 -1
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +9 -3
- package/browser/_version.d.ts +0 -2
- package/browser/_version.d.ts.map +0 -1
- package/browser/abi/ABICoder.d.ts.map +0 -1
- package/browser/abi/ABIDataTypes.d.ts.map +0 -1
- package/browser/abi/AbiTypes.d.ts.map +0 -1
- package/browser/abi/TupleUtils.d.ts.map +0 -1
- package/browser/branded/Branded.d.ts.map +0 -1
- package/browser/buffer/BinaryReader.d.ts.map +0 -1
- package/browser/buffer/BinaryWriter.d.ts.map +0 -1
- package/browser/bytecode/Compressor.d.ts.map +0 -1
- package/browser/chain/ChainData.d.ts.map +0 -1
- package/browser/consensus/Consensus.d.ts.map +0 -1
- package/browser/consensus/ConsensusConfig.d.ts.map +0 -1
- package/browser/consensus/IConsensusConfig.d.ts.map +0 -1
- package/browser/consensus/metadata/RoswellConsensus.d.ts.map +0 -1
- package/browser/crypto/crypto.d.ts.map +0 -1
- package/browser/deterministic/AddressMap.d.ts.map +0 -1
- package/browser/deterministic/AddressSet.d.ts.map +0 -1
- package/browser/deterministic/CustomMap.d.ts.map +0 -1
- package/browser/deterministic/DeterministicMap.d.ts.map +0 -1
- package/browser/deterministic/DeterministicSet.d.ts.map +0 -1
- package/browser/deterministic/ExtendedAddressMap.d.ts.map +0 -1
- package/browser/deterministic/FastMap.d.ts.map +0 -1
- package/browser/ecc/backend.d.ts.map +0 -1
- package/browser/epoch/ChallengeSolution.d.ts.map +0 -1
- package/browser/epoch/interfaces/IChallengeSolution.d.ts.map +0 -1
- package/browser/epoch/validator/EpochValidator.d.ts.map +0 -1
- package/browser/event/NetEvent.d.ts.map +0 -1
- package/browser/generators/AddressGenerator.d.ts.map +0 -1
- package/browser/generators/Features.d.ts.map +0 -1
- package/browser/generators/Generator.d.ts.map +0 -1
- package/browser/generators/MLDSAData.d.ts.map +0 -1
- package/browser/generators/builders/CalldataGenerator.d.ts.map +0 -1
- package/browser/generators/builders/CustomGenerator.d.ts.map +0 -1
- package/browser/generators/builders/DeploymentGenerator.d.ts.map +0 -1
- package/browser/generators/builders/HashCommitmentGenerator.d.ts.map +0 -1
- package/browser/generators/builders/LegacyCalldataGenerator.d.ts.map +0 -1
- package/browser/generators/builders/MultiSignGenerator.d.ts.map +0 -1
- package/browser/generators/builders/P2WDAGenerator.d.ts.map +0 -1
- package/browser/index.d.ts.map +0 -1
- package/browser/keypair/Address.d.ts.map +0 -1
- package/browser/keypair/AddressVerificator.d.ts.map +0 -1
- package/browser/keypair/EcKeyPair.d.ts.map +0 -1
- package/browser/keypair/MessageSigner.d.ts.map +0 -1
- package/browser/keypair/Secp256k1PointDeriver.d.ts.map +0 -1
- package/browser/keypair/Wallet.d.ts.map +0 -1
- package/browser/keypair/interfaces/IWallet.d.ts.map +0 -1
- package/browser/metadata/ContractBaseMetadata.d.ts.map +0 -1
- package/browser/mnemonic/BIPStandard.d.ts.map +0 -1
- package/browser/mnemonic/Mnemonic.d.ts.map +0 -1
- package/browser/mnemonic/MnemonicStrength.d.ts.map +0 -1
- package/browser/network/ChainId.d.ts.map +0 -1
- package/browser/opnet.d.ts.map +0 -1
- package/browser/p2wda/P2WDADetector.d.ts.map +0 -1
- package/browser/polyfill/disposable.d.ts.map +0 -1
- package/browser/signer/AddressRotation.d.ts.map +0 -1
- package/browser/signer/IRotationSigner.d.ts.map +0 -1
- package/browser/signer/ParallelSignerAdapter.d.ts.map +0 -1
- package/browser/signer/SignerUtils.d.ts.map +0 -1
- package/browser/signer/TweakedSigner.d.ts.map +0 -1
- package/browser/transaction/ContractAddress.d.ts.map +0 -1
- package/browser/transaction/TransactionFactory.d.ts.map +0 -1
- package/browser/transaction/browser/BrowserSignerBase.d.ts.map +0 -1
- package/browser/transaction/browser/WalletNetworks.d.ts.map +0 -1
- package/browser/transaction/browser/Web3Provider.d.ts.map +0 -1
- package/browser/transaction/browser/extensions/UnisatSigner.d.ts.map +0 -1
- package/browser/transaction/browser/extensions/XverseSigner.d.ts.map +0 -1
- package/browser/transaction/browser/types/OPWallet.d.ts.map +0 -1
- package/browser/transaction/browser/types/Unisat.d.ts.map +0 -1
- package/browser/transaction/browser/types/Xverse.d.ts.map +0 -1
- package/browser/transaction/builders/CancelTransaction.d.ts.map +0 -1
- package/browser/transaction/builders/ChallengeSolutionTransaction.d.ts +0 -2
- package/browser/transaction/builders/ChallengeSolutionTransaction.d.ts.map +0 -1
- package/browser/transaction/builders/ConsolidatedInteractionTransaction.d.ts.map +0 -1
- package/browser/transaction/builders/CustomScriptTransaction.d.ts.map +0 -1
- package/browser/transaction/builders/DeploymentTransaction.d.ts.map +0 -1
- package/browser/transaction/builders/FundingTransaction.d.ts.map +0 -1
- package/browser/transaction/builders/InteractionTransaction.d.ts.map +0 -1
- package/browser/transaction/builders/InteractionTransactionP2WDA.d.ts.map +0 -1
- package/browser/transaction/builders/MultiSignTransaction.d.ts.map +0 -1
- package/browser/transaction/builders/SharedInteractionTransaction.d.ts.map +0 -1
- package/browser/transaction/builders/TransactionBuilder.d.ts.map +0 -1
- package/browser/transaction/enums/TransactionType.d.ts.map +0 -1
- package/browser/transaction/interfaces/ICancelTransactionParameters.d.ts.map +0 -1
- package/browser/transaction/interfaces/IConsolidatedTransactionParameters.d.ts.map +0 -1
- package/browser/transaction/interfaces/ICustomTransactionParameters.d.ts.map +0 -1
- package/browser/transaction/interfaces/ITransactionParameters.d.ts.map +0 -1
- package/browser/transaction/interfaces/ITransactionResponses.d.ts.map +0 -1
- package/browser/transaction/interfaces/ITweakedTransactionData.d.ts.map +0 -1
- package/browser/transaction/interfaces/IWeb3ProviderTypes.d.ts.map +0 -1
- package/browser/transaction/interfaces/Tap.d.ts.map +0 -1
- package/browser/transaction/mineable/IP2WSHAddress.d.ts.map +0 -1
- package/browser/transaction/mineable/TimelockGenerator.d.ts.map +0 -1
- package/browser/transaction/offline/OfflineTransactionManager.d.ts.map +0 -1
- package/browser/transaction/offline/TransactionReconstructor.d.ts.map +0 -1
- package/browser/transaction/offline/TransactionSerializer.d.ts.map +0 -1
- package/browser/transaction/offline/TransactionStateCapture.d.ts.map +0 -1
- package/browser/transaction/offline/interfaces/ISerializableState.d.ts.map +0 -1
- package/browser/transaction/offline/interfaces/ITypeSpecificData.d.ts.map +0 -1
- package/browser/transaction/psbt/PSBTTypes.d.ts.map +0 -1
- package/browser/transaction/shared/P2MR_MS.d.ts.map +0 -1
- package/browser/transaction/shared/P2TR_MS.d.ts.map +0 -1
- package/browser/transaction/shared/TweakedTransaction.d.ts.map +0 -1
- package/browser/transaction/utils/WitnessUtils.d.ts.map +0 -1
- package/browser/utils/BitcoinUtils.d.ts.map +0 -1
- package/browser/utils/BufferHelper.d.ts.map +0 -1
- package/browser/utils/StringToBuffer.d.ts.map +0 -1
- package/browser/utils/lengths.d.ts.map +0 -1
- package/browser/utils/types.d.ts.map +0 -1
- package/browser/utxo/OPNetLimitedProvider.d.ts.map +0 -1
- package/browser/utxo/interfaces/BroadcastResponse.d.ts.map +0 -1
- package/browser/utxo/interfaces/IUTXO.d.ts.map +0 -1
- package/browser/verification/TapscriptVerificator.d.ts.map +0 -1
- package/build/_version.d.ts.map +0 -1
- package/build/_version.js.map +0 -1
- package/build/abi/ABICoder.d.ts.map +0 -1
- package/build/abi/ABICoder.js.map +0 -1
- package/build/abi/ABIDataTypes.d.ts.map +0 -1
- package/build/abi/ABIDataTypes.js.map +0 -1
- package/build/abi/AbiTypes.d.ts.map +0 -1
- package/build/abi/AbiTypes.js.map +0 -1
- package/build/abi/TupleUtils.d.ts.map +0 -1
- package/build/abi/TupleUtils.js.map +0 -1
- package/build/branded/Branded.d.ts.map +0 -1
- package/build/branded/Branded.js.map +0 -1
- package/build/buffer/BinaryReader.d.ts.map +0 -1
- package/build/buffer/BinaryReader.js.map +0 -1
- package/build/buffer/BinaryWriter.d.ts.map +0 -1
- package/build/buffer/BinaryWriter.js.map +0 -1
- package/build/bytecode/Compressor.d.ts.map +0 -1
- package/build/bytecode/Compressor.js.map +0 -1
- package/build/chain/ChainData.d.ts.map +0 -1
- package/build/chain/ChainData.js.map +0 -1
- package/build/consensus/Consensus.d.ts.map +0 -1
- package/build/consensus/Consensus.js.map +0 -1
- package/build/consensus/ConsensusConfig.d.ts.map +0 -1
- package/build/consensus/ConsensusConfig.js.map +0 -1
- package/build/consensus/IConsensusConfig.d.ts.map +0 -1
- package/build/consensus/IConsensusConfig.js.map +0 -1
- package/build/consensus/metadata/RoswellConsensus.d.ts.map +0 -1
- package/build/consensus/metadata/RoswellConsensus.js.map +0 -1
- package/build/crypto/crypto.d.ts.map +0 -1
- package/build/crypto/crypto.js.map +0 -1
- package/build/deterministic/AddressMap.d.ts.map +0 -1
- package/build/deterministic/AddressMap.js.map +0 -1
- package/build/deterministic/AddressSet.d.ts.map +0 -1
- package/build/deterministic/AddressSet.js.map +0 -1
- package/build/deterministic/CustomMap.d.ts.map +0 -1
- package/build/deterministic/CustomMap.js.map +0 -1
- package/build/deterministic/DeterministicMap.d.ts.map +0 -1
- package/build/deterministic/DeterministicMap.js.map +0 -1
- package/build/deterministic/DeterministicSet.d.ts.map +0 -1
- package/build/deterministic/DeterministicSet.js.map +0 -1
- package/build/deterministic/ExtendedAddressMap.d.ts.map +0 -1
- package/build/deterministic/ExtendedAddressMap.js.map +0 -1
- package/build/deterministic/FastMap.d.ts.map +0 -1
- package/build/deterministic/FastMap.js.map +0 -1
- package/build/ecc/backend.d.ts.map +0 -1
- package/build/ecc/backend.js.map +0 -1
- package/build/epoch/ChallengeSolution.d.ts.map +0 -1
- package/build/epoch/ChallengeSolution.js.map +0 -1
- package/build/epoch/interfaces/IChallengeSolution.d.ts.map +0 -1
- package/build/epoch/interfaces/IChallengeSolution.js.map +0 -1
- package/build/epoch/validator/EpochValidator.d.ts.map +0 -1
- package/build/epoch/validator/EpochValidator.js.map +0 -1
- package/build/event/NetEvent.d.ts.map +0 -1
- package/build/event/NetEvent.js.map +0 -1
- package/build/generators/AddressGenerator.d.ts.map +0 -1
- package/build/generators/AddressGenerator.js.map +0 -1
- package/build/generators/Features.d.ts.map +0 -1
- package/build/generators/Features.js.map +0 -1
- package/build/generators/Generator.d.ts.map +0 -1
- package/build/generators/Generator.js.map +0 -1
- package/build/generators/MLDSAData.d.ts.map +0 -1
- package/build/generators/MLDSAData.js.map +0 -1
- package/build/generators/builders/CalldataGenerator.d.ts.map +0 -1
- package/build/generators/builders/CalldataGenerator.js.map +0 -1
- package/build/generators/builders/CustomGenerator.d.ts.map +0 -1
- package/build/generators/builders/CustomGenerator.js.map +0 -1
- package/build/generators/builders/DeploymentGenerator.d.ts.map +0 -1
- package/build/generators/builders/DeploymentGenerator.js.map +0 -1
- package/build/generators/builders/HashCommitmentGenerator.d.ts.map +0 -1
- package/build/generators/builders/HashCommitmentGenerator.js.map +0 -1
- package/build/generators/builders/LegacyCalldataGenerator.d.ts.map +0 -1
- package/build/generators/builders/LegacyCalldataGenerator.js.map +0 -1
- package/build/generators/builders/MultiSignGenerator.d.ts.map +0 -1
- package/build/generators/builders/MultiSignGenerator.js.map +0 -1
- package/build/generators/builders/P2WDAGenerator.d.ts.map +0 -1
- package/build/generators/builders/P2WDAGenerator.js.map +0 -1
- package/build/index.d.ts.map +0 -1
- package/build/index.js.map +0 -1
- package/build/keypair/Address.d.ts.map +0 -1
- package/build/keypair/Address.js.map +0 -1
- package/build/keypair/AddressVerificator.d.ts.map +0 -1
- package/build/keypair/AddressVerificator.js.map +0 -1
- package/build/keypair/EcKeyPair.d.ts.map +0 -1
- package/build/keypair/EcKeyPair.js.map +0 -1
- package/build/keypair/MessageSigner.d.ts.map +0 -1
- package/build/keypair/MessageSigner.js.map +0 -1
- package/build/keypair/Secp256k1PointDeriver.d.ts.map +0 -1
- package/build/keypair/Secp256k1PointDeriver.js.map +0 -1
- package/build/keypair/Wallet.d.ts.map +0 -1
- package/build/keypair/Wallet.js.map +0 -1
- package/build/keypair/interfaces/IWallet.d.ts.map +0 -1
- package/build/keypair/interfaces/IWallet.js.map +0 -1
- package/build/metadata/ContractBaseMetadata.d.ts.map +0 -1
- package/build/metadata/ContractBaseMetadata.js.map +0 -1
- package/build/mnemonic/BIPStandard.d.ts.map +0 -1
- package/build/mnemonic/BIPStandard.js.map +0 -1
- package/build/mnemonic/Mnemonic.d.ts.map +0 -1
- package/build/mnemonic/Mnemonic.js.map +0 -1
- package/build/mnemonic/MnemonicStrength.d.ts.map +0 -1
- package/build/mnemonic/MnemonicStrength.js.map +0 -1
- package/build/network/ChainId.d.ts.map +0 -1
- package/build/network/ChainId.js.map +0 -1
- package/build/opnet.d.ts.map +0 -1
- package/build/opnet.js.map +0 -1
- package/build/p2wda/P2WDADetector.d.ts.map +0 -1
- package/build/p2wda/P2WDADetector.js.map +0 -1
- package/build/polyfill/disposable.d.ts.map +0 -1
- package/build/polyfill/disposable.js.map +0 -1
- package/build/signer/AddressRotation.d.ts.map +0 -1
- package/build/signer/AddressRotation.js.map +0 -1
- package/build/signer/IRotationSigner.d.ts.map +0 -1
- package/build/signer/IRotationSigner.js.map +0 -1
- package/build/signer/ParallelSignerAdapter.d.ts.map +0 -1
- package/build/signer/ParallelSignerAdapter.js.map +0 -1
- package/build/signer/SignerUtils.d.ts.map +0 -1
- package/build/signer/SignerUtils.js.map +0 -1
- package/build/signer/TweakedSigner.d.ts.map +0 -1
- package/build/signer/TweakedSigner.js.map +0 -1
- package/build/transaction/ContractAddress.d.ts.map +0 -1
- package/build/transaction/ContractAddress.js.map +0 -1
- package/build/transaction/TransactionFactory.d.ts.map +0 -1
- package/build/transaction/TransactionFactory.js.map +0 -1
- package/build/transaction/browser/BrowserSignerBase.d.ts.map +0 -1
- package/build/transaction/browser/BrowserSignerBase.js.map +0 -1
- package/build/transaction/browser/WalletNetworks.d.ts.map +0 -1
- package/build/transaction/browser/WalletNetworks.js.map +0 -1
- package/build/transaction/browser/Web3Provider.d.ts.map +0 -1
- package/build/transaction/browser/Web3Provider.js.map +0 -1
- package/build/transaction/browser/extensions/UnisatSigner.d.ts.map +0 -1
- package/build/transaction/browser/extensions/UnisatSigner.js.map +0 -1
- package/build/transaction/browser/extensions/XverseSigner.d.ts.map +0 -1
- package/build/transaction/browser/extensions/XverseSigner.js.map +0 -1
- package/build/transaction/browser/types/OPWallet.d.ts.map +0 -1
- package/build/transaction/browser/types/OPWallet.js.map +0 -1
- package/build/transaction/browser/types/Unisat.d.ts.map +0 -1
- package/build/transaction/browser/types/Unisat.js.map +0 -1
- package/build/transaction/browser/types/Xverse.d.ts.map +0 -1
- package/build/transaction/browser/types/Xverse.js.map +0 -1
- package/build/transaction/builders/CancelTransaction.d.ts.map +0 -1
- package/build/transaction/builders/CancelTransaction.js.map +0 -1
- package/build/transaction/builders/ChallengeSolutionTransaction.d.ts.map +0 -1
- package/build/transaction/builders/ChallengeSolutionTransaction.js.map +0 -1
- package/build/transaction/builders/ConsolidatedInteractionTransaction.d.ts.map +0 -1
- package/build/transaction/builders/ConsolidatedInteractionTransaction.js.map +0 -1
- package/build/transaction/builders/CustomScriptTransaction.d.ts.map +0 -1
- package/build/transaction/builders/CustomScriptTransaction.js.map +0 -1
- package/build/transaction/builders/DeploymentTransaction.d.ts.map +0 -1
- package/build/transaction/builders/DeploymentTransaction.js.map +0 -1
- package/build/transaction/builders/FundingTransaction.d.ts.map +0 -1
- package/build/transaction/builders/FundingTransaction.js.map +0 -1
- package/build/transaction/builders/InteractionTransaction.d.ts.map +0 -1
- package/build/transaction/builders/InteractionTransaction.js.map +0 -1
- package/build/transaction/builders/InteractionTransactionP2WDA.d.ts.map +0 -1
- package/build/transaction/builders/InteractionTransactionP2WDA.js.map +0 -1
- package/build/transaction/builders/MultiSignTransaction.d.ts.map +0 -1
- package/build/transaction/builders/MultiSignTransaction.js.map +0 -1
- package/build/transaction/builders/SharedInteractionTransaction.d.ts.map +0 -1
- package/build/transaction/builders/SharedInteractionTransaction.js.map +0 -1
- package/build/transaction/builders/TransactionBuilder.d.ts.map +0 -1
- package/build/transaction/builders/TransactionBuilder.js.map +0 -1
- package/build/transaction/enums/TransactionType.d.ts.map +0 -1
- package/build/transaction/enums/TransactionType.js.map +0 -1
- package/build/transaction/interfaces/ICancelTransactionParameters.d.ts.map +0 -1
- package/build/transaction/interfaces/ICancelTransactionParameters.js.map +0 -1
- package/build/transaction/interfaces/IConsolidatedTransactionParameters.d.ts.map +0 -1
- package/build/transaction/interfaces/IConsolidatedTransactionParameters.js.map +0 -1
- package/build/transaction/interfaces/ICustomTransactionParameters.d.ts.map +0 -1
- package/build/transaction/interfaces/ICustomTransactionParameters.js.map +0 -1
- package/build/transaction/interfaces/ITransactionParameters.d.ts.map +0 -1
- package/build/transaction/interfaces/ITransactionParameters.js.map +0 -1
- package/build/transaction/interfaces/ITransactionResponses.d.ts.map +0 -1
- package/build/transaction/interfaces/ITransactionResponses.js.map +0 -1
- package/build/transaction/interfaces/ITweakedTransactionData.d.ts.map +0 -1
- package/build/transaction/interfaces/ITweakedTransactionData.js.map +0 -1
- package/build/transaction/interfaces/IWeb3ProviderTypes.d.ts.map +0 -1
- package/build/transaction/interfaces/IWeb3ProviderTypes.js.map +0 -1
- package/build/transaction/interfaces/Tap.d.ts.map +0 -1
- package/build/transaction/interfaces/Tap.js.map +0 -1
- package/build/transaction/mineable/IP2WSHAddress.d.ts.map +0 -1
- package/build/transaction/mineable/IP2WSHAddress.js.map +0 -1
- package/build/transaction/mineable/TimelockGenerator.d.ts.map +0 -1
- package/build/transaction/mineable/TimelockGenerator.js.map +0 -1
- package/build/transaction/offline/OfflineTransactionManager.d.ts.map +0 -1
- package/build/transaction/offline/OfflineTransactionManager.js.map +0 -1
- package/build/transaction/offline/TransactionReconstructor.d.ts.map +0 -1
- package/build/transaction/offline/TransactionReconstructor.js.map +0 -1
- package/build/transaction/offline/TransactionSerializer.d.ts.map +0 -1
- package/build/transaction/offline/TransactionSerializer.js.map +0 -1
- package/build/transaction/offline/TransactionStateCapture.d.ts.map +0 -1
- package/build/transaction/offline/TransactionStateCapture.js.map +0 -1
- package/build/transaction/offline/interfaces/ISerializableState.d.ts.map +0 -1
- package/build/transaction/offline/interfaces/ISerializableState.js.map +0 -1
- package/build/transaction/offline/interfaces/ITypeSpecificData.d.ts.map +0 -1
- package/build/transaction/offline/interfaces/ITypeSpecificData.js.map +0 -1
- package/build/transaction/psbt/PSBTTypes.d.ts.map +0 -1
- package/build/transaction/psbt/PSBTTypes.js.map +0 -1
- package/build/transaction/shared/P2MR_MS.d.ts.map +0 -1
- package/build/transaction/shared/P2MR_MS.js.map +0 -1
- package/build/transaction/shared/P2TR_MS.d.ts.map +0 -1
- package/build/transaction/shared/P2TR_MS.js.map +0 -1
- package/build/transaction/shared/TweakedTransaction.d.ts.map +0 -1
- package/build/transaction/shared/TweakedTransaction.js.map +0 -1
- package/build/transaction/utils/WitnessUtils.d.ts.map +0 -1
- package/build/transaction/utils/WitnessUtils.js.map +0 -1
- package/build/tsconfig.build.tsbuildinfo +0 -1
- package/build/utils/BitcoinUtils.d.ts.map +0 -1
- package/build/utils/BitcoinUtils.js.map +0 -1
- package/build/utils/BufferHelper.d.ts.map +0 -1
- package/build/utils/BufferHelper.js.map +0 -1
- package/build/utils/StringToBuffer.d.ts.map +0 -1
- package/build/utils/StringToBuffer.js.map +0 -1
- package/build/utils/lengths.d.ts.map +0 -1
- package/build/utils/lengths.js.map +0 -1
- package/build/utils/types.d.ts.map +0 -1
- package/build/utils/types.js.map +0 -1
- package/build/utxo/OPNetLimitedProvider.d.ts.map +0 -1
- package/build/utxo/OPNetLimitedProvider.js.map +0 -1
- package/build/utxo/interfaces/BroadcastResponse.d.ts.map +0 -1
- package/build/utxo/interfaces/BroadcastResponse.js.map +0 -1
- package/build/utxo/interfaces/IUTXO.d.ts.map +0 -1
- package/build/utxo/interfaces/IUTXO.js.map +0 -1
- package/build/verification/TapscriptVerificator.d.ts.map +0 -1
- package/build/verification/TapscriptVerificator.js.map +0 -1
package/browser/noble-curves.js
CHANGED
|
@@ -1,114 +1,119 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
function
|
|
3
|
-
return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
|
|
1
|
+
import { n as Dt, r as Bn } from "./rolldown-runtime.js";
|
|
2
|
+
function Sn(t) {
|
|
3
|
+
return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in t && t.BYTES_PER_ELEMENT === 1;
|
|
4
4
|
}
|
|
5
|
-
function
|
|
5
|
+
function Pt(t, n = "") {
|
|
6
|
+
if (typeof t != "number") {
|
|
7
|
+
const e = n && `"${n}" `;
|
|
8
|
+
throw new TypeError(`${e}expected number, got ${typeof t}`);
|
|
9
|
+
}
|
|
6
10
|
if (!Number.isSafeInteger(t) || t < 0) {
|
|
7
|
-
const
|
|
8
|
-
throw new
|
|
11
|
+
const e = n && `"${n}" `;
|
|
12
|
+
throw new RangeError(`${e}expected integer >= 0, got ${t}`);
|
|
9
13
|
}
|
|
10
14
|
}
|
|
11
|
-
function
|
|
12
|
-
const
|
|
13
|
-
if (!
|
|
14
|
-
const
|
|
15
|
-
throw new
|
|
15
|
+
function zt(t, n, e = "") {
|
|
16
|
+
const r = Sn(t), o = t?.length, i = n !== void 0;
|
|
17
|
+
if (!r || i && o !== n) {
|
|
18
|
+
const a = e && `"${e}" `, f = i ? ` of length ${n}` : "", l = r ? `length=${o}` : `type=${typeof t}`, g = a + "expected Uint8Array" + f + ", got " + l;
|
|
19
|
+
throw r ? new RangeError(g) : new TypeError(g);
|
|
16
20
|
}
|
|
17
21
|
return t;
|
|
18
22
|
}
|
|
19
|
-
function
|
|
20
|
-
if (typeof t != "function" || typeof t.create != "function") throw new
|
|
21
|
-
|
|
23
|
+
function An(t) {
|
|
24
|
+
if (typeof t != "function" || typeof t.create != "function") throw new TypeError("Hash must wrapped by utils.createHasher");
|
|
25
|
+
if (Pt(t.outputLen), Pt(t.blockLen), t.outputLen < 1) throw new Error('"outputLen" must be >= 1');
|
|
26
|
+
if (t.blockLen < 1) throw new Error('"blockLen" must be >= 1');
|
|
22
27
|
}
|
|
23
|
-
function
|
|
28
|
+
function de(t, n = !0) {
|
|
24
29
|
if (t.destroyed) throw new Error("Hash instance has been destroyed");
|
|
25
|
-
if (
|
|
26
|
-
}
|
|
27
|
-
function Rn(t, e) {
|
|
28
|
-
C(t, void 0, "digestInto() output");
|
|
29
|
-
const r = e.outputLen;
|
|
30
|
-
if (t.length < r) throw new Error('"digestInto() output" expected to be of length >=' + r);
|
|
30
|
+
if (n && t.finished) throw new Error("Hash#digest() has already been called");
|
|
31
31
|
}
|
|
32
|
-
function
|
|
33
|
-
|
|
32
|
+
function Rn(t, n) {
|
|
33
|
+
zt(t, void 0, "digestInto() output");
|
|
34
|
+
const e = n.outputLen;
|
|
35
|
+
if (t.length < e) throw new RangeError('"digestInto() output" expected to be of length >=' + e);
|
|
34
36
|
}
|
|
35
|
-
function
|
|
36
|
-
for (let
|
|
37
|
+
function Kt(...t) {
|
|
38
|
+
for (let n = 0; n < t.length; n++) t[n].fill(0);
|
|
37
39
|
}
|
|
38
|
-
function
|
|
40
|
+
function Be(t) {
|
|
39
41
|
return new DataView(t.buffer, t.byteOffset, t.byteLength);
|
|
40
42
|
}
|
|
41
|
-
function
|
|
42
|
-
return t << 32 -
|
|
43
|
-
}
|
|
44
|
-
function Ir(t, e) {
|
|
45
|
-
return t << e | t >>> 32 - e >>> 0;
|
|
43
|
+
function vt(t, n) {
|
|
44
|
+
return t << 32 - n | t >>> n;
|
|
46
45
|
}
|
|
47
|
-
function
|
|
48
|
-
return t <<
|
|
46
|
+
function Ho(t, n) {
|
|
47
|
+
return t << n | t >>> 32 - n >>> 0;
|
|
49
48
|
}
|
|
50
|
-
function
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
function Ke(t) {
|
|
50
|
+
if (zt(t), Xe) return t.toHex();
|
|
51
|
+
let n = "";
|
|
52
|
+
for (let e = 0; e < t.length; e++) n += On[t[e]];
|
|
53
|
+
return n;
|
|
53
54
|
}
|
|
54
|
-
function
|
|
55
|
-
if (
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return e;
|
|
55
|
+
function sn(t) {
|
|
56
|
+
if (t >= xt._0 && t <= xt._9) return t - xt._0;
|
|
57
|
+
if (t >= xt.A && t <= xt.F) return t - (xt.A - 10);
|
|
58
|
+
if (t >= xt.a && t <= xt.f) return t - (xt.a - 10);
|
|
59
59
|
}
|
|
60
|
-
function
|
|
61
|
-
if (t
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
n[o] = i * 16 + c;
|
|
60
|
+
function _n(t) {
|
|
61
|
+
if (typeof t != "string") throw new TypeError("hex string expected, got " + typeof t);
|
|
62
|
+
if (Xe) try {
|
|
63
|
+
return Uint8Array.fromHex(t);
|
|
64
|
+
} catch (o) {
|
|
65
|
+
throw o instanceof SyntaxError ? new RangeError(o.message) : o;
|
|
66
|
+
}
|
|
67
|
+
const n = t.length, e = n / 2;
|
|
68
|
+
if (n % 2) throw new RangeError("hex string expected, got unpadded hex of length " + n);
|
|
69
|
+
const r = new Uint8Array(e);
|
|
70
|
+
for (let o = 0, i = 0; o < e; o++, i += 2) {
|
|
71
|
+
const a = sn(t.charCodeAt(i)), f = sn(t.charCodeAt(i + 1));
|
|
72
|
+
if (a === void 0 || f === void 0) {
|
|
73
|
+
const l = t[i] + t[i + 1];
|
|
74
|
+
throw new RangeError('hex string expected, got non-hex character "' + l + '" at index ' + i);
|
|
75
|
+
}
|
|
76
|
+
r[o] = a * 16 + f;
|
|
78
77
|
}
|
|
79
|
-
return
|
|
78
|
+
return r;
|
|
80
79
|
}
|
|
81
|
-
function
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
80
|
+
function Nt(t) {
|
|
81
|
+
if (typeof t != "string") throw new TypeError("string expected");
|
|
82
|
+
return new Uint8Array(new TextEncoder().encode(t));
|
|
83
|
+
}
|
|
84
|
+
function br(...t) {
|
|
85
|
+
let n = 0;
|
|
86
|
+
for (let r = 0; r < t.length; r++) {
|
|
87
|
+
const o = t[r];
|
|
88
|
+
zt(o), n += o.length;
|
|
86
89
|
}
|
|
87
|
-
const
|
|
88
|
-
for (let
|
|
89
|
-
const
|
|
90
|
-
|
|
90
|
+
const e = new Uint8Array(n);
|
|
91
|
+
for (let r = 0, o = 0; r < t.length; r++) {
|
|
92
|
+
const i = t[r];
|
|
93
|
+
e.set(i, o), o += i.length;
|
|
91
94
|
}
|
|
92
|
-
return
|
|
95
|
+
return e;
|
|
93
96
|
}
|
|
94
|
-
function
|
|
95
|
-
const
|
|
96
|
-
return
|
|
97
|
+
function Yt(t, n = {}) {
|
|
98
|
+
const e = (o, i) => t(i).update(o).digest(), r = t(void 0);
|
|
99
|
+
return e.outputLen = r.outputLen, e.blockLen = r.blockLen, e.canXOF = r.canXOF, e.create = (o) => t(o), Object.assign(e, n), Object.freeze(e);
|
|
97
100
|
}
|
|
98
|
-
function
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
function yr(t = 32) {
|
|
102
|
+
Pt(t, "bytesLength");
|
|
103
|
+
const n = typeof globalThis == "object" ? globalThis.crypto : null;
|
|
104
|
+
if (typeof n?.getRandomValues != "function") throw new Error("crypto.getRandomValues must be defined");
|
|
105
|
+
if (t > 65536) throw new RangeError(`"bytesLength" expected <= 65536, got ${t}`);
|
|
106
|
+
return n.getRandomValues(new Uint8Array(t));
|
|
102
107
|
}
|
|
103
|
-
var
|
|
104
|
-
|
|
108
|
+
var pr, Xe, On, xt, Lt, Qt = Dt((() => {
|
|
109
|
+
pr = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68, Xe = typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", On = /* @__PURE__ */ Array.from({ length: 256 }, (t, n) => n.toString(16).padStart(2, "0")), xt = {
|
|
105
110
|
_0: 48,
|
|
106
111
|
_9: 57,
|
|
107
112
|
A: 65,
|
|
108
113
|
F: 70,
|
|
109
114
|
a: 97,
|
|
110
115
|
f: 102
|
|
111
|
-
},
|
|
116
|
+
}, Lt = (t) => ({ oid: Uint8Array.from([
|
|
112
117
|
6,
|
|
113
118
|
9,
|
|
114
119
|
96,
|
|
@@ -121,32 +126,35 @@ var He, In, pe, Ke, it, mt, Nt = Bt((() => {
|
|
|
121
126
|
2,
|
|
122
127
|
t
|
|
123
128
|
]) });
|
|
124
|
-
})),
|
|
125
|
-
_HMAC: () =>
|
|
126
|
-
hmac: () =>
|
|
127
|
-
}),
|
|
128
|
-
|
|
129
|
+
})), To = /* @__PURE__ */ Bn({
|
|
130
|
+
_HMAC: () => le,
|
|
131
|
+
hmac: () => We
|
|
132
|
+
}), le, We, Er = Dt((() => {
|
|
133
|
+
Qt(), le = class {
|
|
129
134
|
oHash;
|
|
130
135
|
iHash;
|
|
131
136
|
blockLen;
|
|
132
137
|
outputLen;
|
|
138
|
+
canXOF = !1;
|
|
133
139
|
finished = !1;
|
|
134
140
|
destroyed = !1;
|
|
135
|
-
constructor(t,
|
|
136
|
-
if (
|
|
141
|
+
constructor(t, n) {
|
|
142
|
+
if (An(t), zt(n, void 0, "key"), this.iHash = t.create(), typeof this.iHash.update != "function") throw new Error("Expected instance of class which extends utils.Hash");
|
|
137
143
|
this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
for (let o = 0; o <
|
|
141
|
-
this.iHash.update(
|
|
142
|
-
for (let o = 0; o <
|
|
143
|
-
this.oHash.update(
|
|
144
|
+
const e = this.blockLen, r = new Uint8Array(e);
|
|
145
|
+
r.set(n.length > e ? t.create().update(n).digest() : n);
|
|
146
|
+
for (let o = 0; o < r.length; o++) r[o] ^= 54;
|
|
147
|
+
this.iHash.update(r), this.oHash = t.create();
|
|
148
|
+
for (let o = 0; o < r.length; o++) r[o] ^= 106;
|
|
149
|
+
this.oHash.update(r), Kt(r);
|
|
144
150
|
}
|
|
145
151
|
update(t) {
|
|
146
|
-
return
|
|
152
|
+
return de(this), this.iHash.update(t), this;
|
|
147
153
|
}
|
|
148
154
|
digestInto(t) {
|
|
149
|
-
|
|
155
|
+
de(this), Rn(t, this), this.finished = !0;
|
|
156
|
+
const n = t.subarray(0, this.outputLen);
|
|
157
|
+
this.iHash.digestInto(n), this.oHash.update(n), this.oHash.digestInto(n), this.destroy();
|
|
150
158
|
}
|
|
151
159
|
digest() {
|
|
152
160
|
const t = new Uint8Array(this.oHash.outputLen);
|
|
@@ -154,8 +162,8 @@ var He, In, pe, Ke, it, mt, Nt = Bt((() => {
|
|
|
154
162
|
}
|
|
155
163
|
_cloneInto(t) {
|
|
156
164
|
t ||= Object.create(Object.getPrototypeOf(this), {});
|
|
157
|
-
const { oHash:
|
|
158
|
-
return t = t, t.finished =
|
|
165
|
+
const { oHash: n, iHash: e, finished: r, destroyed: o, blockLen: i, outputLen: a } = this;
|
|
166
|
+
return t = t, t.finished = r, t.destroyed = o, t.blockLen = i, t.outputLen = a, t.oHash = n._cloneInto(t.oHash), t.iHash = e._cloneInto(t.iHash), t;
|
|
159
167
|
}
|
|
160
168
|
clone() {
|
|
161
169
|
return this._cloneInto();
|
|
@@ -163,18 +171,22 @@ var He, In, pe, Ke, it, mt, Nt = Bt((() => {
|
|
|
163
171
|
destroy() {
|
|
164
172
|
this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
|
|
165
173
|
}
|
|
166
|
-
},
|
|
174
|
+
}, We = /* @__PURE__ */ (() => {
|
|
175
|
+
const t = ((n, e, r) => new le(n, e).update(r).digest());
|
|
176
|
+
return t.create = (n, e) => new le(n, e), t;
|
|
177
|
+
})();
|
|
167
178
|
}));
|
|
168
|
-
function
|
|
169
|
-
return t &
|
|
179
|
+
function vr(t, n, e) {
|
|
180
|
+
return t & n ^ ~t & e;
|
|
170
181
|
}
|
|
171
|
-
function
|
|
172
|
-
return t &
|
|
182
|
+
function xr(t, n, e) {
|
|
183
|
+
return t & n ^ t & e ^ n & e;
|
|
173
184
|
}
|
|
174
|
-
var
|
|
175
|
-
|
|
185
|
+
var Fe, Ht, Tt, lt, ut, Br = Dt((() => {
|
|
186
|
+
Qt(), Fe = class {
|
|
176
187
|
blockLen;
|
|
177
188
|
outputLen;
|
|
189
|
+
canXOF = !1;
|
|
178
190
|
padOffset;
|
|
179
191
|
isLE;
|
|
180
192
|
buffer;
|
|
@@ -183,51 +195,51 @@ var ae, dt, ht, K, X, Nn = Bt((() => {
|
|
|
183
195
|
length = 0;
|
|
184
196
|
pos = 0;
|
|
185
197
|
destroyed = !1;
|
|
186
|
-
constructor(t, e, r
|
|
187
|
-
this.blockLen = t, this.outputLen =
|
|
198
|
+
constructor(t, n, e, r) {
|
|
199
|
+
this.blockLen = t, this.outputLen = n, this.padOffset = e, this.isLE = r, this.buffer = new Uint8Array(t), this.view = Be(this.buffer);
|
|
188
200
|
}
|
|
189
201
|
update(t) {
|
|
190
|
-
|
|
191
|
-
const { view:
|
|
192
|
-
for (let
|
|
193
|
-
const
|
|
194
|
-
if (
|
|
195
|
-
const
|
|
196
|
-
for (;
|
|
202
|
+
de(this), zt(t);
|
|
203
|
+
const { view: n, buffer: e, blockLen: r } = this, o = t.length;
|
|
204
|
+
for (let i = 0; i < o; ) {
|
|
205
|
+
const a = Math.min(r - this.pos, o - i);
|
|
206
|
+
if (a === r) {
|
|
207
|
+
const f = Be(t);
|
|
208
|
+
for (; r <= o - i; i += r) this.process(f, i);
|
|
197
209
|
continue;
|
|
198
210
|
}
|
|
199
|
-
|
|
211
|
+
e.set(t.subarray(i, i + a), this.pos), this.pos += a, i += a, this.pos === r && (this.process(n, 0), this.pos = 0);
|
|
200
212
|
}
|
|
201
213
|
return this.length += t.length, this.roundClean(), this;
|
|
202
214
|
}
|
|
203
215
|
digestInto(t) {
|
|
204
|
-
|
|
205
|
-
const { buffer:
|
|
206
|
-
let { pos:
|
|
207
|
-
|
|
208
|
-
for (let
|
|
209
|
-
|
|
210
|
-
const
|
|
211
|
-
if (
|
|
212
|
-
const
|
|
213
|
-
if (
|
|
214
|
-
for (let
|
|
216
|
+
de(this), Rn(t, this), this.finished = !0;
|
|
217
|
+
const { buffer: n, view: e, blockLen: r, isLE: o } = this;
|
|
218
|
+
let { pos: i } = this;
|
|
219
|
+
n[i++] = 128, Kt(this.buffer.subarray(i)), this.padOffset > r - i && (this.process(e, 0), i = 0);
|
|
220
|
+
for (let s = i; s < r; s++) n[s] = 0;
|
|
221
|
+
e.setBigUint64(r - 8, BigInt(this.length * 8), o), this.process(e, 0);
|
|
222
|
+
const a = Be(t), f = this.outputLen;
|
|
223
|
+
if (f % 4) throw new Error("_sha2: outputLen must be aligned to 32bit");
|
|
224
|
+
const l = f / 4, g = this.get();
|
|
225
|
+
if (l > g.length) throw new Error("_sha2: outputLen bigger than state");
|
|
226
|
+
for (let s = 0; s < l; s++) a.setUint32(4 * s, g[s], o);
|
|
215
227
|
}
|
|
216
228
|
digest() {
|
|
217
|
-
const { buffer: t, outputLen:
|
|
229
|
+
const { buffer: t, outputLen: n } = this;
|
|
218
230
|
this.digestInto(t);
|
|
219
|
-
const
|
|
220
|
-
return this.destroy(),
|
|
231
|
+
const e = t.slice(0, n);
|
|
232
|
+
return this.destroy(), e;
|
|
221
233
|
}
|
|
222
234
|
_cloneInto(t) {
|
|
223
235
|
t ||= new this.constructor(), t.set(...this.get());
|
|
224
|
-
const { blockLen:
|
|
225
|
-
return t.destroyed =
|
|
236
|
+
const { blockLen: n, buffer: e, length: r, finished: o, destroyed: i, pos: a } = this;
|
|
237
|
+
return t.destroyed = i, t.finished = o, t.length = r, t.pos = a, r % n && t.buffer.set(e), t;
|
|
226
238
|
}
|
|
227
239
|
clone() {
|
|
228
240
|
return this._cloneInto();
|
|
229
241
|
}
|
|
230
|
-
},
|
|
242
|
+
}, Ht = /* @__PURE__ */ Uint32Array.from([
|
|
231
243
|
1779033703,
|
|
232
244
|
3144134277,
|
|
233
245
|
1013904242,
|
|
@@ -236,7 +248,7 @@ var ae, dt, ht, K, X, Nn = Bt((() => {
|
|
|
236
248
|
2600822924,
|
|
237
249
|
528734635,
|
|
238
250
|
1541459225
|
|
239
|
-
]),
|
|
251
|
+
]), Tt = /* @__PURE__ */ Uint32Array.from([
|
|
240
252
|
3238371032,
|
|
241
253
|
914150663,
|
|
242
254
|
812702999,
|
|
@@ -245,7 +257,7 @@ var ae, dt, ht, K, X, Nn = Bt((() => {
|
|
|
245
257
|
1750603025,
|
|
246
258
|
1694076839,
|
|
247
259
|
3204075428
|
|
248
|
-
]),
|
|
260
|
+
]), lt = /* @__PURE__ */ Uint32Array.from([
|
|
249
261
|
3418070365,
|
|
250
262
|
3238371032,
|
|
251
263
|
1654270250,
|
|
@@ -262,7 +274,7 @@ var ae, dt, ht, K, X, Nn = Bt((() => {
|
|
|
262
274
|
1694076839,
|
|
263
275
|
1203062813,
|
|
264
276
|
3204075428
|
|
265
|
-
]),
|
|
277
|
+
]), ut = /* @__PURE__ */ Uint32Array.from([
|
|
266
278
|
1779033703,
|
|
267
279
|
4089235720,
|
|
268
280
|
3144134277,
|
|
@@ -281,48 +293,48 @@ var ae, dt, ht, K, X, Nn = Bt((() => {
|
|
|
281
293
|
327033209
|
|
282
294
|
]);
|
|
283
295
|
}));
|
|
284
|
-
function
|
|
285
|
-
return
|
|
286
|
-
h: Number(t &
|
|
287
|
-
l: Number(t >>
|
|
296
|
+
function Sr(t, n = !1) {
|
|
297
|
+
return n ? {
|
|
298
|
+
h: Number(t & ee),
|
|
299
|
+
l: Number(t >> Ie & ee)
|
|
288
300
|
} : {
|
|
289
|
-
h: Number(t >>
|
|
290
|
-
l: Number(t &
|
|
301
|
+
h: Number(t >> Ie & ee) | 0,
|
|
302
|
+
l: Number(t & ee) | 0
|
|
291
303
|
};
|
|
292
304
|
}
|
|
293
|
-
function
|
|
294
|
-
const
|
|
295
|
-
let
|
|
296
|
-
for (let
|
|
297
|
-
const { h:
|
|
298
|
-
[
|
|
305
|
+
function Ar(t, n = !1) {
|
|
306
|
+
const e = t.length;
|
|
307
|
+
let r = new Uint32Array(e), o = new Uint32Array(e);
|
|
308
|
+
for (let i = 0; i < e; i++) {
|
|
309
|
+
const { h: a, l: f } = Sr(t[i], n);
|
|
310
|
+
[r[i], o[i]] = [a, f];
|
|
299
311
|
}
|
|
300
|
-
return [
|
|
312
|
+
return [r, o];
|
|
301
313
|
}
|
|
302
|
-
function
|
|
303
|
-
const o = (
|
|
314
|
+
function At(t, n, e, r) {
|
|
315
|
+
const o = (n >>> 0) + (r >>> 0);
|
|
304
316
|
return {
|
|
305
|
-
h: t +
|
|
317
|
+
h: t + e + (o / 2 ** 32 | 0) | 0,
|
|
306
318
|
l: o | 0
|
|
307
319
|
};
|
|
308
320
|
}
|
|
309
|
-
var
|
|
310
|
-
|
|
311
|
-
})),
|
|
312
|
-
_SHA224: () =>
|
|
313
|
-
_SHA256: () =>
|
|
314
|
-
_SHA384: () =>
|
|
315
|
-
_SHA512: () =>
|
|
316
|
-
_SHA512_224: () =>
|
|
317
|
-
_SHA512_256: () =>
|
|
318
|
-
sha224: () =>
|
|
319
|
-
sha256: () =>
|
|
320
|
-
sha384: () =>
|
|
321
|
-
sha512: () =>
|
|
322
|
-
sha512_224: () =>
|
|
323
|
-
sha512_256: () =>
|
|
324
|
-
}),
|
|
325
|
-
|
|
321
|
+
var ee, Ie, Ne, je, Ut, qt, ne, re, Hn, Tn, Fn, In, Nn, jn, Rr = Dt((() => {
|
|
322
|
+
ee = /* @__PURE__ */ BigInt(2 ** 32 - 1), Ie = /* @__PURE__ */ BigInt(32), Ne = (t, n, e) => t >>> e, je = (t, n, e) => t << 32 - e | n >>> e, Ut = (t, n, e) => t >>> e | n << 32 - e, qt = (t, n, e) => t << 32 - e | n >>> e, ne = (t, n, e) => t << 64 - e | n >>> e - 32, re = (t, n, e) => t >>> e - 32 | n << 64 - e, Hn = (t, n, e) => (t >>> 0) + (n >>> 0) + (e >>> 0), Tn = (t, n, e, r) => n + e + r + (t / 2 ** 32 | 0) | 0, Fn = (t, n, e, r) => (t >>> 0) + (n >>> 0) + (e >>> 0) + (r >>> 0), In = (t, n, e, r, o) => n + e + r + o + (t / 2 ** 32 | 0) | 0, Nn = (t, n, e, r, o) => (t >>> 0) + (n >>> 0) + (e >>> 0) + (r >>> 0) + (o >>> 0), jn = (t, n, e, r, o, i) => n + e + r + o + i + (t / 2 ** 32 | 0) | 0;
|
|
323
|
+
})), Fo = /* @__PURE__ */ Bn({
|
|
324
|
+
_SHA224: () => Le,
|
|
325
|
+
_SHA256: () => De,
|
|
326
|
+
_SHA384: () => qe,
|
|
327
|
+
_SHA512: () => Ue,
|
|
328
|
+
_SHA512_224: () => Ce,
|
|
329
|
+
_SHA512_256: () => ke,
|
|
330
|
+
sha224: () => Dn,
|
|
331
|
+
sha256: () => jt,
|
|
332
|
+
sha384: () => Un,
|
|
333
|
+
sha512: () => Ln,
|
|
334
|
+
sha512_224: () => Cn,
|
|
335
|
+
sha512_256: () => qn
|
|
336
|
+
}), cn, Rt, Se, De, Le, Ae, fn, an, _t, Ot, te, Ue, qe, ft, at, Ce, ke, jt, Dn, Ln, Un, qn, Cn, _r = Dt((() => {
|
|
337
|
+
Br(), Rr(), Qt(), cn = /* @__PURE__ */ Uint32Array.from([
|
|
326
338
|
1116352408,
|
|
327
339
|
1899447441,
|
|
328
340
|
3049323471,
|
|
@@ -387,70 +399,70 @@ var It, le, ue, de, yt, Et, Lt, qt, Zn, kn, Tn, Vn, Xe, ze, We, Qe, Je, Pe, Mn =
|
|
|
387
399
|
2756734187,
|
|
388
400
|
3204031479,
|
|
389
401
|
3329325298
|
|
390
|
-
]),
|
|
402
|
+
]), Rt = /* @__PURE__ */ new Uint32Array(64), Se = class extends Fe {
|
|
391
403
|
constructor(t) {
|
|
392
404
|
super(64, t, 8, !1);
|
|
393
405
|
}
|
|
394
406
|
get() {
|
|
395
|
-
const { A: t, B:
|
|
407
|
+
const { A: t, B: n, C: e, D: r, E: o, F: i, G: a, H: f } = this;
|
|
396
408
|
return [
|
|
397
409
|
t,
|
|
410
|
+
n,
|
|
398
411
|
e,
|
|
399
412
|
r,
|
|
400
|
-
n,
|
|
401
413
|
o,
|
|
402
|
-
s,
|
|
403
414
|
i,
|
|
404
|
-
|
|
415
|
+
a,
|
|
416
|
+
f
|
|
405
417
|
];
|
|
406
418
|
}
|
|
407
|
-
set(t, e, r,
|
|
408
|
-
this.A = t | 0, this.B =
|
|
419
|
+
set(t, n, e, r, o, i, a, f) {
|
|
420
|
+
this.A = t | 0, this.B = n | 0, this.C = e | 0, this.D = r | 0, this.E = o | 0, this.F = i | 0, this.G = a | 0, this.H = f | 0;
|
|
409
421
|
}
|
|
410
|
-
process(t,
|
|
411
|
-
for (let
|
|
412
|
-
for (let
|
|
413
|
-
const
|
|
414
|
-
|
|
422
|
+
process(t, n) {
|
|
423
|
+
for (let s = 0; s < 16; s++, n += 4) Rt[s] = t.getUint32(n, !1);
|
|
424
|
+
for (let s = 16; s < 64; s++) {
|
|
425
|
+
const u = Rt[s - 15], d = Rt[s - 2], h = vt(u, 7) ^ vt(u, 18) ^ u >>> 3;
|
|
426
|
+
Rt[s] = (vt(d, 17) ^ vt(d, 19) ^ d >>> 10) + Rt[s - 7] + h + Rt[s - 16] | 0;
|
|
415
427
|
}
|
|
416
|
-
let { A:
|
|
417
|
-
for (let
|
|
418
|
-
const
|
|
419
|
-
|
|
428
|
+
let { A: e, B: r, C: o, D: i, E: a, F: f, G: l, H: g } = this;
|
|
429
|
+
for (let s = 0; s < 64; s++) {
|
|
430
|
+
const u = vt(a, 6) ^ vt(a, 11) ^ vt(a, 25), d = g + u + vr(a, f, l) + cn[s] + Rt[s] | 0, h = (vt(e, 2) ^ vt(e, 13) ^ vt(e, 22)) + xr(e, r, o) | 0;
|
|
431
|
+
g = l, l = f, f = a, a = i + d | 0, i = o, o = r, r = e, e = d + h | 0;
|
|
420
432
|
}
|
|
421
|
-
|
|
433
|
+
e = e + this.A | 0, r = r + this.B | 0, o = o + this.C | 0, i = i + this.D | 0, a = a + this.E | 0, f = f + this.F | 0, l = l + this.G | 0, g = g + this.H | 0, this.set(e, r, o, i, a, f, l, g);
|
|
422
434
|
}
|
|
423
435
|
roundClean() {
|
|
424
|
-
|
|
436
|
+
Kt(Rt);
|
|
425
437
|
}
|
|
426
438
|
destroy() {
|
|
427
|
-
this.set(0, 0, 0, 0, 0, 0, 0, 0),
|
|
428
|
-
}
|
|
429
|
-
},
|
|
430
|
-
A =
|
|
431
|
-
B =
|
|
432
|
-
C =
|
|
433
|
-
D =
|
|
434
|
-
E =
|
|
435
|
-
F =
|
|
436
|
-
G =
|
|
437
|
-
H =
|
|
439
|
+
this.destroyed = !0, this.set(0, 0, 0, 0, 0, 0, 0, 0), Kt(this.buffer);
|
|
440
|
+
}
|
|
441
|
+
}, De = class extends Se {
|
|
442
|
+
A = Ht[0] | 0;
|
|
443
|
+
B = Ht[1] | 0;
|
|
444
|
+
C = Ht[2] | 0;
|
|
445
|
+
D = Ht[3] | 0;
|
|
446
|
+
E = Ht[4] | 0;
|
|
447
|
+
F = Ht[5] | 0;
|
|
448
|
+
G = Ht[6] | 0;
|
|
449
|
+
H = Ht[7] | 0;
|
|
438
450
|
constructor() {
|
|
439
451
|
super(32);
|
|
440
452
|
}
|
|
441
|
-
},
|
|
442
|
-
A =
|
|
443
|
-
B =
|
|
444
|
-
C =
|
|
445
|
-
D =
|
|
446
|
-
E =
|
|
447
|
-
F =
|
|
448
|
-
G =
|
|
449
|
-
H =
|
|
453
|
+
}, Le = class extends Se {
|
|
454
|
+
A = Tt[0] | 0;
|
|
455
|
+
B = Tt[1] | 0;
|
|
456
|
+
C = Tt[2] | 0;
|
|
457
|
+
D = Tt[3] | 0;
|
|
458
|
+
E = Tt[4] | 0;
|
|
459
|
+
F = Tt[5] | 0;
|
|
460
|
+
G = Tt[6] | 0;
|
|
461
|
+
H = Tt[7] | 0;
|
|
450
462
|
constructor() {
|
|
451
463
|
super(28);
|
|
452
464
|
}
|
|
453
|
-
},
|
|
465
|
+
}, Ae = Ar([
|
|
454
466
|
"0x428a2f98d728ae22",
|
|
455
467
|
"0x7137449123ef65cd",
|
|
456
468
|
"0xb5c0fbcfec4d3b2f",
|
|
@@ -531,97 +543,97 @@ var It, le, ue, de, yt, Et, Lt, qt, Zn, kn, Tn, Vn, Xe, ze, We, Qe, Je, Pe, Mn =
|
|
|
531
543
|
"0x597f299cfc657e2a",
|
|
532
544
|
"0x5fcb6fab3ad6faec",
|
|
533
545
|
"0x6c44198c4a475817"
|
|
534
|
-
].map((t) => BigInt(t))),
|
|
546
|
+
].map((t) => BigInt(t))), fn = Ae[0], an = Ae[1], _t = /* @__PURE__ */ new Uint32Array(80), Ot = /* @__PURE__ */ new Uint32Array(80), te = class extends Fe {
|
|
535
547
|
constructor(t) {
|
|
536
548
|
super(128, t, 16, !1);
|
|
537
549
|
}
|
|
538
550
|
get() {
|
|
539
|
-
const { Ah: t, Al:
|
|
551
|
+
const { Ah: t, Al: n, Bh: e, Bl: r, Ch: o, Cl: i, Dh: a, Dl: f, Eh: l, El: g, Fh: s, Fl: u, Gh: d, Gl: h, Hh: w, Hl: b } = this;
|
|
540
552
|
return [
|
|
541
553
|
t,
|
|
554
|
+
n,
|
|
542
555
|
e,
|
|
543
556
|
r,
|
|
544
|
-
n,
|
|
545
557
|
o,
|
|
546
|
-
s,
|
|
547
558
|
i,
|
|
548
|
-
|
|
559
|
+
a,
|
|
549
560
|
f,
|
|
550
561
|
l,
|
|
551
|
-
a,
|
|
552
562
|
g,
|
|
553
|
-
|
|
563
|
+
s,
|
|
564
|
+
u,
|
|
565
|
+
d,
|
|
566
|
+
h,
|
|
554
567
|
w,
|
|
555
|
-
|
|
556
|
-
x
|
|
568
|
+
b
|
|
557
569
|
];
|
|
558
570
|
}
|
|
559
|
-
set(t, e, r,
|
|
560
|
-
this.Ah = t | 0, this.Al =
|
|
571
|
+
set(t, n, e, r, o, i, a, f, l, g, s, u, d, h, w, b) {
|
|
572
|
+
this.Ah = t | 0, this.Al = n | 0, this.Bh = e | 0, this.Bl = r | 0, this.Ch = o | 0, this.Cl = i | 0, this.Dh = a | 0, this.Dl = f | 0, this.Eh = l | 0, this.El = g | 0, this.Fh = s | 0, this.Fl = u | 0, this.Gh = d | 0, this.Gl = h | 0, this.Hh = w | 0, this.Hl = b | 0;
|
|
561
573
|
}
|
|
562
|
-
process(t,
|
|
563
|
-
for (let
|
|
564
|
-
|
|
565
|
-
for (let
|
|
566
|
-
const
|
|
567
|
-
|
|
574
|
+
process(t, n) {
|
|
575
|
+
for (let B = 0; B < 16; B++, n += 4)
|
|
576
|
+
_t[B] = t.getUint32(n), Ot[B] = t.getUint32(n += 4);
|
|
577
|
+
for (let B = 16; B < 80; B++) {
|
|
578
|
+
const C = _t[B - 15] | 0, O = Ot[B - 15] | 0, F = Ut(C, O, 1) ^ Ut(C, O, 8) ^ Ne(C, O, 7), z = qt(C, O, 1) ^ qt(C, O, 8) ^ je(C, O, 7), W = _t[B - 2] | 0, N = Ot[B - 2] | 0, V = Ut(W, N, 19) ^ ne(W, N, 61) ^ Ne(W, N, 6), K = qt(W, N, 19) ^ re(W, N, 61) ^ je(W, N, 6), M = Fn(z, K, Ot[B - 7], Ot[B - 16]);
|
|
579
|
+
_t[B] = In(M, F, V, _t[B - 7], _t[B - 16]) | 0, Ot[B] = M | 0;
|
|
568
580
|
}
|
|
569
|
-
let { Ah:
|
|
570
|
-
for (let
|
|
571
|
-
const
|
|
572
|
-
|
|
573
|
-
const
|
|
574
|
-
|
|
581
|
+
let { Ah: e, Al: r, Bh: o, Bl: i, Ch: a, Cl: f, Dh: l, Dl: g, Eh: s, El: u, Fh: d, Fl: h, Gh: w, Gl: b, Hh: E, Hl: T } = this;
|
|
582
|
+
for (let B = 0; B < 80; B++) {
|
|
583
|
+
const C = Ut(s, u, 14) ^ Ut(s, u, 18) ^ ne(s, u, 41), O = qt(s, u, 14) ^ qt(s, u, 18) ^ re(s, u, 41), F = s & d ^ ~s & w, z = u & h ^ ~u & b, W = Nn(T, O, z, an[B], Ot[B]), N = jn(W, E, C, F, fn[B], _t[B]), V = W | 0, K = Ut(e, r, 28) ^ ne(e, r, 34) ^ ne(e, r, 39), M = qt(e, r, 28) ^ re(e, r, 34) ^ re(e, r, 39), v = e & o ^ e & a ^ o & a, H = r & i ^ r & f ^ i & f;
|
|
584
|
+
E = w | 0, T = b | 0, w = d | 0, b = h | 0, d = s | 0, h = u | 0, { h: s, l: u } = At(l | 0, g | 0, N | 0, V | 0), l = a | 0, g = f | 0, a = o | 0, f = i | 0, o = e | 0, i = r | 0;
|
|
585
|
+
const U = Hn(V, M, H);
|
|
586
|
+
e = Tn(U, N, K, v), r = U | 0;
|
|
575
587
|
}
|
|
576
|
-
({ h:
|
|
588
|
+
({ h: e, l: r } = At(this.Ah | 0, this.Al | 0, e | 0, r | 0)), { h: o, l: i } = At(this.Bh | 0, this.Bl | 0, o | 0, i | 0), { h: a, l: f } = At(this.Ch | 0, this.Cl | 0, a | 0, f | 0), { h: l, l: g } = At(this.Dh | 0, this.Dl | 0, l | 0, g | 0), { h: s, l: u } = At(this.Eh | 0, this.El | 0, s | 0, u | 0), { h: d, l: h } = At(this.Fh | 0, this.Fl | 0, d | 0, h | 0), { h: w, l: b } = At(this.Gh | 0, this.Gl | 0, w | 0, b | 0), { h: E, l: T } = At(this.Hh | 0, this.Hl | 0, E | 0, T | 0), this.set(e, r, o, i, a, f, l, g, s, u, d, h, w, b, E, T);
|
|
577
589
|
}
|
|
578
590
|
roundClean() {
|
|
579
|
-
|
|
591
|
+
Kt(_t, Ot);
|
|
580
592
|
}
|
|
581
593
|
destroy() {
|
|
582
|
-
|
|
583
|
-
}
|
|
584
|
-
},
|
|
585
|
-
Ah =
|
|
586
|
-
Al =
|
|
587
|
-
Bh =
|
|
588
|
-
Bl =
|
|
589
|
-
Ch =
|
|
590
|
-
Cl =
|
|
591
|
-
Dh =
|
|
592
|
-
Dl =
|
|
593
|
-
Eh =
|
|
594
|
-
El =
|
|
595
|
-
Fh =
|
|
596
|
-
Fl =
|
|
597
|
-
Gh =
|
|
598
|
-
Gl =
|
|
599
|
-
Hh =
|
|
600
|
-
Hl =
|
|
594
|
+
this.destroyed = !0, Kt(this.buffer), this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
595
|
+
}
|
|
596
|
+
}, Ue = class extends te {
|
|
597
|
+
Ah = ut[0] | 0;
|
|
598
|
+
Al = ut[1] | 0;
|
|
599
|
+
Bh = ut[2] | 0;
|
|
600
|
+
Bl = ut[3] | 0;
|
|
601
|
+
Ch = ut[4] | 0;
|
|
602
|
+
Cl = ut[5] | 0;
|
|
603
|
+
Dh = ut[6] | 0;
|
|
604
|
+
Dl = ut[7] | 0;
|
|
605
|
+
Eh = ut[8] | 0;
|
|
606
|
+
El = ut[9] | 0;
|
|
607
|
+
Fh = ut[10] | 0;
|
|
608
|
+
Fl = ut[11] | 0;
|
|
609
|
+
Gh = ut[12] | 0;
|
|
610
|
+
Gl = ut[13] | 0;
|
|
611
|
+
Hh = ut[14] | 0;
|
|
612
|
+
Hl = ut[15] | 0;
|
|
601
613
|
constructor() {
|
|
602
614
|
super(64);
|
|
603
615
|
}
|
|
604
|
-
},
|
|
605
|
-
Ah =
|
|
606
|
-
Al =
|
|
607
|
-
Bh =
|
|
608
|
-
Bl =
|
|
609
|
-
Ch =
|
|
610
|
-
Cl =
|
|
611
|
-
Dh =
|
|
612
|
-
Dl =
|
|
613
|
-
Eh =
|
|
614
|
-
El =
|
|
615
|
-
Fh =
|
|
616
|
-
Fl =
|
|
617
|
-
Gh =
|
|
618
|
-
Gl =
|
|
619
|
-
Hh =
|
|
620
|
-
Hl =
|
|
616
|
+
}, qe = class extends te {
|
|
617
|
+
Ah = lt[0] | 0;
|
|
618
|
+
Al = lt[1] | 0;
|
|
619
|
+
Bh = lt[2] | 0;
|
|
620
|
+
Bl = lt[3] | 0;
|
|
621
|
+
Ch = lt[4] | 0;
|
|
622
|
+
Cl = lt[5] | 0;
|
|
623
|
+
Dh = lt[6] | 0;
|
|
624
|
+
Dl = lt[7] | 0;
|
|
625
|
+
Eh = lt[8] | 0;
|
|
626
|
+
El = lt[9] | 0;
|
|
627
|
+
Fh = lt[10] | 0;
|
|
628
|
+
Fl = lt[11] | 0;
|
|
629
|
+
Gh = lt[12] | 0;
|
|
630
|
+
Gl = lt[13] | 0;
|
|
631
|
+
Hh = lt[14] | 0;
|
|
632
|
+
Hl = lt[15] | 0;
|
|
621
633
|
constructor() {
|
|
622
634
|
super(48);
|
|
623
635
|
}
|
|
624
|
-
},
|
|
636
|
+
}, ft = /* @__PURE__ */ Uint32Array.from([
|
|
625
637
|
2352822216,
|
|
626
638
|
424955298,
|
|
627
639
|
1944164710,
|
|
@@ -638,7 +650,7 @@ var It, le, ue, de, yt, Et, Lt, qt, Zn, kn, Tn, Vn, Xe, ze, We, Qe, Je, Pe, Mn =
|
|
|
638
650
|
1780299464,
|
|
639
651
|
286451373,
|
|
640
652
|
2446758561
|
|
641
|
-
]),
|
|
653
|
+
]), at = /* @__PURE__ */ Uint32Array.from([
|
|
642
654
|
573645204,
|
|
643
655
|
4230739756,
|
|
644
656
|
2673172387,
|
|
@@ -655,285 +667,376 @@ var It, le, ue, de, yt, Et, Lt, qt, Zn, kn, Tn, Vn, Xe, ze, We, Qe, Je, Pe, Mn =
|
|
|
655
667
|
746961066,
|
|
656
668
|
246885852,
|
|
657
669
|
2177182882
|
|
658
|
-
]),
|
|
659
|
-
Ah =
|
|
660
|
-
Al =
|
|
661
|
-
Bh =
|
|
662
|
-
Bl =
|
|
663
|
-
Ch =
|
|
664
|
-
Cl =
|
|
665
|
-
Dh =
|
|
666
|
-
Dl =
|
|
667
|
-
Eh =
|
|
668
|
-
El =
|
|
669
|
-
Fh =
|
|
670
|
-
Fl =
|
|
671
|
-
Gh =
|
|
672
|
-
Gl =
|
|
673
|
-
Hh =
|
|
674
|
-
Hl =
|
|
670
|
+
]), Ce = class extends te {
|
|
671
|
+
Ah = ft[0] | 0;
|
|
672
|
+
Al = ft[1] | 0;
|
|
673
|
+
Bh = ft[2] | 0;
|
|
674
|
+
Bl = ft[3] | 0;
|
|
675
|
+
Ch = ft[4] | 0;
|
|
676
|
+
Cl = ft[5] | 0;
|
|
677
|
+
Dh = ft[6] | 0;
|
|
678
|
+
Dl = ft[7] | 0;
|
|
679
|
+
Eh = ft[8] | 0;
|
|
680
|
+
El = ft[9] | 0;
|
|
681
|
+
Fh = ft[10] | 0;
|
|
682
|
+
Fl = ft[11] | 0;
|
|
683
|
+
Gh = ft[12] | 0;
|
|
684
|
+
Gl = ft[13] | 0;
|
|
685
|
+
Hh = ft[14] | 0;
|
|
686
|
+
Hl = ft[15] | 0;
|
|
675
687
|
constructor() {
|
|
676
688
|
super(28);
|
|
677
689
|
}
|
|
678
|
-
},
|
|
679
|
-
Ah =
|
|
680
|
-
Al =
|
|
681
|
-
Bh =
|
|
682
|
-
Bl =
|
|
683
|
-
Ch =
|
|
684
|
-
Cl =
|
|
685
|
-
Dh =
|
|
686
|
-
Dl =
|
|
687
|
-
Eh =
|
|
688
|
-
El =
|
|
689
|
-
Fh =
|
|
690
|
-
Fl =
|
|
691
|
-
Gh =
|
|
692
|
-
Gl =
|
|
693
|
-
Hh =
|
|
694
|
-
Hl =
|
|
690
|
+
}, ke = class extends te {
|
|
691
|
+
Ah = at[0] | 0;
|
|
692
|
+
Al = at[1] | 0;
|
|
693
|
+
Bh = at[2] | 0;
|
|
694
|
+
Bl = at[3] | 0;
|
|
695
|
+
Ch = at[4] | 0;
|
|
696
|
+
Cl = at[5] | 0;
|
|
697
|
+
Dh = at[6] | 0;
|
|
698
|
+
Dl = at[7] | 0;
|
|
699
|
+
Eh = at[8] | 0;
|
|
700
|
+
El = at[9] | 0;
|
|
701
|
+
Fh = at[10] | 0;
|
|
702
|
+
Fl = at[11] | 0;
|
|
703
|
+
Gh = at[12] | 0;
|
|
704
|
+
Gl = at[13] | 0;
|
|
705
|
+
Hh = at[14] | 0;
|
|
706
|
+
Hl = at[15] | 0;
|
|
695
707
|
constructor() {
|
|
696
708
|
super(32);
|
|
697
709
|
}
|
|
698
|
-
},
|
|
710
|
+
}, jt = /* @__PURE__ */ Yt(() => new De(), /* @__PURE__ */ Lt(1)), Dn = /* @__PURE__ */ Yt(() => new Le(), /* @__PURE__ */ Lt(4)), Ln = /* @__PURE__ */ Yt(() => new Ue(), /* @__PURE__ */ Lt(3)), Un = /* @__PURE__ */ Yt(() => new qe(), /* @__PURE__ */ Lt(2)), qn = /* @__PURE__ */ Yt(() => new ke(), /* @__PURE__ */ Lt(6)), Cn = /* @__PURE__ */ Yt(() => new Ce(), /* @__PURE__ */ Lt(5));
|
|
699
711
|
}));
|
|
700
|
-
function
|
|
701
|
-
|
|
702
|
-
const r = e && `"${e}" `;
|
|
703
|
-
throw new Error(r + "expected boolean, got type=" + typeof t);
|
|
704
|
-
}
|
|
705
|
-
return t;
|
|
706
|
-
}
|
|
707
|
-
function on(t) {
|
|
708
|
-
if (typeof t == "bigint") {
|
|
709
|
-
if (!Ut(t)) throw new Error("positive bigint expected, got " + t);
|
|
710
|
-
} else xt(t);
|
|
711
|
-
return t;
|
|
712
|
+
function Or(t) {
|
|
713
|
+
return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
|
|
712
714
|
}
|
|
713
|
-
function
|
|
714
|
-
if (!Number.isSafeInteger(t)) {
|
|
715
|
-
const
|
|
716
|
-
throw new Error(
|
|
715
|
+
function Io(t, n = "") {
|
|
716
|
+
if (!Number.isSafeInteger(t) || t < 0) {
|
|
717
|
+
const e = n && `"${n}" `;
|
|
718
|
+
throw new Error(`${e}expected integer >= 0, got ${t}`);
|
|
717
719
|
}
|
|
718
720
|
}
|
|
719
|
-
function
|
|
720
|
-
const
|
|
721
|
-
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
return t
|
|
726
|
-
}
|
|
727
|
-
function Dt(t) {
|
|
728
|
-
return sn(Xt(t));
|
|
729
|
-
}
|
|
730
|
-
function cn(t) {
|
|
731
|
-
return sn(Xt(jn(C(t)).reverse()));
|
|
721
|
+
function kn(t, n, e = "") {
|
|
722
|
+
const r = Or(t), o = t?.length, i = n !== void 0;
|
|
723
|
+
if (!r || i && o !== n) {
|
|
724
|
+
const a = e && `"${e}" `, f = i ? ` of length ${n}` : "", l = r ? `length=${o}` : `type=${typeof t}`;
|
|
725
|
+
throw new Error(a + "expected Uint8Array" + f + ", got " + l);
|
|
726
|
+
}
|
|
727
|
+
return t;
|
|
732
728
|
}
|
|
733
|
-
function
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
if (r.length !== e) throw new Error("number too large");
|
|
737
|
-
return r;
|
|
729
|
+
function No(t, n = !0) {
|
|
730
|
+
if (t.destroyed) throw new Error("Hash instance has been destroyed");
|
|
731
|
+
if (n && t.finished) throw new Error("Hash#digest() has already been called");
|
|
738
732
|
}
|
|
739
|
-
function
|
|
740
|
-
|
|
733
|
+
function jo(t, n) {
|
|
734
|
+
kn(t, void 0, "digestInto() output");
|
|
735
|
+
const e = n.outputLen;
|
|
736
|
+
if (t.length < e) throw new Error('"digestInto() output" expected to be of length >=' + e);
|
|
741
737
|
}
|
|
742
|
-
function
|
|
743
|
-
return
|
|
738
|
+
function Do(t) {
|
|
739
|
+
return new Uint32Array(t.buffer, t.byteOffset, Math.floor(t.byteLength / 4));
|
|
744
740
|
}
|
|
745
|
-
function
|
|
746
|
-
|
|
747
|
-
const n = e.charCodeAt(0);
|
|
748
|
-
if (e.length !== 1 || n > 127) throw new Error(`string contains non-ASCII character "${t[r]}" with code ${n} at position ${r}`);
|
|
749
|
-
return n;
|
|
750
|
-
});
|
|
741
|
+
function Lo(...t) {
|
|
742
|
+
for (let n = 0; n < t.length; n++) t[n].fill(0);
|
|
751
743
|
}
|
|
752
|
-
function
|
|
753
|
-
return
|
|
744
|
+
function Hr(t) {
|
|
745
|
+
return t << 24 & 4278190080 | t << 8 & 16711680 | t >>> 8 & 65280 | t >>> 24 & 255;
|
|
754
746
|
}
|
|
755
|
-
function
|
|
756
|
-
|
|
747
|
+
function Tr(t) {
|
|
748
|
+
for (let n = 0; n < t.length; n++) t[n] = Hr(t[n]);
|
|
749
|
+
return t;
|
|
757
750
|
}
|
|
758
|
-
function
|
|
759
|
-
let
|
|
760
|
-
for (
|
|
751
|
+
function Uo(...t) {
|
|
752
|
+
let n = 0;
|
|
753
|
+
for (let r = 0; r < t.length; r++) {
|
|
754
|
+
const o = t[r];
|
|
755
|
+
kn(o), n += o.length;
|
|
756
|
+
}
|
|
757
|
+
const e = new Uint8Array(n);
|
|
758
|
+
for (let r = 0, o = 0; r < t.length; r++) {
|
|
759
|
+
const i = t[r];
|
|
760
|
+
e.set(i, o), o += i.length;
|
|
761
|
+
}
|
|
761
762
|
return e;
|
|
762
763
|
}
|
|
763
|
-
function
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
let f = n(t), l = n(t), a = 0;
|
|
767
|
-
const g = () => {
|
|
768
|
-
f.fill(1), l.fill(0), a = 0;
|
|
769
|
-
}, b = (...v) => r(l, P(f, ...v)), w = (v = o) => {
|
|
770
|
-
l = b(s, v), f = b(), v.length !== 0 && (l = b(i, v), f = b());
|
|
771
|
-
}, m = () => {
|
|
772
|
-
if (a++ >= c) throw new Error("drbg: tried max amount of iterations");
|
|
773
|
-
let v = 0;
|
|
774
|
-
const B = [];
|
|
775
|
-
for (; v < e; ) {
|
|
776
|
-
f = b();
|
|
777
|
-
const E = f.slice();
|
|
778
|
-
B.push(E), v += f.length;
|
|
779
|
-
}
|
|
780
|
-
return P(...B);
|
|
781
|
-
};
|
|
782
|
-
return (v, B) => {
|
|
783
|
-
g(), w(v);
|
|
784
|
-
let E;
|
|
785
|
-
for (; !(E = B(m())); ) w();
|
|
786
|
-
return g(), E;
|
|
787
|
-
};
|
|
764
|
+
function qo(t, n = {}) {
|
|
765
|
+
const e = (o, i) => t(i).update(o).digest(), r = t(void 0);
|
|
766
|
+
return e.outputLen = r.outputLen, e.blockLen = r.blockLen, e.create = (o) => t(o), Object.assign(e, n), Object.freeze(e);
|
|
788
767
|
}
|
|
789
|
-
function
|
|
790
|
-
|
|
791
|
-
function
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
};
|
|
768
|
+
function Co(t = 32) {
|
|
769
|
+
const n = typeof globalThis == "object" ? globalThis.crypto : null;
|
|
770
|
+
if (typeof n?.getRandomValues != "function") throw new Error("crypto.getRandomValues must be defined");
|
|
771
|
+
return n.getRandomValues(new Uint8Array(t));
|
|
772
|
+
}
|
|
773
|
+
var ln, Fr, Ir, Nr, jr = Dt((() => {
|
|
774
|
+
ln = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68, Fr = ln ? (t) => t : Tr, Ir = typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", Nr = (t) => ({ oid: Uint8Array.from([
|
|
775
|
+
6,
|
|
776
|
+
9,
|
|
777
|
+
96,
|
|
778
|
+
134,
|
|
779
|
+
72,
|
|
780
|
+
1,
|
|
781
|
+
101,
|
|
782
|
+
3,
|
|
783
|
+
4,
|
|
784
|
+
2,
|
|
785
|
+
t
|
|
786
|
+
]) });
|
|
787
|
+
}));
|
|
788
|
+
function ko(t, n = "") {
|
|
789
|
+
if (typeof t != "boolean") {
|
|
790
|
+
const e = n && `"${n}" `;
|
|
791
|
+
throw new Error(e + "expected boolean, got type=" + typeof t);
|
|
792
|
+
}
|
|
793
|
+
return t;
|
|
808
794
|
}
|
|
809
|
-
var
|
|
810
|
-
|
|
795
|
+
var $o = Dt((() => {
|
|
796
|
+
jr();
|
|
811
797
|
}));
|
|
812
|
-
function
|
|
798
|
+
function Qe(t) {
|
|
813
799
|
if (!Number.isSafeInteger(t) || t < 0 || t > 4294967295) throw new Error("wrong u32 integer:" + t);
|
|
814
800
|
return t;
|
|
815
801
|
}
|
|
816
|
-
function
|
|
817
|
-
return
|
|
802
|
+
function $n(t) {
|
|
803
|
+
return Qe(t), (t & t - 1) === 0 && t !== 0;
|
|
818
804
|
}
|
|
819
|
-
function
|
|
820
|
-
|
|
821
|
-
let
|
|
822
|
-
for (let
|
|
823
|
-
return
|
|
805
|
+
function Dr(t, n) {
|
|
806
|
+
Qe(t);
|
|
807
|
+
let e = 0;
|
|
808
|
+
for (let r = 0; r < n; r++, t >>>= 1) e = e << 1 | t & 1;
|
|
809
|
+
return e;
|
|
824
810
|
}
|
|
825
|
-
function
|
|
826
|
-
return
|
|
811
|
+
function Zn(t) {
|
|
812
|
+
return Qe(t), 31 - Math.clz32(t);
|
|
827
813
|
}
|
|
828
|
-
function
|
|
829
|
-
const
|
|
830
|
-
if (
|
|
831
|
-
const
|
|
832
|
-
for (let
|
|
833
|
-
const o =
|
|
834
|
-
if (
|
|
835
|
-
const
|
|
836
|
-
t[
|
|
814
|
+
function un(t) {
|
|
815
|
+
const n = t.length;
|
|
816
|
+
if (n < 2 || !$n(n)) throw new Error("n must be a power of 2 and greater than 1. Got " + n);
|
|
817
|
+
const e = Zn(n);
|
|
818
|
+
for (let r = 0; r < n; r++) {
|
|
819
|
+
const o = Dr(r, e);
|
|
820
|
+
if (r < o) {
|
|
821
|
+
const i = t[r];
|
|
822
|
+
t[r] = t[o], t[o] = i;
|
|
837
823
|
}
|
|
838
824
|
}
|
|
839
825
|
return t;
|
|
840
826
|
}
|
|
841
|
-
var
|
|
842
|
-
|
|
843
|
-
const { N:
|
|
844
|
-
if (
|
|
845
|
-
const
|
|
846
|
-
return (
|
|
847
|
-
if (
|
|
848
|
-
o &&
|
|
849
|
-
for (let
|
|
850
|
-
const
|
|
851
|
-
for (let
|
|
852
|
-
const
|
|
853
|
-
if (
|
|
854
|
-
const
|
|
855
|
-
|
|
856
|
-
} else
|
|
827
|
+
var Lr, Zo = Dt((() => {
|
|
828
|
+
Lr = (t, n) => {
|
|
829
|
+
const { N: e, roots: r, dit: o, invertButterflies: i = !1, skipStages: a = 0, brp: f = !0 } = n, l = Zn(e);
|
|
830
|
+
if (!$n(e)) throw new Error("FFT: Polynomial size should be power of two");
|
|
831
|
+
const g = o !== i;
|
|
832
|
+
return (s) => {
|
|
833
|
+
if (s.length !== e) throw new Error("FFT: wrong Polynomial length");
|
|
834
|
+
o && f && un(s);
|
|
835
|
+
for (let u = 0, d = 1; u < l - a; u++) {
|
|
836
|
+
const h = o ? u + 1 + a : l - u, w = 1 << h, b = w >> 1, E = e >> h;
|
|
837
|
+
for (let T = 0; T < e; T += w) for (let B = 0, C = d++; B < b; B++) {
|
|
838
|
+
const O = i ? o ? e - C : C : B * E, F = T + B, z = T + B + b, W = r[O], N = s[z], V = s[F];
|
|
839
|
+
if (g) {
|
|
840
|
+
const K = t.mul(N, W);
|
|
841
|
+
s[F] = t.add(V, K), s[z] = t.sub(V, K);
|
|
842
|
+
} else i ? (s[F] = t.add(N, V), s[z] = t.mul(t.sub(N, V), W)) : (s[F] = t.add(V, N), s[z] = t.mul(t.sub(V, N), W));
|
|
857
843
|
}
|
|
858
844
|
}
|
|
859
|
-
return !o &&
|
|
845
|
+
return !o && f && un(s), s;
|
|
860
846
|
};
|
|
861
847
|
};
|
|
862
848
|
}));
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
849
|
+
_r();
|
|
850
|
+
Qt();
|
|
851
|
+
var st = (t, n, e) => zt(t, n, e), Vn = Pt, Ct = Ke, Q = (...t) => br(...t), he = (t) => _n(t), oe = Sn, wt = (t) => yr(t), me = /* @__PURE__ */ BigInt(0), $e = /* @__PURE__ */ BigInt(1);
|
|
852
|
+
function ie(t, n = "") {
|
|
853
|
+
if (typeof t != "boolean") {
|
|
854
|
+
const e = n && `"${n}" `;
|
|
855
|
+
throw new TypeError(e + "expected boolean, got type=" + typeof t);
|
|
856
|
+
}
|
|
857
|
+
return t;
|
|
858
|
+
}
|
|
859
|
+
function Je(t) {
|
|
860
|
+
if (typeof t == "bigint") {
|
|
861
|
+
if (!ue(t)) throw new RangeError("positive bigint expected, got " + t);
|
|
862
|
+
} else Vn(t);
|
|
863
|
+
return t;
|
|
864
|
+
}
|
|
865
|
+
function Ft(t, n = "") {
|
|
866
|
+
if (typeof t != "number") {
|
|
867
|
+
const e = n && `"${n}" `;
|
|
868
|
+
throw new TypeError(e + "expected number, got type=" + typeof t);
|
|
869
|
+
}
|
|
870
|
+
if (!Number.isSafeInteger(t)) {
|
|
871
|
+
const e = n && `"${n}" `;
|
|
872
|
+
throw new RangeError(e + "expected safe integer, got " + t);
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
function ce(t) {
|
|
876
|
+
const n = Je(t).toString(16);
|
|
877
|
+
return n.length & 1 ? "0" + n : n;
|
|
878
|
+
}
|
|
879
|
+
function Pn(t) {
|
|
880
|
+
if (typeof t != "string") throw new TypeError("hex string expected, got " + typeof t);
|
|
881
|
+
return t === "" ? me : BigInt("0x" + t);
|
|
882
|
+
}
|
|
883
|
+
function St(t) {
|
|
884
|
+
return Pn(Ke(t));
|
|
885
|
+
}
|
|
886
|
+
function ge(t) {
|
|
887
|
+
return Pn(Ke(Ze(zt(t)).reverse()));
|
|
888
|
+
}
|
|
889
|
+
function tn(t, n) {
|
|
890
|
+
if (Pt(n), n === 0) throw new RangeError("zero length");
|
|
891
|
+
t = Je(t);
|
|
892
|
+
const e = t.toString(16);
|
|
893
|
+
if (e.length > n * 2) throw new RangeError("number too large");
|
|
894
|
+
return _n(e.padStart(n * 2, "0"));
|
|
895
|
+
}
|
|
896
|
+
function zn(t, n) {
|
|
897
|
+
return tn(t, n).reverse();
|
|
898
|
+
}
|
|
899
|
+
function Ze(t) {
|
|
900
|
+
return Uint8Array.from(st(t));
|
|
901
|
+
}
|
|
902
|
+
function be(t) {
|
|
903
|
+
if (typeof t != "string") throw new TypeError("ascii string expected, got " + typeof t);
|
|
904
|
+
return Uint8Array.from(t, (n, e) => {
|
|
905
|
+
const r = n.charCodeAt(0);
|
|
906
|
+
if (n.length !== 1 || r > 127) throw new RangeError(`string contains non-ASCII character "${t[e]}" with code ${r} at position ${e}`);
|
|
907
|
+
return r;
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
var ue = (t) => typeof t == "bigint" && me <= t;
|
|
911
|
+
function Ur(t, n, e) {
|
|
912
|
+
return ue(t) && ue(n) && ue(e) && n <= t && t < e;
|
|
913
|
+
}
|
|
914
|
+
function Mn(t, n, e, r) {
|
|
915
|
+
if (!Ur(n, e, r)) throw new RangeError("expected valid " + t + ": " + e + " <= n < " + r + ", got " + n);
|
|
916
|
+
}
|
|
917
|
+
function ye(t) {
|
|
918
|
+
if (t < me) throw new Error("expected non-negative bigint, got " + t);
|
|
919
|
+
let n;
|
|
920
|
+
for (n = 0; t > me; t >>= $e, n += 1) ;
|
|
873
921
|
return n;
|
|
874
922
|
}
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
if (e
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
}
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
const r = (t.ORDER - hn) / bn, n = t.mul(e, vt), o = t.pow(n, r), s = t.mul(e, o), i = t.mul(t.mul(s, vt), o), c = t.mul(s, t.sub(i, t.ONE));
|
|
895
|
-
return _e(t, c, e), c;
|
|
896
|
-
}
|
|
897
|
-
function Fn(t) {
|
|
898
|
-
const e = te(t), r = mn(t), n = r(e, e.neg(e.ONE)), o = r(e, n), s = r(e, e.neg(n)), i = (t + Qn) / wn;
|
|
899
|
-
return (c, f) => {
|
|
900
|
-
let l = c.pow(f, i), a = c.mul(l, n);
|
|
901
|
-
const g = c.mul(l, o), b = c.mul(l, s), w = c.eql(c.sqr(a), f), m = c.eql(c.sqr(g), f);
|
|
902
|
-
l = c.cmov(l, a, w), a = c.cmov(b, g, m);
|
|
903
|
-
const x = c.eql(c.sqr(a), f), v = c.cmov(l, a, x);
|
|
904
|
-
return _e(c, v, f), v;
|
|
923
|
+
var pe = (t) => ($e << BigInt(t)) - $e;
|
|
924
|
+
function qr(t, n, e) {
|
|
925
|
+
if (Pt(t, "hashLen"), Pt(n, "qByteLen"), typeof e != "function") throw new TypeError("hmacFn must be a function");
|
|
926
|
+
const r = (E) => new Uint8Array(E), o = Uint8Array.of(), i = Uint8Array.of(0), a = Uint8Array.of(1), f = 1e3;
|
|
927
|
+
let l = r(t), g = r(t), s = 0;
|
|
928
|
+
const u = () => {
|
|
929
|
+
l.fill(1), g.fill(0), s = 0;
|
|
930
|
+
}, d = (...E) => e(g, Q(l, ...E)), h = (E = o) => {
|
|
931
|
+
g = d(i, E), l = d(), E.length !== 0 && (g = d(a, E), l = d());
|
|
932
|
+
}, w = () => {
|
|
933
|
+
if (s++ >= f) throw new Error("drbg: tried max amount of iterations");
|
|
934
|
+
let E = 0;
|
|
935
|
+
const T = [];
|
|
936
|
+
for (; E < n; ) {
|
|
937
|
+
l = d();
|
|
938
|
+
const B = l.slice();
|
|
939
|
+
T.push(B), E += l.length;
|
|
940
|
+
}
|
|
941
|
+
return Q(...T);
|
|
905
942
|
};
|
|
943
|
+
return (E, T) => {
|
|
944
|
+
u(), h(E);
|
|
945
|
+
let B;
|
|
946
|
+
for (; (B = T(w())) === void 0; ) h();
|
|
947
|
+
return u(), B;
|
|
948
|
+
};
|
|
949
|
+
}
|
|
950
|
+
function Mt(t, n = {}, e = {}) {
|
|
951
|
+
if (Object.prototype.toString.call(t) !== "[object Object]") throw new TypeError("expected valid options object");
|
|
952
|
+
function r(i, a, f) {
|
|
953
|
+
if (!f && a !== "function" && !Object.hasOwn(t, i)) throw new TypeError(`param "${i}" is invalid: expected own property`);
|
|
954
|
+
const l = t[i];
|
|
955
|
+
if (f && l === void 0) return;
|
|
956
|
+
const g = typeof l;
|
|
957
|
+
if (g !== a || l === null) throw new TypeError(`param "${i}" is invalid: expected ${a}, got ${g}`);
|
|
958
|
+
}
|
|
959
|
+
const o = (i, a) => Object.entries(i).forEach(([f, l]) => r(f, l, a));
|
|
960
|
+
o(n, !1), o(e, !0);
|
|
961
|
+
}
|
|
962
|
+
var dt = /* @__PURE__ */ BigInt(0), ot = /* @__PURE__ */ BigInt(1), $t = /* @__PURE__ */ BigInt(2), Gn = /* @__PURE__ */ BigInt(3), Yn = /* @__PURE__ */ BigInt(4), Kn = /* @__PURE__ */ BigInt(5), Cr = /* @__PURE__ */ BigInt(7), Xn = /* @__PURE__ */ BigInt(8), kr = /* @__PURE__ */ BigInt(9), Wn = /* @__PURE__ */ BigInt(16);
|
|
963
|
+
function bt(t, n) {
|
|
964
|
+
if (n <= dt) throw new Error("mod: expected positive modulus, got " + n);
|
|
965
|
+
const e = t % n;
|
|
966
|
+
return e >= dt ? e : n + e;
|
|
967
|
+
}
|
|
968
|
+
function gt(t, n, e) {
|
|
969
|
+
if (n < dt) throw new Error("pow2: expected non-negative exponent, got " + n);
|
|
970
|
+
let r = t;
|
|
971
|
+
for (; n-- > dt; )
|
|
972
|
+
r *= r, r %= e;
|
|
973
|
+
return r;
|
|
974
|
+
}
|
|
975
|
+
function dn(t, n) {
|
|
976
|
+
if (t === dt) throw new Error("invert: expected non-zero number");
|
|
977
|
+
if (n <= dt) throw new Error("invert: expected positive modulus, got " + n);
|
|
978
|
+
let e = bt(t, n), r = n, o = dt, i = ot, a = ot, f = dt;
|
|
979
|
+
for (; e !== dt; ) {
|
|
980
|
+
const l = r / e, g = r - e * l, s = o - a * l, u = i - f * l;
|
|
981
|
+
r = e, e = g, o = a, i = f, a = s, f = u;
|
|
982
|
+
}
|
|
983
|
+
if (r !== ot) throw new Error("invert: does not exist");
|
|
984
|
+
return bt(o, n);
|
|
985
|
+
}
|
|
986
|
+
function en(t, n, e) {
|
|
987
|
+
const r = t;
|
|
988
|
+
if (!r.eql(r.sqr(n), e)) throw new Error("Cannot find square root");
|
|
989
|
+
}
|
|
990
|
+
function Qn(t, n) {
|
|
991
|
+
const e = t, r = (e.ORDER + ot) / Yn, o = e.pow(n, r);
|
|
992
|
+
return en(e, o, n), o;
|
|
993
|
+
}
|
|
994
|
+
function $r(t, n) {
|
|
995
|
+
const e = t, r = (e.ORDER - Kn) / Xn, o = e.mul(n, $t), i = e.pow(o, r), a = e.mul(n, i), f = e.mul(e.mul(a, $t), i), l = e.mul(a, e.sub(f, e.ONE));
|
|
996
|
+
return en(e, l, n), l;
|
|
997
|
+
}
|
|
998
|
+
function Zr(t) {
|
|
999
|
+
const n = ve(t), e = Jn(t), r = e(n, n.neg(n.ONE)), o = e(n, r), i = e(n, n.neg(r)), a = (t + Cr) / Wn;
|
|
1000
|
+
return ((f, l) => {
|
|
1001
|
+
const g = f;
|
|
1002
|
+
let s = g.pow(l, a), u = g.mul(s, r);
|
|
1003
|
+
const d = g.mul(s, o), h = g.mul(s, i), w = g.eql(g.sqr(u), l), b = g.eql(g.sqr(d), l);
|
|
1004
|
+
s = g.cmov(s, u, w), u = g.cmov(h, d, b);
|
|
1005
|
+
const E = g.eql(g.sqr(u), l), T = g.cmov(s, u, E);
|
|
1006
|
+
return en(g, T, l), T;
|
|
1007
|
+
});
|
|
906
1008
|
}
|
|
907
|
-
function
|
|
908
|
-
if (t <
|
|
909
|
-
let
|
|
910
|
-
for (;
|
|
911
|
-
|
|
912
|
-
let
|
|
913
|
-
const o =
|
|
914
|
-
for (;
|
|
915
|
-
if (
|
|
916
|
-
let
|
|
917
|
-
const
|
|
918
|
-
return function(
|
|
919
|
-
|
|
920
|
-
if (
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
1009
|
+
function Jn(t) {
|
|
1010
|
+
if (t < Gn) throw new Error("sqrt is not defined for small field");
|
|
1011
|
+
let n = t - ot, e = 0;
|
|
1012
|
+
for (; n % $t === dt; )
|
|
1013
|
+
n /= $t, e++;
|
|
1014
|
+
let r = $t;
|
|
1015
|
+
const o = ve(t);
|
|
1016
|
+
for (; Ve(o, r) === 1; ) if (r++ > 1e3) throw new Error("Cannot find square root: probably non-prime P");
|
|
1017
|
+
if (e === 1) return Qn;
|
|
1018
|
+
let i = o.pow(r, n);
|
|
1019
|
+
const a = (n + ot) / $t;
|
|
1020
|
+
return function(l, g) {
|
|
1021
|
+
const s = l;
|
|
1022
|
+
if (s.is0(g)) return g;
|
|
1023
|
+
if (Ve(s, g) !== 1) throw new Error("Cannot find square root");
|
|
1024
|
+
let u = e, d = s.mul(s.ONE, i), h = s.pow(g, n), w = s.pow(g, a);
|
|
1025
|
+
for (; !s.eql(h, s.ONE); ) {
|
|
1026
|
+
if (s.is0(h)) return s.ZERO;
|
|
1027
|
+
let b = 1, E = s.sqr(h);
|
|
1028
|
+
for (; !s.eql(E, s.ONE); )
|
|
1029
|
+
if (b++, E = s.sqr(E), b === u) throw new Error("Cannot find square root");
|
|
1030
|
+
const T = ot << BigInt(u - b - 1), B = s.pow(d, T);
|
|
1031
|
+
u = b, d = s.sqr(B), h = s.mul(h, d), w = s.mul(w, B);
|
|
929
1032
|
}
|
|
930
1033
|
return w;
|
|
931
1034
|
};
|
|
932
1035
|
}
|
|
933
|
-
function
|
|
934
|
-
return t %
|
|
1036
|
+
function Vr(t) {
|
|
1037
|
+
return t % Yn === Gn ? Qn : t % Xn === Kn ? $r : t % Wn === kr ? Zr(t) : Jn(t);
|
|
935
1038
|
}
|
|
936
|
-
var
|
|
1039
|
+
var Pr = [
|
|
937
1040
|
"create",
|
|
938
1041
|
"isValid",
|
|
939
1042
|
"is0",
|
|
@@ -952,448 +1055,1088 @@ var er = [
|
|
|
952
1055
|
"mulN",
|
|
953
1056
|
"sqrN"
|
|
954
1057
|
];
|
|
955
|
-
function
|
|
956
|
-
|
|
1058
|
+
function se(t) {
|
|
1059
|
+
if (Mt(t, Pr.reduce((n, e) => (n[e] = "function", n), {
|
|
957
1060
|
ORDER: "bigint",
|
|
958
1061
|
BYTES: "number",
|
|
959
1062
|
BITS: "number"
|
|
960
|
-
})), t;
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
if (r < J) throw new Error("invalid exponent, negatives unsupported");
|
|
964
|
-
if (r === J) return t.ONE;
|
|
965
|
-
if (r === W) return e;
|
|
966
|
-
let n = t.ONE, o = e;
|
|
967
|
-
for (; r > J; )
|
|
968
|
-
r & W && (n = t.mul(n, o)), o = t.sqr(o), r >>= W;
|
|
969
|
-
return n;
|
|
970
|
-
}
|
|
971
|
-
function Ft(t, e, r = !1) {
|
|
972
|
-
const n = new Array(e.length).fill(r ? t.ZERO : void 0), o = e.reduce((i, c, f) => t.is0(c) ? i : (n[f] = i, t.mul(i, c)), t.ONE), s = t.inv(o);
|
|
973
|
-
return e.reduceRight((i, c, f) => t.is0(c) ? i : (n[f] = t.mul(i, n[f]), t.mul(i, c)), s), n;
|
|
974
|
-
}
|
|
975
|
-
function Ce(t, e) {
|
|
976
|
-
const r = (t.ORDER - W) / vt, n = t.pow(e, r), o = t.eql(n, t.ONE), s = t.eql(n, t.ZERO), i = t.eql(n, t.neg(t.ONE));
|
|
977
|
-
if (!o && !s && !i) throw new Error("invalid Legendre symbol result");
|
|
978
|
-
return o ? 1 : s ? 0 : -1;
|
|
1063
|
+
})), Ft(t.BYTES, "BYTES"), Ft(t.BITS, "BITS"), t.BYTES < 1 || t.BITS < 1) throw new Error("invalid field: expected BYTES/BITS > 0");
|
|
1064
|
+
if (t.ORDER <= ot) throw new Error("invalid field: expected ORDER > 1, got " + t.ORDER);
|
|
1065
|
+
return t;
|
|
979
1066
|
}
|
|
980
|
-
function
|
|
981
|
-
|
|
982
|
-
|
|
1067
|
+
function zr(t, n, e) {
|
|
1068
|
+
const r = t;
|
|
1069
|
+
if (e < dt) throw new Error("invalid exponent, negatives unsupported");
|
|
1070
|
+
if (e === dt) return r.ONE;
|
|
1071
|
+
if (e === ot) return n;
|
|
1072
|
+
let o = r.ONE, i = n;
|
|
1073
|
+
for (; e > dt; )
|
|
1074
|
+
e & ot && (o = r.mul(o, i)), i = r.sqr(i), e >>= ot;
|
|
1075
|
+
return o;
|
|
1076
|
+
}
|
|
1077
|
+
function Ee(t, n, e = !1) {
|
|
1078
|
+
const r = t, o = new Array(n.length).fill(e ? r.ZERO : void 0), i = n.reduce((f, l, g) => r.is0(l) ? f : (o[g] = f, r.mul(f, l)), r.ONE), a = r.inv(i);
|
|
1079
|
+
return n.reduceRight((f, l, g) => r.is0(l) ? f : (o[g] = r.mul(f, o[g]), r.mul(f, l)), a), o;
|
|
1080
|
+
}
|
|
1081
|
+
function Ve(t, n) {
|
|
1082
|
+
const e = t, r = (e.ORDER - ot) / $t, o = e.pow(n, r), i = e.eql(o, e.ONE), a = e.eql(o, e.ZERO), f = e.eql(o, e.neg(e.ONE));
|
|
1083
|
+
if (!i && !a && !f) throw new Error("invalid Legendre symbol result");
|
|
1084
|
+
return i ? 1 : a ? 0 : -1;
|
|
1085
|
+
}
|
|
1086
|
+
function hn(t, n) {
|
|
1087
|
+
return Ve(t, n) !== -1;
|
|
1088
|
+
}
|
|
1089
|
+
function Mr(t, n) {
|
|
1090
|
+
if (n !== void 0 && Vn(n), t <= dt) throw new Error("invalid n length: expected positive n, got " + t);
|
|
1091
|
+
if (n !== void 0 && n < 1) throw new Error("invalid n length: expected positive bit length, got " + n);
|
|
1092
|
+
const e = ye(t);
|
|
1093
|
+
if (n !== void 0 && n < e) throw new Error(`invalid n length: expected bit length (${e}) >= n.length (${n})`);
|
|
1094
|
+
const r = n !== void 0 ? n : e;
|
|
983
1095
|
return {
|
|
984
1096
|
nBitLength: r,
|
|
985
1097
|
nByteLength: Math.ceil(r / 8)
|
|
986
1098
|
};
|
|
987
1099
|
}
|
|
988
|
-
var
|
|
1100
|
+
var mn = /* @__PURE__ */ new WeakMap(), tr = class {
|
|
989
1101
|
ORDER;
|
|
990
1102
|
BITS;
|
|
991
1103
|
BYTES;
|
|
992
1104
|
isLE;
|
|
993
|
-
ZERO =
|
|
994
|
-
ONE =
|
|
1105
|
+
ZERO = dt;
|
|
1106
|
+
ONE = ot;
|
|
995
1107
|
_lengths;
|
|
996
|
-
_sqrt;
|
|
997
1108
|
_mod;
|
|
998
|
-
constructor(t,
|
|
999
|
-
if (t <=
|
|
1000
|
-
let
|
|
1001
|
-
this.isLE = !1,
|
|
1002
|
-
|
|
1109
|
+
constructor(t, n = {}) {
|
|
1110
|
+
if (t <= ot) throw new Error("invalid field: expected ORDER > 1, got " + t);
|
|
1111
|
+
let e;
|
|
1112
|
+
this.isLE = !1, n != null && typeof n == "object" && (typeof n.BITS == "number" && (e = n.BITS), typeof n.sqrt == "function" && Object.defineProperty(this, "sqrt", {
|
|
1113
|
+
value: n.sqrt,
|
|
1114
|
+
enumerable: !0
|
|
1115
|
+
}), typeof n.isLE == "boolean" && (this.isLE = n.isLE), n.allowedLengths && (this._lengths = Object.freeze(n.allowedLengths.slice())), typeof n.modFromBytes == "boolean" && (this._mod = n.modFromBytes));
|
|
1116
|
+
const { nBitLength: r, nByteLength: o } = Mr(t, e);
|
|
1003
1117
|
if (o > 2048) throw new Error("invalid field: expected ORDER of <= 2048 bytes");
|
|
1004
|
-
this.ORDER = t, this.BITS =
|
|
1118
|
+
this.ORDER = t, this.BITS = r, this.BYTES = o, Object.freeze(this);
|
|
1005
1119
|
}
|
|
1006
1120
|
create(t) {
|
|
1007
|
-
return
|
|
1121
|
+
return bt(t, this.ORDER);
|
|
1008
1122
|
}
|
|
1009
1123
|
isValid(t) {
|
|
1010
|
-
if (typeof t != "bigint") throw new
|
|
1011
|
-
return
|
|
1124
|
+
if (typeof t != "bigint") throw new TypeError("invalid field element: expected bigint, got " + typeof t);
|
|
1125
|
+
return dt <= t && t < this.ORDER;
|
|
1012
1126
|
}
|
|
1013
1127
|
is0(t) {
|
|
1014
|
-
return t ===
|
|
1128
|
+
return t === dt;
|
|
1015
1129
|
}
|
|
1016
1130
|
isValidNot0(t) {
|
|
1017
1131
|
return !this.is0(t) && this.isValid(t);
|
|
1018
1132
|
}
|
|
1019
1133
|
isOdd(t) {
|
|
1020
|
-
return (t &
|
|
1134
|
+
return (t & ot) === ot;
|
|
1021
1135
|
}
|
|
1022
1136
|
neg(t) {
|
|
1023
|
-
return
|
|
1137
|
+
return bt(-t, this.ORDER);
|
|
1024
1138
|
}
|
|
1025
|
-
eql(t,
|
|
1026
|
-
return t ===
|
|
1139
|
+
eql(t, n) {
|
|
1140
|
+
return t === n;
|
|
1027
1141
|
}
|
|
1028
1142
|
sqr(t) {
|
|
1029
|
-
return
|
|
1143
|
+
return bt(t * t, this.ORDER);
|
|
1030
1144
|
}
|
|
1031
|
-
add(t,
|
|
1032
|
-
return
|
|
1145
|
+
add(t, n) {
|
|
1146
|
+
return bt(t + n, this.ORDER);
|
|
1033
1147
|
}
|
|
1034
|
-
sub(t,
|
|
1035
|
-
return
|
|
1148
|
+
sub(t, n) {
|
|
1149
|
+
return bt(t - n, this.ORDER);
|
|
1036
1150
|
}
|
|
1037
|
-
mul(t,
|
|
1038
|
-
return
|
|
1151
|
+
mul(t, n) {
|
|
1152
|
+
return bt(t * n, this.ORDER);
|
|
1039
1153
|
}
|
|
1040
|
-
pow(t,
|
|
1041
|
-
return
|
|
1154
|
+
pow(t, n) {
|
|
1155
|
+
return zr(this, t, n);
|
|
1042
1156
|
}
|
|
1043
|
-
div(t,
|
|
1044
|
-
return
|
|
1157
|
+
div(t, n) {
|
|
1158
|
+
return bt(t * dn(n, this.ORDER), this.ORDER);
|
|
1045
1159
|
}
|
|
1046
1160
|
sqrN(t) {
|
|
1047
1161
|
return t * t;
|
|
1048
1162
|
}
|
|
1049
|
-
addN(t,
|
|
1050
|
-
return t +
|
|
1163
|
+
addN(t, n) {
|
|
1164
|
+
return t + n;
|
|
1051
1165
|
}
|
|
1052
|
-
subN(t,
|
|
1053
|
-
return t -
|
|
1166
|
+
subN(t, n) {
|
|
1167
|
+
return t - n;
|
|
1054
1168
|
}
|
|
1055
|
-
mulN(t,
|
|
1056
|
-
return t *
|
|
1169
|
+
mulN(t, n) {
|
|
1170
|
+
return t * n;
|
|
1057
1171
|
}
|
|
1058
1172
|
inv(t) {
|
|
1059
|
-
return
|
|
1173
|
+
return dn(t, this.ORDER);
|
|
1060
1174
|
}
|
|
1061
1175
|
sqrt(t) {
|
|
1062
|
-
|
|
1176
|
+
let n = mn.get(this);
|
|
1177
|
+
return n || mn.set(this, n = Vr(this.ORDER)), n(this, t);
|
|
1063
1178
|
}
|
|
1064
1179
|
toBytes(t) {
|
|
1065
|
-
return this.isLE ?
|
|
1066
|
-
}
|
|
1067
|
-
fromBytes(t,
|
|
1068
|
-
|
|
1069
|
-
const { _lengths:
|
|
1070
|
-
if (
|
|
1071
|
-
if (!
|
|
1072
|
-
const
|
|
1073
|
-
|
|
1074
|
-
}
|
|
1075
|
-
if (t.length !==
|
|
1076
|
-
let
|
|
1077
|
-
if (
|
|
1180
|
+
return this.isLE ? zn(t, this.BYTES) : tn(t, this.BYTES);
|
|
1181
|
+
}
|
|
1182
|
+
fromBytes(t, n = !1) {
|
|
1183
|
+
st(t);
|
|
1184
|
+
const { _lengths: e, BYTES: r, isLE: o, ORDER: i, _mod: a } = this;
|
|
1185
|
+
if (e) {
|
|
1186
|
+
if (t.length < 1 || !e.includes(t.length) || t.length > r) throw new Error("Field.fromBytes: expected " + e + " bytes, got " + t.length);
|
|
1187
|
+
const l = new Uint8Array(r);
|
|
1188
|
+
l.set(t, o ? 0 : l.length - t.length), t = l;
|
|
1189
|
+
}
|
|
1190
|
+
if (t.length !== r) throw new Error("Field.fromBytes: expected " + r + " bytes, got " + t.length);
|
|
1191
|
+
let f = o ? ge(t) : St(t);
|
|
1192
|
+
if (a && (f = bt(f, i)), !n && !this.isValid(f))
|
|
1078
1193
|
throw new Error("invalid field element: outside of range 0..ORDER");
|
|
1079
|
-
return
|
|
1194
|
+
return f;
|
|
1080
1195
|
}
|
|
1081
1196
|
invertBatch(t) {
|
|
1082
|
-
return
|
|
1197
|
+
return Ee(this, t);
|
|
1083
1198
|
}
|
|
1084
|
-
cmov(t,
|
|
1085
|
-
return
|
|
1199
|
+
cmov(t, n, e) {
|
|
1200
|
+
return ie(e, "condition"), e ? n : t;
|
|
1086
1201
|
}
|
|
1087
1202
|
};
|
|
1088
|
-
|
|
1089
|
-
|
|
1203
|
+
Object.freeze(tr.prototype);
|
|
1204
|
+
function ve(t, n = {}) {
|
|
1205
|
+
return new tr(t, n);
|
|
1090
1206
|
}
|
|
1091
|
-
function
|
|
1207
|
+
function er(t) {
|
|
1092
1208
|
if (typeof t != "bigint") throw new Error("field order must be bigint");
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
var
|
|
1109
|
-
function
|
|
1110
|
-
const
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1209
|
+
if (t <= ot) throw new Error("field order must be greater than 1");
|
|
1210
|
+
const n = ye(t - ot);
|
|
1211
|
+
return Math.ceil(n / 8);
|
|
1212
|
+
}
|
|
1213
|
+
function nn(t) {
|
|
1214
|
+
const n = er(t);
|
|
1215
|
+
return n + Math.ceil(n / 2);
|
|
1216
|
+
}
|
|
1217
|
+
function nr(t, n, e = !1) {
|
|
1218
|
+
st(t);
|
|
1219
|
+
const r = t.length, o = er(n), i = Math.max(nn(n), 16);
|
|
1220
|
+
if (r < i || r > 1024) throw new Error("expected " + i + "-1024 bytes of input, got " + r);
|
|
1221
|
+
const a = bt(e ? ge(t) : St(t), n - ot) + ot;
|
|
1222
|
+
return e ? zn(a, o) : tn(a, o);
|
|
1223
|
+
}
|
|
1224
|
+
var Wt = /* @__PURE__ */ BigInt(0), Zt = /* @__PURE__ */ BigInt(1);
|
|
1225
|
+
function Gr(t) {
|
|
1226
|
+
const n = t;
|
|
1227
|
+
if (typeof n != "function") throw new TypeError("Point must be a constructor");
|
|
1228
|
+
Mt({
|
|
1229
|
+
Fp: n.Fp,
|
|
1230
|
+
Fn: n.Fn,
|
|
1231
|
+
fromAffine: n.fromAffine,
|
|
1232
|
+
fromBytes: n.fromBytes,
|
|
1233
|
+
fromHex: n.fromHex
|
|
1234
|
+
}, {
|
|
1235
|
+
Fp: "object",
|
|
1236
|
+
Fn: "object",
|
|
1237
|
+
fromAffine: "function",
|
|
1238
|
+
fromBytes: "function",
|
|
1239
|
+
fromHex: "function"
|
|
1240
|
+
}), se(n.Fp), se(n.Fn);
|
|
1241
|
+
}
|
|
1242
|
+
function we(t, n) {
|
|
1243
|
+
const e = n.negate();
|
|
1244
|
+
return t ? e : n;
|
|
1245
|
+
}
|
|
1246
|
+
function gn(t, n) {
|
|
1247
|
+
const e = Ee(t.Fp, n.map((r) => r.Z));
|
|
1248
|
+
return n.map((r, o) => t.fromAffine(r.toAffine(e[o])));
|
|
1249
|
+
}
|
|
1250
|
+
function rr(t, n) {
|
|
1251
|
+
if (!Number.isSafeInteger(t) || t <= 0 || t > n) throw new Error("invalid window size, expected [1.." + n + "], got W=" + t);
|
|
1252
|
+
}
|
|
1253
|
+
function Re(t, n) {
|
|
1254
|
+
rr(t, n);
|
|
1255
|
+
const e = Math.ceil(n / t) + 1, r = 2 ** (t - 1), o = 2 ** t;
|
|
1123
1256
|
return {
|
|
1124
|
-
windows:
|
|
1125
|
-
windowSize:
|
|
1126
|
-
mask:
|
|
1257
|
+
windows: e,
|
|
1258
|
+
windowSize: r,
|
|
1259
|
+
mask: pe(t),
|
|
1127
1260
|
maxNumber: o,
|
|
1128
1261
|
shiftBy: BigInt(t)
|
|
1129
1262
|
};
|
|
1130
1263
|
}
|
|
1131
|
-
function
|
|
1132
|
-
const { windowSize:
|
|
1133
|
-
let
|
|
1134
|
-
|
|
1135
|
-
const
|
|
1264
|
+
function wn(t, n, e) {
|
|
1265
|
+
const { windowSize: r, mask: o, maxNumber: i, shiftBy: a } = e;
|
|
1266
|
+
let f = Number(t & o), l = t >> a;
|
|
1267
|
+
f > r && (f -= i, l += Zt);
|
|
1268
|
+
const g = n * r, s = g + Math.abs(f) - 1, u = f === 0, d = f < 0, h = n % 2 !== 0;
|
|
1136
1269
|
return {
|
|
1137
|
-
nextN:
|
|
1138
|
-
offset:
|
|
1139
|
-
isZero:
|
|
1140
|
-
isNeg:
|
|
1141
|
-
isNegF:
|
|
1142
|
-
offsetF:
|
|
1270
|
+
nextN: l,
|
|
1271
|
+
offset: s,
|
|
1272
|
+
isZero: u,
|
|
1273
|
+
isNeg: d,
|
|
1274
|
+
isNegF: h,
|
|
1275
|
+
offsetF: g
|
|
1143
1276
|
};
|
|
1144
1277
|
}
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1278
|
+
function Yr(t, n) {
|
|
1279
|
+
if (!Array.isArray(t)) throw new Error("array expected");
|
|
1280
|
+
t.forEach((e, r) => {
|
|
1281
|
+
if (!(e instanceof n)) throw new Error("invalid point at index " + r);
|
|
1282
|
+
});
|
|
1148
1283
|
}
|
|
1149
|
-
function
|
|
1150
|
-
if (t
|
|
1284
|
+
function Kr(t, n) {
|
|
1285
|
+
if (!Array.isArray(t)) throw new Error("array of scalars expected");
|
|
1286
|
+
t.forEach((e, r) => {
|
|
1287
|
+
if (!n.isValid(e)) throw new Error("invalid scalar at index " + r);
|
|
1288
|
+
});
|
|
1151
1289
|
}
|
|
1152
|
-
var
|
|
1290
|
+
var _e = /* @__PURE__ */ new WeakMap(), or = /* @__PURE__ */ new WeakMap();
|
|
1291
|
+
function Oe(t) {
|
|
1292
|
+
return or.get(t) || 1;
|
|
1293
|
+
}
|
|
1294
|
+
function bn(t) {
|
|
1295
|
+
if (t !== Wt) throw new Error("invalid wNAF");
|
|
1296
|
+
}
|
|
1297
|
+
var Xr = class {
|
|
1153
1298
|
BASE;
|
|
1154
1299
|
ZERO;
|
|
1155
1300
|
Fn;
|
|
1156
1301
|
bits;
|
|
1157
|
-
constructor(t,
|
|
1158
|
-
this.BASE = t.BASE, this.ZERO = t.ZERO, this.Fn = t.Fn, this.bits =
|
|
1159
|
-
}
|
|
1160
|
-
_unsafeLadder(t,
|
|
1161
|
-
let
|
|
1162
|
-
for (;
|
|
1163
|
-
|
|
1164
|
-
return
|
|
1165
|
-
}
|
|
1166
|
-
precomputeWindow(t,
|
|
1167
|
-
const { windows:
|
|
1168
|
-
let
|
|
1169
|
-
for (let
|
|
1170
|
-
|
|
1171
|
-
for (let
|
|
1172
|
-
|
|
1173
|
-
|
|
1302
|
+
constructor(t, n) {
|
|
1303
|
+
this.BASE = t.BASE, this.ZERO = t.ZERO, this.Fn = t.Fn, this.bits = n;
|
|
1304
|
+
}
|
|
1305
|
+
_unsafeLadder(t, n, e = this.ZERO) {
|
|
1306
|
+
let r = t;
|
|
1307
|
+
for (; n > Wt; )
|
|
1308
|
+
n & Zt && (e = e.add(r)), r = r.double(), n >>= Zt;
|
|
1309
|
+
return e;
|
|
1310
|
+
}
|
|
1311
|
+
precomputeWindow(t, n) {
|
|
1312
|
+
const { windows: e, windowSize: r } = Re(n, this.bits), o = [];
|
|
1313
|
+
let i = t, a = i;
|
|
1314
|
+
for (let f = 0; f < e; f++) {
|
|
1315
|
+
a = i, o.push(a);
|
|
1316
|
+
for (let l = 1; l < r; l++)
|
|
1317
|
+
a = a.add(i), o.push(a);
|
|
1318
|
+
i = a.double();
|
|
1174
1319
|
}
|
|
1175
1320
|
return o;
|
|
1176
1321
|
}
|
|
1177
|
-
wNAF(t,
|
|
1178
|
-
if (!this.Fn.isValid(
|
|
1179
|
-
let
|
|
1180
|
-
const
|
|
1181
|
-
for (let
|
|
1182
|
-
const { nextN:
|
|
1183
|
-
|
|
1322
|
+
wNAF(t, n, e) {
|
|
1323
|
+
if (!this.Fn.isValid(e)) throw new Error("invalid scalar");
|
|
1324
|
+
let r = this.ZERO, o = this.BASE;
|
|
1325
|
+
const i = Re(t, this.bits);
|
|
1326
|
+
for (let a = 0; a < i.windows; a++) {
|
|
1327
|
+
const { nextN: f, offset: l, isZero: g, isNeg: s, isNegF: u, offsetF: d } = wn(e, a, i);
|
|
1328
|
+
e = f, g ? o = o.add(we(u, n[d])) : r = r.add(we(s, n[l]));
|
|
1184
1329
|
}
|
|
1185
|
-
return
|
|
1186
|
-
p:
|
|
1330
|
+
return bn(e), {
|
|
1331
|
+
p: r,
|
|
1187
1332
|
f: o
|
|
1188
1333
|
};
|
|
1189
1334
|
}
|
|
1190
|
-
wNAFUnsafe(t, e, r
|
|
1191
|
-
const o =
|
|
1192
|
-
for (let
|
|
1193
|
-
const { nextN:
|
|
1194
|
-
if (
|
|
1195
|
-
const
|
|
1196
|
-
|
|
1335
|
+
wNAFUnsafe(t, n, e, r = this.ZERO) {
|
|
1336
|
+
const o = Re(t, this.bits);
|
|
1337
|
+
for (let i = 0; i < o.windows && e !== Wt; i++) {
|
|
1338
|
+
const { nextN: a, offset: f, isZero: l, isNeg: g } = wn(e, i, o);
|
|
1339
|
+
if (e = a, !l) {
|
|
1340
|
+
const s = n[f];
|
|
1341
|
+
r = r.add(g ? s.negate() : s);
|
|
1197
1342
|
}
|
|
1198
1343
|
}
|
|
1199
|
-
return
|
|
1344
|
+
return bn(e), r;
|
|
1200
1345
|
}
|
|
1201
|
-
getPrecomputes(t,
|
|
1202
|
-
let
|
|
1203
|
-
return
|
|
1346
|
+
getPrecomputes(t, n, e) {
|
|
1347
|
+
let r = _e.get(n);
|
|
1348
|
+
return r || (r = this.precomputeWindow(n, t), t !== 1 && (typeof e == "function" && (r = e(r)), _e.set(n, r))), r;
|
|
1204
1349
|
}
|
|
1205
|
-
cached(t,
|
|
1206
|
-
const
|
|
1207
|
-
return this.wNAF(
|
|
1350
|
+
cached(t, n, e) {
|
|
1351
|
+
const r = Oe(t);
|
|
1352
|
+
return this.wNAF(r, this.getPrecomputes(r, t, e), n);
|
|
1208
1353
|
}
|
|
1209
|
-
unsafe(t, e, r
|
|
1210
|
-
const o =
|
|
1211
|
-
return o === 1 ? this._unsafeLadder(t,
|
|
1354
|
+
unsafe(t, n, e, r) {
|
|
1355
|
+
const o = Oe(t);
|
|
1356
|
+
return o === 1 ? this._unsafeLadder(t, n, r) : this.wNAFUnsafe(o, this.getPrecomputes(o, t, e), n, r);
|
|
1212
1357
|
}
|
|
1213
|
-
createCache(t,
|
|
1214
|
-
|
|
1358
|
+
createCache(t, n) {
|
|
1359
|
+
rr(n, this.bits), or.set(t, n), _e.delete(t);
|
|
1215
1360
|
}
|
|
1216
1361
|
hasCache(t) {
|
|
1217
|
-
return
|
|
1362
|
+
return Oe(t) !== 1;
|
|
1218
1363
|
}
|
|
1219
1364
|
};
|
|
1220
|
-
function
|
|
1221
|
-
let o =
|
|
1222
|
-
for (;
|
|
1223
|
-
|
|
1365
|
+
function Wr(t, n, e, r) {
|
|
1366
|
+
let o = n, i = t.ZERO, a = t.ZERO;
|
|
1367
|
+
for (; e > Wt || r > Wt; )
|
|
1368
|
+
e & Zt && (i = i.add(o)), r & Zt && (a = a.add(o)), o = o.double(), e >>= Zt, r >>= Zt;
|
|
1224
1369
|
return {
|
|
1225
|
-
p1:
|
|
1226
|
-
p2:
|
|
1370
|
+
p1: i,
|
|
1371
|
+
p2: a
|
|
1227
1372
|
};
|
|
1228
1373
|
}
|
|
1229
|
-
function
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1374
|
+
function Qr(t, n, e) {
|
|
1375
|
+
const r = t.Fn;
|
|
1376
|
+
Yr(n, t), Kr(e, r);
|
|
1377
|
+
const o = n.length, i = e.length;
|
|
1378
|
+
if (o !== i) throw new Error("arrays of points and scalars must have equal length");
|
|
1379
|
+
const a = t.ZERO, f = ye(BigInt(o));
|
|
1380
|
+
let l = 1;
|
|
1381
|
+
f > 12 ? l = f - 3 : f > 4 ? l = f - 2 : f > 0 && (l = 2);
|
|
1382
|
+
const g = pe(l), s = new Array(Number(g) + 1).fill(a), u = Math.floor((r.BITS - 1) / l) * l;
|
|
1383
|
+
let d = a;
|
|
1384
|
+
for (let h = u; h >= 0; h -= l) {
|
|
1385
|
+
s.fill(a);
|
|
1386
|
+
for (let b = 0; b < i; b++) {
|
|
1387
|
+
const E = e[b], T = Number(E >> BigInt(h) & g);
|
|
1388
|
+
s[T] = s[T].add(n[b]);
|
|
1389
|
+
}
|
|
1390
|
+
let w = a;
|
|
1391
|
+
for (let b = s.length - 1, E = a; b > 0; b--)
|
|
1392
|
+
E = E.add(s[b]), w = w.add(E);
|
|
1393
|
+
if (d = d.add(w), h !== 0) for (let b = 0; b < l; b++) d = d.double();
|
|
1394
|
+
}
|
|
1395
|
+
return d;
|
|
1396
|
+
}
|
|
1397
|
+
function yn(t, n, e) {
|
|
1398
|
+
if (n) {
|
|
1399
|
+
if (n.ORDER !== t) throw new Error("Field.ORDER must match order: Fp == p, Fn == n");
|
|
1400
|
+
return se(n), n;
|
|
1401
|
+
} else return ve(t, { isLE: e });
|
|
1402
|
+
}
|
|
1403
|
+
function Jr(t, n, e = {}, r) {
|
|
1404
|
+
if (r === void 0 && (r = t === "edwards"), !n || typeof n != "object") throw new Error(`expected valid ${t} CURVE object`);
|
|
1405
|
+
for (const f of [
|
|
1238
1406
|
"p",
|
|
1239
1407
|
"n",
|
|
1240
1408
|
"h"
|
|
1241
1409
|
]) {
|
|
1242
|
-
const
|
|
1243
|
-
if (!(typeof
|
|
1410
|
+
const l = n[f];
|
|
1411
|
+
if (!(typeof l == "bigint" && l > Wt)) throw new Error(`CURVE.${f} must be positive bigint`);
|
|
1244
1412
|
}
|
|
1245
|
-
const o =
|
|
1413
|
+
const o = yn(n.p, e.Fp, r), i = yn(n.n, e.Fn, r), a = [
|
|
1246
1414
|
"Gx",
|
|
1247
1415
|
"Gy",
|
|
1248
1416
|
"a",
|
|
1249
1417
|
t === "weierstrass" ? "b" : "d"
|
|
1250
1418
|
];
|
|
1251
|
-
for (const
|
|
1252
|
-
return
|
|
1253
|
-
CURVE:
|
|
1419
|
+
for (const f of a) if (!o.isValid(n[f])) throw new Error(`CURVE.${f} must be valid field element of CURVE.Fp`);
|
|
1420
|
+
return n = Object.freeze(Object.assign({}, n)), {
|
|
1421
|
+
CURVE: n,
|
|
1254
1422
|
Fp: o,
|
|
1255
|
-
Fn:
|
|
1423
|
+
Fn: i
|
|
1256
1424
|
};
|
|
1257
1425
|
}
|
|
1258
|
-
function
|
|
1259
|
-
return function(
|
|
1260
|
-
const o = t(
|
|
1426
|
+
function to(t, n) {
|
|
1427
|
+
return function(r) {
|
|
1428
|
+
const o = t(r);
|
|
1261
1429
|
return {
|
|
1262
1430
|
secretKey: o,
|
|
1263
|
-
publicKey:
|
|
1431
|
+
publicKey: n(o)
|
|
1264
1432
|
};
|
|
1265
1433
|
};
|
|
1266
1434
|
}
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
return
|
|
1275
|
-
}
|
|
1276
|
-
function
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1435
|
+
function ir(t) {
|
|
1436
|
+
if (!Number.isSafeInteger(t) || t < 0 || t > 4294967295) throw new Error("wrong u32 integer:" + t);
|
|
1437
|
+
return t;
|
|
1438
|
+
}
|
|
1439
|
+
function eo(t) {
|
|
1440
|
+
if (ir(t), t <= 1) return 1;
|
|
1441
|
+
if (t > 2147483648) throw new Error("nextPowerOfTwo overflow: result does not fit u32");
|
|
1442
|
+
return 1 << Pe(t - 1) + 1 >>> 0;
|
|
1443
|
+
}
|
|
1444
|
+
function Pe(t) {
|
|
1445
|
+
return ir(t), 31 - Math.clz32(t);
|
|
1446
|
+
}
|
|
1447
|
+
function no(t, n, e, r, o) {
|
|
1448
|
+
const i = t, a = e || ((s, u) => new Array(s).fill(u ?? i.ZERO)), f = (s) => {
|
|
1449
|
+
if (Array.isArray(s)) return !0;
|
|
1450
|
+
if (!ArrayBuffer.isView(s)) return !1;
|
|
1451
|
+
const u = s;
|
|
1452
|
+
return typeof u.length == "number" && typeof u.slice == "function" && typeof u[Symbol.iterator] == "function";
|
|
1453
|
+
}, l = (...s) => {
|
|
1454
|
+
if (!s.length) return 0;
|
|
1455
|
+
for (const d of s) if (!f(d)) throw new Error("poly: not polynomial: " + d);
|
|
1456
|
+
const u = s[0].length;
|
|
1457
|
+
for (let d = 1; d < s.length; d++) if (s[d].length !== u) throw new Error(`poly: mismatched lengths ${u} vs ${s[d].length}`);
|
|
1458
|
+
if (o !== void 0 && u !== o) throw new Error(`poly: expected fixed length ${o}, got ${u}`);
|
|
1459
|
+
return u;
|
|
1460
|
+
};
|
|
1461
|
+
function g(s, u, d = !1) {
|
|
1462
|
+
const h = Pe(u), w = d ? n.brp(h) : n.roots(h);
|
|
1463
|
+
for (let b = 0; b < u; b++) if (i.eql(s, w[b])) return b;
|
|
1464
|
+
return -1;
|
|
1465
|
+
}
|
|
1466
|
+
return {
|
|
1467
|
+
roots: n,
|
|
1468
|
+
create: a,
|
|
1469
|
+
length: o,
|
|
1470
|
+
extend: (s, u) => {
|
|
1471
|
+
l(s);
|
|
1472
|
+
const d = a(u, i.ZERO);
|
|
1473
|
+
for (let h = 0; h < Math.min(s.length, u); h++) d[h] = s[h];
|
|
1474
|
+
return d;
|
|
1475
|
+
},
|
|
1476
|
+
degree: (s) => {
|
|
1477
|
+
l(s);
|
|
1478
|
+
for (let u = s.length - 1; u >= 0; u--) if (!i.is0(s[u])) return u;
|
|
1479
|
+
return -1;
|
|
1480
|
+
},
|
|
1481
|
+
add: (s, u) => {
|
|
1482
|
+
const d = l(s, u), h = a(d);
|
|
1483
|
+
for (let w = 0; w < d; w++) h[w] = i.add(s[w], u[w]);
|
|
1484
|
+
return h;
|
|
1485
|
+
},
|
|
1486
|
+
sub: (s, u) => {
|
|
1487
|
+
const d = l(s, u), h = a(d);
|
|
1488
|
+
for (let w = 0; w < d; w++) h[w] = i.sub(s[w], u[w]);
|
|
1489
|
+
return h;
|
|
1490
|
+
},
|
|
1491
|
+
dot: (s, u) => {
|
|
1492
|
+
const d = l(s, u), h = a(d);
|
|
1493
|
+
for (let w = 0; w < d; w++) h[w] = i.mul(s[w], u[w]);
|
|
1494
|
+
return h;
|
|
1495
|
+
},
|
|
1496
|
+
mul: (s, u) => {
|
|
1497
|
+
if (f(u)) {
|
|
1498
|
+
const d = l(s, u);
|
|
1499
|
+
if (r) {
|
|
1500
|
+
const h = r.direct(s, !1, !0), w = r.direct(u, !1, !0);
|
|
1501
|
+
for (let b = 0; b < h.length; b++) h[b] = i.mul(h[b], w[b]);
|
|
1502
|
+
return r.inverse(h, !0, !1);
|
|
1503
|
+
} else {
|
|
1504
|
+
const h = a(d);
|
|
1505
|
+
for (let w = 0; w < d; w++) for (let b = 0; b < d; b++) {
|
|
1506
|
+
const E = (w + b) % d;
|
|
1507
|
+
h[E] = i.add(h[E], i.mul(s[w], u[b]));
|
|
1508
|
+
}
|
|
1509
|
+
return h;
|
|
1510
|
+
}
|
|
1511
|
+
} else {
|
|
1512
|
+
const d = a(l(s));
|
|
1513
|
+
for (let h = 0; h < d.length; h++) d[h] = i.mul(s[h], u);
|
|
1514
|
+
return d;
|
|
1515
|
+
}
|
|
1516
|
+
},
|
|
1517
|
+
convolve(s, u) {
|
|
1518
|
+
const d = eo(s.length + u.length - 1);
|
|
1519
|
+
return this.mul(this.extend(s, d), this.extend(u, d));
|
|
1520
|
+
},
|
|
1521
|
+
shift(s, u) {
|
|
1522
|
+
const d = a(l(s));
|
|
1523
|
+
d[0] = s[0];
|
|
1524
|
+
for (let h = 1, w = i.ONE; h < s.length; h++)
|
|
1525
|
+
w = i.mul(w, u), d[h] = i.mul(s[h], w);
|
|
1526
|
+
return d;
|
|
1527
|
+
},
|
|
1528
|
+
clone: (s) => {
|
|
1529
|
+
l(s);
|
|
1530
|
+
const u = a(s.length);
|
|
1531
|
+
for (let d = 0; d < s.length; d++) u[d] = s[d];
|
|
1532
|
+
return u;
|
|
1533
|
+
},
|
|
1534
|
+
eval: (s, u) => {
|
|
1535
|
+
l(s, u);
|
|
1536
|
+
let d = i.ZERO;
|
|
1537
|
+
for (let h = 0; h < s.length; h++) d = i.add(d, i.mul(s[h], u[h]));
|
|
1538
|
+
return d;
|
|
1539
|
+
},
|
|
1540
|
+
monomial: {
|
|
1541
|
+
basis: (s, u) => {
|
|
1542
|
+
const d = a(u);
|
|
1543
|
+
let h = i.ONE;
|
|
1544
|
+
for (let w = 0; w < u; w++)
|
|
1545
|
+
d[w] = h, h = i.mul(h, s);
|
|
1546
|
+
return d;
|
|
1547
|
+
},
|
|
1548
|
+
eval: (s, u) => {
|
|
1549
|
+
l(s);
|
|
1550
|
+
let d = i.ZERO;
|
|
1551
|
+
for (let h = s.length - 1; h >= 0; h--) d = i.add(i.mul(d, u), s[h]);
|
|
1552
|
+
return d;
|
|
1553
|
+
}
|
|
1554
|
+
},
|
|
1555
|
+
lagrange: {
|
|
1556
|
+
basis: (s, u, d = !1, h) => {
|
|
1557
|
+
const w = Pe(u), b = h || (d ? n.brp(w) : n.roots(w)), E = a(u), T = g(s, u, d);
|
|
1558
|
+
if (T !== -1)
|
|
1559
|
+
return E[T] = i.ONE, E;
|
|
1560
|
+
const B = i.pow(s, BigInt(u)), C = i.mul(i.sub(B, i.ONE), i.inv(BigInt(u))), O = a(u);
|
|
1561
|
+
for (let z = 0; z < u; z++) O[z] = i.sub(s, b[z]);
|
|
1562
|
+
const F = i.invertBatch(O);
|
|
1563
|
+
for (let z = 0; z < u; z++) E[z] = i.mul(C, i.mul(b[z], F[z]));
|
|
1564
|
+
return E;
|
|
1565
|
+
},
|
|
1566
|
+
eval(s, u, d = !1) {
|
|
1567
|
+
l(s);
|
|
1568
|
+
const h = g(u, s.length, d);
|
|
1569
|
+
if (h !== -1) return s[h];
|
|
1570
|
+
const w = this.basis(u, s.length, d);
|
|
1571
|
+
let b = i.ZERO;
|
|
1572
|
+
for (let E = 0; E < s.length; E++) i.is0(s[E]) || (b = i.add(b, i.mul(s[E], w[E])));
|
|
1573
|
+
return b;
|
|
1574
|
+
}
|
|
1575
|
+
},
|
|
1576
|
+
vanishing(s) {
|
|
1577
|
+
l(s);
|
|
1578
|
+
const u = a(s.length + 1, i.ZERO);
|
|
1579
|
+
u[0] = i.ONE;
|
|
1580
|
+
for (const d of s) {
|
|
1581
|
+
const h = i.neg(d);
|
|
1582
|
+
for (let w = u.length - 1; w > 0; w--) u[w] = i.add(i.mul(u[w], h), u[w - 1]);
|
|
1583
|
+
u[0] = i.mul(u[0], h);
|
|
1584
|
+
}
|
|
1585
|
+
return u;
|
|
1586
|
+
}
|
|
1587
|
+
};
|
|
1588
|
+
}
|
|
1589
|
+
var ro = St;
|
|
1590
|
+
function kt(t, n) {
|
|
1591
|
+
if (Ft(t), Ft(n), n < 0 || n > 4) throw new Error("invalid I2OSP length: " + n);
|
|
1592
|
+
if (t < 0 || t > 2 ** (8 * n) - 1) throw new Error("invalid I2OSP input: " + t);
|
|
1593
|
+
const e = Array.from({ length: n }).fill(0);
|
|
1594
|
+
for (let r = n - 1; r >= 0; r--)
|
|
1595
|
+
e[r] = t & 255, t >>>= 8;
|
|
1596
|
+
return new Uint8Array(e);
|
|
1597
|
+
}
|
|
1598
|
+
function oo(t, n) {
|
|
1599
|
+
const e = new Uint8Array(t.length);
|
|
1600
|
+
for (let r = 0; r < t.length; r++) e[r] = t[r] ^ n[r];
|
|
1601
|
+
return e;
|
|
1602
|
+
}
|
|
1603
|
+
function sr(t) {
|
|
1604
|
+
if (!oe(t) && typeof t != "string") throw new Error("DST must be Uint8Array or ascii string");
|
|
1605
|
+
const n = typeof t == "string" ? be(t) : t;
|
|
1606
|
+
if (n.length === 0) throw new Error("DST must be non-empty");
|
|
1607
|
+
return n;
|
|
1280
1608
|
}
|
|
1281
|
-
function
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
}
|
|
1294
|
-
|
|
1295
|
-
if (
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
return o.create({ dkLen: r }).update(t).update(bt(r, 2)).update(e).update(bt(e.length, 1)).digest();
|
|
1301
|
-
}
|
|
1302
|
-
function ce(t, e, r) {
|
|
1303
|
-
Qt(r, {
|
|
1609
|
+
function io(t, n, e, r) {
|
|
1610
|
+
st(t), Ft(e), n = sr(n), n.length > 255 && (n = r(Q(be("H2C-OVERSIZE-DST-"), n)));
|
|
1611
|
+
const { outputLen: o, blockLen: i } = r, a = Math.ceil(e / o);
|
|
1612
|
+
if (e > 65535 || a > 255) throw new Error("expand_message_xmd: invalid lenInBytes");
|
|
1613
|
+
const f = Q(n, kt(n.length, 1)), l = new Uint8Array(i), g = kt(e, 2), s = new Array(a), u = r(Q(l, t, g, kt(0, 1), f));
|
|
1614
|
+
s[0] = r(Q(u, kt(1, 1), f));
|
|
1615
|
+
for (let d = 1; d < a; d++) s[d] = r(Q(oo(u, s[d - 1]), kt(d + 1, 1), f));
|
|
1616
|
+
return Q(...s).slice(0, e);
|
|
1617
|
+
}
|
|
1618
|
+
function so(t, n, e, r, o) {
|
|
1619
|
+
if (st(t), Ft(e), n = sr(n), n.length > 255) {
|
|
1620
|
+
const i = Math.ceil(2 * r / 8);
|
|
1621
|
+
n = o.create({ dkLen: i }).update(be("H2C-OVERSIZE-DST-")).update(n).digest();
|
|
1622
|
+
}
|
|
1623
|
+
if (e > 65535 || n.length > 255) throw new Error("expand_message_xof: invalid lenInBytes");
|
|
1624
|
+
return o.create({ dkLen: e }).update(t).update(kt(e, 2)).update(n).update(kt(n.length, 1)).digest();
|
|
1625
|
+
}
|
|
1626
|
+
function He(t, n, e) {
|
|
1627
|
+
Mt(e, {
|
|
1304
1628
|
p: "bigint",
|
|
1305
1629
|
m: "number",
|
|
1306
1630
|
k: "number",
|
|
1307
1631
|
hash: "function"
|
|
1308
1632
|
});
|
|
1309
|
-
const { p:
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
else if (
|
|
1633
|
+
const { p: r, k: o, m: i, hash: a, expand: f, DST: l } = e;
|
|
1634
|
+
if (Ft(a.outputLen, "valid hash"), st(t), Ft(n), n < 1) throw new Error("hash_to_field: expected count >= 1");
|
|
1635
|
+
if (i < 1) throw new Error("hash_to_field: expected m >= 1");
|
|
1636
|
+
const g = r.toString(2).length, s = Math.ceil((g + o) / 8), u = n * i * s;
|
|
1637
|
+
let d;
|
|
1638
|
+
if (f === "xmd") d = io(t, l, u, a);
|
|
1639
|
+
else if (f === "xof") d = so(t, l, u, o, a);
|
|
1640
|
+
else if (f === "_internal_pass") d = t;
|
|
1316
1641
|
else throw new Error('expand must be "xmd" or "xof"');
|
|
1317
|
-
const
|
|
1318
|
-
for (let
|
|
1319
|
-
const
|
|
1320
|
-
for (let
|
|
1321
|
-
const
|
|
1322
|
-
|
|
1323
|
-
}
|
|
1324
|
-
w
|
|
1325
|
-
}
|
|
1326
|
-
return
|
|
1327
|
-
}
|
|
1328
|
-
function
|
|
1329
|
-
const
|
|
1330
|
-
return (
|
|
1331
|
-
const [
|
|
1332
|
-
return
|
|
1333
|
-
x:
|
|
1642
|
+
const h = new Array(n);
|
|
1643
|
+
for (let w = 0; w < n; w++) {
|
|
1644
|
+
const b = new Array(i);
|
|
1645
|
+
for (let E = 0; E < i; E++) {
|
|
1646
|
+
const T = s * (E + w * i);
|
|
1647
|
+
b[E] = bt(ro(d.subarray(T, T + s)), r);
|
|
1648
|
+
}
|
|
1649
|
+
h[w] = b;
|
|
1650
|
+
}
|
|
1651
|
+
return h;
|
|
1652
|
+
}
|
|
1653
|
+
function co(t, n) {
|
|
1654
|
+
const e = n.map((r) => Array.from(r).reverse());
|
|
1655
|
+
return (r, o) => {
|
|
1656
|
+
const [i, a, f, l] = e.map((u) => u.reduce((d, h) => t.add(t.mul(d, r), h))), [g, s] = Ee(t, [a, l], !0);
|
|
1657
|
+
return r = t.mul(i, g), o = t.mul(o, t.mul(f, s)), {
|
|
1658
|
+
x: r,
|
|
1334
1659
|
y: o
|
|
1335
1660
|
};
|
|
1336
1661
|
};
|
|
1337
1662
|
}
|
|
1338
|
-
var
|
|
1339
|
-
function
|
|
1340
|
-
if (typeof
|
|
1341
|
-
|
|
1342
|
-
|
|
1663
|
+
var fo = "HashToScalar-";
|
|
1664
|
+
function ao(t, n, e) {
|
|
1665
|
+
if (typeof n != "function") throw new Error("mapToCurve() must be defined");
|
|
1666
|
+
const r = (f) => Object.freeze({
|
|
1667
|
+
...f,
|
|
1668
|
+
DST: oe(f.DST) ? Ze(f.DST) : f.DST,
|
|
1669
|
+
...f.encodeDST === void 0 ? {} : { encodeDST: oe(f.encodeDST) ? Ze(f.encodeDST) : f.encodeDST }
|
|
1670
|
+
}), o = r(e);
|
|
1671
|
+
function i(f) {
|
|
1672
|
+
return t.fromAffine(n(f));
|
|
1673
|
+
}
|
|
1674
|
+
function a(f) {
|
|
1675
|
+
const l = f.clearCofactor();
|
|
1676
|
+
return l.equals(t.ZERO) ? t.ZERO : (l.assertValidity(), l);
|
|
1343
1677
|
}
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
return {
|
|
1349
|
-
defaults: Object.freeze(r),
|
|
1678
|
+
return Object.freeze({
|
|
1679
|
+
get defaults() {
|
|
1680
|
+
return r(o);
|
|
1681
|
+
},
|
|
1350
1682
|
Point: t,
|
|
1351
|
-
hashToCurve(
|
|
1352
|
-
const
|
|
1353
|
-
return
|
|
1683
|
+
hashToCurve(f, l) {
|
|
1684
|
+
const g = He(f, 2, Object.assign({}, o, l)), s = i(g[0]), u = i(g[1]);
|
|
1685
|
+
return a(s.add(u));
|
|
1354
1686
|
},
|
|
1355
|
-
encodeToCurve(
|
|
1356
|
-
const
|
|
1357
|
-
return
|
|
1687
|
+
encodeToCurve(f, l) {
|
|
1688
|
+
const g = o.encodeDST ? { DST: o.encodeDST } : {};
|
|
1689
|
+
return a(i(He(f, 1, Object.assign({}, o, g, l))[0]));
|
|
1358
1690
|
},
|
|
1359
|
-
mapToCurve(
|
|
1360
|
-
if (
|
|
1361
|
-
if (typeof
|
|
1362
|
-
return
|
|
1691
|
+
mapToCurve(f) {
|
|
1692
|
+
if (o.m === 1) {
|
|
1693
|
+
if (typeof f != "bigint") throw new Error("expected bigint (m=1)");
|
|
1694
|
+
return a(i([f]));
|
|
1363
1695
|
}
|
|
1364
|
-
if (!Array.isArray(
|
|
1365
|
-
for (const
|
|
1366
|
-
return
|
|
1696
|
+
if (!Array.isArray(f)) throw new Error("expected array of bigints");
|
|
1697
|
+
for (const l of f) if (typeof l != "bigint") throw new Error("expected array of bigints");
|
|
1698
|
+
return a(i(f));
|
|
1367
1699
|
},
|
|
1368
|
-
hashToScalar(
|
|
1369
|
-
const
|
|
1370
|
-
return
|
|
1371
|
-
p:
|
|
1700
|
+
hashToScalar(f, l) {
|
|
1701
|
+
const g = t.Fn.ORDER;
|
|
1702
|
+
return He(f, 1, Object.assign({}, o, {
|
|
1703
|
+
p: g,
|
|
1372
1704
|
m: 1,
|
|
1373
|
-
DST:
|
|
1374
|
-
},
|
|
1705
|
+
DST: fo
|
|
1706
|
+
}, l))[0][0];
|
|
1375
1707
|
}
|
|
1376
|
-
};
|
|
1708
|
+
});
|
|
1377
1709
|
}
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1710
|
+
Qt();
|
|
1711
|
+
var fe = (t) => {
|
|
1712
|
+
if (!Number.isSafeInteger(t.min) || !Number.isSafeInteger(t.max)) throw new Error("Wrong signers info: min=" + t.min + " max=" + t.max);
|
|
1713
|
+
if (t.min < 2 || t.max < 2 || t.min > t.max) throw new Error("Wrong signers info: min=" + t.min + " max=" + t.max);
|
|
1714
|
+
}, pn = (t, n) => {
|
|
1715
|
+
if (n < t.min || n > t.max) throw new Error("Wrong number of commitments=" + n);
|
|
1716
|
+
}, ae = class extends Error {
|
|
1717
|
+
cheaters;
|
|
1718
|
+
constructor(t, n) {
|
|
1719
|
+
super(t), this.cheaters = n;
|
|
1720
|
+
}
|
|
1721
|
+
};
|
|
1722
|
+
function cr(t) {
|
|
1723
|
+
Mt(t, {
|
|
1724
|
+
name: "string",
|
|
1725
|
+
hash: "function"
|
|
1726
|
+
}, {
|
|
1727
|
+
hashToScalar: "function",
|
|
1728
|
+
validatePoint: "function",
|
|
1729
|
+
parsePublicKey: "function",
|
|
1730
|
+
adjustScalar: "function",
|
|
1731
|
+
adjustPoint: "function",
|
|
1732
|
+
challenge: "function",
|
|
1733
|
+
adjustNonces: "function",
|
|
1734
|
+
adjustSecret: "function",
|
|
1735
|
+
adjustPublic: "function",
|
|
1736
|
+
adjustGroupCommitmentShare: "function",
|
|
1737
|
+
adjustDKG: "function"
|
|
1738
|
+
}), Gr(t.Point);
|
|
1739
|
+
const { Point: n } = t, e = t.Fn === void 0 ? n.Fn : t.Fn, r = t.hash, o = t.hashToScalar === void 0 ? (c, m = { DST: new Uint8Array() }) => {
|
|
1740
|
+
const y = r(Q(m.DST, c));
|
|
1741
|
+
return e.create(e.isLE ? ge(y) : St(y));
|
|
1742
|
+
} : t.hashToScalar, i = Nt(t.H1 !== void 0 ? t.H1 : t.name + "rho"), a = Nt(t.H2 !== void 0 ? t.H2 : t.name + "chal"), f = Nt(t.H3 !== void 0 ? t.H3 : t.name + "nonce"), l = Nt(t.H4 !== void 0 ? t.H4 : t.name + "msg"), g = Nt(t.H5 !== void 0 ? t.H5 : t.name + "com"), s = Nt(t.HDKG !== void 0 ? t.HDKG : t.name + "dkg"), u = Nt(t.HID !== void 0 ? t.HID : t.name + "id"), d = (c) => o(c, { DST: i }), h = (c) => o(c, { DST: a }), w = (c) => o(c, { DST: f }), b = (c) => r(Q(l, c)), E = (c) => r(Q(g, c)), T = (c) => o(c, { DST: s }), B = (c) => o(c, { DST: u }), C = (c = wt) => {
|
|
1743
|
+
const m = nr(c(nn(e.ORDER)), e.ORDER, e.isLE);
|
|
1744
|
+
return e.isLE ? ge(m) : St(m);
|
|
1745
|
+
}, O = (c) => c.toBytes(), F = (c) => {
|
|
1746
|
+
const m = n.fromBytes(c);
|
|
1747
|
+
return t.validatePoint && t.validatePoint(m), m;
|
|
1748
|
+
}, z = (c, m) => ({
|
|
1749
|
+
identifier: c,
|
|
1750
|
+
hiding: O(n.BASE.multiply(e.fromBytes(m.hiding))),
|
|
1751
|
+
binding: O(n.BASE.multiply(e.fromBytes(m.binding)))
|
|
1752
|
+
}), W = t.adjustPoint === void 0 ? (c) => c : t.adjustPoint, N = (c) => {
|
|
1753
|
+
if (!e.isValid(c) || e.is0(c)) throw new Error("Invalid identifier " + c);
|
|
1754
|
+
return c;
|
|
1755
|
+
}, V = (c) => Ct(e.toBytes(N(c))), K = (c) => {
|
|
1756
|
+
const m = N(e.fromBytes(he(c)));
|
|
1757
|
+
if (V(m) !== c) throw new Error("expected canonical identifier hex");
|
|
1758
|
+
return m;
|
|
1759
|
+
}, M = {
|
|
1760
|
+
encode: (c, m) => {
|
|
1761
|
+
let y = Q(O(c), e.toBytes(m));
|
|
1762
|
+
return t.adjustTx && (y = t.adjustTx.encode(y)), y;
|
|
1763
|
+
},
|
|
1764
|
+
decode: (c) => (t.adjustTx && (c = t.adjustTx.decode(c)), {
|
|
1765
|
+
R: F(c.subarray(0, -e.BYTES)),
|
|
1766
|
+
z: e.fromBytes(c.subarray(-e.BYTES))
|
|
1767
|
+
})
|
|
1768
|
+
}, v = (c = wt) => {
|
|
1769
|
+
let m = C(c);
|
|
1770
|
+
t.adjustScalar && (m = t.adjustScalar(m));
|
|
1771
|
+
let y = n.BASE.multiply(m);
|
|
1772
|
+
return {
|
|
1773
|
+
scalar: m,
|
|
1774
|
+
point: y
|
|
1775
|
+
};
|
|
1776
|
+
}, H = "roots are unavailable in FROST polynomial mode", U = no(e, {
|
|
1777
|
+
info: {
|
|
1778
|
+
G: e.ZERO,
|
|
1779
|
+
oddFactor: e.ZERO,
|
|
1780
|
+
powerOfTwo: 0
|
|
1781
|
+
},
|
|
1782
|
+
roots() {
|
|
1783
|
+
throw new Error(H);
|
|
1784
|
+
},
|
|
1785
|
+
brp() {
|
|
1786
|
+
throw new Error(H);
|
|
1787
|
+
},
|
|
1788
|
+
inverse() {
|
|
1789
|
+
throw new Error(H);
|
|
1790
|
+
},
|
|
1791
|
+
omega() {
|
|
1792
|
+
throw new Error(H);
|
|
1793
|
+
},
|
|
1794
|
+
clear() {
|
|
1795
|
+
}
|
|
1796
|
+
}), S = (c, m) => Qr(n, c, m), p = (c, m) => {
|
|
1797
|
+
if (!m.length) throw new Error("empty coefficients");
|
|
1798
|
+
return U.monomial.eval(m, c);
|
|
1799
|
+
}, R = (c, m) => {
|
|
1800
|
+
const y = "invalid parameters";
|
|
1801
|
+
if (!c.some((L) => e.eql(L, m))) throw new Error(y);
|
|
1802
|
+
const x = new Set(c);
|
|
1803
|
+
if (x.size !== c.length) throw new Error(y);
|
|
1804
|
+
if (!x.has(m)) throw new Error(y);
|
|
1805
|
+
let A = e.ONE, j = e.ONE;
|
|
1806
|
+
for (const L of c)
|
|
1807
|
+
e.eql(L, m) || (A = e.mul(A, L), j = e.mul(j, e.sub(L, m)));
|
|
1808
|
+
return e.div(A, j);
|
|
1809
|
+
}, I = (c, m) => S(m, U.monomial.basis(c, m.length)), _ = (c, m, y, x = wt) => {
|
|
1810
|
+
fe(c);
|
|
1811
|
+
const A = m === void 0 ? C(x) : e.fromBytes(m);
|
|
1812
|
+
if (!y) {
|
|
1813
|
+
y = [];
|
|
1814
|
+
for (let L = 0; L < c.min - 1; L++) y.push(C(x));
|
|
1815
|
+
}
|
|
1816
|
+
if (y.length !== c.min - 1) throw new Error("wrong coefficients length");
|
|
1817
|
+
const j = [A, ...y];
|
|
1818
|
+
return {
|
|
1819
|
+
coefficients: j,
|
|
1820
|
+
commitment: j.map((L) => n.BASE.multiply(L)),
|
|
1821
|
+
secret: A
|
|
1822
|
+
};
|
|
1823
|
+
}, D = {
|
|
1824
|
+
challenge: (c, m, y) => T(Q(e.toBytes(c), O(m), O(y))),
|
|
1825
|
+
compute(c, m, y, x = wt) {
|
|
1826
|
+
if (m.length < 1) throw new Error("coefficients should have at least one element");
|
|
1827
|
+
const { point: A, scalar: j } = v(x), L = y[0], P = this.challenge(c, L, A), k = e.add(j, e.mul(m[0], P));
|
|
1828
|
+
return M.encode(A, k);
|
|
1829
|
+
},
|
|
1830
|
+
validate(c, m, y) {
|
|
1831
|
+
if (m.length < 1) throw new Error("commitment should have at least one element");
|
|
1832
|
+
const { R: x, z: A } = M.decode(y), j = F(m[0]), L = this.challenge(c, j, x);
|
|
1833
|
+
if (!x.equals(n.BASE.multiply(A).subtract(j.multiply(L)))) throw new Error("invalid proof of knowledge");
|
|
1834
|
+
}
|
|
1835
|
+
}, q = {
|
|
1836
|
+
challenge: (c, m, y) => t.challenge ? t.challenge(c, m, y) : h(Q(O(c), O(m), y)),
|
|
1837
|
+
sign(c, m, y = wt) {
|
|
1838
|
+
const { point: x, scalar: A } = v(y), j = n.BASE.multiply(m), L = this.challenge(x, j, c);
|
|
1839
|
+
return [x, e.add(A, e.mul(L, m))];
|
|
1840
|
+
},
|
|
1841
|
+
verify(c, m, y, x) {
|
|
1842
|
+
t.adjustPoint && (x = t.adjustPoint(x)), t.adjustPoint && (m = t.adjustPoint(m));
|
|
1843
|
+
const A = this.challenge(m, x, c), j = n.BASE.multiply(y), L = x.multiply(A);
|
|
1844
|
+
let P = j.subtract(L).subtract(m);
|
|
1845
|
+
return P.clearCofactor && (P = P.clearCofactor()), n.ZERO.equals(P);
|
|
1846
|
+
}
|
|
1847
|
+
}, X = (c, m, y) => {
|
|
1848
|
+
if (!n.BASE.multiply(y).equals(I(c, m))) throw new Error("invalid secret share");
|
|
1849
|
+
}, Y = {
|
|
1850
|
+
fromNumber(c) {
|
|
1851
|
+
if (!Number.isSafeInteger(c)) throw new Error("expected safe interger");
|
|
1852
|
+
return V(BigInt(c));
|
|
1853
|
+
},
|
|
1854
|
+
derive(c) {
|
|
1855
|
+
if (typeof c != "string") throw new Error("wrong identifier string: " + c);
|
|
1856
|
+
return V(B(Nt(c)));
|
|
1857
|
+
}
|
|
1858
|
+
}, Z = (c, m = wt) => w(Q(m(32), e.toBytes(c))), nt = (c, m, y) => {
|
|
1859
|
+
const x = m.map((tt) => [
|
|
1860
|
+
tt.identifier,
|
|
1861
|
+
K(tt.identifier),
|
|
1862
|
+
F(tt.hiding),
|
|
1863
|
+
F(tt.binding)
|
|
1864
|
+
]);
|
|
1865
|
+
x.sort((tt, ht) => tt[1] < ht[1] ? -1 : tt[1] > ht[1] ? 1 : 0);
|
|
1866
|
+
const A = [];
|
|
1867
|
+
for (const [tt, ht, $, et] of x) A.push(e.toBytes(ht), O($), O(et));
|
|
1868
|
+
const j = E(Q(...A)), L = Q(O(c), b(y), j), P = {};
|
|
1869
|
+
for (const [tt, ht] of x) P[tt] = d(Q(L, e.toBytes(ht)));
|
|
1870
|
+
const k = [], G = [];
|
|
1871
|
+
for (const [tt, ht, $, et] of x) {
|
|
1872
|
+
if (n.ZERO.equals($) || n.ZERO.equals(et)) throw new Error("infinity commitment");
|
|
1873
|
+
k.push($, et), G.push(e.ONE, P[tt]);
|
|
1874
|
+
}
|
|
1875
|
+
const mt = S(k, G);
|
|
1876
|
+
return {
|
|
1877
|
+
identifiers: x.map((tt) => tt[1]),
|
|
1878
|
+
groupCommitment: mt,
|
|
1879
|
+
bindingFactors: P
|
|
1880
|
+
};
|
|
1881
|
+
}, rt = (c, m, y, x) => {
|
|
1882
|
+
const A = W(F(c)), j = K(x), { identifiers: L, groupCommitment: P, bindingFactors: k } = nt(A, m, y), G = k[x];
|
|
1883
|
+
return {
|
|
1884
|
+
lambda: R(L, j),
|
|
1885
|
+
challenge: q.challenge(P, A, y),
|
|
1886
|
+
bindingFactor: G,
|
|
1887
|
+
groupCommitment: P
|
|
1888
|
+
};
|
|
1889
|
+
};
|
|
1890
|
+
Object.freeze(Y);
|
|
1891
|
+
const it = {
|
|
1892
|
+
Identifier: Y,
|
|
1893
|
+
DKG: Object.freeze({
|
|
1894
|
+
round1: (c, m, y, x = wt) => {
|
|
1895
|
+
fe(m);
|
|
1896
|
+
const A = K(c), { coefficients: j, commitment: L } = _(m, y, void 0, x), P = D.compute(A, j, L, x), k = L.map(O);
|
|
1897
|
+
return {
|
|
1898
|
+
public: {
|
|
1899
|
+
identifier: V(A),
|
|
1900
|
+
commitment: k,
|
|
1901
|
+
proofOfKnowledge: P
|
|
1902
|
+
},
|
|
1903
|
+
secret: {
|
|
1904
|
+
identifier: A,
|
|
1905
|
+
coefficients: j,
|
|
1906
|
+
commitment: L.map(O),
|
|
1907
|
+
signers: {
|
|
1908
|
+
min: m.min,
|
|
1909
|
+
max: m.max
|
|
1910
|
+
},
|
|
1911
|
+
step: 1
|
|
1912
|
+
}
|
|
1913
|
+
};
|
|
1914
|
+
},
|
|
1915
|
+
round2: (c, m) => {
|
|
1916
|
+
if (m.length !== c.signers.max - 1) throw new Error("wrong number of round1 packages");
|
|
1917
|
+
if (!c.coefficients || c.step === 3) throw new Error("round3 package used in round2");
|
|
1918
|
+
const y = {};
|
|
1919
|
+
for (const x of m) {
|
|
1920
|
+
if (x.commitment.length !== c.signers.min) throw new Error("wrong number of commitments");
|
|
1921
|
+
const A = K(x.identifier);
|
|
1922
|
+
if (A === c.identifier) throw new Error("duplicate id=" + V(A));
|
|
1923
|
+
D.validate(A, x.commitment, x.proofOfKnowledge);
|
|
1924
|
+
for (const L of x.commitment) F(L);
|
|
1925
|
+
if (y[x.identifier]) throw new Error("Duplicate id=" + A);
|
|
1926
|
+
const j = e.toBytes(p(A, c.coefficients));
|
|
1927
|
+
y[x.identifier] = {
|
|
1928
|
+
identifier: V(c.identifier),
|
|
1929
|
+
signingShare: j
|
|
1930
|
+
};
|
|
1931
|
+
}
|
|
1932
|
+
return c.step = 2, y;
|
|
1933
|
+
},
|
|
1934
|
+
round3: (c, m, y) => {
|
|
1935
|
+
if (m.length !== c.signers.max - 1) throw new Error("wrong length of round1 packages");
|
|
1936
|
+
if (!c.coefficients || c.step !== 2) throw new Error("round2 package used in round3");
|
|
1937
|
+
if (y.length !== m.length) throw new Error("wrong length of round2 packages");
|
|
1938
|
+
const x = {};
|
|
1939
|
+
for (const $ of m) {
|
|
1940
|
+
if (!$.identifier || !$.commitment) throw new Error("wrong round1 share");
|
|
1941
|
+
x[$.identifier] = { ...$ };
|
|
1942
|
+
}
|
|
1943
|
+
for (const $ of y) {
|
|
1944
|
+
if (!$.identifier || !$.signingShare) throw new Error("wrong round2 share");
|
|
1945
|
+
if (!x[$.identifier]) throw new Error("round1 share for " + $.identifier + " is missing");
|
|
1946
|
+
x[$.identifier].signingShare = $.signingShare;
|
|
1947
|
+
}
|
|
1948
|
+
if (Object.keys(x).length !== m.length) throw new Error("mismatch identifiers between rounds");
|
|
1949
|
+
let A = e.ZERO;
|
|
1950
|
+
if (c.commitment.length !== c.signers.min) throw new Error("wrong commitments length");
|
|
1951
|
+
const j = c.commitment.map(F), L = p(c.identifier, c.coefficients);
|
|
1952
|
+
X(c.identifier, j, L);
|
|
1953
|
+
const P = j.map(O), k = { [V(c.identifier)]: P };
|
|
1954
|
+
for (const $ in x) {
|
|
1955
|
+
const et = x[$];
|
|
1956
|
+
if (!et.signingShare || !et.commitment) throw new Error("mismatch identifiers");
|
|
1957
|
+
const pt = K($), Gt = e.fromBytes(et.signingShare), xe = et.commitment.map(F);
|
|
1958
|
+
X(c.identifier, xe, Gt), A = e.add(A, Gt);
|
|
1959
|
+
const Jt = V(pt);
|
|
1960
|
+
if (k[Jt]) throw new Error("duplicated id=" + Jt);
|
|
1961
|
+
k[Jt] = et.commitment;
|
|
1962
|
+
}
|
|
1963
|
+
A = e.add(A, L);
|
|
1964
|
+
const G = new Array(c.signers.min).fill(n.ZERO);
|
|
1965
|
+
for (const $ in k) {
|
|
1966
|
+
const et = k[$];
|
|
1967
|
+
if (et.length !== c.signers.min) throw new Error("wrong commitments length");
|
|
1968
|
+
for (let pt = 0; pt < et.length; pt++) G[pt] = G[pt].add(F(et[pt]));
|
|
1969
|
+
}
|
|
1970
|
+
const mt = G.map(O), tt = {};
|
|
1971
|
+
for (const $ in k) tt[$] = O(I(K($), G));
|
|
1972
|
+
let ht = {
|
|
1973
|
+
public: {
|
|
1974
|
+
signers: {
|
|
1975
|
+
min: c.signers.min,
|
|
1976
|
+
max: c.signers.max
|
|
1977
|
+
},
|
|
1978
|
+
commitments: mt,
|
|
1979
|
+
verifyingShares: Object.fromEntries(Object.entries(tt).map(([$, et]) => [$, et.slice()]))
|
|
1980
|
+
},
|
|
1981
|
+
secret: {
|
|
1982
|
+
identifier: V(c.identifier),
|
|
1983
|
+
signingShare: e.toBytes(A)
|
|
1984
|
+
}
|
|
1985
|
+
};
|
|
1986
|
+
t.adjustDKG && (ht = t.adjustDKG(ht));
|
|
1987
|
+
for (let $ = 0; $ < c.coefficients.length; $++) c.coefficients[$] -= c.coefficients[$];
|
|
1988
|
+
return delete c.coefficients, c.step = 3, ht;
|
|
1989
|
+
},
|
|
1990
|
+
clean(c) {
|
|
1991
|
+
if (c.identifier -= c.identifier, c.coefficients) for (let m = 0; m < c.coefficients.length; m++) c.coefficients[m] -= c.coefficients[m];
|
|
1992
|
+
c.step = 3;
|
|
1993
|
+
}
|
|
1994
|
+
}),
|
|
1995
|
+
trustedDealer(c, m, y, x = wt) {
|
|
1996
|
+
if (fe(c), m === void 0) {
|
|
1997
|
+
m = [];
|
|
1998
|
+
for (let G = 1; G <= c.max; G++) m.push(Y.fromNumber(G));
|
|
1999
|
+
} else if (!Array.isArray(m) || m.length !== c.max) throw new Error("identifiers should be array of " + c.max);
|
|
2000
|
+
const A = {};
|
|
2001
|
+
for (const G of m) {
|
|
2002
|
+
const mt = K(G);
|
|
2003
|
+
if (G in A) throw new Error("duplicated id=" + G);
|
|
2004
|
+
A[G] = mt;
|
|
2005
|
+
}
|
|
2006
|
+
const j = _(c, y, void 0, x), L = j.commitment.map(O), P = {}, k = {};
|
|
2007
|
+
for (const G of m) {
|
|
2008
|
+
const mt = p(A[G], j.coefficients);
|
|
2009
|
+
k[G] = O(n.BASE.multiply(mt)), P[G] = {
|
|
2010
|
+
identifier: G,
|
|
2011
|
+
signingShare: e.toBytes(mt)
|
|
2012
|
+
};
|
|
2013
|
+
}
|
|
2014
|
+
return {
|
|
2015
|
+
public: {
|
|
2016
|
+
signers: {
|
|
2017
|
+
min: c.min,
|
|
2018
|
+
max: c.max
|
|
2019
|
+
},
|
|
2020
|
+
commitments: L,
|
|
2021
|
+
verifyingShares: k
|
|
2022
|
+
},
|
|
2023
|
+
secretShares: P
|
|
2024
|
+
};
|
|
2025
|
+
},
|
|
2026
|
+
validateSecret(c, m) {
|
|
2027
|
+
X(K(c.identifier), m.commitments.map(F), e.fromBytes(c.signingShare));
|
|
2028
|
+
},
|
|
2029
|
+
commit(c, m = wt) {
|
|
2030
|
+
const y = e.fromBytes(c.signingShare), x = Z(y, m), A = Z(y, m), j = {
|
|
2031
|
+
hiding: e.toBytes(x),
|
|
2032
|
+
binding: e.toBytes(A)
|
|
2033
|
+
};
|
|
2034
|
+
return {
|
|
2035
|
+
nonces: j,
|
|
2036
|
+
commitments: z(c.identifier, j)
|
|
2037
|
+
};
|
|
2038
|
+
},
|
|
2039
|
+
signShare(c, m, y, x, A) {
|
|
2040
|
+
pn(m.signers, x.length);
|
|
2041
|
+
const j = e.fromBytes(y.hiding), L = e.fromBytes(y.binding);
|
|
2042
|
+
if (e.is0(j) || e.is0(L)) throw new Error("signing nonces already used");
|
|
2043
|
+
const P = {
|
|
2044
|
+
identifier: c.identifier,
|
|
2045
|
+
hiding: O(n.BASE.multiply(j)),
|
|
2046
|
+
binding: O(n.BASE.multiply(L))
|
|
2047
|
+
}, k = x.find((wr) => wr.identifier === c.identifier);
|
|
2048
|
+
if (!k) throw new Error("missing signer commitment");
|
|
2049
|
+
if (Ct(k.hiding) !== Ct(P.hiding) || Ct(k.binding) !== Ct(P.binding)) throw new Error("incorrect signer commitment");
|
|
2050
|
+
t.adjustSecret && (c = t.adjustSecret(c, m)), t.adjustPublic && (m = t.adjustPublic(m));
|
|
2051
|
+
const G = e.fromBytes(c.signingShare), { lambda: mt, challenge: tt, bindingFactor: ht, groupCommitment: $ } = rt(m.commitments[0], x, A, c.identifier), et = t.adjustNonces ? t.adjustNonces($, y) : y, pt = t.adjustNonces ? e.fromBytes(et.hiding) : j, Gt = t.adjustNonces ? e.fromBytes(et.binding) : L, xe = e.mul(e.mul(mt, G), tt), Jt = e.mul(Gt, ht), gr = e.toBytes(e.add(e.add(pt, Jt), xe));
|
|
2052
|
+
return y.hiding.fill(0), y.binding.fill(0), gr;
|
|
2053
|
+
},
|
|
2054
|
+
verifyShare(c, m, y, x, A) {
|
|
2055
|
+
t.adjustPublic && (c = t.adjustPublic(c));
|
|
2056
|
+
const j = m.find((Gt) => Gt.identifier === x);
|
|
2057
|
+
if (!j) throw new Error("cannot find identifier commitment");
|
|
2058
|
+
const L = F(c.verifyingShares[x]), P = F(j.hiding), k = F(j.binding), { lambda: G, challenge: mt, bindingFactor: tt, groupCommitment: ht } = rt(c.commitments[0], m, y, x);
|
|
2059
|
+
let $ = P.add(k.multiply(tt));
|
|
2060
|
+
t.adjustGroupCommitmentShare && ($ = t.adjustGroupCommitmentShare(ht, $));
|
|
2061
|
+
const et = n.BASE.multiply(e.fromBytes(A)), pt = $.add(L.multiply(e.mul(mt, G)));
|
|
2062
|
+
return et.equals(pt);
|
|
2063
|
+
},
|
|
2064
|
+
aggregate(c, m, y, x) {
|
|
2065
|
+
t.adjustPublic && (c = t.adjustPublic(c));
|
|
2066
|
+
try {
|
|
2067
|
+
pn(c.signers, m.length);
|
|
2068
|
+
} catch {
|
|
2069
|
+
throw new ae("aggregation failed", []);
|
|
2070
|
+
}
|
|
2071
|
+
const A = m.map((k) => k.identifier);
|
|
2072
|
+
if (A.length !== Object.keys(x).length) throw new ae("aggregation failed", []);
|
|
2073
|
+
for (const k of A) if (!(k in x) || !(k in c.verifyingShares)) throw new ae("aggregation failed", []);
|
|
2074
|
+
const j = F(c.commitments[0]), { groupCommitment: L } = nt(j, m, y);
|
|
2075
|
+
let P = e.ZERO;
|
|
2076
|
+
for (const k of A) P = e.add(P, e.fromBytes(x[k]));
|
|
2077
|
+
if (!q.verify(y, L, P, j)) {
|
|
2078
|
+
const k = [];
|
|
2079
|
+
for (const G of A) this.verifyShare(c, m, y, G, x[G]) || k.push(G);
|
|
2080
|
+
throw new ae("aggregation failed", k);
|
|
2081
|
+
}
|
|
2082
|
+
return M.encode(L, P);
|
|
2083
|
+
},
|
|
2084
|
+
sign(c, m) {
|
|
2085
|
+
let y = e.fromBytes(m);
|
|
2086
|
+
t.adjustScalar && (y = t.adjustScalar(y));
|
|
2087
|
+
const [x, A] = q.sign(c, y);
|
|
2088
|
+
return M.encode(x, A);
|
|
2089
|
+
},
|
|
2090
|
+
verify(c, m, y) {
|
|
2091
|
+
const x = t.parsePublicKey ? t.parsePublicKey(y) : F(y), { R: A, z: j } = M.decode(c);
|
|
2092
|
+
return q.verify(m, A, j, x);
|
|
2093
|
+
},
|
|
2094
|
+
combineSecret(c, m) {
|
|
2095
|
+
if (fe(m), !Array.isArray(c) || c.length < m.min) throw new Error("wrong secret shares array");
|
|
2096
|
+
const y = [], x = {};
|
|
2097
|
+
for (const L of c) {
|
|
2098
|
+
const P = K(L.identifier), k = V(P);
|
|
2099
|
+
if (x[k]) throw new Error("duplicated id=" + k);
|
|
2100
|
+
x[k] = !0, y.push([P, e.fromBytes(L.signingShare)]);
|
|
2101
|
+
}
|
|
2102
|
+
const A = y.map(([L]) => L);
|
|
2103
|
+
let j = e.ZERO;
|
|
2104
|
+
for (const [L, P] of y) j = e.add(j, e.mul(P, R(A, L)));
|
|
2105
|
+
return e.toBytes(j);
|
|
2106
|
+
},
|
|
2107
|
+
utils: Object.freeze({
|
|
2108
|
+
Fn: e,
|
|
2109
|
+
randomScalar: (c = wt) => e.toBytes(v(c).scalar),
|
|
2110
|
+
generateSecretPolynomial: (c, m, y, x) => {
|
|
2111
|
+
const A = _(c, m, y, x);
|
|
2112
|
+
return {
|
|
2113
|
+
...A,
|
|
2114
|
+
commitment: A.commitment.map(O)
|
|
2115
|
+
};
|
|
2116
|
+
}
|
|
2117
|
+
})
|
|
2118
|
+
};
|
|
2119
|
+
return Object.freeze(it);
|
|
2120
|
+
}
|
|
2121
|
+
Er();
|
|
2122
|
+
Qt();
|
|
2123
|
+
var En = (t, n) => (t + (t >= 0 ? n : -n) / Bt) / n;
|
|
2124
|
+
function lo(t, n, e) {
|
|
2125
|
+
Mn("scalar", t, yt, e);
|
|
2126
|
+
const [[r, o], [i, a]] = n, f = En(a * t, e), l = En(-o * t, e);
|
|
2127
|
+
let g = t - f * r - l * i, s = -f * o - l * a;
|
|
2128
|
+
const u = g < yt, d = s < yt;
|
|
2129
|
+
u && (g = -g), d && (s = -s);
|
|
2130
|
+
const h = pe(Math.ceil(ye(e) / 2)) + ct;
|
|
2131
|
+
if (g < yt || g >= h || s < yt || s >= h) throw new Error("splitScalar (endomorphism): failed for k");
|
|
1389
2132
|
return {
|
|
1390
|
-
k1neg:
|
|
1391
|
-
k1:
|
|
1392
|
-
k2neg:
|
|
1393
|
-
k2:
|
|
2133
|
+
k1neg: u,
|
|
2134
|
+
k1: g,
|
|
2135
|
+
k2neg: d,
|
|
2136
|
+
k2: s
|
|
1394
2137
|
};
|
|
1395
2138
|
}
|
|
1396
|
-
function
|
|
2139
|
+
function ze(t) {
|
|
1397
2140
|
if (![
|
|
1398
2141
|
"compact",
|
|
1399
2142
|
"recovered",
|
|
@@ -1401,88 +2144,96 @@ function Ee(t) {
|
|
|
1401
2144
|
].includes(t)) throw new Error('Signature format must be "compact", "recovered", or "der"');
|
|
1402
2145
|
return t;
|
|
1403
2146
|
}
|
|
1404
|
-
function
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
2147
|
+
function Te(t, n) {
|
|
2148
|
+
Mt(t);
|
|
2149
|
+
const e = {};
|
|
2150
|
+
for (let r of Object.keys(n)) e[r] = t[r] === void 0 ? n[r] : t[r];
|
|
2151
|
+
return ie(e.lowS, "lowS"), ie(e.prehash, "prehash"), e.format !== void 0 && ze(e.format), e;
|
|
1408
2152
|
}
|
|
1409
|
-
var
|
|
2153
|
+
var uo = class extends Error {
|
|
1410
2154
|
constructor(t = "") {
|
|
1411
2155
|
super(t);
|
|
1412
2156
|
}
|
|
1413
|
-
},
|
|
1414
|
-
Err:
|
|
2157
|
+
}, Et = {
|
|
2158
|
+
Err: uo,
|
|
1415
2159
|
_tlv: {
|
|
1416
|
-
encode: (t,
|
|
1417
|
-
const { Err:
|
|
1418
|
-
if (t < 0 || t >
|
|
1419
|
-
if (
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
2160
|
+
encode: (t, n) => {
|
|
2161
|
+
const { Err: e } = Et;
|
|
2162
|
+
if (Ft(t, "tag"), t < 0 || t > 255) throw new e("tlv.encode: wrong tag");
|
|
2163
|
+
if (typeof n != "string") throw new TypeError('"data" expected string, got type=' + typeof n);
|
|
2164
|
+
if (n.length & 1) throw new e("tlv.encode: unpadded data");
|
|
2165
|
+
const r = n.length / 2, o = ce(r);
|
|
2166
|
+
if (o.length / 2 & 128) throw new e("tlv.encode: long form length too big");
|
|
2167
|
+
const i = r > 127 ? ce(o.length / 2 | 128) : "";
|
|
2168
|
+
return ce(t) + i + o + n;
|
|
1424
2169
|
},
|
|
1425
|
-
decode(t,
|
|
1426
|
-
const { Err:
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
if (
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
2170
|
+
decode(t, n) {
|
|
2171
|
+
const { Err: e } = Et;
|
|
2172
|
+
n = st(n, void 0, "DER data");
|
|
2173
|
+
let r = 0;
|
|
2174
|
+
if (t < 0 || t > 255) throw new e("tlv.encode: wrong tag");
|
|
2175
|
+
if (n.length < 2 || n[r++] !== t) throw new e("tlv.decode: wrong tlv");
|
|
2176
|
+
const o = n[r++], i = !!(o & 128);
|
|
2177
|
+
let a = 0;
|
|
2178
|
+
if (!i) a = o;
|
|
1433
2179
|
else {
|
|
1434
|
-
const
|
|
1435
|
-
if (!
|
|
1436
|
-
if (
|
|
1437
|
-
const
|
|
1438
|
-
if (
|
|
1439
|
-
if (
|
|
1440
|
-
for (const
|
|
1441
|
-
if (
|
|
2180
|
+
const l = o & 127;
|
|
2181
|
+
if (!l) throw new e("tlv.decode(long): indefinite length not supported");
|
|
2182
|
+
if (l > 4) throw new e("tlv.decode(long): byte length is too big");
|
|
2183
|
+
const g = n.subarray(r, r + l);
|
|
2184
|
+
if (g.length !== l) throw new e("tlv.decode: length bytes not complete");
|
|
2185
|
+
if (g[0] === 0) throw new e("tlv.decode(long): zero leftmost byte");
|
|
2186
|
+
for (const s of g) a = a << 8 | s;
|
|
2187
|
+
if (r += l, a < 128) throw new e("tlv.decode(long): not minimal encoding");
|
|
1442
2188
|
}
|
|
1443
|
-
const
|
|
1444
|
-
if (
|
|
2189
|
+
const f = n.subarray(r, r + a);
|
|
2190
|
+
if (f.length !== a) throw new e("tlv.decode: wrong value length");
|
|
1445
2191
|
return {
|
|
1446
|
-
v:
|
|
1447
|
-
l:
|
|
2192
|
+
v: f,
|
|
2193
|
+
l: n.subarray(r + a)
|
|
1448
2194
|
};
|
|
1449
2195
|
}
|
|
1450
2196
|
},
|
|
1451
2197
|
_int: {
|
|
1452
2198
|
encode(t) {
|
|
1453
|
-
const { Err:
|
|
1454
|
-
if (t <
|
|
1455
|
-
let
|
|
1456
|
-
if (Number.parseInt(
|
|
1457
|
-
return
|
|
2199
|
+
const { Err: n } = Et;
|
|
2200
|
+
if (Je(t), t < yt) throw new n("integer: negative integers are not allowed");
|
|
2201
|
+
let e = ce(t);
|
|
2202
|
+
if (Number.parseInt(e[0], 16) & 8 && (e = "00" + e), e.length & 1) throw new n("unexpected DER parsing assertion: unpadded hex");
|
|
2203
|
+
return e;
|
|
1458
2204
|
},
|
|
1459
2205
|
decode(t) {
|
|
1460
|
-
const { Err:
|
|
1461
|
-
if (t
|
|
1462
|
-
if (t[0]
|
|
1463
|
-
|
|
2206
|
+
const { Err: n } = Et;
|
|
2207
|
+
if (t.length < 1) throw new n("invalid signature integer: empty");
|
|
2208
|
+
if (t[0] & 128) throw new n("invalid signature integer: negative");
|
|
2209
|
+
if (t.length > 1 && t[0] === 0 && !(t[1] & 128)) throw new n("invalid signature integer: unnecessary leading zero");
|
|
2210
|
+
return St(t);
|
|
1464
2211
|
}
|
|
1465
2212
|
},
|
|
1466
2213
|
toSig(t) {
|
|
1467
|
-
const { Err:
|
|
1468
|
-
if (
|
|
1469
|
-
const { v:
|
|
1470
|
-
if (
|
|
2214
|
+
const { Err: n, _int: e, _tlv: r } = Et, o = st(t, void 0, "signature"), { v: i, l: a } = r.decode(48, o);
|
|
2215
|
+
if (a.length) throw new n("invalid signature: left bytes after parsing");
|
|
2216
|
+
const { v: f, l } = r.decode(2, i), { v: g, l: s } = r.decode(2, l);
|
|
2217
|
+
if (s.length) throw new n("invalid signature: left bytes after parsing");
|
|
1471
2218
|
return {
|
|
1472
|
-
r:
|
|
1473
|
-
s:
|
|
2219
|
+
r: e.decode(f),
|
|
2220
|
+
s: e.decode(g)
|
|
1474
2221
|
};
|
|
1475
2222
|
},
|
|
1476
2223
|
hexFromSig(t) {
|
|
1477
|
-
const { _tlv:
|
|
1478
|
-
return
|
|
1479
|
-
}
|
|
1480
|
-
}
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
2224
|
+
const { _tlv: n, _int: e } = Et, r = n.encode(2, e.encode(t.r)) + n.encode(2, e.encode(t.s));
|
|
2225
|
+
return n.encode(48, r);
|
|
2226
|
+
}
|
|
2227
|
+
};
|
|
2228
|
+
Object.freeze(Et._tlv);
|
|
2229
|
+
Object.freeze(Et._int);
|
|
2230
|
+
Object.freeze(Et);
|
|
2231
|
+
var yt = /* @__PURE__ */ BigInt(0), ct = /* @__PURE__ */ BigInt(1), Bt = /* @__PURE__ */ BigInt(2), Xt = /* @__PURE__ */ BigInt(3), Me = /* @__PURE__ */ BigInt(4);
|
|
2232
|
+
function ho(t, n = {}) {
|
|
2233
|
+
const e = Jr("weierstrass", t, n), r = e.Fp, o = e.Fn;
|
|
2234
|
+
let i = e.CURVE;
|
|
2235
|
+
const { h: a, n: f } = i;
|
|
2236
|
+
Mt(n, {}, {
|
|
1486
2237
|
allowInfinityPoint: "boolean",
|
|
1487
2238
|
clearCofactor: "function",
|
|
1488
2239
|
isTorsionFree: "function",
|
|
@@ -1490,127 +2241,103 @@ function Er(t, e = {}) {
|
|
|
1490
2241
|
toBytes: "function",
|
|
1491
2242
|
endo: "object"
|
|
1492
2243
|
});
|
|
1493
|
-
const { endo:
|
|
1494
|
-
if (
|
|
2244
|
+
const { endo: l, allowInfinityPoint: g } = n;
|
|
2245
|
+
if (l && (!r.is0(i.a) || typeof l.beta != "bigint" || !Array.isArray(l.basises)))
|
|
1495
2246
|
throw new Error('invalid endo: expected "beta": bigint and "basises": array');
|
|
1496
|
-
const
|
|
1497
|
-
function
|
|
1498
|
-
if (!
|
|
1499
|
-
}
|
|
1500
|
-
function
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
2247
|
+
const s = ar(r, o);
|
|
2248
|
+
function u() {
|
|
2249
|
+
if (!r.isOdd) throw new Error("compression is not supported: Field does not have .isOdd()");
|
|
2250
|
+
}
|
|
2251
|
+
function d(M, v, H) {
|
|
2252
|
+
if (g && v.is0()) return Uint8Array.of(0);
|
|
2253
|
+
const { x: U, y: S } = v.toAffine(), p = r.toBytes(U);
|
|
2254
|
+
return ie(H, "isCompressed"), H ? (u(), Q(fr(!r.isOdd(S)), p)) : Q(Uint8Array.of(4), p, r.toBytes(S));
|
|
2255
|
+
}
|
|
2256
|
+
function h(M) {
|
|
2257
|
+
st(M, void 0, "Point");
|
|
2258
|
+
const { publicKey: v, publicKeyUncompressed: H } = s, U = M.length, S = M[0], p = M.subarray(1);
|
|
2259
|
+
if (g && U === 1 && S === 0) return {
|
|
2260
|
+
x: r.ZERO,
|
|
2261
|
+
y: r.ZERO
|
|
2262
|
+
};
|
|
2263
|
+
if (U === v && (S === 2 || S === 3)) {
|
|
2264
|
+
const R = r.fromBytes(p);
|
|
2265
|
+
if (!r.isValid(R)) throw new Error("bad point: is not on curve, wrong x");
|
|
2266
|
+
const I = E(R);
|
|
2267
|
+
let _;
|
|
1512
2268
|
try {
|
|
1513
|
-
|
|
1514
|
-
} catch (
|
|
1515
|
-
const
|
|
1516
|
-
throw new Error("bad point: is not on curve, sqrt error" +
|
|
2269
|
+
_ = r.sqrt(I);
|
|
2270
|
+
} catch (q) {
|
|
2271
|
+
const X = q instanceof Error ? ": " + q.message : "";
|
|
2272
|
+
throw new Error("bad point: is not on curve, sqrt error" + X);
|
|
1517
2273
|
}
|
|
1518
|
-
|
|
1519
|
-
const
|
|
1520
|
-
return (
|
|
1521
|
-
x:
|
|
1522
|
-
y:
|
|
2274
|
+
u();
|
|
2275
|
+
const D = r.isOdd(_);
|
|
2276
|
+
return (S & 1) === 1 !== D && (_ = r.neg(_)), {
|
|
2277
|
+
x: R,
|
|
2278
|
+
y: _
|
|
1523
2279
|
};
|
|
1524
|
-
} else if (
|
|
1525
|
-
const
|
|
1526
|
-
if (!
|
|
2280
|
+
} else if (U === H && S === 4) {
|
|
2281
|
+
const R = r.BYTES, I = r.fromBytes(p.subarray(0, R)), _ = r.fromBytes(p.subarray(R, R * 2));
|
|
2282
|
+
if (!T(I, _)) throw new Error("bad point: is not on curve");
|
|
1527
2283
|
return {
|
|
1528
|
-
x:
|
|
1529
|
-
y:
|
|
2284
|
+
x: I,
|
|
2285
|
+
y: _
|
|
1530
2286
|
};
|
|
1531
|
-
} else throw new Error(`bad point: got length ${
|
|
1532
|
-
}
|
|
1533
|
-
const w =
|
|
1534
|
-
function
|
|
1535
|
-
const
|
|
1536
|
-
return
|
|
1537
|
-
}
|
|
1538
|
-
function
|
|
1539
|
-
const
|
|
1540
|
-
return
|
|
1541
|
-
}
|
|
1542
|
-
if (!
|
|
1543
|
-
const B =
|
|
1544
|
-
if (
|
|
1545
|
-
function
|
|
1546
|
-
if (!
|
|
1547
|
-
return
|
|
1548
|
-
}
|
|
1549
|
-
function
|
|
1550
|
-
if (!(
|
|
1551
|
-
}
|
|
1552
|
-
function
|
|
1553
|
-
if (!
|
|
1554
|
-
return
|
|
1555
|
-
}
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
h == null && (h = _ ? n.ONE : n.inv(y));
|
|
1564
|
-
const S = n.mul(d, h), A = n.mul(u, h), p = n.mul(y, h);
|
|
1565
|
-
if (_) return {
|
|
1566
|
-
x: n.ZERO,
|
|
1567
|
-
y: n.ZERO
|
|
1568
|
-
};
|
|
1569
|
-
if (!n.eql(p, n.ONE)) throw new Error("invZ was invalid");
|
|
1570
|
-
return {
|
|
1571
|
-
x: S,
|
|
1572
|
-
y: A
|
|
1573
|
-
};
|
|
1574
|
-
}), D = Ue((U) => {
|
|
1575
|
-
if (U.is0()) {
|
|
1576
|
-
if (e.allowInfinityPoint && !n.is0(U.Y)) return;
|
|
1577
|
-
throw new Error("bad point: ZERO");
|
|
1578
|
-
}
|
|
1579
|
-
const { x: h, y: d } = U.toAffine();
|
|
1580
|
-
if (!n.isValid(h) || !n.isValid(d)) throw new Error("bad point: x or y not field elements");
|
|
1581
|
-
if (!v(h, d)) throw new Error("bad point: equation left != right");
|
|
1582
|
-
if (!U.isTorsionFree()) throw new Error("bad point: not in prime-order subgroup");
|
|
1583
|
-
return !0;
|
|
1584
|
-
});
|
|
1585
|
-
function N(U, h, d, u, y) {
|
|
1586
|
-
return d = new O(n.mul(d.X, U), d.Y, d.Z), h = Gt(u, h), d = Gt(y, d), h.add(d);
|
|
1587
|
-
}
|
|
1588
|
-
class O {
|
|
1589
|
-
static BASE = new O(s.Gx, s.Gy, n.ONE);
|
|
1590
|
-
static ZERO = new O(n.ZERO, n.ONE, n.ZERO);
|
|
1591
|
-
static Fp = n;
|
|
2287
|
+
} else throw new Error(`bad point: got length ${U}, expected compressed=${v} or uncompressed=${H}`);
|
|
2288
|
+
}
|
|
2289
|
+
const w = n.toBytes === void 0 ? d : n.toBytes, b = n.fromBytes === void 0 ? h : n.fromBytes;
|
|
2290
|
+
function E(M) {
|
|
2291
|
+
const v = r.sqr(M), H = r.mul(v, M);
|
|
2292
|
+
return r.add(r.add(H, r.mul(M, i.a)), i.b);
|
|
2293
|
+
}
|
|
2294
|
+
function T(M, v) {
|
|
2295
|
+
const H = r.sqr(v), U = E(M);
|
|
2296
|
+
return r.eql(H, U);
|
|
2297
|
+
}
|
|
2298
|
+
if (!T(i.Gx, i.Gy)) throw new Error("bad curve params: generator point");
|
|
2299
|
+
const B = r.mul(r.pow(i.a, Xt), Me), C = r.mul(r.sqr(i.b), BigInt(27));
|
|
2300
|
+
if (r.is0(r.add(B, C))) throw new Error("bad curve params: a or b");
|
|
2301
|
+
function O(M, v, H = !1) {
|
|
2302
|
+
if (!r.isValid(v) || H && r.is0(v)) throw new Error(`bad point coordinate ${M}`);
|
|
2303
|
+
return v;
|
|
2304
|
+
}
|
|
2305
|
+
function F(M) {
|
|
2306
|
+
if (!(M instanceof N)) throw new Error("Weierstrass Point expected");
|
|
2307
|
+
}
|
|
2308
|
+
function z(M) {
|
|
2309
|
+
if (!l || !l.basises) throw new Error("no endo");
|
|
2310
|
+
return lo(M, l.basises, o.ORDER);
|
|
2311
|
+
}
|
|
2312
|
+
function W(M, v, H, U, S) {
|
|
2313
|
+
return H = new N(r.mul(H.X, M), H.Y, H.Z), v = we(U, v), H = we(S, H), v.add(H);
|
|
2314
|
+
}
|
|
2315
|
+
class N {
|
|
2316
|
+
static BASE = new N(i.Gx, i.Gy, r.ONE);
|
|
2317
|
+
static ZERO = new N(r.ZERO, r.ONE, r.ZERO);
|
|
2318
|
+
static Fp = r;
|
|
1592
2319
|
static Fn = o;
|
|
1593
2320
|
X;
|
|
1594
2321
|
Y;
|
|
1595
2322
|
Z;
|
|
1596
|
-
constructor(
|
|
1597
|
-
this.X =
|
|
2323
|
+
constructor(v, H, U) {
|
|
2324
|
+
this.X = O("x", v), this.Y = O("y", H, !0), this.Z = O("z", U), Object.freeze(this);
|
|
1598
2325
|
}
|
|
1599
2326
|
static CURVE() {
|
|
1600
|
-
return
|
|
2327
|
+
return i;
|
|
1601
2328
|
}
|
|
1602
|
-
static fromAffine(
|
|
1603
|
-
const { x:
|
|
1604
|
-
if (!
|
|
1605
|
-
if (
|
|
1606
|
-
return
|
|
2329
|
+
static fromAffine(v) {
|
|
2330
|
+
const { x: H, y: U } = v || {};
|
|
2331
|
+
if (!v || !r.isValid(H) || !r.isValid(U)) throw new Error("invalid affine point");
|
|
2332
|
+
if (v instanceof N) throw new Error("projective point not allowed");
|
|
2333
|
+
return r.is0(H) && r.is0(U) ? N.ZERO : new N(H, U, r.ONE);
|
|
1607
2334
|
}
|
|
1608
|
-
static fromBytes(
|
|
1609
|
-
const
|
|
1610
|
-
return
|
|
2335
|
+
static fromBytes(v) {
|
|
2336
|
+
const H = N.fromAffine(b(st(v, void 0, "point")));
|
|
2337
|
+
return H.assertValidity(), H;
|
|
1611
2338
|
}
|
|
1612
|
-
static fromHex(
|
|
1613
|
-
return
|
|
2339
|
+
static fromHex(v) {
|
|
2340
|
+
return N.fromBytes(he(v));
|
|
1614
2341
|
}
|
|
1615
2342
|
get x() {
|
|
1616
2343
|
return this.toAffine().x;
|
|
@@ -1618,389 +2345,420 @@ function Er(t, e = {}) {
|
|
|
1618
2345
|
get y() {
|
|
1619
2346
|
return this.toAffine().y;
|
|
1620
2347
|
}
|
|
1621
|
-
precompute(
|
|
1622
|
-
return
|
|
2348
|
+
precompute(v = 8, H = !0) {
|
|
2349
|
+
return K.createCache(this, v), H || this.multiply(Xt), this;
|
|
1623
2350
|
}
|
|
1624
2351
|
assertValidity() {
|
|
1625
|
-
|
|
2352
|
+
const v = this;
|
|
2353
|
+
if (v.is0()) {
|
|
2354
|
+
if (n.allowInfinityPoint && r.is0(v.X) && r.eql(v.Y, r.ONE) && r.is0(v.Z)) return;
|
|
2355
|
+
throw new Error("bad point: ZERO");
|
|
2356
|
+
}
|
|
2357
|
+
const { x: H, y: U } = v.toAffine();
|
|
2358
|
+
if (!r.isValid(H) || !r.isValid(U)) throw new Error("bad point: x or y not field elements");
|
|
2359
|
+
if (!T(H, U)) throw new Error("bad point: equation left != right");
|
|
2360
|
+
if (!v.isTorsionFree()) throw new Error("bad point: not in prime-order subgroup");
|
|
1626
2361
|
}
|
|
1627
2362
|
hasEvenY() {
|
|
1628
|
-
const { y:
|
|
1629
|
-
if (!
|
|
1630
|
-
return !
|
|
2363
|
+
const { y: v } = this.toAffine();
|
|
2364
|
+
if (!r.isOdd) throw new Error("Field doesn't support isOdd");
|
|
2365
|
+
return !r.isOdd(v);
|
|
1631
2366
|
}
|
|
1632
|
-
equals(
|
|
1633
|
-
|
|
1634
|
-
const { X:
|
|
1635
|
-
return
|
|
2367
|
+
equals(v) {
|
|
2368
|
+
F(v);
|
|
2369
|
+
const { X: H, Y: U, Z: S } = this, { X: p, Y: R, Z: I } = v, _ = r.eql(r.mul(H, I), r.mul(p, S)), D = r.eql(r.mul(U, I), r.mul(R, S));
|
|
2370
|
+
return _ && D;
|
|
1636
2371
|
}
|
|
1637
2372
|
negate() {
|
|
1638
|
-
return new
|
|
2373
|
+
return new N(this.X, r.neg(this.Y), this.Z);
|
|
1639
2374
|
}
|
|
1640
2375
|
double() {
|
|
1641
|
-
const { a:
|
|
1642
|
-
let
|
|
1643
|
-
return
|
|
1644
|
-
}
|
|
1645
|
-
add(
|
|
1646
|
-
|
|
1647
|
-
const { X:
|
|
1648
|
-
let
|
|
1649
|
-
const
|
|
1650
|
-
let
|
|
1651
|
-
|
|
1652
|
-
let
|
|
1653
|
-
return
|
|
1654
|
-
}
|
|
1655
|
-
subtract(
|
|
1656
|
-
return this.add(
|
|
2376
|
+
const { a: v, b: H } = i, U = r.mul(H, Xt), { X: S, Y: p, Z: R } = this;
|
|
2377
|
+
let I = r.ZERO, _ = r.ZERO, D = r.ZERO, q = r.mul(S, S), X = r.mul(p, p), Y = r.mul(R, R), Z = r.mul(S, p);
|
|
2378
|
+
return Z = r.add(Z, Z), D = r.mul(S, R), D = r.add(D, D), I = r.mul(v, D), _ = r.mul(U, Y), _ = r.add(I, _), I = r.sub(X, _), _ = r.add(X, _), _ = r.mul(I, _), I = r.mul(Z, I), D = r.mul(U, D), Y = r.mul(v, Y), Z = r.sub(q, Y), Z = r.mul(v, Z), Z = r.add(Z, D), D = r.add(q, q), q = r.add(D, q), q = r.add(q, Y), q = r.mul(q, Z), _ = r.add(_, q), Y = r.mul(p, R), Y = r.add(Y, Y), q = r.mul(Y, Z), I = r.sub(I, q), D = r.mul(Y, X), D = r.add(D, D), D = r.add(D, D), new N(I, _, D);
|
|
2379
|
+
}
|
|
2380
|
+
add(v) {
|
|
2381
|
+
F(v);
|
|
2382
|
+
const { X: H, Y: U, Z: S } = this, { X: p, Y: R, Z: I } = v;
|
|
2383
|
+
let _ = r.ZERO, D = r.ZERO, q = r.ZERO;
|
|
2384
|
+
const X = i.a, Y = r.mul(i.b, Xt);
|
|
2385
|
+
let Z = r.mul(H, p), nt = r.mul(U, R), rt = r.mul(S, I), it = r.add(H, U), c = r.add(p, R);
|
|
2386
|
+
it = r.mul(it, c), c = r.add(Z, nt), it = r.sub(it, c), c = r.add(H, S);
|
|
2387
|
+
let m = r.add(p, I);
|
|
2388
|
+
return c = r.mul(c, m), m = r.add(Z, rt), c = r.sub(c, m), m = r.add(U, S), _ = r.add(R, I), m = r.mul(m, _), _ = r.add(nt, rt), m = r.sub(m, _), q = r.mul(X, c), _ = r.mul(Y, rt), q = r.add(_, q), _ = r.sub(nt, q), q = r.add(nt, q), D = r.mul(_, q), nt = r.add(Z, Z), nt = r.add(nt, Z), rt = r.mul(X, rt), c = r.mul(Y, c), nt = r.add(nt, rt), rt = r.sub(Z, rt), rt = r.mul(X, rt), c = r.add(c, rt), Z = r.mul(nt, c), D = r.add(D, Z), Z = r.mul(m, c), _ = r.mul(it, _), _ = r.sub(_, Z), Z = r.mul(it, nt), q = r.mul(m, q), q = r.add(q, Z), new N(_, D, q);
|
|
2389
|
+
}
|
|
2390
|
+
subtract(v) {
|
|
2391
|
+
return F(v), this.add(v.negate());
|
|
1657
2392
|
}
|
|
1658
2393
|
is0() {
|
|
1659
|
-
return this.equals(
|
|
1660
|
-
}
|
|
1661
|
-
multiply(
|
|
1662
|
-
const { endo:
|
|
1663
|
-
if (!o.isValidNot0(
|
|
1664
|
-
let
|
|
1665
|
-
const
|
|
1666
|
-
if (
|
|
1667
|
-
const { k1neg:
|
|
1668
|
-
|
|
2394
|
+
return this.equals(N.ZERO);
|
|
2395
|
+
}
|
|
2396
|
+
multiply(v) {
|
|
2397
|
+
const { endo: H } = n;
|
|
2398
|
+
if (!o.isValidNot0(v)) throw new RangeError("invalid scalar: out of range");
|
|
2399
|
+
let U, S;
|
|
2400
|
+
const p = (R) => K.cached(this, R, (I) => gn(N, I));
|
|
2401
|
+
if (H) {
|
|
2402
|
+
const { k1neg: R, k1: I, k2neg: _, k2: D } = z(v), { p: q, f: X } = p(I), { p: Y, f: Z } = p(D);
|
|
2403
|
+
S = X.add(Z), U = W(H.beta, q, Y, R, _);
|
|
1669
2404
|
} else {
|
|
1670
|
-
const { p:
|
|
1671
|
-
|
|
2405
|
+
const { p: R, f: I } = p(v);
|
|
2406
|
+
U = R, S = I;
|
|
1672
2407
|
}
|
|
1673
|
-
return
|
|
1674
|
-
}
|
|
1675
|
-
multiplyUnsafe(
|
|
1676
|
-
const { endo:
|
|
1677
|
-
if (!o.isValid(
|
|
1678
|
-
if (
|
|
1679
|
-
if (
|
|
1680
|
-
if (
|
|
1681
|
-
if (
|
|
1682
|
-
const { k1neg:
|
|
1683
|
-
return
|
|
1684
|
-
} else return
|
|
1685
|
-
}
|
|
1686
|
-
toAffine(
|
|
1687
|
-
|
|
2408
|
+
return gn(N, [U, S])[0];
|
|
2409
|
+
}
|
|
2410
|
+
multiplyUnsafe(v) {
|
|
2411
|
+
const { endo: H } = n, U = this, S = v;
|
|
2412
|
+
if (!o.isValid(S)) throw new RangeError("invalid scalar: out of range");
|
|
2413
|
+
if (S === yt || U.is0()) return N.ZERO;
|
|
2414
|
+
if (S === ct) return U;
|
|
2415
|
+
if (K.hasCache(this)) return this.multiply(S);
|
|
2416
|
+
if (H) {
|
|
2417
|
+
const { k1neg: p, k1: R, k2neg: I, k2: _ } = z(S), { p1: D, p2: q } = Wr(N, U, R, _);
|
|
2418
|
+
return W(H.beta, D, q, p, I);
|
|
2419
|
+
} else return K.unsafe(U, S);
|
|
2420
|
+
}
|
|
2421
|
+
toAffine(v) {
|
|
2422
|
+
const H = this;
|
|
2423
|
+
let U = v;
|
|
2424
|
+
const { X: S, Y: p, Z: R } = H;
|
|
2425
|
+
if (r.eql(R, r.ONE)) return {
|
|
2426
|
+
x: S,
|
|
2427
|
+
y: p
|
|
2428
|
+
};
|
|
2429
|
+
const I = H.is0();
|
|
2430
|
+
U == null && (U = I ? r.ONE : r.inv(R));
|
|
2431
|
+
const _ = r.mul(S, U), D = r.mul(p, U), q = r.mul(R, U);
|
|
2432
|
+
if (I) return {
|
|
2433
|
+
x: r.ZERO,
|
|
2434
|
+
y: r.ZERO
|
|
2435
|
+
};
|
|
2436
|
+
if (!r.eql(q, r.ONE)) throw new Error("invZ was invalid");
|
|
2437
|
+
return {
|
|
2438
|
+
x: _,
|
|
2439
|
+
y: D
|
|
2440
|
+
};
|
|
1688
2441
|
}
|
|
1689
2442
|
isTorsionFree() {
|
|
1690
|
-
const { isTorsionFree:
|
|
1691
|
-
return
|
|
2443
|
+
const { isTorsionFree: v } = n;
|
|
2444
|
+
return a === ct ? !0 : v ? v(N, this) : K.unsafe(this, f).is0();
|
|
1692
2445
|
}
|
|
1693
2446
|
clearCofactor() {
|
|
1694
|
-
const { clearCofactor:
|
|
1695
|
-
return
|
|
2447
|
+
const { clearCofactor: v } = n;
|
|
2448
|
+
return a === ct ? this : v ? v(N, this) : this.multiplyUnsafe(a);
|
|
1696
2449
|
}
|
|
1697
2450
|
isSmallOrder() {
|
|
1698
|
-
return this.
|
|
2451
|
+
return a === ct ? this.is0() : this.clearCofactor().is0();
|
|
1699
2452
|
}
|
|
1700
|
-
toBytes(
|
|
1701
|
-
return
|
|
2453
|
+
toBytes(v = !0) {
|
|
2454
|
+
return ie(v, "isCompressed"), this.assertValidity(), w(N, this, v);
|
|
1702
2455
|
}
|
|
1703
|
-
toHex(
|
|
1704
|
-
return
|
|
2456
|
+
toHex(v = !0) {
|
|
2457
|
+
return Ct(this.toBytes(v));
|
|
1705
2458
|
}
|
|
1706
2459
|
toString() {
|
|
1707
2460
|
return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
|
|
1708
2461
|
}
|
|
1709
2462
|
}
|
|
1710
|
-
const
|
|
1711
|
-
return
|
|
2463
|
+
const V = o.BITS, K = new Xr(N, n.endo ? Math.ceil(V / 2) : V);
|
|
2464
|
+
return V >= 8 && N.BASE.precompute(8), Object.freeze(N.prototype), Object.freeze(N), N;
|
|
1712
2465
|
}
|
|
1713
|
-
function
|
|
2466
|
+
function fr(t) {
|
|
1714
2467
|
return Uint8Array.of(t ? 2 : 3);
|
|
1715
2468
|
}
|
|
1716
|
-
function
|
|
1717
|
-
const r =
|
|
1718
|
-
let
|
|
1719
|
-
for (let
|
|
1720
|
-
const
|
|
1721
|
-
let w = (
|
|
1722
|
-
let
|
|
1723
|
-
|
|
1724
|
-
let
|
|
1725
|
-
|
|
1726
|
-
let
|
|
1727
|
-
|
|
1728
|
-
let
|
|
1729
|
-
B =
|
|
1730
|
-
for (let
|
|
1731
|
-
let
|
|
1732
|
-
|
|
1733
|
-
let
|
|
1734
|
-
const
|
|
1735
|
-
B =
|
|
2469
|
+
function mo(t, n) {
|
|
2470
|
+
const e = se(t), r = e.ORDER;
|
|
2471
|
+
let o = yt;
|
|
2472
|
+
for (let b = r - ct; b % Bt === yt; b /= Bt) o += ct;
|
|
2473
|
+
const i = o, a = Bt << i - ct - ct, f = a * Bt, l = (r - ct) / f, g = (l - ct) / Bt, s = f - ct, u = a, d = e.pow(n, l), h = e.pow(n, (l + ct) / Bt);
|
|
2474
|
+
let w = (b, E) => {
|
|
2475
|
+
let T = d, B = e.pow(E, s), C = e.sqr(B);
|
|
2476
|
+
C = e.mul(C, E);
|
|
2477
|
+
let O = e.mul(b, C);
|
|
2478
|
+
O = e.pow(O, g), O = e.mul(O, B), B = e.mul(O, E), C = e.mul(O, b);
|
|
2479
|
+
let F = e.mul(C, B);
|
|
2480
|
+
O = e.pow(F, u);
|
|
2481
|
+
let z = e.eql(O, e.ONE);
|
|
2482
|
+
B = e.mul(C, h), O = e.mul(F, T), C = e.cmov(B, C, z), F = e.cmov(O, F, z);
|
|
2483
|
+
for (let W = i; W > ct; W--) {
|
|
2484
|
+
let N = W - Bt;
|
|
2485
|
+
N = Bt << N - ct;
|
|
2486
|
+
let V = e.pow(F, N);
|
|
2487
|
+
const K = e.eql(V, e.ONE);
|
|
2488
|
+
B = e.mul(C, T), T = e.mul(T, T), V = e.mul(F, T), C = e.cmov(B, C, K), F = e.cmov(V, F, K);
|
|
1736
2489
|
}
|
|
1737
2490
|
return {
|
|
1738
|
-
isValid:
|
|
1739
|
-
value:
|
|
2491
|
+
isValid: !e.is0(E) && (z || e.is0(b)),
|
|
2492
|
+
value: C
|
|
1740
2493
|
};
|
|
1741
2494
|
};
|
|
1742
|
-
if (
|
|
1743
|
-
const
|
|
1744
|
-
w = (
|
|
1745
|
-
let
|
|
1746
|
-
const
|
|
1747
|
-
|
|
1748
|
-
let
|
|
1749
|
-
|
|
1750
|
-
const
|
|
2495
|
+
if (e.ORDER % Me === Xt) {
|
|
2496
|
+
const b = (e.ORDER - Xt) / Me, E = e.sqrt(e.neg(n));
|
|
2497
|
+
w = (T, B) => {
|
|
2498
|
+
let C = e.sqr(B);
|
|
2499
|
+
const O = e.mul(T, B);
|
|
2500
|
+
C = e.mul(C, O);
|
|
2501
|
+
let F = e.pow(C, b);
|
|
2502
|
+
F = e.mul(F, O);
|
|
2503
|
+
const z = e.mul(F, E), W = e.mul(e.sqr(F), B), N = e.eql(W, T);
|
|
2504
|
+
let V = e.cmov(z, F, N);
|
|
1751
2505
|
return {
|
|
1752
|
-
isValid:
|
|
1753
|
-
value:
|
|
2506
|
+
isValid: !e.is0(B) && N,
|
|
2507
|
+
value: V
|
|
1754
2508
|
};
|
|
1755
2509
|
};
|
|
1756
2510
|
}
|
|
1757
2511
|
return w;
|
|
1758
2512
|
}
|
|
1759
|
-
function
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
if (
|
|
1763
|
-
const
|
|
1764
|
-
if (!
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
const B =
|
|
1771
|
-
|
|
1772
|
-
const
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
2513
|
+
function go(t, n) {
|
|
2514
|
+
const e = se(t), { A: r, B: o, Z: i } = n;
|
|
2515
|
+
if (!e.isValidNot0(r) || !e.isValidNot0(o) || !e.isValid(i)) throw new Error("mapToCurveSimpleSWU: invalid opts");
|
|
2516
|
+
if (e.eql(i, e.neg(e.ONE)) || hn(e, i)) throw new Error("mapToCurveSimpleSWU: invalid opts");
|
|
2517
|
+
const a = e.mul(o, e.inv(e.mul(i, r)));
|
|
2518
|
+
if (!hn(e, e.add(e.add(e.mul(e.sqr(a), a), e.mul(r, a)), o))) throw new Error("mapToCurveSimpleSWU: invalid opts");
|
|
2519
|
+
const f = mo(e, i);
|
|
2520
|
+
if (!e.isOdd) throw new Error("Field does not have .isOdd()");
|
|
2521
|
+
return (l) => {
|
|
2522
|
+
let g, s, u, d, h, w, b, E;
|
|
2523
|
+
g = e.sqr(l), g = e.mul(g, i), s = e.sqr(g), s = e.add(s, g), u = e.add(s, e.ONE), u = e.mul(u, o), d = e.cmov(i, e.neg(s), !e.eql(s, e.ZERO)), d = e.mul(d, r), s = e.sqr(u), w = e.sqr(d), h = e.mul(w, r), s = e.add(s, h), s = e.mul(s, u), w = e.mul(w, d), h = e.mul(w, o), s = e.add(s, h), b = e.mul(g, u);
|
|
2524
|
+
const { isValid: T, value: B } = f(s, w);
|
|
2525
|
+
E = e.mul(g, l), E = e.mul(E, B), b = e.cmov(b, u, T), E = e.cmov(E, B, T);
|
|
2526
|
+
const C = e.isOdd(l) === e.isOdd(E);
|
|
2527
|
+
E = e.cmov(e.neg(E), E, C);
|
|
2528
|
+
const O = Ee(e, [d], !0)[0];
|
|
2529
|
+
return b = e.mul(b, O), {
|
|
2530
|
+
x: b,
|
|
2531
|
+
y: E
|
|
1776
2532
|
};
|
|
1777
2533
|
};
|
|
1778
2534
|
}
|
|
1779
|
-
function
|
|
2535
|
+
function ar(t, n) {
|
|
1780
2536
|
return {
|
|
1781
|
-
secretKey:
|
|
2537
|
+
secretKey: n.BYTES,
|
|
1782
2538
|
publicKey: 1 + t.BYTES,
|
|
1783
2539
|
publicKeyUncompressed: 1 + 2 * t.BYTES,
|
|
1784
2540
|
publicKeyHasPrefix: !0,
|
|
1785
|
-
signature: 2 *
|
|
2541
|
+
signature: 2 * n.BYTES
|
|
1786
2542
|
};
|
|
1787
2543
|
}
|
|
1788
|
-
function
|
|
1789
|
-
const { Fn:
|
|
1790
|
-
function
|
|
2544
|
+
function wo(t, n = {}) {
|
|
2545
|
+
const { Fn: e } = t, r = n.randomBytes === void 0 ? wt : n.randomBytes, o = Object.assign(ar(t.Fp, e), { seed: Math.max(nn(e.ORDER), 16) });
|
|
2546
|
+
function i(h) {
|
|
1791
2547
|
try {
|
|
1792
|
-
const
|
|
1793
|
-
return
|
|
2548
|
+
const w = e.fromBytes(h);
|
|
2549
|
+
return e.isValidNot0(w);
|
|
1794
2550
|
} catch {
|
|
1795
2551
|
return !1;
|
|
1796
2552
|
}
|
|
1797
2553
|
}
|
|
1798
|
-
function
|
|
1799
|
-
const { publicKey:
|
|
2554
|
+
function a(h, w) {
|
|
2555
|
+
const { publicKey: b, publicKeyUncompressed: E } = o;
|
|
1800
2556
|
try {
|
|
1801
|
-
const
|
|
1802
|
-
return
|
|
2557
|
+
const T = h.length;
|
|
2558
|
+
return w === !0 && T !== b || w === !1 && T !== E ? !1 : !!t.fromBytes(h);
|
|
1803
2559
|
} catch {
|
|
1804
2560
|
return !1;
|
|
1805
2561
|
}
|
|
1806
2562
|
}
|
|
1807
|
-
function
|
|
1808
|
-
return
|
|
1809
|
-
}
|
|
1810
|
-
function
|
|
1811
|
-
return t.BASE.multiply(
|
|
1812
|
-
}
|
|
1813
|
-
function
|
|
1814
|
-
const { secretKey:
|
|
1815
|
-
if (!
|
|
1816
|
-
const B =
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
if (
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
2563
|
+
function f(h) {
|
|
2564
|
+
return h = h === void 0 ? r(o.seed) : h, nr(st(h, o.seed, "seed"), e.ORDER);
|
|
2565
|
+
}
|
|
2566
|
+
function l(h, w = !0) {
|
|
2567
|
+
return t.BASE.multiply(e.fromBytes(h)).toBytes(w);
|
|
2568
|
+
}
|
|
2569
|
+
function g(h) {
|
|
2570
|
+
const { secretKey: w, publicKey: b, publicKeyUncompressed: E } = o, T = e._lengths;
|
|
2571
|
+
if (!oe(h)) return;
|
|
2572
|
+
const B = st(h, void 0, "key").length, C = B === b || B === E, O = B === w || !!T?.includes(B);
|
|
2573
|
+
if (!(C && O))
|
|
2574
|
+
return C;
|
|
2575
|
+
}
|
|
2576
|
+
function s(h, w, b = !0) {
|
|
2577
|
+
if (g(h) === !0) throw new Error("first arg must be private key");
|
|
2578
|
+
if (g(w) === !1) throw new Error("second arg must be public key");
|
|
2579
|
+
const E = e.fromBytes(h);
|
|
2580
|
+
return t.fromBytes(w).multiply(E).toBytes(b);
|
|
2581
|
+
}
|
|
2582
|
+
const u = {
|
|
2583
|
+
isValidSecretKey: i,
|
|
2584
|
+
isValidPublicKey: a,
|
|
2585
|
+
randomSecretKey: f
|
|
2586
|
+
}, d = to(f, l);
|
|
2587
|
+
return Object.freeze(u), Object.freeze(o), Object.freeze({
|
|
2588
|
+
getPublicKey: l,
|
|
2589
|
+
getSharedSecret: s,
|
|
2590
|
+
keygen: d,
|
|
1834
2591
|
Point: t,
|
|
1835
|
-
utils:
|
|
2592
|
+
utils: u,
|
|
1836
2593
|
lengths: o
|
|
1837
2594
|
});
|
|
1838
2595
|
}
|
|
1839
|
-
function
|
|
1840
|
-
|
|
2596
|
+
function bo(t, n, e = {}) {
|
|
2597
|
+
const r = n;
|
|
2598
|
+
An(r), Mt(e, {}, {
|
|
1841
2599
|
hmac: "function",
|
|
1842
2600
|
lowS: "boolean",
|
|
1843
2601
|
randomBytes: "function",
|
|
1844
2602
|
bits2int: "function",
|
|
1845
2603
|
bits2int_modN: "function"
|
|
1846
|
-
}),
|
|
1847
|
-
const
|
|
2604
|
+
}), e = Object.assign({}, e);
|
|
2605
|
+
const o = e.randomBytes === void 0 ? wt : e.randomBytes, i = e.hmac === void 0 ? (S, p) => We(r, S, p) : e.hmac, { Fp: a, Fn: f } = t, { ORDER: l, BITS: g } = f, { keygen: s, getPublicKey: u, getSharedSecret: d, utils: h, lengths: w } = wo(t, e), b = {
|
|
1848
2606
|
prehash: !0,
|
|
1849
|
-
lowS: typeof
|
|
2607
|
+
lowS: typeof e.lowS == "boolean" ? e.lowS : !0,
|
|
1850
2608
|
format: "compact",
|
|
1851
2609
|
extraEntropy: !1
|
|
1852
|
-
},
|
|
1853
|
-
function
|
|
1854
|
-
return
|
|
2610
|
+
}, E = l * Bt + ct < a.ORDER;
|
|
2611
|
+
function T(S) {
|
|
2612
|
+
return S > l >> ct;
|
|
1855
2613
|
}
|
|
1856
|
-
function B(
|
|
1857
|
-
if (!
|
|
1858
|
-
return
|
|
2614
|
+
function B(S, p) {
|
|
2615
|
+
if (!f.isValidNot0(p)) throw new Error(`invalid signature ${S}: out of range 1..Point.Fn.ORDER`);
|
|
2616
|
+
return p;
|
|
1859
2617
|
}
|
|
1860
|
-
function
|
|
1861
|
-
if (
|
|
2618
|
+
function C() {
|
|
2619
|
+
if (E) throw new Error('"recovered" sig type is not supported for cofactor >2 curves');
|
|
1862
2620
|
}
|
|
1863
|
-
function
|
|
1864
|
-
|
|
1865
|
-
const
|
|
1866
|
-
return
|
|
2621
|
+
function O(S, p) {
|
|
2622
|
+
ze(p);
|
|
2623
|
+
const R = w.signature;
|
|
2624
|
+
return st(S, p === "compact" ? R : p === "recovered" ? R + 1 : void 0);
|
|
1867
2625
|
}
|
|
1868
|
-
class
|
|
2626
|
+
class F {
|
|
1869
2627
|
r;
|
|
1870
2628
|
s;
|
|
1871
2629
|
recovery;
|
|
1872
|
-
constructor(
|
|
1873
|
-
if (this.r = B("r",
|
|
1874
|
-
if (
|
|
2630
|
+
constructor(p, R, I) {
|
|
2631
|
+
if (this.r = B("r", p), this.s = B("s", R), I != null) {
|
|
2632
|
+
if (C(), ![
|
|
1875
2633
|
0,
|
|
1876
2634
|
1,
|
|
1877
2635
|
2,
|
|
1878
2636
|
3
|
|
1879
|
-
].includes(
|
|
1880
|
-
this.recovery =
|
|
2637
|
+
].includes(I)) throw new Error("invalid recovery id");
|
|
2638
|
+
this.recovery = I;
|
|
1881
2639
|
}
|
|
1882
2640
|
Object.freeze(this);
|
|
1883
2641
|
}
|
|
1884
|
-
static fromBytes(
|
|
1885
|
-
|
|
1886
|
-
let
|
|
1887
|
-
if (
|
|
1888
|
-
const { r:
|
|
1889
|
-
return new
|
|
2642
|
+
static fromBytes(p, R = b.format) {
|
|
2643
|
+
O(p, R);
|
|
2644
|
+
let I;
|
|
2645
|
+
if (R === "der") {
|
|
2646
|
+
const { r: X, s: Y } = Et.toSig(st(p));
|
|
2647
|
+
return new F(X, Y);
|
|
1890
2648
|
}
|
|
1891
|
-
|
|
1892
|
-
const
|
|
1893
|
-
return new
|
|
2649
|
+
R === "recovered" && (I = p[0], R = "compact", p = p.subarray(1));
|
|
2650
|
+
const _ = w.signature / 2, D = p.subarray(0, _), q = p.subarray(_, _ * 2);
|
|
2651
|
+
return new F(f.fromBytes(D), f.fromBytes(q), I);
|
|
1894
2652
|
}
|
|
1895
|
-
static fromHex(
|
|
1896
|
-
return this.fromBytes(
|
|
2653
|
+
static fromHex(p, R) {
|
|
2654
|
+
return this.fromBytes(he(p), R);
|
|
1897
2655
|
}
|
|
1898
2656
|
assertRecovery() {
|
|
1899
|
-
const { recovery:
|
|
1900
|
-
if (
|
|
1901
|
-
return
|
|
2657
|
+
const { recovery: p } = this;
|
|
2658
|
+
if (p == null) throw new Error("invalid recovery id: must be present");
|
|
2659
|
+
return p;
|
|
1902
2660
|
}
|
|
1903
|
-
addRecoveryBit(
|
|
1904
|
-
return new
|
|
2661
|
+
addRecoveryBit(p) {
|
|
2662
|
+
return new F(this.r, this.s, p);
|
|
1905
2663
|
}
|
|
1906
|
-
recoverPublicKey(
|
|
1907
|
-
const { r:
|
|
1908
|
-
if (!
|
|
1909
|
-
const
|
|
1910
|
-
if (
|
|
1911
|
-
return
|
|
2664
|
+
recoverPublicKey(p) {
|
|
2665
|
+
const { r: R, s: I } = this, _ = this.assertRecovery(), D = _ === 2 || _ === 3 ? R + l : R;
|
|
2666
|
+
if (!a.isValid(D)) throw new Error("invalid recovery id: sig.r+curve.n != R.x");
|
|
2667
|
+
const q = a.toBytes(D), X = t.fromBytes(Q(fr((_ & 1) === 0), q)), Y = f.inv(D), Z = W(st(p, void 0, "msgHash")), nt = f.create(-Z * Y), rt = f.create(I * Y), it = t.BASE.multiplyUnsafe(nt).add(X.multiplyUnsafe(rt));
|
|
2668
|
+
if (it.is0()) throw new Error("invalid recovery: point at infinify");
|
|
2669
|
+
return it.assertValidity(), it;
|
|
1912
2670
|
}
|
|
1913
2671
|
hasHighS() {
|
|
1914
|
-
return
|
|
1915
|
-
}
|
|
1916
|
-
toBytes(
|
|
1917
|
-
if (
|
|
1918
|
-
const { r:
|
|
1919
|
-
return
|
|
1920
|
-
}
|
|
1921
|
-
toHex(
|
|
1922
|
-
return
|
|
1923
|
-
}
|
|
1924
|
-
}
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
2672
|
+
return T(this.s);
|
|
2673
|
+
}
|
|
2674
|
+
toBytes(p = b.format) {
|
|
2675
|
+
if (ze(p), p === "der") return he(Et.hexFromSig(this));
|
|
2676
|
+
const { r: R, s: I } = this, _ = f.toBytes(R), D = f.toBytes(I);
|
|
2677
|
+
return p === "recovered" ? (C(), Q(Uint8Array.of(this.assertRecovery()), _, D)) : Q(_, D);
|
|
2678
|
+
}
|
|
2679
|
+
toHex(p) {
|
|
2680
|
+
return Ct(this.toBytes(p));
|
|
2681
|
+
}
|
|
2682
|
+
}
|
|
2683
|
+
Object.freeze(F.prototype), Object.freeze(F);
|
|
2684
|
+
const z = e.bits2int === void 0 ? function(p) {
|
|
2685
|
+
if (p.length > 8192) throw new Error("input is too large");
|
|
2686
|
+
const R = St(p), I = p.length * 8 - g;
|
|
2687
|
+
return I > 0 ? R >> BigInt(I) : R;
|
|
2688
|
+
} : e.bits2int, W = e.bits2int_modN === void 0 ? function(p) {
|
|
2689
|
+
return f.create(z(p));
|
|
2690
|
+
} : e.bits2int_modN, N = pe(g);
|
|
2691
|
+
function V(S) {
|
|
2692
|
+
return Mn("num < 2^" + g, S, yt, N), f.toBytes(S);
|
|
2693
|
+
}
|
|
2694
|
+
function K(S, p) {
|
|
2695
|
+
return st(S, void 0, "message"), p ? st(r(S), void 0, "prehashed message") : S;
|
|
2696
|
+
}
|
|
2697
|
+
function M(S, p, R) {
|
|
2698
|
+
const { lowS: I, prehash: _, extraEntropy: D } = Te(R, b);
|
|
2699
|
+
S = K(S, _);
|
|
2700
|
+
const q = W(S), X = f.fromBytes(p);
|
|
2701
|
+
if (!f.isValidNot0(X)) throw new Error("invalid private key");
|
|
2702
|
+
const Y = [V(X), V(q)];
|
|
2703
|
+
if (D != null && D !== !1) {
|
|
2704
|
+
const it = D === !0 ? o(w.secretKey) : D;
|
|
2705
|
+
Y.push(st(it, void 0, "extraEntropy"));
|
|
2706
|
+
}
|
|
2707
|
+
const Z = Q(...Y), nt = q;
|
|
2708
|
+
function rt(it) {
|
|
2709
|
+
const c = z(it);
|
|
2710
|
+
if (!f.isValidNot0(c)) return;
|
|
2711
|
+
const m = f.inv(c), y = t.BASE.multiply(c).toAffine(), x = f.create(y.x);
|
|
2712
|
+
if (x === yt) return;
|
|
2713
|
+
const A = f.create(m * f.create(nt + x * X));
|
|
2714
|
+
if (A === yt) return;
|
|
2715
|
+
let j = (y.x === x ? 0 : 2) | Number(y.y & ct), L = A;
|
|
2716
|
+
return I && T(A) && (L = f.neg(A), j ^= 1), new F(x, L, E ? void 0 : j);
|
|
1958
2717
|
}
|
|
1959
2718
|
return {
|
|
1960
|
-
seed:
|
|
1961
|
-
k2sig:
|
|
2719
|
+
seed: Z,
|
|
2720
|
+
k2sig: rt
|
|
1962
2721
|
};
|
|
1963
2722
|
}
|
|
1964
|
-
function
|
|
1965
|
-
const { seed:
|
|
1966
|
-
return
|
|
2723
|
+
function v(S, p, R = {}) {
|
|
2724
|
+
const { seed: I, k2sig: _ } = M(S, p, R);
|
|
2725
|
+
return qr(r.outputLen, f.BYTES, i)(I, _).toBytes(R.format);
|
|
1967
2726
|
}
|
|
1968
|
-
function
|
|
1969
|
-
const { lowS:
|
|
1970
|
-
if (
|
|
1971
|
-
const
|
|
1972
|
-
throw new Error("verify expects Uint8Array signature" +
|
|
2727
|
+
function H(S, p, R, I = {}) {
|
|
2728
|
+
const { lowS: _, prehash: D, format: q } = Te(I, b);
|
|
2729
|
+
if (R = st(R, void 0, "publicKey"), p = K(p, D), !oe(S)) {
|
|
2730
|
+
const X = S instanceof F ? ", use sig.toBytes()" : "";
|
|
2731
|
+
throw new Error("verify expects Uint8Array signature" + X);
|
|
1973
2732
|
}
|
|
1974
|
-
|
|
2733
|
+
O(S, q);
|
|
1975
2734
|
try {
|
|
1976
|
-
const
|
|
1977
|
-
if (
|
|
1978
|
-
const { r:
|
|
1979
|
-
return
|
|
2735
|
+
const X = F.fromBytes(S, q), Y = t.fromBytes(R);
|
|
2736
|
+
if (_ && X.hasHighS()) return !1;
|
|
2737
|
+
const { r: Z, s: nt } = X, rt = W(p), it = f.inv(nt), c = f.create(rt * it), m = f.create(Z * it), y = t.BASE.multiplyUnsafe(c).add(Y.multiplyUnsafe(m));
|
|
2738
|
+
return y.is0() ? !1 : f.create(y.x) === Z;
|
|
1980
2739
|
} catch {
|
|
1981
2740
|
return !1;
|
|
1982
2741
|
}
|
|
1983
2742
|
}
|
|
1984
|
-
function
|
|
1985
|
-
const { prehash:
|
|
1986
|
-
return
|
|
2743
|
+
function U(S, p, R = {}) {
|
|
2744
|
+
const { prehash: I } = Te(R, b);
|
|
2745
|
+
return p = K(p, I), F.fromBytes(S, "recovered").recoverPublicKey(p).toBytes();
|
|
1987
2746
|
}
|
|
1988
2747
|
return Object.freeze({
|
|
1989
|
-
keygen:
|
|
1990
|
-
getPublicKey:
|
|
1991
|
-
getSharedSecret:
|
|
1992
|
-
utils:
|
|
2748
|
+
keygen: s,
|
|
2749
|
+
getPublicKey: u,
|
|
2750
|
+
getSharedSecret: d,
|
|
2751
|
+
utils: h,
|
|
1993
2752
|
lengths: w,
|
|
1994
2753
|
Point: t,
|
|
1995
|
-
sign:
|
|
1996
|
-
verify:
|
|
1997
|
-
recoverPublicKey:
|
|
1998
|
-
Signature:
|
|
1999
|
-
hash:
|
|
2754
|
+
sign: v,
|
|
2755
|
+
verify: H,
|
|
2756
|
+
recoverPublicKey: U,
|
|
2757
|
+
Signature: F,
|
|
2758
|
+
hash: r
|
|
2000
2759
|
});
|
|
2001
2760
|
}
|
|
2002
|
-
|
|
2003
|
-
var Ae = {
|
|
2761
|
+
var rn = {
|
|
2004
2762
|
p: BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),
|
|
2005
2763
|
n: BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),
|
|
2006
2764
|
h: BigInt(1),
|
|
@@ -2008,19 +2766,45 @@ var Ae = {
|
|
|
2008
2766
|
b: BigInt(7),
|
|
2009
2767
|
Gx: BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),
|
|
2010
2768
|
Gy: BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")
|
|
2011
|
-
},
|
|
2769
|
+
}, yo = {
|
|
2012
2770
|
beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
|
|
2013
2771
|
basises: [[BigInt("0x3086d221a7d46bcde86c90e49284eb15"), -BigInt("0xe4437ed6010e88286f547fa90abfe4c3")], [BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]
|
|
2014
|
-
},
|
|
2015
|
-
function
|
|
2016
|
-
const
|
|
2017
|
-
if (!
|
|
2018
|
-
return
|
|
2019
|
-
}
|
|
2020
|
-
var
|
|
2021
|
-
Fp:
|
|
2022
|
-
endo:
|
|
2023
|
-
}),
|
|
2772
|
+
}, lr = /* @__PURE__ */ BigInt(0), Ge = /* @__PURE__ */ BigInt(2);
|
|
2773
|
+
function po(t) {
|
|
2774
|
+
const n = rn.p, e = BigInt(3), r = BigInt(6), o = BigInt(11), i = BigInt(22), a = BigInt(23), f = BigInt(44), l = BigInt(88), g = t * t * t % n, s = g * g * t % n, u = gt(gt(gt(s, e, n) * s % n, e, n) * s % n, Ge, n) * g % n, d = gt(u, o, n) * u % n, h = gt(d, i, n) * d % n, w = gt(h, f, n) * h % n, b = gt(gt(gt(gt(gt(gt(w, l, n) * w % n, f, n) * h % n, e, n) * s % n, a, n) * d % n, r, n) * g % n, Ge, n);
|
|
2775
|
+
if (!It.eql(It.sqr(b), t)) throw new Error("Cannot find square root");
|
|
2776
|
+
return b;
|
|
2777
|
+
}
|
|
2778
|
+
var It = ve(rn.p, { sqrt: po }), J = /* @__PURE__ */ ho(rn, {
|
|
2779
|
+
Fp: It,
|
|
2780
|
+
endo: yo
|
|
2781
|
+
}), Vo = /* @__PURE__ */ bo(J, jt), vn = {};
|
|
2782
|
+
function ur(t, ...n) {
|
|
2783
|
+
let e = vn[t];
|
|
2784
|
+
if (e === void 0) {
|
|
2785
|
+
const r = jt(be(t));
|
|
2786
|
+
e = Q(r, r), vn[t] = e;
|
|
2787
|
+
}
|
|
2788
|
+
return jt(Q(e, ...n));
|
|
2789
|
+
}
|
|
2790
|
+
var Ye = (t) => t.toBytes(!0).slice(1), Vt = (t) => t % Ge === lr;
|
|
2791
|
+
function Eo(t) {
|
|
2792
|
+
const n = It;
|
|
2793
|
+
if (!n.isValidNot0(t)) throw new Error("invalid x: Fail if x ≥ p");
|
|
2794
|
+
const e = n.create(t * t), r = n.create(e * t + BigInt(7));
|
|
2795
|
+
let o = n.sqrt(r);
|
|
2796
|
+
Vt(o) || (o = n.neg(o));
|
|
2797
|
+
const i = J.fromAffine({
|
|
2798
|
+
x: t,
|
|
2799
|
+
y: o
|
|
2800
|
+
});
|
|
2801
|
+
return i.assertValidity(), i;
|
|
2802
|
+
}
|
|
2803
|
+
var vo = St;
|
|
2804
|
+
function xo(...t) {
|
|
2805
|
+
return J.Fn.create(vo(ur("BIP0340/challenge", ...t)));
|
|
2806
|
+
}
|
|
2807
|
+
var Bo = co(It, [
|
|
2024
2808
|
[
|
|
2025
2809
|
"0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7",
|
|
2026
2810
|
"0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581",
|
|
@@ -2044,59 +2828,147 @@ var gt = te(Ae.p, { sqrt: Ar }), Sn = /* @__PURE__ */ Er(Ae, {
|
|
|
2044
2828
|
"0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f",
|
|
2045
2829
|
"0x0000000000000000000000000000000000000000000000000000000000000001"
|
|
2046
2830
|
]
|
|
2047
|
-
].map((t) => t.map((
|
|
2831
|
+
].map((t) => t.map((n) => BigInt(n)))), xn, So = () => xn || (xn = go(It, {
|
|
2048
2832
|
A: BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),
|
|
2049
2833
|
B: BigInt("1771"),
|
|
2050
|
-
Z:
|
|
2051
|
-
}),
|
|
2052
|
-
const { x:
|
|
2053
|
-
return
|
|
2834
|
+
Z: It.create(BigInt("-11"))
|
|
2835
|
+
})), dr = ao(J, (t) => {
|
|
2836
|
+
const { x: n, y: e } = So()(It.create(t[0]));
|
|
2837
|
+
return Bo(n, e);
|
|
2054
2838
|
}, {
|
|
2055
2839
|
DST: "secp256k1_XMD:SHA-256_SSWU_RO_",
|
|
2056
2840
|
encodeDST: "secp256k1_XMD:SHA-256_SSWU_NU_",
|
|
2057
|
-
p:
|
|
2841
|
+
p: It.ORDER,
|
|
2058
2842
|
m: 1,
|
|
2059
2843
|
k: 128,
|
|
2060
2844
|
expand: "xmd",
|
|
2061
|
-
hash:
|
|
2845
|
+
hash: jt
|
|
2846
|
+
}), Po = cr({
|
|
2847
|
+
name: "FROST-secp256k1-SHA256-v1",
|
|
2848
|
+
Point: J,
|
|
2849
|
+
hashToScalar: dr.hashToScalar,
|
|
2850
|
+
hash: jt
|
|
2851
|
+
});
|
|
2852
|
+
function hr(t, n) {
|
|
2853
|
+
if (n === void 0) return lr;
|
|
2854
|
+
const e = St(ur("TapTweak", Ye(t), n));
|
|
2855
|
+
if (!J.Fn.isValid(e)) throw new Error("invalid TapTweak hash");
|
|
2856
|
+
return e;
|
|
2857
|
+
}
|
|
2858
|
+
function on(t) {
|
|
2859
|
+
return Vt(J.fromBytes(t.commitments[0]).y) ? t : {
|
|
2860
|
+
signers: {
|
|
2861
|
+
min: t.signers.min,
|
|
2862
|
+
max: t.signers.max
|
|
2863
|
+
},
|
|
2864
|
+
commitments: t.commitments.map((n) => J.fromBytes(n).negate().toBytes()),
|
|
2865
|
+
verifyingShares: Object.fromEntries(Object.entries(t.verifyingShares).map(([n, e]) => [n, J.fromBytes(e).negate().toBytes()]))
|
|
2866
|
+
};
|
|
2867
|
+
}
|
|
2868
|
+
function mr(t, n) {
|
|
2869
|
+
if (Vt(J.fromBytes(n.commitments[0]).y)) return t;
|
|
2870
|
+
const e = J.Fn;
|
|
2871
|
+
return {
|
|
2872
|
+
...t,
|
|
2873
|
+
signingShare: e.toBytes(e.neg(e.fromBytes(t.signingShare)))
|
|
2874
|
+
};
|
|
2875
|
+
}
|
|
2876
|
+
function Ao(t, n) {
|
|
2877
|
+
if (Vt(t.y)) return n;
|
|
2878
|
+
const e = J.Fn;
|
|
2879
|
+
return {
|
|
2880
|
+
binding: e.toBytes(e.neg(e.fromBytes(n.binding))),
|
|
2881
|
+
hiding: e.toBytes(e.neg(e.fromBytes(n.hiding)))
|
|
2882
|
+
};
|
|
2883
|
+
}
|
|
2884
|
+
function Ro(t, n, e) {
|
|
2885
|
+
const r = J.Fn, o = mr(t, n), i = on(n), a = hr(J.fromBytes(i.commitments[0]), e), f = r.toBytes(r.add(r.fromBytes(o.signingShare), a));
|
|
2886
|
+
return {
|
|
2887
|
+
identifier: o.identifier,
|
|
2888
|
+
signingShare: f
|
|
2889
|
+
};
|
|
2890
|
+
}
|
|
2891
|
+
function _o(t, n) {
|
|
2892
|
+
const e = on(t), r = hr(J.fromBytes(e.commitments[0]), n), o = J.BASE.multiply(r), i = e.commitments.map((f, l) => (l === 0 ? J.fromBytes(f).add(o) : J.fromBytes(f)).toBytes()), a = {};
|
|
2893
|
+
for (const f in e.verifyingShares) a[f] = J.fromBytes(e.verifyingShares[f]).add(o).toBytes();
|
|
2894
|
+
return {
|
|
2895
|
+
signers: {
|
|
2896
|
+
min: e.signers.min,
|
|
2897
|
+
max: e.signers.max
|
|
2898
|
+
},
|
|
2899
|
+
commitments: i,
|
|
2900
|
+
verifyingShares: a
|
|
2901
|
+
};
|
|
2902
|
+
}
|
|
2903
|
+
var zo = cr({
|
|
2904
|
+
name: "FROST-secp256k1-SHA256-TR-v1",
|
|
2905
|
+
Point: J,
|
|
2906
|
+
hashToScalar: dr.hashToScalar,
|
|
2907
|
+
hash: jt,
|
|
2908
|
+
parsePublicKey(t) {
|
|
2909
|
+
if (t.length === 32) return Eo(St(t));
|
|
2910
|
+
if (t.length === 33) return J.fromBytes(t);
|
|
2911
|
+
throw new Error(`expected x-only or compressed public key, got length=${t.length}`);
|
|
2912
|
+
},
|
|
2913
|
+
adjustScalar(t) {
|
|
2914
|
+
return Vt(J.BASE.multiply(t).y) ? t : J.Fn.neg(t);
|
|
2915
|
+
},
|
|
2916
|
+
adjustPoint: (t) => Vt(t.y) ? t : t.negate(),
|
|
2917
|
+
challenge(t, n, e) {
|
|
2918
|
+
return xo(Ye(t), Ye(n), e);
|
|
2919
|
+
},
|
|
2920
|
+
adjustNonces: Ao,
|
|
2921
|
+
adjustGroupCommitmentShare: (t, n) => Vt(t.y) ? n : n.negate(),
|
|
2922
|
+
adjustPublic: on,
|
|
2923
|
+
adjustSecret: mr,
|
|
2924
|
+
adjustTx: {
|
|
2925
|
+
encode: (t) => t.subarray(1),
|
|
2926
|
+
decode: (t) => Q(Uint8Array.of(2), t)
|
|
2927
|
+
},
|
|
2928
|
+
adjustDKG: (t) => {
|
|
2929
|
+
const n = new Uint8Array(0);
|
|
2930
|
+
return {
|
|
2931
|
+
public: _o(t.public, n),
|
|
2932
|
+
secret: Ro(t.secret, t.public, n)
|
|
2933
|
+
};
|
|
2934
|
+
}
|
|
2062
2935
|
});
|
|
2063
2936
|
export {
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
qn as y
|
|
2937
|
+
xr as A,
|
|
2938
|
+
Do as C,
|
|
2939
|
+
Ln as D,
|
|
2940
|
+
Fo as E,
|
|
2941
|
+
Yt as F,
|
|
2942
|
+
Qt as I,
|
|
2943
|
+
Ho as L,
|
|
2944
|
+
To as M,
|
|
2945
|
+
Er as N,
|
|
2946
|
+
vr as O,
|
|
2947
|
+
Kt as P,
|
|
2948
|
+
Fr as S,
|
|
2949
|
+
jt as T,
|
|
2950
|
+
qo as _,
|
|
2951
|
+
wt as a,
|
|
2952
|
+
Nr as b,
|
|
2953
|
+
Dr as c,
|
|
2954
|
+
kn as d,
|
|
2955
|
+
No as f,
|
|
2956
|
+
Uo as g,
|
|
2957
|
+
Lo as h,
|
|
2958
|
+
Q as i,
|
|
2959
|
+
Br as j,
|
|
2960
|
+
Fe as k,
|
|
2961
|
+
ko as l,
|
|
2962
|
+
jo as m,
|
|
2963
|
+
bt as n,
|
|
2964
|
+
Lr as o,
|
|
2965
|
+
Io as p,
|
|
2966
|
+
St as r,
|
|
2967
|
+
Zo as s,
|
|
2968
|
+
Vo as t,
|
|
2969
|
+
$o as u,
|
|
2970
|
+
jr as v,
|
|
2971
|
+
_r as w,
|
|
2972
|
+
Co as x,
|
|
2973
|
+
Or as y
|
|
2102
2974
|
};
|