-
Notifications
You must be signed in to change notification settings - Fork 164
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
[Bug] Observed discrepancy in the behavior of the compute_doubling_slope
function
#1877
Comments
Yes, negative limbs are possible: |
Hi @whichqua! Talking about you question: Yes, limbs can be negative. You can check BigInt in Python VM for references on that. |
I am not sure. I can spend a little more time on this but it might be good to have pointers on what to check. |
How are you compiling and running that program? |
Compiling via
For running I was using run_program_simple fn run_program_simple(data: &[u8]) {
run_program(data, false, None, None, None)
} |
@FrancoGiachetta any updates? |
Hi @whichqua! %{
from starkware.cairo.common.cairo_secp.secp_utils import SECP_P, pack
q, r = divmod(pack(ids.val, PRIME), SECP_P)
assert r == 0, f"verify_zero: Invalid input {ids.val.d0, ids.val.d1, ids.val.d2}."
ids.q = q % PRIME
%} The problem here is that, to mimic the divmod inside the hint from rust, we use div_rem: pub fn verify_zero(
vm: &mut VirtualMachine,
exec_scopes: &mut ExecutionScopes,
ids_data: &HashMap<String, HintReference>,
ap_tracking: &ApTracking,
secp_p: &BigInt,
) -> Result<(), HintError> {
exec_scopes.insert_value("SECP_P", secp_p.clone());
let val = Uint384::from_var_name("val", vm, ids_data, ap_tracking)?.pack86();
let (q, r) = val.div_rem(&secp_p);
if !r.is_zero() {
return Err(HintError::SecpVerifyZero(Box::new(val)));
}
insert_value_from_var_name("q", Felt252::from(&q), vm, ids_data, ap_tracking)
} An so Running the example above with this little change should provide with same result in both VMs. |
@FrancoGiachetta I will look at the hint at hand, and get back! Thanks for your speedy response and PR |
Describe the bug
When investigating a discrepancy in the behavior of the
compute_doubling_slope
function, I was able to isolate a potential bug. The issue arises when compiling and running the following Cairo program:To Reproduce
Compile and run the program with both VMs
Rust VM: The program runs successfully without any issues.
Python VM: The program fails with the following error:
Expected behavior
Both VMs should behave the same way.
What version/commit are you on?
Rust version: 2.0.0-rc0
Python version: 0.13.2
Additional context
compute_slope
function from the Rust VM implementation.Relevant PRs
#1706
#1829
The text was updated successfully, but these errors were encountered: