Skip to content

Commit 34fbcda

Browse files
Update comments on Group::is_identity impl
1 parent 688d95d commit 34fbcda

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

extensions/ecc/guest/src/edwards.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,16 @@ macro_rules! impl_te_group_ops {
172172
*self = self.add_impl(self)
173173
}
174174
}
175+
176+
// Note: It was found that implementing `is_identity` in group.rs as a default
177+
// implementation increases the cycle count by 50% on the ecrecover benchmark. For
178+
// this reason, we implement it here instead. We hypothesize that this is due to
179+
// compiler optimizations that are not possible when the `is_identity` function is
180+
// defined in a different source file.
181+
#[inline(always)]
182+
fn is_identity(&self) -> bool {
183+
self == &<Self as Group>::IDENTITY
184+
}
175185
}
176186

177187
impl core::ops::Add<&$struct_name> for $struct_name {

extensions/ecc/guest/src/weierstrass.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -451,11 +451,11 @@ macro_rules! impl_sw_group_ops {
451451
self.double_assign_impl::<true>();
452452
}
453453

454-
// This implementation is the same as the default implementation in the `Group` trait,
455-
// but it was found that overriding the default implementation reduced the cycle count
456-
// by 50% on the ecrecover benchmark.
457-
// We hypothesize that this is due to compiler optimizations that are not possible when
458-
// the `is_identity` function is defined in a different source file.
454+
// Note: It was found that implementing `is_identity` in group.rs as a default
455+
// implementation increases the cycle count by 50% on the ecrecover benchmark. For
456+
// this reason, we implement it here instead. We hypothesize that this is due to
457+
// compiler optimizations that are not possible when the `is_identity` function is
458+
// defined in a different source file.
459459
#[inline(always)]
460460
fn is_identity(&self) -> bool {
461461
self == &<Self as Group>::IDENTITY

0 commit comments

Comments
 (0)