feat: guest (de)serialization for preprocessing & proof#1224
Closed
feat: guest (de)serialization for preprocessing & proof#1224
Conversation
Replace JSON-based Instruction (de)serialization with a fixed-width binary format to avoid serde_json parsing costs during preprocessing and recursion verification.
Disable dory-pcs default features at the workspace level and enable only the arkworks backend and cache for recursion/minimal builds; avoid disk-persistence APIs in non-host builds.
Introduce a Jolt-owned GuestSerialize/GuestDeserialize encoding (Montgomery limbs and uncompressed curve points) and a native validated transport decode step that emits guest-optimized bytes consumed by recursion verification. Also gate cycle-tracking markers behind a feature and enable it by default for recursion builds.
…atements
Add `use crate::zkvm::guest_serde::{GuestDeserialize, GuestSerialize}` imports
and simplify impl blocks across 8 files to improve readability.
Use `usize::try_from` with proper error handling instead of `as usize` to avoid silent truncation of Vec/byte lengths on 32-bit systems.
Tighten guest length prefix encoding/decoding to avoid silent truncation (notably Claims length) and add explicit documentation that GuestDeserialize is unchecked by design for the trusted-host recursion pipeline.
Collaborator
|
@quangvdao can i close this? |
Contributor
Author
|
Yes, it's badly outdated. We can revisit this in the future |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduces a Jolt-owned guest encoding (
GuestSerialize/GuestDeserialize) optimized for recursion verification, along with a native transport decode layer that converts compressed proof bytes into guest-optimized bytes.Performance (recursion
trace, virtual cycles, fibonacci)Measured with:
cargo run -p recursion --release -- generate --example fibonacci --workdir outputRUST_LOG=info cargo run -p recursion --release -- trace --example fibonacci --workdir outputEnd-to-end deserialize costs (before → after)
verification remains the dominant cost (~1.19B virtual cycles) and is unchanged by this PR.
Validation policy change (enabled by moving decode out of guest)
Previously, recursion verification deserialized arkworks-encoded proofs/preprocessing inside the guest using unchecked canonical deserialization (
Validate::No) to save virtual cycles, meaning incoming curve points were not validated.With this PR, transport bytes are decoded and validated in native execution (canonical
deserialize_compressed, i.e. validated), and only then converted into the guest-optimized encoding. Because this validation happens outside the proved computation, it incurs no zkVM virtual-cycle cost.Guest decoding remains intentionally unchecked (
GuestDeserializeusesnew_uncheckedfor field elements/curve points) because its input is now the trusted output of the native validation+conversion step.Key Changes
GuestSerialize/GuestDeserializetraits encoding field elements as Montgomery limbs and curve points uncompressed - avoids expensive in-guest decompression/conversiondecompress_transport_bytes_to_guest_bytes()validates compressed transport bytes and emits guest-optimized encodingcycle-trackingfeature, enabled by default for recursion buildscrate::zkvm::guest_serde::*paths withusestatementsMotivation
Recursion verification requires deserializing proofs and preprocessing inside the guest. The standard arkworks encoding (compressed points, non-Montgomery field elements) incurs significant in-guest costs:
This PR eliminates those costs by pre-converting on the native side.
Testing
cargo check -p jolt-core --features provercargo clippy -p jolt-core --features proverReview Guidance
Focus on:
jolt-core/src/zkvm/guest_serde.rs- the core encoding traits and implsjolt-sdk/src/decompression.rs- the native transport → guest conversionjolt-core/src/poly/commitment/dory/mod.rs