@aptos-labs/ts-sdk 1.16.0-zeta.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 (352) hide show
  1. package/dist/common/{accountAddress-BtD_TE5q.d.ts → accountAddress-OUd5ov6z.d.ts} +56 -10
  2. package/dist/common/cli/index.d.ts +1 -1
  3. package/dist/common/index.d.ts +156 -32
  4. package/dist/common/index.js +28 -28
  5. package/dist/common/index.js.map +1 -1
  6. package/dist/esm/account/Account.mjs +1 -1
  7. package/dist/esm/account/Ed25519Account.mjs +1 -1
  8. package/dist/esm/account/EphemeralKeyPair.d.mts +4 -4
  9. package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
  10. package/dist/esm/account/KeylessAccount.d.mts +68 -9
  11. package/dist/esm/account/KeylessAccount.mjs +1 -1
  12. package/dist/esm/account/MultiKeyAccount.mjs +1 -1
  13. package/dist/esm/account/SingleKeyAccount.mjs +1 -1
  14. package/dist/esm/account/index.d.mts +2 -2
  15. package/dist/esm/account/index.mjs +1 -1
  16. package/dist/esm/api/account.mjs +1 -1
  17. package/dist/esm/api/ans.mjs +1 -1
  18. package/dist/esm/api/aptos.d.mts +5 -4
  19. package/dist/esm/api/aptos.mjs +1 -1
  20. package/dist/esm/api/aptosConfig.mjs +1 -1
  21. package/dist/esm/api/coin.mjs +1 -1
  22. package/dist/esm/api/digitalAsset.mjs +1 -1
  23. package/dist/esm/api/event.mjs +1 -1
  24. package/dist/esm/api/faucet.mjs +1 -1
  25. package/dist/esm/api/fungibleAsset.mjs +1 -1
  26. package/dist/esm/api/general.mjs +1 -1
  27. package/dist/esm/api/index.d.mts +5 -4
  28. package/dist/esm/api/index.mjs +1 -1
  29. package/dist/esm/api/keyless.d.mts +15 -10
  30. package/dist/esm/api/keyless.mjs +1 -1
  31. package/dist/esm/api/staking.mjs +1 -1
  32. package/dist/esm/api/table.mjs +1 -1
  33. package/dist/esm/api/transaction.mjs +1 -1
  34. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  35. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  36. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  37. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  38. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  39. package/dist/esm/api/utils.mjs +1 -1
  40. package/dist/esm/bcs/deserializer.d.mts +14 -8
  41. package/dist/esm/bcs/deserializer.mjs +1 -1
  42. package/dist/esm/bcs/index.mjs +1 -1
  43. package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
  44. package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
  45. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  46. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  47. package/dist/esm/bcs/serializer.d.mts +40 -0
  48. package/dist/esm/bcs/serializer.mjs +1 -1
  49. package/dist/esm/{chunk-TVRJ3M7B.mjs → chunk-272NA6H5.mjs} +1 -1
  50. package/dist/esm/{chunk-TVRJ3M7B.mjs.map → chunk-272NA6H5.mjs.map} +1 -1
  51. package/dist/esm/{chunk-OT37OTT7.mjs → chunk-34WI7I3Z.mjs} +2 -2
  52. package/dist/esm/{chunk-Z2ZR4PTF.mjs → chunk-3DP4R3FI.mjs} +2 -2
  53. package/dist/esm/{chunk-IJE5YSXW.mjs → chunk-3J53BCEQ.mjs} +2 -2
  54. package/dist/esm/{chunk-NWWXZ7EW.mjs → chunk-3SXTTG2X.mjs} +2 -2
  55. package/dist/esm/{chunk-7H3HRFVM.mjs → chunk-3YIUOKWW.mjs} +2 -2
  56. package/dist/esm/{chunk-REBMGDZ5.mjs → chunk-45ESRYGP.mjs} +2 -2
  57. package/dist/esm/{chunk-5V2RGYYK.mjs → chunk-4RXGVY2H.mjs} +2 -2
  58. package/dist/esm/{chunk-MWUJCP27.mjs → chunk-4VAYXBD2.mjs} +2 -2
  59. package/dist/esm/{chunk-6KNAIXZ3.mjs → chunk-5SGIYAB7.mjs} +2 -2
  60. package/dist/esm/chunk-5VLCYHNJ.mjs +2 -0
  61. package/dist/esm/chunk-5VLCYHNJ.mjs.map +1 -0
  62. package/dist/esm/{chunk-Q3AUNZDW.mjs → chunk-6F3HFDL3.mjs} +2 -2
  63. package/dist/esm/{chunk-FBLSW5TB.mjs → chunk-6MDYCC7P.mjs} +2 -2
  64. package/dist/esm/{chunk-M7HZOQ6A.mjs → chunk-7CJAEAQZ.mjs} +2 -2
  65. package/dist/esm/{chunk-Y33VGXNI.mjs → chunk-7Y6AWDBZ.mjs} +2 -2
  66. package/dist/esm/{chunk-COW5IGYC.mjs → chunk-AUAL3H36.mjs} +2 -2
  67. package/dist/esm/{chunk-6M53MDWB.mjs → chunk-AUV4VAXK.mjs} +2 -2
  68. package/dist/esm/{chunk-MTLETLKV.mjs → chunk-AVWAYKNS.mjs} +2 -2
  69. package/dist/esm/{chunk-EIRSA5UU.mjs → chunk-BNA3SGG6.mjs} +2 -2
  70. package/dist/esm/{chunk-Y5BON557.mjs → chunk-CEGCSC3T.mjs} +2 -2
  71. package/dist/esm/chunk-CIPPNT3W.mjs +2 -0
  72. package/dist/esm/chunk-CIPPNT3W.mjs.map +1 -0
  73. package/dist/esm/{chunk-UFJGYMEB.mjs → chunk-CZOUSIAD.mjs} +2 -2
  74. package/dist/esm/chunk-D76FE35G.mjs +2 -0
  75. package/dist/esm/chunk-D76FE35G.mjs.map +1 -0
  76. package/dist/esm/{chunk-SBQRBBRS.mjs → chunk-DSVNXD5A.mjs} +2 -2
  77. package/dist/esm/{chunk-IEZO4PIG.mjs → chunk-EJ7ODMDA.mjs} +2 -2
  78. package/dist/esm/{chunk-ONIYM7IU.mjs → chunk-EJURLI4L.mjs} +2 -2
  79. package/dist/esm/chunk-FUQDDIKQ.mjs +2 -0
  80. package/dist/esm/chunk-FUQDDIKQ.mjs.map +1 -0
  81. package/dist/esm/chunk-FWTJQHJR.mjs +2 -0
  82. package/dist/esm/chunk-FWTJQHJR.mjs.map +1 -0
  83. package/dist/esm/{chunk-W637YAND.mjs → chunk-GHHIUWPP.mjs} +2 -2
  84. package/dist/esm/{chunk-EB7AI4B4.mjs → chunk-GS5Z3HO7.mjs} +2 -2
  85. package/dist/esm/{chunk-4USAUOCE.mjs → chunk-HGRU3HWY.mjs} +2 -2
  86. package/dist/esm/{chunk-TEJ7BXJK.mjs → chunk-HOX6Q6ZP.mjs} +2 -2
  87. package/dist/esm/chunk-HQK6MF3G.mjs +2 -0
  88. package/dist/esm/chunk-IMVC2JKU.mjs +2 -0
  89. package/dist/esm/{chunk-N7CE244N.mjs.map → chunk-IMVC2JKU.mjs.map} +1 -1
  90. package/dist/esm/{chunk-RUSWW265.mjs → chunk-ISXBJPLD.mjs} +2 -2
  91. package/dist/esm/{chunk-MKUAW7KW.mjs → chunk-IU6REVKX.mjs} +2 -2
  92. package/dist/esm/{chunk-Z6JERVLX.mjs → chunk-IWKIZLFW.mjs} +2 -2
  93. package/dist/esm/{chunk-LQH7T3TE.mjs → chunk-J534ICWA.mjs} +2 -2
  94. package/dist/esm/{chunk-STYDBDYL.mjs → chunk-J577ODDM.mjs} +2 -2
  95. package/dist/esm/chunk-JBTLE33X.mjs +2 -0
  96. package/dist/esm/{chunk-JKZHPY24.mjs.map → chunk-JBTLE33X.mjs.map} +1 -1
  97. package/dist/esm/{chunk-EPTCPBVW.mjs → chunk-LLRWILVZ.mjs} +2 -2
  98. package/dist/esm/{chunk-I5JWDZIP.mjs → chunk-M4Q4XDVR.mjs} +2 -2
  99. package/dist/esm/chunk-M4Q4XDVR.mjs.map +1 -0
  100. package/dist/esm/chunk-MEOBWD6V.mjs +2 -0
  101. package/dist/esm/chunk-MEOBWD6V.mjs.map +1 -0
  102. package/dist/esm/{chunk-ZNEBMSNC.mjs → chunk-MLQT5I6K.mjs} +2 -2
  103. package/dist/esm/{chunk-C3L4ETUF.mjs → chunk-MSGHGK52.mjs} +2 -2
  104. package/dist/esm/{chunk-7STYQ5ZE.mjs → chunk-NGTNMV6Q.mjs} +2 -2
  105. package/dist/esm/{chunk-OX5GWFHX.mjs → chunk-NH466YFP.mjs} +2 -2
  106. package/dist/esm/{chunk-ZCCYHFPK.mjs → chunk-NMD45OTM.mjs} +2 -2
  107. package/dist/esm/{chunk-UWI5D7FD.mjs → chunk-NUBYALZP.mjs} +2 -2
  108. package/dist/esm/{chunk-KKP4FBWZ.mjs → chunk-OFC75EWS.mjs} +2 -2
  109. package/dist/esm/{chunk-T6OEZ4KP.mjs → chunk-OOYRJQPD.mjs} +2 -2
  110. package/dist/esm/chunk-OZ3GSAFK.mjs +2 -0
  111. package/dist/esm/chunk-OZ3GSAFK.mjs.map +1 -0
  112. package/dist/esm/{chunk-EU6CX56Q.mjs → chunk-PENBUSGL.mjs} +2 -2
  113. package/dist/esm/{chunk-A3UVZHDJ.mjs → chunk-PG7KSUMN.mjs} +2 -2
  114. package/dist/esm/{chunk-HGZGTBA4.mjs → chunk-PGP2XMDE.mjs} +2 -2
  115. package/dist/esm/{chunk-JM2B5E2I.mjs → chunk-Q6LFIZ3L.mjs} +1 -1
  116. package/dist/esm/chunk-Q6LFIZ3L.mjs.map +1 -0
  117. package/dist/esm/{chunk-EADBYPUD.mjs → chunk-QJIMZI32.mjs} +2 -2
  118. package/dist/esm/{chunk-YHO2EBXH.mjs → chunk-QLE5JL4X.mjs} +2 -2
  119. package/dist/esm/{chunk-KFUOOBMJ.mjs → chunk-QOOHLRRJ.mjs} +2 -2
  120. package/dist/esm/{chunk-UO5LUYGO.mjs → chunk-QYEJOEWB.mjs} +2 -2
  121. package/dist/esm/{chunk-NQMF46E5.mjs → chunk-R4HLV32L.mjs} +2 -2
  122. package/dist/esm/chunk-RAHMGSBW.mjs +2 -0
  123. package/dist/esm/{chunk-CNH2RAJQ.mjs.map → chunk-RAHMGSBW.mjs.map} +1 -1
  124. package/dist/esm/{chunk-C34M4T77.mjs → chunk-RWYPGTNL.mjs} +2 -2
  125. package/dist/esm/{chunk-3FVRXELT.mjs → chunk-SCHMTP4N.mjs} +2 -2
  126. package/dist/esm/chunk-SCHZ67F3.mjs +2 -0
  127. package/dist/esm/chunk-SCHZ67F3.mjs.map +1 -0
  128. package/dist/esm/{chunk-3Y6JNFPD.mjs → chunk-SCRIQQV3.mjs} +2 -2
  129. package/dist/esm/{chunk-W36IQO5K.mjs → chunk-SNBE5YAC.mjs} +2 -2
  130. package/dist/esm/{chunk-NCDP26DV.mjs → chunk-SSDWEOF7.mjs} +2 -2
  131. package/dist/esm/{chunk-N466X3S6.mjs → chunk-SZ6KR73C.mjs} +2 -2
  132. package/dist/esm/{chunk-F5C4SZZ7.mjs → chunk-THURV6CN.mjs} +2 -2
  133. package/dist/esm/{chunk-5RRZMXND.mjs → chunk-TU6VKYDC.mjs} +2 -2
  134. package/dist/esm/{chunk-UDU5L4XH.mjs → chunk-UFMIMN7W.mjs} +2 -2
  135. package/dist/esm/{chunk-LO7B3CWN.mjs → chunk-ULW5LX5H.mjs} +2 -2
  136. package/dist/esm/{chunk-4KEEUDZA.mjs → chunk-V6M7FGQT.mjs} +2 -2
  137. package/dist/esm/{chunk-3VGX3TXH.mjs → chunk-VBODXPT3.mjs} +2 -2
  138. package/dist/esm/{chunk-MGOHPDX4.mjs → chunk-VMVSUH2K.mjs} +2 -2
  139. package/dist/esm/{chunk-T23OVRNF.mjs → chunk-WHSN42R2.mjs} +2 -2
  140. package/dist/esm/{chunk-LEBJNW6Y.mjs → chunk-WJIICWOB.mjs} +2 -2
  141. package/dist/esm/{chunk-PYUU4OEL.mjs → chunk-WOLLRMXR.mjs} +2 -2
  142. package/dist/esm/{chunk-QZRWRX6P.mjs → chunk-WSVJNBSJ.mjs} +2 -2
  143. package/dist/esm/{chunk-QZRWRX6P.mjs.map → chunk-WSVJNBSJ.mjs.map} +1 -1
  144. package/dist/esm/{chunk-VT6XJSRO.mjs → chunk-WXLSJF4A.mjs} +1 -1
  145. package/dist/esm/chunk-WXLSJF4A.mjs.map +1 -0
  146. package/dist/esm/{chunk-NC5HHEEM.mjs → chunk-XQ7I34AL.mjs} +2 -2
  147. package/dist/esm/{chunk-MWN63XBE.mjs → chunk-Y24BMR2W.mjs} +2 -2
  148. package/dist/esm/{chunk-WAXCU6D6.mjs → chunk-YLQJBXUF.mjs} +2 -2
  149. package/dist/esm/chunk-ZAXWW7VW.mjs +2 -0
  150. package/dist/esm/chunk-ZAXWW7VW.mjs.map +1 -0
  151. package/dist/esm/{chunk-6RBUXB5I.mjs → chunk-ZV5P2GSJ.mjs} +2 -2
  152. package/dist/esm/cli/index.mjs +1 -1
  153. package/dist/esm/client/core.mjs +1 -1
  154. package/dist/esm/client/get.d.mts +6 -0
  155. package/dist/esm/client/get.mjs +1 -1
  156. package/dist/esm/client/index.mjs +1 -1
  157. package/dist/esm/client/post.d.mts +6 -0
  158. package/dist/esm/client/post.mjs +1 -1
  159. package/dist/esm/core/account/index.mjs +1 -1
  160. package/dist/esm/core/account/utils/address.mjs +1 -1
  161. package/dist/esm/core/account/utils/index.mjs +1 -1
  162. package/dist/esm/core/accountAddress.mjs +1 -1
  163. package/dist/esm/core/authenticationKey.mjs +1 -1
  164. package/dist/esm/core/crypto/cryptoHasher.d.mts +21 -0
  165. package/dist/esm/core/crypto/cryptoHasher.mjs +2 -0
  166. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  167. package/dist/esm/core/crypto/ephemeral.mjs +1 -1
  168. package/dist/esm/core/crypto/index.d.mts +2 -1
  169. package/dist/esm/core/crypto/index.mjs +1 -1
  170. package/dist/esm/core/crypto/keyless.d.mts +52 -8
  171. package/dist/esm/core/crypto/keyless.mjs +1 -1
  172. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  173. package/dist/esm/core/crypto/multiKey.mjs +1 -1
  174. package/dist/esm/core/crypto/poseidon.d.mts +14 -2
  175. package/dist/esm/core/crypto/poseidon.mjs +1 -1
  176. package/dist/esm/core/crypto/proof.mjs +1 -1
  177. package/dist/esm/core/crypto/publicKey.mjs +1 -1
  178. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  179. package/dist/esm/core/crypto/signature.mjs +1 -1
  180. package/dist/esm/core/crypto/singleKey.mjs +1 -1
  181. package/dist/esm/core/index.d.mts +2 -1
  182. package/dist/esm/core/index.mjs +1 -1
  183. package/dist/esm/index.d.mts +5 -4
  184. package/dist/esm/index.mjs +1 -1
  185. package/dist/esm/internal/account.mjs +1 -1
  186. package/dist/esm/internal/ans.mjs +1 -1
  187. package/dist/esm/internal/coin.mjs +1 -1
  188. package/dist/esm/internal/digitalAsset.mjs +1 -1
  189. package/dist/esm/internal/event.mjs +1 -1
  190. package/dist/esm/internal/faucet.mjs +1 -1
  191. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  192. package/dist/esm/internal/general.mjs +1 -1
  193. package/dist/esm/internal/keyless.d.mts +10 -8
  194. package/dist/esm/internal/keyless.mjs +1 -1
  195. package/dist/esm/internal/staking.mjs +1 -1
  196. package/dist/esm/internal/table.mjs +1 -1
  197. package/dist/esm/internal/transaction.mjs +1 -1
  198. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  199. package/dist/esm/internal/view.mjs +1 -1
  200. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  201. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  202. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  203. package/dist/esm/transactions/index.d.mts +1 -2
  204. package/dist/esm/transactions/index.mjs +1 -1
  205. package/dist/esm/transactions/instances/chainId.mjs +1 -1
  206. package/dist/esm/transactions/instances/identifier.mjs +1 -1
  207. package/dist/esm/transactions/instances/index.mjs +1 -1
  208. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  209. package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
  210. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  211. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  212. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  213. package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
  214. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  215. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  216. package/dist/esm/transactions/management/index.mjs +1 -1
  217. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  218. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  219. package/dist/esm/transactions/transactionBuilder/index.d.mts +1 -2
  220. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  221. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  222. package/dist/esm/transactions/transactionBuilder/signingMessage.d.mts +1 -11
  223. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
  224. package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +1 -1
  225. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  226. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  227. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  228. package/dist/esm/types/index.d.mts +2 -2
  229. package/dist/esm/types/index.mjs +1 -1
  230. package/dist/esm/types/keyless.d.mts +37 -1
  231. package/dist/esm/utils/apiEndpoints.mjs +1 -1
  232. package/dist/esm/utils/index.mjs +1 -1
  233. package/dist/esm/utils/normalizeBundle.mjs +1 -1
  234. package/dist/esm/version.d.mts +1 -1
  235. package/dist/esm/version.mjs +1 -1
  236. package/package.json +1 -1
  237. package/src/account/EphemeralKeyPair.ts +6 -6
  238. package/src/account/KeylessAccount.ts +68 -30
  239. package/src/api/keyless.ts +15 -4
  240. package/src/bcs/deserializer.ts +15 -9
  241. package/src/bcs/serializer.ts +40 -0
  242. package/src/client/core.ts +4 -7
  243. package/src/client/get.ts +6 -0
  244. package/src/client/post.ts +6 -0
  245. package/src/core/crypto/cryptoHasher.ts +16 -0
  246. package/src/core/crypto/keyless.ts +159 -23
  247. package/src/core/crypto/poseidon.ts +17 -8
  248. package/src/internal/keyless.ts +81 -15
  249. package/src/transactions/transactionBuilder/signingMessage.ts +0 -13
  250. package/src/transactions/transactionBuilder/transactionBuilder.ts +4 -2
  251. package/src/types/index.ts +2 -2
  252. package/src/types/keyless.ts +36 -0
  253. package/src/utils/apiEndpoints.ts +4 -2
  254. package/src/version.ts +1 -1
  255. package/dist/esm/bcs/cryptoHasher.d.mts +0 -15
  256. package/dist/esm/bcs/cryptoHasher.mjs +0 -2
  257. package/dist/esm/chunk-5ADNWXP2.mjs +0 -2
  258. package/dist/esm/chunk-5ADNWXP2.mjs.map +0 -1
  259. package/dist/esm/chunk-5YI2GEG5.mjs +0 -2
  260. package/dist/esm/chunk-5YI2GEG5.mjs.map +0 -1
  261. package/dist/esm/chunk-CNH2RAJQ.mjs +0 -2
  262. package/dist/esm/chunk-I5JWDZIP.mjs.map +0 -1
  263. package/dist/esm/chunk-JKZHPY24.mjs +0 -2
  264. package/dist/esm/chunk-JM2B5E2I.mjs.map +0 -1
  265. package/dist/esm/chunk-KPZDC5ZE.mjs +0 -2
  266. package/dist/esm/chunk-KPZDC5ZE.mjs.map +0 -1
  267. package/dist/esm/chunk-LECNIPW7.mjs +0 -2
  268. package/dist/esm/chunk-LECNIPW7.mjs.map +0 -1
  269. package/dist/esm/chunk-N7CE244N.mjs +0 -2
  270. package/dist/esm/chunk-R2P2XANA.mjs +0 -2
  271. package/dist/esm/chunk-R2P2XANA.mjs.map +0 -1
  272. package/dist/esm/chunk-UTXJOB3O.mjs +0 -2
  273. package/dist/esm/chunk-VT6XJSRO.mjs.map +0 -1
  274. package/dist/esm/chunk-W4IWORPF.mjs +0 -2
  275. package/dist/esm/chunk-W4IWORPF.mjs.map +0 -1
  276. package/dist/esm/chunk-WDE54GRQ.mjs +0 -2
  277. package/dist/esm/chunk-WDE54GRQ.mjs.map +0 -1
  278. package/dist/esm/chunk-YZPQVZ7S.mjs +0 -2
  279. package/dist/esm/chunk-YZPQVZ7S.mjs.map +0 -1
  280. package/dist/esm/chunk-ZUQJLFR2.mjs +0 -2
  281. package/dist/esm/chunk-ZUQJLFR2.mjs.map +0 -1
  282. package/src/bcs/cryptoHasher.ts +0 -6
  283. /package/dist/esm/{chunk-OT37OTT7.mjs.map → chunk-34WI7I3Z.mjs.map} +0 -0
  284. /package/dist/esm/{chunk-Z2ZR4PTF.mjs.map → chunk-3DP4R3FI.mjs.map} +0 -0
  285. /package/dist/esm/{chunk-IJE5YSXW.mjs.map → chunk-3J53BCEQ.mjs.map} +0 -0
  286. /package/dist/esm/{chunk-NWWXZ7EW.mjs.map → chunk-3SXTTG2X.mjs.map} +0 -0
  287. /package/dist/esm/{chunk-7H3HRFVM.mjs.map → chunk-3YIUOKWW.mjs.map} +0 -0
  288. /package/dist/esm/{chunk-REBMGDZ5.mjs.map → chunk-45ESRYGP.mjs.map} +0 -0
  289. /package/dist/esm/{chunk-5V2RGYYK.mjs.map → chunk-4RXGVY2H.mjs.map} +0 -0
  290. /package/dist/esm/{chunk-MWUJCP27.mjs.map → chunk-4VAYXBD2.mjs.map} +0 -0
  291. /package/dist/esm/{chunk-6KNAIXZ3.mjs.map → chunk-5SGIYAB7.mjs.map} +0 -0
  292. /package/dist/esm/{chunk-Q3AUNZDW.mjs.map → chunk-6F3HFDL3.mjs.map} +0 -0
  293. /package/dist/esm/{chunk-FBLSW5TB.mjs.map → chunk-6MDYCC7P.mjs.map} +0 -0
  294. /package/dist/esm/{chunk-M7HZOQ6A.mjs.map → chunk-7CJAEAQZ.mjs.map} +0 -0
  295. /package/dist/esm/{chunk-Y33VGXNI.mjs.map → chunk-7Y6AWDBZ.mjs.map} +0 -0
  296. /package/dist/esm/{chunk-COW5IGYC.mjs.map → chunk-AUAL3H36.mjs.map} +0 -0
  297. /package/dist/esm/{chunk-6M53MDWB.mjs.map → chunk-AUV4VAXK.mjs.map} +0 -0
  298. /package/dist/esm/{chunk-MTLETLKV.mjs.map → chunk-AVWAYKNS.mjs.map} +0 -0
  299. /package/dist/esm/{chunk-EIRSA5UU.mjs.map → chunk-BNA3SGG6.mjs.map} +0 -0
  300. /package/dist/esm/{chunk-Y5BON557.mjs.map → chunk-CEGCSC3T.mjs.map} +0 -0
  301. /package/dist/esm/{chunk-UFJGYMEB.mjs.map → chunk-CZOUSIAD.mjs.map} +0 -0
  302. /package/dist/esm/{chunk-SBQRBBRS.mjs.map → chunk-DSVNXD5A.mjs.map} +0 -0
  303. /package/dist/esm/{chunk-IEZO4PIG.mjs.map → chunk-EJ7ODMDA.mjs.map} +0 -0
  304. /package/dist/esm/{chunk-ONIYM7IU.mjs.map → chunk-EJURLI4L.mjs.map} +0 -0
  305. /package/dist/esm/{chunk-W637YAND.mjs.map → chunk-GHHIUWPP.mjs.map} +0 -0
  306. /package/dist/esm/{chunk-EB7AI4B4.mjs.map → chunk-GS5Z3HO7.mjs.map} +0 -0
  307. /package/dist/esm/{chunk-4USAUOCE.mjs.map → chunk-HGRU3HWY.mjs.map} +0 -0
  308. /package/dist/esm/{chunk-TEJ7BXJK.mjs.map → chunk-HOX6Q6ZP.mjs.map} +0 -0
  309. /package/dist/esm/{chunk-UTXJOB3O.mjs.map → chunk-HQK6MF3G.mjs.map} +0 -0
  310. /package/dist/esm/{chunk-RUSWW265.mjs.map → chunk-ISXBJPLD.mjs.map} +0 -0
  311. /package/dist/esm/{chunk-MKUAW7KW.mjs.map → chunk-IU6REVKX.mjs.map} +0 -0
  312. /package/dist/esm/{chunk-Z6JERVLX.mjs.map → chunk-IWKIZLFW.mjs.map} +0 -0
  313. /package/dist/esm/{chunk-LQH7T3TE.mjs.map → chunk-J534ICWA.mjs.map} +0 -0
  314. /package/dist/esm/{chunk-STYDBDYL.mjs.map → chunk-J577ODDM.mjs.map} +0 -0
  315. /package/dist/esm/{chunk-EPTCPBVW.mjs.map → chunk-LLRWILVZ.mjs.map} +0 -0
  316. /package/dist/esm/{chunk-ZNEBMSNC.mjs.map → chunk-MLQT5I6K.mjs.map} +0 -0
  317. /package/dist/esm/{chunk-C3L4ETUF.mjs.map → chunk-MSGHGK52.mjs.map} +0 -0
  318. /package/dist/esm/{chunk-7STYQ5ZE.mjs.map → chunk-NGTNMV6Q.mjs.map} +0 -0
  319. /package/dist/esm/{chunk-OX5GWFHX.mjs.map → chunk-NH466YFP.mjs.map} +0 -0
  320. /package/dist/esm/{chunk-ZCCYHFPK.mjs.map → chunk-NMD45OTM.mjs.map} +0 -0
  321. /package/dist/esm/{chunk-UWI5D7FD.mjs.map → chunk-NUBYALZP.mjs.map} +0 -0
  322. /package/dist/esm/{chunk-KKP4FBWZ.mjs.map → chunk-OFC75EWS.mjs.map} +0 -0
  323. /package/dist/esm/{chunk-T6OEZ4KP.mjs.map → chunk-OOYRJQPD.mjs.map} +0 -0
  324. /package/dist/esm/{chunk-EU6CX56Q.mjs.map → chunk-PENBUSGL.mjs.map} +0 -0
  325. /package/dist/esm/{chunk-A3UVZHDJ.mjs.map → chunk-PG7KSUMN.mjs.map} +0 -0
  326. /package/dist/esm/{chunk-HGZGTBA4.mjs.map → chunk-PGP2XMDE.mjs.map} +0 -0
  327. /package/dist/esm/{chunk-EADBYPUD.mjs.map → chunk-QJIMZI32.mjs.map} +0 -0
  328. /package/dist/esm/{chunk-YHO2EBXH.mjs.map → chunk-QLE5JL4X.mjs.map} +0 -0
  329. /package/dist/esm/{chunk-KFUOOBMJ.mjs.map → chunk-QOOHLRRJ.mjs.map} +0 -0
  330. /package/dist/esm/{chunk-UO5LUYGO.mjs.map → chunk-QYEJOEWB.mjs.map} +0 -0
  331. /package/dist/esm/{chunk-NQMF46E5.mjs.map → chunk-R4HLV32L.mjs.map} +0 -0
  332. /package/dist/esm/{chunk-C34M4T77.mjs.map → chunk-RWYPGTNL.mjs.map} +0 -0
  333. /package/dist/esm/{chunk-3FVRXELT.mjs.map → chunk-SCHMTP4N.mjs.map} +0 -0
  334. /package/dist/esm/{chunk-3Y6JNFPD.mjs.map → chunk-SCRIQQV3.mjs.map} +0 -0
  335. /package/dist/esm/{chunk-W36IQO5K.mjs.map → chunk-SNBE5YAC.mjs.map} +0 -0
  336. /package/dist/esm/{chunk-NCDP26DV.mjs.map → chunk-SSDWEOF7.mjs.map} +0 -0
  337. /package/dist/esm/{chunk-N466X3S6.mjs.map → chunk-SZ6KR73C.mjs.map} +0 -0
  338. /package/dist/esm/{chunk-F5C4SZZ7.mjs.map → chunk-THURV6CN.mjs.map} +0 -0
  339. /package/dist/esm/{chunk-5RRZMXND.mjs.map → chunk-TU6VKYDC.mjs.map} +0 -0
  340. /package/dist/esm/{chunk-UDU5L4XH.mjs.map → chunk-UFMIMN7W.mjs.map} +0 -0
  341. /package/dist/esm/{chunk-LO7B3CWN.mjs.map → chunk-ULW5LX5H.mjs.map} +0 -0
  342. /package/dist/esm/{chunk-4KEEUDZA.mjs.map → chunk-V6M7FGQT.mjs.map} +0 -0
  343. /package/dist/esm/{chunk-3VGX3TXH.mjs.map → chunk-VBODXPT3.mjs.map} +0 -0
  344. /package/dist/esm/{chunk-MGOHPDX4.mjs.map → chunk-VMVSUH2K.mjs.map} +0 -0
  345. /package/dist/esm/{chunk-T23OVRNF.mjs.map → chunk-WHSN42R2.mjs.map} +0 -0
  346. /package/dist/esm/{chunk-LEBJNW6Y.mjs.map → chunk-WJIICWOB.mjs.map} +0 -0
  347. /package/dist/esm/{chunk-PYUU4OEL.mjs.map → chunk-WOLLRMXR.mjs.map} +0 -0
  348. /package/dist/esm/{chunk-NC5HHEEM.mjs.map → chunk-XQ7I34AL.mjs.map} +0 -0
  349. /package/dist/esm/{chunk-MWN63XBE.mjs.map → chunk-Y24BMR2W.mjs.map} +0 -0
  350. /package/dist/esm/{chunk-WAXCU6D6.mjs.map → chunk-YLQJBXUF.mjs.map} +0 -0
  351. /package/dist/esm/{chunk-6RBUXB5I.mjs.map → chunk-ZV5P2GSJ.mjs.map} +0 -0
  352. /package/dist/esm/{bcs → core/crypto}/cryptoHasher.mjs.map +0 -0
