-
Notifications
You must be signed in to change notification settings - Fork 200
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
signature: final comment period and intent to ship 1.0 #78
Comments
One notable issue with the current
|
Removed |
Hey, thanks for the new docs, they're really helpful. IMO, there's still a bit of documentation missing on each trait. In particular, it'd be good to explain in Signer and Verifier that they take a Signature type argument to allow for a single concrete type to generate different "kinds" of signatures. Maybe give some concrete example (I believe ECDSA has multiple kinds of signatures, and some HSMs are able to use multiple different signatures). There should be a section of documentation show-casing a simple implementation. As it currently stands, the crate doc has no guidelines on how to write your own impls, and the traits aren't so straightforward that it can be figured out right away. IMO there should be a simple example, maybe wrapping ring or something. The impl here seems very simple and straightforward, perfect for inclusion in docs. Also, something that bothers me is that every single example uses (I rambled a lot about the docs, but as far as the API goes, it looks fine to me). |
Oh one small misgiving about the Error type: As it stands it's possible in fn main() {
let err = signature::Error {}
} For the sake of forward-compatibility (should we eventually add the ability to define errors with sources in no_std), the Error type should be changed to the following to ensure that users have to go through the new constructor. #[derive(Debug, Default)]
pub struct Error {
/// Source of the error (if applicable).
#[cfg(feature = "std")]
source: Option<Box<dyn std::error::Error + Send + Sync + 'static>>,
ensure_always_private: (),
} |
Good point regarding the To answer some of your other questions:
The signature types used by Signatory come from the Signatory provides a set of wrappers for notable Rust ecosystem signature provider crates which use the signature types from the Ideally though, provider crates would adopt these traits/types natively, so "wrapper crates" aren't needed. The |
We could do that Error type much better, although I've still never gotten around to doing so. |
Any concrete suggestions? |
I'll try to make one, but maybe it'll need to wait until v2. In essence, there are many rust crates that should be using an error type with the small box optimization, but doing that in rust is mildly tricky. It's not that the small box optimization matters so much for performance, although that's nice if you plan to error lots, but I think it can be made to work for small types even without alloc. |
I mean, for what it's worth the signature error cause should only be set in very rare situations from what we've talked about (basically, it should only be used to communicate transport errors such as HSM connection failures) and nothing else. Errors happening during the signature process should be "empty" to avoid leaking info. So the kind of errors that actually allocate are expected to be extremely rare and not require too much optimization work. |
Just adding a quick note I took a look at HRTBs for adding a pub trait Signature: AsRef<[u8]> + Debug + Sized
where
for<'a> Self: TryFrom<&'a [u8], Error = Error>,
{
/// Parse a signature from its byte representation
fn from_bytes(bytes: &[u8]) -> Result<Self, Error> {
bytes.try_into()
}
/// Borrow this signature as serialized bytes
fn as_slice(&self) -> &[u8] {
self.as_ref()
}
} This eliminates the ability to use
|
One other note: the Suggestion: rename |
The Fiat-Shamir heuristic is about hashing the transcript of an interactive protocol, not about hashing the message. You can have a non-Fiat-Shamir signature algorithm that hashes the message in this way, and you can have a Fiat-Shamir-derived algorithm that does not. These aren't obscure cases, either; an example of the latter is Ed25519. The important thing is whether you can compute the digest separately from the signature (and without the private key), not how the signature algorithm was derived. |
@daira yeah, these have been tricky things to document, that one in particular. See here for the original PR on it (which mentioned nothing about Fiat-Shamir): Notably as you mentioned I'm not sure if there's a better name for such a signature algorithm (some of the previous discussion called it "raw digest" signer. I think "prehash" is another common term ala Ed25519ph), but notably the |
FWIW I think DigestSignature conversation should go in a dedicated tracking issue since it's not part of the API getting currently stabilized, and it'd suck for those discussion points to get lost in an unrelated ticket ^^. Which brings me to something else: It'd be nice to have a tracking issue per preview feature to funnel API and stabilization discussion of those APIs there. |
The `signature` crate provides `Signer` and `Verifier` traits generic over signature types: https://github.com/RustCrypto/traits/tree/master/signature There's presently an open call to stabilize the parts of its API needed by Ed25519 signatures and release a 1.0 version: RustCrypto/traits#78 The `ed25519` crate, based on the `signature` crate, provides an `ed25519::Signature` type which can be shared across multiple Ed25519 crates (e.g. it is also used by the `yubihsm` crate): https://github.com/RustCrypto/signatures/tree/master/ed25519 This commit integrates the `ed25519::Signature` type, and changes the existing `sign` and `verify` methods (where applicable) to use the `Signer` and `Verifier` traits from the `signature` crate. Additionally, it replaces `SignatureError` with the `signature` crate's error type. This has the drawback of requiring the `Signer` and/or `Verifier` traits are in scope in order to create and/or verify signatures, but with the benefit of supporting interoperability with other Ed25519 crates which also make use of these traits.
Quick update on this: I got some good feedback it seems. Here are the remaining issues, neither of which are a 1.0 blocker, but both of which could probably use work before a 1.0 release:
Would still be nice to have some clarity / feedback around dalek-cryptography/ed25519-dalek#80 before shipping this as well. All that said, I'm not in a huge rush here, so if you'd still like to give any final feedback, please do. |
|
I've opened a PR for the final 1.0 release of the I'm going to do some preflight checks on it and then cut the release |
It's out! 🎉 |
More info on this release: RustCrypto/traits#78
More info on this release: RustCrypto/traits#78
The `signature` crate provides `Signer` and `Verifier` traits generic over signature types: https://github.com/RustCrypto/traits/tree/master/signature There's presently an open call to stabilize the parts of its API needed by Ed25519 signatures and release a 1.0 version: RustCrypto/traits#78 The `ed25519` crate, based on the `signature` crate, provides an `ed25519::Signature` type which can be shared across multiple Ed25519 crates (e.g. it is also used by the `yubihsm` crate): https://github.com/RustCrypto/signatures/tree/master/ed25519 This commit integrates the `ed25519::Signature` type, and changes the existing `sign` and `verify` methods (where applicable) to use the `Signer` and `Verifier` traits from the `signature` crate. Additionally, it replaces `SignatureError` with the `signature` crate's error type. This has the drawback of requiring the `Signer` and/or `Verifier` traits are in scope in order to create and/or verify signatures, but with the benefit of supporting interoperability with other Ed25519 crates which also make use of these traits.
This is an announcement of a 2-week final comment period (ending March 22nd) which will be followed by a 1.0 release of the
signature
crate some time thereafter.Original 1.0 stabilization proposal here.
Current status
I've published
signature
v1.0.0-pre.3, which includes significantly more documentation and clearly calls out (usingdoc_cfg
) the 1.0 stable versus unstable "preview" parts of the API:Docs: https://docs.rs/signature/1.0.0-pre.3/signature/index.html
I'd love feedback on the docs before a final release, particularly what parts of the current design remain unclear.
Note that I do intend to include more usage examples, but I would like those examples to highlight notable real-world ecosystem examples rather than contrived ones, and there's a bit of a chicken-and-egg problem in doing that.
API to be stabilized
The goal of this stabilization proposal is to stabilize the following types in the
signature
crate:Signature
Signer
Verifier
Error
The remaining types (e.g.
Digest*
) now require enabling off-by-default*-preview
features which call out their instability, but with a pledge that breaking changes are accompanied by a minor version bump. I've opened separate tracking issues for each of these here:digest-preview
:DigestSignature
,DigestSigner
,DigestVerifier
derive-preview
: custom derive forSigner
andVerifier
for use withDigestSignature
rand-preview
:RandomizedSigner
Rationale for stabilization
The four types/traits called out earlier for stabilization are sufficient for stable use of Ed25519 signatures/signers/verifiers via the
ed25519
crate, which is intended to see a 1.0 release as well after a 1.0 release of this crate is published. This is the main impetus for a 1.0 release of this crate.Current usage
The
signature
traits have seen a lot of real world usage, both in libraries that natively use them, and in crates which provide thin wrappers (and therefore a unified object-safe API) across several other notable ecosystem crates:ed25519-dalek
: via thesignatory-dalek
wrapper crate. There is also an open PR to use thesignature
traits anded25519
crate directlyring
: via thesignatory-ring
cratesecp256k1-rs
: via thesignatory-secp256k1
cratesodiumoxide
: via thesignatory-sodiumoxide
crateCrates which natively leverage the
signature
traits include:yubihsm
for ECDSA and Ed25519 signingledger-tendermint
for Ed25519 signingAlternatives considered
NOTE: See also the "Alternatives considered" section of the
signature
rustdoc.This stabilization proposal is for a trait/object-safe API, as enumerated above. The main audience of this API is consumers of digital signature systems, and thus its design is very much optimized with that audience in mind.
Several people have proposed, and we have previously investigated, an alternative design based on generic signature types with algorithm-specific marker traits, as well as leveraging use of associated types, rather than generic type parameters on traits, to allow the usage of more concrete types. An API like this would be more beneficial to implementers of signature provider libraries, and allow less invasive first-class support of the
signature
traits.The good news is that these approaches aren't orthogonal, and several of the other crates in
RustCrypto/traits
provide both an object-safe high-level API as well as an associated type-leveraging lower-level API for similar reasons. Done correctly there can be a blanket impl of the object-safe API for the provider-oriented API.That said, the design and implementation of such an API isn't considered a blocker on a 1.0 release specifically for the reasons that it can be implemented in the future in a purely additive manner.
The text was updated successfully, but these errors were encountered: