diff --git a/packages/bitcore-lib-cash/lib/crypto/signature.js b/packages/bitcore-lib-cash/lib/crypto/signature.js index 661f799e82b..300d96b2b2d 100644 --- a/packages/bitcore-lib-cash/lib/crypto/signature.js +++ b/packages/bitcore-lib-cash/lib/crypto/signature.js @@ -30,7 +30,7 @@ Signature.prototype.set = function(obj) { this.i = typeof obj.i !== 'undefined' ? obj.i : this.i; //public key recovery parameter in range [0, 3] this.compressed = typeof obj.compressed !== 'undefined' ? obj.compressed : this.compressed; // whether the recovered pubkey is compressed - this.isSchnorr = obj.isSchnorr; + this.isSchnorr = obj.isSchnorr || this.isSchnorr || undefined; this.nhashtype = obj.nhashtype || this.nhashtype || undefined; return this; }; @@ -207,14 +207,12 @@ Signature.prototype.toCompact = function(i, compressed) { return Buffer.concat([b1, b2, b3]); }; -Signature.prototype.toBuffer = Signature.prototype.toDER = function(signingMethod) { +Signature.prototype.toBuffer = Signature.prototype.toDER = function() { // Schnorr signatures use a 64 byte r,s format, where as ECDSA takes the form decribed // below, above the isDER function signature. - signingMethod = signingMethod || "ecdsa"; - - if(signingMethod === "schnorr") { + if(this.isSchnorr) { return Buffer.concat([this.r.toBuffer({size: 32}), this.s.toBuffer({size: 32})]); } diff --git a/packages/bitcore-lib-cash/test/crypto/schnorr.js b/packages/bitcore-lib-cash/test/crypto/schnorr.js index dfcd8034fd2..2755dbd1705 100644 --- a/packages/bitcore-lib-cash/test/crypto/schnorr.js +++ b/packages/bitcore-lib-cash/test/crypto/schnorr.js @@ -43,7 +43,7 @@ describe("#Schnorr", function() { let x = new Signature(); x.isSchnorr = true; x.set(schnorr.sig); - let str = x.toBuffer("schnorr").toString('hex'); + let str = x.toBuffer().toString('hex'); str.should.equal("005e7ab0906a0164306975916350214a69fb80210cf7e37533f197c3d18b23d1b794262dc663d9e99605784b14ee1ecfca27b602e88dbc87af85f9907c214ea3"); });