@aptos-labs/ts-sdk 1.13.2 → 1.13.3-zeta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/index.d.ts +1781 -1347
- package/dist/common/index.js +26 -26
- package/dist/common/index.js.map +1 -1
- package/dist/esm/{Ed25519Account--qjfup2u.d.mts → Ed25519Account-8gJF5t3F.d.mts} +10 -12
- package/dist/esm/account/Account.d.mts +34 -0
- package/dist/esm/account/Account.mjs +2 -0
- package/dist/esm/account/Ed25519Account.d.mts +34 -0
- package/dist/esm/account/Ed25519Account.mjs +2 -0
- package/dist/esm/account/EphemeralKeyPair.d.mts +46 -0
- package/dist/esm/account/EphemeralKeyPair.mjs +2 -0
- package/dist/esm/account/KeylessAccount.d.mts +87 -0
- package/dist/esm/account/KeylessAccount.mjs +2 -0
- package/dist/esm/account/MultiKeyAccount.d.mts +99 -0
- package/dist/esm/account/MultiKeyAccount.mjs +2 -0
- package/dist/esm/account/SingleKeyAccount.d.mts +34 -0
- package/dist/esm/account/SingleKeyAccount.mjs +2 -0
- package/dist/esm/account/index.d.mts +39 -0
- package/dist/esm/account/index.mjs +2 -0
- package/dist/esm/api/account.d.mts +13 -1
- package/dist/esm/api/account.mjs +1 -1
- package/dist/esm/api/ans.d.mts +2 -2
- package/dist/esm/api/ans.mjs +1 -1
- package/dist/esm/api/aptos.d.mts +14 -8
- package/dist/esm/api/aptos.mjs +1 -1
- package/dist/esm/api/aptosConfig.d.mts +20 -0
- package/dist/esm/api/aptosConfig.mjs +1 -1
- package/dist/esm/api/coin.d.mts +7 -7
- package/dist/esm/api/coin.mjs +1 -1
- package/dist/esm/api/digitalAsset.d.mts +1 -1
- package/dist/esm/api/digitalAsset.mjs +1 -1
- package/dist/esm/api/event.mjs +1 -1
- package/dist/esm/api/faucet.mjs +1 -1
- package/dist/esm/api/fungibleAsset.d.mts +5 -5
- package/dist/esm/api/fungibleAsset.mjs +1 -1
- package/dist/esm/api/general.d.mts +7 -7
- package/dist/esm/api/general.mjs +1 -1
- package/dist/esm/api/index.d.mts +13 -8
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/keyless.d.mts +65 -0
- package/dist/esm/api/keyless.mjs +2 -0
- package/dist/esm/api/staking.mjs +1 -1
- package/dist/esm/api/transaction.d.mts +1 -1
- package/dist/esm/api/transaction.mjs +1 -1
- package/dist/esm/api/transactionSubmission/build.d.mts +3 -3
- package/dist/esm/api/transactionSubmission/build.mjs +1 -1
- package/dist/esm/api/transactionSubmission/management.d.mts +8 -8
- package/dist/esm/api/transactionSubmission/management.mjs +1 -1
- package/dist/esm/api/transactionSubmission/sign.d.mts +1 -1
- package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
- package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -1
- package/dist/esm/api/transactionSubmission/simulate.d.mts +6 -6
- package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
- package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
- package/dist/esm/api/utils.mjs +1 -1
- package/dist/esm/bcs/index.mjs +1 -1
- package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
- package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
- package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
- package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
- package/dist/esm/bcs/serializer.d.mts +2 -0
- package/dist/esm/bcs/serializer.mjs +1 -1
- package/dist/esm/{chunk-KDCHX7BI.mjs → chunk-274CXZ6R.mjs} +2 -2
- package/dist/esm/chunk-2M7KHFEG.mjs +2 -0
- package/dist/esm/chunk-2M7KHFEG.mjs.map +1 -0
- package/dist/esm/{chunk-TORRTLWV.mjs → chunk-2SD6JLIU.mjs} +2 -2
- package/dist/esm/chunk-2SD6JLIU.mjs.map +1 -0
- package/dist/esm/chunk-2YDIOWRJ.mjs +2 -0
- package/dist/esm/chunk-2YDIOWRJ.mjs.map +1 -0
- package/dist/esm/{chunk-4DNVCOW7.mjs → chunk-3CIA6J5L.mjs} +2 -2
- package/dist/esm/chunk-3CIA6J5L.mjs.map +1 -0
- package/dist/esm/{chunk-TBMAJ6AW.mjs → chunk-3FVRXELT.mjs} +2 -2
- package/dist/esm/{chunk-RQEWIZ67.mjs → chunk-3LQPAGL6.mjs} +2 -2
- package/dist/esm/{chunk-6IGEUEER.mjs → chunk-3PGVEOWR.mjs} +2 -2
- package/dist/esm/{chunk-DMKUAQB7.mjs → chunk-3VGX3TXH.mjs} +2 -2
- package/dist/esm/chunk-4NMDYPUD.mjs +1 -0
- package/dist/esm/chunk-4NMDYPUD.mjs.map +1 -0
- package/dist/esm/chunk-5VSMDXZ6.mjs +2 -0
- package/dist/esm/chunk-5VSMDXZ6.mjs.map +1 -0
- package/dist/esm/chunk-6GQAHQGW.mjs +2 -0
- package/dist/esm/chunk-6GQAHQGW.mjs.map +1 -0
- package/dist/esm/chunk-6NMHAFIO.mjs +2 -0
- package/dist/esm/chunk-6NMHAFIO.mjs.map +1 -0
- package/dist/esm/{chunk-YKVKSNH4.mjs → chunk-6NZNCDDW.mjs} +2 -2
- package/dist/esm/{chunk-QIAHBEEW.mjs → chunk-6RBUXB5I.mjs} +2 -2
- package/dist/esm/{chunk-3HV2C4SS.mjs → chunk-7FNHL6LU.mjs} +2 -2
- package/dist/esm/{chunk-FXNFWLQC.mjs → chunk-7H3HRFVM.mjs} +2 -2
- package/dist/esm/chunk-7MPJPZ73.mjs +2 -0
- package/dist/esm/chunk-7MPJPZ73.mjs.map +1 -0
- package/dist/esm/{chunk-NPFNYP75.mjs → chunk-7STYQ5ZE.mjs} +2 -2
- package/dist/esm/chunk-7XHVF3ZX.mjs +2 -0
- package/dist/esm/{chunk-MNBYKY5P.mjs.map → chunk-7XHVF3ZX.mjs.map} +1 -1
- package/dist/esm/chunk-7Z6DYLCA.mjs +1 -0
- package/dist/esm/chunk-7Z6DYLCA.mjs.map +1 -0
- package/dist/esm/{chunk-UMFJDDYI.mjs → chunk-AKGASNN4.mjs} +2 -2
- package/dist/esm/chunk-AKGASNN4.mjs.map +1 -0
- package/dist/esm/{chunk-QWRH22H4.mjs → chunk-APEBWN6Q.mjs} +2 -2
- package/dist/esm/chunk-AQ4I7VVB.mjs +1 -0
- package/dist/esm/chunk-AQ4I7VVB.mjs.map +1 -0
- package/dist/esm/{chunk-ZYYK3UXP.mjs → chunk-C3L4ETUF.mjs} +2 -2
- package/dist/esm/{chunk-3RUY5FQK.mjs → chunk-CN37OHFT.mjs} +2 -2
- package/dist/esm/chunk-CN37OHFT.mjs.map +1 -0
- package/dist/esm/{chunk-WFZDFFBM.mjs → chunk-COW5IGYC.mjs} +2 -2
- package/dist/esm/chunk-CQJ4WN7M.mjs +2 -0
- package/dist/esm/chunk-CQJ4WN7M.mjs.map +1 -0
- package/dist/esm/{chunk-PIOHC246.mjs → chunk-DKLA4F3P.mjs} +2 -2
- package/dist/esm/chunk-DKLA4F3P.mjs.map +1 -0
- package/dist/esm/{chunk-TC3VVMPY.mjs → chunk-E36GTDEB.mjs} +2 -2
- package/dist/esm/chunk-E4Z5IEZP.mjs +2 -0
- package/dist/esm/chunk-E4Z5IEZP.mjs.map +1 -0
- package/dist/esm/{chunk-FS3NSGBF.mjs → chunk-EB7AI4B4.mjs} +2 -2
- package/dist/esm/chunk-EQKI6NJR.mjs +2 -0
- package/dist/esm/chunk-EQKI6NJR.mjs.map +1 -0
- package/dist/esm/chunk-F6QCHPVS.mjs +2 -0
- package/dist/esm/chunk-F6QCHPVS.mjs.map +1 -0
- package/dist/esm/chunk-FLYEALDB.mjs +2 -0
- package/dist/esm/chunk-FLYEALDB.mjs.map +1 -0
- package/dist/esm/{chunk-GRT5PHL6.mjs → chunk-H3LMPXEM.mjs} +2 -2
- package/dist/esm/{chunk-YBEF3UR3.mjs → chunk-H6BRBIMG.mjs} +2 -2
- package/dist/esm/{chunk-2PFN7LYP.mjs → chunk-HFLWASAB.mjs} +2 -2
- package/dist/esm/{chunk-UML2VQZT.mjs → chunk-HGZGTBA4.mjs} +2 -2
- package/dist/esm/chunk-HQWIGPYQ.mjs +2 -0
- package/dist/esm/chunk-HQWIGPYQ.mjs.map +1 -0
- package/dist/esm/chunk-HURQZGUZ.mjs +2 -0
- package/dist/esm/chunk-HURQZGUZ.mjs.map +1 -0
- package/dist/esm/{chunk-TGXZVNR5.mjs → chunk-IEZO4PIG.mjs} +2 -2
- package/dist/esm/{chunk-PJLCPRYJ.mjs → chunk-J2IIPYZG.mjs} +2 -2
- package/dist/esm/chunk-JEUAQVXW.mjs +2 -0
- package/dist/esm/chunk-JEUAQVXW.mjs.map +1 -0
- package/dist/esm/chunk-JOYJUVSE.mjs +2 -0
- package/dist/esm/chunk-JOYJUVSE.mjs.map +1 -0
- package/dist/esm/chunk-JXCZTOYC.mjs +1 -0
- package/dist/esm/chunk-JXCZTOYC.mjs.map +1 -0
- package/dist/esm/{chunk-TGG7SWBO.mjs → chunk-KCVBUZ6L.mjs} +2 -2
- package/dist/esm/chunk-KCVBUZ6L.mjs.map +1 -0
- package/dist/esm/{chunk-EJCKCYYI.mjs → chunk-KNHI66FK.mjs} +2 -2
- package/dist/esm/{chunk-4LMAVPA4.mjs → chunk-LDMEIVL6.mjs} +2 -2
- package/dist/esm/chunk-LX7N4NUS.mjs +2 -0
- package/dist/esm/chunk-LX7N4NUS.mjs.map +1 -0
- package/dist/esm/{chunk-DSTKXJMA.mjs → chunk-MGOHPDX4.mjs} +2 -2
- package/dist/esm/{chunk-UPIN5AIO.mjs → chunk-MKUAW7KW.mjs} +2 -2
- package/dist/esm/{chunk-BWFJHFBQ.mjs → chunk-MWUJCP27.mjs} +2 -2
- package/dist/esm/{chunk-LV2V23Z6.mjs → chunk-N4B6S6FK.mjs} +2 -2
- package/dist/esm/chunk-N4B6S6FK.mjs.map +1 -0
- package/dist/esm/{chunk-QTRYMRYK.mjs → chunk-NC5HHEEM.mjs} +2 -2
- package/dist/esm/chunk-NMVZP3Q2.mjs +2 -0
- package/dist/esm/chunk-NMVZP3Q2.mjs.map +1 -0
- package/dist/esm/chunk-NNA5VEB2.mjs +2 -0
- package/dist/esm/chunk-NNA5VEB2.mjs.map +1 -0
- package/dist/esm/chunk-OKRUEVF3.mjs +2 -0
- package/dist/esm/chunk-OKRUEVF3.mjs.map +1 -0
- package/dist/esm/{chunk-U43IJHQN.mjs → chunk-PFFAQZHT.mjs} +2 -2
- package/dist/esm/chunk-PLPCOELE.mjs +2 -0
- package/dist/esm/chunk-PLPCOELE.mjs.map +1 -0
- package/dist/esm/{chunk-BRQYARQ3.mjs → chunk-Q7TGZJT4.mjs} +2 -2
- package/dist/esm/chunk-QHIQLTBS.mjs +2 -0
- package/dist/esm/chunk-QHIQLTBS.mjs.map +1 -0
- package/dist/esm/{chunk-6MG4JAYB.mjs → chunk-QMIEBNTP.mjs} +2 -2
- package/dist/esm/{chunk-3QBZU5ZD.mjs → chunk-QXVGXZJX.mjs} +2 -2
- package/dist/esm/chunk-QXVGXZJX.mjs.map +1 -0
- package/dist/esm/{chunk-GS5J57UA.mjs → chunk-R6PFLI3Z.mjs} +2 -2
- package/dist/esm/chunk-R6PFLI3Z.mjs.map +1 -0
- package/dist/esm/chunk-RFSO3JRG.mjs +1 -0
- package/dist/esm/chunk-RFSO3JRG.mjs.map +1 -0
- package/dist/esm/chunk-RPXN7HGR.mjs +2 -0
- package/dist/esm/chunk-RPXN7HGR.mjs.map +1 -0
- package/dist/esm/chunk-S5HG2QUD.mjs +2 -0
- package/dist/esm/chunk-S5HG2QUD.mjs.map +1 -0
- package/dist/esm/{chunk-BBU2EE6D.mjs → chunk-SNQJV7MF.mjs} +2 -2
- package/dist/esm/chunk-SRLCFTZR.mjs +2 -0
- package/dist/esm/chunk-SRLCFTZR.mjs.map +1 -0
- package/dist/esm/{chunk-R5QUBEH6.mjs → chunk-STYDBDYL.mjs} +2 -2
- package/dist/esm/{chunk-IOSQVDZI.mjs → chunk-T23OVRNF.mjs} +2 -2
- package/dist/esm/{chunk-GXYS45Y5.mjs → chunk-T3W5USZC.mjs} +2 -2
- package/dist/esm/chunk-TBG3MIIE.mjs +2 -0
- package/dist/esm/chunk-TBG3MIIE.mjs.map +1 -0
- package/dist/esm/{chunk-XLPVG4XR.mjs → chunk-TE7AJKSU.mjs} +2 -2
- package/dist/esm/chunk-TJPWYYNO.mjs +2 -0
- package/dist/esm/chunk-TJPWYYNO.mjs.map +1 -0
- package/dist/esm/{chunk-52C73T26.mjs → chunk-TVRJ3M7B.mjs} +2 -2
- package/dist/esm/{chunk-52C73T26.mjs.map → chunk-TVRJ3M7B.mjs.map} +1 -1
- package/dist/esm/{chunk-A556OVZY.mjs → chunk-U72H6EST.mjs} +2 -2
- package/dist/esm/{chunk-BAV4XY7C.mjs → chunk-W637YAND.mjs} +2 -2
- package/dist/esm/chunk-W76IQV5K.mjs +2 -0
- package/dist/esm/chunk-W76IQV5K.mjs.map +1 -0
- package/dist/esm/chunk-WO2KROQ6.mjs +2 -0
- package/dist/esm/{chunk-B252RJCU.mjs.map → chunk-WO2KROQ6.mjs.map} +1 -1
- package/dist/esm/chunk-X56CTMYB.mjs +2 -0
- package/dist/esm/chunk-XEXWFQNP.mjs +2 -0
- package/dist/esm/chunk-YE5B2S5L.mjs +2 -0
- package/dist/esm/chunk-YE5B2S5L.mjs.map +1 -0
- package/dist/esm/chunk-YGHLXEB4.mjs +2 -0
- package/dist/esm/{chunk-IZT6OX3R.mjs.map → chunk-YGHLXEB4.mjs.map} +1 -1
- package/dist/esm/{chunk-OGHE4AQA.mjs → chunk-Z2ZR4PTF.mjs} +2 -2
- package/dist/esm/{chunk-RHBCVCOS.mjs → chunk-ZNEBMSNC.mjs} +2 -2
- package/dist/esm/client/core.mjs +1 -1
- package/dist/esm/client/get.d.mts +2 -1
- package/dist/esm/client/get.mjs +1 -1
- package/dist/esm/client/index.d.mts +2 -2
- package/dist/esm/client/index.mjs +1 -1
- package/dist/esm/client/post.d.mts +3 -1
- package/dist/esm/client/post.mjs +1 -1
- package/dist/esm/core/account/index.d.mts +5 -14
- package/dist/esm/core/account/index.mjs +1 -1
- package/dist/esm/core/account/utils/address.mjs +1 -1
- package/dist/esm/core/account/utils/index.mjs +1 -1
- package/dist/esm/core/accountAddress.mjs +1 -1
- package/dist/esm/core/authenticationKey.mjs +1 -1
- package/dist/esm/core/crypto/ed25519.d.mts +0 -10
- package/dist/esm/core/crypto/ed25519.mjs +1 -1
- package/dist/esm/core/crypto/ephemeral.d.mts +77 -0
- package/dist/esm/core/crypto/ephemeral.mjs +2 -0
- package/dist/esm/core/crypto/ephemeral.mjs.map +1 -0
- package/dist/esm/core/crypto/hdKey.d.mts +15 -1
- package/dist/esm/core/crypto/hdKey.mjs +1 -1
- package/dist/esm/core/crypto/index.d.mts +7 -5
- package/dist/esm/core/crypto/index.mjs +1 -1
- package/dist/esm/core/crypto/keyless.d.mts +217 -0
- package/dist/esm/core/crypto/keyless.mjs +2 -0
- package/dist/esm/core/crypto/keyless.mjs.map +1 -0
- package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
- package/dist/esm/core/crypto/multiKey.d.mts +4 -3
- package/dist/esm/core/crypto/multiKey.mjs +1 -1
- package/dist/esm/core/crypto/poseidon.d.mts +7 -0
- package/dist/esm/core/crypto/poseidon.mjs +2 -0
- package/dist/esm/core/crypto/poseidon.mjs.map +1 -0
- package/dist/esm/core/crypto/publicKey.mjs +1 -1
- package/dist/esm/core/crypto/secp256k1.mjs +1 -1
- package/dist/esm/core/crypto/signature.mjs +1 -1
- package/dist/esm/core/crypto/singleKey.mjs +1 -1
- package/dist/esm/core/index.d.mts +6 -7
- package/dist/esm/core/index.mjs +1 -1
- package/dist/esm/index.d.mts +16 -10
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internal/account.d.mts +14 -2
- package/dist/esm/internal/account.mjs +1 -1
- package/dist/esm/internal/ans.d.mts +1 -1
- package/dist/esm/internal/ans.mjs +1 -1
- package/dist/esm/internal/coin.d.mts +7 -7
- package/dist/esm/internal/coin.mjs +1 -1
- package/dist/esm/internal/digitalAsset.d.mts +2 -2
- package/dist/esm/internal/digitalAsset.mjs +1 -1
- package/dist/esm/internal/event.d.mts +1 -1
- package/dist/esm/internal/event.mjs +1 -1
- package/dist/esm/internal/faucet.d.mts +1 -1
- package/dist/esm/internal/faucet.mjs +1 -1
- package/dist/esm/internal/fungibleAsset.d.mts +5 -5
- package/dist/esm/internal/fungibleAsset.mjs +1 -1
- package/dist/esm/internal/general.mjs +1 -1
- package/dist/esm/internal/keyless.d.mts +65 -0
- package/dist/esm/internal/keyless.mjs +2 -0
- package/dist/esm/internal/keyless.mjs.map +1 -0
- package/dist/esm/internal/staking.d.mts +1 -1
- package/dist/esm/internal/staking.mjs +1 -1
- package/dist/esm/internal/transaction.mjs +1 -1
- package/dist/esm/internal/transactionSubmission.d.mts +1 -1
- package/dist/esm/internal/transactionSubmission.mjs +1 -1
- package/dist/esm/internal/view.d.mts +7 -7
- package/dist/esm/internal/view.mjs +1 -1
- package/dist/esm/transactions/authenticator/account.d.mts +3 -4
- package/dist/esm/transactions/authenticator/account.mjs +1 -1
- package/dist/esm/transactions/authenticator/index.mjs +1 -1
- package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
- package/dist/esm/transactions/index.d.mts +3 -3
- package/dist/esm/transactions/index.mjs +1 -1
- package/dist/esm/transactions/instances/chainId.mjs +1 -1
- package/dist/esm/transactions/instances/identifier.mjs +1 -1
- package/dist/esm/transactions/instances/index.d.mts +1 -0
- package/dist/esm/transactions/instances/index.mjs +1 -1
- package/dist/esm/transactions/instances/moduleId.d.mts +1 -1
- package/dist/esm/transactions/instances/moduleId.mjs +1 -1
- package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
- package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/transactionPayload.d.mts +1 -1
- package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
- package/dist/esm/transactions/management/accountSequenceNumber.d.mts +13 -1
- package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
- package/dist/esm/transactions/management/index.d.mts +2 -2
- package/dist/esm/transactions/management/index.mjs +1 -1
- package/dist/esm/transactions/management/transactionWorker.d.mts +1 -1
- package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/helpers.d.mts +9 -9
- package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/index.d.mts +9 -9
- package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +6 -6
- package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/signingMessage.d.mts +47 -0
- package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +2 -0
- package/dist/esm/transactions/transactionBuilder/signingMessage.mjs.map +1 -0
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +13 -25
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
- package/dist/esm/transactions/typeTag/index.mjs +1 -1
- package/dist/esm/transactions/typeTag/parser.mjs +1 -1
- package/dist/esm/transactions/types.d.mts +7 -7
- package/dist/esm/types/index.d.mts +17 -3
- package/dist/esm/types/index.mjs +1 -1
- package/dist/esm/types/keyless.d.mts +14 -0
- package/dist/esm/types/keyless.mjs +1 -0
- package/dist/esm/types/keyless.mjs.map +1 -0
- package/dist/esm/utils/apiEndpoints.d.mts +3 -1
- package/dist/esm/utils/apiEndpoints.mjs +1 -1
- package/dist/esm/utils/const.d.mts +3 -1
- package/dist/esm/utils/const.mjs +1 -1
- package/dist/esm/utils/index.d.mts +1 -1
- package/dist/esm/utils/index.mjs +1 -1
- package/dist/esm/utils/normalizeBundle.mjs +1 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +7 -2
- package/src/{core/account → account}/Account.ts +12 -16
- package/src/{core/account → account}/Ed25519Account.ts +13 -7
- package/src/account/EphemeralKeyPair.ts +115 -0
- package/src/account/KeylessAccount.ts +240 -0
- package/src/account/MultiKeyAccount.ts +119 -0
- package/src/{core/account → account}/SingleKeyAccount.ts +13 -8
- package/src/account/index.ts +6 -0
- package/src/api/account.ts +2 -1
- package/src/api/ans.ts +2 -1
- package/src/api/aptos.ts +6 -0
- package/src/api/aptosConfig.ts +46 -1
- package/src/api/digitalAsset.ts +2 -1
- package/src/api/fungibleAsset.ts +2 -1
- package/src/api/keyless.ts +34 -0
- package/src/api/transaction.ts +2 -1
- package/src/api/transactionSubmission/management.ts +1 -1
- package/src/api/transactionSubmission/sign.ts +1 -1
- package/src/bcs/serializer.ts +18 -0
- package/src/client/core.ts +8 -0
- package/src/client/get.ts +6 -0
- package/src/client/post.ts +12 -0
- package/src/core/account/index.ts +1 -3
- package/src/core/crypto/ed25519.ts +4 -24
- package/src/core/crypto/ephemeral.ts +149 -0
- package/src/core/crypto/hdKey.ts +31 -0
- package/src/core/crypto/index.ts +2 -0
- package/src/core/crypto/keyless.ts +508 -0
- package/src/core/crypto/multiKey.ts +21 -11
- package/src/core/crypto/poseidon.ts +134 -0
- package/src/core/crypto/singleKey.ts +11 -0
- package/src/core/index.ts +0 -1
- package/src/index.ts +1 -0
- package/src/internal/account.ts +1 -1
- package/src/internal/ans.ts +2 -1
- package/src/internal/digitalAsset.ts +2 -1
- package/src/internal/fungibleAsset.ts +2 -1
- package/src/internal/keyless.ts +185 -0
- package/src/internal/transactionSubmission.ts +8 -7
- package/src/transactions/authenticator/account.ts +6 -11
- package/src/transactions/instances/index.ts +1 -0
- package/src/transactions/management/accountSequenceNumber.ts +1 -1
- package/src/transactions/management/transactionWorker.ts +8 -2
- package/src/transactions/transactionBuilder/index.ts +1 -0
- package/src/transactions/transactionBuilder/signingMessage.ts +70 -0
- package/src/transactions/transactionBuilder/transactionBuilder.ts +41 -70
- package/src/types/index.ts +19 -0
- package/src/types/keyless.ts +6 -0
- package/src/utils/apiEndpoints.ts +14 -0
- package/src/utils/const.ts +2 -0
- package/src/version.ts +1 -1
- package/dist/esm/chunk-3426VLAZ.mjs +0 -2
- package/dist/esm/chunk-3426VLAZ.mjs.map +0 -1
- package/dist/esm/chunk-3OCTOB2E.mjs +0 -2
- package/dist/esm/chunk-3OCTOB2E.mjs.map +0 -1
- package/dist/esm/chunk-3QBZU5ZD.mjs.map +0 -1
- package/dist/esm/chunk-3RUY5FQK.mjs.map +0 -1
- package/dist/esm/chunk-4DNVCOW7.mjs.map +0 -1
- package/dist/esm/chunk-5HALZ6JC.mjs +0 -2
- package/dist/esm/chunk-5HALZ6JC.mjs.map +0 -1
- package/dist/esm/chunk-5OM4V4DR.mjs +0 -2
- package/dist/esm/chunk-5TMLAKSH.mjs +0 -2
- package/dist/esm/chunk-5TMLAKSH.mjs.map +0 -1
- package/dist/esm/chunk-B252RJCU.mjs +0 -2
- package/dist/esm/chunk-CYNQRMO5.mjs +0 -2
- package/dist/esm/chunk-CYNQRMO5.mjs.map +0 -1
- package/dist/esm/chunk-E7FWVXGX.mjs +0 -1
- package/dist/esm/chunk-FO6ZKE7A.mjs +0 -2
- package/dist/esm/chunk-FO6ZKE7A.mjs.map +0 -1
- package/dist/esm/chunk-GMQQSSEO.mjs +0 -2
- package/dist/esm/chunk-GMQQSSEO.mjs.map +0 -1
- package/dist/esm/chunk-GNQXMS53.mjs +0 -2
- package/dist/esm/chunk-GNQXMS53.mjs.map +0 -1
- package/dist/esm/chunk-GS5J57UA.mjs.map +0 -1
- package/dist/esm/chunk-HLVMEUWD.mjs +0 -2
- package/dist/esm/chunk-HLVMEUWD.mjs.map +0 -1
- package/dist/esm/chunk-HQSLBTW5.mjs +0 -2
- package/dist/esm/chunk-HQSLBTW5.mjs.map +0 -1
- package/dist/esm/chunk-ICXA3DZH.mjs +0 -1
- package/dist/esm/chunk-IZT6OX3R.mjs +0 -2
- package/dist/esm/chunk-KHOHRD2B.mjs +0 -2
- package/dist/esm/chunk-KHOHRD2B.mjs.map +0 -1
- package/dist/esm/chunk-L6PGWGFF.mjs +0 -2
- package/dist/esm/chunk-LR65XHSF.mjs +0 -2
- package/dist/esm/chunk-LR65XHSF.mjs.map +0 -1
- package/dist/esm/chunk-LV2V23Z6.mjs.map +0 -1
- package/dist/esm/chunk-MLWIHWNH.mjs +0 -1
- package/dist/esm/chunk-MNBYKY5P.mjs +0 -2
- package/dist/esm/chunk-OVJQWQ2N.mjs +0 -2
- package/dist/esm/chunk-OVJQWQ2N.mjs.map +0 -1
- package/dist/esm/chunk-OWW6SIDP.mjs +0 -2
- package/dist/esm/chunk-OWW6SIDP.mjs.map +0 -1
- package/dist/esm/chunk-PIOHC246.mjs.map +0 -1
- package/dist/esm/chunk-R7G3CLRI.mjs +0 -1
- package/dist/esm/chunk-TGG7SWBO.mjs.map +0 -1
- package/dist/esm/chunk-TORRTLWV.mjs.map +0 -1
- package/dist/esm/chunk-TQR7M73S.mjs +0 -2
- package/dist/esm/chunk-TQR7M73S.mjs.map +0 -1
- package/dist/esm/chunk-UMFJDDYI.mjs.map +0 -1
- package/dist/esm/chunk-UVSRX4SV.mjs +0 -1
- package/dist/esm/chunk-VNO4VHJN.mjs +0 -2
- package/dist/esm/chunk-VNO4VHJN.mjs.map +0 -1
- package/dist/esm/chunk-WBOLHLPX.mjs +0 -2
- package/dist/esm/chunk-WBOLHLPX.mjs.map +0 -1
- package/dist/esm/chunk-XDGQTMDV.mjs +0 -2
- package/dist/esm/chunk-XDGQTMDV.mjs.map +0 -1
- package/dist/esm/chunk-YVSU6GOA.mjs +0 -2
- package/dist/esm/chunk-YVSU6GOA.mjs.map +0 -1
- package/dist/esm/core/account/Account.d.mts +0 -20
- package/dist/esm/core/account/Account.mjs +0 -2
- package/dist/esm/core/account/Ed25519Account.d.mts +0 -20
- package/dist/esm/core/account/Ed25519Account.mjs +0 -2
- package/dist/esm/core/account/SingleKeyAccount.d.mts +0 -20
- package/dist/esm/core/account/SingleKeyAccount.mjs +0 -2
- /package/dist/esm/{core/account → account}/Account.mjs.map +0 -0
- /package/dist/esm/{core/account → account}/Ed25519Account.mjs.map +0 -0
- /package/dist/esm/{chunk-E7FWVXGX.mjs.map → account/EphemeralKeyPair.mjs.map} +0 -0
- /package/dist/esm/{chunk-ICXA3DZH.mjs.map → account/KeylessAccount.mjs.map} +0 -0
- /package/dist/esm/{chunk-MLWIHWNH.mjs.map → account/MultiKeyAccount.mjs.map} +0 -0
- /package/dist/esm/{core/account → account}/SingleKeyAccount.mjs.map +0 -0
- /package/dist/esm/{chunk-R7G3CLRI.mjs.map → account/index.mjs.map} +0 -0
- /package/dist/esm/{chunk-UVSRX4SV.mjs.map → api/keyless.mjs.map} +0 -0
- /package/dist/esm/{chunk-KDCHX7BI.mjs.map → chunk-274CXZ6R.mjs.map} +0 -0
- /package/dist/esm/{chunk-TBMAJ6AW.mjs.map → chunk-3FVRXELT.mjs.map} +0 -0
- /package/dist/esm/{chunk-RQEWIZ67.mjs.map → chunk-3LQPAGL6.mjs.map} +0 -0
- /package/dist/esm/{chunk-6IGEUEER.mjs.map → chunk-3PGVEOWR.mjs.map} +0 -0
- /package/dist/esm/{chunk-DMKUAQB7.mjs.map → chunk-3VGX3TXH.mjs.map} +0 -0
- /package/dist/esm/{chunk-YKVKSNH4.mjs.map → chunk-6NZNCDDW.mjs.map} +0 -0
- /package/dist/esm/{chunk-QIAHBEEW.mjs.map → chunk-6RBUXB5I.mjs.map} +0 -0
- /package/dist/esm/{chunk-3HV2C4SS.mjs.map → chunk-7FNHL6LU.mjs.map} +0 -0
- /package/dist/esm/{chunk-FXNFWLQC.mjs.map → chunk-7H3HRFVM.mjs.map} +0 -0
- /package/dist/esm/{chunk-NPFNYP75.mjs.map → chunk-7STYQ5ZE.mjs.map} +0 -0
- /package/dist/esm/{chunk-QWRH22H4.mjs.map → chunk-APEBWN6Q.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZYYK3UXP.mjs.map → chunk-C3L4ETUF.mjs.map} +0 -0
- /package/dist/esm/{chunk-WFZDFFBM.mjs.map → chunk-COW5IGYC.mjs.map} +0 -0
- /package/dist/esm/{chunk-TC3VVMPY.mjs.map → chunk-E36GTDEB.mjs.map} +0 -0
- /package/dist/esm/{chunk-FS3NSGBF.mjs.map → chunk-EB7AI4B4.mjs.map} +0 -0
- /package/dist/esm/{chunk-GRT5PHL6.mjs.map → chunk-H3LMPXEM.mjs.map} +0 -0
- /package/dist/esm/{chunk-YBEF3UR3.mjs.map → chunk-H6BRBIMG.mjs.map} +0 -0
- /package/dist/esm/{chunk-2PFN7LYP.mjs.map → chunk-HFLWASAB.mjs.map} +0 -0
- /package/dist/esm/{chunk-UML2VQZT.mjs.map → chunk-HGZGTBA4.mjs.map} +0 -0
- /package/dist/esm/{chunk-TGXZVNR5.mjs.map → chunk-IEZO4PIG.mjs.map} +0 -0
- /package/dist/esm/{chunk-PJLCPRYJ.mjs.map → chunk-J2IIPYZG.mjs.map} +0 -0
- /package/dist/esm/{chunk-EJCKCYYI.mjs.map → chunk-KNHI66FK.mjs.map} +0 -0
- /package/dist/esm/{chunk-4LMAVPA4.mjs.map → chunk-LDMEIVL6.mjs.map} +0 -0
- /package/dist/esm/{chunk-DSTKXJMA.mjs.map → chunk-MGOHPDX4.mjs.map} +0 -0
- /package/dist/esm/{chunk-UPIN5AIO.mjs.map → chunk-MKUAW7KW.mjs.map} +0 -0
- /package/dist/esm/{chunk-BWFJHFBQ.mjs.map → chunk-MWUJCP27.mjs.map} +0 -0
- /package/dist/esm/{chunk-QTRYMRYK.mjs.map → chunk-NC5HHEEM.mjs.map} +0 -0
- /package/dist/esm/{chunk-U43IJHQN.mjs.map → chunk-PFFAQZHT.mjs.map} +0 -0
- /package/dist/esm/{chunk-BRQYARQ3.mjs.map → chunk-Q7TGZJT4.mjs.map} +0 -0
- /package/dist/esm/{chunk-6MG4JAYB.mjs.map → chunk-QMIEBNTP.mjs.map} +0 -0
- /package/dist/esm/{chunk-BBU2EE6D.mjs.map → chunk-SNQJV7MF.mjs.map} +0 -0
- /package/dist/esm/{chunk-R5QUBEH6.mjs.map → chunk-STYDBDYL.mjs.map} +0 -0
- /package/dist/esm/{chunk-IOSQVDZI.mjs.map → chunk-T23OVRNF.mjs.map} +0 -0
- /package/dist/esm/{chunk-GXYS45Y5.mjs.map → chunk-T3W5USZC.mjs.map} +0 -0
- /package/dist/esm/{chunk-XLPVG4XR.mjs.map → chunk-TE7AJKSU.mjs.map} +0 -0
- /package/dist/esm/{chunk-A556OVZY.mjs.map → chunk-U72H6EST.mjs.map} +0 -0
- /package/dist/esm/{chunk-BAV4XY7C.mjs.map → chunk-W637YAND.mjs.map} +0 -0
- /package/dist/esm/{chunk-5OM4V4DR.mjs.map → chunk-X56CTMYB.mjs.map} +0 -0
- /package/dist/esm/{chunk-L6PGWGFF.mjs.map → chunk-XEXWFQNP.mjs.map} +0 -0
- /package/dist/esm/{chunk-OGHE4AQA.mjs.map → chunk-Z2ZR4PTF.mjs.map} +0 -0
- /package/dist/esm/{chunk-RHBCVCOS.mjs.map → chunk-ZNEBMSNC.mjs.map} +0 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/* eslint-disable no-bitwise */
|
|
2
|
+
import {
|
|
3
|
+
poseidon1,
|
|
4
|
+
poseidon2,
|
|
5
|
+
poseidon3,
|
|
6
|
+
poseidon4,
|
|
7
|
+
poseidon5,
|
|
8
|
+
poseidon6,
|
|
9
|
+
poseidon7,
|
|
10
|
+
poseidon8,
|
|
11
|
+
poseidon9,
|
|
12
|
+
poseidon10,
|
|
13
|
+
poseidon11,
|
|
14
|
+
poseidon12,
|
|
15
|
+
poseidon13,
|
|
16
|
+
poseidon14,
|
|
17
|
+
poseidon15,
|
|
18
|
+
poseidon16,
|
|
19
|
+
} from "poseidon-lite";
|
|
20
|
+
|
|
21
|
+
const numInputsToPoseidonFunc = [
|
|
22
|
+
poseidon1,
|
|
23
|
+
poseidon2,
|
|
24
|
+
poseidon3,
|
|
25
|
+
poseidon4,
|
|
26
|
+
poseidon5,
|
|
27
|
+
poseidon6,
|
|
28
|
+
poseidon7,
|
|
29
|
+
poseidon8,
|
|
30
|
+
poseidon9,
|
|
31
|
+
poseidon10,
|
|
32
|
+
poseidon11,
|
|
33
|
+
poseidon12,
|
|
34
|
+
poseidon13,
|
|
35
|
+
poseidon14,
|
|
36
|
+
poseidon15,
|
|
37
|
+
poseidon16,
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
const BYTES_PACKED_PER_SCALAR = 31;
|
|
41
|
+
const MAX_NUM_INPUT_SCALARS = 16;
|
|
42
|
+
const MAX_NUM_INPUT_BYTES = (MAX_NUM_INPUT_SCALARS - 1) * BYTES_PACKED_PER_SCALAR;
|
|
43
|
+
|
|
44
|
+
// hashes an ASCII string to a field element
|
|
45
|
+
export function hashASCIIStrToField(str: string, maxSizeBytes: number) {
|
|
46
|
+
const textEncoder = new TextEncoder();
|
|
47
|
+
const strBytes = textEncoder.encode(str);
|
|
48
|
+
return hashBytesWithLen(strBytes, maxSizeBytes);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function hashBytesWithLen(bytes: Uint8Array, maxSizeBytes: number) {
|
|
52
|
+
if (bytes.length > maxSizeBytes) {
|
|
53
|
+
throw new Error(`Inputted bytes of length ${bytes} is longer than ${maxSizeBytes}`);
|
|
54
|
+
}
|
|
55
|
+
const packed = padAndPackBytesWithLen(bytes, maxSizeBytes);
|
|
56
|
+
return poseidonHash(packed);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function padAndPackBytesNoLen(bytes: Uint8Array, maxSizeBytes: number): bigint[] {
|
|
60
|
+
if (bytes.length > maxSizeBytes) {
|
|
61
|
+
throw new Error(`Input bytes of length ${bytes} is longer than ${maxSizeBytes}`);
|
|
62
|
+
}
|
|
63
|
+
const paddedStrBytes = padUint8ArrayWithZeros(bytes, maxSizeBytes);
|
|
64
|
+
return packBytes(paddedStrBytes);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function padAndPackBytesWithLen(bytes: Uint8Array, maxSizeBytes: number): bigint[] {
|
|
68
|
+
if (bytes.length > maxSizeBytes) {
|
|
69
|
+
throw new Error(`Input bytes of length ${bytes} is longer than ${maxSizeBytes}`);
|
|
70
|
+
}
|
|
71
|
+
return padAndPackBytesNoLen(bytes, maxSizeBytes).concat([BigInt(bytes.length)]);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function packBytes(bytes: Uint8Array): bigint[] {
|
|
75
|
+
if (bytes.length > MAX_NUM_INPUT_BYTES) {
|
|
76
|
+
throw new Error(`Can't pack more than ${MAX_NUM_INPUT_BYTES}. Was given ${bytes.length} bytes`);
|
|
77
|
+
}
|
|
78
|
+
return chunkUint8Array(bytes, BYTES_PACKED_PER_SCALAR).map((chunk) => bytesToBigIntLE(chunk));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function chunkUint8Array(array: Uint8Array, chunkSize: number): Uint8Array[] {
|
|
82
|
+
const result: Uint8Array[] = [];
|
|
83
|
+
for (let i = 0; i < array.length; i += chunkSize) {
|
|
84
|
+
result.push(array.subarray(i, i + chunkSize));
|
|
85
|
+
}
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function bytesToBigIntLE(bytes: Uint8Array): bigint {
|
|
90
|
+
let result = BigInt(0);
|
|
91
|
+
for (let i = bytes.length - 1; i >= 0; i -= 1) {
|
|
92
|
+
result = (result << BigInt(8)) | BigInt(bytes[i]);
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function bigIntToBytesLE(value: bigint, length: number): Uint8Array {
|
|
98
|
+
const bytes = new Uint8Array(length);
|
|
99
|
+
for (let i = 0; i < length; i += 1) {
|
|
100
|
+
bytes[i] = Number(value & BigInt(0xff));
|
|
101
|
+
// eslint-disable-next-line no-param-reassign
|
|
102
|
+
value >>= BigInt(8);
|
|
103
|
+
}
|
|
104
|
+
return bytes;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// From chatGPT
|
|
108
|
+
function padUint8ArrayWithZeros(inputArray: Uint8Array, paddedSize: number): Uint8Array {
|
|
109
|
+
if (paddedSize < inputArray.length) {
|
|
110
|
+
throw new Error("Padded size must be greater than or equal to the input array size.");
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Create a new Uint8Array with the padded size
|
|
114
|
+
const paddedArray = new Uint8Array(paddedSize);
|
|
115
|
+
|
|
116
|
+
// Copy the content of the input array to the new array
|
|
117
|
+
paddedArray.set(inputArray);
|
|
118
|
+
|
|
119
|
+
// Fill the remaining space with zeros
|
|
120
|
+
for (let i = inputArray.length; i < paddedSize; i += 1) {
|
|
121
|
+
paddedArray[i] = 0;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return paddedArray;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function poseidonHash(inputs: (number | bigint | string)[]): bigint {
|
|
128
|
+
const poseidonFixedHash = numInputsToPoseidonFunc[inputs.length - 1];
|
|
129
|
+
|
|
130
|
+
if (poseidonFixedHash) {
|
|
131
|
+
return poseidonFixedHash(inputs);
|
|
132
|
+
}
|
|
133
|
+
throw new Error(`Unable to hash input of length ${inputs.length}`);
|
|
134
|
+
}
|
|
@@ -4,6 +4,7 @@ import { AuthenticationKey } from "../authenticationKey";
|
|
|
4
4
|
import { Ed25519PublicKey, Ed25519Signature } from "./ed25519";
|
|
5
5
|
import { AccountPublicKey, PublicKey, VerifySignatureArgs } from "./publicKey";
|
|
6
6
|
import { Secp256k1PublicKey, Secp256k1Signature } from "./secp256k1";
|
|
7
|
+
import { KeylessPublicKey, KeylessSignature } from "./keyless";
|
|
7
8
|
import { Signature } from "./signature";
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -34,6 +35,8 @@ export class AnyPublicKey extends AccountPublicKey {
|
|
|
34
35
|
this.variant = AnyPublicKeyVariant.Ed25519;
|
|
35
36
|
} else if (publicKey instanceof Secp256k1PublicKey) {
|
|
36
37
|
this.variant = AnyPublicKeyVariant.Secp256k1;
|
|
38
|
+
} else if (publicKey instanceof KeylessPublicKey) {
|
|
39
|
+
this.variant = AnyPublicKeyVariant.Keyless;
|
|
37
40
|
} else {
|
|
38
41
|
throw new Error("Unsupported public key type");
|
|
39
42
|
}
|
|
@@ -85,6 +88,9 @@ export class AnyPublicKey extends AccountPublicKey {
|
|
|
85
88
|
case AnyPublicKeyVariant.Secp256k1:
|
|
86
89
|
publicKey = Secp256k1PublicKey.deserialize(deserializer);
|
|
87
90
|
break;
|
|
91
|
+
case AnyPublicKeyVariant.Keyless:
|
|
92
|
+
publicKey = KeylessPublicKey.deserialize(deserializer);
|
|
93
|
+
break;
|
|
88
94
|
default:
|
|
89
95
|
throw new Error(`Unknown variant index for AnyPublicKey: ${variantIndex}`);
|
|
90
96
|
}
|
|
@@ -138,6 +144,8 @@ export class AnySignature extends Signature {
|
|
|
138
144
|
this.variant = AnySignatureVariant.Ed25519;
|
|
139
145
|
} else if (signature instanceof Secp256k1Signature) {
|
|
140
146
|
this.variant = AnySignatureVariant.Secp256k1;
|
|
147
|
+
} else if (signature instanceof KeylessSignature) {
|
|
148
|
+
this.variant = AnySignatureVariant.Keyless;
|
|
141
149
|
} else {
|
|
142
150
|
throw new Error("Unsupported signature type");
|
|
143
151
|
}
|
|
@@ -170,6 +178,9 @@ export class AnySignature extends Signature {
|
|
|
170
178
|
case AnySignatureVariant.Secp256k1:
|
|
171
179
|
signature = Secp256k1Signature.deserialize(deserializer);
|
|
172
180
|
break;
|
|
181
|
+
case AnySignatureVariant.Keyless:
|
|
182
|
+
signature = KeylessSignature.deserialize(deserializer);
|
|
183
|
+
break;
|
|
173
184
|
default:
|
|
174
185
|
throw new Error(`Unknown variant index for AnySignature: ${variantIndex}`);
|
|
175
186
|
}
|
package/src/core/index.ts
CHANGED
package/src/index.ts
CHANGED
package/src/internal/account.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import { AptosConfig } from "../api/aptosConfig";
|
|
12
12
|
import { AptosApiError, getAptosFullNode, paginateWithCursor } from "../client";
|
|
13
13
|
import { AccountAddress, AccountAddressInput } from "../core/accountAddress";
|
|
14
|
-
import { Account } from "../
|
|
14
|
+
import { Account } from "../account";
|
|
15
15
|
import { AnyPublicKey, Ed25519PublicKey, PrivateKey } from "../core/crypto";
|
|
16
16
|
import { getTableItem, queryIndexer } from "./general";
|
|
17
17
|
import {
|
package/src/internal/ans.ts
CHANGED
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { AptosConfig } from "../api/aptosConfig";
|
|
12
|
-
import { Account
|
|
12
|
+
import { Account } from "../account";
|
|
13
|
+
import { AccountAddress, AccountAddressInput } from "../core";
|
|
13
14
|
import { InputGenerateTransactionOptions } from "../transactions/types";
|
|
14
15
|
import { GetANSNameResponse, MoveAddressType, OrderByArg, PaginationArgs, WhereArg } from "../types";
|
|
15
16
|
import { GetNamesQuery } from "../types/generated/operations";
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
|
|
11
11
|
import { AptosConfig } from "../api/aptosConfig";
|
|
12
12
|
import { Bool, MoveString, MoveVector, U64 } from "../bcs";
|
|
13
|
-
import {
|
|
13
|
+
import { AccountAddress, AccountAddressInput } from "../core";
|
|
14
|
+
import { Account } from "../account";
|
|
14
15
|
import { EntryFunctionABI, InputGenerateTransactionOptions } from "../transactions/types";
|
|
15
16
|
import {
|
|
16
17
|
AnyNumber,
|
|
@@ -33,7 +33,8 @@ import {
|
|
|
33
33
|
FungibleAssetActivitiesBoolExp,
|
|
34
34
|
FungibleAssetMetadataBoolExp,
|
|
35
35
|
} from "../types/generated/types";
|
|
36
|
-
import {
|
|
36
|
+
import { AccountAddressInput } from "../core";
|
|
37
|
+
import { Account } from "../account";
|
|
37
38
|
import {
|
|
38
39
|
EntryFunctionABI,
|
|
39
40
|
InputGenerateTransactionOptions,
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// Copyright © Aptos Foundation
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This file contains the underlying implementations for exposed API surface in
|
|
6
|
+
* the {@link api/oidb}. By moving the methods out into a separate file,
|
|
7
|
+
* other namespaces and processes can access these methods without depending on the entire
|
|
8
|
+
* faucet namespace and without having a dependency cycle error.
|
|
9
|
+
*/
|
|
10
|
+
import { jwtDecode } from "jwt-decode";
|
|
11
|
+
import { bls12_381 as bls } from "@noble/curves/bls12-381";
|
|
12
|
+
import { ProjPointType } from "@noble/curves/abstract/weierstrass";
|
|
13
|
+
import { AptosConfig } from "../api/aptosConfig";
|
|
14
|
+
import { getAptosPepperService, postAptosPepperService, postAptosProvingService } from "../client";
|
|
15
|
+
import {
|
|
16
|
+
APTOS_BIP44_DEFAULT_DERIVATION_PATH,
|
|
17
|
+
EPK_HORIZON_SECS,
|
|
18
|
+
EphemeralSignature,
|
|
19
|
+
Groth16Zkp,
|
|
20
|
+
Hex,
|
|
21
|
+
SignedGroth16Signature,
|
|
22
|
+
} from "../core";
|
|
23
|
+
import { HexInput } from "../types";
|
|
24
|
+
import { Serializer } from "../bcs";
|
|
25
|
+
import { EphemeralKeyPair, KeylessAccount } from "../account";
|
|
26
|
+
import { PepperFetchResponse, ProverResponse } from "../types/keyless";
|
|
27
|
+
|
|
28
|
+
const APTOS_KEYLESS_PEPPER_PINKAS_VUF_DST = "APTOS_KEYLESS_PEPPER_PINKAS_VUF_DST";
|
|
29
|
+
|
|
30
|
+
function stringToUint8Array(str: string): Uint8Array {
|
|
31
|
+
const encoder = new TextEncoder();
|
|
32
|
+
return encoder.encode(str);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const PINKAS_VUF_SECRET_KEY_BASE_AFFINE = bls.G2.hashToCurve(
|
|
36
|
+
stringToUint8Array("APTOS_KEYLESS_PEPPER_PINKAS_VUF_SECRET_KEY_BASE"),
|
|
37
|
+
{ DST: APTOS_KEYLESS_PEPPER_PINKAS_VUF_DST },
|
|
38
|
+
).toAffine();
|
|
39
|
+
|
|
40
|
+
function getPepperInput(args: { jwt: string; uidKey?: string }): ProjPointType<bigint> {
|
|
41
|
+
const { jwt, uidKey } = args;
|
|
42
|
+
const jwtPayload = jwtDecode<{ [key: string]: string }>(jwt);
|
|
43
|
+
const serializer = new Serializer();
|
|
44
|
+
serializer.serializeStr(jwtPayload.iss);
|
|
45
|
+
serializer.serializeStr(jwtPayload.aud);
|
|
46
|
+
serializer.serializeStr(jwtPayload[uidKey || "sub"]);
|
|
47
|
+
serializer.serializeStr(uidKey || "sub");
|
|
48
|
+
const serial = serializer.toUint8Array();
|
|
49
|
+
const msg = bls.G1.hashToCurve(serial, { DST: "APTOS_PEPPER_SERVICE_BLS12381_VUF_DST" }).toAffine();
|
|
50
|
+
const pp = bls.G1.ProjectivePoint.fromAffine(msg);
|
|
51
|
+
return pp;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function verifyPepperBase(args: {
|
|
55
|
+
aptosConfig: AptosConfig;
|
|
56
|
+
pepperInput: ProjPointType<bigint>;
|
|
57
|
+
pepperBase: Uint8Array;
|
|
58
|
+
}): Promise<boolean> {
|
|
59
|
+
const { aptosConfig, pepperInput, pepperBase } = args;
|
|
60
|
+
const { data: pubKeyResponse } = await getAptosPepperService<any, { vrf_public_key_hex_string: string }>({
|
|
61
|
+
aptosConfig,
|
|
62
|
+
path: "vrf-pub-key",
|
|
63
|
+
originMethod: "getPepper",
|
|
64
|
+
});
|
|
65
|
+
const publicKeyFromService = bls.G2.ProjectivePoint.fromHex(pubKeyResponse.vrf_public_key_hex_string);
|
|
66
|
+
return bls.verifyShortSignature(pepperBase, pepperInput, publicKeyFromService);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export async function getPepper(args: {
|
|
70
|
+
aptosConfig: AptosConfig;
|
|
71
|
+
jwt: string;
|
|
72
|
+
ephemeralKeyPair: EphemeralKeyPair;
|
|
73
|
+
uidKey?: string;
|
|
74
|
+
derivationPath?: string;
|
|
75
|
+
verify?: boolean;
|
|
76
|
+
}): Promise<Uint8Array> {
|
|
77
|
+
const { aptosConfig, jwt, ephemeralKeyPair, uidKey, verify } = args;
|
|
78
|
+
let { derivationPath } = args;
|
|
79
|
+
|
|
80
|
+
const body = {
|
|
81
|
+
jwt_b64: jwt,
|
|
82
|
+
epk: ephemeralKeyPair.getPublicKey().bcsToHex().toStringWithoutPrefix(),
|
|
83
|
+
exp_date_secs: Number(ephemeralKeyPair.expiryDateSecs),
|
|
84
|
+
epk_blinder: Hex.fromHexInput(ephemeralKeyPair.blinder).toStringWithoutPrefix(),
|
|
85
|
+
uid_key: uidKey,
|
|
86
|
+
};
|
|
87
|
+
// console.log(JSON.stringify(body));
|
|
88
|
+
const { data } = await postAptosPepperService<any, PepperFetchResponse>({
|
|
89
|
+
aptosConfig,
|
|
90
|
+
path: "fetch",
|
|
91
|
+
body,
|
|
92
|
+
originMethod: "getPepper",
|
|
93
|
+
overrides: { WITH_CREDENTIALS: false },
|
|
94
|
+
});
|
|
95
|
+
const pepperBase = Hex.fromHexInput(data.signature).toUint8Array();
|
|
96
|
+
|
|
97
|
+
if (verify) {
|
|
98
|
+
const pepperVerified = verifyPepperBase({ aptosConfig, pepperBase, pepperInput: getPepperInput(args) });
|
|
99
|
+
if (!pepperVerified) {
|
|
100
|
+
throw new Error("Unable to verify");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// This takes the BLS VUF H(m)^sk and transforms it into a Pinkas VUF e(H(m), g_3^sk), where g_3 is the base of the secret key (computed pseudo-randomly via hash-to-curve).
|
|
104
|
+
// This gives us the freedom of either decentralizing the pepper service as a BLS-based MPC or on top of the validators, by reusing the Pinkas WVUF-based randomness infrastructure.
|
|
105
|
+
const newPepperBase = bls.pairing(
|
|
106
|
+
bls.G1.ProjectivePoint.fromHex(pepperBase),
|
|
107
|
+
bls.G2.ProjectivePoint.fromAffine(PINKAS_VUF_SECRET_KEY_BASE_AFFINE),
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
if (derivationPath === undefined) {
|
|
111
|
+
derivationPath = APTOS_BIP44_DEFAULT_DERIVATION_PATH;
|
|
112
|
+
}
|
|
113
|
+
const pepper = KeylessAccount.fromDerivationPath(derivationPath, bls.fields.Fp12.toBytes(newPepperBase));
|
|
114
|
+
return pepper.slice(0, 31);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export async function getProof(args: {
|
|
118
|
+
aptosConfig: AptosConfig;
|
|
119
|
+
jwt: string;
|
|
120
|
+
ephemeralKeyPair: EphemeralKeyPair;
|
|
121
|
+
pepper: HexInput;
|
|
122
|
+
uidKey?: string;
|
|
123
|
+
extraFieldKey?: string;
|
|
124
|
+
}): Promise<SignedGroth16Signature> {
|
|
125
|
+
const { aptosConfig, jwt, ephemeralKeyPair, pepper, uidKey, extraFieldKey } = args;
|
|
126
|
+
const jwtPayload = jwtDecode<{ [key: string]: string }>(jwt);
|
|
127
|
+
let extraField;
|
|
128
|
+
if (extraFieldKey) {
|
|
129
|
+
const extraFieldVal = jwtPayload[extraFieldKey];
|
|
130
|
+
extraField = `"${extraFieldKey}":"${extraFieldVal}",`;
|
|
131
|
+
}
|
|
132
|
+
const json = {
|
|
133
|
+
jwt_b64: jwt,
|
|
134
|
+
epk: ephemeralKeyPair.getPublicKey().bcsToHex().toStringWithoutPrefix(),
|
|
135
|
+
epk_blinder: Hex.fromHexInput(ephemeralKeyPair.blinder).toStringWithoutPrefix(),
|
|
136
|
+
exp_date_secs: Number(ephemeralKeyPair.expiryDateSecs),
|
|
137
|
+
exp_horizon_secs: EPK_HORIZON_SECS,
|
|
138
|
+
pepper: Hex.fromHexInput(pepper).toStringWithoutPrefix(),
|
|
139
|
+
extra_field: extraFieldKey,
|
|
140
|
+
uid_key: uidKey || "sub",
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const { data } = await postAptosProvingService<any, ProverResponse>({
|
|
144
|
+
aptosConfig,
|
|
145
|
+
path: "prove",
|
|
146
|
+
body: json,
|
|
147
|
+
originMethod: "getProof",
|
|
148
|
+
overrides: { WITH_CREDENTIALS: false },
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
const proofPoints = data.proof;
|
|
152
|
+
const proof = new Groth16Zkp({
|
|
153
|
+
a: proofPoints.a,
|
|
154
|
+
b: proofPoints.b,
|
|
155
|
+
c: proofPoints.c,
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
const signedProof = new SignedGroth16Signature({
|
|
159
|
+
proof,
|
|
160
|
+
extraField,
|
|
161
|
+
trainingWheelsSignature: EphemeralSignature.fromHex(data.training_wheels_signature),
|
|
162
|
+
});
|
|
163
|
+
return signedProof;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export async function deriveKeylessAccount(args: {
|
|
167
|
+
aptosConfig: AptosConfig;
|
|
168
|
+
jwt: string;
|
|
169
|
+
ephemeralKeyPair: EphemeralKeyPair;
|
|
170
|
+
uidKey?: string;
|
|
171
|
+
pepper?: HexInput;
|
|
172
|
+
extraFieldKey?: string;
|
|
173
|
+
}): Promise<KeylessAccount> {
|
|
174
|
+
let { pepper } = args;
|
|
175
|
+
if (pepper === undefined) {
|
|
176
|
+
pepper = await getPepper(args);
|
|
177
|
+
} else if (Hex.fromHexInput(pepper).toUint8Array().length !== 31) {
|
|
178
|
+
throw new Error("Pepper needs to be 31 bytes");
|
|
179
|
+
}
|
|
180
|
+
const proof = await getProof({ ...args, pepper });
|
|
181
|
+
|
|
182
|
+
const keylessAccount = KeylessAccount.fromJWTAndProof({ ...args, proof, pepper });
|
|
183
|
+
|
|
184
|
+
return keylessAccount;
|
|
185
|
+
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { AptosConfig } from "../api/aptosConfig";
|
|
9
9
|
import { MoveVector, U8 } from "../bcs";
|
|
10
10
|
import { postAptosFullNode } from "../client";
|
|
11
|
-
import { Account } from "../
|
|
11
|
+
import { Account, KeylessAccount, MultiKeyAccount } from "../account";
|
|
12
12
|
import { AccountAddress, AccountAddressInput } from "../core/accountAddress";
|
|
13
13
|
import { PrivateKey } from "../core/crypto";
|
|
14
14
|
import { AccountAuthenticator } from "../transactions/authenticator/account";
|
|
@@ -18,8 +18,6 @@ import {
|
|
|
18
18
|
generateTransactionPayload,
|
|
19
19
|
generateSignedTransactionForSimulation,
|
|
20
20
|
generateSignedTransaction,
|
|
21
|
-
sign,
|
|
22
|
-
generateSigningMessage,
|
|
23
21
|
} from "../transactions/transactionBuilder/transactionBuilder";
|
|
24
22
|
import {
|
|
25
23
|
InputGenerateTransactionData,
|
|
@@ -35,7 +33,7 @@ import {
|
|
|
35
33
|
} from "../transactions/types";
|
|
36
34
|
import { getInfo } from "./account";
|
|
37
35
|
import { UserTransactionResponse, PendingTransactionResponse, MimeType, HexInput, TransactionResponse } from "../types";
|
|
38
|
-
import { TypeTagU8, TypeTagVector } from "../transactions";
|
|
36
|
+
import { TypeTagU8, TypeTagVector, generateSigningMessageForTransaction } from "../transactions";
|
|
39
37
|
import { SimpleTransaction } from "../transactions/instances/simpleTransaction";
|
|
40
38
|
import { MultiAgentTransaction } from "../transactions/instances/multiAgentTransaction";
|
|
41
39
|
|
|
@@ -185,7 +183,7 @@ function isMultiAgentTransactionInput(
|
|
|
185
183
|
*/
|
|
186
184
|
export function getSigningMessage(args: { transaction: AnyRawTransaction }): Uint8Array {
|
|
187
185
|
const { transaction } = args;
|
|
188
|
-
return
|
|
186
|
+
return generateSigningMessageForTransaction(transaction);
|
|
189
187
|
}
|
|
190
188
|
|
|
191
189
|
/**
|
|
@@ -204,8 +202,8 @@ export function getSigningMessage(args: { transaction: AnyRawTransaction }): Uin
|
|
|
204
202
|
* @return The signer AccountAuthenticator
|
|
205
203
|
*/
|
|
206
204
|
export function signTransaction(args: { signer: Account; transaction: AnyRawTransaction }): AccountAuthenticator {
|
|
207
|
-
const
|
|
208
|
-
return
|
|
205
|
+
const { signer, transaction } = args;
|
|
206
|
+
return signer.signWithAuthenticator(transaction);
|
|
209
207
|
}
|
|
210
208
|
|
|
211
209
|
/**
|
|
@@ -277,6 +275,9 @@ export async function signAndSubmitTransaction(args: {
|
|
|
277
275
|
transaction: AnyRawTransaction;
|
|
278
276
|
}): Promise<PendingTransactionResponse> {
|
|
279
277
|
const { aptosConfig, signer, transaction } = args;
|
|
278
|
+
if (signer instanceof KeylessAccount || signer instanceof MultiKeyAccount) {
|
|
279
|
+
await signer.waitForProofFetch();
|
|
280
|
+
}
|
|
280
281
|
const authenticator = signTransaction({ signer, transaction });
|
|
281
282
|
return submitTransaction({
|
|
282
283
|
aptosConfig,
|
|
@@ -7,7 +7,7 @@ import { Serializer, Deserializer, Serializable } from "../../bcs";
|
|
|
7
7
|
import { AnyPublicKey, AnySignature } from "../../core/crypto";
|
|
8
8
|
import { Ed25519PublicKey, Ed25519Signature } from "../../core/crypto/ed25519";
|
|
9
9
|
import { MultiEd25519PublicKey, MultiEd25519Signature } from "../../core/crypto/multiEd25519";
|
|
10
|
-
import { MultiKey } from "../../core/crypto/multiKey";
|
|
10
|
+
import { MultiKey, MultiSignature } from "../../core/crypto/multiKey";
|
|
11
11
|
import { AccountAuthenticatorVariant } from "../../types";
|
|
12
12
|
|
|
13
13
|
export abstract class AccountAuthenticator extends Serializable {
|
|
@@ -149,28 +149,23 @@ export class AccountAuthenticatorSingleKey extends AccountAuthenticator {
|
|
|
149
149
|
export class AccountAuthenticatorMultiKey extends AccountAuthenticator {
|
|
150
150
|
public readonly public_keys: MultiKey;
|
|
151
151
|
|
|
152
|
-
public readonly signatures:
|
|
152
|
+
public readonly signatures: MultiSignature;
|
|
153
153
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
constructor(public_keys: MultiKey, signatures: Array<AnySignature>, signatures_bitmap: Uint8Array) {
|
|
154
|
+
constructor(public_keys: MultiKey, signatures: MultiSignature) {
|
|
157
155
|
super();
|
|
158
156
|
this.public_keys = public_keys;
|
|
159
157
|
this.signatures = signatures;
|
|
160
|
-
this.signatures_bitmap = signatures_bitmap;
|
|
161
158
|
}
|
|
162
159
|
|
|
163
160
|
serialize(serializer: Serializer): void {
|
|
164
161
|
serializer.serializeU32AsUleb128(AccountAuthenticatorVariant.MultiKey);
|
|
165
162
|
this.public_keys.serialize(serializer);
|
|
166
|
-
|
|
167
|
-
serializer.serializeBytes(this.signatures_bitmap);
|
|
163
|
+
this.signatures.serialize(serializer);
|
|
168
164
|
}
|
|
169
165
|
|
|
170
166
|
static load(deserializer: Deserializer): AccountAuthenticatorMultiKey {
|
|
171
167
|
const public_keys = MultiKey.deserialize(deserializer);
|
|
172
|
-
const signatures =
|
|
173
|
-
|
|
174
|
-
return new AccountAuthenticatorMultiKey(public_keys, signatures, signatures_bitmap);
|
|
168
|
+
const signatures = MultiSignature.deserialize(deserializer);
|
|
169
|
+
return new AccountAuthenticatorMultiKey(public_keys, signatures);
|
|
175
170
|
}
|
|
176
171
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import EventEmitter from "eventemitter3";
|
|
4
4
|
import { AptosConfig } from "../../api/aptosConfig";
|
|
5
|
-
import { Account } from "../../
|
|
5
|
+
import { Account } from "../../account";
|
|
6
6
|
import { waitForTransaction } from "../../internal/transaction";
|
|
7
7
|
import { generateTransaction, signAndSubmitTransaction } from "../../internal/transactionSubmission";
|
|
8
8
|
import { PendingTransactionResponse, TransactionResponse } from "../../types";
|
|
@@ -233,7 +233,13 @@ export class TransactionWorker extends EventEmitter<TransactionWorkerEvents> {
|
|
|
233
233
|
async checkTransaction(sentTransaction: PromiseFulfilledResult<PendingTransactionResponse>, sequenceNumber: bigint) {
|
|
234
234
|
try {
|
|
235
235
|
const waitFor: Array<Promise<TransactionResponse>> = [];
|
|
236
|
-
waitFor.push(
|
|
236
|
+
waitFor.push(
|
|
237
|
+
waitForTransaction({
|
|
238
|
+
aptosConfig: this.aptosConfig,
|
|
239
|
+
transactionHash: sentTransaction.value.hash,
|
|
240
|
+
options: { timeoutSecs: 3 },
|
|
241
|
+
}),
|
|
242
|
+
);
|
|
237
243
|
const sentTransactions = await Promise.allSettled(waitFor);
|
|
238
244
|
|
|
239
245
|
for (let i = 0; i < sentTransactions.length; i += 1) {
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Copyright © Aptos Foundation
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This file handles the transaction creation lifecycle.
|
|
6
|
+
* It holds different operations to generate a transaction payload, a raw transaction,
|
|
7
|
+
* and a signed transaction that can be simulated, signed and submitted to chain.
|
|
8
|
+
*/
|
|
9
|
+
import { sha3_256 as sha3Hash } from "@noble/hashes/sha3";
|
|
10
|
+
import { RAW_TRANSACTION_SALT, RAW_TRANSACTION_WITH_DATA_SALT } from "../../utils/const";
|
|
11
|
+
import { FeePayerRawTransaction, MultiAgentRawTransaction, RawTransaction } from "../instances";
|
|
12
|
+
import { AnyRawTransaction, AnyRawTransactionInstance } from "../types";
|
|
13
|
+
import { Serializable } from "../../bcs";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Derive the raw transaction type - FeePayerRawTransaction or MultiAgentRawTransaction or RawTransaction
|
|
17
|
+
*
|
|
18
|
+
* @param transaction A aptos transaction type
|
|
19
|
+
*
|
|
20
|
+
* @returns FeePayerRawTransaction | MultiAgentRawTransaction | RawTransaction
|
|
21
|
+
*/
|
|
22
|
+
export function deriveTransactionType(transaction: AnyRawTransaction): AnyRawTransactionInstance {
|
|
23
|
+
if (transaction.feePayerAddress) {
|
|
24
|
+
return new FeePayerRawTransaction(
|
|
25
|
+
transaction.rawTransaction,
|
|
26
|
+
transaction.secondarySignerAddresses ?? [],
|
|
27
|
+
transaction.feePayerAddress,
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
if (transaction.secondarySignerAddresses) {
|
|
31
|
+
return new MultiAgentRawTransaction(transaction.rawTransaction, transaction.secondarySignerAddresses);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return transaction.rawTransaction;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function generateSigningMessage(bytes: Uint8Array, domainSeparator: string): Uint8Array {
|
|
38
|
+
const hash = sha3Hash.create();
|
|
39
|
+
|
|
40
|
+
if (!domainSeparator.startsWith("APTOS::")) {
|
|
41
|
+
throw new Error(`Domain separator needs to start with 'APTOS::'. Provided - ${domainSeparator}`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
hash.update(domainSeparator);
|
|
45
|
+
|
|
46
|
+
const prefix = hash.digest();
|
|
47
|
+
|
|
48
|
+
const body = bytes;
|
|
49
|
+
|
|
50
|
+
const mergedArray = new Uint8Array(prefix.length + body.length);
|
|
51
|
+
mergedArray.set(prefix);
|
|
52
|
+
mergedArray.set(body, prefix.length);
|
|
53
|
+
|
|
54
|
+
return mergedArray;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function generateSigningMessageForSerializable(obj: Serializable): Uint8Array {
|
|
58
|
+
return generateSigningMessage(obj.bcsToBytes(), obj.constructor.name);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function generateSigningMessageForTransaction(transaction: AnyRawTransaction): Uint8Array {
|
|
62
|
+
const rawTxn = deriveTransactionType(transaction);
|
|
63
|
+
if (rawTxn instanceof RawTransaction) {
|
|
64
|
+
return generateSigningMessage(rawTxn.bcsToBytes(), RAW_TRANSACTION_SALT);
|
|
65
|
+
}
|
|
66
|
+
if (rawTxn instanceof MultiAgentRawTransaction || rawTxn instanceof FeePayerRawTransaction) {
|
|
67
|
+
return generateSigningMessage(rawTxn.bcsToBytes(), RAW_TRANSACTION_WITH_DATA_SALT);
|
|
68
|
+
}
|
|
69
|
+
throw new Error(`Unknown transaction type to sign on: ${rawTxn}`);
|
|
70
|
+
}
|