@aptos-labs/ts-sdk 1.13.1-zeta.3 → 1.13.1-zeta.5
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/common/index.d.ts +10 -10
- package/dist/common/index.js +5 -5
- package/dist/common/index.js.map +1 -1
- package/dist/esm/account/Account.mjs +1 -1
- package/dist/esm/account/Ed25519Account.mjs +1 -1
- package/dist/esm/account/EphemeralKeyPair.d.mts +4 -2
- package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
- package/dist/esm/account/KeylessAccount.d.mts +6 -7
- package/dist/esm/account/KeylessAccount.mjs +1 -1
- package/dist/esm/account/MultiKeyAccount.mjs +1 -1
- package/dist/esm/account/SingleKeyAccount.mjs +1 -1
- package/dist/esm/account/index.mjs +1 -1
- package/dist/esm/api/account.d.mts +1 -1
- package/dist/esm/api/account.mjs +1 -1
- package/dist/esm/api/ans.mjs +1 -1
- package/dist/esm/api/aptos.mjs +1 -1
- package/dist/esm/api/coin.d.mts +2 -2
- package/dist/esm/api/coin.mjs +1 -1
- package/dist/esm/api/digitalAsset.d.mts +2 -2
- package/dist/esm/api/digitalAsset.mjs +1 -1
- package/dist/esm/api/event.d.mts +1 -1
- package/dist/esm/api/event.mjs +1 -1
- package/dist/esm/api/faucet.mjs +1 -1
- package/dist/esm/api/fungibleAsset.d.mts +1 -1
- package/dist/esm/api/fungibleAsset.mjs +1 -1
- package/dist/esm/api/general.d.mts +2 -2
- package/dist/esm/api/general.mjs +1 -1
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/keyless.d.mts +0 -1
- package/dist/esm/api/keyless.mjs +1 -1
- package/dist/esm/api/staking.d.mts +2 -2
- package/dist/esm/api/staking.mjs +1 -1
- package/dist/esm/api/transaction.d.mts +1 -1
- package/dist/esm/api/transaction.mjs +1 -1
- package/dist/esm/api/transactionSubmission/build.mjs +1 -1
- package/dist/esm/api/transactionSubmission/management.mjs +1 -1
- package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
- package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
- 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-UKOX55K4.mjs → chunk-3HL2ZWKG.mjs} +2 -2
- package/dist/esm/{chunk-FFKQCXTQ.mjs → chunk-47DNXBM6.mjs} +2 -2
- package/dist/esm/{chunk-FCJLWZWL.mjs → chunk-4MHEB5MN.mjs} +2 -2
- package/dist/esm/{chunk-WXRK2AKZ.mjs → chunk-4MS27RPK.mjs} +2 -2
- package/dist/esm/{chunk-KXZSBE7W.mjs → chunk-4VAQCOR6.mjs} +2 -2
- package/dist/esm/{chunk-INS2SYOV.mjs → chunk-6M6XXPQQ.mjs} +2 -2
- package/dist/esm/{chunk-CQJ4WN7M.mjs → chunk-7JNPSNL6.mjs} +2 -2
- package/dist/esm/{chunk-QXI5L5MN.mjs → chunk-7PICPK26.mjs} +2 -2
- package/dist/esm/{chunk-RYFIXEOV.mjs → chunk-7QFBF7FS.mjs} +2 -2
- package/dist/esm/{chunk-5WBDOSJO.mjs → chunk-AZABJ5QQ.mjs} +2 -2
- package/dist/esm/{chunk-AVCNFBZ6.mjs → chunk-C3AEWQ3A.mjs} +2 -2
- package/dist/esm/{chunk-LYUXOW2M.mjs → chunk-D4QQKQXJ.mjs} +2 -2
- package/dist/esm/{chunk-6SIZZAWU.mjs → chunk-D73X3S27.mjs} +2 -2
- package/dist/esm/{chunk-IOPG2AU7.mjs → chunk-DORK55K3.mjs} +2 -2
- package/dist/esm/{chunk-MP5ROJ2O.mjs → chunk-E7HMV2GZ.mjs} +2 -2
- package/dist/esm/{chunk-4P3VIMVM.mjs → chunk-FEWIHUNW.mjs} +2 -2
- package/dist/esm/{chunk-5EQXQFGY.mjs → chunk-FFVWTX36.mjs} +2 -2
- package/dist/esm/{chunk-SEJ2XNM7.mjs → chunk-FJH4H4E5.mjs} +2 -2
- package/dist/esm/chunk-FTWBJZYH.mjs +2 -0
- package/dist/esm/{chunk-US26M7LP.mjs.map → chunk-FTWBJZYH.mjs.map} +1 -1
- package/dist/esm/{chunk-6LTGQWJQ.mjs → chunk-FVU47J7S.mjs} +2 -2
- package/dist/esm/{chunk-PHYMHZJW.mjs → chunk-FYJMB23M.mjs} +2 -2
- package/dist/esm/chunk-GHVMDDWO.mjs +2 -0
- package/dist/esm/{chunk-DDZGSI33.mjs.map → chunk-GHVMDDWO.mjs.map} +1 -1
- package/dist/esm/{chunk-NSF64TWI.mjs → chunk-GOT527V2.mjs} +2 -2
- package/dist/esm/{chunk-JH7BYJ4C.mjs → chunk-GUWBE3CV.mjs} +2 -2
- package/dist/esm/{chunk-3AC5TPYW.mjs → chunk-H5YTHO4L.mjs} +2 -2
- package/dist/esm/{chunk-4CLRAOCB.mjs → chunk-HGXO74Q3.mjs} +2 -2
- package/dist/esm/{chunk-HWTQJARL.mjs → chunk-HTSXKHXX.mjs} +2 -2
- package/dist/esm/{chunk-5JRZCLBY.mjs → chunk-IGJCOZGO.mjs} +2 -2
- package/dist/esm/chunk-IPH435RF.mjs +2 -0
- package/dist/esm/chunk-IPH435RF.mjs.map +1 -0
- package/dist/esm/{chunk-VLRFXWPH.mjs → chunk-JTCWZB3Q.mjs} +2 -2
- package/dist/esm/{chunk-MDENCOVF.mjs → chunk-KGJITNRZ.mjs} +2 -2
- package/dist/esm/{chunk-WL4HOO3M.mjs → chunk-KY3SB7JG.mjs} +2 -2
- package/dist/esm/{chunk-ACFXTTRJ.mjs → chunk-L3OMI2PE.mjs} +2 -2
- package/dist/esm/{chunk-IJBPBDYK.mjs → chunk-LJ624HBI.mjs} +2 -2
- package/dist/esm/{chunk-5UYYCW5V.mjs → chunk-LX2KX36Q.mjs} +2 -2
- package/dist/esm/{chunk-GY5C3NFK.mjs → chunk-MIMIRNUQ.mjs} +2 -2
- package/dist/esm/chunk-MO5LGCZV.mjs +2 -0
- package/dist/esm/chunk-MO5LGCZV.mjs.map +1 -0
- package/dist/esm/chunk-MQ32XR4V.mjs +2 -0
- package/dist/esm/chunk-MQ32XR4V.mjs.map +1 -0
- package/dist/esm/{chunk-C5VCRT5G.mjs → chunk-MRTAMMS3.mjs} +2 -2
- package/dist/esm/{chunk-NUR3TCTI.mjs → chunk-NC5HHEEM.mjs} +2 -2
- package/dist/esm/{chunk-DIX5DLNP.mjs → chunk-NCIRQZOJ.mjs} +2 -2
- package/dist/esm/{chunk-A4DVDNSM.mjs → chunk-OJ4NIVFW.mjs} +2 -2
- package/dist/esm/{chunk-WYLZXOER.mjs → chunk-OPCSBCGS.mjs} +2 -2
- package/dist/esm/{chunk-4OT5OXVG.mjs → chunk-PKENQYTQ.mjs} +2 -2
- package/dist/esm/{chunk-7FNHL6LU.mjs → chunk-PTIZKRON.mjs} +2 -2
- package/dist/esm/{chunk-NNRRPXQF.mjs → chunk-Q5T2WL2M.mjs} +2 -2
- package/dist/esm/{chunk-OGOHKIIA.mjs → chunk-QI2ILOP4.mjs} +2 -2
- package/dist/esm/{chunk-XM3VKHID.mjs → chunk-QJHFD2MT.mjs} +2 -2
- package/dist/esm/{chunk-CYIEYPXQ.mjs → chunk-R7BAM2G6.mjs} +2 -2
- package/dist/esm/{chunk-U2XWRAPL.mjs → chunk-RQ6M2YQF.mjs} +2 -2
- package/dist/esm/{chunk-XM7P5CUO.mjs → chunk-T7XMSCZV.mjs} +2 -2
- package/dist/esm/{chunk-SVSVP4FM.mjs → chunk-TTELTGMA.mjs} +2 -2
- package/dist/esm/{chunk-W4EQGTSE.mjs → chunk-UT37XKQU.mjs} +2 -2
- package/dist/esm/{chunk-RIJEDN6X.mjs → chunk-VLUJRHOL.mjs} +2 -2
- package/dist/esm/{chunk-IHCL7UWQ.mjs → chunk-W3UCKFFU.mjs} +2 -2
- package/dist/esm/{chunk-22CDTJSF.mjs → chunk-WPVBC4JS.mjs} +2 -2
- package/dist/esm/{chunk-4X4HJL3N.mjs → chunk-WTVN3XGK.mjs} +2 -2
- package/dist/esm/{chunk-TE7AJKSU.mjs → chunk-XHPLLMR5.mjs} +2 -2
- package/dist/esm/{chunk-VJ2W4HR4.mjs → chunk-YQOKWIVY.mjs} +2 -2
- package/dist/esm/{chunk-4EBHV35B.mjs → chunk-YQUZLZL4.mjs} +2 -2
- package/dist/esm/{chunk-EXRFZC3C.mjs → chunk-ZGTJMNZG.mjs} +2 -2
- 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/index.mjs +1 -1
- package/dist/esm/core/account/utils/address.mjs +1 -1
- package/dist/esm/core/account/utils/index.mjs +1 -1
- package/dist/esm/core/accountAddress.mjs +1 -1
- package/dist/esm/core/authenticationKey.mjs +1 -1
- package/dist/esm/core/crypto/ed25519.mjs +1 -1
- package/dist/esm/core/crypto/ephemeral.mjs +1 -1
- package/dist/esm/core/crypto/index.mjs +1 -1
- package/dist/esm/core/crypto/keyless.mjs +1 -1
- package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
- package/dist/esm/core/crypto/multiKey.mjs +1 -1
- package/dist/esm/core/crypto/publicKey.mjs +1 -1
- package/dist/esm/core/crypto/secp256k1.mjs +1 -1
- package/dist/esm/core/crypto/signature.mjs +1 -1
- package/dist/esm/core/crypto/singleKey.mjs +1 -1
- package/dist/esm/core/index.mjs +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internal/account.d.mts +1 -1
- package/dist/esm/internal/account.mjs +1 -1
- package/dist/esm/internal/ans.mjs +1 -1
- package/dist/esm/internal/coin.d.mts +3 -3
- package/dist/esm/internal/coin.mjs +1 -1
- package/dist/esm/internal/digitalAsset.mjs +1 -1
- package/dist/esm/internal/event.d.mts +1 -1
- package/dist/esm/internal/event.mjs +1 -1
- package/dist/esm/internal/faucet.d.mts +3 -3
- package/dist/esm/internal/faucet.mjs +1 -1
- package/dist/esm/internal/fungibleAsset.d.mts +1 -1
- package/dist/esm/internal/fungibleAsset.mjs +1 -1
- package/dist/esm/internal/general.mjs +1 -1
- package/dist/esm/internal/keyless.d.mts +0 -1
- package/dist/esm/internal/keyless.mjs +1 -1
- package/dist/esm/internal/staking.mjs +1 -1
- package/dist/esm/internal/transaction.mjs +1 -1
- package/dist/esm/internal/transactionSubmission.mjs +1 -1
- package/dist/esm/internal/view.mjs +1 -1
- package/dist/esm/transactions/authenticator/account.mjs +1 -1
- package/dist/esm/transactions/authenticator/index.mjs +1 -1
- package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
- package/dist/esm/transactions/index.mjs +1 -1
- package/dist/esm/transactions/instances/index.mjs +1 -1
- package/dist/esm/transactions/instances/moduleId.mjs +1 -1
- package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
- package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
- package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
- package/dist/esm/transactions/management/index.mjs +1 -1
- package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
- 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/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
- package/src/account/EphemeralKeyPair.ts +16 -8
- package/src/account/KeylessAccount.ts +16 -30
- package/src/api/keyless.ts +0 -1
- package/src/internal/keyless.ts +4 -8
- package/src/version.ts +1 -1
- package/dist/esm/chunk-DDZGSI33.mjs +0 -2
- package/dist/esm/chunk-GFW5KSAZ.mjs +0 -2
- package/dist/esm/chunk-GFW5KSAZ.mjs.map +0 -1
- package/dist/esm/chunk-U6XKW7OK.mjs +0 -2
- package/dist/esm/chunk-U6XKW7OK.mjs.map +0 -1
- package/dist/esm/chunk-US26M7LP.mjs +0 -2
- package/dist/esm/chunk-WP7YNQOI.mjs +0 -2
- package/dist/esm/chunk-WP7YNQOI.mjs.map +0 -1
- /package/dist/esm/{chunk-UKOX55K4.mjs.map → chunk-3HL2ZWKG.mjs.map} +0 -0
- /package/dist/esm/{chunk-FFKQCXTQ.mjs.map → chunk-47DNXBM6.mjs.map} +0 -0
- /package/dist/esm/{chunk-FCJLWZWL.mjs.map → chunk-4MHEB5MN.mjs.map} +0 -0
- /package/dist/esm/{chunk-WXRK2AKZ.mjs.map → chunk-4MS27RPK.mjs.map} +0 -0
- /package/dist/esm/{chunk-KXZSBE7W.mjs.map → chunk-4VAQCOR6.mjs.map} +0 -0
- /package/dist/esm/{chunk-INS2SYOV.mjs.map → chunk-6M6XXPQQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-CQJ4WN7M.mjs.map → chunk-7JNPSNL6.mjs.map} +0 -0
- /package/dist/esm/{chunk-QXI5L5MN.mjs.map → chunk-7PICPK26.mjs.map} +0 -0
- /package/dist/esm/{chunk-RYFIXEOV.mjs.map → chunk-7QFBF7FS.mjs.map} +0 -0
- /package/dist/esm/{chunk-5WBDOSJO.mjs.map → chunk-AZABJ5QQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-AVCNFBZ6.mjs.map → chunk-C3AEWQ3A.mjs.map} +0 -0
- /package/dist/esm/{chunk-LYUXOW2M.mjs.map → chunk-D4QQKQXJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-6SIZZAWU.mjs.map → chunk-D73X3S27.mjs.map} +0 -0
- /package/dist/esm/{chunk-IOPG2AU7.mjs.map → chunk-DORK55K3.mjs.map} +0 -0
- /package/dist/esm/{chunk-MP5ROJ2O.mjs.map → chunk-E7HMV2GZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-4P3VIMVM.mjs.map → chunk-FEWIHUNW.mjs.map} +0 -0
- /package/dist/esm/{chunk-5EQXQFGY.mjs.map → chunk-FFVWTX36.mjs.map} +0 -0
- /package/dist/esm/{chunk-SEJ2XNM7.mjs.map → chunk-FJH4H4E5.mjs.map} +0 -0
- /package/dist/esm/{chunk-6LTGQWJQ.mjs.map → chunk-FVU47J7S.mjs.map} +0 -0
- /package/dist/esm/{chunk-PHYMHZJW.mjs.map → chunk-FYJMB23M.mjs.map} +0 -0
- /package/dist/esm/{chunk-NSF64TWI.mjs.map → chunk-GOT527V2.mjs.map} +0 -0
- /package/dist/esm/{chunk-JH7BYJ4C.mjs.map → chunk-GUWBE3CV.mjs.map} +0 -0
- /package/dist/esm/{chunk-3AC5TPYW.mjs.map → chunk-H5YTHO4L.mjs.map} +0 -0
- /package/dist/esm/{chunk-4CLRAOCB.mjs.map → chunk-HGXO74Q3.mjs.map} +0 -0
- /package/dist/esm/{chunk-HWTQJARL.mjs.map → chunk-HTSXKHXX.mjs.map} +0 -0
- /package/dist/esm/{chunk-5JRZCLBY.mjs.map → chunk-IGJCOZGO.mjs.map} +0 -0
- /package/dist/esm/{chunk-VLRFXWPH.mjs.map → chunk-JTCWZB3Q.mjs.map} +0 -0
- /package/dist/esm/{chunk-MDENCOVF.mjs.map → chunk-KGJITNRZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-WL4HOO3M.mjs.map → chunk-KY3SB7JG.mjs.map} +0 -0
- /package/dist/esm/{chunk-ACFXTTRJ.mjs.map → chunk-L3OMI2PE.mjs.map} +0 -0
- /package/dist/esm/{chunk-IJBPBDYK.mjs.map → chunk-LJ624HBI.mjs.map} +0 -0
- /package/dist/esm/{chunk-5UYYCW5V.mjs.map → chunk-LX2KX36Q.mjs.map} +0 -0
- /package/dist/esm/{chunk-GY5C3NFK.mjs.map → chunk-MIMIRNUQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-C5VCRT5G.mjs.map → chunk-MRTAMMS3.mjs.map} +0 -0
- /package/dist/esm/{chunk-NUR3TCTI.mjs.map → chunk-NC5HHEEM.mjs.map} +0 -0
- /package/dist/esm/{chunk-DIX5DLNP.mjs.map → chunk-NCIRQZOJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-A4DVDNSM.mjs.map → chunk-OJ4NIVFW.mjs.map} +0 -0
- /package/dist/esm/{chunk-WYLZXOER.mjs.map → chunk-OPCSBCGS.mjs.map} +0 -0
- /package/dist/esm/{chunk-4OT5OXVG.mjs.map → chunk-PKENQYTQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-7FNHL6LU.mjs.map → chunk-PTIZKRON.mjs.map} +0 -0
- /package/dist/esm/{chunk-NNRRPXQF.mjs.map → chunk-Q5T2WL2M.mjs.map} +0 -0
- /package/dist/esm/{chunk-OGOHKIIA.mjs.map → chunk-QI2ILOP4.mjs.map} +0 -0
- /package/dist/esm/{chunk-XM3VKHID.mjs.map → chunk-QJHFD2MT.mjs.map} +0 -0
- /package/dist/esm/{chunk-CYIEYPXQ.mjs.map → chunk-R7BAM2G6.mjs.map} +0 -0
- /package/dist/esm/{chunk-U2XWRAPL.mjs.map → chunk-RQ6M2YQF.mjs.map} +0 -0
- /package/dist/esm/{chunk-XM7P5CUO.mjs.map → chunk-T7XMSCZV.mjs.map} +0 -0
- /package/dist/esm/{chunk-SVSVP4FM.mjs.map → chunk-TTELTGMA.mjs.map} +0 -0
- /package/dist/esm/{chunk-W4EQGTSE.mjs.map → chunk-UT37XKQU.mjs.map} +0 -0
- /package/dist/esm/{chunk-RIJEDN6X.mjs.map → chunk-VLUJRHOL.mjs.map} +0 -0
- /package/dist/esm/{chunk-IHCL7UWQ.mjs.map → chunk-W3UCKFFU.mjs.map} +0 -0
- /package/dist/esm/{chunk-22CDTJSF.mjs.map → chunk-WPVBC4JS.mjs.map} +0 -0
- /package/dist/esm/{chunk-4X4HJL3N.mjs.map → chunk-WTVN3XGK.mjs.map} +0 -0
- /package/dist/esm/{chunk-TE7AJKSU.mjs.map → chunk-XHPLLMR5.mjs.map} +0 -0
- /package/dist/esm/{chunk-VJ2W4HR4.mjs.map → chunk-YQOKWIVY.mjs.map} +0 -0
- /package/dist/esm/{chunk-4EBHV35B.mjs.map → chunk-YQUZLZL4.mjs.map} +0 -0
- /package/dist/esm/{chunk-EXRFZC3C.mjs.map → chunk-ZGTJMNZG.mjs.map} +0 -0
|
@@ -15,19 +15,19 @@ import { bytesToBigIntLE, padAndPackBytesWithLen, poseidonHash } from "../core/c
|
|
|
15
15
|
import { EphemeralPublicKeyVariant, HexInput, SigningSchemeInput } from "../types";
|
|
16
16
|
import { Deserializer, Serializable, Serializer } from "../bcs";
|
|
17
17
|
|
|
18
|
-
export class EphemeralKeyPair extends Serializable{
|
|
18
|
+
export class EphemeralKeyPair extends Serializable {
|
|
19
19
|
readonly blinder: Uint8Array;
|
|
20
20
|
|
|
21
21
|
readonly expiryDateSecs: bigint | number;
|
|
22
22
|
|
|
23
23
|
readonly nonce: string;
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
private privateKey: PrivateKey;
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
private publicKey: EphemeralPublicKey;
|
|
28
28
|
|
|
29
29
|
constructor(args: { privateKey: PrivateKey; expiryDateSecs?: bigint | number; blinder?: HexInput }) {
|
|
30
|
-
super()
|
|
30
|
+
super();
|
|
31
31
|
const { privateKey, expiryDateSecs, blinder } = args;
|
|
32
32
|
this.privateKey = privateKey;
|
|
33
33
|
this.publicKey = new EphemeralPublicKey(privateKey.publicKey());
|
|
@@ -36,11 +36,15 @@ export class EphemeralKeyPair extends Serializable{
|
|
|
36
36
|
this.nonce = this.generateNonce();
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
getPublicKey(): EphemeralPublicKey {
|
|
40
|
+
return this.publicKey;
|
|
41
|
+
}
|
|
42
|
+
|
|
39
43
|
serialize(serializer: Serializer): void {
|
|
40
44
|
serializer.serializeU32AsUleb128(this.publicKey.variant);
|
|
41
|
-
serializer.serializeBytes(this.privateKey.toUint8Array())
|
|
42
|
-
serializer.serializeU64(this.expiryDateSecs)
|
|
43
|
-
serializer.serializeFixedBytes(this.blinder)
|
|
45
|
+
serializer.serializeBytes(this.privateKey.toUint8Array());
|
|
46
|
+
serializer.serializeU64(this.expiryDateSecs);
|
|
47
|
+
serializer.serializeFixedBytes(this.blinder);
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
static deserialize(deserializer: Deserializer): EphemeralKeyPair {
|
|
@@ -55,7 +59,11 @@ export class EphemeralKeyPair extends Serializable{
|
|
|
55
59
|
}
|
|
56
60
|
const expiryDateSecs = deserializer.deserializeU64();
|
|
57
61
|
const blinder = deserializer.deserializeFixedBytes(31);
|
|
58
|
-
return new EphemeralKeyPair({privateKey, expiryDateSecs, blinder});
|
|
62
|
+
return new EphemeralKeyPair({ privateKey, expiryDateSecs, blinder });
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static fromBytes(bytes: Uint8Array): EphemeralKeyPair {
|
|
66
|
+
return EphemeralKeyPair.deserialize(new Deserializer(bytes));
|
|
59
67
|
}
|
|
60
68
|
|
|
61
69
|
static generate(args?: { scheme: SigningSchemeInput }): EphemeralKeyPair {
|
|
@@ -58,7 +58,7 @@ export class KeylessAccount implements Account {
|
|
|
58
58
|
|
|
59
59
|
accountAddress: AccountAddress;
|
|
60
60
|
|
|
61
|
-
proof: SignedGroth16Signature
|
|
61
|
+
proof: SignedGroth16Signature;
|
|
62
62
|
|
|
63
63
|
signingScheme: SigningScheme;
|
|
64
64
|
|
|
@@ -72,10 +72,10 @@ export class KeylessAccount implements Account {
|
|
|
72
72
|
uidVal: string;
|
|
73
73
|
aud: string;
|
|
74
74
|
pepper: HexInput;
|
|
75
|
-
|
|
75
|
+
proof: SignedGroth16Signature;
|
|
76
76
|
jwt: string;
|
|
77
77
|
}) {
|
|
78
|
-
const { address, ephemeralKeyPair, iss, uidKey, uidVal, aud, pepper,
|
|
78
|
+
const { address, ephemeralKeyPair, iss, uidKey, uidVal, aud, pepper, proof, jwt } = args;
|
|
79
79
|
this.ephemeralKeyPair = ephemeralKeyPair;
|
|
80
80
|
const addressSeed = computeAddressSeed(args);
|
|
81
81
|
this.publicKey = new KeylessPublicKey(iss, addressSeed);
|
|
@@ -84,12 +84,7 @@ export class KeylessAccount implements Account {
|
|
|
84
84
|
this.uidVal = uidVal;
|
|
85
85
|
this.aud = aud;
|
|
86
86
|
this.jwt = jwt;
|
|
87
|
-
|
|
88
|
-
this.proof = proofFetcherOrData;
|
|
89
|
-
this.initialize(proofFetcherOrData);
|
|
90
|
-
} else {
|
|
91
|
-
this.proof = proofFetcherOrData;
|
|
92
|
-
}
|
|
87
|
+
this.proof = proof;
|
|
93
88
|
|
|
94
89
|
this.signingScheme = SigningScheme.SingleKey;
|
|
95
90
|
const pepperBytes = Hex.fromHexInput(pepper).toUint8Array();
|
|
@@ -99,13 +94,12 @@ export class KeylessAccount implements Account {
|
|
|
99
94
|
this.pepper = pepperBytes;
|
|
100
95
|
}
|
|
101
96
|
|
|
102
|
-
|
|
97
|
+
serialize(serializer: Serializer): void {
|
|
103
98
|
serializer.serializeStr(this.jwt);
|
|
104
99
|
serializer.serializeStr(this.uidKey);
|
|
105
100
|
serializer.serializeFixedBytes(this.pepper);
|
|
106
101
|
this.ephemeralKeyPair.serialize(serializer);
|
|
107
|
-
|
|
108
|
-
proof.serialize(serializer);
|
|
102
|
+
this.proof.serialize(serializer);
|
|
109
103
|
}
|
|
110
104
|
|
|
111
105
|
static deserialize(deserializer: Deserializer): KeylessAccount {
|
|
@@ -115,7 +109,7 @@ export class KeylessAccount implements Account {
|
|
|
115
109
|
const ephemeralKeyPair = EphemeralKeyPair.deserialize(deserializer);
|
|
116
110
|
const proof = SignedGroth16Signature.deserialize(deserializer);
|
|
117
111
|
return KeylessAccount.fromJWTAndProof({
|
|
118
|
-
|
|
112
|
+
proof,
|
|
119
113
|
pepper,
|
|
120
114
|
uidKey,
|
|
121
115
|
jwt,
|
|
@@ -123,25 +117,17 @@ export class KeylessAccount implements Account {
|
|
|
123
117
|
});
|
|
124
118
|
}
|
|
125
119
|
|
|
126
|
-
|
|
120
|
+
bcsToBytes(): Uint8Array {
|
|
127
121
|
const serializer = new Serializer();
|
|
128
|
-
|
|
122
|
+
this.serialize(serializer);
|
|
129
123
|
return serializer.toUint8Array();
|
|
130
124
|
}
|
|
131
125
|
|
|
132
|
-
|
|
133
|
-
const bcsBytes =
|
|
126
|
+
bcsToHex(): Hex {
|
|
127
|
+
const bcsBytes = this.bcsToBytes();
|
|
134
128
|
return Hex.fromHexInput(bcsBytes);
|
|
135
129
|
}
|
|
136
130
|
|
|
137
|
-
private async initialize(promise: Promise<SignedGroth16Signature>) {
|
|
138
|
-
try {
|
|
139
|
-
this.proof = await promise;
|
|
140
|
-
} catch (error) {
|
|
141
|
-
throw new Error("Failed to fetch proof");
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
131
|
signWithAuthenticator(transaction: AnyRawTransaction): AccountAuthenticatorSingleKey {
|
|
146
132
|
const raw = deriveTransactionType(transaction);
|
|
147
133
|
const signature = new AnySignature(this.sign(raw.bcsToBytes()));
|
|
@@ -165,7 +151,7 @@ export class KeylessAccount implements Account {
|
|
|
165
151
|
throw new Error("Failed to fetch proof.");
|
|
166
152
|
}
|
|
167
153
|
const jwtHeader = this.jwt.split(".")[0];
|
|
168
|
-
const ephemeralPublicKey = this.ephemeralKeyPair.
|
|
154
|
+
const ephemeralPublicKey = this.ephemeralKeyPair.getPublicKey();
|
|
169
155
|
|
|
170
156
|
const serializer = new Serializer();
|
|
171
157
|
serializer.serializeFixedBytes(Hex.fromHexInput(data).toUint8Array());
|
|
@@ -199,7 +185,7 @@ export class KeylessAccount implements Account {
|
|
|
199
185
|
});
|
|
200
186
|
|
|
201
187
|
const { expiryDateSecs } = this.ephemeralKeyPair;
|
|
202
|
-
const ephemeralPublicKey = this.ephemeralKeyPair.
|
|
188
|
+
const ephemeralPublicKey = this.ephemeralKeyPair.getPublicKey();
|
|
203
189
|
const ephemeralSignature = this.ephemeralKeyPair.sign(data);
|
|
204
190
|
return new KeylessSignature({
|
|
205
191
|
jwtHeader,
|
|
@@ -220,13 +206,13 @@ export class KeylessAccount implements Account {
|
|
|
220
206
|
}
|
|
221
207
|
|
|
222
208
|
static fromJWTAndProof(args: {
|
|
223
|
-
|
|
209
|
+
proof: SignedGroth16Signature;
|
|
224
210
|
jwt: string;
|
|
225
211
|
ephemeralKeyPair: EphemeralKeyPair;
|
|
226
212
|
pepper: HexInput;
|
|
227
213
|
uidKey?: string;
|
|
228
214
|
}): KeylessAccount {
|
|
229
|
-
const {
|
|
215
|
+
const { proof, jwt, ephemeralKeyPair, pepper } = args;
|
|
230
216
|
const uidKey = args.uidKey ?? "sub";
|
|
231
217
|
|
|
232
218
|
const jwtPayload = jwtDecode<JwtPayload & { [key: string]: string }>(jwt);
|
|
@@ -237,7 +223,7 @@ export class KeylessAccount implements Account {
|
|
|
237
223
|
const aud = jwtPayload.aud!;
|
|
238
224
|
const uidVal = jwtPayload[uidKey];
|
|
239
225
|
return new KeylessAccount({
|
|
240
|
-
|
|
226
|
+
proof,
|
|
241
227
|
ephemeralKeyPair,
|
|
242
228
|
iss,
|
|
243
229
|
uidKey,
|
package/src/api/keyless.ts
CHANGED
package/src/internal/keyless.ts
CHANGED
|
@@ -79,7 +79,7 @@ export async function getPepper(args: {
|
|
|
79
79
|
|
|
80
80
|
const body = {
|
|
81
81
|
jwt_b64: jwt,
|
|
82
|
-
epk: ephemeralKeyPair.
|
|
82
|
+
epk: ephemeralKeyPair.getPublicKey().bcsToHex().toStringWithoutPrefix(),
|
|
83
83
|
exp_date_secs: Number(ephemeralKeyPair.expiryDateSecs),
|
|
84
84
|
epk_blinder: Hex.fromHexInput(ephemeralKeyPair.blinder).toStringWithoutPrefix(),
|
|
85
85
|
uid_key: uidKey,
|
|
@@ -131,7 +131,7 @@ export async function getProof(args: {
|
|
|
131
131
|
}
|
|
132
132
|
const json = {
|
|
133
133
|
jwt_b64: jwt,
|
|
134
|
-
epk: ephemeralKeyPair.
|
|
134
|
+
epk: ephemeralKeyPair.getPublicKey().bcsToHex().toStringWithoutPrefix(),
|
|
135
135
|
epk_blinder: Hex.fromHexInput(ephemeralKeyPair.blinder).toStringWithoutPrefix(),
|
|
136
136
|
exp_date_secs: Number(ephemeralKeyPair.expiryDateSecs),
|
|
137
137
|
exp_horizon_secs: EPK_HORIZON_SECS,
|
|
@@ -170,20 +170,16 @@ export async function deriveKeylessAccount(args: {
|
|
|
170
170
|
uidKey?: string;
|
|
171
171
|
pepper?: HexInput;
|
|
172
172
|
extraFieldKey?: string;
|
|
173
|
-
fetchProofAsync?: boolean;
|
|
174
173
|
}): Promise<KeylessAccount> {
|
|
175
|
-
const { fetchProofAsync } = args;
|
|
176
174
|
let { pepper } = args;
|
|
177
175
|
if (pepper === undefined) {
|
|
178
176
|
pepper = await getPepper(args);
|
|
179
177
|
} else if (Hex.fromHexInput(pepper).toUint8Array().length !== 31) {
|
|
180
178
|
throw new Error("Pepper needs to be 31 bytes");
|
|
181
179
|
}
|
|
180
|
+
const proof = await getProof({ ...args, pepper });
|
|
182
181
|
|
|
183
|
-
const
|
|
184
|
-
const proof = fetchProofAsync ? proofPromise : await proofPromise;
|
|
185
|
-
|
|
186
|
-
const keylessAccount = KeylessAccount.fromJWTAndProof({ ...args, proofFetcherOrData: proof, pepper });
|
|
182
|
+
const keylessAccount = KeylessAccount.fromJWTAndProof({ ...args, proof, pepper });
|
|
187
183
|
|
|
188
184
|
return keylessAccount;
|
|
189
185
|
}
|
package/src/version.ts
CHANGED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as j}from"./chunk-U6XKW7OK.mjs";import{a as g,b as I}from"./chunk-6SIZZAWU.mjs";import{d as x}from"./chunk-22CDTJSF.mjs";import{a as E,b as T}from"./chunk-INS2SYOV.mjs";import{i as w,j as K,k as y,m as A,n as b,o as l}from"./chunk-4X4HJL3N.mjs";import{k as S}from"./chunk-S5HG2QUD.mjs";import{b as P}from"./chunk-T23OVRNF.mjs";import{b as h}from"./chunk-TVRJ3M7B.mjs";import{b as u}from"./chunk-AOCNYMMX.mjs";import{a as f}from"./chunk-6IFMQ5AS.mjs";import{jwtDecode as O}from"jwt-decode";import{decode as B}from"base-64";function F(D){let e=D.replace(/-/g,"+").replace(/_/g,"/"),r=e+"==".substring(0,(3-e.length%3)%3);return B(r)}var o=class o{constructor(e){let{address:r,ephemeralKeyPair:t,iss:n,uidKey:a,uidVal:i,aud:s,pepper:p,proofFetcherOrData:c,jwt:d}=e;this.ephemeralKeyPair=t;let z=K(e);this.publicKey=new w(n,z),this.accountAddress=r?P.from(r):this.publicKey.authKey().derivedAddress(),this.uidKey=a,this.uidVal=i,this.aud=s,this.jwt=d,c instanceof Promise?(this.proof=c,this.initialize(c)):this.proof=c,this.signingScheme=2;let m=u.fromHexInput(p).toUint8Array();if(m.length!==o.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${o.PEPPER_LENGTH}`);this.pepper=m}async serialize(e){e.serializeStr(this.jwt),e.serializeStr(this.uidKey),e.serializeFixedBytes(this.pepper),this.ephemeralKeyPair.serialize(e),(await this.proof).serialize(e)}static deserialize(e){let r=e.deserializeStr(),t=e.deserializeStr(),n=e.deserializeFixedBytes(31),a=j.deserialize(e),i=A.deserialize(e);return o.fromJWTAndProof({proofFetcherOrData:i,pepper:n,uidKey:t,jwt:r,ephemeralKeyPair:a})}async bcsToBytes(){let e=new h;return await this.serialize(e),e.toUint8Array()}async bcsToHex(){let e=await this.bcsToBytes();return u.fromHexInput(e)}async initialize(e){try{this.proof=await e}catch{throw new Error("Failed to fetch proof")}}signWithAuthenticator(e){let r=g(e),t=new T(this.sign(r.bcsToBytes())),n=new E(this.publicKey);return new x(n,t)}async waitForProofFetch(){this.proof instanceof Promise&&await this.proof}sign(e){let{expiryDateSecs:r}=this.ephemeralKeyPair,t=Math.floor(new Date().getTime()/1e3);if(r<t)throw new Error("Ephemeral key pair is expired.");if(this.proof instanceof Promise)throw new Error("Failed to fetch proof.");let n=this.jwt.split(".")[0],a=this.ephemeralKeyPair.publicKey,i=new h;i.serializeFixedBytes(u.fromHexInput(e).toUint8Array()),i.serializeOption(this.proof.proof);let s=I(i.toUint8Array(),"APTOS::TransactionAndProof"),p=this.ephemeralKeyPair.sign(s);return new l({jwtHeader:F(n),openIdSignatureOrZkProof:new y(this.proof),expiryDateSecs:r,ephemeralPublicKey:a,ephemeralSignature:p})}signTransaction(e){let r=g(e);return this.sign(r.bcsToBytes())}signWithOpenIdSignature(e){let[r,t,n]=this.jwt.split("."),a=new b({jwtSignature:n,jwtPayloadJson:t,uidKey:this.uidKey,epkBlinder:this.ephemeralKeyPair.blinder,pepper:this.pepper}),{expiryDateSecs:i}=this.ephemeralKeyPair,s=this.ephemeralKeyPair.publicKey,p=this.ephemeralKeyPair.sign(e);return new l({jwtHeader:r,openIdSignatureOrZkProof:new y(a),expiryDateSecs:i,ephemeralPublicKey:s,ephemeralSignature:p})}verifySignature(e){return!0}static fromBytes(e){return o.deserialize(new f(e))}static fromJWTAndProof(e){let{proofFetcherOrData:r,jwt:t,ephemeralKeyPair:n,pepper:a}=e,i=e.uidKey??"sub",s=O(t),p=s.iss;if(typeof s.aud!="string")throw new Error("aud was not found or an array of values");let c=s.aud,d=s[i];return new o({proofFetcherOrData:r,ephemeralKeyPair:n,iss:p,uidKey:i,uidVal:d,aud:c,pepper:a,jwt:t})}static fromDerivationPath(e,r){return S(e,o.SLIP_0010_SEED,r)}};o.PEPPER_LENGTH=31,o.SLIP_0010_SEED="32 bytes";var H=o;export{H as a};
|
|
2
|
-
//# sourceMappingURL=chunk-GFW5KSAZ.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/account/KeylessAccount.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { JwtPayload, jwtDecode } from \"jwt-decode\";\nimport { decode } from \"base-64\";\nimport { HexInput, SigningScheme } from \"../types\";\nimport { AccountAddress } from \"../core/accountAddress\";\nimport {\n AnyPublicKey,\n AnySignature,\n KeylessPublicKey,\n KeylessSignature,\n OpenIdSignature,\n OpenIdSignatureOrZkProof,\n Signature,\n SignedGroth16Signature,\n computeAddressSeed,\n fromDerivationPath as fromDerivationPathInner,\n} from \"../core/crypto\";\n\nimport { Account } from \"./Account\";\nimport { EphemeralKeyPair } from \"./EphemeralKeyPair\";\nimport { Hex } from \"../core/hex\";\nimport { AccountAuthenticatorSingleKey } from \"../transactions/authenticator/account\";\nimport { Deserializer, Serializer } from \"../bcs\";\nimport { deriveTransactionType, generateSigningMessage } from \"../transactions/transactionBuilder/signingMessage\";\nimport { AnyRawTransaction } from \"../transactions/types\";\n\nfunction base64UrlDecode(base64Url: string): string {\n // Replace base64url-specific characters\n const base64 = base64Url.replace(/-/g, \"+\").replace(/_/g, \"/\");\n\n // Pad the string with '=' characters if needed\n const paddedBase64 = base64 + \"==\".substring(0, (3 - (base64.length % 3)) % 3);\n\n // Decode the base64 string using the base-64 library\n const decodedString = decode(paddedBase64);\n\n return decodedString;\n}\n\nexport class KeylessAccount implements Account {\n static readonly PEPPER_LENGTH: number = 31;\n\n static readonly SLIP_0010_SEED: string = \"32 bytes\";\n\n publicKey: KeylessPublicKey;\n\n ephemeralKeyPair: EphemeralKeyPair;\n\n uidKey: string;\n\n uidVal: string;\n\n aud: string;\n\n pepper: Uint8Array;\n\n accountAddress: AccountAddress;\n\n proof: SignedGroth16Signature | Promise<SignedGroth16Signature>;\n\n signingScheme: SigningScheme;\n\n jwt: string;\n\n constructor(args: {\n address?: AccountAddress;\n ephemeralKeyPair: EphemeralKeyPair;\n iss: string;\n uidKey: string;\n uidVal: string;\n aud: string;\n pepper: HexInput;\n proofFetcherOrData: Promise<SignedGroth16Signature> | SignedGroth16Signature;\n jwt: string;\n }) {\n const { address, ephemeralKeyPair, iss, uidKey, uidVal, aud, pepper, proofFetcherOrData, jwt } = args;\n this.ephemeralKeyPair = ephemeralKeyPair;\n const addressSeed = computeAddressSeed(args);\n this.publicKey = new KeylessPublicKey(iss, addressSeed);\n this.accountAddress = address ? AccountAddress.from(address) : this.publicKey.authKey().derivedAddress();\n this.uidKey = uidKey;\n this.uidVal = uidVal;\n this.aud = aud;\n this.jwt = jwt;\n if (proofFetcherOrData instanceof Promise) {\n this.proof = proofFetcherOrData;\n this.initialize(proofFetcherOrData);\n } else {\n this.proof = proofFetcherOrData;\n }\n\n this.signingScheme = SigningScheme.SingleKey;\n const pepperBytes = Hex.fromHexInput(pepper).toUint8Array();\n if (pepperBytes.length !== KeylessAccount.PEPPER_LENGTH) {\n throw new Error(`Pepper length in bytes should be ${KeylessAccount.PEPPER_LENGTH}`);\n }\n this.pepper = pepperBytes;\n }\n\n async serialize(serializer: Serializer): Promise<void> {\n serializer.serializeStr(this.jwt);\n serializer.serializeStr(this.uidKey);\n serializer.serializeFixedBytes(this.pepper);\n this.ephemeralKeyPair.serialize(serializer);\n const proof = await this.proof;\n proof.serialize(serializer);\n }\n\n static deserialize(deserializer: Deserializer): KeylessAccount {\n const jwt = deserializer.deserializeStr();\n const uidKey = deserializer.deserializeStr();\n const pepper = deserializer.deserializeFixedBytes(31);\n const ephemeralKeyPair = EphemeralKeyPair.deserialize(deserializer);\n const proof = SignedGroth16Signature.deserialize(deserializer);\n return KeylessAccount.fromJWTAndProof({\n proofFetcherOrData: proof,\n pepper,\n uidKey,\n jwt,\n ephemeralKeyPair,\n });\n }\n\n async bcsToBytes(): Promise<Uint8Array> {\n const serializer = new Serializer();\n await this.serialize(serializer);\n return serializer.toUint8Array();\n }\n\n async bcsToHex(): Promise<Hex> {\n const bcsBytes = await this.bcsToBytes();\n return Hex.fromHexInput(bcsBytes);\n }\n\n private async initialize(promise: Promise<SignedGroth16Signature>) {\n try {\n this.proof = await promise;\n } catch (error) {\n throw new Error(\"Failed to fetch proof\");\n }\n }\n\n signWithAuthenticator(transaction: AnyRawTransaction): AccountAuthenticatorSingleKey {\n const raw = deriveTransactionType(transaction);\n const signature = new AnySignature(this.sign(raw.bcsToBytes()));\n const publicKey = new AnyPublicKey(this.publicKey);\n return new AccountAuthenticatorSingleKey(publicKey, signature);\n }\n\n async waitForProofFetch() {\n if (this.proof instanceof Promise) {\n await this.proof;\n }\n }\n\n sign(data: HexInput): Signature {\n const { expiryDateSecs } = this.ephemeralKeyPair;\n const currentTimeInSeconds = Math.floor(new Date().getTime() / 1000);\n if (expiryDateSecs < currentTimeInSeconds) {\n throw new Error(\"Ephemeral key pair is expired.\");\n }\n if (this.proof instanceof Promise) {\n throw new Error(\"Failed to fetch proof.\");\n }\n const jwtHeader = this.jwt.split(\".\")[0];\n const ephemeralPublicKey = this.ephemeralKeyPair.publicKey;\n\n const serializer = new Serializer();\n serializer.serializeFixedBytes(Hex.fromHexInput(data).toUint8Array());\n serializer.serializeOption(this.proof.proof);\n const signMess = generateSigningMessage(serializer.toUint8Array(), \"APTOS::TransactionAndProof\");\n\n const ephemeralSignature = this.ephemeralKeyPair.sign(signMess);\n\n return new KeylessSignature({\n jwtHeader: base64UrlDecode(jwtHeader),\n openIdSignatureOrZkProof: new OpenIdSignatureOrZkProof(this.proof),\n expiryDateSecs,\n ephemeralPublicKey,\n ephemeralSignature,\n });\n }\n\n signTransaction(transaction: AnyRawTransaction): Signature {\n const raw = deriveTransactionType(transaction);\n return this.sign(raw.bcsToBytes());\n }\n\n signWithOpenIdSignature(data: HexInput): Signature {\n const [jwtHeader, jwtPayload, jwtSignature] = this.jwt.split(\".\");\n const openIdSig = new OpenIdSignature({\n jwtSignature,\n jwtPayloadJson: jwtPayload,\n uidKey: this.uidKey,\n epkBlinder: this.ephemeralKeyPair.blinder,\n pepper: this.pepper,\n });\n\n const { expiryDateSecs } = this.ephemeralKeyPair;\n const ephemeralPublicKey = this.ephemeralKeyPair.publicKey;\n const ephemeralSignature = this.ephemeralKeyPair.sign(data);\n return new KeylessSignature({\n jwtHeader,\n openIdSignatureOrZkProof: new OpenIdSignatureOrZkProof(openIdSig),\n expiryDateSecs,\n ephemeralPublicKey,\n ephemeralSignature,\n });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this\n verifySignature(args: { message: HexInput; signature: Signature }): boolean {\n return true;\n }\n\n static fromBytes(bytes: Uint8Array): KeylessAccount {\n return KeylessAccount.deserialize(new Deserializer(bytes));\n }\n\n static fromJWTAndProof(args: {\n proofFetcherOrData: Promise<SignedGroth16Signature> | SignedGroth16Signature;\n jwt: string;\n ephemeralKeyPair: EphemeralKeyPair;\n pepper: HexInput;\n uidKey?: string;\n }): KeylessAccount {\n const { proofFetcherOrData, jwt, ephemeralKeyPair, pepper } = args;\n const uidKey = args.uidKey ?? \"sub\";\n\n const jwtPayload = jwtDecode<JwtPayload & { [key: string]: string }>(jwt);\n const iss = jwtPayload.iss!;\n if (typeof jwtPayload.aud !== \"string\") {\n throw new Error(\"aud was not found or an array of values\");\n }\n const aud = jwtPayload.aud!;\n const uidVal = jwtPayload[uidKey];\n return new KeylessAccount({\n proofFetcherOrData,\n ephemeralKeyPair,\n iss,\n uidKey,\n uidVal,\n aud,\n pepper,\n jwt,\n });\n }\n\n static fromDerivationPath(path: string, seed: Uint8Array): Uint8Array {\n return fromDerivationPathInner(path, KeylessAccount.SLIP_0010_SEED, seed);\n }\n}\n"],"mappings":"2cAGA,OAAqB,aAAAA,MAAiB,aACtC,OAAS,UAAAC,MAAc,UAwBvB,SAASC,EAAgBC,EAA2B,CAElD,IAAMC,EAASD,EAAU,QAAQ,KAAM,GAAG,EAAE,QAAQ,KAAM,GAAG,EAGvDE,EAAeD,EAAS,KAAK,UAAU,GAAI,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IAAAC,EACA,OAAAC,EACA,OAAAC,EACA,IAAAC,EACA,OAAAC,EACA,IAAAE,CACF,CAAC,CACH,CAEA,OAAO,mBAAmBwC,EAAcC,EAA8B,CACpE,OAAOC,EAAwBF,EAAMlD,EAAe,eAAgBmD,CAAI,CAC1E,CACF,EApNanD,EACK,cAAwB,GAD7BA,EAGK,eAAyB,WAHpC,IAAMqD,EAANrD","names":["jwtDecode","decode","base64UrlDecode","base64Url","base64","paddedBase64","decode","_KeylessAccount","args","address","ephemeralKeyPair","iss","uidKey","uidVal","aud","pepper","proofFetcherOrData","jwt","addressSeed","computeAddressSeed","KeylessPublicKey","AccountAddress","pepperBytes","Hex","serializer","deserializer","EphemeralKeyPair","proof","SignedGroth16Signature","Serializer","bcsBytes","promise","transaction","raw","deriveTransactionType","signature","AnySignature","publicKey","AnyPublicKey","AccountAuthenticatorSingleKey","data","expiryDateSecs","currentTimeInSeconds","jwtHeader","ephemeralPublicKey","signMess","generateSigningMessage","ephemeralSignature","KeylessSignature","OpenIdSignatureOrZkProof","jwtPayload","jwtSignature","openIdSig","OpenIdSignature","bytes","Deserializer","jwtDecode","path","seed","fromDerivationPath","KeylessAccount"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as h}from"./chunk-4X4HJL3N.mjs";import{b as p,c as u,e as d}from"./chunk-FLYEALDB.mjs";import{a as c,b as y}from"./chunk-CYIEYPXQ.mjs";import{b as s}from"./chunk-CQJ4WN7M.mjs";import{a as l}from"./chunk-TVRJ3M7B.mjs";import{b as o}from"./chunk-AOCNYMMX.mjs";import{randomBytes as K}from"@noble/hashes/utils";var m=class r extends l{constructor(e){super();let{privateKey:t,expiryDateSecs:n,blinder:a}=e;this.privateKey=t,this.publicKey=new c(t.publicKey()),this.expiryDateSecs=n||BigInt(f(S()+h)),this.blinder=a!==void 0?o.fromHexInput(a).toUint8Array():g(),this.nonce=this.generateNonce()}serialize(e){e.serializeU32AsUleb128(this.publicKey.variant),e.serializeBytes(this.privateKey.toUint8Array()),e.serializeU64(this.expiryDateSecs),e.serializeFixedBytes(this.blinder)}static deserialize(e){let t=e.deserializeUleb128AsU32(),n;switch(t){case 0:n=s.deserialize(e);break;default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}let a=e.deserializeU64(),b=e.deserializeFixedBytes(31);return new r({privateKey:n,expiryDateSecs:a,blinder:b})}static generate(e){let t;switch(e?.scheme){case 0:default:t=s.generate()}return new r({privateKey:t})}generateNonce(){let e=p(this.publicKey.bcsToBytes(),93);return e.push(BigInt(this.expiryDateSecs)),e.push(u(this.blinder)),d(e).toString()}sign(e){return new y(this.privateKey.sign(e))}};function g(){return K(31)}function S(){return Math.floor(new Date().getTime()/1e3)}function f(r){let i=new Date(r*1e3);return i.setMinutes(0),i.setSeconds(0),i.setMilliseconds(0),Math.floor(i.getTime()/1e3)}export{m as a};
|
|
2
|
-
//# sourceMappingURL=chunk-U6XKW7OK.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/account/EphemeralKeyPair.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { randomBytes } from \"@noble/hashes/utils\";\n\nimport {\n EPK_HORIZON_SECS,\n Ed25519PrivateKey,\n EphemeralPublicKey,\n EphemeralSignature,\n PrivateKey,\n} from \"../core/crypto\";\nimport { Hex } from \"../core/hex\";\nimport { bytesToBigIntLE, padAndPackBytesWithLen, poseidonHash } from \"../core/crypto/poseidon\";\nimport { EphemeralPublicKeyVariant, HexInput, SigningSchemeInput } from \"../types\";\nimport { Deserializer, Serializable, Serializer } from \"../bcs\";\n\nexport class EphemeralKeyPair extends Serializable{\n readonly blinder: Uint8Array;\n\n readonly expiryDateSecs: bigint | number;\n\n readonly nonce: string;\n\n readonly privateKey: PrivateKey;\n\n readonly publicKey: EphemeralPublicKey;\n\n constructor(args: { privateKey: PrivateKey; expiryDateSecs?: bigint | number; blinder?: HexInput }) {\n super()\n const { privateKey, expiryDateSecs, blinder } = args;\n this.privateKey = privateKey;\n this.publicKey = new EphemeralPublicKey(privateKey.publicKey());\n this.expiryDateSecs = expiryDateSecs || BigInt(floorToWholeHour(currentTimeInSeconds() + EPK_HORIZON_SECS));\n this.blinder = blinder !== undefined ? Hex.fromHexInput(blinder).toUint8Array() : generateBlinder();\n this.nonce = this.generateNonce();\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(this.publicKey.variant);\n serializer.serializeBytes(this.privateKey.toUint8Array())\n serializer.serializeU64(this.expiryDateSecs)\n serializer.serializeFixedBytes(this.blinder)\n }\n\n static deserialize(deserializer: Deserializer): EphemeralKeyPair {\n const variantIndex = deserializer.deserializeUleb128AsU32();\n let privateKey: PrivateKey;\n switch (variantIndex) {\n case EphemeralPublicKeyVariant.Ed25519:\n privateKey = Ed25519PrivateKey.deserialize(deserializer);\n break;\n default:\n throw new Error(`Unknown variant index for EphemeralPublicKey: ${variantIndex}`);\n }\n const expiryDateSecs = deserializer.deserializeU64();\n const blinder = deserializer.deserializeFixedBytes(31);\n return new EphemeralKeyPair({privateKey, expiryDateSecs, blinder});\n }\n\n static generate(args?: { scheme: SigningSchemeInput }): EphemeralKeyPair {\n let privateKey: PrivateKey;\n\n switch (args?.scheme) {\n case SigningSchemeInput.Ed25519:\n default:\n privateKey = Ed25519PrivateKey.generate();\n }\n\n return new EphemeralKeyPair({ privateKey });\n }\n\n generateNonce(): string {\n const fields = padAndPackBytesWithLen(this.publicKey.bcsToBytes(), 93);\n fields.push(BigInt(this.expiryDateSecs));\n fields.push(bytesToBigIntLE(this.blinder));\n const nonceHash = poseidonHash(fields);\n return nonceHash.toString();\n }\n\n /**\n * Sign the given message with the private key.\n * *\n * @param data in HexInput format\n * @returns EphemeralSignature\n */\n sign(data: HexInput): EphemeralSignature {\n return new EphemeralSignature(this.privateKey.sign(data));\n }\n}\n\nfunction generateBlinder(): Uint8Array {\n return randomBytes(31);\n}\n\nfunction currentTimeInSeconds(): number {\n return Math.floor(new Date().getTime() / 1000);\n}\n\nfunction floorToWholeHour(timestampInSeconds: number): number {\n const date = new Date(timestampInSeconds * 1000);\n // Reset minutes and seconds to zero\n date.setMinutes(0);\n date.setSeconds(0);\n date.setMilliseconds(0);\n return Math.floor(date.getTime() / 1000);\n}\n"],"mappings":"2QAGA,OAAS,eAAAA,MAAmB,sBAcrB,IAAMC,EAAN,MAAMC,UAAyBC,CAAY,CAWhD,YAAYC,EAAwF,CAClG,MAAM,EACN,GAAM,CAAE,WAAAC,EAAY,eAAAC,EAAgB,QAAAC,CAAQ,EAAIH,EAChD,KAAK,WAAaC,EAClB,KAAK,UAAY,IAAIG,EAAmBH,EAAW,UAAU,CAAC,EAC9D,KAAK,eAAiBC,GAAkB,OAAOG,EAAiBC,EAAqB,EAAIC,CAAgB,CAAC,EAC1G,KAAK,QAAUJ,IAAY,OAAYK,EAAI,aAAaL,CAAO,EAAE,aAAa,EAAIM,EAAgB,EAClG,KAAK,MAAQ,KAAK,cAAc,CAClC,CAEA,UAAUC,EAA8B,CACtCA,EAAW,sBAAsB,KAAK,UAAU,OAAO,EACvDA,EAAW,eAAe,KAAK,WAAW,aAAa,CAAC,EACxDA,EAAW,aAAa,KAAK,cAAc,EAC3CA,EAAW,oBAAoB,KAAK,OAAO,CAC7C,CAEA,OAAO,YAAYC,EAA8C,CAC/D,IAAMC,EAAeD,EAAa,wBAAwB,EACtDV,EACJ,OAAQW,EAAc,CACpB,OACEX,EAAaY,EAAkB,YAAYF,CAAY,EACvD,MACF,QACE,MAAM,IAAI,MAAM,iDAAiDC,CAAY,EAAE,CACnF,CACA,IAAMV,EAAiBS,EAAa,eAAe,EAC7CR,EAAUQ,EAAa,sBAAsB,EAAE,EACrD,OAAO,IAAIb,EAAiB,CAAC,WAAAG,EAAY,eAAAC,EAAgB,QAAAC,CAAO,CAAC,CACnE,CAEA,OAAO,SAASH,EAAyD,CACvE,IAAIC,EAEJ,OAAQD,GAAM,OAAQ,CACpB,OACA,QACEC,EAAaY,EAAkB,SAAS,CAC5C,CAEA,OAAO,IAAIf,EAAiB,CAAE,WAAAG,CAAW,CAAC,CAC5C,CAEA,eAAwB,CACtB,IAAMa,EAASC,EAAuB,KAAK,UAAU,WAAW,EAAG,EAAE,EACrE,OAAAD,EAAO,KAAK,OAAO,KAAK,cAAc,CAAC,EACvCA,EAAO,KAAKE,EAAgB,KAAK,OAAO,CAAC,EACvBC,EAAaH,CAAM,EACpB,SAAS,CAC5B,CAQA,KAAKI,EAAoC,CACvC,OAAO,IAAIC,EAAmB,KAAK,WAAW,KAAKD,CAAI,CAAC,CAC1D,CACF,EAEA,SAAST,GAA8B,CACrC,OAAOW,EAAY,EAAE,CACvB,CAEA,SAASd,GAA+B,CACtC,OAAO,KAAK,MAAM,IAAI,KAAK,EAAE,QAAQ,EAAI,GAAI,CAC/C,CAEA,SAASD,EAAiBgB,EAAoC,CAC5D,IAAMC,EAAO,IAAI,KAAKD,EAAqB,GAAI,EAE/C,OAAAC,EAAK,WAAW,CAAC,EACjBA,EAAK,WAAW,CAAC,EACjBA,EAAK,gBAAgB,CAAC,EACf,KAAK,MAAMA,EAAK,QAAQ,EAAI,GAAI,CACzC","names":["randomBytes","EphemeralKeyPair","_EphemeralKeyPair","Serializable","args","privateKey","expiryDateSecs","blinder","EphemeralPublicKey","floorToWholeHour","currentTimeInSeconds","EPK_HORIZON_SECS","Hex","generateBlinder","serializer","deserializer","variantIndex","Ed25519PrivateKey","fields","padAndPackBytesWithLen","bytesToBigIntLE","poseidonHash","data","EphemeralSignature","randomBytes","timestampInSeconds","date"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as r,c as o}from"./chunk-WP7YNQOI.mjs";var t=class{constructor(e){this.config=e}async getPepper(e){return r({aptosConfig:this.config,...e})}async deriveKeylessAccount(e){return o({aptosConfig:this.config,...e})}};export{t as a};
|
|
2
|
-
//# sourceMappingURL=chunk-US26M7LP.mjs.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{c as E}from"./chunk-U2XWRAPL.mjs";import{e as x,f as K}from"./chunk-SEJ2XNM7.mjs";import{a as g}from"./chunk-GFW5KSAZ.mjs";import{a as m,l as h,m as A}from"./chunk-4X4HJL3N.mjs";import{b as S}from"./chunk-CYIEYPXQ.mjs";import{c as d}from"./chunk-S5HG2QUD.mjs";import{b as l}from"./chunk-TVRJ3M7B.mjs";import{b as a}from"./chunk-AOCNYMMX.mjs";import{jwtDecode as b}from"jwt-decode";import{bls12_381 as p}from"@noble/curves/bls12-381";var v="APTOS_KEYLESS_PEPPER_PINKAS_VUF_DST";function w(e){return new TextEncoder().encode(e)}var I=p.G2.hashToCurve(w("APTOS_KEYLESS_PEPPER_PINKAS_VUF_SECRET_KEY_BASE"),{DST:v}).toAffine();function j(e){let{jwt:i,uidKey:t}=e,r=b(i),o=new l;o.serializeStr(r.iss),o.serializeStr(r.aud),o.serializeStr(r[t||"sub"]),o.serializeStr(t||"sub");let s=o.toUint8Array(),n=p.G1.hashToCurve(s,{DST:"APTOS_PEPPER_SERVICE_BLS12381_VUF_DST"}).toAffine();return p.G1.ProjectivePoint.fromAffine(n)}async function C(e){let{aptosConfig:i,pepperInput:t,pepperBase:r}=e,{data:o}=await E({aptosConfig:i,path:"vrf-pub-key",originMethod:"getPepper"}),s=p.G2.ProjectivePoint.fromHex(o.vrf_public_key_hex_string);return p.verifyShortSignature(r,t,s)}async function F(e){let{aptosConfig:i,jwt:t,ephemeralKeyPair:r,uidKey:o,verify:s}=e,{derivationPath:n}=e,f={jwt_b64:t,epk:r.publicKey.bcsToHex().toStringWithoutPrefix(),exp_date_secs:Number(r.expiryDateSecs),epk_blinder:a.fromHexInput(r.blinder).toStringWithoutPrefix(),uid_key:o},{data:c}=await x({aptosConfig:i,path:"fetch",body:f,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}}),P=a.fromHexInput(c.signature).toUint8Array();if(s&&!C({aptosConfig:i,pepperBase:P,pepperInput:j(e)}))throw new Error("Unable to verify");let u=p.pairing(p.G1.ProjectivePoint.fromHex(P),p.G2.ProjectivePoint.fromAffine(I));return n===void 0&&(n=d),g.fromDerivationPath(n,p.fields.Fp12.toBytes(u)).slice(0,31)}async function H(e){let{aptosConfig:i,jwt:t,ephemeralKeyPair:r,pepper:o,uidKey:s,extraFieldKey:n}=e,f=b(t),c;if(n){let T=f[n];c=`"${n}":"${T}",`}let P={jwt_b64:t,epk:r.publicKey.bcsToHex().toStringWithoutPrefix(),epk_blinder:a.fromHexInput(r.blinder).toStringWithoutPrefix(),exp_date_secs:Number(r.expiryDateSecs),exp_horizon_secs:m,pepper:a.fromHexInput(o).toStringWithoutPrefix(),extra_field:n,uid_key:s||"sub"},{data:u}=await K({aptosConfig:i,path:"prove",body:P,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),y=u.proof,_=new h({a:y.a,b:y.b,c:y.c});return new A({proof:_,extraField:c,trainingWheelsSignature:S.fromHex(u.training_wheels_signature)})}async function O(e){let{fetchProofAsync:i}=e,{pepper:t}=e;if(t===void 0)t=await F(e);else if(a.fromHexInput(t).toUint8Array().length!==31)throw new Error("Pepper needs to be 31 bytes");let r=H({...e,pepper:t}),o=i?r:await r;return g.fromJWTAndProof({...e,proofFetcherOrData:o,pepper:t})}export{F as a,H as b,O as c};
|
|
2
|
-
//# sourceMappingURL=chunk-WP7YNQOI.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/internal/keyless.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * This file contains the underlying implementations for exposed API surface in\n * the {@link api/oidb}. By moving the methods out into a separate file,\n * other namespaces and processes can access these methods without depending on the entire\n * faucet namespace and without having a dependency cycle error.\n */\nimport { jwtDecode } from \"jwt-decode\";\nimport { bls12_381 as bls } from \"@noble/curves/bls12-381\";\nimport { ProjPointType } from \"@noble/curves/abstract/weierstrass\";\nimport { AptosConfig } from \"../api/aptosConfig\";\nimport { getAptosPepperService, postAptosPepperService, postAptosProvingService } from \"../client\";\nimport {\n APTOS_BIP44_DEFAULT_DERIVATION_PATH,\n EPK_HORIZON_SECS,\n EphemeralSignature,\n Groth16Zkp,\n Hex,\n SignedGroth16Signature,\n} from \"../core\";\nimport { HexInput } from \"../types\";\nimport { Serializer } from \"../bcs\";\nimport { EphemeralKeyPair, KeylessAccount } from \"../account\";\nimport { PepperFetchResponse, ProverResponse } from \"../types/keyless\";\n\nconst APTOS_KEYLESS_PEPPER_PINKAS_VUF_DST = \"APTOS_KEYLESS_PEPPER_PINKAS_VUF_DST\";\n\nfunction stringToUint8Array(str: string): Uint8Array {\n const encoder = new TextEncoder();\n return encoder.encode(str);\n}\n\nconst PINKAS_VUF_SECRET_KEY_BASE_AFFINE = bls.G2.hashToCurve(\n stringToUint8Array(\"APTOS_KEYLESS_PEPPER_PINKAS_VUF_SECRET_KEY_BASE\"),\n { DST: APTOS_KEYLESS_PEPPER_PINKAS_VUF_DST },\n).toAffine();\n\nfunction getPepperInput(args: { jwt: string; uidKey?: string }): ProjPointType<bigint> {\n const { jwt, uidKey } = args;\n const jwtPayload = jwtDecode<{ [key: string]: string }>(jwt);\n const serializer = new Serializer();\n serializer.serializeStr(jwtPayload.iss);\n serializer.serializeStr(jwtPayload.aud);\n serializer.serializeStr(jwtPayload[uidKey || \"sub\"]);\n serializer.serializeStr(uidKey || \"sub\");\n const serial = serializer.toUint8Array();\n const msg = bls.G1.hashToCurve(serial, { DST: \"APTOS_PEPPER_SERVICE_BLS12381_VUF_DST\" }).toAffine();\n const pp = bls.G1.ProjectivePoint.fromAffine(msg);\n return pp;\n}\n\nasync function verifyPepperBase(args: {\n aptosConfig: AptosConfig;\n pepperInput: ProjPointType<bigint>;\n pepperBase: Uint8Array;\n}): Promise<boolean> {\n const { aptosConfig, pepperInput, pepperBase } = args;\n const { data: pubKeyResponse } = await getAptosPepperService<any, { vrf_public_key_hex_string: string }>({\n aptosConfig,\n path: \"vrf-pub-key\",\n originMethod: \"getPepper\",\n });\n const publicKeyFromService = bls.G2.ProjectivePoint.fromHex(pubKeyResponse.vrf_public_key_hex_string);\n return bls.verifyShortSignature(pepperBase, pepperInput, publicKeyFromService);\n}\n\nexport async function getPepper(args: {\n aptosConfig: AptosConfig;\n jwt: string;\n ephemeralKeyPair: EphemeralKeyPair;\n uidKey?: string;\n derivationPath?: string;\n verify?: boolean;\n}): Promise<Uint8Array> {\n const { aptosConfig, jwt, ephemeralKeyPair, uidKey, verify } = args;\n let { derivationPath } = args;\n\n const body = {\n jwt_b64: jwt,\n epk: ephemeralKeyPair.publicKey.bcsToHex().toStringWithoutPrefix(),\n exp_date_secs: Number(ephemeralKeyPair.expiryDateSecs),\n epk_blinder: Hex.fromHexInput(ephemeralKeyPair.blinder).toStringWithoutPrefix(),\n uid_key: uidKey,\n };\n // console.log(JSON.stringify(body));\n const { data } = await postAptosPepperService<any, PepperFetchResponse>({\n aptosConfig,\n path: \"fetch\",\n body,\n originMethod: \"getPepper\",\n overrides: { WITH_CREDENTIALS: false },\n });\n const pepperBase = Hex.fromHexInput(data.signature).toUint8Array();\n\n if (verify) {\n const pepperVerified = verifyPepperBase({ aptosConfig, pepperBase, pepperInput: getPepperInput(args) });\n if (!pepperVerified) {\n throw new Error(\"Unable to verify\");\n }\n }\n // This takes the BLS VUF H(m)^sk and transforms it into a Pinkas VUF e(H(m), g_3^sk), where g_3 is the base of the secret key (computed pseudo-randomly via hash-to-curve).\n // This gives us the freedom of either decentralizing the pepper service as a BLS-based MPC or on top of the validators, by reusing the Pinkas WVUF-based randomness infrastructure.\n const newPepperBase = bls.pairing(\n bls.G1.ProjectivePoint.fromHex(pepperBase),\n bls.G2.ProjectivePoint.fromAffine(PINKAS_VUF_SECRET_KEY_BASE_AFFINE),\n );\n\n if (derivationPath === undefined) {\n derivationPath = APTOS_BIP44_DEFAULT_DERIVATION_PATH;\n }\n const pepper = KeylessAccount.fromDerivationPath(derivationPath, bls.fields.Fp12.toBytes(newPepperBase));\n return pepper.slice(0, 31);\n}\n\nexport async function getProof(args: {\n aptosConfig: AptosConfig;\n jwt: string;\n ephemeralKeyPair: EphemeralKeyPair;\n pepper: HexInput;\n uidKey?: string;\n extraFieldKey?: string;\n}): Promise<SignedGroth16Signature> {\n const { aptosConfig, jwt, ephemeralKeyPair, pepper, uidKey, extraFieldKey } = args;\n const jwtPayload = jwtDecode<{ [key: string]: string }>(jwt);\n let extraField;\n if (extraFieldKey) {\n const extraFieldVal = jwtPayload[extraFieldKey];\n extraField = `\"${extraFieldKey}\":\"${extraFieldVal}\",`;\n }\n const json = {\n jwt_b64: jwt,\n epk: ephemeralKeyPair.publicKey.bcsToHex().toStringWithoutPrefix(),\n epk_blinder: Hex.fromHexInput(ephemeralKeyPair.blinder).toStringWithoutPrefix(),\n exp_date_secs: Number(ephemeralKeyPair.expiryDateSecs),\n exp_horizon_secs: EPK_HORIZON_SECS,\n pepper: Hex.fromHexInput(pepper).toStringWithoutPrefix(),\n extra_field: extraFieldKey,\n uid_key: uidKey || \"sub\",\n };\n\n const { data } = await postAptosProvingService<any, ProverResponse>({\n aptosConfig,\n path: \"prove\",\n body: json,\n originMethod: \"getProof\",\n overrides: { WITH_CREDENTIALS: false },\n });\n\n const proofPoints = data.proof;\n const proof = new Groth16Zkp({\n a: proofPoints.a,\n b: proofPoints.b,\n c: proofPoints.c,\n });\n\n const signedProof = new SignedGroth16Signature({\n proof,\n extraField,\n trainingWheelsSignature: EphemeralSignature.fromHex(data.training_wheels_signature),\n });\n return signedProof;\n}\n\nexport async function deriveKeylessAccount(args: {\n aptosConfig: AptosConfig;\n jwt: string;\n ephemeralKeyPair: EphemeralKeyPair;\n uidKey?: string;\n pepper?: HexInput;\n extraFieldKey?: string;\n fetchProofAsync?: boolean;\n}): Promise<KeylessAccount> {\n const { fetchProofAsync } = args;\n let { pepper } = args;\n if (pepper === undefined) {\n pepper = await getPepper(args);\n } else if (Hex.fromHexInput(pepper).toUint8Array().length !== 31) {\n throw new Error(\"Pepper needs to be 31 bytes\");\n }\n\n const proofPromise = getProof({ ...args, pepper });\n const proof = fetchProofAsync ? proofPromise : await proofPromise;\n\n const keylessAccount = KeylessAccount.fromJWTAndProof({ ...args, proofFetcherOrData: proof, pepper });\n\n return keylessAccount;\n}\n"],"mappings":"6VASA,OAAS,aAAAA,MAAiB,aAC1B,OAAS,aAAaC,MAAW,0BAiBjC,IAAMC,EAAsC,sCAE5C,SAASC,EAAmBC,EAAyB,CAEnD,OADgB,IAAI,YAAY,EACjB,OAAOA,CAAG,CAC3B,CAEA,IAAMC,EAAoCC,EAAI,GAAG,YAC/CH,EAAmB,iDAAiD,EACpE,CAAE,IAAKD,CAAoC,CAC7C,EAAE,SAAS,EAEX,SAASK,EAAeC,EAA+D,CACrF,GAAM,CAAE,IAAAC,EAAK,OAAAC,CAAO,EAAIF,EAClBG,EAAaC,EAAqCH,CAAG,EACrDI,EAAa,IAAIC,EACvBD,EAAW,aAAaF,EAAW,GAAG,EACtCE,EAAW,aAAaF,EAAW,GAAG,EACtCE,EAAW,aAAaF,EAAWD,GAAU,KAAK,CAAC,EACnDG,EAAW,aAAaH,GAAU,KAAK,EACvC,IAAMK,EAASF,EAAW,aAAa,EACjCG,EAAMV,EAAI,GAAG,YAAYS,EAAQ,CAAE,IAAK,uCAAwC,CAAC,EAAE,SAAS,EAElG,OADWT,EAAI,GAAG,gBAAgB,WAAWU,CAAG,CAElD,CAEA,eAAeC,EAAiBT,EAIX,CACnB,GAAM,CAAE,YAAAU,EAAa,YAAAC,EAAa,WAAAC,CAAW,EAAIZ,EAC3C,CAAE,KAAMa,CAAe,EAAI,MAAMC,EAAkE,CACvG,YAAAJ,EACA,KAAM,cACN,aAAc,WAChB,CAAC,EACKK,EAAuBjB,EAAI,GAAG,gBAAgB,QAAQe,EAAe,yBAAyB,EACpG,OAAOf,EAAI,qBAAqBc,EAAYD,EAAaI,CAAoB,CAC/E,CAEA,eAAsBC,EAAUhB,EAOR,CACtB,GAAM,CAAE,YAAAU,EA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YAAaI,EAAI,aAAaJ,EAAiB,OAAO,EAAE,sBAAsB,EAC9E,cAAe,OAAOA,EAAiB,cAAc,EACrD,iBAAkBgB,EAClB,OAAQZ,EAAI,aAAaO,CAAM,EAAE,sBAAsB,EACvD,YAAaC,EACb,QAAS3B,GAAU,KACrB,EAEM,CAAE,KAAAoB,CAAK,EAAI,MAAMY,EAA6C,CAClE,YAAAxB,EACA,KAAM,QACN,KAAMsB,EACN,aAAc,WACd,UAAW,CAAE,iBAAkB,EAAM,CACvC,CAAC,EAEKG,EAAcb,EAAK,MACnBc,EAAQ,IAAIC,EAAW,CAC3B,EAAGF,EAAY,EACf,EAAGA,EAAY,EACf,EAAGA,EAAY,CACjB,CAAC,EAOD,OALoB,IAAIG,EAAuB,CAC7C,MAAAF,EACA,WAAAN,EACA,wBAAyBS,EAAmB,QAAQjB,EAAK,yBAAyB,CACpF,CAAC,CAEH,CAEA,eAAsBkB,EAAqBxC,EAQf,CAC1B,GAAM,CAAE,gBAAAyC,CAAgB,EAAIzC,EACxB,CAAE,OAAA4B,CAAO,EAAI5B,EACjB,GAAI4B,IAAW,OACbA,EAAS,MAAMZ,EAAUhB,CAAI,UACpBqB,EAAI,aAAaO,CAAM,EAAE,aAAa,EAAE,SAAW,GAC5D,MAAM,IAAI,MAAM,6BAA6B,EAG/C,IAAMc,EAAef,EAAS,CAAE,GAAG3B,EAAM,OAAA4B,CAAO,CAAC,EAC3CQ,EAAQK,EAAkBC,EAAe,MAAMA,EAInD,OAFqBhB,EAAe,gBAAgB,CAAE,GAAG1B,EAAM,mBAAoBoC,EAAO,OAAAR,CAAO,CAAC,CAGtG","names":["jwtDecode","bls","APTOS_KEYLESS_PEPPER_PINKAS_VUF_DST","stringToUint8Array","str","PINKAS_VUF_SECRET_KEY_BASE_AFFINE","bls","getPepperInput","args","jwt","uidKey","jwtPayload","jwtDecode","serializer","Serializer","serial","msg","verifyPepperBase","aptosConfig","pepperInput","pepperBase","pubKeyResponse","getAptosPepperService","publicKeyFromService","getPepper","ephemeralKeyPair","verify","derivationPath","body","Hex","data","postAptosPepperService","newPepperBase","APTOS_BIP44_DEFAULT_DERIVATION_PATH","KeylessAccount","getProof","pepper","extraFieldKey","extraField","extraFieldVal","json","EPK_HORIZON_SECS","postAptosProvingService","proofPoints","proof","Groth16Zkp","SignedGroth16Signature","EphemeralSignature","deriveKeylessAccount","fetchProofAsync","proofPromise"]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|