@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
|
@@ -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
|
/**
|
|
@@ -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";
|