@aptos-labs/ts-sdk 1.7.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (370) hide show
  1. package/dist/browser/index.d.ts +1226 -975
  2. package/dist/browser/index.global.js +32 -30
  3. package/dist/browser/index.global.js.map +1 -1
  4. package/dist/common/index.d.ts +1226 -975
  5. package/dist/common/index.js +27 -25
  6. package/dist/common/index.js.map +1 -1
  7. package/dist/esm/api/account.d.mts +12 -6
  8. package/dist/esm/api/account.mjs +1 -1
  9. package/dist/esm/api/ans.d.mts +11 -12
  10. package/dist/esm/api/ans.mjs +1 -1
  11. package/dist/esm/api/aptos.d.mts +13 -14
  12. package/dist/esm/api/aptos.mjs +1 -1
  13. package/dist/esm/api/aptosConfig.mjs +1 -1
  14. package/dist/esm/api/coin.d.mts +13 -13
  15. package/dist/esm/api/coin.mjs +1 -1
  16. package/dist/esm/api/digitalAsset.d.mts +20 -10
  17. package/dist/esm/api/digitalAsset.mjs +1 -1
  18. package/dist/esm/api/event.d.mts +14 -1
  19. package/dist/esm/api/event.mjs +1 -1
  20. package/dist/esm/api/faucet.mjs +1 -1
  21. package/dist/esm/api/fungibleAsset.d.mts +9 -10
  22. package/dist/esm/api/fungibleAsset.mjs +1 -1
  23. package/dist/esm/api/general.mjs +1 -1
  24. package/dist/esm/api/index.d.mts +13 -14
  25. package/dist/esm/api/index.mjs +1 -1
  26. package/dist/esm/api/staking.mjs +1 -1
  27. package/dist/esm/api/transaction.d.mts +5 -6
  28. package/dist/esm/api/transaction.mjs +1 -1
  29. package/dist/esm/api/transactionSubmission/build.d.mts +8 -8
  30. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  31. package/dist/esm/api/transactionSubmission/management.d.mts +11 -12
  32. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  33. package/dist/esm/api/transactionSubmission/sign.d.mts +11 -12
  34. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  35. package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -1
  36. package/dist/esm/api/transactionSubmission/simulate.d.mts +11 -11
  37. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  38. package/dist/esm/api/transactionSubmission/submit.d.mts +6 -6
  39. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  40. package/dist/esm/api/utils.mjs +1 -1
  41. package/dist/esm/bcs/index.mjs +1 -1
  42. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  43. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  44. package/dist/esm/chunk-2E2JOGE5.mjs +2 -0
  45. package/dist/esm/chunk-2E2JOGE5.mjs.map +1 -0
  46. package/dist/esm/chunk-3EUOBVCT.mjs +2 -0
  47. package/dist/esm/{chunk-A2QH4A6D.mjs.map → chunk-3EUOBVCT.mjs.map} +1 -1
  48. package/dist/esm/{chunk-RNO5ZG3C.mjs → chunk-52RTAMN7.mjs} +2 -2
  49. package/dist/esm/chunk-7BDYKJXX.mjs +2 -0
  50. package/dist/esm/chunk-7BDYKJXX.mjs.map +1 -0
  51. package/dist/esm/{chunk-WQI2RH2S.mjs → chunk-7U36LMP4.mjs} +2 -2
  52. package/dist/esm/{chunk-NWRKJFHV.mjs → chunk-ARIC32W7.mjs} +2 -2
  53. package/dist/esm/{chunk-RIL4SHXC.mjs → chunk-B7M3OWHV.mjs} +2 -2
  54. package/dist/esm/{chunk-C7ZX475J.mjs → chunk-BBUAAJRA.mjs} +2 -2
  55. package/dist/esm/chunk-C3HM7HQP.mjs +2 -0
  56. package/dist/esm/chunk-C3HM7HQP.mjs.map +1 -0
  57. package/dist/esm/{chunk-DRF6AMEZ.mjs → chunk-CHA5DSSD.mjs} +2 -2
  58. package/dist/esm/chunk-CVEJHRAU.mjs +2 -0
  59. package/dist/esm/chunk-CVEJHRAU.mjs.map +1 -0
  60. package/dist/esm/chunk-DE5OOOVY.mjs +2 -0
  61. package/dist/esm/{chunk-3UYBNX3P.mjs.map → chunk-DE5OOOVY.mjs.map} +1 -1
  62. package/dist/esm/{chunk-IKCBGNRD.mjs → chunk-DGOT2VR5.mjs} +2 -2
  63. package/dist/esm/{chunk-GVHOHNHT.mjs → chunk-EF2F7NWO.mjs} +2 -2
  64. package/dist/esm/{chunk-J6RCCKOA.mjs → chunk-EQZ757ES.mjs} +2 -2
  65. package/dist/esm/{chunk-CX5ULWJQ.mjs → chunk-F67Y7YH6.mjs} +2 -2
  66. package/dist/esm/{chunk-JLL7BCD4.mjs → chunk-FVMVV4V3.mjs} +2 -2
  67. package/dist/esm/chunk-FWDKABRW.mjs +2 -0
  68. package/dist/esm/chunk-FWDKABRW.mjs.map +1 -0
  69. package/dist/esm/chunk-G62HQC77.mjs +2 -0
  70. package/dist/esm/chunk-G62HQC77.mjs.map +1 -0
  71. package/dist/esm/{chunk-ESX5X52V.mjs → chunk-GQOOXOTN.mjs} +2 -2
  72. package/dist/esm/chunk-GRJJBGHT.mjs +2 -0
  73. package/dist/esm/chunk-GRJJBGHT.mjs.map +1 -0
  74. package/dist/esm/chunk-HEPV52CH.mjs +2 -0
  75. package/dist/esm/chunk-HEPV52CH.mjs.map +1 -0
  76. package/dist/esm/{chunk-XQIWF5HY.mjs → chunk-I3TCHVQQ.mjs} +2 -2
  77. package/dist/esm/{chunk-3NOQE6U3.mjs → chunk-ILJWEPDW.mjs} +2 -2
  78. package/dist/esm/chunk-INORE66K.mjs +2 -0
  79. package/dist/esm/chunk-INORE66K.mjs.map +1 -0
  80. package/dist/esm/{chunk-5L6SRCJP.mjs → chunk-J6MWD4XN.mjs} +2 -2
  81. package/dist/esm/{chunk-YGMT4GQ5.mjs → chunk-JEHR6GKW.mjs} +2 -2
  82. package/dist/esm/chunk-JEHR6GKW.mjs.map +1 -0
  83. package/dist/esm/chunk-KUX6GQ2E.mjs +1 -0
  84. package/dist/esm/{chunk-6UNBJAV6.mjs → chunk-KWJTVJ7C.mjs} +2 -2
  85. package/dist/esm/chunk-KWJTVJ7C.mjs.map +1 -0
  86. package/dist/esm/{chunk-WK36MJRI.mjs → chunk-LLL2LFYH.mjs} +2 -2
  87. package/dist/esm/chunk-LMXP3JUU.mjs +2 -0
  88. package/dist/esm/chunk-LMXP3JUU.mjs.map +1 -0
  89. package/dist/esm/{chunk-5WXR2O3T.mjs → chunk-N65SOKJQ.mjs} +2 -2
  90. package/dist/esm/{chunk-XOBXX273.mjs → chunk-NL3XVNS5.mjs} +2 -2
  91. package/dist/esm/{chunk-Q7JKS6WV.mjs → chunk-NURFZOR4.mjs} +2 -2
  92. package/dist/esm/{chunk-MKERJNYN.mjs → chunk-OG56TYZE.mjs} +2 -2
  93. package/dist/esm/chunk-Q6WOHF4A.mjs +2 -0
  94. package/dist/esm/chunk-Q6WOHF4A.mjs.map +1 -0
  95. package/dist/esm/chunk-QA4XWNIH.mjs +2 -0
  96. package/dist/esm/chunk-QA4XWNIH.mjs.map +1 -0
  97. package/dist/esm/chunk-QE4ASJ5K.mjs +1 -0
  98. package/dist/esm/chunk-QR72RXBS.mjs +2 -0
  99. package/dist/esm/chunk-QR72RXBS.mjs.map +1 -0
  100. package/dist/esm/{chunk-TVURQPLA.mjs → chunk-R4VJDSIP.mjs} +2 -2
  101. package/dist/esm/{chunk-O57QZZF2.mjs → chunk-S2F6CSH4.mjs} +2 -2
  102. package/dist/esm/chunk-S2F6CSH4.mjs.map +1 -0
  103. package/dist/esm/{chunk-BQSE5HHW.mjs → chunk-S4SEFF4K.mjs} +3 -1
  104. package/dist/esm/chunk-S4SEFF4K.mjs.map +1 -0
  105. package/dist/esm/{chunk-OVSV4Y32.mjs → chunk-SXIFL5DQ.mjs} +2 -2
  106. package/dist/esm/{chunk-OVSV4Y32.mjs.map → chunk-SXIFL5DQ.mjs.map} +1 -1
  107. package/dist/esm/{chunk-Z6XNTGNK.mjs → chunk-TN5BUH4F.mjs} +2 -2
  108. package/dist/esm/chunk-TNVR7SNR.mjs +2 -0
  109. package/dist/esm/chunk-TNVR7SNR.mjs.map +1 -0
  110. package/dist/esm/chunk-TX7UK75Q.mjs +2 -0
  111. package/dist/esm/chunk-TX7UK75Q.mjs.map +1 -0
  112. package/dist/esm/{chunk-YE3DZD6T.mjs → chunk-UIUSDBCL.mjs} +2 -2
  113. package/dist/esm/{chunk-7JTOGYO7.mjs → chunk-UMLDKLDL.mjs} +2 -2
  114. package/dist/esm/chunk-UVSRX4SV.mjs +1 -0
  115. package/dist/esm/{chunk-6Y3VBRMN.mjs → chunk-VEVBHH3M.mjs} +2 -2
  116. package/dist/esm/{chunk-T5IFXLOP.mjs → chunk-VMXBMAYK.mjs} +2 -2
  117. package/dist/esm/chunk-WKUXBIYB.mjs +2 -0
  118. package/dist/esm/chunk-WKUXBIYB.mjs.map +1 -0
  119. package/dist/esm/chunk-WME5D6YR.mjs +2 -0
  120. package/dist/esm/chunk-WME5D6YR.mjs.map +1 -0
  121. package/dist/esm/chunk-WTHNSNAX.mjs +2 -0
  122. package/dist/esm/chunk-WTHNSNAX.mjs.map +1 -0
  123. package/dist/esm/{chunk-WC2WSKYZ.mjs → chunk-X5C3LYI7.mjs} +2 -2
  124. package/dist/esm/chunk-XKD7W5NO.mjs +2 -0
  125. package/dist/esm/{chunk-UJAX75ON.mjs.map → chunk-XKD7W5NO.mjs.map} +1 -1
  126. package/dist/esm/{chunk-OWZLBIDD.mjs → chunk-XTPFQ4MH.mjs} +2 -2
  127. package/dist/esm/{chunk-D2GNCG27.mjs → chunk-Y5AJLNUD.mjs} +2 -2
  128. package/dist/esm/chunk-YDAA4RG4.mjs +2 -0
  129. package/dist/esm/chunk-YDAA4RG4.mjs.map +1 -0
  130. package/dist/esm/{chunk-ZFPA45OK.mjs → chunk-YR2R3LW4.mjs} +2 -2
  131. package/dist/esm/chunk-YZZO6VDC.mjs +2 -0
  132. package/dist/esm/chunk-YZZO6VDC.mjs.map +1 -0
  133. package/dist/esm/client/core.mjs +1 -1
  134. package/dist/esm/client/get.mjs +1 -1
  135. package/dist/esm/client/index.mjs +1 -1
  136. package/dist/esm/client/post.mjs +1 -1
  137. package/dist/esm/core/account/Account.d.mts +20 -0
  138. package/dist/esm/core/account/Account.mjs +2 -0
  139. package/dist/esm/core/account/Ed25519Account.d.mts +20 -0
  140. package/dist/esm/core/account/Ed25519Account.mjs +2 -0
  141. package/dist/esm/core/account/SingleKeyAccount.d.mts +20 -0
  142. package/dist/esm/core/account/SingleKeyAccount.mjs +2 -0
  143. package/dist/esm/core/account/SingleKeyAccount.mjs.map +1 -0
  144. package/dist/esm/core/account/index.d.mts +305 -0
  145. package/dist/esm/core/account/index.mjs +2 -0
  146. package/dist/esm/core/account/index.mjs.map +1 -0
  147. package/dist/esm/core/accountAddress.mjs +1 -1
  148. package/dist/esm/core/authenticationKey.d.mts +7 -68
  149. package/dist/esm/core/authenticationKey.mjs +1 -1
  150. package/dist/esm/core/crypto/ed25519.d.mts +49 -61
  151. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  152. package/dist/esm/core/crypto/index.d.mts +9 -6
  153. package/dist/esm/core/crypto/index.mjs +1 -1
  154. package/dist/esm/core/crypto/multiEd25519.d.mts +17 -14
  155. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  156. package/dist/esm/core/crypto/multiKey.d.mts +70 -17
  157. package/dist/esm/core/crypto/multiKey.mjs +1 -1
  158. package/dist/esm/core/crypto/privateKey.d.mts +35 -0
  159. package/dist/esm/core/crypto/privateKey.mjs +2 -0
  160. package/dist/esm/core/crypto/privateKey.mjs.map +1 -0
  161. package/dist/esm/core/crypto/publicKey.d.mts +13 -0
  162. package/dist/esm/core/crypto/publicKey.mjs +2 -0
  163. package/dist/esm/core/crypto/publicKey.mjs.map +1 -0
  164. package/dist/esm/core/crypto/secp256k1.d.mts +43 -67
  165. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  166. package/dist/esm/core/crypto/signature.d.mts +28 -0
  167. package/dist/esm/core/crypto/signature.mjs +2 -0
  168. package/dist/esm/core/crypto/signature.mjs.map +1 -0
  169. package/dist/esm/core/crypto/singleKey.d.mts +68 -0
  170. package/dist/esm/core/crypto/singleKey.mjs +2 -0
  171. package/dist/esm/core/crypto/singleKey.mjs.map +1 -0
  172. package/dist/esm/core/index.d.mts +9 -8
  173. package/dist/esm/core/index.mjs +1 -1
  174. package/dist/esm/index.d.mts +9 -9
  175. package/dist/esm/index.mjs +1 -1
  176. package/dist/esm/internal/account.d.mts +9 -3
  177. package/dist/esm/internal/account.mjs +1 -1
  178. package/dist/esm/internal/ans.d.mts +10 -11
  179. package/dist/esm/internal/ans.mjs +1 -1
  180. package/dist/esm/internal/coin.d.mts +9 -9
  181. package/dist/esm/internal/coin.mjs +1 -1
  182. package/dist/esm/internal/digitalAsset.d.mts +15 -12
  183. package/dist/esm/internal/digitalAsset.mjs +1 -1
  184. package/dist/esm/internal/event.d.mts +7 -2
  185. package/dist/esm/internal/event.mjs +1 -1
  186. package/dist/esm/internal/faucet.d.mts +1 -1
  187. package/dist/esm/internal/faucet.mjs +1 -1
  188. package/dist/esm/internal/fungibleAsset.d.mts +9 -10
  189. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  190. package/dist/esm/internal/general.mjs +1 -1
  191. package/dist/esm/internal/staking.d.mts +1 -1
  192. package/dist/esm/internal/staking.mjs +1 -1
  193. package/dist/esm/internal/transaction.mjs +1 -1
  194. package/dist/esm/internal/transactionSubmission.d.mts +10 -11
  195. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  196. package/dist/esm/publicKey-lq5djCIY.d.mts +113 -0
  197. package/dist/esm/transactions/authenticator/account.d.mts +6 -4
  198. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  199. package/dist/esm/transactions/authenticator/index.d.mts +6 -6
  200. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  201. package/dist/esm/transactions/authenticator/transaction.d.mts +5 -5
  202. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  203. package/dist/esm/transactions/index.d.mts +6 -7
  204. package/dist/esm/transactions/index.mjs +1 -1
  205. package/dist/esm/transactions/instances/index.d.mts +4 -4
  206. package/dist/esm/transactions/instances/index.mjs +1 -1
  207. package/dist/esm/transactions/instances/moduleId.d.mts +1 -1
  208. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  209. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  210. package/dist/esm/transactions/instances/rotationProofChallenge.d.mts +2 -1
  211. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  212. package/dist/esm/transactions/instances/signedTransaction.d.mts +8 -8
  213. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  214. package/dist/esm/transactions/instances/transactionPayload.d.mts +1 -1
  215. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  216. package/dist/esm/transactions/management/accountSequenceNumber.d.mts +11 -5
  217. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  218. package/dist/esm/transactions/management/index.d.mts +11 -12
  219. package/dist/esm/transactions/management/index.mjs +1 -1
  220. package/dist/esm/transactions/management/transactionWorker.d.mts +11 -12
  221. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  222. package/dist/esm/transactions/transactionBuilder/helpers.d.mts +10 -10
  223. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  224. package/dist/esm/transactions/transactionBuilder/index.d.mts +9 -10
  225. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  226. package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +8 -8
  227. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  228. package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +9 -10
  229. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  230. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  231. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  232. package/dist/esm/transactions/types.d.mts +9 -9
  233. package/dist/esm/types/generated/operations.d.mts +6 -0
  234. package/dist/esm/types/generated/queries.d.mts +6 -6
  235. package/dist/esm/types/generated/queries.mjs +1 -1
  236. package/dist/esm/types/generated/types.d.mts +594 -56
  237. package/dist/esm/types/generated/types.mjs +1 -1
  238. package/dist/esm/types/generated/types.mjs.map +1 -1
  239. package/dist/esm/types/index.d.mts +35 -6
  240. package/dist/esm/types/index.mjs +1 -1
  241. package/dist/esm/utils/const.d.mts +1 -2
  242. package/dist/esm/utils/const.mjs +1 -1
  243. package/dist/esm/utils/index.d.mts +1 -1
  244. package/dist/esm/utils/index.mjs +1 -1
  245. package/dist/esm/version.d.mts +1 -1
  246. package/dist/esm/version.mjs +1 -1
  247. package/package.json +16 -16
  248. package/src/api/aptosConfig.ts +2 -2
  249. package/src/api/digitalAsset.ts +20 -0
  250. package/src/api/event.ts +27 -1
  251. package/src/core/account/Account.ts +245 -0
  252. package/src/core/account/Ed25519Account.ts +88 -0
  253. package/src/core/account/SingleKeyAccount.ts +120 -0
  254. package/src/core/account/index.ts +3 -0
  255. package/src/core/authenticationKey.ts +18 -52
  256. package/src/core/crypto/ed25519.ts +118 -104
  257. package/src/core/crypto/index.ts +6 -5
  258. package/src/core/crypto/multiEd25519.ts +98 -44
  259. package/src/core/crypto/multiKey.ts +192 -34
  260. package/src/core/crypto/privateKey.ts +25 -0
  261. package/src/core/crypto/publicKey.ts +52 -0
  262. package/src/core/crypto/secp256k1.ts +108 -111
  263. package/src/core/crypto/signature.ts +46 -0
  264. package/src/core/crypto/singleKey.ts +180 -0
  265. package/src/internal/account.ts +5 -3
  266. package/src/internal/digitalAsset.ts +26 -0
  267. package/src/internal/event.ts +33 -1
  268. package/src/internal/queries/currentTokenOwnershipFieldsFragment.graphql +1 -0
  269. package/src/internal/queries/getTokenData.graphql +1 -0
  270. package/src/transactions/authenticator/account.ts +1 -2
  271. package/src/transactions/instances/rotationProofChallenge.ts +1 -1
  272. package/src/transactions/transactionBuilder/transactionBuilder.ts +3 -21
  273. package/src/transactions/types.ts +1 -1
  274. package/src/types/generated/operations.ts +6 -0
  275. package/src/types/generated/queries.ts +2 -0
  276. package/src/types/generated/types.ts +662 -55
  277. package/src/types/index.ts +40 -4
  278. package/src/utils/const.ts +0 -4
  279. package/src/version.ts +1 -1
  280. package/dist/esm/chunk-2QV6HI3M.mjs +0 -2
  281. package/dist/esm/chunk-2QV6HI3M.mjs.map +0 -1
  282. package/dist/esm/chunk-3UYBNX3P.mjs +0 -2
  283. package/dist/esm/chunk-4SAUEZTN.mjs +0 -2
  284. package/dist/esm/chunk-4SAUEZTN.mjs.map +0 -1
  285. package/dist/esm/chunk-6UNBJAV6.mjs.map +0 -1
  286. package/dist/esm/chunk-7IGH7N52.mjs +0 -2
  287. package/dist/esm/chunk-7IGH7N52.mjs.map +0 -1
  288. package/dist/esm/chunk-A2QH4A6D.mjs +0 -2
  289. package/dist/esm/chunk-AA3GRJNL.mjs +0 -2
  290. package/dist/esm/chunk-AA3GRJNL.mjs.map +0 -1
  291. package/dist/esm/chunk-ALFESCPU.mjs +0 -2
  292. package/dist/esm/chunk-ALFESCPU.mjs.map +0 -1
  293. package/dist/esm/chunk-BQSE5HHW.mjs.map +0 -1
  294. package/dist/esm/chunk-CCUD52OF.mjs +0 -2
  295. package/dist/esm/chunk-CCUD52OF.mjs.map +0 -1
  296. package/dist/esm/chunk-ERWQOVBF.mjs +0 -2
  297. package/dist/esm/chunk-ERWQOVBF.mjs.map +0 -1
  298. package/dist/esm/chunk-FBFMQZTM.mjs +0 -2
  299. package/dist/esm/chunk-FBFMQZTM.mjs.map +0 -1
  300. package/dist/esm/chunk-FP5DPRYL.mjs +0 -2
  301. package/dist/esm/chunk-FP5DPRYL.mjs.map +0 -1
  302. package/dist/esm/chunk-HHJBCGAQ.mjs +0 -2
  303. package/dist/esm/chunk-HHJBCGAQ.mjs.map +0 -1
  304. package/dist/esm/chunk-I7WRJY7K.mjs +0 -2
  305. package/dist/esm/chunk-I7WRJY7K.mjs.map +0 -1
  306. package/dist/esm/chunk-INV6U3KS.mjs +0 -2
  307. package/dist/esm/chunk-INV6U3KS.mjs.map +0 -1
  308. package/dist/esm/chunk-O57QZZF2.mjs.map +0 -1
  309. package/dist/esm/chunk-SBMJNU2O.mjs +0 -2
  310. package/dist/esm/chunk-SBMJNU2O.mjs.map +0 -1
  311. package/dist/esm/chunk-SZYATFM7.mjs +0 -2
  312. package/dist/esm/chunk-SZYATFM7.mjs.map +0 -1
  313. package/dist/esm/chunk-UCHGKGCF.mjs +0 -2
  314. package/dist/esm/chunk-UCHGKGCF.mjs.map +0 -1
  315. package/dist/esm/chunk-UIVJXLRM.mjs +0 -1
  316. package/dist/esm/chunk-UJAX75ON.mjs +0 -2
  317. package/dist/esm/chunk-V6JFR2CB.mjs +0 -2
  318. package/dist/esm/chunk-V6JFR2CB.mjs.map +0 -1
  319. package/dist/esm/chunk-YGMT4GQ5.mjs.map +0 -1
  320. package/dist/esm/chunk-ZFIMVSCR.mjs +0 -2
  321. package/dist/esm/chunk-ZFIMVSCR.mjs.map +0 -1
  322. package/dist/esm/chunk-ZIZ7PVK2.mjs +0 -2
  323. package/dist/esm/chunk-ZIZ7PVK2.mjs.map +0 -1
  324. package/dist/esm/core/account.d.mts +0 -184
  325. package/dist/esm/core/account.mjs +0 -2
  326. package/dist/esm/core/crypto/anyPublicKey.d.mts +0 -59
  327. package/dist/esm/core/crypto/anyPublicKey.mjs +0 -2
  328. package/dist/esm/core/crypto/anySignature.d.mts +0 -31
  329. package/dist/esm/core/crypto/anySignature.mjs +0 -2
  330. package/dist/esm/core/crypto/asymmetricCrypto.d.mts +0 -74
  331. package/dist/esm/core/crypto/asymmetricCrypto.mjs +0 -2
  332. package/src/core/account.ts +0 -282
  333. package/src/core/crypto/anyPublicKey.ts +0 -92
  334. package/src/core/crypto/anySignature.ts +0 -56
  335. package/src/core/crypto/asymmetricCrypto.ts +0 -77
  336. /package/dist/esm/{chunk-RNO5ZG3C.mjs.map → chunk-52RTAMN7.mjs.map} +0 -0
  337. /package/dist/esm/{chunk-WQI2RH2S.mjs.map → chunk-7U36LMP4.mjs.map} +0 -0
  338. /package/dist/esm/{chunk-NWRKJFHV.mjs.map → chunk-ARIC32W7.mjs.map} +0 -0
  339. /package/dist/esm/{chunk-RIL4SHXC.mjs.map → chunk-B7M3OWHV.mjs.map} +0 -0
  340. /package/dist/esm/{chunk-C7ZX475J.mjs.map → chunk-BBUAAJRA.mjs.map} +0 -0
  341. /package/dist/esm/{chunk-DRF6AMEZ.mjs.map → chunk-CHA5DSSD.mjs.map} +0 -0
  342. /package/dist/esm/{chunk-IKCBGNRD.mjs.map → chunk-DGOT2VR5.mjs.map} +0 -0
  343. /package/dist/esm/{chunk-GVHOHNHT.mjs.map → chunk-EF2F7NWO.mjs.map} +0 -0
  344. /package/dist/esm/{chunk-J6RCCKOA.mjs.map → chunk-EQZ757ES.mjs.map} +0 -0
  345. /package/dist/esm/{chunk-CX5ULWJQ.mjs.map → chunk-F67Y7YH6.mjs.map} +0 -0
  346. /package/dist/esm/{chunk-JLL7BCD4.mjs.map → chunk-FVMVV4V3.mjs.map} +0 -0
  347. /package/dist/esm/{chunk-ESX5X52V.mjs.map → chunk-GQOOXOTN.mjs.map} +0 -0
  348. /package/dist/esm/{chunk-XQIWF5HY.mjs.map → chunk-I3TCHVQQ.mjs.map} +0 -0
  349. /package/dist/esm/{chunk-3NOQE6U3.mjs.map → chunk-ILJWEPDW.mjs.map} +0 -0
  350. /package/dist/esm/{chunk-5L6SRCJP.mjs.map → chunk-J6MWD4XN.mjs.map} +0 -0
  351. /package/dist/esm/{chunk-UIVJXLRM.mjs.map → chunk-KUX6GQ2E.mjs.map} +0 -0
  352. /package/dist/esm/{chunk-WK36MJRI.mjs.map → chunk-LLL2LFYH.mjs.map} +0 -0
  353. /package/dist/esm/{chunk-5WXR2O3T.mjs.map → chunk-N65SOKJQ.mjs.map} +0 -0
  354. /package/dist/esm/{chunk-XOBXX273.mjs.map → chunk-NL3XVNS5.mjs.map} +0 -0
  355. /package/dist/esm/{chunk-Q7JKS6WV.mjs.map → chunk-NURFZOR4.mjs.map} +0 -0
  356. /package/dist/esm/{chunk-MKERJNYN.mjs.map → chunk-OG56TYZE.mjs.map} +0 -0
  357. /package/dist/esm/{core/account.mjs.map → chunk-QE4ASJ5K.mjs.map} +0 -0
  358. /package/dist/esm/{chunk-TVURQPLA.mjs.map → chunk-R4VJDSIP.mjs.map} +0 -0
  359. /package/dist/esm/{chunk-Z6XNTGNK.mjs.map → chunk-TN5BUH4F.mjs.map} +0 -0
  360. /package/dist/esm/{chunk-YE3DZD6T.mjs.map → chunk-UIUSDBCL.mjs.map} +0 -0
  361. /package/dist/esm/{chunk-7JTOGYO7.mjs.map → chunk-UMLDKLDL.mjs.map} +0 -0
  362. /package/dist/esm/{core/crypto/anyPublicKey.mjs.map → chunk-UVSRX4SV.mjs.map} +0 -0
  363. /package/dist/esm/{chunk-6Y3VBRMN.mjs.map → chunk-VEVBHH3M.mjs.map} +0 -0
  364. /package/dist/esm/{chunk-T5IFXLOP.mjs.map → chunk-VMXBMAYK.mjs.map} +0 -0
  365. /package/dist/esm/{chunk-WC2WSKYZ.mjs.map → chunk-X5C3LYI7.mjs.map} +0 -0
  366. /package/dist/esm/{chunk-OWZLBIDD.mjs.map → chunk-XTPFQ4MH.mjs.map} +0 -0
  367. /package/dist/esm/{chunk-D2GNCG27.mjs.map → chunk-Y5AJLNUD.mjs.map} +0 -0
  368. /package/dist/esm/{chunk-ZFPA45OK.mjs.map → chunk-YR2R3LW4.mjs.map} +0 -0
  369. /package/dist/esm/core/{crypto/anySignature.mjs.map → account/Account.mjs.map} +0 -0
  370. /package/dist/esm/core/{crypto/asymmetricCrypto.mjs.map → account/Ed25519Account.mjs.map} +0 -0
