Skip to content

Commit d29425a

Browse files
committed
secp256k1-compat: additional check for zero point
1 parent b2b50f8 commit d29425a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/secp256k1-compat.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export function ecdsaSign(
112112
}
113113
const [signature, recid] = secp.signSync(msgHash, privateKey, {
114114
recovered: true,
115-
der: false
115+
der: false,
116116
});
117117
return { signature: output(out, 64, signature), recid };
118118
}
@@ -214,8 +214,12 @@ export function publicKeyCombine(
214214
}
215215
assertBool(compressed);
216216
const combined = publicKeys
217-
.map(pub => secp.Point.fromHex(pub))
217+
.map((pub) => secp.Point.fromHex(pub))
218218
.reduce((res, curr) => res.add(curr), secp.Point.ZERO);
219+
// Prohibit returning ZERO point
220+
if (combined.equals(secp.Point.ZERO)) {
221+
throw new Error("Combined result must not be zero");
222+
}
219223
return output(out, compressed ? 33 : 65, combined.toRawBytes(compressed));
220224
}
221225

0 commit comments

Comments
 (0)