mirror of
https://github.com/hanzoai/elliptic.git
synced 2026-09-23 23:51:03 +00:00
@@ -134,13 +134,15 @@ EC.prototype.sign = function sign(msg, key, enc, options) {
|
||||
if (s.cmpn(0) === 0)
|
||||
continue;
|
||||
|
||||
// Use complement of `s`, if it is > `n / 2`
|
||||
if (options.canonical && s.cmp(this.nh) > 0)
|
||||
s = this.n.sub(s);
|
||||
|
||||
var recoveryParam = (kp.getY().isOdd() ? 1 : 0) |
|
||||
(kpX.cmp(r) !== 0 ? 2 : 0);
|
||||
|
||||
// Use complement of `s`, if it is > `n / 2`
|
||||
if (options.canonical && s.cmp(this.nh) > 0) {
|
||||
s = this.n.sub(s);
|
||||
recoveryParam ^= 1;
|
||||
}
|
||||
|
||||
return new Signature({ r: r, s: s, recoveryParam: recoveryParam });
|
||||
} while (true);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user