Crypto Reference
All crypto modules insrc/crypto/. Implementations use Zig core with Rust/C for complex curves.
Hash Functions
Keccak256
Primary Ethereum hash function. Used for addresses, transaction hashes, storage keys.Keccak256/index.ts- TypeScript APIkeccak256.wasm.ts- WASM variantkeccak256_accel.zig- Hardware-accelerated implementationkeccak_asm.zig- Assembly-optimizedkeccak_wrapper.rs- Rust keccak-asm wrapper
SHA256
SHA-256 for EVM precompile and general use.SHA256/index.ts- TypeScript APIsha256.wasm.ts- WASM variantsha256_accel.zig- Hardware-accelerated (SHA-NI)
Blake2
Blake2b hashing (EVM precompile 0x09).Blake2/index.ts- TypeScript APIblake2.zig- Zig implementationblake2_c.zig- C bindings (optional)blake2.fuzz.zig- Fuzz tests
Ripemd160
RIPEMD-160 for Bitcoin compatibility (EVM precompile 0x03).Ripemd160/index.ts- TypeScript APIripemd160.zig- Zig implementationripemd160_c.zig- C bindings
Digital Signatures
Secp256k1
Bitcoin/Ethereum ECDSA curve. Core signing primitive.sign(hash, privateKey)- ECDSA signverify(signature, hash, publicKey)- Verify signaturerecover(signature, hash, v)- Recover public keygetPublicKey(privateKey)- Derive public keycompressPublicKey(pubkey)- Compress to 33 bytesdecompressPublicKey(pubkey)- Decompress to 65 bytesisValidPrivateKey(key)- Validate private keyisValidPublicKey(key)- Validate public key
Secp256k1/index.ts- TypeScript APIsecp256k1.zig- Zig implementationsecp256k1.wasm.ts- WASM variantsecp256k1.bench.zig- Benchmarkssecp256k1.fuzz.zig- Fuzz tests
Ed25519
EdDSA signatures. Used by some L2s and alt chains.Ed25519/index.ts- TypeScript APIed25519.zig- Zig implementationed25519.wasm.ts- WASM variant
P256
NIST P-256 (secp256r1). Used by hardware wallets and WebAuthn.P256/index.ts- TypeScript APIp256.zig- Zig implementationp256.wasm.ts- WASM variant
Elliptic Curves & Pairings
BN254
BN254 (alt_bn128) curve for zkSNARKs. Used by EVM precompiles 0x06-0x08.bn254.zig- Pure Zig implementationbn254_arkworks.zig- Rust arkworks wrapper (higher performance)bn254_ark_c.zig- C interface to Rustbn254_wrapper.rs- Rust arkworks bindings
bn254.ts- TypeScript API (auto-selects best impl)bn254.wasm.ts- WASM variantbn254.ark.ts- arkworks-specific exports
BLS12-381
BLS12-381 curve for beacon chain consensus. EVM precompiles 0x0B-0x13 (Prague). Usesblst C library for production performance.
Files (in
src/evm/precompiles/):
bls12_g1_add.zig,bls12_g1_mul.zig,bls12_g1_msm.zigbls12_g2_add.zig,bls12_g2_mul.zig,bls12_g2_msm.zigbls12_pairing.zigbls12_map_fp_to_g1.zig,bls12_map_fp2_to_g2.zig
KZG Commitments
KZG
Kate-Zaverucha-Goldberg polynomial commitments for EIP-4844 blob transactions.c-kzg-4844- C library (lib/c-kzg-4844)- Trusted setup:
kzg_trusted_setup.zig
KZG/index.ts- TypeScript APIc_kzg.zig- C bindingskzg_setup.zig- Setup loadingkzg_trusted_setup.zig- Embedded trusted setup
Typed Data (EIP-712)
EIP712
Typed structured data hashing and signing.EIP712/index.ts- TypeScript API (placeholder/WIP)eip712.zig- Zig implementationeip712.wasm.ts- WASM variant
Symmetric Encryption
AesGcm
AES-256-GCM authenticated encryption.AesGcm/index.ts- TypeScript APIaes_gcm.zig- Zig implementation
X25519
Elliptic curve Diffie-Hellman key exchange.X25519/index.ts- TypeScript APIx25519.zig- Zig implementationx25519.wasm.ts- WASM variant
Wallet Derivation
Bip39
Mnemonic seed phrase generation and validation.Bip39/index.ts- TypeScript API (uses @scure/bip39)bip39.test.ts- Tests
HDWallet
Hierarchical Deterministic wallet derivation (BIP-32).HDWallet/index.ts- TypeScript API (uses @scure/bip32)hdwallet.test.ts- Testssigners/- Hardware wallet signers (Ledger, Trezor)
Hardware Acceleration
CPU Feature Detection
Detects available CPU features for optimal implementation selection.Accelerated Implementations
Files:
cpu_features.zig- Feature detectionkeccak256_accel.zig- Accelerated Keccaksha256_accel.zig- Accelerated SHA256keccak_asm.zig- Assembly Keccak
Modular Exponentiation
ModExp
Modular exponentiation for MODEXP precompile (0x05).modexp.zig- Zig implementation
Module Summary
WASM Limitations:
- BLS12-381: Requires blst C library
- KZG: Requires trusted setup file and c-kzg library

