Kani harness gen
Skill Yue-Zhou1/zkcrypto-audit/plugins/evidence-and-tooling/skills/kani-harness-gen
Generate Kani proof harnesses for Rust crypto code. User-triggered only — never auto-invoked by the audit flow. Produces formal verification evidence for crypto-fp-check.From its SKILL.md
npx -y skills add Yue-Zhou1/zkcrypto-audit --skill kani-harness-genAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 2 stars2 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
3.5 KB, 773 tokens by cl100k_base, as published. Nobody here has run it
kani-harness-gen
Generate #[kani::proof] harnesses for formal verification of Rust cryptographic code.
This skill is user-triggered only. It must never be auto-invoked by the
audit router or any other skill. It consumes significant computation resources
(default timeout: 5 minutes per harness via KANI_TIMEOUT_SECONDS).
When to Use
- User explicitly requests Kani verification
- User invokes this skill by name
- A Phase 2 finding needs stronger formal proof beyond the standard compilable PoC test
When NOT to Use
- Never auto-trigger from audit flow
- Never run without explicit user request
- Code is not Rust
- cargo-kani is not installed (detect and warn)
Prerequisites
Before generating harnesses, verify cargo-kani is available:
cargo kani --version 2>/dev/null || echo "ERROR: cargo-kani not installed. Install from https://github.com/model-checking/kani"
If not installed, inform the user and stop.
Core Harness Categories
- Field arithmetic —
a * inverse(a) == 1for all non-zeroa - No-panic — function does not panic for any input within type bounds
- Serialization roundtrip —
deserialize(serialize(x)) == x - Constraint soundness — satisfying witness implies valid statement
- State invariants — API pre/post-conditions and rejection behavior over bounded inputs
Limits
- Kani does not prove constant-time behavior or model timing/microarchitectural side channels.
kani::assumeconstrains input space; it does not provide timing-side-channel guarantees.- For timing analysis, route to
side-channel-auditor(and supporting tools likedudect/ctgrind).
Budget and Fallback Controls
- Override harness timeout with
KANI_TIMEOUT_SECONDS(default300) - Keep unwind bounds explicit in harness code so run cost remains predictable
- Use optional
PROPTEST_CASESfor lightweightproptestfallback checks when Kani is unavailable or too expensive
Workflow
Phase 1: Identify verification targets
- Read the code under audit
- Identify functions with formal-verification-worthy properties
- Read
references/kani-checklist.mdfor pre-generation checks
Phase 2: Generate harnesses
- Read
references/harness-patterns.mdfor templates - Generate
#[kani::proof]functions tailored to the target code - Set appropriate
#[kani::unwind(N)]bounds - Write harnesses to a test file in the target project
Phase 3: Execute and interpret
- Run
cargo kani --harness {name}withKANI_TIMEOUT_SECONDS(default 300 seconds) - If verification succeeds: property holds for all inputs within bounds
- If counterexample found: extract the failing input as PoC evidence
- If Kani is unavailable, run targeted
proptestchecks (bounded byPROPTEST_CASES) and clearly label evidence type - Report results for use by
crypto-fp-check
Output Contract
Produce Kani verification results that include:
- The harness code generated
- The property being verified
- PASS (property holds) or FAIL (counterexample found)
- If FAIL: the counterexample input values for PoC evidence
- The kani::unwind bound used and its coverage implications
Reference Index
What ships with it: 3 files
3.5 KB alongside SKILL.md
agents/
- openai.yaml478 B
references/
- harness-patterns.md1.7 KB
- kani-checklist.md1.3 KB