@@ -0,0 +1,120 @@
1
+ import { AccountAuthenticatorSingleKey } from "../../transactions/authenticator/account";
2
+ import { type HexInput, SigningScheme, SigningSchemeInput } from "../../types";
3
+ import { AccountAddress, AccountAddressInput } from "../accountAddress";
4
+ import { AnyPublicKey, AnySignature, Ed25519PrivateKey, PrivateKey, Secp256k1PrivateKey } from "../crypto";
5
+ import type { Account } from "./Account";
6
+
7
+ export interface SingleKeySignerConstructorArgs {
8
+ privateKey: PrivateKey;
9
+ address?: AccountAddressInput;
10
+ }
11
+
12
+ export interface SingleKeySignerGenerateArgs {
13
+ scheme?: SigningSchemeInput;
14
+ }
15
+
16
+ export type SingleKeySignerFromDerivationPathArgs = SingleKeySignerGenerateArgs & {
17
+ path: string;
18
+ mnemonic: string;
19
+ };
20
+
21
+ export interface VerifySingleKeySignatureArgs {
22
+ message: HexInput;
23
+ signature: AnySignature;
24
+ }
25
+
26
+ /**
27
+ * Signer implementation for the SingleKey authentication scheme.
28
+ * This extends a SingleKeyAccount by adding signing capabilities through a valid private key.
29
+ * Currently, the only supported signature schemes are Ed25519 and Secp256k1.
30
+ *
31
+ * Note: Generating a signer instance does not create the account on-chain.
32
+ */
33
+ export class SingleKeyAccount implements Account {
34
+ /**
35
+ * Private key associated with the account
36
+ */
37
+ readonly privateKey: PrivateKey;
38
+
39
+ readonly publicKey: AnyPublicKey;
40
+
41
+ readonly accountAddress: AccountAddress;
42
+
43
+ readonly signingScheme = SigningScheme.SingleKey;
44
+
45
+ // region Constructors
46
+
47
+ constructor(args: SingleKeySignerConstructorArgs) {
48
+ const { privateKey, address } = args;
49
+ this.privateKey = privateKey;
50
+ this.publicKey = new AnyPublicKey(privateKey.publicKey());
51
+ this.accountAddress = address ? AccountAddress.from(address) : this.publicKey.authKey().derivedAddress();
52
+ }
53
+
54
+ /**
55
+ * Derives an account from a randomly generated private key.
56
+ * Default generation is using an Ed25519 key
57
+ * @returns Account with the given signature scheme
58
+ */
59
+ static generate(args: SingleKeySignerGenerateArgs = {}) {
60
+ const { scheme = SigningSchemeInput.Ed25519 } = args;
61
+ let privateKey: PrivateKey;
62
+ switch (scheme) {
63
+ case SigningSchemeInput.Ed25519:
64
+ privateKey = Ed25519PrivateKey.generate();
65
+ break;
66
+ case SigningSchemeInput.Secp256k1Ecdsa:
67
+ privateKey = Secp256k1PrivateKey.generate();
68
+ break;
69
+ default:
70
+ throw new Error(`Unsupported signature scheme ${scheme}`);
71
+ }
72
+ return new SingleKeyAccount({ privateKey });
73
+ }
74
+
75
+ /**
76
+ * Derives an account with bip44 path and mnemonics,
77
+ * Default to using an Ed25519 signature scheme.
78
+ *
79
+ * @param args.scheme The signature scheme to derive the private key with
80
+ * @param args.path the BIP44 derive hardened path (e.g. m/44'/637'/0'/0'/0') for Ed25519,
81
+ * or non-hardened path (e.g. m/44'/637'/0'/0/0) for secp256k1
82
+ * Detailed description: {@link https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki}
83
+ * @param args.mnemonic the mnemonic seed phrase of the account
84
+ */
85
+ static fromDerivationPath(args: SingleKeySignerFromDerivationPathArgs) {
86
+ const { scheme = SigningSchemeInput.Ed25519, path, mnemonic } = args;
87
+ let privateKey: PrivateKey;
88
+ switch (scheme) {
89
+ case SigningSchemeInput.Ed25519:
90
+ privateKey = Ed25519PrivateKey.fromDerivationPath(path, mnemonic);
91
+ break;
92
+ case SigningSchemeInput.Secp256k1Ecdsa:
93
+ privateKey = Secp256k1PrivateKey.fromDerivationPath(path, mnemonic);
94
+ break;
95
+ default:
96
+ throw new Error(`Unsupported signature scheme ${scheme}`);
97
+ }
98
+ return new SingleKeyAccount({ privateKey });
99
+ }
100
+
101
+ // endregion
102
+
103
+ // region Account
104
+
105
+ verifySignature(args: VerifySingleKeySignatureArgs): boolean {
106
+ return this.publicKey.verifySignature(args);
107
+ }
108
+
109
+ signWithAuthenticator(message: HexInput) {
110
+ const innerSignature = this.privateKey.sign(message);
111
+ const signature = new AnySignature(innerSignature);
112
+ return new AccountAuthenticatorSingleKey(this.publicKey, signature);
113
+ }
114
+
115
+ sign(message: HexInput) {
116
+ return this.signWithAuthenticator(message).signature;
117
+ }
118
+
119
+ // endregion
120
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./Ed25519Account";
2
+ export * from "./Account";
3
+ export * from "./SingleKeyAccount";
@@ -3,13 +3,9 @@
3
3
 
4
4
  import { sha3_256 as sha3Hash } from "@noble/hashes/sha3";
5
5
  import { AccountAddress } from "./accountAddress";
6
- import { PublicKey } from "./crypto/asymmetricCrypto";
7
- import { Ed25519PublicKey } from "./crypto/ed25519";
8
- import { MultiEd25519PublicKey } from "./crypto/multiEd25519";
6
+ import type { AccountPublicKey } from "./crypto";
9
7
  import { Hex } from "./hex";
10
- import { AuthenticationKeyScheme, HexInput, SigningScheme } from "../types";
11
- import { AnyPublicKey } from "./crypto/anyPublicKey";
12
- import { MultiKey } from "./crypto/multiKey";
8
+ import { AuthenticationKeyScheme, HexInput } from "../types";
13
9
  import { Serializable, Serializer } from "../bcs/serializer";
14
10
  import { Deserializer } from "../bcs/deserializer";
15
11
 
@@ -65,41 +61,27 @@ export class AuthenticationKey extends Serializable {
65
61
  return this.data.toUint8Array();
66
62
  }
67
63
 
64
+ static fromSchemeAndBytes(args: { scheme: AuthenticationKeyScheme; input: HexInput }): AuthenticationKey {
65
+ const { scheme, input } = args;
66
+ const inputBytes = Hex.fromHexInput(input).toUint8Array();
67
+ const hashInput = new Uint8Array([...inputBytes, scheme]);
68
+ const hash = sha3Hash.create();
69
+ hash.update(hashInput);
70
+ const hashDigest = hash.digest();
71
+ return new AuthenticationKey({ data: hashDigest });
72
+ }
73
+
68
74
  /**
75
+ * @deprecated Use `fromPublicKey` instead
69
76
  * Derives an AuthenticationKey from the public key seed bytes and an explicit derivation scheme.
70
77
  *
71
78
  * This facilitates targeting a specific scheme for deriving an authentication key from a public key.
72
79
  *
73
80
  * @param args - the public key and scheme to use for the derivation
74
81
  */
75
- public static fromPublicKeyAndScheme(args: { publicKey: PublicKey; scheme: AuthenticationKeyScheme }) {
76
- const { publicKey, scheme } = args;
77
- let authKeyBytes: Uint8Array;
78
-
79
- switch (scheme) {
80
- case SigningScheme.MultiKey:
81
- case SigningScheme.SingleKey: {
82
- const singleKeyBytes = publicKey.bcsToBytes();
83
- authKeyBytes = new Uint8Array([...singleKeyBytes, scheme]);
84
- break;
85
- }
86
-
87
- case SigningScheme.Ed25519:
88
- case SigningScheme.MultiEd25519: {
89
- const ed25519PublicKeyBytes = publicKey.toUint8Array();
90
- const inputBytes = Hex.fromHexInput(ed25519PublicKeyBytes).toUint8Array();
91
- authKeyBytes = new Uint8Array([...inputBytes, scheme]);
92
- break;
93
- }
94
-
95
- default:
96
- throw new Error(`Scheme ${scheme} is not supported`);
97
- }
98
-
99
- const hash = sha3Hash.create();
100
- hash.update(authKeyBytes);
101
- const hashDigest = hash.digest();
102
- return new AuthenticationKey({ data: hashDigest });
82
+ public static fromPublicKeyAndScheme(args: { publicKey: AccountPublicKey; scheme: AuthenticationKeyScheme }) {
83
+ const { publicKey } = args;
84
+ return publicKey.authKey();
103
85
  }
104
86
 
105
87
  /**
@@ -109,25 +91,9 @@ export class AuthenticationKey extends Serializable {
109
91
  * @param args.publicKey
110
92
  * @returns AuthenticationKey
111
93
  */
112
- static fromPublicKey(args: { publicKey: PublicKey }): AuthenticationKey {
94
+ static fromPublicKey(args: { publicKey: AccountPublicKey }): AuthenticationKey {
113
95
  const { publicKey } = args;
114
-
115
- let scheme: number;
116
- if (publicKey instanceof Ed25519PublicKey) {
117
- // for legacy support
118
- scheme = SigningScheme.Ed25519.valueOf();
119
- } else if (publicKey instanceof MultiEd25519PublicKey) {
120
- // for legacy support
121
- scheme = SigningScheme.MultiEd25519.valueOf();
122
- } else if (publicKey instanceof AnyPublicKey) {
123
- scheme = SigningScheme.SingleKey.valueOf();
124
- } else if (publicKey instanceof MultiKey) {
125
- scheme = SigningScheme.MultiKey.valueOf();
126
- } else {
127
- throw new Error("No supported authentication scheme for public key");
128
- }
129
-
130
- return AuthenticationKey.fromPublicKeyAndScheme({ publicKey, scheme });
96
+ return publicKey.authKey();
131
97
  }
132
98
 
133
99
  /**
@@ -2,12 +2,15 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import nacl from "tweetnacl";
5
- import { PublicKey, PrivateKey, Signature } from "./asymmetricCrypto";
6
5
  import { Deserializer } from "../../bcs/deserializer";
7
- import { Serializer } from "../../bcs/serializer";
6
+ import { Serializable, Serializer } from "../../bcs/serializer";
7
+ import { AuthenticationKey } from "../authenticationKey";
8
8
  import { Hex } from "../hex";
9
- import { HexInput } from "../../types";
9
+ import { HexInput, SigningScheme as AuthenticationKeyScheme } from "../../types";
10
10
  import { CKDPriv, deriveKey, HARDENED_OFFSET, isValidHardenedPath, mnemonicToSeed, splitPath } from "./hdKey";
11
+ import { PrivateKey } from "./privateKey";
12
+ import { AccountPublicKey, VerifySignatureArgs } from "./publicKey";
13
+ import { Signature } from "./signature";
11
14
 
12
15
  /**
13
16
  * Represents the public key of an Ed25519 key pair.
@@ -18,7 +21,7 @@ import { CKDPriv, deriveKey, HARDENED_OFFSET, isValidHardenedPath, mnemonicToSee
18
21
  * Ed25519 scheme is represented in the SDK as `Legacy authentication key` and also
19
22
  * as `AnyPublicKey` that represents any `Unified authentication key`
20
23
  */
21
- export class Ed25519PublicKey extends PublicKey {
24
+ export class Ed25519PublicKey extends AccountPublicKey {
22
25
  /**
23
26
  * Length of an Ed25519 public key
24
27
  */
@@ -45,6 +48,32 @@ export class Ed25519PublicKey extends PublicKey {
45
48
  this.key = hex;
46
49
  }
47
50
 
51
+ // region AccountPublicKey
52
+
53
+ /**
54
+ * Verifies a signed data with a public key
55
+ * @param args.message a signed message
56
+ * @param args.signature the signature of the message
57
+ */
58
+ verifySignature(args: VerifySignatureArgs): boolean {
59
+ const { message, signature } = args;
60
+ if (!(signature instanceof Ed25519Signature)) {
61
+ return false;
62
+ }
63
+
64
+ const messageBytes = Hex.fromHexInput(message).toUint8Array();
65
+ const signatureBytes = signature.toUint8Array();
66
+ const publicKeyBytes = this.key.toUint8Array();
67
+ return nacl.sign.detached.verify(messageBytes, signatureBytes, publicKeyBytes);
68
+ }
69
+
70
+ authKey(): AuthenticationKey {
71
+ return AuthenticationKey.fromSchemeAndBytes({
72
+ scheme: AuthenticationKeyScheme.Ed25519,
73
+ input: this.toUint8Array(),
74
+ });
75
+ }
76
+
48
77
  /**
49
78
  * Get the public key in bytes (Uint8Array).
50
79
  *
@@ -54,26 +83,9 @@ export class Ed25519PublicKey extends PublicKey {
54
83
  return this.key.toUint8Array();
55
84
  }
56
85
 
57
- /**
58
- * Get the public key as a hex string with the 0x prefix.
59
- *
60
- * @returns string representation of the public key
61
- */
62
- toString(): string {
63
- return this.key.toString();
64
- }
86
+ // endregion
65
87
 
66
- /**
67
- * Verifies a signed data with a public key
68
- * @param args.message a signed message
69
- * @param args.signature the signature of the message
70
- */
71
- verifySignature(args: { message: HexInput; signature: Ed25519Signature }): boolean {
72
- const { message, signature } = args;
73
- const rawMessage = Hex.fromHexInput(message).toUint8Array();
74
- const rawSignature = signature.toUint8Array();
75
- return nacl.sign.detached.verify(rawMessage, rawSignature, this.key.toUint8Array());
76
- }
88
+ // region Serializable
77
89
 
78
90
  serialize(serializer: Serializer): void {
79
91
  serializer.serializeBytes(this.key.toUint8Array());
@@ -84,13 +96,12 @@ export class Ed25519PublicKey extends PublicKey {
84
96
  return new Ed25519PublicKey(bytes);
85
97
  }
86
98
 
87
- static load(deserializer: Deserializer): Ed25519PublicKey {
88
- const bytes = deserializer.deserializeBytes();
89
- return new Ed25519PublicKey(bytes);
90
- }
99
+ // endregion
91
100
 
92
- // TODO(greg): Currently, we can't put this on the abstract type, because of a circular dependency
93
- static isPublicKey(publicKey: PublicKey): publicKey is Ed25519PublicKey {
101
+ /**
102
+ * @deprecated use `instanceof Ed25519PublicKey` instead.
103
+ */
104
+ static isPublicKey(publicKey: AccountPublicKey): publicKey is Ed25519PublicKey {
94
105
  return publicKey instanceof Ed25519PublicKey;
95
106
  }
96
107
  }
@@ -98,7 +109,7 @@ export class Ed25519PublicKey extends PublicKey {
98
109
  /**
99
110
  * Represents the private key of an Ed25519 key pair.
100
111
  */
101
- export class Ed25519PrivateKey extends PrivateKey {
112
+ export class Ed25519PrivateKey extends Serializable implements PrivateKey {
102
113
  /**
103
114
  * Length of an Ed25519 private key
104
115
  */
@@ -116,6 +127,8 @@ export class Ed25519PrivateKey extends PrivateKey {
116
127
  */
117
128
  private readonly signingKeyPair: nacl.SignKeyPair;
118
129
 
130
+ // region Constructors
131
+
119
132
  /**
120
133
  * Create a new PrivateKey instance from a Uint8Array or String.
121
134
  *
@@ -133,45 +146,6 @@ export class Ed25519PrivateKey extends PrivateKey {
133
146
  this.signingKeyPair = nacl.sign.keyPair.fromSeed(privateKeyHex.toUint8Array().slice(0, Ed25519PrivateKey.LENGTH));
134
147
  }
135
148
 
136
- /**
137
- * Get the private key in bytes (Uint8Array).
138
- *
139
- * @returns Uint8Array representation of the private key
140
- */
141
- toUint8Array(): Uint8Array {
142
- return this.signingKeyPair.secretKey.slice(0, Ed25519PrivateKey.LENGTH);
143
- }
144
-
145
- /**
146
- * Get the private key as a hex string with the 0x prefix.
147
- *
148
- * @returns string representation of the private key
149
- */
150
- toString(): string {
151
- return Hex.fromHexInput(this.toUint8Array()).toString();
152
- }
153
-
154
- /**
155
- * Sign the given message with the private key.
156
- *
157
- * @param message in HexInput format
158
- * @returns Signature
159
- */
160
- sign(message: HexInput): Ed25519Signature {
161
- const hex = Hex.fromHexInput(message);
162
- const signature = nacl.sign.detached(hex.toUint8Array(), this.signingKeyPair.secretKey);
163
- return new Ed25519Signature(signature);
164
- }
165
-
166
- serialize(serializer: Serializer): void {
167
- serializer.serializeBytes(this.toUint8Array());
168
- }
169
-
170
- static deserialize(deserializer: Deserializer): Ed25519PrivateKey {
171
- const bytes = deserializer.deserializeBytes();
172
- return new Ed25519PrivateKey(bytes);
173
- }
174
-
175
149
  /**
176
150
  * Generate a new random private key.
177
151
  *
@@ -182,16 +156,6 @@ export class Ed25519PrivateKey extends PrivateKey {
182
156
  return new Ed25519PrivateKey(keyPair.secretKey.slice(0, Ed25519PrivateKey.LENGTH));
183
157
  }
184
158
 
185
- /**
186
- * Derive the Ed25519PublicKey for this private key.
187
- *
188
- * @returns Ed25519PublicKey
189
- */
190
- publicKey(): Ed25519PublicKey {
191
- const bytes = this.signingKeyPair.publicKey;
192
- return new Ed25519PublicKey(bytes);
193
- }
194
-
195
159
  /**
196
160
  * Derives a private key from a mnemonic seed phrase.
197
161
  *
@@ -232,6 +196,68 @@ export class Ed25519PrivateKey extends PrivateKey {
232
196
  return new Ed25519PrivateKey(privateKey);
233
197
  }
234
198
 
199
+ // endregion
200
+
201
+ // region PrivateKey
202
+
203
+ /**
204
+ * Derive the Ed25519PublicKey for this private key.
205
+ *
206
+ * @returns Ed25519PublicKey
207
+ */
208
+ publicKey(): Ed25519PublicKey {
209
+ const bytes = this.signingKeyPair.publicKey;
210
+ return new Ed25519PublicKey(bytes);
211
+ }
212
+
213
+ /**
214
+ * Sign the given message with the private key.
215
+ *
216
+ * @param message in HexInput format
217
+ * @returns Signature
218
+ */
219
+ sign(message: HexInput): Ed25519Signature {
220
+ const messageBytes = Hex.fromHexInput(message).toUint8Array();
221
+ const signatureBytes = nacl.sign.detached(messageBytes, this.signingKeyPair.secretKey);
222
+ return new Ed25519Signature(signatureBytes);
223
+ }
224
+
225
+ /**
226
+ * Get the private key in bytes (Uint8Array).
227
+ *
228
+ * @returns Uint8Array representation of the private key
229
+ */
230
+ toUint8Array(): Uint8Array {
231
+ return this.signingKeyPair.secretKey.slice(0, Ed25519PrivateKey.LENGTH);
232
+ }
233
+
234
+ /**
235
+ * Get the private key as a hex string with the 0x prefix.
236
+ *
237
+ * @returns string representation of the private key
238
+ */
239
+ toString(): string {
240
+ return Hex.fromHexInput(this.toUint8Array()).toString();
241
+ }
242
+
243
+ // endregion
244
+
245
+ // region Serializable
246
+
247
+ serialize(serializer: Serializer): void {
248
+ serializer.serializeBytes(this.toUint8Array());
249
+ }
250
+
251
+ static deserialize(deserializer: Deserializer): Ed25519PrivateKey {
252
+ const bytes = deserializer.deserializeBytes();
253
+ return new Ed25519PrivateKey(bytes);
254
+ }
255
+
256
+ // endregion
257
+
258
+ /**
259
+ * @deprecated use `instanceof Ed25519PrivateKey` instead.
260
+ */
235
261
  static isPrivateKey(privateKey: PrivateKey): privateKey is Ed25519PrivateKey {
236
262
  return privateKey instanceof Ed25519PrivateKey;
237
263
  }
@@ -252,33 +278,28 @@ export class Ed25519Signature extends Signature {
252
278
  */
253
279
  private readonly data: Hex;
254
280
 
281
+ // region Constructors
282
+
255
283
  constructor(hexInput: HexInput) {
256
284
  super();
257
- const hex = Hex.fromHexInput(hexInput);
258
- if (hex.toUint8Array().length !== Ed25519Signature.LENGTH) {
285
+ const data = Hex.fromHexInput(hexInput);
286
+ if (data.toUint8Array().length !== Ed25519Signature.LENGTH) {
259
287
  throw new Error(`Signature length should be ${Ed25519Signature.LENGTH}`);
260
288
  }
261
-
262
- this.data = hex;
289
+ this.data = data;
263
290
  }
264
291
 
265
- /**
266
- * Get the signature in bytes (Uint8Array).
267
- *
268
- * @returns Uint8Array representation of the signature
269
- */
292
+ // endregion
293
+
294
+ // region Signature
295
+
270
296
  toUint8Array(): Uint8Array {
271
297
  return this.data.toUint8Array();
272
298
  }
273
299
 
274
- /**
275
- * Get the signature as a hex string with the 0x prefix.
276
- *
277
- * @returns string representation of the signature
278
- */
279
- toString(): string {
280
- return this.data.toString();
281
- }
300
+ // endregion
301
+
302
+ // region Serializable
282
303
 
283
304
  serialize(serializer: Serializer): void {
284
305
  serializer.serializeBytes(this.data.toUint8Array());
@@ -289,12 +310,5 @@ export class Ed25519Signature extends Signature {
289
310
  return new Ed25519Signature(bytes);
290
311
  }
291
312
 
292
- static load(deserializer: Deserializer): Ed25519Signature {
293
- const bytes = deserializer.deserializeBytes();
294
- return new Ed25519Signature(bytes);
295
- }
296
-
297
- static isSignature(signature: Signature): signature is Ed25519Signature {
298
- return signature instanceof Ed25519Signature;
299
- }
313
+ // endregion
300
314
  }
@@ -1,11 +1,12 @@
1
1
  // Copyright © Aptos Foundation
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- export * from "./asymmetricCrypto";
5
4
  export * from "./ed25519";
5
+ export * from "./hdKey";
6
6
  export * from "./multiEd25519";
7
- export * from "./secp256k1";
8
7
  export * from "./multiKey";
9
- export * from "./hdKey";
10
- export * from "./anyPublicKey";
11
- export * from "./anySignature";
8
+ export * from "./privateKey";
9
+ export * from "./publicKey";
10
+ export * from "./secp256k1";
11
+ export * from "./signature";
12
+ export * from "./singleKey";