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) 55, 56 & 57 #1077

Merged
merged 20 commits into from
Apr 28, 2023
Merged

Feat(hints) 55, 56 & 57 #1077

merged 20 commits into from
Apr 28, 2023

Conversation

jpcenteno
Copy link
Contributor

@jpcenteno jpcenteno commented Apr 26, 2023

Feat(hints) 55, 56 & 57

Description

Implement NewHint#55 from vrf.json

from starkware.cairo.common.cairo_secp.secp_utils import pack
SECP_P=2**255-19

x = pack(ids.x, PRIME) % SECP_P

Implement NewHint#56 from vrf.json

from starkware.cairo.common.cairo_secp.secp_utils import pack
SECP_P=2**255-19

value = pack(ids.x, PRIME) % SECP_P

Implement NewHint#57 from vrf.json

SECP_P=2**255-19
from starkware.python.math_utils import div_mod

value = x_inv = div_mod(1, x, SECP_P)

Closes: #979

Checklist

  • Linked to Github Issue
  • Unit tests added
  • Integration tests added.
  • This change requires new documentation.
    • Documentation has been added/updated.
    • CHANGELOG has been updated.

@github-actions
Copy link

github-actions bot commented Apr 26, 2023

Benchmark Results for unmodified programs 🚀

Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 2.522 ± 0.032 2.486 2.581 1.02 ± 0.02
head blake2s_integration_benchmark 2.481 ± 0.026 2.458 2.545 1.00
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 3.136 ± 0.027 3.101 3.176 1.03 ± 0.02
head compare_arrays_200000 3.048 ± 0.042 3.009 3.134 1.00
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 2.439 ± 0.036 2.406 2.534 1.02 ± 0.02
head dict_integration_benchmark 2.399 ± 0.010 2.382 2.412 1.00
Command Mean [s] Min [s] Max [s] Relative
base factorial_multirun 3.775 ± 0.015 3.752 3.807 1.02 ± 0.01
head factorial_multirun 3.694 ± 0.018 3.675 3.721 1.00
Command Mean [s] Min [s] Max [s] Relative
base fibonacci_1000_multirun 3.025 ± 0.008 3.014 3.041 1.03 ± 0.01
head fibonacci_1000_multirun 2.949 ± 0.015 2.935 2.988 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base field_arithmetic_get_square_benchmark 132.2 ± 1.0 130.6 133.7 1.00 ± 0.03
head field_arithmetic_get_square_benchmark 131.6 ± 4.3 129.0 143.8 1.00
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 2.969 ± 0.018 2.951 3.004 1.02 ± 0.01
head integration_builtins 2.925 ± 0.026 2.893 2.986 1.00
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 2.670 ± 0.018 2.645 2.712 1.01 ± 0.01
head keccak_integration_benchmark 2.644 ± 0.019 2.627 2.693 1.00
Command Mean [s] Min [s] Max [s] Relative
base linear_search 3.199 ± 0.015 3.177 3.220 1.01 ± 0.02
head linear_search 3.155 ± 0.065 3.117 3.323 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 2.695 ± 0.008 2.683 2.709 1.01 ± 0.01
head math_cmp_and_pow_integration_benchmark 2.674 ± 0.028 2.649 2.747 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 2.500 ± 0.046 2.477 2.630 1.01 ± 0.02
head math_integration_benchmark 2.469 ± 0.031 2.448 2.549 1.00
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 2.164 ± 0.009 2.151 2.180 1.02 ± 0.01
head memory_integration_benchmark 2.122 ± 0.024 2.102 2.171 1.00
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 2.225 ± 0.010 2.215 2.252 1.01 ± 0.01
head operations_with_data_structures_benchmarks 2.213 ± 0.011 2.195 2.233 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base pedersen 784.6 ± 5.5 779.6 799.0 1.01 ± 0.01
head pedersen 774.3 ± 1.7 771.2 776.0 1.00
Command Mean [s] Min [s] Max [s] Relative
base poseidon_integration_benchmark 1.514 ± 0.019 1.501 1.566 1.01 ± 0.01
head poseidon_integration_benchmark 1.499 ± 0.006 1.488 1.509 1.00
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 2.376 ± 0.011 2.358 2.392 1.01 ± 0.01
head secp_integration_benchmark 2.345 ± 0.010 2.333 2.361 1.00
Command Mean [s] Min [s] Max [s] Relative
base set_integration_benchmark 1.698 ± 0.020 1.684 1.753 1.01 ± 0.01
head set_integration_benchmark 1.680 ± 0.013 1.667 1.713 1.00
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 3.937 ± 0.027 3.909 3.989 1.01 ± 0.01
head uint256_integration_benchmark 3.879 ± 0.007 3.865 3.888 1.00

