mirror of
https://github.com/logos-blockchain/lssa-zkvm-testing.git
synced 2026-01-08 08:13:10 +00:00
pedersen tests nexus
includes: bn254, pallas, vesta, jubjub, curve25519
This commit is contained in:
parent
e204db5cd9
commit
98d4fd2d2a
1
nexus/ped_bls12-381_test/.gitignore
vendored
Normal file
1
nexus/ped_bls12-381_test/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
||||
14
nexus/ped_bls12-381_test/Cargo.toml
Normal file
14
nexus/ped_bls12-381_test/Cargo.toml
Normal file
@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "ped_bls12-381_test"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
nexus-sdk = { git = "https://github.com/nexus-xyz/nexus-zkvm.git", tag = "0.3.4", version = "0.3.4" }
|
||||
|
||||
[workspace]
|
||||
members = [
|
||||
"src/guest"
|
||||
]
|
||||
|
||||
|
||||
2
nexus/ped_bls12-381_test/rust-toolchain.toml
Normal file
2
nexus/ped_bls12-381_test/rust-toolchain.toml
Normal file
@ -0,0 +1,2 @@
|
||||
[toolchain]
|
||||
channel = "nightly-2025-04-06"
|
||||
5
nexus/ped_bls12-381_test/src/guest/.cargo/config.toml
Normal file
5
nexus/ped_bls12-381_test/src/guest/.cargo/config.toml
Normal file
@ -0,0 +1,5 @@
|
||||
[target.riscv32i-unknown-none-elf]
|
||||
rustflags = [
|
||||
"-C", "link-arg=-Tlink.x",
|
||||
]
|
||||
runner="nexus-run"
|
||||
14
nexus/ped_bls12-381_test/src/guest/Cargo.toml
Normal file
14
nexus/ped_bls12-381_test/src/guest/Cargo.toml
Normal file
@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "guest"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
nexus-rt = { git = "https://github.com/nexus-xyz/nexus-zkvm.git", tag = "0.3.4", version = "0.3.4" }
|
||||
postcard = { version = "1.1.1", default-features = false, features = ["alloc"] }
|
||||
|
||||
# Generated by cargo-nexus, do not remove!
|
||||
#
|
||||
[features]
|
||||
cycles = [] # Enable cycle counting for run command
|
||||
|
||||
2
nexus/ped_bls12-381_test/src/guest/rust-toolchain.toml
Normal file
2
nexus/ped_bls12-381_test/src/guest/rust-toolchain.toml
Normal file
@ -0,0 +1,2 @@
|
||||
[toolchain]
|
||||
channel = "nightly-2025-04-06"
|
||||
8
nexus/ped_bls12-381_test/src/guest/src/main.rs
Normal file
8
nexus/ped_bls12-381_test/src/guest/src/main.rs
Normal file
@ -0,0 +1,8 @@
|
||||
#![cfg_attr(target_arch = "riscv32", no_std, no_main)]
|
||||
|
||||
use nexus_rt::print;
|
||||
|
||||
#[nexus_rt::main]
|
||||
fn main() {
|
||||
print!("Hello, World!\n");
|
||||
}
|
||||
65
nexus/ped_bls12-381_test/src/main.rs
Normal file
65
nexus/ped_bls12-381_test/src/main.rs
Normal file
@ -0,0 +1,65 @@
|
||||
use nexus_sdk::{
|
||||
compile::{cargo::CargoPackager, Compile, Compiler},
|
||||
stwo::seq::Stwo,
|
||||
ByGuestCompilation, Local, Prover, Verifiable, Viewable,
|
||||
};
|
||||
|
||||
const PACKAGE: &str = "guest";
|
||||
|
||||
fn main() {
|
||||
println!("Compiling guest program...");
|
||||
let mut prover_compiler = Compiler::<CargoPackager>::new(PACKAGE);
|
||||
let prover: Stwo<Local> =
|
||||
Stwo::compile(&mut prover_compiler).expect("failed to compile guest program");
|
||||
|
||||
let elf = prover.elf.clone(); // save elf for use with verification
|
||||
|
||||
println!("Proving execution of vm...");
|
||||
let (view, proof) = prover.prove().expect("failed to prove program");
|
||||
|
||||
println!(
|
||||
">>>>> Logging\n{}<<<<<",
|
||||
view.logs().expect("failed to retrieve debug logs").join("")
|
||||
);
|
||||
assert_eq!(
|
||||
view.exit_code().expect("failed to retrieve exit code"),
|
||||
nexus_sdk::KnownExitCodes::ExitSuccess as u32
|
||||
);
|
||||
|
||||
// Normally the prover communicates the seralized proof to the verifier who deserializes it.
|
||||
//
|
||||
// The verifier must also possess the program binary and the public i/o. Usually, either
|
||||
// the verifier will rebuild the elf in a reproducible way (e.g., within a container) or
|
||||
// the prover will communicate it to the verifier who will then check that it is a valid
|
||||
// compilation of the claimed guest program. Here we simulate the latter.
|
||||
//
|
||||
// If we instead wanted to simulate the former, it might look something like:
|
||||
//
|
||||
// println!("Verifier recompiling guest program...");
|
||||
// let mut verifier_compiler = Compiler::<CargoPackager>::new(PACKAGE);
|
||||
// let path = verifier_compiler.build().expect("failed to (re)compile guest program");
|
||||
//
|
||||
// print!("Verifying execution...");
|
||||
// proof.verify_expected_from_program_path::<&str, (), ()>(
|
||||
// &(), // no public input
|
||||
// nexus_sdk::KnownExitCodes::ExitSuccess as u32,
|
||||
// &(), // no public output
|
||||
// &path, // path to expected program binary
|
||||
// &[] // no associated data,
|
||||
// ).expect("failed to verify proof");
|
||||
|
||||
print!("Verifying execution...");
|
||||
|
||||
#[rustfmt::skip]
|
||||
proof
|
||||
.verify_expected::<(), ()>(
|
||||
&(), // no public input
|
||||
nexus_sdk::KnownExitCodes::ExitSuccess as u32,
|
||||
&(), // no public output
|
||||
&elf, // expected elf (program binary)
|
||||
&[], // no associated data,
|
||||
)
|
||||
.expect("failed to verify proof");
|
||||
|
||||
println!(" Succeeded!");
|
||||
}
|
||||
1
nexus/ped_bn254_test/.gitignore
vendored
Normal file
1
nexus/ped_bn254_test/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
||||
14
nexus/ped_bn254_test/Cargo.toml
Normal file
14
nexus/ped_bn254_test/Cargo.toml
Normal file
@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "ped_bn254_test"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
nexus-sdk = { git = "https://github.com/nexus-xyz/nexus-zkvm.git", tag = "0.3.4", version = "0.3.4" }
|
||||
|
||||
[workspace]
|
||||
members = [
|
||||
"src/guest"
|
||||
]
|
||||
|
||||
|
||||
2
nexus/ped_bn254_test/rust-toolchain.toml
Normal file
2
nexus/ped_bn254_test/rust-toolchain.toml
Normal file
@ -0,0 +1,2 @@
|
||||
[toolchain]
|
||||
channel = "nightly-2025-04-06"
|
||||
5
nexus/ped_bn254_test/src/guest/.cargo/config.toml
Normal file
5
nexus/ped_bn254_test/src/guest/.cargo/config.toml
Normal file
@ -0,0 +1,5 @@
|
||||
[target.riscv32i-unknown-none-elf]
|
||||
rustflags = [
|
||||
"-C", "link-arg=-Tlink.x",
|
||||
]
|
||||
runner="nexus-run"
|
||||
16
nexus/ped_bn254_test/src/guest/Cargo.toml
Normal file
16
nexus/ped_bn254_test/src/guest/Cargo.toml
Normal file
@ -0,0 +1,16 @@
|
||||
[package]
|
||||
name = "guest"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
nexus-rt = { git = "https://github.com/nexus-xyz/nexus-zkvm.git", tag = "0.3.4", version = "0.3.4" }
|
||||
postcard = { version = "1.1.1", default-features = false, features = ["alloc"] }
|
||||
ark-bn254 = "0.5.0"
|
||||
ark-ec = "0.5.0"
|
||||
|
||||
# Generated by cargo-nexus, do not remove!
|
||||
#
|
||||
[features]
|
||||
cycles = [] # Enable cycle counting for run command
|
||||
|
||||
2
nexus/ped_bn254_test/src/guest/rust-toolchain.toml
Normal file
2
nexus/ped_bn254_test/src/guest/rust-toolchain.toml
Normal file
@ -0,0 +1,2 @@
|
||||
[toolchain]
|
||||
channel = "nightly-2025-04-06"
|
||||
20
nexus/ped_bn254_test/src/guest/src/main.rs
Normal file
20
nexus/ped_bn254_test/src/guest/src/main.rs
Normal file
@ -0,0 +1,20 @@
|
||||
#![cfg_attr(target_arch = "riscv32", no_std, no_main)]
|
||||
|
||||
use ark_ec::{CurveGroup, PrimeGroup};
|
||||
|
||||
#[nexus_rt::main]
|
||||
fn main() {
|
||||
let g1 = ark_bn254::G1Projective::generator();
|
||||
let g2 = g1 + g1;
|
||||
let g3 = g1 + g2;
|
||||
let g4 = g1 + g3;
|
||||
let g5 = g1 + g4;
|
||||
|
||||
let s1 = ark_bn254::Fr::from(87329482u64);
|
||||
let s2 = ark_bn254::Fr::from(37264829u64);
|
||||
let s3 = ark_bn254::Fr::from(98098098u64);
|
||||
let s4 = ark_bn254::Fr::from(63980948u64);
|
||||
let s5 = ark_bn254::Fr::from(15098098u64);
|
||||
|
||||
let _ = (g1*s1 + g2*s2 + g3*s3 + g4*s4 + g5*s5).into_affine();
|
||||
}
|
||||
65
nexus/ped_bn254_test/src/main.rs
Normal file
65
nexus/ped_bn254_test/src/main.rs
Normal file
@ -0,0 +1,65 @@
|
||||
use nexus_sdk::{
|
||||
compile::{cargo::CargoPackager, Compile, Compiler},
|
||||
stwo::seq::Stwo,
|
||||
ByGuestCompilation, Local, Prover, Verifiable, Viewable,
|
||||
};
|
||||
|
||||
const PACKAGE: &str = "guest";
|
||||
|
||||
fn main() {
|
||||
println!("Compiling guest program...");
|
||||
let mut prover_compiler = Compiler::<CargoPackager>::new(PACKAGE);
|
||||
let prover: Stwo<Local> =
|
||||
Stwo::compile(&mut prover_compiler).expect("failed to compile guest program");
|
||||
|
||||
let elf = prover.elf.clone(); // save elf for use with verification
|
||||
|
||||
println!("Proving execution of vm...");
|
||||
let (view, proof) = prover.prove().expect("failed to prove program");
|
||||
|
||||
println!(
|
||||
">>>>> Logging\n{}<<<<<",
|
||||
view.logs().expect("failed to retrieve debug logs").join("")
|
||||
);
|
||||
assert_eq!(
|
||||
view.exit_code().expect("failed to retrieve exit code"),
|
||||
nexus_sdk::KnownExitCodes::ExitSuccess as u32
|
||||
);
|
||||
|
||||
// Normally the prover communicates the seralized proof to the verifier who deserializes it.
|
||||
//
|
||||
// The verifier must also possess the program binary and the public i/o. Usually, either
|
||||
// the verifier will rebuild the elf in a reproducible way (e.g., within a container) or
|
||||
// the prover will communicate it to the verifier who will then check that it is a valid
|
||||
// compilation of the claimed guest program. Here we simulate the latter.
|
||||
//
|
||||
// If we instead wanted to simulate the former, it might look something like:
|
||||
//
|
||||
// println!("Verifier recompiling guest program...");
|
||||
// let mut verifier_compiler = Compiler::<CargoPackager>::new(PACKAGE);
|
||||
// let path = verifier_compiler.build().expect("failed to (re)compile guest program");
|
||||
//
|
||||
// print!("Verifying execution...");
|
||||
// proof.verify_expected_from_program_path::<&str, (), ()>(
|
||||
// &(), // no public input
|
||||
// nexus_sdk::KnownExitCodes::ExitSuccess as u32,
|
||||
// &(), // no public output
|
||||
// &path, // path to expected program binary
|
||||
// &[] // no associated data,
|
||||
// ).expect("failed to verify proof");
|
||||
|
||||
print!("Verifying execution...");
|
||||
|
||||
#[rustfmt::skip]
|
||||
proof
|
||||
.verify_expected::<(), ()>(
|
||||
&(), // no public input
|
||||
nexus_sdk::KnownExitCodes::ExitSuccess as u32,
|
||||
&(), // no public output
|
||||
&elf, // expected elf (program binary)
|
||||
&[], // no associated data,
|
||||
)
|
||||
.expect("failed to verify proof");
|
||||
|
||||
println!(" Succeeded!");
|
||||
}
|
||||
1
nexus/ped_curve25519_test/.gitignore
vendored
Normal file
1
nexus/ped_curve25519_test/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
||||
14
nexus/ped_curve25519_test/Cargo.toml
Normal file
14
nexus/ped_curve25519_test/Cargo.toml
Normal file
@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "ped_curve25519_test"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
nexus-sdk = { git = "https://github.com/nexus-xyz/nexus-zkvm.git", tag = "0.3.4", version = "0.3.4" }
|
||||
|
||||
[workspace]
|
||||
members = [
|
||||
"src/guest"
|
||||
]
|
||||
|
||||
|
||||
2
nexus/ped_curve25519_test/rust-toolchain.toml
Normal file
2
nexus/ped_curve25519_test/rust-toolchain.toml
Normal file
@ -0,0 +1,2 @@
|
||||
[toolchain]
|
||||
channel = "nightly-2025-04-06"
|
||||
5
nexus/ped_curve25519_test/src/guest/.cargo/config.toml
Normal file
5
nexus/ped_curve25519_test/src/guest/.cargo/config.toml
Normal file
@ -0,0 +1,5 @@
|
||||
[target.riscv32i-unknown-none-elf]
|
||||
rustflags = [
|
||||
"-C", "link-arg=-Tlink.x",
|
||||
]
|
||||
runner="nexus-run"
|
||||
15
nexus/ped_curve25519_test/src/guest/Cargo.toml
Normal file
15
nexus/ped_curve25519_test/src/guest/Cargo.toml
Normal file
@ -0,0 +1,15 @@
|
||||
[package]
|
||||
name = "guest"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
nexus-rt = { git = "https://github.com/nexus-xyz/nexus-zkvm.git", tag = "0.3.4", version = "0.3.4" }
|
||||
postcard = { version = "1.1.1", default-features = false, features = ["alloc"] }
|
||||
curve25519-dalek = "4"
|
||||
|
||||
# Generated by cargo-nexus, do not remove!
|
||||
#
|
||||
[features]
|
||||
cycles = [] # Enable cycle counting for run command
|
||||
|
||||
2
nexus/ped_curve25519_test/src/guest/rust-toolchain.toml
Normal file
2
nexus/ped_curve25519_test/src/guest/rust-toolchain.toml
Normal file
@ -0,0 +1,2 @@
|
||||
[toolchain]
|
||||
channel = "nightly-2025-04-06"
|
||||
29
nexus/ped_curve25519_test/src/guest/src/main.rs
Normal file
29
nexus/ped_curve25519_test/src/guest/src/main.rs
Normal file
@ -0,0 +1,29 @@
|
||||
#![cfg_attr(target_arch = "riscv32", no_std, no_main)]
|
||||
|
||||
use curve25519_dalek::constants;
|
||||
use curve25519_dalek::ristretto::RistrettoPoint;
|
||||
use curve25519_dalek::scalar::Scalar;
|
||||
use curve25519_dalek::traits::MultiscalarMul;
|
||||
|
||||
#[nexus_rt::main]
|
||||
fn main() {
|
||||
// read the input
|
||||
let input: u32 = env::read();
|
||||
|
||||
// TODO: do something with the input
|
||||
let s1 = Scalar::from(87329482u64);
|
||||
let s2 = Scalar::from(37264829u64);
|
||||
let s3 = Scalar::from(98098098u64);
|
||||
let s4 = Scalar::from(63980948u64);
|
||||
let s5 = Scalar::from(15098098u64);
|
||||
|
||||
let g1 = constants::RISTRETTO_BASEPOINT_POINT;
|
||||
let g2 = g1 + g1;
|
||||
let g3 = g1 + g2;
|
||||
let g4 = g1 + g3;
|
||||
let g5 = g1 + g4;
|
||||
|
||||
let nums = [s1,s2,s3,s4,s5];
|
||||
|
||||
let _ = RistrettoPoint::multiscalar_mul(&nums, &[g1,g2,g3,g4,g5]);
|
||||
}
|
||||
65
nexus/ped_curve25519_test/src/main.rs
Normal file
65
nexus/ped_curve25519_test/src/main.rs
Normal file
@ -0,0 +1,65 @@
|
||||
use nexus_sdk::{
|
||||
compile::{cargo::CargoPackager, Compile, Compiler},
|
||||
stwo::seq::Stwo,
|
||||
ByGuestCompilation, Local, Prover, Verifiable, Viewable,
|
||||
};
|
||||
|
||||
const PACKAGE: &str = "guest";
|
||||
|
||||
fn main() {
|
||||
println!("Compiling guest program...");
|
||||
let mut prover_compiler = Compiler::<CargoPackager>::new(PACKAGE);
|
||||
let prover: Stwo<Local> =
|
||||
Stwo::compile(&mut prover_compiler).expect("failed to compile guest program");
|
||||
|
||||
let elf = prover.elf.clone(); // save elf for use with verification
|
||||
|
||||
println!("Proving execution of vm...");
|
||||
let (view, proof) = prover.prove().expect("failed to prove program");
|
||||
|
||||
println!(
|
||||
">>>>> Logging\n{}<<<<<",
|
||||
view.logs().expect("failed to retrieve debug logs").join("")
|
||||
);
|
||||
assert_eq!(
|
||||
view.exit_code().expect("failed to retrieve exit code"),
|
||||
nexus_sdk::KnownExitCodes::ExitSuccess as u32
|
||||
);
|
||||
|
||||
// Normally the prover communicates the seralized proof to the verifier who deserializes it.
|
||||
//
|
||||
// The verifier must also possess the program binary and the public i/o. Usually, either
|
||||
// the verifier will rebuild the elf in a reproducible way (e.g., within a container) or
|
||||
// the prover will communicate it to the verifier who will then check that it is a valid
|
||||
// compilation of the claimed guest program. Here we simulate the latter.
|
||||
//
|
||||
// If we instead wanted to simulate the former, it might look something like:
|
||||
//
|
||||
// println!("Verifier recompiling guest program...");
|
||||
// let mut verifier_compiler = Compiler::<CargoPackager>::new(PACKAGE);
|
||||
// let path = verifier_compiler.build().expect("failed to (re)compile guest program");
|
||||
//
|
||||
// print!("Verifying execution...");
|
||||
// proof.verify_expected_from_program_path::<&str, (), ()>(
|
||||
// &(), // no public input
|
||||
// nexus_sdk::KnownExitCodes::ExitSuccess as u32,
|
||||
// &(), // no public output
|
||||
// &path, // path to expected program binary
|
||||
// &[] // no associated data,
|
||||
// ).expect("failed to verify proof");
|
||||
|
||||
print!("Verifying execution...");
|
||||
|
||||
#[rustfmt::skip]
|
||||
proof
|
||||
.verify_expected::<(), ()>(
|
||||
&(), // no public input
|
||||
nexus_sdk::KnownExitCodes::ExitSuccess as u32,
|
||||
&(), // no public output
|
||||
&elf, // expected elf (program binary)
|
||||
&[], // no associated data,
|
||||
)
|
||||
.expect("failed to verify proof");
|
||||
|
||||
println!(" Succeeded!");
|
||||
}
|
||||
1
nexus/ped_jubjub_test/.gitignore
vendored
Normal file
1
nexus/ped_jubjub_test/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
||||
14
nexus/ped_jubjub_test/Cargo.toml
Normal file
14
nexus/ped_jubjub_test/Cargo.toml
Normal file
@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "ped_jubjub_test"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
nexus-sdk = { git = "https://github.com/nexus-xyz/nexus-zkvm.git", tag = "0.3.4", version = "0.3.4" }
|
||||
|
||||
[workspace]
|
||||
members = [
|
||||
"src/guest"
|
||||
]
|
||||
|
||||
|
||||
2
nexus/ped_jubjub_test/rust-toolchain.toml
Normal file
2
nexus/ped_jubjub_test/rust-toolchain.toml
Normal file
@ -0,0 +1,2 @@
|
||||
[toolchain]
|
||||
channel = "nightly-2025-04-06"
|
||||
5
nexus/ped_jubjub_test/src/guest/.cargo/config.toml
Normal file
5
nexus/ped_jubjub_test/src/guest/.cargo/config.toml
Normal file
@ -0,0 +1,5 @@
|
||||
[target.riscv32i-unknown-none-elf]
|
||||
rustflags = [
|
||||
"-C", "link-arg=-Tlink.x",
|
||||
]
|
||||
runner="nexus-run"
|
||||
15
nexus/ped_jubjub_test/src/guest/Cargo.toml
Normal file
15
nexus/ped_jubjub_test/src/guest/Cargo.toml
Normal file
@ -0,0 +1,15 @@
|
||||
[package]
|
||||
name = "guest"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
nexus-rt = { git = "https://github.com/nexus-xyz/nexus-zkvm.git", tag = "0.3.4", version = "0.3.4" }
|
||||
postcard = { version = "1.1.1", default-features = false, features = ["alloc"] }
|
||||
jubjub = "0.10.0"
|
||||
group = "0.13.0"
|
||||
# Generated by cargo-nexus, do not remove!
|
||||
#
|
||||
[features]
|
||||
cycles = [] # Enable cycle counting for run command
|
||||
|
||||
2
nexus/ped_jubjub_test/src/guest/rust-toolchain.toml
Normal file
2
nexus/ped_jubjub_test/src/guest/rust-toolchain.toml
Normal file
@ -0,0 +1,2 @@
|
||||
[toolchain]
|
||||
channel = "nightly-2025-04-06"
|
||||
19
nexus/ped_jubjub_test/src/guest/src/main.rs
Normal file
19
nexus/ped_jubjub_test/src/guest/src/main.rs
Normal file
@ -0,0 +1,19 @@
|
||||
#![cfg_attr(target_arch = "riscv32", no_std, no_main)]
|
||||
use group::Group;
|
||||
|
||||
#[nexus_rt::main]
|
||||
fn main() {
|
||||
let g1 = jubjub::SubgroupPoint::generator();
|
||||
let g2 = g1 + g1;
|
||||
let g3 = g1 + g2;
|
||||
let g4 = g1 + g3;
|
||||
let g5 = g1 + g4;
|
||||
|
||||
let s1 = jubjub::Fr::from(87329482u64);
|
||||
let s2 = jubjub::Fr::from(37264829u64);
|
||||
let s3 = jubjub::Fr::from(98098098u64);
|
||||
let s4 = jubjub::Fr::from(63980948u64);
|
||||
let s5 = jubjub::Fr::from(15098098u64);
|
||||
|
||||
let _ = g1*s1 + g2*s2 + g3*s3 + g4*s4 + g5*s5;
|
||||
}
|
||||
65
nexus/ped_jubjub_test/src/main.rs
Normal file
65
nexus/ped_jubjub_test/src/main.rs
Normal file
@ -0,0 +1,65 @@
|
||||
use nexus_sdk::{
|
||||
compile::{cargo::CargoPackager, Compile, Compiler},
|
||||
stwo::seq::Stwo,
|
||||
ByGuestCompilation, Local, Prover, Verifiable, Viewable,
|
||||
};
|
||||
|
||||
const PACKAGE: &str = "guest";
|
||||
|
||||
fn main() {
|
||||
println!("Compiling guest program...");
|
||||
let mut prover_compiler = Compiler::<CargoPackager>::new(PACKAGE);
|
||||
let prover: Stwo<Local> =
|
||||
Stwo::compile(&mut prover_compiler).expect("failed to compile guest program");
|
||||
|
||||
let elf = prover.elf.clone(); // save elf for use with verification
|
||||
|
||||
println!("Proving execution of vm...");
|
||||
let (view, proof) = prover.prove().expect("failed to prove program");
|
||||
|
||||
println!(
|
||||
">>>>> Logging\n{}<<<<<",
|
||||
view.logs().expect("failed to retrieve debug logs").join("")
|
||||
);
|
||||
assert_eq!(
|
||||
view.exit_code().expect("failed to retrieve exit code"),
|
||||
nexus_sdk::KnownExitCodes::ExitSuccess as u32
|
||||
);
|
||||
|
||||
// Normally the prover communicates the seralized proof to the verifier who deserializes it.
|
||||
//
|
||||
// The verifier must also possess the program binary and the public i/o. Usually, either
|
||||
// the verifier will rebuild the elf in a reproducible way (e.g., within a container) or
|
||||
// the prover will communicate it to the verifier who will then check that it is a valid
|
||||
// compilation of the claimed guest program. Here we simulate the latter.
|
||||
//
|
||||
// If we instead wanted to simulate the former, it might look something like:
|
||||
//
|
||||
// println!("Verifier recompiling guest program...");
|
||||
// let mut verifier_compiler = Compiler::<CargoPackager>::new(PACKAGE);
|
||||
// let path = verifier_compiler.build().expect("failed to (re)compile guest program");
|
||||
//
|
||||
// print!("Verifying execution...");
|
||||
// proof.verify_expected_from_program_path::<&str, (), ()>(
|
||||
// &(), // no public input
|
||||
// nexus_sdk::KnownExitCodes::ExitSuccess as u32,
|
||||
// &(), // no public output
|
||||
// &path, // path to expected program binary
|
||||
// &[] // no associated data,
|
||||
// ).expect("failed to verify proof");
|
||||
|
||||
print!("Verifying execution...");
|
||||
|
||||
#[rustfmt::skip]
|
||||
proof
|
||||
.verify_expected::<(), ()>(
|
||||
&(), // no public input
|
||||
nexus_sdk::KnownExitCodes::ExitSuccess as u32,
|
||||
&(), // no public output
|
||||
&elf, // expected elf (program binary)
|
||||
&[], // no associated data,
|
||||
)
|
||||
.expect("failed to verify proof");
|
||||
|
||||
println!(" Succeeded!");
|
||||
}
|
||||
1
nexus/ped_pallas_test/.gitignore
vendored
Normal file
1
nexus/ped_pallas_test/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
||||
14
nexus/ped_pallas_test/Cargo.toml
Normal file
14
nexus/ped_pallas_test/Cargo.toml
Normal file
@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "ped_pallas_test"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
nexus-sdk = { git = "https://github.com/nexus-xyz/nexus-zkvm.git", tag = "0.3.4", version = "0.3.4" }
|
||||
|
||||
[workspace]
|
||||
members = [
|
||||
"src/guest"
|
||||
]
|
||||
|
||||
|
||||
2
nexus/ped_pallas_test/rust-toolchain.toml
Normal file
2
nexus/ped_pallas_test/rust-toolchain.toml
Normal file
@ -0,0 +1,2 @@
|
||||
[toolchain]
|
||||
channel = "nightly-2025-04-06"
|
||||
5
nexus/ped_pallas_test/src/guest/.cargo/config.toml
Normal file
5
nexus/ped_pallas_test/src/guest/.cargo/config.toml
Normal file
@ -0,0 +1,5 @@
|
||||
[target.riscv32i-unknown-none-elf]
|
||||
rustflags = [
|
||||
"-C", "link-arg=-Tlink.x",
|
||||
]
|
||||
runner="nexus-run"
|
||||
15
nexus/ped_pallas_test/src/guest/Cargo.toml
Normal file
15
nexus/ped_pallas_test/src/guest/Cargo.toml
Normal file
@ -0,0 +1,15 @@
|
||||
[package]
|
||||
name = "guest"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
nexus-rt = { git = "https://github.com/nexus-xyz/nexus-zkvm.git", tag = "0.3.4", version = "0.3.4" }
|
||||
postcard = { version = "1.1.1", default-features = false, features = ["alloc"] }
|
||||
pasta_curves = "0.5.1"
|
||||
|
||||
# Generated by cargo-nexus, do not remove!
|
||||
#
|
||||
[features]
|
||||
cycles = [] # Enable cycle counting for run command
|
||||
|
||||
2
nexus/ped_pallas_test/src/guest/rust-toolchain.toml
Normal file
2
nexus/ped_pallas_test/src/guest/rust-toolchain.toml
Normal file
@ -0,0 +1,2 @@
|
||||
[toolchain]
|
||||
channel = "nightly-2025-04-06"
|
||||
19
nexus/ped_pallas_test/src/guest/src/main.rs
Normal file
19
nexus/ped_pallas_test/src/guest/src/main.rs
Normal file
@ -0,0 +1,19 @@
|
||||
#![cfg_attr(target_arch = "riscv32", no_std, no_main)]
|
||||
use pasta_curves::group::Group;
|
||||
|
||||
#[nexus_rt::main]
|
||||
fn main() {
|
||||
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 _ = g1*s1 + g2*s2 + g3*s3 + g4*s4 + g5*s5;
|
||||
}
|
||||
65
nexus/ped_pallas_test/src/main.rs
Normal file
65
nexus/ped_pallas_test/src/main.rs
Normal file
@ -0,0 +1,65 @@
|
||||
use nexus_sdk::{
|
||||
compile::{cargo::CargoPackager, Compile, Compiler},
|
||||
stwo::seq::Stwo,
|
||||
ByGuestCompilation, Local, Prover, Verifiable, Viewable,
|
||||
};
|
||||
|
||||
const PACKAGE: &str = "guest";
|
||||
|
||||
fn main() {
|
||||
println!("Compiling guest program...");
|
||||
let mut prover_compiler = Compiler::<CargoPackager>::new(PACKAGE);
|
||||
let prover: Stwo<Local> =
|
||||
Stwo::compile(&mut prover_compiler).expect("failed to compile guest program");
|
||||
|
||||
let elf = prover.elf.clone(); // save elf for use with verification
|
||||
|
||||
println!("Proving execution of vm...");
|
||||
let (view, proof) = prover.prove().expect("failed to prove program");
|
||||
|
||||
println!(
|
||||
">>>>> Logging\n{}<<<<<",
|
||||
view.logs().expect("failed to retrieve debug logs").join("")
|
||||
);
|
||||
assert_eq!(
|
||||
view.exit_code().expect("failed to retrieve exit code"),
|
||||
nexus_sdk::KnownExitCodes::ExitSuccess as u32
|
||||
);
|
||||
|
||||
// Normally the prover communicates the seralized proof to the verifier who deserializes it.
|
||||
//
|
||||
// The verifier must also possess the program binary and the public i/o. Usually, either
|
||||
// the verifier will rebuild the elf in a reproducible way (e.g., within a container) or
|
||||
// the prover will communicate it to the verifier who will then check that it is a valid
|
||||
// compilation of the claimed guest program. Here we simulate the latter.
|
||||
//
|
||||
// If we instead wanted to simulate the former, it might look something like:
|
||||
//
|
||||
// println!("Verifier recompiling guest program...");
|
||||
// let mut verifier_compiler = Compiler::<CargoPackager>::new(PACKAGE);
|
||||
// let path = verifier_compiler.build().expect("failed to (re)compile guest program");
|
||||
//
|
||||
// print!("Verifying execution...");
|
||||
// proof.verify_expected_from_program_path::<&str, (), ()>(
|
||||
// &(), // no public input
|
||||
// nexus_sdk::KnownExitCodes::ExitSuccess as u32,
|
||||
// &(), // no public output
|
||||
// &path, // path to expected program binary
|
||||
// &[] // no associated data,
|
||||
// ).expect("failed to verify proof");
|
||||
|
||||
print!("Verifying execution...");
|
||||
|
||||
#[rustfmt::skip]
|
||||
proof
|
||||
.verify_expected::<(), ()>(
|
||||
&(), // no public input
|
||||
nexus_sdk::KnownExitCodes::ExitSuccess as u32,
|
||||
&(), // no public output
|
||||
&elf, // expected elf (program binary)
|
||||
&[], // no associated data,
|
||||
)
|
||||
.expect("failed to verify proof");
|
||||
|
||||
println!(" Succeeded!");
|
||||
}
|
||||
1
nexus/ped_secp256k1_test/.gitignore
vendored
Normal file
1
nexus/ped_secp256k1_test/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
||||
14
nexus/ped_secp256k1_test/Cargo.toml
Normal file
14
nexus/ped_secp256k1_test/Cargo.toml
Normal file
@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "ped_secp256k1_test"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
nexus-sdk = { git = "https://github.com/nexus-xyz/nexus-zkvm.git", tag = "0.3.4", version = "0.3.4" }
|
||||
|
||||
[workspace]
|
||||
members = [
|
||||
"src/guest"
|
||||
]
|
||||
|
||||
|
||||
2
nexus/ped_secp256k1_test/rust-toolchain.toml
Normal file
2
nexus/ped_secp256k1_test/rust-toolchain.toml
Normal file
@ -0,0 +1,2 @@
|
||||
[toolchain]
|
||||
channel = "nightly-2025-04-06"
|
||||
5
nexus/ped_secp256k1_test/src/guest/.cargo/config.toml
Normal file
5
nexus/ped_secp256k1_test/src/guest/.cargo/config.toml
Normal file
@ -0,0 +1,5 @@
|
||||
[target.riscv32i-unknown-none-elf]
|
||||
rustflags = [
|
||||
"-C", "link-arg=-Tlink.x",
|
||||
]
|
||||
runner="nexus-run"
|
||||
14
nexus/ped_secp256k1_test/src/guest/Cargo.toml
Normal file
14
nexus/ped_secp256k1_test/src/guest/Cargo.toml
Normal file
@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "guest"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
nexus-rt = { git = "https://github.com/nexus-xyz/nexus-zkvm.git", tag = "0.3.4", version = "0.3.4" }
|
||||
postcard = { version = "1.1.1", default-features = false, features = ["alloc"] }
|
||||
k256 = "0.13.4"
|
||||
# Generated by cargo-nexus, do not remove!
|
||||
#
|
||||
[features]
|
||||
cycles = [] # Enable cycle counting for run command
|
||||
|
||||
2
nexus/ped_secp256k1_test/src/guest/rust-toolchain.toml
Normal file
2
nexus/ped_secp256k1_test/src/guest/rust-toolchain.toml
Normal file
@ -0,0 +1,2 @@
|
||||
[toolchain]
|
||||
channel = "nightly-2025-04-06"
|
||||
21
nexus/ped_secp256k1_test/src/guest/src/main.rs
Normal file
21
nexus/ped_secp256k1_test/src/guest/src/main.rs
Normal file
@ -0,0 +1,21 @@
|
||||
#![cfg_attr(target_arch = "riscv32", no_std, no_main)]
|
||||
|
||||
use nexus_rt::print;
|
||||
|
||||
#[nexus_rt::main]
|
||||
fn main() {
|
||||
let g1 = k256::ProjectivePoint::GENERATOR;
|
||||
let g2 = g1 + g1;
|
||||
let g3 = g1 + g2;
|
||||
let g4 = g1 + g3;
|
||||
let g5 = g1 + g4;
|
||||
|
||||
|
||||
let s1 = k256::Scalar::from(87329482u64);
|
||||
let s2 = k256::Scalar::from(37264829u64);
|
||||
let s3 = k256::Scalar::from(98098098u64);
|
||||
let s4 = k256::Scalar::from(63980948u64);
|
||||
let s5 = k256::Scalar::from(15098098u64);
|
||||
|
||||
let _ = g1*s1 + g2*s2 + g3*s3 + g4*s4 + g5*s5;
|
||||
}
|
||||
65
nexus/ped_secp256k1_test/src/main.rs
Normal file
65
nexus/ped_secp256k1_test/src/main.rs
Normal file
@ -0,0 +1,65 @@
|
||||
use nexus_sdk::{
|
||||
compile::{cargo::CargoPackager, Compile, Compiler},
|
||||
stwo::seq::Stwo,
|
||||
ByGuestCompilation, Local, Prover, Verifiable, Viewable,
|
||||
};
|
||||
|
||||
const PACKAGE: &str = "guest";
|
||||
|
||||
fn main() {
|
||||
println!("Compiling guest program...");
|
||||
let mut prover_compiler = Compiler::<CargoPackager>::new(PACKAGE);
|
||||
let prover: Stwo<Local> =
|
||||
Stwo::compile(&mut prover_compiler).expect("failed to compile guest program");
|
||||
|
||||
let elf = prover.elf.clone(); // save elf for use with verification
|
||||
|
||||
println!("Proving execution of vm...");
|
||||
let (view, proof) = prover.prove().expect("failed to prove program");
|
||||
|
||||
println!(
|
||||
">>>>> Logging\n{}<<<<<",
|
||||
view.logs().expect("failed to retrieve debug logs").join("")
|
||||
);
|
||||
assert_eq!(
|
||||
view.exit_code().expect("failed to retrieve exit code"),
|
||||
nexus_sdk::KnownExitCodes::ExitSuccess as u32
|
||||
);
|
||||
|
||||
// Normally the prover communicates the seralized proof to the verifier who deserializes it.
|
||||
//
|
||||
// The verifier must also possess the program binary and the public i/o. Usually, either
|
||||
// the verifier will rebuild the elf in a reproducible way (e.g., within a container) or
|
||||
// the prover will communicate it to the verifier who will then check that it is a valid
|
||||
// compilation of the claimed guest program. Here we simulate the latter.
|
||||
//
|
||||
// If we instead wanted to simulate the former, it might look something like:
|
||||
//
|
||||
// println!("Verifier recompiling guest program...");
|
||||
// let mut verifier_compiler = Compiler::<CargoPackager>::new(PACKAGE);
|
||||
// let path = verifier_compiler.build().expect("failed to (re)compile guest program");
|
||||
//
|
||||
// print!("Verifying execution...");
|
||||
// proof.verify_expected_from_program_path::<&str, (), ()>(
|
||||
// &(), // no public input
|
||||
// nexus_sdk::KnownExitCodes::ExitSuccess as u32,
|
||||
// &(), // no public output
|
||||
// &path, // path to expected program binary
|
||||
// &[] // no associated data,
|
||||
// ).expect("failed to verify proof");
|
||||
|
||||
print!("Verifying execution...");
|
||||
|
||||
#[rustfmt::skip]
|
||||
proof
|
||||
.verify_expected::<(), ()>(
|
||||
&(), // no public input
|
||||
nexus_sdk::KnownExitCodes::ExitSuccess as u32,
|
||||
&(), // no public output
|
||||
&elf, // expected elf (program binary)
|
||||
&[], // no associated data,
|
||||
)
|
||||
.expect("failed to verify proof");
|
||||
|
||||
println!(" Succeeded!");
|
||||
}
|
||||
1
nexus/ped_vesta_test/.gitignore
vendored
Normal file
1
nexus/ped_vesta_test/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
||||
14
nexus/ped_vesta_test/Cargo.toml
Normal file
14
nexus/ped_vesta_test/Cargo.toml
Normal file
@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "ped_vesta_test"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
nexus-sdk = { git = "https://github.com/nexus-xyz/nexus-zkvm.git", tag = "0.3.4", version = "0.3.4" }
|
||||
|
||||
[workspace]
|
||||
members = [
|
||||
"src/guest"
|
||||
]
|
||||
|
||||
|
||||
2
nexus/ped_vesta_test/rust-toolchain.toml
Normal file
2
nexus/ped_vesta_test/rust-toolchain.toml
Normal file
@ -0,0 +1,2 @@
|
||||
[toolchain]
|
||||
channel = "nightly-2025-04-06"
|
||||
5
nexus/ped_vesta_test/src/guest/.cargo/config.toml
Normal file
5
nexus/ped_vesta_test/src/guest/.cargo/config.toml
Normal file
@ -0,0 +1,5 @@
|
||||
[target.riscv32i-unknown-none-elf]
|
||||
rustflags = [
|
||||
"-C", "link-arg=-Tlink.x",
|
||||
]
|
||||
runner="nexus-run"
|
||||
14
nexus/ped_vesta_test/src/guest/Cargo.toml
Normal file
14
nexus/ped_vesta_test/src/guest/Cargo.toml
Normal file
@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "guest"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
nexus-rt = { git = "https://github.com/nexus-xyz/nexus-zkvm.git", tag = "0.3.4", version = "0.3.4" }
|
||||
postcard = { version = "1.1.1", default-features = false, features = ["alloc"] }
|
||||
pasta_curves = "0.5.1"
|
||||
# Generated by cargo-nexus, do not remove!
|
||||
#
|
||||
[features]
|
||||
cycles = [] # Enable cycle counting for run command
|
||||
|
||||
2
nexus/ped_vesta_test/src/guest/rust-toolchain.toml
Normal file
2
nexus/ped_vesta_test/src/guest/rust-toolchain.toml
Normal file
@ -0,0 +1,2 @@
|
||||
[toolchain]
|
||||
channel = "nightly-2025-04-06"
|
||||
19
nexus/ped_vesta_test/src/guest/src/main.rs
Normal file
19
nexus/ped_vesta_test/src/guest/src/main.rs
Normal file
@ -0,0 +1,19 @@
|
||||
#![cfg_attr(target_arch = "riscv32", no_std, no_main)]
|
||||
use pasta_curves::group::Group;
|
||||
|
||||
#[nexus_rt::main]
|
||||
fn main() {
|
||||
let g1 = pasta_curves::vesta::Point::generator();
|
||||
let g2 = g1 + g1;
|
||||
let g3 = g1 + g2;
|
||||
let g4 = g1 + g3;
|
||||
let g5 = g1 + g4;
|
||||
|
||||
let s1 = pasta_curves::vesta::Scalar::from(87329482u64);
|
||||
let s2 = pasta_curves::vesta::Scalar::from(37264829u64);
|
||||
let s3 = pasta_curves::vesta::Scalar::from(98098098u64);
|
||||
let s4 = pasta_curves::vesta::Scalar::from(63980948u64);
|
||||
let s5 = pasta_curves::vesta::Scalar::from(15098098u64);
|
||||
|
||||
let _ = g1*s1 + g2*s2 + g3*s3 + g4*s4 + g5*s5;
|
||||
}
|
||||
65
nexus/ped_vesta_test/src/main.rs
Normal file
65
nexus/ped_vesta_test/src/main.rs
Normal file
@ -0,0 +1,65 @@
|
||||
use nexus_sdk::{
|
||||
compile::{cargo::CargoPackager, Compile, Compiler},
|
||||
stwo::seq::Stwo,
|
||||
ByGuestCompilation, Local, Prover, Verifiable, Viewable,
|
||||
};
|
||||
|
||||
const PACKAGE: &str = "guest";
|
||||
|
||||
fn main() {
|
||||
println!("Compiling guest program...");
|
||||
let mut prover_compiler = Compiler::<CargoPackager>::new(PACKAGE);
|
||||
let prover: Stwo<Local> =
|
||||
Stwo::compile(&mut prover_compiler).expect("failed to compile guest program");
|
||||
|
||||
let elf = prover.elf.clone(); // save elf for use with verification
|
||||
|
||||
println!("Proving execution of vm...");
|
||||
let (view, proof) = prover.prove().expect("failed to prove program");
|
||||
|
||||
println!(
|
||||
">>>>> Logging\n{}<<<<<",
|
||||
view.logs().expect("failed to retrieve debug logs").join("")
|
||||
);
|
||||
assert_eq!(
|
||||
view.exit_code().expect("failed to retrieve exit code"),
|
||||
nexus_sdk::KnownExitCodes::ExitSuccess as u32
|
||||
);
|
||||
|
||||
// Normally the prover communicates the seralized proof to the verifier who deserializes it.
|
||||
//
|
||||
// The verifier must also possess the program binary and the public i/o. Usually, either
|
||||
// the verifier will rebuild the elf in a reproducible way (e.g., within a container) or
|
||||
// the prover will communicate it to the verifier who will then check that it is a valid
|
||||
// compilation of the claimed guest program. Here we simulate the latter.
|
||||
//
|
||||
// If we instead wanted to simulate the former, it might look something like:
|
||||
//
|
||||
// println!("Verifier recompiling guest program...");
|
||||
// let mut verifier_compiler = Compiler::<CargoPackager>::new(PACKAGE);
|
||||
// let path = verifier_compiler.build().expect("failed to (re)compile guest program");
|
||||
//
|
||||
// print!("Verifying execution...");
|
||||
// proof.verify_expected_from_program_path::<&str, (), ()>(
|
||||
// &(), // no public input
|
||||
// nexus_sdk::KnownExitCodes::ExitSuccess as u32,
|
||||
// &(), // no public output
|
||||
// &path, // path to expected program binary
|
||||
// &[] // no associated data,
|
||||
// ).expect("failed to verify proof");
|
||||
|
||||
print!("Verifying execution...");
|
||||
|
||||
#[rustfmt::skip]
|
||||
proof
|
||||
.verify_expected::<(), ()>(
|
||||
&(), // no public input
|
||||
nexus_sdk::KnownExitCodes::ExitSuccess as u32,
|
||||
&(), // no public output
|
||||
&elf, // expected elf (program binary)
|
||||
&[], // no associated data,
|
||||
)
|
||||
.expect("failed to verify proof");
|
||||
|
||||
println!(" Succeeded!");
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user