Skip to content

Conversation

@jimmychu0807
Copy link

  • Copied from discord: Investigated the issue if I can use target_os, target_arch to distinguish brevis pico from other zkvms. I believe the ans is not.
    Because pico themselves use riscv32im-risc0-zkvm-elf as the target string.
    As a result, target_arch == riscv32, target_vendor == risc0, target_os == zkvm, same as risc0 vm 😓. Here is an example of their check in pico sha256 lib.
    I raised this issue to them this morning, but there will be a lot of changes, across multiple repos, if they decide to address this issue. So I am not hopeful they will address this anytime soon and we probably have to resolve to add our own (feature) flag.

  • Also run cargo fmt on sha2 crate.

@jimmychu0807
Copy link
Author

@ArtiomTr this PR is good to review.
Should merge this first before merging grandinetech/grandine#386.

sha2/Cargo.toml Outdated
force-soft = [] # Force software implementation
force-soft-compact = [] # Force compact software implementation
asm-aarch64 = ["asm"] # DEPRECATED: use `asm` instead
zkvm-pico = [] # For Brevis pico zkvm compilation
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a new feature

Copy link
Collaborator

@ArtiomTr ArtiomTr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, just one more check needed

Comment on lines +29 to +36
} else if #[cfg(all(target_os = "zkvm", target_vendor = "risc0", target_arch = "riscv32", feature = "zkvm-pico"))] {
// Brevis Pico target string is also `riscv32im-risc0-zkvm-elf`, so we use an additional feature
// to distinguish pico.
// ref: https://github.com/brevis-network/pico/blob/main/sdk/cli/src/build/build.rs#L82
mod pico;
use pico::compress;
} else if #[cfg(all(target_os = "zkvm", target_vendor = "risc0", target_arch = "riscv32", feature = "zkvm-risc0"))] {
// zkvm-r0vm
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this would successfully compile, even if target_vendor = "risc0", but both zkvm-pico and zkvm-risc0 features are disabled? Can you please add:

#[cfg(all(target_os = "zkvm", target_vendor = "risc0", not(any(feature = "zkvm-pico", feature = "zkvm-risc0"))))]
compile_error!("please select at least one feature from [`zkvm-pico`, `zkvm-risc0`]");

or something similar, to prevent accidentally keeping precompile off

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated.

@ArtiomTr ArtiomTr merged commit 0d3a387 into grandinetech:RustCrypto-hashes/sha2-v0.10.9 Nov 4, 2025
5 of 22 checks passed
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.

2 participants