dalek-cryptography / curve25519-dalek

A pure-Rust implementation of group operations on Ristretto and Curve25519
Other
867 stars 439 forks source link

ed25519-dalek: make `ExpandedSecretKey` fields private #544

Closed tarcieri closed 1 year ago

tarcieri commented 1 year ago

Motivation can be found in this comment:

https://github.com/dalek-cryptography/ed25519-dalek/pull/293#pullrequestreview-1507115602

Replaces public fields with private fields + accessor methods.

Also adds an ExpandedSecretKey::from_scalar_and_prefix constructor which makes it possible to construct ExpandedSecretKey using a Scalar again, which is useful for protocols that derive the scalar such as Ed25519-BIP32.

Additionally defines a HashPrefix type alias to make it semantically clear which [u8; 32] is involved in type signatures.

tarcieri commented 1 year ago

Alternatively (and alternatively to #541) we could get rid of the to_bytes method, which seems to be the reason for retaining it in the first place.

I'm not sure what the motivation is for having it at all. Serializing this format on the wire is an antipattern, IMO.

tarcieri commented 1 year ago

I opened #545 as an alternative to this PR to try just getting rid of the private field, which makes all of the fields pub now and allows for public construction of ExpandedSecretKey again

rozbb commented 1 year ago

Superseded by #545