feat(wallet): native wallet framework for SDK integrators#132
Open
JaeLeex wants to merge 2 commits into
Open
Conversation
Ship nunchi-wallet for SDK integrators with encrypted keystore, CLI, RPC client, and passkey types, and bind transactions to chain_id to prevent cross-chain replay. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Summary
This PR ships a first-party wallet framework in the Nunchi SDK so chain operators and dApp developers can create, store, sign, and submit transactions without rolling their own tooling.
nunchi-walletcrate: encrypted keystore, Ed25519 CLI, JSON-RPC client, and passkey assertion typesexamples/wallet-web: browser passkey wallet kit (Constantinople-compatible encoding)chain_idtoTransactionPayloadfor cross-chain replay protectionsdk_build_*tools to accept optionalchain_idSpecification
1. Bech32 addresses (
nch1…)nchAddressdigestAddress::to_bech32()/Address::from_bech32()Addresses are derived identifiers:
012Only
Addressuser-facing fields use Bech32. Public keys, coin IDs, tx hashes, and state roots remain hex.Canonical implementation:
nunchi-common/src/account.rs(merged in #75).2. Chain ID replay protection
Every
TransactionPayloadnow includeschain_id: u64encoded beforenonceandoperation.Signing bytes:
where
payload.encode()ischain_id || nonce || operation.DEFAULT_CHAIN_ID = 0for devnet/testschain_idafter signing invalidates the authorizationcommon/src/tests/transaction.rs3. CLI wallet (Ed25519)
~/.nunchi/wallets/<name>/wallet.jsonNUNCHI_WALLET_PASSWORDenv var--insecure-store(plaintext JSON)Commands:
4. RPC client
Submits hex-encoded coin transactions via:
Library API:
nunchi_wallet::client::WalletRpcClient5. Passkey wallet (web)
Browser wallets use WebAuthn P-256 assertions in Constantinople-compatible form:
Reference:
examples/wallet-web— adapted from Commonware Constantinople.On-chain verification of passkey signatures requires chain support for bundled WebAuthn assertions (future
nunchi-cryptoextension). This PR ships encoding types now so web wallets and chains can integrate without another breaking wire change.6. Wallet kit scope for third parties
nunchi-common,nunchi-cryptonunchi-walletexamples/wallet-webnunchi-wallet::client7. Security notes
NUNCHI_WALLET_PASSWORD--insecure-storechain_id; multi-chain operators should create one wallet record per chainchain_idvaluesBreaking changes
Transaction::signandTransaction::sign_multisignow require an explicitchain_idargument. All in-repo call sites are updated.Test plan
cargo test -p nunchi-common(includes cross-chain replay test)cargo test -p nunchi-coins -p nunchi-mempool -p nunchi-mcp -p nunchi-walletnunchi-walletkeystore round-trip + Bech32 address creationnunchi-wallet create+submit-transferagainst a running devnet nodeexamples/wallet-webpasskey create/sign in a secure browser contextDocs
wallet/SPEC.md— canonical wallet specificationwallet/README.md— quick startexamples/wallet-web/README.md— browser kit usageMade with Cursor