@aptos-labs/ts-sdk 5.1.0 → 5.1.1-side-effect-free.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (421) hide show
  1. package/dist/common/{account-BW99GTa5.d.ts → account-Dr4y1uZG.d.ts} +1 -0
  2. package/dist/common/chunk-AWFAHZSB.js +4 -0
  3. package/dist/common/{chunk-A2XB7TVI.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 +94 -16
  8. package/dist/common/index.js +34 -34
  9. package/dist/common/index.js.map +1 -1
  10. package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
  11. package/dist/esm/account/AbstractKeylessAccount.mjs.map +1 -1
  12. package/dist/esm/account/AbstractedAccount.mjs +1 -1
  13. package/dist/esm/account/AbstractedAccount.mjs.map +1 -1
  14. package/dist/esm/account/Account.mjs +1 -1
  15. package/dist/esm/account/Account.mjs.map +1 -1
  16. package/dist/esm/account/AccountUtils.mjs +1 -1
  17. package/dist/esm/account/AccountUtils.mjs.map +1 -1
  18. package/dist/esm/account/DerivableAbstractedAccount.mjs +1 -1
  19. package/dist/esm/account/DerivableAbstractedAccount.mjs.map +1 -1
  20. package/dist/esm/account/Ed25519Account.mjs +1 -1
  21. package/dist/esm/account/Ed25519Account.mjs.map +1 -1
  22. package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
  23. package/dist/esm/account/EphemeralKeyPair.mjs.map +1 -1
  24. package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
  25. package/dist/esm/account/FederatedKeylessAccount.mjs.map +1 -1
  26. package/dist/esm/account/KeylessAccount.mjs +1 -1
  27. package/dist/esm/account/KeylessAccount.mjs.map +1 -1
  28. package/dist/esm/account/MultiEd25519Account.mjs +1 -1
  29. package/dist/esm/account/MultiEd25519Account.mjs.map +1 -1
  30. package/dist/esm/account/MultiKeyAccount.mjs +1 -1
  31. package/dist/esm/account/MultiKeyAccount.mjs.map +1 -1
  32. package/dist/esm/account/SingleKeyAccount.mjs +1 -1
  33. package/dist/esm/account/SingleKeyAccount.mjs.map +1 -1
  34. package/dist/esm/account/index.mjs +1 -1
  35. package/dist/esm/account/index.mjs.map +1 -1
  36. package/dist/esm/account/utils.mjs +1 -1
  37. package/dist/esm/account/utils.mjs.map +1 -1
  38. package/dist/esm/api/account/abstraction.mjs +1 -1
  39. package/dist/esm/api/account/abstraction.mjs.map +1 -1
  40. package/dist/esm/api/account.d.mts +1 -1
  41. package/dist/esm/api/account.mjs +1 -1
  42. package/dist/esm/api/account.mjs.map +1 -1
  43. package/dist/esm/api/ans.mjs +1 -1
  44. package/dist/esm/api/ans.mjs.map +1 -1
  45. package/dist/esm/api/aptos.d.mts +81 -14
  46. package/dist/esm/api/aptos.mjs +1 -1
  47. package/dist/esm/api/aptos.mjs.map +1 -1
  48. package/dist/esm/api/aptosConfig.mjs +1 -1
  49. package/dist/esm/api/aptosConfig.mjs.map +1 -1
  50. package/dist/esm/api/coin.mjs +1 -1
  51. package/dist/esm/api/coin.mjs.map +1 -1
  52. package/dist/esm/api/digitalAsset.mjs +1 -1
  53. package/dist/esm/api/digitalAsset.mjs.map +1 -1
  54. package/dist/esm/api/faucet.mjs +1 -1
  55. package/dist/esm/api/faucet.mjs.map +1 -1
  56. package/dist/esm/api/fungibleAsset.mjs +1 -1
  57. package/dist/esm/api/fungibleAsset.mjs.map +1 -1
  58. package/dist/esm/api/general.mjs +1 -1
  59. package/dist/esm/api/general.mjs.map +1 -1
  60. package/dist/esm/api/index.d.mts +2 -2
  61. package/dist/esm/api/index.mjs +1 -1
  62. package/dist/esm/api/index.mjs.map +1 -1
  63. package/dist/esm/api/keyless.mjs +1 -1
  64. package/dist/esm/api/keyless.mjs.map +1 -1
  65. package/dist/esm/api/object.mjs +1 -1
  66. package/dist/esm/api/object.mjs.map +1 -1
  67. package/dist/esm/api/staking.mjs +1 -1
  68. package/dist/esm/api/staking.mjs.map +1 -1
  69. package/dist/esm/api/table.mjs +1 -1
  70. package/dist/esm/api/table.mjs.map +1 -1
  71. package/dist/esm/api/transaction.mjs +1 -1
  72. package/dist/esm/api/transaction.mjs.map +1 -1
  73. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  74. package/dist/esm/api/transactionSubmission/build.mjs.map +1 -1
  75. package/dist/esm/api/transactionSubmission/helpers.mjs +1 -1
  76. package/dist/esm/api/transactionSubmission/helpers.mjs.map +1 -1
  77. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  78. package/dist/esm/api/transactionSubmission/management.mjs.map +1 -1
  79. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  80. package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -1
  81. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  82. package/dist/esm/api/transactionSubmission/simulate.mjs.map +1 -1
  83. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  84. package/dist/esm/api/transactionSubmission/submit.mjs.map +1 -1
  85. package/dist/esm/api/utils.mjs +1 -1
  86. package/dist/esm/api/utils.mjs.map +1 -1
  87. package/dist/esm/bcs/consts.mjs +1 -1
  88. package/dist/esm/bcs/consts.mjs.map +1 -1
  89. package/dist/esm/bcs/deserializer.mjs +1 -1
  90. package/dist/esm/bcs/deserializer.mjs.map +1 -1
  91. package/dist/esm/bcs/index.mjs +1 -1
  92. package/dist/esm/bcs/index.mjs.map +1 -1
  93. package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
  94. package/dist/esm/bcs/serializable/entryFunctionBytes.mjs.map +1 -1
  95. package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
  96. package/dist/esm/bcs/serializable/fixedBytes.mjs.map +1 -1
  97. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  98. package/dist/esm/bcs/serializable/movePrimitives.mjs.map +1 -1
  99. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  100. package/dist/esm/bcs/serializable/moveStructs.mjs.map +1 -1
  101. package/dist/esm/bcs/serializer.mjs +1 -1
  102. package/dist/esm/bcs/serializer.mjs.map +1 -1
  103. package/dist/esm/cli/index.mjs +1 -1
  104. package/dist/esm/cli/index.mjs.map +1 -1
  105. package/dist/esm/cli/localNode.mjs +1 -1
  106. package/dist/esm/cli/localNode.mjs.map +1 -1
  107. package/dist/esm/cli/move.mjs +1 -1
  108. package/dist/esm/cli/move.mjs.map +1 -1
  109. package/dist/esm/client/core.mjs +1 -1
  110. package/dist/esm/client/core.mjs.map +1 -1
  111. package/dist/esm/client/get.mjs +1 -1
  112. package/dist/esm/client/get.mjs.map +1 -1
  113. package/dist/esm/client/index.mjs +1 -1
  114. package/dist/esm/client/index.mjs.map +1 -1
  115. package/dist/esm/client/post.mjs +1 -1
  116. package/dist/esm/client/post.mjs.map +1 -1
  117. package/dist/esm/core/account/index.d.mts +1 -1
  118. package/dist/esm/core/account/index.mjs +1 -1
  119. package/dist/esm/core/account/index.mjs.map +1 -1
  120. package/dist/esm/core/account/utils/address.d.mts +12 -1
  121. package/dist/esm/core/account/utils/address.mjs +1 -1
  122. package/dist/esm/core/account/utils/address.mjs.map +1 -1
  123. package/dist/esm/core/account/utils/index.d.mts +1 -1
  124. package/dist/esm/core/account/utils/index.mjs +1 -1
  125. package/dist/esm/core/account/utils/index.mjs.map +1 -1
  126. package/dist/esm/core/accountAddress.mjs +3 -1
  127. package/dist/esm/core/accountAddress.mjs.map +1 -1
  128. package/dist/esm/core/authenticationKey.mjs +1 -1
  129. package/dist/esm/core/authenticationKey.mjs.map +1 -1
  130. package/dist/esm/core/common.mjs +1 -1
  131. package/dist/esm/core/common.mjs.map +1 -1
  132. package/dist/esm/core/crypto/abstraction.mjs +1 -1
  133. package/dist/esm/core/crypto/abstraction.mjs.map +1 -1
  134. package/dist/esm/core/crypto/deserializationUtils.mjs +1 -1
  135. package/dist/esm/core/crypto/deserializationUtils.mjs.map +1 -1
  136. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  137. package/dist/esm/core/crypto/ed25519.mjs.map +1 -1
  138. package/dist/esm/core/crypto/ephemeral.mjs +1 -1
  139. package/dist/esm/core/crypto/ephemeral.mjs.map +1 -1
  140. package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
  141. package/dist/esm/core/crypto/federatedKeyless.mjs.map +1 -1
  142. package/dist/esm/core/crypto/hdKey.mjs +1 -1
  143. package/dist/esm/core/crypto/hdKey.mjs.map +1 -1
  144. package/dist/esm/core/crypto/index.mjs +1 -1
  145. package/dist/esm/core/crypto/index.mjs.map +1 -1
  146. package/dist/esm/core/crypto/keyless.mjs +1 -1
  147. package/dist/esm/core/crypto/keyless.mjs.map +1 -1
  148. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  149. package/dist/esm/core/crypto/multiEd25519.mjs.map +1 -1
  150. package/dist/esm/core/crypto/multiKey.mjs +3 -1
  151. package/dist/esm/core/crypto/multiKey.mjs.map +1 -1
  152. package/dist/esm/core/crypto/poseidon.mjs +1 -1
  153. package/dist/esm/core/crypto/poseidon.mjs.map +1 -1
  154. package/dist/esm/core/crypto/privateKey.mjs +1 -1
  155. package/dist/esm/core/crypto/privateKey.mjs.map +1 -1
  156. package/dist/esm/core/crypto/proof.mjs +1 -1
  157. package/dist/esm/core/crypto/proof.mjs.map +1 -1
  158. package/dist/esm/core/crypto/publicKey.mjs +1 -1
  159. package/dist/esm/core/crypto/publicKey.mjs.map +1 -1
  160. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  161. package/dist/esm/core/crypto/secp256k1.mjs.map +1 -1
  162. package/dist/esm/core/crypto/secp256r1.mjs +1 -1
  163. package/dist/esm/core/crypto/secp256r1.mjs.map +1 -1
  164. package/dist/esm/core/crypto/signature.mjs +1 -1
  165. package/dist/esm/core/crypto/signature.mjs.map +1 -1
  166. package/dist/esm/core/crypto/singleKey.mjs +1 -1
  167. package/dist/esm/core/crypto/singleKey.mjs.map +1 -1
  168. package/dist/esm/core/crypto/types.mjs +0 -1
  169. package/dist/esm/core/crypto/utils.mjs +1 -1
  170. package/dist/esm/core/crypto/utils.mjs.map +1 -1
  171. package/dist/esm/core/hex.mjs +1 -1
  172. package/dist/esm/core/hex.mjs.map +1 -1
  173. package/dist/esm/core/index.d.mts +1 -1
  174. package/dist/esm/core/index.mjs +1 -1
  175. package/dist/esm/core/index.mjs.map +1 -1
  176. package/dist/esm/errors/index.mjs +6 -1
  177. package/dist/esm/errors/index.mjs.map +1 -1
  178. package/dist/esm/index.d.mts +2 -2
  179. package/dist/esm/index.mjs +1 -1
  180. package/dist/esm/index.mjs.map +1 -1
  181. package/dist/esm/internal/abstraction.mjs +1 -1
  182. package/dist/esm/internal/abstraction.mjs.map +1 -1
  183. package/dist/esm/internal/account.mjs +1 -1
  184. package/dist/esm/internal/account.mjs.map +1 -1
  185. package/dist/esm/internal/ans.mjs +1 -1
  186. package/dist/esm/internal/ans.mjs.map +1 -1
  187. package/dist/esm/internal/coin.mjs +1 -1
  188. package/dist/esm/internal/coin.mjs.map +1 -1
  189. package/dist/esm/internal/digitalAsset.mjs +1 -1
  190. package/dist/esm/internal/digitalAsset.mjs.map +1 -1
  191. package/dist/esm/internal/faucet.mjs +1 -1
  192. package/dist/esm/internal/faucet.mjs.map +1 -1
  193. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  194. package/dist/esm/internal/fungibleAsset.mjs.map +1 -1
  195. package/dist/esm/internal/general.mjs +1 -1
  196. package/dist/esm/internal/general.mjs.map +1 -1
  197. package/dist/esm/internal/keyless.mjs +1 -1
  198. package/dist/esm/internal/keyless.mjs.map +1 -1
  199. package/dist/esm/internal/object.mjs +1 -1
  200. package/dist/esm/internal/object.mjs.map +1 -1
  201. package/dist/esm/internal/staking.mjs +1 -1
  202. package/dist/esm/internal/staking.mjs.map +1 -1
  203. package/dist/esm/internal/table.mjs +1 -1
  204. package/dist/esm/internal/table.mjs.map +1 -1
  205. package/dist/esm/internal/transaction.mjs +1 -1
  206. package/dist/esm/internal/transaction.mjs.map +1 -1
  207. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  208. package/dist/esm/internal/transactionSubmission.mjs.map +1 -1
  209. package/dist/esm/internal/utils/index.mjs +1 -1
  210. package/dist/esm/internal/utils/index.mjs.map +1 -1
  211. package/dist/esm/internal/utils/utils.mjs +1 -1
  212. package/dist/esm/internal/utils/utils.mjs.map +1 -1
  213. package/dist/esm/internal/view.mjs +1 -1
  214. package/dist/esm/internal/view.mjs.map +1 -1
  215. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  216. package/dist/esm/transactions/authenticator/account.mjs.map +1 -1
  217. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  218. package/dist/esm/transactions/authenticator/index.mjs.map +1 -1
  219. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  220. package/dist/esm/transactions/authenticator/transaction.mjs.map +1 -1
  221. package/dist/esm/transactions/index.mjs +1 -1
  222. package/dist/esm/transactions/index.mjs.map +1 -1
  223. package/dist/esm/transactions/instances/chainId.mjs +1 -1
  224. package/dist/esm/transactions/instances/chainId.mjs.map +1 -1
  225. package/dist/esm/transactions/instances/identifier.mjs +1 -1
  226. package/dist/esm/transactions/instances/identifier.mjs.map +1 -1
  227. package/dist/esm/transactions/instances/index.mjs +1 -1
  228. package/dist/esm/transactions/instances/index.mjs.map +1 -1
  229. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  230. package/dist/esm/transactions/instances/moduleId.mjs.map +1 -1
  231. package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
  232. package/dist/esm/transactions/instances/multiAgentTransaction.mjs.map +1 -1
  233. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  234. package/dist/esm/transactions/instances/rawTransaction.mjs.map +1 -1
  235. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  236. package/dist/esm/transactions/instances/rotationProofChallenge.mjs.map +1 -1
  237. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  238. package/dist/esm/transactions/instances/signedTransaction.mjs.map +1 -1
  239. package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
  240. package/dist/esm/transactions/instances/simpleTransaction.mjs.map +1 -1
  241. package/dist/esm/transactions/instances/transactionArgument.mjs +0 -1
  242. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  243. package/dist/esm/transactions/instances/transactionPayload.mjs.map +1 -1
  244. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  245. package/dist/esm/transactions/management/accountSequenceNumber.mjs.map +1 -1
  246. package/dist/esm/transactions/management/asyncQueue.mjs +1 -1
  247. package/dist/esm/transactions/management/asyncQueue.mjs.map +1 -1
  248. package/dist/esm/transactions/management/index.mjs +1 -1
  249. package/dist/esm/transactions/management/index.mjs.map +1 -1
  250. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  251. package/dist/esm/transactions/management/transactionWorker.mjs.map +1 -1
  252. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  253. package/dist/esm/transactions/transactionBuilder/helpers.mjs.map +1 -1
  254. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  255. package/dist/esm/transactions/transactionBuilder/index.mjs.map +1 -1
  256. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  257. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs.map +1 -1
  258. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
  259. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs.map +1 -1
  260. package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +2 -2
  261. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  262. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs.map +1 -1
  263. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  264. package/dist/esm/transactions/typeTag/index.mjs.map +1 -1
  265. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  266. package/dist/esm/transactions/typeTag/parser.mjs.map +1 -1
  267. package/dist/esm/transactions/types.mjs +0 -1
  268. package/dist/esm/types/abstraction.mjs +1 -1
  269. package/dist/esm/types/abstraction.mjs.map +1 -1
  270. package/dist/esm/types/generated/queries.mjs +493 -1
  271. package/dist/esm/types/generated/queries.mjs.map +1 -1
  272. package/dist/esm/types/generated/types.mjs +1 -1
  273. package/dist/esm/types/generated/types.mjs.map +1 -1
  274. package/dist/esm/types/index.mjs +1 -1
  275. package/dist/esm/types/index.mjs.map +1 -1
  276. package/dist/esm/types/indexer.mjs +0 -1
  277. package/dist/esm/types/types.mjs +1 -1
  278. package/dist/esm/types/types.mjs.map +1 -1
  279. package/dist/esm/utils/apiEndpoints.d.mts +1 -0
  280. package/dist/esm/utils/apiEndpoints.mjs +1 -1
  281. package/dist/esm/utils/apiEndpoints.mjs.map +1 -1
  282. package/dist/esm/utils/const.mjs +1 -1
  283. package/dist/esm/utils/const.mjs.map +1 -1
  284. package/dist/esm/utils/helpers.mjs +1 -1
  285. package/dist/esm/utils/helpers.mjs.map +1 -1
  286. package/dist/esm/utils/index.mjs +1 -1
  287. package/dist/esm/utils/index.mjs.map +1 -1
  288. package/dist/esm/utils/memoize.mjs +1 -1
  289. package/dist/esm/utils/memoize.mjs.map +1 -1
  290. package/dist/esm/utils/normalizeBundle.mjs +1 -1
  291. package/dist/esm/utils/normalizeBundle.mjs.map +1 -1
  292. package/dist/esm/version.d.mts +1 -1
  293. package/dist/esm/version.mjs +1 -1
  294. package/dist/esm/version.mjs.map +1 -1
  295. package/package.json +39 -20
  296. package/src/api/aptos.ts +193 -51
  297. package/src/core/account/utils/address.ts +22 -0
  298. package/src/internal/ans.ts +1 -0
  299. package/src/utils/apiEndpoints.ts +7 -0
  300. package/src/version.ts +1 -1
  301. package/dist/common/chunk-A2XB7TVI.js +0 -4
  302. package/dist/esm/chunk-2PASUPUO.mjs +0 -2
  303. package/dist/esm/chunk-2PASUPUO.mjs.map +0 -1
  304. package/dist/esm/chunk-2XQKGWHQ.mjs +0 -2
  305. package/dist/esm/chunk-2XQKGWHQ.mjs.map +0 -1
  306. package/dist/esm/chunk-35DKMW7Q.mjs +0 -2
  307. package/dist/esm/chunk-35DKMW7Q.mjs.map +0 -1
  308. package/dist/esm/chunk-4AI7KQQ7.mjs +0 -2
  309. package/dist/esm/chunk-4AI7KQQ7.mjs.map +0 -1
  310. package/dist/esm/chunk-4QMXOWHP.mjs +0 -1
  311. package/dist/esm/chunk-4QMXOWHP.mjs.map +0 -1
  312. package/dist/esm/chunk-4RXKALLC.mjs +0 -2
  313. package/dist/esm/chunk-4RXKALLC.mjs.map +0 -1
  314. package/dist/esm/chunk-4WPQQPUF.mjs +0 -1
  315. package/dist/esm/chunk-4WPQQPUF.mjs.map +0 -1
  316. package/dist/esm/chunk-56CNRT2K.mjs +0 -2
  317. package/dist/esm/chunk-56CNRT2K.mjs.map +0 -1
  318. package/dist/esm/chunk-5HXLZHDW.mjs +0 -1
  319. package/dist/esm/chunk-5HXLZHDW.mjs.map +0 -1
  320. package/dist/esm/chunk-6OWBKU7N.mjs +0 -2
  321. package/dist/esm/chunk-6OWBKU7N.mjs.map +0 -1
  322. package/dist/esm/chunk-6WDVDEQZ.mjs +0 -7
  323. package/dist/esm/chunk-6WDVDEQZ.mjs.map +0 -1
  324. package/dist/esm/chunk-7DQDJ2SA.mjs +0 -2
  325. package/dist/esm/chunk-7DQDJ2SA.mjs.map +0 -1
  326. package/dist/esm/chunk-7ECCT6PK.mjs +0 -1
  327. package/dist/esm/chunk-7ECCT6PK.mjs.map +0 -1
  328. package/dist/esm/chunk-7EER7GWV.mjs +0 -2
  329. package/dist/esm/chunk-7EER7GWV.mjs.map +0 -1
  330. package/dist/esm/chunk-A5L76YP7.mjs +0 -2
  331. package/dist/esm/chunk-A5L76YP7.mjs.map +0 -1
  332. package/dist/esm/chunk-AMXZQPUQ.mjs +0 -2
  333. package/dist/esm/chunk-AMXZQPUQ.mjs.map +0 -1
  334. package/dist/esm/chunk-B563XRSZ.mjs +0 -2
  335. package/dist/esm/chunk-B563XRSZ.mjs.map +0 -1
  336. package/dist/esm/chunk-C3Q23D22.mjs +0 -2
  337. package/dist/esm/chunk-C3Q23D22.mjs.map +0 -1
  338. package/dist/esm/chunk-CIJA7ONS.mjs +0 -2
  339. package/dist/esm/chunk-CIJA7ONS.mjs.map +0 -1
  340. package/dist/esm/chunk-CW35YAMN.mjs +0 -2
  341. package/dist/esm/chunk-CW35YAMN.mjs.map +0 -1
  342. package/dist/esm/chunk-EBMEXURY.mjs +0 -2
  343. package/dist/esm/chunk-EBMEXURY.mjs.map +0 -1
  344. package/dist/esm/chunk-EF4FA5I6.mjs +0 -2
  345. package/dist/esm/chunk-EF4FA5I6.mjs.map +0 -1
  346. package/dist/esm/chunk-FD6FGKYY.mjs +0 -1
  347. package/dist/esm/chunk-FD6FGKYY.mjs.map +0 -1
  348. package/dist/esm/chunk-FGFLPH5K.mjs +0 -2
  349. package/dist/esm/chunk-FGFLPH5K.mjs.map +0 -1
  350. package/dist/esm/chunk-FLZPUYXQ.mjs +0 -2
  351. package/dist/esm/chunk-FLZPUYXQ.mjs.map +0 -1
  352. package/dist/esm/chunk-FZY4PMEE.mjs +0 -1
  353. package/dist/esm/chunk-FZY4PMEE.mjs.map +0 -1
  354. package/dist/esm/chunk-G3MHXDYA.mjs +0 -1
  355. package/dist/esm/chunk-G3MHXDYA.mjs.map +0 -1
  356. package/dist/esm/chunk-GOXRBEIJ.mjs +0 -2
  357. package/dist/esm/chunk-GOXRBEIJ.mjs.map +0 -1
  358. package/dist/esm/chunk-HGLO5LDS.mjs +0 -1
  359. package/dist/esm/chunk-HGLO5LDS.mjs.map +0 -1
  360. package/dist/esm/chunk-HNBVYE3N.mjs +0 -2
  361. package/dist/esm/chunk-HNBVYE3N.mjs.map +0 -1
  362. package/dist/esm/chunk-I7XT6L7S.mjs +0 -2
  363. package/dist/esm/chunk-I7XT6L7S.mjs.map +0 -1
  364. package/dist/esm/chunk-IF4UU2MT.mjs +0 -2
  365. package/dist/esm/chunk-IF4UU2MT.mjs.map +0 -1
  366. package/dist/esm/chunk-JABP65XD.mjs +0 -2
  367. package/dist/esm/chunk-JABP65XD.mjs.map +0 -1
  368. package/dist/esm/chunk-KDMSOCZY.mjs +0 -2
  369. package/dist/esm/chunk-KDMSOCZY.mjs.map +0 -1
  370. package/dist/esm/chunk-L72TIN7T.mjs +0 -4
  371. package/dist/esm/chunk-L72TIN7T.mjs.map +0 -1
  372. package/dist/esm/chunk-M3AO73ZL.mjs +0 -2
  373. package/dist/esm/chunk-M3AO73ZL.mjs.map +0 -1
  374. package/dist/esm/chunk-MCFQE4GC.mjs +0 -2
  375. package/dist/esm/chunk-MCFQE4GC.mjs.map +0 -1
  376. package/dist/esm/chunk-MT2RJ7H3.mjs +0 -2
  377. package/dist/esm/chunk-MT2RJ7H3.mjs.map +0 -1
  378. package/dist/esm/chunk-N6YTF76Q.mjs +0 -2
  379. package/dist/esm/chunk-N6YTF76Q.mjs.map +0 -1
  380. package/dist/esm/chunk-NECL5FCQ.mjs +0 -1
  381. package/dist/esm/chunk-NECL5FCQ.mjs.map +0 -1
  382. package/dist/esm/chunk-OLILO7VD.mjs +0 -2
  383. package/dist/esm/chunk-OLILO7VD.mjs.map +0 -1
  384. package/dist/esm/chunk-ORMOQWWH.mjs +0 -2
  385. package/dist/esm/chunk-ORMOQWWH.mjs.map +0 -1
  386. package/dist/esm/chunk-Q4W3WJ2U.mjs +0 -2
  387. package/dist/esm/chunk-Q4W3WJ2U.mjs.map +0 -1
  388. package/dist/esm/chunk-QP2BY4PK.mjs +0 -2
  389. package/dist/esm/chunk-QP2BY4PK.mjs.map +0 -1
  390. package/dist/esm/chunk-QREVMGQZ.mjs +0 -2
  391. package/dist/esm/chunk-QREVMGQZ.mjs.map +0 -1
  392. package/dist/esm/chunk-RCSJFTST.mjs +0 -2
  393. package/dist/esm/chunk-RCSJFTST.mjs.map +0 -1
  394. package/dist/esm/chunk-RGKRCZ36.mjs +0 -4
  395. package/dist/esm/chunk-RGKRCZ36.mjs.map +0 -1
  396. package/dist/esm/chunk-SJDCGNWU.mjs +0 -2
  397. package/dist/esm/chunk-SJDCGNWU.mjs.map +0 -1
  398. package/dist/esm/chunk-STY74NUA.mjs +0 -2
  399. package/dist/esm/chunk-STY74NUA.mjs.map +0 -1
  400. package/dist/esm/chunk-TOBQ5UE6.mjs +0 -2
  401. package/dist/esm/chunk-TOBQ5UE6.mjs.map +0 -1
  402. package/dist/esm/chunk-UL777LTI.mjs +0 -494
  403. package/dist/esm/chunk-UL777LTI.mjs.map +0 -1
  404. package/dist/esm/chunk-UYVPNUH3.mjs +0 -1
  405. package/dist/esm/chunk-UYVPNUH3.mjs.map +0 -1
  406. package/dist/esm/chunk-V3MBJJTL.mjs +0 -1
  407. package/dist/esm/chunk-V3MBJJTL.mjs.map +0 -1
  408. package/dist/esm/chunk-WCMW2L3P.mjs +0 -2
  409. package/dist/esm/chunk-WCMW2L3P.mjs.map +0 -1
  410. package/dist/esm/chunk-WHSTLR3F.mjs +0 -2
  411. package/dist/esm/chunk-WHSTLR3F.mjs.map +0 -1
  412. package/dist/esm/chunk-WSR5EBJM.mjs +0 -2
  413. package/dist/esm/chunk-WSR5EBJM.mjs.map +0 -1
  414. package/dist/esm/chunk-XJJVJOX5.mjs +0 -2
  415. package/dist/esm/chunk-XJJVJOX5.mjs.map +0 -1
  416. package/dist/esm/chunk-XKUIMGKU.mjs +0 -2
  417. package/dist/esm/chunk-XKUIMGKU.mjs.map +0 -1
  418. package/dist/esm/chunk-YOZBVVKL.mjs +0 -2
  419. package/dist/esm/chunk-YOZBVVKL.mjs.map +0 -1
  420. package/dist/esm/chunk-ZP4DWSQA.mjs +0 -2
  421. package/dist/esm/chunk-ZP4DWSQA.mjs.map +0 -1
@@ -1,2 +1,2 @@
1
- import{K as a,L as b}from"../../chunk-L72TIN7T.mjs";import"../../chunk-2XQKGWHQ.mjs";import"../../chunk-UYVPNUH3.mjs";import"../../chunk-XKUIMGKU.mjs";import"../../chunk-N6YTF76Q.mjs";import"../../chunk-A5L76YP7.mjs";import"../../chunk-I7XT6L7S.mjs";import"../../chunk-5HXLZHDW.mjs";import"../../chunk-G3MHXDYA.mjs";import"../../chunk-JABP65XD.mjs";import"../../chunk-GOXRBEIJ.mjs";import"../../chunk-2PASUPUO.mjs";import"../../chunk-XJJVJOX5.mjs";import"../../chunk-NECL5FCQ.mjs";import"../../chunk-4QMXOWHP.mjs";import"../../chunk-EF4FA5I6.mjs";import"../../chunk-WCMW2L3P.mjs";import"../../chunk-WSR5EBJM.mjs";import"../../chunk-C3Q23D22.mjs";import"../../chunk-QREVMGQZ.mjs";import"../../chunk-V3MBJJTL.mjs";import"../../chunk-ZP4DWSQA.mjs";import"../../chunk-FGFLPH5K.mjs";import"../../chunk-WHSTLR3F.mjs";import"../../chunk-M3AO73ZL.mjs";import"../../chunk-6OWBKU7N.mjs";import"../../chunk-AMXZQPUQ.mjs";import"../../chunk-YOZBVVKL.mjs";import"../../chunk-SJDCGNWU.mjs";import"../../chunk-UL777LTI.mjs";import"../../chunk-7ECCT6PK.mjs";import"../../chunk-4AI7KQQ7.mjs";import"../../chunk-7EER7GWV.mjs";import"../../chunk-QP2BY4PK.mjs";import"../../chunk-HGLO5LDS.mjs";import"../../chunk-CW35YAMN.mjs";import"../../chunk-6WDVDEQZ.mjs";import"../../chunk-RCSJFTST.mjs";import"../../chunk-4RXKALLC.mjs";import"../../chunk-OLILO7VD.mjs";import"../../chunk-7DQDJ2SA.mjs";import"../../chunk-HNBVYE3N.mjs";import"../../chunk-RGKRCZ36.mjs";import"../../chunk-FZY4PMEE.mjs";import"../../chunk-Q4W3WJ2U.mjs";import"../../chunk-TOBQ5UE6.mjs";import"../../chunk-MT2RJ7H3.mjs";import"../../chunk-ORMOQWWH.mjs";import"../../chunk-FD6FGKYY.mjs";import"../../chunk-4WPQQPUF.mjs";import"../../chunk-MCFQE4GC.mjs";import"../../chunk-FLZPUYXQ.mjs";import"../../chunk-EBMEXURY.mjs";import"../../chunk-STY74NUA.mjs";import"../../chunk-IF4UU2MT.mjs";import"../../chunk-56CNRT2K.mjs";import"../../chunk-CIJA7ONS.mjs";import"../../chunk-KDMSOCZY.mjs";export{a as MultiEd25519PublicKey,b as MultiEd25519Signature};
1
+ import{SigningScheme as E}from"../../types";import{AuthenticationKey as p}from"../authenticationKey";import{Ed25519PublicKey as u,Ed25519Signature as l}from"./ed25519";import{AbstractMultiKey as d}from"./multiKey";import{Signature as m}from"./signature";const a=class a extends d{constructor(e){const{publicKeys:t,threshold:r}=e;if(super({publicKeys:t}),t.length>a.MAX_KEYS||t.length<a.MIN_KEYS)throw new Error(`Must have between ${a.MIN_KEYS} and ${a.MAX_KEYS} public keys, inclusive`);if(r<a.MIN_THRESHOLD||r>t.length)throw new Error(`Threshold must be between ${a.MIN_THRESHOLD} and ${t.length}, inclusive`);this.publicKeys=t,this.threshold=r}getSignaturesRequired(){return this.threshold}verifySignature(e){const{message:t,signature:r}=e;if(!(r instanceof g))return!1;const s=[];for(let i=0;i<4;i+=1)for(let n=0;n<8;n+=1)if((r.bitmap[i]&1<<7-n)!==0){const c=i*8+n;s.push(c)}if(s.length!==r.signatures.length)throw new Error("Bitmap and signatures length mismatch");if(s.length<this.threshold)throw new Error("Not enough signatures");for(let i=0;i<s.length;i+=1)if(!this.publicKeys[s[i]].verifySignature({message:t,signature:r.signatures[i]}))return!1;return!0}async verifySignatureAsync(e){return this.verifySignature(e)}authKey(){return p.fromSchemeAndBytes({scheme:E.MultiEd25519,input:this.toUint8Array()})}toUint8Array(){const e=new Uint8Array(this.publicKeys.length*u.LENGTH+1);return this.publicKeys.forEach((t,r)=>{e.set(t.toUint8Array(),r*u.LENGTH)}),e[this.publicKeys.length*u.LENGTH]=this.threshold,e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){const t=e.deserializeBytes(),r=t[t.length-1],s=[];for(let i=0;i<t.length-1;i+=u.LENGTH){const n=i;s.push(new u(t.subarray(n,n+u.LENGTH)))}return new a({publicKeys:s,threshold:r})}static deserializeWithoutLength(e){const t=e.remaining(),r=e.deserializeFixedBytes(t),s=r[r.length-1],i=[];for(let n=0;n<r.length-1;n+=u.LENGTH){const h=n;i.push(new u(r.subarray(h,h+u.LENGTH)))}return new a({publicKeys:i,threshold:s})}getIndex(e){return super.getIndex(e)}};a.MAX_KEYS=32,a.MIN_KEYS=2,a.MIN_THRESHOLD=1;let b=a;const o=class o extends m{constructor(e){super();const{signatures:t,bitmap:r}=e;if(t.length>o.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${o.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t,!(r instanceof Uint8Array))this.bitmap=o.createBitmap({bits:r});else{if(r.length!==o.BITMAP_LEN)throw new Error(`"bitmap" length should be ${o.BITMAP_LEN}`);this.bitmap=r}}toUint8Array(){const e=new Uint8Array(this.signatures.length*l.LENGTH+o.BITMAP_LEN);return this.signatures.forEach((t,r)=>{e.set(t.toUint8Array(),r*l.LENGTH)}),e.set(this.bitmap,this.signatures.length*l.LENGTH),e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){const t=e.deserializeBytes(),r=t.subarray(t.length-4),s=[];for(let i=0;i<t.length-r.length;i+=l.LENGTH){const n=i;s.push(new l(t.subarray(n,n+l.LENGTH)))}return new o({signatures:s,bitmap:r})}static createBitmap(e){const{bits:t}=e,r=128,s=new Uint8Array([0,0,0,0]),i=new Set;return t.forEach((n,h)=>{if(n>=o.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${o.MAX_SIGNATURES_SUPPORTED-1}.`);if(i.has(n))throw new Error("Duplicate bits detected.");if(h>0&&n<=t[h-1])throw new Error("The bits need to be sorted in ascending order.");i.add(n);const c=Math.floor(n/8);let y=s[c];y|=r>>n%8,s[c]=y}),s}};o.MAX_SIGNATURES_SUPPORTED=32,o.BITMAP_LEN=4;let g=o;export{b as MultiEd25519PublicKey,g as MultiEd25519Signature};
2
2
  //# sourceMappingURL=multiEd25519.mjs.map
@@ -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,EAA6D,CACvE,KAAM,CAAE,WAAAC,EAAY,UAAAC,CAAU,EAAIF,EAIlC,GAHA,MAAM,CAAE,WAAAC,CAAW,CAAC,EAGhBA,EAAW,OAASF,EAAsB,UAAYE,EAAW,OAASF,EAAsB,SAClG,MAAM,IAAI,MACR,qBAAqBA,EAAsB,QAAQ,QAC9CA,EAAsB,QAAQ,yBACrC,EAIF,GAAIG,EAAYH,EAAsB,eAAiBG,EAAYD,EAAW,OAC5E,MAAM,IAAI,MACR,6BAA6BF,EAAsB,aAAa,QAAQE,EAAW,MAAM,aAC3F,EAGF,KAAK,WAAaA,EAClB,KAAK,UAAYC,CACnB,CAEA,uBAAgC,CAC9B,OAAO,KAAK,SACd,CAgBA,gBAAgBF,EAA4D,CAC1E,KAAM,CAAE,QAAAG,EAAS,UAAAC,CAAU,EAAIJ,EAC/B,GAAI,EAAEI,aAAqBC,GACzB,MAAO,GAGT,MAAMC,EAAoB,CAAC,EAC3B,QAAS,EAAI,EAAG,EAAI,EAAG,GAAK,EAC1B,QAASC,EAAI,EAAGA,EAAI,EAAGA,GAAK,EAG1B,IADkBH,EAAU,OAAO,CAAC,EAAK,GAAM,EAAIG,KAAS,EAC9C,CACZ,MAAMC,EAAQ,EAAI,EAAID,EACtBD,EAAQ,KAAKE,CAAK,C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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,2 +1,4 @@
1
- import{H as a,I as b,J as c}from"../../chunk-L72TIN7T.mjs";import"../../chunk-2XQKGWHQ.mjs";import"../../chunk-UYVPNUH3.mjs";import"../../chunk-XKUIMGKU.mjs";import"../../chunk-N6YTF76Q.mjs";import"../../chunk-A5L76YP7.mjs";import"../../chunk-I7XT6L7S.mjs";import"../../chunk-5HXLZHDW.mjs";import"../../chunk-G3MHXDYA.mjs";import"../../chunk-JABP65XD.mjs";import"../../chunk-GOXRBEIJ.mjs";import"../../chunk-2PASUPUO.mjs";import"../../chunk-XJJVJOX5.mjs";import"../../chunk-NECL5FCQ.mjs";import"../../chunk-4QMXOWHP.mjs";import"../../chunk-EF4FA5I6.mjs";import"../../chunk-WCMW2L3P.mjs";import"../../chunk-WSR5EBJM.mjs";import"../../chunk-C3Q23D22.mjs";import"../../chunk-QREVMGQZ.mjs";import"../../chunk-V3MBJJTL.mjs";import"../../chunk-ZP4DWSQA.mjs";import"../../chunk-FGFLPH5K.mjs";import"../../chunk-WHSTLR3F.mjs";import"../../chunk-M3AO73ZL.mjs";import"../../chunk-6OWBKU7N.mjs";import"../../chunk-AMXZQPUQ.mjs";import"../../chunk-YOZBVVKL.mjs";import"../../chunk-SJDCGNWU.mjs";import"../../chunk-UL777LTI.mjs";import"../../chunk-7ECCT6PK.mjs";import"../../chunk-4AI7KQQ7.mjs";import"../../chunk-7EER7GWV.mjs";import"../../chunk-QP2BY4PK.mjs";import"../../chunk-HGLO5LDS.mjs";import"../../chunk-CW35YAMN.mjs";import"../../chunk-6WDVDEQZ.mjs";import"../../chunk-RCSJFTST.mjs";import"../../chunk-4RXKALLC.mjs";import"../../chunk-OLILO7VD.mjs";import"../../chunk-7DQDJ2SA.mjs";import"../../chunk-HNBVYE3N.mjs";import"../../chunk-RGKRCZ36.mjs";import"../../chunk-FZY4PMEE.mjs";import"../../chunk-Q4W3WJ2U.mjs";import"../../chunk-TOBQ5UE6.mjs";import"../../chunk-MT2RJ7H3.mjs";import"../../chunk-ORMOQWWH.mjs";import"../../chunk-FD6FGKYY.mjs";import"../../chunk-4WPQQPUF.mjs";import"../../chunk-MCFQE4GC.mjs";import"../../chunk-FLZPUYXQ.mjs";import"../../chunk-EBMEXURY.mjs";import"../../chunk-STY74NUA.mjs";import"../../chunk-IF4UU2MT.mjs";import"../../chunk-56CNRT2K.mjs";import"../../chunk-CIJA7ONS.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,GA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AAII,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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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,2 +1,2 @@
1
- import{a}from"../../chunk-2PASUPUO.mjs";import"../../chunk-FD6FGKYY.mjs";import"../../chunk-4WPQQPUF.mjs";import"../../chunk-MCFQE4GC.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,2 +1,2 @@
1
- import{a}from"../../chunk-XJJVJOX5.mjs";import"../../chunk-FZY4PMEE.mjs";import"../../chunk-Q4W3WJ2U.mjs";import"../../chunk-TOBQ5UE6.mjs";import"../../chunk-MT2RJ7H3.mjs";import"../../chunk-ORMOQWWH.mjs";import"../../chunk-FD6FGKYY.mjs";import"../../chunk-4WPQQPUF.mjs";import"../../chunk-MCFQE4GC.mjs";import"../../chunk-FLZPUYXQ.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,2 +1,2 @@
1
- import{a,b}from"../../chunk-WSR5EBJM.mjs";import"../../chunk-FZY4PMEE.mjs";import"../../chunk-Q4W3WJ2U.mjs";import"../../chunk-TOBQ5UE6.mjs";import"../../chunk-MT2RJ7H3.mjs";import"../../chunk-ORMOQWWH.mjs";import"../../chunk-FD6FGKYY.mjs";import"../../chunk-4WPQQPUF.mjs";import"../../chunk-MCFQE4GC.mjs";import"../../chunk-FLZPUYXQ.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,2 +1,2 @@
1
- import{C as a,D as b,E as c}from"../../chunk-L72TIN7T.mjs";import"../../chunk-2XQKGWHQ.mjs";import"../../chunk-UYVPNUH3.mjs";import"../../chunk-XKUIMGKU.mjs";import"../../chunk-N6YTF76Q.mjs";import"../../chunk-A5L76YP7.mjs";import"../../chunk-I7XT6L7S.mjs";import"../../chunk-5HXLZHDW.mjs";import"../../chunk-G3MHXDYA.mjs";import"../../chunk-JABP65XD.mjs";import"../../chunk-GOXRBEIJ.mjs";import"../../chunk-2PASUPUO.mjs";import"../../chunk-XJJVJOX5.mjs";import"../../chunk-NECL5FCQ.mjs";import"../../chunk-4QMXOWHP.mjs";import"../../chunk-EF4FA5I6.mjs";import"../../chunk-WCMW2L3P.mjs";import"../../chunk-WSR5EBJM.mjs";import"../../chunk-C3Q23D22.mjs";import"../../chunk-QREVMGQZ.mjs";import"../../chunk-V3MBJJTL.mjs";import"../../chunk-ZP4DWSQA.mjs";import"../../chunk-FGFLPH5K.mjs";import"../../chunk-WHSTLR3F.mjs";import"../../chunk-M3AO73ZL.mjs";import"../../chunk-6OWBKU7N.mjs";import"../../chunk-AMXZQPUQ.mjs";import"../../chunk-YOZBVVKL.mjs";import"../../chunk-SJDCGNWU.mjs";import"../../chunk-UL777LTI.mjs";import"../../chunk-7ECCT6PK.mjs";import"../../chunk-4AI7KQQ7.mjs";import"../../chunk-7EER7GWV.mjs";import"../../chunk-QP2BY4PK.mjs";import"../../chunk-HGLO5LDS.mjs";import"../../chunk-CW35YAMN.mjs";import"../../chunk-6WDVDEQZ.mjs";import"../../chunk-RCSJFTST.mjs";import"../../chunk-4RXKALLC.mjs";import"../../chunk-OLILO7VD.mjs";import"../../chunk-7DQDJ2SA.mjs";import"../../chunk-HNBVYE3N.mjs";import"../../chunk-RGKRCZ36.mjs";import"../../chunk-FZY4PMEE.mjs";import"../../chunk-Q4W3WJ2U.mjs";import"../../chunk-TOBQ5UE6.mjs";import"../../chunk-MT2RJ7H3.mjs";import"../../chunk-ORMOQWWH.mjs";import"../../chunk-FD6FGKYY.mjs";import"../../chunk-4WPQQPUF.mjs";import"../../chunk-MCFQE4GC.mjs";import"../../chunk-FLZPUYXQ.mjs";import"../../chunk-EBMEXURY.mjs";import"../../chunk-STY74NUA.mjs";import"../../chunk-IF4UU2MT.mjs";import"../../chunk-56CNRT2K.mjs";import"../../chunk-CIJA7ONS.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,aAAAC,MAAiB,cAC1B,OAAS,aAAAC,MAAiB,cAC1B,OAAS,yBAAAC,MAA6B,UAW/B,MAAMC,EAAN,MAAMA,UAA2BH,CAAU,CAsBhD,YAAYI,EAAoB,CAC9B,MAAM,EAZR,KAAgB,QAAkB,YAchC,MAAMC,EAAMV,EAAI,aAAaS,CAAQ,EAC/B,CAAE,OAAAE,CAAO,EAAID,EAAI,aAAa,EACpC,GAAIC,IAAWH,EAAmB,OAChC,KAAK,IAAME,UACFC,IAAWH,EAAmB,kBAAmB,CAC1D,MAAMI,EAAQf,EAAU,gBAAgB,QAAQa,EAAI,aAAa,CAAC,EAClE,KAAK,IAAMV,EAAI,aAAaY,EAAM,WAAW,EAAK,CAAC,CACrD,KACE,OAAM,IAAI,MACR,8BAA8BJ,EAAmB,MAAM,OAAOA,EAAmB,iBAAiB,cAAcG,CAAM,EACxH,CAEJ,CAcA,gBAAgBE,EAAqE,CACnF,KAAM,CAAE,QAAAC,EAAS,UAAAC,CAAU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AAO,EAAK,CAC7C,CAaA,OAAO,aAAaS,EAA2D,CAC7E,OAAOA,aAAsBN,CAC/B,CACF,EAjMaA,EAMK,OAAiB,GAN5B,IAAMS,EAANT,EAyMA,MAAMU,EAAN,MAAMA,UAA2B9B,CAAU,CAyBhD,YAAYG,EAAoB,CAC9B,MAAM,EACN,MAAM4B,EAAOrC,EAAI,aAAaS,CAAQ,EACtC,GAAI4B,EAAK,aAAa,EAAE,SAAWD,EAAmB,OACpD,MAAM,IAAI,MACR,8BAA8BA,EAAmB,MAAM,cAAcC,EAAK,aAAa,EAAE,MAAM,EACjG,EAEF,KAAK,KAAOA,CACd,CAMA,cAA2B,CACzB,OAAO,KAAK,KAAK,aAAa,CAChC,CAMA,UAAUjB,EAA8B,CACtCA,EAAW,eAAe,KAAK,KAAK,aAAa,CAAC,CACpD,CAEA,OAAO,YAAYC,EAAgD,CACjE,MAAMX,EAAMW,EAAa,iBAAiB,EAC1C,OAAO,IAAIe,EAAmB1B,CAAG,CACnC,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"]}
@@ -1,2 +1,2 @@
1
- import{a,b,c,d}from"../../chunk-I7XT6L7S.mjs";import"../../chunk-2PASUPUO.mjs";import"../../chunk-WCMW2L3P.mjs";import"../../chunk-WSR5EBJM.mjs";import"../../chunk-FGFLPH5K.mjs";import"../../chunk-RGKRCZ36.mjs";import"../../chunk-FZY4PMEE.mjs";import"../../chunk-Q4W3WJ2U.mjs";import"../../chunk-TOBQ5UE6.mjs";import"../../chunk-MT2RJ7H3.mjs";import"../../chunk-ORMOQWWH.mjs";import"../../chunk-FD6FGKYY.mjs";import"../../chunk-4WPQQPUF.mjs";import"../../chunk-MCFQE4GC.mjs";import"../../chunk-FLZPUYXQ.mjs";import"../../chunk-EBMEXURY.mjs";import"../../chunk-STY74NUA.mjs";import"../../chunk-IF4UU2MT.mjs";import"../../chunk-56CNRT2K.mjs";import"../../chunk-KDMSOCZY.mjs";export{b as Secp256r1PrivateKey,a as Secp256r1PublicKey,d as Secp256r1Signature,c as WebAuthnSignature};
1
+ import{sha3_256 as p}from"@noble/hashes/sha3";import{p256 as o}from"@noble/curves/nist.js";import{Serializer as c}from"../../bcs";import{Hex as s}from"../hex";import{PrivateKeyVariants as m,SigningScheme as f,AnyPublicKeyVariant as U}from"../../types";import{PublicKey as z}from"./publicKey";import{PrivateKey as l}from"./privateKey";import{Signature as x}from"./signature";import{AuthenticationKey as b}from"../authenticationKey";const n=class n extends z{constructor(e){super();this.keyType="secp256r1";const r=s.fromHexInput(e),i=r.toUint8Array().length;if(i!==n.LENGTH&&i!==n.COMPRESSED_LENGTH)throw new Error(`PublicKey length should be ${n.LENGTH} or ${n.COMPRESSED_LENGTH}, received ${i}`);if(i===n.COMPRESSED_LENGTH){const u=o.ProjectivePoint.fromHex(r.toUint8Array());this.key=s.fromHexInput(u.toRawBytes(!1))}else this.key=r}toUint8Array(){return this.key.toUint8Array()}toString(){return this.key.toString()}bcsToBytes(){const e=new c;return this.serialize(e),e.toUint8Array()}verifySignature(e){const{message:r,signature:i}=e,u=s.fromHexInput(r).toUint8Array(),A=p(u),d=i.toUint8Array();return o.verify(d,A,this.toUint8Array())}async verifySignatureAsync(e){return this.verifySignature({message:e.message,signature:e.signature})}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){const r=e.deserializeBytes();return new n(r)}static load(e){const r=e.deserializeBytes();return new n(r)}static isInstance(e){return"key"in e&&e.key?.data?.length===n.LENGTH&&"keyType"in e&&e.keyType==="secp256r1"}authKey(){const e=new c;return e.serializeU32AsUleb128(U.Secp256r1),e.serializeFixedBytes(this.bcsToBytes()),b.fromSchemeAndBytes({scheme:f.SingleKey,input:e.toUint8Array()})}};n.LENGTH=65,n.COMPRESSED_LENGTH=33;let h=n;const a=class a extends l{constructor(t,e){super();const r=l.parseHexInput(t,m.Secp256r1,e),i=r.toUint8Array().length;if(i!==a.LENGTH)throw new Error(`PrivateKey length should be ${a.LENGTH}, received ${i}`);this.key=r}toUint8Array(){return this.key.toUint8Array()}toString(){return l.formatPrivateKey(this.key.toString(),m.Secp256r1)}toHexString(){return this.key.toString()}sign(t){const e=s.fromHexInput(t),r=p(e.toUint8Array()),i=o.sign(r,this.key.toUint8Array());return new g(i.toCompactRawBytes())}serialize(t){t.serializeBytes(this.toUint8Array())}static deserialize(t){const e=t.deserializeBytes();return new a(e)}static generate(){const t=o.utils.randomPrivateKey();return new a(t)}publicKey(){const t=o.getPublicKey(this.key.toUint8Array(),!1);return new h(t)}};a.LENGTH=32;let H=a;class S extends x{constructor(t,e,r){super(),this.signature=s.fromHexInput(t),this.authenticatorData=s.fromHexInput(e),this.clientDataJSON=s.fromHexInput(r)}toUint8Array(){return this.signature.toUint8Array()}serialize(t){t.serializeU32AsUleb128(0),t.serializeBytes(this.signature.toUint8Array()),t.serializeBytes(this.authenticatorData.toUint8Array()),t.serializeBytes(this.clientDataJSON.toUint8Array())}bcsToBytes(){const t=new c;return this.serialize(t),t.toUint8Array()}bcsToHex(){return s.fromHexInput(this.bcsToBytes())}toStringWithoutPrefix(){return s.fromHexInput(this.bcsToBytes()).toString()}static deserialize(t){const e=t.deserializeUleb128AsU32();if(e!==0)throw new Error(`Invalid id for WebAuthnSignature: ${e}`);const r=t.deserializeBytes(),i=t.deserializeBytes(),u=t.deserializeBytes();return new S(r,i,u)}}const y=class y extends x{constructor(t){super();const e=s.fromHexInput(t),r=e.toUint8Array().length;if(r!==y.LENGTH)throw new Error(`Signature length should be ${y.LENGTH}, received ${r}`);const i=o.Signature.fromCompact(e.toUint8Array()).normalizeS().toCompactRawBytes();this.data=s.fromHexInput(i)}toUint8Array(){return this.data.toUint8Array()}toString(){return this.data.toString()}serialize(t){t.serializeBytes(this.data.toUint8Array())}static deserialize(t){const e=t.deserializeBytes();return new y(e)}};y.LENGTH=64;let g=y;export{H as Secp256r1PrivateKey,h as Secp256r1PublicKey,g as Secp256r1Signature,S as WebAuthnSignature};
2
2
  //# sourceMappingURL=secp256r1.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../../src/core/crypto/secp256r1.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { sha3_256 } from \"@noble/hashes/sha3\";\nimport { p256 } from \"@noble/curves/nist.js\";\nimport { Deserializer, Serializer } from \"../../bcs\";\nimport { Hex } from \"../hex\";\nimport {\n HexInput,\n PrivateKeyVariants,\n SigningScheme as AuthenticationKeyScheme,\n AnyPublicKeyVariant,\n} from \"../../types\";\nimport { PublicKey, VerifySignatureAsyncArgs } from \"./publicKey\";\nimport { PrivateKey } from \"./privateKey\";\nimport { Signature } from \"./signature\";\nimport { AuthenticationKey } from \"../authenticationKey\";\n\n/**\n * Represents a Secp256r1 ECDSA public key.\n *\n * @extends PublicKey\n * @property LENGTH - The length of the Secp256r1 public key in bytes.\n * @group Implementation\n * @category Serialization\n */\nexport class Secp256r1PublicKey extends PublicKey {\n // Secp256r1 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 = \"secp256r1\";\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 public key data.\n *\n * @param hexInput - A HexInput (string or Uint8Array) representing the public key data.\n * @throws Error if the length of the public key data is not equal to Secp256r1PublicKey.LENGTH or COMPRESSED_LENGTH.\n * @group Implementation\n * @category Serialization\n */\n constructor(hexInput: HexInput) {\n super();\n\n const hex = Hex.fromHexInput(hexInput);\n const keyLength = hex.toUint8Array().length;\n if (keyLength !== Secp256r1PublicKey.LENGTH && keyLength !== Secp256r1PublicKey.COMPRESSED_LENGTH) {\n throw new Error(\n `PublicKey length should be ${Secp256r1PublicKey.LENGTH} or ${Secp256r1PublicKey.COMPRESSED_LENGTH}, received ${keyLength}`,\n );\n }\n\n if (keyLength === Secp256r1PublicKey.COMPRESSED_LENGTH) {\n const point = p256.ProjectivePoint.fromHex(hex.toUint8Array());\n this.key = Hex.fromHexInput(point.toRawBytes(false));\n } else {\n this.key = hex;\n }\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 /**\n * Get the public key as a hex string with the 0x prefix.\n *\n * @returns string representation of the public key.\n * @group Implementation\n * @category Serialization\n */\n toString(): string {\n return this.key.toString();\n }\n\n /**\n * Converts the public key to BCS (Binary Canonical Serialization) bytes.\n * This function serializes the public key data into a byte array format suitable for transmission or storage.\n *\n * @returns Uint8Array representation of the serialized public key.\n * @group Implementation\n * @category Serialization\n */\n bcsToBytes() {\n const serializer = new Serializer();\n this.serialize(serializer);\n return serializer.toUint8Array();\n }\n\n /**\n * Verifies a Secp256r1 signature against the public key.\n *\n * This function checks the validity of a signature for a 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 signature to verify against the public key.\n * @group Implementation\n * @category Serialization\n */\n verifySignature(args: { message: HexInput; signature: Signature }): boolean {\n const { message, signature } = args;\n\n const msgHex = Hex.fromHexInput(message).toUint8Array();\n const sha3Message = sha3_256(msgHex);\n const rawSignature = signature.toUint8Array();\n\n return p256.verify(rawSignature, sha3Message, this.toUint8Array());\n }\n\n /**\n * Note: Secp256r1Signatures can be verified synchronously.\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.message - The message that was signed.\n * @param args.signature - The signature to verify, which must be an instance of Secp256r1Signature.\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: VerifySignatureAsyncArgs): Promise<boolean> {\n return this.verifySignature({ message: args.message, signature: args.signature });\n }\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 Secp256r1PublicKey from the provided deserializer.\n * This function allows you to reconstruct a Secp256r1PublicKey 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): Secp256r1PublicKey {\n const bytes = deserializer.deserializeBytes();\n return new Secp256r1PublicKey(bytes);\n }\n\n /**\n * Loads a Secp256r1PublicKey from the provided deserializer.\n *\n * @param deserializer - The deserializer instance used to read the serialized data.\n * @group Implementation\n * @category Serialization\n */\n static load(deserializer: Deserializer): Secp256r1PublicKey {\n const bytes = deserializer.deserializeBytes();\n return new Secp256r1PublicKey(bytes);\n }\n\n /**\n * Determines if the provided public key is a valid instance of a Secp256r1 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 Secp256r1 public key.\n * @group Implementation\n * @category Serialization\n */\n static isInstance(publicKey: PublicKey): publicKey is Secp256r1PublicKey {\n return (\n \"key\" in publicKey &&\n (publicKey.key as any)?.data?.length === Secp256r1PublicKey.LENGTH &&\n \"keyType\" in publicKey &&\n (publicKey as any).keyType === \"secp256r1\"\n );\n }\n\n /**\n * Generates an authentication key from the public key using the Secp256r1 scheme.\n * This function is essential for creating a secure authentication key that can be used for further cryptographic operations.\n *\n * @returns {AuthenticationKey} The generated authentication key.\n * @group Implementation\n * @category Serialization\n */\n authKey(): AuthenticationKey {\n const serializer = new Serializer();\n serializer.serializeU32AsUleb128(AnyPublicKeyVariant.Secp256r1);\n serializer.serializeFixedBytes(this.bcsToBytes());\n return AuthenticationKey.fromSchemeAndBytes({\n scheme: AuthenticationKeyScheme.SingleKey,\n input: serializer.toUint8Array(),\n });\n }\n}\n\n/**\n * Represents a Secp256r1 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 Secp256r1PrivateKey extends PrivateKey {\n /**\n * Length of Secp256r1 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 /**\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.Secp256r1, strict);\n const keyLength = privateKeyHex.toUint8Array().length;\n if (keyLength !== Secp256r1PrivateKey.LENGTH) {\n throw new Error(`PrivateKey length should be ${Secp256r1PrivateKey.LENGTH}, received ${keyLength}`);\n }\n\n this.key = privateKeyHex;\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 PrivateKey.formatPrivateKey(this.key.toString(), PrivateKeyVariants.Secp256r1);\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 * Sign the given message with the private key.\n * This function generates a cryptographic signature for the provided message.\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): Secp256r1Signature {\n const msgHex = Hex.fromHexInput(message);\n const sha3Message = sha3_256(msgHex.toUint8Array());\n const signature = p256.sign(sha3Message, this.key.toUint8Array());\n return new Secp256r1Signature(signature.toCompactRawBytes());\n }\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.toUint8Array());\n }\n\n /**\n * Deserializes a Secp256r1PrivateKey from the provided deserializer.\n * This function allows you to reconstruct a Secp256r1PrivateKey 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): Secp256r1PrivateKey {\n const bytes = deserializer.deserializeBytes();\n return new Secp256r1PrivateKey(bytes);\n }\n\n /**\n * Generate a new random private key.\n *\n * @returns Secp256r1PrivateKey - A newly generated Secp256r1 private key.\n * @group Implementation\n * @category Serialization\n */\n static generate(): Secp256r1PrivateKey {\n const hexInput = p256.utils.randomPrivateKey();\n return new Secp256r1PrivateKey(hexInput);\n }\n\n /**\n * Derive the Secp256r1PublicKey from this private key.\n *\n * @returns Secp256r1PublicKey The derived public key.\n * @group Implementation\n * @category Serialization\n */\n publicKey(): Secp256r1PublicKey {\n const bytes = p256.getPublicKey(this.key.toUint8Array(), false);\n return new Secp256r1PublicKey(bytes);\n }\n}\n\nexport class WebAuthnSignature extends Signature {\n signature: Hex;\n\n authenticatorData: Hex;\n\n clientDataJSON: Hex;\n\n constructor(signature: HexInput, authenticatorData: HexInput, clientDataJSON: HexInput) {\n super();\n this.signature = Hex.fromHexInput(signature);\n this.authenticatorData = Hex.fromHexInput(authenticatorData);\n this.clientDataJSON = Hex.fromHexInput(clientDataJSON);\n }\n\n toUint8Array() {\n return this.signature.toUint8Array();\n }\n\n serialize(serializer: Serializer) {\n serializer.serializeU32AsUleb128(0);\n serializer.serializeBytes(this.signature.toUint8Array());\n serializer.serializeBytes(this.authenticatorData.toUint8Array());\n serializer.serializeBytes(this.clientDataJSON.toUint8Array());\n }\n\n bcsToBytes() {\n const serializer = new Serializer();\n this.serialize(serializer);\n return serializer.toUint8Array();\n }\n\n bcsToHex() {\n return Hex.fromHexInput(this.bcsToBytes());\n }\n\n toStringWithoutPrefix() {\n return Hex.fromHexInput(this.bcsToBytes()).toString();\n }\n\n static deserialize(deserializer: Deserializer) {\n const id = deserializer.deserializeUleb128AsU32();\n if (id !== 0) {\n throw new Error(`Invalid id for WebAuthnSignature: ${id}`);\n }\n const signature = deserializer.deserializeBytes();\n const authenticatorData = deserializer.deserializeBytes();\n const clientDataJSON = deserializer.deserializeBytes();\n return new WebAuthnSignature(signature, authenticatorData, clientDataJSON);\n }\n}\n\n/**\n * Represents a signature of a message signed using a Secp256r1 ECDSA private key.\n *\n * @group Implementation\n * @category Serialization\n */\nexport class Secp256r1Signature extends Signature {\n /**\n * Secp256r1 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 /**\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\n const hex = Hex.fromHexInput(hexInput);\n const signatureLength = hex.toUint8Array().length;\n if (signatureLength !== Secp256r1Signature.LENGTH) {\n throw new Error(`Signature length should be ${Secp256r1Signature.LENGTH}, received ${signatureLength}`);\n }\n const signature = p256.Signature.fromCompact(hex.toUint8Array()).normalizeS().toCompactRawBytes();\n this.data = Hex.fromHexInput(signature);\n }\n\n /**\n * Get the signature in bytes (Uint8Array).\n *\n * @returns Uint8Array representation of the signature\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.data.toUint8Array();\n }\n\n /**\n * Get the signature as a hex string with the 0x prefix.\n *\n * @returns string representation of the signature\n * @group Implementation\n * @category Serialization\n */\n toString(): string {\n return this.data.toString();\n }\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.data.toUint8Array());\n }\n\n /**\n * Deserializes a Secp256r1Signature from the provided deserializer.\n * This function allows you to reconstruct a Secp256r1Signature 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): Secp256r1Signature {\n const hex = deserializer.deserializeBytes();\n return new Secp256r1Signature(hex);\n }\n}\n"],"mappings":"AAGA,OAAS,YAAAA,MAAgB,qBACzB,OAAS,QAAAC,MAAY,wBACrB,OAAuB,cAAAC,MAAkB,YACzC,OAAS,OAAAC,MAAW,SACpB,OAEE,sBAAAC,EACA,iBAAiBC,EACjB,uBAAAC,MACK,cACP,OAAS,aAAAC,MAA2C,cACpD,OAAS,cAAAC,MAAkB,eAC3B,OAAS,aAAAC,MAAiB,cAC1B,OAAS,qBAAAC,MAAyB,uBAU3B,MAAMC,EAAN,MAAMA,UAA2BJ,CAAU,CAsBhD,YAAYK,EAAoB,CAC9B,MAAM,EAZR,KAAgB,QAAkB,YAchC,MAAMC,EAAMV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CAC3E,CACF,CAQO,MAAME,EAAN,MAAMA,UAA2B3B,CAAU,CAuBhD,YAAYG,EAAoB,CAC9B,MAAM,EAEN,MAAMC,EAAMV,EAAI,aAAaS,CAAQ,EAC/ByB,EAAkBxB,EAAI,aAAa,EAAE,OAC3C,GAAIwB,IAAoBD,EAAmB,OACzC,MAAM,IAAI,MAAM,8BAA8BA,EAAmB,MAAM,cAAcC,CAAe,EAAE,EAExG,MAAMlB,EAAYlB,EAAK,UAAU,YAAYY,EAAI,aAAa,CAAC,EAAE,WAAW,EAAE,kBAAkB,EAChG,KAAK,KAAOV,EAAI,aAAagB,CAAS,CACxC,CASA,cAA2B,CACzB,OAAO,KAAK,KAAK,aAAa,CAChC,CASA,UAAmB,CACjB,OAAO,KAAK,KAAK,SAAS,CAC5B,CAUA,UAAUH,EAA8B,CACtCA,EAAW,eAAe,KAAK,KAAK,aAAa,CAAC,CACpD,CAUA,OAAO,YAAYO,EAAgD,CACjE,MAAMV,EAAMU,EAAa,iBAAiB,EAC1C,OAAO,IAAIa,EAAmBvB,CAAG,CACnC,CACF,EAjFauB,EAMK,OAAS,GANpB,IAAMN,EAANM","names":["sha3_256","p256","Serializer","Hex","PrivateKeyVariants","AuthenticationKeyScheme","AnyPublicKeyVariant","PublicKey","PrivateKey","Signature","AuthenticationKey","_Secp256r1PublicKey","hexInput","hex","keyLength","point","serializer","args","message","signature","msgHex","sha3Message","rawSignature","deserializer","bytes","publicKey","Secp256r1PublicKey","_Secp256r1PrivateKey","strict","privateKeyHex","Secp256r1Signature","Secp256r1PrivateKey","WebAuthnSignature","authenticatorData","clientDataJSON","id","_Secp256r1Signature","signatureLength"]}
@@ -1,2 +1,2 @@
1
- import{a}from"../../chunk-WCMW2L3P.mjs";import"../../chunk-FZY4PMEE.mjs";import"../../chunk-Q4W3WJ2U.mjs";import"../../chunk-TOBQ5UE6.mjs";import"../../chunk-MT2RJ7H3.mjs";import"../../chunk-ORMOQWWH.mjs";import"../../chunk-FD6FGKYY.mjs";import"../../chunk-4WPQQPUF.mjs";import"../../chunk-MCFQE4GC.mjs";import"../../chunk-FLZPUYXQ.mjs";import"../../chunk-EBMEXURY.mjs";import"../../chunk-STY74NUA.mjs";import"../../chunk-IF4UU2MT.mjs";import"../../chunk-56CNRT2K.mjs";import"../../chunk-KDMSOCZY.mjs";export{a as Signature};
1
+ import{Serializable as r}from"../../bcs";import{Hex as i}from"../hex";class s extends r{toUint8Array(){return this.bcsToBytes()}toString(){const t=this.toUint8Array();return i.fromHexInput(t).toString()}}export{s as Signature};
2
2
  //# sourceMappingURL=signature.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../../src/core/crypto/signature.ts"],"sourcesContent":["import { Serializable } from \"../../bcs\";\nimport { Hex } from \"../hex\";\n\n/**\n * An abstract representation of a crypto signature,\n * associated with a specific signature scheme, e.g., Ed25519 or Secp256k1.\n *\n * This class represents the product of signing a message directly from a\n * PrivateKey and can be verified against a CryptoPublicKey.\n * @group Implementation\n * @category Serialization\n */\nexport abstract class Signature extends Serializable {\n /**\n * Get the raw signature bytes\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.bcsToBytes();\n }\n\n /**\n * Get the signature as a hex string with a 0x prefix e.g. 0x123456...\n * @returns The hex string representation of the signature.\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 signature,\n * associated to a specific authentication scheme e.g. Ed25519 or SingleKey\n *\n * This is the product of signing a message through an account,\n * and can be verified against an AccountPublicKey.\n * @group Implementation\n * @category Serialization\n */\n// export abstract class AccountSignature extends Serializable {\n// /**\n// * Get the raw signature bytes\n// */\n// abstract toUint8Array(): Uint8Array;\n//\n// /**\n// * Get the signature as a hex string with a 0x prefix e.g. 0x123456...\n// */\n// toString(): string {\n// const bytes = this.toUint8Array();\n// return Hex.fromHexInput(bytes).toString();\n// }\n// }\n"],"mappings":"AAAA,OAAS,gBAAAA,MAAoB,YAC7B,OAAS,OAAAC,MAAW,SAWb,MAAeC,UAAkBF,CAAa,CAMnD,cAA2B,CACzB,OAAO,KAAK,WAAW,CACzB,CAQA,UAAmB,CACjB,MAAMG,EAAQ,KAAK,aAAa,EAChC,OAAOF,EAAI,aAAaE,CAAK,EAAE,SAAS,CAC1C,CACF","names":["Serializable","Hex","Signature","bytes"]}
@@ -1,2 +1,2 @@
1
- import{F as a,G as b}from"../../chunk-L72TIN7T.mjs";import"../../chunk-2XQKGWHQ.mjs";import"../../chunk-UYVPNUH3.mjs";import"../../chunk-XKUIMGKU.mjs";import"../../chunk-N6YTF76Q.mjs";import"../../chunk-A5L76YP7.mjs";import"../../chunk-I7XT6L7S.mjs";import"../../chunk-5HXLZHDW.mjs";import"../../chunk-G3MHXDYA.mjs";import"../../chunk-JABP65XD.mjs";import"../../chunk-GOXRBEIJ.mjs";import"../../chunk-2PASUPUO.mjs";import"../../chunk-XJJVJOX5.mjs";import"../../chunk-NECL5FCQ.mjs";import"../../chunk-4QMXOWHP.mjs";import"../../chunk-EF4FA5I6.mjs";import"../../chunk-WCMW2L3P.mjs";import"../../chunk-WSR5EBJM.mjs";import"../../chunk-C3Q23D22.mjs";import"../../chunk-QREVMGQZ.mjs";import"../../chunk-V3MBJJTL.mjs";import"../../chunk-ZP4DWSQA.mjs";import"../../chunk-FGFLPH5K.mjs";import"../../chunk-WHSTLR3F.mjs";import"../../chunk-M3AO73ZL.mjs";import"../../chunk-6OWBKU7N.mjs";import"../../chunk-AMXZQPUQ.mjs";import"../../chunk-YOZBVVKL.mjs";import"../../chunk-SJDCGNWU.mjs";import"../../chunk-UL777LTI.mjs";import"../../chunk-7ECCT6PK.mjs";import"../../chunk-4AI7KQQ7.mjs";import"../../chunk-7EER7GWV.mjs";import"../../chunk-QP2BY4PK.mjs";import"../../chunk-HGLO5LDS.mjs";import"../../chunk-CW35YAMN.mjs";import"../../chunk-6WDVDEQZ.mjs";import"../../chunk-RCSJFTST.mjs";import"../../chunk-4RXKALLC.mjs";import"../../chunk-OLILO7VD.mjs";import"../../chunk-7DQDJ2SA.mjs";import"../../chunk-HNBVYE3N.mjs";import"../../chunk-RGKRCZ36.mjs";import"../../chunk-FZY4PMEE.mjs";import"../../chunk-Q4W3WJ2U.mjs";import"../../chunk-TOBQ5UE6.mjs";import"../../chunk-MT2RJ7H3.mjs";import"../../chunk-ORMOQWWH.mjs";import"../../chunk-FD6FGKYY.mjs";import"../../chunk-4WPQQPUF.mjs";import"../../chunk-MCFQE4GC.mjs";import"../../chunk-FLZPUYXQ.mjs";import"../../chunk-EBMEXURY.mjs";import"../../chunk-STY74NUA.mjs";import"../../chunk-IF4UU2MT.mjs";import"../../chunk-56CNRT2K.mjs";import"../../chunk-CIJA7ONS.mjs";import"../../chunk-KDMSOCZY.mjs";export{a as AnyPublicKey,b as AnySignature};
1
+ import{AnyPublicKeyVariant as t,AnySignatureVariant as r,SigningScheme as g}from"../../types";import{AuthenticationKey as K}from"../authenticationKey";import{Ed25519PublicKey as a,Ed25519Signature as l}from"./ed25519";import{AccountPublicKey as S}from"./publicKey";import{Secp256k1PublicKey as s,Secp256k1Signature as y}from"./secp256k1";import{KeylessPublicKey as o,KeylessSignature as p}from"./keyless";import{Signature as A}from"./signature";import{FederatedKeylessPublicKey as b}from"./federatedKeyless";import{Secp256r1PublicKey as f,WebAuthnSignature as h}from"./secp256r1";class u extends S{constructor(e){if(super(),this.publicKey=e,e instanceof a)this.variant=t.Ed25519;else if(e instanceof s)this.variant=t.Secp256k1;else if(e instanceof f)this.variant=t.Secp256r1;else if(e instanceof o)this.variant=t.Keyless;else if(e instanceof b)this.variant=t.FederatedKeyless;else throw new Error("Unsupported public key type")}verifySignature(e){const{message:n,signature:i}=e;if(this.publicKey instanceof o)throw new Error("Use verifySignatureAsync to verify Keyless signatures");return this.publicKey.verifySignature({message:n,signature:i.signature})}async verifySignatureAsync(e){if(!(e.signature instanceof c)){if(e.options?.throwErrorWithReason)throw new Error("Signature must be an instance of AnySignature");return!1}return await this.publicKey.verifySignatureAsync({...e,signature:e.signature.signature})}authKey(){return K.fromSchemeAndBytes({scheme:g.SingleKey,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.publicKey.serialize(e)}static deserialize(e){const n=e.deserializeUleb128AsU32();let i;switch(n){case t.Ed25519:i=a.deserialize(e);break;case t.Secp256k1:i=s.deserialize(e);break;case t.Secp256r1:i=f.deserialize(e);break;case t.Keyless:i=o.deserialize(e);break;case t.FederatedKeyless:i=b.deserialize(e);break;default:throw new Error(`Unknown variant index for AnyPublicKey: ${n}`)}return new u(i)}static isPublicKey(e){return e instanceof u}isEd25519(){return this.publicKey instanceof a}isSecp256k1PublicKey(){return this.publicKey instanceof s}static isInstance(e){return"publicKey"in e&&"variant"in e}}class c extends A{constructor(e){if(super(),this.signature=e,e instanceof l)this.variant=r.Ed25519;else if(e instanceof y)this.variant=r.Secp256k1;else if(e instanceof h)this.variant=r.WebAuthn;else if(e instanceof p)this.variant=r.Keyless;else throw new Error("Unsupported signature type")}toUint8Array(){return console.warn("[Aptos SDK] Calls to AnySignature.toUint8Array() will soon return the underlying signature bytes. Use AnySignature.bcsToBytes() instead."),this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){const n=e.deserializeUleb128AsU32();let i;switch(n){case r.Ed25519:i=l.deserialize(e);break;case r.Secp256k1:i=y.deserialize(e);break;case r.WebAuthn:i=h.deserialize(e);break;case r.Keyless:i=p.deserialize(e);break;default:throw new Error(`Unknown variant index for AnySignature: ${n}`)}return new c(i)}static isInstance(e){return"signature"in e&&typeof e.signature=="object"&&e.signature!==null&&"toUint8Array"in e.signature}}export{u as AnyPublicKey,c as AnySignature};
2
2
  //# sourceMappingURL=singleKey.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../../src/core/crypto/singleKey.ts"],"sourcesContent":["import { Deserializer, Serializer } from \"../../bcs\";\nimport {\n AnyPublicKeyVariant,\n AnySignatureVariant,\n SigningScheme as AuthenticationKeyScheme,\n HexInput,\n} from \"../../types\";\nimport { AuthenticationKey } from \"../authenticationKey\";\nimport { Ed25519PrivateKey, Ed25519PublicKey, Ed25519Signature } from \"./ed25519\";\nimport { AccountPublicKey, PublicKey } from \"./publicKey\";\nimport { Secp256k1PrivateKey, Secp256k1PublicKey, Secp256k1Signature } from \"./secp256k1\";\nimport { KeylessPublicKey, KeylessSignature } from \"./keyless\";\nimport { Signature } from \"./signature\";\nimport { FederatedKeylessPublicKey } from \"./federatedKeyless\";\nimport { AptosConfig } from \"../../api\";\nimport { Secp256r1PublicKey, WebAuthnSignature } from \"./secp256r1\";\n\nexport type PrivateKeyInput = Ed25519PrivateKey | Secp256k1PrivateKey;\n\n/**\n * Represents any public key supported by Aptos.\n *\n * Since [AIP-55](https://github.com/aptos-foundation/AIPs/pull/263) Aptos supports\n * `Legacy` and `Unified` authentication keys.\n *\n * Any unified authentication key is represented in the SDK as `AnyPublicKey`.\n * @group Implementation\n * @category Serialization\n */\nexport class AnyPublicKey extends AccountPublicKey {\n /**\n * Reference to the inner public key\n * @group Implementation\n * @category Serialization\n */\n public readonly publicKey: PublicKey;\n\n /**\n * Index of the underlying enum variant\n * @group Implementation\n * @category Serialization\n */\n public readonly variant: AnyPublicKeyVariant;\n\n // region Constructors\n\n /**\n * Creates an instance of the signature class based on the provided signature type.\n * This allows for the handling of different signature variants such as Ed25519, Secp256k1, and Keyless.\n *\n * @param publicKey - The publicKey object which determines the variant to be used.\n * @throws Error if the provided signature type is unsupported.\n * @group Implementation\n * @category Serialization\n */\n constructor(publicKey: PublicKey) {\n super();\n this.publicKey = publicKey;\n if (publicKey instanceof Ed25519PublicKey) {\n this.variant = AnyPublicKeyVariant.Ed25519;\n } else if (publicKey instanceof Secp256k1PublicKey) {\n this.variant = AnyPublicKeyVariant.Secp256k1;\n } else if (publicKey instanceof Secp256r1PublicKey) {\n this.variant = AnyPublicKeyVariant.Secp256r1;\n } else if (publicKey instanceof KeylessPublicKey) {\n this.variant = AnyPublicKeyVariant.Keyless;\n } else if (publicKey instanceof FederatedKeylessPublicKey) {\n this.variant = AnyPublicKeyVariant.FederatedKeyless;\n } else {\n throw new Error(\"Unsupported public key type\");\n }\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 confirming that the signature is valid.\n *\n * @param args - The arguments for signature verification.\n * @param args.message - The message that was signed.\n * @param args.signature - The signature to verify, which must be an instance of AnySignature.\n * @returns A boolean indicating whether the signature is valid for the given message.\n * @group Implementation\n * @category Serialization\n */\n verifySignature(args: { message: HexInput; signature: AnySignature }): boolean {\n const { message, signature } = args;\n if (this.publicKey instanceof KeylessPublicKey) {\n throw new Error(\"Use verifySignatureAsync to verify Keyless signatures\");\n }\n return this.publicKey.verifySignature({\n message,\n signature: signature.signature,\n });\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 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 AnySignature.\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: Signature;\n options?: { throwErrorWithReason?: boolean };\n }): Promise<boolean> {\n if (!(args.signature instanceof AnySignature)) {\n if (args.options?.throwErrorWithReason) {\n throw new Error(\"Signature must be an instance of AnySignature\");\n }\n return false;\n }\n return await this.publicKey.verifySignatureAsync({\n ...args,\n signature: args.signature.signature,\n });\n }\n\n /**\n * Generates an authentication key from the current instance's byte representation.\n * This function is essential for creating a unique identifier for authentication purposes.\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.SingleKey,\n input: this.toUint8Array(),\n });\n }\n\n /**\n * Get the signature in bytes (Uint8Array).\n *\n * This function is a warning that it will soon return the underlying signature bytes directly.\n * Use AnySignature.bcsToBytes() instead.\n *\n * @returns Uint8Array representation of the signature.\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.bcsToBytes();\n }\n\n // endregion\n\n // region Serializable\n\n /**\n * Serializes the current object using the provided serializer.\n * This function helps in converting the object 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.serializeU32AsUleb128(this.variant);\n this.publicKey.serialize(serializer);\n }\n\n /**\n * Deserializes an AnySignature from the provided deserializer.\n * This function helps in reconstructing the AnySignature object from its serialized form, allowing for further processing or validation.\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): AnyPublicKey {\n const variantIndex = deserializer.deserializeUleb128AsU32();\n let publicKey: PublicKey;\n switch (variantIndex) {\n case AnyPublicKeyVariant.Ed25519:\n publicKey = Ed25519PublicKey.deserialize(deserializer);\n break;\n case AnyPublicKeyVariant.Secp256k1:\n publicKey = Secp256k1PublicKey.deserialize(deserializer);\n break;\n case AnyPublicKeyVariant.Secp256r1:\n publicKey = Secp256r1PublicKey.deserialize(deserializer);\n break;\n case AnyPublicKeyVariant.Keyless:\n publicKey = KeylessPublicKey.deserialize(deserializer);\n break;\n case AnyPublicKeyVariant.FederatedKeyless:\n publicKey = FederatedKeylessPublicKey.deserialize(deserializer);\n break;\n default:\n throw new Error(`Unknown variant index for AnyPublicKey: ${variantIndex}`);\n }\n return new AnyPublicKey(publicKey);\n }\n // endregion\n\n /**\n * Determines if the provided public key is an instance of AnyPublicKey.\n *\n * @param publicKey - The public key to check.\n * @deprecated Use `instanceof AnyPublicKey` instead.\n * @group Implementation\n * @category Serialization\n */\n static isPublicKey(publicKey: AccountPublicKey): publicKey is AnyPublicKey {\n return publicKey instanceof AnyPublicKey;\n }\n\n /**\n * Determines if the current public key is an instance of Ed25519PublicKey.\n *\n * @deprecated use `publicKey instanceof Ed25519PublicKey` instead.\n * @group Implementation\n * @category Serialization\n */\n isEd25519(): boolean {\n return this.publicKey instanceof Ed25519PublicKey;\n }\n\n /**\n * Checks if the public key is an instance of Secp256k1PublicKey.\n *\n * @deprecated use `publicKey instanceof Secp256k1PublicKey` instead.\n * @group Implementation\n * @category Serialization\n */\n isSecp256k1PublicKey(): boolean {\n return this.publicKey instanceof Secp256k1PublicKey;\n }\n\n /**\n * Determines if the provided publicKey is an instance of a valid PublicKey object.\n *\n * @param publicKey - The publicKey to be checked for validity.\n * @param publicKey.publicKey - The actual publicKey object that needs to be validated.\n * @returns True if the signature is a valid instance; otherwise, false.\n * @group Implementation\n * @category Serialization\n */\n static isInstance(publicKey: PublicKey): publicKey is AnyPublicKey {\n return \"publicKey\" in publicKey && \"variant\" in publicKey;\n }\n}\n\n/**\n * Represents a signature that utilizes the SingleKey authentication scheme.\n * This class is designed to encapsulate various types of signatures, which can\n * only be generated by a `SingleKeySigner` due to the shared authentication mechanism.\n *\n * @extends Signature\n * @group Implementation\n * @category Serialization\n */\nexport class AnySignature extends Signature {\n public readonly signature: Signature;\n\n /**\n * Index of the underlying enum variant\n * @group Implementation\n * @category Serialization\n */\n private readonly variant: AnySignatureVariant;\n\n // region Constructors\n\n constructor(signature: Signature) {\n super();\n this.signature = signature;\n\n if (signature instanceof Ed25519Signature) {\n this.variant = AnySignatureVariant.Ed25519;\n } else if (signature instanceof Secp256k1Signature) {\n this.variant = AnySignatureVariant.Secp256k1;\n } else if (signature instanceof WebAuthnSignature) {\n this.variant = AnySignatureVariant.WebAuthn;\n } else if (signature instanceof KeylessSignature) {\n this.variant = AnySignatureVariant.Keyless;\n } else {\n throw new Error(\"Unsupported signature type\");\n }\n }\n\n // endregion\n\n // region AccountSignature\n\n toUint8Array(): Uint8Array {\n // TODO: keep this warning around for a bit, and eventually change this to return `this.signature.toUint8Array()`.\n // eslint-disable-next-line no-console\n console.warn(\n \"[Aptos SDK] Calls to AnySignature.toUint8Array() will soon return the underlying signature bytes. \" +\n \"Use AnySignature.bcsToBytes() instead.\",\n );\n return this.bcsToBytes();\n }\n\n // endregion\n\n // region Serializable\n\n serialize(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(this.variant);\n this.signature.serialize(serializer);\n }\n\n static deserialize(deserializer: Deserializer): AnySignature {\n const variantIndex = deserializer.deserializeUleb128AsU32();\n let signature: Signature;\n switch (variantIndex) {\n case AnySignatureVariant.Ed25519:\n signature = Ed25519Signature.deserialize(deserializer);\n break;\n case AnySignatureVariant.Secp256k1:\n signature = Secp256k1Signature.deserialize(deserializer);\n break;\n case AnySignatureVariant.WebAuthn:\n signature = WebAuthnSignature.deserialize(deserializer);\n break;\n case AnySignatureVariant.Keyless:\n signature = KeylessSignature.deserialize(deserializer);\n break;\n default:\n throw new Error(`Unknown variant index for AnySignature: ${variantIndex}`);\n }\n return new AnySignature(signature);\n }\n\n // endregion\n\n static isInstance(signature: Signature): signature is AnySignature {\n return (\n \"signature\" in signature &&\n typeof signature.signature === \"object\" &&\n signature.signature !== null &&\n \"toUint8Array\" in signature.signature\n );\n }\n}\n"],"mappings":"AACA,OACE,uBAAAA,EACA,uBAAAC,EACA,iBAAiBC,MAEZ,cACP,OAAS,qBAAAC,MAAyB,uBAClC,OAA4B,oBAAAC,EAAkB,oBAAAC,MAAwB,YACtE,OAAS,oBAAAC,MAAmC,cAC5C,OAA8B,sBAAAC,EAAoB,sBAAAC,MAA0B,cAC5E,OAAS,oBAAAC,EAAkB,oBAAAC,MAAwB,YACnD,OAAS,aAAAC,MAAiB,cAC1B,OAAS,6BAAAC,MAAiC,qBAE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AY,EACrD,MACF,KAAKrB,EAAoB,UACvBkB,EAAYX,EAAmB,YAAYc,CAAY,EACvD,MACF,KAAKrB,EAAoB,SACvBkB,EAAYL,EAAkB,YAAYQ,CAAY,EACtD,MACF,KAAKrB,EAAoB,QACvBkB,EAAYT,EAAiB,YAAYY,CAAY,EACrD,MACF,QACE,MAAM,IAAI,MAAM,2CAA2CC,CAAY,EAAE,CAC7E,CACA,OAAO,IAAIH,EAAaD,CAAS,CACnC,CAIA,OAAO,WAAWA,EAAiD,CACjE,MACE,cAAeA,GACf,OAAOA,EAAU,WAAc,UAC/BA,EAAU,YAAc,MACxB,iBAAkBA,EAAU,SAEhC,CACF","names":["AnyPublicKeyVariant","AnySignatureVariant","AuthenticationKeyScheme","AuthenticationKey","Ed25519PublicKey","Ed25519Signature","AccountPublicKey","Secp256k1PublicKey","Secp256k1Signature","KeylessPublicKey","KeylessSignature","Signature","FederatedKeylessPublicKey","Secp256r1PublicKey","WebAuthnSignature","AnyPublicKey","publicKey","args","message","signature","AnySignature","serializer","deserializer","variantIndex"]}
@@ -1,2 +1 @@
1
- import"../../chunk-5HXLZHDW.mjs";
2
1
  //# sourceMappingURL=types.mjs.map
@@ -1,2 +1,2 @@
1
- import{M as a,N as b,O as c}from"../../chunk-L72TIN7T.mjs";import"../../chunk-2XQKGWHQ.mjs";import"../../chunk-UYVPNUH3.mjs";import"../../chunk-XKUIMGKU.mjs";import"../../chunk-N6YTF76Q.mjs";import"../../chunk-A5L76YP7.mjs";import"../../chunk-I7XT6L7S.mjs";import"../../chunk-5HXLZHDW.mjs";import"../../chunk-G3MHXDYA.mjs";import"../../chunk-JABP65XD.mjs";import"../../chunk-GOXRBEIJ.mjs";import"../../chunk-2PASUPUO.mjs";import"../../chunk-XJJVJOX5.mjs";import"../../chunk-NECL5FCQ.mjs";import"../../chunk-4QMXOWHP.mjs";import"../../chunk-EF4FA5I6.mjs";import"../../chunk-WCMW2L3P.mjs";import"../../chunk-WSR5EBJM.mjs";import"../../chunk-C3Q23D22.mjs";import"../../chunk-QREVMGQZ.mjs";import"../../chunk-V3MBJJTL.mjs";import"../../chunk-ZP4DWSQA.mjs";import"../../chunk-FGFLPH5K.mjs";import"../../chunk-WHSTLR3F.mjs";import"../../chunk-M3AO73ZL.mjs";import"../../chunk-6OWBKU7N.mjs";import"../../chunk-AMXZQPUQ.mjs";import"../../chunk-YOZBVVKL.mjs";import"../../chunk-SJDCGNWU.mjs";import"../../chunk-UL777LTI.mjs";import"../../chunk-7ECCT6PK.mjs";import"../../chunk-4AI7KQQ7.mjs";import"../../chunk-7EER7GWV.mjs";import"../../chunk-QP2BY4PK.mjs";import"../../chunk-HGLO5LDS.mjs";import"../../chunk-CW35YAMN.mjs";import"../../chunk-6WDVDEQZ.mjs";import"../../chunk-RCSJFTST.mjs";import"../../chunk-4RXKALLC.mjs";import"../../chunk-OLILO7VD.mjs";import"../../chunk-7DQDJ2SA.mjs";import"../../chunk-HNBVYE3N.mjs";import"../../chunk-RGKRCZ36.mjs";import"../../chunk-FZY4PMEE.mjs";import"../../chunk-Q4W3WJ2U.mjs";import"../../chunk-TOBQ5UE6.mjs";import"../../chunk-MT2RJ7H3.mjs";import"../../chunk-ORMOQWWH.mjs";import"../../chunk-FD6FGKYY.mjs";import"../../chunk-4WPQQPUF.mjs";import"../../chunk-MCFQE4GC.mjs";import"../../chunk-FLZPUYXQ.mjs";import"../../chunk-EBMEXURY.mjs";import"../../chunk-STY74NUA.mjs";import"../../chunk-IF4UU2MT.mjs";import"../../chunk-56CNRT2K.mjs";import"../../chunk-CIJA7ONS.mjs";import"../../chunk-KDMSOCZY.mjs";export{b as accountPublicKeyToBaseAccountPublicKey,c as accountPublicKeyToSigningScheme,a as convertSigningMessage};
1
+ import{SigningScheme as t}from"../../types";import{Hex as u}from"../hex";import{Ed25519PublicKey as i}from"./ed25519";import{FederatedKeylessPublicKey as f}from"./federatedKeyless";import{KeylessPublicKey as s}from"./keyless";import{MultiEd25519PublicKey as r}from"./multiEd25519";import{MultiKey as c}from"./multiKey";import{AnyPublicKey as o}from"./singleKey";const E=n=>typeof n=="string"?u.isValid(n).valid?n:new TextEncoder().encode(n):n,l=n=>{if(n instanceof i||n instanceof o||n instanceof r||n instanceof c)return n;if(n instanceof s||n instanceof f)return new o(n);throw new Error(`Unknown account public key: ${n}`)},h=n=>{const e=l(n);if(e instanceof i)return t.Ed25519;if(e instanceof o)return t.SingleKey;if(e instanceof r)return t.MultiEd25519;if(e instanceof c)return t.MultiKey;throw new Error(`Unknown signing scheme: ${e}`)};export{l as accountPublicKeyToBaseAccountPublicKey,h as accountPublicKeyToSigningScheme,E as convertSigningMessage};
2
2
  //# sourceMappingURL=utils.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../../src/core/crypto/utils.ts"],"sourcesContent":["import { HexInput, SigningScheme } from \"../../types\";\nimport { Hex } from \"../hex\";\nimport { Ed25519PublicKey } from \"./ed25519\";\nimport { FederatedKeylessPublicKey } from \"./federatedKeyless\";\nimport { KeylessPublicKey } from \"./keyless\";\nimport { MultiEd25519PublicKey } from \"./multiEd25519\";\nimport { MultiKey } from \"./multiKey\";\nimport { AccountPublicKey } from \"./publicKey\";\nimport { AnyPublicKey } from \"./singleKey\";\nimport { BaseAccountPublicKey } from \"./types\";\n\n/**\n * Helper function to convert a message to sign or to verify to a valid message input\n *\n * @param message a message as a string or Uint8Array\n *\n * @returns a valid HexInput - string or Uint8Array\n * @group Implementation\n * @category Serialization\n */\nexport const convertSigningMessage = (message: HexInput): HexInput => {\n // if message is of type string, verify it is a valid Hex string\n if (typeof message === \"string\") {\n const isValid = Hex.isValid(message);\n // If message is not a valid Hex string, convert it\n if (!isValid.valid) {\n return new TextEncoder().encode(message);\n }\n // If message is a valid Hex string, return it\n return message;\n }\n // message is a Uint8Array\n return message;\n};\n\nexport const accountPublicKeyToBaseAccountPublicKey = (publicKey: AccountPublicKey): BaseAccountPublicKey => {\n if (\n publicKey instanceof Ed25519PublicKey ||\n publicKey instanceof AnyPublicKey ||\n publicKey instanceof MultiEd25519PublicKey ||\n publicKey instanceof MultiKey\n ) {\n return publicKey;\n }\n if (publicKey instanceof KeylessPublicKey || publicKey instanceof FederatedKeylessPublicKey) {\n return new AnyPublicKey(publicKey);\n }\n throw new Error(`Unknown account public key: ${publicKey}`);\n};\n\nexport const accountPublicKeyToSigningScheme = (publicKey: AccountPublicKey): SigningScheme => {\n const baseAccountPublicKey = accountPublicKeyToBaseAccountPublicKey(publicKey);\n if (baseAccountPublicKey instanceof Ed25519PublicKey) {\n return SigningScheme.Ed25519;\n } else if (baseAccountPublicKey instanceof AnyPublicKey) {\n return SigningScheme.SingleKey;\n } else if (baseAccountPublicKey instanceof MultiEd25519PublicKey) {\n return SigningScheme.MultiEd25519;\n } else if (baseAccountPublicKey instanceof MultiKey) {\n return SigningScheme.MultiKey;\n }\n throw new Error(`Unknown signing scheme: ${baseAccountPublicKey}`);\n};\n"],"mappings":"AAAA,OAAmB,iBAAAA,MAAqB,cACxC,OAAS,OAAAC,MAAW,SACpB,OAAS,oBAAAC,MAAwB,YACjC,OAAS,6BAAAC,MAAiC,qBAC1C,OAAS,oBAAAC,MAAwB,YACjC,OAAS,yBAAAC,MAA6B,iBACtC,OAAS,YAAAC,MAAgB,aAEzB,OAAS,gBAAAC,MAAoB,cAYtB,MAAMC,EAAyBC,GAEhC,OAAOA,GAAY,SACLR,EAAI,QAAQQ,CAAO,EAEtB,MAINA,EAHE,IAAI,YAAY,EAAE,OAAOA,CAAO,EAMpCA,EAGIC,EAA0CC,GAAsD,CAC3G,GACEA,aAAqBT,GACrBS,aAAqBJ,GACrBI,aAAqBN,GACrBM,aAAqBL,EAErB,OAAOK,EAET,GAAIA,aAAqBP,GAAoBO,aAAqBR,EAChE,OAAO,IAAII,EAAaI,CAAS,EAEnC,MAAM,IAAI,MAAM,+BAA+BA,CAAS,EAAE,CAC5D,EAEaC,EAAmCD,GAA+C,CAC7F,MAAME,EAAuBH,EAAuCC,CAAS,EAC7E,GAAIE,aAAgCX,EAClC,OAAOF,EAAc,QAChB,GAAIa,aAAgCN,EACzC,OAAOP,EAAc,UAChB,GAAIa,aAAgCR,EACzC,OAAOL,EAAc,aAChB,GAAIa,aAAgCP,EACzC,OAAON,EAAc,SAEvB,MAAM,IAAI,MAAM,2BAA2Ba,CAAoB,EAAE,CACnE","names":["SigningScheme","Hex","Ed25519PublicKey","FederatedKeylessPublicKey","KeylessPublicKey","MultiEd25519PublicKey","MultiKey","AnyPublicKey","convertSigningMessage","message","accountPublicKeyToBaseAccountPublicKey","publicKey","accountPublicKeyToSigningScheme","baseAccountPublicKey"]}
@@ -1,2 +1,2 @@
1
- import{a,b,c}from"../chunk-STY74NUA.mjs";import"../chunk-IF4UU2MT.mjs";import"../chunk-KDMSOCZY.mjs";export{b as Hex,a as HexInvalidReason,c as hexToAsciiString};
1
+ import{bytesToHex as o,hexToBytes as s}from"@noble/hashes/utils";import{ParsingError as i}from"./common";var u=(e=>(e.TOO_SHORT="too_short",e.INVALID_LENGTH="invalid_length",e.INVALID_HEX_CHARS="invalid_hex_chars",e))(u||{});class n{constructor(t){this.data=t}toUint8Array(){return this.data}toStringWithoutPrefix(){return o(this.data)}toString(){return`0x${this.toStringWithoutPrefix()}`}static fromHexString(t){let r=t;if(r.startsWith("0x")&&(r=r.slice(2)),r.length===0)throw new i("Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.","too_short");if(r.length%2!==0)throw new i("Hex string must be an even number of hex characters.","invalid_length");try{return new n(s(r))}catch(e){throw new i(`Hex string contains invalid hex characters: ${e?.message}`,"invalid_hex_chars")}}static fromHexInput(t){return t instanceof Uint8Array?new n(t):n.fromHexString(t)}static hexInputToUint8Array(t){return t instanceof Uint8Array?t:n.fromHexString(t).toUint8Array()}static hexInputToString(t){return n.fromHexInput(t).toString()}static hexInputToStringWithoutPrefix(t){return n.fromHexInput(t).toStringWithoutPrefix()}static isValid(t){try{return n.fromHexString(t),{valid:!0}}catch(r){return{valid:!1,invalidReason:r?.invalidReason,invalidReasonMessage:r?.message}}}equals(t){return this.data.length!==t.data.length?!1:this.data.every((r,e)=>r===t.data[e])}}const f=a=>new TextDecoder().decode(n.fromHexInput(a).toUint8Array());export{n as Hex,u as HexInvalidReason,f as hexToAsciiString};
2
2
  //# sourceMappingURL=hex.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../src/core/hex.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bytesToHex, hexToBytes } from \"@noble/hashes/utils\";\nimport { ParsingError, ParsingResult } from \"./common\";\nimport { HexInput } from \"../types\";\n\n/**\n * Provides reasons for parsing failures related to hexadecimal values.\n * @group Implementation\n * @category Serialization\n */\nexport enum HexInvalidReason {\n TOO_SHORT = \"too_short\",\n INVALID_LENGTH = \"invalid_length\",\n INVALID_HEX_CHARS = \"invalid_hex_chars\",\n}\n\n/**\n * NOTE: Do not use this class when working with account addresses; use AccountAddress instead.\n * When accepting hex data as input to a function, prefer to accept HexInput and\n *\n * A helper class for working with hex data. Hex data, when represented as a string,\n * generally looks like this, for example: 0xaabbcc, 45cd32, etc.\n *\n * then use the static helper methods of this class to convert it into the desired\n * format. This enables the greatest flexibility for the developer.\n *\n * Example usage:\n * ```typescript\n * getTransactionByHash(txnHash: HexInput): Promise<Transaction> {\n * const txnHashString = Hex.fromHexInput(txnHash).toString();\n * return await getTransactionByHashInner(txnHashString);\n * }\n * ```\n * This call to `Hex.fromHexInput().toString()` converts the HexInput to a hex string\n * with a leading 0x prefix, regardless of what the input format was.\n *\n * Other ways to chain the functions together:\n * - `Hex.fromHexString({ hexInput: \"0x1f\" }).toUint8Array()`\n * - `new Hex([1, 3]).toStringWithoutPrefix()`\n * @group Implementation\n * @category Serialization\n */\nexport class Hex {\n private readonly data: Uint8Array;\n\n /**\n * Create a new Hex instance from a Uint8Array.\n *\n * @param data - The Uint8Array containing the data to initialize the Hex instance.\n * @group Implementation\n * @category Serialization\n */\n constructor(data: Uint8Array) {\n this.data = data;\n }\n\n // ===\n // Methods for representing an instance of Hex as other types.\n // ===\n\n /**\n * Get the inner hex data as a Uint8Array. The inner data is already a Uint8Array, so no conversion takes place.\n *\n * @returns Hex data as Uint8Array\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.data;\n }\n\n /**\n * Get the hex data as a string without the 0x prefix.\n *\n * @returns Hex string without 0x prefix\n * @group Implementation\n * @category Serialization\n */\n toStringWithoutPrefix(): string {\n return bytesToHex(this.data);\n }\n\n /**\n * Get the hex data as a string with the 0x prefix.\n *\n * @returns Hex string with 0x prefix\n * @group Implementation\n * @category Serialization\n */\n toString(): string {\n return `0x${this.toStringWithoutPrefix()}`;\n }\n\n // ===\n // Methods for creating an instance of Hex from other types.\n // ===\n\n /**\n * Converts a hex string into a Hex instance, allowing for both prefixed and non-prefixed formats.\n *\n * @param str - A hex string, with or without the 0x prefix.\n *\n * @throws ParsingError - If the hex string is too short, has an odd number of characters, or contains invalid hex characters.\n *\n * @returns Hex - The resulting Hex instance created from the provided string.\n * @group Implementation\n * @category Serialization\n */\n static fromHexString(str: string): Hex {\n let input = str;\n\n if (input.startsWith(\"0x\")) {\n input = input.slice(2);\n }\n\n if (input.length === 0) {\n throw new ParsingError(\n \"Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.\",\n HexInvalidReason.TOO_SHORT,\n );\n }\n\n if (input.length % 2 !== 0) {\n throw new ParsingError(\"Hex string must be an even number of hex characters.\", HexInvalidReason.INVALID_LENGTH);\n }\n\n try {\n return new Hex(hexToBytes(input));\n } catch (error: any) {\n throw new ParsingError(\n `Hex string contains invalid hex characters: ${error?.message}`,\n HexInvalidReason.INVALID_HEX_CHARS,\n );\n }\n }\n\n /**\n * Converts an instance of HexInput, which can be a string or a Uint8Array, into a Hex instance.\n * This function is useful for transforming hexadecimal representations into a structured Hex object for further manipulation.\n *\n * @param hexInput - A HexInput which can be a string or Uint8Array.\n * @returns A Hex instance created from the provided hexInput.\n * @group Implementation\n * @category Serialization\n */\n static fromHexInput(hexInput: HexInput): Hex {\n if (hexInput instanceof Uint8Array) return new Hex(hexInput);\n return Hex.fromHexString(hexInput);\n }\n\n /**\n * Converts an instance of HexInput, which can be a string or a Uint8Array, into a Uint8Array.\n *\n * @param hexInput - A HexInput which can be a string or Uint8Array.\n * @returns A Uint8Array created from the provided hexInput.\n */\n static hexInputToUint8Array(hexInput: HexInput): Uint8Array {\n if (hexInput instanceof Uint8Array) return hexInput;\n return Hex.fromHexString(hexInput).toUint8Array();\n }\n\n /**\n * Converts a HexInput (string or Uint8Array) to a hex string with '0x' prefix.\n *\n * @param hexInput - The input to convert, either a hex string (with/without '0x' prefix) or Uint8Array\n * @returns A hex string with '0x' prefix (e.g., \"0x1234\")\n *\n * @example\n * ```typescript\n * Hex.hexInputToString(\"1234\") // returns \"0x1234\"\n * Hex.hexInputToString(\"0x1234\") // returns \"0x1234\"\n * Hex.hexInputToString(new Uint8Array([0x12, 0x34])) // returns \"0x1234\"\n * ```\n */\n static hexInputToString(hexInput: HexInput): string {\n return Hex.fromHexInput(hexInput).toString();\n }\n\n /**\n * Converts a HexInput (string or Uint8Array) to a hex string without '0x' prefix.\n *\n * @param hexInput - The input to convert, either a hex string (with/without '0x' prefix) or Uint8Array\n * @returns A hex string without '0x' prefix (e.g., \"1234\")\n *\n * @example\n * ```typescript\n * Hex.hexInputToStringWithoutPrefix(\"1234\") // returns \"1234\"\n * Hex.hexInputToStringWithoutPrefix(\"0x1234\") // returns \"1234\"\n * Hex.hexInputToStringWithoutPrefix(new Uint8Array([0x12, 0x34])) // returns \"1234\"\n * ```\n */\n static hexInputToStringWithoutPrefix(hexInput: HexInput): string {\n return Hex.fromHexInput(hexInput).toStringWithoutPrefix();\n }\n\n // ===\n // Methods for checking validity.\n // ===\n\n /**\n * Check if the provided string is a valid hexadecimal representation.\n *\n * @param str - A hex string representing byte data.\n *\n * @returns An object containing:\n * - valid: A boolean indicating whether the string is valid.\n * - invalidReason: The reason for invalidity if the string is not valid.\n * - invalidReasonMessage: A message explaining why the string is invalid.\n * @group Implementation\n * @category Serialization\n */\n static isValid(str: string): ParsingResult<HexInvalidReason> {\n try {\n Hex.fromHexString(str);\n return { valid: true };\n } catch (error: any) {\n return {\n valid: false,\n invalidReason: error?.invalidReason,\n invalidReasonMessage: error?.message,\n };\n }\n }\n\n /**\n * Determine if two Hex instances are equal by comparing their underlying byte data.\n *\n * @param other The Hex instance to compare to.\n * @returns true if the Hex instances are equal, false if not.\n * @group Implementation\n * @category Serialization\n */\n equals(other: Hex): boolean {\n if (this.data.length !== other.data.length) return false;\n return this.data.every((value, index) => value === other.data[index]);\n }\n}\n\nexport const hexToAsciiString = (hex: string) => new TextDecoder().decode(Hex.fromHexInput(hex).toUint8Array());\n"],"mappings":"AAGA,OAAS,cAAAA,EAAY,cAAAC,MAAkB,sBACvC,OAAS,gBAAAC,MAAmC,WAQrC,IAAKC,OACVA,EAAA,UAAY,YACZA,EAAA,eAAiB,iBACjBA,EAAA,kBAAoB,oBAHVA,OAAA,IAgCL,MAAMC,CAAI,CAUf,YAAYC,EAAkB,CAC5B,KAAK,KAAOA,CACd,CAaA,cAA2B,CACzB,OAAO,KAAK,IACd,CASA,uBAAgC,CAC9B,OAAOL,EAAW,KAAK,IAAI,CAC7B,CASA,UAAmB,CACjB,MAAO,KAAK,KAAK,sBAAsB,CAAC,EAC1C,CAiBA,OAAO,cAAcM,EAAkB,CACrC,IAAIC,EAAQD,EAMZ,GAJIC,EAAM,WAAW,IAAI,IACvBA,EAAQA,EAAM,MAAM,CAAC,GAGnBA,EAAM,SAAW,EACnB,MAAM,IAAIL,EACR,4FACA,WACF,EAGF,GAAIK,EAAM,OAAS,IAAM,EACvB,MAAM,IAAIL,EAAa,uDAAwD,gBAA+B,EAGhH,GAAI,CACF,OAAO,IAAIE,EAAIH,EAAWM,CAAK,CAAC,CAClC,OAASC,EAAY,CACnB,MAAM,IAAIN,EACR,+CAA+CM,GAAO,OAAO,GAC7D,mBACF,CACF,CACF,CAWA,OAAO,aAAaC,EAAyB,CAC3C,OAAIA,aAAoB,WAAmB,IAAIL,EAAIK,CAAQ,EACpDL,EAAI,cAAcK,CAAQ,CACnC,CAQA,OAAO,qBAAqBA,EAAgC,CAC1D,OAAIA,aAAoB,WAAmBA,EACpCL,EAAI,cAAcK,CAAQ,EAAE,aAAa,CAClD,CAeA,OAAO,iBAAiBA,EAA4B,CAClD,OAAOL,EAAI,aAAaK,CAAQ,EAAE,SAAS,CAC7C,CAeA,OAAO,8BAA8BA,EAA4B,CAC/D,OAAOL,EAAI,aAAaK,CAAQ,EAAE,sBAAsB,CAC1D,CAkBA,OAAO,QAAQH,EAA8C,CAC3D,GAAI,CACF,OAAAF,EAAI,cAAcE,CAAG,EACd,CAAE,MAAO,EAAK,CACvB,OAASE,EAAY,CACnB,MAAO,CACL,MAAO,GACP,cAAeA,GAAO,cACtB,qBAAsBA,GAAO,OAC/B,CACF,CACF,CAUA,OAAOE,EAAqB,CAC1B,OAAI,KAAK,KAAK,SAAWA,EAAM,KAAK,OAAe,GAC5C,KAAK,KAAK,MAAM,CAACC,EAAOC,IAAUD,IAAUD,EAAM,KAAKE,CAAK,CAAC,CACtE,CACF,CAEO,MAAMC,EAAoBC,GAAgB,IAAI,YAAY,EAAE,OAAOV,EAAI,aAAaU,CAAG,EAAE,aAAa,CAAC","names":["bytesToHex","hexToBytes","ParsingError","HexInvalidReason","Hex","data","str","input","error","hexInput","other","value","index","hexToAsciiString","hex"]}