@aptos-labs/ts-sdk 1.7.0 → 1.9.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/browser/index.d.ts +1226 -975
- package/dist/browser/index.global.js +32 -30
- package/dist/browser/index.global.js.map +1 -1
- package/dist/common/index.d.ts +1226 -975
- package/dist/common/index.js +27 -25
- 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.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.d.mts +14 -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/bcs/index.mjs +1 -1
- package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
- package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
- package/dist/esm/chunk-2E2JOGE5.mjs +2 -0
- package/dist/esm/chunk-2E2JOGE5.mjs.map +1 -0
- package/dist/esm/chunk-3EUOBVCT.mjs +2 -0
- package/dist/esm/{chunk-A2QH4A6D.mjs.map → chunk-3EUOBVCT.mjs.map} +1 -1
- package/dist/esm/{chunk-RNO5ZG3C.mjs → chunk-52RTAMN7.mjs} +2 -2
- package/dist/esm/chunk-7BDYKJXX.mjs +2 -0
- package/dist/esm/chunk-7BDYKJXX.mjs.map +1 -0
- package/dist/esm/{chunk-WQI2RH2S.mjs → chunk-7U36LMP4.mjs} +2 -2
- package/dist/esm/{chunk-NWRKJFHV.mjs → chunk-ARIC32W7.mjs} +2 -2
- package/dist/esm/{chunk-RIL4SHXC.mjs → chunk-B7M3OWHV.mjs} +2 -2
- package/dist/esm/{chunk-C7ZX475J.mjs → chunk-BBUAAJRA.mjs} +2 -2
- package/dist/esm/chunk-C3HM7HQP.mjs +2 -0
- package/dist/esm/chunk-C3HM7HQP.mjs.map +1 -0
- package/dist/esm/{chunk-DRF6AMEZ.mjs → chunk-CHA5DSSD.mjs} +2 -2
- package/dist/esm/chunk-CVEJHRAU.mjs +2 -0
- package/dist/esm/chunk-CVEJHRAU.mjs.map +1 -0
- package/dist/esm/chunk-DE5OOOVY.mjs +2 -0
- package/dist/esm/{chunk-3UYBNX3P.mjs.map → chunk-DE5OOOVY.mjs.map} +1 -1
- package/dist/esm/{chunk-IKCBGNRD.mjs → chunk-DGOT2VR5.mjs} +2 -2
- package/dist/esm/{chunk-GVHOHNHT.mjs → chunk-EF2F7NWO.mjs} +2 -2
- package/dist/esm/{chunk-J6RCCKOA.mjs → chunk-EQZ757ES.mjs} +2 -2
- package/dist/esm/{chunk-CX5ULWJQ.mjs → chunk-F67Y7YH6.mjs} +2 -2
- package/dist/esm/{chunk-JLL7BCD4.mjs → chunk-FVMVV4V3.mjs} +2 -2
- package/dist/esm/chunk-FWDKABRW.mjs +2 -0
- package/dist/esm/chunk-FWDKABRW.mjs.map +1 -0
- package/dist/esm/chunk-G62HQC77.mjs +2 -0
- package/dist/esm/chunk-G62HQC77.mjs.map +1 -0
- package/dist/esm/{chunk-ESX5X52V.mjs → chunk-GQOOXOTN.mjs} +2 -2
- package/dist/esm/chunk-GRJJBGHT.mjs +2 -0
- package/dist/esm/chunk-GRJJBGHT.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-XQIWF5HY.mjs → chunk-I3TCHVQQ.mjs} +2 -2
- package/dist/esm/{chunk-3NOQE6U3.mjs → chunk-ILJWEPDW.mjs} +2 -2
- package/dist/esm/chunk-INORE66K.mjs +2 -0
- package/dist/esm/chunk-INORE66K.mjs.map +1 -0
- package/dist/esm/{chunk-5L6SRCJP.mjs → chunk-J6MWD4XN.mjs} +2 -2
- package/dist/esm/{chunk-YGMT4GQ5.mjs → chunk-JEHR6GKW.mjs} +2 -2
- package/dist/esm/chunk-JEHR6GKW.mjs.map +1 -0
- package/dist/esm/chunk-KUX6GQ2E.mjs +1 -0
- package/dist/esm/{chunk-6UNBJAV6.mjs → chunk-KWJTVJ7C.mjs} +2 -2
- package/dist/esm/chunk-KWJTVJ7C.mjs.map +1 -0
- package/dist/esm/{chunk-WK36MJRI.mjs → chunk-LLL2LFYH.mjs} +2 -2
- package/dist/esm/chunk-LMXP3JUU.mjs +2 -0
- package/dist/esm/chunk-LMXP3JUU.mjs.map +1 -0
- package/dist/esm/{chunk-5WXR2O3T.mjs → chunk-N65SOKJQ.mjs} +2 -2
- package/dist/esm/{chunk-XOBXX273.mjs → chunk-NL3XVNS5.mjs} +2 -2
- package/dist/esm/{chunk-Q7JKS6WV.mjs → chunk-NURFZOR4.mjs} +2 -2
- package/dist/esm/{chunk-MKERJNYN.mjs → chunk-OG56TYZE.mjs} +2 -2
- package/dist/esm/chunk-Q6WOHF4A.mjs +2 -0
- package/dist/esm/chunk-Q6WOHF4A.mjs.map +1 -0
- package/dist/esm/chunk-QA4XWNIH.mjs +2 -0
- package/dist/esm/chunk-QA4XWNIH.mjs.map +1 -0
- package/dist/esm/chunk-QE4ASJ5K.mjs +1 -0
- package/dist/esm/chunk-QR72RXBS.mjs +2 -0
- package/dist/esm/chunk-QR72RXBS.mjs.map +1 -0
- package/dist/esm/{chunk-TVURQPLA.mjs → chunk-R4VJDSIP.mjs} +2 -2
- package/dist/esm/{chunk-O57QZZF2.mjs → chunk-S2F6CSH4.mjs} +2 -2
- package/dist/esm/chunk-S2F6CSH4.mjs.map +1 -0
- package/dist/esm/{chunk-BQSE5HHW.mjs → chunk-S4SEFF4K.mjs} +3 -1
- package/dist/esm/chunk-S4SEFF4K.mjs.map +1 -0
- package/dist/esm/{chunk-OVSV4Y32.mjs → chunk-SXIFL5DQ.mjs} +2 -2
- package/dist/esm/{chunk-OVSV4Y32.mjs.map → chunk-SXIFL5DQ.mjs.map} +1 -1
- package/dist/esm/{chunk-Z6XNTGNK.mjs → chunk-TN5BUH4F.mjs} +2 -2
- package/dist/esm/chunk-TNVR7SNR.mjs +2 -0
- package/dist/esm/chunk-TNVR7SNR.mjs.map +1 -0
- package/dist/esm/chunk-TX7UK75Q.mjs +2 -0
- package/dist/esm/chunk-TX7UK75Q.mjs.map +1 -0
- package/dist/esm/{chunk-YE3DZD6T.mjs → chunk-UIUSDBCL.mjs} +2 -2
- package/dist/esm/{chunk-7JTOGYO7.mjs → chunk-UMLDKLDL.mjs} +2 -2
- package/dist/esm/chunk-UVSRX4SV.mjs +1 -0
- package/dist/esm/{chunk-6Y3VBRMN.mjs → chunk-VEVBHH3M.mjs} +2 -2
- package/dist/esm/{chunk-T5IFXLOP.mjs → chunk-VMXBMAYK.mjs} +2 -2
- package/dist/esm/chunk-WKUXBIYB.mjs +2 -0
- package/dist/esm/chunk-WKUXBIYB.mjs.map +1 -0
- package/dist/esm/chunk-WME5D6YR.mjs +2 -0
- package/dist/esm/chunk-WME5D6YR.mjs.map +1 -0
- package/dist/esm/chunk-WTHNSNAX.mjs +2 -0
- package/dist/esm/chunk-WTHNSNAX.mjs.map +1 -0
- package/dist/esm/{chunk-WC2WSKYZ.mjs → chunk-X5C3LYI7.mjs} +2 -2
- package/dist/esm/chunk-XKD7W5NO.mjs +2 -0
- package/dist/esm/{chunk-UJAX75ON.mjs.map → chunk-XKD7W5NO.mjs.map} +1 -1
- package/dist/esm/{chunk-OWZLBIDD.mjs → chunk-XTPFQ4MH.mjs} +2 -2
- package/dist/esm/{chunk-D2GNCG27.mjs → chunk-Y5AJLNUD.mjs} +2 -2
- package/dist/esm/chunk-YDAA4RG4.mjs +2 -0
- package/dist/esm/chunk-YDAA4RG4.mjs.map +1 -0
- package/dist/esm/{chunk-ZFPA45OK.mjs → chunk-YR2R3LW4.mjs} +2 -2
- package/dist/esm/chunk-YZZO6VDC.mjs +2 -0
- package/dist/esm/chunk-YZZO6VDC.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/core/account/Account.d.mts +20 -0
- package/dist/esm/core/account/Account.mjs +2 -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/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/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/index.d.mts +9 -8
- package/dist/esm/core/index.mjs +1 -1
- package/dist/esm/index.d.mts +9 -9
- 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 +9 -9
- package/dist/esm/internal/coin.mjs +1 -1
- package/dist/esm/internal/digitalAsset.d.mts +15 -12
- package/dist/esm/internal/digitalAsset.mjs +1 -1
- package/dist/esm/internal/event.d.mts +7 -2
- 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 +9 -10
- package/dist/esm/internal/fungibleAsset.mjs +1 -1
- package/dist/esm/internal/general.mjs +1 -1
- 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 +10 -11
- package/dist/esm/internal/transactionSubmission.mjs +1 -1
- package/dist/esm/publicKey-lq5djCIY.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/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/generated/operations.d.mts +6 -0
- package/dist/esm/types/generated/queries.d.mts +6 -6
- package/dist/esm/types/generated/queries.mjs +1 -1
- package/dist/esm/types/generated/types.d.mts +594 -56
- package/dist/esm/types/generated/types.mjs +1 -1
- package/dist/esm/types/generated/types.mjs.map +1 -1
- package/dist/esm/types/index.d.mts +35 -6
- 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 +16 -16
- package/src/api/aptosConfig.ts +2 -2
- package/src/api/digitalAsset.ts +20 -0
- package/src/api/event.ts +27 -1
- 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/internal/account.ts +5 -3
- package/src/internal/digitalAsset.ts +26 -0
- package/src/internal/event.ts +33 -1
- package/src/internal/queries/currentTokenOwnershipFieldsFragment.graphql +1 -0
- package/src/internal/queries/getTokenData.graphql +1 -0
- 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/generated/operations.ts +6 -0
- package/src/types/generated/queries.ts +2 -0
- package/src/types/generated/types.ts +662 -55
- package/src/types/index.ts +40 -4
- package/src/utils/const.ts +0 -4
- package/src/version.ts +1 -1
- package/dist/esm/chunk-2QV6HI3M.mjs +0 -2
- package/dist/esm/chunk-2QV6HI3M.mjs.map +0 -1
- package/dist/esm/chunk-3UYBNX3P.mjs +0 -2
- package/dist/esm/chunk-4SAUEZTN.mjs +0 -2
- package/dist/esm/chunk-4SAUEZTN.mjs.map +0 -1
- package/dist/esm/chunk-6UNBJAV6.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-A2QH4A6D.mjs +0 -2
- package/dist/esm/chunk-AA3GRJNL.mjs +0 -2
- package/dist/esm/chunk-AA3GRJNL.mjs.map +0 -1
- package/dist/esm/chunk-ALFESCPU.mjs +0 -2
- package/dist/esm/chunk-ALFESCPU.mjs.map +0 -1
- package/dist/esm/chunk-BQSE5HHW.mjs.map +0 -1
- package/dist/esm/chunk-CCUD52OF.mjs +0 -2
- package/dist/esm/chunk-CCUD52OF.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-FP5DPRYL.mjs +0 -2
- package/dist/esm/chunk-FP5DPRYL.mjs.map +0 -1
- 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-INV6U3KS.mjs +0 -2
- package/dist/esm/chunk-INV6U3KS.mjs.map +0 -1
- package/dist/esm/chunk-O57QZZF2.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-SZYATFM7.mjs +0 -2
- package/dist/esm/chunk-SZYATFM7.mjs.map +0 -1
- 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-UJAX75ON.mjs +0 -2
- package/dist/esm/chunk-V6JFR2CB.mjs +0 -2
- package/dist/esm/chunk-V6JFR2CB.mjs.map +0 -1
- package/dist/esm/chunk-YGMT4GQ5.mjs.map +0 -1
- package/dist/esm/chunk-ZFIMVSCR.mjs +0 -2
- package/dist/esm/chunk-ZFIMVSCR.mjs.map +0 -1
- package/dist/esm/chunk-ZIZ7PVK2.mjs +0 -2
- package/dist/esm/chunk-ZIZ7PVK2.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-RNO5ZG3C.mjs.map → chunk-52RTAMN7.mjs.map} +0 -0
- /package/dist/esm/{chunk-WQI2RH2S.mjs.map → chunk-7U36LMP4.mjs.map} +0 -0
- /package/dist/esm/{chunk-NWRKJFHV.mjs.map → chunk-ARIC32W7.mjs.map} +0 -0
- /package/dist/esm/{chunk-RIL4SHXC.mjs.map → chunk-B7M3OWHV.mjs.map} +0 -0
- /package/dist/esm/{chunk-C7ZX475J.mjs.map → chunk-BBUAAJRA.mjs.map} +0 -0
- /package/dist/esm/{chunk-DRF6AMEZ.mjs.map → chunk-CHA5DSSD.mjs.map} +0 -0
- /package/dist/esm/{chunk-IKCBGNRD.mjs.map → chunk-DGOT2VR5.mjs.map} +0 -0
- /package/dist/esm/{chunk-GVHOHNHT.mjs.map → chunk-EF2F7NWO.mjs.map} +0 -0
- /package/dist/esm/{chunk-J6RCCKOA.mjs.map → chunk-EQZ757ES.mjs.map} +0 -0
- /package/dist/esm/{chunk-CX5ULWJQ.mjs.map → chunk-F67Y7YH6.mjs.map} +0 -0
- /package/dist/esm/{chunk-JLL7BCD4.mjs.map → chunk-FVMVV4V3.mjs.map} +0 -0
- /package/dist/esm/{chunk-ESX5X52V.mjs.map → chunk-GQOOXOTN.mjs.map} +0 -0
- /package/dist/esm/{chunk-XQIWF5HY.mjs.map → chunk-I3TCHVQQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-3NOQE6U3.mjs.map → chunk-ILJWEPDW.mjs.map} +0 -0
- /package/dist/esm/{chunk-5L6SRCJP.mjs.map → chunk-J6MWD4XN.mjs.map} +0 -0
- /package/dist/esm/{chunk-UIVJXLRM.mjs.map → chunk-KUX6GQ2E.mjs.map} +0 -0
- /package/dist/esm/{chunk-WK36MJRI.mjs.map → chunk-LLL2LFYH.mjs.map} +0 -0
- /package/dist/esm/{chunk-5WXR2O3T.mjs.map → chunk-N65SOKJQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-XOBXX273.mjs.map → chunk-NL3XVNS5.mjs.map} +0 -0
- /package/dist/esm/{chunk-Q7JKS6WV.mjs.map → chunk-NURFZOR4.mjs.map} +0 -0
- /package/dist/esm/{chunk-MKERJNYN.mjs.map → chunk-OG56TYZE.mjs.map} +0 -0
- /package/dist/esm/{core/account.mjs.map → chunk-QE4ASJ5K.mjs.map} +0 -0
- /package/dist/esm/{chunk-TVURQPLA.mjs.map → chunk-R4VJDSIP.mjs.map} +0 -0
- /package/dist/esm/{chunk-Z6XNTGNK.mjs.map → chunk-TN5BUH4F.mjs.map} +0 -0
- /package/dist/esm/{chunk-YE3DZD6T.mjs.map → chunk-UIUSDBCL.mjs.map} +0 -0
- /package/dist/esm/{chunk-7JTOGYO7.mjs.map → chunk-UMLDKLDL.mjs.map} +0 -0
- /package/dist/esm/{core/crypto/anyPublicKey.mjs.map → chunk-UVSRX4SV.mjs.map} +0 -0
- /package/dist/esm/{chunk-6Y3VBRMN.mjs.map → chunk-VEVBHH3M.mjs.map} +0 -0
- /package/dist/esm/{chunk-T5IFXLOP.mjs.map → chunk-VMXBMAYK.mjs.map} +0 -0
- /package/dist/esm/{chunk-WC2WSKYZ.mjs.map → chunk-X5C3LYI7.mjs.map} +0 -0
- /package/dist/esm/{chunk-OWZLBIDD.mjs.map → chunk-XTPFQ4MH.mjs.map} +0 -0
- /package/dist/esm/{chunk-D2GNCG27.mjs.map → chunk-Y5AJLNUD.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZFPA45OK.mjs.map → chunk-YR2R3LW4.mjs.map} +0 -0
- /package/dist/esm/core/{crypto/anySignature.mjs.map → account/Account.mjs.map} +0 -0
- /package/dist/esm/core/{crypto/asymmetricCrypto.mjs.map → account/Ed25519Account.mjs.map} +0 -0
|
@@ -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
|
}
|
|
@@ -1,12 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { HexInput } from "../../types";
|
|
1
|
+
import { SigningScheme as AuthenticationKeyScheme } from "../../types";
|
|
3
2
|
import { Deserializer } from "../../bcs/deserializer";
|
|
4
3
|
import { Serializer } from "../../bcs/serializer";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { AuthenticationKey } from "../authenticationKey";
|
|
5
|
+
import { AccountPublicKey, PublicKey, VerifySignatureArgs } from "./publicKey";
|
|
6
|
+
import { Signature } from "./signature";
|
|
7
|
+
import { AnyPublicKey, AnySignature } from "./singleKey";
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
/* eslint-disable no-bitwise */
|
|
10
|
+
|
|
11
|
+
function bitCount(byte: number) {
|
|
12
|
+
let n = byte;
|
|
13
|
+
n -= (n >> 1) & 0x55555555;
|
|
14
|
+
n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
|
|
15
|
+
return (((n + (n >> 4)) & 0xf0f0f0f) * 0x1010101) >> 24;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* eslint-enable no-bitwise */
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Represents the public key of a multi-agent account.
|
|
22
|
+
*
|
|
23
|
+
* The public keys of each individual agent can be any type of public key supported by Aptos.
|
|
24
|
+
* Since [AIP-55](https://github.com/aptos-foundation/AIPs/pull/263) Aptos supports
|
|
25
|
+
* `Legacy` and `Unified` authentication keys.
|
|
26
|
+
*/
|
|
27
|
+
export class MultiKey extends AccountPublicKey {
|
|
10
28
|
/**
|
|
11
29
|
* List of any public keys
|
|
12
30
|
*/
|
|
@@ -17,13 +35,15 @@ export class MultiKey extends PublicKey {
|
|
|
17
35
|
*/
|
|
18
36
|
public readonly signaturesRequired: number;
|
|
19
37
|
|
|
20
|
-
|
|
38
|
+
// region Constructors
|
|
39
|
+
|
|
40
|
+
constructor(args: { publicKeys: Array<PublicKey>; signaturesRequired: number }) {
|
|
21
41
|
super();
|
|
22
42
|
const { publicKeys, signaturesRequired } = args;
|
|
23
43
|
|
|
24
44
|
// Validate number of public keys is greater than signature required
|
|
25
45
|
if (signaturesRequired < 1) {
|
|
26
|
-
throw new Error("The number of required signatures needs to be greater
|
|
46
|
+
throw new Error("The number of required signatures needs to be greater than 0");
|
|
27
47
|
}
|
|
28
48
|
|
|
29
49
|
// Validate number of public keys is greater than signature required
|
|
@@ -33,25 +53,52 @@ export class MultiKey extends PublicKey {
|
|
|
33
53
|
);
|
|
34
54
|
}
|
|
35
55
|
|
|
36
|
-
|
|
37
|
-
publicKeys.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
} else {
|
|
41
|
-
// if public key is instance of a legacy authentication key, i.e
|
|
42
|
-
// Legacy Ed25519, convert it into AnyPublicKey
|
|
43
|
-
keys.push(new AnyPublicKey(publicKey));
|
|
44
|
-
}
|
|
45
|
-
});
|
|
56
|
+
// Make sure that all keys are normalized to the SingleKey authentication scheme
|
|
57
|
+
this.publicKeys = publicKeys.map((publicKey) =>
|
|
58
|
+
publicKey instanceof AnyPublicKey ? publicKey : new AnyPublicKey(publicKey),
|
|
59
|
+
);
|
|
46
60
|
|
|
47
|
-
this.publicKeys = keys;
|
|
48
61
|
this.signaturesRequired = signaturesRequired;
|
|
49
62
|
}
|
|
50
63
|
|
|
64
|
+
// endregion
|
|
65
|
+
|
|
66
|
+
// region AccountPublicKey
|
|
67
|
+
|
|
68
|
+
// eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars
|
|
69
|
+
verifySignature(args: VerifySignatureArgs): boolean {
|
|
70
|
+
throw new Error("not implemented");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
authKey(): AuthenticationKey {
|
|
74
|
+
return AuthenticationKey.fromSchemeAndBytes({
|
|
75
|
+
scheme: AuthenticationKeyScheme.MultiKey,
|
|
76
|
+
input: this.toUint8Array(),
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
51
80
|
toUint8Array(): Uint8Array {
|
|
52
81
|
return this.bcsToBytes();
|
|
53
82
|
}
|
|
54
83
|
|
|
84
|
+
// endregion
|
|
85
|
+
|
|
86
|
+
// region Serializable
|
|
87
|
+
|
|
88
|
+
serialize(serializer: Serializer): void {
|
|
89
|
+
serializer.serializeVector(this.publicKeys);
|
|
90
|
+
serializer.serializeU8(this.signaturesRequired);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
static deserialize(deserializer: Deserializer): MultiKey {
|
|
94
|
+
const keys = deserializer.deserializeVector(AnyPublicKey);
|
|
95
|
+
const signaturesRequired = deserializer.deserializeU8();
|
|
96
|
+
|
|
97
|
+
return new MultiKey({ publicKeys: keys, signaturesRequired });
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// endregion
|
|
101
|
+
|
|
55
102
|
/**
|
|
56
103
|
* Create a bitmap that holds the mapping from the original public keys
|
|
57
104
|
* to the signatures passed in
|
|
@@ -92,31 +139,142 @@ export class MultiKey extends PublicKey {
|
|
|
92
139
|
|
|
93
140
|
return bitmap;
|
|
94
141
|
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export class MultiKeySignature extends Signature {
|
|
145
|
+
/**
|
|
146
|
+
* Number of bytes in the bitmap representing who signed the transaction (32-bits)
|
|
147
|
+
*/
|
|
148
|
+
static BITMAP_LEN: number = 4;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Maximum number of Ed25519 signatures supported
|
|
152
|
+
*/
|
|
153
|
+
static MAX_SIGNATURES_SUPPORTED = MultiKeySignature.BITMAP_LEN * 8;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* The list of underlying Ed25519 signatures
|
|
157
|
+
*/
|
|
158
|
+
public readonly signatures: AnySignature[];
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* 32-bit Bitmap representing who signed the transaction
|
|
162
|
+
*
|
|
163
|
+
* This is represented where each public key can be masked to determine whether the message was signed by that key.
|
|
164
|
+
*/
|
|
165
|
+
public readonly bitmap: Uint8Array;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Signature for a K-of-N multi-sig transaction.
|
|
169
|
+
*
|
|
170
|
+
* @see {@link
|
|
171
|
+
* https://aptos.dev/integration/creating-a-signed-transaction/#multisignature-transactions | Creating a Signed Transaction}
|
|
172
|
+
*
|
|
173
|
+
* @param args.signatures A list of signatures
|
|
174
|
+
* @param args.bitmap 4 bytes, at most 32 signatures are supported. If Nth bit value is `1`, the Nth
|
|
175
|
+
* signature should be provided in `signatures`. Bits are read from left to right
|
|
176
|
+
*/
|
|
177
|
+
constructor(args: { signatures: Array<Signature | AnySignature>; bitmap: Uint8Array | number[] }) {
|
|
178
|
+
super();
|
|
179
|
+
const { signatures, bitmap } = args;
|
|
180
|
+
|
|
181
|
+
if (signatures.length > MultiKeySignature.MAX_SIGNATURES_SUPPORTED) {
|
|
182
|
+
throw new Error(`The number of signatures cannot be greater than ${MultiKeySignature.MAX_SIGNATURES_SUPPORTED}`);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Make sure that all signatures are normalized to the SingleKey authentication scheme
|
|
186
|
+
this.signatures = signatures.map((signature) =>
|
|
187
|
+
signature instanceof AnySignature ? signature : new AnySignature(signature),
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
if (!(bitmap instanceof Uint8Array)) {
|
|
191
|
+
this.bitmap = MultiKeySignature.createBitmap({ bits: bitmap });
|
|
192
|
+
} else if (bitmap.length !== MultiKeySignature.BITMAP_LEN) {
|
|
193
|
+
throw new Error(`"bitmap" length should be ${MultiKeySignature.BITMAP_LEN}`);
|
|
194
|
+
} else {
|
|
195
|
+
this.bitmap = bitmap;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const nSignatures = this.bitmap.reduce((acc, byte) => acc + bitCount(byte), 0);
|
|
199
|
+
if (nSignatures !== this.signatures.length) {
|
|
200
|
+
throw new Error(`Expecting ${nSignatures} signatures from the bitmap, but got ${this.signatures.length}`);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
95
203
|
|
|
96
204
|
/**
|
|
97
|
-
*
|
|
205
|
+
* Helper method to create a bitmap out of the specified bit positions
|
|
206
|
+
* @param args.bits The bitmap positions that should be set. A position starts at index 0.
|
|
207
|
+
* Valid position should range between 0 and 31.
|
|
208
|
+
* @example
|
|
209
|
+
* Here's an example of valid `bits`
|
|
210
|
+
* ```
|
|
211
|
+
* [0, 2, 31]
|
|
212
|
+
* ```
|
|
213
|
+
* `[0, 2, 31]` means the 1st, 3rd and 32nd bits should be set in the bitmap.
|
|
214
|
+
* The result bitmap should be 0b1010000000000000000000000000001
|
|
98
215
|
*
|
|
99
|
-
* @returns
|
|
216
|
+
* @returns bitmap that is 32bit long
|
|
100
217
|
*/
|
|
101
|
-
|
|
102
|
-
|
|
218
|
+
static createBitmap(args: { bits: number[] }): Uint8Array {
|
|
219
|
+
const { bits } = args;
|
|
220
|
+
// Bits are read from left to right. e.g. 0b10000000 represents the first bit is set in one byte.
|
|
221
|
+
// The decimal value of 0b10000000 is 128.
|
|
222
|
+
const firstBitInByte = 128;
|
|
223
|
+
const bitmap = new Uint8Array([0, 0, 0, 0]);
|
|
224
|
+
|
|
225
|
+
// Check if duplicates exist in bits
|
|
226
|
+
const dupCheckSet = new Set();
|
|
227
|
+
|
|
228
|
+
bits.forEach((bit: number) => {
|
|
229
|
+
if (bit >= MultiKeySignature.MAX_SIGNATURES_SUPPORTED) {
|
|
230
|
+
throw new Error(`Cannot have a signature larger than ${MultiKeySignature.MAX_SIGNATURES_SUPPORTED - 1}.`);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (dupCheckSet.has(bit)) {
|
|
234
|
+
throw new Error("Duplicate bits detected.");
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
dupCheckSet.add(bit);
|
|
238
|
+
|
|
239
|
+
const byteOffset = Math.floor(bit / 8);
|
|
240
|
+
|
|
241
|
+
let byte = bitmap[byteOffset];
|
|
242
|
+
|
|
243
|
+
// eslint-disable-next-line no-bitwise
|
|
244
|
+
byte |= firstBitInByte >> bit % 8;
|
|
245
|
+
|
|
246
|
+
bitmap[byteOffset] = byte;
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
return bitmap;
|
|
103
250
|
}
|
|
104
251
|
|
|
105
|
-
//
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
252
|
+
// region Signature
|
|
253
|
+
|
|
254
|
+
toUint8Array(): Uint8Array {
|
|
255
|
+
return this.bcsToBytes();
|
|
109
256
|
}
|
|
110
257
|
|
|
258
|
+
// endregion
|
|
259
|
+
|
|
260
|
+
// region Serializable
|
|
261
|
+
|
|
111
262
|
serialize(serializer: Serializer): void {
|
|
112
|
-
|
|
113
|
-
serializer.
|
|
263
|
+
// Note: we should not need to serialize the vector length, as it can be derived from the bitmap
|
|
264
|
+
serializer.serializeVector(this.signatures);
|
|
265
|
+
serializer.serializeBytes(this.bitmap);
|
|
114
266
|
}
|
|
115
267
|
|
|
116
|
-
static deserialize(deserializer: Deserializer):
|
|
117
|
-
const
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
268
|
+
static deserialize(deserializer: Deserializer): MultiKeySignature {
|
|
269
|
+
const bitmap = deserializer.deserializeBytes();
|
|
270
|
+
const nSignatures = bitmap.reduce((acc, byte) => acc + bitCount(byte), 0);
|
|
271
|
+
const signatures: AnySignature[] = [];
|
|
272
|
+
for (let i = 0; i < nSignatures; i += 1) {
|
|
273
|
+
const signature = AnySignature.deserialize(deserializer);
|
|
274
|
+
signatures.push(signature);
|
|
275
|
+
}
|
|
276
|
+
return new MultiKeySignature({ signatures, bitmap });
|
|
121
277
|
}
|
|
278
|
+
|
|
279
|
+
// endregion
|
|
122
280
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { HexInput } from "../../types";
|
|
2
|
+
import { PublicKey } from "./publicKey";
|
|
3
|
+
import { Signature } from "./signature";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* An abstract representation of a private key.
|
|
7
|
+
* It is associated to a signature scheme and provides signing capabilities.
|
|
8
|
+
*/
|
|
9
|
+
export interface PrivateKey {
|
|
10
|
+
/**
|
|
11
|
+
* Sign the given message with the private key.
|
|
12
|
+
* @param message in HexInput format
|
|
13
|
+
*/
|
|
14
|
+
sign(message: HexInput): Signature;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Derive the public key associated with the private key
|
|
18
|
+
*/
|
|
19
|
+
publicKey(): PublicKey;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Get the private key in bytes (Uint8Array).
|
|
23
|
+
*/
|
|
24
|
+
toUint8Array(): Uint8Array;
|
|
25
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Serializable } from "../../bcs";
|
|
2
|
+
import { HexInput } from "../../types";
|
|
3
|
+
import { AuthenticationKey } from "../authenticationKey";
|
|
4
|
+
import { Hex } from "../hex";
|
|
5
|
+
import { Signature } from "./signature";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Arguments for verifying a signature
|
|
9
|
+
*/
|
|
10
|
+
export interface VerifySignatureArgs {
|
|
11
|
+
message: HexInput;
|
|
12
|
+
signature: Signature;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* An abstract representation of a public key.
|
|
17
|
+
*
|
|
18
|
+
* Provides a common interface for verifying any signature.
|
|
19
|
+
*/
|
|
20
|
+
export abstract class PublicKey extends Serializable {
|
|
21
|
+
/**
|
|
22
|
+
* Verifies that the private key associated with this public key signed the message with the given signature.
|
|
23
|
+
* @param args.message The message that was signed
|
|
24
|
+
* @param args.signature The signature to verify
|
|
25
|
+
*/
|
|
26
|
+
abstract verifySignature(args: VerifySignatureArgs): boolean;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Get the raw public key bytes
|
|
30
|
+
*/
|
|
31
|
+
abstract toUint8Array(): Uint8Array;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Get the public key as a hex string with a 0x prefix e.g. 0x123456...
|
|
35
|
+
*/
|
|
36
|
+
toString(): string {
|
|
37
|
+
const bytes = this.toUint8Array();
|
|
38
|
+
return Hex.fromHexInput(bytes).toString();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* An abstract representation of an account public key.
|
|
44
|
+
*
|
|
45
|
+
* Provides a common interface for deriving an authentication key.
|
|
46
|
+
*/
|
|
47
|
+
export abstract class AccountPublicKey extends PublicKey {
|
|
48
|
+
/**
|
|
49
|
+
* Get the authentication key associated with this public key
|
|
50
|
+
*/
|
|
51
|
+
abstract authKey(): AuthenticationKey;
|
|
52
|
+
}
|