diff options
Diffstat (limited to 'test/ecc_conv.js')
-rw-r--r-- | test/ecc_conv.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/ecc_conv.js b/test/ecc_conv.js new file mode 100644 index 0000000..fcc9f3f --- /dev/null +++ b/test/ecc_conv.js @@ -0,0 +1,33 @@ +new sjcl.test.TestCase("ECC convenience test", function (cb) { + if (!sjcl.ecc) { + this.unimplemented(); + cb && cb(); + return; + } + + try { + // Uses hard-coded randomness just to give the test something to work with. + // This isn't how this is supposed to be used in the real world. + var random = [ -625324409, + -1863172196, + -1745409890, + -1513341554, + 1970821986, + -532843769, + -200096675, + -1271344660 ]; + + sjcl.random.addEntropy(random, 8 * 4 * random.length, "crypto.randomBytes") + + var keys = sjcl.ecc.elGamal.generateKeys(192,0); + + var ciphertext = sjcl.encrypt(keys.pub, "hello world"); + var plaintext = sjcl.decrypt(keys.sec, ciphertext); + + this.require(plaintext == "hello world"); + } catch(e) { + console.log(e.stack) + this.fail(e); + } + cb && cb(); +}); |