Skip to content

Commit

Permalink
Merge branch 'main' into hinterror-boxing
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaRedHand committed Jun 1, 2023
2 parents c9b5ef1 + d9784bf commit 8f91da3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

* fix: Handle the deserialization of serde_json::Number with scientific notation (e.g.: Number(1e27)) in felt_from_number function [#1188](https://github.com/lambdaclass/cairo-rs/pull/1188)

* fix: Fix 'as_int' conversion usage in hints `ASSERT_250_BIT` & `SIGNED_DIV_REM` [#1191](https://github.com/lambdaclass/cairo-rs/pull/1191)

* fix: Fix hint `BIGINT_PACK_DIV_MOD` [#1189](https://github.com/lambdaclass/cairo-rs/pull/1189)

* bugfix: Use cairo constants in `ASSERT_250_BIT` hint [#1187](https://github.com/lambdaclass/cairo-rs/pull/1187)

* bugfix: Fix `EC_DOUBLE_ASSIGN_NEW_X_V2` hint not taking `SECP_P` value from the current execution scope [#1186](https://github.com/lambdaclass/cairo-rs/pull/1186)
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,12 @@ This is a list of recommended books to learn how to implement a compiler or an i
#### Basics

- [Intro to zero-knowledge proofs](https://www.youtube.com/watch?v=HUs1bH85X9I)

- [Security and Privacy for Crypto with Zero-Knowledge Proofs](https://www.youtube.com/watch?v=3NL0ThdvWMU)
- [A Hands-On Tutorial for Zero-Knowledge Proofs Series](http://www.shirpeled.com/2018/09/a-hands-on-tutorial-for-zero-knowledge.html)

#### ZK SNARKs

- [What are zk-SNARKs?](https://z.cash/technology/zksnarks/)

- [Vitalik's introduction to how zk-SNARKs are possible](https://vitalik.ca/general/2021/01/26/snarks.html)
- [Vitalik's post on quadratic arithmetic programs](https://medium.com/@VitalikButerin/quadratic-arithmetic-programs-from-zero-to-hero-f6d558cea649)
- [Why and How zk-SNARK Works - Maksym Petkus](https://arxiv.org/abs/1906.07221)
Expand Down
15 changes: 7 additions & 8 deletions src/hint_processor/builtin_hint_processor/math_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,8 @@ pub fn signed_div_rem(
}

let int_value = value.to_signed_felt();
let int_div = div.to_signed_felt();
let int_bound = bound.to_signed_felt();
let int_div = div.to_bigint();
let int_bound = bound.to_bigint();
let (q, r) = int_value.div_mod_floor(&int_div);

if int_bound.abs() < q.abs() {
Expand Down Expand Up @@ -569,13 +569,12 @@ pub fn assert_250_bit(
let shift = constants
.get(SHIFT)
.map_or_else(|| get_constant_from_var_name("SHIFT", constants), Ok)?;
let value = get_integer_from_var_name("value", vm, ids_data, ap_tracking)?;
let value = Felt252::from(
get_integer_from_var_name("value", vm, ids_data, ap_tracking)?.to_signed_felt(),
);
//Main logic
//can be deleted
if value.as_ref() > upper_bound {
return Err(HintError::ValueOutside250BitRange(Box::new(
value.into_owned(),
)));
if &value > upper_bound {
return Err(HintError::ValueOutside250BitRange(Box::new(value)));
}
let (high, low) = value.div_rem(shift);
insert_value_from_var_name("high", high, vm, ids_data, ap_tracking)?;
Expand Down

0 comments on commit 8f91da3

Please sign in to comment.