-
Notifications
You must be signed in to change notification settings - Fork 50
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
Add Core Hints to the VM #36
Labels
Comments
Hey @rodrigo-pino would love to start by an easy one like |
rodrigo-pino
added
enhancement
New feature or request
help wanted
Extra attention is needed
vm hint
Related with VM hints
and removed
help wanted
Extra attention is needed
labels
Sep 4, 2023
Hey @rodrigo-pino can i try |
hey @rodrigo-pino, I'm down to take |
Closed
Open
Just added three more core hints to be implemented |
Hi @cicr99 how are you? I would like to help with "U256InvModN" if it's free 🫡 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We need to define all possible Hints applicable a program execution. The following is a list extracted from the Rust CASM compiler which defines all Core hints. Hints will be implemented in pkg/hintrunner/hint.go.
AllocSegment
andTestLessThan
are already implemented as use examples. Tools that allow abstractions from the VM have been implemented as well, so minimal understanding of the VM is required. Of course if the hint directly affects the VM this may not apply.The workflow is as follows: a contributor asks to get assigned one of the not-implemented hints and a dedicated issue is created. Once the issue is solved, the hint is marked accordingly.
Core Hints
dst: CellRef
lhs: ResOperand, rhs: ResOperand, dst: CellRef
lhs: ResOperand, rhs: ResOperand, dst: CellRef
lhs: ResOperand, rhs: ResOperand, high: CellRef, low: CellRef
lhs: ResOperand, rhs: ResOperand, quotient: CellRef, remainder: CellRef
dividend0: ResOperand, dividend1: ResOperand, divisor0: ResOperand, divisor1: ResOperand, quotient0: CellRef, quotient1: CellRef, remainder0: CellRef, remainder1: CellRef
name
0 is the least significant limb.dividend0: ResOperand, dividend1: ResOperand, dividend2: ResOperand, dividend3: ResOperand, divisor0: ResOperand, divisor1: ResOperand, quotient0: CellRef, quotient1: CellRef, quotient2: CellRef, quotient3: CellRef, remainder0: CellRef, remainder1: CellRef
name
0 is the least significant limb.value: ResOperand, dst: CellRef
value_low: ResOperand, value_high: ResOperand, sqrt0: CellRef, sqrt1: CellRef, remainder_low: CellRef, remainder_high: CellRef, sqrt_mul_2_minus_remainder_ge_u128: CellRef
value - sqrt**2
. Lastly it checks whether2*sqrt - remainder >= 2**128
.value: ResOperand, scalar: ResOperand, max_x: ResOperand, x: CellRef, y: CellRef
x
andy
such thatx * scalar + y = value
andx <= max_x
.segment_arena_ptr: ResOperand
dict_ptr: ResOperand, key: ResOperand
dict_ptr: ResOperand, value: ResOperand
dict_end_ptr: ResOperand, dict_index: CellRef
dict_accesses: ResOperand, ptr_diff: ResOperand, n_accesses: ResOperand, big_keys: CellRef, first_key: CellRef
range_check_ptr: ResOperand
should_skip_loop: CellRef
index_delta_minus1: CellRef
should_continue: CellRef
next_key: CellRef
range_check_ptr: ResOperand, a: ResOperand, b: ResOperand
skip_exclude_a_flag: CellRef
skip_exclude_b_minus_a: CellRef
x: CellRef, y: CellRef
val: ResOperand, sqrt: CellRef
val
, ifval
is a quadratic residue, and of3 * val
otherwise. Since 3 is not a quadratic residue, exactly one ofval
and3 * val
is a quadratic residue (unlessval
is 0). This allows proving thatval
is not a quadratic residue.start: ResOperand, end: ResOperand
size: ResOperand, dst: CellRef
TestLessThanOrEqualAddress
hint #628lhs: ResOperand, rhs: ResOperand, dst: CellRef
U256InvModN
hint #630b0: ResOperand, b1: ResOperand, n0: ResOperand, n1: ResOperand, g0_or_no_inv: CellRef, g1_option: CellRef, s_or_r0: CellRef, s_or_r1: CellRef, t_or_k0: CellRef, t_or_k1: CellRef
n_add_mods: ResOperand, add_mod_builtin: ResOperand, n_mul_mods: ResOperand, mul_mod_builtin: ResOperand
The text was updated successfully, but these errors were encountered: