485 Commits

Author SHA1 Message Date
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
Isis Lovecruft
ce5ff27681 Make serde_bytes/alloc dependent on alloc feature.
Fixup for PR #149.
2020-10-28 00:04:15 +00:00
isis agora lovecruft
50b26f0bb4 Merge pull request #149 from xu-cheng/no_std
fix serde in no_std
2020-10-28 00:02:02 +00:00
isis agora lovecruft
95db7d8eae Merge pull request #153 from huitseeker/non_repudiation
[test-only] Add test showing non-repudiation for verify, verify_strict
2020-10-27 23:59:26 +00:00
François Garillot
da6c7e114f [test-only] Add test showing the non-repudiation property of the signature verifications used in PublicKey::verify and PublicKey::verify_strict.
This PR is a follow-up of #98, which aims to demonstrate the issue brought by small-order public keys. It shows an example of crafting a (public_key, signature) that verifies against two distinct messages using `verify`, but fails using `verify_strict`.
This has consequences on the possibility to repudiate a signed contract of blockchain transactions.

For more details, see:
https://eprint.iacr.org/2020/1244

Joint work with @kchalkias @valerini
2020-10-14 17:28:51 -04:00
Cheng XU
6ce6519287 fix serde in no_std 2020-09-21 19:16:01 -07:00
Isis Lovecruft
91234fcdc8 Merge branch 'master' into develop 2020-09-22 02:01:10 +00:00
Isis Lovecruft
925eb9ea56 Merge branch 'release/1.0.1' 2020-09-22 02:00:50 +00:00
Isis Lovecruft
1042cb60a0 Bump ed25519-dalek version to 1.0.1. 1.0.1 2020-09-22 01:56:35 +00:00
Isis Lovecruft
8c15bce61d Actually, we use unsafe{} in one test. 2020-09-22 01:54:44 +00:00
isis agora lovecruft
97c22f2d07 Merge pull request #146 from xu-cheng/serde2
Fix serde implementation for serde_json
2020-09-22 01:49:58 +00:00
isis agora lovecruft
a9ebf7f53e Merge pull request #148 from isislovecruft/feature/forbid-unsafe
Add #![forbid(unsafe_code)].
2020-09-22 01:39:51 +00:00
isis agora lovecruft
1335f3a859 Merge pull request #147 from isislovecruft/fix/deterministic-batch-malleability
batch verification malleability issue when used with fully deterministic nonce generation
2020-09-22 01:38:22 +00:00
Isis Lovecruft
d6ff6de2cf Add #![forbid(unsafe_code)].
CLOSES https://github.com/dalek-cryptography/ed25519-dalek/issues/144
2020-09-22 01:36:49 +00:00
Cheng XU
69eccda444 Fix serde implementation for serde_json
We use the [serde_bytes](https://github.com/serde-rs/bytes) crate for
serialization implementations, which simplifies codes and fixes issues
for serde_json.
2020-09-21 18:26:59 -07:00
Cheng XU
008c9680f6 Update tests for serde
* Upgrade bincode to 1.0
* Add more serde tests including json serialization.
2020-09-21 18:26:59 -07:00
Isis Lovecruft
b5a15bf451 Feature gate key generation on the "rand" dependency.
See https://github.com/dalek-cryptography/ed25519-dalek/pull/139.
2020-09-21 23:53:56 +00:00
Isis Lovecruft
6609642036 Enable rand crate by default.
See https://github.com/dalek-cryptography/ed25519-dalek/pull/139.
2020-09-21 23:53:29 +00:00
isis agora lovecruft
7155c07afa Merge pull request #139 from garbageslam/fixup_rand_usage
Make `use rand::...` gated on `cfg(feature = "rand")`
2020-09-21 23:47:26 +00:00
isis agora lovecruft
036c18a01b Merge pull request #145 from isislovecruft/fix/rand-nightly-breakage
Workaround for rand crate "nightly" feature breakage.
2020-09-21 23:35:21 +00:00
Isis Lovecruft
5d7bc29ba2 Workaround for rand crate "nightly" feature breakage.
Cf. https://github.com/rust-random/rand/issues/1047
2020-09-21 23:25:15 +00:00
Isis Lovecruft
a02190adf3 Document that we include the message lengths in the transcript. 2020-09-21 22:10:03 +00:00
Isis Lovecruft
57a5473cb0 Fix and document malleability issue in deterministic batch_verify().
Thank you to @real_or_random and @jonasnick for initially pointing it
out and ensuing discussion.
2020-09-21 22:09:27 +00:00