Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docs): Applying structure feedback + adding nodes docs #10976

Merged
merged 62 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
9c6c3e1
initial restructure, broken
catmcgee Dec 30, 2024
eb30ea7
scripts
catmcgee Dec 31, 2024
978dc5d
sidebars
catmcgee Dec 31, 2024
4b490bb
some links
catmcgee Jan 2, 2025
674b776
concepts rearranging
catmcgee Jan 8, 2025
cdc1fec
fix build
catmcgee Jan 8, 2025
6098351
Merge branch 'master' into docs/restructure-feedback
catmcgee Jan 8, 2025
d347638
node docs drqafts
catmcgee Jan 9, 2025
6bcafcc
tidied up
catmcgee Jan 10, 2025
23e9868
governance and upgrades docs
catmcgee Jan 10, 2025
5015d04
tyo
catmcgee Jan 14, 2025
308fbe7
Merge remote-tracking branch 'origin' into docs/restructure-feedback
catmcgee Jan 14, 2025
05642b7
bb
catmcgee Jan 14, 2025
70fbcba
bb
catmcgee Jan 14, 2025
60558f7
bb
catmcgee Jan 14, 2025
dff94a9
broken links
catmcgee Jan 14, 2025
b8bc309
prover docs
catmcgee Jan 14, 2025
371f58c
Merge branch 'master' into docs/restructure-feedback
catmcgee Jan 14, 2025
c05d1b5
upgrades
catmcgee Jan 16, 2025
e78f17a
added aztec strqter
catmcgee Jan 16, 2025
19b5f58
broken links
catmcgee Jan 16, 2025
865108c
Merge branch 'master' into docs/restructure-feedback
catmcgee Jan 16, 2025
5a2024f
redirects
catmcgee Jan 16, 2025
b381605
merge
catmcgee Jan 16, 2025
f0b8c90
oops
catmcgee Jan 16, 2025
d6a88e8
Merge branch 'master' into docs/restructure-feedback
catmcgee Jan 16, 2025
947b942
delete unnecessary index page
catmcgee Jan 16, 2025
294a2b8
build
catmcgee Jan 17, 2025
9849ded
Merge remote-tracking branch 'origin/master' into docs/restructure-fe…
catmcgee Jan 17, 2025
a84275f
links
catmcgee Jan 17, 2025
a20f348
title
catmcgee Jan 17, 2025
2e21362
some final touches
catmcgee Jan 17, 2025
fdd1fab
feedback
catmcgee Jan 23, 2025
93dcf0c
feedback
catmcgee Feb 3, 2025
8af9988
pedro suggestions
catmcgee Feb 3, 2025
3a5d9a4
sequencer concept docs are drafts
catmcgee Feb 3, 2025
cadb097
conflicts
catmcgee Feb 3, 2025
f13dbaf
bb
catmcgee Feb 3, 2025
6b50ded
bb
catmcgee Feb 3, 2025
a97ebbb
bb
catmcgee Feb 3, 2025
e068808
paclagejson
catmcgee Feb 3, 2025
9c96ce6
yarnlock
catmcgee Feb 4, 2025
ead0d23
setting soe things as drafts
catmcgee Feb 4, 2025
061a1ba
broken links
catmcgee Feb 4, 2025
d93fe61
Merge branch 'master' into docs/restructure-feedback
catmcgee Feb 4, 2025
bfefcb1
Merge branch 'master' into docs/restructure-feedback
catmcgee Feb 4, 2025
152d9a3
remove network concepts (per amin, outdated)
catmcgee Feb 4, 2025
a8eb27f
remove references to network docs
catmcgee Feb 4, 2025
3f14bb8
pls build
catmcgee Feb 4, 2025
096e1cb
Merge branch 'master' into docs/restructure-feedback
catmcgee Feb 4, 2025
c5e4cdc
monorepo links
catmcgee Feb 4, 2025
e1fa087
Merge branch 'master' into docs/restructure-feedback
catmcgee Feb 4, 2025
019a009
Merge branch 'master' into docs/restructure-feedback
catmcgee Feb 4, 2025
ffb268b
bbg
catmcgee Feb 5, 2025
d2f1a79
bb
catmcgee Feb 5, 2025
a55717c
josh suggestison
catmcgee Feb 5, 2025
5b47f05
mistek
catmcgee Feb 5, 2025
4e77e2e
fix build
critesjosh Feb 5, 2025
3d5d9cc
Merge branch 'master' into docs/restructure-feedback
critesjosh Feb 5, 2025
9bf540f
remove comments from docusaursu config
catmcgee Feb 5, 2025
a6f1624
Merge branch 'master' into docs/restructure-feedback
catmcgee Feb 5, 2025
43d4c29
Merge remote-tracking branch 'origin' into docs/restructure-feedback
catmcgee Feb 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
catmcgee marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ struct MultiTable {
init_step_sizes();
}

MultiTable(){};
MultiTable() {};
MultiTable(const MultiTable& other) = default;
MultiTable(MultiTable&& other) = default;

Expand Down
4 changes: 2 additions & 2 deletions docs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*

/docs/reference/developer_references/aztecjs
/docs/reference/developer_references/smart_contract_reference/aztec-nr
/docs/developers/reference/aztecjs
/docs/developers/reference/smart_contract_reference/aztec-nr
test-results
12 changes: 6 additions & 6 deletions docs/HOW_WE_WRITE_DOCS.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# How we write docs

This doc covers the structure and tone of Aztec developer documentation. For the contribution guidelines, go [here](./CONTRIBUTING.md). Please keep in mind that this is constantly changing.
This doc covers the structure and tone of Aztec developer documentation. For the contribution guidelines, go [here](./CONTRIBUTING.md). Please keep in mind that this is constantly changing.

## Structure

### High level

Aztec docs are divided into two main sections - `Learn` and `Build`.
Aztec docs are divided into two main sections - `Learn` and `Build`.

Anyone technical can read the `Learn` section, whereas only developers who are actively building or starting to build on Aztec will read the `Build` section.

Expand All @@ -16,7 +16,7 @@ The `Build` section contains information that only developers need to know - thi

### Types of pages

The Aztec docs roughly follow the [Diataxis](https://diataxis.fr/) framework. It is recommended to read this website before contributing to the docs.
The Aztec docs roughly follow the [Diataxis](https://diataxis.fr/) framework. It is recommended to read this website before contributing to the docs.

Every page will fall into **one type of doc**. If your contribution covers multiple types, you will need to split it into multiple pages.

Expand All @@ -39,8 +39,8 @@ These are docs that developers can consult to know exact and succinct informatio
## Tone

* Concise and informative - for example, rather than repeating information, write "to learn more, read ..."
* Friendly and empathetic - for example, "you do not have to worry about this yet"
* Simple and jardon-avoidant when possible
* Friendly and empathetic - for example, "you do not have to worry about this yet"
* Simple and jardon-avoidant when possible
* Short sentences
* Unopinionated language - we know things are exciting sometimes, but try not to tell the developer what they should be excited about

Expand Down Expand Up @@ -85,4 +85,4 @@ The Aztec docs use a sidebar - https://docusaurus.io/docs/sidebar/items

## Indexing and Search

Typesense docs search - https://typesense.org/
Algolia docs search - https://docusaurus.io/docs/search#algolia-index-configuration
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "Common Errors",
"position": 5,
"label": "Accounts",
"position": 2,
"collapsible": true,
"collapsed": true
}
6 changes: 3 additions & 3 deletions docs/docs/aztec/concepts/accounts/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def entryPoint(payload):
enqueueCall(to, data, value, gasLimit);
```

Read more about how to write an account contract [here](../../../tutorials/codealong/contract_tutorials/write_accounts_contract.md).
Read more about how to write an account contract [here](../../../developers/tutorials/codealong/contract_tutorials/write_accounts_contract.md).

### Account contracts and wallets

Expand Down Expand Up @@ -135,7 +135,7 @@ However, during a public function execution, it is not possible to retrieve a va

These two patterns combined allow an account contract to answer whether an action `is_valid_impl` for a given user both in private and public contexts.

You can read more about authorizing actions with authorization witnesses on [this page](./authwit.md).
You can read more about authorizing actions with authorization witnesses on [this page](../advanced/authwit.md).

:::info

Expand All @@ -147,7 +147,7 @@ Transaction simulations in the PXE are not currently simulated, this is future w

Aztec requires users to define [encryption and nullifying keys](./keys.md) that are needed for receiving and spending private notes. Unlike transaction signing, encryption and nullifying is enshrined at the protocol. This means that there is a single scheme used for encryption and nullifying. These keys are derived from a master public key. This master public key, in turn, is used when deterministically deriving the account's address.

A side effect of committing to a master public key as part of the address is that _this key cannot be rotated_. While an account contract implementation could include methods for rotating the signing key, this is unfortunately not possible for encryption and nullifying keys (note that rotating nullifying keys also creates other challenges such as preventing double spends). We are exploring usage of [`SharedMutable`](../../../reference/developer_references/smart_contract_reference/storage/shared_state.md#sharedmutable) to enable rotating these keys.
A side effect of committing to a master public key as part of the address is that _this key cannot be rotated_. While an account contract implementation could include methods for rotating the signing key, this is unfortunately not possible for encryption and nullifying keys (note that rotating nullifying keys also creates other challenges such as preventing double spends). We are exploring usage of [`SharedMutable`](../../../developers/reference/smart_contract_reference/storage/shared_state.md) to enable rotating these keys.

NOTE: While we entertained the idea of abstracting note encryption, where account contracts would define an `encrypt` method that would use a user-defined scheme, there are two main reasons we decided against this. First is that this entailed that, in order to receive funds, a user had to first deploy their account contract, which is a major UX issue. Second, users could define malicious `encrypt` methods that failed in certain circumstances, breaking application flows that required them to receive a private note. While this issue already exists in Ethereum when transferring ETH (see the [king of the hill](https://coinsbench.com/27-king-ethernaut-da5021cd4aa6)), its impact is made worse in Aztec since any execution failure in a private function makes the entire transaction unprovable (ie it is not possible to catch errors in calls to other private functions), and furthermore because encryption is required for any private state (not just for transferring ETH). Nevertheless, both of these problems are solvable. Initialization can be worked around by embedding a commitment to the bytecode in the address and removing the need for actually deploying contracts before interacting with them, and the king of the hill issue can be mitigated by introducing a full private VM that allows catching reverts. As such, we may be able to abstract encryption in the future as well.

Expand Down
4 changes: 2 additions & 2 deletions docs/docs/aztec/concepts/accounts/keys.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ When it comes to storing the signing key in a private note, there are several de

#### Using Shared Mutable state

By [Shared Mutable](../../../reference/developer_references/smart_contract_reference/storage/shared_state#sharedmutable) we mean privately readable publicly mutable state.
By [Shared Mutable](../../../developers/reference/smart_contract_reference/storage/shared_state.md#sharedmutable) we mean privately readable publicly mutable state.

To make public state accessible privately, there is a delay window in public state updates. One needs this window to be able to generate proofs client-side. This approach would not generate additional nullifiers and commitments for each transaction while allowing the user to rotate their key. However, this causes every transaction to now have a time-to-live determined by the frequency of the mutable shared state, as well as imposing restrictions on how fast keys can be rotated due to minimum delays.

Expand Down Expand Up @@ -123,7 +123,7 @@ App-siloed keys allow to minimize damage of potential key leaks as a leak of the

App-siloed keys are derived from the corresponding master keys and the contract address. For example, for the app-siloed nullifier secret key: `nsk_app = hash(nsk_m, app_contract_address)`.

App-siloed keys [are derived](../storage/storage_slots#implementation/index.md) in PXE every time the user interacts with the application.
App-siloed keys [are derived](../advanced/storage/storage_slots.md#implementation) in PXE every time the user interacts with the application.

App-siloed incoming viewing key also allows per-application auditability. A user may choose to disclose this key for a given application to an auditor or regulator (or for 3rd party interfaces, e.g. giving access to a block explorer to display my activity), as a means to reveal all their activity within that context, while retaining privacy across all other applications in the network.

Expand Down
catmcgee marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Authentication Witness (Authwit)
tags: [accounts, authwit]
importance: 1
sidebar_position: 2
keywords: [authwit, authentication witness, accounts]
---

Expand Down Expand Up @@ -42,9 +42,9 @@ All of these issues have been discussed in the community for a while, and there

Adopting ERC20 for Aztec is not as simple as it might seem because of private state.

If you recall from the [Hybrid State model](../storage/state_model/index.md), private state is generally only known by its owner and those they have shared it with. Because it relies on secrets, private state might be "owned" by a contract, but it needs someone with knowledge of these secrets to actually spend it. You might see where this is going.
If you recall from the [Hybrid State model](../storage/state_model.md), private state is generally only known by its owner and those they have shared it with. Because it relies on secrets, private state might be "owned" by a contract, but it needs someone with knowledge of these secrets to actually spend it. You might see where this is going.

If we were to implement the `approve` with an allowance in private, you might know the allowance, but unless you also know about the individual notes that make up the user's balances, it would be of no use to you! It is private after all. To spend the user's funds you would need to know the decryption key, see [keys for more](./keys.md).
If we were to implement the `approve` with an allowance in private, you might know the allowance, but unless you also know about the individual notes that make up the user's balances, it would be of no use to you! It is private after all. To spend the user's funds you would need to know the decryption key, see [keys for more](../accounts/keys.md).

While this might sound limiting in what we can actually do, the main use of approvals have been for simplifying contract interactions that the user is doing. In the case of private transactions, this is executed on the user device, so it is not a blocker that the user need to tell the executor a secret - the user is the executor!

Expand Down Expand Up @@ -140,4 +140,4 @@ We don't need to limit ourselves to the `transfer` function, we can use the same

### Next Steps

Check out the [developer documentation](../../../guides/developer_guides/smart_contracts/writing_contracts/authwit.md) to see how to implement this in your own contracts.
Check out the [developer documentation](../../../developers/guides/smart_contracts/writing_contracts/authwit.md) to see how to implement this in your own contracts.
6 changes: 6 additions & 0 deletions docs/docs/aztec/concepts/advanced/circuits/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"label": "Circuits",
"position": 3,
"collapsible": true,
"collapsed": true
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Circuits
sidebar_position: 7
sidebar_position: 2
tags: [protocol, circuits]
---

Expand Down Expand Up @@ -53,7 +53,7 @@ In other words, since neither the EVM nor other rollups have rules for how to pr

What kind of extra rules / checks does a rollup need, to enforce notions of private states and private functions? Stuff like:

- "Perform state reads and writes using new tree structures which prevent tx linkability" (see [trees](../storage/trees/index.md)).
- "Perform state reads and writes using new tree structures which prevent tx linkability" (see [indexed merkle tree](../storage/indexed_merkle_tree.mdx).
- "Hide which function was just executed, by wrapping it in a zk-snark"
- "Hide all functions which were executed as part of this tx's stack trace, by wrapping the whole tx in a zk-snark"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"label": "Smart Contract Examples",
"label": "Kernel Circuits",
"position": 0,
"collapsible": true,
"collapsed": true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: Public Kernel Circuit
tags: [protocol, circuits]
---

This circuit is executed by a Sequencer, since only a Sequencer knows the current state of the [public data tree](../../../storage/state_model.md#public-state) at any time. A Sequencer might choose to delegate proof generation to the Prover pool.
12 changes: 12 additions & 0 deletions docs/docs/aztec/concepts/advanced/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: Advanced Concepts
sidebar_position: 7
tags: [protocol]
---

In this section, you'll learn about the more advanced concepts of the Aztec Network. It is not required to understand these in order to start building on Aztec.

import DocCardList from '@theme/DocCardList';

<DocCardList />

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"label": "Aztec",
"label": "Advanced Storage Concepts",
"position": 1,
"collapsible": true,
"collapsed": true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
title: Indexed Merkle Tree
title: Indexed Merkle Tree (Nullifier Tree)
tags: [storage, concepts, advanced]
sidebar_position: 2
---

import Image from "@theme/IdealImage";
Expand Down Expand Up @@ -48,7 +50,7 @@ Data is stored at the leaf index corresponding to its value. E.g. if I have a sp

## Problems introduced by using Sparse Merkle Trees for Nullifier Trees

While sparse Merkle Trees offer a simple and elegant solution, their implementation comes with some drawbacks. A sparse nullifier tree must have an index for $e \in \mathbb{F}_p$, which for the bn254 curve means that the sparse tree will need to have a depth of 254.
While sparse Merkle Trees offer a simple and elegant solution, their implementation comes with some drawbacks. A sparse nullifier tree must have an index for $e \in \mathbb{F}_p$, which for the bn254 curve means that the sparse tree will need to have a depth of 254.
If you're familiar with hashing in circuits the alarm bells have probably started ringing. A tree of depth 254 means 254 hashes per membership proof.
In routine nullifier insertions, a non membership check for a value is performed, then an insertion of said value. This amounts to two trips from leaf to root, hashing all the way up. This means that there are $254*2$ hashes per tree insertion. As the tree is sparse, insertions are random and must be performed in sequence. This means the number of hashes performed in the circuit scales linearly with the number of nullifiers being inserted. As a consequence number of constraints in a rollup circuit (where these checks are performed) will sky rocket, leading to long rollup proving times.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Partial Notes
description: Describes how partial notes are used in Aztec
tags: [notes, storage]
sidebar_position: 3
---

Partial notes are a concept that allows users to commit to an encrypted value, and allows a counterparty to update that value without knowing the specific details of the encrypted value.
Expand Down Expand Up @@ -138,7 +139,7 @@ This is implemented by applying the `partial_note` attribute:

#include_code UintNote noir-projects/aztec-nr/uint-note/src/uint_note.nr rust

Those `G_x` are generators that generated [here](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/noir-projects/aztec-nr/aztec/src/generators.nr). Anyone can use them for separating different fields in a "partial note".
Those `G_x` are generators that generated [here](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/noir-projects/noir-projects/aztec-nr/aztec/src/generators.nr). Anyone can use them for separating different fields in a "partial note".

We can see the complete implementation of creating and completing partial notes in an Aztec contract in the `setup_refund` and `complete_refund` functions.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
---
title: Storage Slots
tags: [storage, concepts, advanced]
sidebar_position: 1
---

# Storage Slots

## Public State Slots

As mentioned in [State Model](../storage/state_model/index.md), Aztec public state behaves similarly to public state on Ethereum from the point of view of the developer. Behind the scenes however, the storage is managed differently. As mentioned, public state has just one large sparse tree in Aztec - so we silo slots of public data by hashing it together with its contract address.
As mentioned in [State Model](../../storage/state_model.md), Aztec public state behaves similarly to public state on Ethereum from the point of view of the developer. Behind the scenes however, the storage is managed differently. As mentioned, public state has just one large sparse tree in Aztec - so we silo slots of public data by hashing it together with its contract address.

The mental model is that we have a key-value store, where the siloed slot is the key, and the value is the data stored in that slot. You can think of the `real_storage_slot` identifying its position in the tree, and the `logical_storage_slot` identifying the position in the contract storage.

```rust
real_storage_slot = H(contract_address, logical_storage_slot)
```

The siloing is performed by the [Kernel circuits](../circuits/index.md).
The siloing is performed by the [Kernel circuits](../circuits/kernels/private_kernel.md).

For structs and arrays, we are logically using a similar storage slot computation to ethereum, e.g., as a struct with 3 fields would be stored in 3 consecutive slots. However, because the "actual" storage slot is computed as a hash of the contract address and the logical storage slot, the actual storage slot is not consecutive.

## Private State Slots

Private storage is a different beast. As you might remember from [Hybrid State Model](../storage/state_model/index.md), private state is stored in encrypted logs and the corresponding private state commitments in append-only tree, called the note hash tree where each leaf is a commitment. Append-only means that leaves are never updated or deleted; instead a nullifier is emitted to signify that some note is no longer valid. A major reason we used this tree, is that updates at a specific storage slot would leak information in the context of private state, even if the value is encrypted. That is not good privacy.
Private storage is a different beast. As you might remember from [Hybrid State Model](../../storage/state_model.md), private state is stored in encrypted logs and the corresponding private state commitments in append-only tree, called the note hash tree where each leaf is a commitment. Append-only means that leaves are never updated or deleted; instead a nullifier is emitted to signify that some note is no longer valid. A major reason we used this tree, is that updates at a specific storage slot would leak information in the context of private state, even if the value is encrypted. That is not good privacy.

Following this, the storage slot as we know it doesn't really exist. The leaves of the note hashes tree are just commitments to content (think of it as a hash of its content).

Expand Down Expand Up @@ -52,4 +57,4 @@ By doing this address-siloing at the kernel circuit we _force_ the inserted comm
To ensure that nullifiers don't collide across contracts we also force this contract siloing at the kernel level.
:::

For an example of this see [developer documentation on storage](../../../reference/developer_references/smart_contract_reference/storage/index.md).
For an example of this see [developer documentation on storage](../../../../developers/reference/smart_contract_reference/storage/index.md).
6 changes: 0 additions & 6 deletions docs/docs/aztec/concepts/circuits/kernels/public_kernel.md

This file was deleted.

Loading
Loading