Skip to main content
skill Claude Code CX Codex Cursor GitHub Copilot

nodejs-keccak256 — Claude skill: Ethereum hashing done right

Catches NIST SHA3 used where Ethereum expects Keccak-256. Useful when a selector, signature or storage slot comes out wrong.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add affaan-m/ECC --skill nodejs-keccak256 -a claude-code
Open on GitHub

What nodejs-keccak256 does

Node ships crypto.createHash('sha3-256'), which is NIST SHA3. Ethereum uses Keccak-256. Same input, different digest, and Node gives you no warning. Function selectors, event topics, EIP-712, Merkle trees and storage slots break quietly — the code runs, the values are wrong.

The skill walks through hashing with ethers v6, viem and web3.js: keccak256, toUtf8Bytes, solidityPackedKeccak256, id, AbiCoder. It includes patterns for a selector, a typeHash, a mapping slot and an address derived from a public key. Two grep commands are there for auditing a repo: one for createHash.*sha3, one for every keccak256 outside node_modules.

Worth installing if your project mixes JS or TS with Ethereum. If hashing only happens in Solidity, or you never hand-roll helpers, it changes nothing for you.

What it helps with

  • find createHash('sha3-256') calls across a codebase
  • compute a function selector and event topic correctly
  • derive a storage slot for a mapping
  • turn a public key into an Ethereum address
  • audit EIP-712 and Merkle helpers for Keccak-256

Example prompts for the agent

  • check where this project hashes Ethereum data with Node crypto
  • compute the selector for `transfer(address,uint256)` with ethers
  • write a mapping slot helper using `AbiCoder`

How to install nodejs-keccak256

1Skills CLI (Vercel)

npx skills add affaan-m/ECC --skill nodejs-keccak256 -a claude-code

2Manually: put the files in place

~/.claude/skills/nodejs-keccak256/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/nodejs-keccak256/

From the same set146

The whole set →
video-editing affaan-m AI-assisted workflow for editing, trimming, and enriching real footage. Connects raw recordings with FFmpeg cuts, Remotion overlays, and ElevenLabs voiceovers. Claude Code CX Codex Cursor +1 6,500installs docker-patterns affaan-m A skill with Dockerfile and Docker Compose patterns: local dev stacks, networking, volumes, container hardening. Claude Code CX Codex Cursor +1 6,300installs frontend-patterns affaan-m A skill for React and Next.js work: component patterns, state, data fetching, and render performance. Use it when building or reviewing UI. Claude Code CX Codex Cursor +1 5,900installs backend-patterns affaan-m A skill with backend patterns for Node.js, Express and Next.js API routes: layering, caching, transactions, error handling. Claude Code CX Codex Cursor +1 5,900installs coding-standards affaan-m Baseline cross-project coding conventions for naming, immutability, and clean code principles. Useful for code reviews and refactoring. Claude Code CX Codex Cursor +1 5,600installs api-design affaan-m Provides REST API design standards covering resource naming, status codes, pagination, and error payloads. Use it when creating or auditing API contracts. Claude Code CX Codex Cursor +1 5,500installs rust-testing affaan-m A skill for writing Rust tests: unit, integration, async, property-based, mocks and coverage. Useful when the project runs on TDD. Claude Code CX Codex Cursor +1 5,500installs laravel-security affaan-m This skill reviews Laravel authentication, Eloquent safety, CSRF, XSS, APIs, and production settings. Use it for security reviews or deployment checks. Claude Code CX Codex Cursor +1 5,400installs

Similar

