diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 4245d1b4b8..55d3c7144a 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -3,6 +3,8 @@ members = [ "aggregation/program", "alu-x0/program", "aggregation/script", + "base64/program", + "base64/script", "bls12381/program", "bls12381/script", "bn254/program", diff --git a/examples/base64/program/Cargo.toml b/examples/base64/program/Cargo.toml new file mode 100644 index 0000000000..16cf3d41dc --- /dev/null +++ b/examples/base64/program/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "base64-program" +version = "0.1.0" +edition = "2021" + +[dependencies] +sp1-zkvm = { git = "https://github.com/succinctlabs/sp1.git" } +base64 = "0.22" \ No newline at end of file diff --git a/examples/base64/program/elf/riscv32im-succinct-zkvm-elf b/examples/base64/program/elf/riscv32im-succinct-zkvm-elf new file mode 100755 index 0000000000..4eb342cd6f Binary files /dev/null and b/examples/base64/program/elf/riscv32im-succinct-zkvm-elf differ diff --git a/examples/base64/program/src/main.rs b/examples/base64/program/src/main.rs new file mode 100644 index 0000000000..2139d49759 --- /dev/null +++ b/examples/base64/program/src/main.rs @@ -0,0 +1,13 @@ +#![no_main] +sp1_zkvm::entrypoint!(main); + +use base64::{engine::general_purpose, Engine as _}; + +pub fn main() { + let encoded_string: String = sp1_zkvm::io::read(); + + let decoded_bytes = + general_purpose::STANDARD.decode(&encoded_string).expect("Failed to decode base64"); + + sp1_zkvm::io::commit(&decoded_bytes); +} diff --git a/examples/base64/script/Cargo.toml b/examples/base64/script/Cargo.toml new file mode 100644 index 0000000000..cdb8bff10d --- /dev/null +++ b/examples/base64/script/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "base64-script" +version = "0.1.0" +edition = "2021" + +[dependencies] +sp1-sdk = { git = "https://github.com/succinctlabs/sp1.git" } +tokio = { version = "1.37.0", features = ["full"] } \ No newline at end of file diff --git a/examples/base64/script/src/main.rs b/examples/base64/script/src/main.rs new file mode 100644 index 0000000000..349f50e064 --- /dev/null +++ b/examples/base64/script/src/main.rs @@ -0,0 +1,19 @@ +use sp1_sdk::{ProverClient, SP1Stdin, Prover}; + +const ELF: &[u8] = include_bytes!("/home/amit_2004/sp1/examples/target/elf-compilation/riscv64im-succinct-zkvm-elf/release/base64-program"); + +#[tokio::main] +async fn main() { + let client = ProverClient::from_env().await; + + let mut stdin = SP1Stdin::new(); + stdin.write(&"SGVsbG8sIFNQMSE=".to_string()); + + println!("Executing program logic (Mock Mode)..."); + + + let (mut public_values, _execution_report) = client.execute(sp1_sdk::Elf::Static(ELF), stdin).await.expect("Execution failed"); + let decoded = public_values.read::>(); + println!("Decoded: {}", String::from_utf8(decoded).unwrap()); + println!("Successfully verified execution logic!"); +} \ No newline at end of file