dalek-cryptography / x25519-dalek

X25519 elliptic curve Diffie-Hellman key exchange in pure-Rust, using curve25519-dalek.
BSD 3-Clause "New" or "Revised" License
326 stars 132 forks source link

Add `StaticSecret::as_bytes` #101

Closed cipriancraciun closed 1 year ago

cipriancraciun commented 1 year ago

At the moment (in v1.2.0) there is the to_bytes for PublicKey, StaticSecret and SharedSecret, thus allowing one to convert that key into [u8; _]. However there is also as_bytes available (allowing one to borrow the bytes and perhaps use them), but that is only available for PublicKey and SharedSecret, but not for StaticSecret.

Thus, I'm proposing to also add as_bytes to StaticSecret.

I don't think this violates in any manner the current API philosophy, because there is already to_bytes that allows exporting the underlying key.

cipriancraciun commented 1 year ago

Just for reference, there seems to be another pull request #96, similar to my own proposed one #102, although mine is perhaps simpler, just adding the as_bytes function.

tarcieri commented 1 year ago

Resolved in #96