* ed25519-dalek: remove `ExpandedSecretKey::to_bytes`
The reason `ExpandedSecretKey` needs a private `scalar_bytes` field is
to retain the canonical scalar bytes as output by SHA-512 during key
expansion so they can be serialized by the `to_bytes` method.
However, `ExpandedSecretKey`s should not be serialized to the wire.
Removing this method allows the private field to be removed, which
allows `ExpandedSecretKey` to be constructed entirely from public
fields. This provides an alternative to #544 for use cases like
Ed25519-BIP32 where the private scalar is derived rather than clamped
from bytes.
One other change is needed: `to_scalar_bytes` was changed to `to_scalar`
as the canonical scalar bytes are no longer retained, however this has
no impact on its main use case, X25519 Diffie-Hellman exchanges, where
the `Scalar` should NOT be written to the wire anyway.
* Added scalar byte comparison back to ed25519-dalek x25519 test
---------
Co-authored-by: Michael Rosenberg <michael@mrosenberg.pub>
* 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>
* Vendor import unsafe_target_features as curve25519-dalek-derive
Co-authored-by: Jan Bujak <jan@parity.io>
* Remove feature gates from avx2/ifma
* Add buildtime compile diagnostics about backend selection
* Add build script tests
* Documentation changes
* Disable simd related features unless simd was determined via build
* Add note and test about the override warning when unsuccesful
* Reduce complexity in build gating via compile_error
---------
Co-authored-by: Jan Bujak <jan@parity.io>
Co-authored-by: Michael Rosenberg <michael@mrosenberg.pub>
* 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
* 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`.
* 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>
* 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
* 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