Commit Graph

457 Commits

Author SHA1 Message Date
Tony Arcieri
db4e9ddf02 Bump ed25519 crate dependency to v2.1
The original v2.0.0 release has been yanked.

This release includes a different infallible parsing API which can be
used to eliminate some usages of `unwrap()`.
2023-01-21 15:19:20 -07: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
7d255cd85a CI: test cargo doc build (#271)
* CI: test `cargo doc` build

Ensure it's free of warnings

* Fix rustdoc build
2023-01-21 00:21:35 -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
Tony Arcieri
6d9bbd323e Bump ed25519 dependency to v2 (#266)
Release notes: https://github.com/RustCrypto/signatures/pull/622
2023-01-16 21:38:57 -05:00
pinkforest(she/her)
8c455f58ae Make rand_core optional (#262)
* Make rand_core optional
* Bench requires features rand_core
2023-01-15 19:13:33 -05:00
Michael Rosenberg
b5dc40bedf Make verify_batch deterministic (#256)
Also removed `batch_deterministic` feature
2023-01-14 21:26:39 -05:00
pinkforest(she/her)
4f6b4b247f Make zeroize optional (#263)
Defaults to on
2023-01-09 07:57:59 -07: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
461a2d7e05 Bump ed25519 crate to v2.0.0-rc.0 (#257) 2023-01-07 00:50:39 -05:00
Michael Rosenberg
f036eaf482 Validation criteria tests (#253) 2023-01-05 22:58:54 -05: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
Michael Rosenberg
e2ed3133a6 Fix batch build (#220)
* Fixed bench when `batch` feature is not present

* Added bench build regression test to CI

* Fixed batch build more generally

* Simplified batch cfg gates in benches

* Updated criterion

* Made CI batch-nondeterministic test use nostd

* Fix batch_deterministic build

* Removed bad compile error when batch and batch_deterministic are selected
2023-01-02 00:59:19 -05:00
Michael Rosenberg
616d55c36c Impld Clone for SigningKey (#249) 2022-12-21 15:10:18 -07:00
Tony Arcieri
f6a242a5b0 Use namespaced/weak features; MSRV 1.60 (#235)
This enables activating the `alloc` and `std` features without
unnecessarily pulling in optional dependencies like `rand` and `serde`.

It also fixes tests for `--no-default-features` (w\ `--lib` only)
2022-12-20 04:48:55 -05:00
Tony Arcieri
951d489d51 CI: check code is formatted correctly using rustfmt (#246) 2022-12-20 04:37:04 -05:00
Tony Arcieri
a0384be8fc Impl Drop/ZeroizeOnDrop for SigningKey (#247)
- Zeros out `SigningKey::secret_key` on drop
- Adds the `ZeroizeOnDrop` marker trait to `SigningKey`
2022-12-20 04:28:20 -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
Tony Arcieri
c01cab0d19 Merge pull request #243 from pinkforest/fix-signingkey-docs-coverage
Fix `SigningKey` from/to_bytes docs +coverage
2022-12-18 12:51:02 -07:00
Tony Arcieri
f0b2df03ca Merge pull request #230 from mina86/a
Change from_bytes methods to take fixed-size array argument
2022-12-18 12:49:59 -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
pinkforest
134b5e174d Fix SigningKey to/from_bytes doc/coverage 2022-12-18 19:02:18 +11: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
Tony Arcieri
55620dcde5 PKCS#8 support (#224)
Adds optional integration with `ed25519::pkcs8` with support for
decoding/encoding `Keypair` from/to PKCS#8-encoded documents as well as
`PublicKey` from/to SPKI-encoded documents.

Includes test vectors generated for the `ed25519` crate from:
https://github.com/RustCrypto/signatures/tree/master/ed25519/tests/examples
2022-12-13 18:19:31 -05:00
Tony Arcieri
cfcdf536a0 Cargo.toml: compatibility updates for curve25519-dalek and ed25519 (#236)
curve25519-dalek:

- Enables `digest` and `rand_core` features
- Removes transitive `nightly`, `simd_backend`, and `std` features

ed25519:

- `AsRef` impl for `Signature` has been removed; uses `to_bytes`
- Uses `try_from` for `InternalSignature` conversion
2022-12-09 21:14:38 -05:00
Tony Arcieri
01ad6305f2 Edition fixups: remove extern crate, add idioms lint (#231)
Rust editions 2018+ do not require `extern crate` except for linking
`alloc` and `std`.
2022-12-08 02:39:48 -05:00
Tony Arcieri
44512a3e9c CI: only build simd_backend; don't run tests (#232)
GitHub Actions runners are not guaranteed to have the necessary CPU
features in order for these tests to work.

Uses a `--target x86_64-unknown-linux-gnu` directive when compiling so
the `target_feature` flags don't apply to build scripts.
2022-12-07 03:07:55 -05:00
Tony Arcieri
a03c7a3f0f Tune up CI configuration (#227)
- Consolidate `test` jobs: this allows reusing intermediate artifacts
  between tests which should improve build times, and also make it
  easier to test additional features in the future
- Switch to `dtolnay/rust-toolchain` for setting up toolchain
- Bump checkout to `actions/checkout@3`
- Switch to `run` directives for invoking Cargo: it's more
  straightforward to just call Cargo than use a DSL from an unmaintained
  action, and eliminates the 3rd party dependency
2022-11-21 17:23:05 -05:00
Tony Arcieri
d4cffc7d05 ed25519 v2.0.0-pre.0 (#222)
Bumps the `ed25519` crate to the v2.0.0-pre.0 prerelease.

This version notably uses the `signature` crate's v2 API:

https://github.com/RustCrypto/traits/pull/1141
2022-11-21 17:21:05 -05:00
Tony Arcieri
ae4bd2c81e Fix warnings and add -D warnings check in CI (#226) 2022-11-20 22:28:09 -05:00
Tony Arcieri
f7cbeee7f6 Bump curve25519-dalek to v4.0.0-pre (via git) (#223)
Also bumps these corresponding dependencies which are needed for everything to compile with this update:

* `merlin` v3.0
* `rand` v0.8
* `rand_core` v0.6
* `sha2` v0.10
2022-11-20 15:08:05 -05:00
Michael Rosenberg
7529d65506 Fixed installation section in README; accidentally deleted this earlier 2022-10-16 19:38:36 -04:00
Michael Rosenberg
8319adbff4 Bumped MSRV to 1.56.1 and added some documentation about semver (#218)
Also fixed benchmark build
2022-10-16 18:51:26 -04:00
Alex Xiong
9638ab40a5 Made ExpandedSecretKey private to avoid signing key oracle (#205)
This fix eliminates a scenario where a user misuses the `ExpandedSecretKey` API
in a way that leaks the user's secret key. In short, if a user sends
`ExpandedSecretKey::sign(sk, msg, pk1)` followed by
`ExpandedSecretKey::sign(sk, msg, pk2)`, where `pk1 != pk2`, a passive
adversary [can easily][0] derive `sk`. To mitigate this, we remove the API
entirely.

[0]: https://github.com/MystenLabs/ed25519-unsafe-libs
2022-10-15 15:04:03 -04:00
Isis Lovecruft
ad461f4f0f Merge branch 'feature/github-actions' into main 2021-09-14 01:08:27 +00:00
Isis Lovecruft
ce37a8a047 Merge remote-tracking branch 'spacejam/tyler_optimize_compilation' into main 2021-09-14 01:07:25 +00:00
Isis Lovecruft
10cef49824 Add CI via Github actions. 2021-09-14 01:04:53 +00:00
isis agora lovecruft
da109a8e0f Merge pull request #178 from gbaranski/fix/rust-analyzer-completions
fix: remove rust-analyzer breaking line
2021-09-14 00:08:22 +00:00
isis agora lovecruft
c17df35541 Merge pull request #175 from matteomonti/patch-1
Update README.md
2021-09-13 23:54:28 +00:00
isis agora lovecruft
86db7c9853 Merge pull request #168 from huitseeker/thread-fiat-backends
Threads the `fiat_{u64,u32}_backend` features through the feature set
2021-09-13 23:52:49 +00:00
gbaranski
c5fb932561 fix: stop forbidding unsafe in tests 2021-08-01 19:28:40 +02:00
gbaranski
d94b0f52dc fix: remove rust-analyzer breaking line 2021-08-01 18:29:28 +02:00
Matteo Monti
29932412f8 Update README.md
Fixes minor typo
2021-05-29 17:38:14 +02:00
François Garillot
c12cf48623 Threads the fiat_{u64,u32}_backend features in the feature set
This allows the fiat backends introduced in
[curve25519-dalek/#342](https://github.com/dalek-cryptography/curve25519-dalek/pull/342)
to be used from an ed25519 import without cumbersome overrides.
2021-05-03 16:26:11 -07:00
Tyler Neely
9d9a6b0beb Speed up compilation by avoiding zeroize_derive 2020-11-25 12:35:24 +01:00
Isis Lovecruft
bbb8869550 Fix std builds when serde is enabled. 2020-11-02 23:57:09 +00:00