[CHORE] Modified functions not to overwrite entire prototype

This commit is contained in:
Evan Schwartz
2014-04-23 10:59:15 -07:00
parent 7f59fb917c
commit 8275e036c9

View File

@@ -1,5 +1,4 @@
sjcl.ecc.ecdsa.secretKey.prototype = { sjcl.ecc.ecdsa.secretKey.prototype.sign = function(hash, paranoia) {
sign: function(hash, paranoia) {
var R = this._curve.r, var R = this._curve.r,
l = R.bitLength(), l = R.bitLength(),
k = sjcl.bn.random(R.sub(1), paranoia).add(1), k = sjcl.bn.random(R.sub(1), paranoia).add(1),
@@ -7,11 +6,9 @@ sjcl.ecc.ecdsa.secretKey.prototype = {
s = sjcl.bn.fromBits(hash).add(r.mul(this._exponent)).mul(k.inverseMod(R)).mod(R); s = sjcl.bn.fromBits(hash).add(r.mul(this._exponent)).mul(k.inverseMod(R)).mod(R);
return sjcl.bitArray.concat(r.toBits(l), s.toBits(l)); return sjcl.bitArray.concat(r.toBits(l), s.toBits(l));
}
}; };
sjcl.ecc.ecdsa.publicKey.prototype = { sjcl.ecc.ecdsa.publicKey.prototype.verify = function(hash, rs) {
verify: function(hash, rs) {
var w = sjcl.bitArray, var w = sjcl.bitArray,
R = this._curve.r, R = this._curve.r,
l = R.bitLength(), l = R.bitLength(),
@@ -26,5 +23,4 @@ sjcl.ecc.ecdsa.publicKey.prototype = {
throw (new sjcl.exception.corrupt("signature didn't check out")); throw (new sjcl.exception.corrupt("signature didn't check out"));
} }
return true; return true;
}
}; };