mirror of
https://github.com/logos-blockchain/lssa-zkvm-testing.git
synced 2026-01-10 01:03:09 +00:00
Add files via upload
This commit is contained in:
parent
e204db5cd9
commit
f44492b237
3444
temp_pedersen-tests/Cargo.lock
generated
Normal file
3444
temp_pedersen-tests/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
15
temp_pedersen-tests/Cargo.toml
Normal file
15
temp_pedersen-tests/Cargo.toml
Normal file
@ -0,0 +1,15 @@
|
||||
[workspace]
|
||||
resolver = "2"
|
||||
members = [ "host", "methods"]
|
||||
|
||||
# Always optimize; building and running the guest takes much longer without optimization.
|
||||
[profile.dev]
|
||||
opt-level = 3
|
||||
|
||||
[profile.release]
|
||||
debug = 1
|
||||
lto = true
|
||||
|
||||
[patch.crates-io.crypto-bigint]
|
||||
git = "https://github.com/risc0/RustCrypto-crypto-bigint"
|
||||
tag = "v0.5.5-risczero.0"
|
||||
13
temp_pedersen-tests/host/Cargo.toml
Normal file
13
temp_pedersen-tests/host/Cargo.toml
Normal file
@ -0,0 +1,13 @@
|
||||
[package]
|
||||
name = "host"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
shared = { path = "../../shared" }
|
||||
methods = { path = "../methods" }
|
||||
risc0-zkvm = "2.0.0"
|
||||
pasta_curves = "0.5.1"
|
||||
|
||||
[features]
|
||||
default = [ ]
|
||||
62
temp_pedersen-tests/host/src/main.rs
Normal file
62
temp_pedersen-tests/host/src/main.rs
Normal file
@ -0,0 +1,62 @@
|
||||
//use std::time::Instant;
|
||||
|
||||
use methods::NEBRA0_GUEST_ELF;
|
||||
// These constants represent the RISC-V ELF and the image ID generated by risc0-build.
|
||||
// The ELF is used for proving and the ID is used for verification
|
||||
use risc0_zkvm::{default_prover, ExecutorEnv};
|
||||
|
||||
use pasta_curves::group::Group;
|
||||
|
||||
fn main() {
|
||||
// Initialize tracing. In order to view logs, run `RUST_LOG=info cargo run`
|
||||
//tracing_subscriber::fmt()
|
||||
// .with_env_filter(tracing_subscriber::filter::EnvFilter::from_default_env())
|
||||
// .init();
|
||||
|
||||
// An executor environment describes the configurations for the zkVM
|
||||
// including program inputs.
|
||||
// An default ExecutorEnv can be created like so:
|
||||
// `let env = ExecutorEnv::builder().build().unwrap();`
|
||||
// However, this `env` does not have any inputs.
|
||||
//
|
||||
// To add add guest input to the executor environment, use
|
||||
// ExecutorEnvBuilder::write().
|
||||
// To access this method, you'll need to use ExecutorEnv::builder(), which
|
||||
// creates an ExecutorEnvBuilder. When you're done adding input, call
|
||||
// ExecutorEnvBuilder::build().
|
||||
|
||||
let g1 = pasta_curves::pallas::Point::generator();
|
||||
let g2 = g1 + g1;
|
||||
let g3 = g1 + g2;
|
||||
let g4 = g1 + g3;
|
||||
let g5 = g1 + g4;
|
||||
//should be public inputs...eventually
|
||||
|
||||
|
||||
// let elapsed = now.elapsed();
|
||||
|
||||
|
||||
// let inputs: Inputs = (
|
||||
// g1, g2, g3, g4, g5,
|
||||
//a1.to_repr(),
|
||||
//a2.to_repr(),
|
||||
//b1.to_repr(),
|
||||
//b2.to_repr(),
|
||||
//x2_minus_x1_inv.to_repr(),
|
||||
// );
|
||||
|
||||
//let now = Instant::now();
|
||||
let env = ExecutorEnv::builder()
|
||||
//.write(&inputs)
|
||||
//.unwrap()
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
// Obtain the default prover.
|
||||
let prover = default_prover();
|
||||
|
||||
// Produce a receipt by proving the specified ELF binary.
|
||||
//let now = Instant::now();
|
||||
let receipt = prover.prove(env, NEBRA0_GUEST_ELF).unwrap();
|
||||
//println!("proving time: {:?}", now.elapsed());
|
||||
}
|
||||
11
temp_pedersen-tests/methods/Cargo.toml
Normal file
11
temp_pedersen-tests/methods/Cargo.toml
Normal file
@ -0,0 +1,11 @@
|
||||
[package]
|
||||
name = "methods"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[build-dependencies]
|
||||
risc0-build = "2.0.0"
|
||||
pasta_curves = "0.5.1"
|
||||
|
||||
[package.metadata.risc0]
|
||||
methods = ["guest"]
|
||||
3
temp_pedersen-tests/methods/build.rs
Normal file
3
temp_pedersen-tests/methods/build.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
risc0_build::embed_methods();
|
||||
}
|
||||
3276
temp_pedersen-tests/methods/guest/Cargo.lock
generated
Normal file
3276
temp_pedersen-tests/methods/guest/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
25
temp_pedersen-tests/methods/guest/Cargo.toml
Normal file
25
temp_pedersen-tests/methods/guest/Cargo.toml
Normal file
@ -0,0 +1,25 @@
|
||||
[package]
|
||||
name = "nebra0_guest"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[workspace]
|
||||
|
||||
[profile.dev]
|
||||
opt-level = 3
|
||||
[profile.test]
|
||||
opt-level = 3
|
||||
[profile.release]
|
||||
opt-level = 3
|
||||
[profile.bench]
|
||||
opt-level = 3
|
||||
|
||||
|
||||
[dependencies]
|
||||
# If you want to try (experimental) std support, add `features = [ "std" ]` to risc0-zkvm
|
||||
risc0-zkvm = "2.0.0"
|
||||
pasta_curves= "0.5.1"
|
||||
|
||||
[patch.crates-io.crypto-bigint]
|
||||
git = "https://github.com/risc0/RustCrypto-crypto-bigint"
|
||||
tag = "v0.5.5-risczero.0"
|
||||
22
temp_pedersen-tests/methods/guest/build.rs
Normal file
22
temp_pedersen-tests/methods/guest/build.rs
Normal file
@ -0,0 +1,22 @@
|
||||
use std::{
|
||||
env,
|
||||
fs::File,
|
||||
io::{BufWriter, Write},
|
||||
};
|
||||
|
||||
fn main() {
|
||||
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
|
||||
if target_arch != "x86_64" {
|
||||
let mut w = BufWriter::new(File::create("platform_config").unwrap());
|
||||
|
||||
for (key, value) in env::vars() {
|
||||
if key.starts_with("CARGO_CFG_") {
|
||||
println!("{}: {:?}", key, value);
|
||||
w.write_fmt(format_args!("{}: {:?}\n", key, value)).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// // CARGO_CFG_TARGET_ARCH: "x86_64"
|
||||
// panic!("stop and dump stdout");
|
||||
}
|
||||
17
temp_pedersen-tests/methods/guest/platform_config
Normal file
17
temp_pedersen-tests/methods/guest/platform_config
Normal file
@ -0,0 +1,17 @@
|
||||
CARGO_CFG_FEATURE: ""
|
||||
CARGO_CFG_GETRANDOM_BACKEND: "custom"
|
||||
CARGO_CFG_OVERFLOW_CHECKS: ""
|
||||
CARGO_CFG_PANIC: "abort"
|
||||
CARGO_CFG_RELOCATION_MODEL: "static"
|
||||
CARGO_CFG_TARGET_ABI: ""
|
||||
CARGO_CFG_TARGET_ARCH: "riscv32"
|
||||
CARGO_CFG_TARGET_ENDIAN: "little"
|
||||
CARGO_CFG_TARGET_ENV: ""
|
||||
CARGO_CFG_TARGET_FEATURE: "m"
|
||||
CARGO_CFG_TARGET_HAS_ATOMIC: "16,32,64,8,ptr"
|
||||
CARGO_CFG_TARGET_HAS_ATOMIC_EQUAL_ALIGNMENT: "16,32,64,8,ptr"
|
||||
CARGO_CFG_TARGET_HAS_ATOMIC_LOAD_STORE: "16,32,64,8,ptr"
|
||||
CARGO_CFG_TARGET_OS: "zkvm"
|
||||
CARGO_CFG_TARGET_POINTER_WIDTH: "32"
|
||||
CARGO_CFG_TARGET_VENDOR: "risc0"
|
||||
CARGO_CFG_UB_CHECKS: ""
|
||||
33
temp_pedersen-tests/methods/guest/src/main.rs
Normal file
33
temp_pedersen-tests/methods/guest/src/main.rs
Normal file
@ -0,0 +1,33 @@
|
||||
#![no_main]
|
||||
// If you want to try std support, also update the guest Cargo.toml file
|
||||
// #![no_std] // std support is experimental
|
||||
|
||||
use pasta_curves::group::Group;
|
||||
|
||||
#[cfg(all(target_os = "zkvm", target_arch = "riscv32"))]
|
||||
|
||||
risc0_zkvm::guest::entry!(main);
|
||||
|
||||
|
||||
fn main() {
|
||||
// TODO: Implement your guest code here
|
||||
|
||||
|
||||
let g1 = pasta_curves::pallas::Point::generator();
|
||||
let g2 = g1 + g1;
|
||||
let g3 = g1 + g2;
|
||||
let g4 = g1 + g3;
|
||||
let g5 = g1 + g4;
|
||||
|
||||
let s1 = pasta_curves::pallas::Scalar::from(87329482u64);
|
||||
let s2 = pasta_curves::pallas::Scalar::from(37264829u64);
|
||||
let s3 = pasta_curves::pallas::Scalar::from(98098098u64);
|
||||
let s4 = pasta_curves::pallas::Scalar::from(63980948u64);
|
||||
let s5 = pasta_curves::pallas::Scalar::from(15098098u64);
|
||||
|
||||
let val = g1*s1 + g2*s2 + g3*s3 + g4*s4 + g5*s5;
|
||||
|
||||
//let now = Instant::now();
|
||||
//risc0_zkvm::guest::env::commit();
|
||||
|
||||
}
|
||||
1
temp_pedersen-tests/methods/src/lib.rs
Normal file
1
temp_pedersen-tests/methods/src/lib.rs
Normal file
@ -0,0 +1 @@
|
||||
include!(concat!(env!("OUT_DIR"), "/methods.rs"));
|
||||
4
temp_pedersen-tests/rust-toolchain.toml
Normal file
4
temp_pedersen-tests/rust-toolchain.toml
Normal file
@ -0,0 +1,4 @@
|
||||
[toolchain]
|
||||
channel = "stable"
|
||||
components = ["rustfmt", "rust-src"]
|
||||
profile = "minimal"
|
||||
Loading…
x
Reference in New Issue
Block a user