signatures icon indicating copy to clipboard operation
signatures copied to clipboard

Compilation error in `slh-dsa` when using with `x-wing`

Open gkgoat1 opened this issue 11 months ago • 2 comments

    Checking slh-dsa v0.1.0
error[E0405]: cannot find trait `CryptoRngCore` in crate `signature::rand_core`
   --> /[redacted]/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/slh-dsa-0.1.0/src/signing_key.rs:200:46
    |
200 |         rng: &mut impl signature::rand_core::CryptoRngCore,
    |                                              ^^^^^^^^^^^^^
    |
   ::: /[redacted]/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rand_core-0.9.3/src/lib.rs:204:1
    |
204 | pub trait CryptoRng: RngCore {}
    | ---------------------------- similarly named trait `CryptoRng` defined here
    |
help: a trait with a similar name exists
    |
200 |         rng: &mut impl signature::rand_core::CryptoRng,
    |                                              ~~~~~~~~~
help: consider importing this trait
    |
1   + use rand_core::CryptoRngCore;
    |
help: if you import `CryptoRngCore`, refer to it directly
    |
200 -         rng: &mut impl signature::rand_core::CryptoRngCore,
200 +         rng: &mut impl CryptoRngCore,
    |

error[E0643]: method `try_sign_with_rng` has incompatible signature for trait
   --> /[redacted]/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/slh-dsa-0.1.0/src/signing_key.rs:200:19
    |
200 |         rng: &mut impl signature::rand_core::CryptoRngCore,
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected generic parameter, found `impl Trait`                                                                                   
    |
   ::: /[redacted]/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/signature-2.3.0-pre.6/src/signer.rs:99:26
    |
99  |     fn try_sign_with_rng<R: TryCryptoRng>(&self, rng: &mut R, msg: &[u8]) -> Result<S, E...
    |                          - declaration in trait here

Some errors have detailed explanations: E0405, E0643.
For more information about an error, try `rustc --explain E0405`.
error: could not compile `slh-dsa` (lib) due to 2 previous errors

gkgoat1 avatar Mar 28 '25 17:03 gkgoat1

+1 to this. Reproducible with:

cargo new program && cd program
cargo add slh-dsa && cargo check
error[E0405]: cannot find trait `CryptoRngCore` in crate `signature::rand_core`
$ cargo --version
cargo 1.87.0 (99624be96 2025-05-06)

conduition avatar Aug 06 '25 20:08 conduition

Found a workaround:

cargo add signature@=2.3.0-pre.4

by default cargo is installing [email protected] and up, which causes the compilation error because newer versions of signature uses [email protected], whereas slh-dsa expects it to use [email protected].

conduition avatar Aug 06 '25 20:08 conduition