npx skills add smithery/noir-lang --skill noir-optimize-acir
noir-lang/noir · Archived
noir-optimize-acir
Workflow for measuring and optimizing the ACIR circuit size of a constrained Noir program. Use when asked to optimize a Noir program's gate count or circuit size.
Installation
npx skills add noir-lang/noir --skill noir-optimize-acir
Stronger alternatives
This repository is archived — consider an actively maintained alternative.
Guidelines for writing idiomatic, efficient Noir programs. Use when writing or reviewing Noir c…
46 installsReproduce an AST-fuzzer failure locally from its CI seed. Use when a CI fuzzer test (e.g. `pass…
38 installsWorkflow for debugging SSA pass semantic preservation using the noir-ssa CLI. Use when a progra…
32 installsEnd-to-end workflow for debugging SSA fuzzer failures from CI. Extracts a reproduction case fro…
31 installsSimilar popular skills
Related neighbors and high-traction skills in the same topics — useful to compare before installing.
Browser automation CLI for AI agents. Use when the user needs to interact with websites, includ…
810.4K installsReview UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "chec…
617.3K installsBuild, deploy, evaluate, optimize, fine-tune, and manage Microsoft Foundry agents, models, and …
576.5K installsArchitect and provision enterprise Azure infrastructure from workload descriptions. For cloud a…
402.8K installsAlso in this package
Other skills from noir-lang/noir.
npx skills add noir-lang/noir
More details
Agent compatibility
Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.
Also listed on
Alternate registries and mirrors of this skill.
Repository health
master
Package contents
Files included with this skill beyond the listing page.
-
skill md
SKILL.md3,212 B -
docs
SUMMARY.md188 B
History
- First seen on skills.sh
- First recorded snapshot · 38 installs
SKILL.md
ACIR Optimization Loop
This workflow targets ACIR circuit size for constrained Noir programs. It does not apply to unconstrained (Brillig) functions — Brillig runs on a conventional VM where standard profiling and algorithmic improvements apply instead, and bb gates won't reflect Brillig performance.
Measuring Circuit Size
Binary projects
Compile the program and measure gate count with:
nargo compile && bb gates -b ./target/<package>.json
Library projects
Libraries cannot be compiled with nargo compile. Instead, mark the functions you want to measure with #[export] and use nargo export:
nargo export && bb gates -b ./export/<function_name>.json
Artifacts are written to the export/ directory and named after the exported function (not the package).
If bb is not available, ask the user for their backend's equivalent command. Other backends should have a similar CLI interface.
The output contains two fields:
circuit_size: the actual gate count after backend compilation. This determines proving time, which is generally the bottleneck.aciropcodes: number of ACIR operations. This affects execution time (witness generation). A change can reduce opcodes without affecting circuit size or vice versa — both matter, but prioritizecircuitsizewhen they conflict.
Always record a baseline of both metrics before making changes.
Optimization Loop
- Baseline: compile and record
circuit_size. - Apply one change at a time.
- Recompile and measure: compare
circuit_sizeto the baseline. - Revert if worse: if
circuit_sizeincreased or stayed the same, undo the change. Not every "optimization" helps — the compiler may already handle it, or the overhead of the new approach may outweigh the savings. - Repeat from step 2 with the next candidate change.
What to Try
Candidate optimizations roughly ordered by impact:
- Hint and verify: replace expensive in-circuit computation with an unconstrained hint and constrained verification. This is the highest-impact optimization for most programs.
- Reduce what you hint: if you're hinting intermediate values (selectors, masks, indices), see if you can hint only the final result and verify it directly.
- Hoist assertions out of branches: replace
if c { asserteq(x, a) } else { asserteq(x, b) }withassert_eq(x, if c { a } else { b }). - Simplify comparisons: inequality checks (
<,<=) cost more than equality (==). But don't introduce extra state to avoid them — measure first.
What Not to Try
- Don't hint division or modular arithmetic: the compiler already injects unconstrained helpers for these.
- Don't hand-roll conditional selects:
if/elseexpressions compile to the same circuit asc * (a - b) + b. - Don't replace
<=with flag tracking without measuring: adding mutable state across loop iterations can produce more gates than a simple comparison.