Skip to content

test: Enable API tests and standardize byte array methods#885

Draft
Abeeujah wants to merge 1 commit into
rust-bitcoin:masterfrom
Abeeujah:issue-859
Draft

test: Enable API tests and standardize byte array methods#885
Abeeujah wants to merge 1 commit into
rust-bitcoin:masterfrom
Abeeujah:issue-859

Conversation

@Abeeujah

@Abeeujah Abeeujah commented Feb 9, 2026

Copy link
Copy Markdown
Contributor

Remove FIXME comments in tests/api.rs and enable the corresponding compilation checks by implementing missing byte conversion methods.

Changes include:

  • XOnlyPublicKey: Rename from_byte_array to try_from_byte_array and modify from_byte_array.
  • Keypair: Add from_secret_bytes, as_secret_bytes, and AsRef<[u8]>.
  • ellswift::ElligatorSwift: Add from_byte_array and to_byte_array.
  • ecdh::SharedSecret: Add from_secret_bytes and as_secret_bytes.
  • ellswift::ElligatorSwiftSharedSecret: Add AsRef<[u8]> and non_secure_erase.

fixes #859

Remove FIXME comments in `tests/api.rs` and enable the corresponding
compilation checks by implementing missing byte conversion methods.

Changes include:
- `XOnlyPublicKey`: Rename `from_byte_array` to `try_from_byte_array` and
  modify `from_byte_array`.
- `Keypair`: Add `from_secret_bytes`, `as_secret_bytes`, and `AsRef<[u8]>`.
- `ellswift::ElligatorSwift`: Add `from_byte_array` and `to_byte_array`.
- `ecdh::SharedSecret`: Add `from_secret_bytes` and `as_secret_bytes`.
- `ellswift::ElligatorSwiftSharedSecret`: Add `AsRef<[u8]>` and `non_secure_erase`.

This ensures consistent API patterns across these types and satisfies
the requirements in `tests/api.rs`.
@tcharding

Copy link
Copy Markdown
Member

Thanks for the contribution! This is too many changes in a single patch. Can you split it out so there are multiple small patches that do a single thing. API design is non-trivial so we want to make sure we get it right!

@Abeeujah

Copy link
Copy Markdown
Contributor Author

Hi @tcharding Thank you for mentioning, I've taken the work done so far into individual PRs which mentions this, happy to see how it proceeds from here on

apoelstra added a commit that referenced this pull request Feb 13, 2026
e2d53a0 feat: implement byte array conversions for ElligatorSwift (Abeeujah)

Pull request description:

  ## Description
  
  This PR implements the missing byte array conversion methods for `ElligatorSwift` to enable standard round-trip testing. Previously, the `ElligatorSwift` type lacked the necessary interface to satisfy the `bytes_rtt_test!` macro, leading to a pending `FIXME` in the test suite.
  
  ### Changes
  
  - **Added `ElligatorSwift::to_byte_array`**: Extracts the underlying 64-byte array from the FFI wrapper.
  - **Added `ElligatorSwift::from_byte_array`**: Constructs an `ElligatorSwift` instance from a 64-byte array.
  - **Enabled RTT Test**: Activated the `rtt_g` test case and removed the associated `FIXME` comment.
  
  Child #885 
  References #859


ACKs for top commit:
  apoelstra:
    ACK e2d53a0; successfully ran local tests; short and sweet


Tree-SHA512: 1fdca66d238f3ec16dd4049dad2998e1836f1def982b2649a87c0b081b882a81287c0ebc39d3705a5d0e0e1a9aac074bd3e11cd25b2f8ea37a44f99b6db73e96
@apoelstra

Copy link
Copy Markdown
Member

At the very least this needs a rebase.

@Abeeujah
Abeeujah marked this pull request as draft February 14, 2026 09:25
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.

Remove all the FIXMEs from test/api.rs

3 participants