@aptos-labs/ts-sdk 1.31.0 → 1.32.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/common/{accountAddress-DnSqjhSl.d.ts → accountAddress-6RqI8Aam.d.ts} +144 -63
- package/dist/common/chunk-F43XVDYJ.js +2 -0
- package/dist/common/chunk-F43XVDYJ.js.map +1 -0
- package/dist/common/cli/index.d.ts +1 -1
- package/dist/common/cli/index.js +1 -1
- package/dist/common/cli/index.js.map +1 -1
- package/dist/common/index.d.ts +446 -111
- package/dist/common/index.js +36 -29
- package/dist/common/index.js.map +1 -1
- package/dist/esm/{Ed25519Account-DpH9qAcg.d.mts → Ed25519Account-B3xHXAQe.d.mts} +2 -2
- package/dist/esm/account/AbstractKeylessAccount.d.mts +85 -14
- package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
- package/dist/esm/account/Account.d.mts +4 -4
- package/dist/esm/account/Account.mjs +1 -1
- package/dist/esm/account/Ed25519Account.d.mts +4 -4
- package/dist/esm/account/Ed25519Account.mjs +1 -1
- package/dist/esm/account/EphemeralKeyPair.d.mts +3 -3
- package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
- package/dist/esm/account/FederatedKeylessAccount.d.mts +56 -8
- package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
- package/dist/esm/account/KeylessAccount.d.mts +28 -11
- package/dist/esm/account/KeylessAccount.mjs +1 -1
- package/dist/esm/account/MultiKeyAccount.d.mts +22 -10
- package/dist/esm/account/MultiKeyAccount.mjs +1 -1
- package/dist/esm/account/SingleKeyAccount.d.mts +4 -4
- package/dist/esm/account/SingleKeyAccount.mjs +1 -1
- package/dist/esm/account/index.d.mts +5 -5
- package/dist/esm/account/index.mjs +1 -1
- package/dist/esm/api/account.d.mts +5 -5
- package/dist/esm/api/account.mjs +1 -1
- package/dist/esm/api/ans.d.mts +3 -3
- package/dist/esm/api/ans.mjs +1 -1
- package/dist/esm/api/aptos.d.mts +4 -4
- package/dist/esm/api/aptos.mjs +1 -1
- package/dist/esm/api/aptosConfig.d.mts +1 -1
- package/dist/esm/api/aptosConfig.mjs +1 -1
- package/dist/esm/api/coin.d.mts +5 -5
- package/dist/esm/api/coin.mjs +1 -1
- package/dist/esm/api/digitalAsset.d.mts +5 -5
- package/dist/esm/api/digitalAsset.mjs +1 -1
- package/dist/esm/api/event.d.mts +3 -3
- package/dist/esm/api/event.mjs +1 -1
- package/dist/esm/api/faucet.d.mts +2 -2
- package/dist/esm/api/faucet.mjs +1 -1
- package/dist/esm/api/fungibleAsset.d.mts +5 -5
- package/dist/esm/api/fungibleAsset.mjs +1 -1
- package/dist/esm/api/general.d.mts +3 -3
- package/dist/esm/api/general.mjs +1 -1
- package/dist/esm/api/index.d.mts +4 -4
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/keyless.d.mts +7 -7
- package/dist/esm/api/keyless.mjs +1 -1
- package/dist/esm/api/object.d.mts +3 -3
- package/dist/esm/api/object.mjs +1 -1
- package/dist/esm/api/staking.d.mts +3 -3
- package/dist/esm/api/staking.mjs +1 -1
- package/dist/esm/api/table.d.mts +3 -3
- package/dist/esm/api/table.mjs +1 -1
- package/dist/esm/api/transaction.d.mts +3 -3
- package/dist/esm/api/transaction.mjs +1 -1
- package/dist/esm/api/transactionSubmission/build.d.mts +3 -3
- package/dist/esm/api/transactionSubmission/build.mjs +1 -1
- package/dist/esm/api/transactionSubmission/management.d.mts +4 -4
- package/dist/esm/api/transactionSubmission/management.mjs +1 -1
- package/dist/esm/api/transactionSubmission/sign.d.mts +4 -4
- 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 +3 -3
- package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
- package/dist/esm/api/transactionSubmission/submit.d.mts +3 -3
- package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
- package/dist/esm/api/utils.d.mts +2 -2
- package/dist/esm/api/utils.mjs +1 -1
- package/dist/esm/bcs/consts.d.mts +2 -2
- package/dist/esm/bcs/deserializer.d.mts +35 -27
- package/dist/esm/bcs/deserializer.mjs +1 -1
- package/dist/esm/bcs/index.d.mts +2 -2
- package/dist/esm/bcs/index.mjs +1 -1
- package/dist/esm/bcs/serializable/entryFunctionBytes.d.mts +2 -2
- package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
- package/dist/esm/bcs/serializable/fixedBytes.d.mts +2 -2
- package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
- package/dist/esm/bcs/serializable/movePrimitives.d.mts +2 -2
- package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
- package/dist/esm/bcs/serializable/moveStructs.d.mts +11 -12
- package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
- package/dist/esm/bcs/serializer.d.mts +13 -13
- package/dist/esm/bcs/serializer.mjs +1 -1
- package/dist/esm/{chunk-22ZSW5EN.mjs → chunk-26WX3UFP.mjs} +2 -2
- package/dist/esm/{chunk-A2AEFKXS.mjs → chunk-2E3BT4YW.mjs} +2 -2
- package/dist/esm/{chunk-VYMRIKUV.mjs → chunk-2LQ4FTSR.mjs} +2 -2
- package/dist/esm/{chunk-L5J3V3HW.mjs → chunk-2REHS35S.mjs} +2 -2
- package/dist/esm/{chunk-CC7VOPYH.mjs → chunk-2YTHKFJZ.mjs} +2 -2
- package/dist/esm/{chunk-6FLHGOKP.mjs → chunk-42H7WETG.mjs} +2 -2
- package/dist/esm/{chunk-RBJNSUSU.mjs → chunk-4IQZOAN7.mjs} +2 -2
- package/dist/esm/{chunk-ZPQUCT22.mjs → chunk-4J2JYRV3.mjs} +2 -2
- package/dist/esm/chunk-4O5XDQDO.mjs +2 -0
- package/dist/esm/chunk-5B3SMBXQ.mjs +2 -0
- package/dist/esm/{chunk-5N6KJ7KS.mjs → chunk-5KCKWL2C.mjs} +2 -2
- package/dist/esm/{chunk-IFXUWUP2.mjs → chunk-5O3RHPER.mjs} +2 -2
- package/dist/esm/{chunk-PCLU4KLY.mjs → chunk-6ZOVTYLJ.mjs} +2 -2
- package/dist/esm/chunk-7ECCT6PK.mjs +1 -0
- package/dist/esm/{chunk-RAJTNQNL.mjs → chunk-7OHMMGS6.mjs} +2 -2
- package/dist/esm/{chunk-ZPIMARUG.mjs → chunk-A3USS2NC.mjs} +2 -2
- package/dist/esm/{chunk-NODYW7DM.mjs → chunk-ACVIE7IE.mjs} +2 -2
- package/dist/esm/{chunk-RNRNGJDA.mjs → chunk-AGEJNSEX.mjs} +2 -2
- package/dist/esm/{chunk-QQIVWB6G.mjs → chunk-AJ5JHBAE.mjs} +2 -2
- package/dist/esm/{chunk-QQIVWB6G.mjs.map → chunk-AJ5JHBAE.mjs.map} +1 -1
- package/dist/esm/{chunk-PRZ7AIGA.mjs → chunk-AKIO3OIT.mjs} +2 -2
- package/dist/esm/{chunk-KRVLR3L4.mjs → chunk-AOROYJ74.mjs} +2 -2
- package/dist/esm/chunk-AVZYJAXR.mjs +2 -0
- package/dist/esm/chunk-AVZYJAXR.mjs.map +1 -0
- package/dist/esm/{chunk-BG2TZI3H.mjs → chunk-BP45UJII.mjs} +2 -2
- package/dist/esm/{chunk-JGNMNCQB.mjs → chunk-BRV3RLKW.mjs} +2 -2
- package/dist/esm/{chunk-EE7GDBA5.mjs → chunk-CEW2NI3K.mjs} +2 -2
- package/dist/esm/{chunk-RNJHULIT.mjs → chunk-CPKG25HX.mjs} +2 -2
- package/dist/esm/chunk-CPKG25HX.mjs.map +1 -0
- package/dist/esm/chunk-D52UKPQF.mjs +2 -0
- package/dist/esm/chunk-D52UKPQF.mjs.map +1 -0
- package/dist/esm/{chunk-4LKLOUMG.mjs → chunk-D54FD6XE.mjs} +2 -2
- package/dist/esm/{chunk-MK2QAHXC.mjs → chunk-DYELAVMR.mjs} +2 -2
- package/dist/esm/{chunk-MSHZ4FWB.mjs → chunk-E2GPZCQI.mjs} +2 -2
- package/dist/esm/{chunk-MSHZ4FWB.mjs.map → chunk-E2GPZCQI.mjs.map} +1 -1
- package/dist/esm/chunk-EJKX6MGV.mjs +2 -0
- package/dist/esm/{chunk-WV2VJQDS.mjs.map → chunk-EJKX6MGV.mjs.map} +1 -1
- package/dist/esm/{chunk-OXM4BVAY.mjs → chunk-ERDYU5YQ.mjs} +2 -2
- package/dist/esm/{chunk-7JK7UG4E.mjs → chunk-ETF76XA3.mjs} +2 -2
- package/dist/esm/chunk-F45G3GP3.mjs +7 -0
- package/dist/esm/chunk-F45G3GP3.mjs.map +1 -0
- package/dist/esm/chunk-FD6FGKYY.mjs +1 -0
- package/dist/esm/{chunk-LDZPO76C.mjs → chunk-FFCCBAEZ.mjs} +2 -2
- package/dist/esm/chunk-FYYTCJS4.mjs +2 -0
- package/dist/esm/chunk-FYYTCJS4.mjs.map +1 -0
- package/dist/esm/{chunk-OAEDFM7T.mjs → chunk-GX4CYRK4.mjs} +2 -2
- package/dist/esm/{chunk-UCRROMZN.mjs → chunk-GZBVXXUL.mjs} +2 -2
- package/dist/esm/{chunk-AT2ZGTXQ.mjs → chunk-H7AALSJ7.mjs} +2 -2
- package/dist/esm/{chunk-EUGLLGYW.mjs → chunk-HBWIDPNN.mjs} +2 -2
- package/dist/esm/{chunk-BVVHGSWC.mjs → chunk-HPZQGMSH.mjs} +2 -2
- package/dist/esm/{chunk-T5BCTWGK.mjs → chunk-I5GENJBA.mjs} +2 -2
- package/dist/esm/chunk-I5GENJBA.mjs.map +1 -0
- package/dist/esm/{chunk-73GCGRFW.mjs → chunk-II26BNYA.mjs} +2 -2
- package/dist/esm/{chunk-BOWPP6YG.mjs → chunk-IQ4SCMB6.mjs} +2 -2
- package/dist/esm/chunk-IUSAYAEI.mjs +4 -0
- package/dist/esm/{chunk-HM5HITUC.mjs.map → chunk-IUSAYAEI.mjs.map} +1 -1
- package/dist/esm/{chunk-J245N3XF.mjs → chunk-J7PJSK3J.mjs} +2 -2
- package/dist/esm/{chunk-J245N3XF.mjs.map → chunk-J7PJSK3J.mjs.map} +1 -1
- package/dist/esm/{chunk-CL6EEMSL.mjs → chunk-JGLEKXFP.mjs} +2 -2
- package/dist/esm/{chunk-SOLWFAUY.mjs → chunk-JIT2FYGE.mjs} +2 -2
- package/dist/esm/chunk-JIT2FYGE.mjs.map +1 -0
- package/dist/esm/chunk-JNO7KPMG.mjs +4 -0
- package/dist/esm/chunk-JNO7KPMG.mjs.map +1 -0
- package/dist/esm/{chunk-AZ6LVQEG.mjs → chunk-JONEH52T.mjs} +2 -2
- package/dist/esm/chunk-K62JTXWQ.mjs +2 -0
- package/dist/esm/chunk-K62JTXWQ.mjs.map +1 -0
- package/dist/esm/{chunk-IAVI3H4V.mjs → chunk-KCEI5JYS.mjs} +2 -2
- package/dist/esm/{chunk-XFY4O2S3.mjs → chunk-KM6IOJ6Y.mjs} +2 -2
- package/dist/esm/{chunk-DMSHPWA5.mjs → chunk-KTM6KVUJ.mjs} +2 -2
- package/dist/esm/chunk-KX43GEAB.mjs +2 -0
- package/dist/esm/chunk-KX43GEAB.mjs.map +1 -0
- package/dist/esm/{chunk-KYJU5PWF.mjs → chunk-L25CRR2W.mjs} +2 -2
- package/dist/esm/{chunk-2652SPOM.mjs → chunk-LGHPJTF3.mjs} +2 -2
- package/dist/esm/chunk-LGHPJTF3.mjs.map +1 -0
- package/dist/esm/{chunk-AGBA3Y7A.mjs → chunk-LGTOOAQI.mjs} +2 -2
- package/dist/esm/chunk-LHBMBCFC.mjs +2 -0
- package/dist/esm/chunk-LHBMBCFC.mjs.map +1 -0
- package/dist/esm/{chunk-F2RY4YQ7.mjs → chunk-LYO22HMF.mjs} +2 -2
- package/dist/esm/{chunk-KW4FVBDD.mjs → chunk-MBEWPBGN.mjs} +2 -2
- package/dist/esm/chunk-MHN6XY4Z.mjs +2 -0
- package/dist/esm/{chunk-JVTDP4KV.mjs → chunk-ML7D2CVG.mjs} +2 -2
- package/dist/esm/chunk-NF7ZQQE3.mjs +2 -0
- package/dist/esm/chunk-NF7ZQQE3.mjs.map +1 -0
- package/dist/esm/{chunk-XQ7ONNII.mjs → chunk-O4MRRWRI.mjs} +2 -2
- package/dist/esm/{chunk-PHP47DI4.mjs → chunk-OIOGOW6I.mjs} +1 -1
- package/dist/esm/{chunk-PHP47DI4.mjs.map → chunk-OIOGOW6I.mjs.map} +1 -1
- package/dist/esm/{chunk-ZINOJTLU.mjs → chunk-OPO5EYF7.mjs} +2 -2
- package/dist/esm/{chunk-6DMDYBV6.mjs → chunk-OVI7L7OG.mjs} +2 -2
- package/dist/esm/{chunk-TPJLAYW6.mjs → chunk-P2FTRAK3.mjs} +2 -2
- package/dist/esm/{chunk-IECDO22V.mjs → chunk-Q3CWUEXI.mjs} +2 -2
- package/dist/esm/chunk-Q3CWUEXI.mjs.map +1 -0
- package/dist/esm/{chunk-4JXB6V5O.mjs → chunk-RC43EXC4.mjs} +2 -2
- package/dist/esm/{chunk-WZCKSN2U.mjs → chunk-RLH25IDA.mjs} +2 -2
- package/dist/esm/{chunk-UGL2GPGK.mjs → chunk-RSO5YIDW.mjs} +2 -2
- package/dist/esm/chunk-RZGTHCJY.mjs +2 -0
- package/dist/esm/{chunk-2CGJLPHP.mjs.map → chunk-RZGTHCJY.mjs.map} +1 -1
- package/dist/esm/chunk-SPRNSFUV.mjs +2 -0
- package/dist/esm/chunk-SPRNSFUV.mjs.map +1 -0
- package/dist/esm/{chunk-2GEIHUHT.mjs → chunk-SPX2YFZN.mjs} +2 -2
- package/dist/esm/chunk-SPX2YFZN.mjs.map +1 -0
- package/dist/esm/chunk-SY4HK6CC.mjs +2 -0
- package/dist/esm/chunk-SY4HK6CC.mjs.map +1 -0
- package/dist/esm/{chunk-OTY3NO7Q.mjs → chunk-T6ADNZE5.mjs} +2 -2
- package/dist/esm/{chunk-3H5DGQKX.mjs → chunk-TGW36YOD.mjs} +2 -2
- package/dist/esm/{chunk-WSZCPSV4.mjs → chunk-TQA6HY6A.mjs} +2 -2
- package/dist/esm/{chunk-XFJD6QIP.mjs → chunk-U3GE6IPF.mjs} +2 -2
- package/dist/esm/chunk-UGTIALNW.mjs +2 -0
- package/dist/esm/{chunk-JNRMHDRA.mjs → chunk-UKVH4UGL.mjs} +2 -2
- package/dist/esm/chunk-UWLW2VLZ.mjs +2 -0
- package/dist/esm/chunk-UWLW2VLZ.mjs.map +1 -0
- package/dist/esm/chunk-UZTJWOLS.mjs +2 -0
- package/dist/esm/chunk-V4FKFCBL.mjs +2 -0
- package/dist/esm/chunk-V4FKFCBL.mjs.map +1 -0
- package/dist/esm/{chunk-4ZK3JNQT.mjs → chunk-VGITSRT6.mjs} +2 -2
- package/dist/esm/chunk-VGJIATTB.mjs +2 -0
- package/dist/esm/chunk-VGJIATTB.mjs.map +1 -0
- package/dist/esm/{chunk-XOCRDV2V.mjs → chunk-VQZMI3EZ.mjs} +2 -2
- package/dist/esm/chunk-WQF3IOXC.mjs +2 -0
- package/dist/esm/chunk-WQF3IOXC.mjs.map +1 -0
- package/dist/esm/chunk-WYOFF5DJ.mjs +2 -0
- package/dist/esm/chunk-WYOFF5DJ.mjs.map +1 -0
- package/dist/esm/{chunk-YZ5BCOGI.mjs → chunk-X7JNNNMC.mjs} +2 -2
- package/dist/esm/{chunk-JN36BNWA.mjs → chunk-XIB6LX22.mjs} +2 -2
- package/dist/esm/chunk-YIQ3JFHW.mjs +2 -0
- package/dist/esm/chunk-YIQ3JFHW.mjs.map +1 -0
- package/dist/esm/chunk-YP3VO6GM.mjs +2 -0
- package/dist/esm/chunk-YP3VO6GM.mjs.map +1 -0
- package/dist/esm/{chunk-OZN3OOJV.mjs → chunk-ZMBXHMVQ.mjs} +2 -2
- package/dist/esm/cli/index.d.mts +2 -2
- package/dist/esm/cli/index.mjs +1 -1
- package/dist/esm/cli/localNode.mjs +1 -1
- package/dist/esm/cli/move.d.mts +1 -1
- package/dist/esm/client/core.d.mts +1 -2
- package/dist/esm/client/core.mjs +1 -1
- package/dist/esm/client/get.d.mts +1 -2
- package/dist/esm/client/get.mjs +1 -1
- package/dist/esm/client/index.d.mts +2 -3
- package/dist/esm/client/index.mjs +1 -1
- package/dist/esm/client/post.d.mts +1 -2
- package/dist/esm/client/post.mjs +1 -1
- package/dist/esm/core/account/index.d.mts +2 -2
- package/dist/esm/core/account/index.mjs +1 -1
- package/dist/esm/core/account/utils/address.d.mts +2 -2
- package/dist/esm/core/account/utils/address.mjs +1 -1
- package/dist/esm/core/account/utils/index.d.mts +2 -2
- package/dist/esm/core/account/utils/index.mjs +1 -1
- package/dist/esm/core/accountAddress.d.mts +19 -10
- package/dist/esm/core/accountAddress.mjs +1 -1
- package/dist/esm/core/authenticationKey.d.mts +3 -3
- package/dist/esm/core/authenticationKey.mjs +1 -1
- package/dist/esm/core/crypto/ed25519.d.mts +26 -12
- package/dist/esm/core/crypto/ed25519.mjs +1 -1
- package/dist/esm/core/crypto/ephemeral.d.mts +3 -3
- package/dist/esm/core/crypto/ephemeral.mjs +1 -1
- package/dist/esm/core/crypto/federatedKeyless.d.mts +4 -4
- package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
- package/dist/esm/core/crypto/hdKey.d.mts +0 -1
- package/dist/esm/core/crypto/hdKey.mjs +1 -1
- package/dist/esm/core/crypto/index.d.mts +4 -4
- package/dist/esm/core/crypto/index.mjs +1 -1
- package/dist/esm/core/crypto/keyless.d.mts +72 -11
- package/dist/esm/core/crypto/keyless.mjs +1 -1
- package/dist/esm/core/crypto/multiEd25519.d.mts +3 -3
- package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
- package/dist/esm/core/crypto/multiKey.d.mts +3 -3
- package/dist/esm/core/crypto/multiKey.mjs +1 -1
- package/dist/esm/core/crypto/privateKey.d.mts +37 -10
- package/dist/esm/core/crypto/privateKey.mjs +1 -1
- package/dist/esm/core/crypto/proof.d.mts +2 -2
- package/dist/esm/core/crypto/proof.mjs +1 -1
- package/dist/esm/core/crypto/publicKey.d.mts +3 -3
- package/dist/esm/core/crypto/publicKey.mjs +1 -1
- package/dist/esm/core/crypto/secp256k1.d.mts +23 -9
- package/dist/esm/core/crypto/secp256k1.mjs +1 -1
- package/dist/esm/core/crypto/signature.d.mts +2 -2
- package/dist/esm/core/crypto/signature.mjs +1 -1
- package/dist/esm/core/crypto/singleKey.d.mts +3 -3
- package/dist/esm/core/crypto/singleKey.mjs +1 -1
- package/dist/esm/core/crypto/utils.d.mts +2 -2
- package/dist/esm/core/crypto/utils.mjs +1 -1
- package/dist/esm/core/hex.d.mts +39 -3
- package/dist/esm/core/hex.mjs +1 -1
- package/dist/esm/core/index.d.mts +5 -5
- package/dist/esm/core/index.mjs +1 -1
- package/dist/esm/errors/index.d.mts +122 -0
- package/dist/esm/errors/index.mjs +2 -0
- package/dist/esm/index.d.mts +10 -10
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internal/account.d.mts +4 -4
- package/dist/esm/internal/account.mjs +1 -1
- package/dist/esm/internal/ans.d.mts +4 -4
- package/dist/esm/internal/ans.mjs +1 -1
- package/dist/esm/internal/coin.d.mts +2 -2
- package/dist/esm/internal/coin.mjs +1 -1
- package/dist/esm/internal/digitalAsset.d.mts +4 -4
- 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 +1 -1
- package/dist/esm/internal/faucet.mjs +1 -1
- package/dist/esm/internal/fungibleAsset.d.mts +4 -4
- package/dist/esm/internal/fungibleAsset.mjs +1 -1
- package/dist/esm/internal/general.d.mts +2 -2
- package/dist/esm/internal/general.mjs +1 -1
- package/dist/esm/internal/keyless.d.mts +9 -5
- package/dist/esm/internal/keyless.mjs +1 -1
- package/dist/esm/internal/object.d.mts +2 -2
- package/dist/esm/internal/object.mjs +1 -1
- package/dist/esm/internal/staking.d.mts +1 -1
- package/dist/esm/internal/staking.mjs +1 -1
- package/dist/esm/internal/table.d.mts +2 -2
- package/dist/esm/internal/table.mjs +1 -1
- package/dist/esm/internal/transaction.d.mts +1 -1
- package/dist/esm/internal/transaction.mjs +1 -1
- package/dist/esm/internal/transactionSubmission.d.mts +3 -3
- package/dist/esm/internal/transactionSubmission.mjs +1 -1
- package/dist/esm/internal/view.d.mts +3 -3
- package/dist/esm/internal/view.mjs +1 -1
- package/dist/esm/{publicKey-_tPa99ea.d.mts → publicKey-BVXX1nVl.d.mts} +2 -2
- package/dist/esm/transactions/authenticator/account.d.mts +3 -3
- package/dist/esm/transactions/authenticator/account.mjs +1 -1
- package/dist/esm/transactions/authenticator/index.d.mts +3 -3
- package/dist/esm/transactions/authenticator/index.mjs +1 -1
- package/dist/esm/transactions/authenticator/transaction.d.mts +9 -4
- package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
- package/dist/esm/transactions/index.d.mts +3 -3
- package/dist/esm/transactions/index.mjs +1 -1
- package/dist/esm/transactions/instances/chainId.d.mts +2 -2
- package/dist/esm/transactions/instances/chainId.mjs +1 -1
- package/dist/esm/transactions/instances/identifier.d.mts +2 -2
- package/dist/esm/transactions/instances/identifier.mjs +1 -1
- package/dist/esm/transactions/instances/index.d.mts +3 -3
- package/dist/esm/transactions/instances/index.mjs +1 -1
- package/dist/esm/transactions/instances/moduleId.d.mts +2 -2
- package/dist/esm/transactions/instances/moduleId.mjs +1 -1
- package/dist/esm/transactions/instances/multiAgentTransaction.d.mts +2 -2
- package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rawTransaction.d.mts +2 -2
- package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rotationProofChallenge.d.mts +3 -3
- package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
- package/dist/esm/transactions/instances/signedTransaction.d.mts +3 -3
- package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/simpleTransaction.d.mts +2 -2
- package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/transactionArgument.d.mts +2 -2
- package/dist/esm/transactions/instances/transactionPayload.d.mts +2 -2
- package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
- package/dist/esm/transactions/management/accountSequenceNumber.d.mts +4 -4
- package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
- package/dist/esm/transactions/management/index.d.mts +4 -4
- package/dist/esm/transactions/management/index.mjs +1 -1
- package/dist/esm/transactions/management/transactionWorker.d.mts +4 -4
- package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/helpers.d.mts +2 -2
- package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/index.d.mts +3 -3
- package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +3 -3
- package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/signingMessage.d.mts +3 -3
- package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +3 -3
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
- package/dist/esm/transactions/typeTag/index.d.mts +2 -2
- package/dist/esm/transactions/typeTag/index.mjs +1 -1
- package/dist/esm/transactions/typeTag/parser.d.mts +2 -2
- package/dist/esm/transactions/typeTag/parser.mjs +1 -1
- package/dist/esm/transactions/types.d.mts +2 -2
- package/dist/esm/types/index.d.mts +3 -1260
- package/dist/esm/types/index.mjs +1 -1
- package/dist/esm/types/keyless.d.mts +22 -1
- package/dist/esm/types/types.d.mts +1289 -0
- package/dist/esm/types/types.mjs +2 -0
- package/dist/esm/types/types.mjs.map +1 -0
- package/dist/esm/utils/const.d.mts +7 -1
- package/dist/esm/utils/const.mjs +1 -1
- package/dist/esm/utils/helpers.d.mts +10 -3
- package/dist/esm/utils/helpers.mjs +1 -1
- package/dist/esm/utils/index.d.mts +3 -3
- package/dist/esm/utils/index.mjs +1 -1
- package/dist/esm/utils/normalizeBundle.d.mts +2 -2
- package/dist/esm/utils/normalizeBundle.mjs +1 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
- package/src/account/AbstractKeylessAccount.ts +203 -10
- package/src/account/FederatedKeylessAccount.ts +83 -35
- package/src/account/KeylessAccount.ts +44 -37
- package/src/account/MultiKeyAccount.ts +18 -5
- package/src/api/keyless.ts +2 -2
- package/src/bcs/deserializer.ts +53 -30
- package/src/bcs/serializable/moveStructs.ts +16 -17
- package/src/bcs/serializer.ts +22 -12
- package/src/client/core.ts +2 -2
- package/src/client/get.ts +1 -2
- package/src/client/index.ts +0 -1
- package/src/client/post.ts +1 -2
- package/src/core/accountAddress.ts +36 -9
- package/src/core/crypto/ed25519.ts +34 -14
- package/src/core/crypto/hdKey.ts +0 -1
- package/src/core/crypto/keyless.ts +245 -38
- package/src/core/crypto/privateKey.ts +81 -5
- package/src/core/crypto/secp256k1.ts +31 -11
- package/src/core/hex.ts +47 -0
- package/src/errors/index.ts +406 -0
- package/src/index.ts +1 -0
- package/src/internal/account.ts +6 -6
- package/src/internal/ans.ts +2 -1
- package/src/internal/keyless.ts +57 -19
- package/src/internal/transaction.ts +2 -1
- package/src/internal/transactionSubmission.ts +36 -18
- package/src/transactions/authenticator/transaction.ts +20 -0
- package/src/types/index.ts +1 -1483
- package/src/types/keyless.ts +19 -0
- package/src/types/types.ts +1512 -0
- package/src/utils/const.ts +7 -0
- package/src/utils/helpers.ts +10 -0
- package/src/version.ts +1 -1
- package/dist/common/chunk-7IYTZDXV.js +0 -2
- package/dist/common/chunk-7IYTZDXV.js.map +0 -1
- package/dist/esm/chunk-2652SPOM.mjs.map +0 -1
- package/dist/esm/chunk-2CGJLPHP.mjs +0 -2
- package/dist/esm/chunk-2GEIHUHT.mjs.map +0 -1
- package/dist/esm/chunk-4CDDWSKZ.mjs +0 -2
- package/dist/esm/chunk-4OV7QU2U.mjs +0 -2
- package/dist/esm/chunk-4VU2ABLU.mjs +0 -2
- package/dist/esm/chunk-4VU2ABLU.mjs.map +0 -1
- package/dist/esm/chunk-5S3Z7MT4.mjs +0 -2
- package/dist/esm/chunk-5S3Z7MT4.mjs.map +0 -1
- package/dist/esm/chunk-5SGSPCOY.mjs +0 -2
- package/dist/esm/chunk-5SGSPCOY.mjs.map +0 -1
- package/dist/esm/chunk-7XS45O6M.mjs +0 -2
- package/dist/esm/chunk-7XS45O6M.mjs.map +0 -1
- package/dist/esm/chunk-BAGUHYFD.mjs +0 -2
- package/dist/esm/chunk-BAGUHYFD.mjs.map +0 -1
- package/dist/esm/chunk-CDQGPCHU.mjs +0 -2
- package/dist/esm/chunk-CDQGPCHU.mjs.map +0 -1
- package/dist/esm/chunk-FTZGP6XW.mjs +0 -2
- package/dist/esm/chunk-FTZGP6XW.mjs.map +0 -1
- package/dist/esm/chunk-GLATLXF6.mjs +0 -2
- package/dist/esm/chunk-GLATLXF6.mjs.map +0 -1
- package/dist/esm/chunk-GQABU3RQ.mjs +0 -2
- package/dist/esm/chunk-GQABU3RQ.mjs.map +0 -1
- package/dist/esm/chunk-HM5HITUC.mjs +0 -4
- package/dist/esm/chunk-IBLZ6MZU.mjs +0 -2
- package/dist/esm/chunk-IECDO22V.mjs.map +0 -1
- package/dist/esm/chunk-KFNDDPOW.mjs +0 -2
- package/dist/esm/chunk-KFNDDPOW.mjs.map +0 -1
- package/dist/esm/chunk-KIW54KWR.mjs +0 -2
- package/dist/esm/chunk-KM6UXNC7.mjs +0 -2
- package/dist/esm/chunk-KM6UXNC7.mjs.map +0 -1
- package/dist/esm/chunk-KUX6GQ2E.mjs +0 -1
- package/dist/esm/chunk-LEKBJ2EG.mjs +0 -2
- package/dist/esm/chunk-LEKBJ2EG.mjs.map +0 -1
- package/dist/esm/chunk-M22UGFQ5.mjs +0 -2
- package/dist/esm/chunk-M22UGFQ5.mjs.map +0 -1
- package/dist/esm/chunk-N2FKVZ4D.mjs +0 -1
- package/dist/esm/chunk-N47FTRYO.mjs +0 -2
- package/dist/esm/chunk-N47FTRYO.mjs.map +0 -1
- package/dist/esm/chunk-ONBFUPEC.mjs +0 -2
- package/dist/esm/chunk-P3J54CQG.mjs +0 -2
- package/dist/esm/chunk-P3J54CQG.mjs.map +0 -1
- package/dist/esm/chunk-RNJHULIT.mjs.map +0 -1
- package/dist/esm/chunk-SGQFWWLQ.mjs +0 -2
- package/dist/esm/chunk-SGQFWWLQ.mjs.map +0 -1
- package/dist/esm/chunk-SOLWFAUY.mjs.map +0 -1
- package/dist/esm/chunk-T5BCTWGK.mjs.map +0 -1
- package/dist/esm/chunk-WV2VJQDS.mjs +0 -2
- package/dist/esm/chunk-Y267I7DC.mjs +0 -2
- package/dist/esm/chunk-Y267I7DC.mjs.map +0 -1
- package/dist/esm/client/types.d.mts +0 -66
- package/dist/esm/client/types.mjs +0 -2
- package/src/client/types.ts +0 -138
- /package/dist/esm/{chunk-22ZSW5EN.mjs.map → chunk-26WX3UFP.mjs.map} +0 -0
- /package/dist/esm/{chunk-A2AEFKXS.mjs.map → chunk-2E3BT4YW.mjs.map} +0 -0
- /package/dist/esm/{chunk-VYMRIKUV.mjs.map → chunk-2LQ4FTSR.mjs.map} +0 -0
- /package/dist/esm/{chunk-L5J3V3HW.mjs.map → chunk-2REHS35S.mjs.map} +0 -0
- /package/dist/esm/{chunk-CC7VOPYH.mjs.map → chunk-2YTHKFJZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-6FLHGOKP.mjs.map → chunk-42H7WETG.mjs.map} +0 -0
- /package/dist/esm/{chunk-RBJNSUSU.mjs.map → chunk-4IQZOAN7.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZPQUCT22.mjs.map → chunk-4J2JYRV3.mjs.map} +0 -0
- /package/dist/esm/{chunk-IBLZ6MZU.mjs.map → chunk-4O5XDQDO.mjs.map} +0 -0
- /package/dist/esm/{chunk-KIW54KWR.mjs.map → chunk-5B3SMBXQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-5N6KJ7KS.mjs.map → chunk-5KCKWL2C.mjs.map} +0 -0
- /package/dist/esm/{chunk-IFXUWUP2.mjs.map → chunk-5O3RHPER.mjs.map} +0 -0
- /package/dist/esm/{chunk-PCLU4KLY.mjs.map → chunk-6ZOVTYLJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-KUX6GQ2E.mjs.map → chunk-7ECCT6PK.mjs.map} +0 -0
- /package/dist/esm/{chunk-RAJTNQNL.mjs.map → chunk-7OHMMGS6.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZPIMARUG.mjs.map → chunk-A3USS2NC.mjs.map} +0 -0
- /package/dist/esm/{chunk-NODYW7DM.mjs.map → chunk-ACVIE7IE.mjs.map} +0 -0
- /package/dist/esm/{chunk-RNRNGJDA.mjs.map → chunk-AGEJNSEX.mjs.map} +0 -0
- /package/dist/esm/{chunk-PRZ7AIGA.mjs.map → chunk-AKIO3OIT.mjs.map} +0 -0
- /package/dist/esm/{chunk-KRVLR3L4.mjs.map → chunk-AOROYJ74.mjs.map} +0 -0
- /package/dist/esm/{chunk-BG2TZI3H.mjs.map → chunk-BP45UJII.mjs.map} +0 -0
- /package/dist/esm/{chunk-JGNMNCQB.mjs.map → chunk-BRV3RLKW.mjs.map} +0 -0
- /package/dist/esm/{chunk-EE7GDBA5.mjs.map → chunk-CEW2NI3K.mjs.map} +0 -0
- /package/dist/esm/{chunk-4LKLOUMG.mjs.map → chunk-D54FD6XE.mjs.map} +0 -0
- /package/dist/esm/{chunk-MK2QAHXC.mjs.map → chunk-DYELAVMR.mjs.map} +0 -0
- /package/dist/esm/{chunk-OXM4BVAY.mjs.map → chunk-ERDYU5YQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-7JK7UG4E.mjs.map → chunk-ETF76XA3.mjs.map} +0 -0
- /package/dist/esm/{chunk-N2FKVZ4D.mjs.map → chunk-FD6FGKYY.mjs.map} +0 -0
- /package/dist/esm/{chunk-LDZPO76C.mjs.map → chunk-FFCCBAEZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-OAEDFM7T.mjs.map → chunk-GX4CYRK4.mjs.map} +0 -0
- /package/dist/esm/{chunk-UCRROMZN.mjs.map → chunk-GZBVXXUL.mjs.map} +0 -0
- /package/dist/esm/{chunk-AT2ZGTXQ.mjs.map → chunk-H7AALSJ7.mjs.map} +0 -0
- /package/dist/esm/{chunk-EUGLLGYW.mjs.map → chunk-HBWIDPNN.mjs.map} +0 -0
- /package/dist/esm/{chunk-BVVHGSWC.mjs.map → chunk-HPZQGMSH.mjs.map} +0 -0
- /package/dist/esm/{chunk-73GCGRFW.mjs.map → chunk-II26BNYA.mjs.map} +0 -0
- /package/dist/esm/{chunk-BOWPP6YG.mjs.map → chunk-IQ4SCMB6.mjs.map} +0 -0
- /package/dist/esm/{chunk-CL6EEMSL.mjs.map → chunk-JGLEKXFP.mjs.map} +0 -0
- /package/dist/esm/{chunk-AZ6LVQEG.mjs.map → chunk-JONEH52T.mjs.map} +0 -0
- /package/dist/esm/{chunk-IAVI3H4V.mjs.map → chunk-KCEI5JYS.mjs.map} +0 -0
- /package/dist/esm/{chunk-XFY4O2S3.mjs.map → chunk-KM6IOJ6Y.mjs.map} +0 -0
- /package/dist/esm/{chunk-DMSHPWA5.mjs.map → chunk-KTM6KVUJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-KYJU5PWF.mjs.map → chunk-L25CRR2W.mjs.map} +0 -0
- /package/dist/esm/{chunk-AGBA3Y7A.mjs.map → chunk-LGTOOAQI.mjs.map} +0 -0
- /package/dist/esm/{chunk-F2RY4YQ7.mjs.map → chunk-LYO22HMF.mjs.map} +0 -0
- /package/dist/esm/{chunk-KW4FVBDD.mjs.map → chunk-MBEWPBGN.mjs.map} +0 -0
- /package/dist/esm/{chunk-4OV7QU2U.mjs.map → chunk-MHN6XY4Z.mjs.map} +0 -0
- /package/dist/esm/{chunk-JVTDP4KV.mjs.map → chunk-ML7D2CVG.mjs.map} +0 -0
- /package/dist/esm/{chunk-XQ7ONNII.mjs.map → chunk-O4MRRWRI.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZINOJTLU.mjs.map → chunk-OPO5EYF7.mjs.map} +0 -0
- /package/dist/esm/{chunk-6DMDYBV6.mjs.map → chunk-OVI7L7OG.mjs.map} +0 -0
- /package/dist/esm/{chunk-TPJLAYW6.mjs.map → chunk-P2FTRAK3.mjs.map} +0 -0
- /package/dist/esm/{chunk-4JXB6V5O.mjs.map → chunk-RC43EXC4.mjs.map} +0 -0
- /package/dist/esm/{chunk-WZCKSN2U.mjs.map → chunk-RLH25IDA.mjs.map} +0 -0
- /package/dist/esm/{chunk-UGL2GPGK.mjs.map → chunk-RSO5YIDW.mjs.map} +0 -0
- /package/dist/esm/{chunk-OTY3NO7Q.mjs.map → chunk-T6ADNZE5.mjs.map} +0 -0
- /package/dist/esm/{chunk-3H5DGQKX.mjs.map → chunk-TGW36YOD.mjs.map} +0 -0
- /package/dist/esm/{chunk-WSZCPSV4.mjs.map → chunk-TQA6HY6A.mjs.map} +0 -0
- /package/dist/esm/{chunk-XFJD6QIP.mjs.map → chunk-U3GE6IPF.mjs.map} +0 -0
- /package/dist/esm/{chunk-ONBFUPEC.mjs.map → chunk-UGTIALNW.mjs.map} +0 -0
- /package/dist/esm/{chunk-JNRMHDRA.mjs.map → chunk-UKVH4UGL.mjs.map} +0 -0
- /package/dist/esm/{chunk-4CDDWSKZ.mjs.map → chunk-UZTJWOLS.mjs.map} +0 -0
- /package/dist/esm/{chunk-4ZK3JNQT.mjs.map → chunk-VGITSRT6.mjs.map} +0 -0
- /package/dist/esm/{chunk-XOCRDV2V.mjs.map → chunk-VQZMI3EZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-YZ5BCOGI.mjs.map → chunk-X7JNNNMC.mjs.map} +0 -0
- /package/dist/esm/{chunk-JN36BNWA.mjs.map → chunk-XIB6LX22.mjs.map} +0 -0
- /package/dist/esm/{chunk-OZN3OOJV.mjs.map → chunk-ZMBXHMVQ.mjs.map} +0 -0
- /package/dist/esm/{client/types.mjs.map → errors/index.mjs.map} +0 -0
|
@@ -6,7 +6,7 @@ import { Deserializer } from "../../bcs/deserializer";
|
|
|
6
6
|
import { Serializable, Serializer } from "../../bcs/serializer";
|
|
7
7
|
import { AuthenticationKey } from "../authenticationKey";
|
|
8
8
|
import { Hex } from "../hex";
|
|
9
|
-
import { HexInput, SigningScheme as AuthenticationKeyScheme } from "../../types";
|
|
9
|
+
import { HexInput, SigningScheme as AuthenticationKeyScheme, PrivateKeyVariants } from "../../types";
|
|
10
10
|
import { CKDPriv, deriveKey, HARDENED_OFFSET, isValidHardenedPath, mnemonicToSeed, splitPath } from "./hdKey";
|
|
11
11
|
import { PrivateKey } from "./privateKey";
|
|
12
12
|
import { AccountPublicKey, PublicKey, VerifySignatureArgs } from "./publicKey";
|
|
@@ -181,21 +181,18 @@ export class Ed25519PublicKey extends AccountPublicKey {
|
|
|
181
181
|
|
|
182
182
|
/**
|
|
183
183
|
* Represents the private key of an Ed25519 key pair.
|
|
184
|
-
*
|
|
185
|
-
* @static
|
|
186
|
-
* @readonly LENGTH - Length of an Ed25519 private key.
|
|
187
|
-
* @static
|
|
188
|
-
* @readonly SLIP_0010_SEED - The Ed25519 key seed to use for BIP-32 compatibility.
|
|
189
184
|
*/
|
|
190
185
|
export class Ed25519PrivateKey extends Serializable implements PrivateKey {
|
|
191
186
|
/**
|
|
192
187
|
* Length of an Ed25519 private key
|
|
188
|
+
* @readonly
|
|
193
189
|
*/
|
|
194
190
|
static readonly LENGTH: number = 32;
|
|
195
191
|
|
|
196
192
|
/**
|
|
197
193
|
* The Ed25519 key seed to use for BIP-32 compatibility
|
|
198
194
|
* See more {@link https://github.com/satoshilabs/slips/blob/master/slip-0010.md}
|
|
195
|
+
* @readonly
|
|
199
196
|
*/
|
|
200
197
|
static readonly SLIP_0010_SEED = "ed25519 seed";
|
|
201
198
|
|
|
@@ -210,12 +207,15 @@ export class Ed25519PrivateKey extends Serializable implements PrivateKey {
|
|
|
210
207
|
/**
|
|
211
208
|
* Create a new PrivateKey instance from a Uint8Array or String.
|
|
212
209
|
*
|
|
210
|
+
* [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)
|
|
211
|
+
*
|
|
213
212
|
* @param hexInput HexInput (string or Uint8Array)
|
|
213
|
+
* @param strict If true, private key must AIP-80 compliant.
|
|
214
214
|
*/
|
|
215
|
-
constructor(hexInput: HexInput) {
|
|
215
|
+
constructor(hexInput: HexInput, strict?: boolean) {
|
|
216
216
|
super();
|
|
217
217
|
|
|
218
|
-
const privateKeyHex =
|
|
218
|
+
const privateKeyHex = PrivateKey.parseHexInput(hexInput, PrivateKeyVariants.Ed25519, strict);
|
|
219
219
|
if (privateKeyHex.toUint8Array().length !== Ed25519PrivateKey.LENGTH) {
|
|
220
220
|
throw new Error(`PrivateKey length should be ${Ed25519PrivateKey.LENGTH}`);
|
|
221
221
|
}
|
|
@@ -231,7 +231,7 @@ export class Ed25519PrivateKey extends Serializable implements PrivateKey {
|
|
|
231
231
|
*/
|
|
232
232
|
static generate(): Ed25519PrivateKey {
|
|
233
233
|
const keyPair = ed25519.utils.randomPrivateKey();
|
|
234
|
-
return new Ed25519PrivateKey(keyPair);
|
|
234
|
+
return new Ed25519PrivateKey(keyPair, false);
|
|
235
235
|
}
|
|
236
236
|
|
|
237
237
|
/**
|
|
@@ -271,7 +271,7 @@ export class Ed25519PrivateKey extends Serializable implements PrivateKey {
|
|
|
271
271
|
key,
|
|
272
272
|
chainCode,
|
|
273
273
|
});
|
|
274
|
-
return new Ed25519PrivateKey(privateKey);
|
|
274
|
+
return new Ed25519PrivateKey(privateKey, false);
|
|
275
275
|
}
|
|
276
276
|
|
|
277
277
|
// endregion
|
|
@@ -317,9 +317,29 @@ export class Ed25519PrivateKey extends Serializable implements PrivateKey {
|
|
|
317
317
|
* @returns string representation of the private key.
|
|
318
318
|
*/
|
|
319
319
|
toString(): string {
|
|
320
|
+
return this.toHexString();
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Get the private key as a hex string with the 0x prefix.
|
|
325
|
+
*
|
|
326
|
+
* @returns string representation of the private key.
|
|
327
|
+
*/
|
|
328
|
+
toHexString(): string {
|
|
320
329
|
return this.signingKey.toString();
|
|
321
330
|
}
|
|
322
331
|
|
|
332
|
+
/**
|
|
333
|
+
* Get the private key as a AIP-80 compliant hex string.
|
|
334
|
+
*
|
|
335
|
+
* [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)
|
|
336
|
+
*
|
|
337
|
+
* @returns AIP-80 compliant string representation of the private key.
|
|
338
|
+
*/
|
|
339
|
+
toAIP80String(): string {
|
|
340
|
+
return PrivateKey.formatPrivateKey(this.signingKey.toString(), PrivateKeyVariants.Ed25519);
|
|
341
|
+
}
|
|
342
|
+
|
|
323
343
|
// endregion
|
|
324
344
|
|
|
325
345
|
// region Serializable
|
|
@@ -330,7 +350,7 @@ export class Ed25519PrivateKey extends Serializable implements PrivateKey {
|
|
|
330
350
|
|
|
331
351
|
static deserialize(deserializer: Deserializer): Ed25519PrivateKey {
|
|
332
352
|
const bytes = deserializer.deserializeBytes();
|
|
333
|
-
return new Ed25519PrivateKey(bytes);
|
|
353
|
+
return new Ed25519PrivateKey(bytes, false);
|
|
334
354
|
}
|
|
335
355
|
|
|
336
356
|
// endregion
|
|
@@ -350,12 +370,12 @@ export class Ed25519PrivateKey extends Serializable implements PrivateKey {
|
|
|
350
370
|
|
|
351
371
|
/**
|
|
352
372
|
* Represents a signature of a message signed using an Ed25519 private key.
|
|
353
|
-
*
|
|
354
|
-
* @static LENGTH - Length of an Ed25519 signature, which is 64 bytes.
|
|
355
373
|
*/
|
|
356
374
|
export class Ed25519Signature extends Signature {
|
|
357
375
|
/**
|
|
358
|
-
* Length of an Ed25519 signature
|
|
376
|
+
* Length of an Ed25519 signature, which is 64 bytes.
|
|
377
|
+
*
|
|
378
|
+
* @readonly
|
|
359
379
|
*/
|
|
360
380
|
static readonly LENGTH = 64;
|
|
361
381
|
|
package/src/core/crypto/hdKey.ts
CHANGED
|
@@ -75,7 +75,6 @@ export const deriveKey = (hashSeed: Uint8Array | string, data: Uint8Array | stri
|
|
|
75
75
|
* @param key
|
|
76
76
|
* @param chainCode
|
|
77
77
|
* @param index
|
|
78
|
-
* @constructor
|
|
79
78
|
*/
|
|
80
79
|
export const CKDPriv = ({ key, chainCode }: DerivedKeys, index: number): DerivedKeys => {
|
|
81
80
|
const buffer = new ArrayBuffer(4);
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
// Copyright © Aptos Foundation
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
// eslint-disable-next-line max-classes-per-file
|
|
4
5
|
import { JwtPayload, jwtDecode } from "jwt-decode";
|
|
6
|
+
import { sha3_256 } from "@noble/hashes/sha3";
|
|
5
7
|
import { AccountPublicKey, PublicKey } from "./publicKey";
|
|
6
8
|
import { Signature } from "./signature";
|
|
7
9
|
import { Deserializer, Serializable, Serializer } from "../../bcs";
|
|
8
|
-
import { Hex } from "../hex";
|
|
10
|
+
import { Hex, hexToAsciiString } from "../hex";
|
|
9
11
|
import {
|
|
10
12
|
HexInput,
|
|
11
13
|
EphemeralCertificateVariant,
|
|
@@ -20,11 +22,18 @@ import { bigIntToBytesLE, bytesToBigIntLE, hashStrToField, poseidonHash } from "
|
|
|
20
22
|
import { AuthenticationKey } from "../authenticationKey";
|
|
21
23
|
import { Proof } from "./proof";
|
|
22
24
|
import { Ed25519PublicKey, Ed25519Signature } from "./ed25519";
|
|
23
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
Groth16VerificationKeyResponse,
|
|
27
|
+
KeylessConfigurationResponse,
|
|
28
|
+
MoveAnyStruct,
|
|
29
|
+
PatchedJWKsResponse,
|
|
30
|
+
} from "../../types/keyless";
|
|
24
31
|
import { AptosConfig } from "../../api/aptosConfig";
|
|
25
32
|
import { getAptosFullNode } from "../../client";
|
|
26
33
|
import { memoizeAsync } from "../../utils/memoize";
|
|
27
|
-
import { AccountAddress } from "../accountAddress";
|
|
34
|
+
import { AccountAddress, AccountAddressInput } from "../accountAddress";
|
|
35
|
+
import { getErrorMessage } from "../../utils";
|
|
36
|
+
import { KeylessError, KeylessErrorType } from "../../errors";
|
|
28
37
|
|
|
29
38
|
export const EPK_HORIZON_SECS = 10000000;
|
|
30
39
|
export const MAX_AUD_VAL_BYTES = 120;
|
|
@@ -282,6 +291,15 @@ export class KeylessSignature extends Signature {
|
|
|
282
291
|
this.ephemeralSignature = ephemeralSignature;
|
|
283
292
|
}
|
|
284
293
|
|
|
294
|
+
/**
|
|
295
|
+
* Get the kid of the JWT used to derive the Keyless Account used to sign.
|
|
296
|
+
*
|
|
297
|
+
* @returns the kid as a string
|
|
298
|
+
*/
|
|
299
|
+
getJwkKid(): string {
|
|
300
|
+
return parseJwtHeader(this.jwtHeader).kid;
|
|
301
|
+
}
|
|
302
|
+
|
|
285
303
|
serialize(serializer: Serializer): void {
|
|
286
304
|
this.ephemeralCertificate.serialize(serializer);
|
|
287
305
|
serializer.serializeStr(this.jwtHeader);
|
|
@@ -568,16 +586,16 @@ export class ZeroKnowledgeSig extends Signature {
|
|
|
568
586
|
serialize(serializer: Serializer): void {
|
|
569
587
|
this.proof.serialize(serializer);
|
|
570
588
|
serializer.serializeU64(this.expHorizonSecs);
|
|
571
|
-
serializer.
|
|
572
|
-
serializer.
|
|
589
|
+
serializer.serializeOption(this.extraField);
|
|
590
|
+
serializer.serializeOption(this.overrideAudVal);
|
|
573
591
|
serializer.serializeOption(this.trainingWheelsSignature);
|
|
574
592
|
}
|
|
575
593
|
|
|
576
594
|
static deserialize(deserializer: Deserializer): ZeroKnowledgeSig {
|
|
577
595
|
const proof = ZkProof.deserialize(deserializer);
|
|
578
596
|
const expHorizonSecs = Number(deserializer.deserializeU64());
|
|
579
|
-
const extraField = deserializer.
|
|
580
|
-
const overrideAudVal = deserializer.
|
|
597
|
+
const extraField = deserializer.deserializeOption("string");
|
|
598
|
+
const overrideAudVal = deserializer.deserializeOption("string");
|
|
581
599
|
const trainingWheelsSignature = deserializer.deserializeOption(EphemeralSignature);
|
|
582
600
|
return new ZeroKnowledgeSig({ proof, expHorizonSecs, trainingWheelsSignature, extraField, overrideAudVal });
|
|
583
601
|
}
|
|
@@ -594,16 +612,15 @@ export class KeylessConfiguration {
|
|
|
594
612
|
/**
|
|
595
613
|
* The verification key used to verify Groth16 proofs on chain
|
|
596
614
|
*/
|
|
597
|
-
|
|
598
|
-
readonly verficationKey: Groth16VerificationKey;
|
|
615
|
+
readonly verificationKey: Groth16VerificationKey;
|
|
599
616
|
|
|
600
617
|
/**
|
|
601
618
|
* The maximum lifespan of an ephemeral key pair. This is configured on chain.
|
|
602
619
|
*/
|
|
603
620
|
readonly maxExpHorizonSecs: number;
|
|
604
621
|
|
|
605
|
-
constructor(
|
|
606
|
-
this.
|
|
622
|
+
constructor(verificationKey: Groth16VerificationKey, maxExpHorizonSecs: number) {
|
|
623
|
+
this.verificationKey = verificationKey;
|
|
607
624
|
this.maxExpHorizonSecs = maxExpHorizonSecs;
|
|
608
625
|
}
|
|
609
626
|
|
|
@@ -624,7 +641,7 @@ export class KeylessConfiguration {
|
|
|
624
641
|
/**
|
|
625
642
|
* Represents the verification key stored on-chain used to verify Groth16 proofs.
|
|
626
643
|
*/
|
|
627
|
-
class Groth16VerificationKey {
|
|
644
|
+
export class Groth16VerificationKey {
|
|
628
645
|
// The docstrings below are borrowed from ark-groth16
|
|
629
646
|
|
|
630
647
|
/**
|
|
@@ -645,7 +662,7 @@ class Groth16VerificationKey {
|
|
|
645
662
|
/**
|
|
646
663
|
* The `gamma^{-1} * (beta * a_i + alpha * b_i + c_i) * H`, where H is the generator of G1
|
|
647
664
|
*/
|
|
648
|
-
readonly gammaAbcG1: G1Bytes
|
|
665
|
+
readonly gammaAbcG1: [G1Bytes, G1Bytes];
|
|
649
666
|
|
|
650
667
|
/**
|
|
651
668
|
* The `gamma * H`, where `H` is the generator of G2
|
|
@@ -667,6 +684,27 @@ class Groth16VerificationKey {
|
|
|
667
684
|
this.gammaG2 = new G2Bytes(gammaG2);
|
|
668
685
|
}
|
|
669
686
|
|
|
687
|
+
/**
|
|
688
|
+
* Calculates the hash of the serialized form of the verification key.
|
|
689
|
+
* This is useful for comparing verification keys or using them as unique identifiers.
|
|
690
|
+
*
|
|
691
|
+
* @returns The SHA3-256 hash of the serialized verification key as a Uint8Array
|
|
692
|
+
*/
|
|
693
|
+
public hash(): Uint8Array {
|
|
694
|
+
const serializer = new Serializer();
|
|
695
|
+
this.serialize(serializer);
|
|
696
|
+
return sha3_256.create().update(serializer.toUint8Array()).digest();
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
serialize(serializer: Serializer): void {
|
|
700
|
+
this.alphaG1.serialize(serializer);
|
|
701
|
+
this.betaG2.serialize(serializer);
|
|
702
|
+
this.deltaG2.serialize(serializer);
|
|
703
|
+
this.gammaAbcG1[0].serialize(serializer);
|
|
704
|
+
this.gammaAbcG1[1].serialize(serializer);
|
|
705
|
+
this.gammaG2.serialize(serializer);
|
|
706
|
+
}
|
|
707
|
+
|
|
670
708
|
/**
|
|
671
709
|
* Converts a Groth16VerificationKeyResponse object into a Groth16VerificationKey instance.
|
|
672
710
|
*
|
|
@@ -704,15 +742,64 @@ export async function getKeylessConfig(args: {
|
|
|
704
742
|
options?: LedgerVersionArg;
|
|
705
743
|
}): Promise<KeylessConfiguration> {
|
|
706
744
|
const { aptosConfig } = args;
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
745
|
+
try {
|
|
746
|
+
return await memoizeAsync(
|
|
747
|
+
async () => {
|
|
748
|
+
const config = await getKeylessConfigurationResource(args);
|
|
749
|
+
const vk = await getGroth16VerificationKeyResource(args);
|
|
750
|
+
return KeylessConfiguration.create(vk, Number(config.max_exp_horizon_secs));
|
|
751
|
+
},
|
|
752
|
+
`keyless-configuration-${aptosConfig.network}`,
|
|
753
|
+
1000 * 60 * 5, // 5 minutes
|
|
754
|
+
)();
|
|
755
|
+
} catch (error) {
|
|
756
|
+
if (error instanceof KeylessError) {
|
|
757
|
+
throw error;
|
|
758
|
+
}
|
|
759
|
+
throw KeylessError.fromErrorType({
|
|
760
|
+
type: KeylessErrorType.FULL_NODE_OTHER,
|
|
761
|
+
error,
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* Parses a JWT and returns the 'iss', 'aud', and 'uid' values.
|
|
768
|
+
*
|
|
769
|
+
* @param args - The arguments for parsing the JWT.
|
|
770
|
+
* @param args.jwt - The JWT to parse.
|
|
771
|
+
* @param args.uidKey - The key to use for the 'uid' value; defaults to 'sub'.
|
|
772
|
+
* @returns The 'iss', 'aud', and 'uid' values from the JWT.
|
|
773
|
+
*/
|
|
774
|
+
export function getIssAudAndUidVal(args: { jwt: string; uidKey?: string }): {
|
|
775
|
+
iss: string;
|
|
776
|
+
aud: string;
|
|
777
|
+
uidVal: string;
|
|
778
|
+
} {
|
|
779
|
+
const { jwt, uidKey = "sub" } = args;
|
|
780
|
+
let jwtPayload: JwtPayload & { [key: string]: string };
|
|
781
|
+
try {
|
|
782
|
+
jwtPayload = jwtDecode<JwtPayload & { [key: string]: string }>(jwt);
|
|
783
|
+
} catch (error) {
|
|
784
|
+
throw KeylessError.fromErrorType({
|
|
785
|
+
type: KeylessErrorType.JWT_PARSING_ERROR,
|
|
786
|
+
details: `Failed to parse JWT - ${getErrorMessage(error)}`,
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
if (typeof jwtPayload.iss !== "string") {
|
|
790
|
+
throw KeylessError.fromErrorType({
|
|
791
|
+
type: KeylessErrorType.JWT_PARSING_ERROR,
|
|
792
|
+
details: "JWT is missing 'iss' in the payload. This should never happen.",
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
if (typeof jwtPayload.aud !== "string") {
|
|
796
|
+
throw KeylessError.fromErrorType({
|
|
797
|
+
type: KeylessErrorType.JWT_PARSING_ERROR,
|
|
798
|
+
details: "JWT is missing 'aud' in the payload or 'aud' is an array of values.",
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
const uidVal = jwtPayload[uidKey];
|
|
802
|
+
return { iss: jwtPayload.iss, aud: jwtPayload.aud, uidVal };
|
|
716
803
|
}
|
|
717
804
|
|
|
718
805
|
/**
|
|
@@ -730,14 +817,20 @@ async function getKeylessConfigurationResource(args: {
|
|
|
730
817
|
}): Promise<KeylessConfigurationResponse> {
|
|
731
818
|
const { aptosConfig, options } = args;
|
|
732
819
|
const resourceType = "0x1::keyless_account::Configuration";
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
820
|
+
try {
|
|
821
|
+
const { data } = await getAptosFullNode<{}, MoveResource<KeylessConfigurationResponse>>({
|
|
822
|
+
aptosConfig,
|
|
823
|
+
originMethod: "getKeylessConfigurationResource",
|
|
824
|
+
path: `accounts/${AccountAddress.from("0x1").toString()}/resource/${resourceType}`,
|
|
825
|
+
params: { ledger_version: options?.ledgerVersion },
|
|
826
|
+
});
|
|
827
|
+
return data.data;
|
|
828
|
+
} catch (error) {
|
|
829
|
+
throw KeylessError.fromErrorType({
|
|
830
|
+
type: KeylessErrorType.FULL_NODE_CONFIG_LOOKUP_ERROR,
|
|
831
|
+
error,
|
|
832
|
+
});
|
|
833
|
+
}
|
|
741
834
|
}
|
|
742
835
|
|
|
743
836
|
/**
|
|
@@ -755,12 +848,126 @@ async function getGroth16VerificationKeyResource(args: {
|
|
|
755
848
|
}): Promise<Groth16VerificationKeyResponse> {
|
|
756
849
|
const { aptosConfig, options } = args;
|
|
757
850
|
const resourceType = "0x1::keyless_account::Groth16VerificationKey";
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
851
|
+
try {
|
|
852
|
+
const { data } = await getAptosFullNode<{}, MoveResource<Groth16VerificationKeyResponse>>({
|
|
853
|
+
aptosConfig,
|
|
854
|
+
originMethod: "getGroth16VerificationKeyResource",
|
|
855
|
+
path: `accounts/${AccountAddress.from("0x1").toString()}/resource/${resourceType}`,
|
|
856
|
+
params: { ledger_version: options?.ledgerVersion },
|
|
857
|
+
});
|
|
858
|
+
return data.data;
|
|
859
|
+
} catch (error) {
|
|
860
|
+
throw KeylessError.fromErrorType({
|
|
861
|
+
type: KeylessErrorType.FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR,
|
|
862
|
+
error,
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
export async function getKeylessJWKs(args: {
|
|
868
|
+
aptosConfig: AptosConfig;
|
|
869
|
+
jwkAddr?: AccountAddressInput;
|
|
870
|
+
options?: LedgerVersionArg;
|
|
871
|
+
}): Promise<Map<string, MoveJWK[]>> {
|
|
872
|
+
const { aptosConfig, jwkAddr, options } = args;
|
|
873
|
+
let resource: MoveResource<PatchedJWKsResponse>;
|
|
874
|
+
if (!jwkAddr) {
|
|
875
|
+
const resourceType = "0x1::jwks::PatchedJWKs";
|
|
876
|
+
const { data } = await getAptosFullNode<{}, MoveResource<PatchedJWKsResponse>>({
|
|
877
|
+
aptosConfig,
|
|
878
|
+
originMethod: "getKeylessJWKs",
|
|
879
|
+
path: `accounts/0x1/resource/${resourceType}`,
|
|
880
|
+
params: { ledger_version: options?.ledgerVersion },
|
|
881
|
+
});
|
|
882
|
+
resource = data;
|
|
883
|
+
} else {
|
|
884
|
+
const resourceType = "0x1::jwks::FederatedJWKs";
|
|
885
|
+
const { data } = await getAptosFullNode<{}, MoveResource<PatchedJWKsResponse>>({
|
|
886
|
+
aptosConfig,
|
|
887
|
+
originMethod: "getKeylessJWKs",
|
|
888
|
+
path: `accounts/${AccountAddress.from(jwkAddr).toString()}/resource/${resourceType}`,
|
|
889
|
+
params: { ledger_version: options?.ledgerVersion },
|
|
890
|
+
});
|
|
891
|
+
resource = data;
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
// Create a map of issuer to JWK arrays
|
|
895
|
+
const jwkMap = new Map<string, MoveJWK[]>();
|
|
896
|
+
for (const entry of resource.data.jwks.entries) {
|
|
897
|
+
const jwks: MoveJWK[] = [];
|
|
898
|
+
for (const jwkStruct of entry.jwks) {
|
|
899
|
+
const { data: jwkData } = jwkStruct.variant;
|
|
900
|
+
const deserializer = new Deserializer(Hex.fromHexInput(jwkData).toUint8Array());
|
|
901
|
+
const jwk = MoveJWK.deserialize(deserializer);
|
|
902
|
+
jwks.push(jwk);
|
|
903
|
+
}
|
|
904
|
+
jwkMap.set(hexToAsciiString(entry.issuer), jwks);
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
return jwkMap;
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
export class MoveJWK extends Serializable {
|
|
911
|
+
public kid: string;
|
|
912
|
+
|
|
913
|
+
public kty: string;
|
|
914
|
+
|
|
915
|
+
public alg: string;
|
|
916
|
+
|
|
917
|
+
public e: string;
|
|
918
|
+
|
|
919
|
+
public n: string;
|
|
920
|
+
|
|
921
|
+
constructor(args: { kid: string; kty: string; alg: string; e: string; n: string }) {
|
|
922
|
+
super();
|
|
923
|
+
const { kid, kty, alg, e, n } = args;
|
|
924
|
+
this.kid = kid;
|
|
925
|
+
this.kty = kty;
|
|
926
|
+
this.alg = alg;
|
|
927
|
+
this.e = e;
|
|
928
|
+
this.n = n;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
serialize(serializer: Serializer): void {
|
|
932
|
+
serializer.serializeStr(this.kid);
|
|
933
|
+
serializer.serializeStr(this.kty);
|
|
934
|
+
serializer.serializeStr(this.alg);
|
|
935
|
+
serializer.serializeStr(this.e);
|
|
936
|
+
serializer.serializeStr(this.n);
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
static fromMoveStruct(struct: MoveAnyStruct): MoveJWK {
|
|
940
|
+
const { data } = struct.variant;
|
|
941
|
+
const deserializer = new Deserializer(Hex.fromHexInput(data).toUint8Array());
|
|
942
|
+
return MoveJWK.deserialize(deserializer);
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
static deserialize(deserializer: Deserializer): MoveJWK {
|
|
946
|
+
const kid = deserializer.deserializeStr();
|
|
947
|
+
const kty = deserializer.deserializeStr();
|
|
948
|
+
const alg = deserializer.deserializeStr();
|
|
949
|
+
const n = deserializer.deserializeStr();
|
|
950
|
+
const e = deserializer.deserializeStr();
|
|
951
|
+
return new MoveJWK({ kid, kty, alg, n, e });
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
interface JwtHeader {
|
|
956
|
+
kid: string; // Key ID
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Safely parses the JWT header.
|
|
960
|
+
* @param jwtHeader The JWT header string
|
|
961
|
+
* @returns Parsed JWT header as an object.
|
|
962
|
+
*/
|
|
963
|
+
export function parseJwtHeader(jwtHeader: string): JwtHeader {
|
|
964
|
+
try {
|
|
965
|
+
const header = JSON.parse(jwtHeader);
|
|
966
|
+
if (header.kid === undefined) {
|
|
967
|
+
throw new Error("JWT header missing kid");
|
|
968
|
+
}
|
|
969
|
+
return header;
|
|
970
|
+
} catch (error) {
|
|
971
|
+
throw new Error("Failed to parse JWT header.");
|
|
972
|
+
}
|
|
766
973
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
|
|
3
|
+
import { HexInput, PrivateKeyVariants } from "../../types";
|
|
4
|
+
import { Hex } from "../hex";
|
|
2
5
|
import { PublicKey } from "./publicKey";
|
|
3
6
|
import { Signature } from "./signature";
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
9
|
* Represents a private key used for signing messages and deriving the associated public key.
|
|
7
|
-
*
|
|
8
|
-
* @method sign - Signs the given message with the private key.
|
|
9
|
-
* @method publicKey - Derives the public key associated with the private key.
|
|
10
|
-
* @method toUint8Array - Retrieves the private key in bytes.
|
|
11
10
|
*/
|
|
12
11
|
export interface PrivateKey {
|
|
13
12
|
/**
|
|
@@ -27,3 +26,80 @@ export interface PrivateKey {
|
|
|
27
26
|
*/
|
|
28
27
|
toUint8Array(): Uint8Array;
|
|
29
28
|
}
|
|
29
|
+
|
|
30
|
+
export class PrivateKey {
|
|
31
|
+
/**
|
|
32
|
+
* The AIP-80 compliant prefixes for each private key type. Append this to a private key's hex representation
|
|
33
|
+
* to get an AIP-80 compliant string.
|
|
34
|
+
*
|
|
35
|
+
* [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)
|
|
36
|
+
*/
|
|
37
|
+
public static readonly AIP80_PREFIXES = {
|
|
38
|
+
[PrivateKeyVariants.Ed25519]: "ed25519-priv-",
|
|
39
|
+
[PrivateKeyVariants.Secp256k1]: "secp256k1-priv-",
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Format a HexInput to an AIP-80 compliant string.
|
|
44
|
+
*
|
|
45
|
+
* [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)
|
|
46
|
+
*
|
|
47
|
+
* @param privateKey - The HexString or Uint8Array format of the private key.
|
|
48
|
+
* @param privateKeyType - The private key type
|
|
49
|
+
*/
|
|
50
|
+
public static formatPrivateKey(privateKey: HexInput, type: PrivateKeyVariants): string {
|
|
51
|
+
const aip80Prefix = PrivateKey.AIP80_PREFIXES[type];
|
|
52
|
+
return `${aip80Prefix}${Hex.fromHexInput(privateKey).toString()}`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Parse a HexInput that may be a HexString, Uint8Array, or a AIP-80 compliant string to a Hex instance.
|
|
57
|
+
*
|
|
58
|
+
* [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)
|
|
59
|
+
*
|
|
60
|
+
* @param value - A HexString, Uint8Array, or a AIP-80 compliant string.
|
|
61
|
+
* @param privateKeyType - The private key type
|
|
62
|
+
* @param strict - If true, the value MUST be compliant with AIP-80.
|
|
63
|
+
*/
|
|
64
|
+
public static parseHexInput(value: HexInput, type: PrivateKeyVariants, strict?: boolean): Hex {
|
|
65
|
+
let data: Hex;
|
|
66
|
+
|
|
67
|
+
const aip80Prefix = PrivateKey.AIP80_PREFIXES[type];
|
|
68
|
+
if (typeof value === "string") {
|
|
69
|
+
if (!strict && !value.startsWith(aip80Prefix)) {
|
|
70
|
+
// HexString input
|
|
71
|
+
data = Hex.fromHexInput(value);
|
|
72
|
+
// If the strictness is false, the user has opted into non-AIP-80 compliant private keys.
|
|
73
|
+
if (strict !== false) {
|
|
74
|
+
// eslint-disable-next-line no-console
|
|
75
|
+
console.warn(
|
|
76
|
+
"[Aptos SDK] It is recommended that private keys are AIP-80 compliant (https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md). You can fix the private key by formatting it with `PrivateKey.formatPrivateKey(privateKey: string, type: 'ed25519' | 'secp256k1'): string`.",
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
} else if (value.startsWith(aip80Prefix)) {
|
|
80
|
+
// AIP-80 Compliant String input
|
|
81
|
+
data = Hex.fromHexString(value.split("-")[2]);
|
|
82
|
+
} else {
|
|
83
|
+
if (strict) {
|
|
84
|
+
// The value does not start with the AIP-80 prefix, and strict is true.
|
|
85
|
+
throw new Error("Invalid HexString input while parsing private key. Must AIP-80 compliant string.");
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// This condition should never be reached.
|
|
89
|
+
throw new Error("Invalid HexString input while parsing private key.");
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
// The value is an Uint8Array
|
|
93
|
+
data = Hex.fromHexInput(value);
|
|
94
|
+
// If the strictness is false, the user has opted into non-AIP-80 compliant private keys.
|
|
95
|
+
if (strict !== false) {
|
|
96
|
+
// eslint-disable-next-line no-console
|
|
97
|
+
console.warn(
|
|
98
|
+
"[Aptos SDK] It is recommended that private keys are parsed as AIP-80 compliant strings instead of Uint8Array (https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md). You can fix the private key by formatting it with `PrivateKey.formatPrivateKey(privateKey: Uint8Array, type: 'ed25519' | 'secp256k1'): string`.",
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return data;
|
|
104
|
+
}
|
|
105
|
+
}
|