Skip to content
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

Is it necessary to execute before generating proof #1880

Closed
Subway2023 opened this issue Dec 19, 2024 · 1 comment
Closed

Is it necessary to execute before generating proof #1880

Subway2023 opened this issue Dec 19, 2024 · 1 comment

Comments

@Subway2023
Copy link

Component

sp1-zkvm

Describe the feature you would like

1734607401384
The images in the blog show the results that need to be executed in the process of generating proof. But I don't think the specific program is like that.

use sp1_sdk::{include_elf, utils, ProverClient, SP1Stdin};

/// The ELF we want to execute inside the zkVM.
const ELF: &[u8] = include_elf!("fibonacci-program");

fn main() {
    // Setup logging.
    utils::setup_logger();

    // Create an input stream and write '500' to it.
    let n = 500u32;
    let mut stdin = SP1Stdin::new();
    stdin.write(&n);

    // Generate the constant-sized proof for the given program and input.
    let client = ProverClient::new();
    let (pk, vk) = client.setup(ELF);
    let mut proof = client.prove(&pk, stdin).compressed().run().unwrap();

    println!("generated proof");
    // Read and verify the output.
    let a = proof.public_values.read::<u32>();
    let b = proof.public_values.read::<u32>();
    println!("a: {}, b: {}", a, b);

    // Verify proof and public values
    client.verify(&proof, &vk).expect("verification failed");

    // Save the proof.
    proof.save("compressed-proof-with-pis.bin").expect("saving proof failed");

    println!("successfully generated and verified proof for the program!")
}

In this case program, there is no need to execute the program before generating the proof. So how to ensure that the proof meets the execution results

Additional context

No response

@nhtyy
Copy link
Collaborator

nhtyy commented Dec 20, 2024

execute is done internally when you call prove.

@nhtyy nhtyy closed this as completed Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants