Skip to content

Commit 69638c5

Browse files
authored
fix: EdDSA strict equality check for s (#1684)
1 parent cf26618 commit 69638c5

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

frontend/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ type API interface {
121121
//
122122
// If the absolute difference between the variables b and bound is known, then
123123
// it is more efficient to use the bounded methods in package
124-
// [github.com/consensys/gnark/std/math/bits].
124+
// [github.com/consensys/gnark/std/math/cmp].
125125
AssertIsLessOrEqual(v Variable, bound Variable)
126126

127127
// Println behaves like fmt.Println but accepts frontend.Variable as parameter

std/signature/eddsa/eddsa.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55

66
"github.com/consensys/gnark/std/hash"
7+
"github.com/consensys/gnark/std/math/cmp"
78

89
"github.com/consensys/gnark/frontend"
910
"github.com/consensys/gnark/std/algebra/native/twistededwards"
@@ -63,7 +64,8 @@ func IsValid(curve twistededwards.Curve, sig Signature, msg frontend.Variable, p
6364
}
6465

6566
// Assert S < GroupSize (see https://datatracker.ietf.org/doc/html/rfc8032#section-3.4)
66-
curve.API().AssertIsLessOrEqual(sig.S, curve.Params().Order)
67+
isLess := cmp.IsLess(curve.API(), sig.S, curve.Params().Order)
68+
curve.API().AssertIsEqual(isLess, 1)
6769

6870
//[S]G-[H(R,A,M)]*A
6971
_A := curve.Neg(pubKey.A)

0 commit comments

Comments
 (0)