lurk-lab / bls12_381

Implementation of the BLS12-381 pairing-friendly elliptic curve group
Other
0 stars 0 forks source link

zkvm: Remove unnecessary copies in miller loop and `sum_of_products` #11

Closed wwared closed 1 month ago

wwared commented 1 month ago

This PR removes unnecessary copies in the following hot paths:

This is achieved by adding zkvm-specific variants of base operations that modify a value in-place via &mut self to prevent unnecessary copies. Then functions in the hot-path are modified (adding a zkvm-specific variant) to use these operations instead where possible. We make a new function and use #[cfg] to select between the zkvm no-copy version and the regular version, to make it easier to compare implementations and ensure the functions are equivalent.

This brings the aptos-lc ratcheting test down from 22289711 cycles to 15933247 cycles (~29% reduction)

The other hot-paths that will be optimized in future follow-up PRs are: