485 Commits

Author SHA1 Message Date
Tony Arcieri
c1d6fef6b5 Remove code (#327)
The repo has moved to:

https://github.com/dalek-cryptography/curve25519-dalek/tree/main/ed25519-dalek

This PR removes the old code so people stop sending PRs to the wrong
repo.
2025-12-06 23:55:35 +01:00
Michael Rosenberg
02001d8c34 Added archival notice (#311) 2023-08-12 12:08:19 -04:00
pinkforest(she/her)
58a967f6fb chore: Release 2.0.0-rc.3 (#307)
* chore: Release 2.0.0-rc.3

* cargo update -p curve25519-dalek

* Removed some old backend selection prose and env vars

---------

Co-authored-by: Michael Rosenberg <michael@mrosenberg.pub>
2.0.0-rc.3
2023-06-23 23:53:10 -04:00
Michael Rosenberg
9b166b75e0 Update to new Scalar API (#293)
* Updated to new curve25519 scalar API

* Made ExpandedSecretKey.scalar_bytes unclamped; clamping occurs in all scalar-point multiplication

* Added legacy compat deprecation notice

* Removed deprecation notice on check_scalar

* Removed unnecessary unwraps
2023-06-12 00:06:00 -04:00
Michael Rosenberg
4afbf09e1c Add hazmat module with ExpandedSecretKey, raw_sign, raw_sign_prehashed (#299)
* Added raw_sign() and raw_sign_prehashed() functions

* Renamed `nonce` to `hash_prefix` in signing because it's really not a nonce

* Moved raw signing to hazmat module

* impl From<EdwardsPoint> for VerifyingKey

* Brought back ExpandedSecretKey; made raw_* functions take it as input

* Added remaining features to docs.rs feature set

* Removed redundant ExpandedSecretKey def; made raw signing use a generic CtxDigest

* Implemented raw_verify with generic CtxDigest

* Implemented raw_verify_prehashed with generic MsgDigest and CtxDigest

* Wrote hazmat tests; fixed errors; switched ordering of MsgDigest and CtxDigest

* Updated changelog

* ExpandedSecretKey::from_bytes takes an array and is now infallible

* Add TODO comment for split_array_ref

* Added from_slice and TryFrom<&[u8]> for ExpandedSecretKey

---------

Co-authored-by: Tony Arcieri <bascule@gmail.com>
2023-05-15 00:50:38 -04:00
Damir Jelić
90f10ed096 Fix a typo (#300) 2023-04-11 11:19:36 -06:00
Michael Rosenberg
80aac08c1c Fixed repoerted speedup/slowdown percentages in README benchmarks (#297) 2023-03-30 15:00:52 -04:00
Tony Arcieri
c8c9f29989 Add Scalar and MontgomeryPoint conversions (#296)
* Add `Scalar` and `MontgomeryPoint` conversions

- Adds `SigningKey::to_scalar` to extract the private scalar
- Adds `VerifyingKey::to_montgomery` to map the verifying key's
  `EdwardsPoint` to a `MontgomeryPoint`
- Also adds corresponding `From<&T>` impls which call the inherent
  methods.

This is useful for systems which are keyed using Ed25519 keys which
would like to use X25519 for D-H. Having inherent methods means it's
possible to call these methods without having to import `Scalar` and
`MontgomeryPoint` from `curve25519-dalek`.

This is of course a bit circuitous: we could just multiply `Scalar` by
`EdwardsPoint` and use the resulting `EdwardsPoint` as the D-H shared
secret, however it seems many protocols have adopted this approach of
mapping to `MontgomeryPoint` and using that for the shared secret, since
X25519 is traditionally used for ECDH with Curve25519.

* Add reference to eprint 2021/509

* Basic X25519 Diffie-Hellman test
2023-03-30 13:29:36 -04:00
pinkforest(she/her)
5014c91270 chore: Release 2.0.0-rc.2 (#295)
Co-authored-by: Michael Rosenberg <michael@mrosenberg.pub>
2.0.0-rc.2
2023-03-26 11:23:14 -04:00
Rob Ede
7901b21e06 Improve diagnostics when key being deserializing is too long (#294) 2023-03-26 04:11:23 -04:00
ryan
2931c688eb Fix serde / no_std incompatibility
Co-authored-by: ryan kurte <ryan@kurte.nz>
Co-authored-by: Vlad Semenov <semenov.vlad.by@gmail.com>
2023-03-21 13:45:33 -06:00
pinkforest(she/her)
9577d1e322 Add no_std to CI (#289)
* Add no_std to CI

* Add serde to no_std feature test

* Try out cargo hack

* No serde - expect success

* Add build for no-default-features

* Exclude default
2023-03-21 01:46:43 -04:00
Samuel Moelius
7dc1bbd855 Remove two unnecessary into_iter (#290) 2023-03-18 09:22:15 -06:00
Dirk Stolle
64b26ad074 Fix a few typos (#281) 2023-03-07 02:54:30 -05:00
Dirk Stolle
c33b49bf5a Update actions/checkout in GitHub Actions workflow to v3 (#282) 2023-03-07 02:44:55 -05:00
Dirk Stolle
3efde345b6 Remove invalid input fields from CI action for Rust setup (#283)
Neither `override` nor `profile` are valid inputs for the
`dtolnay/rust-toolchain` action. It always uses the minimal
profile anyways.
2023-03-07 02:35:10 -05:00
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
619ef68d73 Merge pull request #279 from rozbb/main
Bump curve25519 dep to rc.1
2023-02-04 10:06:05 -05:00
Michael Rosenberg
0b04124175 Fixed MSRV build 2023-02-04 03:24:09 -05:00
Michael Rosenberg
b77fa51569 Bump curve25519-dalek dep to rc.1 2023-02-04 03:21:36 -05:00
Michael Rosenberg
ce3eed873c Merge pull request #278 from dalek-cryptography/release/2.0
Merge `release/2.0` into `main`
2023-02-02 18:12:59 -05:00
Michael Rosenberg
57a8add0fd Removed vestigial nightly feature from docsrs instructions 2023-02-02 17:18:47 -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
1b86ff1d3e Bump curve25519-dalek to v4.0.0-rc.0 (#276)
Eliminates the `patch.crates-io` directive by using the latest RC
release of `curve25519-dalek` on crates.io
2023-01-28 18:56:35 -05:00
pinkforest(she/her)
928d6d15f8 Docs.rs + README changes for 2.x (#241) 2023-01-27 01:06:24 -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
Tony Arcieri
27ba9dd614 Bump ed25519 crate dependency to v2.1 (#272)
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 17:59:11 -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
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