
Nodejs Keccak256
Prevents a silent footgun in Ethereum development: Node's `crypto.createHash('sha3-256')` returns NIST SHA3, not the Keccak-256 that Ethereum actually uses, and the two produce different hashes for identical inputs. This matters when you're computing function selectors, event topics, storage slots, or deriving addresses from public keys. The skill shows you the correct helpers from ethers, viem, and web3.js, plus grep commands to audit your codebase for dangerous `createHash('sha3')` calls. If you've ever wondered why your locally computed signature or selector didn't match on-chain data, this is probably why.
- skills.sh installs
- 5.8K
- GitHub stars
- 300.3K
- last updated
- Aug 21, 2026
Install
$ npx -y skills add affaan-m/ecc --skill nodejs-keccak256 --agent claude-codeInstalls into .claude/skills of the current project.
Files
Node.js Keccak-256
Ethereum uses Keccak-256, not the NIST-standardized SHA3 variant exposed by Node's crypto.createHash('sha3-256').
When to Use
- Computing Ethereum function selectors or event topics
- Building EIP-712, signature, Merkle, or storage-slot helpers in JS/TS
- Reviewing any code that hashes Ethereum data with Node crypto directly
How It Works
The two algorithms produce different outputs for the same input, and Node will not warn you.
import crypto from 'crypto';
import { keccak256, toUtf8Bytes } from 'ethers';
const data = 'hello';
const nistSha3 = crypto.createHash('sha3-256').update(data).digest('hex');
const keccak = keccak256(toUtf8Bytes(data)).slice(2);
console.log(nistSha3 === keccak); // false
Examples
ethers v6
import { keccak256, toUtf8Bytes, solidityPackedKeccak256, id } from 'ethers';
const hash = keccak256(new Uint8Array([0x01, 0x02]));
const hash2 = keccak256(toUtf8Bytes('hello'));
const topic = id('Transfer(address,address,uint256)');
const packed = solidityPackedKeccak256(
['address', 'uint256'],
['0x742d35Cc6634C0532925a3b8D4C9B569890FaC1c', 100n],
);
viem
Sponsors
Details
- Repository
- github.com/affaan-m/ecc
- Categories
- Finance & Trading, Web3 & Blockchain
- First seen
- Jul 14, 2026
More from affaan-m/ecc
All 263- Security Scan5.8K
- Cpp Testing5.8K
- Django Tdd5.8K
- Dashboard Builder5.7K
- Redis Patterns5.7K
- Eval Harness5.7K
- Manim Video5.7K
- Content Engine5.7K
- Springboot Tdd5.7K
- Motion Patterns5.7K
- Configure Ecc5.7K
- Token Budget Advisor5.7K
- Investor Materials5.7K
- Agent Introspection Debugging5.7K
- Laravel Verification5.7K
- Marketing Campaign5.7K
- Motion Foundations5.7K
- Kotlin Testing5.7K
- Ai Regression Testing5.7K
- Dart Flutter Patterns5.7K
- Mysql Patterns5.7K
- Production Audit5.7K
- Documentation Lookup5.7K
- Make Interfaces Feel Better5.7K