docs: add HSM integration walkthroughs for CloudHSM/KeyVault/GCP HSM/Zymbit (closes #4)#9
Merged
zeekay merged 1 commit intoluxfi:mainfrom Apr 22, 2026
Conversation
…Zymbit (closes luxfi#4) Resolves issue luxfi#4 by making the README's "HSM compatible" claim concrete: documents what HSM compatibility means for this library (the Config types MarshalBinary/UnmarshalBinary are opaque from an HSM's perspective — the HSM is a storage + access-control boundary, not a compute boundary), and provides four integration walkthroughs. Structure: - What "HSM compatible" means here — the Config serialization contract, two deployment modes (envelope-with-KMS vs. PKCS#11 slot storage), explicit statement that the MPC computation does NOT run inside the HSM enclave, and why that's unavoidable today with commodity HSM hardware. - Recommended adapter interface — a small ShareStore interface callers can implement per HSM, matching the pattern used in luxfi/mpc's pkg/hsm, so integrators can adopt without reading another repo. - Four walkthroughs: AWS CloudHSM + KMS envelope mode, Azure Managed HSM / Key Vault, GCP Cloud HSM, Zymbit SCM. Each covers prerequisites, credential plumbing (preferred = workload identity, fallback = short-lived env creds), the key-share storage contract (what goes in HSM vs what stays on disk), a runnable Go example against the actual SDK, and known limits (FIPS level, rate limits, cost, cold-start). - Runtime isolation (Nitro Enclaves, SGX) — for threat models where the share must never exist unencrypted in host memory; explicitly flagged as an order-of-magnitude more work than envelope encryption, to help integrators choose. - Summary table across the four providers with FIPS level, best- for, throughput, and approximate cost. - Cross-linked with docs/audit.md § Deployment Considerations. All adapter interfaces are illustrative Go code that matches the real SDKs (aws-sdk-go-v2/service/kms, Azure keyvault/azkeys, cloud.google.com/go/kms, zkapputils cgo).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4.
Follow-up to the clarification on issue #4 — makes the README's "HSM compatible" claim concrete and gives integrators a working starting point.
What this PR says about "HSM compatible"
The key observation, cross-checked against the code:
This is the first thing reviewers of issue #4 were asking for — a truthful statement of what "HSM compatible" means so they can decide whether this library fits their threat model.
Recommended adapter interface
A small
ShareStoreinterface that any HSM integration can implement. It matches the abstraction pattern used inluxfi/mpc'spkg/hsm— documented here so integrators can adopt the pattern without reading a second repo:Four integration walkthroughs
Each follows the same structure — prereqs; credential plumbing (preferred = workload identity / IRSA / managed identity, fallback = short-lived env vars); key-share storage contract (what goes in the HSM vs what stays on disk); a runnable Go example against the actual SDK; known limits (FIPS level, rate limits, cost, cold start):
aws-sdk-go-v2/service/kmswithEncryptionContextbinding ciphertext to(org_id, wallet_id, party_id).azure-sdk-for-go/sdk/keyvault/azkeysusingWrapKeywith RSA-OAEP-256.cloud.google.com/go/kmswithAdditionalAuthenticatedDatabinding ciphertext to the same tuple.zkapputils; explicit note that Zymbit is not FIPS certified as of this writing — check current specsheet before deploying to regulated environments.Runtime isolation section
An honest section on Nitro Enclaves and SGX for threat models where the share must never exist unencrypted in host memory — with the caveat that runtime isolation is an order of magnitude more work than envelope encryption, and most integrators should start with envelope-plus-MPC-distribution and add enclaves later if the threat model demands it.
Summary table
Single table comparing FIPS level, throughput, and cost across the four providers, so integrators can pick the right option at a glance.
Cross-links
This guide is cross-linked from
docs/audit.md§ Deployment Considerations in the companion PR (#8). Together they answer the two open security-documentation issues on the repo.On scope
I deliberately did not add
pkg/hsm/adapters/source files in this PR — there's no existingpkg/hsm/tree in this repo today, and an interface-plus-four-adapters module is a larger (code-owning) design change that should go through its own design discussion. This PR lands the integration guide that answers #4 directly; if maintainers want adapter code in-tree, happy to follow up as a separate PR with theShareStoreinterface and the four adapter implementations as a new package.