0) { // 223
+ if(p < this.DB && (d = this[i]>>p) > 0) { m = true; r = int2char(d); } // 224
+ while(i >= 0) { // 225
+ if(p < k) { // 226
+ d = (this[i]&((1<>(p+=this.DB-k); // 228
+ } // 229
+ else { // 230
+ d = (this[i]>>(p-=k))&km; // 231
+ if(p <= 0) { p += this.DB; --i; } // 232
+ } // 233
+ if(d > 0) m = true; // 234
+ if(m) r += int2char(d); // 235
+ } // 236
+ } // 237
+ return m?r:"0"; // 238
+} // 239
+ // 240
+// (public) -this // 241
+function bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this,r); return r; } // 242
+ // 243
+// (public) |this| // 244
+function bnAbs() { return (this.s<0)?this.negate():this; } // 245
+ // 246
+// (public) return + if this > a, - if this < a, 0 if equal // 247
+function bnCompareTo(a) { // 248
+ var r = this.s-a.s; // 249
+ if(r != 0) return r; // 250
+ var i = this.t; // 251
+ r = i-a.t; // 252
+ if(r != 0) return r; // 253
+ while(--i >= 0) if((r=this[i]-a[i]) != 0) return r; // 254
+ return 0; // 255
+} // 256
+ // 257
+// returns bit length of the integer x // 258
+function nbits(x) { // 259
+ var r = 1, t; // 260
+ if((t=x>>>16) != 0) { x = t; r += 16; } // 261
+ if((t=x>>8) != 0) { x = t; r += 8; } // 262
+ if((t=x>>4) != 0) { x = t; r += 4; } // 263
+ if((t=x>>2) != 0) { x = t; r += 2; } // 264
+ if((t=x>>1) != 0) { x = t; r += 1; } // 265
+ return r; // 266
+} // 267
+ // 268
+// (public) return the number of bits in "this" // 269
+function bnBitLength() { // 270
+ if(this.t <= 0) return 0; // 271
+ return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM)); // 272
+} // 273
+ // 274
+// (protected) r = this << n*DB // 275
+function bnpDLShiftTo(n,r) { // 276
+ var i; // 277
+ for(i = this.t-1; i >= 0; --i) r[i+n] = this[i]; // 278
+ for(i = n-1; i >= 0; --i) r[i] = 0; // 279
+ r.t = this.t+n; // 280
+ r.s = this.s; // 281
+} // 282
+ // 283
+// (protected) r = this >> n*DB // 284
+function bnpDRShiftTo(n,r) { // 285
+ for(var i = n; i < this.t; ++i) r[i-n] = this[i]; // 286
+ r.t = Math.max(this.t-n,0); // 287
+ r.s = this.s; // 288
+} // 289
+ // 290
+// (protected) r = this << n // 291
+function bnpLShiftTo(n,r) { // 292
+ var bs = n%this.DB; // 293
+ var cbs = this.DB-bs; // 294
+ var bm = (1<= 0; --i) { // 297
+ r[i+ds+1] = (this[i]>>cbs)|c; // 298
+ c = (this[i]&bm)<= 0; --i) r[i] = 0; // 301
+ r[ds] = c; // 302
+ r.t = this.t+ds+1; // 303
+ r.s = this.s; // 304
+ r.clamp(); // 305
+} // 306
+ // 307
+// (protected) r = this >> n // 308
+function bnpRShiftTo(n,r) { // 309
+ r.s = this.s; // 310
+ var ds = Math.floor(n/this.DB); // 311
+ if(ds >= this.t) { r.t = 0; return; } // 312
+ var bs = n%this.DB; // 313
+ var cbs = this.DB-bs; // 314
+ var bm = (1<>bs; // 316
+ for(var i = ds+1; i < this.t; ++i) { // 317
+ r[i-ds-1] |= (this[i]&bm)<>bs; // 319
+ } // 320
+ if(bs > 0) r[this.t-ds-1] |= (this.s&bm)<>= this.DB; // 332
+ } // 333
+ if(a.t < this.t) { // 334
+ c -= a.s; // 335
+ while(i < this.t) { // 336
+ c += this[i]; // 337
+ r[i++] = c&this.DM; // 338
+ c >>= this.DB; // 339
+ } // 340
+ c += this.s; // 341
+ } // 342
+ else { // 343
+ c += this.s; // 344
+ while(i < a.t) { // 345
+ c -= a[i]; // 346
+ r[i++] = c&this.DM; // 347
+ c >>= this.DB; // 348
+ } // 349
+ c -= a.s; // 350
+ } // 351
+ r.s = (c<0)?-1:0; // 352
+ if(c < -1) r[i++] = this.DV+c; // 353
+ else if(c > 0) r[i++] = c; // 354
+ r.t = i; // 355
+ r.clamp(); // 356
+} // 357
+ // 358
+// (protected) r = this * a, r != this,a (HAC 14.12) // 359
+// "this" should be the larger one if appropriate. // 360
+function bnpMultiplyTo(a,r) { // 361
+ var x = this.abs(), y = a.abs(); // 362
+ var i = x.t; // 363
+ r.t = i+y.t; // 364
+ while(--i >= 0) r[i] = 0; // 365
+ for(i = 0; i < y.t; ++i) r[i+x.t] = x.am(0,y[i],r,i,0,x.t); // 366
+ r.s = 0; // 367
+ r.clamp(); // 368
+ if(this.s != a.s) BigInteger.ZERO.subTo(r,r); // 369
+} // 370
+ // 371
+// (protected) r = this^2, r != this (HAC 14.16) // 372
+function bnpSquareTo(r) { // 373
+ var x = this.abs(); // 374
+ var i = r.t = 2*x.t; // 375
+ while(--i >= 0) r[i] = 0; // 376
+ for(i = 0; i < x.t-1; ++i) { // 377
+ var c = x.am(i,x[i],r,2*i,0,1); // 378
+ if((r[i+x.t]+=x.am(i+1,2*x[i],r,2*i+1,c,x.t-i-1)) >= x.DV) { // 379
+ r[i+x.t] -= x.DV; // 380
+ r[i+x.t+1] = 1; // 381
+ } // 382
+ } // 383
+ if(r.t > 0) r[r.t-1] += x.am(i,x[i],r,2*i,0,1); // 384
+ r.s = 0; // 385
+ r.clamp(); // 386
+} // 387
+ // 388
+// (protected) divide this by m, quotient and remainder to q, r (HAC 14.20) // 389
+// r != q, this != m. q or r may be null. // 390
+function bnpDivRemTo(m,q,r) { // 391
+ var pm = m.abs(); // 392
+ if(pm.t <= 0) return; // 393
+ var pt = this.abs(); // 394
+ if(pt.t < pm.t) { // 395
+ if(q != null) q.fromInt(0); // 396
+ if(r != null) this.copyTo(r); // 397
+ return; // 398
+ } // 399
+ if(r == null) r = nbi(); // 400
+ var y = nbi(), ts = this.s, ms = m.s; // 401
+ var nsh = this.DB-nbits(pm[pm.t-1]); // normalize modulus // 402
+ if(nsh > 0) { pm.lShiftTo(nsh,y); pt.lShiftTo(nsh,r); } // 403
+ else { pm.copyTo(y); pt.copyTo(r); } // 404
+ var ys = y.t; // 405
+ var y0 = y[ys-1]; // 406
+ if(y0 == 0) return; // 407
+ var yt = y0*(1<1)?y[ys-2]>>this.F2:0); // 408
+ var d1 = this.FV/yt, d2 = (1<= 0) { // 412
+ r[r.t++] = 1; // 413
+ r.subTo(t,r); // 414
+ } // 415
+ BigInteger.ONE.dlShiftTo(ys,t); // 416
+ t.subTo(y,y); // "negative" y so we can replace sub with am later // 417
+ while(y.t < ys) y[y.t++] = 0; // 418
+ while(--j >= 0) { // 419
+ // Estimate quotient digit // 420
+ var qd = (r[--i]==y0)?this.DM:Math.floor(r[i]*d1+(r[i-1]+e)*d2); // 421
+ if((r[i]+=y.am(0,qd,r,j,0,ys)) < qd) { // Try it out // 422
+ y.dlShiftTo(j,t); // 423
+ r.subTo(t,r); // 424
+ while(r[i] < --qd) r.subTo(t,r); // 425
+ } // 426
+ } // 427
+ if(q != null) { // 428
+ r.drShiftTo(ys,q); // 429
+ if(ts != ms) BigInteger.ZERO.subTo(q,q); // 430
+ } // 431
+ r.t = ys; // 432
+ r.clamp(); // 433
+ if(nsh > 0) r.rShiftTo(nsh,r); // Denormalize remainder // 434
+ if(ts < 0) BigInteger.ZERO.subTo(r,r); // 435
+} // 436
+ // 437
+// (public) this mod a // 438
+function bnMod(a) { // 439
+ var r = nbi(); // 440
+ this.abs().divRemTo(a,null,r); // 441
+ if(this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r,r); // 442
+ return r; // 443
+} // 444
+ // 445
+// Modular reduction using "classic" algorithm // 446
+function Classic(m) { this.m = m; } // 447
+function cConvert(x) { // 448
+ if(x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m); // 449
+ else return x; // 450
+} // 451
+function cRevert(x) { return x; } // 452
+function cReduce(x) { x.divRemTo(this.m,null,x); } // 453
+function cMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); } // 454
+function cSqrTo(x,r) { x.squareTo(r); this.reduce(r); } // 455
+ // 456
+Classic.prototype.convert = cConvert; // 457
+Classic.prototype.revert = cRevert; // 458
+Classic.prototype.reduce = cReduce; // 459
+Classic.prototype.mulTo = cMulTo; // 460
+Classic.prototype.sqrTo = cSqrTo; // 461
+ // 462
+// (protected) return "-1/this % 2^DB"; useful for Mont. reduction // 463
+// justification: // 464
+// xy == 1 (mod m) // 465
+// xy = 1+km // 466
+// xy(2-xy) = (1+km)(1-km) // 467
+// x[y(2-xy)] = 1-k^2m^2 // 468
+// x[y(2-xy)] == 1 (mod m^2) // 469
+// if y is 1/x mod m, then y(2-xy) is 1/x mod m^2 // 470
+// should reduce x and y(2-xy) by m^2 at each step to keep size bounded. // 471
+// JS multiply "overflows" differently from C/C++, so care is needed here. // 472
+function bnpInvDigit() { // 473
+ if(this.t < 1) return 0; // 474
+ var x = this[0]; // 475
+ if((x&1) == 0) return 0; // 476
+ var y = x&3; // y == 1/x mod 2^2 // 477
+ y = (y*(2-(x&0xf)*y))&0xf; // y == 1/x mod 2^4 // 478
+ y = (y*(2-(x&0xff)*y))&0xff; // y == 1/x mod 2^8 // 479
+ y = (y*(2-(((x&0xffff)*y)&0xffff)))&0xffff; // y == 1/x mod 2^16 // 480
+ // last step - calculate inverse mod DV directly; // 481
+ // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints // 482
+ y = (y*(2-x*y%this.DV))%this.DV; // y == 1/x mod 2^dbits // 483
+ // we really want the negative inverse, and -DV < y < DV // 484
+ return (y>0)?this.DV-y:-y; // 485
+} // 486
+ // 487
+// Montgomery reduction // 488
+function Montgomery(m) { // 489
+ this.m = m; // 490
+ this.mp = m.invDigit(); // 491
+ this.mpl = this.mp&0x7fff; // 492
+ this.mph = this.mp>>15; // 493
+ this.um = (1<<(m.DB-15))-1; // 494
+ this.mt2 = 2*m.t; // 495
+} // 496
+ // 497
+// xR mod m // 498
+function montConvert(x) { // 499
+ var r = nbi(); // 500
+ x.abs().dlShiftTo(this.m.t,r); // 501
+ r.divRemTo(this.m,null,r); // 502
+ if(x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r,r); // 503
+ return r; // 504
+} // 505
+ // 506
+// x/R mod m // 507
+function montRevert(x) { // 508
+ var r = nbi(); // 509
+ x.copyTo(r); // 510
+ this.reduce(r); // 511
+ return r; // 512
+} // 513
+ // 514
+// x = x/R mod m (HAC 14.32) // 515
+function montReduce(x) { // 516
+ while(x.t <= this.mt2) // pad x so am has enough room later // 517
+ x[x.t++] = 0; // 518
+ for(var i = 0; i < this.m.t; ++i) { // 519
+ // faster way of calculating u0 = x[i]*mp mod DV // 520
+ var j = x[i]&0x7fff; // 521
+ var u0 = (j*this.mpl+(((j*this.mph+(x[i]>>15)*this.mpl)&this.um)<<15))&x.DM; // 522
+ // use am to combine the multiply-shift-add into one call // 523
+ j = i+this.m.t; // 524
+ x[j] += this.m.am(0,u0,x,i,0,this.m.t); // 525
+ // propagate carry // 526
+ while(x[j] >= x.DV) { x[j] -= x.DV; x[++j]++; } // 527
+ } // 528
+ x.clamp(); // 529
+ x.drShiftTo(this.m.t,x); // 530
+ if(x.compareTo(this.m) >= 0) x.subTo(this.m,x); // 531
+} // 532
+ // 533
+// r = "x^2/R mod m"; x != r // 534
+function montSqrTo(x,r) { x.squareTo(r); this.reduce(r); } // 535
+ // 536
+// r = "xy/R mod m"; x,y != r // 537
+function montMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); } // 538
+ // 539
+Montgomery.prototype.convert = montConvert; // 540
+Montgomery.prototype.revert = montRevert; // 541
+Montgomery.prototype.reduce = montReduce; // 542
+Montgomery.prototype.mulTo = montMulTo; // 543
+Montgomery.prototype.sqrTo = montSqrTo; // 544
+ // 545
+// (protected) true iff this is even // 546
+function bnpIsEven() { return ((this.t>0)?(this[0]&1):this.s) == 0; } // 547
+ // 548
+// (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79) // 549
+function bnpExp(e,z) { // 550
+ if(e > 0xffffffff || e < 1) return BigInteger.ONE; // 551
+ var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e)-1; // 552
+ g.copyTo(r); // 553
+ while(--i >= 0) { // 554
+ z.sqrTo(r,r2); // 555
+ if((e&(1< 0) z.mulTo(r2,g,r); // 556
+ else { var t = r; r = r2; r2 = t; } // 557
+ } // 558
+ return z.revert(r); // 559
+} // 560
+ // 561
+// (public) this^e % m, 0 <= e < 2^32 // 562
+function bnModPowInt(e,m) { // 563
+ var z; // 564
+ if(e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m); // 565
+ return this.exp(e,z); // 566
+} // 567
+ // 568
+// protected // 569
+BigInteger.prototype.copyTo = bnpCopyTo; // 570
+BigInteger.prototype.fromInt = bnpFromInt; // 571
+BigInteger.prototype.fromString = bnpFromString; // 572
+BigInteger.prototype.clamp = bnpClamp; // 573
+BigInteger.prototype.dlShiftTo = bnpDLShiftTo; // 574
+BigInteger.prototype.drShiftTo = bnpDRShiftTo; // 575
+BigInteger.prototype.lShiftTo = bnpLShiftTo; // 576
+BigInteger.prototype.rShiftTo = bnpRShiftTo; // 577
+BigInteger.prototype.subTo = bnpSubTo; // 578
+BigInteger.prototype.multiplyTo = bnpMultiplyTo; // 579
+BigInteger.prototype.squareTo = bnpSquareTo; // 580
+BigInteger.prototype.divRemTo = bnpDivRemTo; // 581
+BigInteger.prototype.invDigit = bnpInvDigit; // 582
+BigInteger.prototype.isEven = bnpIsEven; // 583
+BigInteger.prototype.exp = bnpExp; // 584
+ // 585
+// public // 586
+BigInteger.prototype.toString = bnToString; // 587
+BigInteger.prototype.negate = bnNegate; // 588
+BigInteger.prototype.abs = bnAbs; // 589
+BigInteger.prototype.compareTo = bnCompareTo; // 590
+BigInteger.prototype.bitLength = bnBitLength; // 591
+BigInteger.prototype.mod = bnMod; // 592
+BigInteger.prototype.modPowInt = bnModPowInt; // 593
+ // 594
+// "constants" // 595
+BigInteger.ZERO = nbv(0); // 596
+BigInteger.ONE = nbv(1); // 597
+ // 598
+ // 599
+/// BEGIN jsbn2.js // 600
+ // 601
+/* // 602
+ * Copyright (c) 2003-2005 Tom Wu // 603
+ * All Rights Reserved. // 604
+ * // 605
+ * Permission is hereby granted, free of charge, to any person obtaining // 606
+ * a copy of this software and associated documentation files (the // 607
+ * "Software"), to deal in the Software without restriction, including // 608
+ * without limitation the rights to use, copy, modify, merge, publish, // 609
+ * distribute, sublicense, and/or sell copies of the Software, and to // 610
+ * permit persons to whom the Software is furnished to do so, subject to // 611
+ * the following conditions: // 612
+ * // 613
+ * The above copyright notice and this permission notice shall be // 614
+ * included in all copies or substantial portions of the Software. // 615
+ * // 616
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, // 617
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY // 618
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. // 619
+ * // 620
+ * IN NO EVENT SHALL TOM WU BE LIABLE FOR ANY SPECIAL, INCIDENTAL, // 621
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER // 622
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF // 623
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT // 624
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // 625
+ * // 626
+ * In addition, the following condition applies: // 627
+ * // 628
+ * All redistributions must retain an intact copy of this copyright notice // 629
+ * and disclaimer. // 630
+ */ // 631
+ // 632
+// Extended JavaScript BN functions, required for RSA private ops. // 633
+ // 634
+// (public) // 635
+function bnClone() { var r = nbi(); this.copyTo(r); return r; } // 636
+ // 637
+// (public) return value as integer // 638
+function bnIntValue() { // 639
+ if(this.s < 0) { // 640
+ if(this.t == 1) return this[0]-this.DV; // 641
+ else if(this.t == 0) return -1; // 642
+ } // 643
+ else if(this.t == 1) return this[0]; // 644
+ else if(this.t == 0) return 0; // 645
+ // assumes 16 < DB < 32 // 646
+ return ((this[1]&((1<<(32-this.DB))-1))<>24; } // 651
+ // 652
+// (public) return value as short (assumes DB>=16) // 653
+function bnShortValue() { return (this.t==0)?this.s:(this[0]<<16)>>16; } // 654
+ // 655
+// (protected) return x s.t. r^x < DV // 656
+function bnpChunkSize(r) { return Math.floor(Math.LN2*this.DB/Math.log(r)); } // 657
+ // 658
+// (public) 0 if this == 0, 1 if this > 0 // 659
+function bnSigNum() { // 660
+ if(this.s < 0) return -1; // 661
+ else if(this.t <= 0 || (this.t == 1 && this[0] <= 0)) return 0; // 662
+ else return 1; // 663
+} // 664
+ // 665
+// (protected) convert to radix string // 666
+function bnpToRadix(b) { // 667
+ if(b == null) b = 10; // 668
+ if(this.signum() == 0 || b < 2 || b > 36) return "0"; // 669
+ var cs = this.chunkSize(b); // 670
+ var a = Math.pow(b,cs); // 671
+ var d = nbv(a), y = nbi(), z = nbi(), r = ""; // 672
+ this.divRemTo(d,y,z); // 673
+ while(y.signum() > 0) { // 674
+ r = (a+z.intValue()).toString(b).substr(1) + r; // 675
+ y.divRemTo(d,y,z); // 676
+ } // 677
+ return z.intValue().toString(b) + r; // 678
+} // 679
+ // 680
+// (protected) convert from radix string // 681
+function bnpFromRadix(s,b) { // 682
+ this.fromInt(0); // 683
+ if(b == null) b = 10; // 684
+ var cs = this.chunkSize(b); // 685
+ var d = Math.pow(b,cs), mi = false, j = 0, w = 0; // 686
+ for(var i = 0; i < s.length; ++i) { // 687
+ var x = intAt(s,i); // 688
+ if(x < 0) { // 689
+ if(s.charAt(i) == "-" && this.signum() == 0) mi = true; // 690
+ continue; // 691
+ } // 692
+ w = b*w+x; // 693
+ if(++j >= cs) { // 694
+ this.dMultiply(d); // 695
+ this.dAddOffset(w,0); // 696
+ j = 0; // 697
+ w = 0; // 698
+ } // 699
+ } // 700
+ if(j > 0) { // 701
+ this.dMultiply(Math.pow(b,j)); // 702
+ this.dAddOffset(w,0); // 703
+ } // 704
+ if(mi) BigInteger.ZERO.subTo(this,this); // 705
+} // 706
+ // 707
+// (protected) alternate constructor // 708
+function bnpFromNumber(a,b,c) { // 709
+ if("number" == typeof b) { // 710
+ // new BigInteger(int,int,RNG) // 711
+ if(a < 2) this.fromInt(1); // 712
+ else { // 713
+ this.fromNumber(a,c); // 714
+ if(!this.testBit(a-1)) // force MSB set // 715
+ this.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,this); // 716
+ if(this.isEven()) this.dAddOffset(1,0); // force odd // 717
+ while(!this.isProbablePrime(b)) { // 718
+ this.dAddOffset(2,0); // 719
+ if(this.bitLength() > a) this.subTo(BigInteger.ONE.shiftLeft(a-1),this); // 720
+ } // 721
+ } // 722
+ } // 723
+ else { // 724
+ // new BigInteger(int,RNG) // 725
+ var x = new Array(), t = a&7; // 726
+ x.length = (a>>3)+1; // 727
+ b.nextBytes(x); // 728
+ if(t > 0) x[0] &= ((1< 0) { // 739
+ if(p < this.DB && (d = this[i]>>p) != (this.s&this.DM)>>p) // 740
+ r[k++] = d|(this.s<<(this.DB-p)); // 741
+ while(i >= 0) { // 742
+ if(p < 8) { // 743
+ d = (this[i]&((1<>(p+=this.DB-8); // 745
+ } // 746
+ else { // 747
+ d = (this[i]>>(p-=8))&0xff; // 748
+ if(p <= 0) { p += this.DB; --i; } // 749
+ } // 750
+ if((d&0x80) != 0) d |= -256; // 751
+ if(k == 0 && (this.s&0x80) != (d&0x80)) ++k; // 752
+ if(k > 0 || d != this.s) r[k++] = d; // 753
+ } // 754
+ } // 755
+ return r; // 756
+} // 757
+ // 758
+function bnEquals(a) { return(this.compareTo(a)==0); } // 759
+function bnMin(a) { return(this.compareTo(a)<0)?this:a; } // 760
+function bnMax(a) { return(this.compareTo(a)>0)?this:a; } // 761
+ // 762
+// (protected) r = this op a (bitwise) // 763
+function bnpBitwiseTo(a,op,r) { // 764
+ var i, f, m = Math.min(a.t,this.t); // 765
+ for(i = 0; i < m; ++i) r[i] = op(this[i],a[i]); // 766
+ if(a.t < this.t) { // 767
+ f = a.s&this.DM; // 768
+ for(i = m; i < this.t; ++i) r[i] = op(this[i],f); // 769
+ r.t = this.t; // 770
+ } // 771
+ else { // 772
+ f = this.s&this.DM; // 773
+ for(i = m; i < a.t; ++i) r[i] = op(f,a[i]); // 774
+ r.t = a.t; // 775
+ } // 776
+ r.s = op(this.s,a.s); // 777
+ r.clamp(); // 778
+} // 779
+ // 780
+// (public) this & a // 781
+function op_and(x,y) { return x&y; } // 782
+function bnAnd(a) { var r = nbi(); this.bitwiseTo(a,op_and,r); return r; } // 783
+ // 784
+// (public) this | a // 785
+function op_or(x,y) { return x|y; } // 786
+function bnOr(a) { var r = nbi(); this.bitwiseTo(a,op_or,r); return r; } // 787
+ // 788
+// (public) this ^ a // 789
+function op_xor(x,y) { return x^y; } // 790
+function bnXor(a) { var r = nbi(); this.bitwiseTo(a,op_xor,r); return r; } // 791
+ // 792
+// (public) this & ~a // 793
+function op_andnot(x,y) { return x&~y; } // 794
+function bnAndNot(a) { var r = nbi(); this.bitwiseTo(a,op_andnot,r); return r; } // 795
+ // 796
+// (public) ~this // 797
+function bnNot() { // 798
+ var r = nbi(); // 799
+ for(var i = 0; i < this.t; ++i) r[i] = this.DM&~this[i]; // 800
+ r.t = this.t; // 801
+ r.s = ~this.s; // 802
+ return r; // 803
+} // 804
+ // 805
+// (public) this << n // 806
+function bnShiftLeft(n) { // 807
+ var r = nbi(); // 808
+ if(n < 0) this.rShiftTo(-n,r); else this.lShiftTo(n,r); // 809
+ return r; // 810
+} // 811
+ // 812
+// (public) this >> n // 813
+function bnShiftRight(n) { // 814
+ var r = nbi(); // 815
+ if(n < 0) this.lShiftTo(-n,r); else this.rShiftTo(n,r); // 816
+ return r; // 817
+} // 818
+ // 819
+// return index of lowest 1-bit in x, x < 2^31 // 820
+function lbit(x) { // 821
+ if(x == 0) return -1; // 822
+ var r = 0; // 823
+ if((x&0xffff) == 0) { x >>= 16; r += 16; } // 824
+ if((x&0xff) == 0) { x >>= 8; r += 8; } // 825
+ if((x&0xf) == 0) { x >>= 4; r += 4; } // 826
+ if((x&3) == 0) { x >>= 2; r += 2; } // 827
+ if((x&1) == 0) ++r; // 828
+ return r; // 829
+} // 830
+ // 831
+// (public) returns index of lowest 1-bit (or -1 if none) // 832
+function bnGetLowestSetBit() { // 833
+ for(var i = 0; i < this.t; ++i) // 834
+ if(this[i] != 0) return i*this.DB+lbit(this[i]); // 835
+ if(this.s < 0) return this.t*this.DB; // 836
+ return -1; // 837
+} // 838
+ // 839
+// return number of 1 bits in x // 840
+function cbit(x) { // 841
+ var r = 0; // 842
+ while(x != 0) { x &= x-1; ++r; } // 843
+ return r; // 844
+} // 845
+ // 846
+// (public) return number of set bits // 847
+function bnBitCount() { // 848
+ var r = 0, x = this.s&this.DM; // 849
+ for(var i = 0; i < this.t; ++i) r += cbit(this[i]^x); // 850
+ return r; // 851
+} // 852
+ // 853
+// (public) true iff nth bit is set // 854
+function bnTestBit(n) { // 855
+ var j = Math.floor(n/this.DB); // 856
+ if(j >= this.t) return(this.s!=0); // 857
+ return((this[j]&(1<<(n%this.DB)))!=0); // 858
+} // 859
+ // 860
+// (protected) this op (1<>= this.DB; // 883
+ } // 884
+ if(a.t < this.t) { // 885
+ c += a.s; // 886
+ while(i < this.t) { // 887
+ c += this[i]; // 888
+ r[i++] = c&this.DM; // 889
+ c >>= this.DB; // 890
+ } // 891
+ c += this.s; // 892
+ } // 893
+ else { // 894
+ c += this.s; // 895
+ while(i < a.t) { // 896
+ c += a[i]; // 897
+ r[i++] = c&this.DM; // 898
+ c >>= this.DB; // 899
+ } // 900
+ c += a.s; // 901
+ } // 902
+ r.s = (c<0)?-1:0; // 903
+ if(c > 0) r[i++] = c; // 904
+ else if(c < -1) r[i++] = this.DV+c; // 905
+ r.t = i; // 906
+ r.clamp(); // 907
+} // 908
+ // 909
+// (public) this + a // 910
+function bnAdd(a) { var r = nbi(); this.addTo(a,r); return r; } // 911
+ // 912
+// (public) this - a // 913
+function bnSubtract(a) { var r = nbi(); this.subTo(a,r); return r; } // 914
+ // 915
+// (public) this * a // 916
+function bnMultiply(a) { var r = nbi(); this.multiplyTo(a,r); return r; } // 917
+ // 918
+// (public) this / a // 919
+function bnDivide(a) { var r = nbi(); this.divRemTo(a,r,null); return r; } // 920
+ // 921
+// (public) this % a // 922
+function bnRemainder(a) { var r = nbi(); this.divRemTo(a,null,r); return r; } // 923
+ // 924
+// (public) [this/a,this%a] // 925
+function bnDivideAndRemainder(a) { // 926
+ var q = nbi(), r = nbi(); // 927
+ this.divRemTo(a,q,r); // 928
+ return new Array(q,r); // 929
+} // 930
+ // 931
+// (protected) this *= n, this >= 0, 1 < n < DV // 932
+function bnpDMultiply(n) { // 933
+ this[this.t] = this.am(0,n-1,this,0,0,this.t); // 934
+ ++this.t; // 935
+ this.clamp(); // 936
+} // 937
+ // 938
+// (protected) this += n << w words, this >= 0 // 939
+function bnpDAddOffset(n,w) { // 940
+ while(this.t <= w) this[this.t++] = 0; // 941
+ this[w] += n; // 942
+ while(this[w] >= this.DV) { // 943
+ this[w] -= this.DV; // 944
+ if(++w >= this.t) this[this.t++] = 0; // 945
+ ++this[w]; // 946
+ } // 947
+} // 948
+ // 949
+// A "null" reducer // 950
+function NullExp() {} // 951
+function nNop(x) { return x; } // 952
+function nMulTo(x,y,r) { x.multiplyTo(y,r); } // 953
+function nSqrTo(x,r) { x.squareTo(r); } // 954
+ // 955
+NullExp.prototype.convert = nNop; // 956
+NullExp.prototype.revert = nNop; // 957
+NullExp.prototype.mulTo = nMulTo; // 958
+NullExp.prototype.sqrTo = nSqrTo; // 959
+ // 960
+// (public) this^e // 961
+function bnPow(e) { return this.exp(e,new NullExp()); } // 962
+ // 963
+// (protected) r = lower n words of "this * a", a.t <= n // 964
+// "this" should be the larger one if appropriate. // 965
+function bnpMultiplyLowerTo(a,n,r) { // 966
+ var i = Math.min(this.t+a.t,n); // 967
+ r.s = 0; // assumes a,this >= 0 // 968
+ r.t = i; // 969
+ while(i > 0) r[--i] = 0; // 970
+ var j; // 971
+ for(j = r.t-this.t; i < j; ++i) r[i+this.t] = this.am(0,a[i],r,i,0,this.t); // 972
+ for(j = Math.min(a.t,n); i < j; ++i) this.am(0,a[i],r,i,0,n-i); // 973
+ r.clamp(); // 974
+} // 975
+ // 976
+// (protected) r = "this * a" without lower n words, n > 0 // 977
+// "this" should be the larger one if appropriate. // 978
+function bnpMultiplyUpperTo(a,n,r) { // 979
+ --n; // 980
+ var i = r.t = this.t+a.t-n; // 981
+ r.s = 0; // assumes a,this >= 0 // 982
+ while(--i >= 0) r[i] = 0; // 983
+ for(i = Math.max(n-this.t,0); i < a.t; ++i) // 984
+ r[this.t+i-n] = this.am(n-i,a[i],r,0,0,this.t+i-n); // 985
+ r.clamp(); // 986
+ r.drShiftTo(1,r); // 987
+} // 988
+ // 989
+// Barrett modular reduction // 990
+function Barrett(m) { // 991
+ // setup Barrett // 992
+ this.r2 = nbi(); // 993
+ this.q3 = nbi(); // 994
+ BigInteger.ONE.dlShiftTo(2*m.t,this.r2); // 995
+ this.mu = this.r2.divide(m); // 996
+ this.m = m; // 997
+} // 998
+ // 999
+function barrettConvert(x) { // 1000
+ if(x.s < 0 || x.t > 2*this.m.t) return x.mod(this.m); // 1001
+ else if(x.compareTo(this.m) < 0) return x; // 1002
+ else { var r = nbi(); x.copyTo(r); this.reduce(r); return r; } // 1003
+} // 1004
+ // 1005
+function barrettRevert(x) { return x; } // 1006
+ // 1007
+// x = x mod m (HAC 14.42) // 1008
+function barrettReduce(x) { // 1009
+ x.drShiftTo(this.m.t-1,this.r2); // 1010
+ if(x.t > this.m.t+1) { x.t = this.m.t+1; x.clamp(); } // 1011
+ this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3); // 1012
+ this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2); // 1013
+ while(x.compareTo(this.r2) < 0) x.dAddOffset(1,this.m.t+1); // 1014
+ x.subTo(this.r2,x); // 1015
+ while(x.compareTo(this.m) >= 0) x.subTo(this.m,x); // 1016
+} // 1017
+ // 1018
+// r = x^2 mod m; x != r // 1019
+function barrettSqrTo(x,r) { x.squareTo(r); this.reduce(r); } // 1020
+ // 1021
+// r = x*y mod m; x,y != r // 1022
+function barrettMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); } // 1023
+ // 1024
+Barrett.prototype.convert = barrettConvert; // 1025
+Barrett.prototype.revert = barrettRevert; // 1026
+Barrett.prototype.reduce = barrettReduce; // 1027
+Barrett.prototype.mulTo = barrettMulTo; // 1028
+Barrett.prototype.sqrTo = barrettSqrTo; // 1029
+ // 1030
+// (public) this^e % m (HAC 14.85) // 1031
+function bnModPow(e,m) { // 1032
+ var i = e.bitLength(), k, r = nbv(1), z; // 1033
+ if(i <= 0) return r; // 1034
+ else if(i < 18) k = 1; // 1035
+ else if(i < 48) k = 3; // 1036
+ else if(i < 144) k = 4; // 1037
+ else if(i < 768) k = 5; // 1038
+ else k = 6; // 1039
+ if(i < 8) // 1040
+ z = new Classic(m); // 1041
+ else if(m.isEven()) // 1042
+ z = new Barrett(m); // 1043
+ else // 1044
+ z = new Montgomery(m); // 1045
+ // 1046
+ // precomputation // 1047
+ var g = new Array(), n = 3, k1 = k-1, km = (1< 1) { // 1050
+ var g2 = nbi(); // 1051
+ z.sqrTo(g[1],g2); // 1052
+ while(n <= km) { // 1053
+ g[n] = nbi(); // 1054
+ z.mulTo(g2,g[n-2],g[n]); // 1055
+ n += 2; // 1056
+ } // 1057
+ } // 1058
+ // 1059
+ var j = e.t-1, w, is1 = true, r2 = nbi(), t; // 1060
+ i = nbits(e[j])-1; // 1061
+ while(j >= 0) { // 1062
+ if(i >= k1) w = (e[j]>>(i-k1))&km; // 1063
+ else { // 1064
+ w = (e[j]&((1<<(i+1))-1))<<(k1-i); // 1065
+ if(j > 0) w |= e[j-1]>>(this.DB+i-k1); // 1066
+ } // 1067
+ // 1068
+ n = k; // 1069
+ while((w&1) == 0) { w >>= 1; --n; } // 1070
+ if((i -= n) < 0) { i += this.DB; --j; } // 1071
+ if(is1) { // ret == 1, don't bother squaring or multiplying it // 1072
+ g[w].copyTo(r); // 1073
+ is1 = false; // 1074
+ } // 1075
+ else { // 1076
+ while(n > 1) { z.sqrTo(r,r2); z.sqrTo(r2,r); n -= 2; } // 1077
+ if(n > 0) z.sqrTo(r,r2); else { t = r; r = r2; r2 = t; } // 1078
+ z.mulTo(r2,g[w],r); // 1079
+ } // 1080
+ // 1081
+ while(j >= 0 && (e[j]&(1< 0) { // 1098
+ x.rShiftTo(g,x); // 1099
+ y.rShiftTo(g,y); // 1100
+ } // 1101
+ while(x.signum() > 0) { // 1102
+ if((i = x.getLowestSetBit()) > 0) x.rShiftTo(i,x); // 1103
+ if((i = y.getLowestSetBit()) > 0) y.rShiftTo(i,y); // 1104
+ if(x.compareTo(y) >= 0) { // 1105
+ x.subTo(y,x); // 1106
+ x.rShiftTo(1,x); // 1107
+ } // 1108
+ else { // 1109
+ y.subTo(x,y); // 1110
+ y.rShiftTo(1,y); // 1111
+ } // 1112
+ } // 1113
+ if(g > 0) y.lShiftTo(g,y); // 1114
+ return y; // 1115
+} // 1116
+ // 1117
+// (protected) this % n, n < 2^26 // 1118
+function bnpModInt(n) { // 1119
+ if(n <= 0) return 0; // 1120
+ var d = this.DV%n, r = (this.s<0)?n-1:0; // 1121
+ if(this.t > 0) // 1122
+ if(d == 0) r = this[0]%n; // 1123
+ else for(var i = this.t-1; i >= 0; --i) r = (d*r+this[i])%n; // 1124
+ return r; // 1125
+} // 1126
+ // 1127
+// (public) 1/this % m (HAC 14.61) // 1128
+function bnModInverse(m) { // 1129
+ var ac = m.isEven(); // 1130
+ if((this.isEven() && ac) || m.signum() == 0) return BigInteger.ZERO; // 1131
+ var u = m.clone(), v = this.clone(); // 1132
+ var a = nbv(1), b = nbv(0), c = nbv(0), d = nbv(1); // 1133
+ while(u.signum() != 0) { // 1134
+ while(u.isEven()) { // 1135
+ u.rShiftTo(1,u); // 1136
+ if(ac) { // 1137
+ if(!a.isEven() || !b.isEven()) { a.addTo(this,a); b.subTo(m,b); } // 1138
+ a.rShiftTo(1,a); // 1139
+ } // 1140
+ else if(!b.isEven()) b.subTo(m,b); // 1141
+ b.rShiftTo(1,b); // 1142
+ } // 1143
+ while(v.isEven()) { // 1144
+ v.rShiftTo(1,v); // 1145
+ if(ac) { // 1146
+ if(!c.isEven() || !d.isEven()) { c.addTo(this,c); d.subTo(m,d); } // 1147
+ c.rShiftTo(1,c); // 1148
+ } // 1149
+ else if(!d.isEven()) d.subTo(m,d); // 1150
+ d.rShiftTo(1,d); // 1151
+ } // 1152
+ if(u.compareTo(v) >= 0) { // 1153
+ u.subTo(v,u); // 1154
+ if(ac) a.subTo(c,a); // 1155
+ b.subTo(d,b); // 1156
+ } // 1157
+ else { // 1158
+ v.subTo(u,v); // 1159
+ if(ac) c.subTo(a,c); // 1160
+ d.subTo(b,d); // 1161
+ } // 1162
+ } // 1163
+ if(v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO; // 1164
+ if(d.compareTo(m) >= 0) return d.subtract(m); // 1165
+ if(d.signum() < 0) d.addTo(m,d); else return d; // 1166
+ if(d.signum() < 0) return d.add(m); else return d; // 1167
+} // 1168
+ // 1169
+var lowprimes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509];
+var lplim = (1<<26)/lowprimes[lowprimes.length-1]; // 1171
+ // 1172
+// (public) test primality with certainty >= 1-.5^t // 1173
+function bnIsProbablePrime(t) { // 1174
+ var i, x = this.abs(); // 1175
+ if(x.t == 1 && x[0] <= lowprimes[lowprimes.length-1]) { // 1176
+ for(i = 0; i < lowprimes.length; ++i) // 1177
+ if(x[0] == lowprimes[i]) return true; // 1178
+ return false; // 1179
+ } // 1180
+ if(x.isEven()) return false; // 1181
+ i = 1; // 1182
+ while(i < lowprimes.length) { // 1183
+ var m = lowprimes[i], j = i+1; // 1184
+ while(j < lowprimes.length && m < lplim) m *= lowprimes[j++]; // 1185
+ m = x.modInt(m); // 1186
+ while(i < j) if(m%lowprimes[i++] == 0) return false; // 1187
+ } // 1188
+ return x.millerRabin(t); // 1189
+} // 1190
+ // 1191
+// (protected) true if probably prime (HAC 4.24, Miller-Rabin) // 1192
+function bnpMillerRabin(t) { // 1193
+ var n1 = this.subtract(BigInteger.ONE); // 1194
+ var k = n1.getLowestSetBit(); // 1195
+ if(k <= 0) return false; // 1196
+ var r = n1.shiftRight(k); // 1197
+ t = (t+1)>>1; // 1198
+ if(t > lowprimes.length) t = lowprimes.length; // 1199
+ var a = nbi(); // 1200
+ for(var i = 0; i < t; ++i) { // 1201
+ a.fromInt(lowprimes[i]); // 1202
+ var y = a.modPow(r,this); // 1203
+ if(y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) { // 1204
+ var j = 1; // 1205
+ while(j++ < k && y.compareTo(n1) != 0) { // 1206
+ y = y.modPowInt(2,this); // 1207
+ if(y.compareTo(BigInteger.ONE) == 0) return false; // 1208
+ } // 1209
+ if(y.compareTo(n1) != 0) return false; // 1210
+ } // 1211
+ } // 1212
+ return true; // 1213
+} // 1214
+ // 1215
+// protected // 1216
+BigInteger.prototype.chunkSize = bnpChunkSize; // 1217
+BigInteger.prototype.toRadix = bnpToRadix; // 1218
+BigInteger.prototype.fromRadix = bnpFromRadix; // 1219
+BigInteger.prototype.fromNumber = bnpFromNumber; // 1220
+BigInteger.prototype.bitwiseTo = bnpBitwiseTo; // 1221
+BigInteger.prototype.changeBit = bnpChangeBit; // 1222
+BigInteger.prototype.addTo = bnpAddTo; // 1223
+BigInteger.prototype.dMultiply = bnpDMultiply; // 1224
+BigInteger.prototype.dAddOffset = bnpDAddOffset; // 1225
+BigInteger.prototype.multiplyLowerTo = bnpMultiplyLowerTo; // 1226
+BigInteger.prototype.multiplyUpperTo = bnpMultiplyUpperTo; // 1227
+BigInteger.prototype.modInt = bnpModInt; // 1228
+BigInteger.prototype.millerRabin = bnpMillerRabin; // 1229
+ // 1230
+// public // 1231
+BigInteger.prototype.clone = bnClone; // 1232
+BigInteger.prototype.intValue = bnIntValue; // 1233
+BigInteger.prototype.byteValue = bnByteValue; // 1234
+BigInteger.prototype.shortValue = bnShortValue; // 1235
+BigInteger.prototype.signum = bnSigNum; // 1236
+BigInteger.prototype.toByteArray = bnToByteArray; // 1237
+BigInteger.prototype.equals = bnEquals; // 1238
+BigInteger.prototype.min = bnMin; // 1239
+BigInteger.prototype.max = bnMax; // 1240
+BigInteger.prototype.and = bnAnd; // 1241
+BigInteger.prototype.or = bnOr; // 1242
+BigInteger.prototype.xor = bnXor; // 1243
+BigInteger.prototype.andNot = bnAndNot; // 1244
+BigInteger.prototype.not = bnNot; // 1245
+BigInteger.prototype.shiftLeft = bnShiftLeft; // 1246
+BigInteger.prototype.shiftRight = bnShiftRight; // 1247
+BigInteger.prototype.getLowestSetBit = bnGetLowestSetBit; // 1248
+BigInteger.prototype.bitCount = bnBitCount; // 1249
+BigInteger.prototype.testBit = bnTestBit; // 1250
+BigInteger.prototype.setBit = bnSetBit; // 1251
+BigInteger.prototype.clearBit = bnClearBit; // 1252
+BigInteger.prototype.flipBit = bnFlipBit; // 1253
+BigInteger.prototype.add = bnAdd; // 1254
+BigInteger.prototype.subtract = bnSubtract; // 1255
+BigInteger.prototype.multiply = bnMultiply; // 1256
+BigInteger.prototype.divide = bnDivide; // 1257
+BigInteger.prototype.remainder = bnRemainder; // 1258
+BigInteger.prototype.divideAndRemainder = bnDivideAndRemainder; // 1259
+BigInteger.prototype.modPow = bnModPow; // 1260
+BigInteger.prototype.modInverse = bnModInverse; // 1261
+BigInteger.prototype.pow = bnPow; // 1262
+BigInteger.prototype.gcd = bnGCD; // 1263
+BigInteger.prototype.isProbablePrime = bnIsProbablePrime; // 1264
+ // 1265
+// BigInteger interfaces not implemented in jsbn: // 1266
+ // 1267
+// BigInteger(int signum, byte[] magnitude) // 1268
+// double doubleValue() // 1269
+// float floatValue() // 1270
+// int hashCode() // 1271
+// long longValue() // 1272
+// static BigInteger valueOf(long val) // 1273
+ // 1274
+/// METEOR WRAPPER // 1275
+return BigInteger; // 1276
+})(); // 1277
+ // 1278
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+}).call(this);
+
+
+
+
+
+
+(function () {
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// //
+// packages/srp/srp.js //
+// //
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ //
+// This package contains just enough of the original SRP code to // 1
+// support the backwards-compatibility upgrade path. // 2
+// // 3
+// An SRP (and possibly also accounts-srp) package should eventually be // 4
+// available in Atmosphere so that users can continue to use SRP if they // 5
+// want to. // 6
+ // 7
+SRP = {}; // 8
+ // 9
+/** // 10
+ * Generate a new SRP verifier. Password is the plaintext password. // 11
+ * // 12
+ * options is optional and can include: // 13
+ * - identity: String. The SRP username to user. Mostly this is passed // 14
+ * in for testing. Random UUID if not provided. // 15
+ * - hashedIdentityAndPassword: combined identity and password, already hashed, for the SRP to bcrypt upgrade path. // 16
+ * - salt: String. A salt to use. Mostly this is passed in for // 17
+ * testing. Random UUID if not provided. // 18
+ * - SRP parameters (see _defaults and paramsFromOptions below) // 19
+ */ // 20
+SRP.generateVerifier = function (password, options) { // 21
+ var params = paramsFromOptions(options); // 22
+ // 23
+ var salt = (options && options.salt) || Random.secret(); // 24
+ // 25
+ var identity; // 26
+ var hashedIdentityAndPassword = options && options.hashedIdentityAndPassword; // 27
+ if (!hashedIdentityAndPassword) { // 28
+ identity = (options && options.identity) || Random.secret(); // 29
+ hashedIdentityAndPassword = params.hash(identity + ":" + password); // 30
+ } // 31
+ // 32
+ var x = params.hash(salt + hashedIdentityAndPassword); // 33
+ var xi = new BigInteger(x, 16); // 34
+ var v = params.g.modPow(xi, params.N); // 35
+ // 36
+ return { // 37
+ identity: identity, // 38
+ salt: salt, // 39
+ verifier: v.toString(16) // 40
+ }; // 41
+}; // 42
+ // 43
+// For use with check(). // 44
+SRP.matchVerifier = { // 45
+ identity: String, // 46
+ salt: String, // 47
+ verifier: String // 48
+}; // 49
+ // 50
+ // 51
+/** // 52
+ * Default parameter values for SRP. // 53
+ * // 54
+ */ // 55
+var _defaults = { // 56
+ hash: function (x) { return SHA256(x).toLowerCase(); }, // 57
+ N: new BigInteger("EEAF0AB9ADB38DD69C33F80AFA8FC5E86072618775FF3C0B9EA2314C9C256576D674DF7496EA81D3383B4813D692C6E0E0D5D8E250B98BE48E495C1D6089DAD15DC7D7B46154D6B6CE8EF4AD69B15D4982559B297BCF1885C529F566660E57EC68EDBC3C05726CC02FD4CBF4976EAA9AFD5138FE8376435B9FC61D2FC0EB06E3", 16),
+ g: new BigInteger("2") // 59
+}; // 60
+_defaults.k = new BigInteger( // 61
+ _defaults.hash( // 62
+ _defaults.N.toString(16) + // 63
+ _defaults.g.toString(16)), // 64
+ 16); // 65
+ // 66
+/** // 67
+ * Process an options hash to create SRP parameters. // 68
+ * // 69
+ * Options can include: // 70
+ * - hash: Function. Defaults to SHA256. // 71
+ * - N: String or BigInteger. Defaults to 1024 bit value from RFC 5054 // 72
+ * - g: String or BigInteger. Defaults to 2. // 73
+ * - k: String or BigInteger. Defaults to hash(N, g) // 74
+ */ // 75
+var paramsFromOptions = function (options) { // 76
+ if (!options) // fast path // 77
+ return _defaults; // 78
+ // 79
+ var ret = _.extend({}, _defaults); // 80
+ // 81
+ _.each(['N', 'g', 'k'], function (p) { // 82
+ if (options[p]) { // 83
+ if (typeof options[p] === "string") // 84
+ ret[p] = new BigInteger(options[p], 16); // 85
+ else if (options[p] instanceof BigInteger) // 86
+ ret[p] = options[p]; // 87
+ else // 88
+ throw new Error("Invalid parameter: " + p); // 89
+ } // 90
+ }); // 91
+ // 92
+ if (options.hash) // 93
+ ret.hash = function (x) { return options.hash(x).toLowerCase(); }; // 94
+ // 95
+ if (!options.k && (options.N || options.g || options.hash)) { // 96
+ ret.k = ret.hash(ret.N.toString(16) + ret.g.toString(16)); // 97
+ } // 98
+ // 99
+ return ret; // 100
+}; // 101
+ // 102
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+}).call(this);
+
+
+/* Exports */
+if (typeof Package === 'undefined') Package = {};
+Package.srp = {
+ SRP: SRP
+};
+
+})();
+//////////////////////////////////////////////////////////////////////////
+// //
+// This is a generated file. You can view the original //
+// source in your browser if your browser supports source maps. //
+// //
+// If you are using Chrome, open the Developer Tools and click the gear //
+// icon in its lower right corner. In the General Settings panel, turn //
+// on 'Enable source maps'. //
+// //
+// If you are using Firefox 23, go to `about:config` and set the //
+// `devtools.debugger.source-maps-enabled` preference to true. //
+// (The preference should be on by default in Firefox 24; versions //
+// older than 23 do not support source maps.) //
+// //
+//////////////////////////////////////////////////////////////////////////
+
+
+(function () {
+
+/* Imports */
+var Meteor = Package.meteor.Meteor;
+var Accounts = Package['accounts-base'].Accounts;
+var SRP = Package.srp.SRP;
+var SHA256 = Package.sha.SHA256;
+var check = Package.check.check;
+var Match = Package.check.Match;
+var _ = Package.underscore._;
+var DDP = Package.ddp.DDP;
+
+(function () {
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////
+// //
+// packages/okland:accounts-phone/phone_client.js //
+// //
+///////////////////////////////////////////////////////////////////////////////////////////////////////////
+ //
+// Attempt to log in with phone and password. // 1
+// // 2
+// @param selector {String|Object} One of the following: // 3
+// - {phone: (phone)} // 4
+// @param password {String} // 5
+// @param callback {Function(error|undefined)} // 6
+ // 7
+ // 8
+/** // 9
+ * @summary Log the user in with a password. // 10
+ * @locus Client // 11
+ * @param {Object | String} user Either a string interpreted as a phone; // 12
+ * or an object with a single key: `phone` or `id`. // 13
+ * @param {String} password The user's password. // 14
+ * @param {Function} [callback] Optional callback. Called with no arguments on success, // 15
+ * or with a single `Error` argument on failure. // 16
+ */ // 17
+Meteor.loginWithPhoneAndPassword = function (selector, password, callback) { // 18
+ if (typeof selector === 'string') // 19
+ selector = {phone: selector}; // 20
+ // 21
+ Accounts.callLoginMethod({ // 22
+ methodArguments: [ // 23
+ { // 24
+ user : selector, // 25
+ password: Accounts._hashPassword(password) // 26
+ } // 27
+ ], // 28
+ userCallback : function (error, result) { // 29
+ if (error && error.error === 400 && // 30
+ error.reason === 'old password format') { // 31
+ // The "reason" string should match the error thrown in the // 32
+ // password login handler in password_server.js. // 33
+ // 34
+ // XXX COMPAT WITH 0.8.1.3 // 35
+ // If this user's last login was with a previous version of // 36
+ // Meteor that used SRP, then the server throws this error to // 37
+ // indicate that we should try again. The error includes the // 38
+ // user's SRP identity. We provide a value derived from the // 39
+ // identity and the password to prove to the server that we know // 40
+ // the password without requiring a full SRP flow, as well as // 41
+ // SHA256(password), which the server bcrypts and stores in // 42
+ // place of the old SRP information for this user. // 43
+ srpUpgradePath({ // 44
+ upgradeError : error, // 45
+ userSelector : selector, // 46
+ plaintextPassword: password // 47
+ }, callback); // 48
+ } // 49
+ else if (error) { // 50
+ callback && callback(error); // 51
+ } else { // 52
+ callback && callback(); // 53
+ } // 54
+ } // 55
+ }); // 56
+}; // 57
+ // 58
+Accounts._hashPassword = function (password) { // 59
+ return { // 60
+ digest : SHA256(password), // 61
+ algorithm: "sha-256" // 62
+ }; // 63
+}; // 64
+ // 65
+// XXX COMPAT WITH 0.8.1.3 // 66
+// The server requested an upgrade from the old SRP password format, // 67
+// so supply the needed SRP identity to login. Options: // 68
+// - upgradeError: the error object that the server returned to tell // 69
+// us to upgrade from SRP to bcrypt. // 70
+// - userSelector: selector to retrieve the user object // 71
+// - plaintextPassword: the password as a string // 72
+var srpUpgradePath = function (options, callback) { // 73
+ var details; // 74
+ try { // 75
+ details = EJSON.parse(options.upgradeError.details); // 76
+ } catch (e) {} // 77
+ if (!(details && details.format === 'srp')) { // 78
+ callback && callback( // 79
+ new Meteor.Error(400, "Password is old. Please reVerify phone again")); // 80
+ } else { // 81
+ Accounts.callLoginMethod({ // 82
+ methodArguments: [ // 83
+ { // 84
+ user : options.userSelector, // 85
+ srp : SHA256(details.identity + ":" + options.plaintextPassword), // 86
+ password: Accounts._hashPassword(options.plaintextPassword) // 87
+ } // 88
+ ], // 89
+ userCallback : callback // 90
+ }); // 91
+ } // 92
+}; // 93
+ // 94
+// Attempt to log in as a new user. // 95
+ // 96
+/** // 97
+ * @summary Create a new user with phone. // 98
+ * @locus Anywhere // 99
+ * @param {Object} options // 100
+ * @param {String} options.phone The user's full phone number. // 101
+ * @param {String} options.password, Optional -- (optional) The user's password. This is __not__ sent in plain text over the wire.
+ * @param {Object} options.profile The user's profile, typically including the `name` field. // 103
+ * @param {Function} [callback] Client only, optional callback. Called with no arguments on success, or with a single `Error` argument on failure.
+ */ // 105
+Accounts.createUserWithPhone = function (options, callback) { // 106
+ options = _.clone(options); // we'll be modifying options // 107
+ // 108
+ // If no password was given create random one // 109
+ if (typeof options.password !== 'string' || !options.password) { // 110
+ options.password = Math.random().toString(36).slice(-8); // 111
+ } // 112
+ // 113
+ // Replace password with the hashed password. // 114
+ options.password = Accounts._hashPassword(options.password); // 115
+ // 116
+ Accounts.callLoginMethod({ // 117
+ methodName : 'createUserWithPhone', // 118
+ methodArguments: [options], // 119
+ userCallback : callback // 120
+ }); // 121
+}; // 122
+ // 123
+ // 124
+// Sends an sms to a user with a code to verify his number. // 125
+// // 126
+// @param phone: (phone) // 127
+// @param callback (optional) {Function(error|undefined)} // 128
+ // 129
+/** // 130
+ * @summary Request a new verification code. // 131
+ * @locus Client // 132
+ * @param {String} phone - The phone we send the verification code to. // 133
+ * @param {Function} [callback] Optional callback. Called with no arguments on success, or with a single `Error` argument on failure.
+ */ // 135
+Accounts.requestPhoneVerification = function (phone, callback) { // 136
+ if (!phone) // 137
+ throw new Error("Must pass phone"); // 138
+ Accounts.connection.call("requestPhoneVerification", phone, callback); // 139
+}; // 140
+ // 141
+// Verify phone number - // 142
+// Based on a code ( received by SMS ) originally created by // 143
+// Accounts.verifyPhone, optionally change password and then logs in the matching user. // 144
+// // 145
+// @param code {String} // 146
+// @param newPassword (optional) {String} // 147
+// @param callback (optional) {Function(error|undefined)} // 148
+ // 149
+/** // 150
+ * @summary Marks the user's phone as verified. Optional change passwords, Logs the user in afterwards.. // 151
+ * @locus Client // 152
+ * @param {String} phone - The phone number we want to verify. // 153
+ * @param {String} code - The code retrieved in the SMS. // 154
+ * @param {String} newPassword, Optional, A new password for the user. This is __not__ sent in plain text over the wire.
+ * @param {Function} [callback] Optional callback. Called with no arguments on success, or with a single `Error` argument on failure.
+ */ // 157
+Accounts.verifyPhone = function (phone, code, newPassword, callback) { // 158
+ check(code, String); // 159
+ check(phone, String); // 160
+ // 161
+ var hashedPassword; // 162
+ // 163
+ if (newPassword) { // 164
+ // If didn't gave newPassword and only callback was given // 165
+ if (typeof(newPassword) === 'function') { // 166
+ callback = newPassword; // 167
+ } else { // 168
+ check(newPassword, String); // 169
+ hashedPassword = Accounts._hashPassword(newPassword); // 170
+ } // 171
+ } // 172
+ Accounts.callLoginMethod({ // 173
+ methodName : 'verifyPhone', // 174
+ methodArguments: [phone, code, hashedPassword], // 175
+ userCallback : callback}); // 176
+}; // 177
+ // 178
+/** // 179
+ * Returns whether the current user phone is verified // 180
+ * @returns {boolean} Whether the user phone is verified // 181
+ */ // 182
+Accounts.isPhoneVerified = function () { // 183
+ var me = Meteor.user(); // 184
+ return !!(me && me.phone && me.phone.verified); // 185
+}; // 186
+ // 187
+ // 188
+///////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+}).call(this);
+
+
+/* Exports */
+if (typeof Package === 'undefined') Package = {};
+Package['okland:accounts-phone'] = {};
+
+})();
+/* Imports for global scope */
+
+Accounts = Package['accounts-base'].Accounts;
+
diff --git a/dist/accounts-phone.bundle.min.js b/dist/accounts-phone.bundle.min.js
new file mode 100644
index 0000000..de43dd3
--- /dev/null
+++ b/dist/accounts-phone.bundle.min.js
@@ -0,0 +1 @@
+(function(){var Meteor=Package.meteor.Meteor;var SHA256;(function(){SHA256=function(){function SHA256(s){var chrsz=8;var hexcase=0;function safe_add(x,y){var lsw=(x&65535)+(y&65535);var msw=(x>>16)+(y>>16)+(lsw>>16);return msw<<16|lsw&65535}function S(X,n){return X>>>n|X<<32-n}function R(X,n){return X>>>n}function Ch(x,y,z){return x&y^~x&z}function Maj(x,y,z){return x&y^x&z^y&z}function Sigma0256(x){return S(x,2)^S(x,13)^S(x,22)}function Sigma1256(x){return S(x,6)^S(x,11)^S(x,25)}function Gamma0256(x){return S(x,7)^S(x,18)^R(x,3)}function Gamma1256(x){return S(x,17)^S(x,19)^R(x,10)}function core_sha256(m,l){var K=new Array(1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298);var HASH=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225);var W=new Array(64);var a,b,c,d,e,f,g,h,i,j;var T1,T2;m[l>>5]|=128<<24-l%32;m[(l+64>>9<<4)+15]=l;for(var i=0;i>5]|=(str.charCodeAt(i/chrsz)&mask)<<24-i%32}return bin}function Utf8Encode(string){var utftext="";for(var n=0;n127&&c<2048){utftext+=String.fromCharCode(c>>6|192);utftext+=String.fromCharCode(c&63|128)}else{utftext+=String.fromCharCode(c>>12|224);utftext+=String.fromCharCode(c>>6&63|128);utftext+=String.fromCharCode(c&63|128)}}return utftext}function binb2hex(binarray){var hex_tab=hexcase?"0123456789ABCDEF":"0123456789abcdef";var str="";for(var i=0;i>2]>>(3-i%4)*8+4&15)+hex_tab.charAt(binarray[i>>2]>>(3-i%4)*8&15)}return str}s=Utf8Encode(s);return binb2hex(core_sha256(str2binb(s),s.length*chrsz))}return SHA256}()}).call(this);if(typeof Package==="undefined")Package={};Package.sha={SHA256:SHA256}})();(function(){var Meteor=Package.meteor.Meteor;var Random=Package.random.Random;var check=Package.check.check;var Match=Package.check.Match;var SHA256=Package.sha.SHA256;var _=Package.underscore._;var SRP,BigInteger;(function(){BigInteger=function(){var dbits;var canary=0xdeadbeefcafe;var j_lm=(canary&16777215)==15715070;function BigInteger(a,b,c){if(a!=null)if("number"==typeof a)this.fromNumber(a,b,c);else if(b==null&&"string"!=typeof a)this.fromString(a,256);else this.fromString(a,b)}function nbi(){return new BigInteger(null)}function am1(i,x,w,j,c,n){while(--n>=0){var v=x*this[i++]+w[j]+c;c=Math.floor(v/67108864);w[j++]=v&67108863}return c}function am2(i,x,w,j,c,n){var xl=x&32767,xh=x>>15;while(--n>=0){var l=this[i]&32767;var h=this[i++]>>15;var m=xh*l+h*xl;l=xl*l+((m&32767)<<15)+w[j]+(c&1073741823);c=(l>>>30)+(m>>>15)+xh*h+(c>>>30);w[j++]=l&1073741823}return c}function am3(i,x,w,j,c,n){var xl=x&16383,xh=x>>14;while(--n>=0){var l=this[i]&16383;var h=this[i++]>>14;var m=xh*l+h*xl;l=xl*l+((m&16383)<<14)+w[j]+c;c=(l>>28)+(m>>14)+xh*h;w[j++]=l&268435455}return c}{BigInteger.prototype.am=am3;dbits=28}BigInteger.prototype.DB=dbits;BigInteger.prototype.DM=(1<=0;--i)r[i]=this[i];r.t=this.t;r.s=this.s}function bnpFromInt(x){this.t=1;this.s=x<0?-1:0;if(x>0)this[0]=x;else if(x<-1)this[0]=x+DV;else this.t=0}function nbv(i){var r=nbi();r.fromInt(i);return r}function bnpFromString(s,b){var k;if(b==16)k=4;else if(b==8)k=3;else if(b==256)k=8;else if(b==2)k=1;else if(b==32)k=5;else if(b==4)k=2;else{this.fromRadix(s,b);return}this.t=0;this.s=0;var i=s.length,mi=false,sh=0;while(--i>=0){var x=k==8?s[i]&255:intAt(s,i);if(x<0){if(s.charAt(i)=="-")mi=true;continue}mi=false;if(sh==0)this[this.t++]=x;else if(sh+k>this.DB){this[this.t-1]|=(x&(1<>this.DB-sh}else this[this.t-1]|=x<=this.DB)sh-=this.DB}if(k==8&&(s[0]&128)!=0){this.s=-1;if(sh>0)this[this.t-1]|=(1<0&&this[this.t-1]==c)--this.t}function bnToString(b){if(this.s<0)return"-"+this.negate().toString(b);var k;if(b==16)k=4;else if(b==8)k=3;else if(b==2)k=1;else if(b==32)k=5;else if(b==4)k=2;else return this.toRadix(b);var km=(1<0){if(p>p)>0){m=true;r=int2char(d)}while(i>=0){if(p>(p+=this.DB-k)}else{d=this[i]>>(p-=k)&km;if(p<=0){p+=this.DB;--i}}if(d>0)m=true;if(m)r+=int2char(d)}}return m?r:"0"}function bnNegate(){var r=nbi();BigInteger.ZERO.subTo(this,r);return r}function bnAbs(){return this.s<0?this.negate():this}function bnCompareTo(a){var r=this.s-a.s;if(r!=0)return r;var i=this.t;r=i-a.t;if(r!=0)return r;while(--i>=0)if((r=this[i]-a[i])!=0)return r;return 0}function nbits(x){var r=1,t;if((t=x>>>16)!=0){x=t;r+=16}if((t=x>>8)!=0){x=t;r+=8}if((t=x>>4)!=0){x=t;r+=4}if((t=x>>2)!=0){x=t;r+=2}if((t=x>>1)!=0){x=t;r+=1}return r}function bnBitLength(){if(this.t<=0)return 0;return this.DB*(this.t-1)+nbits(this[this.t-1]^this.s&this.DM)}function bnpDLShiftTo(n,r){var i;for(i=this.t-1;i>=0;--i)r[i+n]=this[i];for(i=n-1;i>=0;--i)r[i]=0;r.t=this.t+n;r.s=this.s}function bnpDRShiftTo(n,r){for(var i=n;i=0;--i){r[i+ds+1]=this[i]>>cbs|c;c=(this[i]&bm)<=0;--i)r[i]=0;r[ds]=c;r.t=this.t+ds+1;r.s=this.s;r.clamp()}function bnpRShiftTo(n,r){r.s=this.s;var ds=Math.floor(n/this.DB);if(ds>=this.t){r.t=0;return}var bs=n%this.DB;var cbs=this.DB-bs;var bm=(1<>bs;for(var i=ds+1;i>bs}if(bs>0)r[this.t-ds-1]|=(this.s&bm)<>=this.DB}if(a.t>=this.DB}c+=this.s}else{c+=this.s;while(i>=this.DB}c-=a.s}r.s=c<0?-1:0;if(c<-1)r[i++]=this.DV+c;else if(c>0)r[i++]=c;r.t=i;r.clamp()}function bnpMultiplyTo(a,r){var x=this.abs(),y=a.abs();var i=x.t;r.t=i+y.t;while(--i>=0)r[i]=0;for(i=0;i=0)r[i]=0;for(i=0;i=x.DV){r[i+x.t]-=x.DV;r[i+x.t+1]=1}}if(r.t>0)r[r.t-1]+=x.am(i,x[i],r,2*i,0,1);r.s=0;r.clamp()}function bnpDivRemTo(m,q,r){var pm=m.abs();if(pm.t<=0)return;var pt=this.abs();if(pt.t0){pm.lShiftTo(nsh,y);pt.lShiftTo(nsh,r)}else{pm.copyTo(y);pt.copyTo(r)}var ys=y.t;var y0=y[ys-1];if(y0==0)return;var yt=y0*(1<1?y[ys-2]>>this.F2:0);var d1=this.FV/yt,d2=(1<=0){r[r.t++]=1;r.subTo(t,r)}BigInteger.ONE.dlShiftTo(ys,t);t.subTo(y,y);while(y.t=0){var qd=r[--i]==y0?this.DM:Math.floor(r[i]*d1+(r[i-1]+e)*d2);if((r[i]+=y.am(0,qd,r,j,0,ys))0)r.rShiftTo(nsh,r);if(ts<0)BigInteger.ZERO.subTo(r,r)}function bnMod(a){var r=nbi();this.abs().divRemTo(a,null,r);if(this.s<0&&r.compareTo(BigInteger.ZERO)>0)a.subTo(r,r);return r}function Classic(m){this.m=m}function cConvert(x){if(x.s<0||x.compareTo(this.m)>=0)return x.mod(this.m);else return x}function cRevert(x){return x}function cReduce(x){x.divRemTo(this.m,null,x)}function cMulTo(x,y,r){x.multiplyTo(y,r);this.reduce(r)}function cSqrTo(x,r){x.squareTo(r);this.reduce(r)}Classic.prototype.convert=cConvert;Classic.prototype.revert=cRevert;Classic.prototype.reduce=cReduce;Classic.prototype.mulTo=cMulTo;Classic.prototype.sqrTo=cSqrTo;function bnpInvDigit(){if(this.t<1)return 0;var x=this[0];if((x&1)==0)return 0;var y=x&3;y=y*(2-(x&15)*y)&15;y=y*(2-(x&255)*y)&255;y=y*(2-((x&65535)*y&65535))&65535;y=y*(2-x*y%this.DV)%this.DV;return y>0?this.DV-y:-y}function Montgomery(m){this.m=m;this.mp=m.invDigit();this.mpl=this.mp&32767;this.mph=this.mp>>15;this.um=(1<0)this.m.subTo(r,r);return r}function montRevert(x){var r=nbi();x.copyTo(r);this.reduce(r);return r}function montReduce(x){while(x.t<=this.mt2)x[x.t++]=0;for(var i=0;i>15)*this.mpl&this.um)<<15)&x.DM;j=i+this.m.t;x[j]+=this.m.am(0,u0,x,i,0,this.m.t);while(x[j]>=x.DV){x[j]-=x.DV;x[++j]++}}x.clamp();x.drShiftTo(this.m.t,x);if(x.compareTo(this.m)>=0)x.subTo(this.m,x)}function montSqrTo(x,r){x.squareTo(r);this.reduce(r)}function montMulTo(x,y,r){x.multiplyTo(y,r);this.reduce(r)}Montgomery.prototype.convert=montConvert;Montgomery.prototype.revert=montRevert;Montgomery.prototype.reduce=montReduce;Montgomery.prototype.mulTo=montMulTo;Montgomery.prototype.sqrTo=montSqrTo;function bnpIsEven(){return(this.t>0?this[0]&1:this.s)==0}function bnpExp(e,z){if(e>4294967295||e<1)return BigInteger.ONE;var r=nbi(),r2=nbi(),g=z.convert(this),i=nbits(e)-1;g.copyTo(r);while(--i>=0){z.sqrTo(r,r2);if((e&1<0)z.mulTo(r2,g,r);else{var t=r;r=r2;r2=t}}return z.revert(r)}function bnModPowInt(e,m){var z;if(e<256||m.isEven())z=new Classic(m);else z=new Montgomery(m);return this.exp(e,z)}BigInteger.prototype.copyTo=bnpCopyTo;BigInteger.prototype.fromInt=bnpFromInt;BigInteger.prototype.fromString=bnpFromString;BigInteger.prototype.clamp=bnpClamp;BigInteger.prototype.dlShiftTo=bnpDLShiftTo;BigInteger.prototype.drShiftTo=bnpDRShiftTo;BigInteger.prototype.lShiftTo=bnpLShiftTo;BigInteger.prototype.rShiftTo=bnpRShiftTo;BigInteger.prototype.subTo=bnpSubTo;BigInteger.prototype.multiplyTo=bnpMultiplyTo;BigInteger.prototype.squareTo=bnpSquareTo;BigInteger.prototype.divRemTo=bnpDivRemTo;BigInteger.prototype.invDigit=bnpInvDigit;BigInteger.prototype.isEven=bnpIsEven;BigInteger.prototype.exp=bnpExp;BigInteger.prototype.toString=bnToString;BigInteger.prototype.negate=bnNegate;BigInteger.prototype.abs=bnAbs;BigInteger.prototype.compareTo=bnCompareTo;BigInteger.prototype.bitLength=bnBitLength;BigInteger.prototype.mod=bnMod;BigInteger.prototype.modPowInt=bnModPowInt;BigInteger.ZERO=nbv(0);BigInteger.ONE=nbv(1);function bnClone(){var r=nbi();this.copyTo(r);return r}function bnIntValue(){if(this.s<0){if(this.t==1)return this[0]-this.DV;else if(this.t==0)return-1}else if(this.t==1)return this[0];else if(this.t==0)return 0;return(this[1]&(1<<32-this.DB)-1)<>24}function bnShortValue(){return this.t==0?this.s:this[0]<<16>>16}function bnpChunkSize(r){return Math.floor(Math.LN2*this.DB/Math.log(r))}function bnSigNum(){if(this.s<0)return-1;else if(this.t<=0||this.t==1&&this[0]<=0)return 0;else return 1}function bnpToRadix(b){if(b==null)b=10;if(this.signum()==0||b<2||b>36)return"0";var cs=this.chunkSize(b);var a=Math.pow(b,cs);var d=nbv(a),y=nbi(),z=nbi(),r="";this.divRemTo(d,y,z);while(y.signum()>0){r=(a+z.intValue()).toString(b).substr(1)+r;y.divRemTo(d,y,z)}return z.intValue().toString(b)+r}function bnpFromRadix(s,b){this.fromInt(0);if(b==null)b=10;var cs=this.chunkSize(b);var d=Math.pow(b,cs),mi=false,j=0,w=0;for(var i=0;i=cs){this.dMultiply(d);this.dAddOffset(w,0);j=0;w=0}}if(j>0){this.dMultiply(Math.pow(b,j));this.dAddOffset(w,0)}if(mi)BigInteger.ZERO.subTo(this,this)}function bnpFromNumber(a,b,c){if("number"==typeof b){if(a<2)this.fromInt(1);else{this.fromNumber(a,c);if(!this.testBit(a-1))this.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,this);if(this.isEven())this.dAddOffset(1,0);while(!this.isProbablePrime(b)){this.dAddOffset(2,0);if(this.bitLength()>a)this.subTo(BigInteger.ONE.shiftLeft(a-1),this)}}}else{var x=new Array,t=a&7;x.length=(a>>3)+1;b.nextBytes(x);if(t>0)x[0]&=(1<0){if(p>p)!=(this.s&this.DM)>>p)r[k++]=d|this.s<=0){if(p<8){d=(this[i]&(1<>(p+=this.DB-8)}else{d=this[i]>>(p-=8)&255;if(p<=0){p+=this.DB;--i}}if((d&128)!=0)d|=-256;if(k==0&&(this.s&128)!=(d&128))++k;if(k>0||d!=this.s)r[k++]=d}}return r}function bnEquals(a){return this.compareTo(a)==0}function bnMin(a){return this.compareTo(a)<0?this:a}function bnMax(a){return this.compareTo(a)>0?this:a}function bnpBitwiseTo(a,op,r){var i,f,m=Math.min(a.t,this.t);for(i=0;i>=16;r+=16}if((x&255)==0){x>>=8;r+=8}if((x&15)==0){x>>=4;r+=4}if((x&3)==0){x>>=2;r+=2}if((x&1)==0)++r;return r}function bnGetLowestSetBit(){for(var i=0;i=this.t)return this.s!=0;return(this[j]&1<>=this.DB}if(a.t>=this.DB}c+=this.s}else{c+=this.s;while(i>=this.DB}c+=a.s}r.s=c<0?-1:0;if(c>0)r[i++]=c;else if(c<-1)r[i++]=this.DV+c;r.t=i;r.clamp()}function bnAdd(a){var r=nbi();this.addTo(a,r);return r}function bnSubtract(a){var r=nbi();this.subTo(a,r);return r}function bnMultiply(a){var r=nbi();this.multiplyTo(a,r);return r}function bnDivide(a){var r=nbi();this.divRemTo(a,r,null);return r}function bnRemainder(a){var r=nbi();this.divRemTo(a,null,r);return r}function bnDivideAndRemainder(a){var q=nbi(),r=nbi();this.divRemTo(a,q,r);return new Array(q,r)}function bnpDMultiply(n){this[this.t]=this.am(0,n-1,this,0,0,this.t);++this.t;this.clamp()}function bnpDAddOffset(n,w){while(this.t<=w)this[this.t++]=0;this[w]+=n;while(this[w]>=this.DV){this[w]-=this.DV;if(++w>=this.t)this[this.t++]=0;++this[w]}}function NullExp(){}function nNop(x){return x}function nMulTo(x,y,r){x.multiplyTo(y,r)}function nSqrTo(x,r){x.squareTo(r)}NullExp.prototype.convert=nNop;NullExp.prototype.revert=nNop;NullExp.prototype.mulTo=nMulTo;NullExp.prototype.sqrTo=nSqrTo;function bnPow(e){return this.exp(e,new NullExp)}function bnpMultiplyLowerTo(a,n,r){var i=Math.min(this.t+a.t,n);r.s=0;r.t=i;while(i>0)r[--i]=0;var j;for(j=r.t-this.t;i=0)r[i]=0;for(i=Math.max(n-this.t,0);i2*this.m.t)return x.mod(this.m);else if(x.compareTo(this.m)<0)return x;else{var r=nbi();x.copyTo(r);this.reduce(r);return r}}function barrettRevert(x){return x}function barrettReduce(x){x.drShiftTo(this.m.t-1,this.r2);if(x.t>this.m.t+1){x.t=this.m.t+1;x.clamp()}this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);while(x.compareTo(this.r2)<0)x.dAddOffset(1,this.m.t+1);x.subTo(this.r2,x);while(x.compareTo(this.m)>=0)x.subTo(this.m,x)}function barrettSqrTo(x,r){x.squareTo(r);this.reduce(r)}function barrettMulTo(x,y,r){x.multiplyTo(y,r);this.reduce(r)}Barrett.prototype.convert=barrettConvert;Barrett.prototype.revert=barrettRevert;Barrett.prototype.reduce=barrettReduce;Barrett.prototype.mulTo=barrettMulTo;Barrett.prototype.sqrTo=barrettSqrTo;function bnModPow(e,m){var i=e.bitLength(),k,r=nbv(1),z;if(i<=0)return r;else if(i<18)k=1;else if(i<48)k=3;else if(i<144)k=4;else if(i<768)k=5;else k=6;if(i<8)z=new Classic(m);else if(m.isEven())z=new Barrett(m);else z=new Montgomery(m);var g=new Array,n=3,k1=k-1,km=(1<1){var g2=nbi();z.sqrTo(g[1],g2);while(n<=km){g[n]=nbi();z.mulTo(g2,g[n-2],g[n]);n+=2}}var j=e.t-1,w,is1=true,r2=nbi(),t;i=nbits(e[j])-1;while(j>=0){if(i>=k1)w=e[j]>>i-k1&km;else{w=(e[j]&(1<0)w|=e[j-1]>>this.DB+i-k1}n=k;while((w&1)==0){w>>=1;--n}if((i-=n)<0){i+=this.DB;--j}if(is1){g[w].copyTo(r);is1=false}else{while(n>1){z.sqrTo(r,r2);z.sqrTo(r2,r);n-=2}if(n>0)z.sqrTo(r,r2);else{t=r;r=r2;r2=t}z.mulTo(r2,g[w],r)}while(j>=0&&(e[j]&1<0){x.rShiftTo(g,x);y.rShiftTo(g,y)}while(x.signum()>0){if((i=x.getLowestSetBit())>0)x.rShiftTo(i,x);if((i=y.getLowestSetBit())>0)y.rShiftTo(i,y);if(x.compareTo(y)>=0){x.subTo(y,x);x.rShiftTo(1,x)}else{y.subTo(x,y);y.rShiftTo(1,y)}}if(g>0)y.lShiftTo(g,y);return y}function bnpModInt(n){if(n<=0)return 0;var d=this.DV%n,r=this.s<0?n-1:0;if(this.t>0)if(d==0)r=this[0]%n;else for(var i=this.t-1;i>=0;--i)r=(d*r+this[i])%n;return r}function bnModInverse(m){var ac=m.isEven();if(this.isEven()&&ac||m.signum()==0)return BigInteger.ZERO;var u=m.clone(),v=this.clone();var a=nbv(1),b=nbv(0),c=nbv(0),d=nbv(1);while(u.signum()!=0){while(u.isEven()){u.rShiftTo(1,u);if(ac){if(!a.isEven()||!b.isEven()){a.addTo(this,a);b.subTo(m,b)}a.rShiftTo(1,a)}else if(!b.isEven())b.subTo(m,b);b.rShiftTo(1,b)}while(v.isEven()){v.rShiftTo(1,v);if(ac){if(!c.isEven()||!d.isEven()){c.addTo(this,c);d.subTo(m,d)}c.rShiftTo(1,c)}else if(!d.isEven())d.subTo(m,d);d.rShiftTo(1,d)}if(u.compareTo(v)>=0){u.subTo(v,u);if(ac)a.subTo(c,a);b.subTo(d,b)}else{v.subTo(u,v);if(ac)c.subTo(a,c);d.subTo(b,d)}}if(v.compareTo(BigInteger.ONE)!=0)return BigInteger.ZERO;if(d.compareTo(m)>=0)return d.subtract(m);if(d.signum()<0)d.addTo(m,d);else return d;if(d.signum()<0)return d.add(m);else return d}var lowprimes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509];var lplim=(1<<26)/lowprimes[lowprimes.length-1];function bnIsProbablePrime(t){var i,x=this.abs();if(x.t==1&&x[0]<=lowprimes[lowprimes.length-1]){for(i=0;i>1;if(t>lowprimes.length)t=lowprimes.length;var a=nbi();for(var i=0;i