kkrt-labs / cairo-vm-ts

A typescript implementation of the Cairo VM
Apache License 2.0
20 stars 13 forks source link

feat: Add proper felt division #50

Closed zmalatrax closed 6 months ago

zmalatrax commented 6 months ago

Solves #49

Add Felt division (modular multiplicative inverse) based on the binary exponentiation.

Identified a bug in the test case "should deduce op1 for assert eq res logic add", using the oplogic "op0 * op1" instead of "op0 + op1". It confirms that string types are not suitable to perform this logic and should rather use enum/const objects, which will be addressed in another PR.

Haven't spotted this bug before, as div was an integer division 3n - 2n == 1n and 3n / 2n == 1n, test succeeding in both cases