-
Notifications
You must be signed in to change notification settings - Fork 62
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
Fix a compile error for certain feature combo. #452
Conversation
`cargo build --features secp256k1,secp256r1,sha2` was failing with a compile error in ssi::hash::sha256. This fixes that.
Hold off on this one too. Related to #451 |
Ok, I've got an explanation for the confusing behavior I was encountering. I think the target-based dependencies work as one would expect. However, within the sha256 function in hash.rs, the choice of implementation is gated on the "sha2" feature, which is an implicit feature because it's an optional crate. Where things go wrong is that the I ran into this trouble while trying to get a wasm build running, where currently Anyway, I'm going to take another stab at this. The goal (at least within my codebase) is to make wasm builds use target-specific dependencies and not use a "wasm" feature, which unfortunately seems to have been the choice of many other crates. This has been a problem because often wasm-specific features are mutually incompatible with non-wasm -- |
ring if present to impl fn sha256, otherwise if sha2 is present, use that, otherwise raise unimplemented.
This is good to go now. This uses the "ring" crate if available to implement ssi::hash::sha256, otherwise will use "sha2" crate, otherwise will panic with unimplemented. Let me know if this isn't the right behavior, and I can can change it to something else suitable. |
Hey, I'm not a fan of these changes. I would prefer to have the compilation fail if a necessary feature is disabled. But I agree that if both |
That's totally fair! I'd like to figure out what specific change to make. To describe the challenge here, the use of the function What I can do is change the "unimplemented!" line in sha256, in which neither "ring" nor "sha2" are enabled, to "compile_error!", which would cause a compile error if the features necessary to provide an implementation for sha256 are not provided. I believe this should meet your request. Does that sound good to you? |
|
illegal feature combination (at least one of "ring" or "sha2" features must be enabled to have an impl of the ssi::hash::sha256 function).
cargo build --features secp256k1,secp256r1,sha2
was failing witha compile error in ssi::hash::sha256. This fixes that.