fix(starkware): Update TWStarkWareGetStarkKeyFromSignature to return nullable pointer and handle exceptions#4715
Merged
sergei-boiko-trustwallet merged 6 commits intomasterfrom Apr 1, 2026
Conversation
…nullable pointer and handle exceptions
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the StarkWare C interface to avoid throwing exceptions across the FFI boundary by returning a nullable TWPrivateKey* and adds Swift-side handling for the now-optional result. It also includes additional core utility changes (HDWallet seed-size validation and subData out-of-range behavior) that materially affect broader code paths.
Changes:
- Make
TWStarkWareGetStarkKeyFromSignaturereturn_Nullableand returnnullptron exceptions. - Update Swift test to unwrap the optional StarkWare private key result.
- Add validation/exception behavior in core primitives (
HDWalletseed constructor;Data::subDatanow throws on out-of-range).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| swift/Tests/HDWalletTests.swift | Updates test to unwrap optional result from StarkWare key derivation. |
| src/interface/TWStarkWare.cpp | Wraps StarkWare key derivation in try/catch and returns nullptr on failure. |
| include/TrustWalletCore/TWStarkWare.h | Changes API contract to return a nullable pointer. |
| src/HDWallet.cpp | Adds seed-size validation to prevent invalid/unsafe seed handling. |
| src/Data.cpp | Changes subData to throw on out-of-range indices (broad behavior change). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Binary size comparison➡️ aarch64-apple-ios: 14.34 MB ➡️ aarch64-apple-ios-sim: 14.34 MB ➡️ aarch64-linux-android: 18.77 MB ➡️ armv7-linux-androideabi: 16.20 MB ➡️ wasm32-unknown-emscripten: 13.68 MB |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…prove subData error handling
davidkulman-tw
previously approved these changes
Apr 1, 2026
nikhil-gupta-tw
previously approved these changes
Apr 1, 2026
cf80a3f
nikhil-gupta-tw
approved these changes
Apr 1, 2026
davidkulman-tw
approved these changes
Apr 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Update TWStarkWareGetStarkKeyFromSignature to return nullable pointer and handle exceptions
How to test
Types of changes
Checklist
If you're adding a new blockchain