function i(r) {
if (t[r])
return t[r].exports;
var n = t[r] = {
i: r,
l: !1,
exports: {}
};
return e[r].call(n.exports, n, n.exports, i),
n.l = !0,
n.exports
}
_i = i;
}
)({
enc: function() {
console.log("正常");
},
8060: function(e, t, n) {
e.exports = {
sm2: n("526b"),
sm3: n("72fa"),
sm4: n("10d1")
}
},
"526b": function(e, t, n) {
const {BigInteger: r} = n("f33e")
, {encodeDer: i, decodeDer: o} = n("f9dd")
, a = n("41d0")
, s = n("a336")
, u = n("dffd")
, {G: l, curve: c, n: f} = u.generateEcparam()
, d = 0;
function h(e, t, n=1) {
const r = new s;
e = u.hexToArray(u.parseUtf8StringToHex(e)),
t.length > 128 && (t = t.substr(t.length - 128));
const i = t.substr(0, 64)
, o = t.substr(64);
t = r.createPoint(i, o);
const a = r.initEncipher(t);
r.encryptBlock(e);
const l = u.arrayToHex(e);
let c = new Array(32);
return r.doFinal(c),
c = u.arrayToHex(c),
n === d ? a + l + c : a + c + l
}
function p(e, t, n=1) {
const i = new s;
t = new r(t,16);
const o = e.substr(0, 64)
, a = e.substr(0 + o.length, 64)
, l = o.length + a.length;
let c = e.substr(l, 64)
, f = e.substr(l + 64);
n === d && (c = e.substr(e.length - 64),
f = e.substr(l, e.length - l - 64));
const h = u.hexToArray(f)
, p = i.createPoint(o, a);
i.initDecipher(t, p),
i.decryptBlock(h);
const m = new Array(32);
i.doFinal(m);
const g = u.arrayToHex(m) === c;
if (g) {
const e = u.arrayToUtf8(h);
return e
}
return ""
}
function m(e, t, {pointPool: n, der: o, hash: a, publicKey: s, userId: l}={}) {
let c = "string" === typeof e ? u.parseUtf8StringToHex(e) : u.parseArrayBufferToHex(e);
a && (s = s || y(t),
c = v(c, s, l));
const d = new r(t,16)
, h = new r(c,16);
let p = null
, m = null
, g = null;
do {
do {
let e;
e = n && n.length ? n.pop() : b(),
p = e.k,
m = h.add(e.x1).mod(f)
} while (m.equals(r.ZERO) || m.add(p).equals(f));
g = d.add(r.ONE).modInverse(f).multiply(p.subtract(m.multiply(d))).mod(f)
} while (g.equals(r.ZERO));
return o ? i(m, g) : u.leftPad(m.toString(16), 64) + u.leftPad(g.toString(16), 64)
}
function g(e, t, n, {der: i, hash: a, userId: s}={}) {
let d, h, p = "string" === typeof e ? u.parseUtf8StringToHex(e) : u.parseArrayBufferToHex(e);
if (a && (p = v(p, n, s)),
i) {
const e = o(t);
d = e.r,
h = e.s
} else
d = new r(t.substring(0, 64),16),
h = new r(t.substring(64),16);
const m = c.decodePointHex(n)
, g = new r(p,16)
, y = d.add(h).mod(f);
if (y.equals(r.ZERO))
return !1;
const b = l.multiply(h).add(m.multiply(y))
, x = g.add(b.getX().toBigInteger()).mod(f);
return d.equals(x)
}
function v(e, t, n="1234567812345678") {
const r = new a
, i = (new a).getZ(l, t.substr(2, 128), n)
, o = u.hexToArray(u.arrayToHex(i).toString())
, s = e
, c = u.hexToArray(s)
, f = new Array(r.getDigestSize());
return r.blockUpdate(o, 0, o.length),
r.blockUpdate(c, 0, c.length),
r.doFinal(f, 0),
u.arrayToHex(f).toString()
}
function y(e) {
const t = l.multiply(new r(e,16))
, n = u.leftPad(t.getX().toBigInteger().toString(16), 64)
, i = u.leftPad(t.getY().toBigInteger().toString(16), 64);
return "04" + n + i
}
function b() {
const e = u.generateKeyPairHex()
, t = c.decodePointHex(e.publicKey);
return e.k = new r(e.privateKey,16),
e.x1 = t.getX().toBigInteger(),
e
}
e.exports = {
generateKeyPairHex: u.generateKeyPairHex,
doEncrypt: h,
doDecrypt: p,
doSignature: m,
doVerifySignature: g,
getPoint: b
}
},
"72fa": function(e, t) {
function n(e) {
return e.map(e=>(e = e.toString(16),
1 === e.length ? "0" + e : e)).join("")
}
function r(e) {
const t = [];
for (let n = 0, r = e.length; n < r; n++) {
const r = e.codePointAt(n);
if (r <= 127)
t.push(r);
else if (r <= 2047)
t.push(192 | r >>> 6),
t.push(128 | 63 & r);
else if (r <= 55295 || r >= 57344 && r <= 65535)
t.push(224 | r >>> 12),
t.push(128 | r >>> 6 & 63),
t.push(128 | 63 & r);
else {
if (!(r >= 65536 && r <= 1114111))
throw t.push(r),
new Error("input is not supported");
n++,
t.push(240 | r >>> 18 & 28),
t.push(128 | r >>> 12 & 63),
t.push(128 | r >>> 6 & 63),
t.push(128 | 63 & r)
}
}
return t
}
function i(e, t) {
const n = []
, r = ~~(t / 8)
, i = t % 8;
for (let o = 0, a = e.length; o < a; o++)
n[o] = (e[(o + r) % a] << i & 255) + (e[(o + r + 1) % a] >>> 8 - i & 255);
return n
}
function o(e, t) {
const n = [];
for (let r = e.length - 1; r >= 0; r--)
n[r] = 255 & (e[r] ^ t[r]);
return n
}
function a(e, t) {
const n = [];
for (let r = e.length - 1; r >= 0; r--)
n[r] = e[r] & t[r] & 255;
return n
}
function s(e, t) {
const n = [];
for (let r = e.length - 1; r >= 0; r--)
n[r] = 255 & (e[r] | t[r]);
return n
}
function u(e, t) {
const n = [];
let r = 0;
for (let i = e.length - 1; i >= 0; i--) {
const o = e[i] + t[i] + r;
o > 255 ? (r = 1,
n[i] = 255 & o) : (r = 0,
n[i] = 255 & o)
}
return n
}
function l(e) {
const t = [];
for (let n = e.length - 1; n >= 0; n--)
t[n] = 255 & ~e[n];
return t
}
function c(e) {
return o(o(e, i(e, 9)), i(e, 17))
}
function f(e) {
return o(o(e, i(e, 15)), i(e, 23))
}
function d(e, t, n, r) {
return r >= 0 && r <= 15 ? o(o(e, t), n) : s(s(a(e, t), a(e, n)), a(t, n))
}
function h(e, t, n, r) {
return r >= 0 && r <= 15 ? o(o(e, t), n) : s(a(e, t), a(l(e), n))
}
function p(e, t) {
const n = []
, r = [];
for (let i = 0; i < 16; i++) {
const e = 4 * i;
n.push(t.slice(e, e + 4))
}
for (let u = 16; u < 68; u++)
n.push(o(o(f(o(o(n[u - 16], n[u - 9]), i(n[u - 3], 15))), i(n[u - 13], 7)), n[u - 6]));
for (let i = 0; i < 64; i++)
r.push(o(n[i], n[i + 4]));
const a = [121, 204, 69, 25]
, s = [122, 135, 157, 138];
let l, p, m, g, v = e.slice(0, 4), y = e.slice(4, 8), b = e.slice(8, 12), x = e.slice(12, 16), w = e.slice(16, 20), _ = e.slice(20, 24), S = e.slice(24, 28), O = e.slice(28, 32);
for (let f = 0; f < 64; f++) {
const e = f >= 0 && f <= 15 ? a : s;
l = i(u(u(i(v, 12), w), i(e, f)), 7),
p = o(l, i(v, 12)),
m = u(u(u(d(v, y, b, f), x), p), r[f]),
g = u(u(u(h(w, _, S, f), O), l), n[f]),
x = b,
b = i(y, 9),
y = v,
v = m,
O = S,
S = i(_, 19),
_ = w,
w = c(g)
}
return o([].concat(v, y, b, x, w, _, S, O), e)
}
e.exports = function(e) {
const t = "string" === typeof e ? r(e) : Array.prototype.slice.call(e);
let i = 8 * t.length
, o = i % 512;
o = o >= 448 ? 512 - o % 448 - 1 : 448 - o - 1;
const a = new Array((o - 7) / 8);
for (let n = 0, r = a.length; n < r; n++)
a[n] = 0;
const s = [];
i = i.toString(2);
for (let n = 7; n >= 0; n--)
if (i.length > 8) {
const e = i.length - 8;
s[n] = parseInt(i.substr(e), 2),
i = i.substr(0, e)
} else
i.length > 0 ? (s[n] = parseInt(i, 2),
i = "") : s[n] = 0;
const u = [].concat(t, [128], a, s)
, l = u.length / 64;
let c = [115, 128, 22, 111, 73, 20, 178, 185, 23, 36, 66, 215, 218, 138, 6, 0, 169, 111, 48, 188, 22, 49, 56, 170, 227, 141, 238, 77, 176, 251, 14, 78];
for (let n = 0; n < l; n++) {
const e = 64 * n
, t = u.slice(e, e + 64);
c = p(c, t)
}
return n(c)
}
},
"10d1": function(e, t) {
const n = 0
, r = 32
, i = 16
, o = [214, 144, 233, 254, 204, 225, 61, 183, 22, 182, 20, 194, 40, 251, 44, 5, 43, 103, 154, 118, 42, 190, 4, 195, 170, 68, 19, 38, 73, 134, 6, 153, 156, 66, 80, 244, 145, 239, 152, 122, 51, 84, 11, 67, 237, 207, 172, 98, 228, 179, 28, 169, 201, 8, 232, 149, 128, 223, 148, 250, 117, 143, 63, 166, 71, 7, 167, 252, 243, 115, 23, 186, 131, 89, 60, 25, 230, 133, 79, 168, 104, 107, 129, 178, 113, 100, 218, 139, 248, 235, 15, 75, 112, 86, 157, 53, 30, 36, 14, 94, 99, 88, 209, 162, 37, 34, 124, 59, 1, 33, 120, 135, 212, 0, 70, 87, 159, 211, 39, 82, 76, 54, 2, 231, 160, 196, 200, 158, 234, 191, 138, 210, 64, 199, 56, 181, 163, 247, 242, 206, 249, 97, 21, 161, 224, 174, 93, 164, 155, 52, 26, 85, 173, 147, 50, 48, 245, 140, 177, 227, 29, 246, 226, 46, 130, 102, 202, 96, 192, 41, 35, 171, 13, 83, 78, 111, 213, 219, 55, 69, 222, 253, 142, 47, 3, 255, 106, 114, 109, 108, 91, 81, 141, 27, 175, 146, 187, 221, 188, 127, 17, 217, 92, 65, 31, 16, 90, 216, 10, 193, 49, 136, 165, 205, 123, 189, 45, 116, 208, 18, 184, 229, 180, 176, 137, 105, 151, 74, 12, 150, 119, 126, 101, 185, 241, 9, 197, 110, 198, 132, 24, 240, 125, 236, 58, 220, 77, 32, 121, 238, 95, 62, 215, 203, 57, 72]
, a = [462357, 472066609, 943670861, 1415275113, 1886879365, 2358483617, 2830087869, 3301692121, 3773296373, 4228057617, 404694573, 876298825, 1347903077, 1819507329, 2291111581, 2762715833, 3234320085, 3705924337, 4177462797, 337322537, 808926789, 1280531041, 1752135293, 2223739545, 2695343797, 3166948049, 3638552301, 4110090761, 269950501, 741554753, 1213159005, 1684763257];
function s(e) {
const t = [];
for (let n = 0, r = e.length; n < r; n += 2)
t.push(parseInt(e.substr(n, 2), 16));
return t
}
function u(e) {
return e.map(e=>(e = e.toString(16),
1 === e.length ? "0" + e : e)).join("")
}
function l(e) {
const t = [];
for (let n = 0, r = e.length; n < r; n++) {
const r = e.codePointAt(n);
if (r <= 127)
t.push(r);
else if (r <= 2047)
t.push(192 | r >>> 6),
t.push(128 | 63 & r);
else if (r <= 55295 || r >= 57344 && r <= 65535)
t.push(224 | r >>> 12),
t.push(128 | r >>> 6 & 63),
t.push(128 | 63 & r);
else {
if (!(r >= 65536 && r <= 1114111))
throw t.push(r),
new Error("input is not supported");
n++,
t.push(240 | r >>> 18 & 28),
t.push(128 | r >>> 12 & 63),
t.push(128 | r >>> 6 & 63),
t.push(128 | 63 & r)
}
}
return t
}
function c(e) {
const t = [];
for (let n = 0, r = e.length; n < r; n++)
e[n] >= 240 && e[n] <= 247 ? (t.push(String.fromCodePoint(((7 & e[n]) << 18) + ((63 & e[n + 1]) << 12) + ((63 & e[n + 2]) << 6) + (63 & e[n + 3]))),
n += 3) : e[n] >= 224 && e[n] <= 239 ? (t.push(String.fromCodePoint(((15 & e[n]) << 12) + ((63 & e[n + 1]) << 6) + (63 & e[n + 2]))),
n += 2) : e[n] >= 192 && e[n] <= 223 ? (t.push(String.fromCodePoint(((31 & e[n]) << 6) + (63 & e[n + 1]))),
n++) : t.push(String.fromCodePoint(e[n]));
return t.join("")
}
function f(e, t) {
return e << t | e >>> 32 - t
}
function d(e) {
return (255 & o[e >>> 24 & 255]) << 24 | (255 & o[e >>> 16 & 255]) << 16 | (255 & o[e >>> 8 & 255]) << 8 | 255 & o[255 & e]
}
function h(e) {
return e ^ f(e, 2) ^ f(e, 10) ^ f(e, 18) ^ f(e, 24)
}
function p(e) {
return e ^ f(e, 13) ^ f(e, 23)
}
function m(e, t, n) {
const r = new Array(4)
, i = new Array(4);
for (let o = 0; o < 4; o++)
i[0] = 255 & e[0 + 4 * o],
i[1] = 255 & e[1 + 4 * o],
i[2] = 255 & e[2 + 4 * o],
i[3] = 255 & e[3 + 4 * o],
r[o] = i[0] << 24 | i[1] << 16 | i[2] << 8 | i[3];
for (let o, a = 0; a < 32; a += 4)
o = r[1] ^ r[2] ^ r[3] ^ n[a + 0],
r[0] ^= h(d(o)),
o = r[2] ^ r[3] ^ r[0] ^ n[a + 1],
r[1] ^= h(d(o)),
o = r[3] ^ r[0] ^ r[1] ^ n[a + 2],
r[2] ^= h(d(o)),
o = r[0] ^ r[1] ^ r[2] ^ n[a + 3],
r[3] ^= h(d(o));
for (let o = 0; o < 16; o += 4)
t[o] = r[3 - o / 4] >>> 24 & 255,
t[o + 1] = r[3 - o / 4] >>> 16 & 255,
t[o + 2] = r[3 - o / 4] >>> 8 & 255,
t[o + 3] = 255 & r[3 - o / 4]
}
function g(e, t, r) {
const i = new Array(4)
, o = new Array(4);
for (let n = 0; n < 4; n++)
o[0] = 255 & e[0 + 4 * n],
o[1] = 255 & e[1 + 4 * n],
o[2] = 255 & e[2 + 4 * n],
o[3] = 255 & e[3 + 4 * n],
i[n] = o[0] << 24 | o[1] << 16 | o[2] << 8 | o[3];
i[0] ^= 2746333894,
i[1] ^= 1453994832,
i[2] ^= 1736282519,
i[3] ^= 2993693404;
for (let n, s = 0; s < 32; s += 4)
n = i[1] ^ i[2] ^ i[3] ^ a[s + 0],
t[s + 0] = i[0] ^= p(d(n)),
n = i[2] ^ i[3] ^ i[0] ^ a[s + 1],
t[s + 1] = i[1] ^= p(d(n)),
n = i[3] ^ i[0] ^ i[1] ^ a[s + 2],
t[s + 2] = i[2] ^= p(d(n)),
n = i[0] ^ i[1] ^ i[2] ^ a[s + 3],
t[s + 3] = i[3] ^= p(d(n));
if (r === n)
for (let n, a = 0; a < 16; a++)
n = t[a],
t[a] = t[31 - a],
t[31 - a] = n
}
function v(e, t, o, {padding: a="pkcs#5", mode: f, output: d="string"}={}) {
if ("string" === typeof t && (t = s(t)),
16 !== t.length)
throw new Error("key is invalid");
if (e = "string" === typeof e ? o !== n ? l(e) : s(e) : [...e],
"pkcs#5" === a && o !== n) {
const t = i - e.length % i;
for (let n = 0; n < t; n++)
e.push(t)
}
const h = new Array(r);
g(t, h, o);
const p = [];
let v = e.length
, y = 0;
while (v >= i) {
const t = e.slice(y, y + 16)
, n = new Array(16);
m(t, n, h);
for (let e = 0; e < i; e++)
p[y + e] = n[e];
v -= i,
y += i
}
if ("pkcs#5" === a && o === n) {
const e = p[p.length - 1];
p.splice(p.length - e, e)
}
return "array" !== d ? o !== n ? u(p) : c(p) : p
}
e.exports = {
encrypt(e, t, n) {
return v(e, t, 1, n)
},
decrypt(e, t, n) {
return v(e, t, 0, n)
}
}
}, f33e: function(e, t, n) {
(function() {
var t, n = 0xdeadbeefcafe, r = 15715070 == (16777215 & n);
function i(e, t, n) {
null != e && ("number" == typeof e ? this.fromNumber(e, t, n) : null == t && "string" != typeof e ? this.fromString(e, 256) : this.fromString(e, t))
}
function o() {
return new i(null)
}
function a(e, t, n, r, i, o) {
while (--o >= 0) {
var a = t * this[e++] + n[r] + i;
i = Math.floor(a / 67108864),
n[r++] = 67108863 & a
}
return i
}
function s(e, t, n, r, i, o) {
var a = 32767 & t
, s = t >> 15;
while (--o >= 0) {
var u = 32767 & this[e]
, l = this[e++] >> 15
, c = s * u + l * a;
u = a * u + ((32767 & c) << 15) + n[r] + (1073741823 & i),
i = (u >>> 30) + (c >>> 15) + s * l + (i >>> 30),
n[r++] = 1073741823 & u
}
return i
}
function u(e, t, n, r, i, o) {
var a = 16383 & t
, s = t >> 14;
while (--o >= 0) {
var u = 16383 & this[e]
, l = this[e++] >> 14
, c = s * u + l * a;
u = a * u + ((16383 & c) << 14) + n[r] + i,
i = (u >> 28) + (c >> 14) + s * l,
n[r++] = 268435455 & u
}
return i
}
var l = "undefined" !== typeof navigator;
l && r && "Microsoft Internet Explorer" == navigator.appName ? (i.prototype.am = s,
t = 30) : l && r && "Netscape" != navigator.appName ? (i.prototype.am = a,
t = 26) : (i.prototype.am = u,
t = 28),
i.prototype.DB = t,
i.prototype.DM = (1 << t) - 1,
i.prototype.DV = 1 << t;
var c = 52;
i.prototype.FV = Math.pow(2, c),
i.prototype.F1 = c - t,
i.prototype.F2 = 2 * t - c;
var f, d, h = "0123456789abcdefghijklmnopqrstuvwxyz", p = new Array;
for (f = "0".charCodeAt(0),
d = 0; d <= 9; ++d)
p[f++] = d;
for (f = "a".charCodeAt(0),
d = 10; d < 36; ++d)
p[f++] = d;
for (f = "A".charCodeAt(0),
d = 10; d < 36; ++d)
p[f++] = d;
function m(e) {
return h.charAt(e)
}
function g(e, t) {
var n = p[e.charCodeAt(t)];
return null == n ? -1 : n
}
function v(e) {
for (var t = this.t - 1; t >= 0; --t)
e[t] = this[t];
e.t = this.t,
e.s = this.s
}
function y(e) {
this.t = 1,
this.s = e < 0 ? -1 : 0,
e > 0 ? this[0] = e : e < -1 ? this[0] = e + this.DV : this.t = 0
}
function b(e) {
var t = o();
return t.fromInt(e),
t
}
function x(e, t) {
var n;
if (16 == t)
n = 4;
else if (8 == t)
n = 3;
else if (256 == t)
n = 8;
else if (2 == t)
n = 1;
else if (32 == t)
n = 5;
else {
if (4 != t)
return void this.fromRadix(e, t);
n = 2
}
this.t = 0,
this.s = 0;
var r = e.length
, o = !1
, a = 0;
while (--r >= 0) {
var s = 8 == n ? 255 & e[r] : g(e, r);
s < 0 ? "-" == e.charAt(r) && (o = !0) : (o = !1,
0 == a ? this[this.t++] = s : a + n > this.DB ? (this[this.t - 1] |= (s & (1 << this.DB - a) - 1) << a,
this[this.t++] = s >> this.DB - a) : this[this.t - 1] |= s << a,
a += n,
a >= this.DB && (a -= this.DB))
}
8 == n && 0 != (128 & e[0]) && (this.s = -1,
a > 0 && (this[this.t - 1] |= (1 << this.DB - a) - 1 << a)),
this.clamp(),
o && i.ZERO.subTo(this, this)
}
function w() {
var e = this.s & this.DM;
while (this.t > 0 && this[this.t - 1] == e)
--this.t
}
function _(e) {
if (this.s < 0)
return "-" + this.negate().toString(e);
var t;
if (16 == e)
t = 4;
else if (8 == e)
t = 3;
else if (2 == e)
t = 1;
else if (32 == e)
t = 5;
else {
if (4 != e)
return this.toRadix(e);
t = 2
}
var n, r = (1 << t) - 1, i = !1, o = "", a = this.t, s = this.DB - a * this.DB % t;
if (a-- > 0) {
s < this.DB && (n = this[a] >> s) > 0 && (i = !0,
o = m(n));
while (a >= 0)
s < t ? (n = (this[a] & (1 << s) - 1) << t - s,
n |= this[--a] >> (s += this.DB - t)) : (n = this[a] >> (s -= t) & r,
s <= 0 && (s += this.DB,
--a)),
n > 0 && (i = !0),
i && (o += m(n))
}
return i ? o : "0"
}
function S() {
var e = o();
return i.ZERO.subTo(this, e),
e
}
function O() {
return this.s < 0 ? this.negate() : this
}
function C(e) {
var t = this.s - e.s;
if (0 != t)
return t;
var n = this.t;
if (t = n - e.t,
0 != t)
return this.s < 0 ? -t : t;
while (--n >= 0)
if (0 != (t = this[n] - e[n]))
return t;
return 0
}
function k(e) {
var t, n = 1;
return 0 != (t = e >>> 16) && (e = t,
n += 16),
0 != (t = e >> 8) && (e = t,
n += 8),
0 != (t = e >> 4) && (e = t,
n += 4),
0 != (t = e >> 2) && (e = t,
n += 2),
0 != (t = e >> 1) && (e = t,
n += 1),
n
}
function T() {
return this.t <= 0 ? 0 : this.DB * (this.t - 1) + k(this[this.t - 1] ^ this.s & this.DM)
}
function M(e, t) {
var n;
for (n = this.t - 1; n >= 0; --n)
t[n + e] = this[n];
for (n = e - 1; n >= 0; --n)
t[n] = 0;
t.t = this.t + e,
t.s = this.s
}
function A(e, t) {
for (var n = e; n < this.t; ++n)
t[n - e] = this[n];
t.t = Math.max(this.t - e, 0),
t.s = this.s
}
function j(e, t) {
var n, r = e % this.DB, i = this.DB - r, o = (1 << i) - 1, a = Math.floor(e / this.DB), s = this.s << r & this.DM;
for (n = this.t - 1; n >= 0; --n)
t[n + a + 1] = this[n] >> i | s,
s = (this[n] & o) << r;
for (n = a - 1; n >= 0; --n)
t[n] = 0;
t[a] = s,
t.t = this.t + a + 1,
t.s = this.s,
t.clamp()
}
function D(e, t) {
t.s = this.s;
var n = Math.floor(e / this.DB);
if (n >= this.t)
t.t = 0;
else {
var r = e % this.DB
, i = this.DB - r
, o = (1 << r) - 1;
t[0] = this[n] >> r;
for (var a = n + 1; a < this.t; ++a)
t[a - n - 1] |= (this[a] & o) << i,
t[a - n] = this[a] >> r;
r > 0 && (t[this.t - n - 1] |= (this.s & o) << i),
t.t = this.t - n,
t.clamp()
}
}
function E(e, t) {
var n = 0
, r = 0
, i = Math.min(e.t, this.t);
while (n < i)
r += this[n] - e[n],
t[n++] = r & this.DM,
r >>= this.DB;
if (e.t < this.t) {
r -= e.s;
while (n < this.t)
r += this[n],
t[n++] = r & this.DM,
r >>= this.DB;
r += this.s
} else {
r += this.s;
while (n < e.t)
r -= e[n],
t[n++] = r & this.DM,
r >>= this.DB;
r -= e.s
}
t.s = r < 0 ? -1 : 0,
r < -1 ? t[n++] = this.DV + r : r > 0 && (t[n++] = r),
t.t = n,
t.clamp()
}
function I(e, t) {
var n = this.abs()
, r = e.abs()
, o = n.t;
t.t = o + r.t;
while (--o >= 0)
t[o] = 0;
for (o = 0; o < r.t; ++o)
t[o + n.t] = n.am(0, r[o], t, o, 0, n.t);
t.s = 0,
t.clamp(),
this.s != e.s && i.ZERO.subTo(t, t)
}
function P(e) {
var t = this.abs()
, n = e.t = 2 * t.t;
while (--n >= 0)
e[n] = 0;
for (n = 0; n < t.t - 1; ++n) {
var r = t.am(n, t[n], e, 2 * n, 0, 1);
(e[n + t.t] += t.am(n + 1, 2 * t[n], e, 2 * n + 1, r, t.t - n - 1)) >= t.DV && (e[n + t.t] -= t.DV,
e[n + t.t + 1] = 1)
}
e.t > 0 && (e[e.t - 1] += t.am(n, t[n], e, 2 * n, 0, 1)),
e.s = 0,
e.clamp()
}
function L(e, t, n) {
var r = e.abs();
if (!(r.t <= 0)) {
var a = this.abs();
if (a.t < r.t)
return null != t && t.fromInt(0),
void (null != n && this.copyTo(n));
null == n && (n = o());
var s = o()
, u = this.s
, l = e.s
, c = this.DB - k(r[r.t - 1]);
c > 0 ? (r.lShiftTo(c, s),
a.lShiftTo(c, n)) : (r.copyTo(s),
a.copyTo(n));
var f = s.t
, d = s[f - 1];
if (0 != d) {
var h = d * (1 << this.F1) + (f > 1 ? s[f - 2] >> this.F2 : 0)
, p = this.FV / h
, m = (1 << this.F1) / h
, g = 1 << this.F2
, v = n.t
, y = v - f
, b = null == t ? o() : t;
s.dlShiftTo(y, b),
n.compareTo(b) >= 0 && (n[n.t++] = 1,
n.subTo(b, n)),
i.ONE.dlShiftTo(f, b),
b.subTo(s, s);
while (s.t < f)
s[s.t++] = 0;
while (--y >= 0) {
var x = n[--v] == d ? this.DM : Math.floor(n[v] * p + (n[v - 1] + g) * m);
if ((n[v] += s.am(0, x, n, y, 0, f)) < x) {
s.dlShiftTo(y, b),
n.subTo(b, n);
while (n[v] < --x)
n.subTo(b, n)
}
}
null != t && (n.drShiftTo(f, t),
u != l && i.ZERO.subTo(t, t)),
n.t = f,
n.clamp(),
c > 0 && n.rShiftTo(c, n),
u < 0 && i.ZERO.subTo(n, n)
}
}
}
function N(e) {
var t = o();
return this.abs().divRemTo(e, null, t),
this.s < 0 && t.compareTo(i.ZERO) > 0 && e.subTo(t, t),
t
}
function B(e) {
this.m = e
}
function R(e) {
return e.s < 0 || e.compareTo(this.m) >= 0 ? e.mod(this.m) : e
}
function z(e) {
return e
}
function F(e) {
e.divRemTo(this.m, null, e)
}
function H(e, t, n) {
e.multiplyTo(t, n),
this.reduce(n)
}
function $(e, t) {
e.squareTo(t),
this.reduce(t)
}
function V() {
if (this.t < 1)
return 0;
var e = this[0];
if (0 == (1 & e))
return 0;
var t = 3 & e;
return t = t * (2 - (15 & e) * t) & 15,
t = t * (2 - (255 & e) * t) & 255,
t = t * (2 - ((65535 & e) * t & 65535)) & 65535,
t = t * (2 - e * t % this.DV) % this.DV,
t > 0 ? this.DV - t : -t
}
function W(e) {
this.m = e,
this.mp = e.invDigit(),
this.mpl = 32767 & this.mp,
this.mph = this.mp >> 15,
this.um = (1 << e.DB - 15) - 1,
this.mt2 = 2 * e.t
}
function U(e) {
var t = o();
return e.abs().dlShiftTo(this.m.t, t),
t.divRemTo(this.m, null, t),
e.s < 0 && t.compareTo(i.ZERO) > 0 && this.m.subTo(t, t),
t
}
function G(e) {
var t = o();
return e.copyTo(t),
this.reduce(t),
t
}
function q(e) {
while (e.t <= this.mt2)
e[e.t++] = 0;
for (var t = 0; t < this.m.t; ++t) {
var n = 32767 & e[t]
, r = n * this.mpl + ((n * this.mph + (e[t] >> 15) * this.mpl & this.um) << 15) & e.DM;
n = t + this.m.t,
e[n] += this.m.am(0, r, e, t, 0, this.m.t);
while (e[n] >= e.DV)
e[n] -= e.DV,
e[++n]++
}
e.clamp(),
e.drShiftTo(this.m.t, e),
e.compareTo(this.m) >= 0 && e.subTo(this.m, e)
}
function Y(e, t) {
e.squareTo(t),
this.reduce(t)
}
function X(e, t, n) {
e.multiplyTo(t, n),
this.reduce(n)
}
function Z() {
return 0 == (this.t > 0 ? 1 & this[0] : this.s)
}
function K(e, t) {
if (e > 4294967295 || e < 1)
return i.ONE;
var n = o()
, r = o()
, a = t.convert(this)
, s = k(e) - 1;
a.copyTo(n);
while (--s >= 0)
if (t.sqrTo(n, r),
(e & 1 << s) > 0)
t.mulTo(r, a, n);
else {
var u = n;
n = r,
r = u
}
return t.revert(n)
}
function J(e, t) {
var n;
return n = e < 256 || t.isEven() ? new B(t) : new W(t),
this.exp(e, n)
}
function Q() {
var e = o();
return this.copyTo(e),
e
}
function ee() {
if (this.s < 0) {
if (1 == this.t)
return this[0] - this.DV;
if (0 == this.t)
return -1
} else {
if (1 == this.t)
return this[0];
if (0 == this.t)
return 0
}
return (this[1] & (1 << 32 - this.DB) - 1) << this.DB | this[0]
}
function te() {
return 0 == this.t ? this.s : this[0] << 24 >> 24
}
function ne() {
return 0 == this.t ? this.s : this[0] << 16 >> 16
}
function re(e) {
return Math.floor(Math.LN2 * this.DB / Math.log(e))
}
function ie() {
return this.s < 0 ? -1 : this.t <= 0 || 1 == this.t && this[0] <= 0 ? 0 : 1
}
function oe(e) {
if (null == e && (e = 10),
0 == this.signum() || e < 2 || e > 36)
return "0";
var t = this.chunkSize(e)
, n = Math.pow(e, t)
, r = b(n)
, i = o()
, a = o()
, s = "";
this.divRemTo(r, i, a);
while (i.signum() > 0)
s = (n + a.intValue()).toString(e).substr(1) + s,
i.divRemTo(r, i, a);
return a.intValue().toString(e) + s
}
function ae(e, t) {
this.fromInt(0),
null == t && (t = 10);
for (var n = this.chunkSize(t), r = Math.pow(t, n), o = !1, a = 0, s = 0, u = 0; u < e.length; ++u) {
var l = g(e, u);
l < 0 ? "-" == e.charAt(u) && 0 == this.signum() && (o = !0) : (s = t * s + l,
++a >= n && (this.dMultiply(r),
this.dAddOffset(s, 0),
a = 0,
s = 0))
}
a > 0 && (this.dMultiply(Math.pow(t, a)),
this.dAddOffset(s, 0)),
o && i.ZERO.subTo(this, this)
}
function se(e, t, n) {
if ("number" == typeof t)
if (e < 2)
this.fromInt(1);
else {
this.fromNumber(e, n),
this.testBit(e - 1) || this.bitwiseTo(i.ONE.shiftLeft(e - 1), me, this),
this.isEven() && this.dAddOffset(1, 0);
while (!this.isProbablePrime(t))
this.dAddOffset(2, 0),
this.bitLength() > e && this.subTo(i.ONE.shiftLeft(e - 1), this)
}
else {
var r = new Array
, o = 7 & e;
r.length = 1 + (e >> 3),
t.nextBytes(r),
o > 0 ? r[0] &= (1 << o) - 1 : r[0] = 0,
this.fromString(r, 256)
}
}
function ue() {
var e = this.t
, t = new Array;
t[0] = this.s;
var n, r = this.DB - e * this.DB % 8, i = 0;
if (e-- > 0) {
r < this.DB && (n = this[e] >> r) != (this.s & this.DM) >> r && (t[i++] = n | this.s << this.DB - r);
while (e >= 0)
r < 8 ? (n = (this[e] & (1 << r) - 1) << 8 - r,
n |= this[--e] >> (r += this.DB - 8)) : (n = this[e] >> (r -= 8) & 255,
r <= 0 && (r += this.DB,
--e)),
0 != (128 & n) && (n |= -256),
0 == i && (128 & this.s) != (128 & n) && ++i,
(i > 0 || n != this.s) && (t[i++] = n)
}
return t
}
function le(e) {
return 0 == this.compareTo(e)
}
function ce(e) {
return this.compareTo(e) < 0 ? this : e
}
function fe(e) {
return this.compareTo(e) > 0 ? this : e
}
function de(e, t, n) {
var r, i, o = Math.min(e.t, this.t);
for (r = 0; r < o; ++r)
n[r] = t(this[r], e[r]);
if (e.t < this.t) {
for (i = e.s & this.DM,
r = o; r < this.t; ++r)
n[r] = t(this[r], i);
n.t = this.t
} else {
for (i = this.s & this.DM,
r = o; r < e.t; ++r)
n[r] = t(i, e[r]);
n.t = e.t
}
n.s = t(this.s, e.s),
n.clamp()
}
function he(e, t) {
return e & t
}
function pe(e) {
var t = o();
return this.bitwiseTo(e, he, t),
t
}
function me(e, t) {
return e | t
}
function ge(e) {
var t = o();
return this.bitwiseTo(e, me, t),
t
}
function ve(e, t) {
return e ^ t
}
function ye(e) {
var t = o();
return this.bitwiseTo(e, ve, t),
t
}
function be(e, t) {
return e & ~t
}
function xe(e) {
var t = o();
return this.bitwiseTo(e, be, t),
t
}
function we() {
for (var e = o(), t = 0; t < this.t; ++t)
e[t] = this.DM & ~this[t];
return e.t = this.t,
e.s = ~this.s,
e
}
function _e(e) {
var t = o();
return e < 0 ? this.rShiftTo(-e, t) : this.lShiftTo(e, t),
t
}
function Se(e) {
var t = o();
return e < 0 ? this.lShiftTo(-e, t) : this.rShiftTo(e, t),
t
}
function Oe(e) {
if (0 == e)
return -1;
var t = 0;
return 0 == (65535 & e) && (e >>= 16,
t += 16),
0 == (255 & e) && (e >>= 8,
t += 8),
0 == (15 & e) && (e >>= 4,
t += 4),
0 == (3 & e) && (e >>= 2,
t += 2),
0 == (1 & e) && ++t,
t
}
function Ce() {
for (var e = 0; e < this.t; ++e)
if (0 != this[e])
return e * this.DB + Oe(this[e]);
return this.s < 0 ? this.t * this.DB : -1
}
function ke(e) {
var t = 0;
while (0 != e)
e &= e - 1,
++t;
return t
}
function Te() {
for (var e = 0, t = this.s & this.DM, n = 0; n < this.t; ++n)
e += ke(this[n] ^ t);
return e
}
function Me(e) {
var t = Math.floor(e / this.DB);
return t >= this.t ? 0 != this.s : 0 != (this[t] & 1 << e % this.DB)
}
function Ae(e, t) {
var n = i.ONE.shiftLeft(e);
return this.bitwiseTo(n, t, n),
n
}
function je(e) {
return this.changeBit(e, me)
}
function De(e) {
return this.changeBit(e, be)
}
function Ee(e) {
return this.changeBit(e, ve)
}
function Ie(e, t) {
var n = 0
, r = 0
, i = Math.min(e.t, this.t);
while (n < i)
r += this[n] + e[n],
t[n++] = r & this.DM,
r >>= this.DB;
if (e.t < this.t) {
r += e.s;
while (n < this.t)
r += this[n],
t[n++] = r & this.DM,
r >>= this.DB;
r += this.s
} else {
r += this.s;
while (n < e.t)
r += e[n],
t[n++] = r & this.DM,
r >>= this.DB;
r += e.s
}
t.s = r < 0 ? -1 : 0,
r > 0 ? t[n++] = r : r < -1 && (t[n++] = this.DV + r),
t.t = n,
t.clamp()
}
function Pe(e) {
var t = o();
return this.addTo(e, t),
t
}
function Le(e) {
var t = o();
return this.subTo(e, t),
t
}
function Ne(e) {
var t = o();
return this.multiplyTo(e, t),
t
}
function Be() {
var e = o();
return this.squareTo(e),
e
}
function Re(e) {
var t = o();
return this.divRemTo(e, t, null),
t
}
function ze(e) {
var t = o();
return this.divRemTo(e, null, t),
t
}
function Fe(e) {
var t = o()
, n = o();
return this.divRemTo(e, t, n),
new Array(t,n)
}
function He(e) {
this[this.t] = this.am(0, e - 1, this, 0, 0, this.t),
++this.t,
this.clamp()
}
function $e(e, t) {
if (0 != e) {
while (this.t <= t)
this[this.t++] = 0;
this[t] += e;
while (this[t] >= this.DV)
this[t] -= this.DV,
++t >= this.t && (this[this.t++] = 0),
++this[t]
}
}
function Ve() {}
function We(e) {
return e
}
function Ue(e, t, n) {
e.multiplyTo(t, n)
}
function Ge(e, t) {
e.squareTo(t)
}
function qe(e) {
return this.exp(e, new Ve)
}
function Ye(e, t, n) {
var r, i = Math.min(this.t + e.t, t);
n.s = 0,
n.t = i;
while (i > 0)
n[--i] = 0;
for (r = n.t - this.t; i < r; ++i)
n[i + this.t] = this.am(0, e[i], n, i, 0, this.t);
for (r = Math.min(e.t, t); i < r; ++i)
this.am(0, e[i], n, i, 0, t - i);
n.clamp()
}
function Xe(e, t, n) {
--t;
var r = n.t = this.t + e.t - t;
n.s = 0;
while (--r >= 0)
n[r] = 0;
for (r = Math.max(t - this.t, 0); r < e.t; ++r)
n[this.t + r - t] = this.am(t - r, e[r], n, 0, 0, this.t + r - t);
n.clamp(),
n.drShiftTo(1, n)
}
function Ze(e) {
this.r2 = o(),
this.q3 = o(),
i.ONE.dlShiftTo(2 * e.t, this.r2),
this.mu = this.r2.divide(e),
this.m = e
}
function Ke(e) {
if (e.s < 0 || e.t > 2 * this.m.t)
return e.mod(this.m);
if (e.compareTo(this.m) < 0)
return e;
var t = o();
return e.copyTo(t),
this.reduce(t),
t
}
function Je(e) {
return e
}
function Qe(e) {
e.drShiftTo(this.m.t - 1, this.r2),
e.t > this.m.t + 1 && (e.t = this.m.t + 1,
e.clamp()),
this.mu.multiplyUpperTo(this.r2, this.m.t + 1, this.q3),
this.m.multiplyLowerTo(this.q3, this.m.t + 1, this.r2);
while (e.compareTo(this.r2) < 0)
e.dAddOffset(1, this.m.t + 1);
e.subTo(this.r2, e);
while (e.compareTo(this.m) >= 0)
e.subTo(this.m, e)
}
function et(e, t) {
e.squareTo(t),
this.reduce(t)
}
function tt(e, t, n) {
e.multiplyTo(t, n),
this.reduce(n)
}
function nt(e, t) {
var n, r, i = e.bitLength(), a = b(1);
if (i <= 0)
return a;
n = i < 18 ? 1 : i < 48 ? 3 : i < 144 ? 4 : i < 768 ? 5 : 6,
r = i < 8 ? new B(t) : t.isEven() ? new Ze(t) : new W(t);
var s = new Array
, u = 3
, l = n - 1
, c = (1 << n) - 1;
if (s[1] = r.convert(this),
n > 1) {
var f = o();
r.sqrTo(s[1], f);
while (u <= c)
s[u] = o(),
r.mulTo(f, s[u - 2], s[u]),
u += 2
}
var d, h, p = e.t - 1, m = !0, g = o();
i = k(e[p]) - 1;
while (p >= 0) {
i >= l ? d = e[p] >> i - l & c : (d = (e[p] & (1 << i + 1) - 1) << l - i,
p > 0 && (d |= e[p - 1] >> this.DB + i - l)),
u = n;
while (0 == (1 & d))
d >>= 1,
--u;
if ((i -= u) < 0 && (i += this.DB,
--p),
m)
s[d].copyTo(a),
m = !1;
else {
while (u > 1)
r.sqrTo(a, g),
r.sqrTo(g, a),
u -= 2;
u > 0 ? r.sqrTo(a, g) : (h = a,
a = g,
g = h),
r.mulTo(g, s[d], a)
}
while (p >= 0 && 0 == (e[p] & 1 << i))
r.sqrTo(a, g),
h = a,
a = g,
g = h,
--i < 0 && (i = this.DB - 1,
--p)
}
return r.revert(a)
}
function rt(e) {
var t = this.s < 0 ? this.negate() : this.clone()
, n = e.s < 0 ? e.negate() : e.clone();
if (t.compareTo(n) < 0) {
var r = t;
t = n,
n = r
}
var i = t.getLowestSetBit()
, o = n.getLowestSetBit();
if (o < 0)
return t;
i < o && (o = i),
o > 0 && (t.rShiftTo(o, t),
n.rShiftTo(o, n));
while (t.signum() > 0)
(i = t.getLowestSetBit()) > 0 && t.rShiftTo(i, t),
(i = n.getLowestSetBit()) > 0 && n.rShiftTo(i, n),
t.compareTo(n) >= 0 ? (t.subTo(n, t),
t.rShiftTo(1, t)) : (n.subTo(t, n),
n.rShiftTo(1, n));
return o > 0 && n.lShiftTo(o, n),
n
}
function it(e) {
if (e <= 0)
return 0;
var t = this.DV % e
, n = this.s < 0 ? e - 1 : 0;
if (this.t > 0)
if (0 == t)
n = this[0] % e;
else
for (var r = this.t - 1; r >= 0; --r)
n = (t * n + this[r]) % e;
return n
}
function ot(e) {
var t = e.isEven();
if (this.isEven() && t || 0 == e.signum())
return i.ZERO;
var n = e.clone()
, r = this.clone()
, o = b(1)
, a = b(0)
, s = b(0)
, u = b(1);
while (0 != n.signum()) {
while (n.isEven())
n.rShiftTo(1, n),
t ? (o.isEven() && a.isEven() || (o.addTo(this, o),
a.subTo(e, a)),
o.rShiftTo(1, o)) : a.isEven() || a.subTo(e, a),
a.rShiftTo(1, a);
while (r.isEven())
r.rShiftTo(1, r),
t ? (s.isEven() && u.isEven() || (s.addTo(this, s),
u.subTo(e, u)),
s.rShiftTo(1, s)) : u.isEven() || u.subTo(e, u),
u.rShiftTo(1, u);
n.compareTo(r) >= 0 ? (n.subTo(r, n),
t && o.subTo(s, o),
a.subTo(u, a)) : (r.subTo(n, r),
t && s.subTo(o, s),
u.subTo(a, u))
}
return 0 != r.compareTo(i.ONE) ? i.ZERO : u.compareTo(e) >= 0 ? u.subtract(e) : u.signum() < 0 ? (u.addTo(e, u),
u.signum() < 0 ? u.add(e) : u) : u
}
B.prototype.convert = R,
B.prototype.revert = z,
B.prototype.reduce = F,
B.prototype.mulTo = H,
B.prototype.sqrTo = $,
W.prototype.convert = U,
W.prototype.revert = G,
W.prototype.reduce = q,
W.prototype.mulTo = X,
W.prototype.sqrTo = Y,
i.prototype.copyTo = v,
i.prototype.fromInt = y,
i.prototype.fromString = x,
i.prototype.clamp = w,
i.prototype.dlShiftTo = M,
i.prototype.drShiftTo = A,
i.prototype.lShiftTo = j,
i.prototype.rShiftTo = D,
i.prototype.subTo = E,
i.prototype.multiplyTo = I,
i.prototype.squareTo = P,
i.prototype.divRemTo = L,
i.prototype.invDigit = V,
i.prototype.isEven = Z,
i.prototype.exp = K,
i.prototype.toString = _,
i.prototype.negate = S,
i.prototype.abs = O,
i.prototype.compareTo = C,
i.prototype.bitLength = T,
i.prototype.mod = N,
i.prototype.modPowInt = J,
i.ZERO = b(0),
i.ONE = b(1),
Ve.prototype.convert = We,
Ve.prototype.revert = We,
Ve.prototype.mulTo = Ue,
Ve.prototype.sqrTo = Ge,
Ze.prototype.convert = Ke,
Ze.prototype.revert = Je,
Ze.prototype.reduce = Qe,
Ze.prototype.mulTo = tt,
Ze.prototype.sqrTo = et;
var at, st, ut, lt = [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, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997], ct = (1 << 26) / lt[lt.length - 1];
function ft(e) {
var t, n = this.abs();
if (1 == n.t && n[0] <= lt[lt.length - 1]) {
for (t = 0; t < lt.length; ++t)
if (n[0] == lt[t])
return !0;
return !1
}
if (n.isEven())
return !1;
t = 1;
while (t < lt.length) {
var r = lt[t]
, i = t + 1;
while (i < lt.length && r < ct)
r *= lt[i++];
r = n.modInt(r);
while (t < i)
if (r % lt[t++] == 0)
return !1
}
return n.millerRabin(e)
}
function dt(e) {
var t = this.subtract(i.ONE)
, n = t.getLowestSetBit();
if (n <= 0)
return !1;
var r = t.shiftRight(n);
e = e + 1 >> 1,
e > lt.length && (e = lt.length);
for (var a = o(), s = 0; s < e; ++s) {
a.fromInt(lt[Math.floor(Math.random() * lt.length)]);
var u = a.modPow(r, this);
if (0 != u.compareTo(i.ONE) && 0 != u.compareTo(t)) {
var l = 1;
while (l++ < n && 0 != u.compareTo(t))
if (u = u.modPowInt(2, this),
0 == u.compareTo(i.ONE))
return !1;
if (0 != u.compareTo(t))
return !1
}
}
return !0
}
function ht(e) {
st[ut++] ^= 255 & e,
st[ut++] ^= e >> 8 & 255,
st[ut++] ^= e >> 16 & 255,
st[ut++] ^= e >> 24 & 255,
ut >= Ct && (ut -= Ct)
}
function pt() {
ht((new Date).getTime())
}
if (i.prototype.chunkSize = re,
i.prototype.toRadix = oe,
i.prototype.fromRadix = ae,
i.prototype.fromNumber = se,
i.prototype.bitwiseTo = de,
i.prototype.changeBit = Ae,
i.prototype.addTo = Ie,
i.prototype.dMultiply = He,
i.prototype.dAddOffset = $e,
i.prototype.multiplyLowerTo = Ye,
i.prototype.multiplyUpperTo = Xe,
i.prototype.modInt = it,
i.prototype.millerRabin = dt,
i.prototype.clone = Q,
i.prototype.intValue = ee,
i.prototype.byteValue = te,
i.prototype.shortValue = ne,
i.prototype.signum = ie,
i.prototype.toByteArray = ue,
i.prototype.equals = le,
i.prototype.min = ce,
i.prototype.max = fe,
i.prototype.and = pe,
i.prototype.or = ge,
i.prototype.xor = ye,
i.prototype.andNot = xe,
i.prototype.not = we,
i.prototype.shiftLeft = _e,
i.prototype.shiftRight = Se,
i.prototype.getLowestSetBit = Ce,
i.prototype.bitCount = Te,
i.prototype.testBit = Me,
i.prototype.setBit = je,
i.prototype.clearBit = De,
i.prototype.flipBit = Ee,
i.prototype.add = Pe,
i.prototype.subtract = Le,
i.prototype.multiply = Ne,
i.prototype.divide = Re,
i.prototype.remainder = ze,
i.prototype.divideAndRemainder = Fe,
i.prototype.modPow = nt,
i.prototype.modInverse = ot,
i.prototype.pow = qe,
i.prototype.gcd = rt,
i.prototype.isProbablePrime = ft,
i.prototype.square = Be,
i.prototype.Barrett = Ze,
null == st) {
var mt;
if (st = new Array,
ut = 0,
"undefined" !== typeof window && window.crypto)
if (window.crypto.getRandomValues) {
var gt = new Uint8Array(32);
for (window.crypto.getRandomValues(gt),
mt = 0; mt < 32; ++mt)
st[ut++] = gt[mt]
} else if ("Netscape" == navigator.appName && navigator.appVersion < "5") {
var vt = window.crypto.random(32);
for (mt = 0; mt < vt.length; ++mt)
st[ut++] = 255 & vt.charCodeAt(mt)
}
while (ut < Ct)
mt = Math.floor(65536 * Math.random()),
st[ut++] = mt >>> 8,
st[ut++] = 255 & mt;
ut = 0,
pt()
}
function yt() {
if (null == at) {
for (pt(),
at = Ot(),
at.init(st),
ut = 0; ut < st.length; ++ut)
st[ut] = 0;
ut = 0
}
return at.next()
}
function bt(e) {
var t;
for (t = 0; t < e.length; ++t)
e[t] = yt()
}
function xt() {}
function wt() {
this.i = 0,
this.j = 0,
this.S = new Array
}
function _t(e) {
var t, n, r;
for (t = 0; t < 256; ++t)
this.S[t] = t;
for (n = 0,
t = 0; t < 256; ++t)
n = n + this.S[t] + e[t % e.length] & 255,
r = this.S[t],
this.S[t] = this.S[n],
this.S[n] = r;
this.i = 0,
this.j = 0
}
function St() {
var e;
return this.i = this.i + 1 & 255,
this.j = this.j + this.S[this.i] & 255,
e = this.S[this.i],
this.S[this.i] = this.S[this.j],
this.S[this.j] = e,
this.S[e + this.S[this.i] & 255]
}
function Ot() {
return new wt
}
xt.prototype.nextBytes = bt,
wt.prototype.init = _t,
wt.prototype.next = St;
var Ct = 256;
e.exports = {
default: i,
BigInteger: i,
SecureRandom: xt
}
}
).call(this)
}, "41d0": function(e, t, n) {
const {BigInteger: r} = n("f33e")
, i = n("dffd")
, o = function(e, t, n, r, i) {
for (let o = 0; o < i; o++)
n[r + o] = e[t + o]
}
, a = {
minValue: -2147483648,
maxValue: 2147483647,
parse(e) {
if (e < this.minValue) {
const t = Number(-e)
, n = t.toString(2)
, r = n.substr(n.length - 31, 31);
let i = "";
for (let e = 0; e < r.length; e++) {
const t = r.substr(e, 1);
i += "0" === t ? "1" : "0"
}
const o = parseInt(i, 2);
return o + 1
}
if (e > this.maxValue) {
const t = Number(e)
, n = t.toString(2)
, r = n.substr(n.length - 31, 31);
let i = "";
for (let e = 0; e < r.length; e++) {
const t = r.substr(e, 1);
i += "0" === t ? "1" : "0"
}
const o = parseInt(i, 2);
return -(o + 1)
}
return e
},
parseByte(e) {
if (e < 0) {
const t = Number(-e)
, n = t.toString(2)
, r = n.substr(n.length - 8, 8);
let i = "";
for (let e = 0; e < r.length; e++) {
const t = r.substr(e, 1);
i += "0" === t ? "1" : "0"
}
const o = parseInt(i, 2);
return (o + 1) % 256
}
if (e > 255) {
const t = Number(e)
, n = t.toString(2);
return parseInt(n.substr(n.length - 8, 8), 2)
}
return e
}
};
class s {
constructor(...e) {
this.xBuf = [],
this.xBufOff = 0,
this.byteCount = 0,
this.DIGEST_LENGTH = 32,
this.v0 = [1937774191, 1226093241, 388252375, 3666478592, 2842636476, 372324522, 3817729613, 2969243214],
this.v0 = [1937774191, 1226093241, 388252375, -628488704, -1452330820, 372324522, -477237683, -1325724082],
this.v = new Array(8),
this.v_ = new Array(8),
this.X0 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
this.X = new Array(68),
this.xOff = 0,
this.T_00_15 = 2043430169,
this.T_16_63 = 2055708042,
e.length > 0 ? this.initDigest(e[0]) : this.init()
}
init() {
this.xBuf = new Array(4),
this.reset()
}
initDigest(e) {
this.xBuf = [].concat(e.xBuf),
this.xBufOff = e.xBufOff,
this.byteCount = e.byteCount,
o(e.X, 0, this.X, 0, e.X.length),
this.xOff = e.xOff,
o(e.v, 0, this.v, 0, e.v.length)
}
getDigestSize() {
return this.DIGEST_LENGTH
}
reset() {
this.byteCount = 0,
this.xBufOff = 0;
const e = Object.keys(this.xBuf);
for (let t = 0, n = e.length; t < n; t++)
this.xBuf[e[t]] = null;
o(this.v0, 0, this.v, 0, this.v0.length),
this.xOff = 0,
o(this.X0, 0, this.X, 0, this.X0.length)
}
processBlock() {
let e;
const t = this.X
, n = new Array(64);
for (e = 16; e < 68; e++)
t[e] = this.p1(t[e - 16] ^ t[e - 9] ^ this.rotate(t[e - 3], 15)) ^ this.rotate(t[e - 13], 7) ^ t[e - 6];
for (e = 0; e < 64; e++)
n[e] = t[e] ^ t[e + 4];
const r = this.v
, i = this.v_;
let s, u, l, c, f;
for (o(r, 0, i, 0, this.v0.length),
e = 0; e < 16; e++)
f = this.rotate(i[0], 12),
s = a.parse(a.parse(f + i[4]) + this.rotate(this.T_00_15, e)),
s = this.rotate(s, 7),
u = s ^ f,
l = a.parse(a.parse(this.ff_00_15(i[0], i[1], i[2]) + i[3]) + u) + n[e],
c = a.parse(a.parse(this.gg_00_15(i[4], i[5], i[6]) + i[7]) + s) + t[e],
i[3] = i[2],
i[2] = this.rotate(i[1], 9),
i[1] = i[0],
i[0] = l,
i[7] = i[6],
i[6] = this.rotate(i[5], 19),
i[5] = i[4],
i[4] = this.p0(c);
for (e = 16; e < 64; e++)
f = this.rotate(i[0], 12),
s = a.parse(a.parse(f + i[4]) + this.rotate(this.T_16_63, e)),
s = this.rotate(s, 7),
u = s ^ f,
l = a.parse(a.parse(this.ff_16_63(i[0], i[1], i[2]) + i[3]) + u) + n[e],
c = a.parse(a.parse(this.gg_16_63(i[4], i[5], i[6]) + i[7]) + s) + t[e],
i[3] = i[2],
i[2] = this.rotate(i[1], 9),
i[1] = i[0],
i[0] = l,
i[7] = i[6],
i[6] = this.rotate(i[5], 19),
i[5] = i[4],
i[4] = this.p0(c);
for (e = 0; e < 8; e++)
r[e] ^= a.parse(i[e]);
this.xOff = 0,
o(this.X0, 0, this.X, 0, this.X0.length)
}
processWord(e, t) {
let n = e[t] << 24;
n |= (255 & e[++t]) << 16,
n |= (255 & e[++t]) << 8,
n |= 255 & e[++t],
this.X[this.xOff] = n,
16 === ++this.xOff && this.processBlock()
}
processLength(e) {
this.xOff > 14 && this.processBlock(),
this.X[14] = this.urShiftLong(e, 32),
this.X[15] = 4294967295 & e
}
intToBigEndian(e, t, n) {
t[n] = 255 & a.parseByte(this.urShift(e, 24)),
t[++n] = 255 & a.parseByte(this.urShift(e, 16)),
t[++n] = 255 & a.parseByte(this.urShift(e, 8)),
t[++n] = 255 & a.parseByte(e)
}
doFinal(e, t) {
this.finish();
for (let n = 0; n < 8; n++)
this.intToBigEndian(this.v[n], e, t + 4 * n);
return this.reset(),
this.DIGEST_LENGTH
}
update(e) {
this.xBuf[this.xBufOff++] = e,
this.xBufOff === this.xBuf.length && (this.processWord(this.xBuf, 0),
this.xBufOff = 0),
this.byteCount++
}
blockUpdate(e, t, n) {
while (0 !== this.xBufOff && n > 0)
this.update(e[t]),
t++,
n--;
while (n > this.xBuf.length)
this.processWord(e, t),
t += this.xBuf.length,
n -= this.xBuf.length,
this.byteCount += this.xBuf.length;
while (n > 0)
this.update(e[t]),
t++,
n--
}
finish() {
const e = this.byteCount << 3;
this.update(128);
while (0 !== this.xBufOff)
this.update(0);
this.processLength(e),
this.processBlock()
}
rotate(e, t) {
return e << t | this.urShift(e, 32 - t)
}
p0(e) {
return e ^ this.rotate(e, 9) ^ this.rotate(e, 17)
}
p1(e) {
return e ^ this.rotate(e, 15) ^ this.rotate(e, 23)
}
ff_00_15(e, t, n) {
return e ^ t ^ n
}
ff_16_63(e, t, n) {
return e & t | e & n | t & n
}
gg_00_15(e, t, n) {
return e ^ t ^ n
}
gg_16_63(e, t, n) {
return e & t | ~e & n
}
urShift(e, t) {
return (e > a.maxValue || e < a.minValue) && (e = a.parse(e)),
e >>> t
}
urShiftLong(e, t) {
let n;
const i = new r;
if (i.fromInt(e),
i.signum() >= 0)
n = i.shiftRight(t).intValue();
else {
const i = new r;
i.fromInt(2);
const o = ~t;
let a = "";
if (o < 0) {
const i = 64 + o;
for (let e = 0; e < i; e++)
a += "0";
const s = new r;
s.fromInt(e >> t);
const u = new r("10" + a,2);
a = u.toRadix(10);
const l = u.add(s);
n = l.toRadix(10)
} else
a = i.shiftLeft(~t).intValue(),
n = (e >> t) + a
}
return n
}
getZ(e, t, n) {
let r = 0;
if (n) {
if ("string" !== typeof n)
throw new Error("sm2: Type of userId Must be String! Receive Type: " + typeof n);
if (n.length >= 8192)
throw new Error("sm2: The Length of userId Must Less Than 8192! Length: " + n.length);
n = i.parseUtf8StringToHex(n),
r = 4 * n.length
}
if (this.update(r >> 8 & 255),
this.update(255 & r),
n) {
const e = i.hexToArray(n);
this.blockUpdate(e, 0, e.length)
}
const o = i.hexToArray(i.leftPad(e.curve.a.toBigInteger().toRadix(16), 64))
, a = i.hexToArray(i.leftPad(e.curve.b.toBigInteger().toRadix(16), 64))
, s = i.hexToArray(i.leftPad(e.getX().toBigInteger().toRadix(16), 64))
, u = i.hexToArray(i.leftPad(e.getY().toBigInteger().toRadix(16), 64))
, l = i.hexToArray(t.substr(0, 64))
, c = i.hexToArray(t.substr(64, 64));
this.blockUpdate(o, 0, o.length),
this.blockUpdate(a, 0, a.length),
this.blockUpdate(s, 0, s.length),
this.blockUpdate(u, 0, u.length),
this.blockUpdate(l, 0, l.length),
this.blockUpdate(c, 0, c.length);
const f = new Array(this.getDigestSize());
return this.doFinal(f, 0),
f
}
}
e.exports = s
},a336: function(e, t, n) {
const {BigInteger: r} = n("f33e")
, i = n("41d0")
, o = n("dffd");
class a {
constructor() {
this.ct = 1,
this.p2 = null,
this.sm3keybase = null,
this.sm3c3 = null,
this.key = new Array(32),
this.keyOff = 0
}
reset() {
this.sm3keybase = new i,
this.sm3c3 = new i;
const e = o.hexToArray(o.leftPad(this.p2.getX().toBigInteger().toRadix(16), 64))
, t = o.hexToArray(o.leftPad(this.p2.getY().toBigInteger().toRadix(16), 64));
this.sm3keybase.blockUpdate(e, 0, e.length),
this.sm3c3.blockUpdate(e, 0, e.length),
this.sm3keybase.blockUpdate(t, 0, t.length),
this.ct = 1,
this.nextKey()
}
nextKey() {
const e = new i(this.sm3keybase);
e.update(this.ct >> 24 & 255),
e.update(this.ct >> 16 & 255),
e.update(this.ct >> 8 & 255),
e.update(255 & this.ct),
e.doFinal(this.key, 0),
this.keyOff = 0,
this.ct++
}
initEncipher(e) {
const t = o.generateKeyPairHex()
, n = new r(t.privateKey,16);
let i = t.publicKey;
return this.p2 = e.multiply(n),
this.reset(),
i.length > 128 && (i = i.substr(i.length - 128)),
i
}
encryptBlock(e) {
this.sm3c3.blockUpdate(e, 0, e.length);
for (let t = 0; t < e.length; t++)
this.keyOff === this.key.length && this.nextKey(),
e[t] ^= 255 & this.key[this.keyOff++]
}
initDecipher(e, t) {
this.p2 = t.multiply(e),
this.reset()
}
decryptBlock(e) {
for (let t = 0; t < e.length; t++)
this.keyOff === this.key.length && this.nextKey(),
e[t] ^= 255 & this.key[this.keyOff++];
this.sm3c3.blockUpdate(e, 0, e.length)
}
doFinal(e) {
const t = o.hexToArray(o.leftPad(this.p2.getY().toBigInteger().toRadix(16), 64));
this.sm3c3.blockUpdate(t, 0, t.length),
this.sm3c3.doFinal(e, 0),
this.reset()
}
createPoint(e, t) {
const n = "04" + e + t
, r = o.getGlobalCurve().decodePointHex(n);
return r
}
}
e.exports = a
}, dffd: function(e, t, n) {
const {BigInteger: r, SecureRandom: i} = n("f33e")
, {ECCurveFp: o} = n("4701")
, a = new i
, {curve: s, G: u, n: l} = f();
function c() {
return s
}
function f() {
const e = new r("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF",16)
, t = new r("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC",16)
, n = new r("28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93",16)
, i = new o(e,t,n)
, a = "32C4AE2C1F1981195F9904466A39C9948FE30BBFF2660BE1715A4589334C74C7"
, s = "BC3736A2F4F6779C59BDCEE36B692153D0A9877CC62A474002DF32E52139F0A0"
, u = i.decodePointHex("04" + a + s)
, l = new r("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123",16);
return {
curve: i,
G: u,
n: l
}
}
function d() {
const e = new r(l.bitLength(),a).mod(l.subtract(r.ONE)).add(r.ONE)
, t = m(e.toString(16), 64)
, n = u.multiply(e)
, i = m(n.getX().toBigInteger().toString(16), 64)
, o = m(n.getY().toBigInteger().toString(16), 64)
, s = "04" + i + o;
return {
privateKey: t,
publicKey: s
}
}
function h(e) {
e = unescape(encodeURIComponent(e));
const t = e.length
, n = [];
for (let i = 0; i < t; i++)
n[i >>> 2] |= (255 & e.charCodeAt(i)) << 24 - i % 4 * 8;
const r = [];
for (let i = 0; i < t; i++) {
const e = n[i >>> 2] >>> 24 - i % 4 * 8 & 255;
r.push((e >>> 4).toString(16)),
r.push((15 & e).toString(16))
}
return r.join("")
}
function p(e) {
return Array.prototype.map.call(new Uint8Array(e), e=>("00" + e.toString(16)).slice(-2)).join("")
}
function m(e, t) {
return e.length >= t ? e : new Array(t - e.length + 1).join("0") + e
}
function g(e) {
const t = [];
let n = 0;
for (let i = 0; i < 2 * e.length; i += 2)
t[i >>> 3] |= parseInt(e[n], 10) << 24 - i % 8 * 4,
n++;
const r = [];
for (let i = 0; i < e.length; i++) {
const e = t[i >>> 2] >>> 24 - i % 4 * 8 & 255;
r.push((e >>> 4).toString(16)),
r.push((15 & e).toString(16))
}
return r.join("")
}
function v(e) {
const t = [];
let n = 0;
for (let i = 0; i < 2 * e.length; i += 2)
t[i >>> 3] |= parseInt(e[n], 10) << 24 - i % 8 * 4,
n++;
try {
const n = [];
for (let r = 0; r < e.length; r++) {
const e = t[r >>> 2] >>> 24 - r % 4 * 8 & 255;
n.push(String.fromCharCode(e))
}
return decodeURIComponent(escape(n.join("")))
} catch (r) {
throw new Error("Malformed UTF-8 data")
}
}
function y(e) {
const t = [];
let n = e.length;
n % 2 !== 0 && (e = m(e, n + 1)),
n = e.length;
for (let r = 0; r < n; r += 2)
t.push(parseInt(e.substr(r, 2), 16));
return t
}
e.exports = {
getGlobalCurve: c,
generateEcparam: f,
generateKeyPairHex: d,
parseUtf8StringToHex: h,
parseArrayBufferToHex: p,
leftPad: m,
arrayToHex: g,
arrayToUtf8: v,
hexToArray: y
}
}, f9dd: function(e, t, n) {
const {BigInteger: r} = n("f33e");
function i(e) {
let t = e.toString(16);
if ("-" !== t.substr(0, 1))
t.length % 2 === 1 ? t = "0" + t : t.match(/^[0-7]/) || (t = "00" + t);
else {
const n = t.substr(1);
let i = n.length;
i % 2 === 1 ? i += 1 : t.match(/^[0-7]/) || (i += 2);
let o = "";
for (let e = 0; e < i; e++)
o += "f";
const a = new r(o,16)
, s = a.xor(e).add(r.ONE);
t = s.toString(16).replace(/^-/, "")
}
return t
}
class o {
constructor() {
this.isModified = !0,
this.hTLV = null,
this.hT = "00",
this.hL = "00",
this.hV = ""
}
getLengthHexFromValue() {
const e = this.hV.length / 2;
let t = e.toString(16);
if (t.length % 2 === 1 && (t = "0" + t),
e < 128)
return t;
{
const e = t.length / 2
, n = 128 + e;
return n.toString(16) + t
}
}
getEncodedHex() {
return (null == this.hTLV || this.isModified) && (this.hV = this.getFreshValueHex(),
this.hL = this.getLengthHexFromValue(),
this.hTLV = this.hT + this.hL + this.hV,
this.isModified = !1),
this.hTLV
}
getFreshValueHex() {
return ""
}
}
class a extends o {
constructor(e) {
super(),
this.hT = "02",
e && e.bigint && (this.hTLV = null,
this.isModified = !0,
this.hV = i(e.bigint))
}
getFreshValueHex() {
return this.hV
}
}
class s extends o {
constructor(e) {
super(),
this.hT = "30",
this.asn1Array = [],
e && e.array && (this.asn1Array = e.array)
}
getFreshValueHex() {
let e = "";
for (let t = 0; t < this.asn1Array.length; t++) {
const n = this.asn1Array[t];
e += n.getEncodedHex()
}
return this.hV = e,
this.hV
}
}
function u(e, t) {
if ("8" !== e.substring(t + 2, t + 3))
return 1;
const n = parseInt(e.substring(t + 3, t + 4), 10);
return 0 === n ? -1 : n > 0 && n < 10 ? n + 1 : -2
}
function l(e, t) {
const n = u(e, t);
return n < 1 ? "" : e.substring(t + 2, t + 2 + 2 * n)
}
function c(e, t) {
const n = l(e, t);
if ("" === n)
return -1;
let i;
return i = parseInt(n.substring(0, 1), 10) < 8 ? new r(n,16) : new r(n.substring(2),16),
i.intValue()
}
function f(e, t) {
const n = u(e, t);
return n < 0 ? n : t + 2 * (n + 1)
}
function d(e, t) {
const n = f(e, t)
, r = c(e, t);
return e.substring(n, n + 2 * r)
}
function h(e, t) {
const n = f(e, t)
, r = c(e, t);
return n + 2 * r
}
function p(e, t) {
const n = []
, r = f(e, t);
n.push(r);
const i = c(e, t);
let o = r
, a = 0;
for (; ; ) {
const t = h(e, o);
if (null == t || t - r >= 2 * i)
break;
if (a >= 200)
break;
n.push(t),
o = t,
a++
}
return n
}
e.exports = {
encodeDer(e, t) {
const n = new a({
bigint: e
})
, r = new a({
bigint: t
})
, i = new s({
array: [n, r]
});
return i.getEncodedHex()
},
decodeDer(e) {
const t = p(e, 0)
, n = t[0]
, i = t[1]
, o = d(e, n)
, a = d(e, i)
, s = new r(o,16)
, u = new r(a,16);
return {
r: s,
s: u
}
}
}
}
, 4701: function(e, t, n) {
const {BigInteger: r} = n("f33e")
, i = new r("3");
class o {
constructor(e, t) {
this.x = t,
this.q = e
}
equals(e) {
return e === this || this.q.equals(e.q) && this.x.equals(e.x)
}
toBigInteger() {
return this.x
}
negate() {
return new o(this.q,this.x.negate().mod(this.q))
}
add(e) {
return new o(this.q,this.x.add(e.toBigInteger()).mod(this.q))
}
subtract(e) {
return new o(this.q,this.x.subtract(e.toBigInteger()).mod(this.q))
}
multiply(e) {
return new o(this.q,this.x.multiply(e.toBigInteger()).mod(this.q))
}
divide(e) {
return new o(this.q,this.x.multiply(e.toBigInteger().modInverse(this.q)).mod(this.q))
}
square() {
return new o(this.q,this.x.square().mod(this.q))
}
}
class a {
constructor(e, t, n, i) {
this.curve = e,
this.x = t,
this.y = n,
this.z = null == i ? r.ONE : i,
this.zinv = null
}
getX() {
return null === this.zinv && (this.zinv = this.z.modInverse(this.curve.q)),
this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))
}
getY() {
return null === this.zinv && (this.zinv = this.z.modInverse(this.curve.q)),
this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))
}
equals(e) {
if (e === this)
return !0;
if (this.isInfinity())
return e.isInfinity();
if (e.isInfinity())
return this.isInfinity();
const t = e.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(e.z)).mod(this.curve.q);
if (!t.equals(r.ZERO))
return !1;
const n = e.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(e.z)).mod(this.curve.q);
return n.equals(r.ZERO)
}
isInfinity() {
return null === this.x && null === this.y || this.z.equals(r.ZERO) && !this.y.toBigInteger().equals(r.ZERO)
}
negate() {
return new a(this.curve,this.x,this.y.negate(),this.z)
}
add(e) {
if (this.isInfinity())
return e;
if (e.isInfinity())
return this;
const t = this.x.toBigInteger()
, n = this.y.toBigInteger()
, i = this.z
, o = e.x.toBigInteger()
, s = e.y.toBigInteger()
, u = e.z
, l = this.curve.q
, c = t.multiply(u).mod(l)
, f = o.multiply(i).mod(l)
, d = c.subtract(f)
, h = n.multiply(u).mod(l)
, p = s.multiply(i).mod(l)
, m = h.subtract(p);
if (r.ZERO.equals(d))
return r.ZERO.equals(m) ? this.twice() : this.curve.infinity;
const g = c.add(f)
, v = i.multiply(u).mod(l)
, y = d.square().mod(l)
, b = d.multiply(y).mod(l)
, x = v.multiply(m.square()).subtract(g.multiply(y)).mod(l)
, w = d.multiply(x).mod(l)
, _ = m.multiply(y.multiply(c).subtract(x)).subtract(h.multiply(b)).mod(l)
, S = b.multiply(v).mod(l);
return new a(this.curve,this.curve.fromBigInteger(w),this.curve.fromBigInteger(_),S)
}
twice() {
if (this.isInfinity())
return this;
if (!this.y.toBigInteger().signum())
return this.curve.infinity;
const e = this.x.toBigInteger()
, t = this.y.toBigInteger()
, n = this.z
, r = this.curve.q
, o = this.curve.a.toBigInteger()
, s = e.square().multiply(i).add(o.multiply(n.square())).mod(r)
, u = t.shiftLeft(1).multiply(n).mod(r)
, l = t.square().mod(r)
, c = l.multiply(e).multiply(n).mod(r)
, f = u.square().mod(r)
, d = s.square().subtract(c.shiftLeft(3)).mod(r)
, h = u.multiply(d).mod(r)
, p = s.multiply(c.shiftLeft(2).subtract(d)).subtract(f.shiftLeft(1).multiply(l)).mod(r)
, m = u.multiply(f).mod(r);
return new a(this.curve,this.curve.fromBigInteger(h),this.curve.fromBigInteger(p),m)
}
multiply(e) {
if (this.isInfinity())
return this;
if (!e.signum())
return this.curve.infinity;
const t = e.multiply(i)
, n = this.negate();
let r = this;
for (let i = t.bitLength() - 2; i > 0; i--) {
r = r.twice();
const o = t.testBit(i)
, a = e.testBit(i);
o !== a && (r = r.add(o ? this : n))
}
return r
}
}
class s {
constructor(e, t, n) {
this.q = e,
this.a = this.fromBigInteger(t),
this.b = this.fromBigInteger(n),
this.infinity = new a(this,null,null)
}
equals(e) {
return e === this || this.q.equals(e.q) && this.a.equals(e.a) && this.b.equals(e.b)
}
fromBigInteger(e) {
return new o(this.q,e)
}
decodePointHex(e) {
switch (parseInt(e.substr(0, 2), 16)) {
case 0:
return this.infinity;
case 2:
case 3:
return null;
case 4:
case 6:
case 7:
const t = (e.length - 2) / 2
, n = e.substr(2, t)
, i = e.substr(t + 2, t);
return new a(this,this.fromBigInteger(new r(n,16)),this.fromBigInteger(new r(i,16)));
default:
return null
}
}
}
e.exports = {
ECPointFp: a,
ECCurveFp: s
}
}
});
function randomString(t) {
for (var e = "0123456789abcdef", n = "", i = 0; i < t; i++) {
var r = Math.floor(Math.random() * e.length);
n += e[r]
}
return n
}
var publicKey = "04efa64dd37d3968bd6cce19858c6dc4013534cea1e334ae84216a221e3ea71a48a31995d103eeabb25c496a1feb0076dcbb4390fe701e03570692fc21e2065b77"
var privateKey = "ce41af2732213745daf33cae0eeaf0affb9a3c6f19d367837ac15117b0a4b09d0f3d3163b2acef8263ea1be86cd1bc2925e9b789ed6c5ae623bab1ba2be7980d4395e2e5809658c09f845a0c42636113";
var sm4 = _i("8060").sm4;
var sm2 = _i("8060").sm2;
var sk2 = sm4.decrypt(privateKey,publicKey.substring(0,32));
function decryptMsg(key,data) {
var c = sm2.doDecrypt(key, sk2, 1);
return sm4.decrypt(data,c);
}
function encryptMsg(data) {
var r = randomString(32);
// json字符串
var t = sm4.encrypt(data,r);
var o = new Date().getTime()
,s = sm2.doEncrypt(r,publicKey,1)
,a = s + o
,l = {
data: t,
timestamp: o,
key: s,
nonce: a,
sign: sm2.doSignature(t + o + s + a, sk2, {
hash: !0,
der: !0
})
};
return l
// return JSON.stringify(l);
}