Skip to content

Implement secret byte conversions for ecdh::SharedSecret#889

Open
Abeeujah wants to merge 2 commits into
rust-bitcoin:masterfrom
Abeeujah:ecdh-secretbytes
Open

Implement secret byte conversions for ecdh::SharedSecret#889
Abeeujah wants to merge 2 commits into
rust-bitcoin:masterfrom
Abeeujah:ecdh-secretbytes

Conversation

@Abeeujah

Copy link
Copy Markdown
Contributor

Description

This PR implements the missing secret byte accessors and constructors for ecdh::SharedSecret. These additions allow the type to conform to the secret_bytes_rtt_test! macro, ensuring consistent handling of shared secrets across the API.

Changes

  • Added SharedSecret::as_secret_bytes: Provides a way to retrieve the underlying byte array of the secret.
  • Added SharedSecret::from_secret_bytes: Enables manual construction of a SharedSecret from a known byte array.
  • Enabled RTT Test: Activated the secret_rtt_b test case

Child #885
References #859

@apoelstra

Copy link
Copy Markdown
Member

In 2cb8058:

missing deprecations, at least one method has wrong signature

@tcharding

Copy link
Copy Markdown
Member

Thanks for the contribution. Patch two needs more attention, please consider reading http://waltermcginnis.com/site/web_links/show/101-chris-beams-how-to-write-a-git-commit-message and for all commits use that format. If you make your changes easy to review you have more chance of getting things merged!

Adds `as_secret_bytes` and `from_secret_bytes` to the `SharedSecret`
implementation. These methods provide a standardized way to access and
initialize the underlying secret array, enabling the type to pass
the `secret_bytes_rtt_test` suite.

Removes the FIXME regarding RTT test failures for this type.
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants