Skip to content

Commit f106efb

Browse files
committed
ecdsa low s value
1 parent a6b0617 commit f106efb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/crypto/ecdsa.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ pub fn sign(pk: [32]u8, z: [32]u8, comptime nonce: ?u256) Signature {
7070
if (s == 0) {
7171
continue;
7272
}
73+
const low_s = if (s > crypto.secp256k1_number_of_points / 2) crypto.secp256k1_number_of_points - s else s;
7374

74-
// TODO: always use the low s value
75-
return Signature{ .r = r, .s = s };
75+
return Signature{ .r = r, .s = low_s };
7676
}
7777

7878
unreachable;

0 commit comments

Comments
 (0)