-
Notifications
You must be signed in to change notification settings - Fork 56
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Bug Report
stark-felt version: 0.0.3
commit: ea52b64
Behavior:
The inverse_mod
functions returns an invalid value: 3.inverse_mod(5)
returns 4 instead of 2.
Indeed 3 * 4 == 12
and 12 % 5 == 2 != 1
.
Other information:
I found this writing documentation (see #10). If you download that PR and run cargo test
, you'll get the error.
Currently, the only test for inverse_mod
is this one:
#[test]
fn inverse_mod_in_range(x in nonzero_felt(), p in nonzero_felt()) {
let nzp = NonZeroFelt(p.0);
prop_assert!(x.inverse_mod(&nzp) <= Some(Felt::MAX));
prop_assert!(x.inverse_mod(&nzp) < Some(p));
}
Which only checks whether the resulting inverse is less than p
. It should probably check something like x.inverse_mod(&nzp).mul_mod(x, &nzp) == 1
.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working