Skip to content

interesting-guy/cofhe-dev-skill

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cofhe-dev — make your AI fluent in FHE

A Claude Skill that teaches Claude (Claude Code, claude.ai, or the API) how to write correct confidential smart contracts with Fhenix CoFHE — first try, no leaked secrets, no ACLNotAllowed surprises.

Why this exists

FHE development is not normal Solidity with extra steps. It's a different programming model:

  • Encrypted values are handles, not data
  • Everything is async — results don't exist in the same transaction
  • Access control is per-handle, and every operation creates a new handle with no permissions
  • You cannot branch on encrypted data — no if, no require
  • Reverting on overflow would leak information, so arithmetic silently wraps

An AI assistant that doesn't know these rules will happily generate contracts that compile, deploy, and then either brick on the second transaction or quietly leak the secrets they were supposed to protect. This skill encodes the rules, the patterns, and the footguns so vibe-coding a confidential dApp actually works.

It found bugs the docs don't mention

While stress-testing this skill against realistic builds, its own review checklist surfaced issues that (as of writing) aren't documented anywhere official:

  1. The handle-swap vulnerability — if your publishDecryptResult wrapper accepts a ctHash as a parameter without binding it to the contract's stored handle, anyone can submit a valid Threshold Network signature for a different publicly-decryptable handle and swap your results (e.g., flip an election's yes/no tallies). Fix: require(euintXX.unwrap(param) == euintXX.unwrap(stored)).
  2. The uninitialized-handle revert — a never-written mapping(address => euint64) entry is handle 0; any FHE op on it reverts. A new user's first interaction with your token bricks unless you guard reads with a pre-allowed encrypted ZERO fallback.
  3. Modulo bias in the docs' own randomness recipeFHE.rem(random, N) is slightly biased unless N divides the type max. Fine for games, not for anything where uniformity is consequential.

All three are encoded as patterns in the skill.

What's inside

cofhe-dev/
├── SKILL.md                          # mental model + 13-item gotcha checklist
└── references/
    ├── contract-patterns.md          # FHE.sol: types, ops, ACL, decrypt flow,
    │                                 # randomness, anti-patterns, 9-pt review checklist
    ├── client-sdk.md                 # @cofhe/sdk: setup, encrypt, decrypt, permits,
    │                                 # async UX states, full cofhejs migration guide
    └── setup-testing-errors.md       # Hardhat/Foundry setup, mock-first workflow,
                                      # all error families + "my decryption is stuck"

Covers the current stack: @cofhe/sdk 0.5.x (not deprecated cofhejs), the allowPublic + publishDecryptResult decryption flow (not deprecated FHE.decrypt), ERC-7984/FHERC20, and Sepolia / Arbitrum Sepolia / Base Sepolia.

Install

Claude Code

# personal (all projects)
git clone https://github.com/interesting-guy/cofhe-dev-skill.git
cp -r cofhe-dev-skill/cofhe-dev ~/.claude/skills/

# or project-scoped (shared with your team via the repo)
cp -r cofhe-dev-skill/cofhe-dev your-project/.claude/skills/

Then just ask: "build me a sealed-bid auction where bids stay encrypted" — the skill triggers automatically.

claude.ai (Pro/Max/Team/Enterprise)

Download cofhe-dev.skill from this repo and upload it via Settings → Capabilities → Skills.

Claude API / Agent SDK

Load the cofhe-dev/ folder contents into your agent's skills directory per the Agent Skills docs.

See it work

The examples/ folder contains unedited outputs from skill test runs:

  • PrivateVote.sol — encrypted yes/no voting, tallies hidden until close, permissionless settlement, handle-binding fix applied
  • ShieldedToken.sol — ERC20 shield/unshield wrapper with clamped confidential transfers and the two-phase unshield reveal
  • witness-migration.ts — a real cofhejs → @cofhe/sdk migration

Contributing

Found a case where Claude-with-this-skill got CoFHE wrong? That's the most valuable thing you can give this repo. Open an issue with the prompt, the wrong output, and what correct looks like. Field failures drive every release.

Disclaimer

Not affiliated with or endorsed by Fhenix (just built by a badge holder who likes the tech). Example contracts are educational, not audited — don't deploy them to guard real value. CoFHE is testnet-only as of June 2026; APIs move fast, and the skill instructs Claude to verify against live docs when in doubt.

License

MIT

About

No description or website provided.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors