Removes curveFpDecodePointHex

This commit is contained in:
Daniel Cousens 2014-04-05 06:27:33 +11:00
parent 39abb2b9f9
commit 7451c54cc6
2 changed files with 1 additions and 27 deletions

View file

@ -283,38 +283,12 @@ function curveFpFromBigInteger(x) {
return new ECFieldElementFp(this.q, x); return new ECFieldElementFp(this.q, x);
} }
// for now, work with hex strings because they're easier in JS
function curveFpDecodePointHex(s) {
switch(parseInt(s.substr(0,2), 16)) { // first byte
case 0:
return this.infinity;
case 2:
case 3:
// point compression not supported yet
return null;
case 4:
case 6:
case 7:
var len = (s.length - 2) / 2;
var xHex = s.substr(2, len);
var yHex = s.substr(len+2, len);
return new ECPointFp(this,
this.fromBigInteger(new BigInteger(xHex, 16)),
this.fromBigInteger(new BigInteger(yHex, 16)));
default: // unsupported
return null;
}
}
ECCurveFp.prototype.getQ = curveFpGetQ; ECCurveFp.prototype.getQ = curveFpGetQ;
ECCurveFp.prototype.getA = curveFpGetA; ECCurveFp.prototype.getA = curveFpGetA;
ECCurveFp.prototype.getB = curveFpGetB; ECCurveFp.prototype.getB = curveFpGetB;
ECCurveFp.prototype.equals = curveFpEquals; ECCurveFp.prototype.equals = curveFpEquals;
ECCurveFp.prototype.getInfinity = curveFpGetInfinity; ECCurveFp.prototype.getInfinity = curveFpGetInfinity;
ECCurveFp.prototype.fromBigInteger = curveFpFromBigInteger; ECCurveFp.prototype.fromBigInteger = curveFpFromBigInteger;
ECCurveFp.prototype.decodePointHex = curveFpDecodePointHex;
// prepends 0 if bytes < len // prepends 0 if bytes < len
// cuts off start if bytes > len // cuts off start if bytes > len

View file

@ -185,7 +185,7 @@ function secp256r1() {
var curve = new ECCurveFp(p, a, b); var curve = new ECCurveFp(p, a, b);
var x = fromHex("6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296") var x = fromHex("6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296")
var y = fromHex("4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5") var y = fromHex("4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5")
var G = new ECPointFp(curve, var G = new ECPointFp(curve,
curve.fromBigInteger(x), curve.fromBigInteger(x),
curve.fromBigInteger(y)) curve.fromBigInteger(y))