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

feature: implement and test secp hints #40

Closed
wants to merge 2 commits into from
Closed

Conversation

whichqua
Copy link

@whichqua whichqua commented Aug 2, 2024

Implement SECP hints required for k1 and r1 curves

Description

This PR implements secp256(k1|r1) hint processing functions and their unit tests in the Cairo VM:

maybe_write_address_to_ap
pack_x_prime
compute_q_mod_prime
compute_ids_high_low
calculate_value
is_on_curve_2 

Failures due to unknown identifiers and missing members; debugging is in progress.

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.

Copy link

github-actions bot commented Aug 2, 2024

**Hyper Thereading Benchmark results**




hyperfine -r 2 -n "hyper_threading_main threads: 1" 'RAYON_NUM_THREADS=1 ./hyper_threading_main' -n "hyper_threading_pr threads: 1" 'RAYON_NUM_THREADS=1 ./hyper_threading_pr'
Benchmark 1: hyper_threading_main threads: 1
  Time (mean ± σ):     25.834 s ±  0.038 s    [User: 25.040 s, System: 0.792 s]
  Range (min … max):   25.807 s … 25.860 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 1
  Time (mean ± σ):     26.443 s ±  0.070 s    [User: 25.750 s, System: 0.692 s]
  Range (min … max):   26.393 s … 26.493 s    2 runs
 
Summary
  'hyper_threading_main threads: 1' ran
    1.02 ± 0.00 times faster than 'hyper_threading_pr threads: 1'




hyperfine -r 2 -n "hyper_threading_main threads: 2" 'RAYON_NUM_THREADS=2 ./hyper_threading_main' -n "hyper_threading_pr threads: 2" 'RAYON_NUM_THREADS=2 ./hyper_threading_pr'
Benchmark 1: hyper_threading_main threads: 2
  Time (mean ± σ):     14.688 s ±  0.050 s    [User: 25.831 s, System: 0.736 s]
  Range (min … max):   14.653 s … 14.724 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 2
  Time (mean ± σ):     15.062 s ±  0.024 s    [User: 26.291 s, System: 0.750 s]
  Range (min … max):   15.045 s … 15.079 s    2 runs
 
Summary
  'hyper_threading_main threads: 2' ran
    1.03 ± 0.00 times faster than 'hyper_threading_pr threads: 2'




hyperfine -r 2 -n "hyper_threading_main threads: 4" 'RAYON_NUM_THREADS=4 ./hyper_threading_main' -n "hyper_threading_pr threads: 4" 'RAYON_NUM_THREADS=4 ./hyper_threading_pr'
Benchmark 1: hyper_threading_main threads: 4
  Time (mean ± σ):     10.455 s ±  0.347 s    [User: 37.547 s, System: 0.935 s]
  Range (min … max):   10.210 s … 10.701 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 4
  Time (mean ± σ):     10.833 s ±  0.022 s    [User: 38.221 s, System: 0.945 s]
  Range (min … max):   10.817 s … 10.848 s    2 runs
 
Summary
  'hyper_threading_main threads: 4' ran
    1.04 ± 0.03 times faster than 'hyper_threading_pr threads: 4'




hyperfine -r 2 -n "hyper_threading_main threads: 6" 'RAYON_NUM_THREADS=6 ./hyper_threading_main' -n "hyper_threading_pr threads: 6" 'RAYON_NUM_THREADS=6 ./hyper_threading_pr'
Benchmark 1: hyper_threading_main threads: 6
  Time (mean ± σ):     10.431 s ±  0.110 s    [User: 36.916 s, System: 0.998 s]
  Range (min … max):   10.353 s … 10.508 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 6
  Time (mean ± σ):     10.727 s ±  0.263 s    [User: 38.541 s, System: 0.926 s]
  Range (min … max):   10.541 s … 10.913 s    2 runs
 
Summary
  'hyper_threading_main threads: 6' ran
    1.03 ± 0.03 times faster than 'hyper_threading_pr threads: 6'




hyperfine -r 2 -n "hyper_threading_main threads: 8" 'RAYON_NUM_THREADS=8 ./hyper_threading_main' -n "hyper_threading_pr threads: 8" 'RAYON_NUM_THREADS=8 ./hyper_threading_pr'
Benchmark 1: hyper_threading_main threads: 8
  Time (mean ± σ):     10.197 s ±  0.176 s    [User: 37.578 s, System: 0.928 s]
  Range (min … max):   10.072 s … 10.321 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 8
  Time (mean ± σ):     10.461 s ±  0.081 s    [User: 38.564 s, System: 0.921 s]
  Range (min … max):   10.404 s … 10.519 s    2 runs
 
