Skip to content

Clio: add EM/SOL external-signer key support#344

Open
heifner wants to merge 2 commits into
masterfrom
feature/clio-external-signer-keys
Open

Clio: add EM/SOL external-signer key support#344
heifner wants to merge 2 commits into
masterfrom
feature/clio-external-signer-keys

Conversation

@heifner
Copy link
Copy Markdown
Contributor

@heifner heifner commented May 15, 2026

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

  • --em generates an EM key (Ethereum-style secp256k1, PVT_EM_/PUB_EM_), the key form a MetaMask / EIP-191 personal_sign wallet uses to sign Wire transactions.
  • --sol generates a Solana key (ed25519, PVT_ED_/PUB_ED_).
  • --r1/--k1/--em/--sol are mutually exclusive (CLI11 ->excludes(), so a bad combination is a non-zero parse error).

convert

  • em_private_key imports a raw Ethereum hex secret (what MetaMask / eth tooling exports) or a PVT_EM_ string and prints the Wire PVT_EM_/PUB_EM_ forms.
  • em_sign signs a 32-byte sha256 digest with an EM key. It dispatches to em::sign_sha256, which wraps the digest in the EIP-191 personal_sign envelope before secp256k1 -- byte-identical to MetaMask and to what nodeop recovers -- and prints the SIG_EM_ form.
  • em_recover recovers the PUB_EM_ from a SIG_EM_ over a digest.

These mirror the existing convert k1_private_key/k1_public_key idiom.

Test

clio_em_key_test is a new offline, parallelizable ctest. It exercises the create-key round-trips and a frozen known-answer vector minted from eth_account (the Ethereum-ecosystem reference, 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; 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.

heifner added 2 commits May 15, 2026 15:29
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant