@kynesyslabs/demosdk 2.3.1-8.2 → 2.3.1-8.3
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/build/abstraction/Identities.d.ts +9 -9
- package/build/abstraction/index.d.ts +1 -1
- package/build/abstraction/index.js +1 -16
- package/build/bridge/index.d.ts +2 -2
- package/build/bridge/index.js +1 -27
- package/build/bridge/nativeBridge.d.ts +3 -3
- package/build/bridge/rubicBridge.d.ts +3 -3
- package/build/demoswork/index.js +1 -27
- package/build/demoswork/operations/baseoperation.d.ts +1 -1
- package/build/demoswork/operations/conditional/condition.d.ts +5 -5
- package/build/demoswork/operations/conditional/index.d.ts +4 -4
- package/build/demoswork/operations/index.d.ts +2 -2
- package/build/demoswork/utils/createTestWorkScript.d.ts +1 -1
- package/build/demoswork/validator/index.d.ts +1 -1
- package/build/demoswork/validator/steps.validator.d.ts +1 -1
- package/build/demoswork/work.d.ts +3 -3
- package/build/demoswork/workstep.d.ts +3 -3
- package/build/encryption/index.js +1 -51
- package/build/encryption/unifiedCrypto.d.ts +1 -1
- package/build/index.js +1 -20
- package/build/l2ps/index.js +1 -9
- package/build/l2ps/l2ps.d.ts +1 -1
- package/build/multichain/core/aptos.d.ts +1 -1
- package/build/multichain/core/btc.d.ts +2 -2
- package/build/multichain/core/index.js +1 -29
- package/build/multichain/core/multiversx.d.ts +3 -2
- package/build/multichain/core/ton.d.ts +2 -2
- package/build/multichain/core/xrp.d.ts +3 -2
- package/build/multichain/localsdk/btc.d.ts +1 -1
- package/build/multichain/localsdk/evm.d.ts +1 -1
- package/build/multichain/localsdk/ibc.d.ts +1 -1
- package/build/multichain/localsdk/index.js +1 -22
- package/build/multichain/localsdk/multiversx.d.ts +1 -1
- package/build/multichain/localsdk/ton.d.ts +1 -1
- package/build/multichain/localsdk/xrp.d.ts +1 -1
- package/build/multichain/websdk/btc.d.ts +1 -1
- package/build/multichain/websdk/evm.d.ts +1 -1
- package/build/multichain/websdk/ibc.d.ts +1 -1
- package/build/multichain/websdk/index.js +1 -22
- package/build/multichain/websdk/multiversx.d.ts +1 -1
- package/build/multichain/websdk/solana.d.ts +1 -1
- package/build/multichain/websdk/xrp.d.ts +1 -1
- package/build/types/blockchain/Transaction.d.ts +2 -2
- package/build/types/blockchain/TransactionSubtypes/CrosschainTransaction.d.ts +1 -1
- package/build/types/blockchain/TransactionSubtypes/DemosworkTransaction.d.ts +1 -1
- package/build/types/blockchain/TransactionSubtypes/IdentityTransaction.d.ts +1 -1
- package/build/types/blockchain/TransactionSubtypes/InstantMessagingTransaction.d.ts +1 -1
- package/build/types/blockchain/TransactionSubtypes/L2PSTransaction.d.ts +1 -1
- package/build/types/blockchain/TransactionSubtypes/NativeBridgeTransaction.d.ts +1 -1
- package/build/types/blockchain/TransactionSubtypes/NativeTransaction.d.ts +1 -1
- package/build/types/blockchain/TransactionSubtypes/Web2Transaction.d.ts +1 -1
- package/build/types/blockchain/blocks.d.ts +2 -2
- package/build/types/demoswork/index.d.ts +1 -1
- package/build/types/demoswork/operations.d.ts +1 -1
- package/build/types/demoswork/steps.d.ts +2 -2
- package/build/utils/index.js +1 -55
- package/build/wallet/Wallet.d.ts +3 -3
- package/build/wallet/index.js +1 -38
- package/build/websdk/DemosTransactions.d.ts +2 -2
- package/build/websdk/DemosWebAuth.d.ts +0 -2
- package/build/websdk/GCRGeneration.d.ts +2 -2
- package/build/websdk/Web2Calls.d.ts +1 -1
- package/build/websdk/XMTransactions.d.ts +1 -1
- package/build/websdk/bridge.d.ts +3 -3
- package/build/websdk/demosclass.d.ts +5 -5
- package/build/websdk/index.js +1 -70
- package/build/websdk/utils/skeletons.d.ts +1 -1
- package/package.json +17 -2
- package/build/abstraction/CoinFinder.js +0 -67
- package/build/abstraction/CoinFinder.js.map +0 -1
- package/build/abstraction/EvmCoinFinder.js +0 -280
- package/build/abstraction/EvmCoinFinder.js.map +0 -1
- package/build/abstraction/Identities.js +0 -348
- package/build/abstraction/Identities.js.map +0 -1
- package/build/abstraction/index.js.map +0 -1
- package/build/abstraction/providers/AbstractionProviders.js +0 -65
- package/build/abstraction/providers/AbstractionProviders.js.map +0 -1
- package/build/abstraction/providers/CoinAddresses.js +0 -232
- package/build/abstraction/providers/CoinAddresses.js.map +0 -1
- package/build/abstraction/providers/Providers.js +0 -22
- package/build/abstraction/providers/Providers.js.map +0 -1
- package/build/abstraction/providers/evm/ankr.js +0 -36
- package/build/abstraction/providers/evm/ankr.js.map +0 -1
- package/build/abstraction/providers/evm/arbitrum.js +0 -23
- package/build/abstraction/providers/evm/arbitrum.js.map +0 -1
- package/build/abstraction/providers/evm/bsc.js +0 -27
- package/build/abstraction/providers/evm/bsc.js.map +0 -1
- package/build/abstraction/providers/evm/ethereum.js +0 -32
- package/build/abstraction/providers/evm/ethereum.js.map +0 -1
- package/build/abstraction/providers/evm/index.js +0 -15
- package/build/abstraction/providers/evm/index.js.map +0 -1
- package/build/abstraction/providers/evm/optimism.js +0 -27
- package/build/abstraction/providers/evm/optimism.js.map +0 -1
- package/build/abstraction/providers/index.js +0 -10
- package/build/abstraction/providers/index.js.map +0 -1
- package/build/abstraction/providers/non-evm/bitcoin.js +0 -23
- package/build/abstraction/providers/non-evm/bitcoin.js.map +0 -1
- package/build/abstraction/providers/non-evm/index.js +0 -15
- package/build/abstraction/providers/non-evm/index.js.map +0 -1
- package/build/abstraction/providers/non-evm/multiversx.js +0 -23
- package/build/abstraction/providers/non-evm/multiversx.js.map +0 -1
- package/build/abstraction/providers/non-evm/solana.js +0 -24
- package/build/abstraction/providers/non-evm/solana.js.map +0 -1
- package/build/abstraction/providers/non-evm/xrp.js +0 -23
- package/build/abstraction/providers/non-evm/xrp.js.map +0 -1
- package/build/bridge/index.js.map +0 -1
- package/build/bridge/nativeBridge.js +0 -108
- package/build/bridge/nativeBridge.js.map +0 -1
- package/build/bridge/nativeBridgeTypes.js +0 -35
- package/build/bridge/nativeBridgeTypes.js.map +0 -1
- package/build/bridge/rubicBridge.js +0 -45
- package/build/bridge/rubicBridge.js.map +0 -1
- package/build/demoswork/executor/index.js +0 -21
- package/build/demoswork/executor/index.js.map +0 -1
- package/build/demoswork/executor/stepexecutor.js +0 -53
- package/build/demoswork/executor/stepexecutor.js.map +0 -1
- package/build/demoswork/index.js.map +0 -1
- package/build/demoswork/operations/baseoperation.js +0 -29
- package/build/demoswork/operations/baseoperation.js.map +0 -1
- package/build/demoswork/operations/conditional/condition.js +0 -54
- package/build/demoswork/operations/conditional/condition.js.map +0 -1
- package/build/demoswork/operations/conditional/index.js +0 -110
- package/build/demoswork/operations/conditional/index.js.map +0 -1
- package/build/demoswork/operations/index.js +0 -65
- package/build/demoswork/operations/index.js.map +0 -1
- package/build/demoswork/utils/createTestWorkScript.js +0 -64
- package/build/demoswork/utils/createTestWorkScript.js.map +0 -1
- package/build/demoswork/utils/index.js +0 -61
- package/build/demoswork/utils/index.js.map +0 -1
- package/build/demoswork/validator/index.js +0 -43
- package/build/demoswork/validator/index.js.map +0 -1
- package/build/demoswork/validator/steps.validator.js +0 -77
- package/build/demoswork/validator/steps.validator.js.map +0 -1
- package/build/demoswork/work.js +0 -77
- package/build/demoswork/work.js.map +0 -1
- package/build/demoswork/workstep.js +0 -88
- package/build/demoswork/workstep.js.map +0 -1
- package/build/encryption/Cryptography.js +0 -271
- package/build/encryption/Cryptography.js.map +0 -1
- package/build/encryption/FHE/index.js +0 -28
- package/build/encryption/FHE/index.js.map +0 -1
- package/build/encryption/Hashing.js +0 -30
- package/build/encryption/Hashing.js.map +0 -1
- package/build/encryption/PQC/enigma.js +0 -249
- package/build/encryption/PQC/enigma.js.map +0 -1
- package/build/encryption/PQC/falconts/falcon.js +0 -228
- package/build/encryption/PQC/falconts/falcon.js.map +0 -1
- package/build/encryption/PQC/falconts/index.js +0 -19
- package/build/encryption/PQC/falconts/index.js.map +0 -1
- package/build/encryption/PQC/falconts/mnemonic.js +0 -109
- package/build/encryption/PQC/falconts/mnemonic.js.map +0 -1
- package/build/encryption/PQC/falconts/wordlist.js +0 -216
- package/build/encryption/PQC/falconts/wordlist.js.map +0 -1
- package/build/encryption/PQC/utils.js +0 -16
- package/build/encryption/PQC/utils.js.map +0 -1
- package/build/encryption/index.js.map +0 -1
- package/build/encryption/unifiedCrypto.js +0 -409
- package/build/encryption/unifiedCrypto.js.map +0 -1
- package/build/encryption/zK/index.js +0 -38
- package/build/encryption/zK/index.js.map +0 -1
- package/build/encryption/zK/interactive/index.js +0 -43
- package/build/encryption/zK/interactive/index.js.map +0 -1
- package/build/encryption/zK/primer.js +0 -69
- package/build/encryption/zK/primer.js.map +0 -1
- package/build/index.js.map +0 -1
- package/build/instant_messaging/index.js +0 -675
- package/build/instant_messaging/index.js.map +0 -1
- package/build/l2ps/index.js.map +0 -1
- package/build/l2ps/l2ps.js +0 -312
- package/build/l2ps/l2ps.js.map +0 -1
- package/build/multichain/core/aptos.js +0 -554
- package/build/multichain/core/aptos.js.map +0 -1
- package/build/multichain/core/btc.js +0 -409
- package/build/multichain/core/btc.js.map +0 -1
- package/build/multichain/core/evm.js +0 -359
- package/build/multichain/core/evm.js.map +0 -1
- package/build/multichain/core/ibc.js +0 -269
- package/build/multichain/core/ibc.js.map +0 -1
- package/build/multichain/core/index.js.map +0 -1
- package/build/multichain/core/multiversx.js +0 -173
- package/build/multichain/core/multiversx.js.map +0 -1
- package/build/multichain/core/near.js +0 -214
- package/build/multichain/core/near.js.map +0 -1
- package/build/multichain/core/solana.js +0 -246
- package/build/multichain/core/solana.js.map +0 -1
- package/build/multichain/core/ten.js +0 -142
- package/build/multichain/core/ten.js.map +0 -1
- package/build/multichain/core/ton.js +0 -142
- package/build/multichain/core/ton.js.map +0 -1
- package/build/multichain/core/types/SolanaPhantomProvider.js +0 -5
- package/build/multichain/core/types/SolanaPhantomProvider.js.map +0 -1
- package/build/multichain/core/types/defaultChain.js +0 -83
- package/build/multichain/core/types/defaultChain.js.map +0 -1
- package/build/multichain/core/types/interfaces.js +0 -9
- package/build/multichain/core/types/interfaces.js.map +0 -1
- package/build/multichain/core/utils.js +0 -21
- package/build/multichain/core/utils.js.map +0 -1
- package/build/multichain/core/xrp.js +0 -191
- package/build/multichain/core/xrp.js.map +0 -1
- package/build/multichain/index.js +0 -40
- package/build/multichain/index.js.map +0 -1
- package/build/multichain/localsdk/aptos.js +0 -192
- package/build/multichain/localsdk/aptos.js.map +0 -1
- package/build/multichain/localsdk/btc.js +0 -89
- package/build/multichain/localsdk/btc.js.map +0 -1
- package/build/multichain/localsdk/evm.js +0 -59
- package/build/multichain/localsdk/evm.js.map +0 -1
- package/build/multichain/localsdk/ibc.js +0 -26
- package/build/multichain/localsdk/ibc.js.map +0 -1
- package/build/multichain/localsdk/index.js.map +0 -1
- package/build/multichain/localsdk/multiversx.js +0 -52
- package/build/multichain/localsdk/multiversx.js.map +0 -1
- package/build/multichain/localsdk/near.js +0 -34
- package/build/multichain/localsdk/near.js.map +0 -1
- package/build/multichain/localsdk/solana.js +0 -32
- package/build/multichain/localsdk/solana.js.map +0 -1
- package/build/multichain/localsdk/ten.js +0 -66
- package/build/multichain/localsdk/ten.js.map +0 -1
- package/build/multichain/localsdk/ton.js +0 -34
- package/build/multichain/localsdk/ton.js.map +0 -1
- package/build/multichain/localsdk/xrp.js +0 -88
- package/build/multichain/localsdk/xrp.js.map +0 -1
- package/build/multichain/websdk/aptos.js +0 -289
- package/build/multichain/websdk/aptos.js.map +0 -1
- package/build/multichain/websdk/btc.js +0 -11
- package/build/multichain/websdk/btc.js.map +0 -1
- package/build/multichain/websdk/evm.js +0 -11
- package/build/multichain/websdk/evm.js.map +0 -1
- package/build/multichain/websdk/ibc.js +0 -12
- package/build/multichain/websdk/ibc.js.map +0 -1
- package/build/multichain/websdk/index.js.map +0 -1
- package/build/multichain/websdk/multiversx.js +0 -69
- package/build/multichain/websdk/multiversx.js.map +0 -1
- package/build/multichain/websdk/near.js +0 -12
- package/build/multichain/websdk/near.js.map +0 -1
- package/build/multichain/websdk/solana.js +0 -92
- package/build/multichain/websdk/solana.js.map +0 -1
- package/build/multichain/websdk/ton.js +0 -8
- package/build/multichain/websdk/ton.js.map +0 -1
- package/build/multichain/websdk/xrp.js +0 -11
- package/build/multichain/websdk/xrp.js.map +0 -1
- package/build/types/abstraction/index.js +0 -4
- package/build/types/abstraction/index.js.map +0 -1
- package/build/types/blockchain/Confirmation.js +0 -23
- package/build/types/blockchain/Confirmation.js.map +0 -1
- package/build/types/blockchain/GCREdit.js +0 -5
- package/build/types/blockchain/GCREdit.js.map +0 -1
- package/build/types/blockchain/ISignature.js +0 -3
- package/build/types/blockchain/ISignature.js.map +0 -1
- package/build/types/blockchain/Transaction.js +0 -19
- package/build/types/blockchain/Transaction.js.map +0 -1
- package/build/types/blockchain/TransactionSubtypes/CrosschainTransaction.js +0 -3
- package/build/types/blockchain/TransactionSubtypes/CrosschainTransaction.js.map +0 -1
- package/build/types/blockchain/TransactionSubtypes/DemosworkTransaction.js +0 -3
- package/build/types/blockchain/TransactionSubtypes/DemosworkTransaction.js.map +0 -1
- package/build/types/blockchain/TransactionSubtypes/IdentityTransaction.js +0 -3
- package/build/types/blockchain/TransactionSubtypes/IdentityTransaction.js.map +0 -1
- package/build/types/blockchain/TransactionSubtypes/InstantMessagingTransaction.js +0 -3
- package/build/types/blockchain/TransactionSubtypes/InstantMessagingTransaction.js.map +0 -1
- package/build/types/blockchain/TransactionSubtypes/L2PSHashTransaction.js +0 -3
- package/build/types/blockchain/TransactionSubtypes/L2PSHashTransaction.js.map +0 -1
- package/build/types/blockchain/TransactionSubtypes/L2PSTransaction.js +0 -3
- package/build/types/blockchain/TransactionSubtypes/L2PSTransaction.js.map +0 -1
- package/build/types/blockchain/TransactionSubtypes/NativeBridgeTransaction.js +0 -3
- package/build/types/blockchain/TransactionSubtypes/NativeBridgeTransaction.js.map +0 -1
- package/build/types/blockchain/TransactionSubtypes/NativeTransaction.js +0 -3
- package/build/types/blockchain/TransactionSubtypes/NativeTransaction.js.map +0 -1
- package/build/types/blockchain/TransactionSubtypes/SmartContractTransaction.js +0 -3
- package/build/types/blockchain/TransactionSubtypes/SmartContractTransaction.js.map +0 -1
- package/build/types/blockchain/TransactionSubtypes/StorageTransaction.js +0 -3
- package/build/types/blockchain/TransactionSubtypes/StorageTransaction.js.map +0 -1
- package/build/types/blockchain/TransactionSubtypes/Web2Transaction.js +0 -3
- package/build/types/blockchain/TransactionSubtypes/Web2Transaction.js.map +0 -1
- package/build/types/blockchain/TransactionSubtypes/index.js +0 -27
- package/build/types/blockchain/TransactionSubtypes/index.js.map +0 -1
- package/build/types/blockchain/TransactionSubtypes/utils.js +0 -42
- package/build/types/blockchain/TransactionSubtypes/utils.js.map +0 -1
- package/build/types/blockchain/TxFee.js +0 -3
- package/build/types/blockchain/TxFee.js.map +0 -1
- package/build/types/blockchain/ValidityData.js +0 -8
- package/build/types/blockchain/ValidityData.js.map +0 -1
- package/build/types/blockchain/WalletTypes.js +0 -3
- package/build/types/blockchain/WalletTypes.js.map +0 -1
- package/build/types/blockchain/address.js +0 -3
- package/build/types/blockchain/address.js.map +0 -1
- package/build/types/blockchain/addressInfo.js +0 -3
- package/build/types/blockchain/addressInfo.js.map +0 -1
- package/build/types/blockchain/blocks.js +0 -13
- package/build/types/blockchain/blocks.js.map +0 -1
- package/build/types/blockchain/encryptedTransaction.js +0 -3
- package/build/types/blockchain/encryptedTransaction.js.map +0 -1
- package/build/types/blockchain/genesisTypes.js +0 -4
- package/build/types/blockchain/genesisTypes.js.map +0 -1
- package/build/types/blockchain/identities.js +0 -14
- package/build/types/blockchain/identities.js.map +0 -1
- package/build/types/blockchain/rawTransaction.js +0 -13
- package/build/types/blockchain/rawTransaction.js.map +0 -1
- package/build/types/blockchain/statusNative.js +0 -3
- package/build/types/blockchain/statusNative.js.map +0 -1
- package/build/types/blockchain/statusProperties.js +0 -3
- package/build/types/blockchain/statusProperties.js.map +0 -1
- package/build/types/bridge/bridgeTradePayload.js +0 -3
- package/build/types/bridge/bridgeTradePayload.js.map +0 -1
- package/build/types/bridge/constants.js +0 -91
- package/build/types/bridge/constants.js.map +0 -1
- package/build/types/communication/demosWork.js +0 -3
- package/build/types/communication/demosWork.js.map +0 -1
- package/build/types/communication/rpc.js +0 -11
- package/build/types/communication/rpc.js.map +0 -1
- package/build/types/communication/transmit.js +0 -13
- package/build/types/communication/transmit.js.map +0 -1
- package/build/types/cryptography.js +0 -3
- package/build/types/cryptography.js.map +0 -1
- package/build/types/demoswork/datatypes.js +0 -10
- package/build/types/demoswork/datatypes.js.map +0 -1
- package/build/types/demoswork/index.js +0 -3
- package/build/types/demoswork/index.js.map +0 -1
- package/build/types/demoswork/operations.js +0 -3
- package/build/types/demoswork/operations.js.map +0 -1
- package/build/types/demoswork/steps.js +0 -21
- package/build/types/demoswork/steps.js.map +0 -1
- package/build/types/gls/Operation.js +0 -3
- package/build/types/gls/Operation.js.map +0 -1
- package/build/types/gls/StateChange.js +0 -13
- package/build/types/gls/StateChange.js.map +0 -1
- package/build/types/index.js +0 -24
- package/build/types/index.js.map +0 -1
- package/build/types/instantMessaging/index.js +0 -3
- package/build/types/instantMessaging/index.js.map +0 -1
- package/build/types/native/INativePayload.js +0 -4
- package/build/types/native/INativePayload.js.map +0 -1
- package/build/types/native/index.js +0 -18
- package/build/types/native/index.js.map +0 -1
- package/build/types/network/ExecutionResult.js +0 -3
- package/build/types/network/ExecutionResult.js.map +0 -1
- package/build/types/network/SecurityTypes.js +0 -3
- package/build/types/network/SecurityTypes.js.map +0 -1
- package/build/types/peers/Peer.js +0 -13
- package/build/types/peers/Peer.js.map +0 -1
- package/build/types/web2/index.js +0 -9
- package/build/types/web2/index.js.map +0 -1
- package/build/types/web2/telegram.js +0 -6
- package/build/types/web2/telegram.js.map +0 -1
- package/build/types/web2/twitter.js +0 -3
- package/build/types/web2/twitter.js.map +0 -1
- package/build/types/xm/apiTools.js +0 -3
- package/build/types/xm/apiTools.js.map +0 -1
- package/build/types/xm/index.js +0 -3
- package/build/types/xm/index.js.map +0 -1
- package/build/utils/dataManipulation.js +0 -37
- package/build/utils/dataManipulation.js.map +0 -1
- package/build/utils/getRemoteIP.js +0 -19
- package/build/utils/getRemoteIP.js.map +0 -1
- package/build/utils/index.js.map +0 -1
- package/build/utils/pprint.js +0 -17
- package/build/utils/pprint.js.map +0 -1
- package/build/utils/uint8Serialize.js +0 -22
- package/build/utils/uint8Serialize.js.map +0 -1
- package/build/wallet/Wallet.js +0 -120
- package/build/wallet/Wallet.js.map +0 -1
- package/build/wallet/index.js.map +0 -1
- package/build/wallet/passkeys/passkeys.js +0 -60
- package/build/wallet/passkeys/passkeys.js.map +0 -1
- package/build/websdk/DemosTransactions.js +0 -298
- package/build/websdk/DemosTransactions.js.map +0 -1
- package/build/websdk/DemosWebAuth.js +0 -187
- package/build/websdk/DemosWebAuth.js.map +0 -1
- package/build/websdk/GCRGeneration.js +0 -237
- package/build/websdk/GCRGeneration.js.map +0 -1
- package/build/websdk/Web2Calls.js +0 -107
- package/build/websdk/Web2Calls.js.map +0 -1
- package/build/websdk/XMTransactions.js +0 -150
- package/build/websdk/XMTransactions.js.map +0 -1
- package/build/websdk/bridge.js +0 -46
- package/build/websdk/bridge.js.map +0 -1
- package/build/websdk/demos.js +0 -11
- package/build/websdk/demos.js.map +0 -1
- package/build/websdk/demosclass.js +0 -734
- package/build/websdk/demosclass.js.map +0 -1
- package/build/websdk/examples/tryWeb2.js +0 -81
- package/build/websdk/examples/tryWeb2.js.map +0 -1
- package/build/websdk/index.js.map +0 -1
- package/build/websdk/rsa.js +0 -86
- package/build/websdk/rsa.js.map +0 -1
- package/build/websdk/types/IBuffer.js +0 -3
- package/build/websdk/types/IBuffer.js.map +0 -1
- package/build/websdk/types/KeyPair.js +0 -3
- package/build/websdk/types/KeyPair.js.map +0 -1
- package/build/websdk/utils/bufferizer.js +0 -18
- package/build/websdk/utils/bufferizer.js.map +0 -1
- package/build/websdk/utils/forge_converter.js +0 -61
- package/build/websdk/utils/forge_converter.js.map +0 -1
- package/build/websdk/utils/required.js +0 -47
- package/build/websdk/utils/required.js.map +0 -1
- package/build/websdk/utils/sha256.js +0 -18
- package/build/websdk/utils/sha256.js.map +0 -1
- package/build/websdk/utils/skeletons.js +0 -70
- package/build/websdk/utils/skeletons.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { XMCoreTargetIdentityPayload, Web2CoreTargetIdentityPayload, GithubProof, TwitterProof, InferFromSignaturePayload } from "
|
|
2
|
-
import { Demos } from "
|
|
3
|
-
import { PQCAlgorithm } from "
|
|
4
|
-
import { RPCResponseWithValidityData } from "
|
|
1
|
+
import { XMCoreTargetIdentityPayload, Web2CoreTargetIdentityPayload, GithubProof, TwitterProof, InferFromSignaturePayload } from "@/types/abstraction";
|
|
2
|
+
import { Demos } from "@/websdk/demosclass";
|
|
3
|
+
import { PQCAlgorithm } from "@/types/cryptography";
|
|
4
|
+
import { RPCResponseWithValidityData } from "@/types";
|
|
5
5
|
export declare class Identities {
|
|
6
6
|
formats: {
|
|
7
7
|
web2: {
|
|
@@ -95,7 +95,7 @@ export declare class Identities {
|
|
|
95
95
|
* @param address The address to get identities for.
|
|
96
96
|
* @returns The identities associated with the address.
|
|
97
97
|
*/
|
|
98
|
-
getIdentities(demos: Demos, call?: string, address?: string): Promise<import("
|
|
98
|
+
getIdentities(demos: Demos, call?: string, address?: string): Promise<import("@/types").RPCResponse>;
|
|
99
99
|
/**
|
|
100
100
|
* Get the crosschain identities associated with an address.
|
|
101
101
|
*
|
|
@@ -103,7 +103,7 @@ export declare class Identities {
|
|
|
103
103
|
* @param address The address to get identities for.
|
|
104
104
|
* @returns The identities associated with the address.
|
|
105
105
|
*/
|
|
106
|
-
getXmIdentities(demos: Demos, address?: string): Promise<import("
|
|
106
|
+
getXmIdentities(demos: Demos, address?: string): Promise<import("@/types").RPCResponse>;
|
|
107
107
|
/**
|
|
108
108
|
* Get the web2 identities associated with an address.
|
|
109
109
|
*
|
|
@@ -111,7 +111,7 @@ export declare class Identities {
|
|
|
111
111
|
* @param address The address to get identities for.
|
|
112
112
|
* @returns The identities associated with the address.
|
|
113
113
|
*/
|
|
114
|
-
getWeb2Identities(demos: Demos, address?: string): Promise<import("
|
|
114
|
+
getWeb2Identities(demos: Demos, address?: string): Promise<import("@/types").RPCResponse>;
|
|
115
115
|
/**
|
|
116
116
|
* Get the points associated with an identity
|
|
117
117
|
*
|
|
@@ -127,7 +127,7 @@ export declare class Identities {
|
|
|
127
127
|
* @param referralCode The referral code to validate.
|
|
128
128
|
* @returns The validation result containing validity status, referrer public key, and message.
|
|
129
129
|
*/
|
|
130
|
-
validateReferralCode(demos: Demos, referralCode: string): Promise<import("
|
|
130
|
+
validateReferralCode(demos: Demos, referralCode: string): Promise<import("@/types").RPCResponse>;
|
|
131
131
|
/**
|
|
132
132
|
* Get referral information for an address.
|
|
133
133
|
*
|
|
@@ -135,5 +135,5 @@ export declare class Identities {
|
|
|
135
135
|
* @param address The address to get referral info for. Defaults to the connected wallet's address.
|
|
136
136
|
* @returns The referral information associated with the address.
|
|
137
137
|
*/
|
|
138
|
-
getReferralInfo(demos: Demos, address?: string): Promise<import("
|
|
138
|
+
getReferralInfo(demos: Demos, address?: string): Promise<import("@/types").RPCResponse>;
|
|
139
139
|
}
|
|
@@ -7,5 +7,5 @@
|
|
|
7
7
|
import { EvmCoinFinder } from "./EvmCoinFinder";
|
|
8
8
|
import { CoinFinder } from "./CoinFinder";
|
|
9
9
|
import { Identities } from "./Identities";
|
|
10
|
-
import { InferFromWritePayload, InferFromSignaturePayload, XMCoreTargetIdentityPayload, Web2CoreTargetIdentityPayload, InferFromGithubPayload, GithubProof, InferFromTwitterPayload, TwitterProof, IdentityPayload, InferFromSignatureTargetIdentityPayload, PqcIdentityAssignPayload, PqcIdentityRemovePayload, UserPoints } from "
|
|
10
|
+
import { InferFromWritePayload, InferFromSignaturePayload, XMCoreTargetIdentityPayload, Web2CoreTargetIdentityPayload, InferFromGithubPayload, GithubProof, InferFromTwitterPayload, TwitterProof, IdentityPayload, InferFromSignatureTargetIdentityPayload, PqcIdentityAssignPayload, PqcIdentityRemovePayload, UserPoints } from "@/types/abstraction";
|
|
11
11
|
export { EvmCoinFinder, CoinFinder, Identities, InferFromWritePayload, InferFromSignaturePayload, XMCoreTargetIdentityPayload, Web2CoreTargetIdentityPayload, InferFromGithubPayload, GithubProof, InferFromTwitterPayload, TwitterProof, IdentityPayload, InferFromSignatureTargetIdentityPayload, PqcIdentityAssignPayload, PqcIdentityRemovePayload, UserPoints, };
|
|
@@ -1,16 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/** NOTE
|
|
3
|
-
* The finders should use public RPCs with failover mechanisms through the Providers singleton getter.
|
|
4
|
-
* The getter is automatically initialized, updated and imported in the exported finders.
|
|
5
|
-
* This is to ensure that the finders don't get rate limited or go offline.
|
|
6
|
-
* This also means that the SDK calls should be made locally (using the ip address of the user).
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.Identities = exports.CoinFinder = exports.EvmCoinFinder = void 0;
|
|
10
|
-
const EvmCoinFinder_1 = require("./EvmCoinFinder");
|
|
11
|
-
Object.defineProperty(exports, "EvmCoinFinder", { enumerable: true, get: function () { return EvmCoinFinder_1.EvmCoinFinder; } });
|
|
12
|
-
const CoinFinder_1 = require("./CoinFinder");
|
|
13
|
-
Object.defineProperty(exports, "CoinFinder", { enumerable: true, get: function () { return CoinFinder_1.CoinFinder; } });
|
|
14
|
-
const Identities_1 = require("./Identities");
|
|
15
|
-
Object.defineProperty(exports, "Identities", { enumerable: true, get: function () { return Identities_1.Identities; } });
|
|
16
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import{clusterApiUrl as t}from"@solana/web3.js";import*as e from"ethers";import n from"axios";import*as r from"crypto";import{randomBytes as s}from"crypto";import{getKernel as i}from"falcon-sign";import*as a from"node-forge";import o from"node-forge";import{promises as c}from"fs";class h{constructor(){this.evm={},this.solana={mainnet:[],testnet:[]},this.multiversx={mainnet:[],testnet:[]},this.xrp={mainnet:[],testnet:[]},this.bitcoin={mainnet:[],testnet:[]}}static getInstance(){return h._instance||(h._instance=new h),h._instance}registerEVM(t,e){this.evm[t]||(this.evm[t]=[]),this.evm[t].push(...e)}registerChainProviders(t,e,n){this[t]&&this[t][e]&&this[t][e].push(...n)}}const d=h.getInstance,l={eth:{mainnet:1,ropsten:3,rinkeby:4,goerli:5,sepolia:11155111,holesky:17e3},bsc:{mainnet:56,testnet:97},arbitrum:{mainnet:42161,testnet:421614},optimism:{mainnet:10,testnet:11155420}};var u;!function(t){t.ETHEREUM="ethereum",t.BSC="bsc",t.ARBITRUM="arbitrum",t.OPTIMISM="optimism",t.SOLANA="solana",t.MULTIVERSX="multiversx",t.XRP="xrp",t.BITCOIN="bitcoin",t.TON="ton"}(u||(u={}));const p={ethereum:{mainnet:"0x0000000000000000000000000000000000000000",sepolia:"0x0000000000000000000000000000000000000000",wrapped:{ethereum:{mainnet:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",testnet:"0xfff9976782d46cc05630d1f6ebab18b2324d6b14"},bsc:{mainnet:"0x2170Ed0880ac9A755fd29B2688956BD959F933F8",testnet:"0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd"},arbitrum:{mainnet:"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",testnet:"0x980B62Da83eFf3D4576C647993b0c1D7faf17c73"},optimism:{mainnet:"0x4200000000000000000000000000000000000006",testnet:"0x4200000000000000000000000000000000000006"}}},solana:{mainnet:"So11111111111111111111111111111111111111112",testnet:"So11111111111111111111111111111111111111112",wrapped:{ethereum:{mainnet:"0xD31a59c85aE9D8edEFeC411D448f90841571b89c",testnet:""},bsc:{mainnet:"0x570A5D26f7765Ecb712C0924E4De545B89fD43dF",testnet:""},arbitrum:{mainnet:"0x2bcC6D6CdBbDC0a4071e48bb3B969b06B3330c07",testnet:""},optimism:{mainnet:"",testnet:""}}},xrp:{mainnet:"XRP",testnet:"XRP",wrapped:{ethereum:{mainnet:"0x39fBBABf11738317a448031930706cd3e612e1B9",testnet:"0x0000000000000000000000000000000000000000"},bsc:{mainnet:"0x1D2F0da169ceB9fC7B3144628dB156f3F6c60dBE",testnet:"0x0000000000000000000000000000000000000000"},arbitrum:{mainnet:"0x0000000000000000000000000000000000000000",testnet:"0x0000000000000000000000000000000000000000"},optimism:{mainnet:"0x0000000000000000000000000000000000000000",testnet:"0x0000000000000000000000000000000000000000"}}},bitcoin:{mainnet:"BTC",testnet:"BTC",wrapped:{ethereum:{mainnet:"0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",testnet:"0x92c63d0e701CAAe670C9415d91C474F686298f00"},bsc:{mainnet:"0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c",testnet:"0x6ce8dA28E2f864420840cF74474eFf5fD80E65B8"},arbitrum:{mainnet:"0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",testnet:""},optimism:{mainnet:"0x68f180fcCe6836688e9084f035309E29Bf0A2095",testnet:""}}},multiversx:{mainnet:"EGLD",testnet:"EGLD",wrapped:{ethereum:{mainnet:"",testnet:""},bsc:{mainnet:"0xbF7c81FFF98BbE61B40Ed186e4AfD6DDd01337fe",testnet:""},arbitrum:{mainnet:"",testnet:""},optimism:{mainnet:"",testnet:""}}},usdc:{ethereum:{mainnet:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",testnet:"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"},bsc:{mainnet:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",testnet:"0x64544969ed7EBf5f083679233325356EbE738930"},arbitrum:{mainnet:"0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8",testnet:"0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"},optimism:{mainnet:"0x7F5c764cBc14f9669B88837ca1490cCa17c31607",testnet:"0x0000000000000000000000000000000000000000"},solana:{mainnet:"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",testnet:"4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU"},multiversx:{mainnet:"USDC-c76f1f",testnet:"USDC-8d4068"},xrp:{mainnet:"",testnet:""},ton:{mainnet:"",testnet:""}},usdt:{ethereum:{mainnet:"0xdAC17F958D2ee523a2206206994597C13D831ec7",testnet:"0x7169D38820dfd117C3FA1f22a697dBA58d90BA06"},bsc:{mainnet:"0x55d398326f99059fF775485246999027B3197955",testnet:"0x337610d27c682E347C9cD60BD4b3b107C9d34dDd"},arbitrum:{mainnet:"0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",testnet:"0x0000000000000000000000000000000000000000"},optimism:{mainnet:"0x94b008aA00579c1307B0EF2c499aD98a8ce58e58",testnet:"0x0000000000000000000000000000000000000000"},solana:{mainnet:"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",testnet:""},multiversx:{mainnet:"",testnet:""},xrp:{mainnet:"",testnet:""},ton:{mainnet:"",testnet:""}}};d().registerEVM(l.eth.mainnet.toString(),["https://rpc.ankr.com/eth","https://eth.drpc.org","https://eth.llamarpc.com","https://ethereum.publicnode.com","https://rpc.flashbots.net","https://rpc.payload.de","https://singapore.rpc.blxrbdn.com","https://uk.rpc.blxrbdn.com","https://virginia.rpc.blxrbdn.com"]),d().registerEVM(l.eth.sepolia.toString(),["https://rpc.ankr.com/eth_sepolia","https://eth-sepolia.public.blastapi.io","https://endpoints.omniatech.io/v1/eth/sepolia/public","https://1rpc.io/sepolia","https://ethereum-sepolia.blockpi.network/v1/rpc/private"]),d().registerEVM("bsc",["https://bsc-dataseed.bnbchain.org","https://bsc-dataseed.nariox.org","https://bsc-dataseed.defibit.io","https://bsc-dataseed.ninicoin.io","https://bsc.nodereal.io","https://bsc-dataseed-public.bnbchain.org","https://bnb.rpc.subquery.network/public"]),d().registerEVM("bsc_testnet",["https://bsc-testnet-dataseed.bnbchain.org","https://bsc-testnet.bnbchain.org","https://bsc-prebsc-dataseed.bnbchain.org"]),d().registerEVM("arbitrum",["https://arb1.arbitrum.io/rpc","https://rpc.ankr.com/arbitrum","https://arbitrum.drpc.org","https://arbitrum.meowrpc.com","https://arb-pokt.nodies.app"]),d().registerEVM("arbitrum_testnet",["https://sepolia-rollup.arbitrum.io/rpc"]),d().registerEVM("optimism",["https://mainnet.optimism.io","https://rpc.ankr.com/optimism","https://endpoints.omniatech.io/v1/op/mainnet/public","https://optimism-rpc.publicnode.com","https://optimism.drpc.org","https://optimism.meowrpc.com"]),d().registerEVM("optimism-sepolia",["https://api.zan.top/opt-sepolia","https://optimism-sepolia.gateway.tenderly.co","https://endpoints.omniatech.io/v1/op/sepolia/public","https://optimism-sepolia.drpc.org"]),d().solana.mainnet=["https://api.mainnet-beta.solana.com",t("mainnet-beta"),"https://solana.api.chainstack.com/mainnet-beta","https://api.metaplex.solana.com"],d().solana.testnet=["https://api.testnet.solana.com",t("testnet"),"https://api.metaplex.solana.com/testnet"],d().multiversx.mainnet=["https://api.multiversx.com","https://gateway.multiversx.com","https://api.elrond.com","https://elrond-api.public.blastapi.io"],d().multiversx.testnet=["https://testnet-api.multiversx.com","https://testnet-gateway.multiversx.com","https://testnet-api.elrond.com"],d().xrp.mainnet=["wss://xrplcluster.com","wss://s1.ripple.com:51233","wss://s2.ripple.com:51233","wss://s.devnet.rippletest.net:51233","wss://xrpl.ws"],d().xrp.testnet=["wss://s.altnet.rippletest.net:51233","wss://testnet.xrpl-labs.com"],d().bitcoin.mainnet=["https://blockstream.info/api","https://mempool.space/api","https://api.blockcypher.com/v1/btc/main","https://api.blockchain.info"],d().bitcoin.testnet=["https://blockstream.info/testnet/api","https://mempool.space/testnet/api","https://api.blockcypher.com/v1/btc/test3"];const f=d();class y extends Error{constructor(t,e,n){super(t),this.code=e,this.details=n}}class m{static getChainName(t){switch(t){case l.eth.mainnet:return u.ETHEREUM;case l.bsc.mainnet:return u.BSC;case l.arbitrum.mainnet:return u.ARBITRUM;case l.optimism.mainnet:return u.OPTIMISM;default:throw new Error(`Unsupported chain ID: ${t}`)}}static isValidAddress(t){return e.isAddress(t)}static getChainNameFromId(t){switch(t){case l.eth.mainnet:return u.ETHEREUM;case l.bsc.mainnet:return u.BSC;case l.arbitrum.mainnet:return u.ARBITRUM;case l.optimism.mainnet:return u.OPTIMISM;default:return}}static async getRandomProvider(t){const n=f.evm[t.toString()].filter(t=>!t.includes("flashbots.net")&&!t.includes("payload.de"));if(!n||0===n.length)throw new Error(`No providers found for chain ${t}`);const r=[...n].sort(()=>Math.random()-.5);for(const t of r)try{const n=new e.JsonRpcProvider(t,void 0,{staticNetwork:!0});return await n.getNetwork(),n}catch(t){continue}throw new Error(`All RPC providers failed for chain ${t}`)}static validateChainId(t){if(!Object.values(l).some(e=>Object.values(e).includes(t)))throw new y(`Unsupported chain ID: ${t}`,"UNSUPPORTED_CHAIN_ID")}static async findNativeEth(t){const e={};for(const n of t){let t;switch(this.validateChainId(n),n){case l.eth.mainnet:t=p.ethereum.wrapped.ethereum.mainnet;break;case l.bsc.mainnet:t=p.ethereum.wrapped.bsc.mainnet;break;case l.arbitrum.mainnet:t=p.ethereum.wrapped.arbitrum.mainnet;break;case l.optimism.mainnet:t=p.ethereum.wrapped.optimism.mainnet}t&&(e[n]={native:p.ethereum.mainnet,wrapped:t})}return e}static async findWrappedAssets(t){const e={};for(const n of t)this.validateChainId(n),e[n]={native:p.ethereum.mainnet,wrapped:p.ethereum.wrapped[this.getChainName(n)]?.mainnet||!1};return e}static async findTokenPairs(t,e,n){if(!this.isValidAddress(t))throw new y("Invalid token address","INVALID_ADDRESS",{address:t});const r={},s=await this.getRandomProvider(e);if("0x"===await s.getCode(t))throw new Error("Token contract not found on source chain");const i=this.getChainNameFromId(e);if(!i)throw new Error(`Unsupported chain ID: ${e}`);for(const s of n){if(s===e){r[s]={native:t,wrapped:!1};continue}const n=this.getChainNameFromId(s);n?t!==p.usdc[i]?.mainnet?t!==p.usdt[i]?.mainnet?r[s]={native:t,wrapped:!1}:r[s]={native:t,wrapped:p.usdt[n]?.mainnet||!1}:r[s]={native:t,wrapped:p.usdc[n]?.mainnet||!1}:r[s]={native:t,wrapped:!1}}return r}static getNativeForSupportedChain(t,e){switch(t){case u.ETHEREUM:if(e!==l.eth.mainnet)throw new Error("Chain ID doesn't match ethereum");return p.ethereum.mainnet;case u.BSC:if(e!==l.bsc.mainnet)throw new Error("Chain ID doesn't match bsc");break;case u.ARBITRUM:if(e!==l.arbitrum.mainnet)throw new Error("Chain ID doesn't match arbitrum");break;case u.OPTIMISM:if(e!==l.optimism.mainnet)throw new Error("Chain ID doesn't match optimism");break;default:throw new Error(`Unsupported chain: ${t}`)}return p.ethereum.mainnet}}class g{static validateChain(t){if(!Object.values(u).includes(t))throw new Error(`Invalid chain: ${t}`)}static async findWrappedToken(t,e){return this.validateChain(t),this.validateChain(e),p[t].wrapped?.[e]?.mainnet||!1}static getNativeForSupportedChain(t,e=1){const[n,r]=t.split("_");switch(n){case u.ETHEREUM:case u.BSC:case u.ARBITRUM:case u.OPTIMISM:if(e!=={[u.ETHEREUM]:l.eth.mainnet,[u.BSC]:l.bsc.mainnet,[u.ARBITRUM]:l.arbitrum.mainnet,[u.OPTIMISM]:l.optimism.mainnet}[n])throw new Error(`Chain ID doesn't match ${n}`);return p.ethereum[r];case u.SOLANA:case u.MULTIVERSX:case u.XRP:case u.BITCOIN:case u.TON:if(1!==e)throw new Error("Non-EVM chains only support targetChainId 1");return p[n][r];default:throw new Error(`Unsupported chain: ${t}`)}}}const b=BigInt(2**32-1),w=BigInt(32);function x(t,e=!1){return e?{h:Number(t&b),l:Number(t>>w&b)}:{h:0|Number(t>>w&b),l:0|Number(t&b)}}function A(t,e=!1){const n=t.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let i=0;i<n;i++){const{h:n,l:a}=x(t[i],e);[r[i],s[i]]=[n,a]}return[r,s]}const k=(t,e,n)=>t>>>n,_=(t,e,n)=>t<<32-n|e>>>n,E=(t,e,n)=>t>>>n|e<<32-n,v=(t,e,n)=>t<<32-n|e>>>n,I=(t,e,n)=>t<<64-n|e>>>n-32,C=(t,e,n)=>t>>>n-32|e<<64-n;function B(t,e,n,r){const s=(e>>>0)+(r>>>0);return{h:t+n+(s/2**32|0)|0,l:0|s}}const K=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),T=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,U=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),D=(t,e,n,r,s)=>e+n+r+s+(t/2**32|0)|0,S=(t,e,n,r,s)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(s>>>0),L=(t,e,n,r,s,i)=>e+n+r+s+i+(t/2**32|0)|0,F="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function H(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function P(t,...e){if(!((n=t)instanceof Uint8Array||ArrayBuffer.isView(n)&&"Uint8Array"===n.constructor.name))throw new Error("Uint8Array expected");var n;if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function M(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.createHasher");H(t.outputLen),H(t.blockLen)}function R(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function O(t,e){P(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function N(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function G(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function X(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function $(t,e){return t<<32-e|t>>>e}function V(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}const W=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])()?t=>t:function(t){for(let e=0;e<t.length;e++)t[e]=V(t[e]);return t},j=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),q=48,Y=57,J=65,Q=70,z=97,Z=102;function tt(t){return t>=q&&t<=Y?t-q:t>=J&&t<=Q?t-(J-10):t>=z&&t<=Z?t-(z-10):void 0}function et(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);if(j)return Uint8Array.fromHex(t);const e=t.length,n=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let e=0,s=0;e<n;e++,s+=2){const n=tt(t.charCodeAt(s)),i=tt(t.charCodeAt(s+1));if(void 0===n||void 0===i){const e=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+e+'" at index '+s)}r[e]=16*n+i}return r}function nt(t){if("string"!=typeof t)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(t))}function rt(t){return"string"==typeof t&&(t=nt(t)),P(t),t}function st(t){return"string"==typeof t&&(t=nt(t)),P(t),t}function it(...t){let e=0;for(let n=0;n<t.length;n++){const r=t[n];P(r),e+=r.length}const n=new Uint8Array(e);for(let e=0,r=0;e<t.length;e++){const s=t[e];n.set(s,r),r+=s.length}return n}class at{}function ot(t){const e=e=>t().update(rt(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function ct(t=32){if(F&&"function"==typeof F.getRandomValues)return F.getRandomValues(new Uint8Array(t));if(F&&"function"==typeof F.randomBytes)return Uint8Array.from(F.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}const ht=BigInt(0),dt=BigInt(1),lt=BigInt(2),ut=BigInt(7),pt=BigInt(256),ft=BigInt(113),yt=[],mt=[],gt=[];for(let t=0,e=dt,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],yt.push(2*(5*r+n)),mt.push((t+1)*(t+2)/2%64);let s=ht;for(let t=0;t<7;t++)e=(e<<dt^(e>>ut)*ft)%pt,e<&&(s^=dt<<(dt<<BigInt(t))-dt);gt.push(s)}const bt=A(gt,!0),wt=bt[0],xt=bt[1],At=(t,e,n)=>n>32?((t,e,n)=>e<<n-32|t>>>64-n)(t,e,n):((t,e,n)=>t<<n|e>>>32-n)(t,e,n),kt=(t,e,n)=>n>32?((t,e,n)=>t<<n-32|e>>>64-n)(t,e,n):((t,e,n)=>e<<n|t>>>32-n)(t,e,n);class _t extends at{constructor(t,e,n,r=!1,s=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=e,this.outputLen=n,this.enableXOF=r,this.rounds=s,H(n),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=N(this.state)}clone(){return this._cloneInto()}keccak(){W(this.state32),function(t,e=24){const n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let e=0;e<10;e++)n[e]=t[e]^t[e+10]^t[e+20]^t[e+30]^t[e+40];for(let e=0;e<10;e+=2){const r=(e+8)%10,s=(e+2)%10,i=n[s],a=n[s+1],o=At(i,a,1)^n[r],c=kt(i,a,1)^n[r+1];for(let n=0;n<50;n+=10)t[e+n]^=o,t[e+n+1]^=c}let e=t[2],s=t[3];for(let n=0;n<24;n++){const r=mt[n],i=At(e,s,r),a=kt(e,s,r),o=yt[n];e=t[o],s=t[o+1],t[o]=i,t[o+1]=a}for(let e=0;e<50;e+=10){for(let r=0;r<10;r++)n[r]=t[e+r];for(let r=0;r<10;r++)t[e+r]^=~n[(r+2)%10]&n[(r+4)%10]}t[0]^=wt[r],t[1]^=xt[r]}G(n)}(this.state32,this.rounds),W(this.state32),this.posOut=0,this.pos=0}update(t){R(this),P(t=rt(t));const{blockLen:e,state:n}=this,r=t.length;for(let s=0;s<r;){const i=Math.min(e-this.pos,r-s);for(let e=0;e<i;e++)n[this.pos++]^=t[s++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:n,blockLen:r}=this;t[n]^=e,128&e&&n===r-1&&this.keccak(),t[r-1]^=128,this.keccak()}writeInto(t){R(this,!1),P(t),this.finish();const e=this.state,{blockLen:n}=this;for(let r=0,s=t.length;r<s;){this.posOut>=n&&this.keccak();const i=Math.min(n-this.posOut,s-r);t.set(e.subarray(this.posOut,this.posOut+i),r),this.posOut+=i,r+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return H(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(O(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,G(this.state)}_cloneInto(t){const{blockLen:e,suffix:n,outputLen:r,rounds:s,enableXOF:i}=this;return t||(t=new _t(e,n,r,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=n,t.outputLen=r,t.enableXOF=i,t.destroyed=this.destroyed,t}}const Et=(t,e,n)=>ot(()=>new _t(e,t,n)),vt=(()=>Et(6,144,28))(),It=(()=>Et(6,136,32))(),Ct=(()=>Et(6,104,48))(),Bt=(()=>Et(6,72,64))(),Kt=(t,e,n)=>function(t){const e=(e,n)=>t(n).update(rt(e)).digest(),n=t({});return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=e=>t(e),e}((r={})=>new _t(e,t,void 0===r.dkLen?n:r.dkLen,!0)),Tt=(()=>Kt(31,168,16))(),Ut=(()=>Kt(31,136,32))();function Dt(t,e,n){return t&e^~t&n}function St(t,e,n){return t&e^t&n^e&n}class Lt extends at{constructor(t,e,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(t),this.view=X(this.buffer)}update(t){R(this),P(t=rt(t));const{view:e,buffer:n,blockLen:r}=this,s=t.length;for(let i=0;i<s;){const a=Math.min(r-this.pos,s-i);if(a===r){const e=X(t);for(;r<=s-i;i+=r)this.process(e,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===r&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){R(this),O(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:r,isLE:s}=this;let{pos:i}=this;e[i++]=128,G(this.buffer.subarray(i)),this.padOffset>r-i&&(this.process(n,0),i=0);for(let t=i;t<r;t++)e[t]=0;!function(t,e,n,r){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,n,r);const s=BigInt(32),i=BigInt(4294967295),a=Number(n>>s&i),o=Number(n&i),c=r?4:0,h=r?0:4;t.setUint32(e+c,a,r),t.setUint32(e+h,o,r)}(n,r-8,BigInt(8*this.length),s),this.process(n,0);const a=X(t),o=this.outputLen;if(o%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=o/4,h=this.get();if(c>h.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<c;t++)a.setUint32(4*t,h[t],s)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:n,length:r,finished:s,destroyed:i,pos:a}=this;return t.destroyed=i,t.finished=s,t.length=r,t.pos=a,r%e&&t.buffer.set(n),t}clone(){return this._cloneInto()}}const Ft=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ht=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),Pt=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),Mt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),Rt=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ot=new Uint32Array(64);class Nt extends Lt{constructor(t=32){super(64,t,8,!1),this.A=0|Ft[0],this.B=0|Ft[1],this.C=0|Ft[2],this.D=0|Ft[3],this.E=0|Ft[4],this.F=0|Ft[5],this.G=0|Ft[6],this.H=0|Ft[7]}get(){const{A:t,B:e,C:n,D:r,E:s,F:i,G:a,H:o}=this;return[t,e,n,r,s,i,a,o]}set(t,e,n,r,s,i,a,o){this.A=0|t,this.B=0|e,this.C=0|n,this.D=0|r,this.E=0|s,this.F=0|i,this.G=0|a,this.H=0|o}process(t,e){for(let n=0;n<16;n++,e+=4)Ot[n]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=Ot[t-15],n=Ot[t-2],r=$(e,7)^$(e,18)^e>>>3,s=$(n,17)^$(n,19)^n>>>10;Ot[t]=s+Ot[t-7]+r+Ot[t-16]|0}let{A:n,B:r,C:s,D:i,E:a,F:o,G:c,H:h}=this;for(let t=0;t<64;t++){const e=h+($(a,6)^$(a,11)^$(a,25))+Dt(a,o,c)+Rt[t]+Ot[t]|0,d=($(n,2)^$(n,13)^$(n,22))+St(n,r,s)|0;h=c,c=o,o=a,a=i+e|0,i=s,s=r,r=n,n=e+d|0}n=n+this.A|0,r=r+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,o=o+this.F|0,c=c+this.G|0,h=h+this.H|0,this.set(n,r,s,i,a,o,c,h)}roundClean(){G(Ot)}destroy(){this.set(0,0,0,0,0,0,0,0),G(this.buffer)}}class Gt extends Nt{constructor(){super(28),this.A=0|Ht[0],this.B=0|Ht[1],this.C=0|Ht[2],this.D=0|Ht[3],this.E=0|Ht[4],this.F=0|Ht[5],this.G=0|Ht[6],this.H=0|Ht[7]}}const Xt=(()=>A(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))))(),$t=(()=>Xt[0])(),Vt=(()=>Xt[1])(),Wt=new Uint32Array(80),jt=new Uint32Array(80);class qt extends Lt{constructor(t=64){super(128,t,16,!1),this.Ah=0|Mt[0],this.Al=0|Mt[1],this.Bh=0|Mt[2],this.Bl=0|Mt[3],this.Ch=0|Mt[4],this.Cl=0|Mt[5],this.Dh=0|Mt[6],this.Dl=0|Mt[7],this.Eh=0|Mt[8],this.El=0|Mt[9],this.Fh=0|Mt[10],this.Fl=0|Mt[11],this.Gh=0|Mt[12],this.Gl=0|Mt[13],this.Hh=0|Mt[14],this.Hl=0|Mt[15]}get(){const{Ah:t,Al:e,Bh:n,Bl:r,Ch:s,Cl:i,Dh:a,Dl:o,Eh:c,El:h,Fh:d,Fl:l,Gh:u,Gl:p,Hh:f,Hl:y}=this;return[t,e,n,r,s,i,a,o,c,h,d,l,u,p,f,y]}set(t,e,n,r,s,i,a,o,c,h,d,l,u,p,f,y){this.Ah=0|t,this.Al=0|e,this.Bh=0|n,this.Bl=0|r,this.Ch=0|s,this.Cl=0|i,this.Dh=0|a,this.Dl=0|o,this.Eh=0|c,this.El=0|h,this.Fh=0|d,this.Fl=0|l,this.Gh=0|u,this.Gl=0|p,this.Hh=0|f,this.Hl=0|y}process(t,e){for(let n=0;n<16;n++,e+=4)Wt[n]=t.getUint32(e),jt[n]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|Wt[t-15],n=0|jt[t-15],r=E(e,n,1)^E(e,n,8)^k(e,0,7),s=v(e,n,1)^v(e,n,8)^_(e,n,7),i=0|Wt[t-2],a=0|jt[t-2],o=E(i,a,19)^I(i,a,61)^k(i,0,6),c=v(i,a,19)^C(i,a,61)^_(i,a,6),h=U(s,c,jt[t-7],jt[t-16]),d=D(h,r,o,Wt[t-7],Wt[t-16]);Wt[t]=0|d,jt[t]=0|h}let{Ah:n,Al:r,Bh:s,Bl:i,Ch:a,Cl:o,Dh:c,Dl:h,Eh:d,El:l,Fh:u,Fl:p,Gh:f,Gl:y,Hh:m,Hl:g}=this;for(let t=0;t<80;t++){const e=E(d,l,14)^E(d,l,18)^I(d,l,41),b=v(d,l,14)^v(d,l,18)^C(d,l,41),w=d&u^~d&f,x=S(g,b,l&p^~l&y,Vt[t],jt[t]),A=L(x,m,e,w,$t[t],Wt[t]),k=0|x,_=E(n,r,28)^I(n,r,34)^I(n,r,39),U=v(n,r,28)^C(n,r,34)^C(n,r,39),D=n&s^n&a^s&a,F=r&i^r&o^i&o;m=0|f,g=0|y,f=0|u,y=0|p,u=0|d,p=0|l,({h:d,l:l}=B(0|c,0|h,0|A,0|k)),c=0|a,h=0|o,a=0|s,o=0|i,s=0|n,i=0|r;const H=K(k,U,F);n=T(H,A,_,D),r=0|H}({h:n,l:r}=B(0|this.Ah,0|this.Al,0|n,0|r)),({h:s,l:i}=B(0|this.Bh,0|this.Bl,0|s,0|i)),({h:a,l:o}=B(0|this.Ch,0|this.Cl,0|a,0|o)),({h:c,l:h}=B(0|this.Dh,0|this.Dl,0|c,0|h)),({h:d,l:l}=B(0|this.Eh,0|this.El,0|d,0|l)),({h:u,l:p}=B(0|this.Fh,0|this.Fl,0|u,0|p)),({h:f,l:y}=B(0|this.Gh,0|this.Gl,0|f,0|y)),({h:m,l:g}=B(0|this.Hh,0|this.Hl,0|m,0|g)),this.set(n,r,s,i,a,o,c,h,d,l,u,p,f,y,m,g)}roundClean(){G(Wt,jt)}destroy(){G(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class Yt extends qt{constructor(){super(48),this.Ah=0|Pt[0],this.Al=0|Pt[1],this.Bh=0|Pt[2],this.Bl=0|Pt[3],this.Ch=0|Pt[4],this.Cl=0|Pt[5],this.Dh=0|Pt[6],this.Dl=0|Pt[7],this.Eh=0|Pt[8],this.El=0|Pt[9],this.Fh=0|Pt[10],this.Fl=0|Pt[11],this.Gh=0|Pt[12],this.Gl=0|Pt[13],this.Hh=0|Pt[14],this.Hl=0|Pt[15]}}const Jt=Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),Qt=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);class zt extends qt{constructor(){super(28),this.Ah=0|Jt[0],this.Al=0|Jt[1],this.Bh=0|Jt[2],this.Bl=0|Jt[3],this.Ch=0|Jt[4],this.Cl=0|Jt[5],this.Dh=0|Jt[6],this.Dl=0|Jt[7],this.Eh=0|Jt[8],this.El=0|Jt[9],this.Fh=0|Jt[10],this.Fl=0|Jt[11],this.Gh=0|Jt[12],this.Gl=0|Jt[13],this.Hh=0|Jt[14],this.Hl=0|Jt[15]}}class Zt extends qt{constructor(){super(32),this.Ah=0|Qt[0],this.Al=0|Qt[1],this.Bh=0|Qt[2],this.Bl=0|Qt[3],this.Ch=0|Qt[4],this.Cl=0|Qt[5],this.Dh=0|Qt[6],this.Dl=0|Qt[7],this.Eh=0|Qt[8],this.El=0|Qt[9],this.Fh=0|Qt[10],this.Fl=0|Qt[11],this.Gh=0|Qt[12],this.Gl=0|Qt[13],this.Hh=0|Qt[14],this.Hl=0|Qt[15]}}const te=ot(()=>new Nt),ee=ot(()=>new Gt),ne=ot(()=>new qt),re=ot(()=>new Yt),se=ot(()=>new Zt),ie=ot(()=>new zt),ae=P,oe=ct;function ce(t,e){if(t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t[r]^e[r];return 0===n}function he(...t){const e=t=>"number"==typeof t?t:t.bytesLen,n=t.reduce((t,n)=>t+e(n),0);return{bytesLen:n,encode:r=>{const s=new Uint8Array(n);for(let n=0,i=0;n<t.length;n++){const a=t[n],o=e(a),c="number"==typeof a?r[n]:a.encode(r[n]);ae(c,o),s.set(c,i),"number"!=typeof a&&c.fill(0),i+=o}return s},decode:r=>{ae(r,n);const s=[];for(const n of t){const t=e(n),i=r.subarray(0,t);s.push("number"==typeof n?i:n.decode(i)),r=r.subarray(t)}return s}}}function de(t,e){const n=e*t.bytesLen;return{bytesLen:n,encode:r=>{if(r.length!==e)throw new Error(`vecCoder.encode: wrong length=${r.length}. Expected: ${e}`);const s=new Uint8Array(n);for(let e=0,n=0;e<r.length;e++){const i=t.encode(r[e]);s.set(i,n),i.fill(0),n+=i.length}return s},decode:e=>{ae(e,n);const r=[];for(let n=0;n<e.length;n+=t.bytesLen)r.push(t.decode(e.subarray(n,n+t.bytesLen)));return r}}}function le(...t){for(const e of t)if(Array.isArray(e))for(const t of e)t.fill(0);else e.fill(0)}function ue(t){return(1<<t)-1}const pe=new Uint8Array(0);function fe(t,e=pe){if(ae(t),ae(e),e.length>255)throw new Error("context should be less than 255 bytes");return it(new Uint8Array([0,e.length]),e,t)}const ye={"SHA2-256":{oid:et("0609608648016503040201"),hash:te},"SHA2-384":{oid:et("0609608648016503040202"),hash:re},"SHA2-512":{oid:et("0609608648016503040203"),hash:ne},"SHA2-224":{oid:et("0609608648016503040204"),hash:ee},"SHA2-512/224":{oid:et("0609608648016503040205"),hash:ie},"SHA2-512/256":{oid:et("0609608648016503040206"),hash:se},"SHA3-224":{oid:et("0609608648016503040207"),hash:vt},"SHA3-256":{oid:et("0609608648016503040208"),hash:It},"SHA3-384":{oid:et("0609608648016503040209"),hash:Ct},"SHA3-512":{oid:et("060960864801650304020A"),hash:Bt},"SHAKE-128":{oid:et("060960864801650304020B"),hash:t=>Tt(t,{dkLen:32})},"SHAKE-256":{oid:et("060960864801650304020C"),hash:t=>Ut(t,{dkLen:64})}};function me(t,e,n=pe){if(ae(e),ae(n),n.length>255)throw new Error("context should be less than 255 bytes");if(!ye[t])throw new Error("unknown hash: "+t);const{oid:r,hash:s}=ye[t],i=s(e);return it(new Uint8Array([1,n.length]),n,r,i)}function ge(t,e=8){const n=t.toString(2).padStart(8,"0").slice(-e).padStart(7,"0").split("").reverse().join("");return Number.parseInt(n,2)}const be=t=>{const{newPoly:e,N:n,Q:r,F:s,ROOT_OF_UNITY:i,brvBits:a,isKyber:o}=t,c=(t,e=r)=>{const n=t%e|0;return 0|(n>=0?n:e+n)};const h=function(){const t=e(n);for(let e=0;e<n;e++){const n=ge(e,a),s=BigInt(i)**BigInt(n)%BigInt(r);t[e]=0|Number(s)}return t}(),d=o?128:n,l=o?1:0,u={encode:t=>{for(let e=1,r=128;r>l;r>>=1)for(let s=0;s<n;s+=2*r){const n=h[e++];for(let e=s;e<s+r;e++){const s=c(n*t[e+r]);t[e+r]=0|c(t[e]-s),t[e]=0|c(t[e]+s)}}return t},decode:t=>{for(let e=d-1,r=1+l;r<d+l;r<<=1)for(let s=0;s<n;s+=2*r){const n=h[e--];for(let e=s;e<s+r;e++){const s=t[e];t[e]=c(s+t[e+r]),t[e+r]=c(n*(t[e+r]-s))}}for(let e=0;e<t.length;e++)t[e]=c(s*t[e]);return t}};return{mod:c,smod:(t,e=r)=>{const n=0|c(t,e);return 0|(n>e>>1?n-e:n)},nttZetas:h,NTT:u,bitsCoder:(t,r)=>{const s=ue(t),i=t*(n/8);return{bytesLen:i,encode:e=>{const n=new Uint8Array(i);for(let i=0,a=0,o=0,c=0;i<e.length;i++)for(a|=(r.encode(e[i])&s)<<o,o+=t;o>=8;o-=8,a>>=8)n[c++]=a&ue(o);return n},decode:i=>{const a=e(n);for(let e=0,n=0,o=0,c=0;e<i.length;e++)for(n|=i[e]<<o,o+=8;o>=t;o-=t,n>>=t)a[c++]=r.decode(n&s);return a}}}}},we=t=>(e,n)=>{n||(n=t.blockLen);const r=new Uint8Array(e.length+2);r.set(e);const s=e.length,i=new Uint8Array(n);let a=t.create({}),o=0,c=0;return{stats:()=>({calls:o,xofs:c}),get:(e,n)=>(r[s+0]=e,r[s+1]=n,a=t.create({}).update(r),o++,()=>(c++,a.xofInto(i))),clean:()=>{i.fill(0),r.fill(0)}}},xe=we(Tt),Ae=we(Ut),ke=256,_e=3329,{mod:Ee,nttZetas:ve,NTT:Ie,bitsCoder:Ce}=be({N:ke,Q:_e,F:3303,ROOT_OF_UNITY:17,newPoly:t=>new Uint16Array(t),brvBits:7,isKyber:!0}),Be=t=>Ce(t,(t=>{if(t>=12)return{encode:t=>t,decode:t=>t};const e=2**(t-1);return{encode:e=>((e<<t)+_e/2)/_e,decode:n=>n*_e+e>>>t}})(t));function Ke(t,e){for(let n=0;n<ke;n++)t[n]=Ee(t[n]+e[n])}function Te(t,e,n,r,s){return{c0:Ee(e*r*s+t*n),c1:Ee(t*r+e*n)}}function Ue(t,e){for(let n=0;n<128;n++){let r=ve[64+(n>>1)];1&n&&(r=-r);const{c0:s,c1:i}=Te(t[2*n+0],t[2*n+1],e[2*n+0],e[2*n+1],r);t[2*n+0]=s,t[2*n+1]=i}return t}function De(t){const e=new Uint16Array(ke);for(let n=0;n<ke;){const r=t();if(r.length%3)throw new Error("SampleNTT: unaligned block");for(let t=0;n<ke&&t+3<=r.length;t+=3){const s=4095&(r[t+0]|r[t+1]<<8),i=4095&(r[t+1]>>4|r[t+2]<<4);s<_e&&(e[n++]=s),n<ke&&i<_e&&(e[n++]=i)}}return e}function Se(t,e,n,r){const s=t(r*ke/4,e,n),i=new Uint16Array(ke),a=N(s);let o=0;for(let t=0,e=0,n=0,s=0;t<a.length;t++){let c=a[t];for(let t=0;t<32;t++)n+=1&c,c>>=1,o+=1,o===r?(s=n,n=0):o===2*r&&(i[e++]=Ee(s-n),n=0,o=0)}if(o)throw new Error(`sampleCBD: leftover bits: ${o}`);return i}const Le=t=>{const{K:e,PRF:n,XOF:r,HASH512:s,ETA1:i,ETA2:a,du:o,dv:c}=t,h=Be(1),d=Be(c),l=Be(o),u=he(de(Be(12),e),32),p=de(Be(12),e),f=he(de(l,e),d),y=he(32,32);return{secretCoder:p,secretKeyLen:p.bytesLen,publicKeyLen:u.bytesLen,cipherTextLen:f.bytesLen,keygen:t=>{ae(t,32);const a=new Uint8Array(33);a.set(t),a[32]=e;const o=s(a),[c,h]=y.decode(o),d=[],l=[];for(let t=0;t<e;t++)d.push(Ie.encode(Se(n,h,t,i)));const f=r(c);for(let t=0;t<e;t++){const r=Ie.encode(Se(n,h,e+t,i));for(let n=0;n<e;n++){Ke(r,Ue(De(f.get(n,t)),d[n]))}l.push(r)}f.clean();const m={publicKey:u.encode([l,c]),secretKey:p.encode(d)};return le(c,h,d,l,a,o),m},encrypt:(t,s,o)=>{const[c,d]=u.decode(t),l=[];for(let t=0;t<e;t++)l.push(Ie.encode(Se(n,o,t,i)));const p=r(d),y=new Uint16Array(ke),m=[];for(let t=0;t<e;t++){const r=Se(n,o,e+t,a),s=new Uint16Array(ke);for(let n=0;n<e;n++){Ke(s,Ue(De(p.get(t,n)),l[n]))}Ke(r,Ie.decode(s)),m.push(r),Ke(y,Ue(c[t],l[t])),s.fill(0)}p.clean();const g=Se(n,o,2*e,a);Ke(g,Ie.decode(y));const b=h.decode(s);return Ke(b,g),le(c,l,y,g),f.encode([m,b])},decrypt:(t,n)=>{const[r,s]=f.decode(t),i=p.decode(n),a=new Uint16Array(ke);for(let t=0;t<e;t++)Ke(a,Ue(i[t],Ie.encode(r[t])));return function(t,e){for(let n=0;n<ke;n++)t[n]=Ee(t[n]-e[n])}(s,Ie.decode(a)),le(a,i,r),h.encode(s)}}};function Fe(t){const e=Le(t),{HASH256:n,HASH512:r,KDF:s}=t,{secretCoder:i,cipherTextLen:a}=e,o=e.publicKeyLen,c=he(e.secretKeyLen,e.publicKeyLen,32,32),h=c.bytesLen;return{publicKeyLen:o,msgLen:32,keygen:(t=oe(64))=>{ae(t,64);const{publicKey:r,secretKey:s}=e.keygen(t.subarray(0,32)),i=n(r),a=c.encode([s,r,i,t.subarray(32)]);return le(s,i),{publicKey:r,secretKey:a}},encapsulate:(s,a=oe(32))=>{ae(s,o),ae(a,32);const c=s.subarray(0,384*t.K),h=i.encode(i.decode(c.slice()));if(!ce(h,c))throw le(h),new Error("ML-KEM.encapsulate: wrong publicKey modulus");le(h);const d=r.create().update(a).update(n(s)).digest(),l=e.encrypt(s,a,d.subarray(32,64));return d.subarray(32).fill(0),{cipherText:l,sharedSecret:d.subarray(0,32)}},decapsulate:(t,n)=>{ae(n,h),ae(t,a);const[i,o,d,l]=c.decode(n),u=e.decrypt(t,i),p=r.create().update(u).update(d).digest(),f=p.subarray(0,32),y=e.encrypt(o,u,p.subarray(32,64)),m=ce(t,y),g=s.create({dkLen:32}).update(l).update(t).digest();return le(u,y,m?g:f),m?f:g}}}const He=Fe({...{HASH256:It,HASH512:Bt,KDF:Ut,XOF:xe,PRF:function(t,e,n){return Ut.create({dkLen:t}).update(e).update(new Uint8Array([n])).digest()}},...{N:ke,Q:_e,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192}}),Pe=256,Me=8380417,Re=0|Math.floor(95232),Oe=0|Math.floor(261888),Ne={K:6,L:5,D:13,GAMMA1:2**19,GAMMA2:Oe,TAU:49,ETA:4,OMEGA:55},Ge=t=>new Int32Array(t),{mod:Xe,smod:$e,NTT:Ve,bitsCoder:We}=be({N:Pe,Q:Me,F:8347681,ROOT_OF_UNITY:1753,newPoly:Ge,isKyber:!1,brvBits:8}),je=t=>t,qe=(t,e=je,n=je)=>We(t,{encode:t=>e(n(t)),decode:t=>n(e(t))}),Ye=(t,e)=>{for(let n=0;n<t.length;n++)t[n]=Xe(t[n]+e[n]);return t},Je=(t,e)=>{for(let n=0;n<t.length;n++)t[n]=Xe(t[n]-e[n]);return t},Qe=t=>{for(let e=0;e<Pe;e++)t[e]<<=13;return t},ze=(t,e)=>{for(let n=0;n<Pe;n++)if(Math.abs($e(t[n]))>=e)return!0;return!1},Ze=(t,e)=>{const n=Ge(Pe);for(let r=0;r<t.length;r++)n[r]=Xe(t[r]*e[r]);return n};function tn(t){const e=Ge(Pe);for(let n=0;n<Pe;){const r=t();if(r.length%3)throw new Error("RejNTTPoly: unaligned block");for(let t=0;n<Pe&&t<=r.length-3;t+=3){const s=8388607&(r[t+0]|r[t+1]<<8|r[t+2]<<16);s<Me&&(e[n++]=s)}}return e}function en(t){const{K:e,L:n,GAMMA1:r,GAMMA2:s,TAU:i,ETA:a,OMEGA:o}=t,{CRH_BYTES:c,TR_BYTES:h,C_TILDE_BYTES:d,XOF128:l,XOF256:u}=t;if(![2,4].includes(a))throw new Error("Wrong ETA");if(![1<<17,1<<19].includes(r))throw new Error("Wrong GAMMA1");if(![Re,Oe].includes(s))throw new Error("Wrong GAMMA2");const p=i*a,f=t=>{const e=Xe(t),n=0|$e(e,2*s);if(e-n===Me-1)return{r1:0,r0:n-1|0};return{r1:0|Math.floor((e-n)/(2*s)),r0:n}},y=t=>f(t).r1,m=t=>f(t).r0,g=(t,e)=>t<=s||t>Me-s||t===Me-s&&0===e?0:1,b=(t,e)=>{const n=Math.floor((Me-1)/(2*s)),{r1:r,r0:i}=f(e);return 1===t?i>0?0|Xe(r+1,n):0|Xe(r-1,n):0|r},w=t=>{const e=Xe(t),n=0|$e(e,8192);return{r1:0|Math.floor((e-n)/8192),r0:n}},x={bytesLen:o+e,encode:t=>{if(!1===t)throw new Error("hint.encode: hint is false");const n=new Uint8Array(o+e);for(let r=0,s=0;r<e;r++){for(let e=0;e<Pe;e++)0!==t[r][e]&&(n[s++]=e);n[o+r]=s}return n},decode:t=>{let n=0;for(let r=0;r<e;r++){const e=Ge(Pe);if(t[o+r]<n||t[o+r]>o)return!1;for(let s=n;s<t[o+r];s++){if(s>n&&t[s]<=t[s-1])return!1;e[t[s]]=1}n=t[o+r]}for(let e=n;e<o;e++)if(0!==t[e])return!1;return[]}},A=qe(2===a?3:4,t=>a-t,t=>{if(!(-a<=t&&t<=a))throw new Error(`malformed key s1/s3 ${t} outside of ETA range [${-a}, ${a}]`);return t}),k=qe(13,t=>4096-t),_=qe(10),E=qe(r===1<<17?18:20,t=>$e(r-t)),v=de(qe(s===Re?6:4),e),I=he(32,de(_,e)),C=he(32,32,h,de(A,n),de(A,e),de(k,e)),B=he(d,de(E,n),x),K=2===a?t=>t<15&&2-t%5:t=>t<9&&4-t;function T(t){const e=Ge(Pe);for(let n=0;n<Pe;){const r=t();for(let t=0;n<Pe&&t<r.length;t+=1){const s=K(15&r[t]),i=K(r[t]>>4&15);!1!==s&&(e[n++]=s),n<Pe&&!1!==i&&(e[n++]=i)}}return e}const U=t=>{const e=Ge(Pe),n=Ut.create({}).update(t),r=new Uint8Array(Ut.blockLen);n.xofInto(r);const s=r.slice(0,8);for(let t=Pe-i,a=8,o=0,c=0;t<Pe;t++){let i=t+1;for(;i>t;)i=r[a++],a<Ut.blockLen||(n.xofInto(r),a=0);e[t]=e[i],e[i]=1-((s[o]>>c++&1)<<1),c>=8&&(o++,c=0)}return e},D=t=>{const e=Ge(Pe),n=Ge(Pe);for(let r=0;r<t.length;r++){const{r0:s,r1:i}=w(t[r]);e[r]=s,n[r]=i}return{r0:e,r1:n}},S=(t,e)=>{for(let n=0;n<Pe;n++)t[n]=b(e[n],t[n]);return t},L=(t,e)=>{const n=Ge(Pe);let r=0;for(let s=0;s<Pe;s++){const i=g(t[s],e[s]);n[s]=i,r+=i}return{v:n,cnt:r}},F=he(32,64,32),H={signRandBytes:32,keygen:t=>{const r=new Uint8Array(34),s=void 0===t;s&&(t=oe(32)),ae(t,32),r.set(t),s&&t.fill(0),r[32]=e,r[33]=n;const[i,a,o]=F.decode(Ut(r,{dkLen:F.bytesLen})),c=u(a),d=[];for(let t=0;t<n;t++)d.push(T(c.get(255&t,t>>8&255)));const p=[];for(let t=n;t<n+e;t++)p.push(T(c.get(255&t,t>>8&255)));const f=d.map(t=>Ve.encode(t.slice())),y=[],m=[],g=l(i),b=Ge(Pe);for(let t=0;t<e;t++){b.fill(0);for(let e=0;e<n;e++){const n=tn(g.get(e,t));Ye(b,Ze(n,f[e]))}Ve.decode(b);const{r0:e,r1:r}=D(Ye(b,p[t]));y.push(e),m.push(r)}const w=I.encode([i,m]),x=Ut(w,{dkLen:h}),A=C.encode([i,o,x,d,p,y]);return g.clean(),c.clean(),le(i,a,o,d,p,f,b,y,m,x,r),{publicKey:w,secretKey:A}},sign:(t,i,a,h=!1)=>{const[f,g,b,w,x,A]=C.decode(t),k=[],_=l(f);for(let t=0;t<e;t++){const e=[];for(let r=0;r<n;r++)e.push(tn(_.get(r,t)));k.push(e)}_.clean();for(let t=0;t<n;t++)Ve.encode(w[t]);for(let t=0;t<e;t++)Ve.encode(x[t]),Ve.encode(A[t]);const I=h?i:Ut.create({dkLen:c}).update(b).update(i).digest(),K=a||new Uint8Array(32);ae(K);const T=Ut.create({dkLen:c}).update(g).update(K).update(I).digest();ae(T,c);const D=u(T,E.bytesLen);t:for(let t=0;;){const i=[];for(let e=0;e<n;e++,t++)i.push(E.decode(D.get(255&t,t>>8)()));const a=i.map(t=>Ve.encode(t.slice())),c=[];for(let t=0;t<e;t++){const e=Ge(Pe);for(let r=0;r<n;r++)Ye(e,Ze(k[t][r],a[r]));Ve.decode(e),c.push(e)}const h=c.map(t=>t.map(y)),l=Ut.create({dkLen:d}).update(I).update(v.encode(h)).digest(),u=Ve.encode(U(l)),f=w.map(t=>Ze(t,u));for(let t=0;t<n;t++)if(Ye(Ve.decode(f[t]),i[t]),ze(f[t],r-p))continue t;let g=0;const b=[];for(let t=0;t<e;t++){const e=Ve.decode(Ze(x[t],u)),n=Je(c[t],e).map(m);if(ze(n,s-p))continue t;const r=Ve.decode(Ze(A[t],u));if(ze(r,s))continue t;Ye(n,r);g+=L(n,h[t]).cnt}if(g>o)continue;D.clean();const _=B.encode([l,f,b]);return le(l,f,b,u,h,c,a,i,T,I,w,x,A,...k),_}throw new Error("Unreachable code path reached, report this error")},verify:(t,s,i,a=!1)=>{const[u,f]=I.decode(t),y=Ut(t,{dkLen:h});if(i.length!==B.bytesLen)return!1;const[m,g,b]=B.decode(i);if(!1===b)return!1;for(let t=0;t<n;t++)if(ze(g[t],r-p))return!1;const w=a?s:Ut.create({dkLen:c}).update(y).update(s).digest(),x=Ve.encode(U(m)),A=g.map(t=>t.slice());for(let t=0;t<n;t++)Ve.encode(A[t]);const k=[],_=l(u);for(let t=0;t<e;t++){const e=Ze(Ve.encode(Qe(f[t])),x),r=Ge(Pe);for(let e=0;e<n;e++){const n=tn(_.get(e,t));Ye(r,Ze(n,A[e]))}const s=Ve.decode(Je(r,e));k.push(S(s,b[t]))}_.clean();const E=Ut.create({dkLen:d}).update(w).update(v.encode(k)).digest();for(const t of b){if(!(t.reduce((t,e)=>t+e,0)<=o))return!1}for(const t of g)if(ze(t,r-p))return!1;return ce(m,E)}};return{internal:H,keygen:H.keygen,signRandBytes:H.signRandBytes,sign:(t,e,n=pe,r)=>{const s=fe(e,n),i=H.sign(t,s,r);return s.fill(0),i},verify:(t,e,n,r=pe)=>H.verify(t,fe(e,r),n),prehash:t=>({sign:(e,n,r=pe,s)=>{const i=me(t,n,r),a=H.sign(e,i,s);return i.fill(0),a},verify:(e,n,r,s=pe)=>H.verify(e,me(t,n,s),r)})}}const nn=en({...Ne,CRH_BYTES:64,TR_BYTES:64,C_TILDE_BYTES:48,XOF128:xe,XOF256:Ae});class rn{constructor(t){if(t&&"falcon512_n3_v1"!==t&&"falcon1024_n3_v1"!==t)throw new Error(`Invalid algorithm ID: ${t}\nSupported algorithms: falcon512_n3_v1, falcon1024_n3_v1\nLeave blank for default: falcon512_n3_v1`);this.algid=t||"falcon512_n3_v1"}async init(){this.kernel=await i(this.algid)}async genkey(t){this.keypair=t?this.kernel.genkey(t):this.kernel.genkey()}async sign(t,e){return e?this.kernel.sign(t,this.keypair.sk,e):this.kernel.sign(t,this.keypair.sk)}async verify(t,e,n){return this.kernel.verify(e,t,n)}async publicKeyCreate(t){return this.kernel.publicKeyCreate(t)}async setKeypair(t){this.keypair=t}async getPublicKey(){return this.keypair.pk}async getPrivateKey(){return this.keypair.sk}async getAlgid(){return this.algid}async getKeypair(){return this.keypair}async getKernel(){return this.kernel}static uint8ArrayToHex(t){return Array.from(t).map(t=>t.toString(16).padStart(2,"0")).join("")}static hexToUint8Array(t){(t=t.replace(/[^0-9a-fA-F]/g,"")).length%2!=0&&(t="0"+t);const e=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)e[n/2]=parseInt(t.substring(n,n+2),16);return e}async getPublicKeyHex(){const t=await this.getPublicKey();return rn.uint8ArrayToHex(t)}async getPrivateKeyHex(){const t=await this.getPrivateKey();return rn.uint8ArrayToHex(t)}async signHex(t){const e=await this.sign(t);return rn.uint8ArrayToHex(e)}async verifyHex(t,e,n){const r=rn.hexToUint8Array(e),s=rn.hexToUint8Array(n);return this.verify(t,r,s)}async publicKeyCreateHex(t){const e=rn.hexToUint8Array(t),n=await this.publicKeyCreate(e);return rn.uint8ArrayToHex(n)}async setPrivateKeyHex(t){const e=rn.hexToUint8Array(t),n=await this.publicKeyCreate(e);return this.keypair={genkeySeed:new Uint8Array(0),sk:e,pk:n},rn.uint8ArrayToHex(n)}static uint8ArrayToBase64(t){return Buffer.from(t).toString("base64")}static base64ToUint8Array(t){return Buffer.from(t,"base64")}async getPublicKeyBase64(){const t=await this.getPublicKey();return rn.uint8ArrayToBase64(t)}async getPrivateKeyBase64(){const t=await this.getPrivateKey();return rn.uint8ArrayToBase64(t)}async signBase64(t){const e=await this.sign(t);return rn.uint8ArrayToBase64(e)}async verifyBase64(t,e,n){const r=rn.base64ToUint8Array(e),s=rn.base64ToUint8Array(n);return this.verify(t,r,s)}async publicKeyCreateBase64(t){const e=rn.base64ToUint8Array(t),n=await this.publicKeyCreate(e);return rn.uint8ArrayToBase64(n)}async setPrivateKeyBase64(t){const e=rn.base64ToUint8Array(t),n=await this.publicKeyCreate(e);return this.keypair={genkeySeed:new Uint8Array(0),sk:e,pk:n},rn.uint8ArrayToBase64(n)}}class sn{constructor(){this.ml_dsa_signing_keypair=null,this.falcon_signing_keypair=null,this.ml_kem_encryption_keypair=null,this.ml_kem_aes_parameters=null}static async hash(t,e="sha3-256"){return It.create().update(t).digest()}static async verify_ml_dsa(t,e,n){return nn.verify(n,e,t)}static async verify_falcon(t,e,n){const r=new rn;return await r.init(),r.verify(e,t,n)}async sign_ml_dsa(t,e){if(e||(e=this.ml_dsa_signing_keypair),!e.privateKey)throw new Error("ml_dsa_signing_keypair.privateKey is not set");return nn.sign(e.privateKey,t)}async sign_falcon(t,e){if(e||(e=this.falcon_signing_keypair),!e.privateKey)throw new Error("falcon_signing_keypair.privateKey is not set");const n=new rn;return await n.init(),await n.setKeypair({genkeySeed:this.falcon_signing_keypair.genKey,sk:this.falcon_signing_keypair.privateKey,pk:this.falcon_signing_keypair.publicKey}),n.sign(t)}async encapsulate_ml_kem(t){if(!this.ml_kem_encryption_keypair.privateKey)throw new Error("ml_kem_encryption_keypair.privateKey is not set");return He.encapsulate(t)}async decapsulate_ml_kem(t){if(!this.ml_kem_encryption_keypair.privateKey)throw new Error("ml_kem_encryption_keypair.privateKey is not set");return He.decapsulate(t,this.ml_kem_encryption_keypair.privateKey)}async encrypt_ml_kem_aes(t,e){if(!this.ml_kem_encryption_keypair.privateKey)throw new Error("ml_kem_encryption_keypair.privateKey is not set");const n=He.encapsulate(e),s=r.randomBytes(12),i=r.createCipheriv("aes-256-gcm",n.sharedSecret,s),a=Buffer.concat([i.update(t),i.final()]),o=i.getAuthTag(),c=Buffer.concat([s,a,o]);return{cipherText:n.cipherText,encryptedMessage:c}}async decrypt_ml_kem_aes(t,e){if(!this.ml_kem_encryption_keypair.privateKey)throw new Error("ml_kem_encryption_keypair.privateKey is not set");const n=He.decapsulate(e,this.ml_kem_encryption_keypair.privateKey),s=t.slice(0,12),i=t.slice(12,-16),a=t.slice(-16),o=r.createDecipheriv("aes-256-gcm",n,s);o.setAuthTag(a);return Buffer.concat([o.update(i),o.final()])}async generate_ml_dsa_signing_keypair(t=null){t||(t=s(32));const e=nn.keygen(t);this.ml_dsa_signing_keypair={publicKey:e.publicKey,privateKey:e.secretKey}}async generate_falcon_signing_keypair(t=null){t||(t=s(48));const e=new rn;await e.init(),await e.genkey(t);const n=await e.getKeypair();this.falcon_signing_keypair={genKey:n.genkeySeed,publicKey:n.pk,privateKey:n.sk}}async generate_ml_kem_encryption_keypair(t=null){t||(t=s(64));let e=He.keygen(t);this.ml_kem_encryption_keypair={privateKey:e.secretKey,publicKey:e.publicKey}}}class an extends at{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,M(t);const n=rt(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,s=new Uint8Array(r);s.set(n.length>r?t.create().update(n).digest():n);for(let t=0;t<s.length;t++)s[t]^=54;this.iHash.update(s),this.oHash=t.create();for(let t=0;t<s.length;t++)s[t]^=106;this.oHash.update(s),G(s)}update(t){return R(this),this.iHash.update(t),this}digestInto(t){R(this),P(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:n,finished:r,destroyed:s,blockLen:i,outputLen:a}=this;return t.finished=r,t.destroyed=s,t.blockLen=i,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const on=(t,e,n)=>new an(t,e).update(n).digest();function cn(t,e,n,r){M(t);const s=function(t,e){if(void 0!==e&&"[object Object]"!=={}.toString.call(e))throw new Error("options should be object or undefined");return Object.assign(t,e)}({dkLen:32,asyncTick:10},r),{c:i,dkLen:a,asyncTick:o}=s;if(H(i),H(a),H(o),i<1)throw new Error("iterations (c) should be >= 1");const c=st(e),h=st(n),d=new Uint8Array(a),l=on.create(t,c),u=l._cloneInto().update(h);return{c:i,dkLen:a,asyncTick:o,DK:d,PRF:l,PRFSalt:u}}function hn(t,e,n,r){const{c:s,dkLen:i,DK:a,PRF:o,PRFSalt:c}=cn(t,e,n,r);let h;const d=new Uint8Array(4),l=X(d),u=new Uint8Array(o.outputLen);for(let t=1,e=0;e<i;t++,e+=o.outputLen){const n=a.subarray(e,e+o.outputLen);l.setInt32(0,t,!1),(h=c._cloneInto(h)).update(d).digestInto(u),n.set(u.subarray(0,n.length));for(let t=1;t<s;t++){o._cloneInto(h).update(u).digestInto(u);for(let t=0;t<n.length;t++)n[t]^=u[t]}}return function(t,e,n,r,s){return t.destroy(),e.destroy(),r&&r.destroy(),G(s),n}(o,c,a,h,u)}function dn(t){if("string"!=typeof t)throw new TypeError("invalid mnemonic type: "+typeof t);return t.normalize("NFKD")}on.create=(t,e)=>new an(t,e);function ln(t,e=""){return hn(ne,function(t){const e=dn(t),n=e.split(" ");if(![12,15,18,21,24].includes(n.length))throw new Error("Invalid mnemonic");return{nfkd:e,words:n}}(t).nfkd,(t=>dn("mnemonic"+t))(e),{c:2048,dkLen:64})}function un(t){t=t.slice(2);let e=new Uint8Array(64);for(let n=0;n<t.length;n+=2){const r=t.substr(n,2),s=parseInt(r,16);e[n/2]=s}return e}class pn{static sha256(t){const e=o.sha256.create();return e.update(t),e.digest().toHex()}static sha3_512(t){return Bt(t)}}const fn="aes-256-cbc";class yn{static new(){const t=o.random.getBytesSync(32);return o.pki.ed25519.generateKeyPair({seed:t})}static newFromSeed(t){"string"==typeof t&&(t=ln(t));const e=t.toString(),n=pn.sha256(e),r=Buffer.from(n,"hex");return o.pki.ed25519.generateKeyPair({seed:r})}static async save(t,e,n="hex"){if("hex"===n){let n=yn.saveToHex(t.privateKey);await c.writeFile(e,n)}else await c.writeFile(e,JSON.stringify(t.privateKey))}static saveToHex(t){return"0x"+t.toString("hex")}static async saveEncrypted(t,e,n){const s=r.createCipher(fn,n),i=t.privateKey.toString("hex"),a=s.update(i,"utf8","hex");await c.writeFile(e,a)}static async loadEncrypted(t,e){let n={privateKey:null,publicKey:null};const s=r.createDecipher(fn,e),i=await c.readFile(t,"utf8");return n=s.update(i,"hex","utf8").includes("{")?yn.loadFromBufferString(i):yn.loadFromHex(i),n}static async load(t,e=!0){let n,r={privateKey:null,publicKey:null};return n=e?await c.readFile(t,"utf8"):t,r=n.includes("{")?yn.loadFromBufferString(n):yn.loadFromHex(n),r}static loadFromHex(t){let e={publicKey:null,privateKey:null};t=t.slice(2);let n=new Uint8Array(64);for(let e=0;e<t.length;e+=2){const r=t.substr(e,2),s=parseInt(r,16);n[e/2]=s}return e.privateKey=Buffer.from(n),e.publicKey=o.pki.ed25519.publicKeyFromPrivateKey({privateKey:e.privateKey}),e}static loadFromBufferString(t){let e={publicKey:null,privateKey:null};return e.privateKey=Buffer.from(JSON.parse(t)),e.publicKey=o.pki.ed25519.publicKeyFromPrivateKey({privateKey:e.privateKey}),e}static sign(t,e){return"string"==e.type&&(e=un(e)),o.pki.ed25519.sign({message:t,encoding:"utf8",privateKey:e})}static verify(t,e,n){return"string"==e.type&&(e=un(e)),"string"==n.type&&(n=un(n)),"Buffer"==e.type&&(e=Buffer.from(e)),"Buffer"==n.type&&(n=Buffer.from(n)),o.pki.ed25519.verify({message:t,encoding:"utf8",signature:e,publicKey:n})}}yn.ed25519={sign:(t,e)=>("string"==e.type&&(e=un(e)),o.pki.ed25519.sign({message:t,encoding:"utf8",privateKey:e})),verify:(t,e,n)=>("string"==e.type&&(e=un(e)),"string"==n.type&&(n=un(n)),"Buffer"==e.type&&(e=Buffer.from(e)),"Buffer"==n.type&&(n=Buffer.from(n)),o.pki.ed25519.verify({message:t,encoding:"utf8",signature:e,publicKey:n}))},yn.rsa={encrypt:(t,e)=>{"Buffer"==e.type&&(e=Buffer.from(e));let n=o.util.encode64(t);return[!0,e.encrypt(n)]},decrypt:(t,e=null)=>{try{"Buffer"==e.type&&(e=Buffer.from(e))}catch(t){}if(!e)return[!1,"No private key found"];let n=o.util.decode64(t);return[!0,e.decrypt(n).toString()]}};const mn=Uint8Array.from([0]),gn=Uint8Array.of();const bn=(t,e,n,r,s)=>function(t,e,n,r=32){M(t),H(r);const s=t.outputLen;if(r>255*s)throw new Error("Length should be <= 255*HashLen");const i=Math.ceil(r/s);void 0===n&&(n=gn);const a=new Uint8Array(i*s),o=on.create(t,e),c=o._cloneInto(),h=new Uint8Array(o.outputLen);for(let t=0;t<i;t++)mn[0]=t+1,c.update(0===t?gn:h).update(n).update(mn).digestInto(h),a.set(h,s*t),o._cloneInto(c);return o.destroy(),c.destroy(),G(h,mn),a.slice(0,r)}(t,function(t,e,n){return M(t),on(t,rt(n),rt(e))}(t,e,n),r,s);function wn(t){return"0x"+Array.from(t,t=>t.toString(16).padStart(2,"0")).join("")}class xn{constructor(t,e){this.enigma=new sn,this.masterSeed=e,this.instanceId=t}static getInstance(t,e){const n=t||xn.DEFAULT_INSTANCE_ID;return xn.instances.has(n)?e&&!xn.instances.get(n).masterSeed&&(xn.instances.get(n).masterSeed=e):xn.instances.set(n,new xn(n,e)),xn.instances.get(n)}getId(){return this.instanceId}static getInstanceIds(){return Array.from(xn.instances.keys())}static removeInstance(t){return xn.instances.delete(t)}async ensureSeed(t){t||this.masterSeed?t&&(this.masterSeed=t):(t=ct(128),this.masterSeed=t),this.masterSeed.length}async deriveSeed(t,e){if(await this.ensureSeed(e),"ed25519"===t)return bn(te,this.masterSeed,"master seed","ed25519",32);if("falcon"===t)return bn(te,this.masterSeed,"master seed","falcon",48);if("ml-dsa"===t)return bn(te,this.masterSeed,"master seed","ml-dsa",32);if("ml-kem-aes"===t)return bn(te,this.masterSeed,"master seed","ml-kem-aes",64);if("rsa"===t)return bn(te,this.masterSeed,"master seed","rsa",32);throw new Error("Invalid algorithm")}async generateAllIdentities(t){await this.generateIdentity("ed25519",t),await this.generateIdentity("falcon",t),await this.generateIdentity("ml-dsa",t),await this.generateIdentity("ml-kem-aes",t)}async generateIdentity(t,e){let n;if(n=e?await this.deriveSeed(t,e):await this.deriveSeed(t),"ed25519"===t)this.ed25519KeyPair=yn.newFromSeed(n);else if("falcon"===t)await this.enigma.generate_falcon_signing_keypair(n);else if("ml-dsa"===t)await this.enigma.generate_ml_dsa_signing_keypair(n);else if("ml-kem-aes"===t)await this.enigma.generate_ml_kem_encryption_keypair(n);else{if("rsa"!==t)throw new Error("Invalid algorithm");{var r=a.random.createInstance();const t=(new TextDecoder).decode(n);r.seedFileSync=()=>t,this.rsaKeyPair=await a.pki.rsa.generateKeyPair({bits:3072,prng:r,workers:2})}}}async getIdentity(t){if("falcon"===t)return this.enigma.falcon_signing_keypair;if("ml-dsa"===t)return this.enigma.ml_dsa_signing_keypair;if("ml-kem-aes"===t)return this.enigma.ml_kem_encryption_keypair;if("ed25519"===t)return{publicKey:this.ed25519KeyPair.publicKey,privateKey:this.ed25519KeyPair.privateKey};if("rsa"===t)return{publicKey:this.rsaKeyPair.publicKey,privateKey:this.rsaKeyPair.privateKey};throw new Error("Invalid algorithm")}async encrypt(t,e,n){let r={algorithm:t,encryptedData:new Uint8Array};if("ml-kem-aes"===t){const{cipherText:t,encryptedMessage:s}=await this.enigma.encrypt_ml_kem_aes(e,n);r.cipherText=t,r.encryptedData=s}else if("rsa"===t){if(!this.rsaKeyPair)throw new Error("RSA key pair not generated");const t=(new TextDecoder).decode(e);let n=this.rsaKeyPair.publicKey.encrypt(t);r.encryptedData=(new TextEncoder).encode(n)}return r}async sign(t,e){let n;if("ed25519"===t){if(!this.ed25519KeyPair)throw new Error("Ed25519 key pair not generated");n={algorithm:"ed25519",signature:yn.sign((new TextDecoder).decode(e),this.ed25519KeyPair.privateKey),message:e,publicKey:this.ed25519KeyPair.publicKey}}else if("ml-dsa"===t)n={algorithm:t,signature:await this.enigma.sign_ml_dsa(e),message:e,publicKey:this.enigma.ml_dsa_signing_keypair.publicKey};else if("falcon"===t){let r=(new TextDecoder).decode(e);n={algorithm:t,signature:await this.enigma.sign_falcon(r),message:e,publicKey:this.enigma.falcon_signing_keypair.publicKey}}return n}async decrypt(t){if("ml-kem-aes"===t.algorithm)return this.enigma.decrypt_ml_kem_aes(t.encryptedData,t.cipherText);if("rsa"===t.algorithm){const e=(new TextDecoder).decode(t.encryptedData);let n=this.rsaKeyPair.privateKey.decrypt(e);return(new TextEncoder).encode(n)}throw new Error("Invalid algorithm")}async verify(t){if("ml-dsa"===t.algorithm)return await sn.verify_ml_dsa(t.signature,t.message,t.publicKey);if("falcon"===t.algorithm){const e=(new TextDecoder).decode(t.message);return await sn.verify_falcon(t.signature,e,t.publicKey)}if("ed25519"===t.algorithm){const e=(new TextDecoder).decode(t.message);return yn.verify(e,t.signature,t.publicKey)}throw new Error("Invalid algorithm")}}xn.supportedPQCAlgorithms=["falcon","ml-dsa"],xn.instances=new Map,xn.DEFAULT_INSTANCE_ID="default",new Proxy({},{get(t,e){if(e in xn&&"function"==typeof xn[e])return xn[e].bind(xn);const n=xn.getInstance(),r=n[e];return"function"==typeof r?r.bind(n):r}});const An={content:{type:"",from:"",to:"",amount:0,data:["",""],nonce:0,timestamp:0,transaction_fee:{network_fee:0,rpc_fee:0,additional_fee:0}},signature:null,hash:"",status:"",blockNumber:null};class kn{static async generate(t,e=!1){const n=[],{content:r}=t;switch(r.type){case"demoswork":case"genesis":break;case"native":var s=await _n.handle(t,e);n.push(...s);break;case"web2Request":case"crosschainOperation":const a=this.createAssignEdit(r,t.hash);n.push(a);break;case"identity":var i=await En.handle(t);n.push(...i)}t:try{if("identity"===r.type)break t;let s=await this.createGasEdit(r.from_ed25519_address,t.hash,e,1);n.push(s)}catch(t){throw new Error("Error creating gas edit: "+t)}n.push(this.createNonceEdit(r.from_ed25519_address,t.hash));for(const t of n)t.account.startsWith("0x")||(t.account="0x"+t.account);return n}static async createGasEdit(t,e,n=!1,r=1){return{type:"balance",account:t,operation:n?"add":"remove",amount:r,txhash:e,isRollback:n}}static createAssignEdit(t,e,n=!1){return{type:"assign",account:t.from_ed25519_address,context:"web2Request"===t.type?"web2":"xm",txhash:e,isRollback:n}}static createNonceEdit(t,e,n=!1){return{type:"nonce",operation:"add",account:t,amount:1,txhash:e,isRollback:n}}}class _n{static async handle(t,e=!1){let n=[],r=t.content.data[1];if("send"===r.nativeOperation){var[s,i]=r.args,a={type:"balance",operation:"remove",isRollback:e,account:t.content.from_ed25519_address,txhash:t.hash,amount:i};n.push(a);var o={type:"balance",operation:"add",isRollback:e,account:s,txhash:t.hash,amount:i};n.push(o)}return n}}class En{static async handle(t){const e=[],n=t.content.data[1],r={account:t.content.from_ed25519_address,type:"identity",operation:n.method.endsWith("assign")?"add":"remove",txhash:t.hash,isRollback:!1,context:n.context,data:null,referralCode:null};switch(n.method){case"xm_identity_assign":{const e=n.payload.target_identity;if(e.isEVM&&!e.chainId)throw new Error("Failed: chainId not provided");const s=structuredClone(e);r.data={...s,timestamp:t.content.timestamp},r.referralCode=n.payload.referralCode;break}case"pqc_identity_assign":r.data=n.payload.map(e=>({...e,timestamp:t.content.timestamp}));break;case"web2_identity_assign":{const e=n.payload;r.data={context:e.context,data:{username:e.username,userId:e.userId,proof:e.proof,proofHash:pn.sha256(e.proof),timestamp:t.content.timestamp}},r.referralCode=n.payload.referralCode;break}case"xm_identity_remove":case"web2_identity_remove":case"pqc_identity_remove":r.data=n.payload}return e.push(r),e}}function vn(t,e="Missing required element",n=!0){if(!t){if(n)throw new Error("[REQUIRED] "+e);return!1}return!0}const In={empty:function(){return structuredClone(An)},prepare:async function(t=null){const e=structuredClone(An);return t&&(e.content.data=t),e},async pay(t,e,n){vn(n.keypair,"Wallet not connected");let r=In.empty();const{publicKey:s}=await n.crypto.getIdentity("ed25519"),i=wn(s),a=await n.getAddressNonce(i);return r.content.to=t,r.content.nonce=a+1,r.content.amount=e,r.content.type="native",r.content.timestamp=Date.now(),r.content.data=["native",{nativeOperation:"send",args:[t,e]}],await n.sign(r)},transfer:(t,e,n)=>In.pay(t,e,n),sign:async function(t,e,n){return vn(e,"Private key not provided"),n&&n.algorithm||(n={algorithm:"ed25519"}),t.content.timestamp&&0!==t.content.timestamp||(t.content.timestamp=Date.now()),t.content.from=wn(e.publicKey),t.content.gcr_edits=await kn.generate(t),t.hash=await async function(t){const e=(new TextEncoder).encode(t),n=await crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(n)).map(t=>t.toString(16).padStart(2,"0")).join("")}(JSON.stringify(t.content)),t.signature=await In.signWithAlgorithm(t.hash,e,{algorithm:n.algorithm}),t},signWithAlgorithm:async function(t,e,n){if(vn(e,"Private key not provided"),vn(n&&n.algorithm,"Algorithm not provided"),"ed25519"===n.algorithm){return{type:"ed25519",data:wn(yn.sign(t,e.privateKey))}}const r=new sn;if("falcon"===n.algorithm){return{type:"falcon",data:wn(await r.sign_falcon(t,e))}}if("ml-dsa"===n.algorithm){const n=(new TextEncoder).encode(t);return{type:"ml-dsa",data:wn(await r.sign_ml_dsa(n,e))}}throw new Error("Unsupported algorithm: "+n.algorithm)},confirm:async function(t,e){let n=await e.call("execute","",t,"confirmTx");if(!n.response.data.valid)throw new Error("[Confirm] Transaction is not valid: "+n.response.data.message);return n},broadcast:async function(t,e){if(!t.response.data.valid)throw new Error("[Broadcast] Transaction is not valid: "+t.response.data.message);const n=await e.call("execute","",t,"broadcastTx");try{return{...n,response:JSON.parse(n.response)}}catch(t){return n}},async store(t,e){vn(e.keypair,"Wallet not connected");let n=In.empty();const{publicKey:r}=await e.crypto.getIdentity("ed25519"),s=wn(r),i=await e.getAddressNonce(s),a=Buffer.from(t).toString("base64");return n.content.to=s,n.content.nonce=i+1,n.content.amount=0,n.content.type="storage",n.content.timestamp=Date.now(),n.content.data=["storage",{bytes:a}],await e.sign(n)},async createL2PSHashUpdate(t,e,n,r){vn(r.keypair,"Wallet not connected"),vn(t,"L2PS UID is required"),vn(e,"Consolidated hash is required"),vn(n>=0,"Transaction count must be non-negative");let s=In.empty();const{publicKey:i}=await r.crypto.getIdentity("ed25519"),a=wn(i),o=await r.getAddressNonce(a);return s.content.to=a,s.content.nonce=o+1,s.content.amount=0,s.content.type="l2ps_hash_update",s.content.timestamp=Date.now(),s.content.data=["l2ps_hash_update",{l2ps_uid:t,consolidated_hash:e,transaction_count:n,timestamp:Date.now()}],await r.sign(s)}};class Cn{constructor(){this.formats={web2:{github:["https://gist.github.com","https://raw.githubusercontent.com","https://gist.githubusercontent.com"],twitter:["https://x.com","https://twitter.com"]}}}async createWeb2ProofPayload(t){const e="dw2p",n=await t.crypto.sign(t.algorithm,(new TextEncoder).encode(e));return`demos:${e}:${t.algorithm}:${wn(n.signature)}`}async inferIdentity(t,e,n){if("web2"===e&&!this.formats.web2[n.context].some(t=>n.proof.startsWith(t))){const t=`Invalid ${n.context} proof format. Supported formats are: ${this.formats.web2[n.context].join(", ")}`;throw new Error(t)}const r=In.empty(),s=wn((await t.crypto.getIdentity("ed25519")).publicKey);r.content={...r.content,type:"identity",to:s,amount:0,data:["identity",{context:e,method:e+"_identity_assign",payload:n}],nonce:1,timestamp:Date.now()};const i=await t.sign(r);return await t.confirm(i)}async removeIdentity(t,e,n){const r=In.empty(),s=wn((await t.crypto.getIdentity("ed25519")).publicKey);r.content={...r.content,type:"identity",to:s,amount:0,data:["identity",{context:e,method:e+"_identity_remove",payload:n}],nonce:1,timestamp:Date.now()};const i=await t.sign(r);return await t.confirm(i)}async inferXmIdentity(t,e,n){return await this.inferIdentity(t,"xm",{...e,referralCode:n})}async inferWeb2Identity(t,e){return await this.inferIdentity(t,"web2",e)}async removeXmIdentity(t,e){return await this.removeIdentity(t,"xm",e)}async removeWeb2Identity(t,e){return await this.removeIdentity(t,"web2",e)}async addGithubIdentity(t,e,r){const s=e.split("/")[3],i=await n.get(`https://api.github.com/users/${s}`);if(!i.data.login)throw new Error("Failed to get github user");let a={context:"github",proof:e,username:i.data.login,userId:i.data.id,referralCode:r};return await this.inferIdentity(t,"web2",a)}async addTwitterIdentity(t,e,n){const r=await t.web2.getTweet(e);if(!r.success)throw new Error(r.error);if(!r.tweet.userId||!r.tweet.username)throw new Error("Unable to get twitter user info. Please try again.");let s={context:"twitter",proof:e,username:r.tweet.username,userId:r.tweet.userId,referralCode:n};return await this.inferIdentity(t,"web2",s)}async bindPqcIdentity(t,e="all"){let n=[];if("all"===e)await t.crypto.generateAllIdentities(),n=xn.supportedPQCAlgorithms;else for(const r of e)await t.crypto.generateIdentity(r),n.push(r);const r=[];for(const e of n){const n=wn((await t.crypto.getIdentity(e)).publicKey),s=await t.crypto.sign("ed25519",(new TextEncoder).encode(n));r.push({algorithm:e,address:n,signature:wn(s.signature)})}return await this.inferIdentity(t,"pqc",r)}async removePqcIdentity(t,e="all"){let n=[];if("all"===e)await t.crypto.generateAllIdentities(),n=xn.supportedPQCAlgorithms;else for(const r of e)await t.crypto.generateIdentity(r),n.push(r);const r=[];for(const e of n){const n=await t.crypto.getIdentity(e);r.push({algorithm:e,address:wn(n.publicKey)})}return await this.removeIdentity(t,"pqc",r)}async getIdentities(t,e="getIdentities",n){if(!n){n=wn((await t.crypto.getIdentity("ed25519")).publicKey)}const r={method:"gcr_routine",params:[{method:e,params:[n]}]};return await t.rpcCall(r,!0)}async getXmIdentities(t,e){return await this.getIdentities(t,"getXmIdentities",e)}async getWeb2Identities(t,e){return await this.getIdentities(t,"getWeb2Identities",e)}async getUserPoints(t,e){vn(e||t.walletConnected,"No address provided and no wallet connected"),e||(e=await t.getEd25519Address());const n={method:"gcr_routine",params:[{method:"getPoints",params:[e]}]};return await t.rpcCall(n,!0)}async validateReferralCode(t,e){const n={method:"gcr_routine",params:[{method:"validateReferralCode",params:[e]}]};return await t.rpcCall(n,!0)}async getReferralInfo(t,e){e||(e=await t.getEd25519Address());const n={method:"gcr_routine",params:[{method:"getReferralInfo",params:[e]}]};return await t.rpcCall(n,!0)}}export{g as CoinFinder,m as EvmCoinFinder,Cn as Identities};
|
package/build/bridge/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { BridgeTradePayload } from "
|
|
2
|
-
export { ChainProviders, SupportedChains, SupportedTokens, } from "
|
|
1
|
+
export { BridgeTradePayload } from "@/types/bridge/bridgeTradePayload";
|
|
2
|
+
export { ChainProviders, SupportedChains, SupportedTokens, } from "@/types/bridge/constants";
|
|
3
3
|
import RubicBridge from "./rubicBridge";
|
|
4
4
|
export { BLOCKCHAIN_NAME, CROSS_CHAIN_TRADE_TYPE, CrossChainTrade, RubicSdkError, WrappedCrossChainTrade, } from "rubic-sdk";
|
|
5
5
|
import { methods as NativeBridgeMethods } from "./nativeBridge";
|
package/build/bridge/index.js
CHANGED
|
@@ -1,27 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.RubicBridge = exports.NativeBridgeUSDCAbi = exports.NativeBridgeUSDCContracts = exports.NativeBridgeSupportedEVMChains = exports.NativeBridgeSupportedStablecoins = exports.NativeBridgeSupportedChains = exports.NativeBridgeMethods = exports.RubicSdkError = exports.CrossChainTrade = exports.CROSS_CHAIN_TRADE_TYPE = exports.BLOCKCHAIN_NAME = exports.SupportedTokens = exports.SupportedChains = exports.ChainProviders = void 0;
|
|
7
|
-
var constants_1 = require("../types/bridge/constants");
|
|
8
|
-
Object.defineProperty(exports, "ChainProviders", { enumerable: true, get: function () { return constants_1.ChainProviders; } });
|
|
9
|
-
Object.defineProperty(exports, "SupportedChains", { enumerable: true, get: function () { return constants_1.SupportedChains; } });
|
|
10
|
-
Object.defineProperty(exports, "SupportedTokens", { enumerable: true, get: function () { return constants_1.SupportedTokens; } });
|
|
11
|
-
const rubicBridge_1 = __importDefault(require("./rubicBridge"));
|
|
12
|
-
exports.RubicBridge = rubicBridge_1.default;
|
|
13
|
-
var rubic_sdk_1 = require("rubic-sdk");
|
|
14
|
-
Object.defineProperty(exports, "BLOCKCHAIN_NAME", { enumerable: true, get: function () { return rubic_sdk_1.BLOCKCHAIN_NAME; } });
|
|
15
|
-
Object.defineProperty(exports, "CROSS_CHAIN_TRADE_TYPE", { enumerable: true, get: function () { return rubic_sdk_1.CROSS_CHAIN_TRADE_TYPE; } });
|
|
16
|
-
Object.defineProperty(exports, "CrossChainTrade", { enumerable: true, get: function () { return rubic_sdk_1.CrossChainTrade; } });
|
|
17
|
-
Object.defineProperty(exports, "RubicSdkError", { enumerable: true, get: function () { return rubic_sdk_1.RubicSdkError; } });
|
|
18
|
-
const nativeBridge_1 = require("./nativeBridge");
|
|
19
|
-
Object.defineProperty(exports, "NativeBridgeMethods", { enumerable: true, get: function () { return nativeBridge_1.methods; } });
|
|
20
|
-
// Export types from nativeBridgeTypes
|
|
21
|
-
var nativeBridgeTypes_1 = require("./nativeBridgeTypes");
|
|
22
|
-
Object.defineProperty(exports, "NativeBridgeSupportedChains", { enumerable: true, get: function () { return nativeBridgeTypes_1.supportedChains; } });
|
|
23
|
-
Object.defineProperty(exports, "NativeBridgeSupportedStablecoins", { enumerable: true, get: function () { return nativeBridgeTypes_1.supportedStablecoins; } });
|
|
24
|
-
Object.defineProperty(exports, "NativeBridgeSupportedEVMChains", { enumerable: true, get: function () { return nativeBridgeTypes_1.supportedEVMChains; } });
|
|
25
|
-
Object.defineProperty(exports, "NativeBridgeUSDCContracts", { enumerable: true, get: function () { return nativeBridgeTypes_1.usdcContracts; } });
|
|
26
|
-
Object.defineProperty(exports, "NativeBridgeUSDCAbi", { enumerable: true, get: function () { return nativeBridgeTypes_1.usdcAbi; } });
|
|
27
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export{BLOCKCHAIN_NAME,CROSS_CHAIN_TRADE_TYPE,CrossChainTrade,RubicSdkError}from"rubic-sdk";import t from"node-forge";import*as e from"crypto";import{promises as n}from"fs";const s={ETH:"ETH",POLYGON:"POLYGON",BSC:"BSC",AVALANCHE:"AVALANCHE",OPTIMISM:"OPTIMISM",ARBITRUM:"ARBITRUM",LINEA:"LINEA",BASE:"BASE",SOLANA:"SOLANA"},i={ETH:{NATIVE:"0x0000000000000000000000000000000000000000",USDC:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",USDT:"0xdAC17F958D2ee523a2206206994597C13D831ec7"},POLYGON:{NATIVE:"0x0000000000000000000000000000000000000000",USDC:"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",USDT:"0xc2132D05D31c914a87C6611C10748AEb04B58e8F"},BSC:{NATIVE:"0x0000000000000000000000000000000000000000",USDC:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",USDT:"0x55d398326f99059fF775485246999027B3197955"},AVALANCHE:{NATIVE:"0x0000000000000000000000000000000000000000",USDC:"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",USDT:"0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7"},OPTIMISM:{NATIVE:"0x0000000000000000000000000000000000000000",USDC:"0x7F5c764cBc14f9669B88837ca1490cCa17c31607",USDT:"0x94b008aA00579c1307B0EF2c499aD98a8ce58e58"},ARBITRUM:{NATIVE:"0x0000000000000000000000000000000000000000",USDC:"0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8",USDT:"0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"},LINEA:{NATIVE:"0x0000000000000000000000000000000000000000",USDC:"0x176211869cA2b568f2A7D4EE941E073a821EE1ff",USDT:"0xA219439258ca9da29E9Cc4cE5596924745e12B93"},BASE:{NATIVE:"0x0000000000000000000000000000000000000000",USDC:"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",USDT:"0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb"},SOLANA:{NATIVE:"So11111111111111111111111111111111111111111",USDC:"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",USDT:"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"}},r={ETH:{mainnet:"https://ethereum-rpc.publicnode.com"},POLYGON:{mainnet:"https://polygon-bor-rpc.publicnode.com"},BSC:{mainnet:"https://bsc-rpc.publicnode.com"},AVALANCHE:{mainnet:"https://avalanche-c-chain-rpc.publicnode.com"},OPTIMISM:{mainnet:"https://optimism-rpc.publicnode.com"},ARBITRUM:{mainnet:"https://arbitrum-one-rpc.publicnode.com"},LINEA:{mainnet:"https://arbitrum-one-rpc.publicnode.com"},BASE:{mainnet:"https://base-rpc.publicnode.com"},SOLANA:{mainnet:"https://api.mainnet-beta.solana.com"}};class o{async getTrade(t,e,n){const s={method:"bridge",params:[{method:"get_trade",chain:e,params:[n]}]};return await t.rpcCall(s,!0)}async executeTrade(t,e,n){const s={method:"bridge",params:[{method:"execute_trade",chain:e,params:[n]}]};return await t.rpcCall(s,!0)}async executeMockTrade(t,e,n){const s={method:"bridge",params:[{method:"execute_mock_trade",chain:e,params:[n]}]};return await t.rpcCall(s,!0)}}const a=BigInt(2**32-1),c=BigInt(32);function h(t,e=!1){return e?{h:Number(t&a),l:Number(t>>c&a)}:{h:0|Number(t>>c&a),l:0|Number(t&a)}}function d(t,e=!1){const n=t.length;let s=new Uint32Array(n),i=new Uint32Array(n);for(let r=0;r<n;r++){const{h:n,l:o}=h(t[r],e);[s[r],i[r]]=[n,o]}return[s,i]}const f=(t,e,n)=>t>>>n,u=(t,e,n)=>t<<32-n|e>>>n,l=(t,e,n)=>t>>>n|e<<32-n,p=(t,e,n)=>t<<32-n|e>>>n,b=(t,e,n)=>t<<64-n|e>>>n-32,y=(t,e,n)=>t>>>n-32|e<<64-n;function x(t,e,n,s){const i=(e>>>0)+(s>>>0);return{h:t+n+(i/2**32|0)|0,l:0|i}}const g=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),A=(t,e,n,s)=>e+n+s+(t/2**32|0)|0,E=(t,e,n,s)=>(t>>>0)+(e>>>0)+(n>>>0)+(s>>>0),m=(t,e,n,s,i)=>e+n+s+i+(t/2**32|0)|0,w=(t,e,n,s,i)=>(t>>>0)+(e>>>0)+(n>>>0)+(s>>>0)+(i>>>0),B=(t,e,n,s,i,r)=>e+n+s+i+r+(t/2**32|0)|0;function C(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function I(t,...e){if(!((n=t)instanceof Uint8Array||ArrayBuffer.isView(n)&&"Uint8Array"===n.constructor.name))throw new Error("Uint8Array expected");var n;if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function D(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.createHasher");C(t.outputLen),C(t.blockLen)}function L(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function S(t,e){I(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function F(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function U(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function k(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}const v=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])()?t=>t:function(t){for(let e=0;e<t.length;e++)t[e]=k(t[e]);return t};function H(t){if("string"!=typeof t)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(t))}function N(t){return"string"==typeof t&&(t=H(t)),I(t),t}function O(t){return"string"==typeof t&&(t=H(t)),I(t),t}class T{}function K(t){const e=e=>t().update(N(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}const M=BigInt(0),_=BigInt(1),P=BigInt(2),R=BigInt(7),G=BigInt(256),V=BigInt(113),Y=[],X=[],j=[];for(let t=0,e=_,n=1,s=0;t<24;t++){[n,s]=[s,(2*n+3*s)%5],Y.push(2*(5*s+n)),X.push((t+1)*(t+2)/2%64);let i=M;for(let t=0;t<7;t++)e=(e<<_^(e>>R)*V)%G,e&P&&(i^=_<<(_<<BigInt(t))-_);j.push(i)}const J=d(j,!0),z=J[0],$=J[1],q=(t,e,n)=>n>32?((t,e,n)=>e<<n-32|t>>>64-n)(t,e,n):((t,e,n)=>t<<n|e>>>32-n)(t,e,n),Z=(t,e,n)=>n>32?((t,e,n)=>t<<n-32|e>>>64-n)(t,e,n):((t,e,n)=>e<<n|t>>>32-n)(t,e,n);class W extends T{constructor(t,e,n,s=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=e,this.outputLen=n,this.enableXOF=s,this.rounds=i,C(n),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");var r;this.state=new Uint8Array(200),this.state32=(r=this.state,new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4)))}clone(){return this._cloneInto()}keccak(){v(this.state32),function(t,e=24){const n=new Uint32Array(10);for(let s=24-e;s<24;s++){for(let e=0;e<10;e++)n[e]=t[e]^t[e+10]^t[e+20]^t[e+30]^t[e+40];for(let e=0;e<10;e+=2){const s=(e+8)%10,i=(e+2)%10,r=n[i],o=n[i+1],a=q(r,o,1)^n[s],c=Z(r,o,1)^n[s+1];for(let n=0;n<50;n+=10)t[e+n]^=a,t[e+n+1]^=c}let e=t[2],i=t[3];for(let n=0;n<24;n++){const s=X[n],r=q(e,i,s),o=Z(e,i,s),a=Y[n];e=t[a],i=t[a+1],t[a]=r,t[a+1]=o}for(let e=0;e<50;e+=10){for(let s=0;s<10;s++)n[s]=t[e+s];for(let s=0;s<10;s++)t[e+s]^=~n[(s+2)%10]&n[(s+4)%10]}t[0]^=z[s],t[1]^=$[s]}F(n)}(this.state32,this.rounds),v(this.state32),this.posOut=0,this.pos=0}update(t){L(this),I(t=N(t));const{blockLen:e,state:n}=this,s=t.length;for(let i=0;i<s;){const r=Math.min(e-this.pos,s-i);for(let e=0;e<r;e++)n[this.pos++]^=t[i++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:n,blockLen:s}=this;t[n]^=e,128&e&&n===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){L(this,!1),I(t),this.finish();const e=this.state,{blockLen:n}=this;for(let s=0,i=t.length;s<i;){this.posOut>=n&&this.keccak();const r=Math.min(n-this.posOut,i-s);t.set(e.subarray(this.posOut,this.posOut+r),s),this.posOut+=r,s+=r}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return C(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(S(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,F(this.state)}_cloneInto(t){const{blockLen:e,suffix:n,outputLen:s,rounds:i,enableXOF:r}=this;return t||(t=new W(e,n,s,r,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=n,t.outputLen=s,t.enableXOF=r,t.destroyed=this.destroyed,t}}const Q=(()=>{return t=6,e=72,n=64,K(()=>new W(e,t,n));var t,e,n})();class tt extends T{constructor(t,e,n,s){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=s,this.buffer=new Uint8Array(t),this.view=U(this.buffer)}update(t){L(this),I(t=N(t));const{view:e,buffer:n,blockLen:s}=this,i=t.length;for(let r=0;r<i;){const o=Math.min(s-this.pos,i-r);if(o===s){const e=U(t);for(;s<=i-r;r+=s)this.process(e,r);continue}n.set(t.subarray(r,r+o),this.pos),this.pos+=o,r+=o,this.pos===s&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){L(this),S(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:s,isLE:i}=this;let{pos:r}=this;e[r++]=128,F(this.buffer.subarray(r)),this.padOffset>s-r&&(this.process(n,0),r=0);for(let t=r;t<s;t++)e[t]=0;!function(t,e,n,s){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,n,s);const i=BigInt(32),r=BigInt(4294967295),o=Number(n>>i&r),a=Number(n&r),c=s?4:0,h=s?0:4;t.setUint32(e+c,o,s),t.setUint32(e+h,a,s)}(n,s-8,BigInt(8*this.length),i),this.process(n,0);const o=U(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,h=this.get();if(c>h.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<c;t++)o.setUint32(4*t,h[t],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:n,length:s,finished:i,destroyed:r,pos:o}=this;return t.destroyed=r,t.finished=i,t.length=s,t.pos=o,s%e&&t.buffer.set(n),t}clone(){return this._cloneInto()}}const et=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),nt=(()=>d(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))))(),st=(()=>nt[0])(),it=(()=>nt[1])(),rt=new Uint32Array(80),ot=new Uint32Array(80);class at extends tt{constructor(t=64){super(128,t,16,!1),this.Ah=0|et[0],this.Al=0|et[1],this.Bh=0|et[2],this.Bl=0|et[3],this.Ch=0|et[4],this.Cl=0|et[5],this.Dh=0|et[6],this.Dl=0|et[7],this.Eh=0|et[8],this.El=0|et[9],this.Fh=0|et[10],this.Fl=0|et[11],this.Gh=0|et[12],this.Gl=0|et[13],this.Hh=0|et[14],this.Hl=0|et[15]}get(){const{Ah:t,Al:e,Bh:n,Bl:s,Ch:i,Cl:r,Dh:o,Dl:a,Eh:c,El:h,Fh:d,Fl:f,Gh:u,Gl:l,Hh:p,Hl:b}=this;return[t,e,n,s,i,r,o,a,c,h,d,f,u,l,p,b]}set(t,e,n,s,i,r,o,a,c,h,d,f,u,l,p,b){this.Ah=0|t,this.Al=0|e,this.Bh=0|n,this.Bl=0|s,this.Ch=0|i,this.Cl=0|r,this.Dh=0|o,this.Dl=0|a,this.Eh=0|c,this.El=0|h,this.Fh=0|d,this.Fl=0|f,this.Gh=0|u,this.Gl=0|l,this.Hh=0|p,this.Hl=0|b}process(t,e){for(let n=0;n<16;n++,e+=4)rt[n]=t.getUint32(e),ot[n]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|rt[t-15],n=0|ot[t-15],s=l(e,n,1)^l(e,n,8)^f(e,0,7),i=p(e,n,1)^p(e,n,8)^u(e,n,7),r=0|rt[t-2],o=0|ot[t-2],a=l(r,o,19)^b(r,o,61)^f(r,0,6),c=p(r,o,19)^y(r,o,61)^u(r,o,6),h=E(i,c,ot[t-7],ot[t-16]),d=m(h,s,a,rt[t-7],rt[t-16]);rt[t]=0|d,ot[t]=0|h}let{Ah:n,Al:s,Bh:i,Bl:r,Ch:o,Cl:a,Dh:c,Dl:h,Eh:d,El:C,Fh:I,Fl:D,Gh:L,Gl:S,Hh:F,Hl:U}=this;for(let t=0;t<80;t++){const e=l(d,C,14)^l(d,C,18)^b(d,C,41),f=p(d,C,14)^p(d,C,18)^y(d,C,41),u=d&I^~d&L,E=w(U,f,C&D^~C&S,it[t],ot[t]),m=B(E,F,e,u,st[t],rt[t]),k=0|E,v=l(n,s,28)^b(n,s,34)^b(n,s,39),H=p(n,s,28)^y(n,s,34)^y(n,s,39),N=n&i^n&o^i&o,O=s&r^s&a^r&a;F=0|L,U=0|S,L=0|I,S=0|D,I=0|d,D=0|C,({h:d,l:C}=x(0|c,0|h,0|m,0|k)),c=0|o,h=0|a,o=0|i,a=0|r,i=0|n,r=0|s;const T=g(k,H,O);n=A(T,m,v,N),s=0|T}({h:n,l:s}=x(0|this.Ah,0|this.Al,0|n,0|s)),({h:i,l:r}=x(0|this.Bh,0|this.Bl,0|i,0|r)),({h:o,l:a}=x(0|this.Ch,0|this.Cl,0|o,0|a)),({h:c,l:h}=x(0|this.Dh,0|this.Dl,0|c,0|h)),({h:d,l:C}=x(0|this.Eh,0|this.El,0|d,0|C)),({h:I,l:D}=x(0|this.Fh,0|this.Fl,0|I,0|D)),({h:L,l:S}=x(0|this.Gh,0|this.Gl,0|L,0|S)),({h:F,l:U}=x(0|this.Hh,0|this.Hl,0|F,0|U)),this.set(n,s,i,r,o,a,c,h,d,C,I,D,L,S,F,U)}roundClean(){F(rt,ot)}destroy(){F(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const ct=K(()=>new at);class ht extends T{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,D(t);const n=N(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(n.length>s?t.create().update(n).digest():n);for(let t=0;t<i.length;t++)i[t]^=54;this.iHash.update(i),this.oHash=t.create();for(let t=0;t<i.length;t++)i[t]^=106;this.oHash.update(i),F(i)}update(t){return L(this),this.iHash.update(t),this}digestInto(t){L(this),I(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:n,finished:s,destroyed:i,blockLen:r,outputLen:o}=this;return t.finished=s,t.destroyed=i,t.blockLen=r,t.outputLen=o,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const dt=(t,e,n)=>new ht(t,e).update(n).digest();function ft(t,e,n,s){D(t);const i=function(t,e){if(void 0!==e&&"[object Object]"!=={}.toString.call(e))throw new Error("options should be object or undefined");return Object.assign(t,e)}({dkLen:32,asyncTick:10},s),{c:r,dkLen:o,asyncTick:a}=i;if(C(r),C(o),C(a),r<1)throw new Error("iterations (c) should be >= 1");const c=O(e),h=O(n),d=new Uint8Array(o),f=dt.create(t,c),u=f._cloneInto().update(h);return{c:r,dkLen:o,asyncTick:a,DK:d,PRF:f,PRFSalt:u}}function ut(t,e,n,s){const{c:i,dkLen:r,DK:o,PRF:a,PRFSalt:c}=ft(t,e,n,s);let h;const d=new Uint8Array(4),f=U(d),u=new Uint8Array(a.outputLen);for(let t=1,e=0;e<r;t++,e+=a.outputLen){const n=o.subarray(e,e+a.outputLen);f.setInt32(0,t,!1),(h=c._cloneInto(h)).update(d).digestInto(u),n.set(u.subarray(0,n.length));for(let t=1;t<i;t++){a._cloneInto(h).update(u).digestInto(u);for(let t=0;t<n.length;t++)n[t]^=u[t]}}return function(t,e,n,s,i){return t.destroy(),e.destroy(),s&&s.destroy(),F(i),n}(a,c,o,h,u)}function lt(t){if("string"!=typeof t)throw new TypeError("invalid mnemonic type: "+typeof t);return t.normalize("NFKD")}dt.create=(t,e)=>new ht(t,e);function pt(t,e=""){return ut(ct,function(t){const e=lt(t),n=e.split(" ");if(![12,15,18,21,24].includes(n.length))throw new Error("Invalid mnemonic");return{nfkd:e,words:n}}(t).nfkd,(t=>lt("mnemonic"+t))(e),{c:2048,dkLen:64})}function bt(t){t=t.slice(2);let e=new Uint8Array(64);for(let n=0;n<t.length;n+=2){const s=t.substr(n,2),i=parseInt(s,16);e[n/2]=i}return e}class yt{static sha256(e){const n=t.sha256.create();return n.update(e),n.digest().toHex()}static sha3_512(t){return Q(t)}}const xt="aes-256-cbc";class gt{static new(){const e=t.random.getBytesSync(32);return t.pki.ed25519.generateKeyPair({seed:e})}static newFromSeed(e){"string"==typeof e&&(e=pt(e));const n=e.toString(),s=yt.sha256(n),i=Buffer.from(s,"hex");return t.pki.ed25519.generateKeyPair({seed:i})}static async save(t,e,s="hex"){if("hex"===s){let s=gt.saveToHex(t.privateKey);await n.writeFile(e,s)}else await n.writeFile(e,JSON.stringify(t.privateKey))}static saveToHex(t){return"0x"+t.toString("hex")}static async saveEncrypted(t,s,i){const r=e.createCipher(xt,i),o=t.privateKey.toString("hex"),a=r.update(o,"utf8","hex");await n.writeFile(s,a)}static async loadEncrypted(t,s){let i={privateKey:null,publicKey:null};const r=e.createDecipher(xt,s),o=await n.readFile(t,"utf8");return i=r.update(o,"hex","utf8").includes("{")?gt.loadFromBufferString(o):gt.loadFromHex(o),i}static async load(t,e=!0){let s,i={privateKey:null,publicKey:null};return s=e?await n.readFile(t,"utf8"):t,i=s.includes("{")?gt.loadFromBufferString(s):gt.loadFromHex(s),i}static loadFromHex(e){let n={publicKey:null,privateKey:null};e=e.slice(2);let s=new Uint8Array(64);for(let t=0;t<e.length;t+=2){const n=e.substr(t,2),i=parseInt(n,16);s[t/2]=i}return n.privateKey=Buffer.from(s),n.publicKey=t.pki.ed25519.publicKeyFromPrivateKey({privateKey:n.privateKey}),n}static loadFromBufferString(e){let n={publicKey:null,privateKey:null};return n.privateKey=Buffer.from(JSON.parse(e)),n.publicKey=t.pki.ed25519.publicKeyFromPrivateKey({privateKey:n.privateKey}),n}static sign(e,n){return"string"==n.type&&(n=bt(n)),t.pki.ed25519.sign({message:e,encoding:"utf8",privateKey:n})}static verify(e,n,s){return"string"==n.type&&(n=bt(n)),"string"==s.type&&(s=bt(s)),"Buffer"==n.type&&(n=Buffer.from(n)),"Buffer"==s.type&&(s=Buffer.from(s)),t.pki.ed25519.verify({message:e,encoding:"utf8",signature:n,publicKey:s})}}gt.ed25519={sign:(e,n)=>("string"==n.type&&(n=bt(n)),t.pki.ed25519.sign({message:e,encoding:"utf8",privateKey:n})),verify:(e,n,s)=>("string"==n.type&&(n=bt(n)),"string"==s.type&&(s=bt(s)),"Buffer"==n.type&&(n=Buffer.from(n)),"Buffer"==s.type&&(s=Buffer.from(s)),t.pki.ed25519.verify({message:e,encoding:"utf8",signature:n,publicKey:s}))},gt.rsa={encrypt:(e,n)=>{"Buffer"==n.type&&(n=Buffer.from(n));let s=t.util.encode64(e);return[!0,n.encrypt(s)]},decrypt:(e,n=null)=>{try{"Buffer"==n.type&&(n=Buffer.from(n))}catch(t){}if(!n)return[!1,"No private key found"];let s=t.util.decode64(e);return[!0,n.decrypt(s).toString()]}};const At=["EVM","SOLANA"],Et=["USDC"],mt=["eth","polygon","bsc","arbitrum","optimism","avalanche","base"],wt=["SOLANA"],Bt={ETHEREUM:"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",POLYGON:"0x0FA8781a83E46826621b3BC094Ea2A0212e71B23",BSC:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",ARBITRUM:"0xfd064A18f3BF249cf1f87FC203E90D8f650f2d63",OPTIMISM:"0x5fd84259d66Cd46123540766Be93DFE6D43130D7",AVALANCHE:"0x5425890298aed601595a70AB815c96711a31Bc65",BASE:"0x036CbD53842c5426634e7929541eC2318f3dCF7e",SOLANA:"4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU"},Ct=["function balanceOf(address owner) view returns (uint256)","function decimals() view returns (uint8)"],It={validateChain(t,e,n){const s=n?"origin":"destination";if("EVM"===e){if(!mt.includes(t))throw new Error(`Invalid ${s} chain: ${t} is not a supported EVM`)}else if(!wt.includes(t))throw new Error(`Invalid ${s} chain: ${t} is not a supported chain`)},generateOperation(t,e,n,s,i,r,o,a,c,h){this.validateChain(s,n,!0),this.validateChain(r,i,!1);const d={demoAddress:e,originChainType:n,originChain:s,destinationChainType:i,destinationChain:r,originAddress:o,destinationAddress:a,amount:c,token:h,txHash:"",status:"empty"};let f=yt.sha256(JSON.stringify(d)),u=gt.sign(f,t);return{method:"nativeBridge",params:[d,(new TextDecoder).decode(u)]}},async generateOperationTx(t,e){const n=t.content.operation,s=n.originAddress,i=n.originAddress,r=n.demoAddress,o={content:{type:"nativeBridge",data:["nativeBridge",t],from:s,to:i,from_ed25519_address:r,amount:0,gcr_edits:[],nonce:await e.getAddressNonce(r)+1,timestamp:Date.now(),transaction_fee:{network_fee:0,rpc_fee:0,additional_fee:0}},signature:{type:"ed25519",data:""},hash:"",status:"empty",blockNumber:0,ed25519_signature:""};return await e.sign(o)}};export{r as ChainProviders,It as NativeBridgeMethods,At as NativeBridgeSupportedChains,mt as NativeBridgeSupportedEVMChains,Et as NativeBridgeSupportedStablecoins,Ct as NativeBridgeUSDCAbi,Bt as NativeBridgeUSDCContracts,o as RubicBridge,s as SupportedChains,i as SupportedTokens};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BridgeOperationCompiled, SupportedChain, SupportedEVMChain, SupportedStablecoin, SupportedNonEVMChain } from "./nativeBridgeTypes";
|
|
2
|
-
import { Transaction } from "
|
|
3
|
-
import { RPCRequest } from "
|
|
4
|
-
import { Demos } from "
|
|
2
|
+
import { Transaction } from "@/types/blockchain/Transaction";
|
|
3
|
+
import { RPCRequest } from "@/types";
|
|
4
|
+
import { Demos } from "@/websdk";
|
|
5
5
|
export declare const methods: {
|
|
6
6
|
/**
|
|
7
7
|
* Validates the chain
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { RPCResponse } from "
|
|
2
|
-
import { BridgeTradePayload } from "
|
|
3
|
-
import { Demos } from "
|
|
1
|
+
import { RPCResponse } from "@/types";
|
|
2
|
+
import { BridgeTradePayload } from "@/types/bridge/bridgeTradePayload";
|
|
3
|
+
import { Demos } from "@/websdk/demosclass";
|
|
4
4
|
import { WrappedCrossChainTrade } from "rubic-sdk";
|
|
5
5
|
export default class RubicBridge {
|
|
6
6
|
getTrade(demos: Demos, chain: string, payload: BridgeTradePayload): Promise<RPCResponse>;
|
package/build/demoswork/index.js
CHANGED
|
@@ -1,27 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.prepareXMStep = exports.prepareWeb2Step = exports.prepareNativeStep = exports.runSanityChecks = exports.XmWorkStep = exports.WorkStep = exports.Web2WorkStep = exports.NativeWorkStep = exports.prepareDemosWorkPayload = exports.DemosWork = exports.Condition = exports.ConditionalOperation = exports.BaseOperation = exports.DemosWorkOperation = void 0;
|
|
4
|
-
var operations_1 = require("./operations");
|
|
5
|
-
Object.defineProperty(exports, "DemosWorkOperation", { enumerable: true, get: function () { return operations_1.DemosWorkOperation; } });
|
|
6
|
-
var baseoperation_1 = require("./operations/baseoperation");
|
|
7
|
-
Object.defineProperty(exports, "BaseOperation", { enumerable: true, get: function () { return baseoperation_1.BaseOperation; } });
|
|
8
|
-
var conditional_1 = require("./operations/conditional");
|
|
9
|
-
Object.defineProperty(exports, "ConditionalOperation", { enumerable: true, get: function () { return conditional_1.ConditionalOperation; } });
|
|
10
|
-
var condition_1 = require("./operations/conditional/condition");
|
|
11
|
-
Object.defineProperty(exports, "Condition", { enumerable: true, get: function () { return condition_1.Condition; } });
|
|
12
|
-
var work_1 = require("./work");
|
|
13
|
-
Object.defineProperty(exports, "DemosWork", { enumerable: true, get: function () { return work_1.DemosWork; } });
|
|
14
|
-
Object.defineProperty(exports, "prepareDemosWorkPayload", { enumerable: true, get: function () { return work_1.prepareDemosWorkPayload; } });
|
|
15
|
-
var workstep_1 = require("./workstep");
|
|
16
|
-
Object.defineProperty(exports, "NativeWorkStep", { enumerable: true, get: function () { return workstep_1.NativeWorkStep; } });
|
|
17
|
-
Object.defineProperty(exports, "Web2WorkStep", { enumerable: true, get: function () { return workstep_1.Web2WorkStep; } });
|
|
18
|
-
Object.defineProperty(exports, "WorkStep", { enumerable: true, get: function () { return workstep_1.WorkStep; } });
|
|
19
|
-
Object.defineProperty(exports, "XmWorkStep", { enumerable: true, get: function () { return workstep_1.XmWorkStep; } });
|
|
20
|
-
// SECTION: Functions
|
|
21
|
-
var validator_1 = require("./validator");
|
|
22
|
-
Object.defineProperty(exports, "runSanityChecks", { enumerable: true, get: function () { return validator_1.runSanityChecks; } });
|
|
23
|
-
var workstep_2 = require("./workstep");
|
|
24
|
-
Object.defineProperty(exports, "prepareNativeStep", { enumerable: true, get: function () { return workstep_2.prepareNativeStep; } });
|
|
25
|
-
Object.defineProperty(exports, "prepareWeb2Step", { enumerable: true, get: function () { return workstep_2.prepareWeb2Step; } });
|
|
26
|
-
Object.defineProperty(exports, "prepareXMStep", { enumerable: true, get: function () { return workstep_2.prepareXMStep; } });
|
|
27
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import*as e from"node-forge";import t from"node-forge";import*as n from"crypto";import{randomBytes as r}from"crypto";import{getKernel as s}from"falcon-sign";import{promises as i}from"fs";function o(){return crypto.randomUUID().replaceAll("-","")}var a,c;!function(e){e.work="$work",e.internal="$internal",e.static="$static"}(a||(a={}));class h{constructor(){this.id="op_"+o(),this.steps={},this.operations=new Set,this.output={success:{type:a.work,src:{self:this,key:"output.success"}}},this.operationScript={id:this.id,operationType:null,critical:!1,depends_on:[]}}get critical(){return this.operationScript.critical}get depends_on(){return this.operationScript.depends_on}set critical(e){this.operationScript.critical=e}addWork(e){if(e.id.startsWith("op_")){this.operations.add(e);for(const t in e.steps)this.steps[t]=e.steps[t];for(const t of e.operations)this.operations.add(t)}else{if(!e.id.startsWith("step_"))throw new Error("Invalid work unit with id:"+e.id);this.steps[e.id]=e}}}class l extends h{constructor(...e){super(),this.type="base",this.operationScript={id:this.id,operationType:"base",order:[],critical:!1,depends_on:[]},this.add(...e)}add(...e){for(const t of e)super.addWork(t),this.operationScript.order.push(t.id)}addWork(...e){this.add(...e)}}!function(e){e.CREATE="create",e.START_PROXY="startProxy"}(c||(c={}));class d extends h{constructor(...e){super(),this.type="conditional",this.tempCondition=null,this.operationScript={id:this.id,operationType:"conditional",critical:!0,depends_on:[],conditions:new Map,order:[]};for(const t of e)this.appendCondition(t)}indexCondition(e){return e.action&&this.addWork(e.action),this.operationScript.conditions.set(e.id,{operator:e.operator,value_a:this.parseConditionValue(e.value_a),value_b:this.parseConditionValue(e.value_b),...e.action?{work:e.action.id}:{}}),{type:a.internal,workUID:e.id,key:"output.result"}}parseConditionValue(e){return e instanceof u?(this.indexCondition(e),{type:a.internal,workUID:e.id,key:null}):e}appendCondition(e){for(const t of e.work.values())this.addWork(t);delete e.work;const t={operator:e.operator,value_a:this.parseConditionValue(e.value_a),value_b:this.parseConditionValue(e.value_b)};return this.addWork(e.action),this.operationScript.conditions.set(e.id,{...t,...e.action?{work:e.action.id}:{}}),this.operationScript.order.push(e.id)}if(e,t,n){let r=new u({action:null,value_a:e,value_b:n,operator:t});return this.tempCondition=r,{then:this.then.bind(this)}}then(e){return this.tempCondition.action=e,this.appendCondition(this.tempCondition),this.tempCondition=null,{elif:this.if.bind(this),else:this.else.bind(this)}}else(e){const t=new u({operator:null,value_a:null,value_b:null,action:e});return t.value_a=null,t.value_b=null,this.appendCondition(t)}}class u{constructor(e){this.id="cond_"+o(),this.action=null,this.value_a=null,this.value_b=null,this.work=new Map,this.action=e.action,this.operator=e.operator,this.value_a=this.parseData(e.value_a),"not"!==e.operator&&(this.value_b=this.parseData(e.value_b))}parseData(e){if(e instanceof u){if(e.work)for(const t of e.work.values())this.work.set(t.id,t);return e}try{if(e.type&&e.type===a.work)return this.work.set(e.src.self.id,e.src.self),{type:a.internal,workUID:e.src.self.id,key:e.src.key}}catch(e){}return{type:a.static,value:e}}}const f={content:{type:"",from:"",to:"",amount:0,data:["",""],nonce:0,timestamp:0,transaction_fee:{network_fee:0,rpc_fee:0,additional_fee:0}},signature:null,hash:"",status:"",blockNumber:null},p={raw:{action:c.CREATE,parameters:[],method:"GET",url:"",headers:{},stage:{origin:{identity:"",connection_url:""}}},result:null,hash:"",signature:{type:"ed25519",data:""}};const y=BigInt(2**32-1),g=BigInt(32);function w(e,t=!1){return t?{h:Number(e&y),l:Number(e>>g&y)}:{h:0|Number(e>>g&y),l:0|Number(e&y)}}function m(e,t=!1){const n=e.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let i=0;i<n;i++){const{h:n,l:o}=w(e[i],t);[r[i],s[i]]=[n,o]}return[r,s]}const b=(e,t,n)=>e>>>n,_=(e,t,n)=>e<<32-n|t>>>n,k=(e,t,n)=>e>>>n|t<<32-n,x=(e,t,n)=>e<<32-n|t>>>n,A=(e,t,n)=>e<<64-n|t>>>n-32,v=(e,t,n)=>e>>>n-32|t<<64-n;function K(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:0|s}}const E=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),S=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,T=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),I=(e,t,n,r,s)=>t+n+r+s+(e/2**32|0)|0,L=(e,t,n,r,s)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(s>>>0),U=(e,t,n,r,s,i)=>t+n+r+s+i+(e/2**32|0)|0,B="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function H(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function C(e,...t){if(!((n=e)instanceof Uint8Array||ArrayBuffer.isView(n)&&"Uint8Array"===n.constructor.name))throw new Error("Uint8Array expected");var n;if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function D(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");H(e.outputLen),H(e.blockLen)}function F(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function O(e,t){C(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function P(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function N(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function R(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function G(e,t){return e<<32-t|e>>>t}function M(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const W=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])()?e=>e:function(e){for(let t=0;t<e.length;t++)e[t]=M(e[t]);return e},$=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),j=48,X=57,V=65,Y=70,q=97,J=102;function Q(e){return e>=j&&e<=X?e-j:e>=V&&e<=Y?e-(V-10):e>=q&&e<=J?e-(q-10):void 0}function z(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if($)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,s=0;t<n;t++,s+=2){const n=Q(e.charCodeAt(s)),i=Q(e.charCodeAt(s+1));if(void 0===n||void 0===i){const t=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+s)}r[t]=16*n+i}return r}function Z(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}function ee(e){return"string"==typeof e&&(e=Z(e)),C(e),e}function te(e){return"string"==typeof e&&(e=Z(e)),C(e),e}function ne(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];C(r),t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const s=e[t];n.set(s,r),r+=s.length}return n}class re{}function se(e){const t=t=>e().update(ee(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function ie(e=32){if(B&&"function"==typeof B.getRandomValues)return B.getRandomValues(new Uint8Array(e));if(B&&"function"==typeof B.randomBytes)return Uint8Array.from(B.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}const oe=BigInt(0),ae=BigInt(1),ce=BigInt(2),he=BigInt(7),le=BigInt(256),de=BigInt(113),ue=[],fe=[],pe=[];for(let e=0,t=ae,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],ue.push(2*(5*r+n)),fe.push((e+1)*(e+2)/2%64);let s=oe;for(let e=0;e<7;e++)t=(t<<ae^(t>>he)*de)%le,t&ce&&(s^=ae<<(ae<<BigInt(e))-ae);pe.push(s)}const ye=m(pe,!0),ge=ye[0],we=ye[1],me=(e,t,n)=>n>32?((e,t,n)=>t<<n-32|e>>>64-n)(e,t,n):((e,t,n)=>e<<n|t>>>32-n)(e,t,n),be=(e,t,n)=>n>32?((e,t,n)=>e<<n-32|t>>>64-n)(e,t,n):((e,t,n)=>t<<n|e>>>32-n)(e,t,n);class _e extends re{constructor(e,t,n,r=!1,s=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=s,H(n),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=P(this.state)}clone(){return this._cloneInto()}keccak(){W(this.state32),function(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)n[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const r=(t+8)%10,s=(t+2)%10,i=n[s],o=n[s+1],a=me(i,o,1)^n[r],c=be(i,o,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=a,e[t+n+1]^=c}let t=e[2],s=e[3];for(let n=0;n<24;n++){const r=fe[n],i=me(t,s,r),o=be(t,s,r),a=ue[n];t=e[a],s=e[a+1],e[a]=i,e[a+1]=o}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)n[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~n[(r+2)%10]&n[(r+4)%10]}e[0]^=ge[r],e[1]^=we[r]}N(n)}(this.state32,this.rounds),W(this.state32),this.posOut=0,this.pos=0}update(e){F(this),C(e=ee(e));const{blockLen:t,state:n}=this,r=e.length;for(let s=0;s<r;){const i=Math.min(t-this.pos,r-s);for(let t=0;t<i;t++)n[this.pos++]^=e[s++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,128&t&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){F(this,!1),C(e),this.finish();const t=this.state,{blockLen:n}=this;for(let r=0,s=e.length;r<s;){this.posOut>=n&&this.keccak();const i=Math.min(n-this.posOut,s-r);e.set(t.subarray(this.posOut,this.posOut+i),r),this.posOut+=i,r+=i}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return H(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(O(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,N(this.state)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:r,rounds:s,enableXOF:i}=this;return e||(e=new _e(t,n,r,i,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=n,e.outputLen=r,e.enableXOF=i,e.destroyed=this.destroyed,e}}const ke=(e,t,n)=>se(()=>new _e(t,e,n)),xe=(()=>ke(6,144,28))(),Ae=(()=>ke(6,136,32))(),ve=(()=>ke(6,104,48))(),Ke=(()=>ke(6,72,64))(),Ee=(e,t,n)=>function(e){const t=(t,n)=>e(n).update(ee(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}((r={})=>new _e(t,e,void 0===r.dkLen?n:r.dkLen,!0)),Se=(()=>Ee(31,168,16))(),Te=(()=>Ee(31,136,32))();class Ie{static sha256(e){const n=t.sha256.create();return n.update(e),n.digest().toHex()}static sha3_512(e){return Ke(e)}}class Le{static async generate(e,t=!1){const n=[],{content:r}=e;switch(r.type){case"demoswork":case"genesis":break;case"native":var s=await Ue.handle(e,t);n.push(...s);break;case"web2Request":case"crosschainOperation":const o=this.createAssignEdit(r,e.hash);n.push(o);break;case"identity":var i=await Be.handle(e);n.push(...i)}e:try{if("identity"===r.type)break e;let s=await this.createGasEdit(r.from_ed25519_address,e.hash,t,1);n.push(s)}catch(e){throw new Error("Error creating gas edit: "+e)}n.push(this.createNonceEdit(r.from_ed25519_address,e.hash));for(const e of n)e.account.startsWith("0x")||(e.account="0x"+e.account);return n}static async createGasEdit(e,t,n=!1,r=1){return{type:"balance",account:e,operation:n?"add":"remove",amount:r,txhash:t,isRollback:n}}static createAssignEdit(e,t,n=!1){return{type:"assign",account:e.from_ed25519_address,context:"web2Request"===e.type?"web2":"xm",txhash:t,isRollback:n}}static createNonceEdit(e,t,n=!1){return{type:"nonce",operation:"add",account:e,amount:1,txhash:t,isRollback:n}}}class Ue{static async handle(e,t=!1){let n=[],r=e.content.data[1];if("send"===r.nativeOperation){var[s,i]=r.args,o={type:"balance",operation:"remove",isRollback:t,account:e.content.from_ed25519_address,txhash:e.hash,amount:i};n.push(o);var a={type:"balance",operation:"add",isRollback:t,account:s,txhash:e.hash,amount:i};n.push(a)}return n}}class Be{static async handle(e){const t=[],n=e.content.data[1],r={account:e.content.from_ed25519_address,type:"identity",operation:n.method.endsWith("assign")?"add":"remove",txhash:e.hash,isRollback:!1,context:n.context,data:null,referralCode:null};switch(n.method){case"xm_identity_assign":{const t=n.payload.target_identity;if(t.isEVM&&!t.chainId)throw new Error("Failed: chainId not provided");const s=structuredClone(t);r.data={...s,timestamp:e.content.timestamp},r.referralCode=n.payload.referralCode;break}case"pqc_identity_assign":r.data=n.payload.map(t=>({...t,timestamp:e.content.timestamp}));break;case"web2_identity_assign":{const t=n.payload;r.data={context:t.context,data:{username:t.username,userId:t.userId,proof:t.proof,proofHash:Ie.sha256(t.proof),timestamp:e.content.timestamp}},r.referralCode=n.payload.referralCode;break}case"xm_identity_remove":case"web2_identity_remove":case"pqc_identity_remove":r.data=n.payload}return t.push(r),t}}function He(e,t="Missing required element",n=!0){if(!e){if(n)throw new Error("[REQUIRED] "+t);return!1}return!0}function Ce(e,t,n){return e&t^~e&n}function De(e,t,n){return e&t^e&n^t&n}class Fe extends re{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=R(this.buffer)}update(e){F(this),C(e=ee(e));const{view:t,buffer:n,blockLen:r}=this,s=e.length;for(let i=0;i<s;){const o=Math.min(r-this.pos,s-i);if(o===r){const t=R(e);for(;r<=s-i;i+=r)this.process(t,i);continue}n.set(e.subarray(i,i+o),this.pos),this.pos+=o,i+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){F(this),O(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:s}=this;let{pos:i}=this;t[i++]=128,N(this.buffer.subarray(i)),this.padOffset>r-i&&(this.process(n,0),i=0);for(let e=i;e<r;e++)t[e]=0;!function(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const s=BigInt(32),i=BigInt(4294967295),o=Number(n>>s&i),a=Number(n&i),c=r?4:0,h=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+h,a,r)}(n,r-8,BigInt(8*this.length),s),this.process(n,0);const o=R(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,h=this.get();if(c>h.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)o.setUint32(4*e,h[e],s)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:s,destroyed:i,pos:o}=this;return e.destroyed=i,e.finished=s,e.length=r,e.pos=o,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}}const Oe=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Pe=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),Ne=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),Re=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),Ge=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Me=new Uint32Array(64);class We extends Fe{constructor(e=32){super(64,e,8,!1),this.A=0|Oe[0],this.B=0|Oe[1],this.C=0|Oe[2],this.D=0|Oe[3],this.E=0|Oe[4],this.F=0|Oe[5],this.G=0|Oe[6],this.H=0|Oe[7]}get(){const{A:e,B:t,C:n,D:r,E:s,F:i,G:o,H:a}=this;return[e,t,n,r,s,i,o,a]}set(e,t,n,r,s,i,o,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|s,this.F=0|i,this.G=0|o,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)Me[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=Me[e-15],n=Me[e-2],r=G(t,7)^G(t,18)^t>>>3,s=G(n,17)^G(n,19)^n>>>10;Me[e]=s+Me[e-7]+r+Me[e-16]|0}let{A:n,B:r,C:s,D:i,E:o,F:a,G:c,H:h}=this;for(let e=0;e<64;e++){const t=h+(G(o,6)^G(o,11)^G(o,25))+Ce(o,a,c)+Ge[e]+Me[e]|0,l=(G(n,2)^G(n,13)^G(n,22))+De(n,r,s)|0;h=c,c=a,a=o,o=i+t|0,i=s,s=r,r=n,n=t+l|0}n=n+this.A|0,r=r+this.B|0,s=s+this.C|0,i=i+this.D|0,o=o+this.E|0,a=a+this.F|0,c=c+this.G|0,h=h+this.H|0,this.set(n,r,s,i,o,a,c,h)}roundClean(){N(Me)}destroy(){this.set(0,0,0,0,0,0,0,0),N(this.buffer)}}class $e extends We{constructor(){super(28),this.A=0|Pe[0],this.B=0|Pe[1],this.C=0|Pe[2],this.D=0|Pe[3],this.E=0|Pe[4],this.F=0|Pe[5],this.G=0|Pe[6],this.H=0|Pe[7]}}const je=(()=>m(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))))(),Xe=(()=>je[0])(),Ve=(()=>je[1])(),Ye=new Uint32Array(80),qe=new Uint32Array(80);class Je extends Fe{constructor(e=64){super(128,e,16,!1),this.Ah=0|Re[0],this.Al=0|Re[1],this.Bh=0|Re[2],this.Bl=0|Re[3],this.Ch=0|Re[4],this.Cl=0|Re[5],this.Dh=0|Re[6],this.Dl=0|Re[7],this.Eh=0|Re[8],this.El=0|Re[9],this.Fh=0|Re[10],this.Fl=0|Re[11],this.Gh=0|Re[12],this.Gl=0|Re[13],this.Hh=0|Re[14],this.Hl=0|Re[15]}get(){const{Ah:e,Al:t,Bh:n,Bl:r,Ch:s,Cl:i,Dh:o,Dl:a,Eh:c,El:h,Fh:l,Fl:d,Gh:u,Gl:f,Hh:p,Hl:y}=this;return[e,t,n,r,s,i,o,a,c,h,l,d,u,f,p,y]}set(e,t,n,r,s,i,o,a,c,h,l,d,u,f,p,y){this.Ah=0|e,this.Al=0|t,this.Bh=0|n,this.Bl=0|r,this.Ch=0|s,this.Cl=0|i,this.Dh=0|o,this.Dl=0|a,this.Eh=0|c,this.El=0|h,this.Fh=0|l,this.Fl=0|d,this.Gh=0|u,this.Gl=0|f,this.Hh=0|p,this.Hl=0|y}process(e,t){for(let n=0;n<16;n++,t+=4)Ye[n]=e.getUint32(t),qe[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|Ye[e-15],n=0|qe[e-15],r=k(t,n,1)^k(t,n,8)^b(t,0,7),s=x(t,n,1)^x(t,n,8)^_(t,n,7),i=0|Ye[e-2],o=0|qe[e-2],a=k(i,o,19)^A(i,o,61)^b(i,0,6),c=x(i,o,19)^v(i,o,61)^_(i,o,6),h=T(s,c,qe[e-7],qe[e-16]),l=I(h,r,a,Ye[e-7],Ye[e-16]);Ye[e]=0|l,qe[e]=0|h}let{Ah:n,Al:r,Bh:s,Bl:i,Ch:o,Cl:a,Dh:c,Dl:h,Eh:l,El:d,Fh:u,Fl:f,Gh:p,Gl:y,Hh:g,Hl:w}=this;for(let e=0;e<80;e++){const t=k(l,d,14)^k(l,d,18)^A(l,d,41),m=x(l,d,14)^x(l,d,18)^v(l,d,41),b=l&u^~l&p,_=L(w,m,d&f^~d&y,Ve[e],qe[e]),T=U(_,g,t,b,Xe[e],Ye[e]),I=0|_,B=k(n,r,28)^A(n,r,34)^A(n,r,39),H=x(n,r,28)^v(n,r,34)^v(n,r,39),C=n&s^n&o^s&o,D=r&i^r&a^i&a;g=0|p,w=0|y,p=0|u,y=0|f,u=0|l,f=0|d,({h:l,l:d}=K(0|c,0|h,0|T,0|I)),c=0|o,h=0|a,o=0|s,a=0|i,s=0|n,i=0|r;const F=E(I,H,D);n=S(F,T,B,C),r=0|F}({h:n,l:r}=K(0|this.Ah,0|this.Al,0|n,0|r)),({h:s,l:i}=K(0|this.Bh,0|this.Bl,0|s,0|i)),({h:o,l:a}=K(0|this.Ch,0|this.Cl,0|o,0|a)),({h:c,l:h}=K(0|this.Dh,0|this.Dl,0|c,0|h)),({h:l,l:d}=K(0|this.Eh,0|this.El,0|l,0|d)),({h:u,l:f}=K(0|this.Fh,0|this.Fl,0|u,0|f)),({h:p,l:y}=K(0|this.Gh,0|this.Gl,0|p,0|y)),({h:g,l:w}=K(0|this.Hh,0|this.Hl,0|g,0|w)),this.set(n,r,s,i,o,a,c,h,l,d,u,f,p,y,g,w)}roundClean(){N(Ye,qe)}destroy(){N(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class Qe extends Je{constructor(){super(48),this.Ah=0|Ne[0],this.Al=0|Ne[1],this.Bh=0|Ne[2],this.Bl=0|Ne[3],this.Ch=0|Ne[4],this.Cl=0|Ne[5],this.Dh=0|Ne[6],this.Dl=0|Ne[7],this.Eh=0|Ne[8],this.El=0|Ne[9],this.Fh=0|Ne[10],this.Fl=0|Ne[11],this.Gh=0|Ne[12],this.Gl=0|Ne[13],this.Hh=0|Ne[14],this.Hl=0|Ne[15]}}const ze=Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),Ze=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);class et extends Je{constructor(){super(28),this.Ah=0|ze[0],this.Al=0|ze[1],this.Bh=0|ze[2],this.Bl=0|ze[3],this.Ch=0|ze[4],this.Cl=0|ze[5],this.Dh=0|ze[6],this.Dl=0|ze[7],this.Eh=0|ze[8],this.El=0|ze[9],this.Fh=0|ze[10],this.Fl=0|ze[11],this.Gh=0|ze[12],this.Gl=0|ze[13],this.Hh=0|ze[14],this.Hl=0|ze[15]}}class tt extends Je{constructor(){super(32),this.Ah=0|Ze[0],this.Al=0|Ze[1],this.Bh=0|Ze[2],this.Bl=0|Ze[3],this.Ch=0|Ze[4],this.Cl=0|Ze[5],this.Dh=0|Ze[6],this.Dl=0|Ze[7],this.Eh=0|Ze[8],this.El=0|Ze[9],this.Fh=0|Ze[10],this.Fl=0|Ze[11],this.Gh=0|Ze[12],this.Gl=0|Ze[13],this.Hh=0|Ze[14],this.Hl=0|Ze[15]}}const nt=se(()=>new We),rt=se(()=>new $e),st=se(()=>new Je),it=se(()=>new Qe),ot=se(()=>new tt),at=se(()=>new et),ct=C,ht=ie;function lt(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return 0===n}function dt(...e){const t=e=>"number"==typeof e?e:e.bytesLen,n=e.reduce((e,n)=>e+t(n),0);return{bytesLen:n,encode:r=>{const s=new Uint8Array(n);for(let n=0,i=0;n<e.length;n++){const o=e[n],a=t(o),c="number"==typeof o?r[n]:o.encode(r[n]);ct(c,a),s.set(c,i),"number"!=typeof o&&c.fill(0),i+=a}return s},decode:r=>{ct(r,n);const s=[];for(const n of e){const e=t(n),i=r.subarray(0,e);s.push("number"==typeof n?i:n.decode(i)),r=r.subarray(e)}return s}}}function ut(e,t){const n=t*e.bytesLen;return{bytesLen:n,encode:r=>{if(r.length!==t)throw new Error(`vecCoder.encode: wrong length=${r.length}. Expected: ${t}`);const s=new Uint8Array(n);for(let t=0,n=0;t<r.length;t++){const i=e.encode(r[t]);s.set(i,n),i.fill(0),n+=i.length}return s},decode:t=>{ct(t,n);const r=[];for(let n=0;n<t.length;n+=e.bytesLen)r.push(e.decode(t.subarray(n,n+e.bytesLen)));return r}}}function ft(...e){for(const t of e)if(Array.isArray(t))for(const e of t)e.fill(0);else t.fill(0)}function pt(e){return(1<<e)-1}const yt=new Uint8Array(0);function gt(e,t=yt){if(ct(e),ct(t),t.length>255)throw new Error("context should be less than 255 bytes");return ne(new Uint8Array([0,t.length]),t,e)}const wt={"SHA2-256":{oid:z("0609608648016503040201"),hash:nt},"SHA2-384":{oid:z("0609608648016503040202"),hash:it},"SHA2-512":{oid:z("0609608648016503040203"),hash:st},"SHA2-224":{oid:z("0609608648016503040204"),hash:rt},"SHA2-512/224":{oid:z("0609608648016503040205"),hash:at},"SHA2-512/256":{oid:z("0609608648016503040206"),hash:ot},"SHA3-224":{oid:z("0609608648016503040207"),hash:xe},"SHA3-256":{oid:z("0609608648016503040208"),hash:Ae},"SHA3-384":{oid:z("0609608648016503040209"),hash:ve},"SHA3-512":{oid:z("060960864801650304020A"),hash:Ke},"SHAKE-128":{oid:z("060960864801650304020B"),hash:e=>Se(e,{dkLen:32})},"SHAKE-256":{oid:z("060960864801650304020C"),hash:e=>Te(e,{dkLen:64})}};function mt(e,t,n=yt){if(ct(t),ct(n),n.length>255)throw new Error("context should be less than 255 bytes");if(!wt[e])throw new Error("unknown hash: "+e);const{oid:r,hash:s}=wt[e],i=s(t);return ne(new Uint8Array([1,n.length]),n,r,i)}function bt(e,t=8){const n=e.toString(2).padStart(8,"0").slice(-t).padStart(7,"0").split("").reverse().join("");return Number.parseInt(n,2)}const _t=e=>{const{newPoly:t,N:n,Q:r,F:s,ROOT_OF_UNITY:i,brvBits:o,isKyber:a}=e,c=(e,t=r)=>{const n=e%t|0;return 0|(n>=0?n:t+n)};const h=function(){const e=t(n);for(let t=0;t<n;t++){const n=bt(t,o),s=BigInt(i)**BigInt(n)%BigInt(r);e[t]=0|Number(s)}return e}(),l=a?128:n,d=a?1:0,u={encode:e=>{for(let t=1,r=128;r>d;r>>=1)for(let s=0;s<n;s+=2*r){const n=h[t++];for(let t=s;t<s+r;t++){const s=c(n*e[t+r]);e[t+r]=0|c(e[t]-s),e[t]=0|c(e[t]+s)}}return e},decode:e=>{for(let t=l-1,r=1+d;r<l+d;r<<=1)for(let s=0;s<n;s+=2*r){const n=h[t--];for(let t=s;t<s+r;t++){const s=e[t];e[t]=c(s+e[t+r]),e[t+r]=c(n*(e[t+r]-s))}}for(let t=0;t<e.length;t++)e[t]=c(s*e[t]);return e}};return{mod:c,smod:(e,t=r)=>{const n=0|c(e,t);return 0|(n>t>>1?n-t:n)},nttZetas:h,NTT:u,bitsCoder:(e,r)=>{const s=pt(e),i=e*(n/8);return{bytesLen:i,encode:t=>{const n=new Uint8Array(i);for(let i=0,o=0,a=0,c=0;i<t.length;i++)for(o|=(r.encode(t[i])&s)<<a,a+=e;a>=8;a-=8,o>>=8)n[c++]=o&pt(a);return n},decode:i=>{const o=t(n);for(let t=0,n=0,a=0,c=0;t<i.length;t++)for(n|=i[t]<<a,a+=8;a>=e;a-=e,n>>=e)o[c++]=r.decode(n&s);return o}}}}},kt=e=>(t,n)=>{n||(n=e.blockLen);const r=new Uint8Array(t.length+2);r.set(t);const s=t.length,i=new Uint8Array(n);let o=e.create({}),a=0,c=0;return{stats:()=>({calls:a,xofs:c}),get:(t,n)=>(r[s+0]=t,r[s+1]=n,o=e.create({}).update(r),a++,()=>(c++,o.xofInto(i))),clean:()=>{i.fill(0),r.fill(0)}}},xt=kt(Se),At=kt(Te),vt=256,Kt=3329,{mod:Et,nttZetas:St,NTT:Tt,bitsCoder:It}=_t({N:vt,Q:Kt,F:3303,ROOT_OF_UNITY:17,newPoly:e=>new Uint16Array(e),brvBits:7,isKyber:!0}),Lt=e=>It(e,(e=>{if(e>=12)return{encode:e=>e,decode:e=>e};const t=2**(e-1);return{encode:t=>((t<<e)+Kt/2)/Kt,decode:n=>n*Kt+t>>>e}})(e));function Ut(e,t){for(let n=0;n<vt;n++)e[n]=Et(e[n]+t[n])}function Bt(e,t,n,r,s){return{c0:Et(t*r*s+e*n),c1:Et(e*r+t*n)}}function Ht(e,t){for(let n=0;n<128;n++){let r=St[64+(n>>1)];1&n&&(r=-r);const{c0:s,c1:i}=Bt(e[2*n+0],e[2*n+1],t[2*n+0],t[2*n+1],r);e[2*n+0]=s,e[2*n+1]=i}return e}function Ct(e){const t=new Uint16Array(vt);for(let n=0;n<vt;){const r=e();if(r.length%3)throw new Error("SampleNTT: unaligned block");for(let e=0;n<vt&&e+3<=r.length;e+=3){const s=4095&(r[e+0]|r[e+1]<<8),i=4095&(r[e+1]>>4|r[e+2]<<4);s<Kt&&(t[n++]=s),n<vt&&i<Kt&&(t[n++]=i)}}return t}function Dt(e,t,n,r){const s=e(r*vt/4,t,n),i=new Uint16Array(vt),o=P(s);let a=0;for(let e=0,t=0,n=0,s=0;e<o.length;e++){let c=o[e];for(let e=0;e<32;e++)n+=1&c,c>>=1,a+=1,a===r?(s=n,n=0):a===2*r&&(i[t++]=Et(s-n),n=0,a=0)}if(a)throw new Error(`sampleCBD: leftover bits: ${a}`);return i}const Ft=e=>{const{K:t,PRF:n,XOF:r,HASH512:s,ETA1:i,ETA2:o,du:a,dv:c}=e,h=Lt(1),l=Lt(c),d=Lt(a),u=dt(ut(Lt(12),t),32),f=ut(Lt(12),t),p=dt(ut(d,t),l),y=dt(32,32);return{secretCoder:f,secretKeyLen:f.bytesLen,publicKeyLen:u.bytesLen,cipherTextLen:p.bytesLen,keygen:e=>{ct(e,32);const o=new Uint8Array(33);o.set(e),o[32]=t;const a=s(o),[c,h]=y.decode(a),l=[],d=[];for(let e=0;e<t;e++)l.push(Tt.encode(Dt(n,h,e,i)));const p=r(c);for(let e=0;e<t;e++){const r=Tt.encode(Dt(n,h,t+e,i));for(let n=0;n<t;n++){Ut(r,Ht(Ct(p.get(n,e)),l[n]))}d.push(r)}p.clean();const g={publicKey:u.encode([d,c]),secretKey:f.encode(l)};return ft(c,h,l,d,o,a),g},encrypt:(e,s,a)=>{const[c,l]=u.decode(e),d=[];for(let e=0;e<t;e++)d.push(Tt.encode(Dt(n,a,e,i)));const f=r(l),y=new Uint16Array(vt),g=[];for(let e=0;e<t;e++){const r=Dt(n,a,t+e,o),s=new Uint16Array(vt);for(let n=0;n<t;n++){Ut(s,Ht(Ct(f.get(e,n)),d[n]))}Ut(r,Tt.decode(s)),g.push(r),Ut(y,Ht(c[e],d[e])),s.fill(0)}f.clean();const w=Dt(n,a,2*t,o);Ut(w,Tt.decode(y));const m=h.decode(s);return Ut(m,w),ft(c,d,y,w),p.encode([g,m])},decrypt:(e,n)=>{const[r,s]=p.decode(e),i=f.decode(n),o=new Uint16Array(vt);for(let e=0;e<t;e++)Ut(o,Ht(i[e],Tt.encode(r[e])));return function(e,t){for(let n=0;n<vt;n++)e[n]=Et(e[n]-t[n])}(s,Tt.decode(o)),ft(o,i,r),h.encode(s)}}};function Ot(e){const t=Ft(e),{HASH256:n,HASH512:r,KDF:s}=e,{secretCoder:i,cipherTextLen:o}=t,a=t.publicKeyLen,c=dt(t.secretKeyLen,t.publicKeyLen,32,32),h=c.bytesLen;return{publicKeyLen:a,msgLen:32,keygen:(e=ht(64))=>{ct(e,64);const{publicKey:r,secretKey:s}=t.keygen(e.subarray(0,32)),i=n(r),o=c.encode([s,r,i,e.subarray(32)]);return ft(s,i),{publicKey:r,secretKey:o}},encapsulate:(s,o=ht(32))=>{ct(s,a),ct(o,32);const c=s.subarray(0,384*e.K),h=i.encode(i.decode(c.slice()));if(!lt(h,c))throw ft(h),new Error("ML-KEM.encapsulate: wrong publicKey modulus");ft(h);const l=r.create().update(o).update(n(s)).digest(),d=t.encrypt(s,o,l.subarray(32,64));return l.subarray(32).fill(0),{cipherText:d,sharedSecret:l.subarray(0,32)}},decapsulate:(e,n)=>{ct(n,h),ct(e,o);const[i,a,l,d]=c.decode(n),u=t.decrypt(e,i),f=r.create().update(u).update(l).digest(),p=f.subarray(0,32),y=t.encrypt(a,u,f.subarray(32,64)),g=lt(e,y),w=s.create({dkLen:32}).update(d).update(e).digest();return ft(u,y,g?w:p),g?p:w}}}const Pt=Ot({...{HASH256:Ae,HASH512:Ke,KDF:Te,XOF:xt,PRF:function(e,t,n){return Te.create({dkLen:e}).update(t).update(new Uint8Array([n])).digest()}},...{N:vt,Q:Kt,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192}}),Nt=256,Rt=8380417,Gt=0|Math.floor(95232),Mt=0|Math.floor(261888),Wt={K:6,L:5,D:13,GAMMA1:2**19,GAMMA2:Mt,TAU:49,ETA:4,OMEGA:55},$t=e=>new Int32Array(e),{mod:jt,smod:Xt,NTT:Vt,bitsCoder:Yt}=_t({N:Nt,Q:Rt,F:8347681,ROOT_OF_UNITY:1753,newPoly:$t,isKyber:!1,brvBits:8}),qt=e=>e,Jt=(e,t=qt,n=qt)=>Yt(e,{encode:e=>t(n(e)),decode:e=>n(t(e))}),Qt=(e,t)=>{for(let n=0;n<e.length;n++)e[n]=jt(e[n]+t[n]);return e},zt=(e,t)=>{for(let n=0;n<e.length;n++)e[n]=jt(e[n]-t[n]);return e},Zt=e=>{for(let t=0;t<Nt;t++)e[t]<<=13;return e},en=(e,t)=>{for(let n=0;n<Nt;n++)if(Math.abs(Xt(e[n]))>=t)return!0;return!1},tn=(e,t)=>{const n=$t(Nt);for(let r=0;r<e.length;r++)n[r]=jt(e[r]*t[r]);return n};function nn(e){const t=$t(Nt);for(let n=0;n<Nt;){const r=e();if(r.length%3)throw new Error("RejNTTPoly: unaligned block");for(let e=0;n<Nt&&e<=r.length-3;e+=3){const s=8388607&(r[e+0]|r[e+1]<<8|r[e+2]<<16);s<Rt&&(t[n++]=s)}}return t}function rn(e){const{K:t,L:n,GAMMA1:r,GAMMA2:s,TAU:i,ETA:o,OMEGA:a}=e,{CRH_BYTES:c,TR_BYTES:h,C_TILDE_BYTES:l,XOF128:d,XOF256:u}=e;if(![2,4].includes(o))throw new Error("Wrong ETA");if(![1<<17,1<<19].includes(r))throw new Error("Wrong GAMMA1");if(![Gt,Mt].includes(s))throw new Error("Wrong GAMMA2");const f=i*o,p=e=>{const t=jt(e),n=0|Xt(t,2*s);if(t-n===Rt-1)return{r1:0,r0:n-1|0};return{r1:0|Math.floor((t-n)/(2*s)),r0:n}},y=e=>p(e).r1,g=e=>p(e).r0,w=(e,t)=>e<=s||e>Rt-s||e===Rt-s&&0===t?0:1,m=(e,t)=>{const n=Math.floor((Rt-1)/(2*s)),{r1:r,r0:i}=p(t);return 1===e?i>0?0|jt(r+1,n):0|jt(r-1,n):0|r},b=e=>{const t=jt(e),n=0|Xt(t,8192);return{r1:0|Math.floor((t-n)/8192),r0:n}},_={bytesLen:a+t,encode:e=>{if(!1===e)throw new Error("hint.encode: hint is false");const n=new Uint8Array(a+t);for(let r=0,s=0;r<t;r++){for(let t=0;t<Nt;t++)0!==e[r][t]&&(n[s++]=t);n[a+r]=s}return n},decode:e=>{let n=0;for(let r=0;r<t;r++){const t=$t(Nt);if(e[a+r]<n||e[a+r]>a)return!1;for(let s=n;s<e[a+r];s++){if(s>n&&e[s]<=e[s-1])return!1;t[e[s]]=1}n=e[a+r]}for(let t=n;t<a;t++)if(0!==e[t])return!1;return[]}},k=Jt(2===o?3:4,e=>o-e,e=>{if(!(-o<=e&&e<=o))throw new Error(`malformed key s1/s3 ${e} outside of ETA range [${-o}, ${o}]`);return e}),x=Jt(13,e=>4096-e),A=Jt(10),v=Jt(r===1<<17?18:20,e=>Xt(r-e)),K=ut(Jt(s===Gt?6:4),t),E=dt(32,ut(A,t)),S=dt(32,32,h,ut(k,n),ut(k,t),ut(x,t)),T=dt(l,ut(v,n),_),I=2===o?e=>e<15&&2-e%5:e=>e<9&&4-e;function L(e){const t=$t(Nt);for(let n=0;n<Nt;){const r=e();for(let e=0;n<Nt&&e<r.length;e+=1){const s=I(15&r[e]),i=I(r[e]>>4&15);!1!==s&&(t[n++]=s),n<Nt&&!1!==i&&(t[n++]=i)}}return t}const U=e=>{const t=$t(Nt),n=Te.create({}).update(e),r=new Uint8Array(Te.blockLen);n.xofInto(r);const s=r.slice(0,8);for(let e=Nt-i,o=8,a=0,c=0;e<Nt;e++){let i=e+1;for(;i>e;)i=r[o++],o<Te.blockLen||(n.xofInto(r),o=0);t[e]=t[i],t[i]=1-((s[a]>>c++&1)<<1),c>=8&&(a++,c=0)}return t},B=e=>{const t=$t(Nt),n=$t(Nt);for(let r=0;r<e.length;r++){const{r0:s,r1:i}=b(e[r]);t[r]=s,n[r]=i}return{r0:t,r1:n}},H=(e,t)=>{for(let n=0;n<Nt;n++)e[n]=m(t[n],e[n]);return e},C=(e,t)=>{const n=$t(Nt);let r=0;for(let s=0;s<Nt;s++){const i=w(e[s],t[s]);n[s]=i,r+=i}return{v:n,cnt:r}},D=dt(32,64,32),F={signRandBytes:32,keygen:e=>{const r=new Uint8Array(34),s=void 0===e;s&&(e=ht(32)),ct(e,32),r.set(e),s&&e.fill(0),r[32]=t,r[33]=n;const[i,o,a]=D.decode(Te(r,{dkLen:D.bytesLen})),c=u(o),l=[];for(let e=0;e<n;e++)l.push(L(c.get(255&e,e>>8&255)));const f=[];for(let e=n;e<n+t;e++)f.push(L(c.get(255&e,e>>8&255)));const p=l.map(e=>Vt.encode(e.slice())),y=[],g=[],w=d(i),m=$t(Nt);for(let e=0;e<t;e++){m.fill(0);for(let t=0;t<n;t++){const n=nn(w.get(t,e));Qt(m,tn(n,p[t]))}Vt.decode(m);const{r0:t,r1:r}=B(Qt(m,f[e]));y.push(t),g.push(r)}const b=E.encode([i,g]),_=Te(b,{dkLen:h}),k=S.encode([i,a,_,l,f,y]);return w.clean(),c.clean(),ft(i,o,a,l,f,p,m,y,g,_,r),{publicKey:b,secretKey:k}},sign:(e,i,o,h=!1)=>{const[p,w,m,b,_,k]=S.decode(e),x=[],A=d(p);for(let e=0;e<t;e++){const t=[];for(let r=0;r<n;r++)t.push(nn(A.get(r,e)));x.push(t)}A.clean();for(let e=0;e<n;e++)Vt.encode(b[e]);for(let e=0;e<t;e++)Vt.encode(_[e]),Vt.encode(k[e]);const E=h?i:Te.create({dkLen:c}).update(m).update(i).digest(),I=o||new Uint8Array(32);ct(I);const L=Te.create({dkLen:c}).update(w).update(I).update(E).digest();ct(L,c);const B=u(L,v.bytesLen);e:for(let e=0;;){const i=[];for(let t=0;t<n;t++,e++)i.push(v.decode(B.get(255&e,e>>8)()));const o=i.map(e=>Vt.encode(e.slice())),c=[];for(let e=0;e<t;e++){const t=$t(Nt);for(let r=0;r<n;r++)Qt(t,tn(x[e][r],o[r]));Vt.decode(t),c.push(t)}const h=c.map(e=>e.map(y)),d=Te.create({dkLen:l}).update(E).update(K.encode(h)).digest(),u=Vt.encode(U(d)),p=b.map(e=>tn(e,u));for(let e=0;e<n;e++)if(Qt(Vt.decode(p[e]),i[e]),en(p[e],r-f))continue e;let w=0;const m=[];for(let e=0;e<t;e++){const t=Vt.decode(tn(_[e],u)),n=zt(c[e],t).map(g);if(en(n,s-f))continue e;const r=Vt.decode(tn(k[e],u));if(en(r,s))continue e;Qt(n,r);w+=C(n,h[e]).cnt}if(w>a)continue;B.clean();const A=T.encode([d,p,m]);return ft(d,p,m,u,h,c,o,i,L,E,b,_,k,...x),A}throw new Error("Unreachable code path reached, report this error")},verify:(e,s,i,o=!1)=>{const[u,p]=E.decode(e),y=Te(e,{dkLen:h});if(i.length!==T.bytesLen)return!1;const[g,w,m]=T.decode(i);if(!1===m)return!1;for(let e=0;e<n;e++)if(en(w[e],r-f))return!1;const b=o?s:Te.create({dkLen:c}).update(y).update(s).digest(),_=Vt.encode(U(g)),k=w.map(e=>e.slice());for(let e=0;e<n;e++)Vt.encode(k[e]);const x=[],A=d(u);for(let e=0;e<t;e++){const t=tn(Vt.encode(Zt(p[e])),_),r=$t(Nt);for(let t=0;t<n;t++){const n=nn(A.get(t,e));Qt(r,tn(n,k[t]))}const s=Vt.decode(zt(r,t));x.push(H(s,m[e]))}A.clean();const v=Te.create({dkLen:l}).update(b).update(K.encode(x)).digest();for(const e of m){if(!(e.reduce((e,t)=>e+t,0)<=a))return!1}for(const e of w)if(en(e,r-f))return!1;return lt(g,v)}};return{internal:F,keygen:F.keygen,signRandBytes:F.signRandBytes,sign:(e,t,n=yt,r)=>{const s=gt(t,n),i=F.sign(e,s,r);return s.fill(0),i},verify:(e,t,n,r=yt)=>F.verify(e,gt(t,r),n),prehash:e=>({sign:(t,n,r=yt,s)=>{const i=mt(e,n,r),o=F.sign(t,i,s);return i.fill(0),o},verify:(t,n,r,s=yt)=>F.verify(t,mt(e,n,s),r)})}}const sn=rn({...Wt,CRH_BYTES:64,TR_BYTES:64,C_TILDE_BYTES:48,XOF128:xt,XOF256:At});class on{constructor(e){if(e&&"falcon512_n3_v1"!==e&&"falcon1024_n3_v1"!==e)throw new Error(`Invalid algorithm ID: ${e}\nSupported algorithms: falcon512_n3_v1, falcon1024_n3_v1\nLeave blank for default: falcon512_n3_v1`);this.algid=e||"falcon512_n3_v1"}async init(){this.kernel=await s(this.algid)}async genkey(e){this.keypair=e?this.kernel.genkey(e):this.kernel.genkey()}async sign(e,t){return t?this.kernel.sign(e,this.keypair.sk,t):this.kernel.sign(e,this.keypair.sk)}async verify(e,t,n){return this.kernel.verify(t,e,n)}async publicKeyCreate(e){return this.kernel.publicKeyCreate(e)}async setKeypair(e){this.keypair=e}async getPublicKey(){return this.keypair.pk}async getPrivateKey(){return this.keypair.sk}async getAlgid(){return this.algid}async getKeypair(){return this.keypair}async getKernel(){return this.kernel}static uint8ArrayToHex(e){return Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")}static hexToUint8Array(e){(e=e.replace(/[^0-9a-fA-F]/g,"")).length%2!=0&&(e="0"+e);const t=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)t[n/2]=parseInt(e.substring(n,n+2),16);return t}async getPublicKeyHex(){const e=await this.getPublicKey();return on.uint8ArrayToHex(e)}async getPrivateKeyHex(){const e=await this.getPrivateKey();return on.uint8ArrayToHex(e)}async signHex(e){const t=await this.sign(e);return on.uint8ArrayToHex(t)}async verifyHex(e,t,n){const r=on.hexToUint8Array(t),s=on.hexToUint8Array(n);return this.verify(e,r,s)}async publicKeyCreateHex(e){const t=on.hexToUint8Array(e),n=await this.publicKeyCreate(t);return on.uint8ArrayToHex(n)}async setPrivateKeyHex(e){const t=on.hexToUint8Array(e),n=await this.publicKeyCreate(t);return this.keypair={genkeySeed:new Uint8Array(0),sk:t,pk:n},on.uint8ArrayToHex(n)}static uint8ArrayToBase64(e){return Buffer.from(e).toString("base64")}static base64ToUint8Array(e){return Buffer.from(e,"base64")}async getPublicKeyBase64(){const e=await this.getPublicKey();return on.uint8ArrayToBase64(e)}async getPrivateKeyBase64(){const e=await this.getPrivateKey();return on.uint8ArrayToBase64(e)}async signBase64(e){const t=await this.sign(e);return on.uint8ArrayToBase64(t)}async verifyBase64(e,t,n){const r=on.base64ToUint8Array(t),s=on.base64ToUint8Array(n);return this.verify(e,r,s)}async publicKeyCreateBase64(e){const t=on.base64ToUint8Array(e),n=await this.publicKeyCreate(t);return on.uint8ArrayToBase64(n)}async setPrivateKeyBase64(e){const t=on.base64ToUint8Array(e),n=await this.publicKeyCreate(t);return this.keypair={genkeySeed:new Uint8Array(0),sk:t,pk:n},on.uint8ArrayToBase64(n)}}class an{constructor(){this.ml_dsa_signing_keypair=null,this.falcon_signing_keypair=null,this.ml_kem_encryption_keypair=null,this.ml_kem_aes_parameters=null}static async hash(e,t="sha3-256"){return Ae.create().update(e).digest()}static async verify_ml_dsa(e,t,n){return sn.verify(n,t,e)}static async verify_falcon(e,t,n){const r=new on;return await r.init(),r.verify(t,e,n)}async sign_ml_dsa(e,t){if(t||(t=this.ml_dsa_signing_keypair),!t.privateKey)throw new Error("ml_dsa_signing_keypair.privateKey is not set");return sn.sign(t.privateKey,e)}async sign_falcon(e,t){if(t||(t=this.falcon_signing_keypair),!t.privateKey)throw new Error("falcon_signing_keypair.privateKey is not set");const n=new on;return await n.init(),await n.setKeypair({genkeySeed:this.falcon_signing_keypair.genKey,sk:this.falcon_signing_keypair.privateKey,pk:this.falcon_signing_keypair.publicKey}),n.sign(e)}async encapsulate_ml_kem(e){if(!this.ml_kem_encryption_keypair.privateKey)throw new Error("ml_kem_encryption_keypair.privateKey is not set");return Pt.encapsulate(e)}async decapsulate_ml_kem(e){if(!this.ml_kem_encryption_keypair.privateKey)throw new Error("ml_kem_encryption_keypair.privateKey is not set");return Pt.decapsulate(e,this.ml_kem_encryption_keypair.privateKey)}async encrypt_ml_kem_aes(e,t){if(!this.ml_kem_encryption_keypair.privateKey)throw new Error("ml_kem_encryption_keypair.privateKey is not set");const r=Pt.encapsulate(t),s=n.randomBytes(12),i=n.createCipheriv("aes-256-gcm",r.sharedSecret,s),o=Buffer.concat([i.update(e),i.final()]),a=i.getAuthTag(),c=Buffer.concat([s,o,a]);return{cipherText:r.cipherText,encryptedMessage:c}}async decrypt_ml_kem_aes(e,t){if(!this.ml_kem_encryption_keypair.privateKey)throw new Error("ml_kem_encryption_keypair.privateKey is not set");const r=Pt.decapsulate(t,this.ml_kem_encryption_keypair.privateKey),s=e.slice(0,12),i=e.slice(12,-16),o=e.slice(-16),a=n.createDecipheriv("aes-256-gcm",r,s);a.setAuthTag(o);return Buffer.concat([a.update(i),a.final()])}async generate_ml_dsa_signing_keypair(e=null){e||(e=r(32));const t=sn.keygen(e);this.ml_dsa_signing_keypair={publicKey:t.publicKey,privateKey:t.secretKey}}async generate_falcon_signing_keypair(e=null){e||(e=r(48));const t=new on;await t.init(),await t.genkey(e);const n=await t.getKeypair();this.falcon_signing_keypair={genKey:n.genkeySeed,publicKey:n.pk,privateKey:n.sk}}async generate_ml_kem_encryption_keypair(e=null){e||(e=r(64));let t=Pt.keygen(e);this.ml_kem_encryption_keypair={privateKey:t.secretKey,publicKey:t.publicKey}}}class cn extends re{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,D(e);const n=ee(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,s=new Uint8Array(r);s.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<s.length;e++)s[e]^=54;this.iHash.update(s),this.oHash=e.create();for(let e=0;e<s.length;e++)s[e]^=106;this.oHash.update(s),N(s)}update(e){return F(this),this.iHash.update(e),this}digestInto(e){F(this),C(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:s,blockLen:i,outputLen:o}=this;return e.finished=r,e.destroyed=s,e.blockLen=i,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const hn=(e,t,n)=>new cn(e,t).update(n).digest();function ln(e,t,n,r){D(e);const s=function(e,t){if(void 0!==t&&"[object Object]"!=={}.toString.call(t))throw new Error("options should be object or undefined");return Object.assign(e,t)}({dkLen:32,asyncTick:10},r),{c:i,dkLen:o,asyncTick:a}=s;if(H(i),H(o),H(a),i<1)throw new Error("iterations (c) should be >= 1");const c=te(t),h=te(n),l=new Uint8Array(o),d=hn.create(e,c),u=d._cloneInto().update(h);return{c:i,dkLen:o,asyncTick:a,DK:l,PRF:d,PRFSalt:u}}function dn(e,t,n,r){const{c:s,dkLen:i,DK:o,PRF:a,PRFSalt:c}=ln(e,t,n,r);let h;const l=new Uint8Array(4),d=R(l),u=new Uint8Array(a.outputLen);for(let e=1,t=0;t<i;e++,t+=a.outputLen){const n=o.subarray(t,t+a.outputLen);d.setInt32(0,e,!1),(h=c._cloneInto(h)).update(l).digestInto(u),n.set(u.subarray(0,n.length));for(let e=1;e<s;e++){a._cloneInto(h).update(u).digestInto(u);for(let e=0;e<n.length;e++)n[e]^=u[e]}}return function(e,t,n,r,s){return e.destroy(),t.destroy(),r&&r.destroy(),N(s),n}(a,c,o,h,u)}function un(e){if("string"!=typeof e)throw new TypeError("invalid mnemonic type: "+typeof e);return e.normalize("NFKD")}hn.create=(e,t)=>new cn(e,t);function fn(e,t=""){return dn(st,function(e){const t=un(e),n=t.split(" ");if(![12,15,18,21,24].includes(n.length))throw new Error("Invalid mnemonic");return{nfkd:t,words:n}}(e).nfkd,(e=>un("mnemonic"+e))(t),{c:2048,dkLen:64})}function pn(e){e=e.slice(2);let t=new Uint8Array(64);for(let n=0;n<e.length;n+=2){const r=e.substr(n,2),s=parseInt(r,16);t[n/2]=s}return t}const yn="aes-256-cbc";class gn{static new(){const e=t.random.getBytesSync(32);return t.pki.ed25519.generateKeyPair({seed:e})}static newFromSeed(e){"string"==typeof e&&(e=fn(e));const n=e.toString(),r=Ie.sha256(n),s=Buffer.from(r,"hex");return t.pki.ed25519.generateKeyPair({seed:s})}static async save(e,t,n="hex"){if("hex"===n){let n=gn.saveToHex(e.privateKey);await i.writeFile(t,n)}else await i.writeFile(t,JSON.stringify(e.privateKey))}static saveToHex(e){return"0x"+e.toString("hex")}static async saveEncrypted(e,t,r){const s=n.createCipher(yn,r),o=e.privateKey.toString("hex"),a=s.update(o,"utf8","hex");await i.writeFile(t,a)}static async loadEncrypted(e,t){let r={privateKey:null,publicKey:null};const s=n.createDecipher(yn,t),o=await i.readFile(e,"utf8");return r=s.update(o,"hex","utf8").includes("{")?gn.loadFromBufferString(o):gn.loadFromHex(o),r}static async load(e,t=!0){let n,r={privateKey:null,publicKey:null};return n=t?await i.readFile(e,"utf8"):e,r=n.includes("{")?gn.loadFromBufferString(n):gn.loadFromHex(n),r}static loadFromHex(e){let n={publicKey:null,privateKey:null};e=e.slice(2);let r=new Uint8Array(64);for(let t=0;t<e.length;t+=2){const n=e.substr(t,2),s=parseInt(n,16);r[t/2]=s}return n.privateKey=Buffer.from(r),n.publicKey=t.pki.ed25519.publicKeyFromPrivateKey({privateKey:n.privateKey}),n}static loadFromBufferString(e){let n={publicKey:null,privateKey:null};return n.privateKey=Buffer.from(JSON.parse(e)),n.publicKey=t.pki.ed25519.publicKeyFromPrivateKey({privateKey:n.privateKey}),n}static sign(e,n){return"string"==n.type&&(n=pn(n)),t.pki.ed25519.sign({message:e,encoding:"utf8",privateKey:n})}static verify(e,n,r){return"string"==n.type&&(n=pn(n)),"string"==r.type&&(r=pn(r)),"Buffer"==n.type&&(n=Buffer.from(n)),"Buffer"==r.type&&(r=Buffer.from(r)),t.pki.ed25519.verify({message:e,encoding:"utf8",signature:n,publicKey:r})}}gn.ed25519={sign:(e,n)=>("string"==n.type&&(n=pn(n)),t.pki.ed25519.sign({message:e,encoding:"utf8",privateKey:n})),verify:(e,n,r)=>("string"==n.type&&(n=pn(n)),"string"==r.type&&(r=pn(r)),"Buffer"==n.type&&(n=Buffer.from(n)),"Buffer"==r.type&&(r=Buffer.from(r)),t.pki.ed25519.verify({message:e,encoding:"utf8",signature:n,publicKey:r}))},gn.rsa={encrypt:(e,n)=>{"Buffer"==n.type&&(n=Buffer.from(n));let r=t.util.encode64(e);return[!0,n.encrypt(r)]},decrypt:(e,n=null)=>{try{"Buffer"==n.type&&(n=Buffer.from(n))}catch(e){}if(!n)return[!1,"No private key found"];let r=t.util.decode64(e);return[!0,n.decrypt(r).toString()]}};const wn=Uint8Array.from([0]),mn=Uint8Array.of();const bn=(e,t,n,r,s)=>function(e,t,n,r=32){D(e),H(r);const s=e.outputLen;if(r>255*s)throw new Error("Length should be <= 255*HashLen");const i=Math.ceil(r/s);void 0===n&&(n=mn);const o=new Uint8Array(i*s),a=hn.create(e,t),c=a._cloneInto(),h=new Uint8Array(a.outputLen);for(let e=0;e<i;e++)wn[0]=e+1,c.update(0===e?mn:h).update(n).update(wn).digestInto(h),o.set(h,s*e),a._cloneInto(c);return a.destroy(),c.destroy(),N(h,wn),o.slice(0,r)}(e,function(e,t,n){return D(e),hn(e,ee(n),ee(t))}(e,t,n),r,s);function _n(e){return"0x"+Array.from(e,e=>e.toString(16).padStart(2,"0")).join("")}class kn{constructor(e,t){this.enigma=new an,this.masterSeed=t,this.instanceId=e}static getInstance(e,t){const n=e||kn.DEFAULT_INSTANCE_ID;return kn.instances.has(n)?t&&!kn.instances.get(n).masterSeed&&(kn.instances.get(n).masterSeed=t):kn.instances.set(n,new kn(n,t)),kn.instances.get(n)}getId(){return this.instanceId}static getInstanceIds(){return Array.from(kn.instances.keys())}static removeInstance(e){return kn.instances.delete(e)}async ensureSeed(e){e||this.masterSeed?e&&(this.masterSeed=e):(e=ie(128),this.masterSeed=e),this.masterSeed.length}async deriveSeed(e,t){if(await this.ensureSeed(t),"ed25519"===e)return bn(nt,this.masterSeed,"master seed","ed25519",32);if("falcon"===e)return bn(nt,this.masterSeed,"master seed","falcon",48);if("ml-dsa"===e)return bn(nt,this.masterSeed,"master seed","ml-dsa",32);if("ml-kem-aes"===e)return bn(nt,this.masterSeed,"master seed","ml-kem-aes",64);if("rsa"===e)return bn(nt,this.masterSeed,"master seed","rsa",32);throw new Error("Invalid algorithm")}async generateAllIdentities(e){await this.generateIdentity("ed25519",e),await this.generateIdentity("falcon",e),await this.generateIdentity("ml-dsa",e),await this.generateIdentity("ml-kem-aes",e)}async generateIdentity(t,n){let r;if(r=n?await this.deriveSeed(t,n):await this.deriveSeed(t),"ed25519"===t)this.ed25519KeyPair=gn.newFromSeed(r);else if("falcon"===t)await this.enigma.generate_falcon_signing_keypair(r);else if("ml-dsa"===t)await this.enigma.generate_ml_dsa_signing_keypair(r);else if("ml-kem-aes"===t)await this.enigma.generate_ml_kem_encryption_keypair(r);else{if("rsa"!==t)throw new Error("Invalid algorithm");{var s=e.random.createInstance();const t=(new TextDecoder).decode(r);s.seedFileSync=()=>t,this.rsaKeyPair=await e.pki.rsa.generateKeyPair({bits:3072,prng:s,workers:2})}}}async getIdentity(e){if("falcon"===e)return this.enigma.falcon_signing_keypair;if("ml-dsa"===e)return this.enigma.ml_dsa_signing_keypair;if("ml-kem-aes"===e)return this.enigma.ml_kem_encryption_keypair;if("ed25519"===e)return{publicKey:this.ed25519KeyPair.publicKey,privateKey:this.ed25519KeyPair.privateKey};if("rsa"===e)return{publicKey:this.rsaKeyPair.publicKey,privateKey:this.rsaKeyPair.privateKey};throw new Error("Invalid algorithm")}async encrypt(e,t,n){let r={algorithm:e,encryptedData:new Uint8Array};if("ml-kem-aes"===e){const{cipherText:e,encryptedMessage:s}=await this.enigma.encrypt_ml_kem_aes(t,n);r.cipherText=e,r.encryptedData=s}else if("rsa"===e){if(!this.rsaKeyPair)throw new Error("RSA key pair not generated");const e=(new TextDecoder).decode(t);let n=this.rsaKeyPair.publicKey.encrypt(e);r.encryptedData=(new TextEncoder).encode(n)}return r}async sign(e,t){let n;if("ed25519"===e){if(!this.ed25519KeyPair)throw new Error("Ed25519 key pair not generated");n={algorithm:"ed25519",signature:gn.sign((new TextDecoder).decode(t),this.ed25519KeyPair.privateKey),message:t,publicKey:this.ed25519KeyPair.publicKey}}else if("ml-dsa"===e)n={algorithm:e,signature:await this.enigma.sign_ml_dsa(t),message:t,publicKey:this.enigma.ml_dsa_signing_keypair.publicKey};else if("falcon"===e){let r=(new TextDecoder).decode(t);n={algorithm:e,signature:await this.enigma.sign_falcon(r),message:t,publicKey:this.enigma.falcon_signing_keypair.publicKey}}return n}async decrypt(e){if("ml-kem-aes"===e.algorithm)return this.enigma.decrypt_ml_kem_aes(e.encryptedData,e.cipherText);if("rsa"===e.algorithm){const t=(new TextDecoder).decode(e.encryptedData);let n=this.rsaKeyPair.privateKey.decrypt(t);return(new TextEncoder).encode(n)}throw new Error("Invalid algorithm")}async verify(e){if("ml-dsa"===e.algorithm)return await an.verify_ml_dsa(e.signature,e.message,e.publicKey);if("falcon"===e.algorithm){const t=(new TextDecoder).decode(e.message);return await an.verify_falcon(e.signature,t,e.publicKey)}if("ed25519"===e.algorithm){const t=(new TextDecoder).decode(e.message);return gn.verify(t,e.signature,e.publicKey)}throw new Error("Invalid algorithm")}}kn.supportedPQCAlgorithms=["falcon","ml-dsa"],kn.instances=new Map,kn.DEFAULT_INSTANCE_ID="default",new Proxy({},{get(e,t){if(t in kn&&"function"==typeof kn[t])return kn[t].bind(kn);const n=kn.getInstance(),r=n[t];return"function"==typeof r?r.bind(n):r}});const xn={empty:function(){return structuredClone(f)},prepare:async function(e=null){const t=structuredClone(f);return e&&(t.content.data=e),t},async pay(e,t,n){He(n.keypair,"Wallet not connected");let r=xn.empty();const{publicKey:s}=await n.crypto.getIdentity("ed25519"),i=_n(s),o=await n.getAddressNonce(i);return r.content.to=e,r.content.nonce=o+1,r.content.amount=t,r.content.type="native",r.content.timestamp=Date.now(),r.content.data=["native",{nativeOperation:"send",args:[e,t]}],await n.sign(r)},transfer:(e,t,n)=>xn.pay(e,t,n),sign:async function(e,t,n){return He(t,"Private key not provided"),n&&n.algorithm||(n={algorithm:"ed25519"}),e.content.timestamp&&0!==e.content.timestamp||(e.content.timestamp=Date.now()),e.content.from=_n(t.publicKey),e.content.gcr_edits=await Le.generate(e),e.hash=await async function(e){const t=(new TextEncoder).encode(e),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,"0")).join("")}(JSON.stringify(e.content)),e.signature=await xn.signWithAlgorithm(e.hash,t,{algorithm:n.algorithm}),e},signWithAlgorithm:async function(e,t,n){if(He(t,"Private key not provided"),He(n&&n.algorithm,"Algorithm not provided"),"ed25519"===n.algorithm){return{type:"ed25519",data:_n(gn.sign(e,t.privateKey))}}const r=new an;if("falcon"===n.algorithm){return{type:"falcon",data:_n(await r.sign_falcon(e,t))}}if("ml-dsa"===n.algorithm){const n=(new TextEncoder).encode(e);return{type:"ml-dsa",data:_n(await r.sign_ml_dsa(n,t))}}throw new Error("Unsupported algorithm: "+n.algorithm)},confirm:async function(e,t){let n=await t.call("execute","",e,"confirmTx");if(!n.response.data.valid)throw new Error("[Confirm] Transaction is not valid: "+n.response.data.message);return n},broadcast:async function(e,t){if(!e.response.data.valid)throw new Error("[Broadcast] Transaction is not valid: "+e.response.data.message);const n=await t.call("execute","",e,"broadcastTx");try{return{...n,response:JSON.parse(n.response)}}catch(e){return n}},async store(e,t){He(t.keypair,"Wallet not connected");let n=xn.empty();const{publicKey:r}=await t.crypto.getIdentity("ed25519"),s=_n(r),i=await t.getAddressNonce(s),o=Buffer.from(e).toString("base64");return n.content.to=s,n.content.nonce=i+1,n.content.amount=0,n.content.type="storage",n.content.timestamp=Date.now(),n.content.data=["storage",{bytes:o}],await t.sign(n)},async createL2PSHashUpdate(e,t,n,r){He(r.keypair,"Wallet not connected"),He(e,"L2PS UID is required"),He(t,"Consolidated hash is required"),He(n>=0,"Transaction count must be non-negative");let s=xn.empty();const{publicKey:i}=await r.crypto.getIdentity("ed25519"),o=_n(i),a=await r.getAddressNonce(o);return s.content.to=o,s.content.nonce=a+1,s.content.amount=0,s.content.type="l2ps_hash_update",s.content.timestamp=Date.now(),s.content.data=["l2ps_hash_update",{l2ps_uid:e,consolidated_hash:t,transaction_count:n,timestamp:Date.now()}],await r.sign(s)}};function An(e,t){let n=new Set;switch(e.operationType){case"conditional":let t=function(e){let t=new Set;return e.conditions.forEach(e=>{const n=e=>{e&&e.type===a.internal&&e.workUID.startsWith("step_")&&t.add(e.workUID)};n(e.value_a),n(e.value_b),e.work&&e.work.startsWith("step_")&&t.add(e.work)}),t}(e);n=new Set([...n,...t]);break;case"base":let r=new Set(e.order.filter(e=>e.startsWith("step_")));n=new Set([...n,...r])}return function(e,t,n=""){let r=new Set(Array.from(e).filter(e=>!t.has(e)));if(r.size>0)throw new Error(`Steps ${[...r]} not included in final script - ${n}`)}(n,t,`${e.operationType} - ${e.id}`),n}function vn(e){let t=function(e){return new Map(Object.keys(e.steps).map(t=>[t,e.steps[t].description]))}(e),n=function(e,t){let n=new Set;return Object.keys(e.operations).forEach(r=>{let s=e.operations[r];n=new Set([...n,...An(s,t)])}),n}(e,t);for(const e of t.keys())if(!n.has(e))throw new Error(`Step ${t.get(e)||e} not used in script`)}function Kn(e){vn(e),function(e){const t=["step_","op_"],n=[],r=new Set([...Object.keys(e.operations),...Object.keys(e.steps)]);function s(e,s){const i=e.depends_on.find(e=>!t.some(t=>e.startsWith(t)));i&&n.push(`${s} ${e.description||e.id} depends on an invalid work UID: ${i}`),e.depends_on.forEach(t=>{r.has(t)||n.push(`${s} ${e.id} depends on a non-existent work UID: ${t}`)})}if(Object.entries(e.operations).forEach(([e,t])=>s({...t,id:e},"Operation")),Object.entries(e.steps).forEach(([e,t])=>s({...t,id:e},"Step")),n.length>0)throw new Error("Invalid dependencies found:\n"+n.join("\n"))}(e)}class En{constructor(){this.script={operationOrder:new Set,operations:{},steps:{}},this.results={}}push(e){this.script.operations[e.operationScript.id]=e.operationScript,this.script.operationOrder.add(e.operationScript.id);for(const t in e.steps)this.script.steps[t]=e.steps[t];for(const t of e.operations)this.script.operations[t.operationScript.id]=t.operationScript}validate(e){Kn(e)}fromJSON(e){return e.operationOrder=new Set(e.operationOrder),this.script=e,this}toJSON(){let e=this.script;e.operationOrder=[...e.operationOrder];for(const t in e.steps)delete e.steps[t].id;for(const t in e.operations)delete e.operations[t].id;return this.validate(e),e}}async function Sn(e,t){const n=e.toJSON();let r=xn.empty();return r.content.to=r.content.from,r.content.type="demoswork",r.content.data=["demoswork",n],r.content.timestamp=Date.now(),r=await t.sign(r),r}class Tn{constructor(e){this.timestamp=Date.now(),this.critical=!1,this.depends_on=[],this.content=e,this.id="step_"+o()}get output(){return new Proxy({type:a.work,src:{self:this,key:"output"}},{get:(e,t)=>({type:a.work,src:{self:this,key:`output.${String(t)}`}})})}get base_output(){return this.output}}class In extends Tn{constructor(e){super(e),this.context="web2"}}class Ln extends Tn{constructor(e){super(e),this.context="xm"}}class Un extends Tn{constructor(e){super(e),this.context="native"}}function Bn(e){return new Ln(e)}function Hn({method:e="GET",url:t="https://icanhazip.com",parameters:n=[],headers:r=null}){const s=structuredClone(p);return s.raw.action=c.CREATE,s.raw.method=e,s.raw.url=t,s.raw.parameters=n,s.raw.headers=r,s.hash="",s.signature={type:"ed25519",data:null},s.result="",new In(s)}function Cn(e){return new Un(e)}export{l as BaseOperation,u as Condition,d as ConditionalOperation,En as DemosWork,h as DemosWorkOperation,Un as NativeWorkStep,In as Web2WorkStep,Tn as WorkStep,Ln as XmWorkStep,Sn as prepareDemosWorkPayload,Cn as prepareNativeStep,Hn as prepareWeb2Step,Bn as prepareXMStep,Kn as runSanityChecks};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WorkStep } from "..";
|
|
2
2
|
import { DemosWorkOperation } from ".";
|
|
3
|
-
import { BaseOperationScript, OperationType } from "
|
|
3
|
+
import { BaseOperationScript, OperationType } from "@/types/demoswork/operations";
|
|
4
4
|
export declare class BaseOperation extends DemosWorkOperation {
|
|
5
5
|
type: OperationType;
|
|
6
6
|
operationScript: BaseOperationScript;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Operand } from "../../../types/demoswork/steps";
|
|
1
|
+
import { ICondition, operators, DataTypes } from "@/types";
|
|
2
|
+
import { DemosWorkOutputKey } from "@/types/demoswork";
|
|
3
|
+
import { Operand } from "@/types/demoswork/steps";
|
|
5
4
|
import { DemosWorkOperation } from "..";
|
|
6
|
-
import { BinaryConditionParams, UnaryConditionParams } from "
|
|
5
|
+
import { BinaryConditionParams, UnaryConditionParams } from "@/types/demoswork/operations";
|
|
6
|
+
import { WorkStep } from "@/demoswork/workstep";
|
|
7
7
|
export declare class Condition implements ICondition {
|
|
8
8
|
id: string;
|
|
9
9
|
action: WorkStep | DemosWorkOperation;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Condition, WorkStep } from "
|
|
2
|
-
import { OperationType, ConditionalOperationScript, operators, DataTypes } from "
|
|
3
|
-
import { DemosWorkOutputKey } from "
|
|
4
|
-
import { Operand } from "
|
|
1
|
+
import { Condition, WorkStep } from "@/demoswork";
|
|
2
|
+
import { OperationType, ConditionalOperationScript, operators, DataTypes } from "@/types";
|
|
3
|
+
import { DemosWorkOutputKey } from "@/types/demoswork";
|
|
4
|
+
import { Operand } from "@/types/demoswork/steps";
|
|
5
5
|
import { DemosWorkOperation } from "..";
|
|
6
6
|
export declare class ConditionalOperation extends DemosWorkOperation {
|
|
7
7
|
type: OperationType;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { OperationScript, OperationType } from "
|
|
1
|
+
import { OperationScript, OperationType } from "@/types/demoswork/operations";
|
|
2
2
|
import { WorkStep } from "../workstep";
|
|
3
|
-
import { DataTypes } from "
|
|
3
|
+
import { DataTypes } from "@/types/demoswork/datatypes";
|
|
4
4
|
export declare abstract class DemosWorkOperation {
|
|
5
5
|
id: string;
|
|
6
6
|
abstract type: OperationType;
|