Clio: add EM/SOL external-signer key support#344
Open
heifner wants to merge 2 commits into
Open
Conversation
First-class CLI support for Wire's external-signer key types, built on libfc's own crypto (the same code nodeop runs to validate these signatures), all offline (no node, no wallet): create key --em EM key (Ethereum-style secp256k1, PVT_EM_/PUB_EM_) -- the form a MetaMask / EIP-191 personal_sign wallet uses to sign Wire transactions --sol Solana key (ed25519, PVT_ED_/PUB_ED_) --r1/--em/--sol are mutually exclusive via CLI11 ->excludes() convert em_private_key import a raw Ethereum hex secret (what MetaMask/eth tooling exports) or a PVT_EM_ string, print the Wire PVT_EM_/PUB_EM_ forms em_sign sign a 32-byte sha256 digest with an EM key; dispatches to em::sign_sha256, which applies the EIP-191 personal_sign envelope, byte-identical to MetaMask and to what nodeop recovers; prints SIG_EM_ em_recover recover the PUB_EM_ from a SIG_EM_ over a digest These mirror the existing convert k1_private_key/k1_public_key idiom and share two local parse helpers. clio_em_key_test (offline, parallelizable) covers create-key round-trips and a frozen known-answer vector minted from eth_account, the Ethereum-ecosystem reference that is byte-identical to MetaMask personal_sign. The vector pins libfc's EIP-191 envelope, low-s normalization and recovery-id handling against an independent implementation with no pip/apt/browser dependency; any divergence fails hermetically. Provenance is documented in the test for deliberate, reviewed regeneration.
create key: --k1/--r1/--em/--sol are now mutually exclusive (CLI11 ->excludes()), so any contradictory combination is a non-zero parse error instead of being silently resolved by precedence. em_private_key/em_sign --private-key help: note the secret is visible in ps and shell history; omit the option to enter it at the interactive prompt instead. clio_em_key_test: add a digest-binding negative (the reference signature recovered against a different well-formed digest must yield a different key -- the property the external-signer pre-flight depends on), a 64-char non-hex digest rejection, and the new --k1 exclusion pairs. elliptic_em.hpp: fix the from_native_string doc comment, which described a public key; it takes the raw Ethereum private-key hex.
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 first-class clio support for Wire's external-signer key types, using libfc's own crypto path (the same code nodeop runs to validate these signatures). All commands are offline -- no node, no wallet.
create key
--emgenerates an EM key (Ethereum-style secp256k1,PVT_EM_/PUB_EM_), the key form a MetaMask / EIP-191personal_signwallet uses to sign Wire transactions.--solgenerates a Solana key (ed25519,PVT_ED_/PUB_ED_).--r1/--k1/--em/--solare mutually exclusive (CLI11->excludes(), so a bad combination is a non-zero parse error).convert
em_private_keyimports a raw Ethereum hex secret (what MetaMask / eth tooling exports) or aPVT_EM_string and prints the WirePVT_EM_/PUB_EM_forms.em_signsigns a 32-byte sha256 digest with an EM key. It dispatches toem::sign_sha256, which wraps the digest in the EIP-191personal_signenvelope before secp256k1 -- byte-identical to MetaMask and to what nodeop recovers -- and prints theSIG_EM_form.em_recoverrecovers thePUB_EM_from aSIG_EM_over a digest.These mirror the existing
convert k1_private_key/k1_public_keyidiom.Test
clio_em_key_testis a new offline, parallelizable ctest. It exercises the create-key round-trips and a frozen known-answer vector minted frometh_account(the Ethereum-ecosystem reference, byte-identical to MetaMaskpersonal_sign). The vector pins libfc's EIP-191 envelope, low-s normalization and recovery-id handling against an independent implementation with no pip/apt/browser dependency; a divergence fails the test hermetically. The vector's provenance (reference implementation, key, message, recipe) is documented in the test so regeneration is a deliberate, reviewed act.