Skip to content

feat(signing): validate key format before signing in KeypairSigner (#768) - #798

Merged
Kingsman-99 merged 1 commit into
Stellar-split:mainfrom
therealbibson:feat/issue-768-keypair-signer-validation
Aug 31, 2026
Merged

feat(signing): validate key format before signing in KeypairSigner (#768)#798
Kingsman-99 merged 1 commit into
Stellar-split:mainfrom
therealbibson:feat/issue-768-keypair-signer-validation

Conversation

@therealbibson

Copy link
Copy Markdown
Contributor

Overview

Validates Stellar secret key and Keypair format at KeypairSigner construction time to surface format errors eagerly, rejecting malformed secret keys with InvalidKeypairError.

Related Issue

Closes #768

Changes

Signing Key Vault Adapter

  • [MODIFY] src/signing/adapters/KeypairSigner.ts
    • Added upfront secret key validation in constructor using Keypair.fromSecret
    • Validated that Keypair instances have signing capability (canSign())
    • Throws InvalidKeypairError when secret key or keypair format is invalid
  • [MODIFY] src/errors.ts
    • Defined InvalidKeypairError and isInvalidKeypairError type guard
  • [MODIFY] src/index.ts
    • Exported InvalidKeypairError and isInvalidKeypairError
  • [MODIFY] test/signing.test.ts
    • Added unit tests for secret key validation, format errors, public-key-only keypairs, invalid types, and error type guards
  • [MODIFY] test/sdkExports.test.ts
    • Added assertions verifying public API export of InvalidKeypairError and isInvalidKeypairError

Verification Results

 RUN  v1.6.1 /Users/user/Documents/Projects/open_source/split-sdk

 ✓ test/signing.test.ts  (20 tests) 135ms
 ✓ test/sdkExports.test.ts  (2 tests) 2ms

 Test Files  2 passed (2)
      Tests  22 passed (22)
Acceptance Criteria Status
The constructor validates that the provided secret key is a valid Stellar secret key (starts with 'S', correct length, valid base32) ✅ Validated via Keypair.fromSecret at construction time
An InvalidKeypairError is thrown at construction with a message indicating the format issue InvalidKeypairError thrown with descriptive format error message
Valid keys continue to work unchanged ✅ Valid secret key strings and Keypair instances construct and sign as expected
Unit tests pass ✅ All 20 signing tests and 2 sdkExports tests pass

@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@therealbibson Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Kingsman-99
Kingsman-99 merged commit 21e2f42 into Stellar-split:main Aug 31, 2026
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.

Validate key format before signing in KeypairSigner

2 participants