Skip to content

fix(starkware): Update TWStarkWareGetStarkKeyFromSignature to return nullable pointer and handle exceptions#4715

Merged
sergei-boiko-trustwallet merged 6 commits intomasterfrom
fix/starkware-key-from-signature
Apr 1, 2026
Merged

fix(starkware): Update TWStarkWareGetStarkKeyFromSignature to return nullable pointer and handle exceptions#4715
sergei-boiko-trustwallet merged 6 commits intomasterfrom
fix/starkware-key-from-signature

Conversation

@sergei-boiko-trustwallet
Copy link
Copy Markdown
Contributor

Description

Update TWStarkWareGetStarkKeyFromSignature to return nullable pointer and handle exceptions

How to test

Types of changes

Checklist

  • Create pull request as draft initially, unless its complete.
  • Add tests to cover changes as needed.
  • Update documentation as needed.
  • If there is a related Issue, mention it in the description.

If you're adding a new blockchain

  • I have read the guidelines for adding a new blockchain.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 TWStarkWareGetStarkKeyFromSignature return _Nullable and return nullptr on exceptions.
  • Update Swift test to unwrap the optional StarkWare private key result.
  • Add validation/exception behavior in core primitives (HDWallet seed constructor; Data::subData now 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.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 31, 2026

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

davidkulman-tw
davidkulman-tw previously approved these changes Apr 1, 2026
nikhil-gupta-tw
nikhil-gupta-tw previously approved these changes Apr 1, 2026
@sergei-boiko-trustwallet sergei-boiko-trustwallet merged commit b5cf554 into master Apr 1, 2026
15 checks passed
@sergei-boiko-trustwallet sergei-boiko-trustwallet deleted the fix/starkware-key-from-signature branch April 1, 2026 13:37
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.

4 participants