@aptos-labs/ts-sdk 1.15.0 → 1.16.0-zeta.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.
Files changed (495) hide show
  1. package/dist/common/{accountAddress-ccLvlUQe.d.ts → accountAddress-OUd5ov6z.d.ts} +97 -5
  2. package/dist/common/chunk-VLEH6QBR.js +2 -0
  3. package/dist/common/chunk-VLEH6QBR.js.map +1 -0
  4. package/dist/common/cli/index.d.ts +1 -1
  5. package/dist/common/cli/index.js +1 -1
  6. package/dist/common/cli/index.js.map +1 -1
  7. package/dist/common/index.d.ts +757 -58
  8. package/dist/common/index.js +28 -28
  9. package/dist/common/index.js.map +1 -1
  10. package/dist/esm/{Ed25519Account-B1VMJOY2.d.mts → Ed25519Account-9zBaZEnp.d.mts} +1 -1
  11. package/dist/esm/account/Account.d.mts +2 -2
  12. package/dist/esm/account/Account.mjs +1 -1
  13. package/dist/esm/account/Ed25519Account.d.mts +2 -2
  14. package/dist/esm/account/Ed25519Account.mjs +1 -1
  15. package/dist/esm/account/EphemeralKeyPair.d.mts +85 -0
  16. package/dist/esm/account/EphemeralKeyPair.mjs +2 -0
  17. package/dist/esm/account/KeylessAccount.d.mts +225 -0
  18. package/dist/esm/account/KeylessAccount.mjs +2 -0
  19. package/dist/esm/account/MultiKeyAccount.d.mts +13 -7
  20. package/dist/esm/account/MultiKeyAccount.mjs +1 -1
  21. package/dist/esm/account/SingleKeyAccount.d.mts +2 -2
  22. package/dist/esm/account/SingleKeyAccount.mjs +1 -1
  23. package/dist/esm/account/index.d.mts +10 -2
  24. package/dist/esm/account/index.mjs +1 -1
  25. package/dist/esm/api/account.d.mts +2 -2
  26. package/dist/esm/api/account.mjs +1 -1
  27. package/dist/esm/api/ans.d.mts +2 -2
  28. package/dist/esm/api/ans.mjs +1 -1
  29. package/dist/esm/api/aptos.d.mts +13 -3
  30. package/dist/esm/api/aptos.mjs +1 -1
  31. package/dist/esm/api/aptosConfig.d.mts +20 -0
  32. package/dist/esm/api/aptosConfig.mjs +1 -1
  33. package/dist/esm/api/coin.d.mts +1 -1
  34. package/dist/esm/api/coin.mjs +1 -1
  35. package/dist/esm/api/digitalAsset.d.mts +2 -2
  36. package/dist/esm/api/digitalAsset.mjs +1 -1
  37. package/dist/esm/api/event.mjs +1 -1
  38. package/dist/esm/api/faucet.mjs +1 -1
  39. package/dist/esm/api/fungibleAsset.d.mts +2 -2
  40. package/dist/esm/api/fungibleAsset.mjs +1 -1
  41. package/dist/esm/api/general.d.mts +1 -1
  42. package/dist/esm/api/general.mjs +1 -1
  43. package/dist/esm/api/index.d.mts +11 -2
  44. package/dist/esm/api/index.mjs +1 -1
  45. package/dist/esm/api/keyless.d.mts +88 -0
  46. package/dist/esm/api/keyless.mjs +2 -0
  47. package/dist/esm/api/keyless.mjs.map +1 -0
  48. package/dist/esm/api/staking.mjs +1 -1
  49. package/dist/esm/api/table.mjs +1 -1
  50. package/dist/esm/api/transaction.d.mts +2 -2
  51. package/dist/esm/api/transaction.mjs +1 -1
  52. package/dist/esm/api/transactionSubmission/build.d.mts +1 -1
  53. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  54. package/dist/esm/api/transactionSubmission/management.d.mts +2 -2
  55. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  56. package/dist/esm/api/transactionSubmission/sign.d.mts +2 -2
  57. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  58. package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -1
  59. package/dist/esm/api/transactionSubmission/simulate.d.mts +1 -1
  60. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  61. package/dist/esm/api/transactionSubmission/submit.d.mts +1 -1
  62. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  63. package/dist/esm/api/utils.mjs +1 -1
  64. package/dist/esm/bcs/deserializer.d.mts +32 -0
  65. package/dist/esm/bcs/deserializer.mjs +1 -1
  66. package/dist/esm/bcs/index.mjs +1 -1
  67. package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
  68. package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
  69. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  70. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  71. package/dist/esm/bcs/serializer.d.mts +42 -0
  72. package/dist/esm/bcs/serializer.mjs +1 -1
  73. package/dist/esm/{chunk-36QXVFR5.mjs → chunk-272NA6H5.mjs} +2 -2
  74. package/dist/esm/{chunk-36QXVFR5.mjs.map → chunk-272NA6H5.mjs.map} +1 -1
  75. package/dist/esm/{chunk-R5ST36VJ.mjs → chunk-34WI7I3Z.mjs} +2 -2
  76. package/dist/esm/chunk-3DP4R3FI.mjs +2 -0
  77. package/dist/esm/{chunk-FFGY7Z4B.mjs → chunk-3J53BCEQ.mjs} +2 -2
  78. package/dist/esm/chunk-3SXTTG2X.mjs +2 -0
  79. package/dist/esm/chunk-3SXTTG2X.mjs.map +1 -0
  80. package/dist/esm/{chunk-4GWNWSZP.mjs → chunk-3YIUOKWW.mjs} +2 -2
  81. package/dist/esm/{chunk-EA2DKJPX.mjs → chunk-45ESRYGP.mjs} +2 -2
  82. package/dist/esm/chunk-4RXGVY2H.mjs +2 -0
  83. package/dist/esm/chunk-4RXGVY2H.mjs.map +1 -0
  84. package/dist/esm/chunk-4VAYXBD2.mjs +2 -0
  85. package/dist/esm/chunk-5SGIYAB7.mjs +2 -0
  86. package/dist/esm/chunk-5SGIYAB7.mjs.map +1 -0
  87. package/dist/esm/chunk-5VLCYHNJ.mjs +2 -0
  88. package/dist/esm/chunk-5VLCYHNJ.mjs.map +1 -0
  89. package/dist/esm/{chunk-JGSOTNJ5.mjs → chunk-6F3HFDL3.mjs} +2 -2
  90. package/dist/esm/{chunk-BN22EYXR.mjs → chunk-6MDYCC7P.mjs} +2 -2
  91. package/dist/esm/{chunk-F7NLNWHN.mjs → chunk-7CJAEAQZ.mjs} +2 -2
  92. package/dist/esm/chunk-7QGIAVW4.mjs +2 -0
  93. package/dist/esm/chunk-7QGIAVW4.mjs.map +1 -0
  94. package/dist/esm/chunk-7UBKXR37.mjs +2 -0
  95. package/dist/esm/chunk-7UBKXR37.mjs.map +1 -0
  96. package/dist/esm/{chunk-JQIGQMNZ.mjs → chunk-7Y6AWDBZ.mjs} +2 -2
  97. package/dist/esm/chunk-7Z6DYLCA.mjs +1 -0
  98. package/dist/esm/chunk-7Z6DYLCA.mjs.map +1 -0
  99. package/dist/esm/{chunk-BCUSI3N6.mjs → chunk-AOCNYMMX.mjs} +2 -2
  100. package/dist/esm/chunk-AQ4I7VVB.mjs +1 -0
  101. package/dist/esm/chunk-AQ4I7VVB.mjs.map +1 -0
  102. package/dist/esm/chunk-AUAL3H36.mjs +2 -0
  103. package/dist/esm/{chunk-I5T6PHDV.mjs → chunk-AUV4VAXK.mjs} +2 -2
  104. package/dist/esm/{chunk-2X7A4HUS.mjs → chunk-AVWAYKNS.mjs} +2 -2
  105. package/dist/esm/{chunk-EZPUVLME.mjs → chunk-BNA3SGG6.mjs} +2 -2
  106. package/dist/esm/chunk-CEGCSC3T.mjs +2 -0
  107. package/dist/esm/chunk-CIPPNT3W.mjs +2 -0
  108. package/dist/esm/chunk-CIPPNT3W.mjs.map +1 -0
  109. package/dist/esm/{chunk-F4GDEXZ6.mjs → chunk-CZOUSIAD.mjs} +2 -2
  110. package/dist/esm/chunk-D76FE35G.mjs +2 -0
  111. package/dist/esm/chunk-D76FE35G.mjs.map +1 -0
  112. package/dist/esm/{chunk-A4JUQZXI.mjs → chunk-DSVNXD5A.mjs} +2 -2
  113. package/dist/esm/chunk-EJ7ODMDA.mjs +2 -0
  114. package/dist/esm/{chunk-UR3JTLIT.mjs → chunk-EJURLI4L.mjs} +2 -2
  115. package/dist/esm/chunk-FBPNHF54.mjs +2 -0
  116. package/dist/esm/chunk-FUQDDIKQ.mjs +2 -0
  117. package/dist/esm/chunk-FUQDDIKQ.mjs.map +1 -0
  118. package/dist/esm/chunk-FWTJQHJR.mjs +2 -0
  119. package/dist/esm/chunk-FWTJQHJR.mjs.map +1 -0
  120. package/dist/esm/{chunk-AHW3SKT7.mjs → chunk-GHHIUWPP.mjs} +2 -2
  121. package/dist/esm/{chunk-G56GPLTB.mjs → chunk-GS5Z3HO7.mjs} +2 -2
  122. package/dist/esm/chunk-HGRU3HWY.mjs +2 -0
  123. package/dist/esm/{chunk-P5TZBE3L.mjs.map → chunk-HGRU3HWY.mjs.map} +1 -1
  124. package/dist/esm/{chunk-XFSDV3ND.mjs → chunk-HOX6Q6ZP.mjs} +2 -2
  125. package/dist/esm/chunk-HQK6MF3G.mjs +2 -0
  126. package/dist/esm/chunk-IMVC2JKU.mjs +2 -0
  127. package/dist/esm/{chunk-2XK53QFA.mjs.map → chunk-IMVC2JKU.mjs.map} +1 -1
  128. package/dist/esm/chunk-ISXBJPLD.mjs +2 -0
  129. package/dist/esm/{chunk-JX75UKJX.mjs → chunk-IU6REVKX.mjs} +2 -2
  130. package/dist/esm/{chunk-ERIPXWXJ.mjs → chunk-IWKIZLFW.mjs} +2 -2
  131. package/dist/esm/{chunk-PIVZMT5D.mjs → chunk-J534ICWA.mjs} +2 -2
  132. package/dist/esm/chunk-J577ODDM.mjs +2 -0
  133. package/dist/esm/chunk-JBTLE33X.mjs +2 -0
  134. package/dist/esm/{chunk-CJDEPZ4J.mjs.map → chunk-JBTLE33X.mjs.map} +1 -1
  135. package/dist/esm/chunk-JCDZ2WXX.mjs +2 -0
  136. package/dist/esm/chunk-JCDZ2WXX.mjs.map +1 -0
  137. package/dist/esm/{chunk-YK63A5T6.mjs → chunk-LLRWILVZ.mjs} +2 -2
  138. package/dist/esm/chunk-M4Q4XDVR.mjs +2 -0
  139. package/dist/esm/chunk-M4Q4XDVR.mjs.map +1 -0
  140. package/dist/esm/chunk-MEOBWD6V.mjs +2 -0
  141. package/dist/esm/chunk-MEOBWD6V.mjs.map +1 -0
  142. package/dist/esm/{chunk-35EWRSDK.mjs → chunk-MLQT5I6K.mjs} +2 -2
  143. package/dist/esm/chunk-MSGHGK52.mjs +2 -0
  144. package/dist/esm/{chunk-5EN52MUT.mjs → chunk-NGTNMV6Q.mjs} +2 -2
  145. package/dist/esm/{chunk-P46OPJB4.mjs → chunk-NH466YFP.mjs} +2 -2
  146. package/dist/esm/chunk-NMD45OTM.mjs +2 -0
  147. package/dist/esm/chunk-NMD45OTM.mjs.map +1 -0
  148. package/dist/esm/{chunk-ZM33M6QO.mjs → chunk-NUBYALZP.mjs} +2 -2
  149. package/dist/esm/{chunk-CHWE77CR.mjs → chunk-OFC75EWS.mjs} +2 -2
  150. package/dist/esm/{chunk-H6FEXRTK.mjs → chunk-OOYRJQPD.mjs} +2 -2
  151. package/dist/esm/chunk-OZ3GSAFK.mjs +2 -0
  152. package/dist/esm/chunk-OZ3GSAFK.mjs.map +1 -0
  153. package/dist/esm/chunk-PENBUSGL.mjs +2 -0
  154. package/dist/esm/chunk-PENBUSGL.mjs.map +1 -0
  155. package/dist/esm/{chunk-WN3JL7ZT.mjs → chunk-PG7KSUMN.mjs} +2 -2
  156. package/dist/esm/{chunk-KAGLWBIJ.mjs → chunk-PGP2XMDE.mjs} +2 -2
  157. package/dist/esm/chunk-Q6LFIZ3L.mjs +2 -0
  158. package/dist/esm/chunk-Q6LFIZ3L.mjs.map +1 -0
  159. package/dist/esm/{chunk-CYTRYBWN.mjs → chunk-QJIMZI32.mjs} +2 -2
  160. package/dist/esm/{chunk-E56MTU2U.mjs → chunk-QLE5JL4X.mjs} +2 -2
  161. package/dist/esm/{chunk-WNPL4SEJ.mjs → chunk-QOOHLRRJ.mjs} +2 -2
  162. package/dist/esm/chunk-QYEJOEWB.mjs +2 -0
  163. package/dist/esm/chunk-QYEJOEWB.mjs.map +1 -0
  164. package/dist/esm/{chunk-TM7NDDT3.mjs → chunk-R4HLV32L.mjs} +2 -2
  165. package/dist/esm/chunk-RAHMGSBW.mjs +2 -0
  166. package/dist/esm/chunk-RAHMGSBW.mjs.map +1 -0
  167. package/dist/esm/{chunk-GHYE26Q5.mjs → chunk-RKHPXZM6.mjs} +2 -2
  168. package/dist/esm/{chunk-GHYE26Q5.mjs.map → chunk-RKHPXZM6.mjs.map} +1 -1
  169. package/dist/esm/{chunk-MCRRHBFQ.mjs → chunk-RWYPGTNL.mjs} +2 -2
  170. package/dist/esm/chunk-SCHMTP4N.mjs +2 -0
  171. package/dist/esm/chunk-SCHZ67F3.mjs +2 -0
  172. package/dist/esm/chunk-SCHZ67F3.mjs.map +1 -0
  173. package/dist/esm/{chunk-GP6Z47HM.mjs → chunk-SCRIQQV3.mjs} +2 -2
  174. package/dist/esm/{chunk-NGQR5UQ3.mjs → chunk-SNBE5YAC.mjs} +2 -2
  175. package/dist/esm/chunk-SSDWEOF7.mjs +2 -0
  176. package/dist/esm/chunk-SSDWEOF7.mjs.map +1 -0
  177. package/dist/esm/chunk-SZ6KR73C.mjs +2 -0
  178. package/dist/esm/chunk-SZ6KR73C.mjs.map +1 -0
  179. package/dist/esm/{chunk-UW2FPXYA.mjs → chunk-THURV6CN.mjs} +2 -2
  180. package/dist/esm/chunk-TJDC5PWD.mjs +2 -0
  181. package/dist/esm/{chunk-GUALXVFI.mjs → chunk-TU6VKYDC.mjs} +2 -2
  182. package/dist/esm/{chunk-DZSDCUP2.mjs → chunk-UFMIMN7W.mjs} +2 -2
  183. package/dist/esm/{chunk-3Y46WJUR.mjs → chunk-ULW5LX5H.mjs} +2 -2
  184. package/dist/esm/chunk-V6M7FGQT.mjs +2 -0
  185. package/dist/esm/chunk-V6M7FGQT.mjs.map +1 -0
  186. package/dist/esm/{chunk-U3YYSIIT.mjs → chunk-VBODXPT3.mjs} +2 -2
  187. package/dist/esm/chunk-VMVSUH2K.mjs +2 -0
  188. package/dist/esm/{chunk-QRS4DGP3.mjs → chunk-WHSN42R2.mjs} +2 -2
  189. package/dist/esm/{chunk-QRS4DGP3.mjs.map → chunk-WHSN42R2.mjs.map} +1 -1
  190. package/dist/esm/{chunk-ZCG6WBLE.mjs → chunk-WJIICWOB.mjs} +2 -2
  191. package/dist/esm/{chunk-T2AGN5YT.mjs → chunk-WOLLRMXR.mjs} +2 -2
  192. package/dist/esm/chunk-WSVJNBSJ.mjs +2 -0
  193. package/dist/esm/{chunk-YMB2XW2O.mjs.map → chunk-WSVJNBSJ.mjs.map} +1 -1
  194. package/dist/esm/chunk-WXLSJF4A.mjs +2 -0
  195. package/dist/esm/chunk-WXLSJF4A.mjs.map +1 -0
  196. package/dist/esm/{chunk-GM56MMNJ.mjs → chunk-XQ7I34AL.mjs} +2 -2
  197. package/dist/esm/{chunk-RT6LEYHZ.mjs → chunk-Y24BMR2W.mjs} +2 -2
  198. package/dist/esm/chunk-YE5B2S5L.mjs +2 -0
  199. package/dist/esm/chunk-YE5B2S5L.mjs.map +1 -0
  200. package/dist/esm/{chunk-HSJTQLI2.mjs → chunk-YLQJBXUF.mjs} +2 -2
  201. package/dist/esm/chunk-ZAXWW7VW.mjs +2 -0
  202. package/dist/esm/chunk-ZAXWW7VW.mjs.map +1 -0
  203. package/dist/esm/chunk-ZV5P2GSJ.mjs +2 -0
  204. package/dist/esm/{chunk-SRDIYE3M.mjs.map → chunk-ZV5P2GSJ.mjs.map} +1 -1
  205. package/dist/esm/cli/index.mjs +1 -1
  206. package/dist/esm/cli/localNode.mjs +1 -1
  207. package/dist/esm/cli/move.mjs +1 -1
  208. package/dist/esm/client/core.mjs +1 -1
  209. package/dist/esm/client/get.d.mts +8 -1
  210. package/dist/esm/client/get.mjs +1 -1
  211. package/dist/esm/client/index.d.mts +2 -2
  212. package/dist/esm/client/index.mjs +1 -1
  213. package/dist/esm/client/post.d.mts +9 -1
  214. package/dist/esm/client/post.mjs +1 -1
  215. package/dist/esm/client/types.d.mts +5 -1
  216. package/dist/esm/client/types.mjs +1 -1
  217. package/dist/esm/core/account/index.mjs +1 -1
  218. package/dist/esm/core/account/utils/address.mjs +1 -1
  219. package/dist/esm/core/account/utils/index.mjs +1 -1
  220. package/dist/esm/core/accountAddress.mjs +1 -1
  221. package/dist/esm/core/authenticationKey.d.mts +1 -1
  222. package/dist/esm/core/authenticationKey.mjs +1 -1
  223. package/dist/esm/core/common.mjs +1 -1
  224. package/dist/esm/core/crypto/cryptoHasher.d.mts +21 -0
  225. package/dist/esm/core/crypto/cryptoHasher.mjs +2 -0
  226. package/dist/esm/core/crypto/cryptoHasher.mjs.map +1 -0
  227. package/dist/esm/core/crypto/ed25519.d.mts +1 -1
  228. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  229. package/dist/esm/core/crypto/ephemeral.d.mts +73 -0
  230. package/dist/esm/core/crypto/ephemeral.mjs +2 -0
  231. package/dist/esm/core/crypto/ephemeral.mjs.map +1 -0
  232. package/dist/esm/core/crypto/index.d.mts +5 -1
  233. package/dist/esm/core/crypto/index.mjs +1 -1
  234. package/dist/esm/core/crypto/keyless.d.mts +276 -0
  235. package/dist/esm/core/crypto/keyless.mjs +2 -0
  236. package/dist/esm/core/crypto/keyless.mjs.map +1 -0
  237. package/dist/esm/core/crypto/multiEd25519.d.mts +1 -1
  238. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  239. package/dist/esm/core/crypto/multiKey.d.mts +1 -1
  240. package/dist/esm/core/crypto/multiKey.mjs +1 -1
  241. package/dist/esm/core/crypto/poseidon.d.mts +19 -0
  242. package/dist/esm/core/crypto/poseidon.mjs +2 -0
  243. package/dist/esm/core/crypto/poseidon.mjs.map +1 -0
  244. package/dist/esm/core/crypto/privateKey.d.mts +1 -1
  245. package/dist/esm/core/crypto/proof.d.mts +21 -0
  246. package/dist/esm/core/crypto/proof.mjs +2 -0
  247. package/dist/esm/core/crypto/proof.mjs.map +1 -0
  248. package/dist/esm/core/crypto/publicKey.d.mts +1 -1
  249. package/dist/esm/core/crypto/publicKey.mjs +1 -1
  250. package/dist/esm/core/crypto/secp256k1.d.mts +1 -1
  251. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  252. package/dist/esm/core/crypto/signature.mjs +1 -1
  253. package/dist/esm/core/crypto/singleKey.d.mts +1 -1
  254. package/dist/esm/core/crypto/singleKey.mjs +1 -1
  255. package/dist/esm/core/crypto/utils.mjs +1 -1
  256. package/dist/esm/core/hex.mjs +1 -1
  257. package/dist/esm/core/index.d.mts +5 -1
  258. package/dist/esm/core/index.mjs +1 -1
  259. package/dist/esm/index.d.mts +16 -8
  260. package/dist/esm/index.mjs +1 -1
  261. package/dist/esm/internal/account.d.mts +2 -2
  262. package/dist/esm/internal/account.mjs +1 -1
  263. package/dist/esm/internal/ans.d.mts +2 -2
  264. package/dist/esm/internal/ans.mjs +1 -1
  265. package/dist/esm/internal/coin.d.mts +1 -1
  266. package/dist/esm/internal/coin.mjs +1 -1
  267. package/dist/esm/internal/digitalAsset.d.mts +2 -2
  268. package/dist/esm/internal/digitalAsset.mjs +1 -1
  269. package/dist/esm/internal/event.mjs +1 -1
  270. package/dist/esm/internal/faucet.mjs +1 -1
  271. package/dist/esm/internal/fungibleAsset.d.mts +2 -2
  272. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  273. package/dist/esm/internal/general.mjs +1 -1
  274. package/dist/esm/internal/keyless.d.mts +78 -0
  275. package/dist/esm/internal/keyless.mjs +2 -0
  276. package/dist/esm/internal/keyless.mjs.map +1 -0
  277. package/dist/esm/internal/staking.mjs +1 -1
  278. package/dist/esm/internal/table.mjs +1 -1
  279. package/dist/esm/internal/transaction.mjs +1 -1
  280. package/dist/esm/internal/transactionSubmission.d.mts +2 -2
  281. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  282. package/dist/esm/internal/view.d.mts +1 -1
  283. package/dist/esm/internal/view.mjs +1 -1
  284. package/dist/esm/transactions/authenticator/account.d.mts +1 -1
  285. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  286. package/dist/esm/transactions/authenticator/index.d.mts +1 -1
  287. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  288. package/dist/esm/transactions/authenticator/transaction.d.mts +1 -1
  289. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  290. package/dist/esm/transactions/index.d.mts +3 -3
  291. package/dist/esm/transactions/index.mjs +1 -1
  292. package/dist/esm/transactions/instances/chainId.mjs +1 -1
  293. package/dist/esm/transactions/instances/identifier.mjs +1 -1
  294. package/dist/esm/transactions/instances/index.d.mts +1 -1
  295. package/dist/esm/transactions/instances/index.mjs +1 -1
  296. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  297. package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
  298. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  299. package/dist/esm/transactions/instances/rotationProofChallenge.d.mts +1 -1
  300. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  301. package/dist/esm/transactions/instances/signedTransaction.d.mts +1 -1
  302. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  303. package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
  304. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  305. package/dist/esm/transactions/management/accountSequenceNumber.d.mts +2 -2
  306. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  307. package/dist/esm/transactions/management/index.d.mts +2 -2
  308. package/dist/esm/transactions/management/index.mjs +1 -1
  309. package/dist/esm/transactions/management/transactionWorker.d.mts +2 -2
  310. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  311. package/dist/esm/transactions/transactionBuilder/helpers.d.mts +1 -1
  312. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  313. package/dist/esm/transactions/transactionBuilder/index.d.mts +2 -2
  314. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  315. package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +3 -3
  316. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  317. package/dist/esm/transactions/transactionBuilder/signingMessage.d.mts +4 -13
  318. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
  319. package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +1 -1
  320. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  321. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  322. package/dist/esm/transactions/typeTag/parser.d.mts +3 -1
  323. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  324. package/dist/esm/transactions/types.d.mts +23 -5
  325. package/dist/esm/types/index.d.mts +21 -5
  326. package/dist/esm/types/index.mjs +1 -1
  327. package/dist/esm/types/keyless.d.mts +52 -0
  328. package/dist/esm/types/keyless.mjs +1 -0
  329. package/dist/esm/types/keyless.mjs.map +1 -0
  330. package/dist/esm/utils/apiEndpoints.d.mts +3 -1
  331. package/dist/esm/utils/apiEndpoints.mjs +1 -1
  332. package/dist/esm/utils/const.d.mts +3 -1
  333. package/dist/esm/utils/const.mjs +1 -1
  334. package/dist/esm/utils/helpers.d.mts +4 -1
  335. package/dist/esm/utils/helpers.mjs +1 -1
  336. package/dist/esm/utils/index.d.mts +1 -1
  337. package/dist/esm/utils/index.mjs +1 -1
  338. package/dist/esm/utils/normalizeBundle.mjs +1 -1
  339. package/dist/esm/version.d.mts +1 -1
  340. package/dist/esm/version.mjs +1 -1
  341. package/package.json +11 -3
  342. package/src/account/EphemeralKeyPair.ts +157 -0
  343. package/src/account/KeylessAccount.ts +404 -0
  344. package/src/account/MultiKeyAccount.ts +11 -0
  345. package/src/account/index.ts +2 -0
  346. package/src/api/aptos.ts +6 -0
  347. package/src/api/aptosConfig.ts +46 -1
  348. package/src/api/keyless.ts +59 -0
  349. package/src/bcs/deserializer.ts +46 -0
  350. package/src/bcs/serializer.ts +58 -0
  351. package/src/cli/localNode.ts +11 -1
  352. package/src/cli/move.ts +11 -1
  353. package/src/client/core.ts +5 -0
  354. package/src/client/get.ts +12 -0
  355. package/src/client/post.ts +18 -0
  356. package/src/client/types.ts +1 -1
  357. package/src/core/crypto/cryptoHasher.ts +16 -0
  358. package/src/core/crypto/ephemeral.ts +138 -0
  359. package/src/core/crypto/index.ts +2 -0
  360. package/src/core/crypto/keyless.ts +589 -0
  361. package/src/core/crypto/poseidon.ts +142 -0
  362. package/src/core/crypto/proof.ts +16 -0
  363. package/src/core/crypto/singleKey.ts +11 -0
  364. package/src/internal/keyless.ts +175 -0
  365. package/src/internal/transactionSubmission.ts +7 -2
  366. package/src/transactions/transactionBuilder/remoteAbi.ts +16 -2
  367. package/src/transactions/transactionBuilder/signingMessage.ts +0 -13
  368. package/src/transactions/transactionBuilder/transactionBuilder.ts +22 -2
  369. package/src/transactions/typeTag/parser.ts +98 -52
  370. package/src/transactions/types.ts +22 -3
  371. package/src/types/index.ts +24 -2
  372. package/src/types/keyless.ts +42 -0
  373. package/src/utils/apiEndpoints.ts +16 -0
  374. package/src/utils/const.ts +2 -0
  375. package/src/utils/helpers.ts +25 -0
  376. package/src/version.ts +1 -1
  377. package/dist/common/chunk-KSEUZTKY.js +0 -2
  378. package/dist/common/chunk-KSEUZTKY.js.map +0 -1
  379. package/dist/esm/chunk-2XK53QFA.mjs +0 -2
  380. package/dist/esm/chunk-3JPVQHOR.mjs +0 -2
  381. package/dist/esm/chunk-3JPVQHOR.mjs.map +0 -1
  382. package/dist/esm/chunk-4NHWV5AI.mjs +0 -2
  383. package/dist/esm/chunk-53INTTOI.mjs +0 -2
  384. package/dist/esm/chunk-6IFMQ5AS.mjs +0 -2
  385. package/dist/esm/chunk-6IFMQ5AS.mjs.map +0 -1
  386. package/dist/esm/chunk-AF5WNJOP.mjs +0 -2
  387. package/dist/esm/chunk-B7X6PSE7.mjs +0 -2
  388. package/dist/esm/chunk-BBKE2QJU.mjs +0 -2
  389. package/dist/esm/chunk-BBKE2QJU.mjs.map +0 -1
  390. package/dist/esm/chunk-CEHCDA3G.mjs +0 -2
  391. package/dist/esm/chunk-CJDEPZ4J.mjs +0 -2
  392. package/dist/esm/chunk-CYNQRMO5.mjs +0 -2
  393. package/dist/esm/chunk-CYNQRMO5.mjs.map +0 -1
  394. package/dist/esm/chunk-F7EMGK4M.mjs +0 -2
  395. package/dist/esm/chunk-GPEM3JVU.mjs +0 -2
  396. package/dist/esm/chunk-HYCGMFC2.mjs +0 -2
  397. package/dist/esm/chunk-HYCGMFC2.mjs.map +0 -1
  398. package/dist/esm/chunk-IENCDVPF.mjs +0 -2
  399. package/dist/esm/chunk-IENCDVPF.mjs.map +0 -1
  400. package/dist/esm/chunk-L54P6EGN.mjs +0 -2
  401. package/dist/esm/chunk-L54P6EGN.mjs.map +0 -1
  402. package/dist/esm/chunk-LDQ6JFEF.mjs +0 -2
  403. package/dist/esm/chunk-LDQ6JFEF.mjs.map +0 -1
  404. package/dist/esm/chunk-LG7RJQ57.mjs +0 -2
  405. package/dist/esm/chunk-LQNPI3IR.mjs +0 -2
  406. package/dist/esm/chunk-LQNPI3IR.mjs.map +0 -1
  407. package/dist/esm/chunk-MJPUASSD.mjs +0 -2
  408. package/dist/esm/chunk-MJPUASSD.mjs.map +0 -1
  409. package/dist/esm/chunk-N3U47Y6Y.mjs +0 -2
  410. package/dist/esm/chunk-O2K7RZWM.mjs +0 -2
  411. package/dist/esm/chunk-O2K7RZWM.mjs.map +0 -1
  412. package/dist/esm/chunk-O4WVPLUX.mjs +0 -2
  413. package/dist/esm/chunk-OWW6SIDP.mjs +0 -2
  414. package/dist/esm/chunk-OWW6SIDP.mjs.map +0 -1
  415. package/dist/esm/chunk-P5TZBE3L.mjs +0 -2
  416. package/dist/esm/chunk-PF57EOJY.mjs +0 -2
  417. package/dist/esm/chunk-PZ4SAXY7.mjs +0 -2
  418. package/dist/esm/chunk-PZ4SAXY7.mjs.map +0 -1
  419. package/dist/esm/chunk-RFZ5LTGP.mjs +0 -2
  420. package/dist/esm/chunk-RFZ5LTGP.mjs.map +0 -1
  421. package/dist/esm/chunk-ROXFCLDT.mjs +0 -2
  422. package/dist/esm/chunk-RTSWVT2Q.mjs +0 -2
  423. package/dist/esm/chunk-RTSWVT2Q.mjs.map +0 -1
  424. package/dist/esm/chunk-S2VSJJRJ.mjs +0 -2
  425. package/dist/esm/chunk-S2VSJJRJ.mjs.map +0 -1
  426. package/dist/esm/chunk-SRDIYE3M.mjs +0 -2
  427. package/dist/esm/chunk-UGPALAPN.mjs +0 -2
  428. package/dist/esm/chunk-UO3NZ5AH.mjs +0 -1
  429. package/dist/esm/chunk-UVSRX4SV.mjs +0 -1
  430. package/dist/esm/chunk-YCC6HN74.mjs +0 -2
  431. package/dist/esm/chunk-YCC6HN74.mjs.map +0 -1
  432. package/dist/esm/chunk-YMB2XW2O.mjs +0 -2
  433. /package/dist/esm/{chunk-UO3NZ5AH.mjs.map → account/EphemeralKeyPair.mjs.map} +0 -0
  434. /package/dist/esm/{chunk-UVSRX4SV.mjs.map → account/KeylessAccount.mjs.map} +0 -0
  435. /package/dist/esm/{chunk-R5ST36VJ.mjs.map → chunk-34WI7I3Z.mjs.map} +0 -0
  436. /package/dist/esm/{chunk-53INTTOI.mjs.map → chunk-3DP4R3FI.mjs.map} +0 -0
  437. /package/dist/esm/{chunk-FFGY7Z4B.mjs.map → chunk-3J53BCEQ.mjs.map} +0 -0
  438. /package/dist/esm/{chunk-4GWNWSZP.mjs.map → chunk-3YIUOKWW.mjs.map} +0 -0
  439. /package/dist/esm/{chunk-EA2DKJPX.mjs.map → chunk-45ESRYGP.mjs.map} +0 -0
  440. /package/dist/esm/{chunk-PF57EOJY.mjs.map → chunk-4VAYXBD2.mjs.map} +0 -0
  441. /package/dist/esm/{chunk-JGSOTNJ5.mjs.map → chunk-6F3HFDL3.mjs.map} +0 -0
  442. /package/dist/esm/{chunk-BN22EYXR.mjs.map → chunk-6MDYCC7P.mjs.map} +0 -0
  443. /package/dist/esm/{chunk-F7NLNWHN.mjs.map → chunk-7CJAEAQZ.mjs.map} +0 -0
  444. /package/dist/esm/{chunk-JQIGQMNZ.mjs.map → chunk-7Y6AWDBZ.mjs.map} +0 -0
  445. /package/dist/esm/{chunk-BCUSI3N6.mjs.map → chunk-AOCNYMMX.mjs.map} +0 -0
  446. /package/dist/esm/{chunk-4NHWV5AI.mjs.map → chunk-AUAL3H36.mjs.map} +0 -0
  447. /package/dist/esm/{chunk-I5T6PHDV.mjs.map → chunk-AUV4VAXK.mjs.map} +0 -0
  448. /package/dist/esm/{chunk-2X7A4HUS.mjs.map → chunk-AVWAYKNS.mjs.map} +0 -0
  449. /package/dist/esm/{chunk-EZPUVLME.mjs.map → chunk-BNA3SGG6.mjs.map} +0 -0
  450. /package/dist/esm/{chunk-GPEM3JVU.mjs.map → chunk-CEGCSC3T.mjs.map} +0 -0
  451. /package/dist/esm/{chunk-F4GDEXZ6.mjs.map → chunk-CZOUSIAD.mjs.map} +0 -0
  452. /package/dist/esm/{chunk-A4JUQZXI.mjs.map → chunk-DSVNXD5A.mjs.map} +0 -0
  453. /package/dist/esm/{chunk-AF5WNJOP.mjs.map → chunk-EJ7ODMDA.mjs.map} +0 -0
  454. /package/dist/esm/{chunk-UR3JTLIT.mjs.map → chunk-EJURLI4L.mjs.map} +0 -0
  455. /package/dist/esm/{chunk-LG7RJQ57.mjs.map → chunk-FBPNHF54.mjs.map} +0 -0
  456. /package/dist/esm/{chunk-AHW3SKT7.mjs.map → chunk-GHHIUWPP.mjs.map} +0 -0
  457. /package/dist/esm/{chunk-G56GPLTB.mjs.map → chunk-GS5Z3HO7.mjs.map} +0 -0
  458. /package/dist/esm/{chunk-XFSDV3ND.mjs.map → chunk-HOX6Q6ZP.mjs.map} +0 -0
  459. /package/dist/esm/{chunk-ROXFCLDT.mjs.map → chunk-HQK6MF3G.mjs.map} +0 -0
  460. /package/dist/esm/{chunk-O4WVPLUX.mjs.map → chunk-ISXBJPLD.mjs.map} +0 -0
  461. /package/dist/esm/{chunk-JX75UKJX.mjs.map → chunk-IU6REVKX.mjs.map} +0 -0
  462. /package/dist/esm/{chunk-ERIPXWXJ.mjs.map → chunk-IWKIZLFW.mjs.map} +0 -0
  463. /package/dist/esm/{chunk-PIVZMT5D.mjs.map → chunk-J534ICWA.mjs.map} +0 -0
  464. /package/dist/esm/{chunk-UGPALAPN.mjs.map → chunk-J577ODDM.mjs.map} +0 -0
  465. /package/dist/esm/{chunk-YK63A5T6.mjs.map → chunk-LLRWILVZ.mjs.map} +0 -0
  466. /package/dist/esm/{chunk-35EWRSDK.mjs.map → chunk-MLQT5I6K.mjs.map} +0 -0
  467. /package/dist/esm/{chunk-N3U47Y6Y.mjs.map → chunk-MSGHGK52.mjs.map} +0 -0
  468. /package/dist/esm/{chunk-5EN52MUT.mjs.map → chunk-NGTNMV6Q.mjs.map} +0 -0
  469. /package/dist/esm/{chunk-P46OPJB4.mjs.map → chunk-NH466YFP.mjs.map} +0 -0
  470. /package/dist/esm/{chunk-ZM33M6QO.mjs.map → chunk-NUBYALZP.mjs.map} +0 -0
  471. /package/dist/esm/{chunk-CHWE77CR.mjs.map → chunk-OFC75EWS.mjs.map} +0 -0
  472. /package/dist/esm/{chunk-H6FEXRTK.mjs.map → chunk-OOYRJQPD.mjs.map} +0 -0
  473. /package/dist/esm/{chunk-WN3JL7ZT.mjs.map → chunk-PG7KSUMN.mjs.map} +0 -0
  474. /package/dist/esm/{chunk-KAGLWBIJ.mjs.map → chunk-PGP2XMDE.mjs.map} +0 -0
  475. /package/dist/esm/{chunk-CYTRYBWN.mjs.map → chunk-QJIMZI32.mjs.map} +0 -0
  476. /package/dist/esm/{chunk-E56MTU2U.mjs.map → chunk-QLE5JL4X.mjs.map} +0 -0
  477. /package/dist/esm/{chunk-WNPL4SEJ.mjs.map → chunk-QOOHLRRJ.mjs.map} +0 -0
  478. /package/dist/esm/{chunk-TM7NDDT3.mjs.map → chunk-R4HLV32L.mjs.map} +0 -0
  479. /package/dist/esm/{chunk-MCRRHBFQ.mjs.map → chunk-RWYPGTNL.mjs.map} +0 -0
  480. /package/dist/esm/{chunk-CEHCDA3G.mjs.map → chunk-SCHMTP4N.mjs.map} +0 -0
  481. /package/dist/esm/{chunk-GP6Z47HM.mjs.map → chunk-SCRIQQV3.mjs.map} +0 -0
  482. /package/dist/esm/{chunk-NGQR5UQ3.mjs.map → chunk-SNBE5YAC.mjs.map} +0 -0
  483. /package/dist/esm/{chunk-UW2FPXYA.mjs.map → chunk-THURV6CN.mjs.map} +0 -0
  484. /package/dist/esm/{chunk-F7EMGK4M.mjs.map → chunk-TJDC5PWD.mjs.map} +0 -0
  485. /package/dist/esm/{chunk-GUALXVFI.mjs.map → chunk-TU6VKYDC.mjs.map} +0 -0
  486. /package/dist/esm/{chunk-DZSDCUP2.mjs.map → chunk-UFMIMN7W.mjs.map} +0 -0
  487. /package/dist/esm/{chunk-3Y46WJUR.mjs.map → chunk-ULW5LX5H.mjs.map} +0 -0
  488. /package/dist/esm/{chunk-U3YYSIIT.mjs.map → chunk-VBODXPT3.mjs.map} +0 -0
  489. /package/dist/esm/{chunk-B7X6PSE7.mjs.map → chunk-VMVSUH2K.mjs.map} +0 -0
  490. /package/dist/esm/{chunk-ZCG6WBLE.mjs.map → chunk-WJIICWOB.mjs.map} +0 -0
  491. /package/dist/esm/{chunk-T2AGN5YT.mjs.map → chunk-WOLLRMXR.mjs.map} +0 -0
  492. /package/dist/esm/{chunk-GM56MMNJ.mjs.map → chunk-XQ7I34AL.mjs.map} +0 -0
  493. /package/dist/esm/{chunk-RT6LEYHZ.mjs.map → chunk-Y24BMR2W.mjs.map} +0 -0
  494. /package/dist/esm/{chunk-HSJTQLI2.mjs.map → chunk-YLQJBXUF.mjs.map} +0 -0
  495. /package/dist/esm/{publicKey-B3XRNhHO.d.mts → publicKey-lq5djCIY.d.mts} +0 -0
@@ -0,0 +1,157 @@
1
+ // Copyright © Aptos Foundation
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { randomBytes } from "@noble/hashes/utils";
5
+
6
+ import {
7
+ EPK_HORIZON_SECS,
8
+ Ed25519PrivateKey,
9
+ EphemeralPublicKey,
10
+ EphemeralSignature,
11
+ PrivateKey,
12
+ } from "../core/crypto";
13
+ import { Hex } from "../core/hex";
14
+ import { bytesToBigIntLE, padAndPackBytesWithLen, poseidonHash } from "../core/crypto/poseidon";
15
+ import { EphemeralPublicKeyVariant, HexInput } from "../types";
16
+ import { Deserializer, Serializable, Serializer } from "../bcs";
17
+ import { currentTimeInSeconds, floorToWholeHour } from "../utils/helpers";
18
+
19
+ export class EphemeralKeyPair extends Serializable {
20
+ static readonly BLINDER_LENGTH: number = 31;
21
+
22
+ /**
23
+ * A byte array of length BLINDER_LENGTH used to obfuscate the public key from the IdP.
24
+ * Used in calculating the nonce passed to the IdP and as a secret witness in proof generation.
25
+ */
26
+ readonly blinder: Uint8Array;
27
+
28
+ /**
29
+ * A timestamp in seconds indicating when the ephemeral key pair is expired. After expiry, a new
30
+ * EphemeralKeyPair must be generated and a new JWT needs to be created.
31
+ */
32
+ readonly expiryDateSecs: number;
33
+
34
+ /**
35
+ * The value passed to the IdP when the user authenticates. It comprises of a hash of the
36
+ * ephermeral public key, expiry date, and blinder.
37
+ */
38
+ readonly nonce: string;
39
+
40
+ /**
41
+ * A private key used to sign transactions. This private key is not tied to any account on the chain as it
42
+ * is ephemeral (not permanent) in nature.
43
+ */
44
+ private privateKey: PrivateKey;
45
+
46
+ /**
47
+ * A public key used to verify transactions. This public key is not tied to any account on the chain as it
48
+ * is ephemeral (not permanent) in nature.
49
+ */
50
+ private publicKey: EphemeralPublicKey;
51
+
52
+ constructor(args: { privateKey: PrivateKey; expiryDateSecs?: number; blinder?: HexInput }) {
53
+ super();
54
+ const { privateKey, expiryDateSecs, blinder } = args;
55
+ this.privateKey = privateKey;
56
+ this.publicKey = new EphemeralPublicKey(privateKey.publicKey());
57
+ // We set the expiry date to be the nearest floored hour
58
+ this.expiryDateSecs = expiryDateSecs || floorToWholeHour(currentTimeInSeconds() + EPK_HORIZON_SECS);
59
+ // Generate the blinder if not provided
60
+ this.blinder = blinder !== undefined ? Hex.fromHexInput(blinder).toUint8Array() : generateBlinder();
61
+ // Calculate the nonce
62
+ this.nonce = this.generateNonce();
63
+ }
64
+
65
+ /**
66
+ * Returns the public key of the key pair.
67
+ * @return EphemeralPublicKey
68
+ */
69
+ getPublicKey(): EphemeralPublicKey {
70
+ return this.publicKey;
71
+ }
72
+
73
+ /**
74
+ * Returns the public key of the key pair.
75
+ * @return boolean
76
+ */
77
+ isExpired(): boolean {
78
+ const currentTimeSecs: number = Math.floor(Date.now() / 1000);
79
+ return currentTimeSecs > this.expiryDateSecs;
80
+ }
81
+
82
+ serialize(serializer: Serializer): void {
83
+ serializer.serializeU32AsUleb128(this.publicKey.variant);
84
+ serializer.serializeBytes(this.privateKey.toUint8Array());
85
+ serializer.serializeU64(this.expiryDateSecs);
86
+ serializer.serializeFixedBytes(this.blinder);
87
+ }
88
+
89
+ static deserialize(deserializer: Deserializer): EphemeralKeyPair {
90
+ const variantIndex = deserializer.deserializeUleb128AsU32();
91
+ let privateKey: PrivateKey;
92
+ switch (variantIndex) {
93
+ case EphemeralPublicKeyVariant.Ed25519:
94
+ privateKey = Ed25519PrivateKey.deserialize(deserializer);
95
+ break;
96
+ default:
97
+ throw new Error(`Unknown variant index for EphemeralPublicKey: ${variantIndex}`);
98
+ }
99
+ const expiryDateSecs = deserializer.deserializeU64();
100
+ const blinder = deserializer.deserializeFixedBytes(31);
101
+ return new EphemeralKeyPair({ privateKey, expiryDateSecs: Number(expiryDateSecs), blinder });
102
+ }
103
+
104
+ static fromBytes(bytes: Uint8Array): EphemeralKeyPair {
105
+ return EphemeralKeyPair.deserialize(new Deserializer(bytes));
106
+ }
107
+
108
+ /**
109
+ * Returns the public key of the key pair.
110
+ * @param scheme the type of keypair to use for the EphemeralKeyPair. Only Ed25519 supported for now.
111
+ * @param expiryDateSecs the date of expiry.
112
+ * @return boolean
113
+ */
114
+ static generate(args?: { scheme: EphemeralPublicKeyVariant; expiryDateSecs?: number }): EphemeralKeyPair {
115
+ let privateKey: PrivateKey;
116
+
117
+ switch (args?.scheme) {
118
+ case EphemeralPublicKeyVariant.Ed25519:
119
+ default:
120
+ privateKey = Ed25519PrivateKey.generate();
121
+ }
122
+
123
+ return new EphemeralKeyPair({ privateKey, expiryDateSecs: args?.expiryDateSecs });
124
+ }
125
+
126
+ /**
127
+ * From the ephemeral public key, expiry timestamp, and blinder, calculate the nonce to be used at authentication via OIDC.
128
+ * @returns string
129
+ */
130
+ private generateNonce(): string {
131
+ const fields = padAndPackBytesWithLen(this.publicKey.bcsToBytes(), 93);
132
+ fields.push(BigInt(this.expiryDateSecs));
133
+ fields.push(bytesToBigIntLE(this.blinder));
134
+ const nonceHash = poseidonHash(fields);
135
+ return nonceHash.toString();
136
+ }
137
+
138
+ /**
139
+ * Sign the given message with the private key.
140
+ * @param data in HexInput format
141
+ * @returns EphemeralSignature
142
+ */
143
+ sign(data: HexInput): EphemeralSignature {
144
+ if (this.isExpired()) {
145
+ throw new Error("EphemeralKeyPair has expired");
146
+ }
147
+ return new EphemeralSignature(this.privateKey.sign(data));
148
+ }
149
+ }
150
+
151
+ /**
152
+ * Generates a random byte array of length EphemeralKeyPair.BLINDER_LENGTH
153
+ * @returns Uint8Array
154
+ */
155
+ function generateBlinder(): Uint8Array {
156
+ return randomBytes(EphemeralKeyPair.BLINDER_LENGTH);
157
+ }
@@ -0,0 +1,404 @@
1
+ // Copyright © Aptos Foundation
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { JwtPayload, jwtDecode } from "jwt-decode";
5
+ import EventEmitter from "eventemitter3";
6
+ import { EphemeralCertificateVariant, HexInput, SigningScheme } from "../types";
7
+ import { AccountAddress } from "../core/accountAddress";
8
+ import {
9
+ AnyPublicKey,
10
+ AnySignature,
11
+ KeylessPublicKey,
12
+ KeylessSignature,
13
+ EphemeralCertificate,
14
+ Signature,
15
+ ZeroKnowledgeSig,
16
+ ZkProof,
17
+ } from "../core/crypto";
18
+
19
+ import { Account } from "./Account";
20
+ import { EphemeralKeyPair } from "./EphemeralKeyPair";
21
+ import { Hex } from "../core/hex";
22
+ import { AccountAuthenticatorSingleKey } from "../transactions/authenticator/account";
23
+ import { Deserializer, Serializable, Serializer } from "../bcs";
24
+ import {
25
+ deriveTransactionType,
26
+ } from "../transactions/transactionBuilder/signingMessage";
27
+ import { AnyRawTransaction, AnyRawTransactionInstance } from "../transactions/types";
28
+ import { AptosApiError } from "../client/types";
29
+ import { AptsoDomainSeparator, CryptoHashable } from "../core/crypto/cryptoHasher";
30
+ import { base64UrlDecode } from "../utils/helpers";
31
+
32
+ export const IssuerToJwkEndpoint: Record<string, string> = {
33
+ "https://accounts.google.com": "https://www.googleapis.com/oauth2/v3/certs",
34
+ };
35
+
36
+ export enum KeylessErrorType {
37
+ JWK_EXPIRED,
38
+ EPK_EXPIRED,
39
+ PROOF_NOT_FOUND,
40
+ UNKNOWN_INVALID_SIGNATURE,
41
+ UNKNOWN,
42
+ }
43
+ export class KeylessError extends Error {
44
+ readonly type: KeylessErrorType;
45
+
46
+ constructor(type: KeylessErrorType) {
47
+ super();
48
+ this.type = type;
49
+ }
50
+
51
+ static async fromAptosApiError(error: AptosApiError, signer: KeylessAccount): Promise<KeylessError> {
52
+ if (!error.data.message.includes("INVALID_SIGNATURE")) {
53
+ return new KeylessError(KeylessErrorType.UNKNOWN);
54
+ }
55
+ if (signer.isExpired()) {
56
+ return new KeylessError(KeylessErrorType.EPK_EXPIRED);
57
+ }
58
+ return new KeylessError(KeylessErrorType.UNKNOWN_INVALID_SIGNATURE);
59
+ }
60
+ }
61
+
62
+ /**
63
+ * Account implementation for the Keyless authentication scheme.
64
+ *
65
+ * Used to represent a Keyless based account and sign transactions with it.
66
+ *
67
+ * Use KeylessAccount.fromJWTAndProof to instantiate a KeylessAccount with a JWT, proof and EphemeralKeyPair.
68
+ *
69
+ * When the proof expires or the JWT becomes invalid, the KeylessAccount must be instantiated again with a new JWT,
70
+ * EphemeralKeyPair, and corresponding proof.
71
+ */
72
+ export class KeylessAccount extends Serializable implements Account {
73
+ static readonly PEPPER_LENGTH: number = 31;
74
+
75
+ /**
76
+ * The KeylessPublicKey associated with the account
77
+ */
78
+ readonly publicKey: KeylessPublicKey;
79
+
80
+ /**
81
+ * The EphemeralKeyPair used to generate sign.
82
+ */
83
+ readonly ephemeralKeyPair: EphemeralKeyPair;
84
+
85
+ /**
86
+ * The claim on the JWT to identify a user. This is typically 'sub' or 'email'.
87
+ */
88
+ readonly uidKey: string;
89
+
90
+ /**
91
+ * The value of the uidKey claim on the JWT. This intended to be a stable user identifier.
92
+ */
93
+ readonly uidVal: string;
94
+
95
+ /**
96
+ * The value of the 'aud' claim on the JWT, also known as client ID. This is the identifier for the dApp's
97
+ * OIDC registration with the identity provider.
98
+ */
99
+ readonly aud: string;
100
+
101
+ /**
102
+ * A value contains 31 bytes of entropy that preserves privacy of the account. Typically fetched from a pepper provider.
103
+ */
104
+ readonly pepper: Uint8Array;
105
+
106
+ /**
107
+ * Account address associated with the account
108
+ */
109
+ readonly accountAddress: AccountAddress;
110
+
111
+ /**
112
+ * The zero knowledge signature (if ready) which contains the proof used to validate the EphemeralKeyPair.
113
+ */
114
+ proof: ZeroKnowledgeSig | undefined;
115
+
116
+ /**
117
+ * The proof of the EphemeralKeyPair or a promise that provides the proof. This is used to allow for awaiting on
118
+ * fetching the proof.
119
+ */
120
+ readonly proofOrPromise: ZeroKnowledgeSig | Promise<ZeroKnowledgeSig>;
121
+
122
+ /**
123
+ * Signing scheme used to sign transactions
124
+ */
125
+ readonly signingScheme: SigningScheme;
126
+
127
+ /**
128
+ * The JWT token used to derive the account
129
+ */
130
+ private jwt: string;
131
+
132
+ /**
133
+ * A value that caches the JWT's validity. A JWT becomes invalid when it's corresponding JWK is rotated from the
134
+ * identity provider's JWK keyset.
135
+ */
136
+ private isJwtValid: boolean;
137
+
138
+ /**
139
+ * An event emitter used to assist in handling asycronous proof fetching.
140
+ */
141
+ private readonly emitter: EventEmitter<ProofFetchEvents>;
142
+
143
+ constructor(args: {
144
+ address?: AccountAddress;
145
+ ephemeralKeyPair: EphemeralKeyPair;
146
+ iss: string;
147
+ uidKey: string;
148
+ uidVal: string;
149
+ aud: string;
150
+ pepper: HexInput;
151
+ proofOrFetcher: ZeroKnowledgeSig | Promise<ZeroKnowledgeSig>;
152
+ proofFetchCallback?: ProofFetchCallback;
153
+ jwt: string;
154
+ }) {
155
+ super();
156
+ const { address, ephemeralKeyPair, uidKey, uidVal, aud, pepper, proofOrFetcher, proofFetchCallback, jwt } = args;
157
+ this.ephemeralKeyPair = ephemeralKeyPair;
158
+ this.publicKey = KeylessPublicKey.create(args);
159
+ this.accountAddress = address ? AccountAddress.from(address) : this.publicKey.authKey().derivedAddress();
160
+ this.uidKey = uidKey;
161
+ this.uidVal = uidVal;
162
+ this.aud = aud;
163
+ this.jwt = jwt;
164
+ this.emitter = new EventEmitter<ProofFetchEvents>();
165
+ this.proofOrPromise = proofOrFetcher;
166
+ if (proofOrFetcher instanceof ZeroKnowledgeSig) {
167
+ this.proof = proofOrFetcher;
168
+ } else {
169
+ if (proofFetchCallback === undefined) {
170
+ throw new Error("Must provide callback for async proof fetch");
171
+ }
172
+ this.emitter.on("proofFetchFinish", async (status) => {
173
+ await proofFetchCallback(status);
174
+ this.emitter.removeAllListeners();
175
+ });
176
+ this.init(proofOrFetcher);
177
+ }
178
+ this.signingScheme = SigningScheme.SingleKey;
179
+ const pepperBytes = Hex.fromHexInput(pepper).toUint8Array();
180
+ if (pepperBytes.length !== KeylessAccount.PEPPER_LENGTH) {
181
+ throw new Error(`Pepper length in bytes should be ${KeylessAccount.PEPPER_LENGTH}`);
182
+ }
183
+ this.pepper = pepperBytes;
184
+ this.isJwtValid = true;
185
+ }
186
+
187
+ /**
188
+ * This initializes the asyncronous proof fetch
189
+ * @return
190
+ */
191
+ async init(promise: Promise<ZeroKnowledgeSig>) {
192
+ try {
193
+ this.proof = await promise;
194
+ this.emitter.emit("proofFetchFinish", { status: "Success" });
195
+ } catch (error) {
196
+ if (error instanceof Error) {
197
+ this.emitter.emit("proofFetchFinish", { status: "Failed", error: error.toString() });
198
+ } else {
199
+ this.emitter.emit("proofFetchFinish", { status: "Failed", error: "Unknown" });
200
+ }
201
+ }
202
+ }
203
+
204
+ serialize(serializer: Serializer): void {
205
+ serializer.serializeStr(this.jwt);
206
+ serializer.serializeStr(this.uidKey);
207
+ serializer.serializeFixedBytes(this.pepper);
208
+ this.ephemeralKeyPair.serialize(serializer);
209
+ if (this.proof === undefined) {
210
+ throw new Error("Connot serialize - proof undefined");
211
+ }
212
+ this.proof.serialize(serializer);
213
+ }
214
+
215
+ static deserialize(deserializer: Deserializer): KeylessAccount {
216
+ const jwt = deserializer.deserializeStr();
217
+ const uidKey = deserializer.deserializeStr();
218
+ const pepper = deserializer.deserializeFixedBytes(31);
219
+ const ephemeralKeyPair = EphemeralKeyPair.deserialize(deserializer);
220
+ const proof = ZeroKnowledgeSig.deserialize(deserializer);
221
+ return KeylessAccount.fromJWTAndProof({
222
+ proof,
223
+ pepper,
224
+ uidKey,
225
+ jwt,
226
+ ephemeralKeyPair,
227
+ });
228
+ }
229
+
230
+ /**
231
+ * Checks if the proof is expired. If so the account must be rederived with a new EphemeralKeyPair
232
+ * and JWT token.
233
+ * @return boolean
234
+ */
235
+ isExpired(): boolean {
236
+ return this.ephemeralKeyPair.isExpired();
237
+ }
238
+
239
+ /**
240
+ * Sign a message using Keyless.
241
+ * @param message the message to sign, as binary input
242
+ * @return the AccountAuthenticator containing the signature, together with the account's public key
243
+ */
244
+ signWithAuthenticator(message: HexInput): AccountAuthenticatorSingleKey {
245
+ const signature = new AnySignature(this.sign(message));
246
+ const publicKey = new AnyPublicKey(this.publicKey);
247
+ return new AccountAuthenticatorSingleKey(publicKey, signature);
248
+ }
249
+
250
+ /**
251
+ * Sign a transaction using Keyless.
252
+ * @param transaction the raw transaction
253
+ * @return the AccountAuthenticator containing the signature of the transaction, together with the account's public key
254
+ */
255
+ signTransactionWithAuthenticator(transaction: AnyRawTransaction): AccountAuthenticatorSingleKey {
256
+ const signature = new AnySignature(this.signTransaction(transaction));
257
+ const publicKey = new AnyPublicKey(this.publicKey);
258
+ return new AccountAuthenticatorSingleKey(publicKey, signature);
259
+ }
260
+
261
+ /**
262
+ * Waits for asyncronous proof fetching to finish.
263
+ * @return
264
+ */
265
+ async waitForProofFetch() {
266
+ if (this.proofOrPromise instanceof Promise) {
267
+ await this.proofOrPromise;
268
+ }
269
+ }
270
+
271
+ /**
272
+ * Sign the given message using Keyless.
273
+ * @param message in HexInput format
274
+ * @returns Signature
275
+ */
276
+ sign(data: HexInput): KeylessSignature {
277
+ const { expiryDateSecs } = this.ephemeralKeyPair;
278
+ if (this.isExpired()) {
279
+ throw new KeylessError(KeylessErrorType.EPK_EXPIRED);
280
+ }
281
+ if (this.proof === undefined) {
282
+ throw new KeylessError(KeylessErrorType.PROOF_NOT_FOUND);
283
+ }
284
+ if (!this.isJwtValid) {
285
+ throw new KeylessError(KeylessErrorType.JWK_EXPIRED);
286
+ }
287
+ const ephemeralPublicKey = this.ephemeralKeyPair.getPublicKey();
288
+ const ephemeralSignature = this.ephemeralKeyPair.sign(data);
289
+
290
+ return new KeylessSignature({
291
+ jwtHeader: base64UrlDecode(this.jwt.split(".")[0]),
292
+ ephemeralCertificate: new EphemeralCertificate(this.proof, EphemeralCertificateVariant.ZkProof),
293
+ expiryDateSecs,
294
+ ephemeralPublicKey,
295
+ ephemeralSignature,
296
+ });
297
+ }
298
+
299
+ /**
300
+ * Sign the given transaction with Keyless.
301
+ * Signs the transaction and proof to guard against proof malleability.
302
+ * @param transaction the transaction to be signed
303
+ * @returns KeylessSignature
304
+ */
305
+ signTransaction(transaction: AnyRawTransaction): KeylessSignature {
306
+ if (this.proof === undefined) {
307
+ throw new Error("Proof not found");
308
+ }
309
+ const raw = deriveTransactionType(transaction);
310
+ const txnAndProof = new TransactionAndProof(raw, this.proof.proof);
311
+ const signMess = txnAndProof.hash();
312
+ return this.sign(signMess);
313
+ }
314
+
315
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this
316
+ verifySignature(args: { message: HexInput; signature: Signature }): boolean {
317
+ throw new Error("Not implemented");
318
+ }
319
+
320
+ static fromBytes(bytes: Uint8Array): KeylessAccount {
321
+ return KeylessAccount.deserialize(new Deserializer(bytes));
322
+ }
323
+
324
+ static fromJWTAndProof(args: {
325
+ proof: ZeroKnowledgeSig | Promise<ZeroKnowledgeSig>;
326
+ jwt: string;
327
+ ephemeralKeyPair: EphemeralKeyPair;
328
+ pepper: HexInput;
329
+ uidKey?: string;
330
+ proofFetchCallback?: ProofFetchCallback;
331
+ }): KeylessAccount {
332
+ const { proof, jwt, ephemeralKeyPair, pepper, proofFetchCallback } = args;
333
+ const uidKey = args.uidKey ?? "sub";
334
+
335
+ const jwtPayload = jwtDecode<JwtPayload & { [key: string]: string }>(jwt);
336
+ const iss = jwtPayload.iss!;
337
+ if (typeof jwtPayload.aud !== "string") {
338
+ throw new Error("aud was not found or an array of values");
339
+ }
340
+ const aud = jwtPayload.aud!;
341
+ const uidVal = jwtPayload[uidKey];
342
+ return new KeylessAccount({
343
+ proofOrFetcher: proof,
344
+ ephemeralKeyPair,
345
+ iss,
346
+ uidKey,
347
+ uidVal,
348
+ aud,
349
+ pepper,
350
+ jwt,
351
+ proofFetchCallback,
352
+ });
353
+ }
354
+ }
355
+
356
+ /**
357
+ * A container class to hold a transaction and a proof. It implements CryptoHashable which is used to create
358
+ * the signing message for Keyless transactions. We sign over the proof to ensure non-malleability.
359
+ */
360
+ export class TransactionAndProof extends CryptoHashable {
361
+ /**
362
+ * The transaction to sign.
363
+ */
364
+ transaction: AnyRawTransactionInstance;
365
+
366
+ /**
367
+ * The zero knowledge proof used in signing the transaction.
368
+ */
369
+ proof?: ZkProof;
370
+
371
+ /**
372
+ * The domain separator prefix used when hashing.
373
+ */
374
+ domainSeparator: AptsoDomainSeparator;
375
+
376
+ constructor(transaction: AnyRawTransactionInstance, proof?: ZkProof) {
377
+ super();
378
+ this.transaction = transaction;
379
+ this.proof = proof;
380
+ this.domainSeparator = "APTOS::TransactionAndProof"
381
+ }
382
+
383
+ serialize(serializer: Serializer): void {
384
+ serializer.serializeFixedBytes(this.transaction.bcsToBytes());
385
+ serializer.serializeOption(this.proof);
386
+ }
387
+ }
388
+
389
+ export type ProofFetchSuccess = {
390
+ status: "Success";
391
+ };
392
+
393
+ export type ProofFetchFailure = {
394
+ status: "Failed";
395
+ error: string;
396
+ };
397
+
398
+ export type ProofFetchStatus = ProofFetchSuccess | ProofFetchFailure;
399
+
400
+ export type ProofFetchCallback = (status: ProofFetchStatus) => Promise<void>;
401
+
402
+ export interface ProofFetchEvents {
403
+ proofFetchFinish: (status: ProofFetchStatus) => void;
404
+ }
@@ -7,6 +7,7 @@ import { AccountAddress } from "../core/accountAddress";
7
7
  import { HexInput, SigningScheme } from "../types";
