If your platform sends stablecoin payouts from its own wallet, somewhere there is a key that can move all of that money with one signature, irreversibly. How that key is stored, and who can ask it to sign, is the single largest security decision in the integration.
This guide compares the realistic options for a small or mid-sized team (environment variables, cloud KMS, dedicated HSMs, MPC custody and smart-contract wallets) and ends with an architecture that works whichever you choose.
No. 01You are protecting two things, not one
Teams usually frame the problem as “keep the private key secret”. That is half of it. The other half is the ability to get a signature. An attacker who can make your system sign a transfer doesn’t need the key at all.
- Key exfiltration: the key is copied out: from an environment variable, a log, a backup, a laptop, a CI runner.
- Signer abuse: the key stays put, but an attacker who compromised the application, or an insider, asks it to sign their transaction.
- Loss: the key is deleted or locked away with no recovery, and the funds are stranded.
Every option below is good at some of these and weak at others. The architecture at the end covers the gaps.
No. 02Environment variables and secrets managers
The starting point for most teams: a private key or mnemonic in an environment variable, perhaps loaded from a secrets manager such as Vault or a cloud secret store.
A secrets manager is an improvement over a .env file, access is logged and permissioned, but the key still ends up as plaintext in the memory of the application that signs. Anything that can read that process’s environment or memory can read the key: a server-side request forgery to a metadata endpoint, a dependency with a malicious update, a crash reporter, a debugging session.
Verdict: acceptable for testnet and for tiny, capped hot wallets during a pilot. Not acceptable as the long-term home of a key that holds customer money.
No. 03Cloud KMS
The major cloud key management services can generate and hold secp256k1 keys, the curve used by Ethereum and other EVM chains, and sign with them without ever exporting the private key. AWS KMS offers it as ECC_SECG_P256K1, Google Cloud KMS as EC_SIGN_SECP256K1_SHA256 (HSM protection level only), and Azure Key Vault as the P-256K curve. Ed25519, which Solana needs, differs by provider. AWS KMS has supported it since November 2025 as ECC_NIST_EDWARDS25519. Google Cloud KMS offers EC_SIGN_ED25519 at the software protection level only, not in an HSM. Azure Key Vault and Managed HSM do not support it.
KMS largely solves exfiltration: the key material stays inside the provider’s key service. That service is HSM-backed for AWS KMS, Cloud KMS HSM keys and Azure Premium or Managed HSM keys, but software-protected for Azure Standard-tier keys and Google’s Ed25519 keys. Every Sign call can be logged; on Google Cloud you must first enable Data Access audit logs, which are off by default. It does not solve signer abuse. Any principal with permission to call Sign can sign any transaction. If that permission belongs to your web application’s role, a compromised application can still drain the wallet: it just can’t take the key home.
AWS and Google return a DER-encoded ECDSA signature; Azure returns raw 64-byte r‖s. None of them returns a recovery ID. For Ethereum you must extract r and s and normalise s to the lower half of the curve order, because EIP-2 makes high-s transaction signatures invalid. AWS can return a high s; Google already returns low-s. Then recover v by testing which candidate public key matches your address, and encode it for the transaction type (EIP-155 v or yParity). Bugs here produce invalid or, worse, intermittently invalid transactions. Use a maintained library rather than hand-rolling it.
Verdict: the best default for teams already in a major cloud, provided signing sits behind a separate signer service with its own policy (see below).
No. 04Dedicated HSMs
A dedicated hardware security module, a cloud HSM cluster or physical devices you operate, gives you the strongest guarantees about where the key lives and full control over the keys and access model. With physical devices you also control the firmware; with a cloud HSM the provider manages it. It also brings real operational cost: cluster management, backups, high availability, firmware updates and staff who understand them.
Verdict: usually overkill for a team under a few dozen engineers. Consider it when regulation or a bank partner requires it, or when you are large enough to run it properly.
No. 05MPC and managed custody
Multi-party computation (MPC) splits the key into shares held by different parties (typically your servers, your devices and the provider) and produces signatures without reassembling the full key. Some vendors’ disaster-recovery kits can still reconstruct it, so check how recovery works. Commercial custody platforms such as Fireblocks build on this and add what most teams actually need: transaction policies, approval workflows, address books, and audit trails.
- Strengths: no single place to steal the key; policy and approvals built in; faster to production than building your own signer.
- Weaknesses: cost, vendor dependency, and the provider’s availability becomes yours. Read the recovery and exit terms: how do you get your funds out if the provider disappears?
Verdict: a strong choice once payout volume justifies the price, especially if you would otherwise have to build approvals and policy yourself.
No. 06Smart-contract wallets and multisig
A multisig such as Safe moves the approval logic on-chain: a transfer executes only when, say, two of three keys sign. It is excellent for treasury (large, infrequent movements with humans in the loop) and poor for high-frequency automated payouts, where waiting for multiple signers defeats the purpose.
Modules can narrow the gap; Safe’s allowance module, for example, once enabled on the Safe, lets a delegate address set by the owners spend up to a per-token amount without owner signatures on each transfer. The amount resets after a set period of up to about 45 days, or is one-time only. Contract wallets are also chain-specific: a Safe exists only on the chains where it has been deployed. Funds sent to the same address on another chain can be recovered only if the identical Safe can be deployed there (same factory, singleton, setup and nonce). Otherwise they may be lost.
Verdict: use for cold and warm treasury; refill the hot wallet from it.
No. 07An architecture that works with any of them
Whichever signing technology you choose, the same structure contains the damage when something goes wrong:
- Tiered wallets. A hot wallet holding only what a day or two of payouts needs; a warm wallet (multisig or MPC with approvals) that refills it; cold storage for the rest. The hot balance is your maximum loss in a single incident: size it deliberately.
- A separate signer service. The application never talks to the key. It writes a payout intent (recipient, amount, token, chain, idempotency key) and a separate service with its own credentials decides whether to sign.
- Policy in the signer, not the app. Per-transaction and daily limits, velocity limits per recipient, destination allowlists for treasury moves, token and chain allowlists, and human approval above a threshold.
- Separate identities. The signer’s cloud role is the only one with signing permission. Engineers do not have it in production. Changes to policy need two people.
- Independent monitoring. A watcher that knows nothing about your application alerts on every outgoing transfer from your wallets and matches it to a payout intent. An unmatched transfer pages someone immediately.
- Recovery that has been tested. Key backups or share recovery procedures, written down, with a dated record of the last time someone actually performed them.
No. 08Choosing for your stage
| Stage | Hot wallet | Treasury |
|---|---|---|
| Pilot, small volume | Cloud KMS behind a minimal signer service with hard limits | Multisig with two or three hardware-wallet signers |
| Growing payouts | Cloud KMS signer with full policy, or MPC custody | Multisig or MPC with approval workflows |
| Large or regulated | MPC custody or dedicated HSM | Qualified custodian or HSM-backed cold storage |
The one row missing on purpose: a production key in an environment variable. If that is where you are today, moving it is the highest-value security work available to you this quarter.
ChecklistKey management, in ten checks
- No production signing key exists in an environment variable, config file, repository or CI secret.
- Keys live in a KMS, HSM or MPC system and are never exported.
- The application cannot sign; it can only create payout intents.
- The signer enforces per-transaction, daily and per-recipient limits.
- Treasury destinations are allowlisted, and changes need two approvers.
- Only the signer’s identity has signing permission; engineers don’t, in production.
- The hot-wallet balance is capped and refilled from a multisig or MPC warm wallet.
- Every outgoing transfer is matched to an intent by an independent watcher.
- Signature handling (low-s, recovery ID) uses a maintained library and is tested.
- Recovery has been rehearsed, and the date of the last rehearsal is recorded.
Want a second pair of eyes?
I run this review on your code, before launch.
Fixed scope, fixed fee, a written report with fixes, and a re-test once you’ve shipped them. Most reviews take five to ten working days.