@aptos-labs/ts-sdk 1.8.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 +1131 -989
- package/dist/browser/index.global.js +30 -30
- package/dist/browser/index.global.js.map +1 -1
- package/dist/common/index.d.ts +1131 -989
- package/dist/common/index.js +25 -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.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/{chunk-S64WKSMI.mjs → chunk-2E2JOGE5.mjs} +2 -2
- package/dist/esm/chunk-3EUOBVCT.mjs +2 -0
- package/dist/esm/{chunk-SRZTA6QH.mjs.map → chunk-3EUOBVCT.mjs.map} +1 -1
- package/dist/esm/{chunk-4OI7MPFH.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-R56OJ4XC.mjs → chunk-7U36LMP4.mjs} +2 -2
- package/dist/esm/{chunk-NWRKJFHV.mjs → chunk-ARIC32W7.mjs} +2 -2
- package/dist/esm/{chunk-SPOHAEHR.mjs → chunk-B7M3OWHV.mjs} +2 -2
- package/dist/esm/{chunk-6SRENFWH.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-PMWH5IGI.mjs → chunk-CHA5DSSD.mjs} +2 -2
- package/dist/esm/chunk-DE5OOOVY.mjs +2 -0
- package/dist/esm/{chunk-MEPX7Z2Z.mjs.map → chunk-DE5OOOVY.mjs.map} +1 -1
- package/dist/esm/{chunk-JJ6Y35DF.mjs → chunk-DGOT2VR5.mjs} +2 -2
- package/dist/esm/{chunk-EUHPML5E.mjs → chunk-EF2F7NWO.mjs} +2 -2
- package/dist/esm/{chunk-FRLPX47J.mjs → chunk-EQZ757ES.mjs} +2 -2
- package/dist/esm/{chunk-Y4AKS4CY.mjs → chunk-F67Y7YH6.mjs} +2 -2
- package/dist/esm/{chunk-KJGQ4ILY.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-V2FPYAK7.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-GD4ULEBC.mjs → chunk-I3TCHVQQ.mjs} +2 -2
- package/dist/esm/{chunk-JQVT2K7G.mjs → chunk-ILJWEPDW.mjs} +2 -2
- package/dist/esm/{chunk-Q3HAJVCM.mjs → chunk-INORE66K.mjs} +2 -2
- package/dist/esm/{chunk-PIXE7MN5.mjs → chunk-J6MWD4XN.mjs} +2 -2
- package/dist/esm/{chunk-ENKMOALS.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-ENDUXRTK.mjs → chunk-KWJTVJ7C.mjs} +2 -2
- package/dist/esm/{chunk-W4UDMBMU.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-2WFMD6C6.mjs → chunk-N65SOKJQ.mjs} +2 -2
- package/dist/esm/{chunk-Q5HK3U64.mjs → chunk-NL3XVNS5.mjs} +2 -2
- package/dist/esm/{chunk-M3WNE7MU.mjs → chunk-NURFZOR4.mjs} +2 -2
- package/dist/esm/{chunk-AFPJ2XXN.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-XBVORX5O.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-2H5Z5EHH.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-VPQ46CAO.mjs → chunk-UIUSDBCL.mjs} +2 -2
- package/dist/esm/{chunk-4M46AWXX.mjs → chunk-UMLDKLDL.mjs} +2 -2
- package/dist/esm/chunk-UVSRX4SV.mjs +1 -0
- package/dist/esm/{chunk-2DNPRIS5.mjs → chunk-VEVBHH3M.mjs} +2 -2
- package/dist/esm/{chunk-QGIJNA37.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-GD5TZLBF.mjs → chunk-X5C3LYI7.mjs} +2 -2
- package/dist/esm/chunk-XKD7W5NO.mjs +2 -0
- package/dist/esm/{chunk-XZYPAQCU.mjs.map → chunk-XKD7W5NO.mjs.map} +1 -1
- package/dist/esm/{chunk-QRQAR6XO.mjs → chunk-XTPFQ4MH.mjs} +2 -2
- package/dist/esm/{chunk-LATJGGVX.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-VKZCIGKY.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/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 +8 -8
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internal/account.d.mts +10 -4
- package/dist/esm/internal/account.mjs +1 -1
- package/dist/esm/internal/ans.d.mts +11 -12
- 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-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/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 +1 -1
- package/src/api/aptosConfig.ts +2 -2
- package/src/api/digitalAsset.ts +20 -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/internal/account.ts +5 -3
- package/src/internal/digitalAsset.ts +26 -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/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-7IGH7N52.mjs +0 -2
- package/dist/esm/chunk-7IGH7N52.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-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-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-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-O57QZZF2.mjs.map +0 -1
- 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-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-S64WKSMI.mjs.map → chunk-2E2JOGE5.mjs.map} +0 -0
- /package/dist/esm/{chunk-4OI7MPFH.mjs.map → chunk-52RTAMN7.mjs.map} +0 -0
- /package/dist/esm/{chunk-R56OJ4XC.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-SPOHAEHR.mjs.map → chunk-B7M3OWHV.mjs.map} +0 -0
- /package/dist/esm/{chunk-6SRENFWH.mjs.map → chunk-BBUAAJRA.mjs.map} +0 -0
- /package/dist/esm/{chunk-PMWH5IGI.mjs.map → chunk-CHA5DSSD.mjs.map} +0 -0
- /package/dist/esm/{chunk-JJ6Y35DF.mjs.map → chunk-DGOT2VR5.mjs.map} +0 -0
- /package/dist/esm/{chunk-EUHPML5E.mjs.map → chunk-EF2F7NWO.mjs.map} +0 -0
- /package/dist/esm/{chunk-FRLPX47J.mjs.map → chunk-EQZ757ES.mjs.map} +0 -0
- /package/dist/esm/{chunk-Y4AKS4CY.mjs.map → chunk-F67Y7YH6.mjs.map} +0 -0
- /package/dist/esm/{chunk-KJGQ4ILY.mjs.map → chunk-FVMVV4V3.mjs.map} +0 -0
- /package/dist/esm/{chunk-V2FPYAK7.mjs.map → chunk-GQOOXOTN.mjs.map} +0 -0
- /package/dist/esm/{chunk-GD4ULEBC.mjs.map → chunk-I3TCHVQQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-JQVT2K7G.mjs.map → chunk-ILJWEPDW.mjs.map} +0 -0
- /package/dist/esm/{chunk-Q3HAJVCM.mjs.map → chunk-INORE66K.mjs.map} +0 -0
- /package/dist/esm/{chunk-PIXE7MN5.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-ENDUXRTK.mjs.map → chunk-KWJTVJ7C.mjs.map} +0 -0
- /package/dist/esm/{chunk-W4UDMBMU.mjs.map → chunk-LLL2LFYH.mjs.map} +0 -0
- /package/dist/esm/{chunk-2WFMD6C6.mjs.map → chunk-N65SOKJQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-Q5HK3U64.mjs.map → chunk-NL3XVNS5.mjs.map} +0 -0
- /package/dist/esm/{chunk-M3WNE7MU.mjs.map → chunk-NURFZOR4.mjs.map} +0 -0
- /package/dist/esm/{chunk-AFPJ2XXN.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-XBVORX5O.mjs.map → chunk-R4VJDSIP.mjs.map} +0 -0
- /package/dist/esm/{chunk-2H5Z5EHH.mjs.map → chunk-TN5BUH4F.mjs.map} +0 -0
- /package/dist/esm/{chunk-VPQ46CAO.mjs.map → chunk-UIUSDBCL.mjs.map} +0 -0
- /package/dist/esm/{chunk-4M46AWXX.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-2DNPRIS5.mjs.map → chunk-VEVBHH3M.mjs.map} +0 -0
- /package/dist/esm/{chunk-QGIJNA37.mjs.map → chunk-VMXBMAYK.mjs.map} +0 -0
- /package/dist/esm/{chunk-GD5TZLBF.mjs.map → chunk-X5C3LYI7.mjs.map} +0 -0
- /package/dist/esm/{chunk-QRQAR6XO.mjs.map → chunk-XTPFQ4MH.mjs.map} +0 -0
- /package/dist/esm/{chunk-LATJGGVX.mjs.map → chunk-Y5AJLNUD.mjs.map} +0 -0
- /package/dist/esm/{chunk-VKZCIGKY.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
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import type { AccountAuthenticator } from "../../transactions/authenticator/account";
|
|
2
|
+
import { HexInput, SigningScheme, SigningSchemeInput } from "../../types";
|
|
3
|
+
import type { AccountAddress, AccountAddressInput } from "../accountAddress";
|
|
4
|
+
import { AuthenticationKey } from "../authenticationKey";
|
|
5
|
+
import { AccountPublicKey, Ed25519PrivateKey, PrivateKey, Signature, VerifySignatureArgs } from "../crypto";
|
|
6
|
+
import { Ed25519Account } from "./Ed25519Account";
|
|
7
|
+
import { SingleKeyAccount } from "./SingleKeyAccount";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Arguments for creating an `Ed25519Account` from an `Ed25519PrivateKey`.
|
|
11
|
+
* This is the default input type when passing an `Ed25519PrivateKey`.
|
|
12
|
+
* In order to use the SingleKey authentication scheme, `legacy` needs to be explicitly set to false.
|
|
13
|
+
*/
|
|
14
|
+
export interface CreateEd25519AccountFromPrivateKeyArgs {
|
|
15
|
+
privateKey: Ed25519PrivateKey;
|
|
16
|
+
address?: AccountAddressInput;
|
|
17
|
+
legacy?: true;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Arguments for creating an `SingleKeyAccount` from an `Ed25519PrivateKey`.
|
|
22
|
+
* The `legacy` argument needs to be explicitly set to false in order to
|
|
23
|
+
* use the `SingleKey` authentication scheme.
|
|
24
|
+
*/
|
|
25
|
+
export interface CreateEd25519SingleKeyAccountFromPrivateKeyArgs {
|
|
26
|
+
privateKey: Ed25519PrivateKey;
|
|
27
|
+
address?: AccountAddressInput;
|
|
28
|
+
legacy: false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Arguments for creating an `SingleKeyAccount` from any supported private key
|
|
33
|
+
* that is not an `Ed25519PrivateKey`.
|
|
34
|
+
* The `legacy` argument defaults to false and cannot be explicitly set to true.
|
|
35
|
+
*/
|
|
36
|
+
export interface CreateSingleKeyAccountFromPrivateKeyArgs {
|
|
37
|
+
privateKey: Exclude<PrivateKey, Ed25519PrivateKey>;
|
|
38
|
+
address?: AccountAddressInput;
|
|
39
|
+
legacy?: false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Arguments for creating an opaque `Account` from any supported private key.
|
|
44
|
+
* This is used when the private key type is not known at compilation time.
|
|
45
|
+
*/
|
|
46
|
+
export interface CreateAccountFromPrivateKeyArgs {
|
|
47
|
+
privateKey: PrivateKey;
|
|
48
|
+
address?: AccountAddressInput;
|
|
49
|
+
legacy?: boolean;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Arguments for generating an `Ed25519Account`.
|
|
54
|
+
* This is the input type used by default.
|
|
55
|
+
*/
|
|
56
|
+
export interface GenerateEd25519AccountArgs {
|
|
57
|
+
scheme?: SigningSchemeInput.Ed25519;
|
|
58
|
+
legacy?: true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Arguments for generating an `SingleKeyAccount` with ah underlying `Ed25519PrivateKey`.
|
|
63
|
+
* The `legacy` argument needs to be explicitly set to false,
|
|
64
|
+
* otherwise an `Ed25519Account` will be returned instead.
|
|
65
|
+
*/
|
|
66
|
+
export interface GenerateEd25519SingleKeyAccountArgs {
|
|
67
|
+
scheme?: SigningSchemeInput.Ed25519;
|
|
68
|
+
legacy: false;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Arguments for generating an `SingleKeyAccount` with any supported private key
|
|
73
|
+
* that is not an `Ed25519PrivateKey`.
|
|
74
|
+
* The `legacy` argument defaults to false and cannot be explicitly set to true.
|
|
75
|
+
*/
|
|
76
|
+
export interface GenerateSingleKeyAccountArgs {
|
|
77
|
+
scheme: Exclude<SigningSchemeInput, SigningSchemeInput.Ed25519>;
|
|
78
|
+
legacy?: false;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Arguments for generating an opaque `Account`.
|
|
83
|
+
* This is used when the input signature scheme is not known at compilation time.
|
|
84
|
+
*/
|
|
85
|
+
export interface GenerateAccountArgs {
|
|
86
|
+
scheme?: SigningSchemeInput;
|
|
87
|
+
legacy?: boolean;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Arguments for deriving a private key from a mnemonic phrase and a BIP44 path.
|
|
92
|
+
*/
|
|
93
|
+
export interface PrivateKeyFromDerivationPathArgs {
|
|
94
|
+
path: string;
|
|
95
|
+
mnemonic: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Interface for a generic Aptos account.
|
|
100
|
+
*
|
|
101
|
+
* The interface is defined as abstract class to provide a single entrypoint for account generation,
|
|
102
|
+
* either through `Account.generate()` or `Account.fromDerivationPath`.
|
|
103
|
+
* Despite this being an abstract class, it should be treated as an interface and enforced using
|
|
104
|
+
* the `implements` keyword.
|
|
105
|
+
*
|
|
106
|
+
* Note: Generating an account instance does not create the account on-chain.
|
|
107
|
+
*/
|
|
108
|
+
export abstract class Account {
|
|
109
|
+
/**
|
|
110
|
+
* Private key associated with the account.
|
|
111
|
+
* Note: this will be removed in the next major release,
|
|
112
|
+
* as not all accounts have a private key.
|
|
113
|
+
*/
|
|
114
|
+
abstract readonly privateKey: PrivateKey;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Public key associated with the account
|
|
118
|
+
*/
|
|
119
|
+
abstract readonly publicKey: AccountPublicKey;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Account address associated with the account
|
|
123
|
+
*/
|
|
124
|
+
abstract readonly accountAddress: AccountAddress;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Signing scheme used to sign transactions
|
|
128
|
+
*/
|
|
129
|
+
abstract signingScheme: SigningScheme;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Derives an account from a randomly generated private key.
|
|
133
|
+
* @param args.scheme The signature scheme to use, to generate the private key
|
|
134
|
+
* @param args.legacy Whether to use a legacy authentication scheme, when applicable
|
|
135
|
+
* @returns An account compatible with the provided signature scheme
|
|
136
|
+
*/
|
|
137
|
+
static generate(args?: GenerateEd25519AccountArgs): Ed25519Account;
|
|
138
|
+
static generate(args: GenerateEd25519SingleKeyAccountArgs): SingleKeyAccount;
|
|
139
|
+
static generate(args: GenerateSingleKeyAccountArgs): SingleKeyAccount;
|
|
140
|
+
static generate(args: GenerateAccountArgs): Account;
|
|
141
|
+
static generate(args: GenerateAccountArgs = {}) {
|
|
142
|
+
const { scheme = SigningSchemeInput.Ed25519, legacy = true } = args;
|
|
143
|
+
if (scheme === SigningSchemeInput.Ed25519 && legacy) {
|
|
144
|
+
return Ed25519Account.generate();
|
|
145
|
+
}
|
|
146
|
+
return SingleKeyAccount.generate({ scheme });
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Creates an account from the provided private key.
|
|
151
|
+
*
|
|
152
|
+
* @param args.privateKey a valid private key
|
|
153
|
+
* @param args.address the account's address. If not provided, it will be derived from the public key.
|
|
154
|
+
* @param args.legacy Whether to use a legacy authentication scheme, when applicable
|
|
155
|
+
*/
|
|
156
|
+
static fromPrivateKey(args: CreateEd25519AccountFromPrivateKeyArgs): Ed25519Account;
|
|
157
|
+
static fromPrivateKey(args: CreateEd25519SingleKeyAccountFromPrivateKeyArgs): SingleKeyAccount;
|
|
158
|
+
static fromPrivateKey(args: CreateSingleKeyAccountFromPrivateKeyArgs): SingleKeyAccount;
|
|
159
|
+
static fromPrivateKey(args: CreateAccountFromPrivateKeyArgs): Account;
|
|
160
|
+
static fromPrivateKey(args: CreateAccountFromPrivateKeyArgs) {
|
|
161
|
+
const { privateKey, address, legacy = true } = args;
|
|
162
|
+
if (privateKey instanceof Ed25519PrivateKey && legacy) {
|
|
163
|
+
return new Ed25519Account({
|
|
164
|
+
privateKey,
|
|
165
|
+
address,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
return new SingleKeyAccount({ privateKey, address });
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* @deprecated use `fromPrivateKey` instead.
|
|
173
|
+
* Instantiates an account given a private key and a specified account address.
|
|
174
|
+
* This is primarily used to instantiate an `Account` that has had its authentication key rotated.
|
|
175
|
+
*
|
|
176
|
+
* @param args.privateKey PrivateKey - the underlying private key for the account
|
|
177
|
+
* @param args.address AccountAddress - The account address the `Account` will sign for
|
|
178
|
+
* @param args.legacy optional. If set to false, the keypair generated is a Unified keypair. Defaults
|
|
179
|
+
* to generating a Legacy Ed25519 keypair
|
|
180
|
+
*
|
|
181
|
+
* @returns Account
|
|
182
|
+
*/
|
|
183
|
+
static fromPrivateKeyAndAddress(args: CreateAccountFromPrivateKeyArgs) {
|
|
184
|
+
return this.fromPrivateKey(args);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Derives an account with bip44 path and mnemonics
|
|
189
|
+
*
|
|
190
|
+
* @param args.scheme The signature scheme to derive the private key with
|
|
191
|
+
* @param args.path the BIP44 derive hardened path (e.g. m/44'/637'/0'/0'/0') for Ed25519,
|
|
192
|
+
* or non-hardened path (e.g. m/44'/637'/0'/0/0) for secp256k1
|
|
193
|
+
* Detailed description: {@link https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki}
|
|
194
|
+
* @param args.mnemonic the mnemonic seed phrase of the account
|
|
195
|
+
*/
|
|
196
|
+
static fromDerivationPath(args: GenerateEd25519AccountArgs & PrivateKeyFromDerivationPathArgs): Ed25519Account;
|
|
197
|
+
static fromDerivationPath(
|
|
198
|
+
args: GenerateEd25519SingleKeyAccountArgs & PrivateKeyFromDerivationPathArgs,
|
|
199
|
+
): SingleKeyAccount;
|
|
200
|
+
static fromDerivationPath(args: GenerateSingleKeyAccountArgs & PrivateKeyFromDerivationPathArgs): SingleKeyAccount;
|
|
201
|
+
static fromDerivationPath(args: GenerateAccountArgs & PrivateKeyFromDerivationPathArgs): Account;
|
|
202
|
+
static fromDerivationPath(args: GenerateAccountArgs & PrivateKeyFromDerivationPathArgs) {
|
|
203
|
+
const { scheme = SigningSchemeInput.Ed25519, mnemonic, path, legacy = true } = args;
|
|
204
|
+
if (scheme === SigningSchemeInput.Ed25519 && legacy) {
|
|
205
|
+
return Ed25519Account.fromDerivationPath({ mnemonic, path });
|
|
206
|
+
}
|
|
207
|
+
return SingleKeyAccount.fromDerivationPath({ scheme, mnemonic, path });
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* @deprecated use `publicKey.authKey()` instead.
|
|
212
|
+
* This key enables account owners to rotate their private key(s)
|
|
213
|
+
* associated with the account without changing the address that hosts their account.
|
|
214
|
+
* See here for more info: {@link https://aptos.dev/concepts/accounts#single-signer-authentication}
|
|
215
|
+
*
|
|
216
|
+
* @param args.publicKey PublicKey - public key of the account
|
|
217
|
+
* @returns The authentication key for the associated account
|
|
218
|
+
*/
|
|
219
|
+
static authKey(args: { publicKey: AccountPublicKey }): AuthenticationKey {
|
|
220
|
+
const { publicKey } = args;
|
|
221
|
+
return publicKey.authKey();
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Sign a message using the available signing capabilities.
|
|
226
|
+
* @param message the signing message, as binary input
|
|
227
|
+
* @return the AccountAuthenticator containing the signature, together with the account's public key
|
|
228
|
+
*/
|
|
229
|
+
abstract signWithAuthenticator(message: HexInput): AccountAuthenticator;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Sign the given message with the private key.
|
|
233
|
+
* @param message in HexInput format
|
|
234
|
+
* @returns AccountSignature
|
|
235
|
+
*/
|
|
236
|
+
abstract sign(message: HexInput): Signature;
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* @param args.message raw message data in HexInput format
|
|
240
|
+
* @param args.signature signed message signature
|
|
241
|
+
*/
|
|
242
|
+
verifySignature(args: VerifySignatureArgs): boolean {
|
|
243
|
+
return this.publicKey.verifySignature(args);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { AccountAuthenticatorEd25519 } from "../../transactions/authenticator/account";
|
|
2
|
+
import { HexInput, SigningScheme } from "../../types";
|
|
3
|
+
import { AccountAddress, AccountAddressInput } from "../accountAddress";
|
|
4
|
+
import { Ed25519PrivateKey, Ed25519PublicKey, Ed25519Signature } from "../crypto";
|
|
5
|
+
import type { Account } from "./Account";
|
|
6
|
+
|
|
7
|
+
export interface Ed25519SignerConstructorArgs {
|
|
8
|
+
privateKey: Ed25519PrivateKey;
|
|
9
|
+
address?: AccountAddressInput;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface Ed25519SignerFromDerivationPathArgs {
|
|
13
|
+
path: string;
|
|
14
|
+
mnemonic: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface VerifyEd25519SignatureArgs {
|
|
18
|
+
message: HexInput;
|
|
19
|
+
signature: Ed25519Signature;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Signer implementation for the Ed25519 authentication scheme.
|
|
24
|
+
* This extends an {@link Ed25519Account} by adding signing capabilities through an {@link Ed25519PrivateKey}.
|
|
25
|
+
*
|
|
26
|
+
* Note: Generating a signer instance does not create the account on-chain.
|
|
27
|
+
*/
|
|
28
|
+
export class Ed25519Account implements Account {
|
|
29
|
+
/**
|
|
30
|
+
* Private key associated with the account
|
|
31
|
+
*/
|
|
32
|
+
readonly privateKey: Ed25519PrivateKey;
|
|
33
|
+
|
|
34
|
+
readonly publicKey: Ed25519PublicKey;
|
|
35
|
+
|
|
36
|
+
readonly accountAddress: AccountAddress;
|
|
37
|
+
|
|
38
|
+
readonly signingScheme = SigningScheme.Ed25519;
|
|
39
|
+
|
|
40
|
+
// region Constructors
|
|
41
|
+
|
|
42
|
+
constructor(args: Ed25519SignerConstructorArgs) {
|
|
43
|
+
const { privateKey, address } = args;
|
|
44
|
+
this.privateKey = privateKey;
|
|
45
|
+
this.publicKey = privateKey.publicKey();
|
|
46
|
+
this.accountAddress = address ? AccountAddress.from(address) : this.publicKey.authKey().derivedAddress();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Derives a signer from a randomly generated private key
|
|
51
|
+
*/
|
|
52
|
+
static generate() {
|
|
53
|
+
const privateKey = Ed25519PrivateKey.generate();
|
|
54
|
+
return new Ed25519Account({ privateKey });
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Derives an account with bip44 path and mnemonics
|
|
59
|
+
*
|
|
60
|
+
* @param args.path the BIP44 derive hardened path e.g. m/44'/637'/0'/0'/0'
|
|
61
|
+
* Detailed description: {@link https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki}
|
|
62
|
+
* @param args.mnemonic the mnemonic seed phrase of the account
|
|
63
|
+
*/
|
|
64
|
+
static fromDerivationPath(args: Ed25519SignerFromDerivationPathArgs) {
|
|
65
|
+
const { path, mnemonic } = args;
|
|
66
|
+
const privateKey = Ed25519PrivateKey.fromDerivationPath(path, mnemonic);
|
|
67
|
+
return new Ed25519Account({ privateKey });
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// endregion
|
|
71
|
+
|
|
72
|
+
// region Account
|
|
73
|
+
|
|
74
|
+
verifySignature(args: VerifyEd25519SignatureArgs): boolean {
|
|
75
|
+
return this.publicKey.verifySignature(args);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
signWithAuthenticator(message: HexInput) {
|
|
79
|
+
const signature = this.privateKey.sign(message);
|
|
80
|
+
return new AccountAuthenticatorEd25519(this.publicKey, signature);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
sign(message: HexInput) {
|
|
84
|
+
return this.signWithAuthenticator(message).signature;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// endregion
|
|
88
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { AccountAuthenticatorSingleKey } from "../../transactions/authenticator/account";
|
|
2
|
+
import { type HexInput, SigningScheme, SigningSchemeInput } from "../../types";
|
|
3
|
+
import { AccountAddress, AccountAddressInput } from "../accountAddress";
|
|
4
|
+
import { AnyPublicKey, AnySignature, Ed25519PrivateKey, PrivateKey, Secp256k1PrivateKey } from "../crypto";
|
|
5
|
+
import type { Account } from "./Account";
|
|
6
|
+
|
|
7
|
+
export interface SingleKeySignerConstructorArgs {
|
|
8
|
+
privateKey: PrivateKey;
|
|
9
|
+
address?: AccountAddressInput;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface SingleKeySignerGenerateArgs {
|
|
13
|
+
scheme?: SigningSchemeInput;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type SingleKeySignerFromDerivationPathArgs = SingleKeySignerGenerateArgs & {
|
|
17
|
+
path: string;
|
|
18
|
+
mnemonic: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export interface VerifySingleKeySignatureArgs {
|
|
22
|
+
message: HexInput;
|
|
23
|
+
signature: AnySignature;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Signer implementation for the SingleKey authentication scheme.
|
|
28
|
+
* This extends a SingleKeyAccount by adding signing capabilities through a valid private key.
|
|
29
|
+
* Currently, the only supported signature schemes are Ed25519 and Secp256k1.
|
|
30
|
+
*
|
|
31
|
+
* Note: Generating a signer instance does not create the account on-chain.
|
|
32
|
+
*/
|
|
33
|
+
export class SingleKeyAccount implements Account {
|
|
34
|
+
/**
|
|
35
|
+
* Private key associated with the account
|
|
36
|
+
*/
|
|
37
|
+
readonly privateKey: PrivateKey;
|
|
38
|
+
|
|
39
|
+
readonly publicKey: AnyPublicKey;
|
|
40
|
+
|
|
41
|
+
readonly accountAddress: AccountAddress;
|
|
42
|
+
|
|
43
|
+
readonly signingScheme = SigningScheme.SingleKey;
|
|
44
|
+
|
|
45
|
+
// region Constructors
|
|
46
|
+
|
|
47
|
+
constructor(args: SingleKeySignerConstructorArgs) {
|
|
48
|
+
const { privateKey, address } = args;
|
|
49
|
+
this.privateKey = privateKey;
|
|
50
|
+
this.publicKey = new AnyPublicKey(privateKey.publicKey());
|
|
51
|
+
this.accountAddress = address ? AccountAddress.from(address) : this.publicKey.authKey().derivedAddress();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Derives an account from a randomly generated private key.
|
|
56
|
+
* Default generation is using an Ed25519 key
|
|
57
|
+
* @returns Account with the given signature scheme
|
|
58
|
+
*/
|
|
59
|
+
static generate(args: SingleKeySignerGenerateArgs = {}) {
|
|
60
|
+
const { scheme = SigningSchemeInput.Ed25519 } = args;
|
|
61
|
+
let privateKey: PrivateKey;
|
|
62
|
+
switch (scheme) {
|
|
63
|
+
case SigningSchemeInput.Ed25519:
|
|
64
|
+
privateKey = Ed25519PrivateKey.generate();
|
|
65
|
+
break;
|
|
66
|
+
case SigningSchemeInput.Secp256k1Ecdsa:
|
|
67
|
+
privateKey = Secp256k1PrivateKey.generate();
|
|
68
|
+
break;
|
|
69
|
+
default:
|
|
70
|
+
throw new Error(`Unsupported signature scheme ${scheme}`);
|
|
71
|
+
}
|
|
72
|
+
return new SingleKeyAccount({ privateKey });
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Derives an account with bip44 path and mnemonics,
|
|
77
|
+
* Default to using an Ed25519 signature scheme.
|
|
78
|
+
*
|
|
79
|
+
* @param args.scheme The signature scheme to derive the private key with
|
|
80
|
+
* @param args.path the BIP44 derive hardened path (e.g. m/44'/637'/0'/0'/0') for Ed25519,
|
|
81
|
+
* or non-hardened path (e.g. m/44'/637'/0'/0/0) for secp256k1
|
|
82
|
+
* Detailed description: {@link https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki}
|
|
83
|
+
* @param args.mnemonic the mnemonic seed phrase of the account
|
|
84
|
+
*/
|
|
85
|
+
static fromDerivationPath(args: SingleKeySignerFromDerivationPathArgs) {
|
|
86
|
+
const { scheme = SigningSchemeInput.Ed25519, path, mnemonic } = args;
|
|
87
|
+
let privateKey: PrivateKey;
|
|
88
|
+
switch (scheme) {
|
|
89
|
+
case SigningSchemeInput.Ed25519:
|
|
90
|
+
privateKey = Ed25519PrivateKey.fromDerivationPath(path, mnemonic);
|
|
91
|
+
break;
|
|
92
|
+
case SigningSchemeInput.Secp256k1Ecdsa:
|
|
93
|
+
privateKey = Secp256k1PrivateKey.fromDerivationPath(path, mnemonic);
|
|
94
|
+
break;
|
|
95
|
+
default:
|
|
96
|
+
throw new Error(`Unsupported signature scheme ${scheme}`);
|
|
97
|
+
}
|
|
98
|
+
return new SingleKeyAccount({ privateKey });
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// endregion
|
|
102
|
+
|
|
103
|
+
// region Account
|
|
104
|
+
|
|
105
|
+
verifySignature(args: VerifySingleKeySignatureArgs): boolean {
|
|
106
|
+
return this.publicKey.verifySignature(args);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
signWithAuthenticator(message: HexInput) {
|
|
110
|
+
const innerSignature = this.privateKey.sign(message);
|
|
111
|
+
const signature = new AnySignature(innerSignature);
|
|
112
|
+
return new AccountAuthenticatorSingleKey(this.publicKey, signature);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
sign(message: HexInput) {
|
|
116
|
+
return this.signWithAuthenticator(message).signature;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// endregion
|
|
120
|
+
}
|
|
@@ -3,13 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
import { sha3_256 as sha3Hash } from "@noble/hashes/sha3";
|
|
5
5
|
import { AccountAddress } from "./accountAddress";
|
|
6
|
-
import {
|
|
7
|
-
import { Ed25519PublicKey } from "./crypto/ed25519";
|
|
8
|
-
import { MultiEd25519PublicKey } from "./crypto/multiEd25519";
|
|
6
|
+
import type { AccountPublicKey } from "./crypto";
|
|
9
7
|
import { Hex } from "./hex";
|
|
10
|
-
import { AuthenticationKeyScheme, HexInput
|
|
11
|
-
import { AnyPublicKey } from "./crypto/anyPublicKey";
|
|
12
|
-
import { MultiKey } from "./crypto/multiKey";
|
|
8
|
+
import { AuthenticationKeyScheme, HexInput } from "../types";
|
|
13
9
|
import { Serializable, Serializer } from "../bcs/serializer";
|
|
14
10
|
import { Deserializer } from "../bcs/deserializer";
|
|
15
11
|
|
|
@@ -65,41 +61,27 @@ export class AuthenticationKey extends Serializable {
|
|
|
65
61
|
return this.data.toUint8Array();
|
|
66
62
|
}
|
|
67
63
|
|
|
64
|
+
static fromSchemeAndBytes(args: { scheme: AuthenticationKeyScheme; input: HexInput }): AuthenticationKey {
|
|
65
|
+
const { scheme, input } = args;
|
|
66
|
+
const inputBytes = Hex.fromHexInput(input).toUint8Array();
|
|
67
|
+
const hashInput = new Uint8Array([...inputBytes, scheme]);
|
|
68
|
+
const hash = sha3Hash.create();
|
|
69
|
+
hash.update(hashInput);
|
|
70
|
+
const hashDigest = hash.digest();
|
|
71
|
+
return new AuthenticationKey({ data: hashDigest });
|
|
72
|
+
}
|
|
73
|
+
|
|
68
74
|
/**
|
|
75
|
+
* @deprecated Use `fromPublicKey` instead
|
|
69
76
|
* Derives an AuthenticationKey from the public key seed bytes and an explicit derivation scheme.
|
|
70
77
|
*
|
|
71
78
|
* This facilitates targeting a specific scheme for deriving an authentication key from a public key.
|
|
72
79
|
*
|
|
73
80
|
* @param args - the public key and scheme to use for the derivation
|
|
74
81
|
*/
|
|
75
|
-
public static fromPublicKeyAndScheme(args: { publicKey:
|
|
76
|
-
const { publicKey
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
switch (scheme) {
|
|
80
|
-
case SigningScheme.MultiKey:
|
|
81
|
-
case SigningScheme.SingleKey: {
|
|
82
|
-
const singleKeyBytes = publicKey.bcsToBytes();
|
|
83
|
-
authKeyBytes = new Uint8Array([...singleKeyBytes, scheme]);
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
case SigningScheme.Ed25519:
|
|
88
|
-
case SigningScheme.MultiEd25519: {
|
|
89
|
-
const ed25519PublicKeyBytes = publicKey.toUint8Array();
|
|
90
|
-
const inputBytes = Hex.fromHexInput(ed25519PublicKeyBytes).toUint8Array();
|
|
91
|
-
authKeyBytes = new Uint8Array([...inputBytes, scheme]);
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
default:
|
|
96
|
-
throw new Error(`Scheme ${scheme} is not supported`);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const hash = sha3Hash.create();
|
|
100
|
-
hash.update(authKeyBytes);
|
|
101
|
-
const hashDigest = hash.digest();
|
|
102
|
-
return new AuthenticationKey({ data: hashDigest });
|
|
82
|
+
public static fromPublicKeyAndScheme(args: { publicKey: AccountPublicKey; scheme: AuthenticationKeyScheme }) {
|
|
83
|
+
const { publicKey } = args;
|
|
84
|
+
return publicKey.authKey();
|
|
103
85
|
}
|
|
104
86
|
|
|
105
87
|
/**
|
|
@@ -109,25 +91,9 @@ export class AuthenticationKey extends Serializable {
|
|
|
109
91
|
* @param args.publicKey
|
|
110
92
|
* @returns AuthenticationKey
|
|
111
93
|
*/
|
|
112
|
-
static fromPublicKey(args: { publicKey:
|
|
94
|
+
static fromPublicKey(args: { publicKey: AccountPublicKey }): AuthenticationKey {
|
|
113
95
|
const { publicKey } = args;
|
|
114
|
-
|
|
115
|
-
let scheme: number;
|
|
116
|
-
if (publicKey instanceof Ed25519PublicKey) {
|
|
117
|
-
// for legacy support
|
|
118
|
-
scheme = SigningScheme.Ed25519.valueOf();
|
|
119
|
-
} else if (publicKey instanceof MultiEd25519PublicKey) {
|
|
120
|
-
// for legacy support
|
|
121
|
-
scheme = SigningScheme.MultiEd25519.valueOf();
|
|
122
|
-
} else if (publicKey instanceof AnyPublicKey) {
|
|
123
|
-
scheme = SigningScheme.SingleKey.valueOf();
|
|
124
|
-
} else if (publicKey instanceof MultiKey) {
|
|
125
|
-
scheme = SigningScheme.MultiKey.valueOf();
|
|
126
|
-
} else {
|
|
127
|
-
throw new Error("No supported authentication scheme for public key");
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return AuthenticationKey.fromPublicKeyAndScheme({ publicKey, scheme });
|
|
96
|
+
return publicKey.authKey();
|
|
131
97
|
}
|
|
132
98
|
|
|
133
99
|
/**
|