Skip to content

Commit dec79e0

Browse files
committed
Update SharedSecret byte access and deprecate old methods
Modify SharedSecret::as_secret_bytes() to return &[u8; SHARED_SECRET_SIZE] instead of [u8; SHARED_SECRET_SIZE] to avoid unnecessary copying of the underlying secret. Deprecates the following methods in favor of the newly standardized `secret_bytes` naming convention: - `to_secret_bytes` (use `as_secret_bytes`) - `from_bytes` (use `from_secret_bytes`) This completes the transition to the standardized byte conversion API while maintaining backward compatibility.
1 parent 2cb8058 commit dec79e0

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/ecdh.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,12 @@ impl SharedSecret {
5555

5656
/// Returns the shared secret as a byte value.
5757
#[inline]
58+
#[deprecated(since = "TBD", note = "use Shared::Secret::as_secret_bytes instead")]
5859
pub fn to_secret_bytes(&self) -> [u8; SHARED_SECRET_SIZE] { self.0 }
5960

6061
/// Returns the shared secret as secret bytes
6162
#[inline]
62-
pub fn as_secret_bytes(&self) -> [u8; SHARED_SECRET_SIZE] { self.0 }
63+
pub fn as_secret_bytes(&self) -> &[u8; SHARED_SECRET_SIZE] { &self.0 }
6364

6465
/// Returns the shared secret as a byte value.
6566
#[deprecated(since = "TBD", note = "Use `to_secret_bytes` instead.")]
@@ -68,6 +69,7 @@ impl SharedSecret {
6869

6970
/// Creates a shared secret from `bytes` array.
7071
#[inline]
72+
#[deprecated(since = "TBD", note = "use SharedSecret::from_secret_bytes instead")]
7173
pub fn from_bytes(bytes: [u8; SHARED_SECRET_SIZE]) -> SharedSecret { SharedSecret(bytes) }
7274

7375
/// Creates a shared secret from a secret `bytes` array.

0 commit comments

Comments
 (0)