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

feat(hints): NewHint#60 #1052

Merged
merged 31 commits into from
Apr 26, 2023
Merged
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e4c5d4f
Add hint code
pefontana Apr 21, 2023
78cae1f
Add cairo_programs/compute_slope_v2.cairo
pefontana Apr 21, 2023
483aaa0
add hints code
pefontana Apr 21, 2023
91b167c
implement compute_slope_v2
pefontana Apr 21, 2023
8a06f9b
Implement VERIFY_ZERO_V3
pefontana Apr 24, 2023
9134ffb
Add verify_zero_v3 unit tests
pefontana Apr 24, 2023
792bf12
Add COMPUTE_SLOPE_V2 unit test
pefontana Apr 24, 2023
2b4223f
Merge branch 'main' into hint-62
pefontana Apr 24, 2023
732b52e
Update CHANGELOG.md
pefontana Apr 24, 2023
ba05184
cargo clippy
pefontana Apr 24, 2023
9a7b7f3
Implement hint
fmoletta Apr 25, 2023
1478f62
fmt
fmoletta Apr 25, 2023
0895a4c
Merge remote-tracking branch 'origin/hint-62' into new-hint-60
fmoletta Apr 25, 2023
2a1d1bb
Add changelog entry
fmoletta Apr 25, 2023
6c77b21
Merge branch 'main' into hint-62
pefontana Apr 25, 2023
c13f800
Add integration test
pefontana Apr 25, 2023
9e7d029
cargo clippy
pefontana Apr 25, 2023
a2fe1ab
Merge branch 'main' into hint-62
pefontana Apr 25, 2023
cf32020
Update cairo_run_test.rs
fmoletta Apr 25, 2023
35e10d2
Merge branch 'main' into new-hint-60
fmoletta Apr 25, 2023
ecb467b
Merge branch 'new-hint-60' of github.com:lambdaclass/cairo-rs into ne…
fmoletta Apr 25, 2023
7a6c23f
Merge remote-tracking branch 'origin/hint-62' into new-hint-60
fmoletta Apr 25, 2023
6a463be
Fix changelog
fmoletta Apr 25, 2023
3d017cc
Merge branch 'main' of github.com:lambdaclass/cairo-rs into new-hint-60
fmoletta Apr 26, 2023
a8a409a
Remove duplicated test
fmoletta Apr 26, 2023
38d65ae
fixes
fmoletta Apr 26, 2023
29e6991
Fix fast_ec_add_assign_new_y
fmoletta Apr 26, 2023
ead88e9
Fix tests
fmoletta Apr 26, 2023
d87bb37
Clippy
fmoletta Apr 26, 2023
a4220de
Merge branch 'main' into new-hint-60
Oppen Apr 26, 2023
714056f
Merge branch 'main' into new-hint-60
fmoletta Apr 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' of github.com:lambdaclass/cairo-rs into new-hint-60
fmoletta committed Apr 26, 2023
commit 3d017cc50473470ba8b7292cdbd9af1aa1bff88a
132 changes: 129 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -20,6 +20,115 @@
%}
```

* Implement hint on 0.6.0.json whitelist [#1044](https://github.com/lambdaclass/cairo-rs/pull/1044):

`BuiltinHintProcessor` now supports the following hints:

%{
ids.a_lsb = ids.a & 1
ids.b_lsb = ids.b & 1
%}

* Implement hint for `starkware.cairo.common.cairo_keccak.keccak._block_permutation` as described by whitelist `starknet/security/whitelists/cairo_keccak.json` [#1046](https://github.com/lambdaclass/cairo-rs/pull/1046)

`BuiltinHintProcessor` now supports the following hint:

```python
%{
from starkware.cairo.common.cairo_keccak.keccak_utils import keccak_func
_keccak_state_size_felts = int(ids.KECCAK_STATE_SIZE_FELTS)
assert 0 <= _keccak_state_size_felts < 100
output_values = keccak_func(memory.get_range(
ids.keccak_ptr_start, _keccak_state_size_felts))
segments.write_arg(ids.output, output_values)
%}
```

* Implement hint on cairo_blake2s whitelist [#1040](https://github.com/lambdaclass/cairo-rs/pull/1040)

`BuiltinHintProcessor` now supports the following hint:

```python
%{
from starkware.cairo.common.cairo_blake2s.blake2s_utils import IV, blake2s_compress

_blake2s_input_chunk_size_felts = int(ids.BLAKE2S_INPUT_CHUNK_SIZE_FELTS)
assert 0 <= _blake2s_input_chunk_size_felts < 100

new_state = blake2s_compress(
message=memory.get_range(ids.blake2s_start, _blake2s_input_chunk_size_felts),
h=[IV[0] ^ 0x01010020] + IV[1:],
t0=ids.n_bytes,
t1=0,
f0=0xffffffff,
f1=0,
)

segments.write_arg(ids.output, new_state)
%}
```

* Implement hint on cairo_blake2s whitelist [#1039](https://github.com/lambdaclass/cairo-rs/pull/1039)

`BuiltinHintProcessor` now supports the following hint:

```python

%{
# Add dummy pairs of input and output.
from starkware.cairo.common.cairo_blake2s.blake2s_utils import IV, blake2s_compress

_n_packed_instances = int(ids.N_PACKED_INSTANCES)
assert 0 <= _n_packed_instances < 20
_blake2s_input_chunk_size_felts = int(ids.BLAKE2S_INPUT_CHUNK_SIZE_FELTS)
assert 0 <= _blake2s_input_chunk_size_felts < 100

message = [0] * _blake2s_input_chunk_size_felts
modified_iv = [IV[0] ^ 0x01010020] + IV[1:]
output = blake2s_compress(
message=message,
h=modified_iv,
t0=0,
t1=0,
f0=0xffffffff,
f1=0,
)
padding = (modified_iv + message + [0, 0xffffffff] + output) * (_n_packed_instances - 1)
segments.write_arg(ids.blake2s_ptr_end, padding)
%}

