pepper-project / pequin

A system for verifying outsourced computations, and applying SNARKs. Simplified release of the main Pepper codebase.
Other
122 stars 46 forks source link

Fix compute_printf #21

Closed fleupold closed 5 years ago

fleupold commented 5 years ago

Currently, printf statements are not working. Running the prove for the following program:

#include <stdint.h>

struct In { int in; };
struct Out { int out; };

void compute(struct In *input, struct Out *output){
    printf("%d", input->in);
    output->out = input->in;
}

Outputs the following error instead of actually printing the input:

Format error in printf, Expected : X Actual: 1
PRINTF in computation_p 0:
Unrecognized token: X
Unrecognized token: I0

Reason for that is that we are looking for the token NUM_X in ComputationProver::compute_printf by checking if strcmp is true-ish. strcmp returns 0 if the strings are equal, thus we have to check for a false-ish value.

After this change proving the program above returns:

PRINTF in computation_p 1:
"1"