Summary
  'hyper_threading_main threads: 8' ran
    1.03 ± 0.02 times faster than 'hyper_threading_pr threads: 8'




hyperfine -r 2 -n "hyper_threading_main threads: 16" 'RAYON_NUM_THREADS=16 ./hyper_threading_main' -n "hyper_threading_pr threads: 16" 'RAYON_NUM_THREADS=16 ./hyper_threading_pr'
Benchmark 1: hyper_threading_main threads: 16
  Time (mean ± σ):     10.107 s ±  0.238 s    [User: 37.908 s, System: 0.978 s]
  Range (min … max):    9.939 s … 10.276 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 16
  Time (mean ± σ):     10.546 s ±  0.210 s    [User: 39.027 s, System: 1.010 s]
  Range (min … max):   10.398 s … 10.695 s    2 runs
 
Summary
  'hyper_threading_main threads: 16' ran
    1.04 ± 0.03 times faster than 'hyper_threading_pr threads: 16'


Copy link

github-actions bot commented Aug 2, 2024

Benchmark Results for unmodified programs 🚀

Command Mean [s] Min [s] Max [s] Relative
base big_factorial 2.058 ± 0.044 2.016 2.167 1.00
head big_factorial 2.131 ± 0.052 2.077 2.250 1.04 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base big_fibonacci 2.045 ± 0.052 1.984 2.156 1.01 ± 0.03
head big_fibonacci 2.030 ± 0.013 2.012 2.048 1.00
Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 7.493 ± 0.182 7.302 7.814 1.00
head blake2s_integration_benchmark 7.699 ± 0.156 7.480 7.862 1.03 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 2.139 ± 0.047 2.089 2.253 1.00
head compare_arrays_200000 2.181 ± 0.043 2.137 2.247 1.02 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 1.442 ± 0.031 1.419 1.520 1.00
head dict_integration_benchmark 1.458 ± 0.031 1.427 1.521 1.01 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base field_arithmetic_get_square_benchmark 1.200 ± 0.028 1.174 1.265 1.00
head field_arithmetic_get_square_benchmark 1.223 ± 0.022 1.203 1.276 1.02 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 7.564 ± 0.164 7.345 7.847 1.00
head integration_builtins 7.840 ± 0.111 7.737 8.071 1.04 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 7.899 ± 0.176 7.651 8.235 1.00
head keccak_integration_benchmark 8.100 ± 0.391 7.755 9.143 1.03 ± 0.05
Command Mean [s] Min [s] Max [s] Relative
base linear_search 2.132 ± 0.040 2.079 2.208 1.00
head linear_search 2.148 ± 0.014 2.128 2.175 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 1.532 ± 0.032 1.488 1.599 1.00
head math_cmp_and_pow_integration_benchmark 1.553 ± 0.010 1.526 1.560 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 1.437 ± 0.016 1.422 1.470 1.00
head math_integration_benchmark 1.461 ± 0.021 1.439 1.507 1.02 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 1.206 ± 0.021 1.171 1.237 1.00
head memory_integration_benchmark 1.241 ± 0.013 1.230 1.265 1.03 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 1.547 ± 0.018 1.530 1.580 1.00
head operations_with_data_structures_benchmarks 1.574 ± 0.017 1.559 1.615 1.02 ± 0.02
Command Mean [ms] Min [ms] Max [ms] Relative
base pedersen 519.5 ± 2.7 516.6 524.7 1.00
head pedersen 540.2 ± 13.9 530.6 577.7 1.04 ± 0.03
Command Mean [ms] Min [ms] Max [ms] Relative
base poseidon_integration_benchmark 772.1 ± 7.7 765.2 791.7 1.00
head poseidon_integration_benchmark 774.5 ± 2.7 770.3 778.7 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 1.826 ± 0.015 1.806 1.852 1.01 ± 0.01
head secp_integration_benchmark 1.800 ± 0.022 1.771 1.833 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base set_integration_benchmark 645.5 ± 5.4 639.6 657.9 1.00
head set_integration_benchmark 660.2 ± 6.5 653.2 671.5 1.02 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 4.242 ± 0.163 4.082 4.669 1.00
head uint256_integration_benchmark 4.303 ± 0.056 4.236 4.388 1.01 ± 0.04

@whichqua whichqua closed this Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant