Diffstat (limited to 'frontend/gamma/tests/tests/Clipperz/Crypto/ECC.K283.deferred.html') (more/less context) (show whitespace changes)
-rw-r--r-- | frontend/gamma/tests/tests/Clipperz/Crypto/ECC.K283.deferred.html | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/frontend/gamma/tests/tests/Clipperz/Crypto/ECC.K283.deferred.html b/frontend/gamma/tests/tests/Clipperz/Crypto/ECC.K283.deferred.html new file mode 100644 index 0000000..b53a9a1 --- a/dev/null +++ b/frontend/gamma/tests/tests/Clipperz/Crypto/ECC.K283.deferred.html @@ -0,0 +1,160 @@ +<!-- + +Copyright 2008-2011 Clipperz Srl + +This file is part of Clipperz's Javascript Crypto Library. +Javascript Crypto Library provides web developers with an extensive +and efficient set of cryptographic functions. The library aims to +obtain maximum execution speed while preserving modularity and +reusability. +For further information about its features and functionalities please +refer to http://www.clipperz.com + +* Javascript Crypto Library 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. + +* Javascript Crypto Library 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. + +* You should have received a copy of the GNU Affero General Public + License along with Javascript Crypto Library. If not, see + <http://www.gnu.org/licenses/>. + +--> + +<html> +<head> +<!-- - -> + <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script> +<!- - --> +<!-- --> + <script type="text/javascript" src="../../../../js/MochiKit/Base.js"></script> + <script type="text/javascript" src="../../../../js/MochiKit/Async.js"></script> + <script type="text/javascript" src="../../../../js/MochiKit/DOM.js"></script> + <script type="text/javascript" src="../../../../js/MochiKit/Logging.js"></script> + <script type="text/javascript" src="../../../../js/MochiKit/Iter.js"></script> +<!-- --> + +<!-- - -> + <script type="text/javascript" src="../../../../js/MochiKit/Style.js"></script> + <script type="text/javascript" src="../../../../js/MochiKit/Signal.js"></script> + <script type="text/javascript" src="../../../../js/MochiKit/Color.js"></script> + <script type="text/javascript" src="../../../../js/MochiKit/Position.js"></script> + <script type="text/javascript" src="../../../../js/MochiKit/Visual.js"></script> +<!- - --> + + + <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css"> + +<!--<script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>--> +<!--<script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>--> +<!--<script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>--> + +<!--<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Value.js'></script>--> +<!--<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Point.js'></script>--> +<!--<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/FiniteField.js'></script>--> +<!--<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Curve.js'></script>--> + + <script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/Koblitz/Value.js'></script> + <script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/Koblitz/Point.js'></script> + <script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/Koblitz/FiniteField.js'></script> + <script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/Koblitz/Curve.js'></script> + + <script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/StandardCurves.js'></script> + +</head> +<body> +<pre id="test"> +<script type="text/javascript"> +try { + + var deferredResult; + + + deferredResult = new MochiKit.Async.Deferred(); +//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("** 1: " + res); return res;}); + + // + // ECC.Curve.multiplication + // + var curve; + var f2m; + var f2m_improved; + var value; + var moduledValue; + var result; + var result_improved; + var expectedResul; + + f2m = new Clipperz.Crypto.ECC.Koblitz.FiniteField({modulus:new Clipperz.Crypto.ECC.Koblitz.Value('08000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 000010a1', 16)}) + f2m_improved = Clipperz.Crypto.ECC.StandardCurves.K283().finiteField(); + + curve = Clipperz.Crypto.ECC.StandardCurves.K283(); + +/** / + value = new Clipperz.Crypto.ECC.Koblitz.Value("7b", 16); + result = curve.multiply(value, curve.G()); + expectedResult = new Clipperz.Crypto.ECC.Koblitz.Point({ + x: new Clipperz.Crypto.ECC.Koblitz.Value('29705d23a9cda75e43984bdb9a8fd33304682da0f506a69bdbd5f36657e11b41e35fcdd', 16), + y: new Clipperz.Crypto.ECC.Koblitz.Value('59157d2ace16563a905361c5206cc0775c3330f4978bddf8aa9916c451cf9951313623b', 16) + }); + is(result.x().asString(16), expectedResult.x().asString(16), "ECC.Curve.multiplication: result.x does match"); + is(result.y().asString(16), expectedResult.y().asString(16), "ECC.Curve.multiplication: result.y does match"); +/ **/ + + value = new Clipperz.Crypto.ECC.Koblitz.Value("ba35032a24eb81238251d85824998bebae3b3e09f4d3845256c87585cf62416ee43191", 16); + +//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("** 6: " + res); return res;}); +// deferredResult.addCallback(console.time, 'K283.deferred.multiply - moduled value'); +//deferredResult.addBoth(function(res) {MochiKit.Base.logDebug("2 - " + res); return res;}); +//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("** 7: " + res); return res;}); + deferredResult.addMethod(curve, 'deferredMultiply', value, curve.G()); +//deferredResult.addBoth(function(res) {MochiKit.Base.logDebug("3 - " + res); return res;}); +//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("** 8: " + res); return res;}); +// deferredResult.addBoth(function(res) {console.timeEnd('K283.deferred.multiply - moduled value'); return res;}); +//deferredResult.addBoth(function(res) {MochiKit.Base.logDebug("4 - " + res); return res;}); +//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("** 9: " + res); return res;}); + deferredResult.addCallback(function(res) { + var expectedResult; + + expectedResult = new Clipperz.Crypto.ECC.Koblitz.Point({ + x: new Clipperz.Crypto.ECC.Koblitz.Value('7cf07c0880d1ae59f567a2ce420e78d1fdfc1249df694a60e5d40d23c6dc631e1501b77', 16), + y: new Clipperz.Crypto.ECC.Koblitz.Value('97d1257d5c98cf71cf481bc0a495e0588150ea904526f503cd600f5e971c39700e95f1', 16) + }); + + is(res.x().asString(16), expectedResult.x().asString(16), "ECC.Curve.multiplication: result.x does match"); + is(res.y().asString(16), expectedResult.y().asString(16), "ECC.Curve.multiplication: result.y does match"); + }) +//deferredResult.addBoth(function(res) {MochiKit.Base.logDebug("5 - " + res); return res;}); +//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("** 10: " + res); return res;}); + deferredResult.addBoth(function(res) {SimpleTest.finish(); return res;}); +//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("** 11: " + res); return res;}); + deferredResult.callback(); + + SimpleTest.waitForExplicitFinish(); + + //------------------------------------------------------------------------- +} catch (err) { + + var s = "test suite failure!\n"; + var o = {}; + var k = null; + for (k in err) { + // ensure unique keys?! + if (!o[k]) { + s += k + ": " + err[k] + "\n"; + o[k] = err[k]; + } + } + ok ( false, s ); +} + +</script> +</pre> +</body> +</html> |