Skip to content

[Feature] Enable safe external loading of inclusion prover for wasm targets #2814

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 27 commits into
base: staging
Choose a base branch
from

Conversation

iamalwaysuncomfortable
Copy link
Member

@iamalwaysuncomfortable iamalwaysuncomfortable commented Jul 16, 2025

Motivation

SnarkVM process stores the inclusion prover and verifier in static location in memory. It is initialized via load_bytes method defined by the impl_remote! macro in the parameters and lazily loaded into a static location the first time the inclusion_proving_key is called. If trying to build a transaction offline using a SnarkVM process running in userspace, this will first check if the inclusion prover is located at a specific location on disk, otherwise it will attempt to download it from the internet.

As a matter of security, wasm runtimes run in a sandboxed environment and generally do not have access to their host machine's file system directly. Thus, the normal approach of checking the local filesystem is not available, and the sole option for initializing the inclusion prover is download it.

If desiring to build a transaction on an offline machine that is using a wasm binary, the inclusion prover is unable to be loaded and offline transaction building will fail. This effectively means offline transaction creation is not available in a javascript environment. Many offline wallets, custodians, and other developers generally desire to write their applications in node.js and thus are currently blocked from doing so.

This PR introduces an option to insert the inclusion prover bytes from an external source, and verify that the checksum and byte buffer length match the expected values for the inclusion prover, allowing safe external insertion of the inclusion prover.

Test Plan

Add tests that ensure

  • Bytes that do not match the expected inclusion prover bytes do not pass.
  • The inclusion prover is successfully loaded from external sources.
  • All functionality surrounding the inclusion prover that exists when the wasm flag is not present remains unaffected.

Steps Before Marking PR as Ready for Review

  • Write described tests.
  • Code & style cleanup.
  • Rebase onto the staging branch (this was branched from v3.8.0 tag in order to provide the SDK the ability to test offline transaction building against the latest stable mainnet tag)

@iamalwaysuncomfortable iamalwaysuncomfortable force-pushed the feat/load-inclusion-external-wasm branch from f5a809f to faad02d Compare July 16, 2025 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants