@aptos-labs/ts-sdk 1.8.0 → 1.9.1-plugin.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/README.md +1 -1
- package/dist/common/index.d.ts +1204 -969
- package/dist/common/index.js +26 -26
- package/dist/common/index.js.map +1 -1
- package/dist/esm/api/account.d.mts +12 -6
- package/dist/esm/api/account.mjs +1 -1
- package/dist/esm/api/ans.d.mts +11 -12
- package/dist/esm/api/ans.mjs +1 -1
- package/dist/esm/api/aptos.d.mts +13 -14
- package/dist/esm/api/aptos.mjs +1 -1
- package/dist/esm/api/aptosConfig.d.mts +7 -0
- package/dist/esm/api/aptosConfig.mjs +1 -1
- package/dist/esm/api/coin.d.mts +13 -13
- package/dist/esm/api/coin.mjs +1 -1
- package/dist/esm/api/digitalAsset.d.mts +20 -10
- 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 +9 -10
- package/dist/esm/api/fungibleAsset.mjs +1 -1
- package/dist/esm/api/general.mjs +1 -1
- package/dist/esm/api/index.d.mts +13 -14
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/staking.mjs +1 -1
- package/dist/esm/api/transaction.d.mts +5 -6
- package/dist/esm/api/transaction.mjs +1 -1
- package/dist/esm/api/transactionSubmission/build.d.mts +8 -8
- package/dist/esm/api/transactionSubmission/build.mjs +1 -1
- package/dist/esm/api/transactionSubmission/management.d.mts +11 -12
- package/dist/esm/api/transactionSubmission/management.mjs +1 -1
- package/dist/esm/api/transactionSubmission/sign.d.mts +11 -12
- 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 +11 -11
- package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
- package/dist/esm/api/transactionSubmission/submit.d.mts +6 -6
- package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
- package/dist/esm/api/utils.mjs +1 -1
- package/dist/esm/assetUploader/assetUploader.d.mts +109 -0
- package/dist/esm/assetUploader/assetUploader.mjs +2 -0
- package/dist/esm/assetUploader/index.d.mts +24 -0
- package/dist/esm/assetUploader/index.mjs +2 -0
- package/dist/esm/assetUploader/irys.d.mts +64 -0
- package/dist/esm/assetUploader/irys.mjs +2 -0
- 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.mjs +1 -1
- package/dist/esm/chunk-2RRFFRBV.mjs +2 -0
- package/dist/esm/chunk-2RRFFRBV.mjs.map +1 -0
- package/dist/esm/chunk-4LUWUDBX.mjs +2 -0
- package/dist/esm/{chunk-O57QZZF2.mjs → chunk-53UNV6UP.mjs} +2 -2
- package/dist/esm/chunk-53UNV6UP.mjs.map +1 -0
- package/dist/esm/{chunk-7D5LHQNS.mjs → chunk-5PIO6MFF.mjs} +2 -2
- package/dist/esm/{chunk-VKZCIGKY.mjs → chunk-6TUHLGW3.mjs} +2 -2
- package/dist/esm/{chunk-ENDUXRTK.mjs → chunk-7KPEDF2R.mjs} +2 -2
- package/dist/esm/chunk-AJRBTHDS.mjs +2 -0
- package/dist/esm/chunk-AJRBTHDS.mjs.map +1 -0
- package/dist/esm/chunk-AXVVJKE4.mjs +2 -0
- package/dist/esm/chunk-BKWJ4G7T.mjs +2 -0
- package/dist/esm/{chunk-VRSUCKJA.mjs.map → chunk-BKWJ4G7T.mjs.map} +1 -1
- package/dist/esm/{chunk-NL72WE3E.mjs → chunk-BZMO6Q6L.mjs} +2 -2
- package/dist/esm/chunk-CNEVWSWR.mjs +2 -0
- package/dist/esm/chunk-CNEVWSWR.mjs.map +1 -0
- package/dist/esm/chunk-CUWAGKEP.mjs +2 -0
- package/dist/esm/chunk-CUWAGKEP.mjs.map +1 -0
- package/dist/esm/chunk-DQHNZBA5.mjs +2 -0
- package/dist/esm/chunk-DQHNZBA5.mjs.map +1 -0
- package/dist/esm/{chunk-XBVORX5O.mjs → chunk-FAAWSTXC.mjs} +2 -2
- package/dist/esm/{chunk-AFPJ2XXN.mjs → chunk-FHWAJCJR.mjs} +2 -2
- package/dist/esm/{chunk-VPQ46CAO.mjs → chunk-GE7VQ5NZ.mjs} +2 -2
- package/dist/esm/{chunk-6FBKUTGF.mjs → chunk-GHYE26Q5.mjs} +2 -2
- package/dist/esm/chunk-GTCDSGOA.mjs +2 -0
- package/dist/esm/chunk-GTCDSGOA.mjs.map +1 -0
- package/dist/esm/chunk-H2FRCXQ6.mjs +2 -0
- package/dist/esm/chunk-H2FRCXQ6.mjs.map +1 -0
- package/dist/esm/chunk-HEPV52CH.mjs +2 -0
- package/dist/esm/chunk-HEPV52CH.mjs.map +1 -0
- package/dist/esm/chunk-HIUJDWMR.mjs +2 -0
- package/dist/esm/{chunk-MEPX7Z2Z.mjs.map → chunk-HIUJDWMR.mjs.map} +1 -1
- package/dist/esm/{chunk-2H5Z5EHH.mjs → chunk-HKAJ5N25.mjs} +2 -2
- package/dist/esm/chunk-HRKLPZL5.mjs +2 -0
- package/dist/esm/chunk-HRKLPZL5.mjs.map +1 -0
- package/dist/esm/{chunk-PJNPLRPR.mjs → chunk-HWTX3HVX.mjs} +2 -2
- package/dist/esm/chunk-IFVMIUMO.mjs +2 -0
- package/dist/esm/{chunk-6SRENFWH.mjs → chunk-IMYKTNDV.mjs} +2 -2
- package/dist/esm/{chunk-PMWH5IGI.mjs → chunk-ITALFUWD.mjs} +2 -2
- package/dist/esm/chunk-JB7ZOUYL.mjs +2 -0
- package/dist/esm/{chunk-2WFMD6C6.mjs → chunk-JMR7G5DT.mjs} +2 -2
- package/dist/esm/{chunk-S64WKSMI.mjs → chunk-JOIUR5QW.mjs} +2 -2
- package/dist/esm/{chunk-F7CR75CJ.mjs → chunk-JPG25VX2.mjs} +2 -2
- package/dist/esm/{chunk-F7CR75CJ.mjs.map → chunk-JPG25VX2.mjs.map} +1 -1
- package/dist/esm/{chunk-4OI7MPFH.mjs → chunk-K5XJKIFT.mjs} +2 -2
- package/dist/esm/chunk-KUX6GQ2E.mjs +1 -0
- package/dist/esm/{chunk-Q5HK3U64.mjs → chunk-L4PAU62E.mjs} +2 -2
- package/dist/esm/chunk-L7ORFGZ7.mjs +1 -0
- package/dist/esm/chunk-LG7RJQ57.mjs +2 -0
- package/dist/esm/chunk-LKKOIIBF.mjs +2 -0
- package/dist/esm/chunk-LKKOIIBF.mjs.map +1 -0
- package/dist/esm/chunk-M6TKSJ4I.mjs +2 -0
- package/dist/esm/chunk-ML7VTAHR.mjs +2 -0
- package/dist/esm/chunk-ML7VTAHR.mjs.map +1 -0
- package/dist/esm/{chunk-2DNPRIS5.mjs → chunk-MVWTTVQZ.mjs} +2 -2
- package/dist/esm/chunk-NA2H44NE.mjs +2 -0
- package/dist/esm/{chunk-CVEJHRAU.mjs → chunk-NCDLIACO.mjs} +1 -1
- package/dist/esm/chunk-NCDLIACO.mjs.map +1 -0
- package/dist/esm/chunk-NF35PRGD.mjs +2 -0
- package/dist/esm/{chunk-XZYPAQCU.mjs.map → chunk-NF35PRGD.mjs.map} +1 -1
- package/dist/esm/{chunk-R56OJ4XC.mjs → chunk-NYGCJ6EJ.mjs} +2 -2
- package/dist/esm/{chunk-PIXE7MN5.mjs → chunk-NZGON5TY.mjs} +2 -2
- package/dist/esm/chunk-O4EVRHDH.mjs +2 -0
- package/dist/esm/chunk-O4EVRHDH.mjs.map +1 -0
- package/dist/esm/{chunk-Y4AKS4CY.mjs → chunk-O5Q3RSEJ.mjs} +2 -2
- package/dist/esm/chunk-OP4VV2UO.mjs +2 -0
- package/dist/esm/chunk-OP4VV2UO.mjs.map +1 -0
- package/dist/esm/chunk-OYQRQC4Z.mjs +2 -0
- package/dist/esm/chunk-OYQRQC4Z.mjs.map +1 -0
- package/dist/esm/chunk-P3CMSOX6.mjs +2 -0
- package/dist/esm/chunk-P3CMSOX6.mjs.map +1 -0
- package/dist/esm/{chunk-LATJGGVX.mjs → chunk-PATJMQAG.mjs} +2 -2
- package/dist/esm/chunk-PEOCYUOO.mjs +2 -0
- package/dist/esm/chunk-PEOCYUOO.mjs.map +1 -0
- package/dist/esm/chunk-PISONN6H.mjs +2 -0
- package/dist/esm/chunk-PISONN6H.mjs.map +1 -0
- package/dist/esm/chunk-Q6YMSZLY.mjs +2 -0
- package/dist/esm/{chunk-SRZTA6QH.mjs.map → chunk-Q6YMSZLY.mjs.map} +1 -1
- package/dist/esm/chunk-QE4ASJ5K.mjs +1 -0
- package/dist/esm/chunk-QE4ASJ5K.mjs.map +1 -0
- package/dist/esm/{chunk-SXIFL5DQ.mjs → chunk-RC5K63LK.mjs} +2 -2
- package/dist/esm/chunk-RZNFFGTD.mjs +2 -0
- package/dist/esm/chunk-RZNFFGTD.mjs.map +1 -0
- package/dist/esm/{chunk-QGIJNA37.mjs → chunk-SKF6E6X7.mjs} +2 -2
- package/dist/esm/{chunk-ENKMOALS.mjs → chunk-SPKBGDFY.mjs} +2 -2
- package/dist/esm/chunk-SPKBGDFY.mjs.map +1 -0
- package/dist/esm/chunk-TWHTXYMB.mjs +2 -0
- package/dist/esm/{chunk-JQVT2K7G.mjs → chunk-UCFIV5UD.mjs} +2 -2
- package/dist/esm/{chunk-JJ6Y35DF.mjs → chunk-UFD443TT.mjs} +2 -2
- package/dist/esm/chunk-UVSRX4SV.mjs +1 -0
- package/dist/esm/chunk-UVSRX4SV.mjs.map +1 -0
- package/dist/esm/{chunk-M3WNE7MU.mjs → chunk-UVTSJ2KP.mjs} +2 -2
- package/dist/esm/{chunk-KJGQ4ILY.mjs → chunk-UZ3SFWTM.mjs} +2 -2
- package/dist/esm/{chunk-V2FPYAK7.mjs → chunk-VPN3KEVB.mjs} +2 -2
- package/dist/esm/chunk-VQM4LMCW.mjs +2 -0
- package/dist/esm/{chunk-W4UDMBMU.mjs → chunk-VWWR2UAQ.mjs} +2 -2
- package/dist/esm/{chunk-F7MOQC7Z.mjs → chunk-VZJ62XF7.mjs} +2 -2
- package/dist/esm/{chunk-N4RBQZ2B.mjs → chunk-W2XLZW4Y.mjs} +2 -2
- package/dist/esm/{chunk-FRLPX47J.mjs → chunk-XH4B5K6W.mjs} +2 -2
- package/dist/esm/{chunk-4M46AWXX.mjs → chunk-XSCYT6TT.mjs} +2 -2
- package/dist/esm/{chunk-EUHPML5E.mjs → chunk-XSYZX66A.mjs} +2 -2
- package/dist/esm/{chunk-SPOHAEHR.mjs → chunk-YTHL7EKV.mjs} +2 -2
- package/dist/esm/{chunk-Q3HAJVCM.mjs → chunk-YXUOYXGZ.mjs} +2 -2
- package/dist/esm/chunk-ZAMLI7FP.mjs +2 -0
- package/dist/esm/chunk-ZAMLI7FP.mjs.map +1 -0
- package/dist/esm/client/core.mjs +1 -1
- package/dist/esm/client/get.mjs +1 -1
- package/dist/esm/client/index.mjs +1 -1
- package/dist/esm/client/post.mjs +1 -1
- package/dist/esm/client/types.mjs +1 -1
- package/dist/esm/core/account/Account.d.mts +20 -0
- package/dist/esm/core/account/Account.mjs +2 -0
- package/dist/esm/core/account/Account.mjs.map +1 -0
- package/dist/esm/core/account/Ed25519Account.d.mts +20 -0
- package/dist/esm/core/account/Ed25519Account.mjs +2 -0
- package/dist/esm/core/account/Ed25519Account.mjs.map +1 -0
- package/dist/esm/core/account/SingleKeyAccount.d.mts +20 -0
- package/dist/esm/core/account/SingleKeyAccount.mjs +2 -0
- package/dist/esm/core/account/SingleKeyAccount.mjs.map +1 -0
- package/dist/esm/core/account/index.d.mts +305 -0
- package/dist/esm/core/account/index.mjs +2 -0
- package/dist/esm/core/account/index.mjs.map +1 -0
- package/dist/esm/core/accountAddress.mjs +1 -1
- package/dist/esm/core/authenticationKey.d.mts +7 -68
- package/dist/esm/core/authenticationKey.mjs +1 -1
- package/dist/esm/core/common.mjs +1 -1
- package/dist/esm/core/crypto/ed25519.d.mts +49 -61
- package/dist/esm/core/crypto/ed25519.mjs +1 -1
- package/dist/esm/core/crypto/index.d.mts +9 -6
- package/dist/esm/core/crypto/index.mjs +1 -1
- package/dist/esm/core/crypto/multiEd25519.d.mts +17 -14
- package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
- package/dist/esm/core/crypto/multiKey.d.mts +70 -17
- package/dist/esm/core/crypto/multiKey.mjs +1 -1
- package/dist/esm/core/crypto/privateKey.d.mts +35 -0
- package/dist/esm/core/crypto/privateKey.mjs +2 -0
- package/dist/esm/core/crypto/privateKey.mjs.map +1 -0
- package/dist/esm/core/crypto/publicKey.d.mts +13 -0
- package/dist/esm/core/crypto/publicKey.mjs +2 -0
- package/dist/esm/core/crypto/publicKey.mjs.map +1 -0
- package/dist/esm/core/crypto/secp256k1.d.mts +43 -67
- package/dist/esm/core/crypto/secp256k1.mjs +1 -1
- package/dist/esm/core/crypto/signature.d.mts +28 -0
- package/dist/esm/core/crypto/signature.mjs +2 -0
- package/dist/esm/core/crypto/signature.mjs.map +1 -0
- package/dist/esm/core/crypto/singleKey.d.mts +68 -0
- package/dist/esm/core/crypto/singleKey.mjs +2 -0
- package/dist/esm/core/crypto/singleKey.mjs.map +1 -0
- package/dist/esm/core/hex.mjs +1 -1
- package/dist/esm/core/index.d.mts +9 -8
- package/dist/esm/core/index.mjs +1 -1
- package/dist/esm/index.d.mts +10 -8
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internal/account.d.mts +9 -3
- package/dist/esm/internal/account.mjs +1 -1
- package/dist/esm/internal/ans.d.mts +10 -11
- package/dist/esm/internal/ans.mjs +1 -1
- package/dist/esm/internal/coin.d.mts +12 -12
- package/dist/esm/internal/coin.mjs +1 -1
- package/dist/esm/internal/digitalAsset.d.mts +17 -14
- package/dist/esm/internal/digitalAsset.mjs +1 -1
- package/dist/esm/internal/event.d.mts +2 -2
- package/dist/esm/internal/event.mjs +1 -1
- package/dist/esm/internal/faucet.d.mts +4 -4
- package/dist/esm/internal/faucet.mjs +1 -1
- package/dist/esm/internal/fungibleAsset.d.mts +10 -11
- package/dist/esm/internal/fungibleAsset.mjs +1 -1
- package/dist/esm/internal/general.mjs +1 -1
- package/dist/esm/internal/staking.d.mts +3 -3
- package/dist/esm/internal/staking.mjs +1 -1
- package/dist/esm/internal/transaction.mjs +1 -1
- package/dist/esm/internal/transactionSubmission.d.mts +12 -13
- package/dist/esm/internal/transactionSubmission.mjs +1 -1
- package/dist/esm/publicKey-B3XRNhHO.d.mts +113 -0
- package/dist/esm/transactions/authenticator/account.d.mts +6 -4
- package/dist/esm/transactions/authenticator/account.mjs +1 -1
- package/dist/esm/transactions/authenticator/index.d.mts +6 -6
- package/dist/esm/transactions/authenticator/index.mjs +1 -1
- package/dist/esm/transactions/authenticator/transaction.d.mts +5 -5
- package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
- package/dist/esm/transactions/index.d.mts +6 -7
- 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 +4 -4
- 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/rawTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rotationProofChallenge.d.mts +2 -1
- package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
- package/dist/esm/transactions/instances/signedTransaction.d.mts +8 -8
- package/dist/esm/transactions/instances/signedTransaction.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 +11 -5
- package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
- package/dist/esm/transactions/management/index.d.mts +11 -12
- package/dist/esm/transactions/management/index.mjs +1 -1
- package/dist/esm/transactions/management/transactionWorker.d.mts +11 -12
- package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/helpers.d.mts +10 -10
- package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/index.d.mts +9 -10
- package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +8 -8
- package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +9 -10
- 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 +9 -9
- package/dist/esm/types/index.d.mts +1 -0
- package/dist/esm/types/index.mjs +1 -1
- package/dist/esm/utils/const.d.mts +1 -2
- 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/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +11 -4
- package/src/api/aptosConfig.ts +11 -2
- package/src/api/digitalAsset.ts +20 -0
- package/src/assetUploader/assetUploader.ts +87 -0
- package/src/assetUploader/index.ts +1 -0
- package/src/assetUploader/irys.ts +102 -0
- package/src/core/account/Account.ts +245 -0
- package/src/core/account/Ed25519Account.ts +88 -0
- package/src/core/account/SingleKeyAccount.ts +120 -0
- package/src/core/account/index.ts +3 -0
- package/src/core/authenticationKey.ts +18 -52
- package/src/core/crypto/ed25519.ts +118 -104
- package/src/core/crypto/index.ts +6 -5
- package/src/core/crypto/multiEd25519.ts +98 -44
- package/src/core/crypto/multiKey.ts +192 -34
- package/src/core/crypto/privateKey.ts +25 -0
- package/src/core/crypto/publicKey.ts +52 -0
- package/src/core/crypto/secp256k1.ts +108 -111
- package/src/core/crypto/signature.ts +46 -0
- package/src/core/crypto/singleKey.ts +180 -0
- package/src/index.ts +1 -0
- package/src/internal/account.ts +5 -3
- package/src/internal/digitalAsset.ts +26 -0
- package/src/internal/queries/currentTokenOwnershipFieldsFragment.graphql +0 -1
- package/src/transactions/authenticator/account.ts +1 -2
- package/src/transactions/instances/rotationProofChallenge.ts +1 -1
- package/src/transactions/transactionBuilder/transactionBuilder.ts +3 -21
- package/src/transactions/types.ts +1 -1
- package/src/types/index.ts +2 -0
- package/src/utils/const.ts +0 -4
- package/src/version.ts +1 -1
- package/dist/browser/index.d.ts +0 -6997
- package/dist/browser/index.global.js +0 -483
- package/dist/browser/index.global.js.map +0 -1
- package/dist/esm/chunk-2QV6HI3M.mjs +0 -2
- package/dist/esm/chunk-2QV6HI3M.mjs.map +0 -1
- package/dist/esm/chunk-7IGH7N52.mjs +0 -2
- package/dist/esm/chunk-7IGH7N52.mjs.map +0 -1
- package/dist/esm/chunk-B2ZKW23W.mjs +0 -2
- package/dist/esm/chunk-CCUD52OF.mjs +0 -2
- package/dist/esm/chunk-CCUD52OF.mjs.map +0 -1
- package/dist/esm/chunk-CVEJHRAU.mjs.map +0 -1
- package/dist/esm/chunk-ENKMOALS.mjs.map +0 -1
- package/dist/esm/chunk-ERWQOVBF.mjs +0 -2
- package/dist/esm/chunk-ERWQOVBF.mjs.map +0 -1
- package/dist/esm/chunk-FBFMQZTM.mjs +0 -2
- package/dist/esm/chunk-FBFMQZTM.mjs.map +0 -1
- package/dist/esm/chunk-FBPNHF54.mjs +0 -2
- package/dist/esm/chunk-FP5DPRYL.mjs +0 -2
- package/dist/esm/chunk-FP5DPRYL.mjs.map +0 -1
- package/dist/esm/chunk-GD4ULEBC.mjs +0 -2
- package/dist/esm/chunk-GD5TZLBF.mjs +0 -2
- package/dist/esm/chunk-HHJBCGAQ.mjs +0 -2
- package/dist/esm/chunk-HHJBCGAQ.mjs.map +0 -1
- package/dist/esm/chunk-I7WRJY7K.mjs +0 -2
- package/dist/esm/chunk-I7WRJY7K.mjs.map +0 -1
- package/dist/esm/chunk-IHCIKE42.mjs +0 -2
- package/dist/esm/chunk-LHJSG5NE.mjs +0 -2
- package/dist/esm/chunk-LHJSG5NE.mjs.map +0 -1
- package/dist/esm/chunk-MEPX7Z2Z.mjs +0 -2
- package/dist/esm/chunk-NWRKJFHV.mjs +0 -2
- package/dist/esm/chunk-O57QZZF2.mjs.map +0 -1
- package/dist/esm/chunk-PPTG6BDV.mjs +0 -2
- package/dist/esm/chunk-QKTV6AZ7.mjs +0 -2
- package/dist/esm/chunk-QRQAR6XO.mjs +0 -2
- package/dist/esm/chunk-S3FBGS3W.mjs +0 -2
- package/dist/esm/chunk-S3FBGS3W.mjs.map +0 -1
- package/dist/esm/chunk-SBMJNU2O.mjs +0 -2
- package/dist/esm/chunk-SBMJNU2O.mjs.map +0 -1
- package/dist/esm/chunk-SRZTA6QH.mjs +0 -2
- package/dist/esm/chunk-UCHGKGCF.mjs +0 -2
- package/dist/esm/chunk-UCHGKGCF.mjs.map +0 -1
- package/dist/esm/chunk-UIVJXLRM.mjs +0 -1
- package/dist/esm/chunk-V6JFR2CB.mjs +0 -2
- package/dist/esm/chunk-V6JFR2CB.mjs.map +0 -1
- package/dist/esm/chunk-VRSUCKJA.mjs +0 -2
- package/dist/esm/chunk-XZYPAQCU.mjs +0 -2
- package/dist/esm/chunk-YL2EDK5M.mjs +0 -2
- package/dist/esm/chunk-YL2EDK5M.mjs.map +0 -1
- package/dist/esm/chunk-ZFIMVSCR.mjs +0 -2
- package/dist/esm/chunk-ZFIMVSCR.mjs.map +0 -1
- package/dist/esm/core/account.d.mts +0 -184
- package/dist/esm/core/account.mjs +0 -2
- package/dist/esm/core/crypto/anyPublicKey.d.mts +0 -59
- package/dist/esm/core/crypto/anyPublicKey.mjs +0 -2
- package/dist/esm/core/crypto/anySignature.d.mts +0 -31
- package/dist/esm/core/crypto/anySignature.mjs +0 -2
- package/dist/esm/core/crypto/asymmetricCrypto.d.mts +0 -74
- package/dist/esm/core/crypto/asymmetricCrypto.mjs +0 -2
- package/src/core/account.ts +0 -282
- package/src/core/crypto/anyPublicKey.ts +0 -92
- package/src/core/crypto/anySignature.ts +0 -56
- package/src/core/crypto/asymmetricCrypto.ts +0 -77
- /package/dist/esm/{chunk-UIVJXLRM.mjs.map → assetUploader/assetUploader.mjs.map} +0 -0
- /package/dist/esm/{core/account.mjs.map → assetUploader/index.mjs.map} +0 -0
- /package/dist/esm/{core/crypto/anyPublicKey.mjs.map → assetUploader/irys.mjs.map} +0 -0
- /package/dist/esm/{chunk-PPTG6BDV.mjs.map → chunk-4LUWUDBX.mjs.map} +0 -0
- /package/dist/esm/{chunk-7D5LHQNS.mjs.map → chunk-5PIO6MFF.mjs.map} +0 -0
- /package/dist/esm/{chunk-VKZCIGKY.mjs.map → chunk-6TUHLGW3.mjs.map} +0 -0
- /package/dist/esm/{chunk-ENDUXRTK.mjs.map → chunk-7KPEDF2R.mjs.map} +0 -0
- /package/dist/esm/{chunk-GD4ULEBC.mjs.map → chunk-AXVVJKE4.mjs.map} +0 -0
- /package/dist/esm/{chunk-NL72WE3E.mjs.map → chunk-BZMO6Q6L.mjs.map} +0 -0
- /package/dist/esm/{chunk-XBVORX5O.mjs.map → chunk-FAAWSTXC.mjs.map} +0 -0
- /package/dist/esm/{chunk-AFPJ2XXN.mjs.map → chunk-FHWAJCJR.mjs.map} +0 -0
- /package/dist/esm/{chunk-VPQ46CAO.mjs.map → chunk-GE7VQ5NZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-6FBKUTGF.mjs.map → chunk-GHYE26Q5.mjs.map} +0 -0
- /package/dist/esm/{chunk-2H5Z5EHH.mjs.map → chunk-HKAJ5N25.mjs.map} +0 -0
- /package/dist/esm/{chunk-PJNPLRPR.mjs.map → chunk-HWTX3HVX.mjs.map} +0 -0
- /package/dist/esm/{chunk-B2ZKW23W.mjs.map → chunk-IFVMIUMO.mjs.map} +0 -0
- /package/dist/esm/{chunk-6SRENFWH.mjs.map → chunk-IMYKTNDV.mjs.map} +0 -0
- /package/dist/esm/{chunk-PMWH5IGI.mjs.map → chunk-ITALFUWD.mjs.map} +0 -0
- /package/dist/esm/{chunk-NWRKJFHV.mjs.map → chunk-JB7ZOUYL.mjs.map} +0 -0
- /package/dist/esm/{chunk-2WFMD6C6.mjs.map → chunk-JMR7G5DT.mjs.map} +0 -0
- /package/dist/esm/{chunk-S64WKSMI.mjs.map → chunk-JOIUR5QW.mjs.map} +0 -0
- /package/dist/esm/{chunk-4OI7MPFH.mjs.map → chunk-K5XJKIFT.mjs.map} +0 -0
- /package/dist/esm/{core/crypto/anySignature.mjs.map → chunk-KUX6GQ2E.mjs.map} +0 -0
- /package/dist/esm/{chunk-Q5HK3U64.mjs.map → chunk-L4PAU62E.mjs.map} +0 -0
- /package/dist/esm/{core/crypto/asymmetricCrypto.mjs.map → chunk-L7ORFGZ7.mjs.map} +0 -0
- /package/dist/esm/{chunk-FBPNHF54.mjs.map → chunk-LG7RJQ57.mjs.map} +0 -0
- /package/dist/esm/{chunk-IHCIKE42.mjs.map → chunk-M6TKSJ4I.mjs.map} +0 -0
- /package/dist/esm/{chunk-2DNPRIS5.mjs.map → chunk-MVWTTVQZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-GD5TZLBF.mjs.map → chunk-NA2H44NE.mjs.map} +0 -0
- /package/dist/esm/{chunk-R56OJ4XC.mjs.map → chunk-NYGCJ6EJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-PIXE7MN5.mjs.map → chunk-NZGON5TY.mjs.map} +0 -0
- /package/dist/esm/{chunk-Y4AKS4CY.mjs.map → chunk-O5Q3RSEJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-LATJGGVX.mjs.map → chunk-PATJMQAG.mjs.map} +0 -0
- /package/dist/esm/{chunk-SXIFL5DQ.mjs.map → chunk-RC5K63LK.mjs.map} +0 -0
- /package/dist/esm/{chunk-QGIJNA37.mjs.map → chunk-SKF6E6X7.mjs.map} +0 -0
- /package/dist/esm/{chunk-QKTV6AZ7.mjs.map → chunk-TWHTXYMB.mjs.map} +0 -0
- /package/dist/esm/{chunk-JQVT2K7G.mjs.map → chunk-UCFIV5UD.mjs.map} +0 -0
- /package/dist/esm/{chunk-JJ6Y35DF.mjs.map → chunk-UFD443TT.mjs.map} +0 -0
- /package/dist/esm/{chunk-M3WNE7MU.mjs.map → chunk-UVTSJ2KP.mjs.map} +0 -0
- /package/dist/esm/{chunk-KJGQ4ILY.mjs.map → chunk-UZ3SFWTM.mjs.map} +0 -0
- /package/dist/esm/{chunk-V2FPYAK7.mjs.map → chunk-VPN3KEVB.mjs.map} +0 -0
- /package/dist/esm/{chunk-QRQAR6XO.mjs.map → chunk-VQM4LMCW.mjs.map} +0 -0
- /package/dist/esm/{chunk-W4UDMBMU.mjs.map → chunk-VWWR2UAQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-F7MOQC7Z.mjs.map → chunk-VZJ62XF7.mjs.map} +0 -0
- /package/dist/esm/{chunk-N4RBQZ2B.mjs.map → chunk-W2XLZW4Y.mjs.map} +0 -0
- /package/dist/esm/{chunk-FRLPX47J.mjs.map → chunk-XH4B5K6W.mjs.map} +0 -0
- /package/dist/esm/{chunk-4M46AWXX.mjs.map → chunk-XSCYT6TT.mjs.map} +0 -0
- /package/dist/esm/{chunk-EUHPML5E.mjs.map → chunk-XSYZX66A.mjs.map} +0 -0
- /package/dist/esm/{chunk-SPOHAEHR.mjs.map → chunk-YTHL7EKV.mjs.map} +0 -0
- /package/dist/esm/{chunk-Q3HAJVCM.mjs.map → chunk-YXUOYXGZ.mjs.map} +0 -0
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import nacl from "tweetnacl";
|
|
5
|
-
import { PublicKey, PrivateKey, Signature } from "./asymmetricCrypto";
|
|
6
5
|
import { Deserializer } from "../../bcs/deserializer";
|
|
7
|
-
import { Serializer } from "../../bcs/serializer";
|
|
6
|
+
import { Serializable, Serializer } from "../../bcs/serializer";
|
|
7
|
+
import { AuthenticationKey } from "../authenticationKey";
|
|
8
8
|
import { Hex } from "../hex";
|
|
9
|
-
import { HexInput } from "../../types";
|
|
9
|
+
import { HexInput, SigningScheme as AuthenticationKeyScheme } from "../../types";
|
|
10
10
|
import { CKDPriv, deriveKey, HARDENED_OFFSET, isValidHardenedPath, mnemonicToSeed, splitPath } from "./hdKey";
|
|
11
|
+
import { PrivateKey } from "./privateKey";
|
|
12
|
+
import { AccountPublicKey, VerifySignatureArgs } from "./publicKey";
|
|
13
|
+
import { Signature } from "./signature";
|
|
11
14
|
|
|
12
15
|
/**
|
|
13
16
|
* Represents the public key of an Ed25519 key pair.
|
|
@@ -18,7 +21,7 @@ import { CKDPriv, deriveKey, HARDENED_OFFSET, isValidHardenedPath, mnemonicToSee
|
|
|
18
21
|
* Ed25519 scheme is represented in the SDK as `Legacy authentication key` and also
|
|
19
22
|
* as `AnyPublicKey` that represents any `Unified authentication key`
|
|
20
23
|
*/
|
|
21
|
-
export class Ed25519PublicKey extends
|
|
24
|
+
export class Ed25519PublicKey extends AccountPublicKey {
|
|
22
25
|
/**
|
|
23
26
|
* Length of an Ed25519 public key
|
|
24
27
|
*/
|
|
@@ -45,6 +48,32 @@ export class Ed25519PublicKey extends PublicKey {
|
|
|
45
48
|
this.key = hex;
|
|
46
49
|
}
|
|
47
50
|
|
|
51
|
+
// region AccountPublicKey
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Verifies a signed data with a public key
|
|
55
|
+
* @param args.message a signed message
|
|
56
|
+
* @param args.signature the signature of the message
|
|
57
|
+
*/
|
|
58
|
+
verifySignature(args: VerifySignatureArgs): boolean {
|
|
59
|
+
const { message, signature } = args;
|
|
60
|
+
if (!(signature instanceof Ed25519Signature)) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const messageBytes = Hex.fromHexInput(message).toUint8Array();
|
|
65
|
+
const signatureBytes = signature.toUint8Array();
|
|
66
|
+
const publicKeyBytes = this.key.toUint8Array();
|
|
67
|
+
return nacl.sign.detached.verify(messageBytes, signatureBytes, publicKeyBytes);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
authKey(): AuthenticationKey {
|
|
71
|
+
return AuthenticationKey.fromSchemeAndBytes({
|
|
72
|
+
scheme: AuthenticationKeyScheme.Ed25519,
|
|
73
|
+
input: this.toUint8Array(),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
48
77
|
/**
|
|
49
78
|
* Get the public key in bytes (Uint8Array).
|
|
50
79
|
*
|
|
@@ -54,26 +83,9 @@ export class Ed25519PublicKey extends PublicKey {
|
|
|
54
83
|
return this.key.toUint8Array();
|
|
55
84
|
}
|
|
56
85
|
|
|
57
|
-
|
|
58
|
-
* Get the public key as a hex string with the 0x prefix.
|
|
59
|
-
*
|
|
60
|
-
* @returns string representation of the public key
|
|
61
|
-
*/
|
|
62
|
-
toString(): string {
|
|
63
|
-
return this.key.toString();
|
|
64
|
-
}
|
|
86
|
+
// endregion
|
|
65
87
|
|
|
66
|
-
|
|
67
|
-
* Verifies a signed data with a public key
|
|
68
|
-
* @param args.message a signed message
|
|
69
|
-
* @param args.signature the signature of the message
|
|
70
|
-
*/
|
|
71
|
-
verifySignature(args: { message: HexInput; signature: Ed25519Signature }): boolean {
|
|
72
|
-
const { message, signature } = args;
|
|
73
|
-
const rawMessage = Hex.fromHexInput(message).toUint8Array();
|
|
74
|
-
const rawSignature = signature.toUint8Array();
|
|
75
|
-
return nacl.sign.detached.verify(rawMessage, rawSignature, this.key.toUint8Array());
|
|
76
|
-
}
|
|
88
|
+
// region Serializable
|
|
77
89
|
|
|
78
90
|
serialize(serializer: Serializer): void {
|
|
79
91
|
serializer.serializeBytes(this.key.toUint8Array());
|
|
@@ -84,13 +96,12 @@ export class Ed25519PublicKey extends PublicKey {
|
|
|
84
96
|
return new Ed25519PublicKey(bytes);
|
|
85
97
|
}
|
|
86
98
|
|
|
87
|
-
|
|
88
|
-
const bytes = deserializer.deserializeBytes();
|
|
89
|
-
return new Ed25519PublicKey(bytes);
|
|
90
|
-
}
|
|
99
|
+
// endregion
|
|
91
100
|
|
|
92
|
-
|
|
93
|
-
|
|
101
|
+
/**
|
|
102
|
+
* @deprecated use `instanceof Ed25519PublicKey` instead.
|
|
103
|
+
*/
|
|
104
|
+
static isPublicKey(publicKey: AccountPublicKey): publicKey is Ed25519PublicKey {
|
|
94
105
|
return publicKey instanceof Ed25519PublicKey;
|
|
95
106
|
}
|
|
96
107
|
}
|
|
@@ -98,7 +109,7 @@ export class Ed25519PublicKey extends PublicKey {
|
|
|
98
109
|
/**
|
|
99
110
|
* Represents the private key of an Ed25519 key pair.
|
|
100
111
|
*/
|
|
101
|
-
export class Ed25519PrivateKey extends PrivateKey {
|
|
112
|
+
export class Ed25519PrivateKey extends Serializable implements PrivateKey {
|
|
102
113
|
/**
|
|
103
114
|
* Length of an Ed25519 private key
|
|
104
115
|
*/
|
|
@@ -116,6 +127,8 @@ export class Ed25519PrivateKey extends PrivateKey {
|
|
|
116
127
|
*/
|
|
117
128
|
private readonly signingKeyPair: nacl.SignKeyPair;
|
|
118
129
|
|
|
130
|
+
// region Constructors
|
|
131
|
+
|
|
119
132
|
/**
|
|
120
133
|
* Create a new PrivateKey instance from a Uint8Array or String.
|
|
121
134
|
*
|
|
@@ -133,45 +146,6 @@ export class Ed25519PrivateKey extends PrivateKey {
|
|
|
133
146
|
this.signingKeyPair = nacl.sign.keyPair.fromSeed(privateKeyHex.toUint8Array().slice(0, Ed25519PrivateKey.LENGTH));
|
|
134
147
|
}
|
|
135
148
|
|
|
136
|
-
/**
|
|
137
|
-
* Get the private key in bytes (Uint8Array).
|
|
138
|
-
*
|
|
139
|
-
* @returns Uint8Array representation of the private key
|
|
140
|
-
*/
|
|
141
|
-
toUint8Array(): Uint8Array {
|
|
142
|
-
return this.signingKeyPair.secretKey.slice(0, Ed25519PrivateKey.LENGTH);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Get the private key as a hex string with the 0x prefix.
|
|
147
|
-
*
|
|
148
|
-
* @returns string representation of the private key
|
|
149
|
-
*/
|
|
150
|
-
toString(): string {
|
|
151
|
-
return Hex.fromHexInput(this.toUint8Array()).toString();
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Sign the given message with the private key.
|
|
156
|
-
*
|
|
157
|
-
* @param message in HexInput format
|
|
158
|
-
* @returns Signature
|
|
159
|
-
*/
|
|
160
|
-
sign(message: HexInput): Ed25519Signature {
|
|
161
|
-
const hex = Hex.fromHexInput(message);
|
|
162
|
-
const signature = nacl.sign.detached(hex.toUint8Array(), this.signingKeyPair.secretKey);
|
|
163
|
-
return new Ed25519Signature(signature);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
serialize(serializer: Serializer): void {
|
|
167
|
-
serializer.serializeBytes(this.toUint8Array());
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
static deserialize(deserializer: Deserializer): Ed25519PrivateKey {
|
|
171
|
-
const bytes = deserializer.deserializeBytes();
|
|
172
|
-
return new Ed25519PrivateKey(bytes);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
149
|
/**
|
|
176
150
|
* Generate a new random private key.
|
|
177
151
|
*
|
|
@@ -182,16 +156,6 @@ export class Ed25519PrivateKey extends PrivateKey {
|
|
|
182
156
|
return new Ed25519PrivateKey(keyPair.secretKey.slice(0, Ed25519PrivateKey.LENGTH));
|
|
183
157
|
}
|
|
184
158
|
|
|
185
|
-
/**
|
|
186
|
-
* Derive the Ed25519PublicKey for this private key.
|
|
187
|
-
*
|
|
188
|
-
* @returns Ed25519PublicKey
|
|
189
|
-
*/
|
|
190
|
-
publicKey(): Ed25519PublicKey {
|
|
191
|
-
const bytes = this.signingKeyPair.publicKey;
|
|
192
|
-
return new Ed25519PublicKey(bytes);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
159
|
/**
|
|
196
160
|
* Derives a private key from a mnemonic seed phrase.
|
|
197
161
|
*
|
|
@@ -232,6 +196,68 @@ export class Ed25519PrivateKey extends PrivateKey {
|
|
|
232
196
|
return new Ed25519PrivateKey(privateKey);
|
|
233
197
|
}
|
|
234
198
|
|
|
199
|
+
// endregion
|
|
200
|
+
|
|
201
|
+
// region PrivateKey
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Derive the Ed25519PublicKey for this private key.
|
|
205
|
+
*
|
|
206
|
+
* @returns Ed25519PublicKey
|
|
207
|
+
*/
|
|
208
|
+
publicKey(): Ed25519PublicKey {
|
|
209
|
+
const bytes = this.signingKeyPair.publicKey;
|
|
210
|
+
return new Ed25519PublicKey(bytes);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Sign the given message with the private key.
|
|
215
|
+
*
|
|
216
|
+
* @param message in HexInput format
|
|
217
|
+
* @returns Signature
|
|
218
|
+
*/
|
|
219
|
+
sign(message: HexInput): Ed25519Signature {
|
|
220
|
+
const messageBytes = Hex.fromHexInput(message).toUint8Array();
|
|
221
|
+
const signatureBytes = nacl.sign.detached(messageBytes, this.signingKeyPair.secretKey);
|
|
222
|
+
return new Ed25519Signature(signatureBytes);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Get the private key in bytes (Uint8Array).
|
|
227
|
+
*
|
|
228
|
+
* @returns Uint8Array representation of the private key
|
|
229
|
+
*/
|
|
230
|
+
toUint8Array(): Uint8Array {
|
|
231
|
+
return this.signingKeyPair.secretKey.slice(0, Ed25519PrivateKey.LENGTH);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Get the private key as a hex string with the 0x prefix.
|
|
236
|
+
*
|
|
237
|
+
* @returns string representation of the private key
|
|
238
|
+
*/
|
|
239
|
+
toString(): string {
|
|
240
|
+
return Hex.fromHexInput(this.toUint8Array()).toString();
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// endregion
|
|
244
|
+
|
|
245
|
+
// region Serializable
|
|
246
|
+
|
|
247
|
+
serialize(serializer: Serializer): void {
|
|
248
|
+
serializer.serializeBytes(this.toUint8Array());
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
static deserialize(deserializer: Deserializer): Ed25519PrivateKey {
|
|
252
|
+
const bytes = deserializer.deserializeBytes();
|
|
253
|
+
return new Ed25519PrivateKey(bytes);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// endregion
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* @deprecated use `instanceof Ed25519PrivateKey` instead.
|
|
260
|
+
*/
|
|
235
261
|
static isPrivateKey(privateKey: PrivateKey): privateKey is Ed25519PrivateKey {
|
|
236
262
|
return privateKey instanceof Ed25519PrivateKey;
|
|
237
263
|
}
|
|
@@ -252,33 +278,28 @@ export class Ed25519Signature extends Signature {
|
|
|
252
278
|
*/
|
|
253
279
|
private readonly data: Hex;
|
|
254
280
|
|
|
281
|
+
// region Constructors
|
|
282
|
+
|
|
255
283
|
constructor(hexInput: HexInput) {
|
|
256
284
|
super();
|
|
257
|
-
const
|
|
258
|
-
if (
|
|
285
|
+
const data = Hex.fromHexInput(hexInput);
|
|
286
|
+
if (data.toUint8Array().length !== Ed25519Signature.LENGTH) {
|
|
259
287
|
throw new Error(`Signature length should be ${Ed25519Signature.LENGTH}`);
|
|
260
288
|
}
|
|
261
|
-
|
|
262
|
-
this.data = hex;
|
|
289
|
+
this.data = data;
|
|
263
290
|
}
|
|
264
291
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
*/
|
|
292
|
+
// endregion
|
|
293
|
+
|
|
294
|
+
// region Signature
|
|
295
|
+
|
|
270
296
|
toUint8Array(): Uint8Array {
|
|
271
297
|
return this.data.toUint8Array();
|
|
272
298
|
}
|
|
273
299
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
* @returns string representation of the signature
|
|
278
|
-
*/
|
|
279
|
-
toString(): string {
|
|
280
|
-
return this.data.toString();
|
|
281
|
-
}
|
|
300
|
+
// endregion
|
|
301
|
+
|
|
302
|
+
// region Serializable
|
|
282
303
|
|
|
283
304
|
serialize(serializer: Serializer): void {
|
|
284
305
|
serializer.serializeBytes(this.data.toUint8Array());
|
|
@@ -289,12 +310,5 @@ export class Ed25519Signature extends Signature {
|
|
|
289
310
|
return new Ed25519Signature(bytes);
|
|
290
311
|
}
|
|
291
312
|
|
|
292
|
-
|
|
293
|
-
const bytes = deserializer.deserializeBytes();
|
|
294
|
-
return new Ed25519Signature(bytes);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
static isSignature(signature: Signature): signature is Ed25519Signature {
|
|
298
|
-
return signature instanceof Ed25519Signature;
|
|
299
|
-
}
|
|
313
|
+
// endregion
|
|
300
314
|
}
|
package/src/core/crypto/index.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// Copyright © Aptos Foundation
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
export * from "./asymmetricCrypto";
|
|
5
4
|
export * from "./ed25519";
|
|
5
|
+
export * from "./hdKey";
|
|
6
6
|
export * from "./multiEd25519";
|
|
7
|
-
export * from "./secp256k1";
|
|
8
7
|
export * from "./multiKey";
|
|
9
|
-
export * from "./
|
|
10
|
-
export * from "./
|
|
11
|
-
export * from "./
|
|
8
|
+
export * from "./privateKey";
|
|
9
|
+
export * from "./publicKey";
|
|
10
|
+
export * from "./secp256k1";
|
|
11
|
+
export * from "./signature";
|
|
12
|
+
export * from "./singleKey";
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
// Copyright © Aptos Foundation
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { Deserializer, Serializer } from "../../bcs";
|
|
5
|
+
import { SigningScheme as AuthenticationKeyScheme } from "../../types";
|
|
6
|
+
import { AuthenticationKey } from "../authenticationKey";
|
|
7
7
|
import { Ed25519PublicKey, Ed25519Signature } from "./ed25519";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { AccountPublicKey, VerifySignatureArgs } from "./publicKey";
|
|
9
|
+
import { Signature } from "./signature";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Represents the public key of a K-of-N Ed25519 multi-sig transaction.
|
|
13
13
|
*/
|
|
14
|
-
export class MultiEd25519PublicKey extends
|
|
14
|
+
export class MultiEd25519PublicKey extends AccountPublicKey {
|
|
15
15
|
/**
|
|
16
16
|
* Maximum number of public keys supported
|
|
17
17
|
*/
|
|
@@ -28,7 +28,7 @@ export class MultiEd25519PublicKey extends PublicKey {
|
|
|
28
28
|
static readonly MIN_THRESHOLD = 1;
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
* List of Ed25519 public keys for this
|
|
31
|
+
* List of Ed25519 public keys for this LegacyMultiEd25519PublicKey
|
|
32
32
|
*/
|
|
33
33
|
public readonly publicKeys: Ed25519PublicKey[];
|
|
34
34
|
|
|
@@ -50,13 +50,13 @@ export class MultiEd25519PublicKey extends PublicKey {
|
|
|
50
50
|
*/
|
|
51
51
|
constructor(args: { publicKeys: Ed25519PublicKey[]; threshold: number }) {
|
|
52
52
|
super();
|
|
53
|
-
|
|
54
53
|
const { publicKeys, threshold } = args;
|
|
55
54
|
|
|
56
55
|
// Validate number of public keys
|
|
57
56
|
if (publicKeys.length > MultiEd25519PublicKey.MAX_KEYS || publicKeys.length < MultiEd25519PublicKey.MIN_KEYS) {
|
|
58
57
|
throw new Error(
|
|
59
|
-
`Must have between ${MultiEd25519PublicKey.MIN_KEYS} and
|
|
58
|
+
`Must have between ${MultiEd25519PublicKey.MIN_KEYS} and ` +
|
|
59
|
+
`${MultiEd25519PublicKey.MAX_KEYS} public keys, inclusive`,
|
|
60
60
|
);
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -71,6 +71,50 @@ export class MultiEd25519PublicKey extends PublicKey {
|
|
|
71
71
|
this.threshold = threshold;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
// region AccountPublicKey
|
|
75
|
+
|
|
76
|
+
verifySignature(args: VerifySignatureArgs): boolean {
|
|
77
|
+
const { message, signature } = args;
|
|
78
|
+
if (!(signature instanceof MultiEd25519Signature)) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const indices: number[] = [];
|
|
83
|
+
for (let i = 0; i < 4; i += 1) {
|
|
84
|
+
for (let j = 0; j < 8; j += 1) {
|
|
85
|
+
// eslint-disable-next-line no-bitwise
|
|
86
|
+
const bitIsSet = (signature.bitmap[i] & (1 << (7 - j))) !== 0;
|
|
87
|
+
if (bitIsSet) {
|
|
88
|
+
const index = i * 8 + j;
|
|
89
|
+
indices.push(index);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (indices.length !== signature.signatures.length) {
|
|
95
|
+
throw new Error("Bitmap and signatures length mismatch");
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (indices.length < this.threshold) {
|
|
99
|
+
throw new Error("Not enough signatures");
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
for (let i = 0; i < indices.length; i += 1) {
|
|
103
|
+
const publicKey = this.publicKeys[indices[i]];
|
|
104
|
+
if (!publicKey.verifySignature({ message, signature: signature.signatures[i] })) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
authKey(): AuthenticationKey {
|
|
112
|
+
return AuthenticationKey.fromSchemeAndBytes({
|
|
113
|
+
scheme: AuthenticationKeyScheme.MultiEd25519,
|
|
114
|
+
input: this.toUint8Array(),
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
74
118
|
/**
|
|
75
119
|
* Converts a PublicKeys into Uint8Array (bytes) with: bytes = p1_bytes | ... | pn_bytes | threshold
|
|
76
120
|
*/
|
|
@@ -85,14 +129,9 @@ export class MultiEd25519PublicKey extends PublicKey {
|
|
|
85
129
|
return bytes;
|
|
86
130
|
}
|
|
87
131
|
|
|
88
|
-
|
|
89
|
-
return Hex.fromHexInput(this.toUint8Array()).toString();
|
|
90
|
-
}
|
|
132
|
+
// endregion
|
|
91
133
|
|
|
92
|
-
//
|
|
93
|
-
verifySignature(args: { message: HexInput; signature: MultiEd25519Signature }): boolean {
|
|
94
|
-
throw new Error("TODO - Method not implemented.");
|
|
95
|
-
}
|
|
134
|
+
// region Serializable
|
|
96
135
|
|
|
97
136
|
serialize(serializer: Serializer): void {
|
|
98
137
|
serializer.serializeBytes(this.toUint8Array());
|
|
@@ -110,6 +149,8 @@ export class MultiEd25519PublicKey extends PublicKey {
|
|
|
110
149
|
}
|
|
111
150
|
return new MultiEd25519PublicKey({ publicKeys: keys, threshold });
|
|
112
151
|
}
|
|
152
|
+
|
|
153
|
+
// endregion
|
|
113
154
|
}
|
|
114
155
|
|
|
115
156
|
/**
|
|
@@ -146,26 +187,33 @@ export class MultiEd25519Signature extends Signature {
|
|
|
146
187
|
*
|
|
147
188
|
* @param args.signatures A list of signatures
|
|
148
189
|
* @param args.bitmap 4 bytes, at most 32 signatures are supported. If Nth bit value is `1`, the Nth
|
|
149
|
-
* signature should be provided in `signatures`. Bits are read from left to right
|
|
190
|
+
* signature should be provided in `signatures`. Bits are read from left to right.
|
|
191
|
+
* Alternatively, you can specify an array of bitmap positions.
|
|
192
|
+
* Valid position should range between 0 and 31.
|
|
193
|
+
* @see MultiEd25519Signature.createBitmap
|
|
150
194
|
*/
|
|
151
|
-
constructor(args: { signatures: Ed25519Signature[]; bitmap: Uint8Array }) {
|
|
195
|
+
constructor(args: { signatures: Ed25519Signature[]; bitmap: Uint8Array | number[] }) {
|
|
152
196
|
super();
|
|
153
|
-
|
|
154
197
|
const { signatures, bitmap } = args;
|
|
155
|
-
if (bitmap.length !== MultiEd25519Signature.BITMAP_LEN) {
|
|
156
|
-
throw new Error(`"bitmap" length should be ${MultiEd25519Signature.BITMAP_LEN}`);
|
|
157
|
-
}
|
|
158
198
|
|
|
159
199
|
if (signatures.length > MultiEd25519Signature.MAX_SIGNATURES_SUPPORTED) {
|
|
160
200
|
throw new Error(
|
|
161
201
|
`The number of signatures cannot be greater than ${MultiEd25519Signature.MAX_SIGNATURES_SUPPORTED}`,
|
|
162
202
|
);
|
|
163
203
|
}
|
|
164
|
-
|
|
165
204
|
this.signatures = signatures;
|
|
166
|
-
|
|
205
|
+
|
|
206
|
+
if (!(bitmap instanceof Uint8Array)) {
|
|
207
|
+
this.bitmap = MultiEd25519Signature.createBitmap({ bits: bitmap });
|
|
208
|
+
} else if (bitmap.length !== MultiEd25519Signature.BITMAP_LEN) {
|
|
209
|
+
throw new Error(`"bitmap" length should be ${MultiEd25519Signature.BITMAP_LEN}`);
|
|
210
|
+
} else {
|
|
211
|
+
this.bitmap = bitmap;
|
|
212
|
+
}
|
|
167
213
|
}
|
|
168
214
|
|
|
215
|
+
// region AccountSignature
|
|
216
|
+
|
|
169
217
|
/**
|
|
170
218
|
* Converts a MultiSignature into Uint8Array (bytes) with `bytes = s1_bytes | ... | sn_bytes | bitmap`
|
|
171
219
|
*/
|
|
@@ -180,10 +228,29 @@ export class MultiEd25519Signature extends Signature {
|
|
|
180
228
|
return bytes;
|
|
181
229
|
}
|
|
182
230
|
|
|
183
|
-
|
|
184
|
-
|
|
231
|
+
// endregion
|
|
232
|
+
|
|
233
|
+
// region Serializable
|
|
234
|
+
|
|
235
|
+
serialize(serializer: Serializer): void {
|
|
236
|
+
serializer.serializeBytes(this.toUint8Array());
|
|
185
237
|
}
|
|
186
238
|
|
|
239
|
+
static deserialize(deserializer: Deserializer): MultiEd25519Signature {
|
|
240
|
+
const bytes = deserializer.deserializeBytes();
|
|
241
|
+
const bitmap = bytes.subarray(bytes.length - 4);
|
|
242
|
+
|
|
243
|
+
const signatures: Ed25519Signature[] = [];
|
|
244
|
+
|
|
245
|
+
for (let i = 0; i < bytes.length - bitmap.length; i += Ed25519Signature.LENGTH) {
|
|
246
|
+
const begin = i;
|
|
247
|
+
signatures.push(new Ed25519Signature(bytes.subarray(begin, begin + Ed25519Signature.LENGTH)));
|
|
248
|
+
}
|
|
249
|
+
return new MultiEd25519Signature({ signatures, bitmap });
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// endregion
|
|
253
|
+
|
|
187
254
|
/**
|
|
188
255
|
* Helper method to create a bitmap out of the specified bit positions
|
|
189
256
|
* @param args.bits The bitmap positions that should be set. A position starts at index 0.
|
|
@@ -208,7 +275,7 @@ export class MultiEd25519Signature extends Signature {
|
|
|
208
275
|
// Check if duplicates exist in bits
|
|
209
276
|
const dupCheckSet = new Set();
|
|
210
277
|
|
|
211
|
-
bits.forEach((bit: number) => {
|
|
278
|
+
bits.forEach((bit: number, index) => {
|
|
212
279
|
if (bit >= MultiEd25519Signature.MAX_SIGNATURES_SUPPORTED) {
|
|
213
280
|
throw new Error(`Cannot have a signature larger than ${MultiEd25519Signature.MAX_SIGNATURES_SUPPORTED - 1}.`);
|
|
214
281
|
}
|
|
@@ -217,6 +284,10 @@ export class MultiEd25519Signature extends Signature {
|
|
|
217
284
|
throw new Error("Duplicate bits detected.");
|
|
218
285
|
}
|
|
219
286
|
|
|
287
|
+
if (index > 0 && bit <= bits[index - 1]) {
|
|
288
|
+
throw new Error("The bits need to be sorted in ascending order.");
|
|
289
|
+
}
|
|
290
|
+
|
|
220
291
|
dupCheckSet.add(bit);
|
|
221
292
|
|
|
222
293
|
const byteOffset = Math.floor(bit / 8);
|
|
@@ -231,21 +302,4 @@ export class MultiEd25519Signature extends Signature {
|
|
|
231
302
|
|
|
232
303
|
return bitmap;
|
|
233
304
|
}
|
|
234
|
-
|
|
235
|
-
serialize(serializer: Serializer): void {
|
|
236
|
-
serializer.serializeBytes(this.toUint8Array());
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
static deserialize(deserializer: Deserializer): MultiEd25519Signature {
|
|
240
|
-
const bytes = deserializer.deserializeBytes();
|
|
241
|
-
const bitmap = bytes.subarray(bytes.length - 4);
|
|
242
|
-
|
|
243
|
-
const signatures: Ed25519Signature[] = [];
|
|
244
|
-
|
|
245
|
-
for (let i = 0; i < bytes.length - bitmap.length; i += Ed25519Signature.LENGTH) {
|
|
246
|
-
const begin = i;
|
|
247
|
-
signatures.push(new Ed25519Signature(bytes.subarray(begin, begin + Ed25519Signature.LENGTH)));
|
|
248
|
-
}
|
|
249
|
-
return new MultiEd25519Signature({ signatures, bitmap });
|
|
250
|
-
}
|
|
251
305
|
}
|