Skip to content

feat(swift-sdk): public RawKeySigner one-shot raw-key signing#4097

Merged
QuantumExplorer merged 2 commits into
v4.1-devfrom
feat/raw-key-signer
Jul 12, 2026
Merged

feat(swift-sdk): public RawKeySigner one-shot raw-key signing#4097
QuantumExplorer merged 2 commits into
v4.1-devfrom
feat/raw-key-signer

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Jul 12, 2026

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

Callers that already hold 32-byte key material (e.g. from a derivation-path lookup) had no way to sign without constructing a full KeychainSigner/KeyManager stack — the create-signer → sign → destroy FFI round-trip was private to KeychainSigner.ffiSign.

dashwallet-ios needs this entry point and has been carrying it on its platform pin branch; upstreaming it shrinks the pin (see DASHSYNC_MIGRATION.md there).

What was done?

  • Extracted the dash_sdk_signer_create_from_private_keydash_sdk_signer_signdash_sdk_signer_destroy round-trip into a public RawKeySigner enum (in KeyWallet/KeyManager.swift), with a typed KeyManagerError surface. The key copy is zeroed before returning.
  • KeychainSigner.ffiSign now delegates to it, keeping a single implementation of the round-trip.
  • Marshals only — no key-management decisions move into Swift; the signer handle binds as OpaquePointer, matching the current header import.

How Has This Been Tested?

  • SwiftExampleApp builds for the iOS simulator on this branch (which exercises the SwiftDashSDK package including the delegating KeychainSigner).
  • The same change has been exercised end-to-end on the dashwallet-ios pin branch, where RawKeySigner signs for the reveal-private-key flow.

Breaking Changes

None. KeychainSigner's public API is unchanged; RawKeySigner is additive.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Improvements
    • Improved private-key signing reliability and error handling.
    • Added validation for private-key size before signing.
    • Enhanced protection of sensitive key material during signing.
    • Added clearer reporting when signer creation or signing fails.

Extract the dash_sdk_signer_create_from_private_key → sign → destroy
FFI round-trip from KeychainSigner.ffiSign into a public RawKeySigner
enum, so callers that already hold 32-byte key material (e.g. a
derivation-path lookup) can sign without constructing a
KeychainSigner/KeyManager stack. KeychainSigner.ffiSign delegates to
it, keeping a single implementation.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@QuantumExplorer, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 39 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e1a822db-cb24-4250-811d-44d6689f07ca

📥 Commits

Reviewing files that changed from the base of the PR and between d7aee13 and 67bcff7.

📒 Files selected for processing (1)
  • packages/swift-sdk/Sources/SwiftDashSDK/FFI/KeychainSigner.swift
📝 Walkthrough

Walkthrough

Adds RawKeySigner for one-shot ECDSA signing from raw private keys, including validation and secure cleanup. KeychainSigner now delegates signing to it and maps KeyManagerError cases to its typed signer errors.

Changes

Raw key signing

Layer / File(s) Summary
Raw key signing utility
packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyManager.swift
Adds KeyManagerError.signingFailed, its description, and RawKeySigner.sign, which validates keys, performs FFI signing, frees resources, and wipes a defensive key copy.
KeychainSigner integration
packages/swift-sdk/Sources/SwiftDashSDK/FFI/KeychainSigner.swift
Routes private-key signing through RawKeySigner.sign and maps creation, format, signing, and fallback errors.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested reviewers: shumkov, llbartekll, thepastaclaw

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely captures the main change: adding a public RawKeySigner for one-shot raw-key signing.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/raw-key-signer

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@thepastaclaw

thepastaclaw commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

🔍 Review in progress — actively reviewing now (commit d7aee13)

@github-actions github-actions Bot added this to the v4.1.0 milestone Jul 12, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/swift-sdk/Sources/SwiftDashSDK/FFI/KeychainSigner.swift`:
- Around line 716-732: Update ffiSign’s KeyManagerError.invalidKeyFormat catch
branch to return the error category intended for invalid signing input rather
than .ffiSignerCreationFailed, while preserving the original message and leaving
signerCreationFailed and signingFailed mappings unchanged.

In `@packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyManager.swift`:
- Line 12: Remove the new public KeyManagerError.signingFailed case and update
the affected KeyManager error path to reuse an existing error case. Do not
expand the public enum API or introduce another case.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 67d3ea1c-bd23-4fb0-909d-2e39b6b7b67a

📥 Commits

Reviewing files that changed from the base of the PR and between 9c75a1c and d7aee13.

📒 Files selected for processing (2)
  • packages/swift-sdk/Sources/SwiftDashSDK/FFI/KeychainSigner.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyManager.swift

Comment thread packages/swift-sdk/Sources/SwiftDashSDK/FFI/KeychainSigner.swift
Comment thread packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyManager.swift
Review fix for #4097: KeyManagerError.invalidKeyFormat surfaced as a
bare "Failed to construct FFI signer" message, pointing debugging at
the FFI layer for what is pre-FFI input validation.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@QuantumExplorer
QuantumExplorer merged commit d6ba78a into v4.1-dev Jul 12, 2026
16 checks passed
@QuantumExplorer
QuantumExplorer deleted the feat/raw-key-signer branch July 12, 2026 09:50
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.

2 participants