dotnet-best-practices official github Guides reviews and edits of selected .NET/C# code with project rules for structure, DI, tests, logging and security. Use it when changing an existing solution. GitHub Copilot 15,752installs migrate-to-shoehorn Matt Pocock Replaces as type assertions in tests with helpers from @total-typescript/shoehorn. Use it when tests need partial objects or deliberately invalid data. Claude Code 475,388installs write-swift emilkowalski This skill guides Swift coding, reviews, and migrations using the language’s current practices. Use it to investigate concurrency errors, hangs, data races, or retain cycles. Claude Code CX Codex Cursor +1 117,500installs megacave JuliusBrussee Switches agent responses to Classical Chinese (wenyan) to reduce terminal output. Activated via /megacave or /caveman wenyan. Claude Code CX Codex Cursor +1 24,400installs find-docs upstash Pulls up-to-date documentation, API references and code examples for any library through the Context7 CLI. Useful when the model's training data lags behind the API. Claude Code CX Codex Cursor +1 9,400installs typescript-advanced-types Seth Hobson Guides an agent through advanced TypeScript types, from generics to conditional and mapped types. Use it for typed libraries, API clients, or strict configuration objects. Claude Code CX Codex Cursor 92,169installs smart-explore thedotmack Uses tree-sitter to map code structure and find symbols. Useful when you need to explore a codebase without loading every full file. Claude Code CX Codex Cursor +1 7,300installs

Questions about nodejs-keccak256

How do I install nodejs-keccak256 in Claude?

Run npx skills add affaan-m/ECC --skill nodejs-keccak256 -a claude-code. The skill lands at ~/.claude/skills/nodejs-keccak256/SKILL.md.

What does nodejs-keccak256 do?

It explains the gap between NIST SHA3 and Ethereum Keccak-256 and shows hashing through ethers, viem and web3.js. It also gives grep commands to find risky spots in your repo.

Why is `crypto.createHash('sha3-256')` wrong for Ethereum?

Node implements standardized NIST SHA3, while Ethereum uses Keccak-256. The two produce different output for the same input, with no warning.

Source text

SKILL.md · MIT
---
name: nodejs-keccak256
description: Prevent Ethereum hashing bugs in JavaScript and TypeScript. Node's sha3-256 is NIST SHA3, not Ethereum Keccak-256, and silently breaks selectors, signatures, storage slots, and address derivation. Use when hashing for Ethereum in JavaScript or TypeScript, or when a selector, signature, storage slot, or derived address is wrong.
metadata:
  version: "1.0.0"
  origin: ECC direct-port adaptation
---

# 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.

```javascript
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

```typescript
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

```typescript
import { keccak256, toBytes } from 'viem';

const hash = keccak256(toBytes('hello'));
```

### web3.js

```javascript
const hash = web3.utils.keccak256('hello');
const packed = web3.utils.soliditySha3(
  { type: 'address', value: '0x742d35Cc6634C0532925a3b8D4C9B569890FaC1c' },
  { type: 'uint256', value: '100' },
);
```

### Common patterns

```typescript
import { id, keccak256, AbiCoder } from 'ethers';

const selector = id('transfer(address,uint256)').slice(0, 10);
const typeHash = keccak256(toUtf8Bytes('Transfer(address from,address to,uint256 value)'));

function getMappingSlot(key: string, mappingSlot: number): string {
  return keccak256(
    AbiCoder.defaultAbiCoder().encode(['address', 'uint256'], [key, mappingSlot]),
  );
}
```

### Address from public key

```typescript
import { keccak256 } from 'ethers';

function pubkeyToAddress(pubkeyBytes: Uint8Array): string {
  const hash = keccak256(pubkeyBytes.slice(1));
  return '0x' + hash.slice(-40);
}
```

### Audit your codebase

```bash
grep -rn "createHash.*sha3" --include="*.ts" --include="*.js" --exclude-dir=node_modules .
grep -rn "keccak256" --include="*.ts" --include="*.js" . | grep -v node_modules
```

## Rule

For Ethereum contexts, never use `crypto.createHash('sha3-256')`. Use Keccak-aware helpers from `ethers`, `viem`, `web3`, or another explicit Keccak implementation.

© affaan-m · MIT · affaan-m/ECC

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor