Skip to content

Lyd/underflow constraints#494

Open
lydiagarms wants to merge 2 commits into
masterfrom
lyd/underflowConstraints
Open

Lyd/underflow constraints#494
lydiagarms wants to merge 2 commits into
masterfrom
lyd/underflowConstraints

Conversation

@lydiagarms

@lydiagarms lydiagarms commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Currently in the circuits in Starlight, there are no checks to prevent underflows. Say we have a decrementation:
c -= a, we do not currently check that c > a first in the circuits. This means that c could underflow to the field modulus minus a. In contracts like Escrow.zol, this will lead to a user having a very high balance.

Changes

  • Changes to the circuit boilerplate for decrementation of unknown variables.
  • Changes to toCircuit.ts to add in underflow guards.

Checklist

  • Tests added/updated
  • CI passes
  • No secrets/keys committed
  • Docs updated (if needed)
  • Backwards compatible (or noted breaking change)

How to test

  1. Compile the Underflows.zol contract and check the circuits for underflow guards

Screenshots / Evidence (if applicable)

NA

@lydiagarms lydiagarms force-pushed the lyd/underflowConstraints branch 2 times, most recently from 7ca3ae7 to 9b4e2b6 Compare July 1, 2026 17:08
@lydiagarms lydiagarms force-pushed the lyd/underflowConstraints branch from 9b4e2b6 to 8df4208 Compare July 2, 2026 13:26
@lydiagarms lydiagarms marked this pull request as ready for review July 2, 2026 13:26
@lydiagarms lydiagarms requested review from SwatiEY and Wei-257 July 2, 2026 13:55
@lydiagarms lydiagarms force-pushed the lyd/underflowConstraints branch from 1fd1727 to 62d98ca Compare July 2, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant