Add crates ere-platform-{zkvm} (#202)

This commit is contained in:
Han
2025-11-05 12:49:12 +08:00
committed by GitHub
parent 52643911bc
commit ae6baa03c1
56 changed files with 997 additions and 250 deletions

View File

@@ -13,11 +13,10 @@ set -e -o pipefail
# .github/scripts/fetch-zkvm-version.sh risc0 risc0-zkvm
# .github/scripts/fetch-zkvm-version.sh sp1 sp1-sdk
# .github/scripts/fetch-zkvm-version.sh ziren zkm-sdk
# .github/scripts/fetch-zkvm-version.sh zisk 0xPolygonHermez/zisk
# .github/scripts/fetch-zkvm-version.sh zisk ziskos
if [ $# -ne 2 ]; then
echo "Usage: $0 <zkvm> <crate>"
echo " crate: crate (e.g. openvm-sdk) or github org/repo (e.g. 0xPolygonHermez/zisk)"
exit 1
fi
@@ -34,24 +33,17 @@ get_crates_io_latest() {
curl -sL -A "EreCI" "https://crates.io/api/v1/crates/$crate" | grep -oP '"max_version":"\K[^"]+'
}
if [[ "$CRATE" == */* ]]; then
# It is in format of org/repo, get current version from build.rs
LATEST=$(get_github_latest "$CRATE")
CURRENT=$(grep -oP 'gen_name_and_sdk_version\("'"$ZKVM"'", "\K[^"]+' "crates/zkvm/$ZKVM/build.rs")
else
# It is a crate name, get current version from Cargo.toml
LINE=$(grep "$CRATE" Cargo.toml)
LINE=$(grep "$CRATE" Cargo.toml)
if echo "$LINE" | grep -q "git ="; then
# Dependency from github.com
REPO=$(echo "$LINE" | grep -oP 'git = "https://github.com/\K[^"]+' | sed 's/\.git$//')
CURRENT=$(echo "$LINE" | grep -oP 'tag = "\K[^"]+')
LATEST=$(get_github_latest "$REPO")
else
# Dependency from crates.io
CURRENT=$(grep "^$CRATE = " Cargo.toml | grep -oP '"\K[0-9.]+(?=")')
LATEST=$(get_crates_io_latest "$CRATE")
fi
if echo "$LINE" | grep -q "git ="; then
# Dependency from github.com
REPO=$(echo "$LINE" | grep -oP 'git = "https://github.com/\K[^"]+' | sed 's/\.git$//')
CURRENT=$(echo "$LINE" | grep -oP 'tag = "\K[^"]+')
LATEST=$(get_github_latest "$REPO")
else
# Dependency from crates.io
CURRENT=$(grep "^$CRATE = " Cargo.toml | grep -oP '"\K[0-9.]+(?=")')
LATEST=$(get_crates_io_latest "$CRATE")
fi
echo "CURRENT=v${CURRENT#v}"

View File

@@ -36,7 +36,7 @@ jobs:
- zkvm: ziren
crate: zkm-sdk
- zkvm: zisk
crate: 0xPolygonHermez/zisk
crate: ziskos
steps:
- name: Checkout repository
uses: actions/checkout@v4

3
.gitignore vendored
View File

@@ -1,3 +1,4 @@
target
notes.md
dory_srs_*_variables.srs
dory_srs_*_variables.srs
.vscode

258
Cargo.lock generated
View File

@@ -2459,6 +2459,12 @@ dependencies = [
"windows-sys 0.59.0",
]
[[package]]
name = "const-default"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b396d1f76d455557e1218ec8066ae14bba60b4b36ecd55577ba979f5db7ecaa"
[[package]]
name = "const-hex"
version = "1.14.0"
@@ -3438,6 +3444,18 @@ dependencies = [
"zeroize",
]
[[package]]
name = "embedded-alloc"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f2de9133f68db0d4627ad69db767726c99ff8585272716708227008d3f1bddd"
dependencies = [
"const-default",
"critical-section",
"linked_list_allocator",
"rlsf",
]
[[package]]
name = "embedded-io"
version = "0.4.0"
@@ -3776,6 +3794,86 @@ dependencies = [
"thiserror 2.0.12",
]
[[package]]
name = "ere-platform-airbender"
version = "0.0.14"
dependencies = [
"ere-platform-trait",
"riscv_common",
]
[[package]]
name = "ere-platform-jolt"
version = "0.0.14"
dependencies = [
"ere-platform-trait",
"jolt-sdk",
"postcard",
]
[[package]]
name = "ere-platform-nexus"
version = "0.0.14"
dependencies = [
"ere-platform-trait",
"nexus-rt",
]
[[package]]
name = "ere-platform-openvm"
version = "0.0.14"
dependencies = [
"ere-platform-trait",
"openvm",
]
[[package]]
name = "ere-platform-pico"
version = "0.0.14"
dependencies = [
"ere-platform-trait",
"pico-sdk",
]
[[package]]
name = "ere-platform-risc0"
version = "0.0.14"
dependencies = [
"ere-platform-trait",
"risc0-zkvm",
]
[[package]]
name = "ere-platform-sp1"
version = "0.0.14"
dependencies = [
"ere-platform-trait",
"sp1-zkvm",
]
[[package]]
name = "ere-platform-trait"
version = "0.0.14"
dependencies = [
"digest 0.10.7",
]
[[package]]
name = "ere-platform-ziren"
version = "0.0.14"
dependencies = [
"ere-platform-trait",
"zkm-zkvm",
]
[[package]]
name = "ere-platform-zisk"
version = "0.0.14"
dependencies = [
"ere-platform-trait",
"ziskos",
]
[[package]]
name = "ere-risc0"
version = "0.0.14"
@@ -3848,6 +3946,7 @@ name = "ere-test-utils"
version = "0.0.14"
dependencies = [
"ere-io-serde",
"ere-platform-trait",
"ere-zkvm-interface",
"rand 0.9.2",
"serde",
@@ -6118,6 +6217,11 @@ version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "lib-c"
version = "0.13.0"
source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.13.0#ea1ed4c518992a170fc59ec19f1228eb4829a9e1"
[[package]]
name = "lib-rv32-asm"
version = "0.2.0"
@@ -6214,6 +6318,12 @@ version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
[[package]]
name = "linked_list_allocator"
version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286"
[[package]]
name = "linux-raw-sys"
version = "0.4.15"
@@ -6930,6 +7040,28 @@ dependencies = [
"pprof",
]
[[package]]
name = "nexus-rt"
version = "0.3.5"
source = "git+https://github.com/nexus-xyz/nexus-zkvm.git?tag=v0.3.5#0c3b093963ff90187349e760b5f77717c8cfe351"
dependencies = [
"nexus-rt-macros",
"postcard",
"serde",
"tiny-keccak",
]
[[package]]
name = "nexus-rt-macros"
version = "0.1.0"
source = "git+https://github.com/nexus-xyz/nexus-zkvm.git?tag=v0.3.5#0c3b093963ff90187349e760b5f77717c8cfe351"
dependencies = [
"proc-macro-crate 3.3.0",
"proc-macro2",
"quote",
"syn 2.0.101",
]
[[package]]
name = "nexus-sdk"
version = "0.3.5"
@@ -7500,6 +7632,8 @@ version = "1.4.1"
source = "git+https://github.com/openvm-org/openvm.git?tag=v1.4.1#05cb6a11bbd7ac3ac8a00c3fc56391b06f54baa2"
dependencies = [
"bytemuck",
"getrandom 0.2.16",
"getrandom 0.3.3",
"num-bigint 0.4.6",
"openvm-custom-insn",
"openvm-platform",
@@ -8156,6 +8290,8 @@ name = "openvm-platform"
version = "1.4.1"
source = "git+https://github.com/openvm-org/openvm.git?tag=v1.4.1#05cb6a11bbd7ac3ac8a00c3fc56391b06f54baa2"
dependencies = [
"critical-section",
"embedded-alloc",
"libm",
"openvm-custom-insn",
"openvm-rv32im-guest",
@@ -10001,6 +10137,41 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "pico-patch-libs"
version = "1.1.6"
source = "git+https://github.com/brevis-network/pico.git?tag=v1.1.7#79b10e613c3a0dd2a92d2a65a149d853f4aface2"
dependencies = [
"bincode 1.3.3",
"serde",
]
[[package]]
name = "pico-sdk"
version = "1.1.6"
source = "git+https://github.com/brevis-network/pico.git?tag=v1.1.7#79b10e613c3a0dd2a92d2a65a149d853f4aface2"
dependencies = [
"anyhow",
"bincode 1.3.3",
"cfg-if",
"env_logger",
"getrandom 0.2.16",
"hex",
"lazy_static",
"log",
"p3-baby-bear 0.1.0 (git+https://github.com/brevis-network/Plonky3.git?rev=a4d376b)",
"p3-challenger 0.1.0 (git+https://github.com/brevis-network/Plonky3.git?rev=a4d376b)",
"p3-field 0.1.0 (git+https://github.com/brevis-network/Plonky3.git?rev=a4d376b)",
"p3-koala-bear 0.1.0 (git+https://github.com/brevis-network/Plonky3.git?rev=a4d376b)",
"p3-mersenne-31 0.1.0 (git+https://github.com/brevis-network/Plonky3.git?rev=a4d376b)",
"pico-patch-libs",
"pico-vm",
"rand 0.8.5",
"serde",
"serde_json",
"sha2",
]
[[package]]
name = "pico-vm"
version = "1.1.6"
@@ -10189,9 +10360,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "170a2601f67cc9dba8edd8c4870b15f71a6a2dc196daec8c83f72b59dff628a8"
dependencies = [
"cobs",
"crc",
"embedded-io 0.4.0",
"embedded-io 0.6.1",
"heapless",
"paste",
"serde",
]
@@ -11460,6 +11633,8 @@ checksum = "cfaa10feba15828c788837ddde84b994393936d8f5715228627cfe8625122a40"
dependencies = [
"bytemuck",
"cfg-if",
"critical-section",
"embedded-alloc",
"getrandom 0.2.16",
"getrandom 0.3.3",
"libm",
@@ -11499,6 +11674,14 @@ dependencies = [
"serde",
]
[[package]]
name = "riscv_common"
version = "0.1.0"
source = "git+https://github.com/matter-labs/zksync-airbender?tag=v0.5.0#a3c74040d2f994608f451550232392333400bbf1"
dependencies = [
"heapless",
]
[[package]]
name = "rlp"
version = "0.5.2"
@@ -11521,6 +11704,18 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "rlsf"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "222fb240c3286247ecdee6fa5341e7cdad0ffdf8e7e401d9937f2d58482a20bf"
dependencies = [
"cfg-if",
"const-default",
"libc",
"svgbobdoc",
]
[[package]]
name = "rrs-lib"
version = "0.1.0"
@@ -12654,6 +12849,17 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "sp1-lib"
version = "5.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fce8ad0f153443d09d398eccb650a0b2dcbf829470e394e4bf60ec4379c7af93"
dependencies = [
"bincode 1.3.3",
"serde",
"sp1-primitives",
]
[[package]]
name = "sp1-primitives"
version = "5.2.2"
@@ -12942,6 +13148,28 @@ dependencies = [
"tracing",
]
[[package]]
name = "sp1-zkvm"
version = "5.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb9cad934f30e245be5c0c55aac0810cf3bbd86187b384e0e95f3afac7cd41b3"
dependencies = [
"blake3",
"cfg-if",
"critical-section",
"embedded-alloc",
"getrandom 0.2.16",
"getrandom 0.3.3",
"lazy_static",
"libm",
"p3-baby-bear 0.2.3-succinct",
"p3-field 0.2.3-succinct",
"rand 0.8.5",
"sha2",
"sp1-lib",
"sp1-primitives",
]
[[package]]
name = "spin"
version = "0.5.2"
@@ -13222,6 +13450,19 @@ version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2"
[[package]]
name = "svgbobdoc"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2c04b93fc15d79b39c63218f15e3fdffaa4c227830686e3b7c5f41244eb3e50"
dependencies = [
"base64 0.13.1",
"proc-macro2",
"quote",
"syn 1.0.109",
"unicode-width 0.1.14",
]
[[package]]
name = "svm-rs"
version = "0.3.5"
@@ -15554,6 +15795,22 @@ dependencies = [
"zopfli",
]
[[package]]
name = "ziskos"
version = "0.13.0"
source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.13.0#ea1ed4c518992a170fc59ec19f1228eb4829a9e1"
dependencies = [
"cfg-if",
"getrandom 0.2.16",
"lazy_static",
"lib-c",
"num-bigint 0.4.6",
"num-traits",
"rand 0.8.5",
"static_assertions",
"tiny-keccak",
]
[[package]]
name = "zkhash"
version = "0.2.0"
@@ -16044,6 +16301,7 @@ dependencies = [
"cfg-if",
"getrandom 0.2.16",
"lazy_static",
"libm",
"rand 0.8.5",
"serde",
"sha2",

View File

@@ -2,17 +2,27 @@
members = [
# zkVM interface
"crates/zkvm-interface",
"crates/zkvm-interface/platform",
# zkVMs
"crates/zkvm/airbender",
"crates/zkvm/airbender/platform",
"crates/zkvm/jolt",
"crates/zkvm/jolt/platform",
"crates/zkvm/miden",
"crates/zkvm/nexus",
"crates/zkvm/nexus/platform",
"crates/zkvm/openvm",
"crates/zkvm/openvm/platform",
"crates/zkvm/pico",
"crates/zkvm/pico/platform",
"crates/zkvm/risc0",
"crates/zkvm/risc0/platform",
"crates/zkvm/sp1",
"crates/zkvm/sp1/platform",
"crates/zkvm/ziren",
"crates/zkvm/ziren/platform",
"crates/zkvm/zisk",
"crates/zkvm/zisk/platform",
# Dockerized zkVM
"crates/dockerized/compiler",
"crates/dockerized/dockerized",
@@ -43,9 +53,10 @@ bytemuck = "1.23.1"
cargo_metadata = "0.19.0"
clap = "4.5.42"
dashmap = "6.1.0"
digest = { version = "0.10.7", default-features = false }
eyre = "0.6.12"
indexmap = "2.10.0"
postcard = "1.0.8"
postcard = { version = "1.0.8", default-features = false }
prost = "0.13"
prost-build = "0.13"
rand = "0.9.2"
@@ -66,12 +77,13 @@ twirp-build = "0.9.0"
# Airbender dependencies
airbender_execution_utils = { git = "https://github.com/matter-labs/zksync-airbender", package = "execution_utils", tag = "v0.5.0" }
airbender_riscv_common = { git = "https://github.com/matter-labs/zksync-airbender", package = "riscv_common", tag = "v0.5.0" }
# Jolt dependencies
jolt-ark-serialize = { git = "https://github.com/a16z/arkworks-algebra", package = "ark-serialize", branch = "feat/fewer-reductions" }
jolt-common = { git = "https://github.com/a16z/jolt.git", package = "common", tag = "v0.3.0-alpha" }
jolt-common = { git = "https://github.com/a16z/jolt.git", package = "common", tag = "v0.3.0-alpha", default-features = false }
jolt-core = { git = "https://github.com/a16z/jolt.git", tag = "v0.3.0-alpha" }
jolt-sdk = { git = "https://github.com/a16z/jolt.git", tag = "v0.3.0-alpha" }
jolt-sdk = { git = "https://github.com/a16z/jolt.git", tag = "v0.3.0-alpha", default-features = false }
# Miden dependencies
miden-assembly = { git = "https://github.com/0xPolygonMiden/miden-vm.git", tag = "v0.18.3" }
@@ -82,9 +94,10 @@ miden-stdlib = { git = "https://github.com/0xPolygonMiden/miden-vm.git", tag = "
miden-verifier = { git = "https://github.com/0xPolygonMiden/miden-vm.git", tag = "v0.18.3" }
# Nexus dependencies
nexus-sdk = { git = "https://github.com/nexus-xyz/nexus-zkvm.git", tag = "v0.3.5" }
nexus-core = { git = "https://github.com/nexus-xyz/nexus-zkvm.git", tag = "v0.3.5" }
nexus-sdk = { git = "https://github.com/nexus-xyz/nexus-zkvm.git", tag = "v0.3.5" }
nexus-vm = { git = "https://github.com/nexus-xyz/nexus-zkvm.git", tag = "v0.3.5" }
nexus-rt = { git = "https://github.com/nexus-xyz/nexus-zkvm.git", tag = "v0.3.5" }
# OpenVM dependencies
openvm-build = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.1" }
@@ -93,25 +106,33 @@ openvm-continuations = { git = "https://github.com/openvm-org/openvm.git", tag =
openvm-sdk = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.1" }
openvm-stark-sdk = { git = "https://github.com/openvm-org/stark-backend.git", tag = "v1.2.1" }
openvm-transpiler = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.1" }
openvm = { git = "https://github.com/openvm-org/openvm.git", tag = "v1.4.1", default-features = false }
# Pico dependencies
pico-p3-field = { git = "https://github.com/brevis-network/Plonky3.git", package = "p3-field", rev = "a4d376b" }
pico-vm = { git = "https://github.com/brevis-network/pico.git", tag = "v1.1.7" }
pico-sdk = { git = "https://github.com/brevis-network/pico", tag = "v1.1.7" }
# Risc0 dependencies
risc0-binfmt = { version = "3.0.2", default-features = false }
risc0-build = "3.0.3"
risc0-zkp = { version = "3.0.2", default-features = false }
risc0-zkvm = { version = "3.0.3", default-features = false }
risc0-binfmt = { version = "3.0.2", default-features = false }
# SP1 dependencies
sp1-sdk = "5.2.2"
sp1-zkvm = "5.2.2"
# Ziren dependencies
zkm-sdk = { git = "https://github.com/ProjectZKM/Ziren.git", tag = "v1.2.1" }
zkm-zkvm = { git = "https://github.com/ProjectZKM/Ziren.git", tag = "v1.2.1" }
# ZisK dependencies
ziskos = { git = "https://github.com/0xPolygonHermez/zisk.git", tag = "v0.13.0" }
# Local dependencies
ere-zkvm-interface = { path = "crates/zkvm-interface" }
ere-platform-trait = { path = "crates/zkvm-interface/platform" }
ere-airbender = { path = "crates/zkvm/airbender", default-features = false }
ere-jolt = { path = "crates/zkvm/jolt", default-features = false }
@@ -124,6 +145,16 @@ ere-sp1 = { path = "crates/zkvm/sp1", default-features = false }
ere-ziren = { path = "crates/zkvm/ziren", default-features = false }
ere-zisk = { path = "crates/zkvm/zisk", default-features = false }
ere-platform-airbender = { path = "crates/zkvm/airbender/platform" }
ere-platform-jolt = { path = "crates/zkvm/jolt/platform" }
ere-platform-nexus = { path = "crates/zkvm/nexus/platform" }
ere-platform-openvm = { path = "crates/zkvm/openvm/platform" }
ere-platform-pico = { path = "crates/zkvm/pico/platform" }
ere-platform-risc0 = { path = "crates/zkvm/risc0/platform" }
ere-platform-sp1 = { path = "crates/zkvm/sp1/platform" }
ere-platform-ziren = { path = "crates/zkvm/ziren/platform" }
ere-platform-zisk = { path = "crates/zkvm/zisk/platform" }
ere-compiler = { path = "crates/dockerized/compiler" }
ere-dockerized = { path = "crates/dockerized/dockerized" }
ere-server = { path = "crates/dockerized/server" }

View File

@@ -29,6 +29,7 @@ fn generate_zkvm_sdk_version_impl() {
risc0_version,
sp1_version,
ziren_version,
zisk_version,
] = [
"execution_utils",
"jolt-sdk",
@@ -39,16 +40,10 @@ fn generate_zkvm_sdk_version_impl() {
"risc0-zkvm",
"sp1-sdk",
"zkm-sdk",
"ziskos",
]
.map(detect_sdk_version);
// FIXME: ZisK doesn't depend on SDK yet, so we hardcode the version here,
// same as the one in `scripts/sdk_installers/install_zisk_sdk.sh`.
// Once ZisK's SDK is ready, we should update this to detect the SDK
// version.
// The issue for tracking https://github.com/eth-act/ere/issues/73.
let zisk_version = "0.13.0";
let zkvm_sdk_version_impl = format!(
r#"impl crate::ErezkVM {{
pub fn sdk_version(&self) -> &'static str {{

View File

@@ -12,7 +12,9 @@ sha2.workspace = true
# Local dependencies
ere-zkvm-interface = { workspace = true, optional = true }
ere-platform-trait.workspace = true
ere-io-serde.workspace = true
[lints]
workspace = true

View File

@@ -1,12 +1 @@
use alloc::vec::Vec;
pub use sha2::{Digest, Sha256};
/// Platform dependent methods.
pub trait Platform {
/// Read the whole input at once from host.
fn read_input() -> Vec<u8>;
/// Write the whole output at once to host.
fn write_output(output: &[u8]);
}
pub use sha2::Sha256;

View File

@@ -1,6 +1,6 @@
use crate::guest::Platform;
use core::fmt::Debug;
use ere_io_serde::IoSerde;
use ere_platform_trait::Platform;
use serde::{Serialize, de::DeserializeOwned};
pub mod basic;
@@ -16,9 +16,9 @@ pub trait Program {
fn run<P: Platform>() {
let io_serde = Self::io_serde();
let input = io_serde.deserialize(&P::read_input()).unwrap();
let input = io_serde.deserialize(&P::read_whole_input()).unwrap();
let output = io_serde.serialize(&Self::compute(input)).unwrap();
P::write_output(&output);
P::write_whole_output(&output);
}
}

View File

@@ -0,0 +1,16 @@
[package]
name = "ere-platform-trait"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
[dependencies]
digest = { workspace = true, optional = true }
[features]
default = []
output-hasher = ["dep:digest"]
[lints]
workspace = true

View File

@@ -0,0 +1,21 @@
#![no_std]
extern crate alloc;
use alloc::vec::Vec;
#[cfg(feature = "output-hasher")]
pub mod output_hasher;
/// Platform dependent methods.
pub trait Platform {
/// Read the whole input at once from host.
///
/// Note that this function should only be called once.
fn read_whole_input() -> Vec<u8>;
/// Write the whole output at once to host.
///
/// Note that this function should only be called once.
fn write_whole_output(output: &[u8]);
}

View File

@@ -0,0 +1,57 @@
use core::marker::PhantomData;
use digest::{Digest, Output, OutputSizeUser, generic_array::ArrayLength};
pub use digest;
/// A hasher that given the output, returns a fixed size hash of it.
pub trait OutputHasher: OutputSizeUser {
fn output_hash(output: &[u8]) -> Output<Self>;
}
/// [`OutputHasher`] implementation that expects the output size to be equal to
/// the fixed size, and returns it as is.
pub struct IdentityOutput<S>(PhantomData<S>);
impl<S: ArrayLength<u8> + 'static> OutputSizeUser for IdentityOutput<S> {
type OutputSize = S;
}
impl<S: ArrayLength<u8> + 'static> OutputHasher for IdentityOutput<S> {
fn output_hash(output: &[u8]) -> Output<Self> {
assert!(
output.len() == Self::output_size(),
"output length should be equal to {}",
Self::output_size()
);
let mut hash = Output::<Self>::default();
hash.copy_from_slice(output);
hash
}
}
/// [`OutputHasher`] implementation that expects the output size to be less than
/// or equal to the fixed size, and returns it with 0s padding.
pub struct PaddedOutput<S>(PhantomData<S>);
impl<S: ArrayLength<u8> + 'static> OutputSizeUser for PaddedOutput<S> {
type OutputSize = S;
}
impl<S: ArrayLength<u8> + 'static> OutputHasher for PaddedOutput<S> {
fn output_hash(output: &[u8]) -> Output<Self> {
assert!(
output.len() <= Self::output_size(),
"output length should be less than or equal to {}",
Self::output_size()
);
let mut hash = Output::<Self>::default();
hash[..output.len()].copy_from_slice(output);
hash
}
}
impl<D: Digest> OutputHasher for D {
fn output_hash(output: &[u8]) -> Output<Self> {
D::digest(output)
}
}

View File

@@ -0,0 +1,22 @@
[package]
name = "ere-platform-airbender"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
[dependencies]
# Airbender dependencies
airbender_riscv_common.workspace = true
# Local dependencies
ere-platform-trait = { workspace = true, features = ["output-hasher"] }
[features]
default = []
uart = ["airbender_riscv_common/uart"]
custom_panic = ["airbender_riscv_common/custom_panic"]
custom_allocator = ["airbender_riscv_common/custom_allocator"]
[lints]
workspace = true

View File

@@ -0,0 +1,32 @@
#![no_std]
extern crate alloc;
use alloc::vec::Vec;
use core::{array, iter::repeat_with, marker::PhantomData};
use ere_platform_trait::output_hasher::{OutputHasher, digest::typenum::U32};
pub use airbender_riscv_common as riscv_common;
pub use ere_platform_trait::{
Platform,
output_hasher::{IdentityOutput, PaddedOutput},
};
pub struct AirbenderPlatform<D>(PhantomData<D>);
impl<D: OutputHasher<OutputSize = U32>> Platform for AirbenderPlatform<D> {
fn read_whole_input() -> Vec<u8> {
let len = riscv_common::csr_read_word() as usize;
repeat_with(riscv_common::csr_read_word)
.take(len.div_ceil(4))
.flat_map(u32::to_le_bytes)
.take(len)
.collect()
}
fn write_whole_output(output: &[u8]) {
let hash = D::output_hash(output);
let words = array::from_fn(|i| u32::from_le_bytes(array::from_fn(|j| hash[4 * i + j])));
riscv_common::zksync_os_finish_success(&words);
}
}

View File

@@ -0,0 +1,22 @@
[package]
name = "ere-platform-jolt"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
[dependencies]
postcard = { workspace = true, features = ["alloc"] }
# Jolt dependencies
jolt-sdk.workspace = true
# Local dependencies
ere-platform-trait.workspace = true
[features]
default = ["jolt-sdk/default"]
guest-std = ["jolt-sdk/guest-std"]
[lints]
workspace = true

View File

@@ -0,0 +1,87 @@
#![no_std]
extern crate alloc;
use alloc::vec::Vec;
use core::{marker::PhantomData, slice};
pub use ere_platform_trait::Platform;
pub use jolt_sdk as jolt;
// FIXME: Because the crate `jolt-common` is not `no_std` compatible, so we have
// to temporarily copy-paste these contant and memory layout calculation.
pub const RAM_START_ADDRESS: u64 = 0x80000000;
pub const DEFAULT_MEMORY_SIZE: u64 = 32 * 1024 * 1024;
pub const DEFAULT_STACK_SIZE: u64 = 4096;
pub const DEFAULT_MAX_INPUT_SIZE: u64 = 4096;
pub const DEFAULT_MAX_OUTPUT_SIZE: u64 = 4096;
pub const DEFAULT_MAX_TRACE_LENGTH: u64 = 1 << 24;
pub struct JoltMemoryLayout {
max_input_size: u64,
max_output_size: u64,
input_start: u64,
output_start: u64,
}
pub trait JoltMemoryConfig {
const MAX_INPUT_SIZE: u64;
const MAX_OUTPUT_SIZE: u64;
const STACK_SIZE: u64;
const MEMORY_SIZE: u64;
// According to https://github.com/a16z/jolt/blob/v0.3.0-alpha/common/src/jolt_device.rs#L181.
fn memory_layout() -> JoltMemoryLayout {
let max_input_size = Self::MAX_INPUT_SIZE.next_multiple_of(8);
let max_output_size = Self::MAX_OUTPUT_SIZE.next_multiple_of(8);
let io_region_bytes = max_input_size
.checked_add(max_output_size)
.unwrap()
.checked_add(16)
.unwrap();
let io_region_words = (io_region_bytes / 8).next_power_of_two();
let io_bytes = io_region_words.checked_mul(8).unwrap();
let input_start = RAM_START_ADDRESS.checked_sub(io_bytes).unwrap();
let output_start = input_start.checked_add(max_input_size).unwrap();
JoltMemoryLayout {
max_input_size,
max_output_size,
input_start,
output_start,
}
}
}
pub struct DefaulJoltMemoryConfig;
impl JoltMemoryConfig for DefaulJoltMemoryConfig {
const MAX_INPUT_SIZE: u64 = DEFAULT_MAX_INPUT_SIZE;
const MAX_OUTPUT_SIZE: u64 = DEFAULT_MAX_OUTPUT_SIZE;
const STACK_SIZE: u64 = DEFAULT_STACK_SIZE;
const MEMORY_SIZE: u64 = DEFAULT_MEMORY_SIZE;
}
pub struct JoltPlatform<C = DefaulJoltMemoryConfig>(PhantomData<C>);
impl<C: JoltMemoryConfig> Platform for JoltPlatform<C> {
fn read_whole_input() -> Vec<u8> {
let memory_layout = C::memory_layout();
let input_ptr = memory_layout.input_start as *const u8;
let max_input_len = memory_layout.max_input_size as usize;
let input_slice = unsafe { slice::from_raw_parts(input_ptr, max_input_len) };
let (input, _) = jolt::postcard::take_from_bytes(input_slice).unwrap();
input
}
fn write_whole_output(output: &[u8]) {
let memory_layout = C::memory_layout();
let output_ptr = memory_layout.output_start as *mut u8;
let max_output_len = memory_layout.max_output_size as usize;
let output_slice = unsafe { core::slice::from_raw_parts_mut(output_ptr, max_output_len) };
jolt::postcard::to_slice(output, output_slice).unwrap();
}
}

View File

@@ -21,8 +21,6 @@ const RUSTFLAGS: &[&str] = &[
"getrandom_backend=\"custom\"",
];
const CARGO_BUILD_OPTIONS: &[&str] = &[
"--features",
"guest",
// For bare metal we have to build core and alloc
"-Zbuild-std=core,alloc",
];

View File

@@ -0,0 +1,19 @@
[package]
name = "ere-platform-nexus"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
[dependencies]
# Nexus dependencies
nexus-rt.workspace = true
# Local dependencies
ere-platform-trait.workspace = true
[features]
default = []
[lints]
workspace = true

View File

@@ -0,0 +1,20 @@
#![no_std]
extern crate alloc;
use alloc::vec::Vec;
pub use ere_platform_trait::Platform;
pub use nexus_rt;
pub struct NexusPlatform;
impl Platform for NexusPlatform {
fn read_whole_input() -> Vec<u8> {
nexus_rt::read_private_input().unwrap()
}
fn write_whole_output(output: &[u8]) {
nexus_rt::write_public_output(&output).unwrap()
}
}

View File

@@ -0,0 +1,22 @@
[package]
name = "ere-platform-openvm"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
[dependencies]
# Openvm dependencies
openvm.workspace = true
# Local dependencies
ere-platform-trait = { workspace = true, features = ["output-hasher"] }
[features]
default = ["getrandom-unsupported"]
getrandom-unsupported = ["openvm/getrandom-unsupported"]
heap-embedded-alloc = ["openvm/heap-embedded-alloc"]
std = ["openvm/std"]
[lints]
workspace = true

View File

@@ -0,0 +1,26 @@
#![no_std]
extern crate alloc;
use alloc::vec::Vec;
use core::marker::PhantomData;
use ere_platform_trait::output_hasher::{OutputHasher, digest::typenum::U32};
pub use ere_platform_trait::{
Platform,
output_hasher::{IdentityOutput, PaddedOutput},
};
pub use openvm;
pub struct OpenVMPlatform<D>(PhantomData<D>);
impl<D: OutputHasher<OutputSize = U32>> Platform for OpenVMPlatform<D> {
fn read_whole_input() -> Vec<u8> {
openvm::io::read_vec()
}
fn write_whole_output(output: &[u8]) {
let hash = D::output_hash(output);
openvm::io::reveal_bytes32(hash.into());
}
}

View File

@@ -0,0 +1,19 @@
[package]
name = "ere-platform-pico"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
[dependencies]
# Pico dependencies
pico-sdk.workspace = true
# Local dependencies
ere-platform-trait.workspace = true
[features]
default = []
[lints]
workspace = true

View File

@@ -0,0 +1,20 @@
#![no_std]
extern crate alloc;
use alloc::vec::Vec;
pub use ere_platform_trait::Platform;
pub use pico_sdk;
pub struct PicoPlatform;
impl Platform for PicoPlatform {
fn read_whole_input() -> Vec<u8> {
pico_sdk::io::read_vec()
}
fn write_whole_output(output: &[u8]) {
pico_sdk::io::commit_bytes(output);
}
}

View File

@@ -0,0 +1,23 @@
[package]
name = "ere-platform-risc0"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
[dependencies]
# Risc0 dependencies
risc0-zkvm.workspace = true
# Local dependencies
ere-platform-trait.workspace = true
[features]
default = []
getrandom = ["risc0-zkvm/getrandom"]
heap-embedded-alloc = ["risc0-zkvm/heap-embedded-alloc"]
std = ["risc0-zkvm/std"]
unstable = ["risc0-zkvm/unstable"]
[lints]
workspace = true

View File

@@ -0,0 +1,27 @@
#![no_std]
extern crate alloc;
use alloc::{vec, vec::Vec};
pub use ere_platform_trait::Platform;
pub use risc0_zkvm;
pub struct Risc0Platform;
impl Platform for Risc0Platform {
fn read_whole_input() -> Vec<u8> {
let len = {
let mut bytes = [0; 4];
risc0_zkvm::guest::env::read_slice(&mut bytes);
u32::from_le_bytes(bytes)
};
let mut input = vec![0u8; len as usize];
risc0_zkvm::guest::env::read_slice(&mut input);
input
}
fn write_whole_output(output: &[u8]) {
risc0_zkvm::guest::env::commit_slice(output);
}
}

View File

@@ -85,6 +85,7 @@ impl zkVM for EreRisc0 {
fn execute(&self, input: &[u8]) -> anyhow::Result<(PublicValues, ProgramExecutionReport)> {
let executor = default_executor();
let env = ExecutorEnv::builder()
.write_slice(&(input.len() as u32).to_le_bytes())
.write_slice(input)
.build()
.map_err(Error::BuildExecutorEnv)?;
@@ -135,6 +136,7 @@ impl zkVM for EreRisc0 {
};
let env = ExecutorEnv::builder()
.write_slice(&(input.len() as u32).to_le_bytes())
.write_slice(input)
.segment_limit_po2(self.segment_po2 as _)
.keccak_max_po2(self.keccak_po2 as _)

View File

@@ -0,0 +1,24 @@
[package]
name = "ere-platform-sp1"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
[dependencies]
# SP1 dependencies
sp1-zkvm.workspace = true
# Local dependencies
ere-platform-trait.workspace = true
[features]
default = ["lib", "libm"]
blake3 = ["sp1-zkvm/blake3"]
embedded = ["sp1-zkvm/embedded"]
lib = ["sp1-zkvm/lib"]
libm = ["sp1-zkvm/libm"]
verify = ["sp1-zkvm/verify"]
[lints]
workspace = true

View File

@@ -0,0 +1,20 @@
#![no_std]
extern crate alloc;
use alloc::vec::Vec;
pub use ere_platform_trait::Platform;
pub use sp1_zkvm;
pub struct SP1Platform;
impl Platform for SP1Platform {
fn read_whole_input() -> Vec<u8> {
sp1_zkvm::io::read_vec()
}
fn write_whole_output(output: &[u8]) {
sp1_zkvm::io::commit_slice(output);
}
}

View File

@@ -0,0 +1,19 @@
[package]
name = "ere-platform-ziren"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
[dependencies]
# Ziren dependencies
zkm-zkvm.workspace = true
# Local dependencies
ere-platform-trait.workspace = true
[features]
default = []
[lints]
workspace = true

View File

@@ -0,0 +1,20 @@
#![no_std]
extern crate alloc;
use alloc::vec::Vec;
pub use ere_platform_trait::Platform;
pub use zkm_zkvm;
pub struct ZirenPlatform;
impl Platform for ZirenPlatform {
fn read_whole_input() -> Vec<u8> {
zkm_zkvm::io::read_vec()
}
fn write_whole_output(output: &[u8]) {
zkm_zkvm::io::commit_slice(output);
}
}

View File

@@ -1,5 +1,5 @@
use ere_build_utils::gen_name_and_sdk_version;
use ere_build_utils::detect_and_generate_name_and_sdk_version;
fn main() {
gen_name_and_sdk_version("zisk", "0.13.0");
detect_and_generate_name_and_sdk_version("zisk", "ziskos");
}

View File

@@ -0,0 +1,19 @@
[package]
name = "ere-platform-zisk"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
[dependencies]
# ZisK dependencies
ziskos.workspace = true
# Local dependencies
ere-platform-trait = { workspace = true, features = ["output-hasher"] }
[features]
default = []
[lints]
workspace = true

View File

@@ -0,0 +1,28 @@
#![no_std]
extern crate alloc;
use alloc::vec::Vec;
use core::marker::PhantomData;
use ere_platform_trait::output_hasher::{OutputHasher, digest::typenum::U32};
pub use ere_platform_trait::{
Platform,
output_hasher::{IdentityOutput, PaddedOutput},
};
pub use ziskos;
pub struct ZiskPlatform<D>(PhantomData<D>);
impl<D: OutputHasher<OutputSize = U32>> Platform for ZiskPlatform<D> {
fn read_whole_input() -> Vec<u8> {
ziskos::read_input()
}
fn write_whole_output(output: &[u8]) {
let hash = D::output_hash(output);
hash.chunks_exact(4).enumerate().for_each(|(idx, bytes)| {
ziskos::set_output(idx, u32::from_le_bytes(bytes.try_into().unwrap()))
});
}
}

View File

@@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"
[dependencies]
riscv_common = { git = "https://github.com/matter-labs/zksync-airbender", features = ["custom_allocator"], tag = "v0.5.0" }
ere-platform-airbender = { path = "../../../crates/zkvm/airbender/platform", features = ["custom_allocator"] }
ere-test-utils = { path = "../../../crates/test-utils" }
[workspace]

View File

@@ -5,38 +5,15 @@
#![feature(allocator_api)]
#![feature(generic_const_exprs)]
extern crate alloc;
use alloc::vec::Vec;
use core::{array, iter::repeat_with};
use ere_platform_airbender::AirbenderPlatform;
use ere_test_utils::{
guest::{Digest, Platform, Sha256},
guest::Sha256,
program::{basic::BasicProgram, Program},
};
use riscv_common::{csr_read_word, zksync_os_finish_success};
mod airbender_rt;
struct AirbenderPlatform;
impl Platform for AirbenderPlatform {
fn read_input() -> Vec<u8> {
let len = csr_read_word() as usize;
repeat_with(csr_read_word)
.take(len.div_ceil(4))
.flat_map(|word| word.to_le_bytes())
.take(len)
.collect()
}
fn write_output(output: &[u8]) {
let digest = Sha256::digest(output);
let words = array::from_fn(|i| u32::from_le_bytes(array::from_fn(|j| digest[4 * i + j])));
zksync_os_finish_success(&words);
}
}
#[inline(never)]
fn main() {
BasicProgram::run::<AirbenderPlatform>();
BasicProgram::run::<AirbenderPlatform<Sha256>>();
}

View File

@@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"
[dependencies]
jolt = { git = "https://github.com/a16z/jolt", package = "jolt-sdk", tag = "v0.3.0-alpha" }
ere-platform-jolt = { path = "../../../crates/zkvm/jolt/platform" }
ere-test-utils = { path = "../../../crates/test-utils" }
[features]

View File

@@ -3,31 +3,10 @@
extern crate alloc;
use alloc::vec::Vec;
use core::mem;
use ere_test_utils::{
guest::Platform,
program::{basic::BasicProgram, Program},
};
static mut INPUT: Vec<u8> = Vec::new();
static mut OUTPUT: Vec<u8> = Vec::new();
struct JoltPlatform;
impl Platform for JoltPlatform {
fn read_input() -> Vec<u8> {
unsafe { mem::take(&mut INPUT) }
}
fn write_output(output: &[u8]) {
unsafe { mem::replace(&mut OUTPUT, output.to_vec()) };
}
}
use ere_platform_jolt::{jolt, JoltPlatform};
use ere_test_utils::program::{basic::BasicProgram, Program};
#[jolt::provable(guest_only)]
fn main(input: Vec<u8>) -> Vec<u8> {
unsafe { mem::replace(&mut INPUT, input) };
fn main() {
BasicProgram::run::<JoltPlatform>();
unsafe { mem::take(&mut OUTPUT) }
}

View File

@@ -2,10 +2,4 @@
name = "addition_no_std"
edition = "2021"
[dependencies]
jolt = { git = "https://github.com/a16z/jolt", package = "jolt-sdk", tag = "v0.3.0-alpha" }
[features]
guest = []
[workspace]

View File

@@ -0,0 +1,76 @@
use core::{
alloc::{GlobalAlloc, Layout},
panic::PanicInfo,
};
// According to https://github.com/a16z/jolt/blob/v0.3.0-alpha/common/src/jolt_device.rs#L139
const DEFAULT_TERMINATION_ADDR: usize = 2147475464;
const DEFAULT_PANIC_ADDR: usize = 2147475456;
// According to https://github.com/a16z/jolt/blob/v0.3.0-alpha/jolt-sdk/macros/src/lib.rs#L545
core::arch::global_asm!(
r#"
.global _start
.extern _STACK_PTR
.section .text.boot
_start:
la sp, _STACK_PTR
call main
j .
"#
);
#[no_mangle]
pub extern "C" fn main() {
crate::main();
unsafe { core::ptr::write_volatile(DEFAULT_TERMINATION_ADDR as *mut u8, 1) };
}
// According to https://github.com/a16z/jolt/blob/v0.3.0-alpha/jolt-sdk/macros/src/lib.rs#L594
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
unsafe { core::ptr::write_volatile(DEFAULT_PANIC_ADDR as *mut u8, 1) };
loop {}
}
#[global_allocator]
static ALLOCATOR: BumpAllocator = BumpAllocator;
// According to https://github.com/a16z/jolt/blob/v0.3.0-alpha/jolt-platform/src/alloc.rs
pub struct BumpAllocator;
unsafe impl GlobalAlloc for BumpAllocator {
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
sys_alloc(layout.size(), layout.align())
}
unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {}
}
extern "C" {
static _HEAP_PTR: u8;
}
static mut ALLOC_NEXT: usize = 0;
#[allow(clippy::missing_safety_doc)]
#[no_mangle]
pub unsafe extern "C" fn sys_alloc(size: usize, align: usize) -> *mut u8 {
let mut next = unsafe { ALLOC_NEXT };
if next == 0 {
next = unsafe { (&_HEAP_PTR) as *const u8 as usize };
}
next = align_up(next, align);
let ptr = next as *mut u8;
next += size;
unsafe { ALLOC_NEXT = next };
ptr
}
fn align_up(addr: usize, align: usize) -> usize {
(addr + align - 1) & !(align - 1)
}

View File

@@ -1,12 +1,14 @@
#![no_std]
#![no_main]
extern crate alloc;
use alloc::vec::Vec;
use core::sync::atomic::AtomicU16;
use core::sync::atomic::Ordering;
#[jolt::provable(guest_only)]
mod jolt_rt;
fn main() {
let a: AtomicU16 = core::hint::black_box(AtomicU16::new(5));
let b: AtomicU16 = core::hint::black_box(AtomicU16::new(7));

View File

@@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"
[dependencies]
nexus-rt = { git = "https://github.com/nexus-xyz/nexus-zkvm.git", tag = "v0.3.5" }
ere-platform-nexus = { path = "../../../crates/zkvm/nexus/platform" }
ere-test-utils = { path = "../../../crates/test-utils" }
[workspace]

View File

@@ -1,25 +1,7 @@
#![cfg_attr(target_arch = "riscv32", no_std, no_main)]
extern crate alloc;
use alloc::vec::Vec;
use ere_test_utils::{
guest::Platform,
program::{basic::BasicProgram, Program},
};
use nexus_rt::{read_private_input, write_public_output};
struct NexusPlatform;
impl Platform for NexusPlatform {
fn read_input() -> Vec<u8> {
read_private_input().unwrap()
}
fn write_output(output: &[u8]) {
write_public_output(&output).unwrap()
}
}
use ere_platform_nexus::{nexus_rt, NexusPlatform};
use ere_test_utils::program::{basic::BasicProgram, Program};
#[nexus_rt::main]
fn main() {

View File

@@ -6,5 +6,5 @@ edition = "2021"
[workspace]
[dependencies]
openvm = { git = "https://github.com/openvm-org/openvm.git", features = ["std"], tag = "v1.4.1" }
ere-platform-openvm = { path = "../../../crates/zkvm/openvm/platform", features = ["std"] }
ere-test-utils = { path = "../../../crates/test-utils" }

View File

@@ -1,22 +1,9 @@
use ere_platform_openvm::OpenVMPlatform;
use ere_test_utils::{
guest::{Digest, Platform, Sha256},
guest::Sha256,
program::{basic::BasicProgram, Program},
};
use openvm::io::{read_vec, reveal_bytes32};
struct OpenVMPlatform;
impl Platform for OpenVMPlatform {
fn read_input() -> Vec<u8> {
read_vec()
}
fn write_output(output: &[u8]) {
let digest = Sha256::digest(output);
reveal_bytes32(digest.into());
}
}
fn main() {
BasicProgram::run::<OpenVMPlatform>();
BasicProgram::run::<OpenVMPlatform<Sha256>>();
}

View File

@@ -6,5 +6,5 @@ edition = "2024"
[workspace]
[dependencies]
pico-sdk = { git = "https://github.com/brevis-network/pico", tag = "v1.1.7" }
ere-platform-pico = { path = "../../../crates/zkvm/pico/platform" }
ere-test-utils = { path = "../../../crates/test-utils" }

View File

@@ -1,25 +1,10 @@
#![no_main]
use ere_test_utils::{
guest::Platform,
program::{basic::BasicProgram, Program},
};
use pico_sdk::io::{commit_bytes, read_vec};
use ere_platform_pico::{pico_sdk, PicoPlatform};
use ere_test_utils::program::{basic::BasicProgram, Program};
pico_sdk::entrypoint!(main);
struct PicoPlatform;
impl Platform for PicoPlatform {
fn read_input() -> Vec<u8> {
read_vec()
}
fn write_output(output: &[u8]) {
commit_bytes(output);
}
}
pub fn main() {
BasicProgram::run::<PicoPlatform>();
}

View File

@@ -6,7 +6,4 @@ edition = "2021"
[workspace]
[dependencies]
risc0-zkvm = { version = "3.0.3", default-features = false, features = [
"std",
"unstable",
] }
ere-platform-risc0 = { path = "../../../crates/zkvm/risc0/platform", default-features = false, features = ["std", "unstable"] }

View File

@@ -1,11 +1,8 @@
use risc0_zkvm::guest::env;
use ere_platform_risc0::{Platform, Risc0Platform};
fn main() {
let alignment = {
let mut buf = [0; 4];
env::read_slice(&mut buf);
u32::from_le_bytes(buf) as usize
};
let alignment =
u32::from_le_bytes(Risc0Platform::read_whole_input().try_into().unwrap()) as usize;
let layout = std::alloc::Layout::from_size_align(1, alignment).unwrap();
let ptr = unsafe { std::alloc::alloc(layout) };

View File

@@ -6,5 +6,5 @@ edition = "2021"
[workspace]
[dependencies]
risc0-zkvm = { version = "3.0.3", default-features = false, features = ["std", "unstable"] }
ere-platform-risc0 = { path = "../../../crates/zkvm/risc0/platform", default-features = false, features = ["std", "unstable"] }
ere-test-utils = { path = "../../../crates/test-utils" }

View File

@@ -1,23 +1,5 @@
use ere_test_utils::{
guest::Platform,
program::{basic::BasicProgram, Program},
};
use risc0_zkvm::guest::env;
use std::io::Read;
struct Risc0Platform;
impl Platform for Risc0Platform {
fn read_input() -> Vec<u8> {
let mut input = Vec::new();
env::stdin().read_to_end(&mut input).unwrap();
input
}
fn write_output(output: &[u8]) {
env::commit_slice(output);
}
}
use ere_platform_risc0::Risc0Platform;
use ere_test_utils::program::{basic::BasicProgram, Program};
fn main() {
BasicProgram::run::<Risc0Platform>();

View File

@@ -6,5 +6,5 @@ edition = "2021"
[workspace]
[dependencies]
sp1-zkvm = "5.2.2"
ere-platform-sp1 = { path = "../../../crates/zkvm/sp1/platform" }
ere-test-utils = { path = "../../../crates/test-utils" }

View File

@@ -1,24 +1,10 @@
#![no_main]
use ere_test_utils::{
guest::Platform,
program::{basic::BasicProgram, Program},
};
use ere_platform_sp1::{sp1_zkvm, SP1Platform};
use ere_test_utils::program::{basic::BasicProgram, Program};
sp1_zkvm::entrypoint!(main);
struct SP1Platform;
impl Platform for SP1Platform {
fn read_input() -> Vec<u8> {
sp1_zkvm::io::read_vec()
}
fn write_output(output: &[u8]) {
sp1_zkvm::io::commit_slice(output);
}
}
pub fn main() {
BasicProgram::run::<SP1Platform>();
}

View File

@@ -6,5 +6,5 @@ edition = "2021"
[workspace]
[dependencies]
zkm-zkvm = { git = "https://github.com/ProjectZKM/Ziren.git", tag = "v1.2.1" }
ere-platform-ziren = { path = "../../../crates/zkvm/ziren/platform" }
ere-test-utils = { path = "../../../crates/test-utils" }

View File

@@ -1,24 +1,10 @@
#![no_main]
use ere_test_utils::{
guest::Platform,
program::{basic::BasicProgram, Program},
};
use ere_platform_ziren::{zkm_zkvm, ZirenPlatform};
use ere_test_utils::program::{basic::BasicProgram, Program};
zkm_zkvm::entrypoint!(main);
struct ZirenPlatform;
impl Platform for ZirenPlatform {
fn read_input() -> Vec<u8> {
zkm_zkvm::io::read_vec()
}
fn write_output(output: &[u8]) {
zkm_zkvm::io::commit_slice(output);
}
}
pub fn main() {
BasicProgram::run::<ZirenPlatform>();
}

View File

@@ -6,5 +6,5 @@ edition = "2021"
[workspace]
[dependencies]
ziskos = { git = "https://github.com/0xPolygonHermez/zisk.git", tag = "v0.13.0" }
ere-platform-zisk = { path = "../../../crates/zkvm/zisk/platform" }
ere-test-utils = { path = "../../../crates/test-utils" }

View File

@@ -1,27 +1,13 @@
#![no_main]
use ere_platform_zisk::{ziskos, ZiskPlatform};
use ere_test_utils::{
guest::{Digest, Platform, Sha256},
guest::Sha256,
program::{basic::BasicProgram, Program},
};
ziskos::entrypoint!(main);
struct ZiskPlatform;
impl Platform for ZiskPlatform {
fn read_input() -> Vec<u8> {
ziskos::read_input()
}
fn write_output(output: &[u8]) {
let digest = Sha256::digest(output);
digest.chunks_exact(4).enumerate().for_each(|(idx, bytes)| {
ziskos::set_output(idx, u32::from_le_bytes(bytes.try_into().unwrap()))
});
}
}
fn main() {
BasicProgram::run::<ZiskPlatform>();
BasicProgram::run::<ZiskPlatform<Sha256>>();
}