feat: implement program hash integrity constraints for continuations - #373
feat: implement program hash integrity constraints for continuations#373avorylli wants to merge 5 commits into
Conversation
aszepieniec
left a comment
There was a problem hiding this comment.
Thanks for the contribution.
The instructions pick and place, which were introduced after this note was written, likewise have the capacity to disturb the program hash. So they should be included also in swap_indicator.
$(n - 21)$ is positive when$n > 21$ (stack is deep enough to protect program hash)
I'm afraid I don't see how the factor
I do see how the factor max(0, 21-n) achieves this purpose, but then the question is how to represent max as an arithmetic circuit of low degree.
|
|
||
| Let $n$ be the current opstack size and let $i$ be the target index. The constraint is: | ||
|
|
||
| $$\text{stack\_manip\_indicator} \cdot (21 - n) \cdot \text{indicator}_{i \geq 11} = 0$$ |
There was a problem hiding this comment.
I'm afraid this constraint is not complete. Counterexample: the instruction is swap 15 when
| The indicator function $\text{indicator}_{n \leq 21}$ can be implemented as an arithmetic circuit of low degree using the fact that $n$ is bounded by the maximum stack size. Specifically, we can use the constraint: | ||
|
|
||
| $$\text{indicator}_{n \leq 21} = \prod_{k=22}^{n_{max}} (n - k)$$ |
There was a problem hiding this comment.
I think it is correct now, but you've introduced another drawback: the maximum stack size is actually
|
made it simpler, if you don't like it, then I could probably think of something else to improve the variant before |
|
Frankly, I don't think protecting the program's hash digest against modification is necessary. In my mind, the entire program is executed by one entity. There is never any “execution handover”; for example, it is not possible to execute a different program as a subroutine of some sort (other than straight up incorporating that other program, then executing it, which means that it's not a different program). Summarizing, with the threat model we're currently working with, I don't see additional protection we gain by disallowing write access to the program's hash digest. In case I misunderstand your, @avorylli, intentions, would you mind opening an issue? There might be other possible solutions to discuss before deciding on a strategy to implement them. |
|
This PR attempts to fill in details in TIP-0008, which proposes a construction for continuations. In that context, there is a notion of handover of execution control between separate entities -- these entities each prove separate chunks of the long-running computation. So we do need to protect the program digest. |
|
Oh, I see! I hadn't realized this was about continuations. Thanks for clarifying. |
Add mathematical constraints to prevent program hash overwriting via swap instructions when opstack size ≤ 21.
swap_indicator · (n - 21) · indicator_{i≥11} = 0