Skip to content

security: Demote threshold_keygen from extern "C" to test helper#172

Merged
palango merged 1 commit into
mainfrom
fix/c3-threshold-keygen-abi
Apr 22, 2026
Merged

security: Demote threshold_keygen from extern "C" to test helper#172
palango merged 1 commit into
mainfrom
fix/c3-threshold-keygen-abi

Conversation

@palango

@palango palango commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

threshold_keygen took seed: &[u8] across an extern "C" boundary. A Rust fat pointer has no defined C ABI; any C caller declaring it with const uint8_t* would misread the slice length and trigger out-of-bounds reads. cbindgen silently omitted it from threshold.h for this reason, so no legitimate C caller ever existed — the only caller was the internal Rust unit test, and the doc comment already warned that central keygen is for local testing only.

Rather than repair the ABI of a function that has no C consumer, demote threshold_keygen and its Keys struct to a plain Rust #[cfg(test)] helper. Delete the now-orphaned accessors (share_ptr, num_shares, polynomial_ptr, threshold_public_key_ptr) and destroy_keys, and prune the matching stale declarations from cross/threshold.h. WASM threshold_keygen is unaffected — wasm-bindgen marshals slices correctly.

threshold_keygen took `seed: &[u8]` across an `extern "C"` boundary.
A Rust fat pointer has no defined C ABI; any C caller declaring it
with `const uint8_t*` would misread the slice length and trigger
out-of-bounds reads. cbindgen silently omitted it from threshold.h
for this reason, so no legitimate C caller ever existed — the only
caller was the internal Rust unit test, and the doc comment already
warned that central keygen is for local testing only.

Rather than repair the ABI of a function that has no C consumer,
demote threshold_keygen and its Keys struct to a plain Rust
`#[cfg(test)]` helper. Delete the now-orphaned accessors
(share_ptr, num_shares, polynomial_ptr, threshold_public_key_ptr)
and destroy_keys, and prune the matching stale declarations from
cross/threshold.h. WASM threshold_keygen is unaffected — wasm-bindgen
marshals slices correctly.
@palango palango merged commit 67ae846 into main Apr 22, 2026
11 checks passed
@palango palango deleted the fix/c3-threshold-keygen-abi branch April 22, 2026 14:16
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.

1 participant