We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bb5cf3a commit b963603Copy full SHA for b963603
1 file changed
lib/js/index.js
@@ -21,17 +21,9 @@ exports.privateKeyExport = function (privateKey, compressed) {
21
22
exports.privateKeyNegate = function (privateKey) {
23
var bn = BN.fromBuffer(privateKey)
24
+ if (bn.isZero()) return Buffer.alloc(32)
25
- if (bn.isZero()) {
26
- return Buffer.alloc(32)
27
- }
28
-
29
- if (bn.ucmp(BN.n) !== 0) {
30
- while (bn.isOverflow()) {
31
- bn.isub(BN.n)
32
33
34
+ if (bn.ucmp(BN.n) > 0) bn.isub(BN.n)
35
return BN.n.sub(bn).toBuffer()
36
}
37
0 commit comments