Diffstat (limited to 'frontend/gamma/js/Clipperz/Crypto/ECC/BinaryField/Curve.js') (more/less context) (show whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/Crypto/ECC/BinaryField/Curve.js | 83 |
1 files changed, 18 insertions, 65 deletions
diff --git a/frontend/gamma/js/Clipperz/Crypto/ECC/BinaryField/Curve.js b/frontend/gamma/js/Clipperz/Crypto/ECC/BinaryField/Curve.js index 19f19c2..0d76b9c 100644 --- a/frontend/gamma/js/Clipperz/Crypto/ECC/BinaryField/Curve.js +++ b/frontend/gamma/js/Clipperz/Crypto/ECC/BinaryField/Curve.js @@ -2,6 +2,5 @@ -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the online password manager. For further information about its features and functionalities please @@ -9,10 +8,10 @@ refer to http://www.clipperz.com. -* Clipperz Community Edition is free software: you can redistribute - it and/or modify it under the terms of the GNU Affero General Public - License as published by the Free Software Foundation, either version - 3 of the License, or (at your option) any later version. +* Clipperz is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. -* Clipperz Community Edition is distributed in the hope that it will - be useful, but WITHOUT ANY WARRANTY; without even the implied - warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +* Clipperz is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. @@ -20,4 +19,3 @@ refer to http://www.clipperz.com. * You should have received a copy of the GNU Affero General Public - License along with Clipperz Community Edition. If not, see - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. @@ -104,18 +102,9 @@ Clipperz.Crypto.ECC.BinaryField.Curve.prototype = MochiKit.Base.update(null, { -//console.log(">>> ECC.BinaryField.Curve.add"); if (aPointA.isZero()) { -//console.log("--- pointA == zero"); result = aPointB; } else if (aPointB.isZero()) { -//console.log("--- pointB == zero"); result = aPointA; } else if ( (aPointA.x().compare(aPointB.x()) == 0) && ((aPointA.y().compare(aPointB.y()) != 0) || aPointB.x().isZero())) { -//console.log("compare A.x - B.x: ", aPointA.x().compare(aPointB.x())); -//console.log("compare A.y - B.y: ", (aPointA.y().compare(aPointB.y()) != 0)); -//console.log("compare B.x.isZero(): ", aPointB.x().isZero()); - -//console.log("--- result = zero"); result = new Clipperz.Crypto.ECC.BinaryField.Point({x:Clipperz.Crypto.ECC.BinaryField.Value.O, y:Clipperz.Crypto.ECC.BinaryField.Value.O}); } else { -//console.log("--- result = ELSE"); var f2m; @@ -133,3 +122,2 @@ Clipperz.Crypto.ECC.BinaryField.Curve.prototype = MochiKit.Base.update(null, { if (aPointA.x().compare(aPointB.x()) != 0) { -//console.log(" a.x != b.x"); lambda = f2m._fastMultiply( @@ -143,9 +131,5 @@ Clipperz.Crypto.ECC.BinaryField.Curve.prototype = MochiKit.Base.update(null, { } else { -//console.log(" a.x == b.x"); lambda = f2m._add(bX, f2m._fastMultiply(bY, f2m._inverse(bX))); -//console.log(" lambda: " + lambda.asString(16)); x = f2m._add(this.a()._value, f2m._square(lambda)); -//console.log(" x (step 1): " + x.asString(16)); f2m._overwriteAdd(x, lambda); -//console.log(" x (step 2): " + x.asString(16)); } @@ -153,7 +137,4 @@ Clipperz.Crypto.ECC.BinaryField.Curve.prototype = MochiKit.Base.update(null, { y = f2m._fastMultiply(f2m._add(bX, x), lambda); -//console.log(" y (step 1): " + y.asString(16)); f2m._overwriteAdd(y, x); -//console.log(" y (step 2): " + y.asString(16)); f2m._overwriteAdd(y, bY); -//console.log(" y (step 3): " + y.asString(16)); @@ -161,3 +142,2 @@ Clipperz.Crypto.ECC.BinaryField.Curve.prototype = MochiKit.Base.update(null, { } -//console.log("<<< ECC.BinaryField.Curve.add"); @@ -199,3 +179,2 @@ Clipperz.Crypto.ECC.BinaryField.Curve.prototype = MochiKit.Base.update(null, { if (aPointA.x().compare(aPointB.x()) != 0) { -//console.log(" a.x != b.x"); lambda = f2m._fastMultiply( @@ -209,9 +188,5 @@ Clipperz.Crypto.ECC.BinaryField.Curve.prototype = MochiKit.Base.update(null, { } else { -//console.log(" a.x == b.x"); lambda = f2m._add(bX, f2m._fastMultiply(bY, f2m._inverse(bX))); -//console.log(" lambda: " + lambda.asString(16)); x = f2m._add(this.a()._value, f2m._square(lambda)); -//console.log(" x (step 1): " + x.asString(16)); f2m._overwriteAdd(x, lambda); -//console.log(" x (step 2): " + x.asString(16)); } @@ -219,7 +194,4 @@ Clipperz.Crypto.ECC.BinaryField.Curve.prototype = MochiKit.Base.update(null, { y = f2m._fastMultiply(f2m._add(bX, x), lambda); -//console.log(" y (step 1): " + y.asString(16)); f2m._overwriteAdd(y, x); -//console.log(" y (step 2): " + y.asString(16)); f2m._overwriteAdd(y, bY); -//console.log(" y (step 3): " + y.asString(16)); @@ -230,3 +202,2 @@ Clipperz.Crypto.ECC.BinaryField.Curve.prototype = MochiKit.Base.update(null, { } -//console.log("<<< ECC.BinaryField.Curve.add"); @@ -252,3 +223,3 @@ Clipperz.Crypto.ECC.BinaryField.Curve.prototype = MochiKit.Base.update(null, { } else { -MochiKit.Logging.logError("The Clipperz.Crypto.ECC.BinaryFields.Value does not work with negative values!!!!"); + Clipperz.logError("The Clipperz.Crypto.ECC.BinaryFields.Value does not work with negative values!!!!"); k = aValue.negate(); @@ -257,4 +228,2 @@ MochiKit.Logging.logError("The Clipperz.Crypto.ECC.BinaryFields.Value does not w -//console.log("k: " + k.toString(16)); -//console.log("k.bitSize: " + k.bitSize()); for (i=k.bitSize()-1; i>=0; i--) { @@ -267,3 +236,3 @@ MochiKit.Logging.logError("The Clipperz.Crypto.ECC.BinaryFields.Value does not w -// if (countIndex==100) {console.log("multiply.break"); break;} else countIndex++; +// if (countIndex==100) {Clipperz.log("multiply.break"); break;} else countIndex++; } @@ -281,3 +250,3 @@ MochiKit.Logging.logError("The Clipperz.Crypto.ECC.BinaryFields.Value does not w -MochiKit.Logging.logDebug(">>> deferredMultiply - value: " + aValue + ", point: " + aPoint); +Clipperz.log(">>> deferredMultiply - value: " + aValue + ", point: " + aPoint); //console.profile("ECC.Curve.multiply"); @@ -285,6 +254,6 @@ MochiKit.Logging.logDebug(">>> deferredMultiply - value: " + aValue + ", point: //deferredResult.addCallback(function(res) {console.profile("ECC.Curve.deferredMultiply"); return res;} ); -//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("# 1: " + res); return res;}); +//deferredResult.addBoth(function(res) {Clipperz.logDebug("# 1: " + res); return res;}); result = new Clipperz.Crypto.ECC.BinaryField.Point({x:Clipperz.Crypto.ECC.BinaryField.Value.O, y:Clipperz.Crypto.ECC.BinaryField.Value.O}); -//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("# 2: " + res); return res;}); +//deferredResult.addBoth(function(res) {Clipperz.logDebug("# 2: " + res); return res;}); @@ -299,3 +268,3 @@ MochiKit.Logging.logDebug(">>> deferredMultiply - value: " + aValue + ", point: } else { -MochiKit.Logging.logError("The Clipperz.Crypto.ECC.BinaryFields.Value does not work with negative values!!!!"); + Clipperz.logError("The Clipperz.Crypto.ECC.BinaryFields.Value does not work with negative values!!!!"); k = aValue.negate(); @@ -304,9 +273,4 @@ MochiKit.Logging.logError("The Clipperz.Crypto.ECC.BinaryFields.Value does not w -//console.log("k: " + k.toString(16)); -//console.log("k.bitSize: " + k.bitSize()); -//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("# 3: " + res); return res;}); for (i=k.bitSize()-1; i>=0; i--) { -//MochiKit.Logging.logDebug("====> " + i); -//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("# 4 > i = " + i + ": " + res); return res;}); deferredResult.addMethod(this, "addTwice"); @@ -320,12 +284,6 @@ MochiKit.Logging.logError("The Clipperz.Crypto.ECC.BinaryFields.Value does not w if (i%20 == 0) {deferredResult.addCallback(MochiKit.Async.wait, 0.1);} - -// if (countIndex==100) {console.log("multiply.break"); break;} else countIndex++; -//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("# 4 < i = " + i + ": " + res); return res;}); } -//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("# 4: " + res); return res;}); } //#console.profileEnd(); -//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("# 5: " + res); return res;}); //deferredResult.addBoth(function(res) {console.profileEnd(); return res;}); -//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("# 6: " + res); return res;}); deferredResult.callback(result); @@ -443,3 +401,3 @@ MochiKit.Base.update(Clipperz.Crypto.ECC.StandardCurves, { if (aValue.bitSize() > 1140) { - MochiKit.Logging.logWarning("ECC.StandarCurves.B571.finiteField().module: falling back to default implementation"); + Clipperz.logWarning("ECC.StandarCurves.B571.finiteField().module: falling back to default implementation"); result = Clipperz.Crypto.ECC.StandardCurves._B571.finiteField().slowModule(aValue); @@ -449,4 +407,2 @@ MochiKit.Base.update(Clipperz.Crypto.ECC.StandardCurves, { -//console.log(">>> binaryField.finiteField.(improved)module"); -// C = aValue.value().slice(0); C = aValue._value.slice(0); @@ -466,3 +422,2 @@ MochiKit.Base.update(Clipperz.Crypto.ECC.StandardCurves, { result = new Clipperz.Crypto.ECC.BinaryField.Value(C); -//console.log("<<< binaryField.finiteField.(improved)module"); } @@ -509,3 +464,3 @@ MochiKit.Base.update(Clipperz.Crypto.ECC.StandardCurves, { if (aValue.bitSize() > 564) { - MochiKit.Logging.logWarning("ECC.StandarCurves.B283.finiteField().module: falling back to default implementation"); + Clipperz.logWarning("ECC.StandarCurves.B283.finiteField().module: falling back to default implementation"); result = Clipperz.Crypto.ECC.StandardCurves._B283.finiteField().slowModule(aValue); @@ -515,3 +470,2 @@ MochiKit.Base.update(Clipperz.Crypto.ECC.StandardCurves, { -//console.log(">>> binaryField.finiteField.(improved)module"); C = aValue._value.slice(0); @@ -531,3 +485,2 @@ MochiKit.Base.update(Clipperz.Crypto.ECC.StandardCurves, { result = new Clipperz.Crypto.ECC.BinaryField.Value(C); -//console.log("<<< binaryField.finiteField.(improved)module"); } |