Abdel on Nostr: So in this case you would need a way to prove that the computation was done ...
So in this case you would need a way to prove that the computation was done correctly. A hash is not the correct way to think about it, since a hash is about integrity of data but not integrity of computation.
What you need to generate is a Zero Knowledge Proof, there are many different type of proofs (SNARKs, STARKs, and many variants in each family etc).
You have multiple approaches to prove a computation. either you build specific circuits / AIR for the computation you prove, or you are able to prove a higher level language, where you use a VM that is provable, and then you dont have to write custom circuits for each computation.
This is the approach i am proposing here. Basically you can write your computation in Cairo language, which is a language that enable you to build provable program.
So in your example the flow would like this:
- write a program in Cairo that performs the sum and return the result
- run the program with the Cairo VM to generate the execution trace (something needed to generate the proof)
- run a prover (like STWO) to generate the STARK proof
- then on the client side you verify the proof instead of re doing the computation yourself
Of course on small programs like this example it does not really make sense because you would just do a naive re execution and compare the result. But on complex programs it makes sense because the verification is exponentially faster and cheaper as the program complexity grows.
What you need to generate is a Zero Knowledge Proof, there are many different type of proofs (SNARKs, STARKs, and many variants in each family etc).
You have multiple approaches to prove a computation. either you build specific circuits / AIR for the computation you prove, or you are able to prove a higher level language, where you use a VM that is provable, and then you dont have to write custom circuits for each computation.
This is the approach i am proposing here. Basically you can write your computation in Cairo language, which is a language that enable you to build provable program.
So in your example the flow would like this:
- write a program in Cairo that performs the sum and return the result
- run the program with the Cairo VM to generate the execution trace (something needed to generate the proof)
- run a prover (like STWO) to generate the STARK proof
- then on the client side you verify the proof instead of re doing the computation yourself
Of course on small programs like this example it does not really make sense because you would just do a naive re execution and compare the result. But on complex programs it makes sense because the verification is exponentially faster and cheaper as the program complexity grows.