diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0c3cfaccf..4816f0af4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,6 +9,10 @@ concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true +env: + AWS_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_KEY }} + jobs: test: name: CI Test Suite diff --git a/prover/src/build.rs b/prover/src/build.rs index 6d3078577..0fc7c51b1 100644 --- a/prover/src/build.rs +++ b/prover/src/build.rs @@ -17,7 +17,7 @@ use crate::utils::{babybear_bytes_to_bn254, babybears_to_bn254, words_to_bytes}; use crate::{OuterSC, SphinxProver}; /// Tries to install the PLONK artifacts if they are not already installed. -pub fn try_install_plonk_bn254_artifacts() -> PathBuf { +pub fn try_install_plonk_bn254_artifacts(use_aws_cli: bool) -> PathBuf { let build_dir = plonk_bn254_artifacts_dir(); if build_dir.exists() { @@ -31,7 +31,7 @@ pub fn try_install_plonk_bn254_artifacts() -> PathBuf { PLONK_BN254_ARTIFACTS_COMMIT, build_dir.display() ); - install_plonk_bn254_artifacts(&build_dir); + install_plonk_bn254_artifacts(&build_dir, use_aws_cli); } build_dir } diff --git a/prover/src/install.rs b/prover/src/install.rs index 50c1b1054..dd9a9ae71 100644 --- a/prover/src/install.rs +++ b/prover/src/install.rs @@ -12,7 +12,7 @@ use reqwest::Client; use crate::utils::block_on; /// The base URL for the S3 bucket containing the plonk bn254 artifacts. -pub const PLONK_BN254_ARTIFACTS_URL_BASE: &str = "https://sp1-circuits.s3-us-east-2.amazonaws.com"; +pub const PLONK_BN254_ARTIFACTS_URL_BASE: &str = "s3://sphinx-plonk-params"; /// The current version of the plonk bn254 artifacts. pub const PLONK_BN254_ARTIFACTS_COMMIT: &str = "4a525e9f"; @@ -21,7 +21,7 @@ pub const PLONK_BN254_ARTIFACTS_COMMIT: &str = "4a525e9f"; /// /// This function will download the latest plonk bn254 artifacts from the S3 bucket and extract them to /// the directory specified by [plonk_bn254_artifacts_dir()]. -pub fn install_plonk_bn254_artifacts(build_dir: &Path) { +pub fn install_plonk_bn254_artifacts(build_dir: &Path, use_aws_cli: bool) { // Create the build directory. std::fs::create_dir_all(build_dir).expect("failed to create build directory"); @@ -32,15 +32,21 @@ pub fn install_plonk_bn254_artifacts(build_dir: &Path) { ); let mut artifacts_tar_gz_file = tempfile::NamedTempFile::new().expect("failed to create tempfile"); - let client = Client::builder() - .build() - .expect("failed to create reqwest client"); - block_on(download_file( - &client, - &download_url, - &mut artifacts_tar_gz_file, - )) - .expect("failed to download file"); + + if use_aws_cli { + block_on(download_file_aws(&download_url, &mut artifacts_tar_gz_file)) + .expect("failed to download file [aws]"); + } else { + let client = Client::builder() + .build() + .expect("failed to create reqwest client"); + block_on(download_file( + &client, + &download_url, + &mut artifacts_tar_gz_file, + )) + .expect("failed to download file"); + } // Extract the tarball to the build directory. let mut res = Command::new("tar") @@ -106,3 +112,17 @@ pub async fn download_file( Ok(()) } + +/// Download the file using the AWS cli +pub async fn download_file_aws( + url: &str, + file: &mut tempfile::NamedTempFile, +) -> Result<(), String> { + let mut res = Command::new("aws") + .args(["s3", "cp", url, file.path().to_str().unwrap()]) + .spawn() + .expect("couldn't run `aws` command. Probably it is not installed / configured"); + res.wait().unwrap(); + + Ok(()) +} diff --git a/recursion/gnark-ffi/assets/ISP1Verifier.txt b/recursion/gnark-ffi/assets/ISphinxVerifier.txt similarity index 72% rename from recursion/gnark-ffi/assets/ISP1Verifier.txt rename to recursion/gnark-ffi/assets/ISphinxVerifier.txt index 4298f4b8c..f9563b688 100644 --- a/recursion/gnark-ffi/assets/ISP1Verifier.txt +++ b/recursion/gnark-ffi/assets/ISphinxVerifier.txt @@ -1,11 +1,10 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.25; -/// @title SP1 Verifier Interface -/// @author Succinct Labs -/// @notice This contract is the interface for the SP1 Verifier. -interface ISP1Verifier { - /// @notice Returns the version of the SP1 Verifier. +/// @title Sphinx Verifier Interface +/// @notice This contract is the interface for the Sphinx Verifier. +interface ISphinxVerifier { + /// @notice Returns the version of the Sphinx Verifier. function VERSION() external pure returns (string memory); /// @notice Verifies a proof with given public values and vkey. diff --git a/recursion/gnark-ffi/assets/SP1MockVerifier.txt b/recursion/gnark-ffi/assets/SphinxMockVerifier.txt similarity index 73% rename from recursion/gnark-ffi/assets/SP1MockVerifier.txt rename to recursion/gnark-ffi/assets/SphinxMockVerifier.txt index bf938718b..ccd597dc7 100644 --- a/recursion/gnark-ffi/assets/SP1MockVerifier.txt +++ b/recursion/gnark-ffi/assets/SphinxMockVerifier.txt @@ -1,18 +1,17 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.25; -import {ISP1Verifier} from "./ISP1Verifier.sol"; +import {ISphinxVerifier} from "./ISphinxVerifier.sol"; -/// @title SP1 Mock Verifier -/// @author Succinct Labs -/// @notice This contracts implements a Mock solidity verifier for SP1. -contract SP1MockVerifier is ISP1Verifier { +/// @title Sphinx Mock Verifier +/// @notice This contracts implements a Mock solidity verifier for Sphinx. +contract SphinxMockVerifier is ISphinxVerifier { function VERSION() external pure returns (string memory) { return "TODO"; } /// @notice Verifies a mock proof with given public values and vkey. - /// @param proofBytes The proof of the program execution the SP1 zkVM encoded as bytes. + /// @param proofBytes The proof of the program execution the Sphinx zkVM encoded as bytes. function verifyProof( bytes32, bytes memory, diff --git a/recursion/gnark-ffi/assets/SP1Verifier.txt b/recursion/gnark-ffi/assets/SphinxVerifier.txt similarity index 83% rename from recursion/gnark-ffi/assets/SP1Verifier.txt rename to recursion/gnark-ffi/assets/SphinxVerifier.txt index f7389163e..685cdee16 100644 --- a/recursion/gnark-ffi/assets/SP1Verifier.txt +++ b/recursion/gnark-ffi/assets/SphinxVerifier.txt @@ -1,13 +1,12 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.25; -import {ISP1Verifier} from "./ISP1Verifier.sol"; +import {ISphinxVerifier} from "./ISphinxVerifier.sol"; import {PlonkVerifier} from "./PlonkVerifier.sol"; -/// @title SP1 Verifier -/// @author Succinct Labs -/// @notice This contracts implements a solidity verifier for SP1. -contract SP1Verifier is PlonkVerifier { +/// @title Sphinx Verifier +/// @notice This contracts implements a solidity verifier for Sphinx. +contract SphinxVerifier is PlonkVerifier { function VERSION() external pure returns (string memory) { return "TODO"; } @@ -23,7 +22,7 @@ contract SP1Verifier is PlonkVerifier { /// @notice Verifies a proof with given public values and vkey. /// @param vkey The verification key for the RISC-V program. /// @param publicValues The public values encoded as bytes. - /// @param proofBytes The proof of the program execution the SP1 zkVM encoded as bytes. + /// @param proofBytes The proof of the program execution the Sphinx zkVM encoded as bytes. function verifyProof( bytes32 vkey, bytes memory publicValues, diff --git a/recursion/gnark-ffi/src/plonk_bn254.rs b/recursion/gnark-ffi/src/plonk_bn254.rs index 723688c1f..26ba0fcba 100644 --- a/recursion/gnark-ffi/src/plonk_bn254.rs +++ b/recursion/gnark-ffi/src/plonk_bn254.rs @@ -69,22 +69,22 @@ impl PlonkBn254Prover { build_plonk_bn254(build_dir.to_str().unwrap()); // Write the corresponding asset files to the build dir. - let sphinx_mock_verifier_path = build_dir.join("SP1MockVerifier.sol"); - let sphinx_mock_verifier_str = include_str!("../assets/SP1MockVerifier.txt"); + let sphinx_mock_verifier_path = build_dir.join("SphinxMockVerifier.sol"); + let sphinx_mock_verifier_str = include_str!("../assets/SphinxMockVerifier.txt"); let mut mock_verifier_file = File::create(sphinx_mock_verifier_path).unwrap(); mock_verifier_file .write_all(sphinx_mock_verifier_str.as_bytes()) .unwrap(); - let sphinx_verifier_path = build_dir.join("SP1Verifier.sol"); - let sphinx_verifier_str = include_str!("../assets/SP1Verifier.txt"); + let sphinx_verifier_path = build_dir.join("SphinxVerifier.sol"); + let sphinx_verifier_str = include_str!("../assets/SphinxVerifier.txt"); let mut sphinx_verifier_file = File::create(sphinx_verifier_path).unwrap(); sphinx_verifier_file .write_all(sphinx_verifier_str.as_bytes()) .unwrap(); - let interface_sphinx_verifier_path = build_dir.join("ISP1Verifier.sol"); - let interface_sphinx_verifier_str = include_str!("../assets/ISP1Verifier.txt"); + let interface_sphinx_verifier_path = build_dir.join("ISphinxVerifier.sol"); + let interface_sphinx_verifier_str = include_str!("../assets/ISphinxVerifier.txt"); let mut interface_sphinx_verifier_file = File::create(interface_sphinx_verifier_path).unwrap(); interface_sphinx_verifier_file diff --git a/sdk/src/artifacts.rs b/sdk/src/artifacts.rs index 4b0e9df80..a858d6267 100644 --- a/sdk/src/artifacts.rs +++ b/sdk/src/artifacts.rs @@ -17,9 +17,9 @@ pub fn export_solidity_plonk_bn254_verifier(output_dir: impl Into) -> R let artifacts_dir = if sphinx_prover::build::sphinx_dev_mode() { sphinx_prover::build::plonk_bn254_artifacts_dev_dir() } else { - try_install_plonk_bn254_artifacts() + try_install_plonk_bn254_artifacts(true) }; - let verifier_path = artifacts_dir.join("SP1Verifier.sol"); + let verifier_path = artifacts_dir.join("SphinxVerifier.sol"); if !verifier_path.exists() { return Err(anyhow::anyhow!( @@ -29,7 +29,7 @@ pub fn export_solidity_plonk_bn254_verifier(output_dir: impl Into) -> R } std::fs::create_dir_all(&output_dir).context("Failed to create output directory.")?; - let output_path = output_dir.join("SP1Verifier.sol"); + let output_path = output_dir.join("SphinxVerifier.sol"); std::fs::copy(&verifier_path, &output_path).context("Failed to copy verifier file.")?; tracing::info!( "exported verifier from {} to {}", diff --git a/sdk/src/provers/local.rs b/sdk/src/provers/local.rs index da8ce2438..4d5cb53b5 100644 --- a/sdk/src/provers/local.rs +++ b/sdk/src/provers/local.rs @@ -82,7 +82,7 @@ impl Prover for LocalProver { &outer_proof.proof, ) } else { - sphinx_prover::build::try_install_plonk_bn254_artifacts() + sphinx_prover::build::try_install_plonk_bn254_artifacts(true) }; let proof = self.prover.wrap_plonk_bn254(outer_proof, &plonk_bn254_aritfacts); Ok(SphinxProofWithPublicValues { diff --git a/sdk/src/provers/mod.rs b/sdk/src/provers/mod.rs index fad3c6292..565ef5527 100644 --- a/sdk/src/provers/mod.rs +++ b/sdk/src/provers/mod.rs @@ -80,7 +80,7 @@ pub trait Prover: Send + Sync { let plonk_bn254_aritfacts = if sphinx_prover::build::sphinx_dev_mode() { sphinx_prover::build::plonk_bn254_artifacts_dev_dir() } else { - sphinx_prover::build::try_install_plonk_bn254_artifacts() + sphinx_prover::build::try_install_plonk_bn254_artifacts(true) }; sphinx_prover.verify_plonk_bn254( &proof.proof,