@@ -77,16 +77,22 @@ export class Deserializer {
77
77
  }
78
78
 
79
79
  /**
80
- * Deserializes a an optional string.
80
+ * Deserializes a an optional deserializable class.
81
81
  *
82
- * BCS layout for Optional<String>: 0 if none, else 1 | string_length | string_content
83
- * @example
84
- * ```ts
85
- * const deserializer = new Deserializer(new Uint8Array([0x00]));
86
- * assert(deserializer.deserializeOptionStr() === undefined);
87
- * const deserializer = new Deserializer(new Uint8Array([1, 8, 49, 50, 51, 52, 97, 98, 99, 100]));
88
- * assert(deserializer.deserializeOptionStr() === "1234abcd");
89
- * ```
82
+ * BCS layout for Optional<T>: 0 if none, else 1 | bcs representation of class
83
+ *
84
+ * @example
85
+ * const deserializer = new Deserializer(new Uint8Array([1, 2, 3]));
86
+ * const value = deserializer.deserializeOption(MyClass); // where MyClass has a `deserialize` function
87
+ * // value is now an instance of MyClass
88
+ *
89
+ * const deserializer = new Deserializer(new Uint8Array([0]));
90
+ * const value = deserializer.deserializeOption(MyClass); // where MyClass has a `deserialize` function
91
+ * // value is undefined
92
+ *
93
+ * @param cls The BCS-deserializable class to deserialize the buffered bytes into.
94
+ *
95
+ * @returns the deserialized value of class type T
90
96
  */
91
97
  deserializeOption<T>(cls: Deserializable<T>): T | undefined {
92
98
  const exists = this.deserializeUleb128AsU32();
@@ -317,6 +317,24 @@ export class Serializer {
317
317
  });
318
318
  }
319
319
 
320
+ /**
321
+ * Serializes a BCS Serializable values into a serializer instance or undefined.
322
+ * Note that this does not return anything. The bytes are added to the serializer instance's byte buffer.
323
+ *
324
+ * @param values The array of BCS Serializable values
325
+ *
326
+ * @example
327
+ * ```ts
328
+ * const serializer = new Serializer();
329
+ * serializer.serializeOption(new AccountAddress(...));
330
+ * const serializedBytes = serializer.toUint8Array();
331
+ * // serializedBytes is now the BCS-serialized byte representation of AccountAddress
332
+ *
333
+ * const serializer = new Serializer();
334
+ * serializer.serializeOption(undefined);
335
+ * assert(serializer.toUint8Array() === new Uint8Array([0x00]));
336
+ * ```
337
+ */
320
338
  serializeOption<T extends Serializable>(value?: T): void {
321
339
  if (value === undefined) {
322
340
  this.serializeU32AsUleb128(0);
@@ -326,6 +344,28 @@ export class Serializer {
326
344
  }
327
345
  }
328
346
 
347
+ /**
348
+ * Serializes an optional string. UTF8 string is supported.
349
+ *
350
+ * The existence of the string is encoded first, 0 if undefined and 1 if it exists.
351
+ * Them the number of bytes in the string content is serialized, as a uleb128-encoded u32 integer.
352
+ * Then the string content is serialized as UTF8 encoded bytes.
353
+ *
354
+ * BCS layout for optional "string": 1 | string_length | string_content
355
+ * where string_length is a u32 integer encoded as a uleb128 integer, equal to the number of bytes in string_content.
356
+ *
357
+ * BCS layout for undefined: 0
358
+ * @example
359
+ * ```ts
360
+ * const serializer = new Serializer();
361
+ * serializer.serializeOptionStr("1234abcd");
362
+ * assert(serializer.toUint8Array() === new Uint8Array([1, 8, 49, 50, 51, 52, 97, 98, 99, 100]));
363
+ *
364
+ * const serializer = new Serializer();
365
+ * serializer.serializeOptionStr(undefined);
366
+ * assert(serializer.toUint8Array() === new Uint8Array([0]));
367
+ * ```
368
+ */
329
369
  serializeOptionStr(value?: string): void {
330
370
  if (value === undefined) {
331
371
  this.serializeU32AsUleb128(0);
@@ -100,19 +100,16 @@ export async function aptosRequest<Req extends {}, Res extends {}>(
100
100
  );
101
101
  }
102
102
  result.data = indexerResponse.data as Res;
103
+ } else if (apiType === AptosApiType.PEPPER || apiType === AptosApiType.PROVER) {
104
+ if (result.status >= 500) {
105
+ throw new AptosApiError(options, result, `${response.data}`);
106
+ }
103
107
  }
104
108
 
105
109
  if (result.status >= 200 && result.status < 300) {
106
110
  return result;
107
111
  }
108
112
 
109
- if (result.status >= 500) {
110
- throw new AptosApiError(options, result, `${response.data}`);
111
- }
112
-
113
- if (aptosConfig.isPepperServiceRequest(url) || aptosConfig.isProverServiceRequest(url)) {
114
- throw new AptosApiError(options, result, `${response.data}`);
115
- }
116
113
 
117
114
  let errorMessage: string;
118
115
 
package/src/client/get.ts CHANGED
@@ -89,6 +89,12 @@ export async function getAptosFullNode<Req extends {}, Res extends {}>(
89
89
  });
90
90
  }
91
91
 
92
+ /**
93
+ * Makes a get request to the pepper service
94
+ *
95
+ * @param options GetAptosRequestOptions
96
+ * @returns AptosResponse
97
+ */
92
98
  export async function getAptosPepperService<Req extends {}, Res extends {}>(
93
99
  options: GetAptosRequestOptions,
94
100
  ): Promise<AptosResponse<Req, Res>> {
@@ -136,6 +136,12 @@ export async function postAptosFaucet<Req extends {}, Res extends {}>(
136
136
  });
137
137
  }
138
138
 
139
+ /**
140
+ * Makes a post request to the pepper service
141
+ *
142
+ * @param options GetAptosRequestOptions
143
+ * @returns AptosResponse
144
+ */
139
145
  export async function postAptosPepperService<Req extends {}, Res extends {}>(
140
146
  options: PostAptosRequestOptions,
141
147
  ): Promise<AptosResponse<Req, Res>> {
@@ -0,0 +1,16 @@
1
+ import { generateSigningMessage } from "../../transactions/transactionBuilder/signingMessage";
2
+ import { Serializable } from "../../bcs/serializer";
3
+
4
+ export type AptsoDomainSeparator = `APTOS::${string}`;
5
+ export abstract class CryptoHashable extends Serializable {
6
+ abstract readonly domainSeparator: AptsoDomainSeparator;
7
+
8
+ /**
9
+ * Hashes the bcs serialized from of the class. This is the typescript corollary to the BCSCryptoHash macro in aptos-core.
10
+ *
11
+ * @returns Uint8Array
12
+ */
13
+ hash(): Uint8Array {
14
+ return generateSigningMessage(this.bcsToBytes(), this.domainSeparator);
15
+ }
16
+ }
@@ -7,9 +7,11 @@ import { Deserializer, Serializable, Serializer } from "../../bcs";
7
7
  import { Hex } from "../hex";
8
8
  import { HexInput, EphemeralCertificateVariant, AnyPublicKeyVariant, SigningScheme, ZkpVariant } from "../../types";
9
9
  import { EphemeralPublicKey, EphemeralSignature } from "./ephemeral";
10
- import { bigIntToBytesLE, bytesToBigIntLE, hashASCIIStrToField, poseidonHash } from "./poseidon";
10
+ import { bigIntToBytesLE, bytesToBigIntLE, hashStrToField, poseidonHash } from "./poseidon";
11
11
  import { AuthenticationKey } from "../authenticationKey";
12
12
  import { Proof } from "./proof";
13
+ import { Ed25519PublicKey, Ed25519Signature } from "./ed25519";
14
+ import { Groth16VerificationKeyResponse } from "../../types/keyless";
13
15
 
14
16
  export const EPK_HORIZON_SECS = 10000000;
15
17
  export const MAX_AUD_VAL_BYTES = 120;
@@ -28,15 +30,23 @@ export const MAX_COMMITED_EPK_BYTES = 93;
28
30
  export class KeylessPublicKey extends AccountPublicKey {
29
31
  static readonly ID_COMMITMENT_LENGTH: number = 32;
30
32
 
33
+ /**
34
+ * The value of the 'iss' claim on the JWT which identifies the OIDC provider.
35
+ */
31
36
  readonly iss: string;
32
37
 
38
+ /**
39
+ * A value representing a cryptographic commitment to a user identity.
40
+ *
41
+ * It is calculated from the aud, uidKey, uidVal, pepper.
42
+ */
33
43
  readonly idCommitment: Uint8Array;
34
44
 
35
45
  constructor(iss: string, idCommitment: HexInput) {
36
46
  super();
37
47
  const idcBytes = Hex.fromHexInput(idCommitment).toUint8Array();
38
48
  if (idcBytes.length !== KeylessPublicKey.ID_COMMITMENT_LENGTH) {
39
- throw new Error(`Address seed length in bytes should be ${KeylessPublicKey.ID_COMMITMENT_LENGTH}`);
49
+ throw new Error(`Id Commitment length in bytes should be ${KeylessPublicKey.ID_COMMITMENT_LENGTH}`);
40
50
  }
41
51
  this.iss = iss;
42
52
  this.idCommitment = idcBytes;
@@ -135,9 +145,9 @@ function computeIdCommitment(args: { uidKey: string; uidVal: string; aud: string
135
145
 
136
146
  const fields = [
137
147
  bytesToBigIntLE(Hex.fromHexInput(pepper).toUint8Array()),
138
- hashASCIIStrToField(aud, MAX_AUD_VAL_BYTES),
139
- hashASCIIStrToField(uidVal, MAX_UID_VAL_BYTES),
140
- hashASCIIStrToField(uidKey, MAX_UID_KEY_BYTES),
148
+ hashStrToField(aud, MAX_AUD_VAL_BYTES),
149
+ hashStrToField(uidVal, MAX_UID_VAL_BYTES),
150
+ hashStrToField(uidKey, MAX_UID_KEY_BYTES),
141
151
  ];
142
152
 
143
153
  return bigIntToBytesLE(poseidonHash(fields), KeylessPublicKey.ID_COMMITMENT_LENGTH);
@@ -160,7 +170,7 @@ export class KeylessSignature extends Signature {
160
170
  /**
161
171
  * The expiry timestamp in seconds of the EphemeralKeyPair used to sign
162
172
  */
163
- readonly expiryDateSecs: bigint | number;
173
+ readonly expiryDateSecs: number;
164
174
 
165
175
  /**
166
176
  * The ephemeral public key used to verify the signature
@@ -175,7 +185,7 @@ export class KeylessSignature extends Signature {
175
185
  constructor(args: {
176
186
  jwtHeader: string;
177
187
  ephemeralCertificate: EphemeralCertificate;
178
- expiryDateSecs: bigint | number;
188
+ expiryDateSecs: number;
179
189
  ephemeralPublicKey: EphemeralPublicKey;
180
190
  ephemeralSignature: EphemeralSignature;
181
191
  }) {
@@ -213,7 +223,7 @@ export class KeylessSignature extends Signature {
213
223
  const ephemeralSignature = EphemeralSignature.deserialize(deserializer);
214
224
  return new KeylessSignature({
215
225
  jwtHeader,
216
- expiryDateSecs,
226
+ expiryDateSecs: Number(expiryDateSecs),
217
227
  ephemeralCertificate,
218
228
  ephemeralPublicKey,
219
229
  ephemeralSignature,
@@ -228,13 +238,31 @@ export class KeylessSignature extends Signature {
228
238
  const ephemeralSignature = EphemeralSignature.deserialize(deserializer);
229
239
  return new KeylessSignature({
230
240
  jwtHeader,
231
- expiryDateSecs,
241
+ expiryDateSecs: Number(expiryDateSecs),
232
242
  ephemeralCertificate,
233
243
  ephemeralPublicKey,
234
244
  ephemeralSignature,
235
245
  });
236
246
  }
237
247
 
248
+ static getSimulationSignature(): KeylessSignature {
249
+ return new KeylessSignature({
250
+ jwtHeader: "{}",
251
+ ephemeralCertificate: new EphemeralCertificate(
252
+ new ZeroKnowledgeSig({
253
+ proof: new ZkProof(
254
+ new Groth16Zkp({ a: new Uint8Array(32), b: new Uint8Array(64), c: new Uint8Array(32) }),
255
+ ZkpVariant.Groth16,
256
+ ),
257
+ }),
258
+ EphemeralCertificateVariant.ZkProof,
259
+ ),
260
+ expiryDateSecs: 0,
261
+ ephemeralPublicKey: new EphemeralPublicKey(new Ed25519PublicKey(new Uint8Array(32))),
262
+ ephemeralSignature: new EphemeralSignature(new Ed25519Signature(new Uint8Array(64))),
263
+ });
264
+ }
265
+
238
266
  static isSignature(signature: Signature): signature is KeylessSignature {
239
267
  return signature instanceof KeylessSignature;
240
268
  }
@@ -282,6 +310,48 @@ export class EphemeralCertificate extends Signature {
282
310
  }
283
311
  }
284
312
 
313
+ class G1Bytes extends Serializable {
314
+ data: Uint8Array;
315
+
316
+ constructor(data: HexInput) {
317
+ super();
318
+ this.data = Hex.fromHexInput(data).toUint8Array();
319
+ if (this.data.length !== 32) {
320
+ throw new Error("Input needs to be 32 bytes");
321
+ }
322
+ }
323
+
324
+ serialize(serializer: Serializer): void {
325
+ serializer.serializeFixedBytes(this.data);
326
+ }
327
+
328
+ static deserialize(deserializer: Deserializer): G1Bytes {
329
+ const bytes = deserializer.deserializeFixedBytes(32);
330
+ return new G1Bytes(bytes);
331
+ }
332
+ }
333
+
334
+ class G2Bytes extends Serializable {
335
+ data: Uint8Array;
336
+
337
+ constructor(data: HexInput) {
338
+ super();
339
+ this.data = Hex.fromHexInput(data).toUint8Array();
340
+ if (this.data.length !== 64) {
341
+ throw new Error("Input needs to be 64 bytes");
342
+ }
343
+ }
344
+
345
+ serialize(serializer: Serializer): void {
346
+ serializer.serializeFixedBytes(this.data);
347
+ }
348
+
349
+ static deserialize(deserializer: Deserializer): G2Bytes {
350
+ const bytes = deserializer.deserializeFixedBytes(64);
351
+ return new G2Bytes(bytes);
352
+ }
353
+ }
354
+
285
355
  /**
286
356
  * A representation of a Groth16 proof. The points are the compressed serialization of affine reprentation of the proof.
287
357
  */
@@ -289,36 +359,36 @@ export class Groth16Zkp extends Proof {
289
359
  /**
290
360
  * The bytes of G1 proof point a
291
361
  */
292
- a: Uint8Array;
362
+ a: G1Bytes;
293
363
 
294
364
  /**
295
365
  * The bytes of G2 proof point b
296
366
  */
297
- b: Uint8Array;
367
+ b: G2Bytes;
298
368
 
299
369
  /**
300
370
  * The bytes of G1 proof point c
301
371
  */
302
- c: Uint8Array;
372
+ c: G1Bytes;
303
373
 
304
374
  constructor(args: { a: HexInput; b: HexInput; c: HexInput }) {
305
375
  super();
306
376
  const { a, b, c } = args;
307
- this.a = Hex.fromHexInput(a).toUint8Array();
308
- this.b = Hex.fromHexInput(b).toUint8Array();
309
- this.c = Hex.fromHexInput(c).toUint8Array();
377
+ this.a = new G1Bytes(a)
378
+ this.b = new G2Bytes(b)
379
+ this.c = new G1Bytes(c)
310
380
  }
311
381
 
312
382
  serialize(serializer: Serializer): void {
313
- serializer.serializeFixedBytes(this.a);
314
- serializer.serializeFixedBytes(this.b);
315
- serializer.serializeFixedBytes(this.c);
383
+ this.a.serialize(serializer);
384
+ this.b.serialize(serializer);
385
+ this.c.serialize(serializer);
316
386
  }
317
387
 
318
388
  static deserialize(deserializer: Deserializer): Groth16Zkp {
319
- const a = deserializer.deserializeFixedBytes(32);
320
- const b = deserializer.deserializeFixedBytes(64);
321
- const c = deserializer.deserializeFixedBytes(32);
389
+ const a = G1Bytes.deserialize(deserializer).bcsToBytes();
390
+ const b = G2Bytes.deserialize(deserializer).bcsToBytes();
391
+ const c = G1Bytes.deserialize(deserializer).bcsToBytes();
322
392
  return new Groth16Zkp({ a, b, c });
323
393
  }
324
394
  }
@@ -371,12 +441,13 @@ export class ZeroKnowledgeSig extends Signature {
371
441
  readonly expHorizonSecs: bigint;
372
442
 
373
443
  /**
374
- * A key value pair on the JWT token that can be made public
444
+ * A key value pair on the JWT token that can be specified on the signature which would reveal the value on chain.
445
+ * Can be used to assert identity or other attributes.
375
446
  */
376
447
  readonly extraField?: string;
377
448
 
378
449
  /**
379
- * Set in the case of signing by recovery services
450
+ * The 'aud' value of the recovery service which is set when recovering an account.
380
451
  */
381
452
  readonly overrideAudVal?: string;
382
453
 
@@ -451,3 +522,68 @@ export class ZeroKnowledgeSig extends Signature {
451
522
  return new ZeroKnowledgeSig({ proof, expHorizonSecs, trainingWheelsSignature, extraField, overrideAudVal });
452
523
  }
453
524
  }
525
+
526
+ export class KeylessConfiguration {
527
+ readonly verficationKey: Groth16VerificationKey;
528
+
529
+ readonly maxExpHorizonSecs: number;
530
+
531
+ constructor(verficationKey: Groth16VerificationKey, maxExpHorizonSecs: number) {
532
+ this.verficationKey = verficationKey;
533
+ this.maxExpHorizonSecs = maxExpHorizonSecs;
534
+ }
535
+
536
+ static create(res: Groth16VerificationKeyResponse, maxExpHorizonSecs: number): KeylessConfiguration {
537
+ return new KeylessConfiguration(new Groth16VerificationKey({
538
+ alphaG1: res.alpha_g1,
539
+ betaG2: res.beta_g2,
540
+ deltaG2: res.delta_g2,
541
+ gammaAbcG1: res.gamma_abc_g1,
542
+ gammaG2: res.gamma_g2
543
+ }), maxExpHorizonSecs)
544
+ }
545
+
546
+ }
547
+
548
+ class Groth16VerificationKey {
549
+ readonly alphaG1: G1Bytes;
550
+
551
+ readonly betaG2: G2Bytes;
552
+
553
+ readonly deltaG2: G2Bytes;
554
+
555
+ readonly gammaAbcG1: G1Bytes[];
556
+
557
+ readonly gammaG2: G2Bytes;
558
+
559
+ constructor(args: {
560
+ alphaG1: HexInput;
561
+ betaG2: HexInput;
562
+ deltaG2: HexInput;
563
+ gammaAbcG1: [HexInput, HexInput];
564
+ gammaG2: HexInput;
565
+ }) {
566
+ const {
567
+ alphaG1,
568
+ betaG2,
569
+ deltaG2,
570
+ gammaAbcG1,
571
+ gammaG2,
572
+ } = args;
573
+ this.alphaG1 = new G1Bytes(alphaG1)
574
+ this.betaG2 = new G2Bytes(betaG2)
575
+ this.deltaG2 = new G2Bytes(deltaG2)
576
+ this.gammaAbcG1 = [new G1Bytes(gammaAbcG1[0]), new G1Bytes(gammaAbcG1[1])]
577
+ this.gammaG2 =new G2Bytes(gammaG2)
578
+ }
579
+
580
+ static fromGroth16VerificationKeyResponse(res: Groth16VerificationKeyResponse): Groth16VerificationKey {
581
+ return new Groth16VerificationKey({
582
+ alphaG1: res.alpha_g1,
583
+ betaG2: res.beta_g2,
584
+ deltaG2: res.delta_g2,
585
+ gammaAbcG1: res.gamma_abc_g1,
586
+ gammaG2: res.gamma_g2
587
+ })
588
+ }
589
+ }
@@ -41,14 +41,18 @@ const BYTES_PACKED_PER_SCALAR = 31;
41
41
  const MAX_NUM_INPUT_SCALARS = 16;
42
42
  const MAX_NUM_INPUT_BYTES = (MAX_NUM_INPUT_SCALARS - 1) * BYTES_PACKED_PER_SCALAR;
43
43
 
44
- // hashes an ASCII string to a field element
45
- export function hashASCIIStrToField(str: string, maxSizeBytes: number) {
44
+ /**
45
+ * Hashes a string to a field element via poseidon
46
+ *
47
+ * @returns bigint result of the hash
48
+ */
49
+ export function hashStrToField(str: string, maxSizeBytes: number): bigint {
46
50
  const textEncoder = new TextEncoder();
47
51
  const strBytes = textEncoder.encode(str);
48
52
  return hashBytesWithLen(strBytes, maxSizeBytes);
49
53
  }
50
54
 
51
- function hashBytesWithLen(bytes: Uint8Array, maxSizeBytes: number) {
55
+ function hashBytesWithLen(bytes: Uint8Array, maxSizeBytes: number): bigint {
52
56
  if (bytes.length > maxSizeBytes) {
53
57
  throw new Error(`Inputted bytes of length ${bytes} is longer than ${maxSizeBytes}`);
54
58
  }
@@ -123,11 +127,16 @@ function padUint8ArrayWithZeros(inputArray: Uint8Array, paddedSize: number): Uin
123
127
  return paddedArray;
124
128
  }
125
129
 
130
+ /**
131
+ * Hashes up to 16 scalar elements via the poseidon hashing algorithm.
132
+ *
133
+ * Each element must be scalar fields of the BN254 elliptic curve group.
134
+ *
135
+ * @returns bigint result of the hash
136
+ */
126
137
  export function poseidonHash(inputs: (number | bigint | string)[]): bigint {
127
- const poseidonFixedHash = numInputsToPoseidonFunc[inputs.length - 1];
128
-
129
- if (poseidonFixedHash) {
130
- return poseidonFixedHash(inputs);
138
+ if (inputs.length > numInputsToPoseidonFunc.length) {
139
+ throw new Error(`Unable to hash input of length ${inputs.length}. Max input length is ${numInputsToPoseidonFunc.length}`);
131
140
  }
132
- throw new Error(`Unable to hash input of length ${inputs.length}`);
141
+ return numInputsToPoseidonFunc[inputs.length - 1](inputs);
133
142
  }
@@ -5,14 +5,79 @@
5
5
  * This file contains the underlying implementations for exposed API surface in
6
6
  * the {@link api/keyless}. By moving the methods out into a separate file,
7
7
  * other namespaces and processes can access these methods without depending on the entire
8
- * faucet namespace and without having a dependency cycle error.
8
+ * keyless namespace and without having a dependency cycle error.
9
9
  */
10
10
  import { AptosConfig } from "../api/aptosConfig";
11
- import { postAptosPepperService, postAptosProvingService } from "../client";
12
- import { EPK_HORIZON_SECS, EphemeralSignature, Groth16Zkp, Hex, ZeroKnowledgeSig, ZkProof } from "../core";
13
- import { HexInput, ZkpVariant } from "../types";
11
+ import { getAptosFullNode, postAptosPepperService, postAptosProvingService } from "../client";
12
+ import {
13
+ AccountAddress,
14
+ EPK_HORIZON_SECS,
15
+ EphemeralSignature,
16
+ Groth16Zkp,
17
+ Hex,
18
+ KeylessConfiguration,
19
+ ZeroKnowledgeSig,
20
+ ZkProof,
21
+ } from "../core";
22
+ import { HexInput, LedgerVersionArg, MoveResource, ZkpVariant } from "../types";
14
23
  import { EphemeralKeyPair, KeylessAccount, ProofFetchCallback } from "../account";
15
- import { PepperFetchResponse, ProverResponse } from "../types/keyless";
24
+ import {
25
+ Groth16VerificationKeyResponse,
26
+ KeylessConfigurationResponse,
27
+ PepperFetchRequest,
28
+ PepperFetchResponse,
29
+ ProverRequest,
30
+ ProverResponse,
31
+ } from "../types/keyless";
32
+ import { memoizeAsync } from "../utils/memoize";
33
+
34
+ export async function getKeylessConfig(args: {
35
+ aptosConfig: AptosConfig;
36
+ options?: LedgerVersionArg;
37
+ }): Promise<KeylessConfiguration> {
38
+ const { aptosConfig } = args;
39
+ return memoizeAsync(
40
+ async () => {
41
+ const config = await getKeylessConfiguration(args);
42
+ const vk = await getGroth16VerificationKey(args);
43
+ return KeylessConfiguration.create(vk, Number(config.max_exp_horizon_secs));
44
+ },
45
+ `keyless-configuration-${aptosConfig.network}`,
46
+ 1000 * 60 * 5, // 5 minutes
47
+ )();
48
+ }
49
+
50
+ async function getKeylessConfiguration(args: {
51
+ aptosConfig: AptosConfig;
52
+ options?: LedgerVersionArg;
53
+ }): Promise<KeylessConfigurationResponse> {
54
+ const { aptosConfig, options } = args;
55
+ const resourceType = "0x1::keyless_account::Configuration";
56
+ const { data } = await getAptosFullNode<{}, MoveResource<KeylessConfigurationResponse>>({
57
+ aptosConfig,
58
+ originMethod: "getKeylessConfiguration",
59
+ path: `accounts/${AccountAddress.from("0x1").toString()}/resource/${resourceType}`,
60
+ params: { ledger_version: options?.ledgerVersion },
61
+ });
62
+
63
+ return data.data;
64
+ }
65
+
66
+ async function getGroth16VerificationKey(args: {
67
+ aptosConfig: AptosConfig;
68
+ options?: LedgerVersionArg;
69
+ }): Promise<Groth16VerificationKeyResponse> {
70
+ const { aptosConfig, options } = args;
71
+ const resourceType = "0x1::keyless_account::Groth16VerificationKey";
72
+ const { data } = await getAptosFullNode<{}, MoveResource<Groth16VerificationKeyResponse>>({
73
+ aptosConfig,
74
+ originMethod: "getGroth16VerificationKey",
75
+ path: `accounts/${AccountAddress.from("0x1").toString()}/resource/${resourceType}`,
76
+ params: { ledger_version: options?.ledgerVersion },
77
+ });
78
+
79
+ return data.data;
80
+ }
16
81
 
17
82
  export async function getPepper(args: {
18
83
  aptosConfig: AptosConfig;
@@ -26,12 +91,12 @@ export async function getPepper(args: {
26
91
  const body = {
27
92
  jwt_b64: jwt,
28
93
  epk: ephemeralKeyPair.getPublicKey().bcsToHex().toStringWithoutPrefix(),
29
- exp_date_secs: Number(ephemeralKeyPair.expiryDateSecs),
94
+ exp_date_secs: ephemeralKeyPair.expiryDateSecs,
30
95
  epk_blinder: Hex.fromHexInput(ephemeralKeyPair.blinder).toStringWithoutPrefix(),
31
- uid_key: uidKey,
96
+ uid_key: uidKey || "sub",
32
97
  derivation_path: derivationPath,
33
98
  };
34
- const { data } = await postAptosPepperService<any, PepperFetchResponse>({
99
+ const { data } = await postAptosPepperService<PepperFetchRequest, PepperFetchResponse>({
35
100
  aptosConfig,
36
101
  path: "fetch",
37
102
  body,
@@ -47,21 +112,19 @@ export async function getProof(args: {
47
112
  ephemeralKeyPair: EphemeralKeyPair;
48
113
  pepper: HexInput;
49
114
  uidKey?: string;
50
- extraFieldKey?: string;
51
115
  }): Promise<ZeroKnowledgeSig> {
52
- const { aptosConfig, jwt, ephemeralKeyPair, pepper, uidKey, extraFieldKey } = args;
116
+ const { aptosConfig, jwt, ephemeralKeyPair, pepper, uidKey } = args;
53
117
  const json = {
54
118
  jwt_b64: jwt,
55
119
  epk: ephemeralKeyPair.getPublicKey().bcsToHex().toStringWithoutPrefix(),
56
120
  epk_blinder: Hex.fromHexInput(ephemeralKeyPair.blinder).toStringWithoutPrefix(),
57
- exp_date_secs: Number(ephemeralKeyPair.expiryDateSecs),
121
+ exp_date_secs: ephemeralKeyPair.expiryDateSecs,
58
122
  exp_horizon_secs: EPK_HORIZON_SECS,
59
123
  pepper: Hex.fromHexInput(pepper).toStringWithoutPrefix(),
60
- extra_field: extraFieldKey,
61
124
  uid_key: uidKey || "sub",
62
125
  };
63
126
 
64
- const { data } = await postAptosProvingService<any, ProverResponse>({
127
+ const { data } = await postAptosProvingService<ProverRequest, ProverResponse>({
65
128
  aptosConfig,
66
129
  path: "prove",
67
130
  body: json,
@@ -89,14 +152,17 @@ export async function deriveKeylessAccount(args: {
89
152
  ephemeralKeyPair: EphemeralKeyPair;
90
153
  uidKey?: string;
91
154
  pepper?: HexInput;
92
- extraFieldKey?: string;
93
155
  proofFetchCallback?: ProofFetchCallback;
94
156
  }): Promise<KeylessAccount> {
95
157
  const { proofFetchCallback } = args;
96
158
  let { pepper } = args;
97
159
  if (pepper === undefined) {
98
160
  pepper = await getPepper(args);
99
- } else if (Hex.fromHexInput(pepper).toUint8Array().length !== KeylessAccount.PEPPER_LENGTH) {
161
+ } else {
162
+ pepper = Hex.fromHexInput(pepper).toUint8Array();
163
+ }
164
+
165
+ if (pepper.length !== KeylessAccount.PEPPER_LENGTH) {
100
166
  throw new Error(`Pepper needs to be ${KeylessAccount.PEPPER_LENGTH} bytes`);
101
167
  }
102
168
 
@@ -8,7 +8,6 @@ import { sha3_256 as sha3Hash } from "@noble/hashes/sha3";
8
8
  import { RAW_TRANSACTION_SALT, RAW_TRANSACTION_WITH_DATA_SALT } from "../../utils/const";
9
9
  import { FeePayerRawTransaction, MultiAgentRawTransaction } from "../instances";
10
10
  import { AnyRawTransaction, AnyRawTransactionInstance } from "../types";
11
- import { CryptoHashable } from "../../bcs/cryptoHasher";
12
11
 
13
12
  /**
14
13
  * Derive the raw transaction type - FeePayerRawTransaction or MultiAgentRawTransaction or RawTransaction
@@ -60,18 +59,6 @@ export function generateSigningMessage(bytes: Uint8Array, domainSeparator: strin
60
59
  return mergedArray;
61
60
  }
62
61
 
63
- /**
64
- * Generates the 'signing message' form of a serilizable value. It bcs serializes the value and uses the name of
65
- * its constructor as the domain separator.
66
- *
67
- * @param hashable An object that has a bcs serialized form
68
- *
69
- * @returns The Uint8Array of the signing message
70
- */
71
- export function generateSigningMessageForBcsCryptoHashable(hashable: CryptoHashable): Uint8Array {
72
- return generateSigningMessage(hashable.bcsToBytes(), hashable.domainSeparator);
73
- }
74
-
75
62
  /**
76
63
  * Generates the 'signing message' form of a transaction. It derives the type of transaction and
77
64
  * applies the appropriate domain separator based on if there is extra data such as a fee payer or