Skip to content

Commit 07bd2b7

Browse files
docs: Add comment explaining the is_identity optimization (openvm-org#1716)
A recent PR (openvm-org#1709) introduced the optimization of overriding the default implementation of `Group::is_identity` in the `impl_sw_group_ops` macro. The overridden implementation was identical to the default one. This PR adds a comment to explain the code duplication. --------- Co-authored-by: Jonathan Wang <[email protected]>
1 parent 27b4e7d commit 07bd2b7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

extensions/ecc/guest/src/weierstrass.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,11 @@ macro_rules! impl_sw_group_ops {
463463
self.double_assign_impl::<true>();
464464
}
465465

466+
// This implementation is the same as the default implementation in the `Group` trait,
467+
// but it was found that overriding the default implementation reduced the cycle count
468+
// by 50% on the ecrecover benchmark.
469+
// We hypothesize that this is due to compiler optimizations that are not possible when
470+
// the `is_identity` function is defined in a different source file.
466471
fn is_identity(&self) -> bool {
467472
self == &<Self as Group>::IDENTITY
468473
}

0 commit comments

Comments
 (0)