* Implement hint on `assert_le_felt` for versions 0.6.0 and 0.8.2 [#1047](https://github.com/lambdaclass/cairo-rs/pull/1047):

`BuiltinHintProcessor` now supports the following hints:

```python

%{
from starkware.cairo.common.math_utils import assert_integer
assert_integer(ids.a)
assert_integer(ids.b)
assert (ids.a % PRIME) <= (ids.b % PRIME), \
f'a = {ids.a % PRIME} is not less than or equal to b = {ids.b % PRIME}.'
%}

```

```python

%{
from starkware.cairo.common.math_utils import assert_integer
assert_integer(ids.a)
assert_integer(ids.b)
a = ids.a % PRIME
b = ids.b % PRIME
assert a <= b, f'a = {a} is not less than or equal to b = {b}.'

ids.small_inputs = int(
a < range_check_builtin.bound and (b - a) < range_check_builtin.bound)
%}

```

* Implement hint on ec_recover.json whitelist [#1038](https://github.com/lambdaclass/cairo-rs/pull/1038):

`BuiltinHintProcessor` now supports the following hint:
@@ -151,7 +260,24 @@
* Optimizations for hash builtin [#1029](https://github.com/lambdaclass/cairo-rs/pull/1029):
* Track the verified addresses by offset in a `Vec<bool>` rather than storing the address in a `Vec<Relocatable>`

* Add missing hint on vrf.json lib [#1035](https://github.com/lambdaclass/cairo-rs/pull/1035):
* Add missing hint on vrf.json whitelist [#1056](https://github.com/lambdaclass/cairo-rs/pull/1056):

`BuiltinHintProcessor` now supports the following hint:

```python
%{
from starkware.python.math_utils import ec_double_slope
from starkware.cairo.common.cairo_secp.secp_utils import pack
SECP_P = 2**255-19

# Compute the slope.
x = pack(ids.point.x, PRIME)
y = pack(ids.point.y, PRIME)
value = slope = ec_double_slope(point=(x, y), alpha=42204101795669822316448953119945047945709099015225996174933988943478124189485, p=SECP_P)
%}
```

* Add missing hint on vrf.json whitelist [#1035](https://github.com/lambdaclass/cairo-rs/pull/1035):

`BuiltinHintProcessor` now supports the following hint:

@@ -169,7 +295,7 @@
%}
```

* Add missing hint on vrf.json lib [#1035](https://github.com/lambdaclass/cairo-rs/pull/1035):
* Add missing hint on vrf.json whitelist [#1035](https://github.com/lambdaclass/cairo-rs/pull/1035):

`BuiltinHintProcessor` now supports the following hint:

@@ -184,7 +310,7 @@
%}
```

* Add missing hint on vrf.json lib [#1000](https://github.com/lambdaclass/cairo-rs/pull/1000):
* Add missing hint on vrf.json whitelist [#1000](https://github.com/lambdaclass/cairo-rs/pull/1000):

`BuiltinHintProcessor` now supports the following hint:

Original file line number Diff line number Diff line change
@@ -4,8 +4,17 @@ use super::{
ec_recover_sub_a_b,
},
field_arithmetic::uint384_div,
secp::secp_utils::{SECP_P, SECP_P_V2},
vrf::{fq::uint512_unsigned_div_rem, inv_mod_p_uint512::inv_mod_p_uint512},
secp::{
ec_utils::{
compute_slope_and_assing_secp_p, ec_double_assign_new_y, ec_mul_inner,
ec_negate_embedded_secp_p, ec_negate_import_secp_p,
},
secp_utils::{ALPHA, ALPHA_V2, SECP_P, SECP_P_V2},
},
vrf::{
fq::{inv_mod_p_uint256, uint512_unsigned_div_rem},
inv_mod_p_uint512::inv_mod_p_uint512,
},
};
use crate::hint_processor::builtin_hint_processor::secp::ec_utils::ec_double_assign_new_x;
use crate::{
@@ -43,10 +52,8 @@ use crate::{
secp::{
bigint_utils::{bigint_to_uint256, hi_max_bitlen, nondet_bigint3},
ec_utils::{
compute_doubling_slope, compute_slope, compute_slope_and_assing_secp_p, di_bit,
ec_double_assign_new_x, ec_double_assign_new_y, ec_mul_inner, ec_negate,
fast_ec_add_assign_new_x, fast_ec_add_assign_new_y, import_secp256r1_p,
quad_bit,
compute_doubling_slope, compute_slope, di_bit, fast_ec_add_assign_new_x,
fast_ec_add_assign_new_y, import_secp256r1_p, quad_bit,
},
field_utils::{
is_zero_assign_scope_variables, is_zero_assign_scope_variables_external_const,
Original file line number Diff line number Diff line change
@@ -32,6 +32,14 @@ lazy_static! {
"57896044618658097711785492504343953926634992332820282019728792003956564819949"
)
.unwrap();

pub(crate) static ref ALPHA: BigInt = BigInt::zero();

pub(crate) static ref ALPHA_V2: BigInt = BigInt::from_str(
"42204101795669822316448953119945047945709099015225996174933988943478124189485"
)
.unwrap();

// BASE = 2**86
pub(crate) static ref BASE: BigUint = BigUint::from_str(
"77371252455336267181195264"
You are viewing a condensed version of this merge commit. You can view the full changes here.