Commit graph

17 commits

Author SHA1 Message Date
Tony Arcieri
e0e02cfcf4
Bump ed25519 to v2.2; pkcs8 to v0.10 (#285)
The `ed25519` v2.2.0 crate bumps the `pkcs8` dependency to v0.10.

This updates `ed25519` to the latest version and updates the PKCS#8
support to use the new API.
2023-03-07 02:20:09 -05:00
Tony Arcieri
4686ade1b5
Use named fields for struct VerifyingKey (#284)
Previously it was a 2-tuple containing a `CompressedEdwardsY`
serialization and a decompressed `EdwardsPoint`, however using
`.0` and `.1` for these respectively makes the code hard to read.

This commit changes them to `compressed` and `point`, which as it were
are the names of the local variables used when constructing a
`VerifyingKey`, which improves clarity.
2023-03-07 02:16:19 -05:00
Michael Rosenberg
783b6e81c4
README changes for 2.0 (#275)
* Added items to changelog for 2.0 release

* Removed unnecessary uses of std in doctests

* Gated `Context` behind `digest`

* Fixed noncompiling doctest when only `digest` is enabled

* README feature flag list mostly done

* Copied changelog to readme

* Redid the malleability section in README

* Added CONTRIBUTING.md

* Bumped version number to 2.0.0-pre.0; small changes to README

* Updated changelog for #277

* Added pem feature description

Co-authored-by: pinkforest(she/her) <36498018+pinkforest@users.noreply.github.com>
2023-02-02 17:07:56 -05:00
Michael Rosenberg
5190ad6df8
Impl VerifyingKey::is_weak (#277)
* Implemented VerifyingKey::is_weak

* Added unit test for VerifyingKey::is_weak
2023-01-31 16:23:38 -05:00
Tony Arcieri
861784f57e
Add Context type (#273)
* Add `Context` type

Adds a generic type which can be used with `SigningKey` and
`VerifyingKey` for storing a context string value along with the key for
use with `DigestSigner` and `DigestVerifier`.

* Added Context tests, docs, and re-exports

* Added docs about SHA-512 for prehashing; re-re-exported Sha512

Co-authored-by: Tony Arcieri <bascule@gmail.com>
Co-authored-by: Michael Rosenberg <michael@mrosenberg.pub>
2023-01-26 15:41:20 -05:00
Michael Rosenberg
c2b8978927
Do byte comparison in all verify_* functions (#269)
* Made all signature R comparisons byte-wise

* Use Scalar::from_bits_clamped rather than manually clamping

* Added clippy lints and comments for use of unwrap()

* Clarify use of unused
2023-01-21 01:05:54 -05:00
Tony Arcieri
ba765a5988
Impl signature::Digest* traits for Ed25519ph (#270)
* Impl `signature::Digest*` traits for Ed25519ph

Adds the following trait impls:

- impl DigestSigner for SigningKey
- impl DigestVerifier for VerifyingKey

These traits can be used to create and verify Ed25519 signatures,
thunking to `SigningKey::sign_prehashed` and
`VerifyingKey::verify_prehashed` respectively.

* Add rustdoc comments for trait impls
2023-01-21 00:02:27 -05:00
Tony Arcieri
f61e9dcf9b
Add on-by-default fast crate feature for gating basepoint tables (#251)
* Add on-by-default `fast` crate feature

Disabling the feature reduces overall code size at the cost of
performance, which is useful for e.g. embedded users.

This feature transitively enables the `basepoint-tables` feature in
`curve25519-dalek` where the basepoint tables are actually defined.

* Consolidated a lot of verification code

* Bump `curve25519-dalek`; use `precomputed-tables` feature

The feature name changed in dalek-cryptography/curve25519-dalek#499

Co-authored-by: Michael Rosenberg <michael@mrosenberg.pub>
2023-01-20 15:46:17 -05:00
pinkforest(she/her)
431e69959d
Make digest optional (#268)
digest isn't yet stable but we have use it in the public API.

This makes the digest API optional to use in opt-in basis by
feature gating this via an optional digest feature.

API items now feature-gated:

- `pub use ed25519_dalek::Digest`
- `SigningKey::sign_prehashed(D: prehashed_message, ..)`
- `SigningKey::verify_prehashed(D: prehahed_message, ..)`
- `VerifyingKey::verify_prehashed(D: prehashed_message, ..)`
- `VerifyingKey::verify_prehashed_strict(D: prehashed_message, ..)`

Also no longer re-exporting `sha2::Sha512`
2023-01-19 02:59:43 -05:00
Linus Karl
e1d4ef313e
Implement Hash trait for VerifyingKey (#265)
* Added and cleaned up some verification docs

Co-authored-by: Michael Rosenberg <michael@mrosenberg.pub>
2023-01-16 22:43:05 -05:00
Michael Rosenberg
b5dc40bedf
Make verify_batch deterministic (#256)
Also removed `batch_deterministic` feature
2023-01-14 21:26:39 -05:00
Tony Arcieri
6ee4d1de5c
Use curve25519-dalek from git; check in Cargo.lock (#260)
Updates to the latest upstream changes in `curve25519-dalek`, including
using the new `EdwardsPoint::mul_base` API.

To keep the build deterministic, this also checks in Cargo.lock, which
pins `curve25519-dalek` to a particular git commit SHA which can be
updated using `cargo update -p curve25519-dalek`.

We can potentially remove `Cargo.lock` again after a crate release.
2023-01-09 04:44:10 -05:00
andrew lyon
4f218d8e67
Adding verify_prehashed_strict() (#212)
Combines `verify_prehashed` and `verify_strict` to allow strict
verification with prehashed values.
2023-01-07 09:21:54 -07:00
Tony Arcieri
65aeda0867
Impl From<&SigningKey> for VerifyingKey (#252)
Calls the inherent `SigningKey::verifying_key` method using `From`
conversions.

This replaces vestigial impl for `SecretKey` which is now an alias for
`[u8; 32]`.
2023-01-05 05:31:58 -05:00
pinkforest(she/her)
194b17f18a
Fix all Clippy warnings (#244)
- Add Clippy to CI
- Rename InternalError variants without redundant Error suffix
- Rename to_bytes to as_bytes on well known naming
- Fix Redundant refs
- Fix redundant lifetimes
- Fix late declarations
2022-12-18 13:56:41 -07:00
Michal Nazarewicz
24cd9421d5 Change from_bytes methods to take fixed-size array argument
Change from_bytes methods to take `&[u8; N]` argument (with `N`
appropriate for given type) rather than `&[u8]`.  This harmonises
the convention with SigningKey and ed25519::Signature; helps type
inference; and allows users to assert bytes size to be asserted at
compile time.

Creating from a slice is still possible via `TryFrom<&[u8]>` trait.

This is an API breaking change.  The simplest way to update existing
code is to replace Foo::from_bytes with Foo::try_from.  This should
cover majority of uses.
2022-12-18 19:43:37 +01:00
Tony Arcieri
52da7353b8
Rename Keypair => SigningKey; PublicKey => VerifyingKey (#242)
* Rename `signing` and `verifying` modules

Renames the following modules:

- `keypair` => `signing`
- `public` => `verifying`

Renaming these in an individual commit preserves the commit history.

This is in anticipation of renaming the following per #225:

- `Keypair` => `SigningKey`
- `PublicKey` => `VerifyingKey`

* Rename `Keypair` => `SigningKey`; `PublicKey` => `VerifyingKey`

As proposed in #225, renames key types after their roles:

- `SigningKey` produces signatures
- `VerifyingKey` verifies signatures

The `SecretKey` type is changed to a type alias for `[u8; 32]`, which
matches the RFC8032 definition:

https://www.rfc-editor.org/rfc/rfc8032#section-5.1.5

> The private key is 32 octets (256 bits, corresponding to b) of
> cryptographically secure random data.
2022-12-18 01:24:58 -05:00
Renamed from src/public.rs (Browse further)