Skip to content

Support external/remote signing (KMS/HSM) without an in-process private key #17

@developerAkX

Description

@developerAkX

Problem

Today the only way to authorize state-changing actions (orders, cancels, modify, withdraw, etc.) is WithPrivateKey, which loads a raw private key into the SDK process and signs in-process inside buildSignSend via Wallet.SignHash. If no key is set, requireWallet() panics.

This rules out setups where the key must never enter the application process — KMS/HSM-backed signing, or a dedicated remote signing service. In those architectures the application is the largest attack surface, and the security goal is that a compromise of that process cannot exfiltrate the key.

Use case

We run a separation-of-duties design: a hardened, minimal signing service holds the keys; our user-facing service must hold none. We still want to use this SDK for order construction/submission, signing each build-step hash via the remote signer.

Proposed solution

Add an external-signer seam alongside WithPrivateKey — a callback that receives the build-step hash and returns the existing Signature:

type Signer func(hashHex string) (*Signature, error)

func WithSigner(fn Signer) Option
func WithSignerAddress(addr string) Option // acting address when no in-process wallet

buildSignSend calls the signer when set, else falls back to Wallet.SignHash. Fully backward compatible — WithPrivateKey is unchanged when no signer is provided.

I have a small, additive implementation with tests and a README section ready and will open a PR referencing this issue. Happy to adjust the API (naming, signature shape) to your preferences.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions