Skip to content

fix(web): generate native Ed25519 wallet keys (#8205) - #8206

Open
iQodeIT wants to merge 1 commit into
Scottcjn:mainfrom
iQodeIT:fix/8205-ed25519-web-wallet
Open

fix(web): generate native Ed25519 wallet keys (#8205)#8206
iQodeIT wants to merge 1 commit into
Scottcjn:mainfrom
iQodeIT:fix/8205-ed25519-web-wallet

Conversation

@iQodeIT

@iQodeIT iQodeIT commented Aug 12, 2026

Copy link
Copy Markdown

Summary

Fixes #8205 by making the public RustChain web wallet generate native Ed25519 key material instead of P-256 ECDSA keys.

The hosted page previously generated { name: 'ECDSA', namedCurve: 'P-256' }, hashed P-256 coordinates into an RTC-formatted address, and labeled the result as a native wallet. That address could not be used consistently with RustChain's Ed25519 signed-transfer implementation.

Changes

  • Added the tracked site/wallet.html source for the deployed wallet page.
    • Generate keys with Web Crypto Ed25519.
    • Export the standard Ed25519 JWK x public-key and d 32-byte seed fields.
    • Derive the RTC address from the raw 32-byte Ed25519 public key using SHA-256, matching tools/rustchain_wallet_cli.py.
    • Store curve: 'Ed25519' in downloaded wallet metadata.
    • Reject unexpected key lengths and provide a clear browser-support error.
    • Added a focused regression test so the page cannot silently revert to P-256.

Validation

  • python3 -m unittest -v tests/test_wallet_page_ed25519.py
    • node --check on the extracted inline wallet script.
    • Manual Chromium verification from file:///home/ubuntu/Rustchain/site/wallet.html: generation succeeded and displayed a 32-byte public key, a 32-byte private seed, and an RTC address derived from the public key.
      This is wallet/crypto-sensitive work and should be reviewed under the repository's BCOS-L2 guidance.

Signed-off-by: iQodeIT 1.62815903e+08+iQodeIT@users.noreply.github.com

Signed-off-by: iQodeIT <1.62815903e+08+iQodeIT@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

Welcome to RustChain! Thanks for your first pull request.

Before we review, please make sure:

  • Non-doc PRs have a BCOS-L1 or BCOS-L2 label
  • Doc-only PRs are exempt from BCOS tier labels when they only touch docs/**, *.md, or common image/PDF files
  • New code files include an SPDX license header
  • You've tested your changes against the live node

Bounty tiers: Micro (1-10 RTC) | Standard (20-50) | Major (75-100) | Critical (100-150)

A maintainer will review your PR soon. Thanks for contributing!

@github-actions github-actions Bot added size/L PR: 201-500 lines BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) BCOS-L2 Beacon Certified Open Source tier BCOS-L2 (required for non-doc PRs) wallet Wallet/transfer related tests Test suite changes labels Aug 12, 2026

@FlintLeng FlintLeng left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review: Native Ed25519 Wallet Key Generation

Reviewed on: 2026-08-13

Summary

Fixes #8205. Replaces P-256 ECDSA with native Ed25519 key generation in the hosted RustChain web wallet. RTC addresses are now derived from Ed25519 public keys, matching the native wallet format used by the RustChain protocol.

Security Analysis ✅

Why Ed25519? RustChain uses Ed25519 for native wallet signatures. A P-256 key cannot sign native RTC transfers. The web wallet was generating keys that would be incompatible with the protocol — a fundamental mismatch. This fix aligns the web wallet with the native wallet format.

Web Crypto API implementation is correct:

  • crypto.subtle.generateKey({ name: 'Ed25519' }, true, ['sign', 'verify']) — modern browsers support Ed25519 natively via Web Crypto (Chromium-based since 2024, Safari since 2023)
  • Exports JWK with d (32-byte private seed) and x (32-byte raw public key) per RFC 8032 — correct Ed25519 encoding
  • RTC address derivation: RTC + SHA256(pubkey)[:40] — matches the native wallet address format

Client-side only, no server round-trip: The warning banner explicitly states "Everything happens in your browser. No data is sent to any server. Your private key never leaves this page." This is the correct security model for a key-generation page.

Code Quality ✅

Error handling is present: Key generation errors fall back to "ERROR — TRY AGAIN" state. Length checks on pubKeyHex and privKeyHex (must be 64 hex chars / 32 bytes) catch malformed exports.

Test coverage: test_wallet_page_ed25519.py parses the HTML, extracts the inline JS, and asserts:

  • Ed25519 key generation code is present
  • crypto.subtle.generateKey is called with Ed25519 params
  • JWK d and x fields are used
  • Address format matches RTC prefix + 40 hex chars

Minor notes:

  1. The HTML includes a "Selya" chat widget (.selya-btn, .selya-panel classes) — this appears to be an embedded support chat. Worth confirming this is intentional and the third-party script is approved.
  2. The warning banner is excellent ("NOT a Solana/ETH/BTC address") — prevents user confusion about wRTC vs RTC.

Wallet: RTC019e78d600fb3131c29d7ba80aba8fe644be426e

✅ LGTM — correct fix that aligns the web wallet with native Ed25519 wallet format, with appropriate security warnings and test coverage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) BCOS-L2 Beacon Certified Open Source tier BCOS-L2 (required for non-doc PRs) size/L PR: 201-500 lines tests Test suite changes wallet Wallet/transfer related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Web wallet generates P-256 keys for native Ed25519 RTC addresses

2 participants