0xMiden / 0xMiden/docs

Improve Felt division and field arithmetic documentation across builder docs

Offen
#232 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
documentation
Vorherrschende Sprache
TypeScript
Sterne
10
Forks
50
Ø Merge
22 T. 23 Std.
Gemergte PRs (30 T.)
1

Beschreibung

The docs already mention that Felt division computes the multiplicative inverse in `types.md`, `pitfalls.md`, and `patterns.md`, but the coverage is fragmented and external developers are still getting tripped up by it. Vaibhav from the Inicio team ran into this during PSWAP development, and it required a back-and-forth with Dennis on Slack to clarify.

I think we should improve this in three places:

1. `types.md`: Add a dedicated "Division" subsection with a side-by-side comparison showing the dramatic difference. For evenly divisible numbers (`10 / 2`) the result is the same, but for something like `20 / 3` the Felt result is `6148914689804861447` while u64 gives `6`. Seeing the actual numbers makes the difference click.

2. `pitfalls.md`: Add a Felt division entry with the same Problem/Why/Solution structure as the existing overflow entry. This is arguably a more common pitfall than overflow.

3. `patterns.md`: Expand the one-liner about Felt division into a "When to use Felt vs u64" section. Developers building DeFi need clear guidance on when Felt arithmetic is correct (hashing, commitments) vs when u64 is required (token amounts, proportional calculations). Worth mentioning that `as_u64()` conversion is zero-cost.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.