Skip to content

Commit 4d1f38f

Browse files
committed
remove unneeded argument from toBuffer/toDER method
1 parent a90b8f5 commit 4d1f38f

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

packages/bitcore-lib-cash/lib/crypto/signature.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Signature.prototype.set = function(obj) {
3030
this.i = typeof obj.i !== 'undefined' ? obj.i : this.i; //public key recovery parameter in range [0, 3]
3131
this.compressed = typeof obj.compressed !== 'undefined' ?
3232
obj.compressed : this.compressed; // whether the recovered pubkey is compressed
33-
this.isSchnorr = obj.isSchnorr;
33+
this.isSchnorr = obj.isSchnorr || this.isSchnorr || undefined;
3434
this.nhashtype = obj.nhashtype || this.nhashtype || undefined;
3535
return this;
3636
};
@@ -207,14 +207,12 @@ Signature.prototype.toCompact = function(i, compressed) {
207207
return Buffer.concat([b1, b2, b3]);
208208
};
209209

210-
Signature.prototype.toBuffer = Signature.prototype.toDER = function(signingMethod) {
210+
Signature.prototype.toBuffer = Signature.prototype.toDER = function() {
211211

212212
// Schnorr signatures use a 64 byte r,s format, where as ECDSA takes the form decribed
213213
// below, above the isDER function signature.
214214

215-
signingMethod = signingMethod || "ecdsa";
216-
217-
if(signingMethod === "schnorr") {
215+
if(this.isSchnorr) {
218216
return Buffer.concat([this.r.toBuffer({size: 32}), this.s.toBuffer({size: 32})]);
219217
}
220218

packages/bitcore-lib-cash/test/crypto/schnorr.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe("#Schnorr", function() {
4343
let x = new Signature();
4444
x.isSchnorr = true;
4545
x.set(schnorr.sig);
46-
let str = x.toBuffer("schnorr").toString('hex');
46+
let str = x.toBuffer().toString('hex');
4747
str.should.equal("005e7ab0906a0164306975916350214a69fb80210cf7e37533f197c3d18b23d1b794262dc663d9e99605784b14ee1ecfca27b602e88dbc87af85f9907c214ea3");
4848
});
4949

0 commit comments

Comments
 (0)