Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions packages/bitcore-lib-cash/lib/crypto/signature.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down Expand Up @@ -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})]);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/bitcore-lib-cash/test/crypto/schnorr.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});

Expand Down