一键导入
u32-assert-before-u32-ops
Use when writing MASM `u32*` instructions on values from user input or untrusted sources — ensure the operands are valid u32s first.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when writing MASM `u32*` instructions on values from user input or untrusted sources — ensure the operands are valid u32s first.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Enforce type-signature conventions for public Miden Assembly (.masm) procedures. Use when adding, editing, or reviewing a `pub proc` signature — parameter and return types, semantic type aliases, struct/array/tuple types, and how the signature maps onto the operand stack and the doc-comment Inputs/Outputs.
Enforce inline commenting conventions for Miden Assembly (.masm) files. Use when editing, reviewing, or creating .masm files.
Enforce doc comment conventions for Miden Assembly (.masm) procedures. Use when editing, reviewing, or creating .masm procedures, especially when documenting inputs, outputs, panic conditions, or invocation types.
Use when writing kernel, account, or note MASM code that reads from or writes to the advice provider (advice stack / advice map) — validate advice data.
Use when writing a Rust test that exercises a failure path or a MASM test that expects a `panic` / `assert` — assert on the specific expected error variant or error code.
Use when writing or reviewing MASM hot paths — prefer the cheaper equivalent instruction: `neq.0` over `gt.0` for non-zero checks, `cdrop` over an `if/else` selecting between two values, `dup.N` over `loc_load` for a value still on the stack, `eqw` over element-wise word comparison, `u32gt`/`u32lt` over generic `gt`/`lt` on known-u32 operands.
| name | u32-assert-before-u32-ops |
| description | Use when writing MASM `u32*` instructions on values from user input or untrusted sources — ensure the operands are valid u32s first. |
MASM's u32* instructions assume their operands are valid u32 values (i.e. fit in 32 bits). Operating on a non-u32 value silently produces garbage or traps with a generic message.
Before applying any u32* instruction to a value that is not already known to be a valid u32 (e.g. it came from the stack as input, was read from memory, or arose from a non-u32 arithmetic op), assert the bound:
u32assert # one value
u32assert2 # two top values
u32assert4 # four top values
If the operand is already known-valid (just produced by another u32* op, or a value loaded from a slot whose layout is u32 by construction), skip the assert.
u32* instructions are tuned for the precondition that operands fit in 32 bits, and the VM does not check it for you. Skipping u32assert* lets a non-u32 input silently produce a wrong result or trap uninformatively; the assert gives the bug a named failure mode.
# Good: assert u32 before the u32 op
u32assert.err=ERR_VALUE_NOT_U32
u32add
# Good: both operands at once
u32assert2.err=ERR_VALUES_NOT_U32
u32lt
# Bad: u32 op on untrusted input
u32add # one operand could be >2^32; silently wraps or traps