feat: add getPublicKey across all chains - #194
Conversation
Adds derive_public_key() to ChainSigner trait and wires it through ows-lib, Node binding, Python binding, and CLI. Closes open-wallet-standard#157 Problem ------- TON wallet contract initialization (WalletContractV5R1) requires the raw Ed25519 public key. The only workaround was exportWallet() to get the mnemonic, re-derive externally, then zero the secret material — partially undermining key isolation. Solution -------- Add get_public_key(wallet, chain, index) that returns the raw public key hex without exposing any secret material. Return format: - Ed25519 chains (TON, Solana, Sui): 32-byte hex (64 chars) - secp256k1 chains (EVM, Bitcoin, Cosmos, Tron, XRPL, Filecoin, Spark): 33-byte compressed SEC1 hex (66 chars, starts with 02 or 03) Changes ------- - ows-signer: derive_public_key() added to ChainSigner trait - ows-signer: implemented for all 10 chains - ows-lib: get_public_key() with 8 unit tests (144 existing pass) - bindings/node: getPublicKey() exported via NAPI - bindings/python: get_public_key() exported via PyO3 - ows-cli: ows wallet public-key --wallet --chain [--index] [--json]
|
@teyrebaz33 is attempting to deploy a commit to the MoonPay Team on Vercel. A member of the Team first needs to authorize it. |
|
Thanks for taking this on. A couple of things to sort out before it can go further. First, the branch is a fair way behind main, so it needs a rebase, and the rebase is where the build breaks. main now has NEAR and Nano signers that this branch predates. Since this PR adds derive_public_key as a trait method with no default body, once you rebase onto main the workspace will not compile (E0046, missing trait item) until NanoSigner and NearSigner also implement derive_public_key. So please add the method to those two as part of the rebase, alongside the chains already covered here. Second, the implementation decrypts the wallet with an empty passphrase and then calls expose() on the secret. That only works for wallets created without a passphrase, and it pulls the raw private key into memory just to derive a public key. The public key can be derived from the key material without exposing the secret, so it would be better to derive it directly rather than decrypt-and-expose. So: rebase and add derive_public_key to the NEAR and Nano signers, and derive the pubkey without decrypting the secret. Final sign-off here is @njdawn's. Thanks again. |
Summary
Adds
getPublicKey(walletName, chainId)to the Node SDK, Python SDK, and CLI. Eliminates the mnemonic round-trip workaround for public key access.Closes #157
Problem
TON wallet contract initialization (
WalletContractV5R1) requires the raw Ed25519 public key. The only workaround was callingexportWallet()to get the mnemonic, re-deriving the keypair externally, then zeroing secret material — partially undermining key isolation even with careful zeroing.Solution
# CLI ows wallet public-key --wallet my-wallet --chain ton ows wallet public-key --wallet my-wallet --chain evm --jsonReturn format
02/03prefix)Changes
ows-signer:derive_public_key()added toChainSignertrait, implemented for all 10 chainsows-lib:get_public_key(wallet, chain, index, vault_path)with 8 unit testsbindings/node:getPublicKey()exported via NAPIbindings/python:get_public_key()exported via PyO3ows-cli:ows wallet public-key --wallet --chain [--index] [--json]Tests
Security
Public keys are not secret — exposing them does not weaken the security model. Private key material never leaves the OWS signing core.