[guardian] dev tool: recover a restarted guardian's BTC key from S3 shares#692
Draft
0xsiddharthks wants to merge 1 commit into
Draft
[guardian] dev tool: recover a restarted guardian's BTC key from S3 shares#6920xsiddharthks wants to merge 1 commit into
0xsiddharthks wants to merge 1 commit into
Conversation
…hares Adds `hashi-guardian-init tools dev-recover`, the recovery analogue of dev-bootstrap. Instead of generating a fresh master secret, it reconstructs the guardian's existing one from the ceremony key-shares persisted to S3. - recovery mode: reads the ceremony SecretSharingInstance + encrypted KP shares from S3, decrypts t of them with a local gpg homedir, then drives OperatorInit -> GetGuardianInfo -> ProvisionerInit reusing the ceremony's instance and a recovered limiter state (so a restart doesn't reset the rate-limit bucket). Asserts the post-init enclave BTC pubkey matches the on-chain guardian_btc_public_key. - --print-master-pubkey: decrypts t shares and combines them locally to print the x-only master pubkey; no chain/RPC. Used at genesis to capture the pubkey to pin on-chain (a ceremony-mode guardian never exposes it). Reuses the ceremony gpg-decrypt helper, the S3 GuardianReader, and limiter_recovery; makes three dev-bootstrap helpers pub(crate). Dev-scoped: the production recovery path runs each KP's share through the relay, not one gpg homedir.
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.
Adds
hashi-guardian-init tools dev-recover, the recovery counterpart todev-bootstrap. Under the ceremony model the master secret is generated inside the enclave and Shamir-split to the KP PGP keys, with encrypted shares persisted to S3 (#685) and theSecretSharingInstancein the ceremony log (#687). A restart loses the in-memory BTC key and nothing currently rebuilds it from S3 — this does.SecretSharingInstance+ encrypted KP shares from S3, decryptstof them with a local gpg homedir (cross-checking each against the ceremony commitments), then drivesOperatorInit -> GetGuardianInfo -> ProvisionerInitreusing the ceremony's instance and a recovered limiter state (so a restart doesn't reset the rate-limit bucket). Asserts the post-init enclave BTC pubkey matches the on-chainguardian_btc_public_key.--print-master-pubkey: decryptstshares and combines them locally to print the x-only master pubkey; no chain/RPC/guardian contact. Used at genesis to capture the pubkey to pin on-chain, since a ceremony-mode guardian never exposes it directly.Reuses the ceremony gpg-decrypt helper, the S3
GuardianReader, andlimiter_recovery; promotes threedev_bootstraphelpers topub(crate).Dev-scoped and clearly marked as such: the production recovery path runs each KP's share through the relay (the
provisionerflow Luke/Deepak own), not one gpg homedir. Not for the prod path.Decrypted-share plaintext is the 32-byte big-endian secp256k1 scalar (
Share::value.to_bytes()), share id taken from theKPEncryptedShare— same formatceremony verifydecrypts.cargo check/clippy -D warningsclean;cargo nextest run -p hashi-guardian-initgreen (32 tests, incl. 3 new pure share-decrypt/commitment/reconstruct tests that don't need gpg or S3).