Skip to content

Commit 8549b3a

Browse files
committed
fix: IsZero edge case on zero limbs
1 parent 8cbafa2 commit 8549b3a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

std/math/emulated/field_assert.go

+5
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ func (f *Field[T]) AssertIsInRange(a *Element[T]) {
103103
// method internally reduces the element and asserts that the value is less than
104104
// the modulus.
105105
func (f *Field[T]) IsZero(a *Element[T]) frontend.Variable {
106+
// fast path - when the element is on zero limbs, then it is always zero
107+
if len(a.Limbs) == 0 {
108+
return 1
109+
}
110+
106111
// to avoid using strict reduction (which is expensive as requires binary
107112
// assertion that value is less than modulus), we use ordinary reduction but
108113
// in this case the result can be either 0 or p (if it is zero).

0 commit comments

Comments
 (0)