Skip to content

Pluggable Signing Key Vault Adapter #589

Description

@Kingsman-99

Description

The SDK currently only supports in-memory keypairs for transaction signing, which is unsuitable for production environments where private keys must reside in hardware security modules, cloud KMS services, or AES-encrypted keystores. A pluggable vault adapter interface would decouple the signing operation from key storage, enabling callers to inject any backend conforming to a narrow Signer contract without modifying SDK internals.

Technical Context

New interface Signer in src/signing/signer.ts with a single method sign(txHash: Buffer): Promise<Buffer>. Concrete adapters in src/signing/adapters/: KeypairSigner (wraps Keypair from @stellar/stellar-sdk), EncryptedFileSigner (reads an AES-256-GCM encrypted PEM file, decrypts on first use), and a CloudKmsSigner that delegates to an injected KmsClient { sign(keyId: string, digest: Buffer): Promise<Buffer> } interface. StellarSplitClient constructor options in src/client.ts accept signer: Signer.

Acceptance Criteria

  • The Signer interface and all three concrete adapters are exported from the SDK's public API surface via src/index.ts
  • KeypairSigner.sign produces a 64-byte ed25519 signature verifiable by Keypair.verify on the corresponding public key
  • EncryptedFileSigner decrypts the key file on first use, holds the plaintext in a WeakRef to allow GC pressure to clear it, and re-reads the file on the next sign call if the ref has been collected
  • CloudKmsSigner accepts any object conforming to the KmsClient interface, enabling easy test mocking without touching real KMS credentials
  • Tests cover KeypairSigner round-trip signing, EncryptedFileSigner with a test-generated AES key (including the re-read-after-GC path via explicit null), and a mock CloudKmsSigner
  • All CI checks (npm test, npm run build, ESLint/TypeScript) pass and the branch has no merge conflicts

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions