diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 8fbe253852..ceb72c9052 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -15,7 +15,7 @@ on: - "sdk/**" - ".github/workflows/**" merge_group: - + concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true @@ -167,11 +167,12 @@ jobs: - name: Run cargo prove new run: | cargo prove new fibonacci - + - name: Build program and run script run: | cd fibonacci cd program cargo prove build cd ../script - SP1_DEV=1 RUST_LOG=info cargo run --release + cargo add sp1-sdk --path $GITHUB_WORKSPACE/sdk + SP1_DEV=1 RUST_LOG=info cargo run --release diff --git a/cli/src/assets/program/Cargo.toml b/cli/src/assets/program/Cargo.toml index d2397eb0f4..4662efd449 100644 --- a/cli/src/assets/program/Cargo.toml +++ b/cli/src/assets/program/Cargo.toml @@ -5,4 +5,4 @@ name = "unnamed-program" edition = "2021" [dependencies] -sp1-zkvm = { git = "https://github.com/succinctlabs/sp1.git", rev = "v1.0.0-testnet" } \ No newline at end of file +sp1-zkvm = { git = "https://github.com/succinctlabs/sp1.git", branch = "main" } \ No newline at end of file diff --git a/cli/src/assets/script/Cargo.toml b/cli/src/assets/script/Cargo.toml index e7a874e49d..283777968f 100644 --- a/cli/src/assets/script/Cargo.toml +++ b/cli/src/assets/script/Cargo.toml @@ -5,7 +5,7 @@ name = "unnamed-script" edition = "2021" [dependencies] -sp1-sdk = { git = "https://github.com/succinctlabs/sp1.git", rev = "v1.0.0-testnet" } +sp1-sdk = { git = "https://github.com/succinctlabs/sp1.git", branch = "main" } [build-dependencies] -sp1-helper = { git = "https://github.com/succinctlabs/sp1.git", rev = "v1.0.0-testnet" } \ No newline at end of file +sp1-helper = { git = "https://github.com/succinctlabs/sp1.git", branch = "main" } \ No newline at end of file diff --git a/cli/src/assets/script/main.rs b/cli/src/assets/script/main.rs index 648f2a9528..3db922be23 100644 --- a/cli/src/assets/script/main.rs +++ b/cli/src/assets/script/main.rs @@ -11,7 +11,7 @@ fn main() { stdin.write(&n); let client = ProverClient::new(); let (pk, vk) = client.setup(ELF); - let mut proof = client.prove(&pk, stdin).expect("proving failed"); + let mut proof = client.prove_compressed(&pk, stdin).expect("proving failed"); // Read output. let a = proof.public_values.read::(); @@ -20,7 +20,9 @@ fn main() { println!("b: {}", b); // Verify proof. - client.verify(&proof, &vk).expect("verification failed"); + client + .verify_compressed(&proof, &vk) + .expect("verification failed"); // Save proof. proof diff --git a/sdk/src/provers/mod.rs b/sdk/src/provers/mod.rs index 9077ec53f0..3c3eb9450f 100644 --- a/sdk/src/provers/mod.rs +++ b/sdk/src/provers/mod.rs @@ -7,13 +7,11 @@ use anyhow::Result; pub use local::LocalProver; pub use mock::MockProver; pub use network::NetworkProver; -use sha2::{Digest, Sha256}; -use sp1_core::air::PublicValues; -use sp1_core::stark::MachineProof; use sp1_core::stark::MachineVerificationError; -use sp1_core::stark::StarkGenericConfig; use sp1_prover::CoreSC; +use sp1_prover::SP1CoreProofData; use sp1_prover::SP1Prover; +use sp1_prover::SP1ReduceProof; use sp1_prover::{SP1ProvingKey, SP1Stdin, SP1VerifyingKey}; /// An implementation of [crate::ProverClient]. @@ -42,32 +40,20 @@ pub trait Prover: Send + Sync { proof: &SP1Proof, vkey: &SP1VerifyingKey, ) -> Result<(), MachineVerificationError> { - let pv = PublicValues::from_vec(proof.proof[0].public_values.clone()); - let pv_digest: [u8; 32] = Sha256::digest(proof.public_values.as_slice()).into(); - if pv_digest != *pv.commit_digest_bytes() { - return Err(MachineVerificationError::InvalidPublicValuesDigest); - } - let machine_proof = MachineProof { - shard_proofs: proof.proof.clone(), - }; - let sp1_prover = self.sp1_prover(); - let mut challenger = sp1_prover.core_machine.config().challenger(); - sp1_prover - .core_machine - .verify(&vkey.vk, &machine_proof, &mut challenger) + self.sp1_prover() + .verify(&SP1CoreProofData(proof.proof.clone()), vkey) } /// Verify that a compressed SP1 proof is valid given its vkey and metadata. fn verify_compressed(&self, proof: &SP1CompressedProof, vkey: &SP1VerifyingKey) -> Result<()> { - // TODO: implement verification of the digest of the public values matching - let sp1_prover = self.sp1_prover(); - let machine_proof = MachineProof { - shard_proofs: vec![proof.proof.clone()], - }; - let mut challenger = sp1_prover.compress_machine.config().challenger(); - Ok(sp1_prover - .compress_machine - .verify(&vkey.vk, &machine_proof, &mut challenger)?) + self.sp1_prover() + .verify_compressed( + &SP1ReduceProof { + proof: proof.proof.clone(), + }, + vkey, + ) + .map_err(|e| e.into()) } /// Verify that a SP1 Groth16 proof is valid given its vkey and metadata.