Skip to content

Conversation

gabrielbosio
Copy link
Collaborator

@gabrielbosio gabrielbosio commented Sep 18, 2025

Downgrades Lambdaworks version from 0.12.0 to 0.11.0 since both supports QM31 but the latter doesn't check that a point is in the curve when creating it.

Pull Request type

Performance improvement.

What is the current behavior?

Run:

cd starknet-types-core
make bench

Here are the results of Pedersen benchmarks, tested in Apple M3 Pro, macOS Sequoia 15.6.1, 18 GB RAM:

rev 5774f89bccf6b5ed772072244ad2a17e604ada55 (base):

Pedersen/hash           time:   [19.395 µs 19.422 µs 19.451 µs]
Pedersen/hash_array/10  time:   [283.07 µs 284.58 µs 285.99 µs]
Pedersen/hash_array/100 time:   [2.7103 ms 2.7125 ms 2.7147 ms]
Pedersen/hash_array/1000 time:   [28.886 ms 28.911 ms 28.937 ms]
Pedersen/hash_array/10000 time:   [272.86 ms 273.57 ms 274.50 ms]

rev ee5743bfc1a91638150029b615fa21fdb6a3292e (head):

Pedersen/hash           time:   [9.0100 µs 9.1308 µs 9.3493 µs]
                        change: [-53.086% -52.651% -52.039%] (p = 0.00 < 0.05)

Pedersen/hash_array/10  time:   [126.93 µs 128.00 µs 129.15 µs]
                        change: [-55.279% -55.011% -54.768%] (p = 0.00 < 0.05)

Pedersen/hash_array/100 time:   [1.2037 ms 1.2217 ms 1.2464 ms]
                        change: [-55.655% -55.338% -54.937%] (p = 0.00 < 0.05)

Pedersen/hash_array/1000
                        time:   [12.444 ms 12.573 ms 12.739 ms]
                        change: [-56.930% -56.513% -55.941%] (p = 0.00 < 0.05)

Pedersen/hash_array/10000
                        time:   [126.63 ms 127.31 ms 128.07 ms]
                        change: [-53.750% -53.464% -53.172%] (p = 0.00 < 0.05)

Resolves: #NA

What is the new behavior?

0.3.0 showed a performance regression in Pedersen, making them ~120% slower. This PR restores Pedersen performance by downgrading Lambdaworks version.

At the moment, I preserved the QM31 API to avoid merging a breaking change. For instance, this function returns a Result but it will always return the Ok variant. However, I'm open for suggestions to change the API for simplification.

Does this introduce a breaking change?

No

@gabrielbosio gabrielbosio marked this pull request as ready for review September 18, 2025 21:03
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