# Cairo Hashes

> Explain Cairo hashing with Poseidon and Pedersen, Hash/HashState traits, and hashing structs/arrays; use when a request involves computing hashes or deriving Hash in Cairo.

- Skill: `teddyjfpender/cairo-hashes` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add teddyjfpender/cairo-hashes`
- Raw SKILL.md: https://api.skillmd.com/api/skills/teddyjfpender/cairo-hashes/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: teddyjfpender (https://skillmd.com/u/teddyjfpender)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/teddyjfpender/cairo-hashes

---


# Cairo Hashes

## Overview
Guide hashing in Cairo with Poseidon and Pedersen and the core hash traits.

## Quick Use
- Read `references/hashes.md` before answering.
- Pick Poseidon for most Cairo use cases; mention Pedersen for legacy compatibility.
- Use `HashStateTrait` + `update`/`finalize` in examples.

## Response Checklist
- Use `PoseidonTrait::new()` or `PedersenTrait::new(base)` to initialize state.
- Derive `Hash` only if all fields are hashable.
- For arrays, hash a span with `poseidon_hash_span`.

## Example Requests
- "How do I hash a struct in Cairo?"
- "Should I use Pedersen or Poseidon?"
- "Why can't I derive Hash for this struct?"

