@aptos-labs/ts-sdk 2.0.0 → 2.0.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 (481) hide show
  1. package/dist/common/{accountAddress-D0xKX-UM.d.ts → accountAddress-AL8HRxQC.d.ts} +8 -0
  2. package/dist/common/chunk-ZMDE3DNL.js.map +1 -1
  3. package/dist/common/cli/index.d.ts +1 -1
  4. package/dist/common/cli/index.js.map +1 -1
  5. package/dist/common/index.d.ts +22 -3
  6. package/dist/common/index.js +30 -30
  7. package/dist/common/index.js.map +1 -1
  8. package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
  9. package/dist/esm/account/AbstractedAccount.mjs +1 -1
  10. package/dist/esm/account/Account.mjs +1 -1
  11. package/dist/esm/account/AccountUtils.mjs +1 -1
  12. package/dist/esm/account/DerivableAbstractedAccount.mjs +1 -1
  13. package/dist/esm/account/Ed25519Account.mjs +1 -1
  14. package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
  15. package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
  16. package/dist/esm/account/KeylessAccount.mjs +1 -1
  17. package/dist/esm/account/MultiEd25519Account.mjs +1 -1
  18. package/dist/esm/account/MultiKeyAccount.mjs +1 -1
  19. package/dist/esm/account/SingleKeyAccount.mjs +1 -1
  20. package/dist/esm/account/index.mjs +1 -1
  21. package/dist/esm/account/utils.mjs +1 -1
  22. package/dist/esm/api/account/abstraction.mjs +1 -1
  23. package/dist/esm/api/account.mjs +1 -1
  24. package/dist/esm/api/ans.mjs +1 -1
  25. package/dist/esm/api/aptos.mjs +1 -1
  26. package/dist/esm/api/coin.d.mts +3 -3
  27. package/dist/esm/api/coin.mjs +1 -1
  28. package/dist/esm/api/digitalAsset.d.mts +1 -1
  29. package/dist/esm/api/digitalAsset.mjs +1 -1
  30. package/dist/esm/api/event.mjs +1 -1
  31. package/dist/esm/api/faucet.mjs +1 -1
  32. package/dist/esm/api/fungibleAsset.mjs +1 -1
  33. package/dist/esm/api/general.mjs +1 -1
  34. package/dist/esm/api/index.mjs +1 -1
  35. package/dist/esm/api/keyless.mjs +1 -1
  36. package/dist/esm/api/object.mjs +1 -1
  37. package/dist/esm/api/staking.mjs +1 -1
  38. package/dist/esm/api/table.mjs +1 -1
  39. package/dist/esm/api/transaction.mjs +1 -1
  40. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  41. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  42. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  43. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  44. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  45. package/dist/esm/api/utils.mjs +1 -1
  46. package/dist/esm/bcs/deserializer.d.mts +8 -0
  47. package/dist/esm/bcs/deserializer.mjs +1 -1
  48. package/dist/esm/bcs/index.mjs +1 -1
  49. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  50. package/dist/esm/{chunk-34R7FSQF.mjs → chunk-57J5YBMT.mjs} +2 -2
  51. package/dist/esm/{chunk-USB3LA6B.mjs → chunk-AMAPBD4D.mjs} +2 -2
  52. package/dist/esm/chunk-BK56GLTP.mjs +4 -0
  53. package/dist/esm/chunk-BK56GLTP.mjs.map +1 -0
  54. package/dist/esm/{chunk-G7WH6GQP.mjs → chunk-CFQFFP6N.mjs} +2 -2
  55. package/dist/esm/{chunk-4JT5AESZ.mjs → chunk-CO67Y6YE.mjs} +2 -2
  56. package/dist/esm/chunk-CW35YAMN.mjs +2 -0
  57. package/dist/esm/{chunk-HW7TSJI2.mjs → chunk-CZYH3G7E.mjs} +2 -2
  58. package/dist/esm/chunk-FLZPUYXQ.mjs +2 -0
  59. package/dist/esm/chunk-FLZPUYXQ.mjs.map +1 -0
  60. package/dist/esm/{chunk-ZNLOQO4Q.mjs → chunk-GBNAG7KK.mjs} +2 -2
  61. package/dist/esm/{chunk-6UZHMEK3.mjs → chunk-HETYL3WN.mjs} +2 -2
  62. package/dist/esm/{chunk-SE2VS7WM.mjs → chunk-KRBZ54CY.mjs} +2 -2
  63. package/dist/esm/{chunk-G6HENV5D.mjs → chunk-Q4W3WJ2U.mjs} +2 -2
  64. package/dist/esm/{chunk-EF4FA5I6.mjs → chunk-RQX6JOEN.mjs} +2 -2
  65. package/dist/esm/{chunk-MA4QUN6P.mjs → chunk-U7HD6PQV.mjs} +2 -2
  66. package/dist/esm/{chunk-TDGLYA35.mjs → chunk-UOP7GBXB.mjs} +2 -2
  67. package/dist/esm/{chunk-K43K3YG7.mjs → chunk-UQWF24SS.mjs} +2 -2
  68. package/dist/esm/{chunk-2UBI3AZJ.mjs → chunk-V2QSMVJ5.mjs} +2 -2
  69. package/dist/esm/{chunk-TLFZOAAB.mjs → chunk-V74WPKSY.mjs} +2 -2
  70. package/dist/esm/chunk-VEGW6HP5.mjs +2 -0
  71. package/dist/esm/{chunk-HLF3U7IS.mjs.map → chunk-VEGW6HP5.mjs.map} +1 -1
  72. package/dist/esm/client/core.mjs +1 -1
  73. package/dist/esm/client/get.mjs +1 -1
  74. package/dist/esm/client/index.mjs +1 -1
  75. package/dist/esm/client/post.mjs +1 -1
  76. package/dist/esm/core/crypto/abstraction.mjs +1 -1
  77. package/dist/esm/core/crypto/deserializationUtils.d.mts +36 -0
  78. package/dist/esm/core/crypto/deserializationUtils.mjs +2 -0
  79. package/dist/esm/core/crypto/deserializationUtils.mjs.map +1 -0
  80. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  81. package/dist/esm/core/crypto/ephemeral.mjs +1 -1
  82. package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
  83. package/dist/esm/core/crypto/index.d.mts +1 -0
  84. package/dist/esm/core/crypto/index.mjs +1 -1
  85. package/dist/esm/core/crypto/keyless.mjs +1 -1
  86. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  87. package/dist/esm/core/crypto/multiKey.mjs +1 -1
  88. package/dist/esm/core/crypto/proof.mjs +1 -1
  89. package/dist/esm/core/crypto/publicKey.mjs +1 -1
  90. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  91. package/dist/esm/core/crypto/signature.mjs +1 -1
  92. package/dist/esm/core/crypto/singleKey.mjs +1 -1
  93. package/dist/esm/core/index.d.mts +1 -0
  94. package/dist/esm/core/index.mjs +1 -1
  95. package/dist/esm/errors/index.mjs +1 -1
  96. package/dist/esm/index.d.mts +1 -0
  97. package/dist/esm/index.mjs +1 -1
  98. package/dist/esm/internal/abstraction.mjs +1 -1
  99. package/dist/esm/internal/account.mjs +1 -1
  100. package/dist/esm/internal/ans.mjs +1 -1
  101. package/dist/esm/internal/coin.mjs +1 -1
  102. package/dist/esm/internal/digitalAsset.mjs +1 -1
  103. package/dist/esm/internal/event.mjs +1 -1
  104. package/dist/esm/internal/faucet.mjs +1 -1
  105. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  106. package/dist/esm/internal/general.mjs +1 -1
  107. package/dist/esm/internal/keyless.mjs +1 -1
  108. package/dist/esm/internal/object.mjs +1 -1
  109. package/dist/esm/internal/staking.mjs +1 -1
  110. package/dist/esm/internal/table.mjs +1 -1
  111. package/dist/esm/internal/transaction.mjs +1 -1
  112. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  113. package/dist/esm/internal/utils/index.mjs +1 -1
  114. package/dist/esm/internal/utils/utils.mjs +1 -1
  115. package/dist/esm/internal/view.mjs +1 -1
  116. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  117. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  118. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  119. package/dist/esm/transactions/index.mjs +1 -1
  120. package/dist/esm/transactions/instances/index.mjs +1 -1
  121. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  122. package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
  123. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  124. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  125. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  126. package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
  127. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  128. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  129. package/dist/esm/transactions/management/index.mjs +1 -1
  130. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  131. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  132. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  133. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  134. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
  135. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  136. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  137. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  138. package/dist/esm/utils/index.mjs +1 -1
  139. package/dist/esm/utils/normalizeBundle.mjs +1 -1
  140. package/dist/esm/version.d.mts +1 -1
  141. package/dist/esm/version.mjs +1 -1
  142. package/package.json +3 -3
  143. package/src/bcs/deserializer.ts +13 -0
  144. package/src/core/crypto/deserializationUtils.ts +106 -0
  145. package/src/core/crypto/index.ts +1 -0
  146. package/src/internal/move/jwks/build/jwk/BuildInfo.yaml +56 -0
  147. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/account.mv +0 -0
  148. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/aggregator.mv +0 -0
  149. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/aggregator_factory.mv +0 -0
  150. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/aggregator_v2.mv +0 -0
  151. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/aptos_account.mv +0 -0
  152. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/aptos_coin.mv +0 -0
  153. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/aptos_governance.mv +0 -0
  154. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/block.mv +0 -0
  155. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/chain_id.mv +0 -0
  156. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/chain_status.mv +0 -0
  157. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/code.mv +0 -0
  158. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/coin.mv +0 -0
  159. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/config_buffer.mv +0 -0
  160. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/consensus_config.mv +0 -0
  161. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/create_signer.mv +0 -0
  162. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/delegation_pool.mv +0 -0
  163. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/dispatchable_fungible_asset.mv +0 -0
  164. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/dkg.mv +0 -0
  165. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/event.mv +0 -0
  166. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/execution_config.mv +0 -0
  167. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/function_info.mv +0 -0
  168. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/fungible_asset.mv +0 -0
  169. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/gas_schedule.mv +0 -0
  170. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/genesis.mv +0 -0
  171. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/governance_proposal.mv +0 -0
  172. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/guid.mv +0 -0
  173. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/jwk_consensus_config.mv +0 -0
  174. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/jwks.mv +0 -0
  175. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/keyless_account.mv +0 -0
  176. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/managed_coin.mv +0 -0
  177. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/multisig_account.mv +0 -0
  178. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/object.mv +0 -0
  179. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/object_code_deployment.mv +0 -0
  180. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/optional_aggregator.mv +0 -0
  181. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/primary_fungible_store.mv +0 -0
  182. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/randomness.mv +0 -0
  183. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/randomness_api_v0_config.mv +0 -0
  184. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/randomness_config.mv +0 -0
  185. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/randomness_config_seqnum.mv +0 -0
  186. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/reconfiguration.mv +0 -0
  187. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/reconfiguration_state.mv +0 -0
  188. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/reconfiguration_with_dkg.mv +0 -0
  189. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/resource_account.mv +0 -0
  190. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/stake.mv +0 -0
  191. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/staking_config.mv +0 -0
  192. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/staking_contract.mv +0 -0
  193. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/staking_proxy.mv +0 -0
  194. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/state_storage.mv +0 -0
  195. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/storage_gas.mv +0 -0
  196. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/system_addresses.mv +0 -0
  197. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/timestamp.mv +0 -0
  198. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/transaction_context.mv +0 -0
  199. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/transaction_fee.mv +0 -0
  200. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/transaction_validation.mv +0 -0
  201. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/util.mv +0 -0
  202. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/validator_consensus_info.mv +0 -0
  203. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/version.mv +0 -0
  204. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/vesting.mv +0 -0
  205. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosFramework/voting.mv +0 -0
  206. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/any.mv +0 -0
  207. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/aptos_hash.mv +0 -0
  208. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/big_vector.mv +0 -0
  209. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/bls12381.mv +0 -0
  210. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/bls12381_algebra.mv +0 -0
  211. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/bn254_algebra.mv +0 -0
  212. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/capability.mv +0 -0
  213. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/comparator.mv +0 -0
  214. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/copyable_any.mv +0 -0
  215. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/crypto_algebra.mv +0 -0
  216. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/debug.mv +0 -0
  217. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/ed25519.mv +0 -0
  218. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/fixed_point64.mv +0 -0
  219. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/from_bcs.mv +0 -0
  220. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/math128.mv +0 -0
  221. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/math64.mv +0 -0
  222. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/math_fixed.mv +0 -0
  223. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/math_fixed64.mv +0 -0
  224. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/multi_ed25519.mv +0 -0
  225. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/pool_u64.mv +0 -0
  226. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/pool_u64_unbound.mv +0 -0
  227. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/ristretto255.mv +0 -0
  228. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/ristretto255_bulletproofs.mv +0 -0
  229. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/ristretto255_elgamal.mv +0 -0
  230. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/ristretto255_pedersen.mv +0 -0
  231. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/secp256k1.mv +0 -0
  232. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/simple_map.mv +0 -0
  233. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/smart_table.mv +0 -0
  234. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/smart_vector.mv +0 -0
  235. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/string_utils.mv +0 -0
  236. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/table.mv +0 -0
  237. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/table_with_length.mv +0 -0
  238. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/AptosStdlib/type_info.mv +0 -0
  239. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/MoveStdlib/acl.mv +0 -0
  240. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/MoveStdlib/bcs.mv +0 -0
  241. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/MoveStdlib/bit_vector.mv +0 -0
  242. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/MoveStdlib/error.mv +0 -0
  243. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/MoveStdlib/features.mv +0 -0
  244. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/MoveStdlib/fixed_point32.mv +0 -0
  245. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/MoveStdlib/hash.mv +0 -0
  246. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/MoveStdlib/option.mv +0 -0
  247. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/MoveStdlib/signer.mv +0 -0
  248. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/MoveStdlib/string.mv +0 -0
  249. package/src/internal/move/jwks/build/jwk/bytecode_modules/dependencies/MoveStdlib/vector.mv +0 -0
  250. package/src/internal/move/jwks/build/jwk/bytecode_scripts/main.mv +0 -0
  251. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/account.mvsm +0 -0
  252. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/aggregator.mvsm +0 -0
  253. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/aggregator_factory.mvsm +0 -0
  254. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/aggregator_v2.mvsm +0 -0
  255. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/aptos_account.mvsm +0 -0
  256. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/aptos_coin.mvsm +0 -0
  257. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/aptos_governance.mvsm +0 -0
  258. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/block.mvsm +0 -0
  259. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/chain_id.mvsm +0 -0
  260. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/chain_status.mvsm +0 -0
  261. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/code.mvsm +0 -0
  262. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/coin.mvsm +0 -0
  263. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/config_buffer.mvsm +0 -0
  264. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/consensus_config.mvsm +0 -0
  265. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/create_signer.mvsm +0 -0
  266. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/delegation_pool.mvsm +0 -0
  267. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/dispatchable_fungible_asset.mvsm +0 -0
  268. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/dkg.mvsm +0 -0
  269. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/event.mvsm +0 -0
  270. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/execution_config.mvsm +0 -0
  271. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/function_info.mvsm +0 -0
  272. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/fungible_asset.mvsm +0 -0
  273. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/gas_schedule.mvsm +0 -0
  274. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/genesis.mvsm +0 -0
  275. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/governance_proposal.mvsm +0 -0
  276. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/guid.mvsm +0 -0
  277. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/jwk_consensus_config.mvsm +0 -0
  278. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/jwks.mvsm +0 -0
  279. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/keyless_account.mvsm +0 -0
  280. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/managed_coin.mvsm +0 -0
  281. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/multisig_account.mvsm +0 -0
  282. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/object.mvsm +0 -0
  283. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/object_code_deployment.mvsm +0 -0
  284. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/optional_aggregator.mvsm +0 -0
  285. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/primary_fungible_store.mvsm +0 -0
  286. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/randomness.mvsm +0 -0
  287. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/randomness_api_v0_config.mvsm +0 -0
  288. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/randomness_config.mvsm +0 -0
  289. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/randomness_config_seqnum.mvsm +0 -0
  290. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/reconfiguration.mvsm +0 -0
  291. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/reconfiguration_state.mvsm +0 -0
  292. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/reconfiguration_with_dkg.mvsm +0 -0
  293. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/resource_account.mvsm +0 -0
  294. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/stake.mvsm +0 -0
  295. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/staking_config.mvsm +0 -0
  296. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/staking_contract.mvsm +0 -0
  297. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/staking_proxy.mvsm +0 -0
  298. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/state_storage.mvsm +0 -0
  299. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/storage_gas.mvsm +0 -0
  300. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/system_addresses.mvsm +0 -0
  301. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/timestamp.mvsm +0 -0
  302. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/transaction_context.mvsm +0 -0
  303. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/transaction_fee.mvsm +0 -0
  304. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/transaction_validation.mvsm +0 -0
  305. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/util.mvsm +0 -0
  306. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/validator_consensus_info.mvsm +0 -0
  307. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/version.mvsm +0 -0
  308. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/vesting.mvsm +0 -0
  309. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosFramework/voting.mvsm +0 -0
  310. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/any.mvsm +0 -0
  311. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/aptos_hash.mvsm +0 -0
  312. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/big_vector.mvsm +0 -0
  313. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/bls12381.mvsm +0 -0
  314. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/bls12381_algebra.mvsm +0 -0
  315. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/bn254_algebra.mvsm +0 -0
  316. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/capability.mvsm +0 -0
  317. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/comparator.mvsm +0 -0
  318. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/copyable_any.mvsm +0 -0
  319. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/crypto_algebra.mvsm +0 -0
  320. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/debug.mvsm +0 -0
  321. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/ed25519.mvsm +0 -0
  322. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/fixed_point64.mvsm +0 -0
  323. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/from_bcs.mvsm +0 -0
  324. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/math128.mvsm +0 -0
  325. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/math64.mvsm +0 -0
  326. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/math_fixed.mvsm +0 -0
  327. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/math_fixed64.mvsm +0 -0
  328. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/multi_ed25519.mvsm +0 -0
  329. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/pool_u64.mvsm +0 -0
  330. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/pool_u64_unbound.mvsm +0 -0
  331. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/ristretto255.mvsm +0 -0
  332. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/ristretto255_bulletproofs.mvsm +0 -0
  333. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/ristretto255_elgamal.mvsm +0 -0
  334. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/ristretto255_pedersen.mvsm +0 -0
  335. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/secp256k1.mvsm +0 -0
  336. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/simple_map.mvsm +0 -0
  337. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/smart_table.mvsm +0 -0
  338. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/smart_vector.mvsm +0 -0
  339. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/string_utils.mvsm +0 -0
  340. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/table.mvsm +0 -0
  341. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/table_with_length.mvsm +0 -0
  342. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/AptosStdlib/type_info.mvsm +0 -0
  343. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/MoveStdlib/acl.mvsm +0 -0
  344. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/MoveStdlib/bcs.mvsm +0 -0
  345. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/MoveStdlib/bit_vector.mvsm +0 -0
  346. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/MoveStdlib/error.mvsm +0 -0
  347. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/MoveStdlib/features.mvsm +0 -0
  348. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/MoveStdlib/fixed_point32.mvsm +0 -0
  349. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/MoveStdlib/hash.mvsm +0 -0
  350. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/MoveStdlib/option.mvsm +0 -0
  351. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/MoveStdlib/signer.mvsm +0 -0
  352. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/MoveStdlib/string.mvsm +0 -0
  353. package/src/internal/move/jwks/build/jwk/source_maps/dependencies/MoveStdlib/vector.mvsm +0 -0
  354. package/src/internal/move/jwks/build/jwk/source_maps/main.mvsm +0 -0
  355. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/account.move +1533 -0
  356. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/aggregator.move +48 -0
  357. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/aggregator_factory.move +66 -0
  358. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/aggregator_v2.move +280 -0
  359. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/aptos_account.move +443 -0
  360. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/aptos_coin.move +204 -0
  361. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/aptos_governance.move +1387 -0
  362. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/block.move +394 -0
  363. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/chain_id.move +41 -0
  364. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/chain_status.move +48 -0
  365. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/code.move +367 -0
  366. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/coin.move +2214 -0
  367. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/config_buffer.move +101 -0
  368. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/consensus_config.move +77 -0
  369. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/create_signer.move +21 -0
  370. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/delegation_pool.move +5568 -0
  371. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/dispatchable_fungible_asset.move +228 -0
  372. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/dkg.move +121 -0
  373. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/event.move +92 -0
  374. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/execution_config.move +66 -0
  375. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/function_info.move +100 -0
  376. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/fungible_asset.move +1566 -0
  377. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/gas_schedule.move +176 -0
  378. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/genesis.move +550 -0
  379. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/governance_proposal.move +23 -0
  380. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/guid.move +68 -0
  381. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/jwk_consensus_config.move +148 -0
  382. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/jwks.move +817 -0
  383. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/keyless_account.move +312 -0
  384. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/managed_coin.move +205 -0
  385. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/multisig_account.move +2477 -0
  386. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/object.move +1073 -0
  387. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/object_code_deployment.move +147 -0
  388. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/optional_aggregator.move +295 -0
  389. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/primary_fungible_store.move +405 -0
  390. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/randomness.move +574 -0
  391. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/randomness_api_v0_config.move +57 -0
  392. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/randomness_config.move +153 -0
  393. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/randomness_config_seqnum.move +49 -0
  394. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/reconfiguration.move +237 -0
  395. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/reconfiguration_state.move +132 -0
  396. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/reconfiguration_with_dkg.move +69 -0
  397. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/resource_account.move +267 -0
  398. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/stake.move +3286 -0
  399. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/staking_config.move +686 -0
  400. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/staking_contract.move +1618 -0
  401. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/staking_proxy.move +228 -0
  402. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/state_storage.move +90 -0
  403. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/storage_gas.move +622 -0
  404. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/system_addresses.move +82 -0
  405. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/timestamp.move +88 -0
  406. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/transaction_context.move +262 -0
  407. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/transaction_fee.move +457 -0
  408. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/transaction_validation.move +501 -0
  409. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/util.move +16 -0
  410. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/validator_consensus_info.move +42 -0
  411. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/version.move +115 -0
  412. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/vesting.move +2183 -0
  413. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosFramework/voting.move +1279 -0
  414. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/any.move +57 -0
  415. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/aptos_hash.move +253 -0
  416. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/big_vector.move +469 -0
  417. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/bls12381.move +985 -0
  418. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/bls12381_algebra.move +802 -0
  419. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/bn254_algebra.move +855 -0
  420. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/capability.move +193 -0
  421. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/comparator.move +173 -0
  422. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/copyable_any.move +45 -0
  423. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/crypto_algebra.move +351 -0
  424. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/debug.move +278 -0
  425. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/ed25519.move +262 -0
  426. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/fixed_point64.move +447 -0
  427. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/from_bcs.move +91 -0
  428. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/math128.move +381 -0
  429. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/math64.move +336 -0
  430. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/math_fixed.move +139 -0
  431. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/math_fixed64.move +142 -0
  432. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/multi_ed25519.move +482 -0
  433. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/pool_u64.move +571 -0
  434. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/pool_u64_unbound.move +270 -0
  435. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/ristretto255.move +1310 -0
  436. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/ristretto255_bulletproofs.move +253 -0
  437. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/ristretto255_elgamal.move +234 -0
  438. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/ristretto255_pedersen.move +158 -0
  439. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/secp256k1.move +114 -0
  440. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/simple_map.move +319 -0
  441. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/smart_table.move +769 -0
  442. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/smart_vector.move +766 -0
  443. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/string_utils.move +148 -0
  444. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/table.move +152 -0
  445. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/table_with_length.move +141 -0
  446. package/src/internal/move/jwks/build/jwk/sources/dependencies/AptosStdlib/type_info.move +351 -0
  447. package/src/internal/move/jwks/build/jwk/sources/dependencies/MoveStdlib/acl.move +46 -0
  448. package/src/internal/move/jwks/build/jwk/sources/dependencies/MoveStdlib/bcs.move +27 -0
  449. package/src/internal/move/jwks/build/jwk/sources/dependencies/MoveStdlib/bit_vector.move +239 -0
  450. package/src/internal/move/jwks/build/jwk/sources/dependencies/MoveStdlib/error.move +88 -0
  451. package/src/internal/move/jwks/build/jwk/sources/dependencies/MoveStdlib/features.move +780 -0
  452. package/src/internal/move/jwks/build/jwk/sources/dependencies/MoveStdlib/fixed_point32.move +295 -0
  453. package/src/internal/move/jwks/build/jwk/sources/dependencies/MoveStdlib/hash.move +8 -0
  454. package/src/internal/move/jwks/build/jwk/sources/dependencies/MoveStdlib/option.move +356 -0
  455. package/src/internal/move/jwks/build/jwk/sources/dependencies/MoveStdlib/signer.move +21 -0
  456. package/src/internal/move/jwks/build/jwk/sources/dependencies/MoveStdlib/string.move +93 -0
  457. package/src/internal/move/jwks/build/jwk/sources/dependencies/MoveStdlib/vector.move +669 -0
  458. package/src/internal/move/jwks/build/jwk/sources/main.move +20 -0
  459. package/src/version.ts +1 -1
  460. package/dist/esm/chunk-5YLNYSBT.mjs +0 -4
  461. package/dist/esm/chunk-5YLNYSBT.mjs.map +0 -1
  462. package/dist/esm/chunk-DLIBG6H7.mjs +0 -2
  463. package/dist/esm/chunk-DLIBG6H7.mjs.map +0 -1
  464. package/dist/esm/chunk-HLF3U7IS.mjs +0 -2
  465. package/dist/esm/chunk-RIRJNQ7B.mjs +0 -2
  466. /package/dist/esm/{chunk-34R7FSQF.mjs.map → chunk-57J5YBMT.mjs.map} +0 -0
  467. /package/dist/esm/{chunk-USB3LA6B.mjs.map → chunk-AMAPBD4D.mjs.map} +0 -0
  468. /package/dist/esm/{chunk-G7WH6GQP.mjs.map → chunk-CFQFFP6N.mjs.map} +0 -0
  469. /package/dist/esm/{chunk-4JT5AESZ.mjs.map → chunk-CO67Y6YE.mjs.map} +0 -0
  470. /package/dist/esm/{chunk-RIRJNQ7B.mjs.map → chunk-CW35YAMN.mjs.map} +0 -0
  471. /package/dist/esm/{chunk-HW7TSJI2.mjs.map → chunk-CZYH3G7E.mjs.map} +0 -0
  472. /package/dist/esm/{chunk-ZNLOQO4Q.mjs.map → chunk-GBNAG7KK.mjs.map} +0 -0
  473. /package/dist/esm/{chunk-6UZHMEK3.mjs.map → chunk-HETYL3WN.mjs.map} +0 -0
  474. /package/dist/esm/{chunk-SE2VS7WM.mjs.map → chunk-KRBZ54CY.mjs.map} +0 -0
  475. /package/dist/esm/{chunk-G6HENV5D.mjs.map → chunk-Q4W3WJ2U.mjs.map} +0 -0
  476. /package/dist/esm/{chunk-EF4FA5I6.mjs.map → chunk-RQX6JOEN.mjs.map} +0 -0
  477. /package/dist/esm/{chunk-MA4QUN6P.mjs.map → chunk-U7HD6PQV.mjs.map} +0 -0
  478. /package/dist/esm/{chunk-TDGLYA35.mjs.map → chunk-UOP7GBXB.mjs.map} +0 -0
  479. /package/dist/esm/{chunk-K43K3YG7.mjs.map → chunk-UQWF24SS.mjs.map} +0 -0
  480. /package/dist/esm/{chunk-2UBI3AZJ.mjs.map → chunk-V2QSMVJ5.mjs.map} +0 -0
  481. /package/dist/esm/{chunk-TLFZOAAB.mjs.map → chunk-V74WPKSY.mjs.map} +0 -0
@@ -0,0 +1,1533 @@
1
+ module aptos_framework::account {
2
+ use std::bcs;
3
+ use std::error;
4
+ use std::hash;
5
+ use std::option::{Self, Option};
6
+ use std::signer;
7
+ use std::vector;
8
+ use aptos_framework::chain_id;
9
+ use aptos_framework::create_signer::create_signer;
10
+ use aptos_framework::event::{Self, EventHandle};
11
+ use aptos_framework::guid;
12
+ use aptos_framework::system_addresses;
13
+ use aptos_std::ed25519;
14
+ use aptos_std::from_bcs;
15
+ use aptos_std::multi_ed25519;
16
+ use aptos_std::table::{Self, Table};
17
+ use aptos_std::type_info::{Self, TypeInfo};
18
+
19
+ friend aptos_framework::aptos_account;
20
+ friend aptos_framework::coin;
21
+ friend aptos_framework::genesis;
22
+ friend aptos_framework::multisig_account;
23
+ friend aptos_framework::resource_account;
24
+ friend aptos_framework::transaction_validation;
25
+
26
+ #[event]
27
+ struct KeyRotation has drop, store {
28
+ account: address,
29
+ old_authentication_key: vector<u8>,
30
+ new_authentication_key: vector<u8>,
31
+ }
32
+
33
+ /// Resource representing an account.
34
+ struct Account has key, store {
35
+ authentication_key: vector<u8>,
36
+ sequence_number: u64,
37
+ guid_creation_num: u64,
38
+ coin_register_events: EventHandle<CoinRegisterEvent>,
39
+ key_rotation_events: EventHandle<KeyRotationEvent>,
40
+ rotation_capability_offer: CapabilityOffer<RotationCapability>,
41
+ signer_capability_offer: CapabilityOffer<SignerCapability>,
42
+ }
43
+
44
+ struct KeyRotationEvent has drop, store {
45
+ old_authentication_key: vector<u8>,
46
+ new_authentication_key: vector<u8>,
47
+ }
48
+
49
+ struct CoinRegisterEvent has drop, store {
50
+ type_info: TypeInfo,
51
+ }
52
+
53
+ struct CapabilityOffer<phantom T> has store { for: Option<address> }
54
+
55
+ struct RotationCapability has drop, store { account: address }
56
+
57
+ struct SignerCapability has drop, store { account: address }
58
+
59
+ /// It is easy to fetch the authentication key of an address by simply reading it from the `Account` struct at that address.
60
+ /// The table in this struct makes it possible to do a reverse lookup: it maps an authentication key, to the address of the account which has that authentication key set.
61
+ ///
62
+ /// This mapping is needed when recovering wallets for accounts whose authentication key has been rotated.
63
+ ///
64
+ /// For example, imagine a freshly-created wallet with address `a` and thus also with authentication key `a`, derived from a PK `pk_a` with corresponding SK `sk_a`.
65
+ /// It is easy to recover such a wallet given just the secret key `sk_a`, since the PK can be derived from the SK, the authentication key can then be derived from the PK, and the address equals the authentication key (since there was no key rotation).
66
+ ///
67
+ /// However, if such a wallet rotates its authentication key to `b` derived from a different PK `pk_b` with SK `sk_b`, how would account recovery work?
68
+ /// The recovered address would no longer be 'a'; it would be `b`, which is incorrect.
69
+ /// This struct solves this problem by mapping the new authentication key `b` to the original address `a` and thus helping the wallet software during recovery find the correct address.
70
+ struct OriginatingAddress has key {
71
+ address_map: Table<address, address>,
72
+ }
73
+
74
+ /// This structs stores the challenge message that should be signed during key rotation. First, this struct is
75
+ /// signed by the account owner's current public key, which proves possession of a capability to rotate the key.
76
+ /// Second, this struct is signed by the new public key that the account owner wants to rotate to, which proves
77
+ /// knowledge of this new public key's associated secret key. These two signatures cannot be replayed in another
78
+ /// context because they include the TXN's unique sequence number.
79
+ struct RotationProofChallenge has copy, drop {
80
+ sequence_number: u64,
81
+ // the sequence number of the account whose key is being rotated
82
+ originator: address,
83
+ // the address of the account whose key is being rotated
84
+ current_auth_key: address,
85
+ // the current authentication key of the account whose key is being rotated
86
+ new_public_key: vector<u8>,
87
+ // the new public key that the account owner wants to rotate to
88
+ }
89
+
90
+ /// Deprecated struct - newest version is `RotationCapabilityOfferProofChallengeV2`
91
+ struct RotationCapabilityOfferProofChallenge has drop {
92
+ sequence_number: u64,
93
+ recipient_address: address,
94
+ }
95
+
96
+ /// Deprecated struct - newest version is `SignerCapabilityOfferProofChallengeV2`
97
+ struct SignerCapabilityOfferProofChallenge has drop {
98
+ sequence_number: u64,
99
+ recipient_address: address,
100
+ }
101
+
102
+ /// This struct stores the challenge message that should be signed by the source account, when the source account
103
+ /// is delegating its rotation capability to the `recipient_address`.
104
+ /// This V2 struct adds the `chain_id` and `source_address` to the challenge message, which prevents replaying the challenge message.
105
+ struct RotationCapabilityOfferProofChallengeV2 has drop {
106
+ chain_id: u8,
107
+ sequence_number: u64,
108
+ source_address: address,
109
+ recipient_address: address,
110
+ }
111
+
112
+ struct SignerCapabilityOfferProofChallengeV2 has copy, drop {
113
+ sequence_number: u64,
114
+ source_address: address,
115
+ recipient_address: address,
116
+ }
117
+
118
+ const MAX_U64: u128 = 18446744073709551615;
119
+ const ZERO_AUTH_KEY: vector<u8> = x"0000000000000000000000000000000000000000000000000000000000000000";
120
+
121
+ /// Scheme identifier for Ed25519 signatures used to derive authentication keys for Ed25519 public keys.
122
+ const ED25519_SCHEME: u8 = 0;
123
+ /// Scheme identifier for MultiEd25519 signatures used to derive authentication keys for MultiEd25519 public keys.
124
+ const MULTI_ED25519_SCHEME: u8 = 1;
125
+ /// Scheme identifier used when hashing an account's address together with a seed to derive the address (not the
126
+ /// authentication key) of a resource account. This is an abuse of the notion of a scheme identifier which, for now,
127
+ /// serves to domain separate hashes used to derive resource account addresses from hashes used to derive
128
+ /// authentication keys. Without such separation, an adversary could create (and get a signer for) a resource account
129
+ /// whose address matches an existing address of a MultiEd25519 wallet.
130
+ const DERIVE_RESOURCE_ACCOUNT_SCHEME: u8 = 255;
131
+
132
+ /// Account already exists
133
+ const EACCOUNT_ALREADY_EXISTS: u64 = 1;
134
+ /// Account does not exist
135
+ const EACCOUNT_DOES_NOT_EXIST: u64 = 2;
136
+ /// Sequence number exceeds the maximum value for a u64
137
+ const ESEQUENCE_NUMBER_TOO_BIG: u64 = 3;
138
+ /// The provided authentication key has an invalid length
139
+ const EMALFORMED_AUTHENTICATION_KEY: u64 = 4;
140
+ /// Cannot create account because address is reserved
141
+ const ECANNOT_RESERVED_ADDRESS: u64 = 5;
142
+ /// Transaction exceeded its allocated max gas
143
+ const EOUT_OF_GAS: u64 = 6;
144
+ /// Specified current public key is not correct
145
+ const EWRONG_CURRENT_PUBLIC_KEY: u64 = 7;
146
+ /// Specified proof of knowledge required to prove ownership of a public key is invalid
147
+ const EINVALID_PROOF_OF_KNOWLEDGE: u64 = 8;
148
+ /// The caller does not have a digital-signature-based capability to call this function
149
+ const ENO_CAPABILITY: u64 = 9;
150
+ /// The caller does not have a valid rotation capability offer from the other account
151
+ const EINVALID_ACCEPT_ROTATION_CAPABILITY: u64 = 10;
152
+ /// Address to create is not a valid reserved address for Aptos framework
153
+ const ENO_VALID_FRAMEWORK_RESERVED_ADDRESS: u64 = 11;
154
+ /// Specified scheme required to proceed with the smart contract operation - can only be ED25519_SCHEME(0) OR MULTI_ED25519_SCHEME(1)
155
+ const EINVALID_SCHEME: u64 = 12;
156
+ /// Abort the transaction if the expected originating address is different from the originating address on-chain
157
+ const EINVALID_ORIGINATING_ADDRESS: u64 = 13;
158
+ /// The signer capability offer doesn't exist at the given address
159
+ const ENO_SUCH_SIGNER_CAPABILITY: u64 = 14;
160
+ /// An attempt to create a resource account on a claimed account
161
+ const ERESOURCE_ACCCOUNT_EXISTS: u64 = 15;
162
+ /// An attempt to create a resource account on an account that has a committed transaction
163
+ const EACCOUNT_ALREADY_USED: u64 = 16;
164
+ /// Offerer address doesn't exist
165
+ const EOFFERER_ADDRESS_DOES_NOT_EXIST: u64 = 17;
166
+ /// The specified rotation capability offer does not exist at the specified offerer address
167
+ const ENO_SUCH_ROTATION_CAPABILITY_OFFER: u64 = 18;
168
+ // The signer capability is not offered to any address
169
+ const ENO_SIGNER_CAPABILITY_OFFERED: u64 = 19;
170
+ // This account has exceeded the allocated GUIDs it can create. It should be impossible to reach this number for real applications.
171
+ const EEXCEEDED_MAX_GUID_CREATION_NUM: u64 = 20;
172
+
173
+ /// Explicitly separate the GUID space between Object and Account to prevent accidental overlap.
174
+ const MAX_GUID_CREATION_NUM: u64 = 0x4000000000000;
175
+
176
+ #[test_only]
177
+ /// Create signer for testing, independently of an Aptos-style `Account`.
178
+ public fun create_signer_for_test(addr: address): signer { create_signer(addr) }
179
+
180
+ /// Only called during genesis to initialize system resources for this module.
181
+ public(friend) fun initialize(aptos_framework: &signer) {
182
+ system_addresses::assert_aptos_framework(aptos_framework);
183
+ move_to(aptos_framework, OriginatingAddress {
184
+ address_map: table::new(),
185
+ });
186
+ }
187
+
188
+ public fun create_account_if_does_not_exist(account_address: address) {
189
+ if (!exists<Account>(account_address)) {
190
+ create_account(account_address);
191
+ }
192
+ }
193
+
194
+ /// Publishes a new `Account` resource under `new_address`. A signer representing `new_address`
195
+ /// is returned. This way, the caller of this function can publish additional resources under
196
+ /// `new_address`.
197
+ public(friend) fun create_account(new_address: address): signer {
198
+ // there cannot be an Account resource under new_addr already.
199
+ assert!(!exists<Account>(new_address), error::already_exists(EACCOUNT_ALREADY_EXISTS));
200
+
201
+ // NOTE: @core_resources gets created via a `create_account` call, so we do not include it below.
202
+ assert!(
203
+ new_address != @vm_reserved && new_address != @aptos_framework && new_address != @aptos_token,
204
+ error::invalid_argument(ECANNOT_RESERVED_ADDRESS)
205
+ );
206
+
207
+ create_account_unchecked(new_address)
208
+ }
209
+
210
+ fun create_account_unchecked(new_address: address): signer {
211
+ let new_account = create_signer(new_address);
212
+ let authentication_key = bcs::to_bytes(&new_address);
213
+ assert!(
214
+ vector::length(&authentication_key) == 32,
215
+ error::invalid_argument(EMALFORMED_AUTHENTICATION_KEY)
216
+ );
217
+
218
+ let guid_creation_num = 0;
219
+
220
+ let guid_for_coin = guid::create(new_address, &mut guid_creation_num);
221
+ let coin_register_events = event::new_event_handle<CoinRegisterEvent>(guid_for_coin);
222
+
223
+ let guid_for_rotation = guid::create(new_address, &mut guid_creation_num);
224
+ let key_rotation_events = event::new_event_handle<KeyRotationEvent>(guid_for_rotation);
225
+
226
+ move_to(
227
+ &new_account,
228
+ Account {
229
+ authentication_key,
230
+ sequence_number: 0,
231
+ guid_creation_num,
232
+ coin_register_events,
233
+ key_rotation_events,
234
+ rotation_capability_offer: CapabilityOffer { for: option::none() },
235
+ signer_capability_offer: CapabilityOffer { for: option::none() },
236
+ }
237
+ );
238
+
239
+ new_account
240
+ }
241
+
242
+ #[view]
243
+ public fun exists_at(addr: address): bool {
244
+ exists<Account>(addr)
245
+ }
246
+
247
+ #[view]
248
+ public fun get_guid_next_creation_num(addr: address): u64 acquires Account {
249
+ borrow_global<Account>(addr).guid_creation_num
250
+ }
251
+
252
+ #[view]
253
+ public fun get_sequence_number(addr: address): u64 acquires Account {
254
+ borrow_global<Account>(addr).sequence_number
255
+ }
256
+
257
+ public(friend) fun increment_sequence_number(addr: address) acquires Account {
258
+ let sequence_number = &mut borrow_global_mut<Account>(addr).sequence_number;
259
+
260
+ assert!(
261
+ (*sequence_number as u128) < MAX_U64,
262
+ error::out_of_range(ESEQUENCE_NUMBER_TOO_BIG)
263
+ );
264
+
265
+ *sequence_number = *sequence_number + 1;
266
+ }
267
+
268
+ #[view]
269
+ public fun get_authentication_key(addr: address): vector<u8> acquires Account {
270
+ borrow_global<Account>(addr).authentication_key
271
+ }
272
+
273
+ /// This function is used to rotate a resource account's authentication key to `new_auth_key`. This is done in
274
+ /// many contexts:
275
+ /// 1. During normal key rotation via `rotate_authentication_key` or `rotate_authentication_key_call`
276
+ /// 2. During resource account initialization so that no private key can control the resource account
277
+ /// 3. During multisig_v2 account creation
278
+ public(friend) fun rotate_authentication_key_internal(account: &signer, new_auth_key: vector<u8>) acquires Account {
279
+ let addr = signer::address_of(account);
280
+ assert!(exists_at(addr), error::not_found(EACCOUNT_DOES_NOT_EXIST));
281
+ assert!(
282
+ vector::length(&new_auth_key) == 32,
283
+ error::invalid_argument(EMALFORMED_AUTHENTICATION_KEY)
284
+ );
285
+ let account_resource = borrow_global_mut<Account>(addr);
286
+ account_resource.authentication_key = new_auth_key;
287
+ }
288
+
289
+ /// Private entry function for key rotation that allows the signer to update their authentication key.
290
+ /// Note that this does not update the `OriginatingAddress` table because the `new_auth_key` is not "verified": it
291
+ /// does not come with a proof-of-knowledge of the underlying SK. Nonetheless, we need this functionality due to
292
+ /// the introduction of non-standard key algorithms, such as passkeys, which cannot produce proofs-of-knowledge in
293
+ /// the format expected in `rotate_authentication_key`.
294
+ entry fun rotate_authentication_key_call(account: &signer, new_auth_key: vector<u8>) acquires Account {
295
+ rotate_authentication_key_internal(account, new_auth_key);
296
+ }
297
+
298
+ /// Generic authentication key rotation function that allows the user to rotate their authentication key from any scheme to any scheme.
299
+ /// To authorize the rotation, we need two signatures:
300
+ /// - the first signature `cap_rotate_key` refers to the signature by the account owner's current key on a valid `RotationProofChallenge`,
301
+ /// demonstrating that the user intends to and has the capability to rotate the authentication key of this account;
302
+ /// - the second signature `cap_update_table` refers to the signature by the new key (that the account owner wants to rotate to) on a
303
+ /// valid `RotationProofChallenge`, demonstrating that the user owns the new private key, and has the authority to update the
304
+ /// `OriginatingAddress` map with the new address mapping `<new_address, originating_address>`.
305
+ /// To verify these two signatures, we need their corresponding public key and public key scheme: we use `from_scheme` and `from_public_key_bytes`
306
+ /// to verify `cap_rotate_key`, and `to_scheme` and `to_public_key_bytes` to verify `cap_update_table`.
307
+ /// A scheme of 0 refers to an Ed25519 key and a scheme of 1 refers to Multi-Ed25519 keys.
308
+ /// `originating address` refers to an account's original/first address.
309
+ ///
310
+ /// Here is an example attack if we don't ask for the second signature `cap_update_table`:
311
+ /// Alice has rotated her account `addr_a` to `new_addr_a`. As a result, the following entry is created, to help Alice when recovering her wallet:
312
+ /// `OriginatingAddress[new_addr_a]` -> `addr_a`
313
+ /// Alice has had a bad day: her laptop blew up and she needs to reset her account on a new one.
314
+ /// (Fortunately, she still has her secret key `new_sk_a` associated with her new address `new_addr_a`, so she can do this.)
315
+ ///
316
+ /// But Bob likes to mess with Alice.
317
+ /// Bob creates an account `addr_b` and maliciously rotates it to Alice's new address `new_addr_a`. Since we are no longer checking a PoK,
318
+ /// Bob can easily do this.
319
+ ///
320
+ /// Now, the table will be updated to make Alice's new address point to Bob's address: `OriginatingAddress[new_addr_a]` -> `addr_b`.
321
+ /// When Alice recovers her account, her wallet will display the attacker's address (Bob's) `addr_b` as her address.
322
+ /// Now Alice will give `addr_b` to everyone to pay her, but the money will go to Bob.
323
+ ///
324
+ /// Because we ask for a valid `cap_update_table`, this kind of attack is not possible. Bob would not have the secret key of Alice's address
325
+ /// to rotate his address to Alice's address in the first place.
326
+ public entry fun rotate_authentication_key(
327
+ account: &signer,
328
+ from_scheme: u8,
329
+ from_public_key_bytes: vector<u8>,
330
+ to_scheme: u8,
331
+ to_public_key_bytes: vector<u8>,
332
+ cap_rotate_key: vector<u8>,
333
+ cap_update_table: vector<u8>,
334
+ ) acquires Account, OriginatingAddress {
335
+ let addr = signer::address_of(account);
336
+ assert!(exists_at(addr), error::not_found(EACCOUNT_DOES_NOT_EXIST));
337
+ let account_resource = borrow_global_mut<Account>(addr);
338
+
339
+ // Verify the given `from_public_key_bytes` matches this account's current authentication key.
340
+ if (from_scheme == ED25519_SCHEME) {
341
+ let from_pk = ed25519::new_unvalidated_public_key_from_bytes(from_public_key_bytes);
342
+ let from_auth_key = ed25519::unvalidated_public_key_to_authentication_key(&from_pk);
343
+ assert!(
344
+ account_resource.authentication_key == from_auth_key,
345
+ error::unauthenticated(EWRONG_CURRENT_PUBLIC_KEY)
346
+ );
347
+ } else if (from_scheme == MULTI_ED25519_SCHEME) {
348
+ let from_pk = multi_ed25519::new_unvalidated_public_key_from_bytes(from_public_key_bytes);
349
+ let from_auth_key = multi_ed25519::unvalidated_public_key_to_authentication_key(&from_pk);
350
+ assert!(
351
+ account_resource.authentication_key == from_auth_key,
352
+ error::unauthenticated(EWRONG_CURRENT_PUBLIC_KEY)
353
+ );
354
+ } else {
355
+ abort error::invalid_argument(EINVALID_SCHEME)
356
+ };
357
+
358
+ // Construct a valid `RotationProofChallenge` that `cap_rotate_key` and `cap_update_table` will validate against.
359
+ let curr_auth_key_as_address = from_bcs::to_address(account_resource.authentication_key);
360
+ let challenge = RotationProofChallenge {
361
+ sequence_number: account_resource.sequence_number,
362
+ originator: addr,
363
+ current_auth_key: curr_auth_key_as_address,
364
+ new_public_key: to_public_key_bytes,
365
+ };
366
+
367
+ // Assert the challenges signed by the current and new keys are valid
368
+ assert_valid_rotation_proof_signature_and_get_auth_key(
369
+ from_scheme,
370
+ from_public_key_bytes,
371
+ cap_rotate_key,
372
+ &challenge
373
+ );
374
+ let new_auth_key = assert_valid_rotation_proof_signature_and_get_auth_key(
375
+ to_scheme,
376
+ to_public_key_bytes,
377
+ cap_update_table,
378
+ &challenge
379
+ );
380
+
381
+ // Update the `OriginatingAddress` table.
382
+ update_auth_key_and_originating_address_table(addr, account_resource, new_auth_key);
383
+ }
384
+
385
+ public entry fun rotate_authentication_key_with_rotation_capability(
386
+ delegate_signer: &signer,
387
+ rotation_cap_offerer_address: address,
388
+ new_scheme: u8,
389
+ new_public_key_bytes: vector<u8>,
390
+ cap_update_table: vector<u8>
391
+ ) acquires Account, OriginatingAddress {
392
+ assert!(exists_at(rotation_cap_offerer_address), error::not_found(EOFFERER_ADDRESS_DOES_NOT_EXIST));
393
+
394
+ // Check that there exists a rotation capability offer at the offerer's account resource for the delegate.
395
+ let delegate_address = signer::address_of(delegate_signer);
396
+ let offerer_account_resource = borrow_global<Account>(rotation_cap_offerer_address);
397
+ assert!(
398
+ option::contains(&offerer_account_resource.rotation_capability_offer.for, &delegate_address),
399
+ error::not_found(ENO_SUCH_ROTATION_CAPABILITY_OFFER)
400
+ );
401
+
402
+ let curr_auth_key = from_bcs::to_address(offerer_account_resource.authentication_key);
403
+ let challenge = RotationProofChallenge {
404
+ sequence_number: get_sequence_number(delegate_address),
405
+ originator: rotation_cap_offerer_address,
406
+ current_auth_key: curr_auth_key,
407
+ new_public_key: new_public_key_bytes,
408
+ };
409
+
410
+ // Verifies that the `RotationProofChallenge` from above is signed under the new public key that we are rotating to. l
411
+ let new_auth_key = assert_valid_rotation_proof_signature_and_get_auth_key(
412
+ new_scheme,
413
+ new_public_key_bytes,
414
+ cap_update_table,
415
+ &challenge
416
+ );
417
+
418
+ // Update the `OriginatingAddress` table, so we can find the originating address using the new address.
419
+ let offerer_account_resource = borrow_global_mut<Account>(rotation_cap_offerer_address);
420
+ update_auth_key_and_originating_address_table(
421
+ rotation_cap_offerer_address,
422
+ offerer_account_resource,
423
+ new_auth_key
424
+ );
425
+ }
426
+
427
+ /// Offers rotation capability on behalf of `account` to the account at address `recipient_address`.
428
+ /// An account can delegate its rotation capability to only one other address at one time. If the account
429
+ /// has an existing rotation capability offer, calling this function will update the rotation capability offer with
430
+ /// the new `recipient_address`.
431
+ /// Here, `rotation_capability_sig_bytes` signature indicates that this key rotation is authorized by the account owner,
432
+ /// and prevents the classic "time-of-check time-of-use" attack.
433
+ /// For example, users usually rely on what the wallet displays to them as the transaction's outcome. Consider a contract that with 50% probability
434
+ /// (based on the current timestamp in Move), rotates somebody's key. The wallet might be unlucky and get an outcome where nothing is rotated,
435
+ /// incorrectly telling the user nothing bad will happen. But when the transaction actually gets executed, the attacker gets lucky and
436
+ /// the execution path triggers the account key rotation.
437
+ /// We prevent such attacks by asking for this extra signature authorizing the key rotation.
438
+ ///
439
+ /// @param rotation_capability_sig_bytes is the signature by the account owner's key on `RotationCapabilityOfferProofChallengeV2`.
440
+ /// @param account_scheme is the scheme of the account (ed25519 or multi_ed25519).
441
+ /// @param account_public_key_bytes is the public key of the account owner.
442
+ /// @param recipient_address is the address of the recipient of the rotation capability - note that if there's an existing rotation capability
443
+ /// offer, calling this function will replace the previous `recipient_address` upon successful verification.
444
+ public entry fun offer_rotation_capability(
445
+ account: &signer,
446
+ rotation_capability_sig_bytes: vector<u8>,
447
+ account_scheme: u8,
448
+ account_public_key_bytes: vector<u8>,
449
+ recipient_address: address,
450
+ ) acquires Account {
451
+ let addr = signer::address_of(account);
452
+ assert!(exists_at(recipient_address), error::not_found(EACCOUNT_DOES_NOT_EXIST));
453
+
454
+ // proof that this account intends to delegate its rotation capability to another account
455
+ let account_resource = borrow_global_mut<Account>(addr);
456
+ let proof_challenge = RotationCapabilityOfferProofChallengeV2 {
457
+ chain_id: chain_id::get(),
458
+ sequence_number: account_resource.sequence_number,
459
+ source_address: addr,
460
+ recipient_address,
461
+ };
462
+
463
+ // verify the signature on `RotationCapabilityOfferProofChallengeV2` by the account owner
464
+ if (account_scheme == ED25519_SCHEME) {
465
+ let pubkey = ed25519::new_unvalidated_public_key_from_bytes(account_public_key_bytes);
466
+ let expected_auth_key = ed25519::unvalidated_public_key_to_authentication_key(&pubkey);
467
+ assert!(
468
+ account_resource.authentication_key == expected_auth_key,
469
+ error::invalid_argument(EWRONG_CURRENT_PUBLIC_KEY)
470
+ );
471
+
472
+ let rotation_capability_sig = ed25519::new_signature_from_bytes(rotation_capability_sig_bytes);
473
+ assert!(
474
+ ed25519::signature_verify_strict_t(&rotation_capability_sig, &pubkey, proof_challenge),
475
+ error::invalid_argument(EINVALID_PROOF_OF_KNOWLEDGE)
476
+ );
477
+ } else if (account_scheme == MULTI_ED25519_SCHEME) {
478
+ let pubkey = multi_ed25519::new_unvalidated_public_key_from_bytes(account_public_key_bytes);
479
+ let expected_auth_key = multi_ed25519::unvalidated_public_key_to_authentication_key(&pubkey);
480
+ assert!(
481
+ account_resource.authentication_key == expected_auth_key,
482
+ error::invalid_argument(EWRONG_CURRENT_PUBLIC_KEY)
483
+ );
484
+
485
+ let rotation_capability_sig = multi_ed25519::new_signature_from_bytes(rotation_capability_sig_bytes);
486
+ assert!(
487
+ multi_ed25519::signature_verify_strict_t(&rotation_capability_sig, &pubkey, proof_challenge),
488
+ error::invalid_argument(EINVALID_PROOF_OF_KNOWLEDGE)
489
+ );
490
+ } else {
491
+ abort error::invalid_argument(EINVALID_SCHEME)
492
+ };
493
+
494
+ // update the existing rotation capability offer or put in a new rotation capability offer for the current account
495
+ option::swap_or_fill(&mut account_resource.rotation_capability_offer.for, recipient_address);
496
+ }
497
+
498
+ #[view]
499
+ /// Returns true if the account at `account_addr` has a rotation capability offer.
500
+ public fun is_rotation_capability_offered(account_addr: address): bool acquires Account {
501
+ let account_resource = borrow_global<Account>(account_addr);
502
+ option::is_some(&account_resource.rotation_capability_offer.for)
503
+ }
504
+
505
+ #[view]
506
+ /// Returns the address of the account that has a rotation capability offer from the account at `account_addr`.
507
+ public fun get_rotation_capability_offer_for(account_addr: address): address acquires Account {
508
+ let account_resource = borrow_global<Account>(account_addr);
509
+ assert!(
510
+ option::is_some(&account_resource.rotation_capability_offer.for),
511
+ error::not_found(ENO_SIGNER_CAPABILITY_OFFERED),
512
+ );
513
+ *option::borrow(&account_resource.rotation_capability_offer.for)
514
+ }
515
+
516
+ /// Revoke the rotation capability offer given to `to_be_revoked_recipient_address` from `account`
517
+ public entry fun revoke_rotation_capability(account: &signer, to_be_revoked_address: address) acquires Account {
518
+ assert!(exists_at(to_be_revoked_address), error::not_found(EACCOUNT_DOES_NOT_EXIST));
519
+ let addr = signer::address_of(account);
520
+ let account_resource = borrow_global_mut<Account>(addr);
521
+ assert!(
522
+ option::contains(&account_resource.rotation_capability_offer.for, &to_be_revoked_address),
523
+ error::not_found(ENO_SUCH_ROTATION_CAPABILITY_OFFER)
524
+ );
525
+ revoke_any_rotation_capability(account);
526
+ }
527
+
528
+ /// Revoke any rotation capability offer in the specified account.
529
+ public entry fun revoke_any_rotation_capability(account: &signer) acquires Account {
530
+ let account_resource = borrow_global_mut<Account>(signer::address_of(account));
531
+ option::extract(&mut account_resource.rotation_capability_offer.for);
532
+ }
533
+
534
+ /// Offers signer capability on behalf of `account` to the account at address `recipient_address`.
535
+ /// An account can delegate its signer capability to only one other address at one time.
536
+ /// `signer_capability_key_bytes` is the `SignerCapabilityOfferProofChallengeV2` signed by the account owner's key
537
+ /// `account_scheme` is the scheme of the account (ed25519 or multi_ed25519).
538
+ /// `account_public_key_bytes` is the public key of the account owner.
539
+ /// `recipient_address` is the address of the recipient of the signer capability - note that if there's an existing
540
+ /// `recipient_address` in the account owner's `SignerCapabilityOffer`, this will replace the
541
+ /// previous `recipient_address` upon successful verification (the previous recipient will no longer have access
542
+ /// to the account owner's signer capability).
543
+ public entry fun offer_signer_capability(
544
+ account: &signer,
545
+ signer_capability_sig_bytes: vector<u8>,
546
+ account_scheme: u8,
547
+ account_public_key_bytes: vector<u8>,
548
+ recipient_address: address
549
+ ) acquires Account {
550
+ let source_address = signer::address_of(account);
551
+ assert!(exists_at(recipient_address), error::not_found(EACCOUNT_DOES_NOT_EXIST));
552
+
553
+ // Proof that this account intends to delegate its signer capability to another account.
554
+ let proof_challenge = SignerCapabilityOfferProofChallengeV2 {
555
+ sequence_number: get_sequence_number(source_address),
556
+ source_address,
557
+ recipient_address,
558
+ };
559
+ verify_signed_message(
560
+ source_address, account_scheme, account_public_key_bytes, signer_capability_sig_bytes, proof_challenge);
561
+
562
+ // Update the existing signer capability offer or put in a new signer capability offer for the recipient.
563
+ let account_resource = borrow_global_mut<Account>(source_address);
564
+ option::swap_or_fill(&mut account_resource.signer_capability_offer.for, recipient_address);
565
+ }
566
+
567
+ #[view]
568
+ /// Returns true if the account at `account_addr` has a signer capability offer.
569
+ public fun is_signer_capability_offered(account_addr: address): bool acquires Account {
570
+ let account_resource = borrow_global<Account>(account_addr);
571
+ option::is_some(&account_resource.signer_capability_offer.for)
572
+ }
573
+
574
+ #[view]
575
+ /// Returns the address of the account that has a signer capability offer from the account at `account_addr`.
576
+ public fun get_signer_capability_offer_for(account_addr: address): address acquires Account {
577
+ let account_resource = borrow_global<Account>(account_addr);
578
+ assert!(
579
+ option::is_some(&account_resource.signer_capability_offer.for),
580
+ error::not_found(ENO_SIGNER_CAPABILITY_OFFERED),
581
+ );
582
+ *option::borrow(&account_resource.signer_capability_offer.for)
583
+ }
584
+
585
+ /// Revoke the account owner's signer capability offer for `to_be_revoked_address` (i.e., the address that
586
+ /// has a signer capability offer from `account` but will be revoked in this function).
587
+ public entry fun revoke_signer_capability(account: &signer, to_be_revoked_address: address) acquires Account {
588
+ assert!(exists_at(to_be_revoked_address), error::not_found(EACCOUNT_DOES_NOT_EXIST));
589
+ let addr = signer::address_of(account);
590
+ let account_resource = borrow_global_mut<Account>(addr);
591
+ assert!(
592
+ option::contains(&account_resource.signer_capability_offer.for, &to_be_revoked_address),
593
+ error::not_found(ENO_SUCH_SIGNER_CAPABILITY)
594
+ );
595
+ revoke_any_signer_capability(account);
596
+ }
597
+
598
+ /// Revoke any signer capability offer in the specified account.
599
+ public entry fun revoke_any_signer_capability(account: &signer) acquires Account {
600
+ let account_resource = borrow_global_mut<Account>(signer::address_of(account));
601
+ option::extract(&mut account_resource.signer_capability_offer.for);
602
+ }
603
+
604
+ /// Return an authorized signer of the offerer, if there's an existing signer capability offer for `account`
605
+ /// at the offerer's address.
606
+ public fun create_authorized_signer(account: &signer, offerer_address: address): signer acquires Account {
607
+ assert!(exists_at(offerer_address), error::not_found(EOFFERER_ADDRESS_DOES_NOT_EXIST));
608
+
609
+ // Check if there's an existing signer capability offer from the offerer.
610
+ let account_resource = borrow_global<Account>(offerer_address);
611
+ let addr = signer::address_of(account);
612
+ assert!(
613
+ option::contains(&account_resource.signer_capability_offer.for, &addr),
614
+ error::not_found(ENO_SUCH_SIGNER_CAPABILITY)
615
+ );
616
+
617
+ create_signer(offerer_address)
618
+ }
619
+
620
+ ///////////////////////////////////////////////////////////////////////////
621
+ /// Helper functions for authentication key rotation.
622
+ ///////////////////////////////////////////////////////////////////////////
623
+ fun assert_valid_rotation_proof_signature_and_get_auth_key(
624
+ scheme: u8,
625
+ public_key_bytes: vector<u8>,
626
+ signature: vector<u8>,
627
+ challenge: &RotationProofChallenge
628
+ ): vector<u8> {
629
+ if (scheme == ED25519_SCHEME) {
630
+ let pk = ed25519::new_unvalidated_public_key_from_bytes(public_key_bytes);
631
+ let sig = ed25519::new_signature_from_bytes(signature);
632
+ assert!(
633
+ ed25519::signature_verify_strict_t(&sig, &pk, *challenge),
634
+ std::error::invalid_argument(EINVALID_PROOF_OF_KNOWLEDGE)
635
+ );
636
+ ed25519::unvalidated_public_key_to_authentication_key(&pk)
637
+ } else if (scheme == MULTI_ED25519_SCHEME) {
638
+ let pk = multi_ed25519::new_unvalidated_public_key_from_bytes(public_key_bytes);
639
+ let sig = multi_ed25519::new_signature_from_bytes(signature);
640
+ assert!(
641
+ multi_ed25519::signature_verify_strict_t(&sig, &pk, *challenge),
642
+ std::error::invalid_argument(EINVALID_PROOF_OF_KNOWLEDGE)
643
+ );
644
+ multi_ed25519::unvalidated_public_key_to_authentication_key(&pk)
645
+ } else {
646
+ abort error::invalid_argument(EINVALID_SCHEME)
647
+ }
648
+ }
649
+
650
+ /// Update the `OriginatingAddress` table, so that we can find the originating address using the latest address
651
+ /// in the event of key recovery.
652
+ fun update_auth_key_and_originating_address_table(
653
+ originating_addr: address,
654
+ account_resource: &mut Account,
655
+ new_auth_key_vector: vector<u8>,
656
+ ) acquires OriginatingAddress {
657
+ let address_map = &mut borrow_global_mut<OriginatingAddress>(@aptos_framework).address_map;
658
+ let curr_auth_key = from_bcs::to_address(account_resource.authentication_key);
659
+
660
+ // Checks `OriginatingAddress[curr_auth_key]` is either unmapped, or mapped to `originating_address`.
661
+ // If it's mapped to the originating address, removes that mapping.
662
+ // Otherwise, abort if it's mapped to a different address.
663
+ if (table::contains(address_map, curr_auth_key)) {
664
+ // If account_a with address_a is rotating its keypair from keypair_a to keypair_b, we expect
665
+ // the address of the account to stay the same, while its keypair updates to keypair_b.
666
+ // Here, by asserting that we're calling from the account with the originating address, we enforce
667
+ // the standard of keeping the same address and updating the keypair at the contract level.
668
+ // Without this assertion, the dapps could also update the account's address to address_b (the address that
669
+ // is programmatically related to keypaier_b) and update the keypair to keypair_b. This causes problems
670
+ // for interoperability because different dapps can implement this in different ways.
671
+ // If the account with address b calls this function with two valid signatures, it will abort at this step,
672
+ // because address b is not the account's originating address.
673
+ assert!(
674
+ originating_addr == table::remove(address_map, curr_auth_key),
675
+ error::not_found(EINVALID_ORIGINATING_ADDRESS)
676
+ );
677
+ };
678
+
679
+ // Set `OriginatingAddress[new_auth_key] = originating_address`.
680
+ let new_auth_key = from_bcs::to_address(new_auth_key_vector);
681
+ table::add(address_map, new_auth_key, originating_addr);
682
+
683
+ if (std::features::module_event_migration_enabled()) {
684
+ event::emit(KeyRotation {
685
+ account: originating_addr,
686
+ old_authentication_key: account_resource.authentication_key,
687
+ new_authentication_key: new_auth_key_vector,
688
+ });
689
+ };
690
+ event::emit_event<KeyRotationEvent>(
691
+ &mut account_resource.key_rotation_events,
692
+ KeyRotationEvent {
693
+ old_authentication_key: account_resource.authentication_key,
694
+ new_authentication_key: new_auth_key_vector,
695
+ }
696
+ );
697
+
698
+ // Update the account resource's authentication key.
699
+ account_resource.authentication_key = new_auth_key_vector;
700
+ }
701
+
702
+ ///////////////////////////////////////////////////////////////////////////
703
+ /// Basic account creation methods.
704
+ ///////////////////////////////////////////////////////////////////////////
705
+
706
+ /// This is a helper function to compute resource addresses. Computation of the address
707
+ /// involves the use of a cryptographic hash operation and should be use thoughtfully.
708
+ public fun create_resource_address(source: &address, seed: vector<u8>): address {
709
+ let bytes = bcs::to_bytes(source);
710
+ vector::append(&mut bytes, seed);
711
+ vector::push_back(&mut bytes, DERIVE_RESOURCE_ACCOUNT_SCHEME);
712
+ from_bcs::to_address(hash::sha3_256(bytes))
713
+ }
714
+
715
+ /// A resource account is used to manage resources independent of an account managed by a user.
716
+ /// In Aptos a resource account is created based upon the sha3 256 of the source's address and additional seed data.
717
+ /// A resource account can only be created once, this is designated by setting the
718
+ /// `Account::signer_capability_offer::for` to the address of the resource account. While an entity may call
719
+ /// `create_account` to attempt to claim an account ahead of the creation of a resource account, if found Aptos will
720
+ /// transition ownership of the account over to the resource account. This is done by validating that the account has
721
+ /// yet to execute any transactions and that the `Account::signer_capability_offer::for` is none. The probability of a
722
+ /// collision where someone has legitimately produced a private key that maps to a resource account address is less
723
+ /// than `(1/2)^(256)`.
724
+ public fun create_resource_account(source: &signer, seed: vector<u8>): (signer, SignerCapability) acquires Account {
725
+ let resource_addr = create_resource_address(&signer::address_of(source), seed);
726
+ let resource = if (exists_at(resource_addr)) {
727
+ let account = borrow_global<Account>(resource_addr);
728
+ assert!(
729
+ option::is_none(&account.signer_capability_offer.for),
730
+ error::already_exists(ERESOURCE_ACCCOUNT_EXISTS),
731
+ );
732
+ assert!(
733
+ account.sequence_number == 0,
734
+ error::invalid_state(EACCOUNT_ALREADY_USED),
735
+ );
736
+ create_signer(resource_addr)
737
+ } else {
738
+ create_account_unchecked(resource_addr)
739
+ };
740
+
741
+ // By default, only the SignerCapability should have control over the resource account and not the auth key.
742
+ // If the source account wants direct control via auth key, they would need to explicitly rotate the auth key
743
+ // of the resource account using the SignerCapability.
744
+ rotate_authentication_key_internal(&resource, ZERO_AUTH_KEY);
745
+
746
+ let account = borrow_global_mut<Account>(resource_addr);
747
+ account.signer_capability_offer.for = option::some(resource_addr);
748
+ let signer_cap = SignerCapability { account: resource_addr };
749
+ (resource, signer_cap)
750
+ }
751
+
752
+ /// create the account for system reserved addresses
753
+ public(friend) fun create_framework_reserved_account(addr: address): (signer, SignerCapability) {
754
+ assert!(
755
+ addr == @0x1 ||
756
+ addr == @0x2 ||
757
+ addr == @0x3 ||
758
+ addr == @0x4 ||
759
+ addr == @0x5 ||
760
+ addr == @0x6 ||
761
+ addr == @0x7 ||
762
+ addr == @0x8 ||
763
+ addr == @0x9 ||
764
+ addr == @0xa,
765
+ error::permission_denied(ENO_VALID_FRAMEWORK_RESERVED_ADDRESS),
766
+ );
767
+ let signer = create_account_unchecked(addr);
768
+ let signer_cap = SignerCapability { account: addr };
769
+ (signer, signer_cap)
770
+ }
771
+
772
+ ///////////////////////////////////////////////////////////////////////////
773
+ /// GUID management methods.
774
+ ///////////////////////////////////////////////////////////////////////////
775
+
776
+ public fun create_guid(account_signer: &signer): guid::GUID acquires Account {
777
+ let addr = signer::address_of(account_signer);
778
+ let account = borrow_global_mut<Account>(addr);
779
+ let guid = guid::create(addr, &mut account.guid_creation_num);
780
+ assert!(
781
+ account.guid_creation_num < MAX_GUID_CREATION_NUM,
782
+ error::out_of_range(EEXCEEDED_MAX_GUID_CREATION_NUM),
783
+ );
784
+ guid
785
+ }
786
+
787
+ ///////////////////////////////////////////////////////////////////////////
788
+ /// GUID management methods.
789
+ ///////////////////////////////////////////////////////////////////////////
790
+
791
+ public fun new_event_handle<T: drop + store>(account: &signer): EventHandle<T> acquires Account {
792
+ event::new_event_handle(create_guid(account))
793
+ }
794
+
795
+ ///////////////////////////////////////////////////////////////////////////
796
+ /// Coin management methods.
797
+ ///////////////////////////////////////////////////////////////////////////
798
+
799
+ public(friend) fun register_coin<CoinType>(account_addr: address) acquires Account {
800
+ let account = borrow_global_mut<Account>(account_addr);
801
+ event::emit_event<CoinRegisterEvent>(
802
+ &mut account.coin_register_events,
803
+ CoinRegisterEvent {
804
+ type_info: type_info::type_of<CoinType>(),
805
+ },
806
+ );
807
+ }
808
+
809
+ ///////////////////////////////////////////////////////////////////////////
810
+ // Test-only create signerCapabilityOfferProofChallengeV2 and return it
811
+ ///////////////////////////////////////////////////////////////////////////
812
+
813
+ #[test_only]
814
+ public fun get_signer_capability_offer_proof_challenge_v2(
815
+ source_address: address,
816
+ recipient_address: address,
817
+ ): SignerCapabilityOfferProofChallengeV2 acquires Account {
818
+ SignerCapabilityOfferProofChallengeV2 {
819
+ sequence_number: borrow_global_mut<Account>(source_address).sequence_number,
820
+ source_address,
821
+ recipient_address,
822
+ }
823
+ }
824
+
825
+ ///////////////////////////////////////////////////////////////////////////
826
+ /// Capability based functions for efficient use.
827
+ ///////////////////////////////////////////////////////////////////////////
828
+
829
+ public fun create_signer_with_capability(capability: &SignerCapability): signer {
830
+ let addr = &capability.account;
831
+ create_signer(*addr)
832
+ }
833
+
834
+ public fun get_signer_capability_address(capability: &SignerCapability): address {
835
+ capability.account
836
+ }
837
+
838
+ public fun verify_signed_message<T: drop>(
839
+ account: address,
840
+ account_scheme: u8,
841
+ account_public_key: vector<u8>,
842
+ signed_message_bytes: vector<u8>,
843
+ message: T,
844
+ ) acquires Account {
845
+ let account_resource = borrow_global_mut<Account>(account);
846
+ // Verify that the `SignerCapabilityOfferProofChallengeV2` has the right information and is signed by the account owner's key
847
+ if (account_scheme == ED25519_SCHEME) {
848
+ let pubkey = ed25519::new_unvalidated_public_key_from_bytes(account_public_key);
849
+ let expected_auth_key = ed25519::unvalidated_public_key_to_authentication_key(&pubkey);
850
+ assert!(
851
+ account_resource.authentication_key == expected_auth_key,
852
+ error::invalid_argument(EWRONG_CURRENT_PUBLIC_KEY),
853
+ );
854
+
855
+ let signer_capability_sig = ed25519::new_signature_from_bytes(signed_message_bytes);
856
+ assert!(
857
+ ed25519::signature_verify_strict_t(&signer_capability_sig, &pubkey, message),
858
+ error::invalid_argument(EINVALID_PROOF_OF_KNOWLEDGE),
859
+ );
860
+ } else if (account_scheme == MULTI_ED25519_SCHEME) {
861
+ let pubkey = multi_ed25519::new_unvalidated_public_key_from_bytes(account_public_key);
862
+ let expected_auth_key = multi_ed25519::unvalidated_public_key_to_authentication_key(&pubkey);
863
+ assert!(
864
+ account_resource.authentication_key == expected_auth_key,
865
+ error::invalid_argument(EWRONG_CURRENT_PUBLIC_KEY),
866
+ );
867
+
868
+ let signer_capability_sig = multi_ed25519::new_signature_from_bytes(signed_message_bytes);
869
+ assert!(
870
+ multi_ed25519::signature_verify_strict_t(&signer_capability_sig, &pubkey, message),
871
+ error::invalid_argument(EINVALID_PROOF_OF_KNOWLEDGE),
872
+ );
873
+ } else {
874
+ abort error::invalid_argument(EINVALID_SCHEME)
875
+ };
876
+ }
877
+
878
+ #[test_only]
879
+ public fun create_account_for_test(new_address: address): signer {
880
+ // Make this easier by just allowing the account to be created again in a test
881
+ if (!exists_at(new_address)) {
882
+ create_account_unchecked(new_address)
883
+ } else {
884
+ create_signer_for_test(new_address)
885
+ }
886
+ }
887
+
888
+ #[test]
889
+ /// Assert correct signer creation.
890
+ fun test_create_signer_for_test() {
891
+ assert!(signer::address_of(&create_signer_for_test(@aptos_framework)) == @0x1, 0);
892
+ assert!(signer::address_of(&create_signer_for_test(@0x123)) == @0x123, 0);
893
+ }
894
+
895
+ #[test(user = @0x1)]
896
+ public entry fun test_create_resource_account(user: signer) acquires Account {
897
+ let (resource_account, resource_account_cap) = create_resource_account(&user, x"01");
898
+ let resource_addr = signer::address_of(&resource_account);
899
+ assert!(resource_addr != signer::address_of(&user), 0);
900
+ assert!(resource_addr == get_signer_capability_address(&resource_account_cap), 1);
901
+ }
902
+
903
+ #[test]
904
+ #[expected_failure(abort_code = 0x10007, location = Self)]
905
+ public entry fun test_cannot_control_resource_account_via_auth_key() acquires Account {
906
+ let alice_pk = x"4141414141414141414141414141414141414141414141414141414141414145";
907
+ let alice = create_account_from_ed25519_public_key(alice_pk);
908
+ let alice_auth = get_authentication_key(signer::address_of(&alice)); // must look like a valid public key
909
+
910
+ let (eve_sk, eve_pk) = ed25519::generate_keys();
911
+ let eve_pk_bytes = ed25519::validated_public_key_to_bytes(&eve_pk);
912
+ let eve = create_account_from_ed25519_public_key(eve_pk_bytes);
913
+ let recipient_address = signer::address_of(&eve);
914
+
915
+ let seed = eve_pk_bytes; // multisig public key
916
+ vector::push_back(&mut seed, 1); // multisig threshold
917
+ vector::push_back(&mut seed, 1); // signature scheme id
918
+ let (resource, _) = create_resource_account(&alice, seed);
919
+
920
+ let resource_addr = signer::address_of(&resource);
921
+ let proof_challenge = SignerCapabilityOfferProofChallengeV2 {
922
+ sequence_number: borrow_global_mut<Account>(resource_addr).sequence_number,
923
+ source_address: resource_addr,
924
+ recipient_address,
925
+ };
926
+
927
+ let eve_sig = ed25519::sign_struct(&eve_sk, copy proof_challenge);
928
+
929
+ // Construct a malicious 1-out-of-2 multisig PK over Alice's authentication key and Eve's Ed25519 PK.
930
+ let account_public_key_bytes = alice_auth;
931
+ vector::append(&mut account_public_key_bytes, eve_pk_bytes);
932
+ vector::push_back(&mut account_public_key_bytes, 1); // Multisig verification threshold.
933
+ let fake_pk = multi_ed25519::new_unvalidated_public_key_from_bytes(account_public_key_bytes);
934
+
935
+ // Construct a multisig for `proof_challenge` as if it is signed by the signers behind `fake_pk`,
936
+ // Eve being the only participant.
937
+ let signer_capability_sig_bytes = x"";
938
+ vector::append(&mut signer_capability_sig_bytes, ed25519::signature_to_bytes(&eve_sig));
939
+ vector::append(&mut signer_capability_sig_bytes, x"40000000"); // Signers bitmap.
940
+ let fake_sig = multi_ed25519::new_signature_from_bytes(signer_capability_sig_bytes);
941
+
942
+ assert!(
943
+ multi_ed25519::signature_verify_strict_t(&fake_sig, &fake_pk, proof_challenge),
944
+ error::invalid_state(EINVALID_PROOF_OF_KNOWLEDGE)
945
+ );
946
+ offer_signer_capability(
947
+ &resource,
948
+ signer_capability_sig_bytes,
949
+ MULTI_ED25519_SCHEME,
950
+ account_public_key_bytes,
951
+ recipient_address
952
+ );
953
+ }
954
+
955
+ #[test_only]
956
+ struct DummyResource has key {}
957
+
958
+ #[test(user = @0x1)]
959
+ public entry fun test_module_capability(user: signer) acquires Account, DummyResource {
960
+ let (resource_account, signer_cap) = create_resource_account(&user, x"01");
961
+ assert!(signer::address_of(&resource_account) != signer::address_of(&user), 0);
962
+
963
+ let resource_account_from_cap = create_signer_with_capability(&signer_cap);
964
+ assert!(&resource_account == &resource_account_from_cap, 1);
965
+
966
+ move_to(&resource_account_from_cap, DummyResource {});
967
+ borrow_global<DummyResource>(signer::address_of(&resource_account));
968
+ }
969
+
970
+ #[test(user = @0x1)]
971
+ public entry fun test_resource_account_and_create_account(user: signer) acquires Account {
972
+ let resource_addr = create_resource_address(&@0x1, x"01");
973
+ create_account_unchecked(resource_addr);
974
+
975
+ create_resource_account(&user, x"01");
976
+ }
977
+
978
+ #[test(user = @0x1)]
979
+ #[expected_failure(abort_code = 0x8000f, location = Self)]
980
+ public entry fun test_duplice_create_resource_account(user: signer) acquires Account {
981
+ create_resource_account(&user, x"01");
982
+ create_resource_account(&user, x"01");
983
+ }
984
+
985
+ ///////////////////////////////////////////////////////////////////////////
986
+ // Test-only sequence number mocking for extant Account resource
987
+ ///////////////////////////////////////////////////////////////////////////
988
+
989
+ #[test_only]
990
+ /// Increment sequence number of account at address `addr`
991
+ public fun increment_sequence_number_for_test(
992
+ addr: address,
993
+ ) acquires Account {
994
+ let acct = borrow_global_mut<Account>(addr);
995
+ acct.sequence_number = acct.sequence_number + 1;
996
+ }
997
+
998
+ #[test_only]
999
+ /// Update address `addr` to have `s` as its sequence number
1000
+ public fun set_sequence_number(
1001
+ addr: address,
1002
+ s: u64
1003
+ ) acquires Account {
1004
+ borrow_global_mut<Account>(addr).sequence_number = s;
1005
+ }
1006
+
1007
+ #[test_only]
1008
+ public fun create_test_signer_cap(account: address): SignerCapability {
1009
+ SignerCapability { account }
1010
+ }
1011
+
1012
+ #[test_only]
1013
+ public fun set_signer_capability_offer(offerer: address, receiver: address) acquires Account {
1014
+ let account_resource = borrow_global_mut<Account>(offerer);
1015
+ option::swap_or_fill(&mut account_resource.signer_capability_offer.for, receiver);
1016
+ }
1017
+
1018
+ #[test_only]
1019
+ public fun set_rotation_capability_offer(offerer: address, receiver: address) acquires Account {
1020
+ let account_resource = borrow_global_mut<Account>(offerer);
1021
+ option::swap_or_fill(&mut account_resource.rotation_capability_offer.for, receiver);
1022
+ }
1023
+
1024
+ #[test]
1025
+ /// Verify test-only sequence number mocking
1026
+ public entry fun mock_sequence_numbers()
1027
+ acquires Account {
1028
+ let addr: address = @0x1234; // Define test address
1029
+ create_account(addr); // Initialize account resource
1030
+ // Assert sequence number intializes to 0
1031
+ assert!(borrow_global<Account>(addr).sequence_number == 0, 0);
1032
+ increment_sequence_number_for_test(addr); // Increment sequence number
1033
+ // Assert correct mock value post-increment
1034
+ assert!(borrow_global<Account>(addr).sequence_number == 1, 1);
1035
+ set_sequence_number(addr, 10); // Set mock sequence number
1036
+ // Assert correct mock value post-modification
1037
+ assert!(borrow_global<Account>(addr).sequence_number == 10, 2);
1038
+ }
1039
+
1040
+ ///////////////////////////////////////////////////////////////////////////
1041
+ // Test account helpers
1042
+ ///////////////////////////////////////////////////////////////////////////
1043
+
1044
+ #[test(alice = @0xa11ce)]
1045
+ #[expected_failure(abort_code = 65537, location = aptos_framework::ed25519)]
1046
+ public entry fun test_empty_public_key(alice: signer) acquires Account, OriginatingAddress {
1047
+ create_account(signer::address_of(&alice));
1048
+ let pk = vector::empty<u8>();
1049
+ let sig = x"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
1050
+ rotate_authentication_key(&alice, ED25519_SCHEME, pk, ED25519_SCHEME, pk, sig, sig);
1051
+ }
1052
+
1053
+ #[test(alice = @0xa11ce)]
1054
+ #[expected_failure(abort_code = 262151, location = Self)]
1055
+ public entry fun test_empty_signature(alice: signer) acquires Account, OriginatingAddress {
1056
+ create_account(signer::address_of(&alice));
1057
+ let test_signature = vector::empty<u8>();
1058
+ let pk = x"0000000000000000000000000000000000000000000000000000000000000000";
1059
+ rotate_authentication_key(&alice, ED25519_SCHEME, pk, ED25519_SCHEME, pk, test_signature, test_signature);
1060
+ }
1061
+
1062
+ #[test_only]
1063
+ public fun create_account_from_ed25519_public_key(pk_bytes: vector<u8>): signer {
1064
+ let pk = ed25519::new_unvalidated_public_key_from_bytes(pk_bytes);
1065
+ let curr_auth_key = ed25519::unvalidated_public_key_to_authentication_key(&pk);
1066
+ let alice_address = from_bcs::to_address(curr_auth_key);
1067
+ let alice = create_account_unchecked(alice_address);
1068
+ alice
1069
+ }
1070
+
1071
+ //
1072
+ // Tests for offering & revoking signer capabilities
1073
+ //
1074
+
1075
+ #[test(bob = @0x345)]
1076
+ #[expected_failure(abort_code = 65544, location = Self)]
1077
+ public entry fun test_invalid_offer_signer_capability(bob: signer) acquires Account {
1078
+ let (_alice_sk, alice_pk) = ed25519::generate_keys();
1079
+ let alice_pk_bytes = ed25519::validated_public_key_to_bytes(&alice_pk);
1080
+ let alice = create_account_from_ed25519_public_key(alice_pk_bytes);
1081
+ let alice_addr = signer::address_of(&alice);
1082
+
1083
+ let bob_addr = signer::address_of(&bob);
1084
+ create_account(bob_addr);
1085
+
1086
+ let challenge = SignerCapabilityOfferProofChallengeV2 {
1087
+ sequence_number: borrow_global<Account>(alice_addr).sequence_number,
1088
+ source_address: alice_addr,
1089
+ recipient_address: bob_addr,
1090
+ };
1091
+
1092
+ let sig = ed25519::sign_struct(&_alice_sk, challenge);
1093
+
1094
+ // Maul the signature and make sure the call would fail
1095
+ let invalid_signature = ed25519::signature_to_bytes(&sig);
1096
+ let first_sig_byte = vector::borrow_mut(&mut invalid_signature, 0);
1097
+ *first_sig_byte = *first_sig_byte ^ 1;
1098
+
1099
+ offer_signer_capability(&alice, invalid_signature, 0, alice_pk_bytes, bob_addr);
1100
+ }
1101
+
1102
+ #[test(bob = @0x345)]
1103
+ public entry fun test_valid_check_signer_capability_and_create_authorized_signer(bob: signer) acquires Account {
1104
+ let (alice_sk, alice_pk) = ed25519::generate_keys();
1105
+ let alice_pk_bytes = ed25519::validated_public_key_to_bytes(&alice_pk);
1106
+ let alice = create_account_from_ed25519_public_key(alice_pk_bytes);
1107
+ let alice_addr = signer::address_of(&alice);
1108
+
1109
+ let bob_addr = signer::address_of(&bob);
1110
+ create_account(bob_addr);
1111
+
1112
+ let challenge = SignerCapabilityOfferProofChallengeV2 {
1113
+ sequence_number: borrow_global<Account>(alice_addr).sequence_number,
1114
+ source_address: alice_addr,
1115
+ recipient_address: bob_addr,
1116
+ };
1117
+
1118
+ let alice_signer_capability_offer_sig = ed25519::sign_struct(&alice_sk, challenge);
1119
+
1120
+ offer_signer_capability(
1121
+ &alice,
1122
+ ed25519::signature_to_bytes(&alice_signer_capability_offer_sig),
1123
+ 0,
1124
+ alice_pk_bytes,
1125
+ bob_addr
1126
+ );
1127
+
1128
+ assert!(option::contains(&borrow_global<Account>(alice_addr).signer_capability_offer.for, &bob_addr), 0);
1129
+
1130
+ let signer = create_authorized_signer(&bob, alice_addr);
1131
+ assert!(signer::address_of(&signer) == signer::address_of(&alice), 0);
1132
+ }
1133
+
1134
+ #[test(bob = @0x345)]
1135
+ public entry fun test_get_signer_cap_and_is_signer_cap(bob: signer) acquires Account {
1136
+ let (alice_sk, alice_pk) = ed25519::generate_keys();
1137
+ let alice_pk_bytes = ed25519::validated_public_key_to_bytes(&alice_pk);
1138
+ let alice = create_account_from_ed25519_public_key(alice_pk_bytes);
1139
+ let alice_addr = signer::address_of(&alice);
1140
+
1141
+ let bob_addr = signer::address_of(&bob);
1142
+ create_account(bob_addr);
1143
+
1144
+ let challenge = SignerCapabilityOfferProofChallengeV2 {
1145
+ sequence_number: borrow_global<Account>(alice_addr).sequence_number,
1146
+ source_address: alice_addr,
1147
+ recipient_address: bob_addr,
1148
+ };
1149
+
1150
+ let alice_signer_capability_offer_sig = ed25519::sign_struct(&alice_sk, challenge);
1151
+
1152
+ offer_signer_capability(
1153
+ &alice,
1154
+ ed25519::signature_to_bytes(&alice_signer_capability_offer_sig),
1155
+ 0,
1156
+ alice_pk_bytes,
1157
+ bob_addr
1158
+ );
1159
+
1160
+ assert!(is_signer_capability_offered(alice_addr), 0);
1161
+ assert!(get_signer_capability_offer_for(alice_addr) == bob_addr, 0);
1162
+ }
1163
+
1164
+
1165
+ #[test(bob = @0x345, charlie = @0x567)]
1166
+ #[expected_failure(abort_code = 393230, location = Self)]
1167
+ public entry fun test_invalid_check_signer_capability_and_create_authorized_signer(
1168
+ bob: signer,
1169
+ charlie: signer
1170
+ ) acquires Account {
1171
+ let (alice_sk, alice_pk) = ed25519::generate_keys();
1172
+ let alice_pk_bytes = ed25519::validated_public_key_to_bytes(&alice_pk);
1173
+ let alice = create_account_from_ed25519_public_key(alice_pk_bytes);
1174
+ let alice_addr = signer::address_of(&alice);
1175
+
1176
+ let bob_addr = signer::address_of(&bob);
1177
+ create_account(bob_addr);
1178
+
1179
+ let challenge = SignerCapabilityOfferProofChallengeV2 {
1180
+ sequence_number: borrow_global<Account>(alice_addr).sequence_number,
1181
+ source_address: alice_addr,
1182
+ recipient_address: bob_addr,
1183
+ };
1184
+
1185
+ let alice_signer_capability_offer_sig = ed25519::sign_struct(&alice_sk, challenge);
1186
+
1187
+ offer_signer_capability(
1188
+ &alice,
1189
+ ed25519::signature_to_bytes(&alice_signer_capability_offer_sig),
1190
+ 0,
1191
+ alice_pk_bytes,
1192
+ bob_addr
1193
+ );
1194
+
1195
+ let alice_account_resource = borrow_global_mut<Account>(alice_addr);
1196
+ assert!(option::contains(&alice_account_resource.signer_capability_offer.for, &bob_addr), 0);
1197
+
1198
+ create_authorized_signer(&charlie, alice_addr);
1199
+ }
1200
+
1201
+ #[test(bob = @0x345)]
1202
+ public entry fun test_valid_revoke_signer_capability(bob: signer) acquires Account {
1203
+ let (alice_sk, alice_pk) = ed25519::generate_keys();
1204
+ let alice_pk_bytes = ed25519::validated_public_key_to_bytes(&alice_pk);
1205
+ let alice = create_account_from_ed25519_public_key(alice_pk_bytes);
1206
+ let alice_addr = signer::address_of(&alice);
1207
+
1208
+ let bob_addr = signer::address_of(&bob);
1209
+ create_account(bob_addr);
1210
+
1211
+ let challenge = SignerCapabilityOfferProofChallengeV2 {
1212
+ sequence_number: borrow_global<Account>(alice_addr).sequence_number,
1213
+ source_address: alice_addr,
1214
+ recipient_address: bob_addr,
1215
+ };
1216
+
1217
+ let alice_signer_capability_offer_sig = ed25519::sign_struct(&alice_sk, challenge);
1218
+
1219
+ offer_signer_capability(
1220
+ &alice,
1221
+ ed25519::signature_to_bytes(&alice_signer_capability_offer_sig),
1222
+ 0,
1223
+ alice_pk_bytes,
1224
+ bob_addr
1225
+ );
1226
+ revoke_signer_capability(&alice, bob_addr);
1227
+ }
1228
+
1229
+ #[test(bob = @0x345, charlie = @0x567)]
1230
+ #[expected_failure(abort_code = 393230, location = Self)]
1231
+ public entry fun test_invalid_revoke_signer_capability(bob: signer, charlie: signer) acquires Account {
1232
+ let (alice_sk, alice_pk) = ed25519::generate_keys();
1233
+ let alice_pk_bytes = ed25519::validated_public_key_to_bytes(&alice_pk);
1234
+ let alice = create_account_from_ed25519_public_key(alice_pk_bytes);
1235
+ let alice_addr = signer::address_of(&alice);
1236
+ let alice_account_resource = borrow_global<Account>(alice_addr);
1237
+
1238
+ let bob_addr = signer::address_of(&bob);
1239
+ create_account(bob_addr);
1240
+
1241
+ let charlie_addr = signer::address_of(&charlie);
1242
+ create_account(charlie_addr);
1243
+
1244
+ let challenge = SignerCapabilityOfferProofChallengeV2 {
1245
+ sequence_number: alice_account_resource.sequence_number,
1246
+ source_address: alice_addr,
1247
+ recipient_address: bob_addr,
1248
+ };
1249
+ let alice_signer_capability_offer_sig = ed25519::sign_struct(&alice_sk, challenge);
1250
+ offer_signer_capability(
1251
+ &alice,
1252
+ ed25519::signature_to_bytes(&alice_signer_capability_offer_sig),
1253
+ 0,
1254
+ alice_pk_bytes,
1255
+ bob_addr
1256
+ );
1257
+ revoke_signer_capability(&alice, charlie_addr);
1258
+ }
1259
+
1260
+ //
1261
+ // Tests for offering rotation capabilities
1262
+ //
1263
+ #[test(bob = @0x345, framework = @aptos_framework)]
1264
+ public entry fun test_valid_offer_rotation_capability(bob: signer, framework: signer) acquires Account {
1265
+ chain_id::initialize_for_test(&framework, 4);
1266
+ let (alice_sk, alice_pk) = ed25519::generate_keys();
1267
+ let alice_pk_bytes = ed25519::validated_public_key_to_bytes(&alice_pk);
1268
+ let alice = create_account_from_ed25519_public_key(alice_pk_bytes);
1269
+ let alice_addr = signer::address_of(&alice);
1270
+
1271
+ let bob_addr = signer::address_of(&bob);
1272
+ create_account(bob_addr);
1273
+
1274
+ let challenge = RotationCapabilityOfferProofChallengeV2 {
1275
+ chain_id: chain_id::get(),
1276
+ sequence_number: get_sequence_number(alice_addr),
1277
+ source_address: alice_addr,
1278
+ recipient_address: bob_addr,
1279
+ };
1280
+
1281
+ let alice_rotation_capability_offer_sig = ed25519::sign_struct(&alice_sk, challenge);
1282
+
1283
+ offer_rotation_capability(
1284
+ &alice,
1285
+ ed25519::signature_to_bytes(&alice_rotation_capability_offer_sig),
1286
+ 0,
1287
+ alice_pk_bytes,
1288
+ bob_addr
1289
+ );
1290
+
1291
+ let alice_resource = borrow_global_mut<Account>(signer::address_of(&alice));
1292
+ assert!(option::contains(&alice_resource.rotation_capability_offer.for, &bob_addr), 0);
1293
+ }
1294
+
1295
+ #[test(bob = @0x345, framework = @aptos_framework)]
1296
+ #[expected_failure(abort_code = 65544, location = Self)]
1297
+ public entry fun test_invalid_offer_rotation_capability(bob: signer, framework: signer) acquires Account {
1298
+ chain_id::initialize_for_test(&framework, 4);
1299
+ let (alice_sk, alice_pk) = ed25519::generate_keys();
1300
+ let alice_pk_bytes = ed25519::validated_public_key_to_bytes(&alice_pk);
1301
+ let alice = create_account_from_ed25519_public_key(alice_pk_bytes);
1302
+ let alice_addr = signer::address_of(&alice);
1303
+
1304
+ let bob_addr = signer::address_of(&bob);
1305
+ create_account(bob_addr);
1306
+
1307
+ let challenge = RotationCapabilityOfferProofChallengeV2 {
1308
+ chain_id: chain_id::get(),
1309
+ // Intentionally make the signature invalid.
1310
+ sequence_number: 2,
1311
+ source_address: alice_addr,
1312
+ recipient_address: bob_addr,
1313
+ };
1314
+
1315
+ let alice_rotation_capability_offer_sig = ed25519::sign_struct(&alice_sk, challenge);
1316
+
1317
+ offer_rotation_capability(
1318
+ &alice,
1319
+ ed25519::signature_to_bytes(&alice_rotation_capability_offer_sig),
1320
+ 0,
1321
+ alice_pk_bytes,
1322
+ signer::address_of(&bob)
1323
+ );
1324
+ }
1325
+
1326
+ #[test(bob = @0x345, framework = @aptos_framework)]
1327
+ public entry fun test_valid_revoke_rotation_capability(bob: signer, framework: signer) acquires Account {
1328
+ chain_id::initialize_for_test(&framework, 4);
1329
+ let (alice_sk, alice_pk) = ed25519::generate_keys();
1330
+ let alice_pk_bytes = ed25519::validated_public_key_to_bytes(&alice_pk);
1331
+ let alice = create_account_from_ed25519_public_key(alice_pk_bytes);
1332
+ let alice_addr = signer::address_of(&alice);
1333
+
1334
+ let bob_addr = signer::address_of(&bob);
1335
+ create_account(bob_addr);
1336
+
1337
+ let challenge = RotationCapabilityOfferProofChallengeV2 {
1338
+ chain_id: chain_id::get(),
1339
+ sequence_number: get_sequence_number(alice_addr),
1340
+ source_address: alice_addr,
1341
+ recipient_address: bob_addr,
1342
+ };
1343
+
1344
+ let alice_rotation_capability_offer_sig = ed25519::sign_struct(&alice_sk, challenge);
1345
+
1346
+ offer_rotation_capability(
1347
+ &alice,
1348
+ ed25519::signature_to_bytes(&alice_rotation_capability_offer_sig),
1349
+ 0,
1350
+ alice_pk_bytes,
1351
+ signer::address_of(&bob)
1352
+ );
1353
+ revoke_rotation_capability(&alice, signer::address_of(&bob));
1354
+ }
1355
+
1356
+ #[test(bob = @0x345, charlie = @0x567, framework = @aptos_framework)]
1357
+ #[expected_failure(abort_code = 393234, location = Self)]
1358
+ public entry fun test_invalid_revoke_rotation_capability(
1359
+ bob: signer,
1360
+ charlie: signer,
1361
+ framework: signer
1362
+ ) acquires Account {
1363
+ chain_id::initialize_for_test(&framework, 4);
1364
+ let (alice_sk, alice_pk) = ed25519::generate_keys();
1365
+ let alice_pk_bytes = ed25519::validated_public_key_to_bytes(&alice_pk);
1366
+ let alice = create_account_from_ed25519_public_key(alice_pk_bytes);
1367
+ let alice_addr = signer::address_of(&alice);
1368
+
1369
+ let bob_addr = signer::address_of(&bob);
1370
+ create_account(bob_addr);
1371
+ create_account(signer::address_of(&charlie));
1372
+
1373
+ let challenge = RotationCapabilityOfferProofChallengeV2 {
1374
+ chain_id: chain_id::get(),
1375
+ sequence_number: get_sequence_number(alice_addr),
1376
+ source_address: alice_addr,
1377
+ recipient_address: bob_addr,
1378
+ };
1379
+
1380
+ let alice_rotation_capability_offer_sig = ed25519::sign_struct(&alice_sk, challenge);
1381
+
1382
+ offer_rotation_capability(
1383
+ &alice,
1384
+ ed25519::signature_to_bytes(&alice_rotation_capability_offer_sig),
1385
+ 0,
1386
+ alice_pk_bytes,
1387
+ signer::address_of(&bob)
1388
+ );
1389
+ revoke_rotation_capability(&alice, signer::address_of(&charlie));
1390
+ }
1391
+
1392
+ //
1393
+ // Tests for key rotation
1394
+ //
1395
+
1396
+ #[test(account = @aptos_framework)]
1397
+ public entry fun test_valid_rotate_authentication_key_multi_ed25519_to_multi_ed25519(
1398
+ account: signer
1399
+ ) acquires Account, OriginatingAddress {
1400
+ initialize(&account);
1401
+ let (curr_sk, curr_pk) = multi_ed25519::generate_keys(2, 3);
1402
+ let curr_pk_unvalidated = multi_ed25519::public_key_to_unvalidated(&curr_pk);
1403
+ let curr_auth_key = multi_ed25519::unvalidated_public_key_to_authentication_key(&curr_pk_unvalidated);
1404
+ let alice_addr = from_bcs::to_address(curr_auth_key);
1405
+ let alice = create_account_unchecked(alice_addr);
1406
+
1407
+ let (new_sk, new_pk) = multi_ed25519::generate_keys(4, 5);
1408
+ let new_pk_unvalidated = multi_ed25519::public_key_to_unvalidated(&new_pk);
1409
+ let new_auth_key = multi_ed25519::unvalidated_public_key_to_authentication_key(&new_pk_unvalidated);
1410
+ let new_address = from_bcs::to_address(new_auth_key);
1411
+
1412
+ let challenge = RotationProofChallenge {
1413
+ sequence_number: borrow_global<Account>(alice_addr).sequence_number,
1414
+ originator: alice_addr,
1415
+ current_auth_key: alice_addr,
1416
+ new_public_key: multi_ed25519::unvalidated_public_key_to_bytes(&new_pk_unvalidated),
1417
+ };
1418
+
1419
+ let from_sig = multi_ed25519::sign_struct(&curr_sk, challenge);
1420
+ let to_sig = multi_ed25519::sign_struct(&new_sk, challenge);
1421
+
1422
+ rotate_authentication_key(
1423
+ &alice,
1424
+ MULTI_ED25519_SCHEME,
1425
+ multi_ed25519::unvalidated_public_key_to_bytes(&curr_pk_unvalidated),
1426
+ MULTI_ED25519_SCHEME,
1427
+ multi_ed25519::unvalidated_public_key_to_bytes(&new_pk_unvalidated),
1428
+ multi_ed25519::signature_to_bytes(&from_sig),
1429
+ multi_ed25519::signature_to_bytes(&to_sig),
1430
+ );
1431
+ let address_map = &mut borrow_global_mut<OriginatingAddress>(@aptos_framework).address_map;
1432
+ let expected_originating_address = table::borrow(address_map, new_address);
1433
+ assert!(*expected_originating_address == alice_addr, 0);
1434
+ assert!(borrow_global<Account>(alice_addr).authentication_key == new_auth_key, 0);
1435
+ }
1436
+
1437
+ #[test(account = @aptos_framework)]
1438
+ public entry fun test_valid_rotate_authentication_key_multi_ed25519_to_ed25519(
1439
+ account: signer
1440
+ ) acquires Account, OriginatingAddress {
1441
+ initialize(&account);
1442
+
1443
+ let (curr_sk, curr_pk) = multi_ed25519::generate_keys(2, 3);
1444
+ let curr_pk_unvalidated = multi_ed25519::public_key_to_unvalidated(&curr_pk);
1445
+ let curr_auth_key = multi_ed25519::unvalidated_public_key_to_authentication_key(&curr_pk_unvalidated);
1446
+ let alice_addr = from_bcs::to_address(curr_auth_key);
1447
+ let alice = create_account_unchecked(alice_addr);
1448
+
1449
+ let account_resource = borrow_global_mut<Account>(alice_addr);
1450
+
1451
+ let (new_sk, new_pk) = ed25519::generate_keys();
1452
+ let new_pk_unvalidated = ed25519::public_key_to_unvalidated(&new_pk);
1453
+ let new_auth_key = ed25519::unvalidated_public_key_to_authentication_key(&new_pk_unvalidated);
1454
+ let new_addr = from_bcs::to_address(new_auth_key);
1455
+
1456
+ let challenge = RotationProofChallenge {
1457
+ sequence_number: account_resource.sequence_number,
1458
+ originator: alice_addr,
1459
+ current_auth_key: alice_addr,
1460
+ new_public_key: ed25519::unvalidated_public_key_to_bytes(&new_pk_unvalidated),
1461
+ };
1462
+
1463
+ let from_sig = multi_ed25519::sign_struct(&curr_sk, challenge);
1464
+ let to_sig = ed25519::sign_struct(&new_sk, challenge);
1465
+
1466
+ rotate_authentication_key(
1467
+ &alice,
1468
+ MULTI_ED25519_SCHEME,
1469
+ multi_ed25519::unvalidated_public_key_to_bytes(&curr_pk_unvalidated),
1470
+ ED25519_SCHEME,
1471
+ ed25519::unvalidated_public_key_to_bytes(&new_pk_unvalidated),
1472
+ multi_ed25519::signature_to_bytes(&from_sig),
1473
+ ed25519::signature_to_bytes(&to_sig),
1474
+ );
1475
+
1476
+ let address_map = &mut borrow_global_mut<OriginatingAddress>(@aptos_framework).address_map;
1477
+ let expected_originating_address = table::borrow(address_map, new_addr);
1478
+ assert!(*expected_originating_address == alice_addr, 0);
1479
+ assert!(borrow_global<Account>(alice_addr).authentication_key == new_auth_key, 0);
1480
+ }
1481
+
1482
+
1483
+ #[test(account = @aptos_framework)]
1484
+ public entry fun test_simple_rotation(account: &signer) acquires Account {
1485
+ initialize(account);
1486
+
1487
+ let alice_addr = @0x1234;
1488
+ let alice = create_account_unchecked(alice_addr);
1489
+
1490
+ let (_new_sk, new_pk) = ed25519::generate_keys();
1491
+ let new_pk_unvalidated = ed25519::public_key_to_unvalidated(&new_pk);
1492
+ let new_auth_key = ed25519::unvalidated_public_key_to_authentication_key(&new_pk_unvalidated);
1493
+ let _new_addr = from_bcs::to_address(new_auth_key);
1494
+
1495
+ rotate_authentication_key_call(&alice, new_auth_key);
1496
+ assert!(borrow_global<Account>(alice_addr).authentication_key == new_auth_key, 0);
1497
+ }
1498
+
1499
+
1500
+ #[test(account = @aptos_framework)]
1501
+ #[expected_failure(abort_code = 0x20014, location = Self)]
1502
+ public entry fun test_max_guid(account: &signer) acquires Account {
1503
+ let addr = signer::address_of(account);
1504
+ create_account_unchecked(addr);
1505
+ let account_state = borrow_global_mut<Account>(addr);
1506
+ account_state.guid_creation_num = MAX_GUID_CREATION_NUM - 1;
1507
+ create_guid(account);
1508
+ }
1509
+
1510
+ #[test_only]
1511
+ struct FakeCoin {}
1512
+
1513
+ #[test_only]
1514
+ struct SadFakeCoin {}
1515
+
1516
+ #[test(account = @0x1234)]
1517
+ fun test_events(account: &signer) acquires Account {
1518
+ let addr = signer::address_of(account);
1519
+ create_account_unchecked(addr);
1520
+ register_coin<FakeCoin>(addr);
1521
+
1522
+ let eventhandle = &borrow_global<Account>(addr).coin_register_events;
1523
+ let event = CoinRegisterEvent { type_info: type_info::type_of<FakeCoin>() };
1524
+
1525
+ let events = event::emitted_events_by_handle(eventhandle);
1526
+ assert!(vector::length(&events) == 1, 0);
1527
+ assert!(vector::borrow(&events, 0) == &event, 1);
1528
+ assert!(event::was_event_emitted_by_handle(eventhandle, &event), 2);
1529
+
1530
+ let event = CoinRegisterEvent { type_info: type_info::type_of<SadFakeCoin>() };
1531
+ assert!(!event::was_event_emitted_by_handle(eventhandle, &event), 3);
1532
+ }
1533
+ }