@secux/protocol-hdkey
Version:
SecuX Hardware Wallet hdkey protocol API
32 lines (31 loc) • 1.25 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Signature = /** @class */ (function () {
function Signature(signature) {
this.r = signature.r;
this.s = signature.s;
this.v = signature.v;
}
Signature.prototype.trimZero = function () {
this.r = (this.r[0] === 0 && this.r.length === 33) ? this.r.slice(1) : this.r;
this.s = (this.s[0] === 0 && this.s.length === 33) ? this.s.slice(1) : this.s;
return this;
};
Signature.prototype.toResult = function (leadingZero, withV) {
if (leadingZero === void 0) { leadingZero = false; }
if (withV === void 0) { withV = false; }
if (!leadingZero) {
this.r = (this.r[0] === 0 && this.r.length === 33) ? this.r.slice(1) : this.r;
this.s = (this.s[0] === 0 && this.s.length === 33) ? this.s.slice(1) : this.s;
}
if (withV) {
return Buffer.concat([this.v, this.r, this.s]);
}
return Buffer.concat([this.r, this.s]);
};
Signature.prototype.toString = function (leadingZero, withV) {
return this.toResult(leadingZero, withV).toString('hex');
};
return Signature;
}());
exports.Signature = Signature;