@aptos-labs/ts-sdk 5.0.0 → 5.1.1-side-effect-free.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 (547) hide show
  1. package/dist/common/{account-BDwBREvt.d.ts → account-Dr4y1uZG.d.ts} +8 -2
  2. package/dist/common/chunk-AWFAHZSB.js +4 -0
  3. package/dist/common/{chunk-6MMUUJHX.js.map → chunk-AWFAHZSB.js.map} +1 -1
  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 +339 -10
  8. package/dist/common/index.js +33 -33
  9. package/dist/common/index.js.map +1 -1
  10. package/dist/esm/{Ed25519Account-8ETkcAk_.d.mts → Ed25519Account-CPwej6wB.d.mts} +1 -1
  11. package/dist/esm/account/AbstractKeylessAccount.d.mts +3 -3
  12. package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
  13. package/dist/esm/account/AbstractKeylessAccount.mjs.map +1 -1
  14. package/dist/esm/account/AbstractedAccount.d.mts +2 -2
  15. package/dist/esm/account/AbstractedAccount.mjs +1 -1
  16. package/dist/esm/account/AbstractedAccount.mjs.map +1 -1
  17. package/dist/esm/account/Account.d.mts +2 -2
  18. package/dist/esm/account/Account.mjs +1 -1
  19. package/dist/esm/account/Account.mjs.map +1 -1
  20. package/dist/esm/account/AccountUtils.d.mts +3 -3
  21. package/dist/esm/account/AccountUtils.mjs +1 -1
  22. package/dist/esm/account/AccountUtils.mjs.map +1 -1
  23. package/dist/esm/account/DerivableAbstractedAccount.d.mts +2 -2
  24. package/dist/esm/account/DerivableAbstractedAccount.mjs +1 -1
  25. package/dist/esm/account/DerivableAbstractedAccount.mjs.map +1 -1
  26. package/dist/esm/account/Ed25519Account.d.mts +2 -2
  27. package/dist/esm/account/Ed25519Account.mjs +1 -1
  28. package/dist/esm/account/Ed25519Account.mjs.map +1 -1
  29. package/dist/esm/account/EphemeralKeyPair.d.mts +1 -1
  30. package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
  31. package/dist/esm/account/EphemeralKeyPair.mjs.map +1 -1
  32. package/dist/esm/account/FederatedKeylessAccount.d.mts +3 -3
  33. package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
  34. package/dist/esm/account/FederatedKeylessAccount.mjs.map +1 -1
  35. package/dist/esm/account/KeylessAccount.d.mts +3 -3
  36. package/dist/esm/account/KeylessAccount.mjs +1 -1
  37. package/dist/esm/account/KeylessAccount.mjs.map +1 -1
  38. package/dist/esm/account/MultiEd25519Account.d.mts +2 -2
  39. package/dist/esm/account/MultiEd25519Account.mjs +1 -1
  40. package/dist/esm/account/MultiEd25519Account.mjs.map +1 -1
  41. package/dist/esm/account/MultiKeyAccount.d.mts +3 -3
  42. package/dist/esm/account/MultiKeyAccount.mjs +1 -1
  43. package/dist/esm/account/MultiKeyAccount.mjs.map +1 -1
  44. package/dist/esm/account/SingleKeyAccount.d.mts +2 -2
  45. package/dist/esm/account/SingleKeyAccount.mjs +1 -1
  46. package/dist/esm/account/SingleKeyAccount.mjs.map +1 -1
  47. package/dist/esm/account/index.d.mts +3 -3
  48. package/dist/esm/account/index.mjs +1 -1
  49. package/dist/esm/account/index.mjs.map +1 -1
  50. package/dist/esm/account/utils.d.mts +1 -1
  51. package/dist/esm/account/utils.mjs +1 -1
  52. package/dist/esm/account/utils.mjs.map +1 -1
  53. package/dist/esm/{account-ClxOwjdh.d.mts → account-BortO8g2.d.mts} +6 -1
  54. package/dist/esm/api/account/abstraction.d.mts +1 -1
  55. package/dist/esm/api/account/abstraction.mjs +1 -1
  56. package/dist/esm/api/account/abstraction.mjs.map +1 -1
  57. package/dist/esm/api/account.d.mts +30 -9
  58. package/dist/esm/api/account.mjs +1 -1
  59. package/dist/esm/api/account.mjs.map +1 -1
  60. package/dist/esm/api/ans.d.mts +2 -2
  61. package/dist/esm/api/ans.mjs +1 -1
  62. package/dist/esm/api/ans.mjs.map +1 -1
  63. package/dist/esm/api/aptos.d.mts +3 -3
  64. package/dist/esm/api/aptos.mjs +1 -1
  65. package/dist/esm/api/aptos.mjs.map +1 -1
  66. package/dist/esm/api/aptosConfig.d.mts +1 -1
  67. package/dist/esm/api/aptosConfig.mjs +1 -1
  68. package/dist/esm/api/aptosConfig.mjs.map +1 -1
  69. package/dist/esm/api/coin.d.mts +1 -1
  70. package/dist/esm/api/coin.mjs +1 -1
  71. package/dist/esm/api/coin.mjs.map +1 -1
  72. package/dist/esm/api/digitalAsset.d.mts +2 -2
  73. package/dist/esm/api/digitalAsset.mjs +1 -1
  74. package/dist/esm/api/digitalAsset.mjs.map +1 -1
  75. package/dist/esm/api/faucet.d.mts +1 -1
  76. package/dist/esm/api/faucet.mjs +1 -1
  77. package/dist/esm/api/faucet.mjs.map +1 -1
  78. package/dist/esm/api/fungibleAsset.d.mts +2 -2
  79. package/dist/esm/api/fungibleAsset.mjs +1 -1
  80. package/dist/esm/api/fungibleAsset.mjs.map +1 -1
  81. package/dist/esm/api/general.d.mts +1 -1
  82. package/dist/esm/api/general.mjs +1 -1
  83. package/dist/esm/api/general.mjs.map +1 -1
  84. package/dist/esm/api/index.d.mts +3 -3
  85. package/dist/esm/api/index.mjs +1 -1
  86. package/dist/esm/api/index.mjs.map +1 -1
  87. package/dist/esm/api/keyless.d.mts +3 -3
  88. package/dist/esm/api/keyless.mjs +1 -1
  89. package/dist/esm/api/keyless.mjs.map +1 -1
  90. package/dist/esm/api/object.d.mts +1 -1
  91. package/dist/esm/api/object.mjs +1 -1
  92. package/dist/esm/api/object.mjs.map +1 -1
  93. package/dist/esm/api/staking.d.mts +1 -1
  94. package/dist/esm/api/staking.mjs +1 -1
  95. package/dist/esm/api/staking.mjs.map +1 -1
  96. package/dist/esm/api/table.d.mts +1 -1
  97. package/dist/esm/api/table.mjs +1 -1
  98. package/dist/esm/api/table.mjs.map +1 -1
  99. package/dist/esm/api/transaction.d.mts +2 -2
  100. package/dist/esm/api/transaction.mjs +1 -1
  101. package/dist/esm/api/transaction.mjs.map +1 -1
  102. package/dist/esm/api/transactionSubmission/build.d.mts +1 -1
  103. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  104. package/dist/esm/api/transactionSubmission/build.mjs.map +1 -1
  105. package/dist/esm/api/transactionSubmission/helpers.d.mts +1 -1
  106. package/dist/esm/api/transactionSubmission/helpers.mjs +1 -1
  107. package/dist/esm/api/transactionSubmission/helpers.mjs.map +1 -1
  108. package/dist/esm/api/transactionSubmission/management.d.mts +2 -2
  109. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  110. package/dist/esm/api/transactionSubmission/management.mjs.map +1 -1
  111. package/dist/esm/api/transactionSubmission/sign.d.mts +2 -2
  112. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  113. package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -1
  114. package/dist/esm/api/transactionSubmission/simulate.d.mts +1 -1
  115. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  116. package/dist/esm/api/transactionSubmission/simulate.mjs.map +1 -1
  117. package/dist/esm/api/transactionSubmission/submit.d.mts +1 -1
  118. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  119. package/dist/esm/api/transactionSubmission/submit.mjs.map +1 -1
  120. package/dist/esm/api/utils.d.mts +1 -1
  121. package/dist/esm/api/utils.mjs +1 -1
  122. package/dist/esm/api/utils.mjs.map +1 -1
  123. package/dist/esm/bcs/consts.d.mts +1 -1
  124. package/dist/esm/bcs/consts.mjs +1 -1
  125. package/dist/esm/bcs/consts.mjs.map +1 -1
  126. package/dist/esm/bcs/deserializer.d.mts +1 -1
  127. package/dist/esm/bcs/deserializer.mjs +1 -1
  128. package/dist/esm/bcs/deserializer.mjs.map +1 -1
  129. package/dist/esm/bcs/index.d.mts +1 -1
  130. package/dist/esm/bcs/index.mjs +1 -1
  131. package/dist/esm/bcs/index.mjs.map +1 -1
  132. package/dist/esm/bcs/serializable/entryFunctionBytes.d.mts +1 -1
  133. package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
  134. package/dist/esm/bcs/serializable/entryFunctionBytes.mjs.map +1 -1
  135. package/dist/esm/bcs/serializable/fixedBytes.d.mts +1 -1
  136. package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
  137. package/dist/esm/bcs/serializable/fixedBytes.mjs.map +1 -1
  138. package/dist/esm/bcs/serializable/movePrimitives.d.mts +1 -1
  139. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  140. package/dist/esm/bcs/serializable/movePrimitives.mjs.map +1 -1
  141. package/dist/esm/bcs/serializable/moveStructs.d.mts +1 -1
  142. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  143. package/dist/esm/bcs/serializable/moveStructs.mjs.map +1 -1
  144. package/dist/esm/bcs/serializer.d.mts +1 -1
  145. package/dist/esm/bcs/serializer.mjs +1 -1
  146. package/dist/esm/bcs/serializer.mjs.map +1 -1
  147. package/dist/esm/cli/index.d.mts +1 -1
  148. package/dist/esm/cli/index.mjs +1 -1
  149. package/dist/esm/cli/index.mjs.map +1 -1
  150. package/dist/esm/cli/localNode.mjs +1 -1
  151. package/dist/esm/cli/localNode.mjs.map +1 -1
  152. package/dist/esm/cli/move.d.mts +1 -1
  153. package/dist/esm/cli/move.mjs +1 -1
  154. package/dist/esm/cli/move.mjs.map +1 -1
  155. package/dist/esm/client/core.d.mts +1 -1
  156. package/dist/esm/client/core.mjs +1 -1
  157. package/dist/esm/client/core.mjs.map +1 -1
  158. package/dist/esm/client/get.d.mts +1 -1
  159. package/dist/esm/client/get.mjs +1 -1
  160. package/dist/esm/client/get.mjs.map +1 -1
  161. package/dist/esm/client/index.d.mts +1 -1
  162. package/dist/esm/client/index.mjs +1 -1
  163. package/dist/esm/client/index.mjs.map +1 -1
  164. package/dist/esm/client/post.d.mts +1 -1
  165. package/dist/esm/client/post.mjs +1 -1
  166. package/dist/esm/client/post.mjs.map +1 -1
  167. package/dist/esm/core/account/index.d.mts +2 -2
  168. package/dist/esm/core/account/index.mjs +1 -1
  169. package/dist/esm/core/account/index.mjs.map +1 -1
  170. package/dist/esm/core/account/utils/address.d.mts +13 -2
  171. package/dist/esm/core/account/utils/address.mjs +1 -1
  172. package/dist/esm/core/account/utils/address.mjs.map +1 -1
  173. package/dist/esm/core/account/utils/index.d.mts +2 -2
  174. package/dist/esm/core/account/utils/index.mjs +1 -1
  175. package/dist/esm/core/account/utils/index.mjs.map +1 -1
  176. package/dist/esm/core/accountAddress.d.mts +1 -1
  177. package/dist/esm/core/accountAddress.mjs +3 -1
  178. package/dist/esm/core/accountAddress.mjs.map +1 -1
  179. package/dist/esm/core/authenticationKey.d.mts +1 -1
  180. package/dist/esm/core/authenticationKey.mjs +1 -1
  181. package/dist/esm/core/authenticationKey.mjs.map +1 -1
  182. package/dist/esm/core/common.mjs +1 -1
  183. package/dist/esm/core/common.mjs.map +1 -1
  184. package/dist/esm/core/crypto/abstraction.d.mts +1 -1
  185. package/dist/esm/core/crypto/abstraction.mjs +1 -1
  186. package/dist/esm/core/crypto/abstraction.mjs.map +1 -1
  187. package/dist/esm/core/crypto/deserializationUtils.d.mts +1 -1
  188. package/dist/esm/core/crypto/deserializationUtils.mjs +1 -1
  189. package/dist/esm/core/crypto/deserializationUtils.mjs.map +1 -1
  190. package/dist/esm/core/crypto/ed25519.d.mts +1 -1
  191. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  192. package/dist/esm/core/crypto/ed25519.mjs.map +1 -1
  193. package/dist/esm/core/crypto/ephemeral.d.mts +1 -1
  194. package/dist/esm/core/crypto/ephemeral.mjs +1 -1
  195. package/dist/esm/core/crypto/ephemeral.mjs.map +1 -1
  196. package/dist/esm/core/crypto/federatedKeyless.d.mts +2 -2
  197. package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
  198. package/dist/esm/core/crypto/federatedKeyless.mjs.map +1 -1
  199. package/dist/esm/core/crypto/hdKey.mjs +1 -1
  200. package/dist/esm/core/crypto/hdKey.mjs.map +1 -1
  201. package/dist/esm/core/crypto/index.d.mts +3 -2
  202. package/dist/esm/core/crypto/index.mjs +1 -1
  203. package/dist/esm/core/crypto/index.mjs.map +1 -1
  204. package/dist/esm/core/crypto/keyless.d.mts +2 -2
  205. package/dist/esm/core/crypto/keyless.mjs +1 -1
  206. package/dist/esm/core/crypto/keyless.mjs.map +1 -1
  207. package/dist/esm/core/crypto/multiEd25519.d.mts +1 -1
  208. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  209. package/dist/esm/core/crypto/multiEd25519.mjs.map +1 -1
  210. package/dist/esm/core/crypto/multiKey.d.mts +1 -1
  211. package/dist/esm/core/crypto/multiKey.mjs +3 -1
  212. package/dist/esm/core/crypto/multiKey.mjs.map +1 -1
  213. package/dist/esm/core/crypto/poseidon.mjs +1 -1
  214. package/dist/esm/core/crypto/poseidon.mjs.map +1 -1
  215. package/dist/esm/core/crypto/privateKey.d.mts +1 -1
  216. package/dist/esm/core/crypto/privateKey.mjs +1 -1
  217. package/dist/esm/core/crypto/privateKey.mjs.map +1 -1
  218. package/dist/esm/core/crypto/proof.d.mts +1 -1
  219. package/dist/esm/core/crypto/proof.mjs +1 -1
  220. package/dist/esm/core/crypto/proof.mjs.map +1 -1
  221. package/dist/esm/core/crypto/publicKey.d.mts +1 -1
  222. package/dist/esm/core/crypto/publicKey.mjs +1 -1
  223. package/dist/esm/core/crypto/publicKey.mjs.map +1 -1
  224. package/dist/esm/core/crypto/secp256k1.d.mts +1 -1
  225. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  226. package/dist/esm/core/crypto/secp256k1.mjs.map +1 -1
  227. package/dist/esm/core/crypto/secp256r1.d.mts +306 -0
  228. package/dist/esm/core/crypto/secp256r1.mjs +2 -0
  229. package/dist/esm/core/crypto/secp256r1.mjs.map +1 -0
  230. package/dist/esm/core/crypto/signature.d.mts +1 -1
  231. package/dist/esm/core/crypto/signature.mjs +1 -1
  232. package/dist/esm/core/crypto/signature.mjs.map +1 -1
  233. package/dist/esm/core/crypto/singleKey.d.mts +1 -1
  234. package/dist/esm/core/crypto/singleKey.mjs +1 -1
  235. package/dist/esm/core/crypto/singleKey.mjs.map +1 -1
  236. package/dist/esm/core/crypto/types.d.mts +1 -1
  237. package/dist/esm/core/crypto/types.mjs +0 -1
  238. package/dist/esm/core/crypto/utils.d.mts +1 -1
  239. package/dist/esm/core/crypto/utils.mjs +1 -1
  240. package/dist/esm/core/crypto/utils.mjs.map +1 -1
  241. package/dist/esm/core/hex.d.mts +1 -1
  242. package/dist/esm/core/hex.mjs +1 -1
  243. package/dist/esm/core/hex.mjs.map +1 -1
  244. package/dist/esm/core/index.d.mts +4 -3
  245. package/dist/esm/core/index.mjs +1 -1
  246. package/dist/esm/core/index.mjs.map +1 -1
  247. package/dist/esm/errors/index.d.mts +1 -1
  248. package/dist/esm/errors/index.mjs +6 -1
  249. package/dist/esm/errors/index.mjs.map +1 -1
  250. package/dist/esm/{federatedKeyless-CUPEnP-W.d.mts → federatedKeyless-CTzDAQTu.d.mts} +1 -1
  251. package/dist/esm/index.d.mts +5 -4
  252. package/dist/esm/index.mjs +1 -1
  253. package/dist/esm/index.mjs.map +1 -1
  254. package/dist/esm/internal/abstraction.d.mts +1 -1
  255. package/dist/esm/internal/abstraction.mjs +1 -1
  256. package/dist/esm/internal/abstraction.mjs.map +1 -1
  257. package/dist/esm/internal/account.d.mts +21 -3
  258. package/dist/esm/internal/account.mjs +1 -1
  259. package/dist/esm/internal/account.mjs.map +1 -1
  260. package/dist/esm/internal/ans.d.mts +2 -2
  261. package/dist/esm/internal/ans.mjs +1 -1
  262. package/dist/esm/internal/ans.mjs.map +1 -1
  263. package/dist/esm/internal/coin.d.mts +1 -1
  264. package/dist/esm/internal/coin.mjs +1 -1
  265. package/dist/esm/internal/coin.mjs.map +1 -1
  266. package/dist/esm/internal/digitalAsset.d.mts +2 -2
  267. package/dist/esm/internal/digitalAsset.mjs +1 -1
  268. package/dist/esm/internal/digitalAsset.mjs.map +1 -1
  269. package/dist/esm/internal/faucet.d.mts +1 -1
  270. package/dist/esm/internal/faucet.mjs +1 -1
  271. package/dist/esm/internal/faucet.mjs.map +1 -1
  272. package/dist/esm/internal/fungibleAsset.d.mts +2 -2
  273. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  274. package/dist/esm/internal/fungibleAsset.mjs.map +1 -1
  275. package/dist/esm/internal/general.d.mts +1 -1
  276. package/dist/esm/internal/general.mjs +1 -1
  277. package/dist/esm/internal/general.mjs.map +1 -1
  278. package/dist/esm/internal/keyless.d.mts +3 -3
  279. package/dist/esm/internal/keyless.mjs +1 -1
  280. package/dist/esm/internal/keyless.mjs.map +1 -1
  281. package/dist/esm/internal/object.d.mts +1 -1
  282. package/dist/esm/internal/object.mjs +1 -1
  283. package/dist/esm/internal/object.mjs.map +1 -1
  284. package/dist/esm/internal/staking.d.mts +1 -1
  285. package/dist/esm/internal/staking.mjs +1 -1
  286. package/dist/esm/internal/staking.mjs.map +1 -1
  287. package/dist/esm/internal/table.d.mts +1 -1
  288. package/dist/esm/internal/table.mjs +1 -1
  289. package/dist/esm/internal/table.mjs.map +1 -1
  290. package/dist/esm/internal/transaction.d.mts +1 -1
  291. package/dist/esm/internal/transaction.mjs +1 -1
  292. package/dist/esm/internal/transaction.mjs.map +1 -1
  293. package/dist/esm/internal/transactionSubmission.d.mts +2 -2
  294. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  295. package/dist/esm/internal/transactionSubmission.mjs.map +1 -1
  296. package/dist/esm/internal/utils/index.d.mts +1 -1
  297. package/dist/esm/internal/utils/index.mjs +1 -1
  298. package/dist/esm/internal/utils/index.mjs.map +1 -1
  299. package/dist/esm/internal/utils/utils.d.mts +1 -1
  300. package/dist/esm/internal/utils/utils.mjs +1 -1
  301. package/dist/esm/internal/utils/utils.mjs.map +1 -1
  302. package/dist/esm/internal/view.d.mts +1 -1
  303. package/dist/esm/internal/view.mjs +1 -1
  304. package/dist/esm/internal/view.mjs.map +1 -1
  305. package/dist/esm/transactions/authenticator/account.d.mts +1 -1
  306. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  307. package/dist/esm/transactions/authenticator/account.mjs.map +1 -1
  308. package/dist/esm/transactions/authenticator/index.d.mts +1 -1
  309. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  310. package/dist/esm/transactions/authenticator/index.mjs.map +1 -1
  311. package/dist/esm/transactions/authenticator/transaction.d.mts +1 -1
  312. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  313. package/dist/esm/transactions/authenticator/transaction.mjs.map +1 -1
  314. package/dist/esm/transactions/index.d.mts +1 -1
  315. package/dist/esm/transactions/index.mjs +1 -1
  316. package/dist/esm/transactions/index.mjs.map +1 -1
  317. package/dist/esm/transactions/instances/chainId.d.mts +1 -1
  318. package/dist/esm/transactions/instances/chainId.mjs +1 -1
  319. package/dist/esm/transactions/instances/chainId.mjs.map +1 -1
  320. package/dist/esm/transactions/instances/identifier.d.mts +1 -1
  321. package/dist/esm/transactions/instances/identifier.mjs +1 -1
  322. package/dist/esm/transactions/instances/identifier.mjs.map +1 -1
  323. package/dist/esm/transactions/instances/index.d.mts +1 -1
  324. package/dist/esm/transactions/instances/index.mjs +1 -1
  325. package/dist/esm/transactions/instances/index.mjs.map +1 -1
  326. package/dist/esm/transactions/instances/moduleId.d.mts +1 -1
  327. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  328. package/dist/esm/transactions/instances/moduleId.mjs.map +1 -1
  329. package/dist/esm/transactions/instances/multiAgentTransaction.d.mts +1 -1
  330. package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
  331. package/dist/esm/transactions/instances/multiAgentTransaction.mjs.map +1 -1
  332. package/dist/esm/transactions/instances/rawTransaction.d.mts +1 -1
  333. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  334. package/dist/esm/transactions/instances/rawTransaction.mjs.map +1 -1
  335. package/dist/esm/transactions/instances/rotationProofChallenge.d.mts +1 -1
  336. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  337. package/dist/esm/transactions/instances/rotationProofChallenge.mjs.map +1 -1
  338. package/dist/esm/transactions/instances/signedTransaction.d.mts +1 -1
  339. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  340. package/dist/esm/transactions/instances/signedTransaction.mjs.map +1 -1
  341. package/dist/esm/transactions/instances/simpleTransaction.d.mts +1 -1
  342. package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
  343. package/dist/esm/transactions/instances/simpleTransaction.mjs.map +1 -1
  344. package/dist/esm/transactions/instances/transactionArgument.d.mts +1 -1
  345. package/dist/esm/transactions/instances/transactionArgument.mjs +0 -1
  346. package/dist/esm/transactions/instances/transactionPayload.d.mts +1 -1
  347. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  348. package/dist/esm/transactions/instances/transactionPayload.mjs.map +1 -1
  349. package/dist/esm/transactions/management/accountSequenceNumber.d.mts +2 -2
  350. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  351. package/dist/esm/transactions/management/accountSequenceNumber.mjs.map +1 -1
  352. package/dist/esm/transactions/management/asyncQueue.mjs +1 -1
  353. package/dist/esm/transactions/management/asyncQueue.mjs.map +1 -1
  354. package/dist/esm/transactions/management/index.d.mts +2 -2
  355. package/dist/esm/transactions/management/index.mjs +1 -1
  356. package/dist/esm/transactions/management/index.mjs.map +1 -1
  357. package/dist/esm/transactions/management/transactionWorker.d.mts +2 -2
  358. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  359. package/dist/esm/transactions/management/transactionWorker.mjs.map +1 -1
  360. package/dist/esm/transactions/transactionBuilder/helpers.d.mts +1 -1
  361. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  362. package/dist/esm/transactions/transactionBuilder/helpers.mjs.map +1 -1
  363. package/dist/esm/transactions/transactionBuilder/index.d.mts +1 -1
  364. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  365. package/dist/esm/transactions/transactionBuilder/index.mjs.map +1 -1
  366. package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +1 -1
  367. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  368. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs.map +1 -1
  369. package/dist/esm/transactions/transactionBuilder/signingMessage.d.mts +1 -1
  370. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
  371. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs.map +1 -1
  372. package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +1 -1
  373. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  374. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs.map +1 -1
  375. package/dist/esm/transactions/typeTag/index.d.mts +1 -1
  376. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  377. package/dist/esm/transactions/typeTag/index.mjs.map +1 -1
  378. package/dist/esm/transactions/typeTag/parser.d.mts +1 -1
  379. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  380. package/dist/esm/transactions/typeTag/parser.mjs.map +1 -1
  381. package/dist/esm/transactions/types.d.mts +1 -1
  382. package/dist/esm/transactions/types.mjs +0 -1
  383. package/dist/esm/types/abstraction.mjs +1 -1
  384. package/dist/esm/types/abstraction.mjs.map +1 -1
  385. package/dist/esm/types/generated/queries.mjs +493 -1
  386. package/dist/esm/types/generated/queries.mjs.map +1 -1
  387. package/dist/esm/types/generated/types.mjs +1 -1
  388. package/dist/esm/types/generated/types.mjs.map +1 -1
  389. package/dist/esm/types/index.d.mts +1 -1
  390. package/dist/esm/types/index.mjs +1 -1
  391. package/dist/esm/types/index.mjs.map +1 -1
  392. package/dist/esm/types/indexer.mjs +0 -1
  393. package/dist/esm/types/types.d.mts +1 -1
  394. package/dist/esm/types/types.mjs +1 -1
  395. package/dist/esm/types/types.mjs.map +1 -1
  396. package/dist/esm/utils/apiEndpoints.d.mts +1 -0
  397. package/dist/esm/utils/apiEndpoints.mjs +1 -1
  398. package/dist/esm/utils/apiEndpoints.mjs.map +1 -1
  399. package/dist/esm/utils/const.mjs +1 -1
  400. package/dist/esm/utils/const.mjs.map +1 -1
  401. package/dist/esm/utils/helpers.d.mts +1 -1
  402. package/dist/esm/utils/helpers.mjs +1 -1
  403. package/dist/esm/utils/helpers.mjs.map +1 -1
  404. package/dist/esm/utils/index.d.mts +1 -1
  405. package/dist/esm/utils/index.mjs +1 -1
  406. package/dist/esm/utils/index.mjs.map +1 -1
  407. package/dist/esm/utils/memoize.mjs +1 -1
  408. package/dist/esm/utils/memoize.mjs.map +1 -1
  409. package/dist/esm/utils/normalizeBundle.d.mts +1 -1
  410. package/dist/esm/utils/normalizeBundle.mjs +1 -1
  411. package/dist/esm/utils/normalizeBundle.mjs.map +1 -1
  412. package/dist/esm/version.d.mts +1 -1
  413. package/dist/esm/version.mjs +1 -1
  414. package/dist/esm/version.mjs.map +1 -1
  415. package/package.json +40 -22
  416. package/src/api/account.ts +32 -7
  417. package/src/api/aptos.ts +25 -14
  418. package/src/core/account/utils/address.ts +22 -0
  419. package/src/core/crypto/index.ts +1 -0
  420. package/src/core/crypto/privateKey.ts +1 -0
  421. package/src/core/crypto/secp256k1.ts +9 -1
  422. package/src/core/crypto/secp256r1.ts +495 -0
  423. package/src/core/crypto/singleKey.ts +11 -0
  424. package/src/internal/account.ts +33 -0
  425. package/src/internal/ans.ts +1 -0
  426. package/src/types/types.ts +5 -0
  427. package/src/utils/apiEndpoints.ts +7 -0
  428. package/src/version.ts +1 -1
  429. package/dist/common/chunk-6MMUUJHX.js +0 -4
  430. package/dist/esm/chunk-35DKMW7Q.mjs +0 -2
  431. package/dist/esm/chunk-35DKMW7Q.mjs.map +0 -1
  432. package/dist/esm/chunk-4QMXOWHP.mjs +0 -1
  433. package/dist/esm/chunk-4QMXOWHP.mjs.map +0 -1
  434. package/dist/esm/chunk-4RXKALLC.mjs +0 -2
  435. package/dist/esm/chunk-4RXKALLC.mjs.map +0 -1
  436. package/dist/esm/chunk-4WPQQPUF.mjs +0 -1
  437. package/dist/esm/chunk-4WPQQPUF.mjs.map +0 -1
  438. package/dist/esm/chunk-56CNRT2K.mjs +0 -2
  439. package/dist/esm/chunk-56CNRT2K.mjs.map +0 -1
  440. package/dist/esm/chunk-5FI4545P.mjs +0 -2
  441. package/dist/esm/chunk-5FI4545P.mjs.map +0 -1
  442. package/dist/esm/chunk-5HXLZHDW.mjs +0 -1
  443. package/dist/esm/chunk-5HXLZHDW.mjs.map +0 -1
  444. package/dist/esm/chunk-6WDVDEQZ.mjs +0 -7
  445. package/dist/esm/chunk-6WDVDEQZ.mjs.map +0 -1
  446. package/dist/esm/chunk-7DQDJ2SA.mjs +0 -2
  447. package/dist/esm/chunk-7DQDJ2SA.mjs.map +0 -1
  448. package/dist/esm/chunk-7ECCT6PK.mjs +0 -1
  449. package/dist/esm/chunk-7ECCT6PK.mjs.map +0 -1
  450. package/dist/esm/chunk-A5L76YP7.mjs +0 -2
  451. package/dist/esm/chunk-A5L76YP7.mjs.map +0 -1
  452. package/dist/esm/chunk-B563XRSZ.mjs +0 -2
  453. package/dist/esm/chunk-B563XRSZ.mjs.map +0 -1
  454. package/dist/esm/chunk-C3Q23D22.mjs +0 -2
  455. package/dist/esm/chunk-C3Q23D22.mjs.map +0 -1
  456. package/dist/esm/chunk-CW35YAMN.mjs +0 -2
  457. package/dist/esm/chunk-CW35YAMN.mjs.map +0 -1
  458. package/dist/esm/chunk-DIGP2ALY.mjs +0 -4
  459. package/dist/esm/chunk-DIGP2ALY.mjs.map +0 -1
  460. package/dist/esm/chunk-DNRUDMMV.mjs +0 -2
  461. package/dist/esm/chunk-DNRUDMMV.mjs.map +0 -1
  462. package/dist/esm/chunk-EBMEXURY.mjs +0 -2
  463. package/dist/esm/chunk-EBMEXURY.mjs.map +0 -1
  464. package/dist/esm/chunk-EM52Z7T7.mjs +0 -2
  465. package/dist/esm/chunk-EM52Z7T7.mjs.map +0 -1
  466. package/dist/esm/chunk-ES2KP6BS.mjs +0 -2
  467. package/dist/esm/chunk-ES2KP6BS.mjs.map +0 -1
  468. package/dist/esm/chunk-FD6FGKYY.mjs +0 -1
  469. package/dist/esm/chunk-FD6FGKYY.mjs.map +0 -1
  470. package/dist/esm/chunk-FGFLPH5K.mjs +0 -2
  471. package/dist/esm/chunk-FGFLPH5K.mjs.map +0 -1
  472. package/dist/esm/chunk-FLZPUYXQ.mjs +0 -2
  473. package/dist/esm/chunk-FLZPUYXQ.mjs.map +0 -1
  474. package/dist/esm/chunk-FZY4PMEE.mjs +0 -1
  475. package/dist/esm/chunk-FZY4PMEE.mjs.map +0 -1
  476. package/dist/esm/chunk-G3MHXDYA.mjs +0 -1
  477. package/dist/esm/chunk-G3MHXDYA.mjs.map +0 -1
  478. package/dist/esm/chunk-GFFKEZ56.mjs +0 -2
  479. package/dist/esm/chunk-GFFKEZ56.mjs.map +0 -1
  480. package/dist/esm/chunk-GMQCQDW4.mjs +0 -2
  481. package/dist/esm/chunk-GMQCQDW4.mjs.map +0 -1
  482. package/dist/esm/chunk-GOXRBEIJ.mjs +0 -2
  483. package/dist/esm/chunk-GOXRBEIJ.mjs.map +0 -1
  484. package/dist/esm/chunk-HGLO5LDS.mjs +0 -1
  485. package/dist/esm/chunk-HGLO5LDS.mjs.map +0 -1
  486. package/dist/esm/chunk-HNBKTJPN.mjs +0 -2
  487. package/dist/esm/chunk-HNBKTJPN.mjs.map +0 -1
  488. package/dist/esm/chunk-HNBVYE3N.mjs +0 -2
  489. package/dist/esm/chunk-HNBVYE3N.mjs.map +0 -1
  490. package/dist/esm/chunk-IF4UU2MT.mjs +0 -2
  491. package/dist/esm/chunk-IF4UU2MT.mjs.map +0 -1
  492. package/dist/esm/chunk-IJE2LVZG.mjs +0 -2
  493. package/dist/esm/chunk-IJE2LVZG.mjs.map +0 -1
  494. package/dist/esm/chunk-KDMSOCZY.mjs +0 -2
  495. package/dist/esm/chunk-KDMSOCZY.mjs.map +0 -1
  496. package/dist/esm/chunk-LWL57YFU.mjs +0 -2
  497. package/dist/esm/chunk-LWL57YFU.mjs.map +0 -1
  498. package/dist/esm/chunk-MT2RJ7H3.mjs +0 -2
  499. package/dist/esm/chunk-MT2RJ7H3.mjs.map +0 -1
  500. package/dist/esm/chunk-N3O3ULF7.mjs +0 -2
  501. package/dist/esm/chunk-N3O3ULF7.mjs.map +0 -1
  502. package/dist/esm/chunk-N6YTF76Q.mjs +0 -2
  503. package/dist/esm/chunk-N6YTF76Q.mjs.map +0 -1
  504. package/dist/esm/chunk-NECL5FCQ.mjs +0 -1
  505. package/dist/esm/chunk-NECL5FCQ.mjs.map +0 -1
  506. package/dist/esm/chunk-OLILO7VD.mjs +0 -2
  507. package/dist/esm/chunk-OLILO7VD.mjs.map +0 -1
  508. package/dist/esm/chunk-ORMOQWWH.mjs +0 -2
  509. package/dist/esm/chunk-ORMOQWWH.mjs.map +0 -1
  510. package/dist/esm/chunk-Q4W3WJ2U.mjs +0 -2
  511. package/dist/esm/chunk-Q4W3WJ2U.mjs.map +0 -1
  512. package/dist/esm/chunk-QREVMGQZ.mjs +0 -2
  513. package/dist/esm/chunk-QREVMGQZ.mjs.map +0 -1
  514. package/dist/esm/chunk-RCSJFTST.mjs +0 -2
  515. package/dist/esm/chunk-RCSJFTST.mjs.map +0 -1
  516. package/dist/esm/chunk-RGKRCZ36.mjs +0 -4
  517. package/dist/esm/chunk-RGKRCZ36.mjs.map +0 -1
  518. package/dist/esm/chunk-ROT6S6BM.mjs +0 -2
  519. package/dist/esm/chunk-ROT6S6BM.mjs.map +0 -1
  520. package/dist/esm/chunk-RQX6JOEN.mjs +0 -2
  521. package/dist/esm/chunk-RQX6JOEN.mjs.map +0 -1
  522. package/dist/esm/chunk-STY74NUA.mjs +0 -2
  523. package/dist/esm/chunk-STY74NUA.mjs.map +0 -1
  524. package/dist/esm/chunk-TGRLDWXV.mjs +0 -2
  525. package/dist/esm/chunk-TGRLDWXV.mjs.map +0 -1
  526. package/dist/esm/chunk-TOBQ5UE6.mjs +0 -2
  527. package/dist/esm/chunk-TOBQ5UE6.mjs.map +0 -1
  528. package/dist/esm/chunk-UL777LTI.mjs +0 -494
  529. package/dist/esm/chunk-UL777LTI.mjs.map +0 -1
  530. package/dist/esm/chunk-UYVPNUH3.mjs +0 -1
  531. package/dist/esm/chunk-UYVPNUH3.mjs.map +0 -1
  532. package/dist/esm/chunk-V3MBJJTL.mjs +0 -1
  533. package/dist/esm/chunk-V3MBJJTL.mjs.map +0 -1
  534. package/dist/esm/chunk-V74WPKSY.mjs +0 -2
  535. package/dist/esm/chunk-V74WPKSY.mjs.map +0 -1
  536. package/dist/esm/chunk-WCMW2L3P.mjs +0 -2
  537. package/dist/esm/chunk-WCMW2L3P.mjs.map +0 -1
  538. package/dist/esm/chunk-WSR5EBJM.mjs +0 -2
  539. package/dist/esm/chunk-WSR5EBJM.mjs.map +0 -1
  540. package/dist/esm/chunk-XJJVJOX5.mjs +0 -2
  541. package/dist/esm/chunk-XJJVJOX5.mjs.map +0 -1
  542. package/dist/esm/chunk-XKUIMGKU.mjs +0 -2
  543. package/dist/esm/chunk-XKUIMGKU.mjs.map +0 -1
  544. package/dist/esm/chunk-YOZBVVKL.mjs +0 -2
  545. package/dist/esm/chunk-YOZBVVKL.mjs.map +0 -1
  546. package/dist/esm/chunk-ZP4DWSQA.mjs +0 -2
  547. package/dist/esm/chunk-ZP4DWSQA.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../../src/core/crypto/multiEd25519.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { AptosConfig } from \"../../api\";\nimport { Deserializer, Serializer } from \"../../bcs\";\nimport { SigningScheme as AuthenticationKeyScheme, HexInput } from \"../../types\";\nimport { AuthenticationKey } from \"../authenticationKey\";\nimport { Ed25519PublicKey, Ed25519Signature } from \"./ed25519\";\nimport { AbstractMultiKey } from \"./multiKey\";\nimport { Signature } from \"./signature\";\n\n/**\n * Represents the public key of a K-of-N Ed25519 multi-sig transaction.\n *\n * A K-of-N multi-sig transaction requires at least K out of N authorized signers to sign the transaction\n * for it to be executed. This class encapsulates the logic for managing the public keys and the threshold\n * for valid signatures.\n *\n * @see {@link https://aptos.dev/integration/creating-a-signed-transaction/ | Creating a Signed Transaction}\n * @group Implementation\n * @category Serialization\n */\nexport class MultiEd25519PublicKey extends AbstractMultiKey {\n /**\n * Maximum number of public keys supported\n * @group Implementation\n * @category Serialization\n */\n static readonly MAX_KEYS = 32;\n\n /**\n * Minimum number of public keys needed\n * @group Implementation\n * @category Serialization\n */\n static readonly MIN_KEYS = 2;\n\n /**\n * Minimum threshold for the number of valid signatures required\n * @group Implementation\n * @category Serialization\n */\n static readonly MIN_THRESHOLD = 1;\n\n /**\n * List of Ed25519 public keys for this LegacyMultiEd25519PublicKey\n * @group Implementation\n * @category Serialization\n */\n public readonly publicKeys: Ed25519PublicKey[];\n\n /**\n * The minimum number of valid signatures required, for the number of public keys specified\n * @group Implementation\n * @category Serialization\n */\n public readonly threshold: number;\n\n /**\n * Public key for a K-of-N multi-sig transaction. A K-of-N multi-sig transaction means that for such a\n * transaction to be executed, at least K out of the N authorized signers have signed the transaction\n * and passed the check conducted by the chain.\n *\n * @see {@link\n * https://aptos.dev/integration/creating-a-signed-transaction/ | Creating a Signed Transaction}\n * @param args - A wrapper to let you choose the param order.\n * @param args.publicKeys A list of public keys\n * @param args.threshold At least \"threshold\" signatures must be valid\n * @group Implementation\n * @category Serialization\n */\n constructor(args: { publicKeys: Ed25519PublicKey[]; threshold: number }) {\n const { publicKeys, threshold } = args;\n super({ publicKeys });\n\n // Validate number of public keys\n if (publicKeys.length > MultiEd25519PublicKey.MAX_KEYS || publicKeys.length < MultiEd25519PublicKey.MIN_KEYS) {\n throw new Error(\n `Must have between ${MultiEd25519PublicKey.MIN_KEYS} and ` +\n `${MultiEd25519PublicKey.MAX_KEYS} public keys, inclusive`,\n );\n }\n\n // Validate threshold: must be between 1 and the number of public keys, inclusive\n if (threshold < MultiEd25519PublicKey.MIN_THRESHOLD || threshold > publicKeys.length) {\n throw new Error(\n `Threshold must be between ${MultiEd25519PublicKey.MIN_THRESHOLD} and ${publicKeys.length}, inclusive`,\n );\n }\n\n this.publicKeys = publicKeys;\n this.threshold = threshold;\n }\n\n getSignaturesRequired(): number {\n return this.threshold;\n }\n\n // region AccountPublicKey\n\n /**\n * Verifies a multi-signature against a given message.\n * This function ensures that the provided signatures meet the required threshold and are valid for the given message.\n *\n * @param args - The arguments for verifying the signature.\n * @param args.message - The message that was signed.\n * @param args.signature - The multi-signature containing multiple signatures and a bitmap indicating which signatures are valid.\n * @returns True if the signature is valid; otherwise, false.\n * @throws Error if the bitmap and signatures length mismatch or if there are not enough valid signatures.\n * @group Implementation\n * @category Serialization\n */\n verifySignature(args: { message: HexInput; signature: Signature }): boolean {\n const { message, signature } = args;\n if (!(signature instanceof MultiEd25519Signature)) {\n return false;\n }\n\n const indices: number[] = [];\n for (let i = 0; i < 4; i += 1) {\n for (let j = 0; j < 8; j += 1) {\n // eslint-disable-next-line no-bitwise\n const bitIsSet = (signature.bitmap[i] & (1 << (7 - j))) !== 0;\n if (bitIsSet) {\n const index = i * 8 + j;\n indices.push(index);\n }\n }\n }\n\n if (indices.length !== signature.signatures.length) {\n throw new Error(\"Bitmap and signatures length mismatch\");\n }\n\n if (indices.length < this.threshold) {\n throw new Error(\"Not enough signatures\");\n }\n\n for (let i = 0; i < indices.length; i += 1) {\n const publicKey = this.publicKeys[indices[i]];\n if (!publicKey.verifySignature({ message, signature: signature.signatures[i] })) {\n return false;\n }\n }\n return true;\n }\n\n async verifySignatureAsync(args: {\n aptosConfig: AptosConfig;\n message: HexInput;\n signature: Signature;\n }): Promise<boolean> {\n return this.verifySignature(args);\n }\n\n /**\n * Generates an authentication key based on the current instance's byte representation.\n * This function is essential for creating a secure authentication key that can be used for various cryptographic operations.\n *\n * @returns {AuthenticationKey} The generated authentication key.\n * @group Implementation\n * @category Serialization\n */\n authKey(): AuthenticationKey {\n return AuthenticationKey.fromSchemeAndBytes({\n scheme: AuthenticationKeyScheme.MultiEd25519,\n input: this.toUint8Array(),\n });\n }\n\n /**\n * Converts a PublicKeys into Uint8Array (bytes) with: bytes = p1_bytes | ... | pn_bytes | threshold\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n const bytes = new Uint8Array(this.publicKeys.length * Ed25519PublicKey.LENGTH + 1);\n this.publicKeys.forEach((k: Ed25519PublicKey, i: number) => {\n bytes.set(k.toUint8Array(), i * Ed25519PublicKey.LENGTH);\n });\n\n bytes[this.publicKeys.length * Ed25519PublicKey.LENGTH] = this.threshold;\n\n return bytes;\n }\n\n // endregion\n\n // region Serializable\n\n /**\n * Serializes the current instance into bytes using the provided serializer.\n * This allows for the conversion of the instance's data into a format suitable for transmission or storage.\n *\n * @param serializer - The serializer used to convert the instance into bytes.\n * @group Implementation\n * @category Serialization\n */\n serialize(serializer: Serializer): void {\n serializer.serializeBytes(this.toUint8Array());\n }\n\n /**\n * Deserializes a MultiEd25519Signature from the provided deserializer.\n * This function helps in reconstructing a MultiEd25519Signature object from its serialized byte representation.\n *\n * @param deserializer - The deserializer instance used to read the serialized data.\n * @group Implementation\n * @category Serialization\n */\n static deserialize(deserializer: Deserializer): MultiEd25519PublicKey {\n const bytes = deserializer.deserializeBytes();\n const threshold = bytes[bytes.length - 1];\n\n const keys: Ed25519PublicKey[] = [];\n\n for (let i = 0; i < bytes.length - 1; i += Ed25519PublicKey.LENGTH) {\n const begin = i;\n keys.push(new Ed25519PublicKey(bytes.subarray(begin, begin + Ed25519PublicKey.LENGTH)));\n }\n return new MultiEd25519PublicKey({ publicKeys: keys, threshold });\n }\n\n /**\n * Deserializes a MultiEd25519Signature from the provided deserializer.\n * This function helps in reconstructing a MultiEd25519Signature object from its serialized byte representation.\n *\n * @param deserializer - The deserializer instance used to read the serialized data.\n * @group Implementation\n * @category Serialization\n */\n static deserializeWithoutLength(deserializer: Deserializer): MultiEd25519PublicKey {\n const length = deserializer.remaining();\n const bytes = deserializer.deserializeFixedBytes(length);\n const threshold = bytes[bytes.length - 1];\n\n const keys: Ed25519PublicKey[] = [];\n\n for (let i = 0; i < bytes.length - 1; i += Ed25519PublicKey.LENGTH) {\n const begin = i;\n keys.push(new Ed25519PublicKey(bytes.subarray(begin, begin + Ed25519PublicKey.LENGTH)));\n }\n return new MultiEd25519PublicKey({ publicKeys: keys, threshold });\n }\n\n // endregion\n\n /**\n * Get the index of the provided public key.\n *\n * This function retrieves the index of a specified public key within the MultiKey.\n * If the public key does not exist, it throws an error.\n *\n * @param publicKey - The public key to find the index for.\n * @returns The corresponding index of the public key, if it exists.\n * @throws Error - If the public key is not found in the MultiKey.\n * @group Implementation\n */\n getIndex(publicKey: Ed25519PublicKey): number {\n return super.getIndex(publicKey);\n }\n}\n\n/**\n * Represents the signature of a K-of-N Ed25519 multi-sig transaction.\n *\n * @see {@link https://aptos.dev/integration/creating-a-signed-transaction/#multisignature-transactions | Creating a Signed Transaction}\n * @group Implementation\n * @category Serialization\n */\nexport class MultiEd25519Signature extends Signature {\n /**\n * Maximum number of Ed25519 signatures supported\n * @group Implementation\n * @category Serialization\n */\n static MAX_SIGNATURES_SUPPORTED = 32;\n\n /**\n * Number of bytes in the bitmap representing who signed the transaction (32-bits)\n * @group Implementation\n * @category Serialization\n */\n static BITMAP_LEN: number = 4;\n\n /**\n * The list of underlying Ed25519 signatures\n * @group Implementation\n * @category Serialization\n */\n public readonly signatures: Ed25519Signature[];\n\n /**\n * 32-bit Bitmap representing who signed the transaction\n *\n * This is represented where each public key can be masked to determine whether the message was signed by that key.\n * @group Implementation\n * @category Serialization\n */\n public readonly bitmap: Uint8Array;\n\n /**\n * Signature for a K-of-N multi-sig transaction.\n *\n * @see {@link\n * https://aptos.dev/integration/creating-a-signed-transaction/#multisignature-transactions | Creating a Signed Transaction}\n *\n * @param args.signatures A list of signatures\n * @param args.bitmap 4 bytes, at most 32 signatures are supported. If Nth bit value is `1`, the Nth\n * signature should be provided in `signatures`. Bits are read from left to right.\n * Alternatively, you can specify an array of bitmap positions.\n * Valid position should range between 0 and 31.\n * @see MultiEd25519Signature.createBitmap\n * @group Implementation\n * @category Serialization\n */\n constructor(args: { signatures: Ed25519Signature[]; bitmap: Uint8Array | number[] }) {\n super();\n const { signatures, bitmap } = args;\n\n if (signatures.length > MultiEd25519Signature.MAX_SIGNATURES_SUPPORTED) {\n throw new Error(\n `The number of signatures cannot be greater than ${MultiEd25519Signature.MAX_SIGNATURES_SUPPORTED}`,\n );\n }\n this.signatures = signatures;\n\n if (!(bitmap instanceof Uint8Array)) {\n this.bitmap = MultiEd25519Signature.createBitmap({ bits: bitmap });\n } else if (bitmap.length !== MultiEd25519Signature.BITMAP_LEN) {\n throw new Error(`\"bitmap\" length should be ${MultiEd25519Signature.BITMAP_LEN}`);\n } else {\n this.bitmap = bitmap;\n }\n }\n\n // region AccountSignature\n\n /**\n * Converts a MultiSignature into Uint8Array (bytes) with `bytes = s1_bytes | ... | sn_bytes | bitmap`\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n const bytes = new Uint8Array(this.signatures.length * Ed25519Signature.LENGTH + MultiEd25519Signature.BITMAP_LEN);\n this.signatures.forEach((k: Ed25519Signature, i: number) => {\n bytes.set(k.toUint8Array(), i * Ed25519Signature.LENGTH);\n });\n\n bytes.set(this.bitmap, this.signatures.length * Ed25519Signature.LENGTH);\n\n return bytes;\n }\n\n // endregion\n\n // region Serializable\n\n serialize(serializer: Serializer): void {\n serializer.serializeBytes(this.toUint8Array());\n }\n\n static deserialize(deserializer: Deserializer): MultiEd25519Signature {\n const bytes = deserializer.deserializeBytes();\n const bitmap = bytes.subarray(bytes.length - 4);\n\n const signatures: Ed25519Signature[] = [];\n\n for (let i = 0; i < bytes.length - bitmap.length; i += Ed25519Signature.LENGTH) {\n const begin = i;\n signatures.push(new Ed25519Signature(bytes.subarray(begin, begin + Ed25519Signature.LENGTH)));\n }\n return new MultiEd25519Signature({ signatures, bitmap });\n }\n\n // endregion\n\n /**\n * Helper method to create a bitmap out of the specified bit positions.\n * This function allows you to set specific bits in a 32-bit long bitmap based on the provided positions.\n *\n * @param args The arguments for creating the bitmap.\n * @param args.bits The bitmap positions that should be set. A position starts at index 0. Valid positions should range between 0 and 31.\n *\n * @example\n * Here's an example of valid `bits`\n * ```\n * [0, 2, 31]\n * ```\n * `[0, 2, 31]` means the 1st, 3rd and 32nd bits should be set in the bitmap.\n * The result bitmap should be 0b1010000000000000000000000000001\n *\n * @returns bitmap that is 32 bits long.\n * @group Implementation\n * @category Serialization\n */\n static createBitmap(args: { bits: number[] }): Uint8Array {\n const { bits } = args;\n // Bits are read from left to right. e.g. 0b10000000 represents the first bit is set in one byte.\n // The decimal value of 0b10000000 is 128.\n const firstBitInByte = 128;\n const bitmap = new Uint8Array([0, 0, 0, 0]);\n\n // Check if duplicates exist in bits\n const dupCheckSet = new Set();\n\n bits.forEach((bit: number, index) => {\n if (bit >= MultiEd25519Signature.MAX_SIGNATURES_SUPPORTED) {\n throw new Error(`Cannot have a signature larger than ${MultiEd25519Signature.MAX_SIGNATURES_SUPPORTED - 1}.`);\n }\n\n if (dupCheckSet.has(bit)) {\n throw new Error(\"Duplicate bits detected.\");\n }\n\n if (index > 0 && bit <= bits[index - 1]) {\n throw new Error(\"The bits need to be sorted in ascending order.\");\n }\n\n dupCheckSet.add(bit);\n\n const byteOffset = Math.floor(bit / 8);\n\n let byte = bitmap[byteOffset];\n\n // eslint-disable-next-line no-bitwise\n byte |= firstBitInByte >> bit % 8;\n\n bitmap[byteOffset] = byte;\n });\n\n return bitmap;\n }\n}\n"],"mappings":"AAKA,OAAS,iBAAiBA,MAAyC,cACnE,OAAS,qBAAAC,MAAyB,uBAClC,OAAS,oBAAAC,EAAkB,oBAAAC,MAAwB,YACnD,OAAS,oBAAAC,MAAwB,aACjC,OAAS,aAAAC,MAAiB,cAanB,MAAMC,EAAN,MAAMA,UAA8BF,CAAiB,CAiD1D,YAAYG,EAA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AAM,CAAC,CAAC,CAC9F,CACA,OAAO,IAAIuB,EAAsB,CAAE,WAAAC,EAAY,OAAAC,CAAO,CAAC,CACzD,CAuBA,OAAO,aAAarB,EAAsC,CACxD,KAAM,CAAE,KAAAsB,CAAK,EAAItB,EAGXuB,EAAiB,IACjBF,EAAS,IAAI,WAAW,CAAC,EAAG,EAAG,EAAG,CAAC,CAAC,EAGpCG,EAAc,IAAI,IAExB,OAAAF,EAAK,QAAQ,CAACG,EAAajB,IAAU,CACnC,GAAIiB,GAAON,EAAsB,yBAC/B,MAAM,IAAI,MAAM,uCAAuCA,EAAsB,yBAA2B,CAAC,GAAG,EAG9G,GAAIK,EAAY,IAAIC,CAAG,EACrB,MAAM,IAAI,MAAM,0BAA0B,EAG5C,GAAIjB,EAAQ,GAAKiB,GAAOH,EAAKd,EAAQ,CAAC,EACpC,MAAM,IAAI,MAAM,gDAAgD,EAGlEgB,EAAY,IAAIC,CAAG,EAEnB,MAAMC,EAAa,KAAK,MAAMD,EAAM,CAAC,EAErC,IAAIE,EAAON,EAAOK,CAAU,EAG5BC,GAAQJ,GAAkBE,EAAM,EAEhCJ,EAAOK,CAAU,EAAIC,CACvB,CAAC,EAEMN,CACT,CACF,EAnKaF,EAMJ,yBAA2B,GANvBA,EAaJ,WAAqB,EAbvB,IAAMd,EAANc","names":["AuthenticationKeyScheme","AuthenticationKey","Ed25519PublicKey","Ed25519Signature","AbstractMultiKey","Signature","_MultiEd25519PublicKey","args","publicKeys","threshold","message","signature","MultiEd25519Signature","indices","j","index","bytes","k","i","serializer","deserializer","keys","begin","length","publicKey","MultiEd25519PublicKey","_MultiEd25519Signature","signatures","bitmap","bits","firstBitInByte","dupCheckSet","bit","byteOffset","byte"]}
@@ -1,4 +1,4 @@
1
- export { w as AbstractMultiKey, x as MultiKey, y as MultiKeySignature } from '../../account-ClxOwjdh.mjs';
1
+ export { w as AbstractMultiKey, x as MultiKey, y as MultiKeySignature } from '../../account-BortO8g2.mjs';
2
2
  import '../../types/indexer.mjs';
3
3
  import '../../types/generated/operations.mjs';
4
4
  import '../../types/generated/types.mjs';
@@ -1,2 +1,4 @@
1
- import{H as a,I as b,J as c}from"../../chunk-DIGP2ALY.mjs";import"../../chunk-5HXLZHDW.mjs";import"../../chunk-GOXRBEIJ.mjs";import"../../chunk-ROT6S6BM.mjs";import"../../chunk-XJJVJOX5.mjs";import"../../chunk-C3Q23D22.mjs";import"../../chunk-NECL5FCQ.mjs";import"../../chunk-4QMXOWHP.mjs";import"../../chunk-RQX6JOEN.mjs";import"../../chunk-WSR5EBJM.mjs";import"../../chunk-WCMW2L3P.mjs";import"../../chunk-G3MHXDYA.mjs";import"../../chunk-HNBKTJPN.mjs";import"../../chunk-V74WPKSY.mjs";import"../../chunk-UYVPNUH3.mjs";import"../../chunk-A5L76YP7.mjs";import"../../chunk-XKUIMGKU.mjs";import"../../chunk-N6YTF76Q.mjs";import"../../chunk-ZP4DWSQA.mjs";import"../../chunk-QREVMGQZ.mjs";import"../../chunk-FGFLPH5K.mjs";import"../../chunk-V3MBJJTL.mjs";import"../../chunk-ES2KP6BS.mjs";import"../../chunk-EM52Z7T7.mjs";import"../../chunk-TGRLDWXV.mjs";import"../../chunk-N3O3ULF7.mjs";import"../../chunk-YOZBVVKL.mjs";import"../../chunk-GMQCQDW4.mjs";import"../../chunk-UL777LTI.mjs";import"../../chunk-7ECCT6PK.mjs";import"../../chunk-DNRUDMMV.mjs";import"../../chunk-GFFKEZ56.mjs";import"../../chunk-LWL57YFU.mjs";import"../../chunk-HGLO5LDS.mjs";import"../../chunk-CW35YAMN.mjs";import"../../chunk-6WDVDEQZ.mjs";import"../../chunk-FZY4PMEE.mjs";import"../../chunk-TOBQ5UE6.mjs";import"../../chunk-MT2RJ7H3.mjs";import"../../chunk-Q4W3WJ2U.mjs";import"../../chunk-ORMOQWWH.mjs";import"../../chunk-FLZPUYXQ.mjs";import"../../chunk-7DQDJ2SA.mjs";import"../../chunk-HNBVYE3N.mjs";import"../../chunk-RGKRCZ36.mjs";import"../../chunk-FD6FGKYY.mjs";import"../../chunk-4WPQQPUF.mjs";import"../../chunk-IJE2LVZG.mjs";import"../../chunk-EBMEXURY.mjs";import"../../chunk-STY74NUA.mjs";import"../../chunk-IF4UU2MT.mjs";import"../../chunk-56CNRT2K.mjs";import"../../chunk-RCSJFTST.mjs";import"../../chunk-4RXKALLC.mjs";import"../../chunk-OLILO7VD.mjs";import"../../chunk-5FI4545P.mjs";import"../../chunk-KDMSOCZY.mjs";export{a as AbstractMultiKey,b as MultiKey,c as MultiKeySignature};
1
+ import{AnyPublicKeyVariant as f,SigningScheme as m}from"../../types";import{AuthenticationKey as d}from"../authenticationKey";import{AccountPublicKey as S}from"./publicKey";import{Signature as w}from"./signature";import{AnyPublicKey as c,AnySignature as g}from"./singleKey";function K(b){let e=b;return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}const l=3;class A extends S{constructor(e){super(),this.publicKeys=e.publicKeys}createBitmap(e){const{bits:t}=e,r=128,i=new Uint8Array([0,0,0,0]),n=new Set;return t.forEach((s,u)=>{if(u+1>this.publicKeys.length)throw new Error(`Signature index ${u+1} is out of public keys range, ${this.publicKeys.length}.`);if(n.has(s))throw new Error(`Duplicate bit ${s} detected.`);n.add(s);const o=Math.floor(s/8);let y=i[o];y|=r>>s%8,i[o]=y}),i}getIndex(e){const t=this.publicKeys.findIndex(r=>r.toString()===e.toString());if(t!==-1)return t;throw new Error(`Public key ${e} not found in multi key set ${this.publicKeys}`)}}class p extends A{constructor(e){const{publicKeys:t,signaturesRequired:r}=e;if(super({publicKeys:t}),r<1)throw new Error("The number of required signatures needs to be greater than 0");if(t.length<r)throw new Error(`Provided ${t.length} public keys is smaller than the ${r} required signatures`);if(this.publicKeys=t.map(i=>i instanceof c?i:new c(i)),r>l&&this.publicKeys.filter(n=>n.variant===f.Keyless||n.variant===f.FederatedKeyless).length>l)throw new Error(`Construction of MultiKey with more than ${l} keyless public keys is not allowed when signaturesRequired
2
+ is greater than ${l}. This is because a maximum of 3 keyless signatures are supported for a
3
+ K-of-N MultiKey transaction.`);this.signaturesRequired=r}getSignaturesRequired(){return this.signaturesRequired}verifySignature(e){const{message:t,signature:r}=e;if(r.signatures.length!==this.signaturesRequired)throw new Error("The number of signatures does not match the number of required signatures");const i=r.bitMapToSignerIndices();for(let n=0;n<r.signatures.length;n+=1){const s=r.signatures[n];if(!this.publicKeys[i[n]].verifySignature({message:t,signature:s}))return!1}return!0}async verifySignatureAsync(e){const{signature:t}=e;try{if(!(t instanceof h))throw new Error("Signature is not a MultiKeySignature");if(t.signatures.length!==this.signaturesRequired)throw new Error("The number of signatures does not match the number of required signatures");const r=t.bitMapToSignerIndices();for(let i=0;i<t.signatures.length;i+=1){const n=t.signatures[i];if(!await this.publicKeys[r[i]].verifySignatureAsync({...e,signature:n}))return!1}return!0}catch(r){if(e.options?.throwErrorWithReason)throw r;return!1}}authKey(){return d.fromSchemeAndBytes({scheme:m.MultiKey,input:this.toUint8Array()})}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){const t=e.deserializeVector(c),r=e.deserializeU8();return new p({publicKeys:t,signaturesRequired:r})}getIndex(e){const t=e instanceof c?e:new c(e);return super.getIndex(t)}static isInstance(e){return"publicKeys"in e&&"signaturesRequired"in e}}const a=class a extends w{constructor(e){super();const{signatures:t,bitmap:r}=e;if(t.length>a.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${a.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t.map(n=>n instanceof g?n:new g(n)),!(r instanceof Uint8Array))this.bitmap=a.createBitmap({bits:r});else{if(r.length!==a.BITMAP_LEN)throw new Error(`"bitmap" length should be ${a.BITMAP_LEN}`);this.bitmap=r}const i=this.bitmap.reduce((n,s)=>n+K(s),0);if(i!==this.signatures.length)throw new Error(`Expecting ${i} signatures from the bitmap, but got ${this.signatures.length}`)}static createBitmap(e){const{bits:t}=e,r=128,i=new Uint8Array([0,0,0,0]),n=new Set;return t.forEach(s=>{if(s>=a.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${a.MAX_SIGNATURES_SUPPORTED-1}.`);if(n.has(s))throw new Error("Duplicate bits detected.");n.add(s);const u=Math.floor(s/8);let o=i[u];o|=r>>s%8,i[u]=o}),i}bitMapToSignerIndices(){const e=[];for(let t=0;t<this.bitmap.length;t+=1){const r=this.bitmap[t];for(let i=0;i<8;i+=1)(r&128>>i)!==0&&e.push(t*8+i)}return e}serialize(e){e.serializeVector(this.signatures),e.serializeBytes(this.bitmap)}static deserialize(e){const t=e.deserializeVector(g),r=e.deserializeBytes();return new a({signatures:t,bitmap:r})}};a.BITMAP_LEN=4,a.MAX_SIGNATURES_SUPPORTED=a.BITMAP_LEN*8;let h=a;export{A as AbstractMultiKey,p as MultiKey,h as MultiKeySignature};
2
4
  //# sourceMappingURL=multiKey.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../../src/core/crypto/multiKey.ts"],"sourcesContent":["import { AnyPublicKeyVariant, SigningScheme as AuthenticationKeyScheme, HexInput } from \"../../types\";\nimport { Deserializer } from \"../../bcs/deserializer\";\nimport { Serializer } from \"../../bcs/serializer\";\nimport { AuthenticationKey } from \"../authenticationKey\";\nimport { AccountPublicKey, PublicKey, VerifySignatureAsyncArgs } from \"./publicKey\";\nimport { Signature } from \"./signature\";\nimport { AnyPublicKey, AnySignature } from \"./singleKey\";\nimport { AptosConfig } from \"../../api\";\n\n/**\n * Counts the number of set bits (1s) in a byte.\n * This function can help you determine the population count of a given byte value.\n *\n * @param byte - The byte value for which to count the number of set bits.\n * @group Implementation\n * @category Serialization\n */\n/* eslint-disable no-bitwise */\nfunction bitCount(byte: number) {\n let n = byte;\n n -= (n >> 1) & 0x55555555;\n n = (n & 0x33333333) + ((n >> 2) & 0x33333333);\n return (((n + (n >> 4)) & 0xf0f0f0f) * 0x1010101) >> 24;\n}\n/* eslint-enable no-bitwise */\n\nconst MAX_NUM_KEYLESS_PUBLIC_FOR_MULTI_KEY = 3;\nexport abstract class AbstractMultiKey extends AccountPublicKey {\n publicKeys: PublicKey[];\n\n constructor(args: { publicKeys: PublicKey[] }) {\n super();\n this.publicKeys = args.publicKeys;\n }\n\n /**\n * Create a bitmap that holds the mapping from the original public keys\n * to the signatures passed in\n *\n * @param args.bits array of the index mapping to the matching public keys\n * @returns Uint8array bit map\n * @group Implementation\n * @category Serialization\n */\n createBitmap(args: { bits: number[] }): Uint8Array {\n const { bits } = args;\n // Bits are read from left to right. e.g. 0b10000000 represents the first bit is set in one byte.\n // The decimal value of 0b10000000 is 128.\n const firstBitInByte = 128;\n const bitmap = new Uint8Array([0, 0, 0, 0]);\n\n // Check if duplicates exist in bits\n const dupCheckSet = new Set();\n\n bits.forEach((bit: number, idx: number) => {\n if (idx + 1 > this.publicKeys.length) {\n throw new Error(`Signature index ${idx + 1} is out of public keys range, ${this.publicKeys.length}.`);\n }\n\n if (dupCheckSet.has(bit)) {\n throw new Error(`Duplicate bit ${bit} detected.`);\n }\n\n dupCheckSet.add(bit);\n\n const byteOffset = Math.floor(bit / 8);\n\n let byte = bitmap[byteOffset];\n\n // eslint-disable-next-line no-bitwise\n byte |= firstBitInByte >> bit % 8;\n\n bitmap[byteOffset] = byte;\n });\n\n return bitmap;\n }\n\n /**\n * Get the index of the provided public key.\n *\n * This function retrieves the index of a specified public key within the MultiKey.\n * If the public key does not exist, it throws an error.\n *\n * @param publicKey - The public key to find the index for.\n * @returns The corresponding index of the public key, if it exists.\n * @throws Error - If the public key is not found in the MultiKey.\n * @group Implementation\n * @category Serialization\n */\n getIndex(publicKey: PublicKey): number {\n const index = this.publicKeys.findIndex((pk) => pk.toString() === publicKey.toString());\n\n if (index !== -1) {\n return index;\n }\n throw new Error(`Public key ${publicKey} not found in multi key set ${this.publicKeys}`);\n }\n\n abstract getSignaturesRequired(): number;\n}\n\n/**\n * Represents a multi-key authentication scheme for accounts, allowing multiple public keys\n * to be associated with a single account. This class enforces a minimum number of valid signatures\n * required to authorize actions, ensuring enhanced security for multi-agent accounts.\n *\n * The public keys of each individual agent can be any type of public key supported by Aptos.\n * Since [AIP-55](https://github.com/aptos-foundation/AIPs/pull/263), Aptos supports\n * `Legacy` and `Unified` authentication keys.\n * @group Implementation\n * @category Serialization\n */\nexport class MultiKey extends AbstractMultiKey {\n /**\n * List of any public keys\n * @group Implementation\n * @category Serialization\n */\n public readonly publicKeys: AnyPublicKey[];\n\n /**\n * The minimum number of valid signatures required, for the number of public keys specified\n * @group Implementation\n * @category Serialization\n */\n public readonly signaturesRequired: number;\n\n /**\n * Signature for a K-of-N multi-sig transaction.\n * This constructor initializes a multi-signature transaction with the provided signatures and bitmap.\n *\n * @param args An object containing the parameters for the multi-signature transaction.\n * @param args.signatures A list of signatures.\n * @param args.bitmap A bitmap represented as a Uint8Array or an array of numbers, where each bit indicates whether a\n * corresponding signature is present. A maximum of 32 signatures is supported, and the length of the bitmap must be 4 bytes.\n *\n * @throws Error if the number of signatures exceeds the maximum supported, if the bitmap length is incorrect, or if the number\n * of signatures does not match the bitmap.\n * @group Implementation\n * @category Serialization\n */\n // region Constructors\n constructor(args: { publicKeys: Array<PublicKey>; signaturesRequired: number }) {\n const { publicKeys, signaturesRequired } = args;\n super({ publicKeys });\n\n // Validate number of public keys is greater than signature required\n if (signaturesRequired < 1) {\n throw new Error(\"The number of required signatures needs to be greater than 0\");\n }\n\n // Validate number of public keys is greater than signature required\n if (publicKeys.length < signaturesRequired) {\n throw new Error(\n `Provided ${publicKeys.length} public keys is smaller than the ${signaturesRequired} required signatures`,\n );\n }\n\n // Make sure that all keys are normalized to the SingleKey authentication scheme\n this.publicKeys = publicKeys.map((publicKey) =>\n publicKey instanceof AnyPublicKey ? publicKey : new AnyPublicKey(publicKey),\n );\n if (signaturesRequired > MAX_NUM_KEYLESS_PUBLIC_FOR_MULTI_KEY) {\n const keylessCount = this.publicKeys.filter(\n (pk) => pk.variant === AnyPublicKeyVariant.Keyless || pk.variant === AnyPublicKeyVariant.FederatedKeyless,\n ).length;\n if (keylessCount > MAX_NUM_KEYLESS_PUBLIC_FOR_MULTI_KEY) {\n throw new Error(\n `Construction of MultiKey with more than ${MAX_NUM_KEYLESS_PUBLIC_FOR_MULTI_KEY} keyless public keys is not allowed when signaturesRequired \n is greater than ${MAX_NUM_KEYLESS_PUBLIC_FOR_MULTI_KEY}. This is because a maximum of 3 keyless signatures are supported for a \n K-of-N MultiKey transaction.`,\n );\n }\n }\n\n this.signaturesRequired = signaturesRequired;\n }\n\n getSignaturesRequired(): number {\n return this.signaturesRequired;\n }\n\n // endregion\n\n // region AccountPublicKey\n\n /**\n * Verifies the provided signature against the given message.\n * This function helps ensure the integrity and authenticity of the message by checking if the signature is valid.\n *\n * Note: This function will fail if a keyless signature is used. Use `verifySignatureAsync` instead.\n *\n * @param args - The arguments for verifying the signature.\n * @param args.message - The message that was signed.\n * @param args.signature - The signature to verify.\n * @group Implementation\n * @category Serialization\n */\n verifySignature(args: { message: HexInput; signature: MultiKeySignature }): boolean {\n const { message, signature } = args;\n if (signature.signatures.length !== this.signaturesRequired) {\n throw new Error(\"The number of signatures does not match the number of required signatures\");\n }\n const signerIndices = signature.bitMapToSignerIndices();\n for (let i = 0; i < signature.signatures.length; i += 1) {\n const singleSignature = signature.signatures[i];\n const publicKey = this.publicKeys[signerIndices[i]];\n if (!publicKey.verifySignature({ message, signature: singleSignature })) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Verifies the provided signature against the given message.\n * This function helps ensure the integrity and authenticity of the message by checking if the signature is valid.\n *\n * @param args - The arguments for verifying the signature.\n * @param args.aptosConfig - The Aptos configuration to use\n * @param args.message - The message that was signed.\n * @param args.signature - The signature to verify.\n * @group Implementation\n * @category Serialization\n */\n async verifySignatureAsync(args: {\n aptosConfig: AptosConfig;\n message: HexInput;\n signature: Signature;\n options?: { throwErrorWithReason?: boolean };\n }): Promise<boolean> {\n const { signature } = args;\n try {\n if (!(signature instanceof MultiKeySignature)) {\n throw new Error(\"Signature is not a MultiKeySignature\");\n }\n if (signature.signatures.length !== this.signaturesRequired) {\n throw new Error(\"The number of signatures does not match the number of required signatures\");\n }\n const signerIndices = signature.bitMapToSignerIndices();\n for (let i = 0; i < signature.signatures.length; i += 1) {\n const singleSignature = signature.signatures[i];\n const publicKey = this.publicKeys[signerIndices[i]];\n if (!(await publicKey.verifySignatureAsync({ ...args, signature: singleSignature }))) {\n return false;\n }\n }\n return true;\n } catch (error) {\n if (args.options?.throwErrorWithReason) {\n throw error;\n }\n return false;\n }\n }\n\n /**\n * Generates an authentication key based on the current instance's byte representation.\n * This key can be used for secure authentication processes within the system.\n *\n * @returns {AuthenticationKey} The generated authentication key.\n * @group Implementation\n * @category Serialization\n */\n authKey(): AuthenticationKey {\n return AuthenticationKey.fromSchemeAndBytes({\n scheme: AuthenticationKeyScheme.MultiKey,\n input: this.toUint8Array(),\n });\n }\n\n // endregion\n\n // region Serializable\n\n /**\n * Serializes the object by writing its signatures and bitmap to the provided serializer.\n * This allows the object to be converted into a format suitable for transmission or storage.\n *\n * @param serializer - The serializer instance used to perform the serialization.\n * @group Implementation\n * @category Serialization\n */\n serialize(serializer: Serializer): void {\n serializer.serializeVector(this.publicKeys);\n serializer.serializeU8(this.signaturesRequired);\n }\n\n /**\n * Deserializes a MultiKeySignature from the provided deserializer.\n * This function retrieves the signatures and bitmap necessary for creating a MultiKeySignature object.\n *\n * @param deserializer - The deserializer instance used to read the serialized data.\n * @group Implementation\n * @category Serialization\n */\n static deserialize(deserializer: Deserializer): MultiKey {\n const keys = deserializer.deserializeVector(AnyPublicKey);\n const signaturesRequired = deserializer.deserializeU8();\n\n return new MultiKey({ publicKeys: keys, signaturesRequired });\n }\n\n // endregion\n\n /**\n * Get the index of the provided public key.\n *\n * This function retrieves the index of a specified public key within the MultiKey.\n * If the public key does not exist, it throws an error.\n *\n * @param publicKey - The public key to find the index for.\n * @returns The corresponding index of the public key, if it exists.\n * @throws Error - If the public key is not found in the MultiKey.\n * @group Implementation\n */\n getIndex(publicKey: PublicKey): number {\n const anyPublicKey = publicKey instanceof AnyPublicKey ? publicKey : new AnyPublicKey(publicKey);\n return super.getIndex(anyPublicKey);\n }\n\n public static isInstance(value: PublicKey): value is MultiKey {\n return \"publicKeys\" in value && \"signaturesRequired\" in value;\n }\n}\n\n/**\n * Represents a multi-signature transaction using Ed25519 signatures.\n * This class allows for the creation and management of a K-of-N multi-signature scheme,\n * where a specified number of signatures are required to authorize a transaction.\n *\n * It includes functionality to validate the number of signatures against a bitmap,\n * which indicates which public keys have signed the transaction.\n * @group Implementation\n * @category Serialization\n */\nexport class MultiKeySignature extends Signature {\n /**\n * Number of bytes in the bitmap representing who signed the transaction (32-bits)\n * @group Implementation\n * @category Serialization\n */\n static BITMAP_LEN: number = 4;\n\n /**\n * Maximum number of Ed25519 signatures supported\n * @group Implementation\n * @category Serialization\n */\n static MAX_SIGNATURES_SUPPORTED = MultiKeySignature.BITMAP_LEN * 8;\n\n /**\n * The list of underlying Ed25519 signatures\n * @group Implementation\n * @category Serialization\n */\n public readonly signatures: AnySignature[];\n\n /**\n * 32-bit Bitmap representing who signed the transaction\n *\n * This is represented where each public key can be masked to determine whether the message was signed by that key.\n * @group Implementation\n * @category Serialization\n */\n public readonly bitmap: Uint8Array;\n\n /**\n * Signature for a K-of-N multi-sig transaction.\n *\n * @see {@link\n * https://aptos.dev/integration/creating-a-signed-transaction/#multisignature-transactions | Creating a Signed Transaction}\n *\n * @param args.signatures A list of signatures\n * @param args.bitmap 4 bytes, at most 32 signatures are supported. If Nth bit value is `1`, the Nth\n * signature should be provided in `signatures`. Bits are read from left to right\n * @group Implementation\n * @category Serialization\n */\n constructor(args: { signatures: Array<Signature | AnySignature>; bitmap: Uint8Array | number[] }) {\n super();\n const { signatures, bitmap } = args;\n\n if (signatures.length > MultiKeySignature.MAX_SIGNATURES_SUPPORTED) {\n throw new Error(`The number of signatures cannot be greater than ${MultiKeySignature.MAX_SIGNATURES_SUPPORTED}`);\n }\n\n // Make sure that all signatures are normalized to the SingleKey authentication scheme\n this.signatures = signatures.map((signature) =>\n signature instanceof AnySignature ? signature : new AnySignature(signature),\n );\n\n if (!(bitmap instanceof Uint8Array)) {\n this.bitmap = MultiKeySignature.createBitmap({ bits: bitmap });\n } else if (bitmap.length !== MultiKeySignature.BITMAP_LEN) {\n throw new Error(`\"bitmap\" length should be ${MultiKeySignature.BITMAP_LEN}`);\n } else {\n this.bitmap = bitmap;\n }\n\n const nSignatures = this.bitmap.reduce((acc, byte) => acc + bitCount(byte), 0);\n if (nSignatures !== this.signatures.length) {\n throw new Error(`Expecting ${nSignatures} signatures from the bitmap, but got ${this.signatures.length}`);\n }\n }\n\n /**\n * Helper method to create a bitmap out of the specified bit positions\n * @param args.bits The bitmap positions that should be set. A position starts at index 0.\n * Valid position should range between 0 and 31.\n * @example\n * Here's an example of valid `bits`\n * ```\n * [0, 2, 31]\n * ```\n * `[0, 2, 31]` means the 1st, 3rd and 32nd bits should be set in the bitmap.\n * The result bitmap should be 0b1010000000000000000000000000001\n *\n * @returns bitmap that is 32bit long\n * @group Implementation\n * @category Serialization\n */\n static createBitmap(args: { bits: number[] }): Uint8Array {\n const { bits } = args;\n // Bits are read from left to right. e.g. 0b10000000 represents the first bit is set in one byte.\n // The decimal value of 0b10000000 is 128.\n const firstBitInByte = 128;\n const bitmap = new Uint8Array([0, 0, 0, 0]);\n\n // Check if duplicates exist in bits\n const dupCheckSet = new Set();\n\n bits.forEach((bit: number) => {\n if (bit >= MultiKeySignature.MAX_SIGNATURES_SUPPORTED) {\n throw new Error(`Cannot have a signature larger than ${MultiKeySignature.MAX_SIGNATURES_SUPPORTED - 1}.`);\n }\n\n if (dupCheckSet.has(bit)) {\n throw new Error(\"Duplicate bits detected.\");\n }\n\n dupCheckSet.add(bit);\n\n const byteOffset = Math.floor(bit / 8);\n\n let byte = bitmap[byteOffset];\n\n // eslint-disable-next-line no-bitwise\n byte |= firstBitInByte >> bit % 8;\n\n bitmap[byteOffset] = byte;\n });\n\n return bitmap;\n }\n\n /**\n * Converts the bitmap to an array of signer indices.\n *\n * Example:\n *\n * bitmap: [0b10001000, 0b01000000, 0b00000000, 0b00000000]\n * signerIndices: [0, 4, 9]\n *\n * @returns An array of signer indices.\n * @group Implementation\n * @category Serialization\n */\n bitMapToSignerIndices(): number[] {\n const signerIndices: number[] = [];\n for (let i = 0; i < this.bitmap.length; i += 1) {\n const byte = this.bitmap[i];\n for (let bit = 0; bit < 8; bit += 1) {\n if ((byte & (128 >> bit)) !== 0) {\n signerIndices.push(i * 8 + bit);\n }\n }\n }\n return signerIndices;\n }\n\n // region Serializable\n\n serialize(serializer: Serializer): void {\n // Note: we should not need to serialize the vector length, as it can be derived from the bitmap\n serializer.serializeVector(this.signatures);\n serializer.serializeBytes(this.bitmap);\n }\n\n static deserialize(deserializer: Deserializer): MultiKeySignature {\n const signatures = deserializer.deserializeVector(AnySignature);\n const bitmap = deserializer.deserializeBytes();\n return new MultiKeySignature({ signatures, bitmap });\n }\n\n // endregion\n}\n"],"mappings":"AAAA,OAAS,uBAAAA,EAAqB,iBAAiBC,MAAyC,cAGxF,OAAS,qBAAAC,MAAyB,uBAClC,OAAS,oBAAAC,MAA6D,cACtE,OAAS,aAAAC,MAAiB,cAC1B,OAAS,gBAAAC,EAAc,gBAAAC,MAAoB,cAY3C,SAASC,EAASC,EAAc,CAC9B,IAAIC,EAAID,EACR,OAAAC,GAAMA,GAAK,EAAK,WAChBA,GAAKA,EAAI,YAAgBA,GAAK,EAAK,YACzBA,GAAKA,GAAK,GAAM,WAAa,UAAc,EACvD,CAGA,MAAMC,EAAuC,EACtC,MAAeC,UAAyBR,CAAiB,CAG9D,YAAYS,EAAmC,CAC7C,MAAM,EACN,KAAK,WAAaA,EAAK,UACzB,CAWA,aAAaA,EAAsC,CACjD,KAAM,CAAE,KAAAC,CAAK,EAAID,EAGXE,EAAiB,IACjBC,EAAS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,CAAE,KAAAC,CAAK,EAAID,EAGXE,EAAiB,IACjBC,EAAS,IAAI,WAAW,CAAC,EAAG,EAAG,EAAG,CAAC,CAAC,EAGpCC,EAAc,IAAI,IAExB,OAAAH,EAAK,QAASI,GAAgB,CAC5B,GAAIA,GAAOqB,EAAkB,yBAC3B,MAAM,IAAI,MAAM,uCAAuCA,EAAkB,yBAA2B,CAAC,GAAG,EAG1G,GAAItB,EAAY,IAAIC,CAAG,EACrB,MAAM,IAAI,MAAM,0BAA0B,EAG5CD,EAAY,IAAIC,CAAG,EAEnB,MAAME,EAAa,KAAK,MAAMF,EAAM,CAAC,EAErC,IAAIT,EAAOO,EAAOI,CAAU,EAG5BX,GAAQM,GAAkBG,EAAM,EAEhCF,EAAOI,CAAU,EAAIX,CACvB,CAAC,EAEMO,CACT,CAcA,uBAAkC,CAChC,MAAMa,EAA0B,CAAC,EACjC,QAASC,EAAI,EAAGA,EAAI,KAAK,OAAO,OAAQA,GAAK,EAAG,CAC9C,MAAMrB,EAAO,KAAK,OAAOqB,CAAC,EAC1B,QAASZ,EAAM,EAAGA,EAAM,EAAGA,GAAO,GAC3BT,EAAQ,KAAOS,KAAU,GAC5BW,EAAc,KAAKC,EAAI,EAAIZ,CAAG,CAGpC,CACA,OAAOW,CACT,CAIA,UAAUK,EAA8B,CAEtCA,EAAW,gBAAgB,KAAK,UAAU,EAC1CA,EAAW,eAAe,KAAK,MAAM,CACvC,CAEA,OAAO,YAAYC,EAA+C,CAChE,MAAMK,EAAaL,EAAa,kBAAkB5B,CAAY,EACxDS,EAASmB,EAAa,iBAAiB,EAC7C,OAAO,IAAII,EAAkB,CAAE,WAAAC,EAAY,OAAAxB,CAAO,CAAC,CACrD,CAGF,EAhKauB,EAMJ,WAAqB,EANjBA,EAaJ,yBAA2BA,EAAkB,WAAa,EAb5D,IAAMP,EAANO","names":["AnyPublicKeyVariant","AuthenticationKeyScheme","AuthenticationKey","AccountPublicKey","Signature","AnyPublicKey","AnySignature","bitCount","byte","n","MAX_NUM_KEYLESS_PUBLIC_FOR_MULTI_KEY","AbstractMultiKey","args","bits","firstBitInByte","bitmap","dupCheckSet","bit","idx","byteOffset","publicKey","index","pk","MultiKey","publicKeys","signaturesRequired","message","signature","signerIndices","i","singleSignature","MultiKeySignature","error","serializer","deserializer","keys","anyPublicKey","value","_MultiKeySignature","signatures","nSignatures","acc"]}
@@ -1,2 +1,2 @@
1
- import{a,b,c,d,e}from"../../chunk-GOXRBEIJ.mjs";import"../../chunk-KDMSOCZY.mjs";export{d as bigIntToBytesLE,c as bytesToBigIntLE,a as hashStrToField,b as padAndPackBytesWithLen,e as poseidonHash};
1
+ import{poseidon1 as h,poseidon2 as u,poseidon3 as a,poseidon4 as l,poseidon5 as c,poseidon6 as d,poseidon7 as p,poseidon8 as f,poseidon9 as A,poseidon10 as U,poseidon11 as b,poseidon12 as w,poseidon13 as E,poseidon14 as I,poseidon15 as y,poseidon16 as B}from"poseidon-lite";const i=[h,u,a,l,c,d,p,f,A,U,b,w,E,I,y,B],s=31,m=16,g=(m-1)*s;function C(n,t){const o=new TextEncoder().encode(n);return $(o,t)}function $(n,t){if(n.length>t)throw new Error(`Inputted bytes of length ${n} is longer than ${t}`);const r=_(n,t);return M(r)}function T(n,t){if(n.length>t)throw new Error(`Input bytes of length ${n} is longer than ${t}`);const r=k(n,t);return P(r)}function _(n,t){if(n.length>t)throw new Error(`Input bytes of length ${n} is longer than ${t}`);return T(n,t).concat([BigInt(n.length)])}function P(n){if(n.length>g)throw new Error(`Can't pack more than ${g}. Was given ${n.length} bytes`);return L(n,s).map(t=>N(t))}function L(n,t){const r=[];for(let o=0;o<n.length;o+=t)r.push(n.subarray(o,o+t));return r}function N(n){let t=BigInt(0);for(let r=n.length-1;r>=0;r-=1)t=t<<BigInt(8)|BigInt(n[r]);return t}function W(n,t){let r=BigInt(n);const o=new Uint8Array(t);for(let e=0;e<t;e+=1)o[e]=Number(r&BigInt(255)),r>>=BigInt(8);return o}function k(n,t){if(t<n.length)throw new Error("Padded size must be greater than or equal to the input array size.");const r=new Uint8Array(t);r.set(n);for(let o=n.length;o<t;o+=1)r[o]=0;return r}function M(n){if(n.length>i.length)throw new Error(`Unable to hash input of length ${n.length}. Max input length is ${i.length}`);return i[n.length-1](n)}export{W as bigIntToBytesLE,N as bytesToBigIntLE,C as hashStrToField,_ as padAndPackBytesWithLen,M as poseidonHash};
2
2
  //# sourceMappingURL=poseidon.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../../src/core/crypto/poseidon.ts"],"sourcesContent":["/* eslint-disable no-bitwise */\nimport {\n poseidon1,\n poseidon2,\n poseidon3,\n poseidon4,\n poseidon5,\n poseidon6,\n poseidon7,\n poseidon8,\n poseidon9,\n poseidon10,\n poseidon11,\n poseidon12,\n poseidon13,\n poseidon14,\n poseidon15,\n poseidon16,\n} from \"poseidon-lite\";\n\nconst numInputsToPoseidonFunc = [\n poseidon1,\n poseidon2,\n poseidon3,\n poseidon4,\n poseidon5,\n poseidon6,\n poseidon7,\n poseidon8,\n poseidon9,\n poseidon10,\n poseidon11,\n poseidon12,\n poseidon13,\n poseidon14,\n poseidon15,\n poseidon16,\n];\n\nconst BYTES_PACKED_PER_SCALAR = 31;\nconst MAX_NUM_INPUT_SCALARS = 16;\nconst MAX_NUM_INPUT_BYTES = (MAX_NUM_INPUT_SCALARS - 1) * BYTES_PACKED_PER_SCALAR;\n\n/**\n * Hashes a string to a field element via Poseidon hashing.\n * This function is useful for converting a string into a fixed-size hash that can be used in cryptographic applications.\n *\n * @param str - The string to be hashed.\n * @param maxSizeBytes - The maximum size in bytes for the resulting hash.\n * @returns bigint - The result of the hash.\n * @group Implementation\n * @category Serialization\n */\nexport function hashStrToField(str: string, maxSizeBytes: number): bigint {\n const textEncoder = new TextEncoder();\n const strBytes = textEncoder.encode(str);\n return hashBytesWithLen(strBytes, maxSizeBytes);\n}\n\n/**\n * Computes a Poseidon hash of the provided byte array, ensuring that the byte array does not exceed the specified maximum size.\n * This function is useful for generating a hash from a byte array while enforcing size constraints.\n *\n * @param bytes - The byte array to be hashed.\n * @param maxSizeBytes - The maximum allowed size for the byte array.\n * @throws Error if the length of the inputted bytes exceeds the specified maximum size.\n * @group Implementation\n * @category Serialization\n */\nfunction hashBytesWithLen(bytes: Uint8Array, maxSizeBytes: number): bigint {\n if (bytes.length > maxSizeBytes) {\n throw new Error(`Inputted bytes of length ${bytes} is longer than ${maxSizeBytes}`);\n }\n const packed = padAndPackBytesWithLen(bytes, maxSizeBytes);\n return poseidonHash(packed);\n}\n\n/**\n * Pads the input byte array with zeros to a specified maximum size and then packs the bytes.\n * This function ensures that the byte array does not exceed the specified maximum size, throwing an error if it does.\n *\n * @param bytes - The byte array to be padded and packed.\n * @param maxSizeBytes - The maximum size in bytes that the input array can have.\n * @throws Error if the input byte array exceeds the specified maximum size.\n * @group Implementation\n * @category Serialization\n */\nfunction padAndPackBytesNoLen(bytes: Uint8Array, maxSizeBytes: number): bigint[] {\n if (bytes.length > maxSizeBytes) {\n throw new Error(`Input bytes of length ${bytes} is longer than ${maxSizeBytes}`);\n }\n const paddedStrBytes = padUint8ArrayWithZeros(bytes, maxSizeBytes);\n return packBytes(paddedStrBytes);\n}\n\n/**\n * Pads and packs the given byte array to a specified maximum size and appends its length.\n * This function ensures that the byte array does not exceed the maximum size, throwing an error if it does.\n * It is useful for preparing byte data for further processing or transmission by ensuring a consistent format.\n *\n * @param bytes - The byte array to be padded and packed.\n * @param maxSizeBytes - The maximum allowed size for the byte array.\n * @throws Error if the length of the input bytes exceeds the maximum size.\n * @returns A new Uint8Array that contains the padded and packed bytes along with the length of the original byte array.\n * @group Implementation\n * @category Serialization\n */\nexport function padAndPackBytesWithLen(bytes: Uint8Array, maxSizeBytes: number): bigint[] {\n if (bytes.length > maxSizeBytes) {\n throw new Error(`Input bytes of length ${bytes} is longer than ${maxSizeBytes}`);\n }\n return padAndPackBytesNoLen(bytes, maxSizeBytes).concat([BigInt(bytes.length)]);\n}\n\n/**\n * Packs a Uint8Array into an array of BigInts, ensuring the input does not exceed the maximum allowed bytes.\n * @param bytes - The Uint8Array to be packed.\n * @throws {Error} Throws an error if the input exceeds the maximum number of bytes allowed.\n * @group Implementation\n * @category Serialization\n */\nfunction packBytes(bytes: Uint8Array): bigint[] {\n if (bytes.length > MAX_NUM_INPUT_BYTES) {\n throw new Error(`Can't pack more than ${MAX_NUM_INPUT_BYTES}. Was given ${bytes.length} bytes`);\n }\n return chunkUint8Array(bytes, BYTES_PACKED_PER_SCALAR).map((chunk) => bytesToBigIntLE(chunk));\n}\n\n/**\n * Splits a Uint8Array into smaller chunks of the specified size.\n * This function is useful for processing large arrays in manageable segments.\n *\n * @param array - The Uint8Array to be split into chunks.\n * @param chunkSize - The size of each chunk.\n * @returns An array of Uint8Array chunks.\n * @group Implementation\n * @category Serialization\n */\nfunction chunkUint8Array(array: Uint8Array, chunkSize: number): Uint8Array[] {\n const result: Uint8Array[] = [];\n for (let i = 0; i < array.length; i += chunkSize) {\n result.push(array.subarray(i, i + chunkSize));\n }\n return result;\n}\n\n/**\n * Converts a little-endian byte array into a BigInt.\n * This function is useful for interpreting byte data as a numerical value in a way that respects the little-endian format.\n *\n * @param bytes - The byte array to convert.\n * @returns The resulting BigInt representation of the byte array.\n * @group Implementation\n * @category Serialization\n */\nexport function bytesToBigIntLE(bytes: Uint8Array): bigint {\n let result = BigInt(0);\n for (let i = bytes.length - 1; i >= 0; i -= 1) {\n result = (result << BigInt(8)) | BigInt(bytes[i]);\n }\n return result;\n}\n\n/**\n * Converts a bigint value into a little-endian byte array of a specified length.\n * This function is useful for representing large integers in a byte format, which is often required for cryptographic operations\n * or binary data manipulation.\n *\n * @param value - The number to convert into bytes.\n * @param length - The desired length of the resulting byte array.\n * @returns A Uint8Array containing the little-endian representation of the bigint value.\n * @group Implementation\n * @category Serialization\n */\nexport function bigIntToBytesLE(value: bigint | number, length: number): Uint8Array {\n let val = BigInt(value);\n const bytes = new Uint8Array(length);\n for (let i = 0; i < length; i += 1) {\n bytes[i] = Number(val & BigInt(0xff));\n val >>= BigInt(8);\n }\n return bytes;\n}\n\n/**\n * Pads the input Uint8Array with zeros to achieve the specified size.\n * This function is useful for ensuring that a byte array meets a required length for further processing.\n *\n * @param inputArray - The Uint8Array to be padded.\n * @param paddedSize - The desired size of the padded array, which must be greater than or equal to the input array size.\n * @throws Error if paddedSize is less than the length of inputArray.\n * @group Implementation\n * @category Serialization\n */\nfunction padUint8ArrayWithZeros(inputArray: Uint8Array, paddedSize: number): Uint8Array {\n if (paddedSize < inputArray.length) {\n throw new Error(\"Padded size must be greater than or equal to the input array size.\");\n }\n\n // Create a new Uint8Array with the padded size\n const paddedArray = new Uint8Array(paddedSize);\n\n // Copy the content of the input array to the new array\n paddedArray.set(inputArray);\n\n // Fill the remaining space with zeros\n for (let i = inputArray.length; i < paddedSize; i += 1) {\n paddedArray[i] = 0;\n }\n\n return paddedArray;\n}\n\n/**\n * Hashes up to 16 scalar elements via the Poseidon hashing algorithm.\n * Each element must be scalar fields of the BN254 elliptic curve group.\n *\n * @param inputs - An array of elements to be hashed, which can be of type number, bigint, or string.\n * @returns bigint - The result of the hash.\n * @throws Error - Throws an error if the input length exceeds the maximum allowed.\n * @group Implementation\n * @category Serialization\n */\nexport function poseidonHash(inputs: (number | bigint | string)[]): bigint {\n if (inputs.length > numInputsToPoseidonFunc.length) {\n throw new Error(\n `Unable to hash input of length ${inputs.length}. Max input length is ${numInputsToPoseidonFunc.length}`,\n );\n }\n return numInputsToPoseidonFunc[inputs.length - 1](inputs);\n}\n"],"mappings":"AACA,OACE,aAAAA,EACA,aAAAC,EACA,aAAAC,EACA,aAAAC,EACA,aAAAC,EACA,aAAAC,EACA,aAAAC,EACA,aAAAC,EACA,aAAAC,EACA,cAAAC,EACA,cAAAC,EACA,cAAAC,EACA,cAAAC,EACA,cAAAC,EACA,cAAAC,EACA,cAAAC,MACK,gBAEP,MAAMC,EAA0B,CAC9Bh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EAAO,KAAKF,EAAM,SAASG,EAAGA,EAAIF,CAAS,CAAC,EAE9C,OAAOC,CACT,CAWO,SAASH,EAAgBV,EAA2B,CACzD,IAAIa,EAAS,OAAO,CAAC,EACrB,QAASC,EAAId,EAAM,OAAS,EAAGc,GAAK,EAAGA,GAAK,EAC1CD,EAAUA,GAAU,OAAO,CAAC,EAAK,OAAOb,EAAMc,CAAC,CAAC,EAElD,OAAOD,CACT,CAaO,SAASE,EAAgBC,EAAwBC,EAA4B,CAClF,IAAIC,EAAM,OAAOF,CAAK,EACtB,MAAMhB,EAAQ,IAAI,WAAWiB,CAAM,EACnC,QAASH,EAAI,EAAGA,EAAIG,EAAQH,GAAK,EAC/Bd,EAAMc,CAAC,EAAI,OAAOI,EAAM,OAAO,GAAI,CAAC,EACpCA,IAAQ,OAAO,CAAC,EAElB,OAAOlB,CACT,CAYA,SAASM,EAAuBa,EAAwBC,EAAgC,CACtF,GAAIA,EAAaD,EAAW,OAC1B,MAAM,IAAI,MAAM,oEAAoE,EAItF,MAAME,EAAc,IAAI,WAAWD,CAAU,EAG7CC,EAAY,IAAIF,CAAU,EAG1B,QAASL,EAAIK,EAAW,OAAQL,EAAIM,EAAYN,GAAK,EACnDO,EAAYP,CAAC,EAAI,EAGnB,OAAOO,CACT,CAYO,SAASlB,EAAamB,EAA8C,CACzE,GAAIA,EAAO,OAAS/B,EAAwB,OAC1C,MAAM,IAAI,MACR,kCAAkC+B,EAAO,MAAM,0BAA0B/B,EAAwB,MAAM,EACzG,EAEF,OAAOA,EAAwB+B,EAAO,OAAS,CAAC,EAAEA,CAAM,CAC1D","names":["poseidon1","poseidon2","poseidon3","poseidon4","poseidon5","poseidon6","poseidon7","poseidon8","poseidon9","poseidon10","poseidon11","poseidon12","poseidon13","poseidon14","poseidon15","poseidon16","numInputsToPoseidonFunc","BYTES_PACKED_PER_SCALAR","MAX_NUM_INPUT_SCALARS","MAX_NUM_INPUT_BYTES","hashStrToField","str","maxSizeBytes","strBytes","hashBytesWithLen","bytes","packed","padAndPackBytesWithLen","poseidonHash","padAndPackBytesNoLen","paddedStrBytes","padUint8ArrayWithZeros","packBytes","chunkUint8Array","chunk","bytesToBigIntLE","array","chunkSize","result","i","bigIntToBytesLE","value","length","val","inputArray","paddedSize","paddedArray","inputs"]}
@@ -1,4 +1,4 @@
1
- export { P as PrivateKey } from '../../account-ClxOwjdh.mjs';
1
+ export { P as PrivateKey } from '../../account-BortO8g2.mjs';
2
2
  import '../../types/indexer.mjs';
3
3
  import '../../types/generated/operations.mjs';
4
4
  import '../../types/generated/types.mjs';
@@ -1,2 +1,2 @@
1
- import{a}from"../../chunk-ROT6S6BM.mjs";import"../../chunk-FD6FGKYY.mjs";import"../../chunk-4WPQQPUF.mjs";import"../../chunk-IJE2LVZG.mjs";import"../../chunk-STY74NUA.mjs";import"../../chunk-IF4UU2MT.mjs";import"../../chunk-KDMSOCZY.mjs";export{a as PrivateKey};
1
+ import{PrivateKeyVariants as p}from"../../types";import{Hex as a}from"../hex";const r=class r{static formatPrivateKey(e,n){const i=r.AIP80_PREFIXES[n];let t=e;return typeof t=="string"&&t.startsWith(i)&&(t=t.split("-")[2]),`${i}${a.fromHexInput(t).toString()}`}static parseHexInput(e,n,i){let t;const s=r.AIP80_PREFIXES[n];if(typeof e=="string")if(!i&&!e.startsWith(s))t=a.fromHexInput(e),i!==!1&&console.warn("[Aptos SDK] It is recommended that private keys are AIP-80 compliant (https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md). You can fix the private key by formatting it with `PrivateKey.formatPrivateKey(privateKey: string, type: 'ed25519' | 'secp256k1'): string`.");else if(e.startsWith(s))t=a.fromHexString(e.split("-")[2]);else throw i?new Error("Invalid HexString input while parsing private key. Must AIP-80 compliant string."):new Error("Invalid HexString input while parsing private key.");else t=a.fromHexInput(e);return t}};r.AIP80_PREFIXES={[p.Ed25519]:"ed25519-priv-",[p.Secp256k1]:"secp256k1-priv-",[p.Secp256r1]:"secp256r1-priv-"};let o=r;export{o as PrivateKey};
2
2
  //# sourceMappingURL=privateKey.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../../src/core/crypto/privateKey.ts"],"sourcesContent":["/* eslint-disable max-len */\n\nimport { HexInput, PrivateKeyVariants } from \"../../types\";\nimport { Hex } from \"../hex\";\nimport { PublicKey } from \"./publicKey\";\nimport { Signature } from \"./signature\";\n\n/**\n * Represents a private key used for signing messages and deriving the associated public key.\n * @group Implementation\n * @category Serialization\n */\nexport interface PrivateKey {\n /**\n * Sign the given message with the private key to create a signature.\n * @param message - The message to be signed, provided in HexInput format.\n * @returns A Signature object representing the signed message.\n * @group Implementation\n * @category Serialization\n */\n sign(message: HexInput): Signature;\n\n /**\n * Derive the public key associated with the private key.\n * @group Implementation\n * @category Serialization\n */\n publicKey(): PublicKey;\n\n /**\n * Get the private key in bytes (Uint8Array).\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array;\n}\n\nexport class PrivateKey {\n /**\n * The AIP-80 compliant prefixes for each private key type. Append this to a private key's hex representation\n * to get an AIP-80 compliant string.\n *\n * [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)\n */\n public static readonly AIP80_PREFIXES = {\n [PrivateKeyVariants.Ed25519]: \"ed25519-priv-\",\n [PrivateKeyVariants.Secp256k1]: \"secp256k1-priv-\",\n [PrivateKeyVariants.Secp256r1]: \"secp256r1-priv-\",\n };\n\n /**\n * Format a HexInput to an AIP-80 compliant string.\n *\n * [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)\n *\n * @param privateKey - The HexString or Uint8Array format of the private key.\n * @param privateKeyType - The private key type\n */\n public static formatPrivateKey(privateKey: HexInput, type: PrivateKeyVariants): string {\n const aip80Prefix = PrivateKey.AIP80_PREFIXES[type];\n\n // Remove the prefix if it exists\n let formattedPrivateKey = privateKey;\n if (typeof formattedPrivateKey === \"string\" && formattedPrivateKey.startsWith(aip80Prefix)) {\n // eslint-disable-next-line prefer-destructuring\n formattedPrivateKey = formattedPrivateKey.split(\"-\")[2];\n }\n\n return `${aip80Prefix}${Hex.fromHexInput(formattedPrivateKey).toString()}`;\n }\n\n /**\n * Parse a HexInput that may be a HexString, Uint8Array, or a AIP-80 compliant string to a Hex instance.\n *\n * [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)\n *\n * @param value - A HexString, Uint8Array, or a AIP-80 compliant string.\n * @param privateKeyType - The private key type\n * @param strict - If true, the value MUST be compliant with AIP-80.\n */\n public static parseHexInput(value: HexInput, type: PrivateKeyVariants, strict?: boolean): Hex {\n let data: Hex;\n\n const aip80Prefix = PrivateKey.AIP80_PREFIXES[type];\n if (typeof value === \"string\") {\n if (!strict && !value.startsWith(aip80Prefix)) {\n // HexString input\n data = Hex.fromHexInput(value);\n // If the strictness is false, the user has opted into non-AIP-80 compliant private keys.\n if (strict !== false) {\n // eslint-disable-next-line no-console\n console.warn(\n \"[Aptos SDK] It is recommended that private keys are AIP-80 compliant (https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md). You can fix the private key by formatting it with `PrivateKey.formatPrivateKey(privateKey: string, type: 'ed25519' | 'secp256k1'): string`.\",\n );\n }\n } else if (value.startsWith(aip80Prefix)) {\n // AIP-80 Compliant String input\n data = Hex.fromHexString(value.split(\"-\")[2]);\n } else {\n if (strict) {\n // The value does not start with the AIP-80 prefix, and strict is true.\n throw new Error(\"Invalid HexString input while parsing private key. Must AIP-80 compliant string.\");\n }\n\n // This condition should never be reached.\n throw new Error(\"Invalid HexString input while parsing private key.\");\n }\n } else {\n // The value is an Uint8Array\n data = Hex.fromHexInput(value);\n }\n\n return data;\n }\n}\n"],"mappings":"AAEA,OAAmB,sBAAAA,MAA0B,cAC7C,OAAS,OAAAC,MAAW,SAkCb,MAAMC,EAAN,MAAMA,CAAW,CAqBtB,OAAc,iBAAiBC,EAAsBC,EAAkC,CACrF,MAAMC,EAAcH,EAAW,eAAeE,CAAI,EAGlD,IAAIE,EAAsBH,EAC1B,OAAI,OAAOG,GAAwB,UAAYA,EAAoB,WAAWD,CAAW,IAEvFC,EAAsBA,EAAoB,MAAM,GAAG,EAAE,CAAC,GAGjD,GAAGD,CAAW,GAAGJ,EAAI,aAAaK,CAAmB,EAAE,SAAS,CAAC,EAC1E,CAWA,OAAc,cAAcC,EAAiBH,EAA0BI,EAAuB,CAC5F,IAAIC,EAEJ,MAAMJ,EAAcH,EAAW,eAAeE,CAAI,EAClD,GAAI,OAAOG,GAAU,SACnB,GAAI,CAACC,GAAU,CAACD,EAAM,WAAWF,CAAW,EAE1CI,EAAOR,EAAI,aAAaM,CAAK,EAEzBC,IAAW,IAEb,QAAQ,KACN,uRACF,UAEOD,EAAM,WAAWF,CAAW,EAErCI,EAAOR,EAAI,cAAcM,EAAM,MAAM,GAAG,EAAE,CAAC,CAAC,MAE5C,OAAIC,EAEI,IAAI,MAAM,kFAAkF,EAI9F,IAAI,MAAM,oDAAoD,OAItEC,EAAOR,EAAI,aAAaM,CAAK,EAG/B,OAAOE,CACT,CACF,EA7EaP,EAOY,eAAiB,CACtC,CAACF,EAAmB,OAAO,EAAG,gBAC9B,CAACA,EAAmB,SAAS,EAAG,kBAChC,CAACA,EAAmB,SAAS,EAAG,iBAClC,EAXK,IAAMU,EAANR","names":["PrivateKeyVariants","Hex","_PrivateKey","privateKey","type","aip80Prefix","formattedPrivateKey","value","strict","data","PrivateKey"]}
@@ -1,4 +1,4 @@
1
- import { S as Serializable } from '../../account-ClxOwjdh.mjs';
1
+ import { S as Serializable } from '../../account-BortO8g2.mjs';
2
2
  import '../../types/indexer.mjs';
3
3
  import '../../types/generated/operations.mjs';
4
4
  import '../../types/generated/types.mjs';
@@ -1,2 +1,2 @@
1
- import{a}from"../../chunk-XJJVJOX5.mjs";import"../../chunk-FZY4PMEE.mjs";import"../../chunk-TOBQ5UE6.mjs";import"../../chunk-MT2RJ7H3.mjs";import"../../chunk-Q4W3WJ2U.mjs";import"../../chunk-ORMOQWWH.mjs";import"../../chunk-FLZPUYXQ.mjs";import"../../chunk-FD6FGKYY.mjs";import"../../chunk-4WPQQPUF.mjs";import"../../chunk-IJE2LVZG.mjs";import"../../chunk-EBMEXURY.mjs";import"../../chunk-STY74NUA.mjs";import"../../chunk-IF4UU2MT.mjs";import"../../chunk-56CNRT2K.mjs";import"../../chunk-KDMSOCZY.mjs";export{a as Proof};
1
+ import{Serializable as r}from"../../bcs";class o extends r{}export{o as Proof};
2
2
  //# sourceMappingURL=proof.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../../src/core/crypto/proof.ts"],"sourcesContent":["import { Serializable } from \"../../bcs\";\n\n/**\n * An abstract representation of a cryptographic proof associated with specific\n * zero-knowledge proof schemes, such as Groth16 and PLONK.\n * @group Implementation\n * @category Serialization\n */\nexport abstract class Proof extends Serializable {}\n"],"mappings":"AAAA,OAAS,gBAAAA,MAAoB,YAQtB,MAAeC,UAAcD,CAAa,CAAC","names":["Serializable","Proof"]}
@@ -1,4 +1,4 @@
1
- export { G as AccountPublicKey, C as PublicKey, V as VerifySignatureArgs, z as VerifySignatureAsyncArgs } from '../../account-ClxOwjdh.mjs';
1
+ export { G as AccountPublicKey, C as PublicKey, V as VerifySignatureArgs, z as VerifySignatureAsyncArgs } from '../../account-BortO8g2.mjs';
2
2
  import '../../types/indexer.mjs';
3
3
  import '../../types/generated/operations.mjs';
4
4
  import '../../types/generated/types.mjs';
@@ -1,2 +1,2 @@
1
- import{a,b}from"../../chunk-WSR5EBJM.mjs";import"../../chunk-FZY4PMEE.mjs";import"../../chunk-TOBQ5UE6.mjs";import"../../chunk-MT2RJ7H3.mjs";import"../../chunk-Q4W3WJ2U.mjs";import"../../chunk-ORMOQWWH.mjs";import"../../chunk-FLZPUYXQ.mjs";import"../../chunk-FD6FGKYY.mjs";import"../../chunk-4WPQQPUF.mjs";import"../../chunk-IJE2LVZG.mjs";import"../../chunk-EBMEXURY.mjs";import"../../chunk-STY74NUA.mjs";import"../../chunk-IF4UU2MT.mjs";import"../../chunk-56CNRT2K.mjs";import"../../chunk-KDMSOCZY.mjs";export{b as AccountPublicKey,a as PublicKey};
1
+ import{Serializable as e}from"../../bcs";import{Hex as i}from"../hex";class n extends e{async verifySignatureAsync(t){return this.verifySignature(t)}toUint8Array(){return this.bcsToBytes()}toString(){const t=this.toUint8Array();return i.fromHexInput(t).toString()}}class m extends n{}export{m as AccountPublicKey,n as PublicKey};
2
2
  //# sourceMappingURL=publicKey.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../../src/core/crypto/publicKey.ts"],"sourcesContent":["import { AptosConfig } from \"../../api\";\nimport { Serializable } from \"../../bcs\";\nimport { HexInput } from \"../../types\";\nimport { AuthenticationKey } from \"../authenticationKey\";\nimport { Hex } from \"../hex\";\nimport { Signature } from \"./signature\";\n\n/**\n * Represents the arguments required to verify a digital signature.\n *\n * @param message - The original message that was signed.\n * @param signature - The signature to be verified against the message.\n * @group Implementation\n * @category Serialization\n */\nexport interface VerifySignatureArgs {\n message: HexInput;\n signature: Signature;\n}\n\n/**\n * Represents the arguments required to verify a digital signature asynchronously.\n *\n * The validity of certain types of signatures are dependent on network state. This is the case for\n * Keyless signatures which need to lookup the verification key and keyless configuration.\n *\n * @param aptosConfig - The Aptos configuration to use\n * @param message - The original message that was signed.\n * @param signature - The signature to be verified against the message.\n * @group Implementation\n * @category Serialization\n */\nexport type VerifySignatureAsyncArgs = VerifySignatureArgs & {\n aptosConfig: AptosConfig;\n options?: any;\n};\n\n/**\n * Represents an abstract public key.\n *\n * This class provides a common interface for verifying signatures associated with the public key.\n * It allows for the retrieval of the raw public key bytes and the public key in a hexadecimal string format.\n * @group Implementation\n * @category Serialization\n */\nexport abstract class PublicKey extends Serializable {\n /**\n * Verifies that the private key associated with this public key signed the message with the given signature.\n * @param args.message The message that was signed\n * @param args.signature The signature to verify\n * @group Implementation\n * @category Serialization\n */\n abstract verifySignature(args: VerifySignatureArgs): boolean;\n\n /**\n * Verifies signature with the public key and makes any network calls required to get state required to verify the signature.\n * @param args.aptosConfig The Aptos configuration\n * @param args.message The message that was signed\n * @param args.signature The signature to verify\n * @group Implementation\n * @category Serialization\n */\n async verifySignatureAsync(args: VerifySignatureAsyncArgs): Promise<boolean> {\n return this.verifySignature(args);\n }\n\n /**\n * Get the raw public key bytes\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.bcsToBytes();\n }\n\n /**\n * Get the public key as a hex string with a 0x prefix.\n *\n * @returns The public key in hex format.\n * @group Implementation\n * @category Serialization\n */\n toString(): string {\n const bytes = this.toUint8Array();\n return Hex.fromHexInput(bytes).toString();\n }\n}\n\n/**\n * An abstract representation of an account public key.\n *\n * Provides a common interface for deriving an authentication key.\n *\n * @abstract\n * @group Implementation\n * @category Serialization\n */\nexport abstract class AccountPublicKey extends PublicKey {\n /**\n * Get the authentication key associated with this public key\n * @group Implementation\n * @category Serialization\n */\n abstract authKey(): AuthenticationKey;\n}\n"],"mappings":"AACA,OAAS,gBAAAA,MAAoB,YAG7B,OAAS,OAAAC,MAAW,SAyCb,MAAeC,UAAkBF,CAAa,CAkBnD,MAAM,qBAAqBG,EAAkD,CAC3E,OAAO,KAAK,gBAAgBA,CAAI,CAClC,CAOA,cAA2B,CACzB,OAAO,KAAK,WAAW,CACzB,CASA,UAAmB,CACjB,MAAMC,EAAQ,KAAK,aAAa,EAChC,OAAOH,EAAI,aAAaG,CAAK,EAAE,SAAS,CAC1C,CACF,CAWO,MAAeC,UAAyBH,CAAU,CAOzD","names":["Serializable","Hex","PublicKey","args","bytes","AccountPublicKey"]}
@@ -1,4 +1,4 @@
1
- export { I as Secp256k1PrivateKey, H as Secp256k1PublicKey, J as Secp256k1Signature } from '../../account-ClxOwjdh.mjs';
1
+ export { I as Secp256k1PrivateKey, H as Secp256k1PublicKey, J as Secp256k1Signature } from '../../account-BortO8g2.mjs';
2
2
  import '../../types/indexer.mjs';
3
3
  import '../../types/generated/operations.mjs';
4
4
  import '../../types/generated/types.mjs';
@@ -1,2 +1,2 @@
1
- import{C as a,D as b,E as c}from"../../chunk-DIGP2ALY.mjs";import"../../chunk-5HXLZHDW.mjs";import"../../chunk-GOXRBEIJ.mjs";import"../../chunk-ROT6S6BM.mjs";import"../../chunk-XJJVJOX5.mjs";import"../../chunk-C3Q23D22.mjs";import"../../chunk-NECL5FCQ.mjs";import"../../chunk-4QMXOWHP.mjs";import"../../chunk-RQX6JOEN.mjs";import"../../chunk-WSR5EBJM.mjs";import"../../chunk-WCMW2L3P.mjs";import"../../chunk-G3MHXDYA.mjs";import"../../chunk-HNBKTJPN.mjs";import"../../chunk-V74WPKSY.mjs";import"../../chunk-UYVPNUH3.mjs";import"../../chunk-A5L76YP7.mjs";import"../../chunk-XKUIMGKU.mjs";import"../../chunk-N6YTF76Q.mjs";import"../../chunk-ZP4DWSQA.mjs";import"../../chunk-QREVMGQZ.mjs";import"../../chunk-FGFLPH5K.mjs";import"../../chunk-V3MBJJTL.mjs";import"../../chunk-ES2KP6BS.mjs";import"../../chunk-EM52Z7T7.mjs";import"../../chunk-TGRLDWXV.mjs";import"../../chunk-N3O3ULF7.mjs";import"../../chunk-YOZBVVKL.mjs";import"../../chunk-GMQCQDW4.mjs";import"../../chunk-UL777LTI.mjs";import"../../chunk-7ECCT6PK.mjs";import"../../chunk-DNRUDMMV.mjs";import"../../chunk-GFFKEZ56.mjs";import"../../chunk-LWL57YFU.mjs";import"../../chunk-HGLO5LDS.mjs";import"../../chunk-CW35YAMN.mjs";import"../../chunk-6WDVDEQZ.mjs";import"../../chunk-FZY4PMEE.mjs";import"../../chunk-TOBQ5UE6.mjs";import"../../chunk-MT2RJ7H3.mjs";import"../../chunk-Q4W3WJ2U.mjs";import"../../chunk-ORMOQWWH.mjs";import"../../chunk-FLZPUYXQ.mjs";import"../../chunk-7DQDJ2SA.mjs";import"../../chunk-HNBVYE3N.mjs";import"../../chunk-RGKRCZ36.mjs";import"../../chunk-FD6FGKYY.mjs";import"../../chunk-4WPQQPUF.mjs";import"../../chunk-IJE2LVZG.mjs";import"../../chunk-EBMEXURY.mjs";import"../../chunk-STY74NUA.mjs";import"../../chunk-IF4UU2MT.mjs";import"../../chunk-56CNRT2K.mjs";import"../../chunk-RCSJFTST.mjs";import"../../chunk-4RXKALLC.mjs";import"../../chunk-OLILO7VD.mjs";import"../../chunk-5FI4545P.mjs";import"../../chunk-KDMSOCZY.mjs";export{b as Secp256k1PrivateKey,a as Secp256k1PublicKey,c as Secp256k1Signature};
1
+ import{sha3_256 as p}from"@noble/hashes/sha3";import{secp256k1 as y}from"@noble/curves/secp256k1";import{HDKey as H}from"@scure/bip32";import{Serializable as P}from"../../bcs";import{Hex as l}from"../hex";import{PrivateKeyVariants as m}from"../../types";import{isValidBIP44Path as k,mnemonicToSeed as x}from"./hdKey";import{PrivateKey as g}from"./privateKey";import{PublicKey as A}from"./publicKey";import{Signature as z}from"./signature";import{convertSigningMessage as f}from"./utils";const i=class i extends A{constructor(e){super();this.keyType="secp256k1";const r=l.fromHexInput(e),{length:s}=r.toUint8Array();if(s===i.LENGTH)this.key=r;else if(s===i.COMPRESSED_LENGTH){const o=y.ProjectivePoint.fromHex(r.toUint8Array());this.key=l.fromHexInput(o.toRawBytes(!1))}else throw new Error(`PublicKey length should be ${i.LENGTH} or ${i.COMPRESSED_LENGTH}, received ${s}`)}verifySignature(e){const{message:r,signature:s}=e,o=f(r),d=l.fromHexInput(o).toUint8Array(),S=p(d),v=s.toUint8Array();return y.verify(v,S,this.key.toUint8Array(),{lowS:!0})}async verifySignatureAsync(e){return this.verifySignature(e)}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}deserialize(e){const r=e.deserializeBytes();return new c(r)}static deserialize(e){const r=e.deserializeBytes();return new i(r)}static isPublicKey(e){return e instanceof i}static isInstance(e){return"key"in e&&e.key?.data?.length===i.LENGTH&&"keyType"in e&&e.keyType==="secp256k1"}};i.LENGTH=65,i.COMPRESSED_LENGTH=33;let u=i;const n=class n extends P{constructor(t,e){super();const r=g.parseHexInput(t,m.Secp256k1,e);if(r.toUint8Array().length!==n.LENGTH)throw new Error(`PrivateKey length should be ${n.LENGTH}`);this.key=r}static generate(){const t=y.utils.randomPrivateKey();return new n(t,!1)}static fromDerivationPath(t,e){if(!k(t))throw new Error(`Invalid derivation path ${t}`);return n.fromDerivationPathInner(t,x(e))}static fromDerivationPathInner(t,e){const{privateKey:r}=H.fromMasterSeed(e).derive(t);if(r===null)throw new Error("Invalid key");return new n(r,!1)}sign(t){const e=f(t),r=l.fromHexInput(e),s=p(r.toUint8Array()),o=y.sign(s,this.key.toUint8Array(),{lowS:!0});return new c(o.toCompactRawBytes())}publicKey(){const t=y.getPublicKey(this.key.toUint8Array(),!1);return new u(t)}toUint8Array(){return this.key.toUint8Array()}toString(){return this.toAIP80String()}toHexString(){return this.key.toString()}toAIP80String(){return g.formatPrivateKey(this.key.toString(),m.Secp256k1)}serialize(t){t.serializeBytes(this.toUint8Array())}static deserialize(t){const e=t.deserializeBytes();return new n(e,!1)}static isPrivateKey(t){return t instanceof n}};n.LENGTH=32;let h=n;const a=class a extends z{constructor(t){super();const e=l.fromHexInput(t);if(e.toUint8Array().length!==a.LENGTH)throw new Error(`Signature length should be ${a.LENGTH}, received ${e.toUint8Array().length}`);this.data=e}toUint8Array(){return this.data.toUint8Array()}serialize(t){t.serializeBytes(this.data.toUint8Array())}static deserialize(t){const e=t.deserializeBytes();return new a(e)}};a.LENGTH=64;let c=a;export{h as Secp256k1PrivateKey,u as Secp256k1PublicKey,c as Secp256k1Signature};
2
2
  //# sourceMappingURL=secp256k1.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../../src/core/crypto/secp256k1.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { sha3_256 } from \"@noble/hashes/sha3\";\nimport { secp256k1 } from \"@noble/curves/secp256k1\";\nimport { HDKey } from \"@scure/bip32\";\nimport { Serializable, Deserializer, Serializer } from \"../../bcs\";\nimport { Hex } from \"../hex\";\nimport { HexInput, PrivateKeyVariants } from \"../../types\";\nimport { isValidBIP44Path, mnemonicToSeed } from \"./hdKey\";\nimport { PrivateKey } from \"./privateKey\";\nimport { PublicKey } from \"./publicKey\";\nimport { Signature } from \"./signature\";\nimport { convertSigningMessage } from \"./utils\";\nimport { AptosConfig } from \"../../api\";\n\n/**\n * Represents a Secp256k1 ECDSA public key.\n *\n * @extends PublicKey\n * @property LENGTH - The length of the Secp256k1 public key in bytes.\n * @group Implementation\n * @category Serialization\n */\nexport class Secp256k1PublicKey extends PublicKey {\n // Secp256k1 ecdsa public keys contain a prefix indicating compression and two 32-byte coordinates.\n static readonly LENGTH: number = 65;\n\n // If it's compressed, it is only 33 bytes\n static readonly COMPRESSED_LENGTH: number = 33;\n\n // Hex value of the public key\n private readonly key: Hex;\n\n // Identifier to distinguish from Secp256k1PublicKey\n public readonly keyType: string = \"secp256k1\";\n\n /**\n * Create a new PublicKey instance from a HexInput, which can be a string or Uint8Array.\n * This constructor validates the length of the provided signature data.\n *\n * @param hexInput - A HexInput (string or Uint8Array) representing the signature data.\n * @throws Error if the length of the signature data is not equal to Secp256k1Signature.LENGTH.\n * @group Implementation\n * @category Serialization\n */\n constructor(hexInput: HexInput) {\n super();\n\n const hex = Hex.fromHexInput(hexInput);\n const { length } = hex.toUint8Array();\n if (length === Secp256k1PublicKey.LENGTH) {\n this.key = hex;\n } else if (length === Secp256k1PublicKey.COMPRESSED_LENGTH) {\n const point = secp256k1.ProjectivePoint.fromHex(hex.toUint8Array());\n this.key = Hex.fromHexInput(point.toRawBytes(false));\n } else {\n throw new Error(\n `PublicKey length should be ${Secp256k1PublicKey.LENGTH} or ${Secp256k1PublicKey.COMPRESSED_LENGTH}, received ${length}`,\n );\n }\n }\n\n // region PublicKey\n /**\n * Verifies a Secp256k1 signature against the public key.\n *\n * This function checks the validity of a signature for a given message, ensuring that the signature is canonical as a malleability check.\n *\n * @param args - The arguments for verifying the signature.\n * @param args.message - The message that was signed.\n * @param args.signature - The signature to verify against the public key.\n * @group Implementation\n * @category Serialization\n */\n verifySignature(args: { message: HexInput; signature: Secp256k1Signature }): boolean {\n const { message, signature } = args;\n const messageToVerify = convertSigningMessage(message);\n const messageBytes = Hex.fromHexInput(messageToVerify).toUint8Array();\n const messageSha3Bytes = sha3_256(messageBytes);\n const signatureBytes = signature.toUint8Array();\n return secp256k1.verify(signatureBytes, messageSha3Bytes, this.key.toUint8Array(), { lowS: true });\n }\n\n /**\n * Note: Secp256k1Signatures can be verified syncronously.\n *\n * Verifies the provided signature against the given message.\n * This function helps ensure the integrity and authenticity of the message by confirming that the signature is valid.\n *\n * @param args - The arguments for signature verification.\n * @param args.aptosConfig - The configuration object for connecting to the Aptos network\n * @param args.message - The message that was signed.\n * @param args.signature - The signature to verify, which must be an instance of Secp256k1Signature.\n * @returns A boolean indicating whether the signature is valid for the given message.\n * @group Implementation\n * @category Serialization\n */\n async verifySignatureAsync(args: {\n aptosConfig: AptosConfig;\n message: HexInput;\n signature: Secp256k1Signature;\n }): Promise<boolean> {\n return this.verifySignature(args);\n }\n\n /**\n * Get the data as a Uint8Array representation.\n *\n * @returns Uint8Array representation of the data.\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.key.toUint8Array();\n }\n\n // endregion\n\n // region Serializable\n\n /**\n * Serializes the data into a byte array using the provided serializer.\n * This function is essential for converting data into a format suitable for transmission or storage.\n *\n * @param serializer - The serializer instance used to convert the data.\n * @group Implementation\n * @category Serialization\n */\n serialize(serializer: Serializer): void {\n serializer.serializeBytes(this.key.toUint8Array());\n }\n\n /**\n * Deserializes a Secp256k1Signature from the provided deserializer.\n * This function allows you to reconstruct a Secp256k1Signature object from its serialized byte representation.\n *\n * @param deserializer - The deserializer instance used to read the serialized data.\n * @group Implementation\n * @category Serialization\n */\n // eslint-disable-next-line class-methods-use-this\n deserialize(deserializer: Deserializer) {\n const hex = deserializer.deserializeBytes();\n return new Secp256k1Signature(hex);\n }\n\n static deserialize(deserializer: Deserializer): Secp256k1PublicKey {\n const bytes = deserializer.deserializeBytes();\n return new Secp256k1PublicKey(bytes);\n }\n\n // endregion\n\n /**\n * Determine if the provided public key is an instance of Secp256k1PublicKey.\n *\n * @deprecated use `instanceof Secp256k1PublicKey` instead\n * @param publicKey - The public key to check.\n * @group Implementation\n * @category Serialization\n */\n static isPublicKey(publicKey: PublicKey): publicKey is Secp256k1PublicKey {\n return publicKey instanceof Secp256k1PublicKey;\n }\n\n /**\n * Determines if the provided public key is a valid instance of a Secp256k1 public key.\n * This function checks for the presence of a \"key\" property and validates the length of the key data.\n *\n * @param publicKey - The public key to validate.\n * @returns A boolean indicating whether the public key is a valid Secp256k1 public key.\n * @group Implementation\n * @category Serialization\n */\n static isInstance(publicKey: PublicKey): publicKey is Secp256k1PublicKey {\n return (\n \"key\" in publicKey &&\n (publicKey.key as any)?.data?.length === Secp256k1PublicKey.LENGTH &&\n \"keyType\" in publicKey &&\n (publicKey as any).keyType === \"secp256k1\"\n );\n }\n}\n\n/**\n * Represents a Secp256k1 ECDSA private key, providing functionality to create, sign messages,\n * derive public keys, and serialize/deserialize the key.\n * @group Implementation\n * @category Serialization\n */\nexport class Secp256k1PrivateKey extends Serializable implements PrivateKey {\n /**\n * Length of Secp256k1 ecdsa private key\n * @group Implementation\n * @category Serialization\n */\n static readonly LENGTH: number = 32;\n\n /**\n * The private key bytes\n * @private\n * @group Implementation\n * @category Serialization\n */\n private readonly key: Hex;\n\n // region Constructors\n\n /**\n * Create a new PrivateKey instance from a Uint8Array or String.\n *\n * [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)\n *\n * @param hexInput A HexInput (string or Uint8Array)\n * @param strict If true, private key must AIP-80 compliant.\n * @group Implementation\n * @category Serialization\n */\n constructor(hexInput: HexInput, strict?: boolean) {\n super();\n\n const privateKeyHex = PrivateKey.parseHexInput(hexInput, PrivateKeyVariants.Secp256k1, strict);\n if (privateKeyHex.toUint8Array().length !== Secp256k1PrivateKey.LENGTH) {\n throw new Error(`PrivateKey length should be ${Secp256k1PrivateKey.LENGTH}`);\n }\n\n this.key = privateKeyHex;\n }\n\n /**\n * Generate a new random private key.\n *\n * @returns Secp256k1PrivateKey - A newly generated Secp256k1 private key.\n * @group Implementation\n * @category Serialization\n */\n static generate(): Secp256k1PrivateKey {\n const hexInput = secp256k1.utils.randomPrivateKey();\n return new Secp256k1PrivateKey(hexInput, false);\n }\n\n /**\n * Derives a private key from a mnemonic seed phrase using a specified BIP44 path.\n *\n * @param path - The BIP44 path to derive the key from.\n * @param mnemonics - The mnemonic seed phrase used for key generation.\n *\n * @returns The generated private key.\n *\n * @throws Error if the provided path is not a valid BIP44 path.\n * @group Implementation\n * @category Serialization\n */\n static fromDerivationPath(path: string, mnemonics: string): Secp256k1PrivateKey {\n if (!isValidBIP44Path(path)) {\n throw new Error(`Invalid derivation path ${path}`);\n }\n return Secp256k1PrivateKey.fromDerivationPathInner(path, mnemonicToSeed(mnemonics));\n }\n\n /**\n * Derives a private key from a specified BIP44 path using a given seed.\n * This function is essential for generating keys that follow the hierarchical deterministic (HD) wallet structure.\n *\n * @param path - The BIP44 path used for key derivation.\n * @param seed - The seed phrase created by the mnemonics, represented as a Uint8Array.\n * @returns The generated private key as an instance of Secp256k1PrivateKey.\n * @throws Error if the derived private key is invalid.\n * @group Implementation\n * @category Serialization\n */\n private static fromDerivationPathInner(path: string, seed: Uint8Array): Secp256k1PrivateKey {\n const { privateKey } = HDKey.fromMasterSeed(seed).derive(path);\n // library returns privateKey as Uint8Array | null\n if (privateKey === null) {\n throw new Error(\"Invalid key\");\n }\n\n return new Secp256k1PrivateKey(privateKey, false);\n }\n\n // endregion\n\n // region PrivateKey\n\n /**\n * Sign the given message with the private key.\n * This function generates a cryptographic signature for the provided message, ensuring the signature is canonical and non-malleable.\n *\n * @param message - A message in HexInput format to be signed.\n * @returns Signature - The generated signature for the provided message.\n * @group Implementation\n * @category Serialization\n */\n sign(message: HexInput): Secp256k1Signature {\n const messageToSign = convertSigningMessage(message);\n const messageBytes = Hex.fromHexInput(messageToSign);\n const messageHashBytes = sha3_256(messageBytes.toUint8Array());\n const signature = secp256k1.sign(messageHashBytes, this.key.toUint8Array(), { lowS: true });\n return new Secp256k1Signature(signature.toCompactRawBytes());\n }\n\n /**\n * Derive the Secp256k1PublicKey from this private key.\n *\n * @returns Secp256k1PublicKey The derived public key.\n * @group Implementation\n * @category Serialization\n */\n publicKey(): Secp256k1PublicKey {\n const bytes = secp256k1.getPublicKey(this.key.toUint8Array(), false);\n return new Secp256k1PublicKey(bytes);\n }\n\n /**\n * Get the private key in bytes (Uint8Array).\n *\n * @returns\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.key.toUint8Array();\n }\n\n /**\n * Get the private key as a string representation.\n *\n * @returns string representation of the private key\n * @group Implementation\n * @category Serialization\n */\n toString(): string {\n return this.toAIP80String();\n }\n\n /**\n * Get the private key as a hex string with the 0x prefix.\n *\n * @returns string representation of the private key.\n */\n toHexString(): string {\n return this.key.toString();\n }\n\n /**\n * Get the private key as a AIP-80 compliant hex string.\n *\n * [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)\n *\n * @returns AIP-80 compliant string representation of the private key.\n */\n toAIP80String(): string {\n return PrivateKey.formatPrivateKey(this.key.toString(), PrivateKeyVariants.Secp256k1);\n }\n\n // endregion\n\n // region Serializable\n\n serialize(serializer: Serializer): void {\n serializer.serializeBytes(this.toUint8Array());\n }\n\n static deserialize(deserializer: Deserializer): Secp256k1PrivateKey {\n const bytes = deserializer.deserializeBytes();\n return new Secp256k1PrivateKey(bytes, false);\n }\n\n // endregion\n\n /**\n * Determines if the provided private key is an instance of Secp256k1PrivateKey.\n *\n * @param privateKey - The private key to be checked.\n *\n * @deprecated use `instanceof Secp256k1PrivateKey` instead\n * @group Implementation\n * @category Serialization\n */\n static isPrivateKey(privateKey: PrivateKey): privateKey is Secp256k1PrivateKey {\n return privateKey instanceof Secp256k1PrivateKey;\n }\n}\n\n/**\n * Represents a signature of a message signed using a Secp256k1 ECDSA private key.\n *\n * @group Implementation\n * @category Serialization\n */\nexport class Secp256k1Signature extends Signature {\n /**\n * Secp256k1 ecdsa signatures are 256-bit.\n * @group Implementation\n * @category Serialization\n */\n static readonly LENGTH = 64;\n\n /**\n * The signature bytes\n * @private\n * @group Implementation\n * @category Serialization\n */\n private readonly data: Hex;\n\n // region Constructors\n\n /**\n * Create a new Signature instance from a Uint8Array or String.\n *\n * @param hexInput A HexInput (string or Uint8Array)\n * @group Implementation\n * @category Serialization\n */\n constructor(hexInput: HexInput) {\n super();\n const data = Hex.fromHexInput(hexInput);\n if (data.toUint8Array().length !== Secp256k1Signature.LENGTH) {\n throw new Error(\n `Signature length should be ${Secp256k1Signature.LENGTH}, received ${data.toUint8Array().length}`,\n );\n }\n this.data = data;\n }\n\n // endregion\n\n // region Signature\n\n toUint8Array(): Uint8Array {\n return this.data.toUint8Array();\n }\n\n // endregion\n\n // region Serializable\n\n serialize(serializer: Serializer): void {\n serializer.serializeBytes(this.data.toUint8Array());\n }\n\n static deserialize(deserializer: Deserializer): Secp256k1Signature {\n const hex = deserializer.deserializeBytes();\n return new Secp256k1Signature(hex);\n }\n\n // endregion\n}\n"],"mappings":"AAGA,OAAS,YAAAA,MAAgB,qBACzB,OAAS,aAAAC,MAAiB,0BAC1B,OAAS,SAAAC,MAAa,eACtB,OAAS,gBAAAC,MAA8C,YACvD,OAAS,OAAAC,MAAW,SACpB,OAAmB,sBAAAC,MAA0B,cAC7C,OAAS,oBAAAC,EAAkB,kBAAAC,MAAsB,UACjD,OAAS,cAAAC,MAAkB,eAC3B,OAAS,aAA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CAGF,EA1Da0B,EAMK,OAAS,GANpB,IAAMd,EAANc","names":["sha3_256","secp256k1","HDKey","Serializable","Hex","PrivateKeyVariants","isValidBIP44Path","mnemonicToSeed","PrivateKey","PublicKey","Signature","convertSigningMessage","_Secp256k1PublicKey","hexInput","hex","length","point","args","message","signature","messageToVerify","messageBytes","messageSha3Bytes","signatureBytes","serializer","deserializer","Secp256k1Signature","bytes","publicKey","Secp256k1PublicKey","_Secp256k1PrivateKey","strict","privateKeyHex","path","mnemonics","seed","privateKey","messageToSign","messageHashBytes","Secp256k1PrivateKey","_Secp256k1Signature","data"]}