@@ -550,6 +550,8 @@ module type Controller_intf = sig
550550 val check : proof_verifies :bool -> signature_verifies :bool -> t -> bool
551551
552552 val verification_key_perm_fallback_to_signature_with_older_version : t -> t
553+
554+ val access_perm_fallback_to_signature_with_older_version : t -> t
553555end
554556
555557module type Txn_version_intf = sig
@@ -1546,11 +1548,19 @@ module Make (Inputs : Inputs_intf) = struct
15461548 This must be done before updating zkApp fields!
15471549 *)
15481550 let a = Account. make_zkapp a in
1551+ let auth_with_fallback ~fallback_logic auth =
1552+ Account.Permissions. set_verification_key_txn_version a
1553+ |> Txn_version. older_than_current
1554+ |> Controller. if_ ~then_: (fallback_logic auth) ~else_: auth
1555+ in
15491556 (* Check that the account can be accessed with the given authorization. *)
15501557 let local_state =
15511558 let has_permission =
1552- Controller. check ~proof_verifies ~signature_verifies
1553- (Account.Permissions. access a)
1559+ Account.Permissions. access a
1560+ |> auth_with_fallback
1561+ ~fallback_logic:
1562+ Controller. access_perm_fallback_to_signature_with_older_version
1563+ |> Controller. check ~proof_verifies ~signature_verifies
15541564 in
15551565 Local_state. add_check local_state Update_not_permitted_access
15561566 has_permission
@@ -1614,21 +1624,13 @@ module Make (Inputs : Inputs_intf) = struct
16141624 let verification_key =
16151625 Account_update.Update. verification_key account_update
16161626 in
1617- let older_than_current_version =
1618- Txn_version. older_than_current
1619- (Account.Permissions. set_verification_key_txn_version a)
1620- in
1621- let original_auth = Account.Permissions. set_verification_key_auth a in
1622- let auth =
1623- Controller. if_ older_than_current_version
1624- ~then_:
1625- (Controller
1626- .verification_key_perm_fallback_to_signature_with_older_version
1627- original_auth )
1628- ~else_: original_auth
1629- in
16301627 let has_permission =
1631- Controller. check ~proof_verifies ~signature_verifies auth
1628+ Account.Permissions. set_verification_key_auth a
1629+ |> auth_with_fallback
1630+ ~fallback_logic:
1631+ Controller
1632+ .verification_key_perm_fallback_to_signature_with_older_version
1633+ |> Controller. check ~proof_verifies ~signature_verifies
16321634 in
16331635 let local_state =
16341636 Local_state. add_check local_state Update_not_permitted_verification_key
0 commit comments