Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A bug in the functionceil #15

Open
DOFYPXY opened this issue Oct 18, 2022 · 0 comments
Open

A bug in the functionceil #15

DOFYPXY opened this issue Oct 18, 2022 · 0 comments

Comments

@DOFYPXY
Copy link

DOFYPXY commented Oct 18, 2022

If the input of the ceil function is an integer x(that is, x modulo FRACT_PART is equal to 0), it will return x+1. But I think this does not match the usual semantics of ceil function in mathematics.

The bug is found by Medjai, a symbolic execution tool for the Cairo program. The spec we write for ceil is:

func ceil_spec{range_check_ptr}():
    alloc_locals
    let (local x) = SymbolicMath64x61()
    let (local res) = Math64x61.ceil(x)
    verify_le_signed(x, res)
    verify_lt_signed(res - Math64x61.ONE, x)
    let (_, rem) = signed_div_rem(res, Math64x61.ONE, Math64x61.BOUND)
    medjai_assert_eq_felt(rem, 0)
    return ()
end
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

No branches or pull requests

1 participant