-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(de)serialization of preprocessing #585
Comments
@jprider63 and I have discussed what the API for this should look like, and we were thinking something like this: let target_dir = "/tmp/target";
guest::compile_fib(&target_dir);
let prover_preprocessing = guest::prover_preprocess_fib(&program);
/* Internally, this is
let config = ...; // Specify max input size, etc.
preprocess_prover(&program, &config)
*/
let prover_preprocessing_file = "/tmp/prover_preprocessing";
prover_preprocessing.save_to_file(&prover_preprocessing_file);
let prove_fib = guest::build_prover(&program, prover_preprocessing_file);
/* Internally, this is
let program = load_program(&target_dir);
let preprocessing = load_prover_preprocessing(&prover_preprocessing_file);
|inputs, ...| {
let input = serialize(inputs);
run_prover(program, preprocessing, input)
}
*/
let (output, proof) = prove_fib(50);
let verifier_preprocessing = guest::verifier_preprocess_fib(&program);
/* Internally, this is
let config = ...; // Specify max input size, etc.
preprocess_verifier(&program, &config)
*/
let verifier_preprocessing_file = "/tmp/verifier_preprocessing";
verifier_preprocessing.save_to_file(&verifier_preprocessing_file);
let verify_fib = guest::build_verifier(&target_dir, verifier_preprocessing_file);
/* Internally, this is
let program = load_program(&target_dir);
let preprocessing = load_verifier_preprocessing(&prover_verifier_file);
|proof, claimed_output, inputs, ...| {
let input = serialize(inputs);
let output = serialize(claimed_output);
run_verifier(program, preprocessing, proof, input, output)
}
*/
let is_valid = verify_fib(proof, output, 50); The stuff in comments would be a lower-level interface, whereas the stuff outside of the comments would be the higher-level interface, using proc macros, as is done currently. How does this look to you? There were a couple of things we weren't clear on:
|
Regarding your first point, the Jolt proof does indeed contain a copy of the guest program inputs and outputs, so there's no need to pass them as arguments to the verify function. The Jolt proof struct contains a field for program IO). The |
The interface looks good to me @protoben |
Would you be open to pulling out the inputs and outputs from
|
To echo what @jprider63 is saying, it seems like even if the inputs/outputs are contained in the proof, the high-level API should have some way of checking that the proof corresponds to the ones the verifier expects. One possibility would be to add a helper function to the high-level API to do this check that inherits the signature of the guest function (like the functions returned by let (output1, ..., proof) = ... // get these from the prover
let instance_check = check_instance_myfunc(proof, input1, ..., output1, ...); // This checks that the inputs/outputs are the ones in the proof
let proof_check = verify_myfunc(proof); |
Makes sense; let's pull the inputs and outputs out of |
Made a PR here: #616 |
Currently, the
jolt::provable
proc_macro generates abuild_*
function for each decorated function (see e.g. build_fib). Calling this function from the host builds the guest program and computes preprocessing. It then returns two closures,prove_*
andverify_*
which prove and verify executions of the guest, respectively.Of course, a more realistic usage pattern would be to compile the guest and compute the preprocessing only once per guest program (more precisely, preprocessing can also depend on parameters specifying e.g. the max input size of the guest), and then serialize it or post it to some public bulletin.
Then a prover could read the preprocessing from disk once and use it for multiple invocations of
Jolt::prove
.Similarly, the verifier needs a subset of the
JoltPreprocessing
data (currently the same preprocessing struct is used for prover and verifier, but this should be changed). This verifier should be able to read the required data from disk once and use it for multiple invocations ofJolt::verify
.The text was updated successfully, but these errors were encountered: