Skip to content

fix: use core::mem instead of std::mem in no_std zkvm precompile module#39

Open
sergey-melnychuk wants to merge 27 commits into
sp1-patches:masterfrom
sergey-melnychuk:fix/no-std-zkvm-core-mem
Open

fix: use core::mem instead of std::mem in no_std zkvm precompile module#39
sergey-melnychuk wants to merge 27 commits into
sp1-patches:masterfrom
sergey-melnychuk:fix/no-std-zkvm-core-mem

Conversation

@sergey-melnychuk

@sergey-melnychuk sergey-melnychuk commented May 15, 2026

Copy link
Copy Markdown

The zkvm module in src/algorithms/rsa.rs is compiled only for cfg(all(target_os = "zkvm", target_vendor = "succinct")), which is a no_std target. The module used std::mem::transmute and std::mem::size_of, causing build failures when the std feature is disabled (the typical setup for SP1 guest programs).

Replace all five occurrences with their core::mem equivalents, which are always available regardless of std.

Error before this fix

error[E0433]: failed to resolve: use of unresolved module or unlinked crate std
--> src/algorithms/rsa.rs:101:21
|
| std::mem::transmute::<[Chunk; $chunks * 2], [u8; $bytes * 2]>(prod_chunks)
| ^^^ use of unresolved module or unlinked crate std

Reproduction

Add rsa = { version = "0.9", default-features = false } to an SP1 guest program and run cargo prove build.

@sergey-melnychuk

sergey-melnychuk commented May 15, 2026

Copy link
Copy Markdown
Author

Note: This branch is based on tag patch-0.9.6-sp1-6.2.0, not master. The extra commits in the diff are from that tag's patch series — the actual change is a single commit touching 5 lines in src/algorithms/rsa.rs.

If this should be rebased onto a different base branch, please let me know and I'll update it.

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.

7 participants