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): add NewHint#13 #1006

Merged
merged 10 commits into from
Apr 19, 2023
Merged

feat(hints): add NewHint#13 #1006

merged 10 commits into from
Apr 19, 2023

Conversation

MegaRedHand
Copy link
Contributor

Description

This PR adds the missing hint NewHint#13, now known as QUAD_BIT. I placed the implementation in the secp::ec_utils module because it's used in point multiplication via Shamir's trick + Windowed method.

@MegaRedHand MegaRedHand added the whitelisted-hint Implementation of hint on whitelist directory label Apr 18, 2023
@github-actions
Copy link

github-actions bot commented Apr 18, 2023

Benchmark Results for unmodified programs 🚀

Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 3.595 ± 0.045 3.560 3.696 1.05 ± 0.03
head blake2s_integration_benchmark 3.436 ± 0.106 3.348 3.637 1.00
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 4.440 ± 0.063 4.370 4.549 1.04 ± 0.04
head compare_arrays_200000 4.280 ± 0.158 4.083 4.465 1.00
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 3.339 ± 0.040 3.294 3.410 1.01 ± 0.02
head dict_integration_benchmark 3.319 ± 0.044 3.267 3.394 1.00
Command Mean [s] Min [s] Max [s] Relative
base factorial_multirun 5.085 ± 0.023 5.048 5.120 1.00
head factorial_multirun 5.254 ± 0.183 5.054 5.557 1.03 ± 0.04
Command Mean [s] Min [s] Max [s] Relative
base fibonacci_1000_multirun 4.152 ± 0.115 3.995 4.310 1.02 ± 0.04
head fibonacci_1000_multirun 4.051 ± 0.094 3.991 4.305 1.00
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 4.263 ± 0.043 4.183 4.322 1.00 ± 0.02
head integration_builtins 4.259 ± 0.048 4.206 4.356 1.00
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 3.652 ± 0.016 3.632 3.682 1.00
head keccak_integration_benchmark 3.656 ± 0.013 3.631 3.680 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base linear_search 4.566 ± 0.041 4.522 4.646 1.00
head linear_search 4.600 ± 0.064 4.459 4.672 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 3.575 ± 0.024 3.545 3.625 1.00 ± 0.01
head math_cmp_and_pow_integration_benchmark 3.573 ± 0.023 3.550 3.624 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 3.520 ± 0.137 3.383 3.824 1.08 ± 0.04
head math_integration_benchmark 3.253 ± 0.013 3.230 3.278 1.00
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 2.940 ± 0.056 2.899 3.045 1.02 ± 0.02
head memory_integration_benchmark 2.884 ± 0.007 2.875 2.893 1.00
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 2.889 ± 0.012 2.871 2.915 1.01 ± 0.01
head operations_with_data_structures_benchmarks 2.864 ± 0.012 2.849 2.885 1.00
Command Mean [s] Min [s] Max [s] Relative
base pedersen 4.026 ± 0.009 4.015 4.042 1.00
head pedersen 4.046 ± 0.029 4.024 4.102 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base poseidon_integration_benchmark 1.818 ± 0.032 1.793 1.878 1.01 ± 0.02
head poseidon_integration_benchmark 1.807 ± 0.015 1.795 1.846 1.00
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 3.227 ± 0.023 3.191 3.269 1.00 ± 0.01
head secp_integration_benchmark 3.219 ± 0.038 3.184 3.314 1.00
Command Mean [s] Min [s] Max [s] Relative
base set_integration_benchmark 2.253 ± 0.029 2.230 2.307 1.01 ± 0.02
head set_integration_benchmark 2.221 ± 0.028 2.183 2.271 1.00
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 5.053 ± 0.029 5.029 5.125 1.01 ± 0.01
head uint256_integration_benchmark 5.018 ± 0.016 5.001 5.055 1.00

@codecov
Copy link

codecov bot commented Apr 18, 2023

Codecov Report

Merging #1006 (88c72cb) into main (a199589) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #1006   +/-   ##
=======================================
  Coverage   98.02%   98.03%           
=======================================
  Files          76       76           
  Lines       31667    31729   +62     
=======================================
+ Hits        31043    31105   +62     
  Misses        624      624           
Impacted Files Coverage Δ
...int_processor/builtin_hint_processor_definition.rs 98.80% <100.00%> (+<0.01%) ⬆️
..._processor/builtin_hint_processor/secp/ec_utils.rs 99.52% <100.00%> (+0.05%) ⬆️

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

@Oppen
Copy link
Contributor

Oppen commented Apr 18, 2023

point multiplication via Shamir's trick + Windowed method

I wanted to add this since someone mentioned it in the Hacker House at Tel Aviv, but couldn't remember the name of the trick to find it online.

Copy link
Contributor

@Oppen Oppen left a comment

Choose a reason for hiding this comment

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

LGTM

@MegaRedHand MegaRedHand enabled auto-merge April 19, 2023 19:12
@MegaRedHand MegaRedHand added this pull request to the merge queue Apr 19, 2023
Merged via the queue into main with commit d307312 Apr 19, 2023
@MegaRedHand MegaRedHand deleted the newhint13-quad_bit branch April 19, 2023 20:11
kariy pushed a commit to dojoengine/cairo-rs that referenced this pull request Jun 23, 2023
* Add NewHint#13

* Update changelog

* Add test for when m is too high

* Restrict the guard clause in quad_bit

* Simplify match with unwrap_or

Feels dirty!

Co-authored-by: Mario Rugiero <[email protected]>

* Fix build errors

---------

Co-authored-by: Mario Rugiero <[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.

3 participants