You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please provide a paragraph or two giving a summary of the change,
including relevant motivation and context.
# Checklist:
Remove the checklist to signal you've completed it. Enable auto-merge if
the PR is ready to merge.
- [ ] If the pull request requires a cryptography review (e.g.
cryptographic algorithm implementations) I have added the 'crypto' tag.
- [ ] I have reviewed my diff in github, line by line and removed
unexpected formatting changes, testing logs, or commented-out code.
- [ ] Every change is related to the PR description.
- [ ] I have
[linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
this pull request to relevant issues (if any exist).
This is a draft. These requirements need to be considered by the wider team, and might change significantly before a mainnet release.
5
+
:::
6
+
7
+
## Overview
8
+
9
+
A transaction begins with a call to a private function, which may invoke nested calls to other private and public functions. The entire set of private function calls is executed in a secure environment, and their proofs are validated and aggregated by private kernel circuits. Meanwhile, any public function calls triggered from private functions will be enqueued. The proofs for these calls, along with those from the nested public function calls, are generated and processed through public kernel circuits in any entity possessing the correct contexts.
10
+
11
+
Once all functions in a transaction are executed, the accumulated data is outputted from a tail circuit. These values are then inserted or updated to the trees within the base rollup circuit. The merge rollup circuit facilitates the merging of two rollup proofs. Repeating this merging process enables the inclusion of more transactions in a block. Finally, the root rollup circuit produces the final proof, which is subsequently submitted and validated onchain.
12
+
13
+
To illustrate, consider a transaction involving the following functions, where circles depict private functions, and squares denote public functions:
14
+
15
+
```mermaid
16
+
flowchart LR
17
+
f0([f0]) --> f1([f1])
18
+
f0 --> f2([f2])
19
+
f0 --> f3([f3])
20
+
f1 -.-> F0
21
+
F0 --> F1
22
+
F0 --> F2
23
+
F2 --> F3
24
+
f3 --> f4([f4])
25
+
f3 -.-> F4
26
+
f3 --> f5([f5])
27
+
```
28
+
29
+
This transaction contains 6 private functions (f0 to f5) and 5 public functions (F0 to F4), with `f0` being the entrypoint. The entire transaction is processed as follows:
30
+
31
+
```mermaid
32
+
flowchart TB
33
+
subgraph Transaction A
34
+
subgraph Private Functions
35
+
f0([f0])
36
+
f1([f1])
37
+
f2([f2])
38
+
f3([f3])
39
+
f4([f4])
40
+
f5([f5])
41
+
end
42
+
subgraph Public Functions
43
+
F0
44
+
F1
45
+
F2
46
+
F3
47
+
F4
48
+
end
49
+
end
50
+
subgraph Transaction C
51
+
init2(...)
52
+
tail2(Tail Private Kernel)
53
+
init2 -.-> tail2
54
+
end
55
+
subgraph Transaction B
56
+
init1(...)
57
+
tail1(Tail Private Kernel)
58
+
init1 -.-> tail1
59
+
end
60
+
subgraph Public Kernel
61
+
INIT0(Initial Public Kernel)
62
+
INNER0(Inner Public Kernel)
63
+
INNER1(Inner Public Kernel)
64
+
INNER2(Inner Public Kernel)
65
+
INNER3(Inner Public Kernel)
66
+
TAIL0(Tail Public Kernel)
67
+
INIT0 --> INNER0
68
+
INNER0 --> INNER1
69
+
INNER1 --> INNER2
70
+
INNER2 --> INNER3
71
+
INNER3 --> TAIL0
72
+
end
73
+
subgraph Private Kernel
74
+
init0(Initial Private Kernel)
75
+
inner0(Inner Private Kernel)
76
+
inner1(Inner Private Kernel)
77
+
inner2(Inner Private Kernel)
78
+
reset0(Reset Private Kernel)
79
+
inner3(Inner Private Kernel)
80
+
inner4(Inner Private Kernel)
81
+
reset1(Reset Private Kernel)
82
+
tail0(Tail Private Kernel)
83
+
init0 --> inner0
84
+
inner0 --> inner1
85
+
inner1 --> inner2
86
+
inner2 --> reset0
87
+
reset0 --> inner3
88
+
inner3 --> inner4
89
+
inner4 --> reset1
90
+
reset1 --> tail0
91
+
end
92
+
f0 --> init0
93
+
f1 --> inner0
94
+
f2 --> inner1
95
+
f3 --> inner2
96
+
f4 --> inner3
97
+
f5 --> inner4
98
+
F0 --> INIT0
99
+
F1 --> INNER0
100
+
F2 --> INNER1
101
+
F3 --> INNER2
102
+
F4 --> INNER3
103
+
subgraph Rollup
104
+
BR0(Base Rollup)
105
+
BR1(Base Rollup)
106
+
BR2(Base Rollup)
107
+
BR3(Base Rollup)
108
+
MR0(Merge Rollup)
109
+
MR1(Merge Rollup)
110
+
MR2(Merge Rollup)
111
+
MR3(Merge Rollup)
112
+
ROOT(Root Rollup)
113
+
end
114
+
tail0 --> INIT0
115
+
TAIL0 --> BR0
116
+
tail1 --> BR1
117
+
tail2 --> BR2
118
+
BR0 --> MR0
119
+
BR1 --> MR0
120
+
BR2 --> MR1
121
+
BR3 --> MR1
122
+
MR0 --> MR2
123
+
MR1 --> MR2
124
+
MR2 --> ROOT
125
+
MR3 --> ROOT
126
+
```
127
+
128
+
A few things to note:
129
+
130
+
- A transaction always starts with an [initial private kernel circuit](./private-kernel-initial.md).
131
+
- An [inner private kernel circuit](./private-kernel-inner.md) won't be required if there is only one private function in a transaction.
132
+
- A [reset private kernel circuit](./private-kernel-reset.md) can be executed between two private kernel circuits to "reset" transient data. The reset process can be repeated as needed.
133
+
- Public functions are "enqueued" when invoked from a private function. Public kernel circuits will be executed after the completion of all private kernel iterations.
134
+
- A [base rollup circuit](../rollup-circuits/base_rollup.md) can accept either a [tail public kernel circuit](./public-kernel-tail.md), or a [tail private kernel circuit](./private-kernel-tail.md) in cases where no public functions are present in the transaction.
135
+
- A [merge rollup circuit](../rollup-circuits/merge_rollup.md) can merge two base rollup circuits or two merge rollup circuits.
136
+
- The final step is the execution of the [root rollup circuit](../rollup-circuits/root_rollup.md), which combines two base rollup circuits or two merge rollup circuits.
Copy file name to clipboardexpand all lines: yellow-paper/docs/circuits/private-function.md
+65-24
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,9 @@ This is a draft. These requirements need to be considered by the wider team, and
6
6
7
7
## Requirements
8
8
9
-
A private function circuit is a custom circuit tailored to the needs of a specific application. This circuit should be designed to handle private data processing while generating public inputs that safeguard the application and account's intentions without compromising sensitive information.
9
+
Private function circuits represent smart contract functions that modify the Aztec private state trees. They serve as untrusted, third-party code that is executed as part of evaluating an Aztec transaction.
10
10
11
-
The logic of this circuit is flexible, yet its public inputs must adhere to a specific format.
11
+
The logic of each private function circuit is tailored to the needs of a particular application or scenario, yet its public inputs must adhere to a specific format. This circuit should be designed to handle private data processing while generating public inputs that safeguard the application and account's intentions without compromising sensitive information.
12
12
13
13
## Private Inputs
14
14
@@ -18,28 +18,69 @@ The private inputs of a private function circuit are customizable.
18
18
19
19
The public inputs of a private function circuit will be incorporated into the private inputs of a private kernel circuit. Private kernel circuits leverage these public inputs, coupled with proof data and verification key from a private function circuit, to prove the correct execution of a private function.
0 commit comments