BigInteger.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. // AMD-ID "dojox/math/BigInteger"
  2. define("dojox/math/BigInteger", ["dojo", "dojox"], function(dojo, dojox) {
  3. dojo.getObject("math.BigInteger", true, dojox);
  4. dojo.experimental("dojox.math.BigInteger");
  5. // Contributed under CLA by Tom Wu <tjw@cs.Stanford.EDU>
  6. // See http://www-cs-students.stanford.edu/~tjw/jsbn/ for details.
  7. // Basic JavaScript BN library - subset useful for RSA encryption.
  8. // The API for dojox.math.BigInteger closely resembles that of the java.math.BigInteger class in Java.
  9. // Bits per digit
  10. var dbits;
  11. // JavaScript engine analysis
  12. var canary = 0xdeadbeefcafe;
  13. var j_lm = ((canary&0xffffff)==0xefcafe);
  14. // (public) Constructor
  15. function BigInteger(a,b,c) {
  16. if(a != null)
  17. if("number" == typeof a) this._fromNumber(a,b,c);
  18. else if(!b && "string" != typeof a) this._fromString(a,256);
  19. else this._fromString(a,b);
  20. }
  21. // return new, unset BigInteger
  22. function nbi() { return new BigInteger(null); }
  23. // am: Compute w_j += (x*this_i), propagate carries,
  24. // c is initial carry, returns final carry.
  25. // c < 3*dvalue, x < 2*dvalue, this_i < dvalue
  26. // We need to select the fastest one that works in this environment.
  27. // am1: use a single mult and divide to get the high bits,
  28. // max digit bits should be 26 because
  29. // max internal value = 2*dvalue^2-2*dvalue (< 2^53)
  30. function am1(i,x,w,j,c,n) {
  31. while(--n >= 0) {
  32. var v = x*this[i++]+w[j]+c;
  33. c = Math.floor(v/0x4000000);
  34. w[j++] = v&0x3ffffff;
  35. }
  36. return c;
  37. }
  38. // am2 avoids a big mult-and-extract completely.
  39. // Max digit bits should be <= 30 because we do bitwise ops
  40. // on values up to 2*hdvalue^2-hdvalue-1 (< 2^31)
  41. function am2(i,x,w,j,c,n) {
  42. var xl = x&0x7fff, xh = x>>15;
  43. while(--n >= 0) {
  44. var l = this[i]&0x7fff;
  45. var h = this[i++]>>15;
  46. var m = xh*l+h*xl;
  47. l = xl*l+((m&0x7fff)<<15)+w[j]+(c&0x3fffffff);
  48. c = (l>>>30)+(m>>>15)+xh*h+(c>>>30);
  49. w[j++] = l&0x3fffffff;
  50. }
  51. return c;
  52. }
  53. // Alternately, set max digit bits to 28 since some
  54. // browsers slow down when dealing with 32-bit numbers.
  55. function am3(i,x,w,j,c,n) {
  56. var xl = x&0x3fff, xh = x>>14;
  57. while(--n >= 0) {
  58. var l = this[i]&0x3fff;
  59. var h = this[i++]>>14;
  60. var m = xh*l+h*xl;
  61. l = xl*l+((m&0x3fff)<<14)+w[j]+c;
  62. c = (l>>28)+(m>>14)+xh*h;
  63. w[j++] = l&0xfffffff;
  64. }
  65. return c;
  66. }
  67. if(j_lm && (navigator.appName == "Microsoft Internet Explorer")) {
  68. BigInteger.prototype.am = am2;
  69. dbits = 30;
  70. }
  71. else if(j_lm && (navigator.appName != "Netscape")) {
  72. BigInteger.prototype.am = am1;
  73. dbits = 26;
  74. }
  75. else { // Mozilla/Netscape seems to prefer am3
  76. BigInteger.prototype.am = am3;
  77. dbits = 28;
  78. }
  79. var BI_FP = 52;
  80. // Digit conversions
  81. var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
  82. var BI_RC = [];
  83. var rr,vv;
  84. rr = "0".charCodeAt(0);
  85. for(vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv;
  86. rr = "a".charCodeAt(0);
  87. for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
  88. rr = "A".charCodeAt(0);
  89. for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
  90. function int2char(n) { return BI_RM.charAt(n); }
  91. function intAt(s,i) {
  92. var c = BI_RC[s.charCodeAt(i)];
  93. return (c==null)?-1:c;
  94. }
  95. // (protected) copy this to r
  96. function bnpCopyTo(r) {
  97. for(var i = this.t-1; i >= 0; --i) r[i] = this[i];
  98. r.t = this.t;
  99. r.s = this.s;
  100. }
  101. // (protected) set from integer value x, -DV <= x < DV
  102. function bnpFromInt(x) {
  103. this.t = 1;
  104. this.s = (x<0)?-1:0;
  105. if(x > 0) this[0] = x;
  106. else if(x < -1) this[0] = x+_DV;
  107. else this.t = 0;
  108. }
  109. // return bigint initialized to value
  110. function nbv(i) { var r = nbi(); r._fromInt(i); return r; }
  111. // (protected) set from string and radix
  112. function bnpFromString(s,b) {
  113. var k;
  114. if(b == 16) k = 4;
  115. else if(b == 8) k = 3;
  116. else if(b == 256) k = 8; // byte array
  117. else if(b == 2) k = 1;
  118. else if(b == 32) k = 5;
  119. else if(b == 4) k = 2;
  120. else { this.fromRadix(s,b); return; }
  121. this.t = 0;
  122. this.s = 0;
  123. var i = s.length, mi = false, sh = 0;
  124. while(--i >= 0) {
  125. var x = (k==8)?s[i]&0xff:intAt(s,i);
  126. if(x < 0) {
  127. if(s.charAt(i) == "-") mi = true;
  128. continue;
  129. }
  130. mi = false;
  131. if(sh == 0)
  132. this[this.t++] = x;
  133. else if(sh+k > this._DB) {
  134. this[this.t-1] |= (x&((1<<(this._DB-sh))-1))<<sh;
  135. this[this.t++] = (x>>(this._DB-sh));
  136. }
  137. else
  138. this[this.t-1] |= x<<sh;
  139. sh += k;
  140. if(sh >= this._DB) sh -= this._DB;
  141. }
  142. if(k == 8 && (s[0]&0x80) != 0) {
  143. this.s = -1;
  144. if(sh > 0) this[this.t-1] |= ((1<<(this._DB-sh))-1)<<sh;
  145. }
  146. this._clamp();
  147. if(mi) BigInteger.ZERO._subTo(this,this);
  148. }
  149. // (protected) clamp off excess high words
  150. function bnpClamp() {
  151. var c = this.s&this._DM;
  152. while(this.t > 0 && this[this.t-1] == c) --this.t;
  153. }
  154. // (public) return string representation in given radix
  155. function bnToString(b) {
  156. if(this.s < 0) return "-"+this.negate().toString(b);
  157. var k;
  158. if(b == 16) k = 4;
  159. else if(b == 8) k = 3;
  160. else if(b == 2) k = 1;
  161. else if(b == 32) k = 5;
  162. else if(b == 4) k = 2;
  163. else return this._toRadix(b);
  164. var km = (1<<k)-1, d, m = false, r = "", i = this.t;
  165. var p = this._DB-(i*this._DB)%k;
  166. if(i-- > 0) {
  167. if(p < this._DB && (d = this[i]>>p) > 0) { m = true; r = int2char(d); }
  168. while(i >= 0) {
  169. if(p < k) {
  170. d = (this[i]&((1<<p)-1))<<(k-p);
  171. d |= this[--i]>>(p+=this._DB-k);
  172. }
  173. else {
  174. d = (this[i]>>(p-=k))&km;
  175. if(p <= 0) { p += this._DB; --i; }
  176. }
  177. if(d > 0) m = true;
  178. if(m) r += int2char(d);
  179. }
  180. }
  181. return m?r:"0";
  182. }
  183. // (public) -this
  184. function bnNegate() { var r = nbi(); BigInteger.ZERO._subTo(this,r); return r; }
  185. // (public) |this|
  186. function bnAbs() { return (this.s<0)?this.negate():this; }
  187. // (public) return + if this > a, - if this < a, 0 if equal
  188. function bnCompareTo(a) {
  189. var r = this.s-a.s;
  190. if(r) return r;
  191. var i = this.t;
  192. r = i-a.t;
  193. if(r) return r;
  194. while(--i >= 0) if((r = this[i] - a[i])) return r;
  195. return 0;
  196. }
  197. // returns bit length of the integer x
  198. function nbits(x) {
  199. var r = 1, t;
  200. if((t=x>>>16)) { x = t; r += 16; }
  201. if((t=x>>8)) { x = t; r += 8; }
  202. if((t=x>>4)) { x = t; r += 4; }
  203. if((t=x>>2)) { x = t; r += 2; }
  204. if((t=x>>1)) { x = t; r += 1; }
  205. return r;
  206. }
  207. // (public) return the number of bits in "this"
  208. function bnBitLength() {
  209. if(this.t <= 0) return 0;
  210. return this._DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this._DM));
  211. }
  212. // (protected) r = this << n*DB
  213. function bnpDLShiftTo(n,r) {
  214. var i;
  215. for(i = this.t-1; i >= 0; --i) r[i+n] = this[i];
  216. for(i = n-1; i >= 0; --i) r[i] = 0;
  217. r.t = this.t+n;
  218. r.s = this.s;
  219. }
  220. // (protected) r = this >> n*DB
  221. function bnpDRShiftTo(n,r) {
  222. for(var i = n; i < this.t; ++i) r[i-n] = this[i];
  223. r.t = Math.max(this.t-n,0);
  224. r.s = this.s;
  225. }
  226. // (protected) r = this << n
  227. function bnpLShiftTo(n,r) {
  228. var bs = n%this._DB;
  229. var cbs = this._DB-bs;
  230. var bm = (1<<cbs)-1;
  231. var ds = Math.floor(n/this._DB), c = (this.s<<bs)&this._DM, i;
  232. for(i = this.t-1; i >= 0; --i) {
  233. r[i+ds+1] = (this[i]>>cbs)|c;
  234. c = (this[i]&bm)<<bs;
  235. }
  236. for(i = ds-1; i >= 0; --i) r[i] = 0;
  237. r[ds] = c;
  238. r.t = this.t+ds+1;
  239. r.s = this.s;
  240. r._clamp();
  241. }
  242. // (protected) r = this >> n
  243. function bnpRShiftTo(n,r) {
  244. r.s = this.s;
  245. var ds = Math.floor(n/this._DB);
  246. if(ds >= this.t) { r.t = 0; return; }
  247. var bs = n%this._DB;
  248. var cbs = this._DB-bs;
  249. var bm = (1<<bs)-1;
  250. r[0] = this[ds]>>bs;
  251. for(var i = ds+1; i < this.t; ++i) {
  252. r[i-ds-1] |= (this[i]&bm)<<cbs;
  253. r[i-ds] = this[i]>>bs;
  254. }
  255. if(bs > 0) r[this.t-ds-1] |= (this.s&bm)<<cbs;
  256. r.t = this.t-ds;
  257. r._clamp();
  258. }
  259. // (protected) r = this - a
  260. function bnpSubTo(a,r) {
  261. var i = 0, c = 0, m = Math.min(a.t,this.t);
  262. while(i < m) {
  263. c += this[i]-a[i];
  264. r[i++] = c&this._DM;
  265. c >>= this._DB;
  266. }
  267. if(a.t < this.t) {
  268. c -= a.s;
  269. while(i < this.t) {
  270. c += this[i];
  271. r[i++] = c&this._DM;
  272. c >>= this._DB;
  273. }
  274. c += this.s;
  275. }
  276. else {
  277. c += this.s;
  278. while(i < a.t) {
  279. c -= a[i];
  280. r[i++] = c&this._DM;
  281. c >>= this._DB;
  282. }
  283. c -= a.s;
  284. }
  285. r.s = (c<0)?-1:0;
  286. if(c < -1) r[i++] = this._DV+c;
  287. else if(c > 0) r[i++] = c;
  288. r.t = i;
  289. r._clamp();
  290. }
  291. // (protected) r = this * a, r != this,a (HAC 14.12)
  292. // "this" should be the larger one if appropriate.
  293. function bnpMultiplyTo(a,r) {
  294. var x = this.abs(), y = a.abs();
  295. var i = x.t;
  296. r.t = i+y.t;
  297. while(--i >= 0) r[i] = 0;
  298. for(i = 0; i < y.t; ++i) r[i+x.t] = x.am(0,y[i],r,i,0,x.t);
  299. r.s = 0;
  300. r._clamp();
  301. if(this.s != a.s) BigInteger.ZERO._subTo(r,r);
  302. }
  303. // (protected) r = this^2, r != this (HAC 14.16)
  304. function bnpSquareTo(r) {
  305. var x = this.abs();
  306. var i = r.t = 2*x.t;
  307. while(--i >= 0) r[i] = 0;
  308. for(i = 0; i < x.t-1; ++i) {
  309. var c = x.am(i,x[i],r,2*i,0,1);
  310. if((r[i+x.t]+=x.am(i+1,2*x[i],r,2*i+1,c,x.t-i-1)) >= x._DV) {
  311. r[i+x.t] -= x._DV;
  312. r[i+x.t+1] = 1;
  313. }
  314. }
  315. if(r.t > 0) r[r.t-1] += x.am(i,x[i],r,2*i,0,1);
  316. r.s = 0;
  317. r._clamp();
  318. }
  319. // (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)
  320. // r != q, this != m. q or r may be null.
  321. function bnpDivRemTo(m,q,r) {
  322. var pm = m.abs();
  323. if(pm.t <= 0) return;
  324. var pt = this.abs();
  325. if(pt.t < pm.t) {
  326. if(q != null) q._fromInt(0);
  327. if(r != null) this._copyTo(r);
  328. return;
  329. }
  330. if(r == null) r = nbi();
  331. var y = nbi(), ts = this.s, ms = m.s;
  332. var nsh = this._DB-nbits(pm[pm.t-1]); // normalize modulus
  333. if(nsh > 0) { pm._lShiftTo(nsh,y); pt._lShiftTo(nsh,r); }
  334. else { pm._copyTo(y); pt._copyTo(r); }
  335. var ys = y.t;
  336. var y0 = y[ys-1];
  337. if(y0 == 0) return;
  338. var yt = y0*(1<<this._F1)+((ys>1)?y[ys-2]>>this._F2:0);
  339. var d1 = this._FV/yt, d2 = (1<<this._F1)/yt, e = 1<<this._F2;
  340. var i = r.t, j = i-ys, t = (q==null)?nbi():q;
  341. y._dlShiftTo(j,t);
  342. if(r.compareTo(t) >= 0) {
  343. r[r.t++] = 1;
  344. r._subTo(t,r);
  345. }
  346. BigInteger.ONE._dlShiftTo(ys,t);
  347. t._subTo(y,y); // "negative" y so we can replace sub with am later
  348. while(y.t < ys) y[y.t++] = 0;
  349. while(--j >= 0) {
  350. // Estimate quotient digit
  351. var qd = (r[--i]==y0)?this._DM:Math.floor(r[i]*d1+(r[i-1]+e)*d2);
  352. if((r[i]+=y.am(0,qd,r,j,0,ys)) < qd) { // Try it out
  353. y._dlShiftTo(j,t);
  354. r._subTo(t,r);
  355. while(r[i] < --qd) r._subTo(t,r);
  356. }
  357. }
  358. if(q != null) {
  359. r._drShiftTo(ys,q);
  360. if(ts != ms) BigInteger.ZERO._subTo(q,q);
  361. }
  362. r.t = ys;
  363. r._clamp();
  364. if(nsh > 0) r._rShiftTo(nsh,r); // Denormalize remainder
  365. if(ts < 0) BigInteger.ZERO._subTo(r,r);
  366. }
  367. // (public) this mod a
  368. function bnMod(a) {
  369. var r = nbi();
  370. this.abs()._divRemTo(a,null,r);
  371. if(this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a._subTo(r,r);
  372. return r;
  373. }
  374. // Modular reduction using "classic" algorithm
  375. function Classic(m) { this.m = m; }
  376. function cConvert(x) {
  377. if(x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m);
  378. else return x;
  379. }
  380. function cRevert(x) { return x; }
  381. function cReduce(x) { x._divRemTo(this.m,null,x); }
  382. function cMulTo(x,y,r) { x._multiplyTo(y,r); this.reduce(r); }
  383. function cSqrTo(x,r) { x._squareTo(r); this.reduce(r); }
  384. dojo.extend(Classic, {
  385. convert: cConvert,
  386. revert: cRevert,
  387. reduce: cReduce,
  388. mulTo: cMulTo,
  389. sqrTo: cSqrTo
  390. });
  391. // (protected) return "-1/this % 2^DB"; useful for Mont. reduction
  392. // justification:
  393. // xy == 1 (mod m)
  394. // xy = 1+km
  395. // xy(2-xy) = (1+km)(1-km)
  396. // x[y(2-xy)] = 1-k^2m^2
  397. // x[y(2-xy)] == 1 (mod m^2)
  398. // if y is 1/x mod m, then y(2-xy) is 1/x mod m^2
  399. // should reduce x and y(2-xy) by m^2 at each step to keep size bounded.
  400. // JS multiply "overflows" differently from C/C++, so care is needed here.
  401. function bnpInvDigit() {
  402. if(this.t < 1) return 0;
  403. var x = this[0];
  404. if((x&1) == 0) return 0;
  405. var y = x&3; // y == 1/x mod 2^2
  406. y = (y*(2-(x&0xf)*y))&0xf; // y == 1/x mod 2^4
  407. y = (y*(2-(x&0xff)*y))&0xff; // y == 1/x mod 2^8
  408. y = (y*(2-(((x&0xffff)*y)&0xffff)))&0xffff; // y == 1/x mod 2^16
  409. // last step - calculate inverse mod DV directly;
  410. // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints
  411. y = (y*(2-x*y%this._DV))%this._DV; // y == 1/x mod 2^dbits
  412. // we really want the negative inverse, and -DV < y < DV
  413. return (y>0)?this._DV-y:-y;
  414. }
  415. // Montgomery reduction
  416. function Montgomery(m) {
  417. this.m = m;
  418. this.mp = m._invDigit();
  419. this.mpl = this.mp&0x7fff;
  420. this.mph = this.mp>>15;
  421. this.um = (1<<(m._DB-15))-1;
  422. this.mt2 = 2*m.t;
  423. }
  424. // xR mod m
  425. function montConvert(x) {
  426. var r = nbi();
  427. x.abs()._dlShiftTo(this.m.t,r);
  428. r._divRemTo(this.m,null,r);
  429. if(x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m._subTo(r,r);
  430. return r;
  431. }
  432. // x/R mod m
  433. function montRevert(x) {
  434. var r = nbi();
  435. x._copyTo(r);
  436. this.reduce(r);
  437. return r;
  438. }
  439. // x = x/R mod m (HAC 14.32)
  440. function montReduce(x) {
  441. while(x.t <= this.mt2) // pad x so am has enough room later
  442. x[x.t++] = 0;
  443. for(var i = 0; i < this.m.t; ++i) {
  444. // faster way of calculating u0 = x[i]*mp mod DV
  445. var j = x[i]&0x7fff;
  446. var u0 = (j*this.mpl+(((j*this.mph+(x[i]>>15)*this.mpl)&this.um)<<15))&x._DM;
  447. // use am to combine the multiply-shift-add into one call
  448. j = i+this.m.t;
  449. x[j] += this.m.am(0,u0,x,i,0,this.m.t);
  450. // propagate carry
  451. while(x[j] >= x._DV) { x[j] -= x._DV; x[++j]++; }
  452. }
  453. x._clamp();
  454. x._drShiftTo(this.m.t,x);
  455. if(x.compareTo(this.m) >= 0) x._subTo(this.m,x);
  456. }
  457. // r = "x^2/R mod m"; x != r
  458. function montSqrTo(x,r) { x._squareTo(r); this.reduce(r); }
  459. // r = "xy/R mod m"; x,y != r
  460. function montMulTo(x,y,r) { x._multiplyTo(y,r); this.reduce(r); }
  461. dojo.extend(Montgomery, {
  462. convert: montConvert,
  463. revert: montRevert,
  464. reduce: montReduce,
  465. mulTo: montMulTo,
  466. sqrTo: montSqrTo
  467. });
  468. // (protected) true iff this is even
  469. function bnpIsEven() { return ((this.t>0)?(this[0]&1):this.s) == 0; }
  470. // (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
  471. function bnpExp(e,z) {
  472. if(e > 0xffffffff || e < 1) return BigInteger.ONE;
  473. var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e)-1;
  474. g._copyTo(r);
  475. while(--i >= 0) {
  476. z.sqrTo(r,r2);
  477. if((e&(1<<i)) > 0) z.mulTo(r2,g,r);
  478. else { var t = r; r = r2; r2 = t; }
  479. }
  480. return z.revert(r);
  481. }
  482. // (public) this^e % m, 0 <= e < 2^32
  483. function bnModPowInt(e,m) {
  484. var z;
  485. if(e < 256 || m._isEven()) z = new Classic(m); else z = new Montgomery(m);
  486. return this._exp(e,z);
  487. }
  488. dojo.extend(BigInteger, {
  489. // protected, not part of the official API
  490. _DB: dbits,
  491. _DM: (1 << dbits) - 1,
  492. _DV: 1 << dbits,
  493. _FV: Math.pow(2, BI_FP),
  494. _F1: BI_FP - dbits,
  495. _F2: 2 * dbits-BI_FP,
  496. // protected
  497. _copyTo: bnpCopyTo,
  498. _fromInt: bnpFromInt,
  499. _fromString: bnpFromString,
  500. _clamp: bnpClamp,
  501. _dlShiftTo: bnpDLShiftTo,
  502. _drShiftTo: bnpDRShiftTo,
  503. _lShiftTo: bnpLShiftTo,
  504. _rShiftTo: bnpRShiftTo,
  505. _subTo: bnpSubTo,
  506. _multiplyTo: bnpMultiplyTo,
  507. _squareTo: bnpSquareTo,
  508. _divRemTo: bnpDivRemTo,
  509. _invDigit: bnpInvDigit,
  510. _isEven: bnpIsEven,
  511. _exp: bnpExp,
  512. // public
  513. toString: bnToString,
  514. negate: bnNegate,
  515. abs: bnAbs,
  516. compareTo: bnCompareTo,
  517. bitLength: bnBitLength,
  518. mod: bnMod,
  519. modPowInt: bnModPowInt
  520. });
  521. dojo._mixin(BigInteger, {
  522. // "constants"
  523. ZERO: nbv(0),
  524. ONE: nbv(1),
  525. // internal functions
  526. _nbi: nbi,
  527. _nbv: nbv,
  528. _nbits: nbits,
  529. // internal classes
  530. _Montgomery: Montgomery
  531. });
  532. // export to DojoX
  533. dojox.math.BigInteger = BigInteger;
  534. return dojox.math.BigInteger;
  535. });