Skip to content

Commit 2144c90

Browse files
committed
build: 💥 update to secp256k1 v2.1.0 w/ breaking changes
1 parent d081a29 commit 2144c90

File tree

3 files changed

+147
-291
lines changed

3 files changed

+147
-291
lines changed

dashhd.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ var DashHd = ("object" === typeof module && exports) || {};
147147
let Secp256k1 =
148148
//@ts-ignore
149149
window.nobleSecp256k1 || require("@dashincubator/secp256k1");
150-
let p = Secp256k1.utils._normalizePrivateKey(privateKeyCopy);
151-
let t = Secp256k1.utils._normalizePrivateKey(tweak);
152-
return Secp256k1.utils._bigintTo32Bytes(
153-
Secp256k1.utils.mod(p + t, Secp256k1.CURVE.n),
150+
let p = Secp256k1.utils.normPrivateKeyToScalar(privateKeyCopy);
151+
let t = Secp256k1.utils.normPrivateKeyToScalar(tweak);
152+
return Secp256k1.etc.numberToBytesBE(
153+
Secp256k1.etc.mod(p + t, Secp256k1.CURVE.n),
154154
);
155155
};
156156

@@ -161,7 +161,7 @@ var DashHd = ("object" === typeof module && exports) || {};
161161
window.nobleSecp256k1 || require("@dashincubator/secp256k1");
162162

163163
try {
164-
let point = Secp256k1.Point.fromHex(pubBytes);
164+
let point = Secp256k1.ProjectivePoint.fromHex(pubBytes);
165165
pubBytes = point.toRawBytes(COMPRESSED);
166166
} catch (e) {
167167
throw new Error("Invalid public key");
@@ -176,9 +176,9 @@ var DashHd = ("object" === typeof module && exports) || {};
176176
//@ts-ignore
177177
window.nobleSecp256k1 || require("@dashincubator/secp256k1");
178178

179-
let P = Secp256k1.Point.fromHex(publicKeyCopy);
180-
let t = Secp256k1.utils._normalizePrivateKey(tweak);
181-
let Q = Secp256k1.Point.BASE.multiplyAndAddUnsafe(P, t, 1n);
179+
let P = Secp256k1.ProjectivePoint.fromHex(publicKeyCopy);
180+
let t = Secp256k1.utils.normPrivateKeyToScalar(tweak);
181+
let Q = Secp256k1.ProjectivePoint.BASE.mulAddQUns(P, t, 1n);
182182
if (!Q) {
183183
throw new Error("Tweaked point at infinity");
184184
}

0 commit comments

Comments
 (0)