nodejs-keccak256

Detect and prevent Keccak-256 hashing mistakes in JavaScript and TypeScript Ethereum code.

2|Updated Mar 3, 2026
One-click install
npx skills add https://github.com/MomoDaviluke/star-citizen-promotion --skill nodejs-keccak256-momodaviluke
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: nodejs-keccak256
Source: https://github.com/MomoDaviluke/star-citizen-promotion/tree/main/.agents/skills/ecc/nodejs-keccak256
Command: npx skills add https://github.com/MomoDaviluke/star-citizen-promotion --skill nodejs-keccak256-momodaviluke

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Ethereum uses Keccak-256, not Node's SHA3-256, which leads to mismatches in selectors, signatures, and address derivations when developers use crypto.createHash('sha3-256').

Core Features & Use Cases

  • Prevents silent hashing bugs by guiding developers to use Keccak-256-aware libraries like ethers, viem, or web3.
  • Covers common Ethereum data hashing tasks such as function selectors, event topics, signatures, Merkle proofs, and storage slot derivations.
  • Use Case: Update a JS/TS project that hashes Ethereum data to ensure keccak256 compatibility and correct address derivation.

Quick Start

Use a keccak256-aware library (ethers, viem, or web3) to hash Ethereum data instead of crypto.createHash('sha3-256').

Frequently Asked Questions about nodejs-keccak256

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does my Ethereum function selector mismatch when using Node.js crypto.createHash?▼

Node.js crypto.createHash('sha3-256') uses the NIST SHA3 standard, not Ethereum's Keccak-256, causing silent hashing mismatches in function selectors and signatures. You must use Keccak-256-aware libraries like ethers, viem, or web3 instead to ensure correct Ethereum compatibility.

What is the difference between SHA3-256 and Keccak-256 in JavaScript?▼

Keccak-256 is the original hashing algorithm adopted by Ethereum, while SHA3-256 is a NIST-standardized variant with different padding. Using Node's crypto.createHash('sha3-256') produces incorrect hashes for Ethereum data like event topics and storage slot derivations.

How do I correctly generate Keccak-256 hashes for Ethereum in TypeScript?▼

To correctly generate Keccak-256 hashes in TypeScript, use Ethereum-aware libraries such as ethers, viem, or web3 instead of Node's built-in crypto module. These libraries implement the correct Keccak-256 algorithm for Ethereum function selectors, event topics, and address derivations.

Does Node.js crypto module work for Ethereum address generation?▼

No, the Node.js crypto module does not work for Ethereum address generation because its sha3-256 implementation differs from Ethereum's Keccak-256. Using it leads to incorrect address derivations; you should use ethers, viem, or web3 libraries to ensure proper Keccak-256 hashing.

When do I need to avoid sha3-256 for Ethereum hashing tasks?▼

You need to avoid Node's sha3-256 whenever performing Ethereum-specific hashing tasks such as deriving function selectors, event topics, signatures, Merkle proofs, or storage slots. Always use Keccak-256-aware libraries like ethers or viem to prevent silent hashing bugs in JS/TS projects.

Can I use viem or web3 for Keccak-256 hashing instead of ethers?▼

Yes, you can use viem or web3 for Keccak-256 hashing as they correctly implement Ethereum's Keccak-256 standard. Any of these three libraries properly handles Ethereum hashing tasks like function selectors and address generation, whereas Node's crypto.createHash does not.