Skip to content

Commit

Permalink
Add warning for undefined 'e' in signSchnorr function (#3)
Browse files Browse the repository at this point in the history
This commit introduces a console warning when 'e' (auxRand equivalent) is undefined during a Schnorr signing operation. The warning informs users of potential discrepancies between our library and tiny-secp256k1 due to differences in how 'e' is handled when it's not provided. This is a response to issue #3.
  • Loading branch information
landabaso committed Jun 28, 2023
1 parent 73bf983 commit e40fadc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,12 @@ export function sign(h, d, e) {
return necc.signSync(h, d, { der: false, extraEntropy: e });
}

export function signSchnorr(h, d, e = Buffer.alloc(32, 0x00)) {
export function signSchnorr(h, d, e) {
if (e === undefined) {
console.warn(
`Warning: The extra data 'e' is not defined. This library defaults to a random value when 'e' is undefined, which is different from the deterministic approach in tiny-secp256k1. This might lead to discrepancies in the Schnorr signatures between the two libraries.`
);
}
if (!isPrivate(d)) {
throw new Error('Expected Private');
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@bitcoinerlab/secp256k1",
"homepage": "https://bitcoinerlab.com/secp256k1",
"version": "1.0.2",
"version": "1.0.3",
"description": "A library for performing elliptic curve operations on the secp256k1 curve. It is designed to integrate into the BitcoinJS & BitcoinerLAB ecosystems and uses the audited noble-secp256k1 library. It is compatible with environments that do not support WASM, such as React Native.",
"main": "dist/index.js",
"types": "types/index.d.ts",
Expand Down

0 comments on commit e40fadc

Please sign in to comment.