2293 Commits

Author SHA1 Message Date
Jan Bujak
502897109c Pin the version of unsafe_target_feature 2023-06-05 16:40:31 +09:00
Jan Bujak
94247a79d1
Revert "(work-in-progress) Partially remove unsafe_target_feature"
This reverts commit c67e430cfdf9699cf9b90226ab08a3b48cadacc6.
2023-06-05 16:38:58 +09:00
Tony Arcieri
618c5081f1
Replace unwrap_u8 with into (#528)
* Replace `unwrap_u8` with `into`

Leverages the `From<Choice>` impl for `bool` where applicable instead,
which results in clearer logic which more closely matches `bool`.
2023-05-30 21:49:13 -04:00
Marek
6c2233bc45
Fix the upper bound in the description of mods (#525) 2023-05-29 15:24:45 -06:00
Tony Arcieri
267961b7ee
README.md: use buildstats.info crate badge (#526)
Includes both version and download count
2023-05-20 13:26:05 -06:00
Jan Bujak
c67e430cfd
(work-in-progress) Partially remove unsafe_target_feature 2023-05-17 14:39:09 +09:00
Jan Bujak
a7df9c7918
Remove Selfs which don't compile anymore 2023-05-17 13:22:11 +09: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
Tony Arcieri
f683cf4d50
Merge pull request #125 from eaon/crypto_box_url
Update `crypto_box` URL
2023-05-09 07:05:03 -06:00
eaon
d828434d60
Update crypto_box URL 2023-05-08 18:56:43 -04:00
Damir Jelić
90f10ed096
Fix a typo (#300) 2023-04-11 11:19:36 -06:00
Jan Bujak
738cfee020
Get rid of the unused_unsafe warning on old versions of Rust. 2023-04-11 21:01:55 +09:00
Jan Bujak
996b1e9077
Make cargodoc happy 2023-04-11 20:49:06 +09:00
Jan Bujak
1b6fee354d
Make clippy happy 2023-04-11 20:44:37 +09:00
Jan Bujak
219995dbc9
rustfmt src/backend/vector/scalar_mul (no changes besides formatting) 2023-04-11 20:13:31 +09:00
Jan Bujak
0db8783be8
Runtime backend autodetection 2023-04-11 20:13:20 +09:00
Jan Bujak
91e839aae5
Add extra #[inline]; this speeds up the avx2 backend slightly 2023-04-11 20:09:21 +09:00
Michael Rosenberg
25fa593df2
Update to new Scalar API (#120)
* Updated to new curve25519 scalar API

* Removed clamping from constructors; clamping is always done during scalar-point multiplication

* Updated test to reflect new functionality

* Updated changelog
2023-03-31 16:58:35 -04:00
pinkforest(she/her)
cccf389467
chore: Release 2.0.0-rc.2 (#123) 2023-03-31 13:53:51 -04:00
pinkforest(she/her)
84158337af
Make static_secrets optional (#122)
* Make `static_secrets` optional

* Added more feature combinations to CI
2023-03-31 13:34:03 -04: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
Koute
4583c472f5
Support SIMD on Rust stable (#520)
* Remove dependency on `packed_simd`

* Support SIMD on stable Rust

* Move `packed_simd.rs` to `vector` module

* Add comment header to `packed_simd.rs`

* Initialize SIMD registers using intrinsics instead of `transmute`

* Use a splat inside of `unpack_pair`

* Update README: the AVX2 backend now works on stable Rust

* Add a CI job to also build the AVX2 SIMD backend on Rust stable

* Added SIMD MSRV test
2023-03-30 02:16:18 -04:00
Michael Rosenberg
f460ae149b
Make scalars always reduced (#519)
* Removed Scalar::{from_bits, from_bytes_clamped}; all constructible scalars are now reduced mod l

* Made Scalar::reduce() not pub; fixed test warning

* Added benches for scalar add/sub/mul

* Docs

* Added EdwardsPoint::mul_base_clamped and gated Scalar::from_bits behind legacy_compatibility

* Added unit test for Mul impl on unreduced Scalars

* Added Montgomery::mul_base_clamped

* Added BasepointTable::mul_base_clamped

* Removed invalid scalar arithmetic test; this functionality is no longer supported

* Made clamp_integer() const

* Updated readme and changelog

* Added BasepointTable::mul_base_clamped to tests

* Added proper deprecation notice to Scalar::from_bits; added legacy_compatibility to Makefile and docsrs flags
2023-03-28 18:12:24 -04:00
pinkforest(she/her)
5014c91270
chore: Release 2.0.0-rc.2 (#295)
Co-authored-by: Michael Rosenberg <michael@mrosenberg.pub>
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
pinkforest(she/her)
c982811d11
chore: Release 4.0.0-rc.2 (#522) 2023-03-26 02:49:20 -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
pinkforest(she/her)
02a5ce20ca
Add getrandom (#118)
* Add getrandom to bring convenience random init functions

* Fix doc name

* Rename new to random_from_rng

* Deprecate new() in favor of random_from_rng()

* Simplify constructors documentation

Co-authored-by: Ciprian Dorin Craciun <ciprian@volution.ro>
2023-03-21 01:40:51 -04:00
Tony Arcieri
6aabb9bf08
Merge pull request #119 from pinkforest/fix-no_std
Fix `no std` by moving `get_random` feat dev-deps
2023-03-20 19:05:42 -06:00
Michael Rosenberg
0e73cb82bc
Merge pull request #117 from dalek-cryptography/release/2.0
Merge `release/2.0` into `main`
2023-03-20 14:24:42 -04:00
Michael Rosenberg
d6c3cbf97d
Merge branch 'main' into release/2.0 2023-03-20 14:19:38 -04:00
Samuel Moelius
7dc1bbd855
Remove two unnecessary into_iter (#290) 2023-03-18 09:22:15 -06:00
pinkforest(she/her)
99c0520aa7
Fixes cfg with target from env (#516)
* Fixes cfg with target from env

* Derive cleanup

* Default to curve25519_dalek_bits="32" on unknown target

* Give out warning (thanks @jcape)

Co-authored-by: ryan <ryankurte@users.noreply.github.com>
Co-authored-by: James Cape <james@mobilecoin.com>
2023-03-18 04:34:47 -04:00
Jordan Rose
a63e14f4de
Use ok_or_else instead of ok_or in serde decoding (#382)
Serde errors are not simple enums; they format a full error string
from their arguments. It's worth not doing that up front.
2023-03-13 21:42:01 -06:00
Tony Arcieri
987f7d6baf
Merge pull request #115 from pinkforest/fix-docsrs
Fix docsrs
2023-03-12 15:16:09 -06:00
pinkforest
379e506336
Merge remote-tracking branch 'origin/release/2.0' into fix-docsrs 2023-03-13 07:22:56 +11:00
pinkforest
5080b42601
Merge remote-tracking branch 'origin/release/2.0' into fix-no_std 2023-03-13 07:22:03 +11:00
Tony Arcieri
853a3df1a7
Merge pull request #109 from pinkforest/fix-ci
Fix CI
2023-03-12 13:04:05 -06:00
pinkforest
0139af7f9d
Remove rustup in favor of rust-toolchain 2023-03-13 05:15:34 +11:00
pinkforest
4b6c61c111
Correct crate name 2023-03-12 16:49:18 +11:00
pinkforest
a7769a645c
Add assets 2023-03-12 16:48:15 +11:00
pinkforest
281fab6af0
Fix docsrs 2023-03-12 16:45:37 +11:00
pinkforest
f3c46bc3bf
Remove redundant feature 2023-03-12 15:27:53 +11:00
pinkforest
fdc992d6cd
Fix no_std with get_random 2023-03-12 14:18:07 +11:00
pinkforest
cbd3958772
Fix bench features 2023-03-12 13:50:50 +11:00
pinkforest
707675d878
Disable no_std from CI 2023-03-12 13:43:48 +11:00
pinkforest
c779e215f7
Fixed doc nit from update-ci branch
Co-Authored-by: Michael Rosenberg <michael@mrosenberg.pub>
2023-03-12 13:42:31 +11:00
pinkforest
be8a657ece
Add .lock 2023-03-12 13:27:44 +11:00