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

ISA efficiency comparison #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions keccak/sp1-native/program/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions keccak/sp1-native/program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ edition = "2021"

[dependencies]
sp1-zkvm = { git = "https://github.com/succinctlabs/sp1.git", tag = "v3.0.0" }
sp1-derive = { git = "https://github.com/succinctlabs/sp1.git", tag = "v3.0.0" }

sha3 = { git = "https://github.com/RustCrypto/hashes", package = "sha3", tag = "sha3/v0.10.8" }
hex = "0.4.3"
2 changes: 2 additions & 0 deletions keccak/sp1-native/program/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ sp1_zkvm::entrypoint!(main);

use sha3::{Digest, Keccak256};

#[sp1_derive::cycle_tracker]
fn keccak(input: &[u8]) -> [u8; 32] {
let mut hasher = Keccak256::new();
hasher.update(input);
let result = hasher.finalize();
Into::<[u8; 32]>::into(result)
}

#[sp1_derive::cycle_tracker]
pub fn main() {
let input: &[u8] = &[5u8; 32];
let output = keccak(input);
Expand Down
1 change: 1 addition & 0 deletions keccak/sp1-native/script/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions keccak/sp1-native/script/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ edition = "2021"

[dependencies]
sp1-sdk = { git = "https://github.com/succinctlabs/sp1.git", tag = "v3.0.0" }
sp1-core-machine = { git = "https://github.com/succinctlabs/sp1.git", tag = "v3.0.0" }

ark-std = "0.4"

[build-dependencies]
Expand Down
7 changes: 7 additions & 0 deletions keccak/sp1-native/script/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ use sp1_sdk::{ProverClient, SP1Stdin};

const ELF: &[u8] = include_bytes!("../../program/elf/riscv32im-succinct-zkvm-elf");

fn init_logger() {
std::env::set_var("RUST_LOG", "info");
sp1_core_machine::utils::setup_logger();
}

fn main() {
init_logger();

// Generate proof.
let stdin = SP1Stdin::new();
let client = ProverClient::new();
Expand Down
25 changes: 23 additions & 2 deletions keccak/sp1-precompile/program/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions keccak/sp1-precompile/program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ edition = "2021"

[dependencies]
sp1-zkvm = { git = "https://github.com/succinctlabs/sp1.git", tag = "v3.0.0" }
sp1-derive = { git = "https://github.com/succinctlabs/sp1.git", tag = "v3.0.0" }

sha3 = { git = "https://github.com/sp1-patches/RustCrypto-hashes.git", package = "sha3", branch = "patch-sha3-v0.10.8" }
hex = "0.4.3"

Expand Down
2 changes: 2 additions & 0 deletions keccak/sp1-precompile/program/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ sp1_zkvm::entrypoint!(main);

use sha3::{Digest, Keccak256};

#[sp1_derive::cycle_tracker]
fn keccak(input: &[u8]) -> [u8; 32] {
let mut hasher = Keccak256::new();
hasher.update(input);
let result = hasher.finalize();
Into::<[u8; 32]>::into(result)
}

#[sp1_derive::cycle_tracker]
pub fn main() {
let input: &[u8] = &[5u8; 32];
let output = keccak(input);
Expand Down
1 change: 1 addition & 0 deletions keccak/sp1-precompile/script/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions keccak/sp1-precompile/script/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ edition = "2021"

[dependencies]
sp1-sdk = { git = "https://github.com/succinctlabs/sp1.git", tag = "v3.0.0" }
sp1-core-machine = { git = "https://github.com/succinctlabs/sp1.git", tag = "v3.0.0" }

ark-std = "0.4"

[features]
Expand Down
7 changes: 7 additions & 0 deletions keccak/sp1-precompile/script/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ use ark_std::{end_timer, start_timer};

const ELF: &[u8] = include_bytes!("../../program/elf/riscv32im-succinct-zkvm-elf");

fn init_logger() {
std::env::set_var("RUST_LOG", "info");
sp1_core_machine::utils::setup_logger();
}

fn main() {
init_logger();

// Generate proof.
let stdin = SP1Stdin::new();
let client = ProverClient::new();
Expand Down
Binary file added media/keccak-ISA-efficiency-bench.mp4
Binary file not shown.