What happens to runtime when the code contains conditional branches? #505
-
Consider a program that branches K different ways depending on the input data, then has to do something different for each contingency that costs about G. A regular processor, crucially, would run this program in G steps. I'm guessing that Risc0 would do it in K*G steps, because the conditional branching would tell us something about the data, so to keep the inputs secret, every branch would have to be run? And that seems important? But this doesn't seem to be mentioned anywhere in the documentation or past discussion of performance? (Is it actually not very important? Are most decentralized computations quite linear?) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
This is a great question! The zkVM runs guest programs the same as any other CPU. In particular, it does not attempt to follow all possible code paths. At the end of execution, the ZK proof does not precisely tell you the number of cycles that ran. Instead, it rounds up to the next power of 2. This rounding is a side effect of the STARK construction. This side channel is likely to be removed in the future. |
Beta Was this translation helpful? Give feedback.
This is a great question!
The zkVM runs guest programs the same as any other CPU. In particular, it does not attempt to follow all possible code paths.
At the end of execution, the ZK proof does not precisely tell you the number of cycles that ran. Instead, it rounds up to the next power of 2. This rounding is a side effect of the STARK construction.
This side channel is likely to be removed in the future.