8
8
  import { AccountAuthenticatorMultiKey } from "../transactions/authenticator/account";
9
9
  import { AnyRawTransaction } from "../transactions/types";
10
+ import { KeylessAccount } from "./KeylessAccount";
10
11
 
11
12
  export interface VerifyMultiKeySignatureArgs {
12
13
  message: HexInput;
@@ -123,6 +124,16 @@ export class MultiKeyAccount implements Account {
123
124
  return new AccountAuthenticatorMultiKey(this.publicKey, this.signTransaction(transaction));
124
125
  }
125
126
 
127
+ /**
128
+ * Waits for any proofs on any KeylessAccount signers to be fetched. If the proof is fetched a syncronously, call this
129
+ * to ensure signing with the KeylessAccount does not fail as the proof must be ready.
130
+ * @return
131
+ */
132
+ async waitForProofFetch() {
133
+ const keylessSigners = this.signers.filter((signer) => signer instanceof KeylessAccount) as KeylessAccount[];
134
+ await Promise.all(keylessSigners.filter((signer) => signer.proof instanceof Promise).map((signer) => signer.proof));
135
+ }
136
+
126
137
  /**
127
138
  * Sign the given message using the MultiKeyAccount's signers
128
139
  * @param message in HexInput format
@@ -1,4 +1,6 @@
1
1
  export * from "./Ed25519Account";
2
2
  export * from "./Account";
3
3
  export * from "./SingleKeyAccount";
4
+ export * from "./EphemeralKeyPair";
5
+ export * from "./KeylessAccount";
4
6
  export * from "./MultiKeyAccount";
package/src/api/aptos.ts CHANGED
@@ -13,6 +13,7 @@ import { ANS } from "./ans";
13
13
  import { Staking } from "./staking";
14
14
  import { Transaction } from "./transaction";
15
15
  import { Table } from "./table";
16
+ import { Keyless } from "./keyless";
16
17
 
17
18
  /**
18
19
  * This class is the main entry point into Aptos's
@@ -50,6 +51,8 @@ export class Aptos {
50
51
 
51
52
  readonly table: Table;
52
53
 
54
+ readonly keyless: Keyless;
55
+
53
56
  constructor(settings?: AptosConfig) {
54
57
  this.config = new AptosConfig(settings);
55
58
  this.account = new Account(this.config);
@@ -63,6 +66,7 @@ export class Aptos {
63
66
  this.staking = new Staking(this.config);
64
67
  this.transaction = new Transaction(this.config);
65
68
  this.table = new Table(this.config);
69
+ this.keyless = new Keyless(this.config);
66
70
  }
67
71
  }
68
72
 
@@ -77,6 +81,7 @@ export interface Aptos
77
81
  Faucet,
78
82
  FungibleAsset,
79
83
  General,
84
+ Keyless,
80
85
  Staking,
81
86
  Table,
82
87
  Omit<Transaction, "build" | "simulate" | "submit" | "batch"> {}
@@ -113,3 +118,4 @@ applyMixin(Aptos, General, "general");
113
118
  applyMixin(Aptos, Staking, "staking");
114
119
  applyMixin(Aptos, Transaction, "transaction");
115
120
  applyMixin(Aptos, Table, "table");
121
+ applyMixin(Aptos, Keyless, "keyless");
@@ -3,7 +3,14 @@
3
3
 
4
4
  import aptosClient from "@aptos-labs/aptos-client";
5
5
  import { AptosSettings, ClientConfig, Client, FullNodeConfig, IndexerConfig, FaucetConfig } from "../types";
6
- import { NetworkToNodeAPI, NetworkToFaucetAPI, NetworkToIndexerAPI, Network } from "../utils/apiEndpoints";
6
+ import {
7
+ NetworkToNodeAPI,
8
+ NetworkToFaucetAPI,
9
+ NetworkToIndexerAPI,
10
+ Network,
11
+ NetworkToPepperAPI,
12
+ NetworkToProverAPI,
13
+ } from "../utils/apiEndpoints";
7
14
  import { AptosApiType } from "../utils/const";
8
15
 
9
16
  /**
@@ -34,6 +41,16 @@ export class AptosConfig {
34
41
  */
35
42
  readonly faucet?: string;
36
43
 
44
+ /**
45
+ * The optional hardcoded pepper service URL to send requests to instead of using the network
46
+ */
47
+ readonly pepper?: string;
48
+
49
+ /**
50
+ * The optional hardcoded prover service URL to send requests to instead of using the network
51
+ */
52
+ readonly prover?: string;
53
+
37
54
  /**
38
55
  * The optional hardcoded indexer URL to send requests to instead of using the network
39
56
  */
@@ -63,6 +80,8 @@ export class AptosConfig {
63
80
  this.network = settings?.network ?? Network.DEVNET;
64
81
  this.fullnode = settings?.fullnode;
65
82
  this.faucet = settings?.faucet;
83
+ this.pepper = settings?.pepper;
84
+ this.prover = settings?.prover;
66
85
  this.indexer = settings?.indexer;
67
86
  this.client = settings?.client ?? { provider: aptosClient };
68
87
  this.clientConfig = settings?.clientConfig ?? {};
@@ -95,8 +114,34 @@ export class AptosConfig {
95
114
  if (this.indexer !== undefined) return this.indexer;
96
115
  if (this.network === Network.CUSTOM) throw new Error("Please provide a custom indexer url");
97
116
  return NetworkToIndexerAPI[this.network];
117
+ case AptosApiType.PEPPER:
118
+ if (this.pepper !== undefined) return this.pepper;
119
+ if (this.network === Network.CUSTOM) throw new Error("Please provide a custom pepper service url");
120
+ return NetworkToPepperAPI[this.network];
121
+ case AptosApiType.PROVER:
122
+ if (this.prover !== undefined) return this.prover;
123
+ if (this.network === Network.CUSTOM) throw new Error("Please provide a custom prover service url");
124
+ return NetworkToProverAPI[this.network];
98
125
  default:
99
126
  throw Error(`apiType ${apiType} is not supported`);
100
127
  }
101
128
  }
129
+
130
+ /**
131
+ * Checks if the URL is a known pepper service endpoint
132
+ *
133
+ * @internal
134
+ * */
135
+ isPepperServiceRequest(url: string): boolean {
136
+ return NetworkToPepperAPI[this.network] === url;
137
+ }
138
+
139
+ /**
140
+ * Checks if the URL is a known prover service endpoint
141
+ *
142
+ * @internal
143
+ * */
144
+ isProverServiceRequest(url: string): boolean {
145
+ return NetworkToProverAPI[this.network] === url;
146
+ }
102
147
  }