RustCrypto / RustCrypto/traits
try_sign_digest() is confusing.
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 755
- Forks
- 256
- Avg merge
- 1h 27m
- Merged PRs (30d)
- 2
Description
As of 3.0.0 the try_sign_digest method is now confusing enough to be unusable.
Previously in 2.x try_sign_digest took a Digest output for signing per https://docs.rs/signature/2.3.0-pre.7/signature/trait.DigestSigner.html
However in 3.x this now takes an fn mut, and it's not clear how this works. To make matters worse the doc comments are practically identical. This leads to update errors such as:
error[E0277]: expected a `Fn(&mut _)` closure, found `sha2::Sha256`
--> src/lib.rs:1010:30
|
1010 | .try_sign_digest(digest)
| --------------- ^^^^^^ expected an `Fn(&mut _)` closure, found `sha2::Sha256`
| |
| required by a bound introduced by this call
|
= help: the trait `for<'a> Fn(&'a mut _)` is not implemented for `sha2::Sha256`
note: required by a bound in `try_sign_digest`
--> /Users/william/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/signature-3.0.0/src/signer.rs:110:27
|
110 | fn try_sign_digest<F: Fn(&mut D) -> Result<(), Error>>(&self, f: F) -> Result<S, Error>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `DigestSigner::try_sign_digest`
But there is no clear or actionable method to proceed as there is no way to pass the digest to this function.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the DigestSigner::try_sign_digest declaration around signer.rs:110 and compare its Rust 3.x documentation with the linked 2.x DigestSigner docs. Clarify the distinction between passing a digest and passing the callback expected by the current method, using only examples supported by the existing API. Done means the method comments no longer appear interchangeable and explain how a caller should proceed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cryptography
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100