Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions bench_vs/lambda/deserialize-only/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Deserialize-only counterpart to the recursion guest.
//!
//! Reads the same private-input blob as `recursion-bench`, postcard-decodes
//! `(VmProof, Vec<u8>, ProofOptions)`, then commits success
//! `(VmProof, Vec<u8>, ProofOptions, VmVerifyingKey)`, then commits success
//! and halts — without ever calling `verify_with_options`. The cycle delta
//! between this guest and `recursion-bench` is the actual cost of the STARK
//! verifier inside the VM (everything else being equal).
Expand All @@ -16,7 +16,7 @@ use core::arch::asm;
use core::panic::PanicInfo;

use embedded_alloc::TlsfHeap as Heap;
use lambda_vm_prover::{ProofOptions, VmProof};
use lambda_vm_prover::{ProofOptions, VmProof, VmVerifyingKey};
// Required to pull in the riscv crate's critical-section implementation.
use riscv as _;

Expand Down Expand Up @@ -75,7 +75,7 @@ pub fn main() -> ! {
init_allocator();

let blob = read_private_input();
let decoded: (VmProof, Vec<u8>, ProofOptions) =
let decoded: (VmProof, Vec<u8>, ProofOptions, VmVerifyingKey) =
postcard::from_bytes(blob).expect("failed to deserialize");

// Force the commit byte to depend on the actually-decoded value. Without
Expand All @@ -86,7 +86,8 @@ pub fn main() -> ! {
// to a deep field of the decoded value, the decode has to run.
let proof_options_byte = decoded.2.blowup_factor;
let inner_elf_byte = *decoded.1.first().unwrap_or(&0);
let marker = proof_options_byte ^ inner_elf_byte;
let vkey_byte = decoded.3.bitwise[0];
let marker = proof_options_byte ^ inner_elf_byte ^ vkey_byte;

commit(&[marker]);
halt()
Expand Down
76 changes: 39 additions & 37 deletions bench_vs/lambda/recursion/Cargo.lock

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

23 changes: 17 additions & 6 deletions bench_vs/lambda/recursion/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use core::arch::asm;
use core::panic::PanicInfo;

use embedded_alloc::TlsfHeap as Heap;
use lambda_vm_prover::{ProofOptions, VmProof};
use lambda_vm_prover::{ProofOptions, VmProof, VmVerifyingKey};
// Required to pull in the riscv crate's critical-section implementation.
use riscv as _;

Expand Down Expand Up @@ -67,18 +67,29 @@ fn halt() -> ! {
}

/// Private input layout (postcard-encoded):
/// (VmProof, Vec<u8>, ProofOptions)
/// where the `Vec<u8>` holds the inner program's ELF bytes and the
/// `ProofOptions` specifies the parameters the inner prover used.
/// (VmProof, Vec<u8>, ProofOptions, VmVerifyingKey)
/// where the `Vec<u8>` holds the inner program's ELF bytes, the
/// `ProofOptions` specifies the parameters the inner prover used, and the
/// `VmVerifyingKey` carries the host-derived bitwise preprocessed commitment
/// so the guest can skip the ~87% of verifier cycles that would otherwise be
/// spent recomputing it from scratch.
#[unsafe(no_mangle)]
pub fn main() -> ! {
init_allocator();

let blob = read_private_input();
let (vm_proof, inner_elf, options): (VmProof, Vec<u8>, ProofOptions) =
let (vm_proof, inner_elf, options, vkey): (VmProof, Vec<u8>, ProofOptions, VmVerifyingKey) =
postcard::from_bytes(blob).expect("failed to deserialize recursion input");

let ok = lambda_vm_prover::verify_with_options(&vm_proof, &inner_elf, &options, None, None)
let ok =
lambda_vm_prover::verify_with_options_with_vkey(
&vm_proof,
&inner_elf,
&options,
None,
None,
Some(&vkey),
)
.expect("verify errored");
assert!(ok, "inner proof failed verification");

Expand Down
1 change: 1 addition & 0 deletions prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ rayon = { version = "1.8.0", optional = true }
sysinfo = { version = "0.31", default-features = false, features = ["system"], optional = true }
log = "0.4"
sha3 = { version = "0.10.8", default-features = false }
postcard = { version = "1.0", default-features = false, features = ["alloc"] }

[dev-dependencies]
env_logger = "*"
Expand Down
Loading
Loading