# Is it possible to verify a python code produced an answer without re-doing the computation?

## Context

Suppose Alice asks Bob to write a (python) code/function named get_sqrt(input) that computes and returns the square root of an input number named input. Next, Alice provides three random numbers as input to Bob. Bob produces the three output numbers using Bob's function get_sqrt(input) and returns to Alice:

• Three output numbers that are the square roots of the three input numbers.
• The python code get_sqrt(input).
• Some kind of signature/hash code. This signature/hash code can consist of any combination of information derived from the input, output and python code get_sqrt(input).

## Assumptions

1. Alice only has access to Alice's world until Alice has verified the solution of Bob. Afterwards Alice gets access to both Alice's and Bob's world.
2. Bob has access to both Bob's world and Alice's world (low- and high costs per operations).
3. Bob can do computations cheaply in Bob's world, but Bob is not trusted in Bob's world.
4. Re-doing the computation is too expensive in the world of Alice (for both Bob and Alice), because in the world of Alice, the costs per computation are too high.
5. The solutions created by the function get_sqrt(input) are reversible or easily(polynomially) verifiable. (For example, the output of Bob's function get_sqrt(input) can be verified by Alice by checking whether the square of each output equals its accompanying input.)

## Challenge

However, just that the answers provided by Bob are correct, does not mean that the get_sqrt(input) function that Bob sent to Alice actually generated those answers/isn't gibberish. Therefore, I was wondering if there is some property that can be computed by Bob (and/or Alice), based on the input, output, and (python) code get_sqrt(input) that makes it possible for Alice to verify that Bob's function indeed generates those output numbers based on the given input numbers (without re-doing the computations).

## Question

Is there a way with which Alice can verify that the output numbers are generated by the get_sqrt(input) function based on the set of input numbers, without re-doing the computation?

• Is it sufficient for you to validate that Bob is able to perform such computations or do you need to validate that a specific piece of code was executed? – SEJPM Feb 4 at 14:51
• There is no need to validate that a specific piece of code was executed. It is not sufficient to validate that Bob is able to perform such computations. It is sufficient to validate that Alice is able to reproduce the computations (later-on (in a different environment where the costs per operation are lower). – a.t. Feb 4 at 14:58
• Do you trust Bob, it seems no. Then why doesn't Alice verifies in the first place? I think this is not your actual question. – kelalaka Feb 4 at 20:12
• Bob is not trusted, but able to do all computations in a cheap environment. Alice can't verify the code by re-computing it because the cost per operation are too high in the world of Alice. Bob has access to both the cheap- and expensive cost per operation worlds. But the costs per operations of verifying in Alice's world (by means of re-computation) are also too high for Bob. – a.t. Feb 4 at 20:20