affaan-m avatar

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-code

Installs 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
1affaan-m avatarinventory-demand-planningaffaan-m/eccCodified expertise for demand forecasting, safety stock optimization, replenishment planning, and promotional lift estimation at multi-location retailers. Infor5.5Kskills.sh installs
2affaan-m avatarevm-token-decimalsaffaan-m/eccPrevent silent decimal mismatch bugs across EVM chains. Covers runtime decimal lookup, chain-aware caching, bridged-token precision drift, and safe normalizatio5.4Kskills.sh installs
3trailofbits avatardimensional-analysistrailofbits/skillsAnnotates codebases with dimensional analysis comments documenting units, dimensions, and decimal scaling. Use when someone asks to annotate units in a codebase4.6Kskills.sh installs
4inngest avatarinngest-eventsinngest/inngest-skillsUse when designing event-driven workflows, decoupling services, implementing fan-out patterns (one trigger, many downstream handlers), implementing idempotent e4Kskills.sh installs
5raroque avatarvibe-securityraroque/vibe-security-skillAudits codebases for common security vulnerabilities that AI coding assistants introduce in "vibe-coded" applications. Checks for exposed API keys, broken acces3.8Kskills.sh installs
6anthropics avatarvariance-analysisanthropics/knowledge-work-pluginsDecompose financial variances into drivers with narrative explanations and waterfall analysis. Use when analyzing budget vs. actual, period-over-period changes,3.4Kskills.sh installs