Skip to content

feat(zig): Implement HDWallet + Transaction builder utilities via eth.zig#385

Open
koko1123 wants to merge 1 commit intoevmts:mainfrom
koko1123:feat/hdwallet-transaction-builder-eth-zig
Open

feat(zig): Implement HDWallet + Transaction builder utilities via eth.zig#385
koko1123 wants to merge 1 commit intoevmts:mainfrom
koko1123:feat/hdwallet-transaction-builder-eth-zig

Conversation

@koko1123
Copy link
Copy Markdown

Description

Implements BIP-32/44 HD Wallet derivation and transaction signing/recovery utilities for Voltaire's Zig packages, powered by eth.zig v0.2.3.

HDWallet (crypto/HDWallet/hdwallet.zig):

  • HDWallet.fromSeed / derivePath / deriveChild / deriveEthereum / deriveEthereumFromSeed
  • getPrivateKey / getPublicKey (compressed SEC1) / getAddress / getChainCode
  • Mnemonic.generate / generate24 / toSeed / validate / fromEntropy128 / fromEntropy256
  • Constants: HARDENED, ETH_COIN_TYPE

Transaction builder utilities (primitives/Transaction/transaction_utils.zig):

  • signEip1559Transaction / signEip4844Transaction / signEip7702Transaction
  • recoverLegacySender / recoverEip1559Sender (ECDSA ecrecover via eth.zig)
  • detectTransactionType (re-export)

Bugfix: Removes duplicate ConsensusSpec, ForkConfig, LightClientHeader, LightClientUpdate, SyncCommittee, SyncAggregate, and consensus declarations in primitives/root.zig that caused compilation errors on main.

AI Disclosure

  • This PR contains AI-generated code

AI Tools Used

Claude (Anthropic)

Prompts Used

- "Find any critical issues in Voltaire that eth.zig can solve"
- "Compare matching features in existing libraries and see if there are no direct implementations"
- "Write tests and ensure coverage"

Human Explanation

Voltaire needed HD wallet support (#353, critical priority) and transaction builder utilities (#368). Rather than implementing from scratch or wrapping libwally-core via C FFI, this PR adds eth.zig as a Zig package dependency - it already has complete, tested implementations of BIP-32/39/44 key derivation and secp256k1 ECDSA that have been validated against standard test vectors.

Related Issues

Fixes #353
Fixes #368

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Test additions or updates
  • Build/CI/tooling changes

Testing

  • zig build completes successfully
  • All existing tests pass (43/43)
  • Added new tests for changes: 13 HDWallet tests + 5 transaction utils tests
    • BIP-39 known vector: abandon...about -> 0x9858EfFD232B4033E47d90003D41EC34EcaEda94
    • BIP-39 TREZOR passphrase seed vector
    • deriveEthereum matches deriveEthereumFromSeed (same BIP-44 path)
    • Sign + recover roundtrips for EIP-1559 and Legacy transactions
    • EIP-4844 and EIP-7702 signing produces valid signatures
    • Different private keys produce different signatures and addresses

Note: blockchain-tests has a pre-existing compilation error (BlockTag member not found) unrelated to this PR.

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code where necessary
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I understand and take responsibility for all code in this PR (including AI-generated code)

….zig

Add BIP-32/44 HD Wallet derivation and BIP-39 mnemonic support via eth.zig
dependency. Implement transaction signing for EIP-1559, EIP-4844, and
EIP-7702 types, plus sender recovery via ECDSA ecrecover.

- Add eth.zig v0.2.3 as build dependency
- Create HDWallet module with fromSeed, derivePath, deriveChild,
  deriveEthereum, getAddress, getPublicKey
- Create Mnemonic utilities (generate, validate, toSeed, fromEntropy)
- Create transaction_utils with sign/recover for all modern tx types
- Fix pre-existing duplicate declarations in primitives/root.zig
- 18 new tests (13 HDWallet + 5 transaction utils)

Fixes evmts#353, Fixes evmts#368
@vercel
Copy link
Copy Markdown

vercel bot commented Feb 28, 2026

@koko1123 is attempting to deploy a commit to the evmts Team on Vercel.

A member of the Team first needs to authorize it.

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.

[Zig] Implement Transaction builder utilities [Zig] Implement HDWallet module

1 participant