Skip to content

Commit 54e464f

Browse files
authored
signature: remove long-winded intro section in rustdoc (#2392)
Much of this is out-of-date (signature types are no longer bag-of-bytes, for example), and probably not generally helpful for understanding the litany of traits available in this crate. It might make sense to add back a similar section but it should probably be written from scratch given the current state of the crate.
1 parent 5cb62a4 commit 54e464f

1 file changed

Lines changed: 12 additions & 99 deletions

File tree

signature/src/lib.rs

Lines changed: 12 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -10,115 +10,28 @@
1010

1111
//! # Design
1212
//!
13-
//! This crate provides a common set of traits for signing and verifying
14-
//! digital signatures intended to be implemented by libraries which produce
15-
//! or contain implementations of digital signature algorithms, and used by
16-
//! libraries which want to produce or verify digital signatures while
17-
//! generically supporting any compatible backend.
18-
//!
19-
//! ## Goals
20-
//!
21-
//! The traits provided by this crate were designed with the following goals
22-
//! in mind:
23-
//!
24-
//! - Provide an easy-to-use, misuse resistant API optimized for consumers
25-
//! (as opposed to implementers) of its traits.
26-
//! - Support common type-safe wrappers around "bag-of-bytes" representations
27-
//! which can be directly parsed from or written to the "wire".
28-
//! - Expose a trait/object-safe API where signers/verifiers spanning multiple
29-
//! homogeneous provider implementations can be seamlessly leveraged together
30-
//! in the same logical "keyring" so long as they operate on the same
31-
//! underlying signature type.
32-
//! - Allow one provider type to potentially implement support (including
33-
//! being generic over) several signature types.
34-
//! - Keep signature algorithm customizations / "knobs" out-of-band from the
35-
//! signing/verification APIs, ideally pushing such concerns into the type
36-
//! system so that algorithm mismatches are caught as type errors.
37-
//! - Opaque error type which minimizes information leaked from cryptographic
38-
//! failures, as "rich" error types in these scenarios are often a source
39-
//! of sidechannel information for attackers (e.g. [BB'06])
40-
//!
41-
//! [BB'06]: https://en.wikipedia.org/wiki/Daniel_Bleichenbacher
42-
//!
43-
//! ## Implementation
44-
//!
45-
//! To accomplish the above goals, the [`Signer`] and [`Verifier`] traits
46-
//! provided by this are generic over a signature value, and use generic
47-
//! parameters rather than associated types. Notably, they use such a parameter
48-
//! for the return value, allowing it to be inferred by the type checker based
49-
//! on the desired signature type.
50-
//!
51-
//! ## Alternatives considered
52-
//!
53-
//! This crate is based on many years of exploration of how to encapsulate
54-
//! digital signature systems in the most flexible, developer-friendly way.
55-
//! During that time many design alternatives were explored, tradeoffs
56-
//! compared, and ultimately the provided API was selected.
57-
//!
58-
//! The tradeoffs made in this API have all been to improve simplicity,
59-
//! ergonomics, type safety, and flexibility for *consumers* of the traits.
60-
//! At times, this has come at a cost to implementers. Below are some concerns
61-
//! we are cognizant of which were considered in the design of the API:
62-
//!
63-
//! - "Bag-of-bytes" serialization precludes signature providers from using
64-
//! their own internal representation of a signature, which can be helpful
65-
//! for many reasons (e.g. advanced signature system features like batch
66-
//! verification).
67-
//! - Associated types, rather than generic parameters of traits, could allow
68-
//! more customization of the types used by a particular signature system,
69-
//! e.g. using custom error types.
70-
//!
71-
//! It may still make sense to continue to explore the above tradeoffs, but
72-
//! with a *new* set of traits which are intended to be implementor-friendly,
73-
//! rather than consumer friendly. The existing [`Signer`] and [`Verifier`]
74-
//! traits could have blanket impls for the "provider-friendly" traits.
75-
//! However, as noted above this is a design space easily explored after
76-
//! stabilizing the consumer-oriented traits, and thus we consider these
77-
//! more important.
78-
//!
79-
//! That said, below are some caveats of trying to design such traits, and
80-
//! why we haven't actively pursued them:
81-
//!
82-
//! - Generics in the return position are already used to select which trait
83-
//! impl to use, i.e. for a particular signature algorithm/system. Avoiding
84-
//! a unified, concrete signature type adds another dimension to complexity
85-
//! and compiler errors, and in our experience makes them unsuitable for this
86-
//! sort of API. We believe such an API is the natural one for signature
87-
//! systems, reflecting the natural way they are written absent a trait.
88-
//! - Associated types preclude multiple implementations of the same trait.
89-
//! These parameters are common in signature systems, notably ones which
90-
//! support different serializations of a signature (e.g. raw vs ASN.1).
91-
//! - Digital signatures are almost always larger than the present 32-entry
92-
//! trait impl limitation on array types, which complicates bounds
93-
//! for these types (particularly things like `From` or `Borrow` bounds).
13+
//! This crate provides a common set of traits for signing and verifying digital signatures intended
14+
//! to be implemented by libraries which produce or contain implementations of digital signature
15+
//! algorithms, and used by libraries which want to produce or verify digital signatures
16+
//! generically.
9417
//!
9518
//! ## Unstable features
9619
//!
97-
//! Despite being post-1.0, this crate includes off-by-default unstable
98-
//! optional features, each of which depends on a pre-1.0
99-
//! crate.
20+
//! Despite being post-1.0, this crate includes off-by-default unstable optional features, each of
21+
//! which depends on a pre-1.0 crate.
10022
//!
101-
//! These features are considered exempt from SemVer. See the
102-
//! [SemVer policy](#semver-policy) above for more information.
23+
//! These features are considered exempt from SemVer. See "SemVer Policy Exemptions" for more
24+
//! information.
10325
//!
10426
//! The following unstable features are presently supported:
10527
//!
106-
//! - `digest`: enables the [`DigestSigner`] and [`DigestVerifier`]
107-
//! traits which are based on the [`Digest`] trait from the [`digest`] crate.
108-
//! These traits are used for representing signature systems based on the
109-
//! [Fiat-Shamir heuristic] which compute a random challenge value to sign
110-
//! by computing a cryptographically secure digest of the input message.
111-
//! - `rand_core`: enables the [`RandomizedSigner`] trait for signature
112-
//! systems which rely on a cryptographically secure random number generator
113-
//! for security.
114-
//!
115-
//! NOTE: the [`async-signature`] crate contains experimental `async` support
116-
//! for [`Signer`] and [`DigestSigner`].
28+
//! - `digest`: enables the [`DigestSigner`] and [`DigestVerifier`] traits which are based on the
29+
//! [`Digest`] trait from the [`digest`] crate.
30+
//! - `rand_core`: enables the [`RandomizedSigner`] trait for signature systems which rely on a
31+
//! cryptographically secure random number generator for security.
11732
//!
118-
//! [`async-signature`]: https://docs.rs/async-signature
11933
//! [`digest`]: https://docs.rs/digest/
12034
//! [`Digest`]: https://docs.rs/digest/latest/digest/trait.Digest.html
121-
//! [Fiat-Shamir heuristic]: https://en.wikipedia.org/wiki/Fiat%E2%80%93Shamir_heuristic
12235
12336
#[cfg(feature = "alloc")]
12437
extern crate alloc;

0 commit comments

Comments
 (0)