mirror of
https://github.com/eth-act/ere.git
synced 2026-04-03 03:00:17 -04:00
add basic compile test for Jolt
This commit is contained in:
1
tests/jolt/compile/basic/.gitignore
vendored
Normal file
1
tests/jolt/compile/basic/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
target
|
||||
25
tests/jolt/compile/basic/Cargo.toml
Normal file
25
tests/jolt/compile/basic/Cargo.toml
Normal file
@@ -0,0 +1,25 @@
|
||||
[package]
|
||||
name = "basic"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[workspace]
|
||||
members = ["guest"]
|
||||
|
||||
[profile.release]
|
||||
debug = 1
|
||||
codegen-units = 1
|
||||
lto = "fat"
|
||||
|
||||
[dependencies]
|
||||
jolt-sdk = { git = "https://github.com/a16z/jolt", features = ["host"] }
|
||||
guest = { path = "./guest" }
|
||||
ark-serialize = "0.5.0"
|
||||
|
||||
[features]
|
||||
icicle = ["jolt-sdk/icicle"]
|
||||
|
||||
[patch.crates-io]
|
||||
ark-ff = { git = "https://github.com/a16z/arkworks-algebra", branch = "v0.5.0-optimize-mul-u64" }
|
||||
ark-ec = { git = "https://github.com/a16z/arkworks-algebra", branch = "v0.5.0-optimize-mul-u64" }
|
||||
ark-serialize = { git = "https://github.com/a16z/arkworks-algebra", branch = "v0.5.0-optimize-mul-u64" }
|
||||
10
tests/jolt/compile/basic/guest/Cargo.toml
Normal file
10
tests/jolt/compile/basic/guest/Cargo.toml
Normal file
@@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "guest"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[features]
|
||||
guest = []
|
||||
|
||||
[dependencies]
|
||||
jolt = { package = "jolt-sdk", git = "https://github.com/a16z/jolt" }
|
||||
15
tests/jolt/compile/basic/guest/src/lib.rs
Normal file
15
tests/jolt/compile/basic/guest/src/lib.rs
Normal file
@@ -0,0 +1,15 @@
|
||||
#![cfg_attr(feature = "guest", no_std)]
|
||||
|
||||
#[jolt::provable]
|
||||
fn fib(n: u32) -> u128 {
|
||||
let mut a: u128 = 0;
|
||||
let mut b: u128 = 1;
|
||||
let mut sum: u128;
|
||||
for _ in 1..n {
|
||||
sum = a + b;
|
||||
a = b;
|
||||
b = sum;
|
||||
}
|
||||
|
||||
// b
|
||||
}
|
||||
5
tests/jolt/compile/basic/guest/src/main.rs
Normal file
5
tests/jolt/compile/basic/guest/src/main.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
#![cfg_attr(feature = "guest", no_std)]
|
||||
#![no_main]
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use guest::*;
|
||||
3
tests/jolt/compile/basic/rust-toolchain.toml
Normal file
3
tests/jolt/compile/basic/rust-toolchain.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
[toolchain]
|
||||
channel = "nightly"
|
||||
targets = ["riscv32im-unknown-none-elf"]
|
||||
16
tests/jolt/compile/basic/src/main.rs
Normal file
16
tests/jolt/compile/basic/src/main.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
pub fn main() {
|
||||
let target_dir = "/tmp/jolt-guest-targets";
|
||||
let program = guest::compile_fib(target_dir);
|
||||
|
||||
let prover_preprocessing = guest::preprocess_prover_fib(&program);
|
||||
let verifier_preprocessing = guest::preprocess_verifier_fib(&program);
|
||||
|
||||
let prove_fib = guest::build_prover_fib(program, prover_preprocessing);
|
||||
let verify_fib = guest::build_verifier_fib(verifier_preprocessing);
|
||||
|
||||
let (output, proof) = prove_fib(50);
|
||||
let is_valid = verify_fib(50, output, proof);
|
||||
|
||||
println!("output: {output}");
|
||||
println!("valid: {is_valid}");
|
||||
}
|
||||
Reference in New Issue
Block a user