bn_test.js 522 B

12345678910111213141516171819202122
  1. new sjcl.test.TestCase("Bignum modular exponentiation test", function (cb) {
  2. if (!sjcl.bn) {
  3. this.unimplemented();
  4. cb && cb();
  5. return;
  6. }
  7. var i, tv, g, x, N, v;
  8. for (i=0; i < sjcl.test.vector.bn_powermod.length; i++) {
  9. tv = sjcl.test.vector.bn_powermod[i];
  10. try {
  11. g = new sjcl.bn(tv.g);
  12. x = new sjcl.bn(tv.x);
  13. N = new sjcl.bn(tv.N);
  14. v = g.powermod(x, N);
  15. this.require(v.equals(new sjcl.bn(tv.v)));
  16. } catch(e) {
  17. this.fail(e);
  18. }
  19. }
  20. cb && cb();
  21. });