Commit graph

2304 commits

Author SHA1 Message Date
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
SergeStrashko
fedb1450de
Add Scalar::from_bits_clamped (#498)
As discussed in #497, adds a function which "clamps" a 256-bit input into a
valid scalar by clearing and setting bits, as used by Ed25519 and X25519
2023-01-09 09:34:57 -07: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
Tony Arcieri
83f6b149d3
Add basepoint-tables crate feature (#489)
* Add `basepoint-tables` crate feature

Feature-gates the inclusion of basepoint tables under a
`basepoint-tables` feature, with the goal of reducing code size for e.g.
embedded applications.

* Add `mul_base` method to `EdwardsPoint` and `RistrettoPoint`

Provides fixed-base scalar multiplication which optionally uses
precomputed basepoint tables when the `basepoint-tables` feature is
enabled, providing 4X better performance.

Falls back on variable-base scalar multiplication in the event the
feature is disabled.

Co-authored-by: Michael Rosenberg <michael@mrosenberg.pub>
2023-01-08 03:51:51 -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
Tony Arcieri
8c2f545d91
Expand const fn support (#494)
Does a pass on adding `const` to methods where it's possible.
2023-01-06 13:29:56 -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
dlblv
d95e3bd536 impl AsRef for keys as well 2022-12-30 01:43:42 +05:00
Tony Arcieri
6a51f4fa40
Make basepoint table constants &'static references (#488)
* Make basepoint table constants static references

This ensures they have a fixed address and aren't duplicated across
compilation units.

Since they were already always borrowed, this changes the static values
to be `&'static` addresses to ensure they're always borrowed rather than
potentially copied.

* rustfmt
2022-12-28 03:24:46 -05:00
Tony Arcieri
1b000d271d
CI: use RustCrypto/actions/cross-install (#487)
This action is located at:
https://github.com/RustCrypto/actions/blob/master/cross-install/action.yml
It's used across the RustCrypto project for installing `cross` in CI.
Installation is performed by fetching a pinned binary release from:
https://github.com/cross-rs/cross/releases/
This eliminates problems that might occur when using `cargo install`
such as:
https://github.com/dalek-cryptography/curve25519-dalek/actions/runs/3786735408/jobs/6437902657
It's also marginally faster.
2022-12-27 15:53:12 -05:00
Tony Arcieri
0ffcb84625
Don't set html_root_url (#483)
The recommendation to set this has been removed from the Rust API
guidelines:

https://github.com/rust-lang/api-guidelines/pull/230

It used to be used by docs.rs, but docs.rs now unconditionally sets the
`--extern-html-root-url` parameter of rustdoc which overrides it, making
it no longer needed and superfluous.
2022-12-27 05:14:34 -05:00
Tony Arcieri
ebcd744054
CI: add build-nostd job (#482)
We currently don't have any checks that this crate builds on a `no_std`
target.

While `curve25519-dalek` itself doesn't link `std`, it uses dependencies
which could potentially link `std`, so it's important to have a job to
check that the crate builds on a `no_std` target to ensure feature
activation doesn't accidentally flip on the `std` feature of one of
those dependencies unintentionally.

This adds a job which checks the crate builds on a `thumbv7em-none-eabi`
target which has no `std` implementation.
2022-12-27 05:13:57 -05:00
Tony Arcieri
7227c6fa9b
Remove Travis CI configuration (#484)
The migration to GitHub Actions occurred quite awhile ago and Travis CI
is no longer used
2022-12-27 05:13:13 -05:00
Tony Arcieri
7d53206366
Weakly activate zeroize?/alloc; MSRV 1.60 (#485)
Previously `alloc` implicitly activated `zeroize` via `zeroize/alloc`.

This commit switches to weak feature activation as added in Rust 1.60,
only activating `zeroize/alloc` if the `zeroize` dependency is
explicitly activated (which it is by default).
2022-12-27 05:12:55 -05:00
Tony Arcieri
39dbaea6f9
Make zeroize an optional dependency (#481)
* Make `zeroize` an optional dependency

The `zeroize` crate provides a defense against memory read oracles which
typically arise from memory unsafety.

Pure Rust programs may not benefit from `zeroize`, and in certain cases
the unsafe code used by `zeroize` may be more concerning.

This commit makes `zeroize` into an optional feature so users may elect
to disable it if they so desire.

* Added zeroize feature flag to README

Co-authored-by: Michael Rosenberg <michael@mrosenberg.pub>
2022-12-26 16:19:55 -05:00
Michael Rosenberg
616d55c36c
Impld Clone for SigningKey (#249) 2022-12-21 15:10:18 -07:00
dlblv
7374fd3d2f fix clippy warnings 2022-12-21 01:11:17 +05: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
dlblv
50dbb9eb4d Add as_bytes() method 2022-12-19 21:30:09 +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
Michael Rosenberg
06186b8511
Merge pull request #479 from pinkforest/doc-fix-release-pre5
Fix docs.rs release pre.5
2022-12-14 00:51:27 -05:00
pinkforest
39053b1c5d Fix docs release pre.5 2022-12-14 11:28:52 +11: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
Michael Rosenberg
b0b22def50
Bumped prerelease version 2022-12-13 17:17:34 -05:00
Michael Rosenberg
14b04b22d5
Merge pull request #478 from pinkforest/fix-clippy-is-my-bestie
Fix clippy for build.rs
2022-12-13 16:31:30 -05:00
Michael Rosenberg
6a513fc3bb
Merge pull request #477 from rozbb/fix-docsrs
Fixed docs.rs flags in Cargo.toml
2022-12-13 16:27:50 -05:00
pinkforest
3f2da879ba Fix clippy for build.rs 2022-12-14 05:21:10 +11:00
Michael Rosenberg
91c2305328
Fixed docsrs flags in Cargo.toml 2022-12-13 08:48:03 -05:00
Michael Rosenberg
42d8dbd42a
Merge release/4.0 into main (#474) 2022-12-13 08:28:41 -05:00
Michael Rosenberg
dbe599532f
Bumped prerelease version 2022-12-13 02:32:48 -05:00
Michael Rosenberg
1cedb3727e
Fixed docs build (#475)
Also sets code font size in docs back to normal (no longer small)
2022-12-13 02:29:45 -05:00
Michael Rosenberg
174611895b
Removed changelog line about wasm and arm defaults 2022-12-12 18:09:31 -05:00
Michael Rosenberg
87fc5310b8
Added latest changelog entries to readme 2022-12-12 18:03:58 -05:00
Michael Rosenberg
d7140146f2
Add rust-version to cargo
Co-authored-by: str4d <thestr4d@gmail.com>
2022-12-12 17:50:58 -05:00
Tony Arcieri
274f4a7bec
Change Scalar::from_canonical_bytes to return CtOption (#472)
This is helpful for implementing `ff::PrimeField::from_repr`.
Also changes `Scalar::is_canonical` to return `Choice`.
2022-12-12 17:38:04 -05:00
Michael Rosenberg
94a99d82f8
README: Removed non-existent features 2022-12-12 03:03:40 -05:00