Repository navigation
feat(enclave): seal and provision key bundles, with enclave seal/provision/status - #1331
Merged
Merged
Conversation
2 of 3 tasks
Gabriel-Trintinalia
temporarily deployed
to
docker
December 2, 2026 07:54 — with
GitHub Actions
Inactive
Gabriel-Trintinalia
temporarily deployed
to
docker
December 2, 2026 07:54 — with
GitHub Actions
Inactive
Gabriel-Trintinalia
temporarily deployed
to
docker
December 2, 2026 07:54 — with
GitHub Actions
Inactive
Gabriel-Trintinalia
temporarily deployed
to
docker
December 2, 2026 07:54 — with
GitHub Actions
Inactive
jframe
reviewed
Dec 2, 2026
Gabriel-Trintinalia
temporarily deployed
to
docker
December 2, 2026 09:03 — with
GitHub Actions
Inactive
Gabriel-Trintinalia
temporarily deployed
to
docker
December 2, 2026 09:03 — with
GitHub Actions
Inactive
Gabriel-Trintinalia
temporarily deployed
to
docker
December 2, 2026 09:03 — with
GitHub Actions
Inactive
Gabriel-Trintinalia
temporarily deployed
to
docker
December 2, 2026 09:03 — with
GitHub Actions
Inactive
…ision/status Adds KeySealer, which seals EIP-2335 keystores and raw secrets into a key bundle, and KeyProvisioner, which loads a bundle into a running enclave signer through the broker's key release. The enclave subcommand wraps both, plus a status check. A fake enclave signer in enclave-host's test fixtures does the dev platform's real crypto, so the host side is tested end to end without the enclave signer module. Ported from #1304 and #1306.
- Errors: keystore failures give their reason; the tools print the cause chain, name missing or unreadable files, and print the stack trace at debug level. - enclave tools: no server startup log line; --version and help on every tool; bare `enclave` fails; key source options are checked up front by name. - seal: takes the region from a KMS key ARN; gets the data key before decrypting keystores, so a wrong key fails fast; keystores are read once. - provision: checks --address first; a 2 second connect timeout so --wait-seconds holds; the key policy check runs before connecting; a protocol version mismatch is an EnclaveHostException; a lost key count after loading no longer fails the run (Result.enclaveKeyCount is optional, bundleKeys removed). - Help text for --response-timeout-seconds and --dev-master-key-file. - Tests: connect retry, partial load, status wait, version mismatch, data key wiping, raw key formats and option checks; no free port races.
- At --logging=DEBUG the HTTP client's wire logger printed KMS responses, including GenerateDataKey's plaintext data key. The enclave tools now hold the client's wire and header loggers at INFO. - The enclave tools log to stderr, so stdout carries only their output. - One shared 2 second connect timeout for provision and status.
…1313 - KeyBundle.Provider enum in place of the provider strings - KeySealer seals a bundle through one AesGcm instance, closed after use - FakeEnclaveSigner opens entries through an AesGcm instance - AwsKmsKeyReleaseBroker.arnRegion matches key and alias ARNs itself, as #1313 replaced regionOf with a key-ARN-only pattern - KeySealerTest keeps the data key array, as DataKey refuses plaintext() once closed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011ykVB9dTVuCZAgm9NVX9oZ
- provision: wait for the enclave with a pooled STATUS on the short request timeout before opening the session, so --wait-seconds holds when a proxy accepts but the enclave never answers - status: add --response-timeout-seconds (default 10); EnclaveClient.Options gains a separate connectTimeout so the connect stays short - seal/provision: refuse options of the other platform, so a leftover --aws-kms-key-id cannot silently produce a dev bundle (and vice versa) - enclave tools: usage errors go to stderr, keeping stdout for results; execution failures no longer say "Failed to initialize Web3Signer"; an OutOfMemoryError while sealing gets a heap hint - timeout options are capped at what the client accepts, checked before any KMS call - blame the data key whenever no key loads, also when some were already held Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- provision: bound the session's first STATUS by what is left of the wait (at least 2 s) by closing the session from a watchdog, instead of probing on a pooled connection first; a session that accepts but never answers no longer holds provisioning for the response timeout - status: refuse a negative --min-keys, which passed for an empty enclave - seal: an empty or whitespace-only *.json keystore fails instead of being skipped as "not a keystore", and content after the JSON value is a parse error, so a truncated keystore cannot drop a key silently Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- required options (--output, --address, --bundle) are checked by the tools and not by picocli, whose check failed the parse before a value from --config-file could be applied - provision: when the first STATUS outlasts the wait, say that the enclave did not answer in time, not that the connection dropped - client: a connect timeout is reported with the connect timeout, not the request timeout; README describes connectTimeout - status: an unreachable enclave is reported with its cause (refused, unknown host, vsock hints), and with a stack trace at DEBUG - seal: check the output directory before the data key and the slow decrypts, and refuse more keys than one signer can hold - test: compare stderr with normalized newlines Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A request in flight at the deadline ran on for the response timeout, which --response-timeout-seconds can make much longer than the wait. With a wait, a watchdog now closes the client at the deadline, which fails the request in flight; without one, the single request still gets the whole response timeout. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Jackson's parse error quotes the text it could not read. With a raw keys file named *.json among the keystores, that text is a secret, and the tools print the causes of a failure. Drop the cause and report only the line and column. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The loop slept until the deadline and then polled once more, just as the watchdog closed the client, so an enclave that answered but held too few keys was mostly reported as not answering STATUS. No request is sent once the wait is over; the last answer is reported instead. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The listing kept regular files only, so a *.json symlink to a volume that is not mounted, or a directory named *.json, was left out and seal succeeded with a key fewer. Entries are now taken by name, and one that is not a readable file fails. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The config file provider throws with the root command line, so a missing file or an unknown key printed the root usage on stdout, which the enclave tools keep for results. The writer is now also picked from the arguments. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A mistyped --keystores-path, password file, passwords directory or raw keys file only failed after KMS had been asked for a data key. sealToFile now checks that each given source is there first, next to the check of the output directory. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Cancelling the CompletableFuture left its timer task in the delayed executor, so each attempt that connected and then failed kept its session and connection until the rest of the wait had passed. The watchdogs now run on a scheduler of the connect that removes cancelled tasks and is shut down when the connect ends. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Only the copy that toArray() made was zeroed. The array behind toBytes(), the copy made for the zero check, the parsed bytes of a raw key and every BLSSecretKey stayed in memory for the rest of the run, also when sealing failed. - seal and the zero check take the array of toBytes() itself and zero it - a raw key's parsed bytes are zeroed once the key is made - sealToFile destroys every key once the bundle is sealed or sealing failed, and readKeyPairs destroys the keys read so far when it fails The in-memory seal(List) used by tests leaves the caller's keys alone. The hex lines of a raw keys file and the copies inside KeyStore.decrypt are Strings and library internals and are not reached by this. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
seal accepted a multi-Region key, and provision then refused the bundle in the key policy check, which is its default: the operator only found out on the enclave host and had to seal again. The KMS broker now refuses it when it creates the data key, by the key ARN that KMS returns, so that an alias or a bare key id is covered too. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
With more keystores than one enclave signer can hold, every one of them was decrypted first, with the data key in memory all the while, and the limit only refused at the end. The *.json entries are now read and parsed first, which is cheap, to leave out those that are not keystores; their number and the number of raw keys are checked against the limit before the first decrypt. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…t fix provision retried every failure for the whole --wait-seconds, 60 seconds by default, and printed nothing meanwhile: also without a vsock driver, or with a host name in --address that does not resolve. A provisioning connect that fails is now marked permanent unless the address refused the connection, did not answer in time or reset it (EnclaveAddress.mayConnectLater, EnclaveUnavailableException.isPermanent), and provision reports a permanent failure at once. A failure after the connect, such as an enclave that accepts but does not answer, is retried as before. On vsock, ENODEV and ENETUNREACH count as permanent: the driver or the transport is missing. An enclave that is not running yet answers ETIMEDOUT, and a port nothing listens on ECONNREFUSED. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Gabriel-Trintinalia
force-pushed
the
enclave-seal-provision
branch
from
December 2, 2026 21:36
da762f1 to
ae2af28
Compare
jframe
reviewed
Dec 2, 2026
Open
3 tasks done
status --wait-seconds kept asking for the whole wait with a typo in the host name or without the vsock driver, although provision stops at once on the same failures. Only the connect of a provisioning session was marked permanent. The client's connect now reports its own failure, for a pooled request as for a provisioning session, and marks it permanent unless the address refused the connection, did not answer in time or reset it. status stops polling on a permanent failure. A request that fails after it connected is not permanent. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ime left The loop was a while (true) with its exits spread through the body. It now tries once and again while the failure is not permanent and the wait has time left, keeps the last failure and throws it once the loop ends. No change in behaviour: after the last pause there is still one attempt. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 570604f. Configure here.
After sleeping the last of the wait, the connect loop made one more attempt, which with the two second minimum for the first STATUS could run a few seconds past --wait-seconds. status sends nothing once its wait is over; provision now does the same. There is still always one attempt, also with a zero wait. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
jframe
approved these changes
Dec 3, 2026
This branch was successfully deployed
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.

PR Description
Supersedes #1317: the same branch, reopened so that its original author can review it. The first four commits are #1317 as it stood; the last four address the reviews it got since (see "Changes since #1317").
Part of #1301, on top of #1313. Seals BLS keys into a key bundle and provisions a bundle into a running enclave signer, with the
enclavesubcommands that drive both. This is the whole host side: an operator can seal, provision and check an enclave signer with what's here.deposit_data-*.json, is skipped.enclave seal,enclave provision,enclave status.sealtakes the region from a KMS key ARN, so--aws-regionis only needed for a bare key id or alias.provisionbuilds its KMS broker from the bundle's key ARN, so there's no region flag.--verify-key-policydefaults to true for KMS bundles and false for dev ones, since the dev broker has no key policy.status --min-keys --wait-secondslets a deployment script wait for a provisioned enclave. The tools print their results on stdout and log to stderr. The HTTP client's wire and header loggers stay at INFO, so--logging=DEBUGnever prints the KMS data key.enclave-host's test fixtures. It does the real crypto for the dev platform: a fresh RSA release key perGET_EVIDENCE, a CMS unwrap, then an AES-GCM open of each sealed key, checked against its public key with Teku. So this PR's tests don't need the enclave signer module.The sealer and provisioner come from #1304 and the subcommands from #1306. Changes from those:
enclave benchis gone.Changes since #1317
These come from two code reviews and two Copilot reviews of #1317.
Waits and timeouts
provision --wait-secondsholds when the enclave accepts a connection but never answers: the session's firstSTATUSis bounded by what is left of the wait (at least 2 s), by closing the session from a watchdog. It used to run for the response timeout. The error says the enclave did not answer in time.statushas--response-timeout-seconds(default 10), so a busy enclave is not reported as down after 2 s. With--wait-seconds, a request in flight at the deadline is cut short.EnclaveClient.Optionshas a separateconnectTimeout. The two-argument constructor keeps one timeout for both. A connect timeout is reported as such. This touchesenclave-protocol, including its README.Refusals
sealandprovisionrefuse options of the other platform, so a leftover--aws-kms-key-idcannot silently produce a dev bundle.sealfails on an empty or whitespace-only*.jsonkeystore and on content after the JSON value, instead of skipping the file. It checks the output directory before the data key and the decrypts, and refuses more keys than one signer holds (Protocol.MAX_KEYS).statusrefuses a negative--min-keys.Command line
--output,--addressand--bundlecan come from--config-file. They are checked by the tools, not with picocli'srequired, which failed the parse before the config file was applied.OutOfMemoryErrorwhile sealing gets a heap hint.statusreports why the enclave is unreachable (refused, unknown host, the vsock hints).Left open, for the reviewer to decide
sealaccepts a multi-Region KMS key, whichprovisionrefuses by default in the key policy check.provisionprints nothing while it retries during--wait-seconds.status --wait-secondsstops at the first refusal ofSTATUSinstead of waiting on.-Dlog4j.configurationFile, logs go where that file sends them, which can be stdout. For the deployment guide.Fixed Issue(s)
Part of #1301.
Documentation
doc-change-requiredlabel to this PR if updates are required. The deployment guide comes at the end of the series.Changelog
Testing
The sealer tests cover every input source and refusal. The provisioner tests run against the fake enclave and cover:
The commandline tests seal, provision and check status end to end against the fake, and check that
seal --logging=DEBUGkeeps the data key out of the logs. They also cover the config file, the refusals above and thestatuswaits. Seal and provision against real KMS and Nitro come with the acceptance tests later in the series.Run locally: the tests of
enclave-protocolandenclave-host, and the enclave and parser tests ofcommandline. The full build was not run locally.🤖 Generated with Claude Code
Note
High Risk
Introduces host-side BLS key handling, KMS data-key generation/release, and enclave provisioning paths where mishandling or logging could expose validator secrets.
Overview
Adds experimental
web3signer enclavesubcommands —seal,provision, andstatus— wired throughenclave-host(KeySealer,KeyProvisioner) so operators can encrypt BLS keys into bundles (AWS Nitro KMS or dev), load them into a running enclave signer, and poll readiness with--min-keys/--wait-seconds.CLI/parser behavior is tailored for tooling: enclave commands keep stdout for machine-readable output, route errors and usage to stderr, skip the normal Web3Signer startup banner, and cap HTTP client debug logging so KMS data keys are not logged at DEBUG.
Security and ops hardening includes optional KMS key-policy verification before provision, refusal of multi-Region KMS keys at seal time, cross-platform option validation, secret hygiene in sealing errors, and
EnclaveClientchanges (separate connect timeout,isPermanent()on connect failures) to support bounded retries instatusandprovision.Extensive unit/integration tests use a new
FakeEnclaveSignertest fixture and expandedenclave-host/ commandline test coverage.Reviewed by Cursor Bugbot for commit ee84ea3. Bugbot is set up for automated code reviews on this repo. Configure here.