-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This pr alters how we are using the public authwits. Namely it will update where they are stored AND how they are consumed. Instead of storing them in every account contract, they are now stored in a shared public auth registry. The registry essentially keep track of a large map, that maps `account => action => authorized`. When allowing something with a public authwit, the `authorized` is set to `true` and when consuming, the value is set to `false`. The reasoning behind the change is fairly simple. If it was required to authorize an authwit in the non-revertible phase of a transaction (say for fees) it needed to execute code on the account contract. Since this phase as phase don't support reverts while still paying a fee, it allowed for a DOS of the sequencer by inserting very computational tasks into your account contract. When it is now in a common registry, the sequencer will only need to execute enqueued public calls to this registry, which is much easier to verify since it is the same for all accounts and have little flexibility for extra logic. In the old model, we were emitting a nullifier when the authwit was "consumed" (public or private did not matter here). This change is instead updating the mapping to ensure that there are no duplicate nullifiers, and to support for "squashing" of public authwits. For example if you are inserting the authwit because you need to use it in the same transaction it can be removed again adding no state diff, this reduces the data overhead by 96 bytes for this case, at the cost of increasing by 32 bytes if the approval happens in a separate transaction. While we have solved the DOS issue that our old design had, it also take away some of the flexibility that we had. Before you could have that certain accounts where allowed to more flexible things on your behalf by having extra logic for it, and also allow mass revoking. To support the mass revoking case, the registry includes a `reject_all` map, that is keeping a flag for each account whether to reject authwits or not. This allows a user that have made approvals to pages that have not yet been spent to update this one flag, revoking all of his approvals at once. Ideally there should not be a lot of outstanding authwits, as they should be created on demand, but for applications such as request-for-quote DEXes, there might be authwits created that are unspent. API wise, there should be no big surprises for consuming authwits in your contracts. The `auth` library have received a slight update to call into the registry instead of the account contracts. Also there are some helper functions for adding the authwits from contracts. The `AccountWallet` have been extended slightly to address the logic better and now have a more clear distinction for what is public.
- Loading branch information
Showing
46 changed files
with
669 additions
and
494 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
noir-projects/noir-contracts/contracts/auth_registry_contract/Nargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "auth_registry_contract" | ||
authors = [""] | ||
compiler_version = ">=0.25.0" | ||
type = "contract" | ||
|
||
[dependencies] | ||
aztec = { path = "../../../aztec-nr/aztec" } | ||
authwit = { path = "../../../aztec-nr/authwit" } |
Oops, something went wrong.