Skip to content

Commit aa7e3cd

Browse files
committed
fix paths
1 parent 598a300 commit aa7e3cd

File tree

7 files changed

+44
-33
lines changed

7 files changed

+44
-33
lines changed

docs/docs/developers/guides/smart_contracts/advanced/common_patterns.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ In this situation, try to mark the public function as `internal`. This ensures y
7575

7676
### Moving public data into the private domain
7777

78-
See [partial notes](../../../../aztec/concepts/advanced/storage/partial_notes.md). Partial notes are how public balances are transferred to private [in the NFT contract](../../../tutorials/codealong/contract_tutorials/nft_contract.md).
78+
See [partial notes](../../../../aztec/concepts/advanced/storage/partial_notes.md). Partial notes are how public balances are transferred to private [in the NFT contract](../../../tutorials/contract_tutorials/nft_contract.md).
7979

8080
### Discovering my notes
8181

@@ -110,7 +110,7 @@ Hence, it's necessary to add a "randomness" field to your note to prevent such a
110110

111111
### L1 -- L2 interactions
112112

113-
Refer to [Token Portal codealong tutorial on bridging tokens between L1 and L2](../../../tutorials/codealong/js_tutorials/token_bridge.md) and/or [Uniswap smart contract example that shows how to swap on L1 using funds on L2](../../../tutorials/codealong/js_tutorials/uniswap/index.md). Both examples show how to:
113+
Refer to [Token Portal codealong tutorial on bridging tokens between L1 and L2](../../../tutorials/js_tutorials/token_bridge.md) and/or [Uniswap smart contract example that shows how to swap on L1 using funds on L2](../../../tutorials/js_tutorials/uniswap/index.md). Both examples show how to:
114114

115115
1. L1 -> L2 message flow
116116
2. L2 -> L1 message flow
@@ -124,7 +124,7 @@ To send a note to someone, they need to have a key which we can encrypt the note
124124
There are several patterns here:
125125

126126
1. Give the contract a key and share it amongst all participants. This leaks privacy, as anyone can see all the notes in the contract.
127-
2. `transfer_to_public` funds into the contract - this is used in the [Uniswap smart contract example where a user sends private funds into a Uniswap Portal contract which eventually withdraws to L1 to swap on L1 Uniswap](../../../tutorials/codealong/js_tutorials/uniswap/index.md). This works like Ethereum - to achieve contract composability, you move funds into the public domain. This way the contract doesn't even need keys.
127+
2. `transfer_to_public` funds into the contract - this is used in the [Uniswap smart contract example where a user sends private funds into a Uniswap Portal contract which eventually withdraws to L1 to swap on L1 Uniswap](../../../tutorials/js_tutorials/uniswap/index.md). This works like Ethereum - to achieve contract composability, you move funds into the public domain. This way the contract doesn't even need keys.
128128

129129
There are several other designs we are discussing through [in this discourse post](https://discourse.aztec.network/t/how-to-handle-private-escrows-between-two-parties/2440) but they need some changes in the protocol or in our demo contract. If you are interested in this discussion, please participate in the discourse post!
130130

docs/docs/developers/guides/smart_contracts/cross_chain_communication.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Note that while the `secret` and the `content` are both hashed, they are actuall
9494

9595
### Token bridge example
9696

97-
Computing the `content` must currently be done manually, as we are still adding a number of bytes utilities. A good example exists within the [Token bridge example (codealong tutorial)](../../tutorials/codealong/js_tutorials/token_bridge.md).
97+
Computing the `content` must currently be done manually, as we are still adding a number of bytes utilities. A good example exists within the [Token bridge example (codealong tutorial)](../../tutorials/js_tutorials/token_bridge.md).
9898

9999
#include_code claim_public /noir-projects/noir-contracts/contracts/app/token_bridge_contract/src/main.nr rust
100100

@@ -239,4 +239,4 @@ Designated callers are enforced at the contract level for contracts that are not
239239

240240
## Further reading
241241

242-
Follow the [token bridge tutorial](../../tutorials/codealong/js_tutorials/token_bridge.md) for hands-on experience writing and deploying a Portal contract.
242+
Follow the [token bridge tutorial](../../tutorials/js_tutorials/token_bridge.md) for hands-on experience writing and deploying a Portal contract.

docs/docs/developers/guides/smart_contracts/define_functions.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,4 @@ You can set multiple functions as an initializer function simply by annotating e
6363

6464
Calling any one of the functions annotated with `#[initializer]` will mark the contract as initialized.
6565

66-
To see an initializer in action, follow the [Counter codealong tutorial](../../tutorials/codealong/contract_tutorials/counter_contract.md).
67-
68-
69-
## Further Reading
66+
To see an initializer in action, follow the [Counter codealong tutorial](../../tutorials/contract_tutorials/counter_contract.md).

docs/docs/developers/tutorials/contract_tutorials/counter_contract.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ SERVE=1 aztec flamegraph target/counter-Counter.json increment
163163

164164
Note the total gate count at the bottom of the image. The image is interactive; you can hover over different parts of the graph to see the full function name of the execution step and its gate count. This tool also provides insight into the low-level operations that are performed in the private function. Don't worry about the details of the internals of the function right now, just be aware that the more complex the function, the more gates it will use and try out the flamegraph tool on your own functions.
165165

166-
Read more about [profiling transactions with the flamegraph tool](../../../guides/smart_contracts/advanced/profiling_transactions.md).
166+
Read more about [profiling transactions with the flamegraph tool](../../guides/smart_contracts/advanced/profiling_transactions.md).
167167

168168
For more information about writing efficient private functions, see [this page](https://noir-lang.org/docs/explainers/explainer-writing-noir) of the Noir documentation.
169169

docs/docs/developers/tutorials/contract_tutorials/crowdfunding_contract.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ Follow the account contract tutorial on the [next page](./write_accounts_contrac
202202

203203
### Optional: Learn more about concepts mentioned here
204204

205-
- [Initializer functions](../../../guides/smart_contracts/define_functions.md#initializer-functions)
206-
- [Versions and Updating](../../../guides/local_env/sandbox.md#updating).
207-
- [Authorizing actions](../../../../aztec/concepts/advanced/authwit.md)
208-
- [Public logs](../../../guides/smart_contracts/how_to_emit_event.md)
205+
- [Initializer functions](../../guides/smart_contracts/define_functions.md#initializer-functions)
206+
- [Versions and Updating](../../guides/local_env/sandbox.md#updating).
207+
- [Authorizing actions](../../../aztec/concepts/advanced/authwit.md)
208+
- [Public logs](../../guides/smart_contracts/how_to_emit_event.md)

docs/docs/developers/tutorials/contract_tutorials/nft_contract.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ Below the dependencies, paste the following Storage struct:
174174

175175
## Custom Notes
176176

177-
The contract storage uses a [custom note](../../../guides/smart_contracts/note_types.md) implementation. Custom notes are useful for defining your own data types. You can think of a custom note as a "chunk" of private data, the entire thing is added, updated or nullified (deleted) together. This NFT note is very simple and stores only the owner and the `token_id` and uses `randomness` to hide its contents.
177+
The contract storage uses a [custom note](../../guides/smart_contracts/note_types.md) implementation. Custom notes are useful for defining your own data types. You can think of a custom note as a "chunk" of private data, the entire thing is added, updated or nullified (deleted) together. This NFT note is very simple and stores only the owner and the `token_id` and uses `randomness` to hide its contents.
178178

179179
Randomness is required because notes are stored as commitments (hashes) in the note hash tree. Without randomness, the contents of a note may be derived through brute force (e.g. without randomness, if you know my Aztec address, you may be able to figure out which note hash in the tree is mine by hashing my address with many potential `token_id`s).
180180

docs/versioned_docs/version-v1.2.0/developers/guides/smart_contracts/writing_contracts/common_patterns/index.md

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,45 @@ Similarly we have discovered some anti-patterns too (like privacy leakage) that
1717
We call this the "authentication witness" pattern or authwit for short.
1818

1919
- Approve someone in private domain:
20-
```typescript title="authwit_to_another_sc" showLineNumbers
20+
21+
```typescript title="authwit_to_another_sc" showLineNumbers
2122
// 4. Give approval to bridge to burn owner's funds:
2223
const withdrawAmount = 9n;
2324
const authwitNonce = Fr.random();
2425
const burnAuthwit = await user1Wallet.createAuthWit({
2526
caller: l2Bridge.address,
26-
action: l2Token.methods.burn_private(ownerAddress, withdrawAmount, authwitNonce),
27+
action: l2Token.methods.burn_private(
28+
ownerAddress,
29+
withdrawAmount,
30+
authwitNonce
31+
),
2732
});
2833
```
29-
> <sup><sub><a href="https://github.com/AztecProtocol/aztec-packages/blob/v1.2.0/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_private.test.ts#L71-L79" target="_blank" rel="noopener noreferrer">Source code: yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_private.test.ts#L71-L79</a></sub></sup>
3034

35+
> <sup><sub><a href="https://github.com/AztecProtocol/aztec-packages/blob/v1.2.0/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_private.test.ts#L71-L79" target="_blank" rel="noopener noreferrer">Source code: yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_private.test.ts#L71-L79</a></sub></sup>
3136
3237
Here you approve a contract to burn funds on your behalf.
3338

3439
- Approve in public domain:
35-
```typescript title="authwit_public_transfer_example" showLineNumbers
40+
41+
```typescript title="authwit_public_transfer_example" showLineNumbers
3642
const action = asset
3743
.withWallet(wallets[1])
38-
.methods.transfer_in_public(accounts[0].address, accounts[1].address, amount, authwitNonce);
44+
.methods.transfer_in_public(
45+
accounts[0].address,
46+
accounts[1].address,
47+
amount,
48+
authwitNonce
49+
);
3950

40-
const validateActionInteraction = await wallets[0].setPublicAuthWit({ caller: accounts[1].address, action }, true);
51+
const validateActionInteraction = await wallets[0].setPublicAuthWit(
52+
{ caller: accounts[1].address, action },
53+
true
54+
);
4155
await validateActionInteraction.send().wait();
4256
```
43-
> <sup><sub><a href="https://github.com/AztecProtocol/aztec-packages/blob/v1.2.0/yarn-project/end-to-end/src/e2e_token_contract/transfer_in_public.test.ts#L69-L76" target="_blank" rel="noopener noreferrer">Source code: yarn-project/end-to-end/src/e2e_token_contract/transfer_in_public.test.ts#L69-L76</a></sub></sup>
4457

58+
> <sup><sub><a href="https://github.com/AztecProtocol/aztec-packages/blob/v1.2.0/yarn-project/end-to-end/src/e2e_token_contract/transfer_in_public.test.ts#L69-L76" target="_blank" rel="noopener noreferrer">Source code: yarn-project/end-to-end/src/e2e_token_contract/transfer_in_public.test.ts#L69-L76</a></sub></sup>
4559
4660
Here you approve someone to transfer funds publicly on your behalf
4761

@@ -51,7 +65,7 @@ E.g. you don't want a user to subscribe once they have subscribed already. Or yo
5165

5266
Emit a nullifier in your function. By adding this nullifier into the tree, you prevent another nullifier from being added again. This is also why in authwit, we emit a nullifier, to prevent someone from reusing their approval.
5367

54-
```rust title="verify_private_authwit" showLineNumbers
68+
```rust title="verify_private_authwit" showLineNumbers
5569
pub fn verify_private_authwit(self, inner_hash: Field) -> Field {
5670
// The `inner_hash` is "siloed" with the `msg_sender` to ensure that only it can
5771
// consume the message.
@@ -67,8 +81,8 @@ pub fn verify_private_authwit(self, inner_hash: Field) -> Field {
6781
IS_VALID_SELECTOR
6882
}
6983
```
70-
> <sup><sub><a href="https://github.com/AztecProtocol/aztec-packages/blob/v1.2.0/noir-projects/aztec-nr/aztec/src/authwit/account.nr#L72-L87" target="_blank" rel="noopener noreferrer">Source code: noir-projects/aztec-nr/aztec/src/authwit/account.nr#L72-L87</a></sub></sup>
7184

85+
> <sup><sub><a href="https://github.com/AztecProtocol/aztec-packages/blob/v1.2.0/noir-projects/aztec-nr/aztec/src/authwit/account.nr#L72-L87" target="_blank" rel="noopener noreferrer">Source code: noir-projects/aztec-nr/aztec/src/authwit/account.nr#L72-L87</a></sub></sup>
7286
7387
Note be careful to ensure that the nullifier is not deterministic and that no one could do a preimage analysis attack. More in [the anti pattern section on deterministic nullifiers](#deterministic-nullifiers)
7488

@@ -124,7 +138,7 @@ When you send someone a note, the note hash gets added to the note hash tree. To
124138
1. When sending someone a note, emit the note log to the recipient (the function encrypts the log in such a way that only a recipient can decrypt it). PXE then tries to decrypt all the encrypted logs, and stores the successfully decrypted one. [More info here](../how_to_emit_event.md)
125139
2. Manually delivering it via a custom contract method, if you choose to not emit logs to save gas or when creating a note in the public domain and want to consume it in private domain (`encrypt_and_emit_note` shouldn't be called in the public domain because everything is public), like in the previous section where we created a note in public that doesn't have a designated owner.
126140

127-
```typescript title="offchain_delivery" showLineNumbers
141+
```typescript title="offchain_delivery" showLineNumbers
128142
const txEffects = await pxe.getTxEffect(txHash);
129143
await contract.methods
130144
.deliver_transparent_note(
@@ -134,16 +148,16 @@ await contract.methods
134148
txHash.hash,
135149
txEffects!.data.noteHashes,
136150
txEffects!.data.nullifiers[0],
137-
recipient,
151+
recipient
138152
)
139153
.simulate();
140154
```
141-
> <sup><sub><a href="https://github.com/AztecProtocol/aztec-packages/blob/v1.2.0/yarn-project/end-to-end/src/composed/e2e_persistence.test.ts#L358-L371" target="_blank" rel="noopener noreferrer">Source code: yarn-project/end-to-end/src/composed/e2e_persistence.test.ts#L358-L371</a></sub></sup>
142155

156+
> <sup><sub><a href="https://github.com/AztecProtocol/aztec-packages/blob/v1.2.0/yarn-project/end-to-end/src/composed/e2e_persistence.test.ts#L358-L371" target="_blank" rel="noopener noreferrer">Source code: yarn-project/end-to-end/src/composed/e2e_persistence.test.ts#L358-L371</a></sub></sup>
143157
144158
Note that this requires your contract to have a utility function that processes these notes and adds them to PXE.
145159

146-
```rust title="deliver_note_contract_method" showLineNumbers
160+
```rust title="deliver_note_contract_method" showLineNumbers
147161
// We cannot replace this function with the standard `process_message` function because the transparent note
148162
// originates in public and hence we cannot emit it as an offchain message. We could construct the offchain message
149163
// "manually" and then pass it to the `process_message` function, but this doesn't seem to be worth the effort
@@ -159,8 +173,8 @@ unconstrained fn deliver_transparent_note(
159173
recipient: AztecAddress,
160174
) {
161175
```
162-
> <sup><sub><a href="https://github.com/AztecProtocol/aztec-packages/blob/v1.2.0/noir-projects/noir-contracts/contracts/app/token_blacklist_contract/src/main.nr#L301-L316" target="_blank" rel="noopener noreferrer">Source code: noir-projects/noir-contracts/contracts/app/token_blacklist_contract/src/main.nr#L301-L316</a></sub></sup>
163176

177+
> <sup><sub><a href="https://github.com/AztecProtocol/aztec-packages/blob/v1.2.0/noir-projects/noir-contracts/contracts/app/token_blacklist_contract/src/main.nr#L301-L316" target="_blank" rel="noopener noreferrer">Source code: noir-projects/noir-contracts/contracts/app/token_blacklist_contract/src/main.nr#L301-L316</a></sub></sup>
164178
165179
### Revealing encrypted logs conditionally
166180

@@ -178,7 +192,7 @@ Notes are hashed and stored in the merkle tree. While notes do have a header wit
178192

179193
Hence, it's necessary to add a "randomness" field to your note to prevent such attacks.
180194

181-
```rust title="address_note_def" showLineNumbers
195+
```rust title="address_note_def" showLineNumbers
182196
#[note]
183197
#[derive(Eq)]
184198
pub struct AddressNote {
@@ -198,8 +212,8 @@ impl AddressNote {
198212
}
199213
}
200214
```
201-
> <sup><sub><a href="https://github.com/AztecProtocol/aztec-packages/blob/v1.2.0/noir-projects/aztec-nr/address-note/src/address_note.nr#L5-L24" target="_blank" rel="noopener noreferrer">Source code: noir-projects/aztec-nr/address-note/src/address_note.nr#L5-L24</a></sub></sup>
202215

216+
> <sup><sub><a href="https://github.com/AztecProtocol/aztec-packages/blob/v1.2.0/noir-projects/aztec-nr/address-note/src/address_note.nr#L5-L24" target="_blank" rel="noopener noreferrer">Source code: noir-projects/aztec-nr/address-note/src/address_note.nr#L5-L24</a></sub></sup>
203217
204218
### L1 -- L2 interactions
205219

@@ -243,7 +257,7 @@ E.g. for a voting contract, if your nullifier simply emits just the `user_addres
243257

244258
Here is an example from the voting contract:
245259

246-
```rust title="cast_vote" showLineNumbers
260+
```rust title="cast_vote" showLineNumbers
247261
#[private]
248262
// annotation to mark function as private and expose private context
249263
fn cast_vote(candidate: Field) {
@@ -257,5 +271,5 @@ fn cast_vote(candidate: Field) {
257271
);
258272
}
259273
```
260-
> <sup><sub><a href="https://github.com/AztecProtocol/aztec-packages/blob/v1.2.0/noir-projects/noir-contracts/contracts/app/easy_private_voting_contract/src/main.nr#L38-L51" target="_blank" rel="noopener noreferrer">Source code: noir-projects/noir-contracts/contracts/app/easy_private_voting_contract/src/main.nr#L38-L51</a></sub></sup>
261274

275+
> <sup><sub><a href="https://github.com/AztecProtocol/aztec-packages/blob/v1.2.0/noir-projects/noir-contracts/contracts/app/easy_private_voting_contract/src/main.nr#L38-L51" target="_blank" rel="noopener noreferrer">Source code: noir-projects/noir-contracts/contracts/app/easy_private_voting_contract/src/main.nr#L38-L51</a></sub></sup>

0 commit comments

Comments
 (0)