Ensures that the three highest bits of the `s` scalar component of an
Ed25519 signature are unset.
This doesn't ensure that `s` is fully reduced (which would require a
full reduction check in the event that the 4th most significant bit is
set), however it will catch a number of invalid signatures relatively
cheaply.
Inspired by:
https://github.com/dalek-cryptography/ed25519-dalek/pull/99
Adds `CompressedCurvePoint` and `UncompressedCurvePoint` as
representations of bytestrings serialized according to the
`Elliptic-Curve-Point-to-Octet-String` encoding as defined in
section 2.3.3 of SEC 1: Elliptic Curve Cryptography (Version 2.0):
https://www.secg.org/sec1-v2.pdf
Adds the NIST CAVP vectors for P-256 and P-384, along with a
self-generated test vector for secp256k1.
When available, these are used to test the transcoding functionality.
Adapts the following code from BearSSL to support translation between
ASN.1 DER encoded and fixed size (a.k.a. "raw") signatures.
This additionally allows eagerly checking that ASN.1 DER-encoded
signatures are well-formed.
Support for ASN.1 DER-encoded signatures.
Uses a GenericArray to store the variable-width signature, calculating
maximum DER framing overhead using typenum's type-level arithmetic.
Moves all trait bounds related to `FixedSignature` from the `Curve`
trait to the `FixedSignature` type.
This avoids compounding the complexity of the trait bounds on `Curve`
when ASN.1 DER signatures are added.
Adds a `Curve` trait representing short Weirstrass curves suitable for
use with ECDSA, along with an initial set of curves and their associated
private scalar size.
The only thing the `signature` crate uses `alloc` for is the
`Signature::to_vec` method, which is trivially accomplished otherwise as
`sig.as_ref().to_vec()` or various other ways.
By getting rid of it, we can completely get rid of the `alloc` feature,
and with that reduce the MSRV back to 1.31.
It might be worth considering a 1.0 release with a higher MSRV so we can
leverage `TryFrom`, but for now, this provides wider compatibility by
removing a single (mis)feature.
This upgrades to the `std::error::Error` features for boxed,
downcastable error sources introduced in Rust 1.30, namely switching
from `Error::cause` to `Error::source`, which adds a `'static` bound and
therefore allows it to support downcasting.
Additionally, it defines a `BoxError` type incorporating those bounds
along with `Send + Sync`, ensuring that `signature::Error` itself is
`Send + Sync`, which should improve the ergonomics.
The motivation for 1.0 stabilization of the `signature` crate is the
upcoming 1.0 release of `ed25519-dalek`. In order to promote Ed25519
interoperability, it would be great if `ed25519-dalek` could use the
traits from this crate along with the `ed25519::Signature` type from the
`ed25519` crate.
To get there, I think we need to do a 1.0 release of this crate, as well
as the `ed25519` crate.
The main impediment towards doing so is the `digest` crate is presently
stuck at v0.8. It would be nice to be able to continue upgrading it,
especially to a 1.0 release, but that would otherwise be a semver
breaking change.
To allow agility around `digest`, and `signatory_derive` which depends
on it, this commit places access to both under the `digest-preview` and
`derive-preview` Cargo features respectively, and calls them out as
not covered under SemVer and subject to change, but breaking changes
will be done with a minor version bump.
This reverts commit 48e33d8758.
After updating my downstream consumers to try to use this, I encountered
an important case where this falls down: deriving `Signer` and
`Verifier` on generic types where the `Digest` *can only* be generically
specified as an associated type, as the `yubihsm` crate is doing here:
https://github.com/tendermint/yubihsm-rs/blob/develop/src/ecdsa/signer.rs#L22
The goal of switching to a derive attribute was to make this
functionality more flexible and eliminate the need for a marker trate,
but in this particular case (one I personally consider very important)
it had the opposite effect.