@@ -1143,8 +1143,11 @@ is returned. This way, the caller of this function can publish additional resour
11431143
11441144## Function ` rotate_authentication_key_internal `
11451145
1146- This function is used to rotate a resource account's authentication key to 0, so that no private key can control
1147- the resource account.
1146+ This function is used to rotate a resource account's authentication key to <code >new_auth_key</code >. This is done in
1147+ many contexts:
1148+ 1 . During normal key rotation via <code >rotate_authentication_key</code > or <code >rotate_authentication_key_call</code >
1149+ 2 . During resource account initialization so that no private key can control the resource account
1150+ 3 . During multisig_v2 account creation
11481151
11491152
11501153<pre ><code ><b >public</b >(<b >friend</b >) <b >fun</b > <a href =" account.md#0x1_account_rotate_authentication_key_internal " >rotate_authentication_key_internal</a >(<a href =" account.md#0x1_account " >account</a >: &<a href =" ../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer " >signer</a >, new_auth_key: <a href =" ../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector " >vector</a >< ; u8> ; )
@@ -1176,7 +1179,11 @@ the resource account.
11761179
11771180## Function ` rotate_authentication_key_call `
11781181
1179- Entry function-only rotation key function that allows the signer update their authentication_key.
1182+ Private entry function for key rotation that allows the signer to update their authentication key.
1183+ Note that this does not update the <code ><a href =" account.md#0x1_account_OriginatingAddress " >OriginatingAddress</a ></code > table because the <code >new_auth_key</code > is not "verified": it
1184+ does not come with a proof-of-knowledge of the underlying SK. Nonetheless, we need this functionality due to
1185+ the introduction of non-standard key algorithms, such as passkeys, which cannot produce proofs-of-knowledge in
1186+ the format expected in <code >rotate_authentication_key</code >.
11801187
11811188
11821189<pre ><code >entry <b >fun</b > <a href =" account.md#0x1_account_rotate_authentication_key_call " >rotate_authentication_key_call</a >(<a href =" account.md#0x1_account " >account</a >: &<a href =" ../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer " >signer</a >, new_auth_key: <a href =" ../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector " >vector</a >< ; u8> ; )
@@ -1188,15 +1195,8 @@ Entry function-only rotation key function that allows the signer update their au
11881195<summary >Implementation</summary >
11891196
11901197
1191- <pre ><code >entry <b >fun</b > <a href =" account.md#0x1_account_rotate_authentication_key_call " >rotate_authentication_key_call</a >(<a href =" account.md#0x1_account " >account</a >: &<a href =" ../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer " >signer</a >, new_auth_key: <a href =" ../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector " >vector</a >< ; u8> ; ) <b >acquires</b > <a href =" account.md#0x1_account_Account " >Account</a >, <a href =" account.md#0x1_account_OriginatingAddress " >OriginatingAddress</a > {
1192- <b >let</b > addr = <a href =" ../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer_address_of " >signer::address_of</a >(<a href =" account.md#0x1_account " >account</a >);
1193- <b >assert</b >!(<a href =" account.md#0x1_account_exists_at " >exists_at</a >(addr), <a href =" ../../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error_not_found " >error::not_found</a >(<a href =" account.md#0x1_account_EACCOUNT_DOES_NOT_EXIST " >EACCOUNT_DOES_NOT_EXIST</a >));
1194- <b >assert</b >!(
1195- <a href =" ../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector_length " >vector::length</a >(&new_auth_key) == 32,
1196- <a href =" ../../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error_invalid_argument " >error::invalid_argument</a >(<a href =" account.md#0x1_account_EMALFORMED_AUTHENTICATION_KEY " >EMALFORMED_AUTHENTICATION_KEY</a >)
1197- );
1198- <b >let</b > account_resource = <b >borrow_global_mut</b >< ; <a href =" account.md#0x1_account_Account " >Account</a >> ; (addr);
1199- <a href =" account.md#0x1_account_update_auth_key_and_originating_address_table " >update_auth_key_and_originating_address_table</a >(addr, account_resource, new_auth_key);
1198+ <pre ><code >entry <b >fun</b > <a href =" account.md#0x1_account_rotate_authentication_key_call " >rotate_authentication_key_call</a >(<a href =" account.md#0x1_account " >account</a >: &<a href =" ../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer " >signer</a >, new_auth_key: <a href =" ../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector " >vector</a >< ; u8> ; ) <b >acquires</b > <a href =" account.md#0x1_account_Account " >Account</a > {
1199+ <a href =" account.md#0x1_account_rotate_authentication_key_internal " >rotate_authentication_key_internal</a >(<a href =" account.md#0x1_account " >account</a >, new_auth_key);
12001200}
12011201</code ></pre >
12021202
@@ -2526,29 +2526,15 @@ The length of new_auth_key is 32.
25262526</code ></pre >
25272527
25282528
2529- The Account existed under the signer before the call.
2530- The length of new_auth_key is 32.
25312529
25322530
25332531<pre ><code ><b >let</b > addr = <a href =" ../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer_address_of " >signer::address_of</a >(<a href =" account.md#0x1_account " >account</a >);
2532+ // This enforces <a id =" high-level-req-10 " href =" #high-level-req " >high-level requirement 10</a >:
2533+ <b >let</b > <b >post</b > account_resource = <b >global</b >< ; <a href =" account.md#0x1_account_Account " >Account</a >> ; (addr);
25342534<b >aborts_if</b > !<b >exists</b >< ; <a href =" account.md#0x1_account_Account " >Account</a >> ; (addr);
25352535<b >aborts_if</b > <a href =" ../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector_length " >vector::length</a >(new_auth_key) != 32;
2536- <b >let</b > account_resource = <b >global</b >< ; <a href =" account.md#0x1_account_Account " >Account</a >> ; (addr);
2537- <b >let</b > curr_auth_key = <a href =" ../../aptos-stdlib/doc/from_bcs.md#0x1_from_bcs_deserialize " >from_bcs::deserialize</a >< ; <b >address</b >> ; (account_resource.authentication_key);
2538- <b >let</b > originating_addr = addr;
2539- <b >let</b > address_map = <b >global</b >< ; <a href =" account.md#0x1_account_OriginatingAddress " >OriginatingAddress</a >> ; (@aptos_framework).address_map;
2540- <b >let</b > new_auth_key_addr = <a href =" ../../aptos-stdlib/doc/from_bcs.md#0x1_from_bcs_deserialize " >from_bcs::deserialize</a >< ; <b >address</b >> ; (new_auth_key);
2541- <b >aborts_if</b > !<b >exists</b >< ; <a href =" account.md#0x1_account_OriginatingAddress " >OriginatingAddress</a >> ; (@aptos_framework);
2542- <b >aborts_if</b > !<a href =" ../../aptos-stdlib/doc/from_bcs.md#0x1_from_bcs_deserializable " >from_bcs::deserializable</a >< ; <b >address</b >> ; (account_resource.authentication_key);
2543- <b >aborts_if</b > <a href =" ../../aptos-stdlib/doc/table.md#0x1_table_spec_contains " >table::spec_contains</a >(address_map, curr_auth_key) &&
2544- <a href =" ../../aptos-stdlib/doc/table.md#0x1_table_spec_get " >table::spec_get</a >(address_map, curr_auth_key) != originating_addr;
2545- <b >aborts_if</b > curr_auth_key != new_auth_key_addr && <a href =" ../../aptos-stdlib/doc/table.md#0x1_table_spec_contains " >table::spec_contains</a >(address_map, new_auth_key_addr);
2546- <b >include</b > <a href =" account.md#0x1_account_UpdateAuthKeyAndOriginatingAddressTableAbortsIf " >UpdateAuthKeyAndOriginatingAddressTableAbortsIf</a > {
2547- originating_addr: addr,
2548- new_auth_key_vector: new_auth_key,
2549- };
2550- <b >let</b > <b >post</b > auth_key = <b >global</b >< ; <a href =" account.md#0x1_account_Account " >Account</a >> ; (addr).authentication_key;
2551- <b >ensures</b > auth_key == new_auth_key;
2536+ <b >modifies</b > <b >global</b >< ; <a href =" account.md#0x1_account_Account " >Account</a >> ; (addr);
2537+ <b >ensures</b > account_resource.authentication_key == new_auth_key;
25522538</code ></pre >
25532539
25542540
0 commit comments