@codecov
Copy link

codecov bot commented Apr 26, 2023

Codecov Report

Merging #1077 (0aa0819) into main (b3447b5) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff            @@
##             main    #1077    +/-   ##
========================================
  Coverage   98.12%   98.12%            
========================================
  Files          84       85     +1     
  Lines       34492    34618   +126     
========================================
+ Hits        33844    33970   +126     
  Misses        648      648            
Impacted Files Coverage Δ
src/utils.rs 99.43% <ø> (ø)
...int_processor/builtin_hint_processor_definition.rs 99.06% <100.00%> (+<0.01%) ⬆️
.../hint_processor/builtin_hint_processor/vrf/pack.rs 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Also renamed:
 - `ASSIGN_PACK_MOD_SECP_PRIME_TO_X` -> `IS_ZERO_PACK_ED25519`
 - `ASSIGN_PACK_MOD_SECP_PRIME_TO_VALUE` -> `REDUCE_ED25519`
 - `ASSIGN_DIV_MOD_1_X_SECP_PRIME_TO_X_INV_AND_VALUE` -> `IS_ZERO_PACK_ED25519`
@MegaRedHand MegaRedHand marked this pull request as ready for review April 28, 2023 14:59
@MegaRedHand MegaRedHand self-assigned this Apr 28, 2023
Copy link
Collaborator

@pefontana pefontana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one!

- fix: `test_reduce_ed25519` wasn't being called in main of reduce.cairo
- don't call `add_segments` macro when using `segments`
- use `check_scope` instead of manual `assert_eq`s
- change `run_program_simple_with_memory_holes(..., 0)` -> `run_program_simple`
Also allow trailing commas in `scope` macro
@MegaRedHand MegaRedHand added the whitelisted-hint Implementation of hint on whitelist directory label Apr 28, 2023
@MegaRedHand MegaRedHand enabled auto-merge April 28, 2023 18:43
@MegaRedHand MegaRedHand added this pull request to the merge queue Apr 28, 2023
Merged via the queue into main with commit 4bc7c54 Apr 28, 2023
@MegaRedHand MegaRedHand deleted the feat_hints_55_56_57 branch April 28, 2023 19:22
kariy pushed a commit to dojoengine/cairo-rs that referenced this pull request Jun 23, 2023
* Skeleton + hint55 implementation

* Refactor

* Implement hint66

* Hint 57

* Appease clippy

* Fix: change SECP_P_V2 instead of SECP_P

* Add integration tests

Also renamed:
 - `ASSIGN_PACK_MOD_SECP_PRIME_TO_X` -> `IS_ZERO_PACK_ED25519`
 - `ASSIGN_PACK_MOD_SECP_PRIME_TO_VALUE` -> `REDUCE_ED25519`
 - `ASSIGN_DIV_MOD_1_X_SECP_PRIME_TO_X_INV_AND_VALUE` -> `IS_ZERO_PACK_ED25519`

* Update changelog

* Insert SECP_P to exec_scopes, and rename functions

* Add call to `test_reduce_ed25519` on reduce.cairo

Co-authored-by: fmoletta <[email protected]>

* Apply changes requesed by @fmoletta

- fix: `test_reduce_ed25519` wasn't being called in main of reduce.cairo
- don't call `add_segments` macro when using `segments`
- use `check_scope` instead of manual `assert_eq`s
- change `run_program_simple_with_memory_holes(..., 0)` -> `run_program_simple`

* Use `scope` macro instead of manual build

Also allow trailing commas in `scope` macro

* Add missing `check_scope`

* Allow use of `scope` macro without args

* Change `assert_matches`+`Ok` for `assert`+`is_ok`

* Fix: remove unused import

---------

Co-authored-by: Tomás <[email protected]>
Co-authored-by: Tomás <[email protected]>
Co-authored-by: fmoletta <[email protected]>
Co-authored-by: Pedro Fontana <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
whitelisted-hint Implementation of hint on whitelist directory
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[New Hints] vrf.json
4 participants