@sabaaa1/common 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/{snarkjsWorkerLauncher-CTJxY_k6.js → snarkjsWorkerLauncher-Dsmwcy9L.js} +1 -1
- package/assets/{snarkjsWorkerLogic-BTc2hrlU.js → snarkjsWorkerLogic-B9NbAQYW.js} +707 -733
- package/assets/{utxoWorkerLauncher-B6d6svhO.js → utxoWorkerLauncher-Bvb09Ewh.js} +1 -1
- package/assets/{utxoWorkerLogic-YPywVy-e.js → utxoWorkerLogic-IHmQBHcc.js} +2287 -2302
- package/assets/{zkProofWorkerLauncher-CCedBtfh.js → zkProofWorkerLauncher-CoKmCKjC.js} +1 -1
- package/assets/{zkProofWorkerLogic-B_sgmDOg.js → zkProofWorkerLogic-DB9cbXu-.js} +7 -33
- package/package.json +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLogic.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLogic.mjs +53 -40
- package/webworker/workerProxy.cjs +1 -1
- package/webworker/workerProxy.mjs +10 -36
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
|
@@ -35,43 +35,17 @@ class nc {
|
|
|
35
35
|
}
|
|
36
36
|
postMessageToMainThread(t) {
|
|
37
37
|
const n = { data: t };
|
|
38
|
-
|
|
39
|
-
this.onmessage(n);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
const e = typeof self < "u" ? self : globalThis;
|
|
43
|
-
e.postMessage && e.postMessage(t);
|
|
38
|
+
this.onmessage ? this.onmessage(n) : postMessage(t);
|
|
44
39
|
}
|
|
45
40
|
postErrorToMainThread(t) {
|
|
46
41
|
const n = { data: { error: t } };
|
|
47
|
-
|
|
48
|
-
this.onerror(n);
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const e = {
|
|
52
|
-
error: !0,
|
|
53
|
-
message: t instanceof Error ? t.message : String(t),
|
|
54
|
-
stack: t instanceof Error ? t.stack : void 0
|
|
55
|
-
}, i = typeof self < "u" ? self : globalThis;
|
|
56
|
-
i.postMessage && i.postMessage(e);
|
|
42
|
+
this.onerror ? this.onerror(n) : postMessage(t);
|
|
57
43
|
}
|
|
58
44
|
attachWorkerSideOnMessage(t) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
if (this.isSandbox) {
|
|
66
|
-
this.eventEmitter.addEventListener("worker-message", (e) => {
|
|
67
|
-
t(e.detail);
|
|
68
|
-
});
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
const n = typeof self < "u" ? self : globalThis;
|
|
72
|
-
n.addEventListener && n.addEventListener("message", (e) => {
|
|
73
|
-
const i = e?.data;
|
|
74
|
-
i && t(i);
|
|
45
|
+
this.isNode ? this.eventEmitter.on("message", (n) => {
|
|
46
|
+
t(n);
|
|
47
|
+
}) : this.isSandbox && this.eventEmitter.addEventListener("worker-message", (n) => {
|
|
48
|
+
t(n.detail);
|
|
75
49
|
});
|
|
76
50
|
}
|
|
77
51
|
}
|
|
@@ -117,7 +91,7 @@ function Le(o, t) {
|
|
|
117
91
|
if (t == 16)
|
|
118
92
|
return o.slice(0, 2) == "0x" ? BigInt(o) : BigInt("0x" + o);
|
|
119
93
|
}
|
|
120
|
-
const
|
|
94
|
+
const Tt = Le;
|
|
121
95
|
function cc(o, t) {
|
|
122
96
|
let n = BigInt(0);
|
|
123
97
|
t = BigInt(t);
|
|
@@ -129,19 +103,19 @@ function Wn(o) {
|
|
|
129
103
|
const t = o.toString(16);
|
|
130
104
|
return (t.length - 1) * 4 + ac[parseInt(t[0], 16)];
|
|
131
105
|
}
|
|
132
|
-
function
|
|
106
|
+
function Qi(o) {
|
|
133
107
|
return BigInt(o) < BigInt(0);
|
|
134
108
|
}
|
|
135
|
-
function
|
|
109
|
+
function Mi(o) {
|
|
136
110
|
return !o;
|
|
137
111
|
}
|
|
138
112
|
function ge(o, t) {
|
|
139
113
|
return BigInt(o) << BigInt(t);
|
|
140
114
|
}
|
|
141
|
-
function
|
|
115
|
+
function Qn(o, t) {
|
|
142
116
|
return BigInt(o) >> BigInt(t);
|
|
143
117
|
}
|
|
144
|
-
const sc = ge, lc =
|
|
118
|
+
const sc = ge, lc = Qn;
|
|
145
119
|
function _o(o) {
|
|
146
120
|
return (BigInt(o) & BigInt(1)) == BigInt(1);
|
|
147
121
|
}
|
|
@@ -165,7 +139,7 @@ function Ui(o) {
|
|
|
165
139
|
t & BigInt(1) ? n.push(1) : n.push(0), t = t >> BigInt(1);
|
|
166
140
|
return n;
|
|
167
141
|
}
|
|
168
|
-
function
|
|
142
|
+
function zi(o) {
|
|
169
143
|
if (o > BigInt(Number.MAX_SAFE_INTEGER))
|
|
170
144
|
throw new Error("Number too big");
|
|
171
145
|
return Number(o);
|
|
@@ -183,7 +157,7 @@ function go(o, t) {
|
|
|
183
157
|
function _n(o, t) {
|
|
184
158
|
return BigInt(o) - BigInt(t);
|
|
185
159
|
}
|
|
186
|
-
function
|
|
160
|
+
function Ti(o) {
|
|
187
161
|
return -BigInt(o);
|
|
188
162
|
}
|
|
189
163
|
function Ri(o, t) {
|
|
@@ -201,7 +175,7 @@ function _c(o, t) {
|
|
|
201
175
|
function gc(o) {
|
|
202
176
|
return BigInt(o) >= 0 ? BigInt(o) : -BigInt(o);
|
|
203
177
|
}
|
|
204
|
-
function
|
|
178
|
+
function Mn(o, t) {
|
|
205
179
|
return BigInt(o) / BigInt(t);
|
|
206
180
|
}
|
|
207
181
|
function an(o, t) {
|
|
@@ -250,7 +224,7 @@ function Yn(o, t, n, e) {
|
|
|
250
224
|
for (let r = d; r < s.length; r++)
|
|
251
225
|
s[r] = 0;
|
|
252
226
|
for (let r = s.length * 4; r < e; r++)
|
|
253
|
-
o[r] =
|
|
227
|
+
o[r] = zi(fo(Qn(n, r * 8), 255));
|
|
254
228
|
}
|
|
255
229
|
function ki(o, t, n, e) {
|
|
256
230
|
const i = "0000000" + n.toString(16), s = new DataView(o.buffer, o.byteOffset + t, e), d = ((i.length - 7) * 4 - 1 >> 5) + 1;
|
|
@@ -278,7 +252,7 @@ function Un(o) {
|
|
|
278
252
|
const t = new Uint8Array(Math.floor((Wn(o) - 1) / 8) + 1);
|
|
279
253
|
return Yn(t, 0, o, t.byteLength), t;
|
|
280
254
|
}
|
|
281
|
-
const Ki =
|
|
255
|
+
const Ki = Tt(0), Fn = Tt(1);
|
|
282
256
|
var Cc = /* @__PURE__ */ Object.freeze({
|
|
283
257
|
__proto__: null,
|
|
284
258
|
abs: gc,
|
|
@@ -288,8 +262,8 @@ var Cc = /* @__PURE__ */ Object.freeze({
|
|
|
288
262
|
bits: Ui,
|
|
289
263
|
bor: Lc,
|
|
290
264
|
bxor: Ac,
|
|
291
|
-
div:
|
|
292
|
-
e:
|
|
265
|
+
div: Mn,
|
|
266
|
+
e: Tt,
|
|
293
267
|
eq: En,
|
|
294
268
|
exp: _c,
|
|
295
269
|
fromArray: cc,
|
|
@@ -298,9 +272,9 @@ var Cc = /* @__PURE__ */ Object.freeze({
|
|
|
298
272
|
fromString: Le,
|
|
299
273
|
geq: Di,
|
|
300
274
|
gt: He,
|
|
301
|
-
isNegative:
|
|
275
|
+
isNegative: Qi,
|
|
302
276
|
isOdd: _o,
|
|
303
|
-
isZero:
|
|
277
|
+
isZero: Mi,
|
|
304
278
|
land: bc,
|
|
305
279
|
leq: pc,
|
|
306
280
|
lnot: Ic,
|
|
@@ -309,26 +283,26 @@ var Cc = /* @__PURE__ */ Object.freeze({
|
|
|
309
283
|
mod: an,
|
|
310
284
|
mul: Ri,
|
|
311
285
|
naf: rc,
|
|
312
|
-
neg:
|
|
286
|
+
neg: Ti,
|
|
313
287
|
neq: fc,
|
|
314
288
|
one: Fn,
|
|
315
289
|
pow: Xn,
|
|
316
290
|
shiftLeft: ge,
|
|
317
|
-
shiftRight:
|
|
291
|
+
shiftRight: Qn,
|
|
318
292
|
shl: sc,
|
|
319
293
|
shr: lc,
|
|
320
294
|
square: uc,
|
|
321
295
|
sub: _n,
|
|
322
296
|
toArray: dc,
|
|
323
297
|
toLEBuff: Un,
|
|
324
|
-
toNumber:
|
|
298
|
+
toNumber: zi,
|
|
325
299
|
toRprBE: ki,
|
|
326
300
|
toRprLE: Yn,
|
|
327
301
|
toString: Gi,
|
|
328
302
|
zero: Ki
|
|
329
303
|
});
|
|
330
304
|
function vo(o, t, n) {
|
|
331
|
-
if (
|
|
305
|
+
if (Mi(n))
|
|
332
306
|
return o.one;
|
|
333
307
|
const e = Ui(n);
|
|
334
308
|
if (e.length == 0)
|
|
@@ -361,13 +335,13 @@ function mc(o) {
|
|
|
361
335
|
}
|
|
362
336
|
function wc(o) {
|
|
363
337
|
for (o.sqrt_q = Xn(o.p, o.m), o.sqrt_s = 0, o.sqrt_t = _n(o.sqrt_q, 1); !_o(o.sqrt_t); )
|
|
364
|
-
o.sqrt_s = o.sqrt_s + 1, o.sqrt_t =
|
|
338
|
+
o.sqrt_s = o.sqrt_s + 1, o.sqrt_t = Mn(o.sqrt_t, 2);
|
|
365
339
|
let t = o.one;
|
|
366
340
|
for (; o.eq(t, o.one); ) {
|
|
367
341
|
const n = o.random();
|
|
368
342
|
o.sqrt_z = o.pow(n, o.sqrt_t), t = o.pow(o.sqrt_z, 2 ** (o.sqrt_s - 1));
|
|
369
343
|
}
|
|
370
|
-
o.sqrt_tm1d2 =
|
|
344
|
+
o.sqrt_tm1d2 = Mn(_n(o.sqrt_t, 1), 2), o.sqrt = function(n) {
|
|
371
345
|
const e = this;
|
|
372
346
|
if (e.isZero(n))
|
|
373
347
|
return e.zero;
|
|
@@ -399,7 +373,7 @@ function Ec(o) {
|
|
|
399
373
|
};
|
|
400
374
|
}
|
|
401
375
|
function Fc(o) {
|
|
402
|
-
o.sqrt_q = Xn(o.p, o.m), o.sqrt_e1 =
|
|
376
|
+
o.sqrt_q = Xn(o.p, o.m), o.sqrt_e1 = Mn(_n(o.sqrt_q, 3), 4), o.sqrt = function(t) {
|
|
403
377
|
if (this.isZero(t))
|
|
404
378
|
return this.zero;
|
|
405
379
|
const n = this.pow(t, this.sqrt_e1), e = this.mul(this.square(n), t);
|
|
@@ -415,7 +389,7 @@ function xc(o) {
|
|
|
415
389
|
};
|
|
416
390
|
}
|
|
417
391
|
function Sc(o) {
|
|
418
|
-
o.sqrt_q = Xn(o.p, o.m / 2), o.sqrt_e34 =
|
|
392
|
+
o.sqrt_q = Xn(o.p, o.m / 2), o.sqrt_e34 = Mn(_n(o.sqrt_q, 3), 4), o.sqrt_e12 = Mn(_n(o.sqrt_q, 1), 2), o.frobenius = function(t, n) {
|
|
419
393
|
return t % 2 == 1 ? o.conjugate(n) : n;
|
|
420
394
|
}, o.sqrt = function(t) {
|
|
421
395
|
const n = this, e = n.pow(t, n.sqrt_e34), i = n.mul(n.square(e), t), s = n.mul(n.frobenius(1, i), i);
|
|
@@ -502,7 +476,7 @@ let se = null;
|
|
|
502
476
|
function ho() {
|
|
503
477
|
return se || (se = new Pc(qc()), se);
|
|
504
478
|
}
|
|
505
|
-
class
|
|
479
|
+
class Qc {
|
|
506
480
|
constructor(t, n, e) {
|
|
507
481
|
this.F = n, this.G = t, this.opMulGF = e;
|
|
508
482
|
let i = n.sqrt_t || n.t, s = n.sqrt_s || n.s, d = n.one;
|
|
@@ -564,7 +538,7 @@ function fe(o, t, n, e, i) {
|
|
|
564
538
|
u[l] = o.G.add(r[l], o.opMulGF(b[l], o.roots[n][l])), u[l + d] = o.G.sub(r[l], o.opMulGF(b[l], o.roots[n][l]));
|
|
565
539
|
return u;
|
|
566
540
|
}
|
|
567
|
-
class
|
|
541
|
+
class Mc {
|
|
568
542
|
constructor(t) {
|
|
569
543
|
this.type = "F1", this.one = BigInt(1), this.zero = BigInt(0), this.p = BigInt(t), this.m = 1, this.negone = this.p - this.one, this.two = BigInt(2), this.half = this.p >> this.one, this.bitLength = Wn(this.p), this.mask = (this.one << BigInt(this.bitLength)) - this.one, this.n64 = Math.floor((this.bitLength - 1) / 64) + 1, this.n32 = this.n64 * 2, this.n8 = this.n64 * 8, this.R = this.e(this.one << BigInt(this.n64 * 64)), this.Ri = this.inv(this.R);
|
|
570
544
|
const n = this.negone >> this.one;
|
|
@@ -574,7 +548,7 @@ class Qc {
|
|
|
574
548
|
this.nqr = this.nqr + this.one, e = this.pow(this.nqr, n);
|
|
575
549
|
for (this.s = 0, this.t = this.negone; (this.t & this.one) == this.zero; )
|
|
576
550
|
this.s = this.s + 1, this.t = this.t >> this.one;
|
|
577
|
-
this.nqr_to_t = this.pow(this.nqr, this.t), mc(this), this.FFT = new
|
|
551
|
+
this.nqr_to_t = this.pow(this.nqr, this.t), mc(this), this.FFT = new Qc(this, this, this.mul.bind(this)), this.fft = this.FFT.fft.bind(this.FFT), this.ifft = this.FFT.ifft.bind(this.FFT), this.w = this.FFT.w, this.wi = this.FFT.wi, this.shift = this.square(this.nqr), this.k = this.exp(this.nqr, 2 ** this.s);
|
|
578
552
|
}
|
|
579
553
|
e(t, n) {
|
|
580
554
|
let e;
|
|
@@ -996,7 +970,7 @@ var Uc = function(t, n, e) {
|
|
|
996
970
|
let D, it;
|
|
997
971
|
return L[y] ? D = f.getLocal("x" + y) : (D = f.teeLocal("x" + y, f.i64_load32_u(f.getLocal("x"), y * 4)), L[y] = !0), V[v] ? it = f.getLocal("y" + v) : (it = f.teeLocal("y" + v, f.i64_load32_u(f.getLocal("y"), v * 4)), V[v] = !0), f.i64_mul(D, it);
|
|
998
972
|
}
|
|
999
|
-
let X = "c0",
|
|
973
|
+
let X = "c0", Q = "c1";
|
|
1000
974
|
for (let y = 0; y < s * 2 - 1; y++) {
|
|
1001
975
|
for (let v = Math.max(0, y - s + 1); v <= y && v < s; v++) {
|
|
1002
976
|
const D = y - v;
|
|
@@ -1013,9 +987,9 @@ var Uc = function(t, n, e) {
|
|
|
1013
987
|
)
|
|
1014
988
|
), F.addCode(
|
|
1015
989
|
f.setLocal(
|
|
1016
|
-
|
|
990
|
+
Q,
|
|
1017
991
|
f.i64_add(
|
|
1018
|
-
f.getLocal(
|
|
992
|
+
f.getLocal(Q),
|
|
1019
993
|
f.i64_shr_u(
|
|
1020
994
|
f.getLocal(X),
|
|
1021
995
|
f.i64_const(32)
|
|
@@ -1030,9 +1004,9 @@ var Uc = function(t, n, e) {
|
|
|
1030
1004
|
y * 4,
|
|
1031
1005
|
f.getLocal(X)
|
|
1032
1006
|
)
|
|
1033
|
-
), [X,
|
|
1007
|
+
), [X, Q] = [Q, X], F.addCode(
|
|
1034
1008
|
f.setLocal(
|
|
1035
|
-
|
|
1009
|
+
Q,
|
|
1036
1010
|
f.i64_shr_u(
|
|
1037
1011
|
f.getLocal(X),
|
|
1038
1012
|
f.i64_const(32)
|
|
@@ -1058,7 +1032,7 @@ var Uc = function(t, n, e) {
|
|
|
1058
1032
|
let it, nt;
|
|
1059
1033
|
return L[v] ? it = f.getLocal("x" + v) : (it = f.teeLocal("x" + v, f.i64_load32_u(f.getLocal("x"), v * 4)), L[v] = !0), L[D] ? nt = f.getLocal("x" + D) : (nt = f.teeLocal("x" + D, f.i64_load32_u(f.getLocal("x"), D * 4)), L[D] = !0), f.i64_mul(it, nt);
|
|
1060
1034
|
}
|
|
1061
|
-
let $ = "c0", X = "c1",
|
|
1035
|
+
let $ = "c0", X = "c1", Q = "c0_old", y = "c1_old";
|
|
1062
1036
|
for (let v = 0; v < s * 2 - 1; v++) {
|
|
1063
1037
|
F.addCode(
|
|
1064
1038
|
f.setLocal($, f.i64_const(0)),
|
|
@@ -1146,7 +1120,7 @@ var Uc = function(t, n, e) {
|
|
|
1146
1120
|
f.i64_const(4294967295)
|
|
1147
1121
|
),
|
|
1148
1122
|
f.i64_and(
|
|
1149
|
-
f.getLocal(
|
|
1123
|
+
f.getLocal(Q),
|
|
1150
1124
|
f.i64_const(4294967295)
|
|
1151
1125
|
)
|
|
1152
1126
|
)
|
|
@@ -1173,13 +1147,13 @@ var Uc = function(t, n, e) {
|
|
|
1173
1147
|
)
|
|
1174
1148
|
), F.addCode(
|
|
1175
1149
|
f.setLocal(
|
|
1176
|
-
|
|
1150
|
+
Q,
|
|
1177
1151
|
f.getLocal(X)
|
|
1178
1152
|
),
|
|
1179
1153
|
f.setLocal(
|
|
1180
1154
|
y,
|
|
1181
1155
|
f.i64_shr_u(
|
|
1182
|
-
f.getLocal(
|
|
1156
|
+
f.getLocal(Q),
|
|
1183
1157
|
f.i64_const(32)
|
|
1184
1158
|
)
|
|
1185
1159
|
)
|
|
@@ -1189,11 +1163,11 @@ var Uc = function(t, n, e) {
|
|
|
1189
1163
|
f.i64_store32(
|
|
1190
1164
|
f.getLocal("r"),
|
|
1191
1165
|
s * 4 * 2 - 4,
|
|
1192
|
-
f.getLocal(
|
|
1166
|
+
f.getLocal(Q)
|
|
1193
1167
|
)
|
|
1194
1168
|
);
|
|
1195
1169
|
}
|
|
1196
|
-
function
|
|
1170
|
+
function z() {
|
|
1197
1171
|
const F = t.addFunction(i + "_squareOld");
|
|
1198
1172
|
F.addParam("x", "i32"), F.addParam("r", "i32");
|
|
1199
1173
|
const f = F.getCodeBuilder();
|
|
@@ -1288,11 +1262,11 @@ var Uc = function(t, n, e) {
|
|
|
1288
1262
|
f.br(0)
|
|
1289
1263
|
)));
|
|
1290
1264
|
}
|
|
1291
|
-
function
|
|
1265
|
+
function T() {
|
|
1292
1266
|
x(), ot();
|
|
1293
1267
|
const F = t.addFunction(i + "_div");
|
|
1294
1268
|
F.addParam("x", "i32"), F.addParam("y", "i32"), F.addParam("c", "i32"), F.addParam("r", "i32"), F.addLocal("rr", "i32"), F.addLocal("cc", "i32"), F.addLocal("eX", "i32"), F.addLocal("eY", "i32"), F.addLocal("sy", "i64"), F.addLocal("sx", "i64"), F.addLocal("ec", "i32");
|
|
1295
|
-
const f = F.getCodeBuilder(), L = f.i32_const(t.alloc(d)), V = f.i32_const(t.alloc(d)), $ = f.i32_const(t.alloc(d)), X = f.getLocal("cc"),
|
|
1269
|
+
const f = F.getCodeBuilder(), L = f.i32_const(t.alloc(d)), V = f.i32_const(t.alloc(d)), $ = f.i32_const(t.alloc(d)), X = f.getLocal("cc"), Q = f.getLocal("rr"), y = t.alloc(d * 2), v = f.i32_const(y), D = f.i32_const(y + d);
|
|
1296
1270
|
F.addCode(f.if(
|
|
1297
1271
|
f.getLocal("c"),
|
|
1298
1272
|
f.setLocal("cc", f.getLocal("c")),
|
|
@@ -1301,7 +1275,7 @@ var Uc = function(t, n, e) {
|
|
|
1301
1275
|
f.getLocal("r"),
|
|
1302
1276
|
f.setLocal("rr", f.getLocal("r")),
|
|
1303
1277
|
f.setLocal("rr", $)
|
|
1304
|
-
)), F.addCode(f.call(i + "_copy", f.getLocal("x"),
|
|
1278
|
+
)), F.addCode(f.call(i + "_copy", f.getLocal("x"), Q)), F.addCode(f.call(i + "_copy", f.getLocal("y"), L)), F.addCode(f.call(i + "_zero", X)), F.addCode(f.call(i + "_zero", v)), F.addCode(f.setLocal("eX", f.i32_const(d - 1))), F.addCode(f.setLocal("eY", f.i32_const(d - 1))), F.addCode(f.block(f.loop(
|
|
1305
1279
|
f.br_if(
|
|
1306
1280
|
1,
|
|
1307
1281
|
f.i32_or(
|
|
@@ -1348,7 +1322,7 @@ var Uc = function(t, n, e) {
|
|
|
1348
1322
|
1,
|
|
1349
1323
|
f.i32_or(
|
|
1350
1324
|
f.i32_load8_u(
|
|
1351
|
-
f.i32_add(
|
|
1325
|
+
f.i32_add(Q, f.getLocal("eX")),
|
|
1352
1326
|
0,
|
|
1353
1327
|
0
|
|
1354
1328
|
),
|
|
@@ -1365,7 +1339,7 @@ var Uc = function(t, n, e) {
|
|
|
1365
1339
|
"sx",
|
|
1366
1340
|
f.i64_load(
|
|
1367
1341
|
f.i32_sub(
|
|
1368
|
-
f.i32_add(
|
|
1342
|
+
f.i32_add(Q, f.getLocal("eX")),
|
|
1369
1343
|
f.i32_const(7)
|
|
1370
1344
|
),
|
|
1371
1345
|
0,
|
|
@@ -1427,7 +1401,7 @@ var Uc = function(t, n, e) {
|
|
|
1427
1401
|
[
|
|
1428
1402
|
...f.br_if(
|
|
1429
1403
|
2,
|
|
1430
|
-
f.i32_eqz(f.call(i + "_gte",
|
|
1404
|
+
f.i32_eqz(f.call(i + "_gte", Q, L))
|
|
1431
1405
|
),
|
|
1432
1406
|
...f.setLocal("sx", f.i64_const(1)),
|
|
1433
1407
|
...f.setLocal("ec", f.i32_const(0))
|
|
@@ -1436,9 +1410,9 @@ var Uc = function(t, n, e) {
|
|
|
1436
1410
|
f.call(i + "__mul1", L, f.getLocal("sx"), D),
|
|
1437
1411
|
f.drop(f.call(
|
|
1438
1412
|
i + "_sub",
|
|
1439
|
-
|
|
1413
|
+
Q,
|
|
1440
1414
|
f.i32_sub(D, f.getLocal("ec")),
|
|
1441
|
-
|
|
1415
|
+
Q
|
|
1442
1416
|
)),
|
|
1443
1417
|
f.call(
|
|
1444
1418
|
i + "__add1",
|
|
@@ -1451,7 +1425,7 @@ var Uc = function(t, n, e) {
|
|
|
1451
1425
|
function rt() {
|
|
1452
1426
|
const F = t.addFunction(i + "_inverseMod");
|
|
1453
1427
|
F.addParam("px", "i32"), F.addParam("pm", "i32"), F.addParam("pr", "i32"), F.addLocal("t", "i32"), F.addLocal("newt", "i32"), F.addLocal("r", "i32"), F.addLocal("qq", "i32"), F.addLocal("qr", "i32"), F.addLocal("newr", "i32"), F.addLocal("swp", "i32"), F.addLocal("x", "i32"), F.addLocal("signt", "i32"), F.addLocal("signnewt", "i32"), F.addLocal("signx", "i32");
|
|
1454
|
-
const f = F.getCodeBuilder(), L = f.i32_const(t.alloc(d)), V = f.i32_const(t.alloc(d)), $ = f.i32_const(t.alloc(d)), X = f.i32_const(t.alloc(d)),
|
|
1428
|
+
const f = F.getCodeBuilder(), L = f.i32_const(t.alloc(d)), V = f.i32_const(t.alloc(d)), $ = f.i32_const(t.alloc(d)), X = f.i32_const(t.alloc(d)), Q = f.i32_const(t.alloc(d)), y = f.i32_const(t.alloc(d)), v = f.i32_const(t.alloc(d * 2)), D = f.i32_const(t.alloc(d));
|
|
1455
1429
|
F.addCode(
|
|
1456
1430
|
f.setLocal("t", L),
|
|
1457
1431
|
f.call(i + "_zero", L),
|
|
@@ -1466,7 +1440,7 @@ var Uc = function(t, n, e) {
|
|
|
1466
1440
|
), F.addCode(
|
|
1467
1441
|
f.setLocal("newr", X),
|
|
1468
1442
|
f.call(i + "_copy", f.getLocal("px"), X)
|
|
1469
|
-
), F.addCode(f.setLocal("qq",
|
|
1443
|
+
), F.addCode(f.setLocal("qq", Q)), F.addCode(f.setLocal("qr", y)), F.addCode(f.setLocal("x", D)), F.addCode(f.block(f.loop(
|
|
1470
1444
|
f.br_if(
|
|
1471
1445
|
1,
|
|
1472
1446
|
f.call(i + "_isZero", f.getLocal("newr"))
|
|
@@ -1529,7 +1503,7 @@ var Uc = function(t, n, e) {
|
|
|
1529
1503
|
f.call(i + "_copy", f.getLocal("t"), f.getLocal("pr"))
|
|
1530
1504
|
));
|
|
1531
1505
|
}
|
|
1532
|
-
return r(), b(), l(), u(), C(), B(), A(), O(), P(), E(),
|
|
1506
|
+
return r(), b(), l(), u(), C(), B(), A(), O(), P(), E(), z(), T(), rt(), t.exportFunction(i + "_copy"), t.exportFunction(i + "_zero"), t.exportFunction(i + "_one"), t.exportFunction(i + "_isZero"), t.exportFunction(i + "_eq"), t.exportFunction(i + "_gte"), t.exportFunction(i + "_add"), t.exportFunction(i + "_sub"), t.exportFunction(i + "_mul"), t.exportFunction(i + "_square"), t.exportFunction(i + "_squareOld"), t.exportFunction(i + "_div"), t.exportFunction(i + "_inverseMod"), i;
|
|
1533
1507
|
}, po = function(t, n, e, i, s, d, r) {
|
|
1534
1508
|
const b = t.addFunction(n);
|
|
1535
1509
|
b.addParam("base", "i32"), b.addParam("scalar", "i32"), b.addParam("scalarLength", "i32"), b.addParam("r", "i32"), b.addLocal("i", "i32"), b.addLocal("b", "i32");
|
|
@@ -1578,8 +1552,8 @@ var Uc = function(t, n, e) {
|
|
|
1578
1552
|
);
|
|
1579
1553
|
return B;
|
|
1580
1554
|
}
|
|
1581
|
-
}, Lo =
|
|
1582
|
-
function
|
|
1555
|
+
}, Lo = zc;
|
|
1556
|
+
function zc(o, t) {
|
|
1583
1557
|
const n = o.modules[t].n64 * 8, e = o.addFunction(t + "_batchInverse");
|
|
1584
1558
|
e.addParam("pIn", "i32"), e.addParam("inStep", "i32"), e.addParam("n", "i32"), e.addParam("pOut", "i32"), e.addParam("outStep", "i32"), e.addLocal("itAux", "i32"), e.addLocal("itIn", "i32"), e.addLocal("itOut", "i32"), e.addLocal("i", "i32");
|
|
1585
1559
|
const i = e.getCodeBuilder(), s = i.i32_const(o.alloc(n));
|
|
@@ -1686,8 +1660,8 @@ function Tc(o, t) {
|
|
|
1686
1660
|
)
|
|
1687
1661
|
);
|
|
1688
1662
|
}
|
|
1689
|
-
var Vi =
|
|
1690
|
-
function
|
|
1663
|
+
var Vi = Tc;
|
|
1664
|
+
function Tc(o, t, n, e, i, s) {
|
|
1691
1665
|
typeof s > "u" && (e < i ? s = !0 : s = !1);
|
|
1692
1666
|
const d = o.addFunction(t);
|
|
1693
1667
|
d.addParam("pIn", "i32"), d.addParam("n", "i32"), d.addParam("pOut", "i32"), d.addLocal("i", "i32"), d.addLocal("itIn", "i32"), d.addLocal("itOut", "i32");
|
|
@@ -1839,13 +1813,13 @@ function Yi(o) {
|
|
|
1839
1813
|
function te(o) {
|
|
1840
1814
|
return o < 0n ? -o : o;
|
|
1841
1815
|
}
|
|
1842
|
-
function
|
|
1816
|
+
function zn(o) {
|
|
1843
1817
|
return te(o) === 1n;
|
|
1844
1818
|
}
|
|
1845
1819
|
function Zi(o, t) {
|
|
1846
1820
|
for (var n = 0n, e = 1n, i = t, s = te(o), d, r, b; s !== 0n; )
|
|
1847
1821
|
d = i / s, r = n, b = i, n = e, i = s, e = r - d * e, s = b - d * s;
|
|
1848
|
-
if (!
|
|
1822
|
+
if (!zn(i))
|
|
1849
1823
|
throw new Error(o.toString() + " and " + t.toString() + " are not co-prime");
|
|
1850
1824
|
return ji(n, 0n) === -1 && (n = n + t), Ae(o) ? -n : n;
|
|
1851
1825
|
}
|
|
@@ -1864,11 +1838,11 @@ function Nc(o, t) {
|
|
|
1864
1838
|
return o = o >= 0n ? o : -o, t = t >= 0n ? t : -t, o === t ? 0 : o > t ? 1 : -1;
|
|
1865
1839
|
}
|
|
1866
1840
|
function qo(o, t) {
|
|
1867
|
-
return t === 0n ? !1 :
|
|
1841
|
+
return t === 0n ? !1 : zn(t) ? !0 : Nc(t, 2n) === 0 ? bo(o) : o % t === 0n;
|
|
1868
1842
|
}
|
|
1869
1843
|
function Gc(o) {
|
|
1870
1844
|
var t = te(o);
|
|
1871
|
-
if (
|
|
1845
|
+
if (zn(t))
|
|
1872
1846
|
return !1;
|
|
1873
1847
|
if (t === 2n || t === 3n || t === 5n)
|
|
1874
1848
|
return !0;
|
|
@@ -1880,14 +1854,14 @@ function Gc(o) {
|
|
|
1880
1854
|
function Kc(o) {
|
|
1881
1855
|
return o - 1n;
|
|
1882
1856
|
}
|
|
1883
|
-
function
|
|
1857
|
+
function Qo(o, t) {
|
|
1884
1858
|
for (var n = Kc(o), e = n, i = 0, s, d, r; bo(e); )
|
|
1885
1859
|
e = e / 2n, i++;
|
|
1886
1860
|
t:
|
|
1887
1861
|
for (d = 0; d < t.length; d++)
|
|
1888
|
-
if (!(o < t[d]) && (r = Ji(BigInt(t[d]), e, o), !(
|
|
1862
|
+
if (!(o < t[d]) && (r = Ji(BigInt(t[d]), e, o), !(zn(r) || r === n))) {
|
|
1889
1863
|
for (s = i - 1; s != 0; s--) {
|
|
1890
|
-
if (r = Ao(r) % o,
|
|
1864
|
+
if (r = Ao(r) % o, zn(r))
|
|
1891
1865
|
return !1;
|
|
1892
1866
|
if (r === n)
|
|
1893
1867
|
continue t;
|
|
@@ -1902,27 +1876,27 @@ function Hc(o) {
|
|
|
1902
1876
|
return t;
|
|
1903
1877
|
var n = te(o), e = Yi(n);
|
|
1904
1878
|
if (e <= 64)
|
|
1905
|
-
return
|
|
1879
|
+
return Qo(n, [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]);
|
|
1906
1880
|
for (var i = Math.log(2) * Number(e), s = Math.ceil(i), d = [], r = 0; r < s; r++)
|
|
1907
1881
|
d.push(BigInt(r + 2));
|
|
1908
|
-
return
|
|
1882
|
+
return Qo(n, d);
|
|
1909
1883
|
}
|
|
1910
1884
|
Yt.bitLength = Yi;
|
|
1911
1885
|
Yt.isOdd = $i;
|
|
1912
1886
|
Yt.isNegative = Ae;
|
|
1913
1887
|
Yt.abs = te;
|
|
1914
|
-
Yt.isUnit =
|
|
1888
|
+
Yt.isUnit = zn;
|
|
1915
1889
|
Yt.compare = ji;
|
|
1916
1890
|
Yt.modInv = Zi;
|
|
1917
1891
|
Yt.modPow = Ji;
|
|
1918
1892
|
Yt.isPrime = Hc;
|
|
1919
1893
|
Yt.square = Ao;
|
|
1920
|
-
const Vc = Uc, rn = mn, jc = po, $c = Lo, xe = Vi, Se = Rc, { bitLength: Yc, modInv: Oe, modPow:
|
|
1894
|
+
const Vc = Uc, rn = mn, jc = po, $c = Lo, xe = Vi, Se = Rc, { bitLength: Yc, modInv: Oe, modPow: Mo, isPrime: Uo, isOdd: Zc, square: Jc } = Yt;
|
|
1921
1895
|
var yo = function(t, n, e, i) {
|
|
1922
1896
|
const s = BigInt(n), d = Math.floor((Yc(s - 1n) - 1) / 64) + 1, r = d * 2, b = d * 8, u = e || "f1m";
|
|
1923
1897
|
if (t.modules[u])
|
|
1924
1898
|
return u;
|
|
1925
|
-
const l = Vc(t, d, i), C = t.alloc(b, rn.bigInt2BytesLE(s, b)), B = t.alloc(rn.bigInt2BytesLE(Jc(1n << BigInt(d * 64)) % s, b)), A = t.alloc(rn.bigInt2BytesLE((1n << BigInt(d * 64)) % s, b)), O = t.alloc(rn.bigInt2BytesLE(0n, b)), P = s - 1n, E = P >> 1n,
|
|
1899
|
+
const l = Vc(t, d, i), C = t.alloc(b, rn.bigInt2BytesLE(s, b)), B = t.alloc(rn.bigInt2BytesLE(Jc(1n << BigInt(d * 64)) % s, b)), A = t.alloc(rn.bigInt2BytesLE((1n << BigInt(d * 64)) % s, b)), O = t.alloc(rn.bigInt2BytesLE(0n, b)), P = s - 1n, E = P >> 1n, z = t.alloc(b, rn.bigInt2BytesLE(E, b)), x = E + 1n, ot = t.alloc(b, rn.bigInt2BytesLE(x, b));
|
|
1926
1900
|
t.modules[u] = {
|
|
1927
1901
|
pq: C,
|
|
1928
1902
|
pR2: B,
|
|
@@ -1932,7 +1906,7 @@ var yo = function(t, n, e, i) {
|
|
|
1932
1906
|
pZero: O,
|
|
1933
1907
|
pePlusOne: ot
|
|
1934
1908
|
};
|
|
1935
|
-
function
|
|
1909
|
+
function T() {
|
|
1936
1910
|
const I = t.addFunction(u + "_one");
|
|
1937
1911
|
I.addParam("pr", "i32");
|
|
1938
1912
|
const h = I.getCodeBuilder();
|
|
@@ -2197,7 +2171,7 @@ var yo = function(t, n, e, i) {
|
|
|
2197
2171
|
)
|
|
2198
2172
|
);
|
|
2199
2173
|
}
|
|
2200
|
-
function
|
|
2174
|
+
function Q() {
|
|
2201
2175
|
const I = t.addFunction(u + "_square");
|
|
2202
2176
|
I.addParam("x", "i32"), I.addParam("r", "i32"), I.addLocal("c0", "i64"), I.addLocal("c1", "i64"), I.addLocal("c0_old", "i64"), I.addLocal("c1_old", "i64"), I.addLocal("np32", "i64");
|
|
2203
2177
|
for (let dt = 0; dt < r; dt++)
|
|
@@ -2446,12 +2420,12 @@ var yo = function(t, n, e, i) {
|
|
|
2446
2420
|
}
|
|
2447
2421
|
let nt = 2n;
|
|
2448
2422
|
if (Uo(s))
|
|
2449
|
-
for (;
|
|
2423
|
+
for (; Mo(nt, E, s) !== P; )
|
|
2450
2424
|
nt = nt + 1n;
|
|
2451
2425
|
let K = 0, ct = P;
|
|
2452
2426
|
for (; !Zc(ct) && ct !== 0n; )
|
|
2453
2427
|
K++, ct = ct >> 1n;
|
|
2454
|
-
const J = t.alloc(b, rn.bigInt2BytesLE(ct, b)), st =
|
|
2428
|
+
const J = t.alloc(b, rn.bigInt2BytesLE(ct, b)), st = Mo(nt, ct, s), At = t.alloc(rn.bigInt2BytesLE((st << BigInt(d * 64)) % s, b)), Bt = ct + 1n >> 1n, pt = t.alloc(b, rn.bigInt2BytesLE(Bt, b));
|
|
2455
2429
|
function p() {
|
|
2456
2430
|
const I = t.addFunction(u + "_sqrt");
|
|
2457
2431
|
I.addParam("n", "i32"), I.addParam("r", "i32"), I.addLocal("m", "i32"), I.addLocal("i", "i32"), I.addLocal("j", "i32");
|
|
@@ -2508,7 +2482,7 @@ var yo = function(t, n, e, i) {
|
|
|
2508
2482
|
h.call(u + "_isZero", h.getLocal("n")),
|
|
2509
2483
|
h.ret(h.i32_const(1))
|
|
2510
2484
|
),
|
|
2511
|
-
h.call(u + "_exp", h.getLocal("n"), h.i32_const(
|
|
2485
|
+
h.call(u + "_exp", h.getLocal("n"), h.i32_const(z), h.i32_const(b), W),
|
|
2512
2486
|
h.call(u + "_eq", W, S)
|
|
2513
2487
|
);
|
|
2514
2488
|
}
|
|
@@ -2575,7 +2549,7 @@ var yo = function(t, n, e, i) {
|
|
|
2575
2549
|
h.ret(h.call(l + "_eq", h.getLocal("x"), h.i32_const(A)))
|
|
2576
2550
|
);
|
|
2577
2551
|
}
|
|
2578
|
-
return t.exportFunction(l + "_copy", u + "_copy"), t.exportFunction(l + "_zero", u + "_zero"), t.exportFunction(l + "_isZero", u + "_isZero"), t.exportFunction(l + "_eq", u + "_eq"), w(), rt(), F(), f(), $(), X(),
|
|
2552
|
+
return t.exportFunction(l + "_copy", u + "_copy"), t.exportFunction(l + "_zero", u + "_zero"), t.exportFunction(l + "_isZero", u + "_isZero"), t.exportFunction(l + "_eq", u + "_eq"), w(), rt(), F(), f(), $(), X(), Q(), y(), v(), D(), L(), V(), it(), T(), m(), c(), $c(t, u), xe(t, u + "_batchToMontgomery", u + "_toMontgomery", b, b), xe(t, u + "_batchFromMontgomery", u + "_fromMontgomery", b, b), xe(t, u + "_batchNeg", u + "_neg", b, b), Se(t, u + "_batchAdd", u + "_add", b, b), Se(t, u + "_batchSub", u + "_sub", b, b), Se(t, u + "_batchMul", u + "_mul", b, b), t.exportFunction(u + "_add"), t.exportFunction(u + "_sub"), t.exportFunction(u + "_neg"), t.exportFunction(u + "_isNegative"), t.exportFunction(u + "_isOne"), t.exportFunction(u + "_sign"), t.exportFunction(u + "_mReduct"), t.exportFunction(u + "_mul"), t.exportFunction(u + "_square"), t.exportFunction(u + "_squareOld"), t.exportFunction(u + "_fromMontgomery"), t.exportFunction(u + "_toMontgomery"), t.exportFunction(u + "_inverse"), t.exportFunction(u + "_one"), t.exportFunction(u + "_load"), t.exportFunction(u + "_timesScalar"), jc(
|
|
2579
2553
|
t,
|
|
2580
2554
|
u + "_exp",
|
|
2581
2555
|
b,
|
|
@@ -2595,32 +2569,32 @@ var Wi = function(t, n, e, i, s) {
|
|
|
2595
2569
|
};
|
|
2596
2570
|
const l = s || "int", C = Wc(t, d, i, l), B = t.modules[C].pR2, A = t.modules[C].pq, O = t.modules[C].pePlusOne;
|
|
2597
2571
|
function P() {
|
|
2598
|
-
const ot = t.alloc(b),
|
|
2599
|
-
|
|
2600
|
-
const rt =
|
|
2601
|
-
|
|
2572
|
+
const ot = t.alloc(b), T = t.addFunction(u + "_mul");
|
|
2573
|
+
T.addParam("x", "i32"), T.addParam("y", "i32"), T.addParam("r", "i32");
|
|
2574
|
+
const rt = T.getCodeBuilder();
|
|
2575
|
+
T.addCode(rt.call(C + "_mul", rt.getLocal("x"), rt.getLocal("y"), rt.i32_const(ot))), T.addCode(rt.call(C + "_mul", rt.i32_const(ot), rt.i32_const(B), rt.getLocal("r")));
|
|
2602
2576
|
}
|
|
2603
2577
|
function E() {
|
|
2604
2578
|
const ot = t.addFunction(u + "_square");
|
|
2605
2579
|
ot.addParam("x", "i32"), ot.addParam("r", "i32");
|
|
2606
|
-
const
|
|
2607
|
-
ot.addCode(
|
|
2580
|
+
const T = ot.getCodeBuilder();
|
|
2581
|
+
ot.addCode(T.call(u + "_mul", T.getLocal("x"), T.getLocal("x"), T.getLocal("r")));
|
|
2608
2582
|
}
|
|
2609
|
-
function
|
|
2583
|
+
function z() {
|
|
2610
2584
|
const ot = t.addFunction(u + "_inverse");
|
|
2611
2585
|
ot.addParam("x", "i32"), ot.addParam("r", "i32");
|
|
2612
|
-
const
|
|
2613
|
-
ot.addCode(
|
|
2586
|
+
const T = ot.getCodeBuilder();
|
|
2587
|
+
ot.addCode(T.call(l + "_inverseMod", T.getLocal("x"), T.i32_const(A), T.getLocal("r")));
|
|
2614
2588
|
}
|
|
2615
2589
|
function x() {
|
|
2616
2590
|
const ot = t.addFunction(u + "_isNegative");
|
|
2617
2591
|
ot.addParam("x", "i32"), ot.setReturnType("i32");
|
|
2618
|
-
const
|
|
2592
|
+
const T = ot.getCodeBuilder();
|
|
2619
2593
|
ot.addCode(
|
|
2620
|
-
|
|
2594
|
+
T.call(l + "_gte", T.getLocal("x"), T.i32_const(O))
|
|
2621
2595
|
);
|
|
2622
2596
|
}
|
|
2623
|
-
return P(), E(),
|
|
2597
|
+
return P(), E(), z(), x(), t.exportFunction(C + "_add", u + "_add"), t.exportFunction(C + "_sub", u + "_sub"), t.exportFunction(C + "_neg", u + "_neg"), t.exportFunction(u + "_mul"), t.exportFunction(u + "_square"), t.exportFunction(u + "_inverse"), t.exportFunction(u + "_isNegative"), t.exportFunction(C + "_copy", u + "_copy"), t.exportFunction(C + "_zero", u + "_zero"), t.exportFunction(C + "_one", u + "_one"), t.exportFunction(C + "_isZero", u + "_isZero"), t.exportFunction(C + "_eq", u + "_eq"), u;
|
|
2624
2598
|
};
|
|
2625
2599
|
const ts = po, ns = Lo, ve = mn;
|
|
2626
2600
|
var Xi = function(t, n, e, i) {
|
|
@@ -2631,55 +2605,55 @@ var Xi = function(t, n, e, i) {
|
|
|
2631
2605
|
n64: t.modules[i].n64 * 2
|
|
2632
2606
|
};
|
|
2633
2607
|
function r() {
|
|
2634
|
-
const
|
|
2635
|
-
|
|
2636
|
-
const y =
|
|
2637
|
-
|
|
2608
|
+
const Q = t.addFunction(e + "_add");
|
|
2609
|
+
Q.addParam("x", "i32"), Q.addParam("y", "i32"), Q.addParam("r", "i32");
|
|
2610
|
+
const y = Q.getCodeBuilder(), v = y.getLocal("x"), D = y.i32_add(y.getLocal("x"), y.i32_const(s)), it = y.getLocal("y"), nt = y.i32_add(y.getLocal("y"), y.i32_const(s)), K = y.getLocal("r"), ct = y.i32_add(y.getLocal("r"), y.i32_const(s));
|
|
2611
|
+
Q.addCode(
|
|
2638
2612
|
y.call(i + "_add", v, it, K),
|
|
2639
2613
|
y.call(i + "_add", D, nt, ct)
|
|
2640
2614
|
);
|
|
2641
2615
|
}
|
|
2642
2616
|
function b() {
|
|
2643
|
-
const
|
|
2644
|
-
|
|
2645
|
-
const y =
|
|
2646
|
-
|
|
2617
|
+
const Q = t.addFunction(e + "_timesScalar");
|
|
2618
|
+
Q.addParam("x", "i32"), Q.addParam("scalar", "i32"), Q.addParam("scalarLen", "i32"), Q.addParam("r", "i32");
|
|
2619
|
+
const y = Q.getCodeBuilder(), v = y.getLocal("x"), D = y.i32_add(y.getLocal("x"), y.i32_const(s)), it = y.getLocal("r"), nt = y.i32_add(y.getLocal("r"), y.i32_const(s));
|
|
2620
|
+
Q.addCode(
|
|
2647
2621
|
y.call(i + "_timesScalar", v, y.getLocal("scalar"), y.getLocal("scalarLen"), it),
|
|
2648
2622
|
y.call(i + "_timesScalar", D, y.getLocal("scalar"), y.getLocal("scalarLen"), nt)
|
|
2649
2623
|
);
|
|
2650
2624
|
}
|
|
2651
2625
|
function u() {
|
|
2652
|
-
const
|
|
2653
|
-
|
|
2654
|
-
const y =
|
|
2655
|
-
|
|
2626
|
+
const Q = t.addFunction(e + "_sub");
|
|
2627
|
+
Q.addParam("x", "i32"), Q.addParam("y", "i32"), Q.addParam("r", "i32");
|
|
2628
|
+
const y = Q.getCodeBuilder(), v = y.getLocal("x"), D = y.i32_add(y.getLocal("x"), y.i32_const(s)), it = y.getLocal("y"), nt = y.i32_add(y.getLocal("y"), y.i32_const(s)), K = y.getLocal("r"), ct = y.i32_add(y.getLocal("r"), y.i32_const(s));
|
|
2629
|
+
Q.addCode(
|
|
2656
2630
|
y.call(i + "_sub", v, it, K),
|
|
2657
2631
|
y.call(i + "_sub", D, nt, ct)
|
|
2658
2632
|
);
|
|
2659
2633
|
}
|
|
2660
2634
|
function l() {
|
|
2661
|
-
const
|
|
2662
|
-
|
|
2663
|
-
const y =
|
|
2664
|
-
|
|
2635
|
+
const Q = t.addFunction(e + "_neg");
|
|
2636
|
+
Q.addParam("x", "i32"), Q.addParam("r", "i32");
|
|
2637
|
+
const y = Q.getCodeBuilder(), v = y.getLocal("x"), D = y.i32_add(y.getLocal("x"), y.i32_const(s)), it = y.getLocal("r"), nt = y.i32_add(y.getLocal("r"), y.i32_const(s));
|
|
2638
|
+
Q.addCode(
|
|
2665
2639
|
y.call(i + "_neg", v, it),
|
|
2666
2640
|
y.call(i + "_neg", D, nt)
|
|
2667
2641
|
);
|
|
2668
2642
|
}
|
|
2669
2643
|
function C() {
|
|
2670
|
-
const
|
|
2671
|
-
|
|
2672
|
-
const y =
|
|
2673
|
-
|
|
2644
|
+
const Q = t.addFunction(e + "_conjugate");
|
|
2645
|
+
Q.addParam("x", "i32"), Q.addParam("r", "i32");
|
|
2646
|
+
const y = Q.getCodeBuilder(), v = y.getLocal("x"), D = y.i32_add(y.getLocal("x"), y.i32_const(s)), it = y.getLocal("r"), nt = y.i32_add(y.getLocal("r"), y.i32_const(s));
|
|
2647
|
+
Q.addCode(
|
|
2674
2648
|
y.call(i + "_copy", v, it),
|
|
2675
2649
|
y.call(i + "_neg", D, nt)
|
|
2676
2650
|
);
|
|
2677
2651
|
}
|
|
2678
2652
|
function B() {
|
|
2679
|
-
const
|
|
2680
|
-
|
|
2681
|
-
const y =
|
|
2682
|
-
|
|
2653
|
+
const Q = t.addFunction(e + "_isNegative");
|
|
2654
|
+
Q.addParam("x", "i32"), Q.setReturnType("i32");
|
|
2655
|
+
const y = Q.getCodeBuilder(), v = y.getLocal("x"), D = y.i32_add(y.getLocal("x"), y.i32_const(s));
|
|
2656
|
+
Q.addCode(
|
|
2683
2657
|
y.if(
|
|
2684
2658
|
y.call(i + "_isZero", D),
|
|
2685
2659
|
y.ret(y.call(i + "_isNegative", v))
|
|
@@ -2688,10 +2662,10 @@ var Xi = function(t, n, e, i) {
|
|
|
2688
2662
|
);
|
|
2689
2663
|
}
|
|
2690
2664
|
function A() {
|
|
2691
|
-
const
|
|
2692
|
-
|
|
2693
|
-
const y =
|
|
2694
|
-
|
|
2665
|
+
const Q = t.addFunction(e + "_mul");
|
|
2666
|
+
Q.addParam("x", "i32"), Q.addParam("y", "i32"), Q.addParam("r", "i32");
|
|
2667
|
+
const y = Q.getCodeBuilder(), v = y.getLocal("x"), D = y.i32_add(y.getLocal("x"), y.i32_const(s)), it = y.getLocal("y"), nt = y.i32_add(y.getLocal("y"), y.i32_const(s)), K = y.getLocal("r"), ct = y.i32_add(y.getLocal("r"), y.i32_const(s)), J = y.i32_const(t.alloc(s)), st = y.i32_const(t.alloc(s)), At = y.i32_const(t.alloc(s)), Bt = y.i32_const(t.alloc(s));
|
|
2668
|
+
Q.addCode(
|
|
2695
2669
|
y.call(i + "_mul", v, it, J),
|
|
2696
2670
|
// A = x0*y0
|
|
2697
2671
|
y.call(i + "_mul", D, nt, st),
|
|
@@ -2714,10 +2688,10 @@ var Xi = function(t, n, e, i) {
|
|
|
2714
2688
|
);
|
|
2715
2689
|
}
|
|
2716
2690
|
function O() {
|
|
2717
|
-
const
|
|
2718
|
-
|
|
2719
|
-
const y =
|
|
2720
|
-
|
|
2691
|
+
const Q = t.addFunction(e + "_mul1");
|
|
2692
|
+
Q.addParam("x", "i32"), Q.addParam("y", "i32"), Q.addParam("r", "i32");
|
|
2693
|
+
const y = Q.getCodeBuilder(), v = y.getLocal("x"), D = y.i32_add(y.getLocal("x"), y.i32_const(s)), it = y.getLocal("y"), nt = y.getLocal("r"), K = y.i32_add(y.getLocal("r"), y.i32_const(s));
|
|
2694
|
+
Q.addCode(
|
|
2721
2695
|
y.call(i + "_mul", v, it, nt),
|
|
2722
2696
|
// A = x0*y
|
|
2723
2697
|
y.call(i + "_mul", D, it, K)
|
|
@@ -2725,10 +2699,10 @@ var Xi = function(t, n, e, i) {
|
|
|
2725
2699
|
);
|
|
2726
2700
|
}
|
|
2727
2701
|
function P() {
|
|
2728
|
-
const
|
|
2729
|
-
|
|
2730
|
-
const y =
|
|
2731
|
-
|
|
2702
|
+
const Q = t.addFunction(e + "_square");
|
|
2703
|
+
Q.addParam("x", "i32"), Q.addParam("r", "i32");
|
|
2704
|
+
const y = Q.getCodeBuilder(), v = y.getLocal("x"), D = y.i32_add(y.getLocal("x"), y.i32_const(s)), it = y.getLocal("r"), nt = y.i32_add(y.getLocal("r"), y.i32_const(s)), K = y.i32_const(t.alloc(s)), ct = y.i32_const(t.alloc(s)), J = y.i32_const(t.alloc(s)), st = y.i32_const(t.alloc(s));
|
|
2705
|
+
Q.addCode(
|
|
2732
2706
|
// AB = x0*y1
|
|
2733
2707
|
y.call(i + "_mul", v, D, K),
|
|
2734
2708
|
// APB = x0+y1
|
|
@@ -2747,55 +2721,55 @@ var Xi = function(t, n, e, i) {
|
|
|
2747
2721
|
);
|
|
2748
2722
|
}
|
|
2749
2723
|
function E() {
|
|
2750
|
-
const
|
|
2751
|
-
|
|
2752
|
-
const y =
|
|
2753
|
-
|
|
2724
|
+
const Q = t.addFunction(e + "_toMontgomery");
|
|
2725
|
+
Q.addParam("x", "i32"), Q.addParam("r", "i32");
|
|
2726
|
+
const y = Q.getCodeBuilder(), v = y.getLocal("x"), D = y.i32_add(y.getLocal("x"), y.i32_const(s)), it = y.getLocal("r"), nt = y.i32_add(y.getLocal("r"), y.i32_const(s));
|
|
2727
|
+
Q.addCode(
|
|
2754
2728
|
y.call(i + "_toMontgomery", v, it),
|
|
2755
2729
|
y.call(i + "_toMontgomery", D, nt)
|
|
2756
2730
|
);
|
|
2757
2731
|
}
|
|
2758
|
-
function
|
|
2759
|
-
const
|
|
2760
|
-
|
|
2761
|
-
const y =
|
|
2762
|
-
|
|
2732
|
+
function z() {
|
|
2733
|
+
const Q = t.addFunction(e + "_fromMontgomery");
|
|
2734
|
+
Q.addParam("x", "i32"), Q.addParam("r", "i32");
|
|
2735
|
+
const y = Q.getCodeBuilder(), v = y.getLocal("x"), D = y.i32_add(y.getLocal("x"), y.i32_const(s)), it = y.getLocal("r"), nt = y.i32_add(y.getLocal("r"), y.i32_const(s));
|
|
2736
|
+
Q.addCode(
|
|
2763
2737
|
y.call(i + "_fromMontgomery", v, it),
|
|
2764
2738
|
y.call(i + "_fromMontgomery", D, nt)
|
|
2765
2739
|
);
|
|
2766
2740
|
}
|
|
2767
2741
|
function x() {
|
|
2768
|
-
const
|
|
2769
|
-
|
|
2770
|
-
const y =
|
|
2771
|
-
|
|
2742
|
+
const Q = t.addFunction(e + "_copy");
|
|
2743
|
+
Q.addParam("x", "i32"), Q.addParam("r", "i32");
|
|
2744
|
+
const y = Q.getCodeBuilder(), v = y.getLocal("x"), D = y.i32_add(y.getLocal("x"), y.i32_const(s)), it = y.getLocal("r"), nt = y.i32_add(y.getLocal("r"), y.i32_const(s));
|
|
2745
|
+
Q.addCode(
|
|
2772
2746
|
y.call(i + "_copy", v, it),
|
|
2773
2747
|
y.call(i + "_copy", D, nt)
|
|
2774
2748
|
);
|
|
2775
2749
|
}
|
|
2776
2750
|
function ot() {
|
|
2777
|
-
const
|
|
2778
|
-
|
|
2779
|
-
const y =
|
|
2780
|
-
|
|
2751
|
+
const Q = t.addFunction(e + "_zero");
|
|
2752
|
+
Q.addParam("x", "i32");
|
|
2753
|
+
const y = Q.getCodeBuilder(), v = y.getLocal("x"), D = y.i32_add(y.getLocal("x"), y.i32_const(s));
|
|
2754
|
+
Q.addCode(
|
|
2781
2755
|
y.call(i + "_zero", v),
|
|
2782
2756
|
y.call(i + "_zero", D)
|
|
2783
2757
|
);
|
|
2784
2758
|
}
|
|
2785
|
-
function
|
|
2786
|
-
const
|
|
2787
|
-
|
|
2788
|
-
const y =
|
|
2789
|
-
|
|
2759
|
+
function T() {
|
|
2760
|
+
const Q = t.addFunction(e + "_one");
|
|
2761
|
+
Q.addParam("x", "i32");
|
|
2762
|
+
const y = Q.getCodeBuilder(), v = y.getLocal("x"), D = y.i32_add(y.getLocal("x"), y.i32_const(s));
|
|
2763
|
+
Q.addCode(
|
|
2790
2764
|
y.call(i + "_one", v),
|
|
2791
2765
|
y.call(i + "_zero", D)
|
|
2792
2766
|
);
|
|
2793
2767
|
}
|
|
2794
2768
|
function rt() {
|
|
2795
|
-
const
|
|
2796
|
-
|
|
2797
|
-
const y =
|
|
2798
|
-
|
|
2769
|
+
const Q = t.addFunction(e + "_eq");
|
|
2770
|
+
Q.addParam("x", "i32"), Q.addParam("y", "i32"), Q.setReturnType("i32");
|
|
2771
|
+
const y = Q.getCodeBuilder(), v = y.getLocal("x"), D = y.i32_add(y.getLocal("x"), y.i32_const(s)), it = y.getLocal("y"), nt = y.i32_add(y.getLocal("y"), y.i32_const(s));
|
|
2772
|
+
Q.addCode(
|
|
2799
2773
|
y.i32_and(
|
|
2800
2774
|
y.call(i + "_eq", v, it),
|
|
2801
2775
|
y.call(i + "_eq", D, nt)
|
|
@@ -2803,10 +2777,10 @@ var Xi = function(t, n, e, i) {
|
|
|
2803
2777
|
);
|
|
2804
2778
|
}
|
|
2805
2779
|
function F() {
|
|
2806
|
-
const
|
|
2807
|
-
|
|
2808
|
-
const y =
|
|
2809
|
-
|
|
2780
|
+
const Q = t.addFunction(e + "_isZero");
|
|
2781
|
+
Q.addParam("x", "i32"), Q.setReturnType("i32");
|
|
2782
|
+
const y = Q.getCodeBuilder(), v = y.getLocal("x"), D = y.i32_add(y.getLocal("x"), y.i32_const(s));
|
|
2783
|
+
Q.addCode(
|
|
2810
2784
|
y.i32_and(
|
|
2811
2785
|
y.call(i + "_isZero", v),
|
|
2812
2786
|
y.call(i + "_isZero", D)
|
|
@@ -2814,10 +2788,10 @@ var Xi = function(t, n, e, i) {
|
|
|
2814
2788
|
);
|
|
2815
2789
|
}
|
|
2816
2790
|
function f() {
|
|
2817
|
-
const
|
|
2818
|
-
|
|
2819
|
-
const y =
|
|
2820
|
-
|
|
2791
|
+
const Q = t.addFunction(e + "_inverse");
|
|
2792
|
+
Q.addParam("x", "i32"), Q.addParam("r", "i32");
|
|
2793
|
+
const y = Q.getCodeBuilder(), v = y.getLocal("x"), D = y.i32_add(y.getLocal("x"), y.i32_const(s)), it = y.getLocal("r"), nt = y.i32_add(y.getLocal("r"), y.i32_const(s)), K = y.i32_const(t.alloc(s)), ct = y.i32_const(t.alloc(s)), J = y.i32_const(t.alloc(s)), st = y.i32_const(t.alloc(s));
|
|
2794
|
+
Q.addCode(
|
|
2821
2795
|
y.call(i + "_square", v, K),
|
|
2822
2796
|
y.call(i + "_square", D, ct),
|
|
2823
2797
|
// c.call(f1mPrefix+"_mul", t1, c.i32_const(pNonResidue), t2),
|
|
@@ -2830,10 +2804,10 @@ var Xi = function(t, n, e, i) {
|
|
|
2830
2804
|
);
|
|
2831
2805
|
}
|
|
2832
2806
|
function L() {
|
|
2833
|
-
const
|
|
2834
|
-
|
|
2835
|
-
const y =
|
|
2836
|
-
|
|
2807
|
+
const Q = t.addFunction(e + "_sign");
|
|
2808
|
+
Q.addParam("x", "i32"), Q.addLocal("s", "i32"), Q.setReturnType("i32");
|
|
2809
|
+
const y = Q.getCodeBuilder(), v = y.getLocal("x"), D = y.i32_add(y.getLocal("x"), y.i32_const(s));
|
|
2810
|
+
Q.addCode(
|
|
2837
2811
|
y.setLocal("s", y.call(i + "_sign", D)),
|
|
2838
2812
|
y.if(
|
|
2839
2813
|
y.getLocal("s"),
|
|
@@ -2843,10 +2817,10 @@ var Xi = function(t, n, e, i) {
|
|
|
2843
2817
|
);
|
|
2844
2818
|
}
|
|
2845
2819
|
function V() {
|
|
2846
|
-
const
|
|
2847
|
-
|
|
2848
|
-
const y =
|
|
2849
|
-
|
|
2820
|
+
const Q = t.addFunction(e + "_isOne");
|
|
2821
|
+
Q.addParam("x", "i32"), Q.setReturnType("i32");
|
|
2822
|
+
const y = Q.getCodeBuilder(), v = y.getLocal("x"), D = y.i32_add(y.getLocal("x"), y.i32_const(s));
|
|
2823
|
+
Q.addCode(
|
|
2850
2824
|
y.ret(y.i32_and(
|
|
2851
2825
|
y.call(i + "_isOne", v),
|
|
2852
2826
|
y.call(i + "_isZero", D)
|
|
@@ -2854,10 +2828,10 @@ var Xi = function(t, n, e, i) {
|
|
|
2854
2828
|
);
|
|
2855
2829
|
}
|
|
2856
2830
|
function $() {
|
|
2857
|
-
const
|
|
2858
|
-
|
|
2859
|
-
const y =
|
|
2860
|
-
|
|
2831
|
+
const Q = t.addFunction(e + "_sqrt");
|
|
2832
|
+
Q.addParam("a", "i32"), Q.addParam("pr", "i32");
|
|
2833
|
+
const y = Q.getCodeBuilder(), v = y.i32_const(t.alloc(ve.bigInt2BytesLE((BigInt(d || 0) - 3n) / 4n, s))), D = y.i32_const(t.alloc(ve.bigInt2BytesLE((BigInt(d || 0) - 1n) / 2n, s))), it = y.getLocal("a"), nt = y.i32_const(t.alloc(s * 2)), K = y.i32_const(t.alloc(s * 2)), ct = y.i32_const(t.alloc(s * 2)), J = t.alloc(s * 2), st = y.i32_const(J), At = y.i32_const(J), Bt = y.i32_const(J + s), pt = y.i32_const(t.alloc(s * 2)), p = y.i32_const(t.alloc(s * 2));
|
|
2834
|
+
Q.addCode(
|
|
2861
2835
|
y.call(e + "_one", st),
|
|
2862
2836
|
y.call(e + "_neg", st, st),
|
|
2863
2837
|
// const a1 = F.pow(a, F.sqrt_e34);
|
|
@@ -2893,10 +2867,10 @@ var Xi = function(t, n, e, i) {
|
|
|
2893
2867
|
);
|
|
2894
2868
|
}
|
|
2895
2869
|
function X() {
|
|
2896
|
-
const
|
|
2897
|
-
|
|
2898
|
-
const y =
|
|
2899
|
-
|
|
2870
|
+
const Q = t.addFunction(e + "_isSquare");
|
|
2871
|
+
Q.addParam("a", "i32"), Q.setReturnType("i32");
|
|
2872
|
+
const y = Q.getCodeBuilder(), v = y.i32_const(t.alloc(ve.bigInt2BytesLE((BigInt(d || 0) - 3n) / 4n, s))), D = y.getLocal("a"), it = y.i32_const(t.alloc(s * 2)), nt = y.i32_const(t.alloc(s * 2)), K = y.i32_const(t.alloc(s * 2)), ct = t.alloc(s * 2), J = y.i32_const(ct);
|
|
2873
|
+
Q.addCode(
|
|
2900
2874
|
y.call(e + "_one", J),
|
|
2901
2875
|
y.call(e + "_neg", J, J),
|
|
2902
2876
|
// const a1 = F.pow(a, F.sqrt_e34);
|
|
@@ -2919,7 +2893,7 @@ var Xi = function(t, n, e, i) {
|
|
|
2919
2893
|
y.ret(y.i32_const(1))
|
|
2920
2894
|
);
|
|
2921
2895
|
}
|
|
2922
|
-
return F(), V(), ot(),
|
|
2896
|
+
return F(), V(), ot(), T(), x(), A(), O(), P(), r(), u(), l(), C(), E(), z(), rt(), f(), b(), L(), B(), t.exportFunction(e + "_isZero"), t.exportFunction(e + "_isOne"), t.exportFunction(e + "_zero"), t.exportFunction(e + "_one"), t.exportFunction(e + "_copy"), t.exportFunction(e + "_mul"), t.exportFunction(e + "_mul1"), t.exportFunction(e + "_square"), t.exportFunction(e + "_add"), t.exportFunction(e + "_sub"), t.exportFunction(e + "_neg"), t.exportFunction(e + "_sign"), t.exportFunction(e + "_conjugate"), t.exportFunction(e + "_fromMontgomery"), t.exportFunction(e + "_toMontgomery"), t.exportFunction(e + "_eq"), t.exportFunction(e + "_inverse"), ns(t, e), ts(
|
|
2923
2897
|
t,
|
|
2924
2898
|
e + "_exp",
|
|
2925
2899
|
s * 2,
|
|
@@ -2940,9 +2914,9 @@ var ta = function(t, n, e, i) {
|
|
|
2940
2914
|
function d() {
|
|
2941
2915
|
const f = t.addFunction(e + "_add");
|
|
2942
2916
|
f.addParam("x", "i32"), f.addParam("y", "i32"), f.addParam("r", "i32");
|
|
2943
|
-
const L = f.getCodeBuilder(), V = L.getLocal("x"), $ = L.i32_add(L.getLocal("x"), L.i32_const(s)), X = L.i32_add(L.getLocal("x"), L.i32_const(2 * s)),
|
|
2917
|
+
const L = f.getCodeBuilder(), V = L.getLocal("x"), $ = L.i32_add(L.getLocal("x"), L.i32_const(s)), X = L.i32_add(L.getLocal("x"), L.i32_const(2 * s)), Q = L.getLocal("y"), y = L.i32_add(L.getLocal("y"), L.i32_const(s)), v = L.i32_add(L.getLocal("y"), L.i32_const(2 * s)), D = L.getLocal("r"), it = L.i32_add(L.getLocal("r"), L.i32_const(s)), nt = L.i32_add(L.getLocal("r"), L.i32_const(2 * s));
|
|
2944
2918
|
f.addCode(
|
|
2945
|
-
L.call(i + "_add", V,
|
|
2919
|
+
L.call(i + "_add", V, Q, D),
|
|
2946
2920
|
L.call(i + "_add", $, y, it),
|
|
2947
2921
|
L.call(i + "_add", X, v, nt)
|
|
2948
2922
|
);
|
|
@@ -2950,9 +2924,9 @@ var ta = function(t, n, e, i) {
|
|
|
2950
2924
|
function r() {
|
|
2951
2925
|
const f = t.addFunction(e + "_timesScalar");
|
|
2952
2926
|
f.addParam("x", "i32"), f.addParam("scalar", "i32"), f.addParam("scalarLen", "i32"), f.addParam("r", "i32");
|
|
2953
|
-
const L = f.getCodeBuilder(), V = L.getLocal("x"), $ = L.i32_add(L.getLocal("x"), L.i32_const(s)), X = L.i32_add(L.getLocal("x"), L.i32_const(2 * s)),
|
|
2927
|
+
const L = f.getCodeBuilder(), V = L.getLocal("x"), $ = L.i32_add(L.getLocal("x"), L.i32_const(s)), X = L.i32_add(L.getLocal("x"), L.i32_const(2 * s)), Q = L.getLocal("r"), y = L.i32_add(L.getLocal("r"), L.i32_const(s)), v = L.i32_add(L.getLocal("r"), L.i32_const(2 * s));
|
|
2954
2928
|
f.addCode(
|
|
2955
|
-
L.call(i + "_timesScalar", V, L.getLocal("scalar"), L.getLocal("scalarLen"),
|
|
2929
|
+
L.call(i + "_timesScalar", V, L.getLocal("scalar"), L.getLocal("scalarLen"), Q),
|
|
2956
2930
|
L.call(i + "_timesScalar", $, L.getLocal("scalar"), L.getLocal("scalarLen"), y),
|
|
2957
2931
|
L.call(i + "_timesScalar", X, L.getLocal("scalar"), L.getLocal("scalarLen"), v)
|
|
2958
2932
|
);
|
|
@@ -2960,9 +2934,9 @@ var ta = function(t, n, e, i) {
|
|
|
2960
2934
|
function b() {
|
|
2961
2935
|
const f = t.addFunction(e + "_sub");
|
|
2962
2936
|
f.addParam("x", "i32"), f.addParam("y", "i32"), f.addParam("r", "i32");
|
|
2963
|
-
const L = f.getCodeBuilder(), V = L.getLocal("x"), $ = L.i32_add(L.getLocal("x"), L.i32_const(s)), X = L.i32_add(L.getLocal("x"), L.i32_const(2 * s)),
|
|
2937
|
+
const L = f.getCodeBuilder(), V = L.getLocal("x"), $ = L.i32_add(L.getLocal("x"), L.i32_const(s)), X = L.i32_add(L.getLocal("x"), L.i32_const(2 * s)), Q = L.getLocal("y"), y = L.i32_add(L.getLocal("y"), L.i32_const(s)), v = L.i32_add(L.getLocal("y"), L.i32_const(2 * s)), D = L.getLocal("r"), it = L.i32_add(L.getLocal("r"), L.i32_const(s)), nt = L.i32_add(L.getLocal("r"), L.i32_const(2 * s));
|
|
2964
2938
|
f.addCode(
|
|
2965
|
-
L.call(i + "_sub", V,
|
|
2939
|
+
L.call(i + "_sub", V, Q, D),
|
|
2966
2940
|
L.call(i + "_sub", $, y, it),
|
|
2967
2941
|
L.call(i + "_sub", X, v, nt)
|
|
2968
2942
|
);
|
|
@@ -2970,9 +2944,9 @@ var ta = function(t, n, e, i) {
|
|
|
2970
2944
|
function u() {
|
|
2971
2945
|
const f = t.addFunction(e + "_neg");
|
|
2972
2946
|
f.addParam("x", "i32"), f.addParam("r", "i32");
|
|
2973
|
-
const L = f.getCodeBuilder(), V = L.getLocal("x"), $ = L.i32_add(L.getLocal("x"), L.i32_const(s)), X = L.i32_add(L.getLocal("x"), L.i32_const(2 * s)),
|
|
2947
|
+
const L = f.getCodeBuilder(), V = L.getLocal("x"), $ = L.i32_add(L.getLocal("x"), L.i32_const(s)), X = L.i32_add(L.getLocal("x"), L.i32_const(2 * s)), Q = L.getLocal("r"), y = L.i32_add(L.getLocal("r"), L.i32_const(s)), v = L.i32_add(L.getLocal("r"), L.i32_const(2 * s));
|
|
2974
2948
|
f.addCode(
|
|
2975
|
-
L.call(i + "_neg", V,
|
|
2949
|
+
L.call(i + "_neg", V, Q),
|
|
2976
2950
|
L.call(i + "_neg", $, y),
|
|
2977
2951
|
L.call(i + "_neg", X, v)
|
|
2978
2952
|
);
|
|
@@ -2996,15 +2970,15 @@ var ta = function(t, n, e, i) {
|
|
|
2996
2970
|
function C() {
|
|
2997
2971
|
const f = t.addFunction(e + "_mul");
|
|
2998
2972
|
f.addParam("x", "i32"), f.addParam("y", "i32"), f.addParam("r", "i32");
|
|
2999
|
-
const L = f.getCodeBuilder(), V = L.getLocal("x"), $ = L.i32_add(L.getLocal("x"), L.i32_const(s)), X = L.i32_add(L.getLocal("x"), L.i32_const(2 * s)),
|
|
2973
|
+
const L = f.getCodeBuilder(), V = L.getLocal("x"), $ = L.i32_add(L.getLocal("x"), L.i32_const(s)), X = L.i32_add(L.getLocal("x"), L.i32_const(2 * s)), Q = L.getLocal("y"), y = L.i32_add(L.getLocal("y"), L.i32_const(s)), v = L.i32_add(L.getLocal("y"), L.i32_const(2 * s)), D = L.getLocal("r"), it = L.i32_add(L.getLocal("r"), L.i32_const(s)), nt = L.i32_add(L.getLocal("r"), L.i32_const(2 * s)), K = L.i32_const(t.alloc(s)), ct = L.i32_const(t.alloc(s)), J = L.i32_const(t.alloc(s)), st = L.i32_const(t.alloc(s)), At = L.i32_const(t.alloc(s)), Bt = L.i32_const(t.alloc(s)), pt = L.i32_const(t.alloc(s)), p = L.i32_const(t.alloc(s)), a = L.i32_const(t.alloc(s)), m = L.i32_const(t.alloc(s)), c = L.i32_const(t.alloc(s)), w = L.i32_const(t.alloc(s)), I = L.i32_const(t.alloc(s));
|
|
3000
2974
|
f.addCode(
|
|
3001
|
-
L.call(i + "_mul", V,
|
|
2975
|
+
L.call(i + "_mul", V, Q, K),
|
|
3002
2976
|
L.call(i + "_mul", $, y, ct),
|
|
3003
2977
|
L.call(i + "_mul", X, v, J),
|
|
3004
2978
|
L.call(i + "_add", V, $, st),
|
|
3005
|
-
L.call(i + "_add",
|
|
2979
|
+
L.call(i + "_add", Q, y, At),
|
|
3006
2980
|
L.call(i + "_add", V, X, Bt),
|
|
3007
|
-
L.call(i + "_add",
|
|
2981
|
+
L.call(i + "_add", Q, v, pt),
|
|
3008
2982
|
L.call(i + "_add", $, X, p),
|
|
3009
2983
|
L.call(i + "_add", y, v, a),
|
|
3010
2984
|
L.call(i + "_add", K, ct, m),
|
|
@@ -3026,7 +3000,7 @@ var ta = function(t, n, e, i) {
|
|
|
3026
3000
|
function B() {
|
|
3027
3001
|
const f = t.addFunction(e + "_square");
|
|
3028
3002
|
f.addParam("x", "i32"), f.addParam("r", "i32");
|
|
3029
|
-
const L = f.getCodeBuilder(), V = L.getLocal("x"), $ = L.i32_add(L.getLocal("x"), L.i32_const(s)), X = L.i32_add(L.getLocal("x"), L.i32_const(2 * s)),
|
|
3003
|
+
const L = f.getCodeBuilder(), V = L.getLocal("x"), $ = L.i32_add(L.getLocal("x"), L.i32_const(s)), X = L.i32_add(L.getLocal("x"), L.i32_const(2 * s)), Q = L.getLocal("r"), y = L.i32_add(L.getLocal("r"), L.i32_const(s)), v = L.i32_add(L.getLocal("r"), L.i32_const(2 * s)), D = L.i32_const(t.alloc(s)), it = L.i32_const(t.alloc(s)), nt = L.i32_const(t.alloc(s)), K = L.i32_const(t.alloc(s)), ct = L.i32_const(t.alloc(s)), J = L.i32_const(t.alloc(s)), st = L.i32_const(t.alloc(s));
|
|
3030
3004
|
f.addCode(
|
|
3031
3005
|
L.call(i + "_square", V, D),
|
|
3032
3006
|
L.call(i + "_mul", V, $, it),
|
|
@@ -3037,8 +3011,8 @@ var ta = function(t, n, e, i) {
|
|
|
3037
3011
|
L.call(i + "_mul", $, X, ct),
|
|
3038
3012
|
L.call(i + "_add", ct, ct, J),
|
|
3039
3013
|
L.call(i + "_square", X, st),
|
|
3040
|
-
L.call(n, J,
|
|
3041
|
-
L.call(i + "_add", D,
|
|
3014
|
+
L.call(n, J, Q),
|
|
3015
|
+
L.call(i + "_add", D, Q, Q),
|
|
3042
3016
|
L.call(n, st, y),
|
|
3043
3017
|
L.call(i + "_add", nt, y, y),
|
|
3044
3018
|
L.call(i + "_add", D, st, v),
|
|
@@ -3050,9 +3024,9 @@ var ta = function(t, n, e, i) {
|
|
|
3050
3024
|
function A() {
|
|
3051
3025
|
const f = t.addFunction(e + "_toMontgomery");
|
|
3052
3026
|
f.addParam("x", "i32"), f.addParam("r", "i32");
|
|
3053
|
-
const L = f.getCodeBuilder(), V = L.getLocal("x"), $ = L.i32_add(L.getLocal("x"), L.i32_const(s)), X = L.i32_add(L.getLocal("x"), L.i32_const(2 * s)),
|
|
3027
|
+
const L = f.getCodeBuilder(), V = L.getLocal("x"), $ = L.i32_add(L.getLocal("x"), L.i32_const(s)), X = L.i32_add(L.getLocal("x"), L.i32_const(2 * s)), Q = L.getLocal("r"), y = L.i32_add(L.getLocal("r"), L.i32_const(s)), v = L.i32_add(L.getLocal("r"), L.i32_const(2 * s));
|
|
3054
3028
|
f.addCode(
|
|
3055
|
-
L.call(i + "_toMontgomery", V,
|
|
3029
|
+
L.call(i + "_toMontgomery", V, Q),
|
|
3056
3030
|
L.call(i + "_toMontgomery", $, y),
|
|
3057
3031
|
L.call(i + "_toMontgomery", X, v)
|
|
3058
3032
|
);
|
|
@@ -3060,9 +3034,9 @@ var ta = function(t, n, e, i) {
|
|
|
3060
3034
|
function O() {
|
|
3061
3035
|
const f = t.addFunction(e + "_fromMontgomery");
|
|
3062
3036
|
f.addParam("x", "i32"), f.addParam("r", "i32");
|
|
3063
|
-
const L = f.getCodeBuilder(), V = L.getLocal("x"), $ = L.i32_add(L.getLocal("x"), L.i32_const(s)), X = L.i32_add(L.getLocal("x"), L.i32_const(2 * s)),
|
|
3037
|
+
const L = f.getCodeBuilder(), V = L.getLocal("x"), $ = L.i32_add(L.getLocal("x"), L.i32_const(s)), X = L.i32_add(L.getLocal("x"), L.i32_const(2 * s)), Q = L.getLocal("r"), y = L.i32_add(L.getLocal("r"), L.i32_const(s)), v = L.i32_add(L.getLocal("r"), L.i32_const(2 * s));
|
|
3064
3038
|
f.addCode(
|
|
3065
|
-
L.call(i + "_fromMontgomery", V,
|
|
3039
|
+
L.call(i + "_fromMontgomery", V, Q),
|
|
3066
3040
|
L.call(i + "_fromMontgomery", $, y),
|
|
3067
3041
|
L.call(i + "_fromMontgomery", X, v)
|
|
3068
3042
|
);
|
|
@@ -3070,9 +3044,9 @@ var ta = function(t, n, e, i) {
|
|
|
3070
3044
|
function P() {
|
|
3071
3045
|
const f = t.addFunction(e + "_copy");
|
|
3072
3046
|
f.addParam("x", "i32"), f.addParam("r", "i32");
|
|
3073
|
-
const L = f.getCodeBuilder(), V = L.getLocal("x"), $ = L.i32_add(L.getLocal("x"), L.i32_const(s)), X = L.i32_add(L.getLocal("x"), L.i32_const(2 * s)),
|
|
3047
|
+
const L = f.getCodeBuilder(), V = L.getLocal("x"), $ = L.i32_add(L.getLocal("x"), L.i32_const(s)), X = L.i32_add(L.getLocal("x"), L.i32_const(2 * s)), Q = L.getLocal("r"), y = L.i32_add(L.getLocal("r"), L.i32_const(s)), v = L.i32_add(L.getLocal("r"), L.i32_const(2 * s));
|
|
3074
3048
|
f.addCode(
|
|
3075
|
-
L.call(i + "_copy", V,
|
|
3049
|
+
L.call(i + "_copy", V, Q),
|
|
3076
3050
|
L.call(i + "_copy", $, y),
|
|
3077
3051
|
L.call(i + "_copy", X, v)
|
|
3078
3052
|
);
|
|
@@ -3087,7 +3061,7 @@ var ta = function(t, n, e, i) {
|
|
|
3087
3061
|
L.call(i + "_zero", X)
|
|
3088
3062
|
);
|
|
3089
3063
|
}
|
|
3090
|
-
function
|
|
3064
|
+
function z() {
|
|
3091
3065
|
const f = t.addFunction(e + "_one");
|
|
3092
3066
|
f.addParam("x", "i32");
|
|
3093
3067
|
const L = f.getCodeBuilder(), V = L.getLocal("x"), $ = L.i32_add(L.getLocal("x"), L.i32_const(s)), X = L.i32_add(L.getLocal("x"), L.i32_const(2 * s));
|
|
@@ -3100,11 +3074,11 @@ var ta = function(t, n, e, i) {
|
|
|
3100
3074
|
function x() {
|
|
3101
3075
|
const f = t.addFunction(e + "_eq");
|
|
3102
3076
|
f.addParam("x", "i32"), f.addParam("y", "i32"), f.setReturnType("i32");
|
|
3103
|
-
const L = f.getCodeBuilder(), V = L.getLocal("x"), $ = L.i32_add(L.getLocal("x"), L.i32_const(s)), X = L.i32_add(L.getLocal("x"), L.i32_const(2 * s)),
|
|
3077
|
+
const L = f.getCodeBuilder(), V = L.getLocal("x"), $ = L.i32_add(L.getLocal("x"), L.i32_const(s)), X = L.i32_add(L.getLocal("x"), L.i32_const(2 * s)), Q = L.getLocal("y"), y = L.i32_add(L.getLocal("y"), L.i32_const(s)), v = L.i32_add(L.getLocal("y"), L.i32_const(2 * s));
|
|
3104
3078
|
f.addCode(
|
|
3105
3079
|
L.i32_and(
|
|
3106
3080
|
L.i32_and(
|
|
3107
|
-
L.call(i + "_eq", V,
|
|
3081
|
+
L.call(i + "_eq", V, Q),
|
|
3108
3082
|
L.call(i + "_eq", $, y)
|
|
3109
3083
|
),
|
|
3110
3084
|
L.call(i + "_eq", X, v)
|
|
@@ -3125,10 +3099,10 @@ var ta = function(t, n, e, i) {
|
|
|
3125
3099
|
)
|
|
3126
3100
|
);
|
|
3127
3101
|
}
|
|
3128
|
-
function
|
|
3102
|
+
function T() {
|
|
3129
3103
|
const f = t.addFunction(e + "_inverse");
|
|
3130
3104
|
f.addParam("x", "i32"), f.addParam("r", "i32");
|
|
3131
|
-
const L = f.getCodeBuilder(), V = L.getLocal("x"), $ = L.i32_add(L.getLocal("x"), L.i32_const(s)), X = L.i32_add(L.getLocal("x"), L.i32_const(2 * s)),
|
|
3105
|
+
const L = f.getCodeBuilder(), V = L.getLocal("x"), $ = L.i32_add(L.getLocal("x"), L.i32_const(s)), X = L.i32_add(L.getLocal("x"), L.i32_const(2 * s)), Q = L.getLocal("r"), y = L.i32_add(L.getLocal("r"), L.i32_const(s)), v = L.i32_add(L.getLocal("r"), L.i32_const(2 * s)), D = L.i32_const(t.alloc(s)), it = L.i32_const(t.alloc(s)), nt = L.i32_const(t.alloc(s)), K = L.i32_const(t.alloc(s)), ct = L.i32_const(t.alloc(s)), J = L.i32_const(t.alloc(s)), st = L.i32_const(t.alloc(s)), At = L.i32_const(t.alloc(s)), Bt = L.i32_const(t.alloc(s)), pt = L.i32_const(t.alloc(s)), p = L.i32_const(t.alloc(s));
|
|
3132
3106
|
f.addCode(
|
|
3133
3107
|
L.call(i + "_square", V, D),
|
|
3134
3108
|
L.call(i + "_square", $, it),
|
|
@@ -3148,7 +3122,7 @@ var ta = function(t, n, e, i) {
|
|
|
3148
3122
|
L.call(i + "_mul", V, st, p),
|
|
3149
3123
|
L.call(i + "_add", p, pt, pt),
|
|
3150
3124
|
L.call(i + "_inverse", pt, pt),
|
|
3151
|
-
L.call(i + "_mul", pt, st,
|
|
3125
|
+
L.call(i + "_mul", pt, st, Q),
|
|
3152
3126
|
L.call(i + "_mul", pt, At, y),
|
|
3153
3127
|
L.call(i + "_mul", pt, Bt, v)
|
|
3154
3128
|
);
|
|
@@ -3187,7 +3161,7 @@ var ta = function(t, n, e, i) {
|
|
|
3187
3161
|
)
|
|
3188
3162
|
);
|
|
3189
3163
|
}
|
|
3190
|
-
return ot(), F(), E(),
|
|
3164
|
+
return ot(), F(), E(), z(), P(), C(), B(), d(), b(), u(), rt(), A(), O(), x(), T(), r(), l(), t.exportFunction(e + "_isZero"), t.exportFunction(e + "_isOne"), t.exportFunction(e + "_zero"), t.exportFunction(e + "_one"), t.exportFunction(e + "_copy"), t.exportFunction(e + "_mul"), t.exportFunction(e + "_square"), t.exportFunction(e + "_add"), t.exportFunction(e + "_sub"), t.exportFunction(e + "_neg"), t.exportFunction(e + "_sign"), t.exportFunction(e + "_fromMontgomery"), t.exportFunction(e + "_toMontgomery"), t.exportFunction(e + "_eq"), t.exportFunction(e + "_inverse"), os(t, e), es(
|
|
3191
3165
|
t,
|
|
3192
3166
|
e + "_exp",
|
|
3193
3167
|
s * 3,
|
|
@@ -3771,7 +3745,7 @@ var ta = function(t, n, e, i) {
|
|
|
3771
3745
|
}
|
|
3772
3746
|
b(), C(), u(), l(), t.exportFunction(e), t.exportFunction(e + "_chunk");
|
|
3773
3747
|
};
|
|
3774
|
-
const
|
|
3748
|
+
const zo = is, kn = Vi, To = as;
|
|
3775
3749
|
var na = function(t, n, e, i) {
|
|
3776
3750
|
const s = t.modules[e].n64, d = s * 8;
|
|
3777
3751
|
if (t.modules[n])
|
|
@@ -4040,7 +4014,7 @@ var na = function(t, n, e, i) {
|
|
|
4040
4014
|
a.call(e + "_sub", I, ut, I)
|
|
4041
4015
|
);
|
|
4042
4016
|
}
|
|
4043
|
-
function
|
|
4017
|
+
function z() {
|
|
4044
4018
|
const p = t.addFunction(n + "_eqAffine");
|
|
4045
4019
|
p.addParam("p1", "i32"), p.addParam("p2", "i32"), p.setReturnType("i32"), p.addLocal("z1", "i32");
|
|
4046
4020
|
const a = p.getCodeBuilder();
|
|
@@ -4091,7 +4065,7 @@ var na = function(t, n, e, i) {
|
|
|
4091
4065
|
a.i32_add(a.getLocal("pr"), a.i32_const(m * d))
|
|
4092
4066
|
));
|
|
4093
4067
|
}
|
|
4094
|
-
function
|
|
4068
|
+
function T() {
|
|
4095
4069
|
const p = t.addFunction(n + "_fromMontgomery");
|
|
4096
4070
|
p.addParam("p1", "i32"), p.addParam("pr", "i32");
|
|
4097
4071
|
const a = p.getCodeBuilder();
|
|
@@ -4130,7 +4104,7 @@ var na = function(t, n, e, i) {
|
|
|
4130
4104
|
p.addCode(a.setLocal("z1", a.i32_add(a.getLocal("p1"), a.i32_const(d * 2))));
|
|
4131
4105
|
const w = a.getLocal("z1"), I = a.getLocal("p2"), h = a.i32_add(a.getLocal("p2"), a.i32_const(d));
|
|
4132
4106
|
p.addCode(a.setLocal("z2", a.i32_add(a.getLocal("p2"), a.i32_const(d * 2))));
|
|
4133
|
-
const S = a.getLocal("z2"), W = a.getLocal("pr"), N = a.i32_add(a.getLocal("pr"), a.i32_const(d)), at = a.i32_add(a.getLocal("pr"), a.i32_const(d * 2)), It = a.i32_const(t.alloc(d)), ut = a.i32_const(t.alloc(d)), Lt = a.i32_const(t.alloc(d)), St = a.i32_const(t.alloc(d)), gt = a.i32_const(t.alloc(d)), dt = a.i32_const(t.alloc(d)), yt = a.i32_const(t.alloc(d)), vt = a.i32_const(t.alloc(d)), Ut = a.i32_const(t.alloc(d)), Vt = a.i32_const(t.alloc(d)), Dt = a.i32_const(t.alloc(d)), jt = a.i32_const(t.alloc(d)),
|
|
4107
|
+
const S = a.getLocal("z2"), W = a.getLocal("pr"), N = a.i32_add(a.getLocal("pr"), a.i32_const(d)), at = a.i32_add(a.getLocal("pr"), a.i32_const(d * 2)), It = a.i32_const(t.alloc(d)), ut = a.i32_const(t.alloc(d)), Lt = a.i32_const(t.alloc(d)), St = a.i32_const(t.alloc(d)), gt = a.i32_const(t.alloc(d)), dt = a.i32_const(t.alloc(d)), yt = a.i32_const(t.alloc(d)), vt = a.i32_const(t.alloc(d)), Ut = a.i32_const(t.alloc(d)), Vt = a.i32_const(t.alloc(d)), Dt = a.i32_const(t.alloc(d)), jt = a.i32_const(t.alloc(d)), zt = a.i32_const(t.alloc(d)), Nt = a.i32_const(t.alloc(d)), Kt = a.i32_const(t.alloc(d)), en = a.i32_const(t.alloc(d)), Zt = a.i32_const(t.alloc(d));
|
|
4134
4108
|
p.addCode(
|
|
4135
4109
|
a.if(
|
|
4136
4110
|
a.call(n + "_isZero", a.getLocal("p1")),
|
|
@@ -4183,16 +4157,16 @@ var na = function(t, n, e, i) {
|
|
|
4183
4157
|
a.call(e + "_add", Ut, Ut, Dt),
|
|
4184
4158
|
a.call(e + "_square", Dt, Dt),
|
|
4185
4159
|
a.call(e + "_mul", Ut, Dt, jt),
|
|
4186
|
-
a.call(e + "_add", Vt, Vt,
|
|
4160
|
+
a.call(e + "_add", Vt, Vt, zt),
|
|
4187
4161
|
a.call(e + "_mul", Lt, Dt, Kt),
|
|
4188
|
-
a.call(e + "_square",
|
|
4162
|
+
a.call(e + "_square", zt, Nt),
|
|
4189
4163
|
a.call(e + "_add", Kt, Kt, en),
|
|
4190
4164
|
a.call(e + "_sub", Nt, jt, W),
|
|
4191
4165
|
a.call(e + "_sub", W, en, W),
|
|
4192
4166
|
a.call(e + "_mul", yt, jt, Zt),
|
|
4193
4167
|
a.call(e + "_add", Zt, Zt, Zt),
|
|
4194
4168
|
a.call(e + "_sub", Kt, W, N),
|
|
4195
|
-
a.call(e + "_mul", N,
|
|
4169
|
+
a.call(e + "_mul", N, zt, N),
|
|
4196
4170
|
a.call(e + "_sub", N, Zt, N),
|
|
4197
4171
|
a.call(e + "_add", w, S, at),
|
|
4198
4172
|
a.call(e + "_square", at, at),
|
|
@@ -4206,7 +4180,7 @@ var na = function(t, n, e, i) {
|
|
|
4206
4180
|
p.addParam("p1", "i32"), p.addParam("p2", "i32"), p.addParam("pr", "i32"), p.addLocal("z1", "i32");
|
|
4207
4181
|
const a = p.getCodeBuilder(), m = a.getLocal("p1"), c = a.i32_add(a.getLocal("p1"), a.i32_const(d));
|
|
4208
4182
|
p.addCode(a.setLocal("z1", a.i32_add(a.getLocal("p1"), a.i32_const(d * 2))));
|
|
4209
|
-
const w = a.getLocal("z1"), I = a.getLocal("p2"), h = a.i32_add(a.getLocal("p2"), a.i32_const(d)), S = a.getLocal("pr"), W = a.i32_add(a.getLocal("pr"), a.i32_const(d)), N = a.i32_add(a.getLocal("pr"), a.i32_const(d * 2)), at = a.i32_const(t.alloc(d)), It = a.i32_const(t.alloc(d)), ut = a.i32_const(t.alloc(d)), Lt = a.i32_const(t.alloc(d)), St = a.i32_const(t.alloc(d)), gt = a.i32_const(t.alloc(d)), dt = a.i32_const(t.alloc(d)), yt = a.i32_const(t.alloc(d)), vt = a.i32_const(t.alloc(d)), Ut = a.i32_const(t.alloc(d)), Vt = a.i32_const(t.alloc(d)), Dt = a.i32_const(t.alloc(d)), jt = a.i32_const(t.alloc(d)),
|
|
4183
|
+
const w = a.getLocal("z1"), I = a.getLocal("p2"), h = a.i32_add(a.getLocal("p2"), a.i32_const(d)), S = a.getLocal("pr"), W = a.i32_add(a.getLocal("pr"), a.i32_const(d)), N = a.i32_add(a.getLocal("pr"), a.i32_const(d * 2)), at = a.i32_const(t.alloc(d)), It = a.i32_const(t.alloc(d)), ut = a.i32_const(t.alloc(d)), Lt = a.i32_const(t.alloc(d)), St = a.i32_const(t.alloc(d)), gt = a.i32_const(t.alloc(d)), dt = a.i32_const(t.alloc(d)), yt = a.i32_const(t.alloc(d)), vt = a.i32_const(t.alloc(d)), Ut = a.i32_const(t.alloc(d)), Vt = a.i32_const(t.alloc(d)), Dt = a.i32_const(t.alloc(d)), jt = a.i32_const(t.alloc(d)), zt = a.i32_const(t.alloc(d));
|
|
4210
4184
|
p.addCode(
|
|
4211
4185
|
a.if(
|
|
4212
4186
|
a.call(n + "_isZero", a.getLocal("p1")),
|
|
@@ -4256,11 +4230,11 @@ var na = function(t, n, e, i) {
|
|
|
4256
4230
|
a.call(e + "_add", Dt, Dt, jt),
|
|
4257
4231
|
a.call(e + "_sub", Vt, vt, S),
|
|
4258
4232
|
a.call(e + "_sub", S, jt, S),
|
|
4259
|
-
a.call(e + "_mul", c, vt,
|
|
4260
|
-
a.call(e + "_add",
|
|
4233
|
+
a.call(e + "_mul", c, vt, zt),
|
|
4234
|
+
a.call(e + "_add", zt, zt, zt),
|
|
4261
4235
|
a.call(e + "_sub", Dt, S, W),
|
|
4262
4236
|
a.call(e + "_mul", W, Ut, W),
|
|
4263
|
-
a.call(e + "_sub", W,
|
|
4237
|
+
a.call(e + "_sub", W, zt, W),
|
|
4264
4238
|
a.call(e + "_add", w, St, N),
|
|
4265
4239
|
a.call(e + "_square", N, N),
|
|
4266
4240
|
a.call(e + "_sub", N, at, N),
|
|
@@ -4348,7 +4322,7 @@ var na = function(t, n, e, i) {
|
|
|
4348
4322
|
a.call(n + "_add", a.getLocal("p1"), m, a.getLocal("pr"))
|
|
4349
4323
|
);
|
|
4350
4324
|
}
|
|
4351
|
-
function
|
|
4325
|
+
function Q() {
|
|
4352
4326
|
const p = t.addFunction(n + "_subMixed");
|
|
4353
4327
|
p.addParam("p1", "i32"), p.addParam("p2", "i32"), p.addParam("pr", "i32");
|
|
4354
4328
|
const a = p.getCodeBuilder(), m = a.i32_const(t.alloc(d * 3));
|
|
@@ -4666,7 +4640,7 @@ var na = function(t, n, e, i) {
|
|
|
4666
4640
|
)
|
|
4667
4641
|
);
|
|
4668
4642
|
}
|
|
4669
|
-
return b(), r(), B(), C(), l(), u(), it(),
|
|
4643
|
+
return b(), r(), B(), C(), l(), u(), it(), z(), O(), A(), E(), P(), L(), f(), F(), $(), V(), y(), Q(), X(), rt(), T(), ot(), x(), D(), Bt(), pt(), nt(), v(), K(), J(), ct(), st(), At(), kn(t, n + "_batchLEMtoU", n + "_LEMtoU", d * 2, d * 2), kn(t, n + "_batchLEMtoC", n + "_LEMtoC", d * 2, d), kn(t, n + "_batchUtoLEM", n + "_UtoLEM", d * 2, d * 2), kn(t, n + "_batchCtoLEM", n + "_CtoLEM", d, d * 2, !0), kn(t, n + "_batchToJacobian", n + "_toJacobian", d * 2, d * 3, !0), To(t, n, n + "_multiexp", n + "_add", d * 3), To(t, n, n + "_multiexpAffine", n + "_addMixed", d * 2), zo(
|
|
4670
4644
|
t,
|
|
4671
4645
|
n + "_timesScalar",
|
|
4672
4646
|
d * 3,
|
|
@@ -4675,7 +4649,7 @@ var na = function(t, n, e, i) {
|
|
|
4675
4649
|
n + "_sub",
|
|
4676
4650
|
n + "_copy",
|
|
4677
4651
|
n + "_zero"
|
|
4678
|
-
),
|
|
4652
|
+
), zo(
|
|
4679
4653
|
t,
|
|
4680
4654
|
n + "_timesScalarAffine",
|
|
4681
4655
|
d * 2,
|
|
@@ -4700,24 +4674,24 @@ var ea = function(t, n, e, i, s) {
|
|
|
4700
4674
|
let P = B - 1;
|
|
4701
4675
|
for (; P >= 0; )
|
|
4702
4676
|
O[P] = Nn(O[P + 1], 2n, l), P--;
|
|
4703
|
-
const E = [],
|
|
4677
|
+
const E = [], z = (1n << BigInt(r * 8)) % l;
|
|
4704
4678
|
for (let m = 0; m < O.length; m++) {
|
|
4705
|
-
const c = O[m] *
|
|
4679
|
+
const c = O[m] * z % l;
|
|
4706
4680
|
E.push(...le.bigInt2BytesLE(c, r));
|
|
4707
4681
|
}
|
|
4708
4682
|
const x = t.alloc(E), ot = new Array(B + 1);
|
|
4709
4683
|
ot[0] = 1n;
|
|
4710
4684
|
for (let m = 1; m <= B; m++)
|
|
4711
4685
|
ot[m] = ot[m - 1] * 2n;
|
|
4712
|
-
const
|
|
4686
|
+
const T = [];
|
|
4713
4687
|
for (let m = 0; m <= B; m++) {
|
|
4714
|
-
const c = Ro(ot[m], l) *
|
|
4715
|
-
|
|
4688
|
+
const c = Ro(ot[m], l) * z % l;
|
|
4689
|
+
T.push(...le.bigInt2BytesLE(c, r));
|
|
4716
4690
|
}
|
|
4717
|
-
const rt = t.alloc(
|
|
4691
|
+
const rt = t.alloc(T), F = Nn(A, 2n, l), f = [], L = [];
|
|
4718
4692
|
for (let m = 0; m <= B; m++) {
|
|
4719
4693
|
const c = Nn(F, 2n ** BigInt(m), l), w = Ro(l + 1n - c, l);
|
|
4720
|
-
f.push(...le.bigInt2BytesLE(c *
|
|
4694
|
+
f.push(...le.bigInt2BytesLE(c * z % l, r)), L.push(...le.bigInt2BytesLE(w * z % l, r));
|
|
4721
4695
|
}
|
|
4722
4696
|
const V = t.alloc(f), $ = t.alloc(L);
|
|
4723
4697
|
function X(m) {
|
|
@@ -4726,10 +4700,10 @@ var ea = function(t, n, e, i, s) {
|
|
|
4726
4700
|
m & 1 << w && (c = c | 128 >> w);
|
|
4727
4701
|
return c;
|
|
4728
4702
|
}
|
|
4729
|
-
const
|
|
4703
|
+
const Q = Array(256);
|
|
4730
4704
|
for (let m = 0; m < 256; m++)
|
|
4731
|
-
|
|
4732
|
-
const y = t.alloc(
|
|
4705
|
+
Q[m] = X(m);
|
|
4706
|
+
const y = t.alloc(Q);
|
|
4733
4707
|
function v() {
|
|
4734
4708
|
const m = t.addFunction(n + "__log2");
|
|
4735
4709
|
m.addParam("n", "i32"), m.setReturnType("i32"), m.addLocal("bits", "i32"), m.addLocal("aux", "i32");
|
|
@@ -6116,29 +6090,29 @@ var hs = function(t, n) {
|
|
|
6116
6090
|
return e;
|
|
6117
6091
|
const i = 21888242871839275222246405745257275088696311157297823662689037894645226208583n, s = 21888242871839275222246405745257275088548364400416034343698204186575808495617n, d = Math.floor((_s(i - 1n) - 1) / 64) + 1, r = d * 8, b = r, u = r, l = u * 2, C = u * 12, B = t.alloc(xt.bigInt2BytesLE(s, b)), A = ss(t, i, "f1m");
|
|
6118
6092
|
ls(t, s, "fr", "frm");
|
|
6119
|
-
const O = t.alloc(xt.bigInt2BytesLE(
|
|
6093
|
+
const O = t.alloc(xt.bigInt2BytesLE(T(3n), u)), P = ko(t, "g1m", "f1m", O);
|
|
6120
6094
|
Pe(t, "frm", "frm", "frm", "frm_mul"), ds(t, "pol", "frm"), us(t, "qap", "frm");
|
|
6121
|
-
const E = Do(t, "f1m_neg", "f2m", "f1m"),
|
|
6122
|
-
...xt.bigInt2BytesLE(
|
|
6123
|
-
...xt.bigInt2BytesLE(
|
|
6124
|
-
]), x = ko(t, "g2m", "f2m",
|
|
6095
|
+
const E = Do(t, "f1m_neg", "f2m", "f1m"), z = t.alloc([
|
|
6096
|
+
...xt.bigInt2BytesLE(T(19485874751759354771024239261021720505790618469301721065564631296452457478373n), u),
|
|
6097
|
+
...xt.bigInt2BytesLE(T(266929791119991161246907387137283842545076965332900288569378510910307636690n), u)
|
|
6098
|
+
]), x = ko(t, "g2m", "f2m", z);
|
|
6125
6099
|
function ot(G, _) {
|
|
6126
6100
|
const g = t.addFunction(G);
|
|
6127
6101
|
g.addParam("pG", "i32"), g.addParam("pFr", "i32"), g.addParam("pr", "i32");
|
|
6128
|
-
const
|
|
6102
|
+
const M = g.getCodeBuilder(), R = M.i32_const(t.alloc(r));
|
|
6129
6103
|
g.addCode(
|
|
6130
|
-
|
|
6131
|
-
|
|
6104
|
+
M.call("frm_fromMontgomery", M.getLocal("pFr"), R),
|
|
6105
|
+
M.call(
|
|
6132
6106
|
_,
|
|
6133
|
-
|
|
6107
|
+
M.getLocal("pG"),
|
|
6134
6108
|
R,
|
|
6135
|
-
|
|
6136
|
-
|
|
6109
|
+
M.i32_const(r),
|
|
6110
|
+
M.getLocal("pr")
|
|
6137
6111
|
)
|
|
6138
6112
|
), t.exportFunction(G);
|
|
6139
6113
|
}
|
|
6140
6114
|
ot("g1m_timesFr", "g1m_timesScalar"), Pe(t, "g1m", "g1m", "frm", "g1m_timesFr"), ot("g2m_timesFr", "g2m_timesScalar"), Pe(t, "g2m", "g2m", "frm", "g2m_timesFr"), ot("g1m_timesFrAffine", "g1m_timesScalarAffine"), ot("g2m_timesFrAffine", "g2m_timesScalarAffine"), Gn(t, "frm_batchApplyKey", "fmr", "frm", r, r, r, "frm_mul"), Gn(t, "g1m_batchApplyKey", "g1m", "frm", r * 3, r * 3, r, "g1m_timesFr"), Gn(t, "g1m_batchApplyKeyMixed", "g1m", "frm", r * 2, r * 3, r, "g1m_timesFrAffine"), Gn(t, "g2m_batchApplyKey", "g2m", "frm", r * 2 * 3, r * 3 * 2, r, "g2m_timesFr"), Gn(t, "g2m_batchApplyKeyMixed", "g2m", "frm", r * 2 * 2, r * 3 * 2, r, "g2m_timesFrAffine");
|
|
6141
|
-
function
|
|
6115
|
+
function T(G) {
|
|
6142
6116
|
return BigInt(G) * (1n << BigInt(u * 8)) % i;
|
|
6143
6117
|
}
|
|
6144
6118
|
const rt = [
|
|
@@ -6147,9 +6121,9 @@ var hs = function(t, n) {
|
|
|
6147
6121
|
1n
|
|
6148
6122
|
], F = t.alloc(
|
|
6149
6123
|
[
|
|
6150
|
-
...xt.bigInt2BytesLE(
|
|
6151
|
-
...xt.bigInt2BytesLE(
|
|
6152
|
-
...xt.bigInt2BytesLE(
|
|
6124
|
+
...xt.bigInt2BytesLE(T(rt[0]), u),
|
|
6125
|
+
...xt.bigInt2BytesLE(T(rt[1]), u),
|
|
6126
|
+
...xt.bigInt2BytesLE(T(rt[2]), u)
|
|
6153
6127
|
]
|
|
6154
6128
|
), f = [
|
|
6155
6129
|
0n,
|
|
@@ -6157,9 +6131,9 @@ var hs = function(t, n) {
|
|
|
6157
6131
|
0n
|
|
6158
6132
|
], L = t.alloc(
|
|
6159
6133
|
[
|
|
6160
|
-
...xt.bigInt2BytesLE(
|
|
6161
|
-
...xt.bigInt2BytesLE(
|
|
6162
|
-
...xt.bigInt2BytesLE(
|
|
6134
|
+
...xt.bigInt2BytesLE(T(f[0]), u),
|
|
6135
|
+
...xt.bigInt2BytesLE(T(f[1]), u),
|
|
6136
|
+
...xt.bigInt2BytesLE(T(f[2]), u)
|
|
6163
6137
|
]
|
|
6164
6138
|
), V = [
|
|
6165
6139
|
[
|
|
@@ -6176,12 +6150,12 @@ var hs = function(t, n) {
|
|
|
6176
6150
|
]
|
|
6177
6151
|
], $ = t.alloc(
|
|
6178
6152
|
[
|
|
6179
|
-
...xt.bigInt2BytesLE(
|
|
6180
|
-
...xt.bigInt2BytesLE(
|
|
6181
|
-
...xt.bigInt2BytesLE(
|
|
6182
|
-
...xt.bigInt2BytesLE(
|
|
6183
|
-
...xt.bigInt2BytesLE(
|
|
6184
|
-
...xt.bigInt2BytesLE(
|
|
6153
|
+
...xt.bigInt2BytesLE(T(V[0][0]), u),
|
|
6154
|
+
...xt.bigInt2BytesLE(T(V[0][1]), u),
|
|
6155
|
+
...xt.bigInt2BytesLE(T(V[1][0]), u),
|
|
6156
|
+
...xt.bigInt2BytesLE(T(V[1][1]), u),
|
|
6157
|
+
...xt.bigInt2BytesLE(T(V[2][0]), u),
|
|
6158
|
+
...xt.bigInt2BytesLE(T(V[2][1]), u)
|
|
6185
6159
|
]
|
|
6186
6160
|
), X = [
|
|
6187
6161
|
[
|
|
@@ -6196,37 +6170,37 @@ var hs = function(t, n) {
|
|
|
6196
6170
|
0n,
|
|
6197
6171
|
0n
|
|
6198
6172
|
]
|
|
6199
|
-
],
|
|
6173
|
+
], Q = t.alloc(
|
|
6200
6174
|
[
|
|
6201
|
-
...xt.bigInt2BytesLE(
|
|
6202
|
-
...xt.bigInt2BytesLE(
|
|
6203
|
-
...xt.bigInt2BytesLE(
|
|
6204
|
-
...xt.bigInt2BytesLE(
|
|
6205
|
-
...xt.bigInt2BytesLE(
|
|
6206
|
-
...xt.bigInt2BytesLE(
|
|
6175
|
+
...xt.bigInt2BytesLE(T(X[0][0]), u),
|
|
6176
|
+
...xt.bigInt2BytesLE(T(X[0][1]), u),
|
|
6177
|
+
...xt.bigInt2BytesLE(T(X[1][0]), u),
|
|
6178
|
+
...xt.bigInt2BytesLE(T(X[1][1]), u),
|
|
6179
|
+
...xt.bigInt2BytesLE(T(X[2][0]), u),
|
|
6180
|
+
...xt.bigInt2BytesLE(T(X[2][1]), u)
|
|
6207
6181
|
]
|
|
6208
6182
|
), y = t.alloc([
|
|
6209
|
-
...xt.bigInt2BytesLE(
|
|
6210
|
-
...xt.bigInt2BytesLE(
|
|
6211
|
-
...xt.bigInt2BytesLE(
|
|
6212
|
-
...xt.bigInt2BytesLE(
|
|
6213
|
-
...xt.bigInt2BytesLE(
|
|
6214
|
-
...xt.bigInt2BytesLE(
|
|
6215
|
-
...xt.bigInt2BytesLE(
|
|
6216
|
-
...xt.bigInt2BytesLE(
|
|
6217
|
-
...xt.bigInt2BytesLE(
|
|
6218
|
-
...xt.bigInt2BytesLE(
|
|
6219
|
-
...xt.bigInt2BytesLE(
|
|
6220
|
-
...xt.bigInt2BytesLE(
|
|
6183
|
+
...xt.bigInt2BytesLE(T(1), u),
|
|
6184
|
+
...xt.bigInt2BytesLE(T(0), u),
|
|
6185
|
+
...xt.bigInt2BytesLE(T(0), u),
|
|
6186
|
+
...xt.bigInt2BytesLE(T(0), u),
|
|
6187
|
+
...xt.bigInt2BytesLE(T(0), u),
|
|
6188
|
+
...xt.bigInt2BytesLE(T(0), u),
|
|
6189
|
+
...xt.bigInt2BytesLE(T(0), u),
|
|
6190
|
+
...xt.bigInt2BytesLE(T(0), u),
|
|
6191
|
+
...xt.bigInt2BytesLE(T(0), u),
|
|
6192
|
+
...xt.bigInt2BytesLE(T(0), u),
|
|
6193
|
+
...xt.bigInt2BytesLE(T(0), u),
|
|
6194
|
+
...xt.bigInt2BytesLE(T(0), u)
|
|
6221
6195
|
]), v = t.alloc([
|
|
6222
|
-
...xt.bigInt2BytesLE(
|
|
6223
|
-
...xt.bigInt2BytesLE(
|
|
6196
|
+
...xt.bigInt2BytesLE(T(9), u),
|
|
6197
|
+
...xt.bigInt2BytesLE(T(1), u)
|
|
6224
6198
|
]), D = t.alloc([
|
|
6225
|
-
...xt.bigInt2BytesLE(
|
|
6199
|
+
...xt.bigInt2BytesLE(T(gs(2n, i)), u),
|
|
6226
6200
|
...xt.bigInt2BytesLE(0n, u)
|
|
6227
6201
|
]), it = v, nt = t.alloc([
|
|
6228
|
-
...xt.bigInt2BytesLE(
|
|
6229
|
-
...xt.bigInt2BytesLE(
|
|
6202
|
+
...xt.bigInt2BytesLE(T(19485874751759354771024239261021720505790618469301721065564631296452457478373n), u),
|
|
6203
|
+
...xt.bigInt2BytesLE(T(266929791119991161246907387137283842545076965332900288569378510910307636690n), u)
|
|
6230
6204
|
]);
|
|
6231
6205
|
function K() {
|
|
6232
6206
|
const G = t.addFunction(e + "_mulNR6");
|
|
@@ -6274,8 +6248,8 @@ var hs = function(t, n) {
|
|
|
6274
6248
|
pG1zero: L,
|
|
6275
6249
|
pG1b: O,
|
|
6276
6250
|
pG2gen: $,
|
|
6277
|
-
pG2zero:
|
|
6278
|
-
pG2b:
|
|
6251
|
+
pG2zero: Q,
|
|
6252
|
+
pG2b: z,
|
|
6279
6253
|
pq: t.modules.f1m.pq,
|
|
6280
6254
|
pr: B,
|
|
6281
6255
|
pOneT: y,
|
|
@@ -6290,8 +6264,8 @@ var hs = function(t, n) {
|
|
|
6290
6264
|
const g = [];
|
|
6291
6265
|
for (; _ > 0n; ) {
|
|
6292
6266
|
if (No(_)) {
|
|
6293
|
-
const
|
|
6294
|
-
g.push(
|
|
6267
|
+
const M = 2 - Number(_ % 4n);
|
|
6268
|
+
g.push(M), _ = _ - BigInt(M);
|
|
6295
6269
|
} else
|
|
6296
6270
|
g.push(0);
|
|
6297
6271
|
_ = _ >> 1n;
|
|
@@ -6317,13 +6291,13 @@ var hs = function(t, n) {
|
|
|
6317
6291
|
function at() {
|
|
6318
6292
|
const G = t.addFunction(e + "_prepAddStep");
|
|
6319
6293
|
G.addParam("pQ", "i32"), G.addParam("pR", "i32"), G.addParam("pCoef", "i32");
|
|
6320
|
-
const _ = G.getCodeBuilder(), g = _.getLocal("pQ"),
|
|
6294
|
+
const _ = G.getCodeBuilder(), g = _.getLocal("pQ"), M = _.i32_add(_.getLocal("pQ"), _.i32_const(l)), R = _.getLocal("pR"), q = _.i32_add(_.getLocal("pR"), _.i32_const(l)), k = _.i32_add(_.getLocal("pR"), _.i32_const(2 * l)), U = _.getLocal("pCoef"), j = _.i32_add(_.getLocal("pCoef"), _.i32_const(l)), Y = _.i32_add(_.getLocal("pCoef"), _.i32_const(2 * l)), Z = j, H = _.i32_const(t.alloc(l)), et = _.i32_const(t.alloc(l)), ft = _.i32_const(t.alloc(l)), _t = _.i32_const(t.alloc(l)), lt = _.i32_const(t.alloc(l)), bt = _.i32_const(t.alloc(l)), mt = _.i32_const(t.alloc(l));
|
|
6321
6295
|
G.addCode(
|
|
6322
6296
|
// D = X1 - X2*Z1
|
|
6323
6297
|
_.call(E + "_mul", g, k, Z),
|
|
6324
6298
|
_.call(E + "_sub", R, Z, Z),
|
|
6325
6299
|
// E = Y1 - Y2*Z1
|
|
6326
|
-
_.call(E + "_mul",
|
|
6300
|
+
_.call(E + "_mul", M, k, H),
|
|
6327
6301
|
_.call(E + "_sub", q, H, H),
|
|
6328
6302
|
// F = D^2
|
|
6329
6303
|
_.call(E + "_square", Z, et),
|
|
@@ -6348,7 +6322,7 @@ var hs = function(t, n) {
|
|
|
6348
6322
|
// Z3 (Z1) = Z1*H
|
|
6349
6323
|
_.call(E + "_mul", k, _t, k),
|
|
6350
6324
|
// ell_0 = xi * (E * X2 - D * Y2)
|
|
6351
|
-
_.call(E + "_mul", Z,
|
|
6325
|
+
_.call(E + "_mul", Z, M, mt),
|
|
6352
6326
|
_.call(E + "_mul", H, g, U),
|
|
6353
6327
|
_.call(E + "_sub", U, mt, U),
|
|
6354
6328
|
_.call(E + "_mul", U, _.i32_const(it), U),
|
|
@@ -6361,13 +6335,13 @@ var hs = function(t, n) {
|
|
|
6361
6335
|
function It() {
|
|
6362
6336
|
const G = t.addFunction(e + "_prepDblStep");
|
|
6363
6337
|
G.addParam("pR", "i32"), G.addParam("pCoef", "i32");
|
|
6364
|
-
const _ = G.getCodeBuilder(), g = _.getLocal("pR"),
|
|
6338
|
+
const _ = G.getCodeBuilder(), g = _.getLocal("pR"), M = _.i32_add(_.getLocal("pR"), _.i32_const(l)), R = _.i32_add(_.getLocal("pR"), _.i32_const(2 * l)), q = _.getLocal("pCoef"), k = _.i32_add(_.getLocal("pCoef"), _.i32_const(l)), U = _.i32_add(_.getLocal("pCoef"), _.i32_const(2 * l)), j = _.i32_const(t.alloc(l)), Y = _.i32_const(t.alloc(l)), Z = _.i32_const(t.alloc(l)), H = _.i32_const(t.alloc(l)), et = _.i32_const(t.alloc(l)), ft = _.i32_const(t.alloc(l)), _t = _.i32_const(t.alloc(l)), lt = _.i32_const(t.alloc(l)), bt = _.i32_const(t.alloc(l)), mt = _.i32_const(t.alloc(l)), Ot = _.i32_const(t.alloc(l)), Ct = _.i32_const(t.alloc(l));
|
|
6365
6339
|
G.addCode(
|
|
6366
6340
|
// A = X1 * Y1 / 2
|
|
6367
|
-
_.call(E + "_mul",
|
|
6341
|
+
_.call(E + "_mul", M, _.i32_const(D), j),
|
|
6368
6342
|
_.call(E + "_mul", g, j, j),
|
|
6369
6343
|
// B = Y1^2
|
|
6370
|
-
_.call(E + "_square",
|
|
6344
|
+
_.call(E + "_square", M, Y),
|
|
6371
6345
|
// C = Z1^2
|
|
6372
6346
|
_.call(E + "_square", R, Z),
|
|
6373
6347
|
// D = 3 * C
|
|
@@ -6383,7 +6357,7 @@ var hs = function(t, n) {
|
|
|
6383
6357
|
_.call(E + "_mul", _t, _.i32_const(D), _t),
|
|
6384
6358
|
// H = (Y1+Z1)^2-(B+C)
|
|
6385
6359
|
_.call(E + "_add", Y, Z, Ct),
|
|
6386
|
-
_.call(E + "_add",
|
|
6360
|
+
_.call(E + "_add", M, R, lt),
|
|
6387
6361
|
_.call(E + "_square", lt, lt),
|
|
6388
6362
|
_.call(E + "_sub", lt, Ct, lt),
|
|
6389
6363
|
// I = E-B
|
|
@@ -6398,8 +6372,8 @@ var hs = function(t, n) {
|
|
|
6398
6372
|
// Y3 (Y1) = G^2 - 3*E^2
|
|
6399
6373
|
_.call(E + "_add", Ot, Ot, Ct),
|
|
6400
6374
|
_.call(E + "_add", Ot, Ct, Ct),
|
|
6401
|
-
_.call(E + "_square", _t,
|
|
6402
|
-
_.call(E + "_sub",
|
|
6375
|
+
_.call(E + "_square", _t, M),
|
|
6376
|
+
_.call(E + "_sub", M, Ct, M),
|
|
6403
6377
|
// Z3 (Z1) = B * H
|
|
6404
6378
|
_.call(E + "_mul", Y, lt, R),
|
|
6405
6379
|
// ell_0 = xi * I
|
|
@@ -6414,18 +6388,18 @@ var hs = function(t, n) {
|
|
|
6414
6388
|
function ut() {
|
|
6415
6389
|
const G = t.addFunction(e + "_mulByQ");
|
|
6416
6390
|
G.addParam("p1", "i32"), G.addParam("pr", "i32");
|
|
6417
|
-
const _ = G.getCodeBuilder(), g = _.getLocal("p1"),
|
|
6418
|
-
...xt.bigInt2BytesLE(
|
|
6419
|
-
...xt.bigInt2BytesLE(
|
|
6391
|
+
const _ = G.getCodeBuilder(), g = _.getLocal("p1"), M = _.i32_add(_.getLocal("p1"), _.i32_const(l)), R = _.i32_add(_.getLocal("p1"), _.i32_const(l * 2)), q = _.getLocal("pr"), k = _.i32_add(_.getLocal("pr"), _.i32_const(l)), U = _.i32_add(_.getLocal("pr"), _.i32_const(l * 2)), j = _.i32_const(t.alloc([
|
|
6392
|
+
...xt.bigInt2BytesLE(T("21575463638280843010398324269430826099269044274347216827212613867836435027261"), u),
|
|
6393
|
+
...xt.bigInt2BytesLE(T("10307601595873709700152284273816112264069230130616436755625194854815875713954"), u)
|
|
6420
6394
|
])), Y = _.i32_const(t.alloc([
|
|
6421
|
-
...xt.bigInt2BytesLE(
|
|
6422
|
-
...xt.bigInt2BytesLE(
|
|
6395
|
+
...xt.bigInt2BytesLE(T("2821565182194536844548159561693502659359617185244120367078079554186484126554"), u),
|
|
6396
|
+
...xt.bigInt2BytesLE(T("3505843767911556378687030309984248845540243509899259641013678093033130930403"), u)
|
|
6423
6397
|
]));
|
|
6424
6398
|
G.addCode(
|
|
6425
6399
|
// The frobeniusMap(1) in this field, is the conjugate
|
|
6426
6400
|
_.call(E + "_conjugate", g, q),
|
|
6427
6401
|
_.call(E + "_mul", j, q, q),
|
|
6428
|
-
_.call(E + "_conjugate",
|
|
6402
|
+
_.call(E + "_conjugate", M, k),
|
|
6429
6403
|
_.call(E + "_mul", Y, k, k),
|
|
6430
6404
|
_.call(E + "_conjugate", R, U)
|
|
6431
6405
|
);
|
|
@@ -6434,7 +6408,7 @@ var hs = function(t, n) {
|
|
|
6434
6408
|
ut();
|
|
6435
6409
|
const G = t.addFunction(e + "_prepareG2");
|
|
6436
6410
|
G.addParam("pQ", "i32"), G.addParam("ppreQ", "i32"), G.addLocal("pCoef", "i32"), G.addLocal("i", "i32");
|
|
6437
|
-
const _ = G.getCodeBuilder(), g = _.getLocal("pQ"),
|
|
6411
|
+
const _ = G.getCodeBuilder(), g = _.getLocal("pQ"), M = t.alloc(l * 3), R = _.i32_const(M), q = _.i32_const(M), k = _.i32_const(M + l), U = _.i32_const(M + 2 * l), j = _.i32_add(_.getLocal("ppreQ"), _.i32_const(0)), Y = _.i32_add(_.getLocal("ppreQ"), _.i32_const(l)), Z = t.alloc(l * 3), H = _.i32_const(Z), et = t.alloc(l * 3), ft = _.i32_const(et), _t = _.i32_const(et + l);
|
|
6438
6412
|
G.addCode(
|
|
6439
6413
|
_.call(x + "_normalize", g, j),
|
|
6440
6414
|
// TODO Remove if already in affine
|
|
@@ -6472,11 +6446,11 @@ var hs = function(t, n) {
|
|
|
6472
6446
|
function St() {
|
|
6473
6447
|
const G = t.addFunction(e + "__mulBy024Old");
|
|
6474
6448
|
G.addParam("pEll0", "i32"), G.addParam("pEllVW", "i32"), G.addParam("pEllVV", "i32"), G.addParam("pR", "i32");
|
|
6475
|
-
const _ = G.getCodeBuilder(), g = _.getLocal("pEll0"),
|
|
6449
|
+
const _ = G.getCodeBuilder(), g = _.getLocal("pEll0"), M = _.getLocal("pEllVV"), R = _.getLocal("pEllVW"), q = _.getLocal("pR"), k = t.alloc(C), U = _.i32_const(k), j = _.i32_const(k), Y = _.i32_const(k + l), Z = _.i32_const(k + l * 2), H = _.i32_const(k + l * 3), et = _.i32_const(k + l * 4), ft = _.i32_const(k + l * 5);
|
|
6476
6450
|
G.addCode(
|
|
6477
6451
|
_.call(E + "_copy", g, j),
|
|
6478
6452
|
_.call(E + "_zero", Y),
|
|
6479
|
-
_.call(E + "_copy",
|
|
6453
|
+
_.call(E + "_copy", M, Z),
|
|
6480
6454
|
_.call(E + "_zero", H),
|
|
6481
6455
|
_.call(E + "_copy", R, et),
|
|
6482
6456
|
_.call(E + "_zero", ft),
|
|
@@ -6486,12 +6460,12 @@ var hs = function(t, n) {
|
|
|
6486
6460
|
function gt() {
|
|
6487
6461
|
const G = t.addFunction(e + "__mulBy024");
|
|
6488
6462
|
G.addParam("pEll0", "i32"), G.addParam("pEllVW", "i32"), G.addParam("pEllVV", "i32"), G.addParam("pR", "i32");
|
|
6489
|
-
const _ = G.getCodeBuilder(), g = _.getLocal("pEll0"),
|
|
6463
|
+
const _ = G.getCodeBuilder(), g = _.getLocal("pEll0"), M = _.getLocal("pEllVV"), R = _.getLocal("pEllVW"), q = _.getLocal("pR"), k = _.i32_add(_.getLocal("pR"), _.i32_const(2 * r)), U = _.i32_add(_.getLocal("pR"), _.i32_const(4 * r)), j = _.i32_add(_.getLocal("pR"), _.i32_const(6 * r)), Y = _.i32_add(_.getLocal("pR"), _.i32_const(8 * r)), Z = _.i32_add(_.getLocal("pR"), _.i32_const(10 * r)), H = _.i32_const(t.alloc(l)), et = _.i32_const(t.alloc(l)), ft = _.i32_const(t.alloc(l)), _t = _.i32_const(t.alloc(l)), lt = _.i32_const(t.alloc(l)), bt = _.i32_const(t.alloc(l)), mt = _.i32_const(t.alloc(l)), Ot = _.i32_const(t.alloc(l)), Ct = _.i32_const(t.alloc(l)), wt = _.i32_const(t.alloc(l)), ht = _.i32_const(t.alloc(l));
|
|
6490
6464
|
G.addCode(
|
|
6491
6465
|
// D0 = z0 * x0;
|
|
6492
6466
|
_.call(E + "_mul", q, g, mt),
|
|
6493
6467
|
// D2 = z2 * x2;
|
|
6494
|
-
_.call(E + "_mul", U,
|
|
6468
|
+
_.call(E + "_mul", U, M, Ot),
|
|
6495
6469
|
// D4 = z4 * x4;
|
|
6496
6470
|
_.call(E + "_mul", Y, R, Ct),
|
|
6497
6471
|
// t2 = z0 + z4;
|
|
@@ -6503,7 +6477,7 @@ var hs = function(t, n) {
|
|
|
6503
6477
|
_.call(E + "_add", _t, Z, _t),
|
|
6504
6478
|
// For z.a_.a_ = z0.
|
|
6505
6479
|
// S1 = z1 * x2;
|
|
6506
|
-
_.call(E + "_mul", k,
|
|
6480
|
+
_.call(E + "_mul", k, M, wt),
|
|
6507
6481
|
// T3 = S1 + D4;
|
|
6508
6482
|
_.call(E + "_add", wt, Ct, lt),
|
|
6509
6483
|
// T4 = my_Fp6::non_residue * T3 + D0;
|
|
@@ -6528,7 +6502,7 @@ var hs = function(t, n) {
|
|
|
6528
6502
|
// z1 = T4;
|
|
6529
6503
|
// For z.a_.c_ = z2
|
|
6530
6504
|
// t0 = x0 + x2;
|
|
6531
|
-
_.call(E + "_add", g,
|
|
6505
|
+
_.call(E + "_add", g, M, H),
|
|
6532
6506
|
// T3 = t1 * t0 - D0 - D2;
|
|
6533
6507
|
_.call(E + "_mul", et, H, lt),
|
|
6534
6508
|
_.call(E + "_add", mt, Ot, ht),
|
|
@@ -6544,7 +6518,7 @@ var hs = function(t, n) {
|
|
|
6544
6518
|
// z2 = T3;
|
|
6545
6519
|
_.call(E + "_add", lt, bt, U),
|
|
6546
6520
|
// t1 = x2 + x4;
|
|
6547
|
-
_.call(E + "_add",
|
|
6521
|
+
_.call(E + "_add", M, R, et),
|
|
6548
6522
|
// T3 = t0 * t1 - D2 - D4;
|
|
6549
6523
|
_.call(E + "_mul", et, H, lt),
|
|
6550
6524
|
_.call(E + "_add", Ot, Ct, ht),
|
|
@@ -6560,7 +6534,7 @@ var hs = function(t, n) {
|
|
|
6560
6534
|
// z3 = T4;
|
|
6561
6535
|
// For z.b_.b_ = z4
|
|
6562
6536
|
// T3 = z5 * x2;
|
|
6563
|
-
_.call(E + "_mul", Z,
|
|
6537
|
+
_.call(E + "_mul", Z, M, lt),
|
|
6564
6538
|
// S1 = S1 + T3;
|
|
6565
6539
|
_.call(E + "_add", wt, lt, wt),
|
|
6566
6540
|
// T4 = my_Fp6::non_residue * T3;
|
|
@@ -6576,7 +6550,7 @@ var hs = function(t, n) {
|
|
|
6576
6550
|
// z4 = T4;
|
|
6577
6551
|
// For z.b_.c_ = z5.
|
|
6578
6552
|
// t0 = x0 + x2 + x4;
|
|
6579
|
-
_.call(E + "_add", g,
|
|
6553
|
+
_.call(E + "_add", g, M, H),
|
|
6580
6554
|
_.call(E + "_add", H, R, H),
|
|
6581
6555
|
// T3 = s0 * t0 - S1;
|
|
6582
6556
|
_.call(E + "_mul", _t, H, lt),
|
|
@@ -6587,21 +6561,21 @@ var hs = function(t, n) {
|
|
|
6587
6561
|
function dt() {
|
|
6588
6562
|
const G = t.addFunction(e + "_millerLoop");
|
|
6589
6563
|
G.addParam("ppreP", "i32"), G.addParam("ppreQ", "i32"), G.addParam("r", "i32"), G.addLocal("pCoef", "i32"), G.addLocal("i", "i32");
|
|
6590
|
-
const _ = G.getCodeBuilder(), g = _.getLocal("ppreP"),
|
|
6564
|
+
const _ = G.getCodeBuilder(), g = _.getLocal("ppreP"), M = _.i32_add(_.getLocal("ppreP"), _.i32_const(u)), R = _.getLocal("pCoef"), q = _.i32_add(_.getLocal("pCoef"), _.i32_const(l)), k = _.i32_add(_.getLocal("pCoef"), _.i32_const(2 * l)), U = t.alloc(l), j = _.i32_const(U), Y = t.alloc(l), Z = _.i32_const(Y), H = _.getLocal("r");
|
|
6591
6565
|
G.addCode(
|
|
6592
6566
|
_.call(st + "_one", H),
|
|
6593
6567
|
_.setLocal("pCoef", _.i32_add(_.getLocal("ppreQ"), _.i32_const(l * 3))),
|
|
6594
6568
|
_.setLocal("i", _.i32_const(Bt.length - 2)),
|
|
6595
6569
|
_.block(_.loop(
|
|
6596
6570
|
_.call(st + "_square", H, H),
|
|
6597
|
-
_.call(E + "_mul1", q,
|
|
6571
|
+
_.call(E + "_mul1", q, M, j),
|
|
6598
6572
|
_.call(E + "_mul1", k, g, Z),
|
|
6599
6573
|
_.call(e + "__mulBy024", R, j, Z, H),
|
|
6600
6574
|
_.setLocal("pCoef", _.i32_add(_.getLocal("pCoef"), _.i32_const(p))),
|
|
6601
6575
|
_.if(
|
|
6602
6576
|
_.i32_load8_s(_.getLocal("i"), pt),
|
|
6603
6577
|
[
|
|
6604
|
-
..._.call(E + "_mul1", q,
|
|
6578
|
+
..._.call(E + "_mul1", q, M, j),
|
|
6605
6579
|
..._.call(E + "_mul1", k, g, Z),
|
|
6606
6580
|
..._.call(e + "__mulBy024", R, j, Z, H),
|
|
6607
6581
|
..._.setLocal("pCoef", _.i32_add(_.getLocal("pCoef"), _.i32_const(p)))
|
|
@@ -6612,11 +6586,11 @@ var hs = function(t, n) {
|
|
|
6612
6586
|
_.br(0)
|
|
6613
6587
|
))
|
|
6614
6588
|
), G.addCode(
|
|
6615
|
-
_.call(E + "_mul1", q,
|
|
6589
|
+
_.call(E + "_mul1", q, M, j),
|
|
6616
6590
|
_.call(E + "_mul1", k, g, Z),
|
|
6617
6591
|
_.call(e + "__mulBy024", R, j, Z, H),
|
|
6618
6592
|
_.setLocal("pCoef", _.i32_add(_.getLocal("pCoef"), _.i32_const(p))),
|
|
6619
|
-
_.call(E + "_mul1", q,
|
|
6593
|
+
_.call(E + "_mul1", q, M, j),
|
|
6620
6594
|
_.call(E + "_mul1", k, g, Z),
|
|
6621
6595
|
_.call(e + "__mulBy024", R, j, Z, H),
|
|
6622
6596
|
_.setLocal("pCoef", _.i32_add(_.getLocal("pCoef"), _.i32_const(p)))
|
|
@@ -6677,19 +6651,19 @@ var hs = function(t, n) {
|
|
|
6677
6651
|
[21888242871839275220042445260109153167277707414472061641714758635765020556616n, 0n],
|
|
6678
6652
|
[13981852324922362344252311234282257507216387789820983642040889267519694726527n, 7629828391165209371577384193250820201684255241773809077146787135900891633097n]
|
|
6679
6653
|
]
|
|
6680
|
-
],
|
|
6681
|
-
|
|
6682
|
-
const R =
|
|
6654
|
+
], M = t.addFunction(e + "__frobeniusMap" + G);
|
|
6655
|
+
M.addParam("x", "i32"), M.addParam("r", "i32");
|
|
6656
|
+
const R = M.getCodeBuilder();
|
|
6683
6657
|
for (let k = 0; k < 6; k++) {
|
|
6684
6658
|
const U = k == 0 ? R.getLocal("x") : R.i32_add(R.getLocal("x"), R.i32_const(k * l)), j = U, Y = R.i32_add(R.getLocal("x"), R.i32_const(k * l + u)), Z = k == 0 ? R.getLocal("r") : R.i32_add(R.getLocal("r"), R.i32_const(k * l)), H = Z, et = R.i32_add(R.getLocal("r"), R.i32_const(k * l + u)), ft = q(_[Math.floor(k / 3)][G % 12], g[k % 3][G % 6]), _t = t.alloc([
|
|
6685
|
-
...xt.bigInt2BytesLE(
|
|
6686
|
-
...xt.bigInt2BytesLE(
|
|
6659
|
+
...xt.bigInt2BytesLE(T(ft[0]), 32),
|
|
6660
|
+
...xt.bigInt2BytesLE(T(ft[1]), 32)
|
|
6687
6661
|
]);
|
|
6688
|
-
G % 2 == 1 ?
|
|
6662
|
+
G % 2 == 1 ? M.addCode(
|
|
6689
6663
|
R.call(A + "_copy", j, H),
|
|
6690
6664
|
R.call(A + "_neg", Y, et),
|
|
6691
6665
|
R.call(E + "_mul", Z, R.i32_const(_t), Z)
|
|
6692
|
-
) :
|
|
6666
|
+
) : M.addCode(R.call(E + "_mul", U, R.i32_const(_t), Z));
|
|
6693
6667
|
}
|
|
6694
6668
|
function q(k, U) {
|
|
6695
6669
|
const j = BigInt(k[0]), Y = BigInt(k[1]), Z = BigInt(U[0]), H = BigInt(U[1]), et = [
|
|
@@ -6702,10 +6676,10 @@ var hs = function(t, n) {
|
|
|
6702
6676
|
function vt() {
|
|
6703
6677
|
const G = t.addFunction(e + "__finalExponentiationFirstChunk");
|
|
6704
6678
|
G.addParam("x", "i32"), G.addParam("r", "i32");
|
|
6705
|
-
const _ = G.getCodeBuilder(), g = _.getLocal("x"),
|
|
6679
|
+
const _ = G.getCodeBuilder(), g = _.getLocal("x"), M = g, R = _.i32_add(g, _.i32_const(r * 6)), q = _.getLocal("r"), k = t.alloc(C), U = _.i32_const(k), j = U, Y = _.i32_const(k + r * 6), Z = _.i32_const(t.alloc(C)), H = _.i32_const(t.alloc(C)), et = _.i32_const(t.alloc(C));
|
|
6706
6680
|
G.addCode(
|
|
6707
6681
|
// const alt_bn128_Fq12 A = alt_bn128_Fq12(elt.c0,-elt.c1);
|
|
6708
|
-
_.call(ct + "_copy",
|
|
6682
|
+
_.call(ct + "_copy", M, j),
|
|
6709
6683
|
_.call(ct + "_neg", R, Y),
|
|
6710
6684
|
// const alt_bn128_Fq12 B = elt.inverse();
|
|
6711
6685
|
_.call(st + "_inverse", g, Z),
|
|
@@ -6720,7 +6694,7 @@ var hs = function(t, n) {
|
|
|
6720
6694
|
function Ut() {
|
|
6721
6695
|
const G = t.addFunction(e + "__cyclotomicSquare");
|
|
6722
6696
|
G.addParam("x", "i32"), G.addParam("r", "i32");
|
|
6723
|
-
const _ = G.getCodeBuilder(), g = _.getLocal("x"),
|
|
6697
|
+
const _ = G.getCodeBuilder(), g = _.getLocal("x"), M = _.i32_add(_.getLocal("x"), _.i32_const(l)), R = _.i32_add(_.getLocal("x"), _.i32_const(2 * l)), q = _.i32_add(_.getLocal("x"), _.i32_const(3 * l)), k = _.i32_add(_.getLocal("x"), _.i32_const(4 * l)), U = _.i32_add(_.getLocal("x"), _.i32_const(5 * l)), j = _.getLocal("r"), Y = _.i32_add(_.getLocal("r"), _.i32_const(l)), Z = _.i32_add(_.getLocal("r"), _.i32_const(2 * l)), H = _.i32_add(_.getLocal("r"), _.i32_const(3 * l)), et = _.i32_add(_.getLocal("r"), _.i32_const(4 * l)), ft = _.i32_add(_.getLocal("r"), _.i32_const(5 * l)), _t = _.i32_const(t.alloc(l)), lt = _.i32_const(t.alloc(l)), bt = _.i32_const(t.alloc(l)), mt = _.i32_const(t.alloc(l)), Ot = _.i32_const(t.alloc(l)), Ct = _.i32_const(t.alloc(l)), wt = _.i32_const(t.alloc(l)), ht = _.i32_const(t.alloc(l));
|
|
6724
6698
|
G.addCode(
|
|
6725
6699
|
// // t0 + t1*y = (z0 + z1*y)^2 = a^2
|
|
6726
6700
|
// tmp = z0 * z1;
|
|
@@ -6752,10 +6726,10 @@ var hs = function(t, n) {
|
|
|
6752
6726
|
// tmp = z4 * z5;
|
|
6753
6727
|
// t4 = (z4 + z5) * (z4 + my_Fp6::non_residue * z5) - tmp - my_Fp6::non_residue * tmp;
|
|
6754
6728
|
// t5 = tmp + tmp;
|
|
6755
|
-
_.call(E + "_mul",
|
|
6729
|
+
_.call(E + "_mul", M, U, wt),
|
|
6756
6730
|
_.call(E + "_mul", U, _.i32_const(v), Ot),
|
|
6757
|
-
_.call(E + "_add",
|
|
6758
|
-
_.call(E + "_add",
|
|
6731
|
+
_.call(E + "_add", M, Ot, Ot),
|
|
6732
|
+
_.call(E + "_add", M, U, ht),
|
|
6759
6733
|
_.call(E + "_mul", ht, Ot, Ot),
|
|
6760
6734
|
_.call(E + "_mul", _.i32_const(v), wt, ht),
|
|
6761
6735
|
_.call(E + "_add", wt, ht, ht),
|
|
@@ -6782,7 +6756,7 @@ var hs = function(t, n) {
|
|
|
6782
6756
|
_.call(E + "_add", Ot, Z, Z),
|
|
6783
6757
|
// For C
|
|
6784
6758
|
// z4 = 3 * t2 - 2 * z4
|
|
6785
|
-
_.call(E + "_sub", bt,
|
|
6759
|
+
_.call(E + "_sub", bt, M, Y),
|
|
6786
6760
|
_.call(E + "_add", Y, Y, Y),
|
|
6787
6761
|
_.call(E + "_add", bt, Y, Y),
|
|
6788
6762
|
// z5 = 3 * t3 + 2 * z5
|
|
@@ -6792,14 +6766,14 @@ var hs = function(t, n) {
|
|
|
6792
6766
|
);
|
|
6793
6767
|
}
|
|
6794
6768
|
function Vt(G, _) {
|
|
6795
|
-
const g = S(G).map((Y) => Y == -1 ? 255 : Y),
|
|
6769
|
+
const g = S(G).map((Y) => Y == -1 ? 255 : Y), M = t.alloc(g), R = t.addFunction(e + "__cyclotomicExp_" + _);
|
|
6796
6770
|
R.addParam("x", "i32"), R.addParam("r", "i32"), R.addLocal("bit", "i32"), R.addLocal("i", "i32");
|
|
6797
6771
|
const q = R.getCodeBuilder(), k = q.getLocal("x"), U = q.getLocal("r"), j = q.i32_const(t.alloc(C));
|
|
6798
6772
|
R.addCode(
|
|
6799
6773
|
q.call(st + "_conjugate", k, j),
|
|
6800
6774
|
q.call(st + "_one", U),
|
|
6801
6775
|
q.if(
|
|
6802
|
-
q.teeLocal("bit", q.i32_load8_s(q.i32_const(g.length - 1),
|
|
6776
|
+
q.teeLocal("bit", q.i32_load8_s(q.i32_const(g.length - 1), M)),
|
|
6803
6777
|
q.if(
|
|
6804
6778
|
q.i32_eq(
|
|
6805
6779
|
q.getLocal("bit"),
|
|
@@ -6813,7 +6787,7 @@ var hs = function(t, n) {
|
|
|
6813
6787
|
q.block(q.loop(
|
|
6814
6788
|
q.call(e + "__cyclotomicSquare", U, U),
|
|
6815
6789
|
q.if(
|
|
6816
|
-
q.teeLocal("bit", q.i32_load8_s(q.getLocal("i"),
|
|
6790
|
+
q.teeLocal("bit", q.i32_load8_s(q.getLocal("i"), M)),
|
|
6817
6791
|
q.if(
|
|
6818
6792
|
q.i32_eq(
|
|
6819
6793
|
q.getLocal("bit"),
|
|
@@ -6833,7 +6807,7 @@ var hs = function(t, n) {
|
|
|
6833
6807
|
Ut(), Vt(h, "w0");
|
|
6834
6808
|
const G = t.addFunction(e + "__finalExponentiationLastChunk");
|
|
6835
6809
|
G.addParam("x", "i32"), G.addParam("r", "i32");
|
|
6836
|
-
const _ = G.getCodeBuilder(), g = _.getLocal("x"),
|
|
6810
|
+
const _ = G.getCodeBuilder(), g = _.getLocal("x"), M = _.getLocal("r"), R = _.i32_const(t.alloc(C)), q = _.i32_const(t.alloc(C)), k = _.i32_const(t.alloc(C)), U = _.i32_const(t.alloc(C)), j = _.i32_const(t.alloc(C)), Y = _.i32_const(t.alloc(C)), Z = _.i32_const(t.alloc(C)), H = _.i32_const(t.alloc(C)), et = _.i32_const(t.alloc(C)), ft = _.i32_const(t.alloc(C)), _t = _.i32_const(t.alloc(C)), lt = _.i32_const(t.alloc(C)), bt = _.i32_const(t.alloc(C)), mt = _.i32_const(t.alloc(C)), Ot = _.i32_const(t.alloc(C)), Ct = _.i32_const(t.alloc(C)), wt = _.i32_const(t.alloc(C)), ht = _.i32_const(t.alloc(C)), qt = _.i32_const(t.alloc(C)), Ht = _.i32_const(t.alloc(C)), Wt = _.i32_const(t.alloc(C));
|
|
6837
6811
|
G.addCode(
|
|
6838
6812
|
// A = exp_by_neg_z(elt) // = elt^(-z)
|
|
6839
6813
|
_.call(e + "__cyclotomicExp_w0", g, R),
|
|
@@ -6881,7 +6855,7 @@ var hs = function(t, n) {
|
|
|
6881
6855
|
// U = T.Frobenius_map(3) // = elt^(q^3(12*z^3 + 6*z^2 + 4*z - 1))
|
|
6882
6856
|
_.call(e + "__frobeniusMap3", Ht, Wt),
|
|
6883
6857
|
// V = U * R // = elt^(q^3(12*z^3 + 6*z^2 + 4*z - 1) + q^2 * (12*z^3 + 6*z^2 + 6*z) + q*(12*z^3 + 6*z^2 + 4*z) * (12*z^3 + 12*z^2 + 6*z + 1))
|
|
6884
|
-
_.call(st + "_mul", Wt, ht,
|
|
6858
|
+
_.call(st + "_mul", Wt, ht, M)
|
|
6885
6859
|
// result = V
|
|
6886
6860
|
);
|
|
6887
6861
|
}
|
|
@@ -6889,18 +6863,18 @@ var hs = function(t, n) {
|
|
|
6889
6863
|
vt(), Dt();
|
|
6890
6864
|
const G = t.addFunction(e + "_finalExponentiation");
|
|
6891
6865
|
G.addParam("x", "i32"), G.addParam("r", "i32");
|
|
6892
|
-
const _ = G.getCodeBuilder(), g = _.getLocal("x"),
|
|
6866
|
+
const _ = G.getCodeBuilder(), g = _.getLocal("x"), M = _.getLocal("r"), R = _.i32_const(t.alloc(C));
|
|
6893
6867
|
G.addCode(
|
|
6894
6868
|
_.call(e + "__finalExponentiationFirstChunk", g, R),
|
|
6895
|
-
_.call(e + "__finalExponentiationLastChunk", R,
|
|
6869
|
+
_.call(e + "__finalExponentiationLastChunk", R, M)
|
|
6896
6870
|
);
|
|
6897
6871
|
}
|
|
6898
|
-
function
|
|
6872
|
+
function zt() {
|
|
6899
6873
|
const G = t.addFunction(e + "_finalExponentiationOld");
|
|
6900
6874
|
G.addParam("x", "i32"), G.addParam("r", "i32");
|
|
6901
|
-
const g = t.alloc(xt.bigInt2BytesLE(552484233613224096312617126783173147097382103762957654188882734314196910839907541213974502761540629817009608548654680343627701153829446747810907373256841551006201639677726139946029199968412598804882391702273019083653272047566316584365559776493027495458238373902875937659943504873220554161550525926302303331747463515644711876653177129578303191095900909191624817826566688241804408081892785725967931714097716709526092261278071952560171111444072049229123565057483750161460024353346284167282452756217662335528813519139808291170539072125381230815729071544861602750936964829313608137325426383735122175229541155376346436093930287402089517426973178917569713384748081827255472576937471496195752727188261435633271238710131736096299798168852925540549342330775279877006784354801422249722573783561685179618816480037695005515426162362431072245638324744480n, 352)),
|
|
6875
|
+
const g = t.alloc(xt.bigInt2BytesLE(552484233613224096312617126783173147097382103762957654188882734314196910839907541213974502761540629817009608548654680343627701153829446747810907373256841551006201639677726139946029199968412598804882391702273019083653272047566316584365559776493027495458238373902875937659943504873220554161550525926302303331747463515644711876653177129578303191095900909191624817826566688241804408081892785725967931714097716709526092261278071952560171111444072049229123565057483750161460024353346284167282452756217662335528813519139808291170539072125381230815729071544861602750936964829313608137325426383735122175229541155376346436093930287402089517426973178917569713384748081827255472576937471496195752727188261435633271238710131736096299798168852925540549342330775279877006784354801422249722573783561685179618816480037695005515426162362431072245638324744480n, 352)), M = G.getCodeBuilder();
|
|
6902
6876
|
G.addCode(
|
|
6903
|
-
|
|
6877
|
+
M.call(st + "_exp", M.getLocal("x"), M.i32_const(g), M.i32_const(352), M.getLocal("r"))
|
|
6904
6878
|
);
|
|
6905
6879
|
}
|
|
6906
6880
|
const Nt = t.alloc(w), Kt = t.alloc(I);
|
|
@@ -6909,11 +6883,11 @@ var hs = function(t, n) {
|
|
|
6909
6883
|
for (let q = 0; q < G; q++)
|
|
6910
6884
|
_.addParam("p_" + q, "i32"), _.addParam("q_" + q, "i32");
|
|
6911
6885
|
_.addParam("c", "i32"), _.setReturnType("i32");
|
|
6912
|
-
const g = _.getCodeBuilder(),
|
|
6913
|
-
_.addCode(g.call(st + "_one",
|
|
6886
|
+
const g = _.getCodeBuilder(), M = g.i32_const(t.alloc(C)), R = g.i32_const(t.alloc(C));
|
|
6887
|
+
_.addCode(g.call(st + "_one", M));
|
|
6914
6888
|
for (let q = 0; q < G; q++)
|
|
6915
|
-
_.addCode(g.call(e + "_prepareG1", g.getLocal("p_" + q), g.i32_const(Nt))), _.addCode(g.call(e + "_prepareG2", g.getLocal("q_" + q), g.i32_const(Kt))), _.addCode(g.call(e + "_millerLoop", g.i32_const(Nt), g.i32_const(Kt), R)), _.addCode(g.call(st + "_mul",
|
|
6916
|
-
_.addCode(g.call(e + "_finalExponentiation",
|
|
6889
|
+
_.addCode(g.call(e + "_prepareG1", g.getLocal("p_" + q), g.i32_const(Nt))), _.addCode(g.call(e + "_prepareG2", g.getLocal("q_" + q), g.i32_const(Kt))), _.addCode(g.call(e + "_millerLoop", g.i32_const(Nt), g.i32_const(Kt), R)), _.addCode(g.call(st + "_mul", M, R, M));
|
|
6890
|
+
_.addCode(g.call(e + "_finalExponentiation", M, M)), _.addCode(g.call(st + "_eq", M, g.getLocal("c")));
|
|
6917
6891
|
}
|
|
6918
6892
|
function Zt() {
|
|
6919
6893
|
const G = t.addFunction(e + "_pairing");
|
|
@@ -6924,7 +6898,7 @@ var hs = function(t, n) {
|
|
|
6924
6898
|
at(), It(), N(), Lt(), gt(), St(), dt();
|
|
6925
6899
|
for (let G = 0; G < 10; G++)
|
|
6926
6900
|
yt(G), t.exportFunction(e + "__frobeniusMap" + G);
|
|
6927
|
-
|
|
6901
|
+
zt(), jt();
|
|
6928
6902
|
for (let G = 1; G <= 5; G++)
|
|
6929
6903
|
en(G), t.exportFunction(e + "_pairingEq" + G);
|
|
6930
6904
|
Zt(), t.exportFunction(e + "_pairing"), t.exportFunction(e + "_prepareG1"), t.exportFunction(e + "_prepareG2"), t.exportFunction(e + "_millerLoop"), t.exportFunction(e + "_finalExponentiation"), t.exportFunction(e + "_finalExponentiationOld"), t.exportFunction(e + "__mulBy024"), t.exportFunction(e + "__mulBy024Old"), t.exportFunction(e + "__cyclotomicSquare"), t.exportFunction(e + "__cyclotomicExp_w0");
|
|
@@ -6936,17 +6910,17 @@ var Cs = function(t, n) {
|
|
|
6936
6910
|
return e;
|
|
6937
6911
|
const i = 0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaabn, s = 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001n, d = Math.floor((Ho(i - 1n) - 1) / 64) + 1, r = d * 8, b = r, u = b * 2, l = b * 12, C = Math.floor((Ho(s - 1n) - 1) / 64) + 1, B = C * 8, A = B, O = t.alloc(Et.bigInt2BytesLE(s, A)), P = ps(t, i, "f1m", "intq");
|
|
6938
6912
|
Ls(t, s, "fr", "frm", "intr");
|
|
6939
|
-
const E = t.alloc(Et.bigInt2BytesLE(F(4n), b)),
|
|
6913
|
+
const E = t.alloc(Et.bigInt2BytesLE(F(4n), b)), z = Ko(t, "g1m", "f1m", E);
|
|
6940
6914
|
qe(t, "frm", "frm", "frm", "frm_mul"), bs(t, "pol", "frm"), ys(t, "qap", "frm");
|
|
6941
6915
|
const x = Go(t, "f1m_neg", "f2m", "f1m"), ot = t.alloc([
|
|
6942
6916
|
...Et.bigInt2BytesLE(F(4n), b),
|
|
6943
6917
|
...Et.bigInt2BytesLE(F(4n), b)
|
|
6944
|
-
]),
|
|
6918
|
+
]), T = Ko(t, "g2m", "f2m", ot);
|
|
6945
6919
|
function rt(_, g) {
|
|
6946
|
-
const
|
|
6947
|
-
|
|
6948
|
-
const R =
|
|
6949
|
-
|
|
6920
|
+
const M = t.addFunction(_);
|
|
6921
|
+
M.addParam("pG", "i32"), M.addParam("pFr", "i32"), M.addParam("pr", "i32");
|
|
6922
|
+
const R = M.getCodeBuilder(), q = R.i32_const(t.alloc(B));
|
|
6923
|
+
M.addCode(
|
|
6950
6924
|
R.call("frm_fromMontgomery", R.getLocal("pFr"), q),
|
|
6951
6925
|
R.call(
|
|
6952
6926
|
g,
|
|
@@ -6994,7 +6968,7 @@ var Cs = function(t, n) {
|
|
|
6994
6968
|
1n,
|
|
6995
6969
|
0n
|
|
6996
6970
|
]
|
|
6997
|
-
],
|
|
6971
|
+
], Q = t.alloc(
|
|
6998
6972
|
[
|
|
6999
6973
|
...Et.bigInt2BytesLE(F(X[0][0]), b),
|
|
7000
6974
|
...Et.bigInt2BytesLE(F(X[0][1]), b),
|
|
@@ -7045,11 +7019,11 @@ var Cs = function(t, n) {
|
|
|
7045
7019
|
function nt() {
|
|
7046
7020
|
const _ = t.addFunction(x + "_mulNR");
|
|
7047
7021
|
_.addParam("x", "i32"), _.addParam("pr", "i32");
|
|
7048
|
-
const g = _.getCodeBuilder(),
|
|
7022
|
+
const g = _.getCodeBuilder(), M = g.i32_const(t.alloc(b)), R = g.getLocal("x"), q = g.i32_add(g.getLocal("x"), g.i32_const(b)), k = g.getLocal("pr"), U = g.i32_add(g.getLocal("pr"), g.i32_const(b));
|
|
7049
7023
|
_.addCode(
|
|
7050
|
-
g.call(P + "_copy", R,
|
|
7024
|
+
g.call(P + "_copy", R, M),
|
|
7051
7025
|
g.call(P + "_sub", R, q, k),
|
|
7052
|
-
g.call(P + "_add",
|
|
7026
|
+
g.call(P + "_add", M, q, U)
|
|
7053
7027
|
);
|
|
7054
7028
|
}
|
|
7055
7029
|
nt();
|
|
@@ -7057,12 +7031,12 @@ var Cs = function(t, n) {
|
|
|
7057
7031
|
function ct() {
|
|
7058
7032
|
const _ = t.addFunction(K + "_mulNR");
|
|
7059
7033
|
_.addParam("x", "i32"), _.addParam("pr", "i32");
|
|
7060
|
-
const g = _.getCodeBuilder(),
|
|
7034
|
+
const g = _.getCodeBuilder(), M = g.i32_const(t.alloc(b * 2));
|
|
7061
7035
|
_.addCode(
|
|
7062
7036
|
g.call(
|
|
7063
7037
|
x + "_copy",
|
|
7064
7038
|
g.getLocal("x"),
|
|
7065
|
-
|
|
7039
|
+
M
|
|
7066
7040
|
),
|
|
7067
7041
|
g.call(
|
|
7068
7042
|
x + "_mulNR",
|
|
@@ -7076,7 +7050,7 @@ var Cs = function(t, n) {
|
|
|
7076
7050
|
),
|
|
7077
7051
|
g.call(
|
|
7078
7052
|
x + "_copy",
|
|
7079
|
-
|
|
7053
|
+
M,
|
|
7080
7054
|
g.i32_add(g.getLocal("pr"), g.i32_const(r * 2))
|
|
7081
7055
|
)
|
|
7082
7056
|
);
|
|
@@ -7091,7 +7065,7 @@ var Cs = function(t, n) {
|
|
|
7091
7065
|
pG1gen: L,
|
|
7092
7066
|
pG1zero: $,
|
|
7093
7067
|
pG1b: E,
|
|
7094
|
-
pG2gen:
|
|
7068
|
+
pG2gen: Q,
|
|
7095
7069
|
pG2zero: v,
|
|
7096
7070
|
pG2b: ot,
|
|
7097
7071
|
pq: t.modules.f1m.pq,
|
|
@@ -7104,46 +7078,46 @@ var Cs = function(t, n) {
|
|
|
7104
7078
|
};
|
|
7105
7079
|
function S(_) {
|
|
7106
7080
|
let g = _;
|
|
7107
|
-
const
|
|
7081
|
+
const M = [];
|
|
7108
7082
|
for (; g > 0n; ) {
|
|
7109
7083
|
if (Vo(g)) {
|
|
7110
7084
|
const R = 2 - Number(g % 4n);
|
|
7111
|
-
|
|
7085
|
+
M.push(R), g = g - BigInt(R);
|
|
7112
7086
|
} else
|
|
7113
|
-
|
|
7087
|
+
M.push(0);
|
|
7114
7088
|
g = g >> 1n;
|
|
7115
7089
|
}
|
|
7116
|
-
return
|
|
7090
|
+
return M;
|
|
7117
7091
|
}
|
|
7118
7092
|
function W(_) {
|
|
7119
7093
|
let g = _;
|
|
7120
|
-
const
|
|
7094
|
+
const M = [];
|
|
7121
7095
|
for (; g > 0n; )
|
|
7122
|
-
Vo(g) ?
|
|
7123
|
-
return
|
|
7096
|
+
Vo(g) ? M.push(1) : M.push(0), g = g >> 1n;
|
|
7097
|
+
return M;
|
|
7124
7098
|
}
|
|
7125
7099
|
function N() {
|
|
7126
7100
|
const _ = t.addFunction(e + "_prepareG1");
|
|
7127
7101
|
_.addParam("pP", "i32"), _.addParam("ppreP", "i32");
|
|
7128
7102
|
const g = _.getCodeBuilder();
|
|
7129
7103
|
_.addCode(
|
|
7130
|
-
g.call(
|
|
7104
|
+
g.call(z + "_normalize", g.getLocal("pP"), g.getLocal("ppreP"))
|
|
7131
7105
|
// TODO Remove if already in affine
|
|
7132
7106
|
);
|
|
7133
7107
|
}
|
|
7134
7108
|
function at() {
|
|
7135
7109
|
const _ = t.addFunction(e + "_prepDblStep");
|
|
7136
7110
|
_.addParam("R", "i32"), _.addParam("r", "i32");
|
|
7137
|
-
const g = _.getCodeBuilder(),
|
|
7111
|
+
const g = _.getCodeBuilder(), M = g.getLocal("R"), R = g.i32_add(g.getLocal("R"), g.i32_const(2 * r)), q = g.i32_add(g.getLocal("R"), g.i32_const(4 * r)), k = g.getLocal("r"), U = g.i32_add(g.getLocal("r"), g.i32_const(2 * r)), j = g.i32_add(g.getLocal("r"), g.i32_const(4 * r)), Y = g.i32_const(t.alloc(u)), Z = g.i32_const(t.alloc(u)), H = g.i32_const(t.alloc(u)), et = g.i32_const(t.alloc(u)), ft = g.i32_const(t.alloc(u));
|
|
7138
7112
|
_.addCode(
|
|
7139
7113
|
// tmp0 = r.x.square();
|
|
7140
|
-
g.call(x + "_square",
|
|
7114
|
+
g.call(x + "_square", M, k),
|
|
7141
7115
|
// tmp1 = r.y.square();
|
|
7142
7116
|
g.call(x + "_square", R, Z),
|
|
7143
7117
|
// tmp2 = tmp1.square();
|
|
7144
7118
|
g.call(x + "_square", Z, H),
|
|
7145
7119
|
// tmp3 = (tmp1 + r.x).square() - tmp0 - tmp2;
|
|
7146
|
-
g.call(x + "_add", Z,
|
|
7120
|
+
g.call(x + "_add", Z, M, U),
|
|
7147
7121
|
g.call(x + "_square", U, U),
|
|
7148
7122
|
g.call(x + "_sub", U, k, U),
|
|
7149
7123
|
g.call(x + "_sub", U, H, U),
|
|
@@ -7153,21 +7127,21 @@ var Cs = function(t, n) {
|
|
|
7153
7127
|
g.call(x + "_add", k, k, et),
|
|
7154
7128
|
g.call(x + "_add", et, k, et),
|
|
7155
7129
|
// tmp6 = r.x + tmp4;
|
|
7156
|
-
g.call(x + "_add",
|
|
7130
|
+
g.call(x + "_add", M, et, j),
|
|
7157
7131
|
// tmp5 = tmp4.square();
|
|
7158
7132
|
g.call(x + "_square", et, ft),
|
|
7159
7133
|
// zsquared = r.z.square();
|
|
7160
7134
|
g.call(x + "_square", q, Y),
|
|
7161
7135
|
// r.x = tmp5 - tmp3 - tmp3;
|
|
7162
|
-
g.call(x + "_sub", ft, U,
|
|
7163
|
-
g.call(x + "_sub",
|
|
7136
|
+
g.call(x + "_sub", ft, U, M),
|
|
7137
|
+
g.call(x + "_sub", M, U, M),
|
|
7164
7138
|
// r.z = (r.z + r.y).square() - tmp1 - zsquared;
|
|
7165
7139
|
g.call(x + "_add", q, R, q),
|
|
7166
7140
|
g.call(x + "_square", q, q),
|
|
7167
7141
|
g.call(x + "_sub", q, Z, q),
|
|
7168
7142
|
g.call(x + "_sub", q, Y, q),
|
|
7169
7143
|
// r.y = (tmp3 - r.x) * tmp4;
|
|
7170
|
-
g.call(x + "_sub", U,
|
|
7144
|
+
g.call(x + "_sub", U, M, R),
|
|
7171
7145
|
g.call(x + "_mul", R, et, R),
|
|
7172
7146
|
// tmp2 = tmp2 + tmp2;
|
|
7173
7147
|
g.call(x + "_add", H, H, H),
|
|
@@ -7202,7 +7176,7 @@ var Cs = function(t, n) {
|
|
|
7202
7176
|
function It() {
|
|
7203
7177
|
const _ = t.addFunction(e + "_prepAddStep");
|
|
7204
7178
|
_.addParam("R", "i32"), _.addParam("Q", "i32"), _.addParam("r", "i32");
|
|
7205
|
-
const g = _.getCodeBuilder(),
|
|
7179
|
+
const g = _.getCodeBuilder(), M = g.getLocal("R"), R = g.i32_add(g.getLocal("R"), g.i32_const(2 * r)), q = g.i32_add(g.getLocal("R"), g.i32_const(4 * r)), k = g.getLocal("Q"), U = g.i32_add(g.getLocal("Q"), g.i32_const(2 * r)), j = g.getLocal("r"), Y = g.i32_add(g.getLocal("r"), g.i32_const(2 * r)), Z = g.i32_add(g.getLocal("r"), g.i32_const(4 * r)), H = g.i32_const(t.alloc(u)), et = g.i32_const(t.alloc(u)), ft = g.i32_const(t.alloc(u)), _t = g.i32_const(t.alloc(u)), lt = g.i32_const(t.alloc(u)), bt = g.i32_const(t.alloc(u)), mt = g.i32_const(t.alloc(u)), Ot = g.i32_const(t.alloc(u)), Ct = g.i32_const(t.alloc(u)), wt = g.i32_const(t.alloc(u)), ht = g.i32_const(t.alloc(u));
|
|
7206
7180
|
_.addCode(
|
|
7207
7181
|
// zsquared = r.z.square();
|
|
7208
7182
|
g.call(x + "_square", q, H),
|
|
@@ -7217,7 +7191,7 @@ var Cs = function(t, n) {
|
|
|
7217
7191
|
g.call(x + "_sub", Y, H, Y),
|
|
7218
7192
|
g.call(x + "_mul", Y, H, Y),
|
|
7219
7193
|
// t2 = t0 - r.x;
|
|
7220
|
-
g.call(x + "_sub", _t,
|
|
7194
|
+
g.call(x + "_sub", _t, M, lt),
|
|
7221
7195
|
// t3 = t2.square();
|
|
7222
7196
|
g.call(x + "_square", lt, bt),
|
|
7223
7197
|
// t4 = t3 + t3;
|
|
@@ -7232,12 +7206,12 @@ var Cs = function(t, n) {
|
|
|
7232
7206
|
// t9 = t6 * q.x;
|
|
7233
7207
|
g.call(x + "_mul", Ct, k, Z),
|
|
7234
7208
|
// t7 = t4 * r.x;
|
|
7235
|
-
g.call(x + "_mul", mt,
|
|
7209
|
+
g.call(x + "_mul", mt, M, wt),
|
|
7236
7210
|
// r.x = t6.square() - t5 - t7 - t7;
|
|
7237
|
-
g.call(x + "_square", Ct,
|
|
7238
|
-
g.call(x + "_sub",
|
|
7239
|
-
g.call(x + "_sub",
|
|
7240
|
-
g.call(x + "_sub",
|
|
7211
|
+
g.call(x + "_square", Ct, M),
|
|
7212
|
+
g.call(x + "_sub", M, Ot, M),
|
|
7213
|
+
g.call(x + "_sub", M, wt, M),
|
|
7214
|
+
g.call(x + "_sub", M, wt, M),
|
|
7241
7215
|
// r.z = (r.z + t2).square() - zsquared - t3;
|
|
7242
7216
|
g.call(x + "_add", q, lt, q),
|
|
7243
7217
|
g.call(x + "_square", q, q),
|
|
@@ -7246,7 +7220,7 @@ var Cs = function(t, n) {
|
|
|
7246
7220
|
// t10 = q.y + r.z;
|
|
7247
7221
|
g.call(x + "_add", U, q, j),
|
|
7248
7222
|
// t8 = (t7 - r.x) * t6;
|
|
7249
|
-
g.call(x + "_sub", wt,
|
|
7223
|
+
g.call(x + "_sub", wt, M, ht),
|
|
7250
7224
|
g.call(x + "_mul", ht, Ct, ht),
|
|
7251
7225
|
// t0 = r.y * t5;
|
|
7252
7226
|
g.call(x + "_mul", R, Ot, _t),
|
|
@@ -7275,14 +7249,14 @@ var Cs = function(t, n) {
|
|
|
7275
7249
|
function ut() {
|
|
7276
7250
|
const _ = t.addFunction(e + "_prepareG2");
|
|
7277
7251
|
_.addParam("pQ", "i32"), _.addParam("ppreQ", "i32"), _.addLocal("pCoef", "i32"), _.addLocal("i", "i32");
|
|
7278
|
-
const g = _.getCodeBuilder(),
|
|
7252
|
+
const g = _.getCodeBuilder(), M = g.getLocal("pQ"), R = t.alloc(u * 3), q = g.i32_const(R), k = g.getLocal("ppreQ");
|
|
7279
7253
|
_.addCode(
|
|
7280
|
-
g.call(
|
|
7254
|
+
g.call(T + "_normalize", M, k),
|
|
7281
7255
|
g.if(
|
|
7282
|
-
g.call(
|
|
7256
|
+
g.call(T + "_isZero", k),
|
|
7283
7257
|
g.ret([])
|
|
7284
7258
|
),
|
|
7285
|
-
g.call(
|
|
7259
|
+
g.call(T + "_copy", k, q),
|
|
7286
7260
|
g.setLocal("pCoef", g.i32_add(g.getLocal("ppreQ"), g.i32_const(u * 3)))
|
|
7287
7261
|
), _.addCode(
|
|
7288
7262
|
g.setLocal("i", g.i32_const(At.length - 2)),
|
|
@@ -7305,9 +7279,9 @@ var Cs = function(t, n) {
|
|
|
7305
7279
|
function Lt() {
|
|
7306
7280
|
const _ = t.addFunction(K + "_mul1");
|
|
7307
7281
|
_.addParam("pA", "i32"), _.addParam("pC1", "i32"), _.addParam("pR", "i32");
|
|
7308
|
-
const g = _.getCodeBuilder(),
|
|
7282
|
+
const g = _.getCodeBuilder(), M = g.getLocal("pA"), R = g.i32_add(g.getLocal("pA"), g.i32_const(b * 2)), q = g.i32_add(g.getLocal("pA"), g.i32_const(b * 4)), k = g.getLocal("pC1"), U = g.getLocal("pR"), j = g.i32_add(g.getLocal("pR"), g.i32_const(b * 2)), Y = g.i32_add(g.getLocal("pR"), g.i32_const(b * 4)), Z = g.i32_const(t.alloc(b * 2)), H = g.i32_const(t.alloc(b * 2));
|
|
7309
7283
|
_.addCode(
|
|
7310
|
-
g.call(x + "_add",
|
|
7284
|
+
g.call(x + "_add", M, R, Z),
|
|
7311
7285
|
g.call(x + "_add", R, q, H),
|
|
7312
7286
|
// let b_b = self.c1 * c1;
|
|
7313
7287
|
g.call(x + "_mul", R, k, Y),
|
|
@@ -7325,14 +7299,14 @@ var Cs = function(t, n) {
|
|
|
7325
7299
|
function St() {
|
|
7326
7300
|
const _ = t.addFunction(K + "_mul01");
|
|
7327
7301
|
_.addParam("pA", "i32"), _.addParam("pC0", "i32"), _.addParam("pC1", "i32"), _.addParam("pR", "i32");
|
|
7328
|
-
const g = _.getCodeBuilder(),
|
|
7302
|
+
const g = _.getCodeBuilder(), M = g.getLocal("pA"), R = g.i32_add(g.getLocal("pA"), g.i32_const(b * 2)), q = g.i32_add(g.getLocal("pA"), g.i32_const(b * 4)), k = g.getLocal("pC0"), U = g.getLocal("pC1"), j = g.getLocal("pR"), Y = g.i32_add(g.getLocal("pR"), g.i32_const(b * 2)), Z = g.i32_add(g.getLocal("pR"), g.i32_const(b * 4)), H = g.i32_const(t.alloc(b * 2)), et = g.i32_const(t.alloc(b * 2)), ft = g.i32_const(t.alloc(b * 2)), _t = g.i32_const(t.alloc(b * 2));
|
|
7329
7303
|
_.addCode(
|
|
7330
7304
|
// let a_a = self.c0 * c0;
|
|
7331
|
-
g.call(x + "_mul",
|
|
7305
|
+
g.call(x + "_mul", M, k, H),
|
|
7332
7306
|
// let b_b = self.c1 * c1;
|
|
7333
7307
|
g.call(x + "_mul", R, U, et),
|
|
7334
|
-
g.call(x + "_add",
|
|
7335
|
-
g.call(x + "_add",
|
|
7308
|
+
g.call(x + "_add", M, R, ft),
|
|
7309
|
+
g.call(x + "_add", M, q, _t),
|
|
7336
7310
|
// let t1 = (self.c1 + self.c2) * c1 - b_b;
|
|
7337
7311
|
g.call(x + "_add", R, q, j),
|
|
7338
7312
|
g.call(x + "_mul", j, U, j),
|
|
@@ -7355,16 +7329,16 @@ var Cs = function(t, n) {
|
|
|
7355
7329
|
function gt() {
|
|
7356
7330
|
const _ = t.addFunction(J + "_mul014");
|
|
7357
7331
|
_.addParam("pA", "i32"), _.addParam("pC0", "i32"), _.addParam("pC1", "i32"), _.addParam("pC4", "i32"), _.addParam("pR", "i32");
|
|
7358
|
-
const g = _.getCodeBuilder(),
|
|
7332
|
+
const g = _.getCodeBuilder(), M = g.getLocal("pA"), R = g.i32_add(g.getLocal("pA"), g.i32_const(b * 6)), q = g.getLocal("pC0"), k = g.getLocal("pC1"), U = g.getLocal("pC4"), j = g.i32_const(t.alloc(b * 6)), Y = g.i32_const(t.alloc(b * 6)), Z = g.i32_const(t.alloc(b * 2)), H = g.getLocal("pR"), et = g.i32_add(g.getLocal("pR"), g.i32_const(b * 6));
|
|
7359
7333
|
_.addCode(
|
|
7360
7334
|
// let aa = self.c0.mul_by_01(c0, c1);
|
|
7361
|
-
g.call(K + "_mul01",
|
|
7335
|
+
g.call(K + "_mul01", M, q, k, j),
|
|
7362
7336
|
// let bb = self.c1.mul_by_1(c4);
|
|
7363
7337
|
g.call(K + "_mul1", R, U, Y),
|
|
7364
7338
|
// let o = c1 + c4;
|
|
7365
7339
|
g.call(x + "_add", k, U, Z),
|
|
7366
7340
|
// let c1 = self.c1 + self.c0;
|
|
7367
|
-
g.call(K + "_add", R,
|
|
7341
|
+
g.call(K + "_add", R, M, et),
|
|
7368
7342
|
// let c1 = c1.mul_by_01(c0, &o);
|
|
7369
7343
|
g.call(K + "_mul01", et, q, Z, et),
|
|
7370
7344
|
// let c1 = c1 - aa - bb;
|
|
@@ -7382,7 +7356,7 @@ var Cs = function(t, n) {
|
|
|
7382
7356
|
function dt() {
|
|
7383
7357
|
const _ = t.addFunction(e + "_ell");
|
|
7384
7358
|
_.addParam("pP", "i32"), _.addParam("pCoefs", "i32"), _.addParam("pF", "i32");
|
|
7385
|
-
const g = _.getCodeBuilder(),
|
|
7359
|
+
const g = _.getCodeBuilder(), M = g.getLocal("pP"), R = g.i32_add(g.getLocal("pP"), g.i32_const(r)), q = g.getLocal("pF"), k = g.getLocal("pCoefs"), U = g.i32_add(g.getLocal("pCoefs"), g.i32_const(b)), j = g.i32_add(g.getLocal("pCoefs"), g.i32_const(b * 2)), Y = g.i32_add(g.getLocal("pCoefs"), g.i32_const(b * 3)), Z = g.i32_add(g.getLocal("pCoefs"), g.i32_const(b * 4)), H = t.alloc(b * 2), et = g.i32_const(H), ft = g.i32_const(H), _t = g.i32_const(H + b), lt = t.alloc(b * 2), bt = g.i32_const(lt), mt = g.i32_const(lt), Ot = g.i32_const(lt + b);
|
|
7386
7360
|
_.addCode(
|
|
7387
7361
|
// let mut c0 = coeffs.0;
|
|
7388
7362
|
// let mut c1 = coeffs.1;
|
|
@@ -7396,8 +7370,8 @@ var Cs = function(t, n) {
|
|
|
7396
7370
|
// f.mul_by_014(&coeffs.2, &c1, &c0)
|
|
7397
7371
|
g.call(P + "_mul", k, R, ft),
|
|
7398
7372
|
g.call(P + "_mul", U, R, _t),
|
|
7399
|
-
g.call(P + "_mul", j,
|
|
7400
|
-
g.call(P + "_mul", Y,
|
|
7373
|
+
g.call(P + "_mul", j, M, mt),
|
|
7374
|
+
g.call(P + "_mul", Y, M, Ot),
|
|
7401
7375
|
g.call(J + "_mul014", q, Z, bt, et, q)
|
|
7402
7376
|
);
|
|
7403
7377
|
}
|
|
@@ -7405,26 +7379,26 @@ var Cs = function(t, n) {
|
|
|
7405
7379
|
function yt() {
|
|
7406
7380
|
const _ = t.addFunction(e + "_millerLoop");
|
|
7407
7381
|
_.addParam("ppreP", "i32"), _.addParam("ppreQ", "i32"), _.addParam("r", "i32"), _.addLocal("pCoef", "i32"), _.addLocal("i", "i32");
|
|
7408
|
-
const g = _.getCodeBuilder(),
|
|
7382
|
+
const g = _.getCodeBuilder(), M = g.getLocal("ppreP"), R = g.getLocal("pCoef"), q = g.getLocal("r");
|
|
7409
7383
|
_.addCode(
|
|
7410
7384
|
g.call(J + "_one", q),
|
|
7411
7385
|
g.if(
|
|
7412
|
-
g.call(
|
|
7386
|
+
g.call(z + "_isZero", M),
|
|
7413
7387
|
g.ret([])
|
|
7414
7388
|
),
|
|
7415
7389
|
g.if(
|
|
7416
|
-
g.call(
|
|
7390
|
+
g.call(z + "_isZero", g.getLocal("ppreQ")),
|
|
7417
7391
|
g.ret([])
|
|
7418
7392
|
),
|
|
7419
7393
|
g.setLocal("pCoef", g.i32_add(g.getLocal("ppreQ"), g.i32_const(u * 3))),
|
|
7420
7394
|
g.setLocal("i", g.i32_const(At.length - 2)),
|
|
7421
7395
|
g.block(g.loop(
|
|
7422
|
-
g.call(e + "_ell",
|
|
7396
|
+
g.call(e + "_ell", M, R, q),
|
|
7423
7397
|
g.setLocal("pCoef", g.i32_add(g.getLocal("pCoef"), g.i32_const(pt))),
|
|
7424
7398
|
g.if(
|
|
7425
7399
|
g.i32_load8_s(g.getLocal("i"), Bt),
|
|
7426
7400
|
[
|
|
7427
|
-
...g.call(e + "_ell",
|
|
7401
|
+
...g.call(e + "_ell", M, R, q),
|
|
7428
7402
|
...g.setLocal("pCoef", g.i32_add(g.getLocal("pCoef"), g.i32_const(pt)))
|
|
7429
7403
|
]
|
|
7430
7404
|
),
|
|
@@ -7433,7 +7407,7 @@ var Cs = function(t, n) {
|
|
|
7433
7407
|
g.setLocal("i", g.i32_sub(g.getLocal("i"), g.i32_const(1))),
|
|
7434
7408
|
g.br(0)
|
|
7435
7409
|
)),
|
|
7436
|
-
g.call(e + "_ell",
|
|
7410
|
+
g.call(e + "_ell", M, R, q)
|
|
7437
7411
|
), _.addCode(
|
|
7438
7412
|
g.call(J + "_conjugate", q, q)
|
|
7439
7413
|
);
|
|
@@ -7468,7 +7442,7 @@ var Cs = function(t, n) {
|
|
|
7468
7442
|
[4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939437n, 0n],
|
|
7469
7443
|
[877076961050607968509681729531255177986764537961432449499635504522207616027455086505066378536590128544573588734230n, 3125332594171059424908108096204648978570118281977575435832422631601824034463382777937621250592425535493320683825557n]
|
|
7470
7444
|
]
|
|
7471
|
-
],
|
|
7445
|
+
], M = [
|
|
7472
7446
|
[
|
|
7473
7447
|
[1n, 0n],
|
|
7474
7448
|
[1n, 0n],
|
|
@@ -7497,7 +7471,7 @@ var Cs = function(t, n) {
|
|
|
7497
7471
|
R.addParam("x", "i32"), R.addParam("r", "i32");
|
|
7498
7472
|
const q = R.getCodeBuilder();
|
|
7499
7473
|
for (let U = 0; U < 6; U++) {
|
|
7500
|
-
const j = U == 0 ? q.getLocal("x") : q.i32_add(q.getLocal("x"), q.i32_const(U * u)), Y = j, Z = q.i32_add(q.getLocal("x"), q.i32_const(U * u + b)), H = U == 0 ? q.getLocal("r") : q.i32_add(q.getLocal("r"), q.i32_const(U * u)), et = H, ft = q.i32_add(q.getLocal("r"), q.i32_const(U * u + b)), _t = k(g[Math.floor(U / 3)][_ % 12],
|
|
7474
|
+
const j = U == 0 ? q.getLocal("x") : q.i32_add(q.getLocal("x"), q.i32_const(U * u)), Y = j, Z = q.i32_add(q.getLocal("x"), q.i32_const(U * u + b)), H = U == 0 ? q.getLocal("r") : q.i32_add(q.getLocal("r"), q.i32_const(U * u)), et = H, ft = q.i32_add(q.getLocal("r"), q.i32_const(U * u + b)), _t = k(g[Math.floor(U / 3)][_ % 12], M[U % 3][_ % 6]), lt = t.alloc([
|
|
7501
7475
|
...Et.bigInt2BytesLE(F(_t[0]), r),
|
|
7502
7476
|
...Et.bigInt2BytesLE(F(_t[1]), r)
|
|
7503
7477
|
]);
|
|
@@ -7518,16 +7492,16 @@ var Cs = function(t, n) {
|
|
|
7518
7492
|
function Ut() {
|
|
7519
7493
|
const _ = t.addFunction(e + "__cyclotomicSquare");
|
|
7520
7494
|
_.addParam("x", "i32"), _.addParam("r", "i32");
|
|
7521
|
-
const g = _.getCodeBuilder(),
|
|
7495
|
+
const g = _.getCodeBuilder(), M = g.getLocal("x"), R = g.i32_add(g.getLocal("x"), g.i32_const(u)), q = g.i32_add(g.getLocal("x"), g.i32_const(2 * u)), k = g.i32_add(g.getLocal("x"), g.i32_const(3 * u)), U = g.i32_add(g.getLocal("x"), g.i32_const(4 * u)), j = g.i32_add(g.getLocal("x"), g.i32_const(5 * u)), Y = g.getLocal("r"), Z = g.i32_add(g.getLocal("r"), g.i32_const(u)), H = g.i32_add(g.getLocal("r"), g.i32_const(2 * u)), et = g.i32_add(g.getLocal("r"), g.i32_const(3 * u)), ft = g.i32_add(g.getLocal("r"), g.i32_const(4 * u)), _t = g.i32_add(g.getLocal("r"), g.i32_const(5 * u)), lt = g.i32_const(t.alloc(u)), bt = g.i32_const(t.alloc(u)), mt = g.i32_const(t.alloc(u)), Ot = g.i32_const(t.alloc(u)), Ct = g.i32_const(t.alloc(u)), wt = g.i32_const(t.alloc(u)), ht = g.i32_const(t.alloc(u)), qt = g.i32_const(t.alloc(u));
|
|
7522
7496
|
_.addCode(
|
|
7523
7497
|
// // t0 + t1*y = (z0 + z1*y)^2 = a^2
|
|
7524
7498
|
// tmp = z0 * z1;
|
|
7525
7499
|
// t0 = (z0 + z1) * (z0 + my_Fp6::non_residue * z1) - tmp - my_Fp6::non_residue * tmp;
|
|
7526
7500
|
// t1 = tmp + tmp;
|
|
7527
|
-
g.call(x + "_mul",
|
|
7501
|
+
g.call(x + "_mul", M, U, ht),
|
|
7528
7502
|
g.call(x + "_mulNR", U, lt),
|
|
7529
|
-
g.call(x + "_add",
|
|
7530
|
-
g.call(x + "_add",
|
|
7503
|
+
g.call(x + "_add", M, lt, lt),
|
|
7504
|
+
g.call(x + "_add", M, U, qt),
|
|
7531
7505
|
g.call(x + "_mul", qt, lt, lt),
|
|
7532
7506
|
g.call(x + "_mulNR", ht, qt),
|
|
7533
7507
|
g.call(x + "_add", ht, qt, qt),
|
|
@@ -7561,7 +7535,7 @@ var Cs = function(t, n) {
|
|
|
7561
7535
|
g.call(x + "_add", ht, ht, wt),
|
|
7562
7536
|
// For A
|
|
7563
7537
|
// z0 = 3 * t0 - 2 * z0
|
|
7564
|
-
g.call(x + "_sub", lt,
|
|
7538
|
+
g.call(x + "_sub", lt, M, Y),
|
|
7565
7539
|
g.call(x + "_add", Y, Y, Y),
|
|
7566
7540
|
g.call(x + "_add", lt, Y, Y),
|
|
7567
7541
|
// z1 = 3 * t1 + 2 * z1
|
|
@@ -7589,8 +7563,8 @@ var Cs = function(t, n) {
|
|
|
7589
7563
|
g.call(x + "_add", Ot, _t, _t)
|
|
7590
7564
|
);
|
|
7591
7565
|
}
|
|
7592
|
-
function Vt(_, g,
|
|
7593
|
-
const R = S(_).map((H) => H == -1 ? 255 : H), q = t.alloc(R), k = t.addFunction(e + "__cyclotomicExp_" +
|
|
7566
|
+
function Vt(_, g, M) {
|
|
7567
|
+
const R = S(_).map((H) => H == -1 ? 255 : H), q = t.alloc(R), k = t.addFunction(e + "__cyclotomicExp_" + M);
|
|
7594
7568
|
k.addParam("x", "i32"), k.addParam("r", "i32"), k.addLocal("bit", "i32"), k.addLocal("i", "i32");
|
|
7595
7569
|
const U = k.getCodeBuilder(), j = U.getLocal("x"), Y = U.getLocal("r"), Z = U.i32_const(t.alloc(l));
|
|
7596
7570
|
k.addCode(
|
|
@@ -7633,12 +7607,12 @@ var Cs = function(t, n) {
|
|
|
7633
7607
|
Ut(), Vt(h, I, "w0");
|
|
7634
7608
|
const _ = t.addFunction(e + "_finalExponentiation");
|
|
7635
7609
|
_.addParam("x", "i32"), _.addParam("r", "i32");
|
|
7636
|
-
const g = _.getCodeBuilder(),
|
|
7610
|
+
const g = _.getCodeBuilder(), M = g.getLocal("x"), R = g.getLocal("r"), q = g.i32_const(t.alloc(l)), k = g.i32_const(t.alloc(l)), U = g.i32_const(t.alloc(l)), j = g.i32_const(t.alloc(l)), Y = g.i32_const(t.alloc(l)), Z = g.i32_const(t.alloc(l)), H = g.i32_const(t.alloc(l));
|
|
7637
7611
|
_.addCode(
|
|
7638
7612
|
// let mut t0 = f.frobenius_map(6)
|
|
7639
|
-
g.call(J + "_frobeniusMap6",
|
|
7613
|
+
g.call(J + "_frobeniusMap6", M, q),
|
|
7640
7614
|
// let t1 = f.invert()
|
|
7641
|
-
g.call(J + "_inverse",
|
|
7615
|
+
g.call(J + "_inverse", M, k),
|
|
7642
7616
|
// let mut t2 = t0 * t1;
|
|
7643
7617
|
g.call(J + "_mul", q, k, U),
|
|
7644
7618
|
// t1 = t2.clone();
|
|
@@ -7696,61 +7670,61 @@ var Cs = function(t, n) {
|
|
|
7696
7670
|
function jt() {
|
|
7697
7671
|
const _ = t.addFunction(e + "_finalExponentiationOld");
|
|
7698
7672
|
_.addParam("x", "i32"), _.addParam("r", "i32");
|
|
7699
|
-
const
|
|
7673
|
+
const M = t.alloc(Et.bigInt2BytesLE(322277361516934140462891564586510139908379969514828494218366688025288661041104682794998680497580008899973249814104447692778988208376779573819485263026159588510513834876303014016798809919343532899164848730280942609956670917565618115867287399623286813270357901731510188149934363360381614501334086825442271920079363289954510565375378443704372994881406797882676971082200626541916413184642520269678897559532260949334760604962086348898118982248842634379637598665468817769075878555493752214492790122785850202957575200176084204422751485957336465472324810982833638490904279282696134323072515220044451592646885410572234451732790590013479358343841220074174848221722017083597872017638514103174122784843925578370430843522959600095676285723737049438346544753168912974976791528535276317256904336520179281145394686565050419250614107803233314658825463117900250701199181529205942363159325765991819433914303908860460720581408201373164047773794825411011922305820065611121544561808414055302212057471395719432072209245600258134364584636810093520285711072578721435517884103526483832733289802426157301542744476740008494780363354305116978805620671467071400711358839553375340724899735460480144599782014906586543813292157922220645089192130209334926661588737007768565838519456601560804957985667880395221049249803753582637708560n, 544)), R = _.getCodeBuilder();
|
|
7700
7674
|
_.addCode(
|
|
7701
|
-
R.call(J + "_exp", R.getLocal("x"), R.i32_const(
|
|
7675
|
+
R.call(J + "_exp", R.getLocal("x"), R.i32_const(M), R.i32_const(544), R.getLocal("r"))
|
|
7702
7676
|
);
|
|
7703
7677
|
}
|
|
7704
|
-
const
|
|
7678
|
+
const zt = t.alloc(c), Nt = t.alloc(w);
|
|
7705
7679
|
function Kt(_) {
|
|
7706
7680
|
const g = t.addFunction(e + "_pairingEq" + _);
|
|
7707
7681
|
for (let k = 0; k < _; k++)
|
|
7708
7682
|
g.addParam("p_" + k, "i32"), g.addParam("q_" + k, "i32");
|
|
7709
7683
|
g.addParam("c", "i32"), g.setReturnType("i32");
|
|
7710
|
-
const
|
|
7711
|
-
g.addCode(
|
|
7684
|
+
const M = g.getCodeBuilder(), R = M.i32_const(t.alloc(l)), q = M.i32_const(t.alloc(l));
|
|
7685
|
+
g.addCode(M.call(J + "_one", R));
|
|
7712
7686
|
for (let k = 0; k < _; k++)
|
|
7713
|
-
g.addCode(
|
|
7714
|
-
|
|
7715
|
-
|
|
7716
|
-
|
|
7687
|
+
g.addCode(M.call(e + "_prepareG1", M.getLocal("p_" + k), M.i32_const(zt))), g.addCode(M.call(e + "_prepareG2", M.getLocal("q_" + k), M.i32_const(Nt))), g.addCode(
|
|
7688
|
+
M.if(
|
|
7689
|
+
M.i32_eqz(M.call(z + "_inGroupAffine", M.i32_const(zt))),
|
|
7690
|
+
M.ret(M.i32_const(0))
|
|
7717
7691
|
),
|
|
7718
|
-
|
|
7719
|
-
|
|
7720
|
-
|
|
7692
|
+
M.if(
|
|
7693
|
+
M.i32_eqz(M.call(T + "_inGroupAffine", M.i32_const(Nt))),
|
|
7694
|
+
M.ret(M.i32_const(0))
|
|
7721
7695
|
)
|
|
7722
|
-
), g.addCode(
|
|
7723
|
-
g.addCode(
|
|
7696
|
+
), g.addCode(M.call(e + "_millerLoop", M.i32_const(zt), M.i32_const(Nt), q)), g.addCode(M.call(J + "_mul", R, q, R));
|
|
7697
|
+
g.addCode(M.call(e + "_finalExponentiation", R, R)), g.addCode(M.call(J + "_eq", R, M.getLocal("c")));
|
|
7724
7698
|
}
|
|
7725
7699
|
function en() {
|
|
7726
7700
|
const _ = t.addFunction(e + "_pairing");
|
|
7727
7701
|
_.addParam("p", "i32"), _.addParam("q", "i32"), _.addParam("r", "i32");
|
|
7728
|
-
const g = _.getCodeBuilder(),
|
|
7729
|
-
_.addCode(g.call(e + "_prepareG1", g.getLocal("p"), g.i32_const(
|
|
7702
|
+
const g = _.getCodeBuilder(), M = g.i32_const(t.alloc(l));
|
|
7703
|
+
_.addCode(g.call(e + "_prepareG1", g.getLocal("p"), g.i32_const(zt))), _.addCode(g.call(e + "_prepareG2", g.getLocal("q"), g.i32_const(Nt))), _.addCode(g.call(e + "_millerLoop", g.i32_const(zt), g.i32_const(Nt), M)), _.addCode(g.call(e + "_finalExponentiation", M, g.getLocal("r")));
|
|
7730
7704
|
}
|
|
7731
7705
|
function Zt() {
|
|
7732
|
-
const _ = t.addFunction(
|
|
7706
|
+
const _ = t.addFunction(T + "_inGroupAffine");
|
|
7733
7707
|
_.addParam("p", "i32"), _.setReturnType("i32");
|
|
7734
|
-
const g = _.getCodeBuilder(),
|
|
7708
|
+
const g = _.getCodeBuilder(), M = [
|
|
7735
7709
|
2001204777610833696708894912867952078278441409969503942666029068062015825245418932221343814564507832018947136279894n,
|
|
7736
7710
|
2001204777610833696708894912867952078278441409969503942666029068062015825245418932221343814564507832018947136279893n
|
|
7737
7711
|
], R = 4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939436n, q = [
|
|
7738
7712
|
2973677408986561043442465346520108879172042883009249989176415018091420807192182638567116318576472649347015917690530n,
|
|
7739
7713
|
2973677408986561043442465346520108879172042883009249989176415018091420807192182638567116318576472649347015917690530n
|
|
7740
7714
|
], k = g.i32_const(t.alloc([
|
|
7741
|
-
...Et.bigInt2BytesLE(F(
|
|
7742
|
-
...Et.bigInt2BytesLE(F(
|
|
7715
|
+
...Et.bigInt2BytesLE(F(M[0]), r),
|
|
7716
|
+
...Et.bigInt2BytesLE(F(M[1]), r)
|
|
7743
7717
|
])), U = g.i32_const(t.alloc(Et.bigInt2BytesLE(F(R), r))), j = g.i32_const(t.alloc([
|
|
7744
7718
|
...Et.bigInt2BytesLE(F(q[0]), r),
|
|
7745
7719
|
...Et.bigInt2BytesLE(F(q[1]), r)
|
|
7746
7720
|
])), Y = g.i32_const(t.alloc(Et.bigInt2BytesLE(h, 8))), Z = g.getLocal("p"), H = g.i32_add(g.getLocal("p"), g.i32_const(u)), et = g.i32_const(t.alloc(b)), ft = g.i32_const(t.alloc(u)), _t = g.i32_const(t.alloc(u)), lt = t.alloc(u * 2), bt = g.i32_const(lt), mt = g.i32_const(lt), Ot = g.i32_const(lt), Ct = g.i32_const(lt + b), wt = g.i32_const(lt + u), ht = g.i32_const(lt + u), qt = g.i32_const(lt + u + b), Ht = t.alloc(u * 3), Wt = g.i32_const(Ht), On = g.i32_const(Ht), pn = g.i32_const(Ht), Ln = g.i32_const(Ht + b), vn = g.i32_const(Ht + u), An = g.i32_const(Ht + u), bn = g.i32_const(Ht + u + b), Pn = g.i32_const(Ht + u * 2);
|
|
7747
7721
|
_.addCode(
|
|
7748
7722
|
g.if(
|
|
7749
|
-
g.call(
|
|
7723
|
+
g.call(T + "_isZeroAffine", g.getLocal("p")),
|
|
7750
7724
|
g.ret(g.i32_const(1))
|
|
7751
7725
|
),
|
|
7752
7726
|
g.if(
|
|
7753
|
-
g.i32_eqz(g.call(
|
|
7727
|
+
g.i32_eqz(g.call(T + "_inCurveAffine", g.getLocal("p"))),
|
|
7754
7728
|
g.ret(g.i32_const(0))
|
|
7755
7729
|
),
|
|
7756
7730
|
g.call(x + "_mul", Z, k, ft),
|
|
@@ -7772,54 +7746,54 @@ var Cs = function(t, n) {
|
|
|
7772
7746
|
g.call(P + "_add", An, bn, bn),
|
|
7773
7747
|
g.call(P + "_copy", et, An),
|
|
7774
7748
|
g.call(x + "_one", Pn),
|
|
7775
|
-
g.call(
|
|
7776
|
-
g.call(
|
|
7749
|
+
g.call(T + "_timesScalar", Wt, Y, g.i32_const(8), Wt),
|
|
7750
|
+
g.call(T + "_addMixed", Wt, bt, Wt),
|
|
7777
7751
|
g.ret(
|
|
7778
|
-
g.call(
|
|
7752
|
+
g.call(T + "_eqMixed", Wt, g.getLocal("p"))
|
|
7779
7753
|
)
|
|
7780
7754
|
);
|
|
7781
|
-
const ln = t.addFunction(
|
|
7755
|
+
const ln = t.addFunction(T + "_inGroup");
|
|
7782
7756
|
ln.addParam("pIn", "i32"), ln.setReturnType("i32");
|
|
7783
7757
|
const on = ln.getCodeBuilder(), wn = on.i32_const(t.alloc(u * 2));
|
|
7784
7758
|
ln.addCode(
|
|
7785
|
-
on.call(
|
|
7759
|
+
on.call(T + "_toAffine", on.getLocal("pIn"), wn),
|
|
7786
7760
|
on.ret(
|
|
7787
|
-
on.call(
|
|
7761
|
+
on.call(T + "_inGroupAffine", wn)
|
|
7788
7762
|
)
|
|
7789
7763
|
);
|
|
7790
7764
|
}
|
|
7791
7765
|
function G() {
|
|
7792
|
-
const _ = t.addFunction(
|
|
7766
|
+
const _ = t.addFunction(z + "_inGroupAffine");
|
|
7793
7767
|
_.addParam("p", "i32"), _.setReturnType("i32");
|
|
7794
|
-
const g = _.getCodeBuilder(),
|
|
7768
|
+
const g = _.getCodeBuilder(), M = 4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939436n, R = 793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620350n, q = (h * h - 1n) / 3n, k = g.i32_const(t.alloc(Et.bigInt2BytesLE(F(M), r))), U = g.i32_const(t.alloc(Et.bigInt2BytesLE(F(R), r))), j = g.i32_const(t.alloc(Et.bigInt2BytesLE(q, 16))), Y = g.getLocal("p"), Z = g.i32_add(g.getLocal("p"), g.i32_const(b)), H = t.alloc(b * 3), et = g.i32_const(H), ft = g.i32_const(H), _t = g.i32_const(H + b), lt = t.alloc(b * 2), bt = g.i32_const(lt), mt = g.i32_const(lt), Ot = g.i32_const(lt + b);
|
|
7795
7769
|
_.addCode(
|
|
7796
7770
|
g.if(
|
|
7797
|
-
g.call(
|
|
7771
|
+
g.call(z + "_isZeroAffine", g.getLocal("p")),
|
|
7798
7772
|
g.ret(g.i32_const(1))
|
|
7799
7773
|
),
|
|
7800
7774
|
g.if(
|
|
7801
|
-
g.i32_eqz(g.call(
|
|
7775
|
+
g.i32_eqz(g.call(z + "_inCurveAffine", g.getLocal("p"))),
|
|
7802
7776
|
g.ret(g.i32_const(0))
|
|
7803
7777
|
),
|
|
7804
7778
|
g.call(P + "_mul", Y, k, ft),
|
|
7805
7779
|
g.call(P + "_copy", Z, _t),
|
|
7806
7780
|
g.call(P + "_mul", Y, U, mt),
|
|
7807
7781
|
g.call(P + "_copy", Z, Ot),
|
|
7808
|
-
g.call(
|
|
7809
|
-
g.call(
|
|
7810
|
-
g.call(
|
|
7811
|
-
g.call(
|
|
7782
|
+
g.call(z + "_doubleAffine", et, et),
|
|
7783
|
+
g.call(z + "_subMixed", et, g.getLocal("p"), et),
|
|
7784
|
+
g.call(z + "_subMixed", et, bt, et),
|
|
7785
|
+
g.call(z + "_timesScalar", et, j, g.i32_const(16), et),
|
|
7812
7786
|
g.ret(
|
|
7813
|
-
g.call(
|
|
7787
|
+
g.call(z + "_eqMixed", et, bt)
|
|
7814
7788
|
)
|
|
7815
7789
|
);
|
|
7816
|
-
const Ct = t.addFunction(
|
|
7790
|
+
const Ct = t.addFunction(z + "_inGroup");
|
|
7817
7791
|
Ct.addParam("pIn", "i32"), Ct.setReturnType("i32");
|
|
7818
7792
|
const wt = Ct.getCodeBuilder(), ht = wt.i32_const(t.alloc(b * 2));
|
|
7819
7793
|
Ct.addCode(
|
|
7820
|
-
wt.call(
|
|
7794
|
+
wt.call(z + "_toAffine", wt.getLocal("pIn"), ht),
|
|
7821
7795
|
wt.ret(
|
|
7822
|
-
wt.call(
|
|
7796
|
+
wt.call(z + "_inGroupAffine", ht)
|
|
7823
7797
|
)
|
|
7824
7798
|
);
|
|
7825
7799
|
}
|
|
@@ -7828,7 +7802,7 @@ var Cs = function(t, n) {
|
|
|
7828
7802
|
G(), Zt(), It(), at(), N(), ut(), yt(), jt(), Dt();
|
|
7829
7803
|
for (let _ = 1; _ <= 5; _++)
|
|
7830
7804
|
Kt(_), t.exportFunction(e + "_pairingEq" + _);
|
|
7831
|
-
en(), t.exportFunction(e + "_pairing"), t.exportFunction(e + "_prepareG1"), t.exportFunction(e + "_prepareG2"), t.exportFunction(e + "_millerLoop"), t.exportFunction(e + "_finalExponentiation"), t.exportFunction(e + "_finalExponentiationOld"), t.exportFunction(e + "__cyclotomicSquare"), t.exportFunction(e + "__cyclotomicExp_w0"), t.exportFunction(K + "_mul1"), t.exportFunction(K + "_mul01"), t.exportFunction(J + "_mul014"), t.exportFunction(
|
|
7805
|
+
en(), t.exportFunction(e + "_pairing"), t.exportFunction(e + "_prepareG1"), t.exportFunction(e + "_prepareG2"), t.exportFunction(e + "_millerLoop"), t.exportFunction(e + "_finalExponentiation"), t.exportFunction(e + "_finalExponentiationOld"), t.exportFunction(e + "__cyclotomicSquare"), t.exportFunction(e + "__cyclotomicExp_w0"), t.exportFunction(K + "_mul1"), t.exportFunction(K + "_mul01"), t.exportFunction(J + "_mul014"), t.exportFunction(z + "_inGroupAffine"), t.exportFunction(z + "_inGroup"), t.exportFunction(T + "_inGroupAffine"), t.exportFunction(T + "_inGroup");
|
|
7832
7806
|
}, ms = hs, ws = Cs;
|
|
7833
7807
|
function Ve(o) {
|
|
7834
7808
|
if (typeof o == "bigint" || o.eq !== void 0)
|
|
@@ -7985,7 +7959,7 @@ var Ss = /* @__PURE__ */ Object.freeze({
|
|
|
7985
7959
|
unstringifyFElements: Ye
|
|
7986
7960
|
});
|
|
7987
7961
|
const Gt = 1 << 30;
|
|
7988
|
-
class
|
|
7962
|
+
class Qt {
|
|
7989
7963
|
constructor(t) {
|
|
7990
7964
|
this.buffers = [], this.byteLength = t;
|
|
7991
7965
|
for (let n = 0; n < t; n += Gt) {
|
|
@@ -8003,7 +7977,7 @@ class Mt {
|
|
|
8003
7977
|
const l = b + u > Gt ? Gt - b : u, C = new Uint8Array(this.buffers[r].buffer, this.buffers[r].byteOffset + b, l);
|
|
8004
7978
|
if (l == e)
|
|
8005
7979
|
return C.slice();
|
|
8006
|
-
d || (e <= Gt ? d = new Uint8Array(e) : d = new
|
|
7980
|
+
d || (e <= Gt ? d = new Uint8Array(e) : d = new Qt(e)), d.set(C, e - u), u = u - l, r++, b = 0;
|
|
8007
7981
|
}
|
|
8008
7982
|
return d;
|
|
8009
7983
|
}
|
|
@@ -8014,7 +7988,7 @@ class Mt {
|
|
|
8014
7988
|
return;
|
|
8015
7989
|
const i = Math.floor(n / Gt), s = Math.floor((n + e - 1) / Gt);
|
|
8016
7990
|
if (i == s)
|
|
8017
|
-
return t instanceof
|
|
7991
|
+
return t instanceof Qt && t.buffers.length == 1 ? this.buffers[i].set(t.buffers[0], n % Gt) : this.buffers[i].set(t, n % Gt);
|
|
8018
7992
|
let d = i, r = n % Gt, b = e;
|
|
8019
7993
|
for (; b > 0; ) {
|
|
8020
7994
|
const u = r + b > Gt ? Gt - r : b, l = t.slice(e - b, e - b + u);
|
|
@@ -8048,7 +8022,7 @@ function Cn(o, t, n, e) {
|
|
|
8048
8022
|
}
|
|
8049
8023
|
const u = await Promise.all(b);
|
|
8050
8024
|
let l;
|
|
8051
|
-
s instanceof
|
|
8025
|
+
s instanceof Qt ? l = new Qt(d * e) : l = new Uint8Array(d * e);
|
|
8052
8026
|
let C = 0;
|
|
8053
8027
|
for (let B = 0; B < u.length; B++)
|
|
8054
8028
|
l.set(u[B][0], C), C += u[B][0].byteLength;
|
|
@@ -8057,16 +8031,16 @@ function Cn(o, t, n, e) {
|
|
|
8057
8031
|
}
|
|
8058
8032
|
class jo {
|
|
8059
8033
|
constructor(t, n, e, i) {
|
|
8060
|
-
if (this.tm = t, this.prefix = n, this.p = i, this.n8 = e, this.type = "F1", this.m = 1, this.half =
|
|
8034
|
+
if (this.tm = t, this.prefix = n, this.p = i, this.n8 = e, this.type = "F1", this.m = 1, this.half = Qn(i, Fn), this.bitLength = Wn(i), this.mask = _n(ge(Fn, this.bitLength), Fn), this.pOp1 = t.alloc(e), this.pOp2 = t.alloc(e), this.pOp3 = t.alloc(e), this.tm.instance.exports[n + "_zero"](this.pOp1), this.zero = this.tm.getBuff(this.pOp1, this.n8), this.tm.instance.exports[n + "_one"](this.pOp1), this.one = this.tm.getBuff(this.pOp1, this.n8), this.negone = this.neg(this.one), this.two = this.add(this.one, this.one), this.n64 = Math.floor(e / 8), this.n32 = Math.floor(e / 4), this.n64 * 8 != this.n8)
|
|
8061
8035
|
throw new Error("n8 must be a multiple of 8");
|
|
8062
|
-
this.half =
|
|
8036
|
+
this.half = Qn(this.p, Fn), this.nqr = this.two;
|
|
8063
8037
|
let s = this.exp(this.nqr, this.half);
|
|
8064
8038
|
for (; !this.eq(s, this.negone); )
|
|
8065
8039
|
this.nqr = this.add(this.nqr, this.one), s = this.exp(this.nqr, this.half);
|
|
8066
8040
|
this.shift = this.mul(this.nqr, this.nqr), this.shiftInv = this.inv(this.shift), this.s = 0;
|
|
8067
8041
|
let d = _n(this.p, Fn);
|
|
8068
8042
|
for (; !_o(d); )
|
|
8069
|
-
this.s = this.s + 1, d =
|
|
8043
|
+
this.s = this.s + 1, d = Qn(d, Fn);
|
|
8070
8044
|
this.w = [], this.w[this.s] = this.exp(this.nqr, d);
|
|
8071
8045
|
for (let r = this.s - 1; r >= 0; r--)
|
|
8072
8046
|
this.w[r] = this.square(this.w[r + 1]);
|
|
@@ -8126,7 +8100,7 @@ class jo {
|
|
|
8126
8100
|
return this.op1("_sqrt", t);
|
|
8127
8101
|
}
|
|
8128
8102
|
exp(t, n) {
|
|
8129
|
-
return n instanceof Uint8Array || (n = Un(
|
|
8103
|
+
return n instanceof Uint8Array || (n = Un(Tt(n))), this.tm.setBuff(this.pOp1, t), this.tm.setBuff(this.pOp2, n), this.tm.instance.exports[this.prefix + "_exp"](this.pOp1, this.pOp2, n.byteLength, this.pOp3), this.tm.getBuff(this.pOp3, this.n8);
|
|
8130
8104
|
}
|
|
8131
8105
|
isNegative(t) {
|
|
8132
8106
|
return this.op1Bool("_isNegative", t);
|
|
@@ -8134,8 +8108,8 @@ class jo {
|
|
|
8134
8108
|
e(t, n) {
|
|
8135
8109
|
if (t instanceof Uint8Array)
|
|
8136
8110
|
return t;
|
|
8137
|
-
let e =
|
|
8138
|
-
|
|
8111
|
+
let e = Tt(t, n);
|
|
8112
|
+
Qi(e) ? (e = Ti(e), He(e, this.p) && (e = an(e, this.p)), e = _n(this.p, e)) : He(e, this.p) && (e = an(e, this.p));
|
|
8139
8113
|
const i = ca(e, this.n8);
|
|
8140
8114
|
return this.toMontgomery(i);
|
|
8141
8115
|
}
|
|
@@ -8211,7 +8185,7 @@ class jo {
|
|
|
8211
8185
|
}
|
|
8212
8186
|
const b = await Promise.all(r);
|
|
8213
8187
|
let u;
|
|
8214
|
-
t instanceof
|
|
8188
|
+
t instanceof Qt ? u = new Qt(s * i) : u = new Uint8Array(s * i);
|
|
8215
8189
|
let l = 0;
|
|
8216
8190
|
for (let C = 0; C < b.length; C++)
|
|
8217
8191
|
u.set(b[C][0], l), l += b[C][0].byteLength;
|
|
@@ -8280,7 +8254,7 @@ class $o {
|
|
|
8280
8254
|
return this.op1("_sqrt", t);
|
|
8281
8255
|
}
|
|
8282
8256
|
exp(t, n) {
|
|
8283
|
-
return n instanceof Uint8Array || (n = Un(
|
|
8257
|
+
return n instanceof Uint8Array || (n = Un(Tt(n))), this.tm.setBuff(this.pOp1, t), this.tm.setBuff(this.pOp2, n), this.tm.instance.exports[this.prefix + "_exp"](this.pOp1, this.pOp2, n.byteLength, this.pOp3), this.tm.getBuff(this.pOp3, this.n8);
|
|
8284
8258
|
}
|
|
8285
8259
|
e(t, n) {
|
|
8286
8260
|
if (t instanceof Uint8Array)
|
|
@@ -8376,7 +8350,7 @@ class Os {
|
|
|
8376
8350
|
return this.op1("_sqrt", t);
|
|
8377
8351
|
}
|
|
8378
8352
|
exp(t, n) {
|
|
8379
|
-
return n instanceof Uint8Array || (n = Un(
|
|
8353
|
+
return n instanceof Uint8Array || (n = Un(Tt(n))), this.tm.setBuff(this.pOp1, t), this.tm.setBuff(this.pOp2, n), this.tm.instance.exports[this.prefix + "_exp"](this.pOp1, this.pOp2, n.byteLength, this.pOp3), this.getBuff(this.pOp3, this.n8);
|
|
8380
8354
|
}
|
|
8381
8355
|
e(t, n) {
|
|
8382
8356
|
if (t instanceof Uint8Array)
|
|
@@ -8489,7 +8463,7 @@ class Yo {
|
|
|
8489
8463
|
throw new Error("invalid point size");
|
|
8490
8464
|
}
|
|
8491
8465
|
timesScalar(t, n) {
|
|
8492
|
-
n instanceof Uint8Array || (n = Un(
|
|
8466
|
+
n instanceof Uint8Array || (n = Un(Tt(n)));
|
|
8493
8467
|
let e;
|
|
8494
8468
|
if (t.byteLength == this.F.n8 * 3)
|
|
8495
8469
|
e = this.prefix + "_timesScalar";
|
|
@@ -8711,8 +8685,8 @@ function vs(o) {
|
|
|
8711
8685
|
break;
|
|
8712
8686
|
case "CALL": {
|
|
8713
8687
|
const E = [];
|
|
8714
|
-
for (let
|
|
8715
|
-
const x = l[P].params[
|
|
8688
|
+
for (let z = 0; z < l[P].params.length; z++) {
|
|
8689
|
+
const x = l[P].params[z];
|
|
8716
8690
|
typeof x.var < "u" ? E.push(C.vars[x.var] + (x.offset || 0)) : typeof x.val < "u" && E.push(x.val);
|
|
8717
8691
|
}
|
|
8718
8692
|
n.exports[l[P].fnName](...E);
|
|
@@ -8729,7 +8703,7 @@ function vs(o) {
|
|
|
8729
8703
|
}
|
|
8730
8704
|
return u;
|
|
8731
8705
|
}
|
|
8732
|
-
const
|
|
8706
|
+
const Qe = 25;
|
|
8733
8707
|
class Zo {
|
|
8734
8708
|
constructor() {
|
|
8735
8709
|
this.promise = new Promise((t, n) => {
|
|
@@ -8867,8 +8841,8 @@ if (globalThis?.Blob) {
|
|
|
8867
8841
|
} else
|
|
8868
8842
|
Ze = "data:application/javascript;base64," + globalThis.btoa(Jo);
|
|
8869
8843
|
async function qs(o, t) {
|
|
8870
|
-
const n = new
|
|
8871
|
-
n.memory = new WebAssembly.Memory({ initial:
|
|
8844
|
+
const n = new Qs();
|
|
8845
|
+
n.memory = new WebAssembly.Memory({ initial: Qe }), n.u8 = new Uint8Array(n.memory.buffer), n.u32 = new Uint32Array(n.memory.buffer);
|
|
8872
8846
|
const e = await WebAssembly.compile(o.code);
|
|
8873
8847
|
if (n.instance = await WebAssembly.instantiate(e, {
|
|
8874
8848
|
env: {
|
|
@@ -8877,7 +8851,7 @@ async function qs(o, t) {
|
|
|
8877
8851
|
}), globalThis?.Worker || (t = !0), n.singleThread = t, n.initalPFree = n.u32[0], n.pq = o.pq, n.pr = o.pr, n.pG1gen = o.pG1gen, n.pG1zero = o.pG1zero, n.pG2gen = o.pG2gen, n.pG2zero = o.pG2zero, n.pOneT = o.pOneT, t)
|
|
8878
8852
|
n.code = o.code, n.taskManager = vs(), await n.taskManager([{
|
|
8879
8853
|
cmd: "INIT",
|
|
8880
|
-
init:
|
|
8854
|
+
init: Qe,
|
|
8881
8855
|
code: n.code.slice()
|
|
8882
8856
|
}]), n.concurrency = 1;
|
|
8883
8857
|
else {
|
|
@@ -8891,7 +8865,7 @@ async function qs(o, t) {
|
|
|
8891
8865
|
const b = o.code.slice();
|
|
8892
8866
|
d.push(n.postAction(r, [{
|
|
8893
8867
|
cmd: "INIT",
|
|
8894
|
-
init:
|
|
8868
|
+
init: Qe,
|
|
8895
8869
|
code: b
|
|
8896
8870
|
}], [b.buffer]));
|
|
8897
8871
|
}
|
|
@@ -8905,7 +8879,7 @@ async function qs(o, t) {
|
|
|
8905
8879
|
};
|
|
8906
8880
|
}
|
|
8907
8881
|
}
|
|
8908
|
-
class
|
|
8882
|
+
class Qs {
|
|
8909
8883
|
constructor() {
|
|
8910
8884
|
this.actionQueue = [], this.oldPFree = 0;
|
|
8911
8885
|
}
|
|
@@ -8969,7 +8943,7 @@ class Ms {
|
|
|
8969
8943
|
await Ps(200);
|
|
8970
8944
|
}
|
|
8971
8945
|
}
|
|
8972
|
-
function
|
|
8946
|
+
function Me(o, t) {
|
|
8973
8947
|
const n = o[t], e = o.Fr, i = o.tm;
|
|
8974
8948
|
o[t].batchApplyKey = async function(s, d, r, b, u) {
|
|
8975
8949
|
b = b || "affine", u = u || "affine";
|
|
@@ -8982,7 +8956,7 @@ function Qe(o, t) {
|
|
|
8982
8956
|
l = "frm_batchApplyKey", B = n.n8, A = n.n8, O = n.n8;
|
|
8983
8957
|
else
|
|
8984
8958
|
throw new Error("Invalid group: " + t);
|
|
8985
|
-
const P = Math.floor(s.byteLength / B), E = Math.floor(P / i.concurrency),
|
|
8959
|
+
const P = Math.floor(s.byteLength / B), E = Math.floor(P / i.concurrency), z = [];
|
|
8986
8960
|
r = e.e(r);
|
|
8987
8961
|
let x = e.e(d);
|
|
8988
8962
|
for (let F = 0; F < i.concurrency; F++) {
|
|
@@ -9012,18 +8986,18 @@ function Qe(o, t) {
|
|
|
9012
8986
|
{ val: f },
|
|
9013
8987
|
{ var: 3 }
|
|
9014
8988
|
]
|
|
9015
|
-
}), L.push({ cmd: "GET", out: 0, var: 3, len: f * O }),
|
|
8989
|
+
}), L.push({ cmd: "GET", out: 0, var: 3, len: f * O }), z.push(i.queueAction(L)), x = e.mul(x, e.exp(r, f));
|
|
9016
8990
|
}
|
|
9017
|
-
const ot = await Promise.all(
|
|
9018
|
-
let
|
|
9019
|
-
s instanceof
|
|
8991
|
+
const ot = await Promise.all(z);
|
|
8992
|
+
let T;
|
|
8993
|
+
s instanceof Qt ? T = new Qt(P * O) : T = new Uint8Array(P * O);
|
|
9020
8994
|
let rt = 0;
|
|
9021
8995
|
for (let F = 0; F < ot.length; F++)
|
|
9022
|
-
|
|
9023
|
-
return
|
|
8996
|
+
T.set(ot[F][0], rt), rt += ot[F][0].byteLength;
|
|
8997
|
+
return T;
|
|
9024
8998
|
};
|
|
9025
8999
|
}
|
|
9026
|
-
function
|
|
9000
|
+
function Ms(o) {
|
|
9027
9001
|
const t = o.tm;
|
|
9028
9002
|
o.pairing = function(e, i) {
|
|
9029
9003
|
t.startSyncOp();
|
|
@@ -9145,8 +9119,8 @@ function Xo(o, t) {
|
|
|
9145
9119
|
const O = Math.floor(r.byteLength / A);
|
|
9146
9120
|
if (O * A != r.byteLength)
|
|
9147
9121
|
throw new Error("Scalar size does not match");
|
|
9148
|
-
const P = Wo[Jt(A)], E = Math.floor((O * 8 - 1) / P) + 1,
|
|
9149
|
-
for (let
|
|
9122
|
+
const P = Wo[Jt(A)], E = Math.floor((O * 8 - 1) / P) + 1, z = [];
|
|
9123
|
+
for (let T = 0; T < E; T++) {
|
|
9150
9124
|
const rt = [
|
|
9151
9125
|
{ cmd: "ALLOCSET", var: 0, buff: d },
|
|
9152
9126
|
{ cmd: "ALLOCSET", var: 1, buff: r },
|
|
@@ -9156,23 +9130,23 @@ function Xo(o, t) {
|
|
|
9156
9130
|
{ var: 1 },
|
|
9157
9131
|
{ val: O },
|
|
9158
9132
|
{ val: A },
|
|
9159
|
-
{ val:
|
|
9160
|
-
{ val: Math.min(O * 8 -
|
|
9133
|
+
{ val: T * P },
|
|
9134
|
+
{ val: Math.min(O * 8 - T * P, P) },
|
|
9161
9135
|
{ var: 2 }
|
|
9162
9136
|
] },
|
|
9163
9137
|
{ cmd: "GET", out: 0, var: 2, len: n.F.n8 * 3 }
|
|
9164
9138
|
];
|
|
9165
|
-
|
|
9139
|
+
z.push(
|
|
9166
9140
|
n.tm.queueAction(rt)
|
|
9167
9141
|
);
|
|
9168
9142
|
}
|
|
9169
|
-
const x = await Promise.all(
|
|
9143
|
+
const x = await Promise.all(z);
|
|
9170
9144
|
let ot = n.zero;
|
|
9171
|
-
for (let
|
|
9145
|
+
for (let T = x.length - 1; T >= 0; T--) {
|
|
9172
9146
|
if (!n.isZero(ot))
|
|
9173
9147
|
for (let rt = 0; rt < P; rt++)
|
|
9174
9148
|
ot = n.double(ot);
|
|
9175
|
-
ot = n.add(ot, x[
|
|
9149
|
+
ot = n.add(ot, x[T][0]);
|
|
9176
9150
|
}
|
|
9177
9151
|
return ot;
|
|
9178
9152
|
}
|
|
@@ -9190,19 +9164,19 @@ function Xo(o, t) {
|
|
|
9190
9164
|
const P = Math.floor(r.byteLength / O);
|
|
9191
9165
|
if (P * O != r.byteLength)
|
|
9192
9166
|
throw new Error("Scalar size does not match");
|
|
9193
|
-
const E = Wo[Jt(O)],
|
|
9167
|
+
const E = Wo[Jt(O)], z = Math.floor((P * 8 - 1) / E) + 1;
|
|
9194
9168
|
let x;
|
|
9195
|
-
x = Math.floor(O / (e.concurrency /
|
|
9169
|
+
x = Math.floor(O / (e.concurrency / z)), x > 4194304 && (x = 4194304), x < 1024 && (x = 1024);
|
|
9196
9170
|
const ot = [];
|
|
9197
9171
|
for (let F = 0; F < O; F += x) {
|
|
9198
9172
|
u && u.debug(`Multiexp start: ${l}: ${F}/${O}`);
|
|
9199
9173
|
const f = Math.min(O - F, x), L = d.slice(F * A, (F + f) * A), V = r.slice(F * P, (F + f) * P);
|
|
9200
9174
|
ot.push(i(L, V, b, u, l).then(($) => (u && u.debug(`Multiexp end: ${l}: ${F}/${O}`), $)));
|
|
9201
9175
|
}
|
|
9202
|
-
const
|
|
9176
|
+
const T = await Promise.all(ot);
|
|
9203
9177
|
let rt = n.zero;
|
|
9204
|
-
for (let F =
|
|
9205
|
-
rt = n.add(rt,
|
|
9178
|
+
for (let F = T.length - 1; F >= 0; F--)
|
|
9179
|
+
rt = n.add(rt, T[F]);
|
|
9206
9180
|
return rt;
|
|
9207
9181
|
}
|
|
9208
9182
|
n.multiExp = async function(r, b, u, l) {
|
|
@@ -9216,8 +9190,8 @@ function Ue(o, t) {
|
|
|
9216
9190
|
async function s(u, l, C, B, A, O) {
|
|
9217
9191
|
C = C || "affine", B = B || "affine";
|
|
9218
9192
|
const P = 14;
|
|
9219
|
-
let E,
|
|
9220
|
-
t == "G1" ? (C == "affine" ? (E = n.F.n8 * 2, ot = "g1m_batchToJacobian") : E = n.F.n8 * 3,
|
|
9193
|
+
let E, z, x, ot, T, rt, F, f;
|
|
9194
|
+
t == "G1" ? (C == "affine" ? (E = n.F.n8 * 2, ot = "g1m_batchToJacobian") : E = n.F.n8 * 3, z = n.F.n8 * 3, l && (f = "g1m_fftFinal"), F = "g1m_fftJoin", rt = "g1m_fftMix", B == "affine" ? (x = n.F.n8 * 2, T = "g1m_batchToAffine") : x = n.F.n8 * 3) : t == "G2" ? (C == "affine" ? (E = n.F.n8 * 2, ot = "g2m_batchToJacobian") : E = n.F.n8 * 3, z = n.F.n8 * 3, l && (f = "g2m_fftFinal"), F = "g2m_fftJoin", rt = "g2m_fftMix", B == "affine" ? (x = n.F.n8 * 2, T = "g2m_batchToAffine") : x = n.F.n8 * 3) : t == "Fr" && (E = n.n8, z = n.n8, x = n.n8, l && (f = "frm_fftFinal"), rt = "frm_fftMix", F = "frm_fftJoin");
|
|
9221
9195
|
let L = !1;
|
|
9222
9196
|
Array.isArray(u) ? (u = Io(u, E), L = !0) : u = u.slice(0, u.byteLength);
|
|
9223
9197
|
const V = u.byteLength / E, $ = Jt(V);
|
|
@@ -9229,7 +9203,7 @@ function Ue(o, t) {
|
|
|
9229
9203
|
}
|
|
9230
9204
|
let X;
|
|
9231
9205
|
l && (X = e.inv(e.e(V)));
|
|
9232
|
-
let
|
|
9206
|
+
let Q;
|
|
9233
9207
|
la(u, E);
|
|
9234
9208
|
let y, v = Math.min(1 << P, V), D = V / v;
|
|
9235
9209
|
for (; D < i.concurrency && v >= 16; )
|
|
@@ -9238,7 +9212,7 @@ function Ue(o, t) {
|
|
|
9238
9212
|
for (let K = 0; K < D; K++) {
|
|
9239
9213
|
A && A.debug(`${O}: fft ${$} mix start: ${K}/${D}`);
|
|
9240
9214
|
const ct = [];
|
|
9241
|
-
ct.push({ cmd: "ALLOC", var: 0, len:
|
|
9215
|
+
ct.push({ cmd: "ALLOC", var: 0, len: z * v });
|
|
9242
9216
|
const J = u.slice(v * K * E, v * (K + 1) * E);
|
|
9243
9217
|
ct.push({ cmd: "SET", var: 0, buff: J }), ot && ct.push({ cmd: "CALL", fnName: ot, params: [{ var: 0 }, { val: v }, { var: 0 }] });
|
|
9244
9218
|
for (let st = 1; st <= it; st++)
|
|
@@ -9247,7 +9221,7 @@ function Ue(o, t) {
|
|
|
9247
9221
|
{ var: 0 },
|
|
9248
9222
|
{ val: v },
|
|
9249
9223
|
{ var: 1 }
|
|
9250
|
-
] })),
|
|
9224
|
+
] })), T && ct.push({ cmd: "CALL", fnName: T, params: [{ var: 0 }, { val: v }, { var: 0 }] }), ct.push({ cmd: "GET", out: 0, var: 0, len: v * x })) : ct.push({ cmd: "GET", out: 0, var: 0, len: z * v }), nt.push(i.queueAction(ct).then((st) => (A && A.debug(`${O}: fft ${$} mix end: ${K}/${D}`), st)));
|
|
9251
9225
|
}
|
|
9252
9226
|
y = await Promise.all(nt);
|
|
9253
9227
|
for (let K = 0; K < D; K++)
|
|
@@ -9272,7 +9246,7 @@ function Ue(o, t) {
|
|
|
9272
9246
|
{ var: 1 },
|
|
9273
9247
|
{ val: v },
|
|
9274
9248
|
{ var: 4 }
|
|
9275
|
-
] })),
|
|
9249
|
+
] })), T && (w.push({ cmd: "CALL", fnName: T, params: [{ var: 0 }, { val: v }, { var: 0 }] }), w.push({ cmd: "CALL", fnName: T, params: [{ var: 1 }, { val: v }, { var: 1 }] })), w.push({ cmd: "GET", out: 0, var: 0, len: v * x }), w.push({ cmd: "GET", out: 1, var: 1, len: v * x })) : (w.push({ cmd: "GET", out: 0, var: 0, len: v * z }), w.push({ cmd: "GET", out: 1, var: 1, len: v * z })), st.push(i.queueAction(w).then((I) => (A && A.debug(`${O}: fft ${$} join ${K}/${$} ${Bt + 1}/${ct} ${pt}/${J / 2}`), I)));
|
|
9276
9250
|
}
|
|
9277
9251
|
const At = await Promise.all(st);
|
|
9278
9252
|
for (let Bt = 0; Bt < ct; Bt++)
|
|
@@ -9281,43 +9255,43 @@ function Ue(o, t) {
|
|
|
9281
9255
|
y[p] = m[0], y[a] = m[1];
|
|
9282
9256
|
}
|
|
9283
9257
|
}
|
|
9284
|
-
if (u instanceof
|
|
9285
|
-
|
|
9258
|
+
if (u instanceof Qt ? Q = new Qt(V * x) : Q = new Uint8Array(V * x), l) {
|
|
9259
|
+
Q.set(y[0].slice((v - 1) * x));
|
|
9286
9260
|
let K = x;
|
|
9287
9261
|
for (let ct = D - 1; ct > 0; ct--)
|
|
9288
|
-
|
|
9289
|
-
|
|
9262
|
+
Q.set(y[ct], K), K += v * x, delete y[ct];
|
|
9263
|
+
Q.set(y[0].slice(0, (v - 1) * x), K), delete y[0];
|
|
9290
9264
|
} else
|
|
9291
9265
|
for (let K = 0; K < D; K++)
|
|
9292
|
-
|
|
9293
|
-
return L ? he(
|
|
9266
|
+
Q.set(y[K], v * x * K), delete y[K];
|
|
9267
|
+
return L ? he(Q, x) : Q;
|
|
9294
9268
|
}
|
|
9295
9269
|
async function d(u, l, C, B, A) {
|
|
9296
9270
|
let O, P;
|
|
9297
9271
|
O = u.slice(0, u.byteLength / 2), P = u.slice(u.byteLength / 2, u.byteLength);
|
|
9298
9272
|
const E = [];
|
|
9299
9273
|
[O, P] = await b(O, P, "fftJoinExt", e.one, e.shift, l, "jacobian", B, A), E.push(s(O, !1, "jacobian", C, B, A)), E.push(s(P, !1, "jacobian", C, B, A));
|
|
9300
|
-
const
|
|
9274
|
+
const z = await Promise.all(E);
|
|
9301
9275
|
let x;
|
|
9302
|
-
return
|
|
9276
|
+
return z[0].byteLength > 1 << 28 ? x = new Qt(z[0].byteLength * 2) : x = new Uint8Array(z[0].byteLength * 2), x.set(z[0]), x.set(z[1], z[0].byteLength), x;
|
|
9303
9277
|
}
|
|
9304
9278
|
async function r(u, l, C, B, A) {
|
|
9305
9279
|
let O, P;
|
|
9306
9280
|
O = u.slice(0, u.byteLength / 2), P = u.slice(u.byteLength / 2, u.byteLength);
|
|
9307
9281
|
const E = [];
|
|
9308
9282
|
E.push(s(O, !0, l, "jacobian", B, A)), E.push(s(P, !0, l, "jacobian", B, A)), [O, P] = await Promise.all(E);
|
|
9309
|
-
const
|
|
9283
|
+
const z = await b(O, P, "fftJoinExtInv", e.one, e.shiftInv, "jacobian", C, B, A);
|
|
9310
9284
|
let x;
|
|
9311
|
-
return
|
|
9285
|
+
return z[0].byteLength > 1 << 28 ? x = new Qt(z[0].byteLength * 2) : x = new Uint8Array(z[0].byteLength * 2), x.set(z[0]), x.set(z[1], z[0].byteLength), x;
|
|
9312
9286
|
}
|
|
9313
|
-
async function b(u, l, C, B, A, O, P, E,
|
|
9314
|
-
let
|
|
9287
|
+
async function b(u, l, C, B, A, O, P, E, z) {
|
|
9288
|
+
let T, rt, F, f, L, V;
|
|
9315
9289
|
if (t == "G1")
|
|
9316
|
-
O == "affine" ? (L = n.F.n8 * 2, rt = "g1m_batchToJacobian") : L = n.F.n8 * 3, V = n.F.n8 * 3,
|
|
9290
|
+
O == "affine" ? (L = n.F.n8 * 2, rt = "g1m_batchToJacobian") : L = n.F.n8 * 3, V = n.F.n8 * 3, T = "g1m_" + C, P == "affine" ? (F = "g1m_batchToAffine", f = n.F.n8 * 2) : f = n.F.n8 * 3;
|
|
9317
9291
|
else if (t == "G2")
|
|
9318
|
-
O == "affine" ? (L = n.F.n8 * 2, rt = "g2m_batchToJacobian") : L = n.F.n8 * 3,
|
|
9292
|
+
O == "affine" ? (L = n.F.n8 * 2, rt = "g2m_batchToJacobian") : L = n.F.n8 * 3, T = "g2m_" + C, V = n.F.n8 * 3, P == "affine" ? (F = "g2m_batchToAffine", f = n.F.n8 * 2) : f = n.F.n8 * 3;
|
|
9319
9293
|
else if (t == "Fr")
|
|
9320
|
-
L = e.n8, f = e.n8, V = e.n8,
|
|
9294
|
+
L = e.n8, f = e.n8, V = e.n8, T = "frm_" + C;
|
|
9321
9295
|
else
|
|
9322
9296
|
throw new Error("Invalid group");
|
|
9323
9297
|
if (u.byteLength != l.byteLength)
|
|
@@ -9327,24 +9301,24 @@ function Ue(o, t) {
|
|
|
9327
9301
|
throw new Error("Invalid number of points");
|
|
9328
9302
|
let X = Math.floor($ / i.concurrency);
|
|
9329
9303
|
X < 16 && (X = 16), X > 65536 && (X = 65536);
|
|
9330
|
-
const
|
|
9304
|
+
const Q = [];
|
|
9331
9305
|
for (let nt = 0; nt < $; nt += X) {
|
|
9332
|
-
E && E.debug(`${
|
|
9306
|
+
E && E.debug(`${z}: fftJoinExt Start: ${nt}/${$}`);
|
|
9333
9307
|
const K = Math.min($ - nt, X), ct = e.mul(B, e.exp(A, nt)), J = [], st = u.slice(nt * L, (nt + K) * L), At = l.slice(nt * L, (nt + K) * L);
|
|
9334
|
-
J.push({ cmd: "ALLOC", var: 0, len: V * K }), J.push({ cmd: "SET", var: 0, buff: st }), J.push({ cmd: "ALLOC", var: 1, len: V * K }), J.push({ cmd: "SET", var: 1, buff: At }), J.push({ cmd: "ALLOCSET", var: 2, buff: ct }), J.push({ cmd: "ALLOCSET", var: 3, buff: A }), rt && (J.push({ cmd: "CALL", fnName: rt, params: [{ var: 0 }, { val: K }, { var: 0 }] }), J.push({ cmd: "CALL", fnName: rt, params: [{ var: 1 }, { val: K }, { var: 1 }] })), J.push({ cmd: "CALL", fnName:
|
|
9308
|
+
J.push({ cmd: "ALLOC", var: 0, len: V * K }), J.push({ cmd: "SET", var: 0, buff: st }), J.push({ cmd: "ALLOC", var: 1, len: V * K }), J.push({ cmd: "SET", var: 1, buff: At }), J.push({ cmd: "ALLOCSET", var: 2, buff: ct }), J.push({ cmd: "ALLOCSET", var: 3, buff: A }), rt && (J.push({ cmd: "CALL", fnName: rt, params: [{ var: 0 }, { val: K }, { var: 0 }] }), J.push({ cmd: "CALL", fnName: rt, params: [{ var: 1 }, { val: K }, { var: 1 }] })), J.push({ cmd: "CALL", fnName: T, params: [
|
|
9335
9309
|
{ var: 0 },
|
|
9336
9310
|
{ var: 1 },
|
|
9337
9311
|
{ val: K },
|
|
9338
9312
|
{ var: 2 },
|
|
9339
9313
|
{ var: 3 },
|
|
9340
9314
|
{ val: e.s }
|
|
9341
|
-
] }), F && (J.push({ cmd: "CALL", fnName: F, params: [{ var: 0 }, { val: K }, { var: 0 }] }), J.push({ cmd: "CALL", fnName: F, params: [{ var: 1 }, { val: K }, { var: 1 }] })), J.push({ cmd: "GET", out: 0, var: 0, len: K * f }), J.push({ cmd: "GET", out: 1, var: 1, len: K * f }),
|
|
9342
|
-
i.queueAction(J).then((Bt) => (E && E.debug(`${
|
|
9315
|
+
] }), F && (J.push({ cmd: "CALL", fnName: F, params: [{ var: 0 }, { val: K }, { var: 0 }] }), J.push({ cmd: "CALL", fnName: F, params: [{ var: 1 }, { val: K }, { var: 1 }] })), J.push({ cmd: "GET", out: 0, var: 0, len: K * f }), J.push({ cmd: "GET", out: 1, var: 1, len: K * f }), Q.push(
|
|
9316
|
+
i.queueAction(J).then((Bt) => (E && E.debug(`${z}: fftJoinExt End: ${nt}/${$}`), Bt))
|
|
9343
9317
|
);
|
|
9344
9318
|
}
|
|
9345
|
-
const y = await Promise.all(
|
|
9319
|
+
const y = await Promise.all(Q);
|
|
9346
9320
|
let v, D;
|
|
9347
|
-
$ * f > 1 << 28 ? (v = new
|
|
9321
|
+
$ * f > 1 << 28 ? (v = new Qt($ * f), D = new Qt($ * f)) : (v = new Uint8Array($ * f), D = new Uint8Array($ * f));
|
|
9348
9322
|
let it = 0;
|
|
9349
9323
|
for (let nt = 0; nt < y.length; nt++)
|
|
9350
9324
|
v.set(y[nt][0], it), D.set(y[nt][1], it), it += y[nt][0].byteLength;
|
|
@@ -9372,13 +9346,13 @@ function Ue(o, t) {
|
|
|
9372
9346
|
return await n.ifft(u, l, C, B, A);
|
|
9373
9347
|
if (E > e.s + 1)
|
|
9374
9348
|
throw B && B.error("lagrangeEvaluations input too big"), new Error("lagrangeEvaluations input too big");
|
|
9375
|
-
let
|
|
9376
|
-
const ot = e.exp(e.shift, P / 2),
|
|
9377
|
-
[
|
|
9349
|
+
let z = u.slice(0, u.byteLength / 2), x = u.slice(u.byteLength / 2, u.byteLength);
|
|
9350
|
+
const ot = e.exp(e.shift, P / 2), T = e.inv(e.sub(e.one, ot));
|
|
9351
|
+
[z, x] = await b(z, x, "prepareLagrangeEvaluation", T, e.shiftInv, l, "jacobian", B, A + " prep");
|
|
9378
9352
|
const rt = [];
|
|
9379
|
-
rt.push(s(
|
|
9353
|
+
rt.push(s(z, !0, "jacobian", C, B, A + " t0")), rt.push(s(x, !0, "jacobian", C, B, A + " t1")), [z, x] = await Promise.all(rt);
|
|
9380
9354
|
let F;
|
|
9381
|
-
return
|
|
9355
|
+
return z.byteLength > 1 << 28 ? F = new Qt(z.byteLength * 2) : F = new Uint8Array(z.byteLength * 2), F.set(z), F.set(x, z.byteLength), F;
|
|
9382
9356
|
}, n.fftMix = async function(l) {
|
|
9383
9357
|
const C = n.F.n8 * 3;
|
|
9384
9358
|
let B, A;
|
|
@@ -9393,45 +9367,45 @@ function Ue(o, t) {
|
|
|
9393
9367
|
const O = Math.floor(l.byteLength / C), P = Jt(O);
|
|
9394
9368
|
let E = 1 << Jt(i.concurrency);
|
|
9395
9369
|
O <= E * 2 && (E = 1);
|
|
9396
|
-
const
|
|
9370
|
+
const z = O / E, x = Jt(z), ot = [];
|
|
9397
9371
|
for (let L = 0; L < E; L++) {
|
|
9398
|
-
const V = [], $ = l.slice(L *
|
|
9372
|
+
const V = [], $ = l.slice(L * z * C, (L + 1) * z * C);
|
|
9399
9373
|
V.push({ cmd: "ALLOCSET", var: 0, buff: $ });
|
|
9400
9374
|
for (let X = 1; X <= x; X++)
|
|
9401
9375
|
V.push({ cmd: "CALL", fnName: B, params: [
|
|
9402
9376
|
{ var: 0 },
|
|
9403
|
-
{ val:
|
|
9377
|
+
{ val: z },
|
|
9404
9378
|
{ val: X }
|
|
9405
9379
|
] });
|
|
9406
|
-
V.push({ cmd: "GET", out: 0, var: 0, len:
|
|
9380
|
+
V.push({ cmd: "GET", out: 0, var: 0, len: z * C }), ot.push(
|
|
9407
9381
|
i.queueAction(V)
|
|
9408
9382
|
);
|
|
9409
9383
|
}
|
|
9410
|
-
const
|
|
9411
|
-
for (let L = 0; L <
|
|
9412
|
-
rt[L] =
|
|
9384
|
+
const T = await Promise.all(ot), rt = [];
|
|
9385
|
+
for (let L = 0; L < T.length; L++)
|
|
9386
|
+
rt[L] = T[L][0];
|
|
9413
9387
|
for (let L = x + 1; L <= P; L++) {
|
|
9414
9388
|
const V = 1 << P - L, $ = E / V, X = [];
|
|
9415
9389
|
for (let y = 0; y < V; y++)
|
|
9416
9390
|
for (let v = 0; v < $ / 2; v++) {
|
|
9417
|
-
const D = e.exp(e.w[L], v *
|
|
9391
|
+
const D = e.exp(e.w[L], v * z), it = e.w[L], nt = y * $ + v, K = y * $ + v + $ / 2, ct = [];
|
|
9418
9392
|
ct.push({ cmd: "ALLOCSET", var: 0, buff: rt[nt] }), ct.push({ cmd: "ALLOCSET", var: 1, buff: rt[K] }), ct.push({ cmd: "ALLOCSET", var: 2, buff: D }), ct.push({ cmd: "ALLOCSET", var: 3, buff: it }), ct.push({ cmd: "CALL", fnName: A, params: [
|
|
9419
9393
|
{ var: 0 },
|
|
9420
9394
|
{ var: 1 },
|
|
9421
|
-
{ val:
|
|
9395
|
+
{ val: z },
|
|
9422
9396
|
{ var: 2 },
|
|
9423
9397
|
{ var: 3 }
|
|
9424
|
-
] }), ct.push({ cmd: "GET", out: 0, var: 0, len:
|
|
9398
|
+
] }), ct.push({ cmd: "GET", out: 0, var: 0, len: z * C }), ct.push({ cmd: "GET", out: 1, var: 1, len: z * C }), X.push(i.queueAction(ct));
|
|
9425
9399
|
}
|
|
9426
|
-
const
|
|
9400
|
+
const Q = await Promise.all(X);
|
|
9427
9401
|
for (let y = 0; y < V; y++)
|
|
9428
9402
|
for (let v = 0; v < $ / 2; v++) {
|
|
9429
|
-
const D = y * $ + v, it = y * $ + v + $ / 2, nt =
|
|
9403
|
+
const D = y * $ + v, it = y * $ + v + $ / 2, nt = Q.shift();
|
|
9430
9404
|
rt[D] = nt[0], rt[it] = nt[1];
|
|
9431
9405
|
}
|
|
9432
9406
|
}
|
|
9433
9407
|
let F;
|
|
9434
|
-
l instanceof
|
|
9408
|
+
l instanceof Qt ? F = new Qt(O * C) : F = new Uint8Array(O * C);
|
|
9435
9409
|
let f = 0;
|
|
9436
9410
|
for (let L = 0; L < E; L++)
|
|
9437
9411
|
F.set(rt[L], f), f += rt[L].byteLength;
|
|
@@ -9452,12 +9426,12 @@ function Ue(o, t) {
|
|
|
9452
9426
|
const E = Math.floor(l.byteLength / O);
|
|
9453
9427
|
if (E != 1 << Jt(E))
|
|
9454
9428
|
throw new Error("Invalid number of points");
|
|
9455
|
-
let
|
|
9456
|
-
E <=
|
|
9457
|
-
const x = E /
|
|
9458
|
-
for (let L = 0; L <
|
|
9459
|
-
const V = [], $ = e.mul(B, e.exp(A, L * x)), X = l.slice(L * x * O, (L + 1) * x * O),
|
|
9460
|
-
V.push({ cmd: "ALLOCSET", var: 0, buff: X }), V.push({ cmd: "ALLOCSET", var: 1, buff:
|
|
9429
|
+
let z = 1 << Jt(i.concurrency);
|
|
9430
|
+
E <= z * 2 && (z = 1);
|
|
9431
|
+
const x = E / z, ot = [];
|
|
9432
|
+
for (let L = 0; L < z; L++) {
|
|
9433
|
+
const V = [], $ = e.mul(B, e.exp(A, L * x)), X = l.slice(L * x * O, (L + 1) * x * O), Q = C.slice(L * x * O, (L + 1) * x * O);
|
|
9434
|
+
V.push({ cmd: "ALLOCSET", var: 0, buff: X }), V.push({ cmd: "ALLOCSET", var: 1, buff: Q }), V.push({ cmd: "ALLOCSET", var: 2, buff: $ }), V.push({ cmd: "ALLOCSET", var: 3, buff: A }), V.push({ cmd: "CALL", fnName: P, params: [
|
|
9461
9435
|
{ var: 0 },
|
|
9462
9436
|
{ var: 1 },
|
|
9463
9437
|
{ val: x },
|
|
@@ -9467,12 +9441,12 @@ function Ue(o, t) {
|
|
|
9467
9441
|
i.queueAction(V)
|
|
9468
9442
|
);
|
|
9469
9443
|
}
|
|
9470
|
-
const
|
|
9444
|
+
const T = await Promise.all(ot);
|
|
9471
9445
|
let rt, F;
|
|
9472
|
-
l instanceof
|
|
9446
|
+
l instanceof Qt ? (rt = new Qt(E * O), F = new Qt(E * O)) : (rt = new Uint8Array(E * O), F = new Uint8Array(E * O));
|
|
9473
9447
|
let f = 0;
|
|
9474
|
-
for (let L = 0; L <
|
|
9475
|
-
rt.set(
|
|
9448
|
+
for (let L = 0; L < T.length; L++)
|
|
9449
|
+
rt.set(T[L][0], f), F.set(T[L][1], f), f += T[L][0].byteLength;
|
|
9476
9450
|
return [rt, F];
|
|
9477
9451
|
}, n.fftFinal = async function(l, C) {
|
|
9478
9452
|
const B = n.F.n8 * 3, A = n.F.n8 * 2;
|
|
@@ -9486,12 +9460,12 @@ function Ue(o, t) {
|
|
|
9486
9460
|
const E = Math.floor(l.byteLength / B);
|
|
9487
9461
|
if (E != 1 << Jt(E))
|
|
9488
9462
|
throw new Error("Invalid number of points");
|
|
9489
|
-
const
|
|
9463
|
+
const z = Math.floor(E / i.concurrency), x = [];
|
|
9490
9464
|
for (let F = 0; F < i.concurrency; F++) {
|
|
9491
9465
|
let f;
|
|
9492
|
-
if (F < i.concurrency - 1 ? f =
|
|
9466
|
+
if (F < i.concurrency - 1 ? f = z : f = E - F * z, f == 0)
|
|
9493
9467
|
continue;
|
|
9494
|
-
const L = [], V = l.slice(F *
|
|
9468
|
+
const L = [], V = l.slice(F * z * B, (F * z + f) * B);
|
|
9495
9469
|
L.push({ cmd: "ALLOCSET", var: 0, buff: V }), L.push({ cmd: "ALLOCSET", var: 1, buff: C }), L.push({ cmd: "CALL", fnName: O, params: [
|
|
9496
9470
|
{ var: 0 },
|
|
9497
9471
|
{ val: f },
|
|
@@ -9505,17 +9479,17 @@ function Ue(o, t) {
|
|
|
9505
9479
|
);
|
|
9506
9480
|
}
|
|
9507
9481
|
const ot = await Promise.all(x);
|
|
9508
|
-
let
|
|
9509
|
-
l instanceof
|
|
9482
|
+
let T;
|
|
9483
|
+
l instanceof Qt ? T = new Qt(E * A) : T = new Uint8Array(E * A);
|
|
9510
9484
|
let rt = 0;
|
|
9511
9485
|
for (let F = ot.length - 1; F >= 0; F--)
|
|
9512
|
-
|
|
9513
|
-
return
|
|
9486
|
+
T.set(ot[F][0], rt), rt += ot[F][0].byteLength;
|
|
9487
|
+
return T;
|
|
9514
9488
|
};
|
|
9515
9489
|
}
|
|
9516
9490
|
async function ra(o) {
|
|
9517
9491
|
const t = await qs(o.wasm, o.singleThread), n = {};
|
|
9518
|
-
return n.q =
|
|
9492
|
+
return n.q = Tt(o.wasm.q.toString()), n.r = Tt(o.wasm.r.toString()), n.name = o.name, n.tm = t, n.prePSize = o.wasm.prePSize, n.preQSize = o.wasm.preQSize, n.Fr = new jo(t, "frm", o.n8r, o.r), n.F1 = new jo(t, "f1m", o.n8q, o.q), n.F2 = new $o(t, "f2m", n.F1), n.G1 = new Yo(t, "g1m", n.F1, o.wasm.pG1gen, o.wasm.pG1b, o.cofactorG1), n.G2 = new Yo(t, "g2m", n.F2, o.wasm.pG2gen, o.wasm.pG2b, o.cofactorG2), n.F6 = new Os(t, "f6m", n.F2), n.F12 = new $o(t, "ftm", n.F6), n.Gt = n.F12, Me(n, "G1"), Me(n, "G2"), Me(n, "Fr"), Xo(n, "G1"), Xo(n, "G2"), Ue(n, "G1"), Ue(n, "G2"), Ue(n, "Fr"), Ms(n), n.array2buffer = function(e, i) {
|
|
9519
9493
|
const s = new Uint8Array(i * e.length);
|
|
9520
9494
|
for (let d = 0; d < e.length; d++)
|
|
9521
9495
|
s.set(e[d], d * i);
|
|
@@ -9536,14 +9510,14 @@ function da(o) {
|
|
|
9536
9510
|
function Us(o) {
|
|
9537
9511
|
return o === 0n;
|
|
9538
9512
|
}
|
|
9539
|
-
function
|
|
9513
|
+
function zs(o) {
|
|
9540
9514
|
return da(o) ? o.toString(2).length - 1 : o.toString(2).length;
|
|
9541
9515
|
}
|
|
9542
|
-
function
|
|
9516
|
+
function ze(o) {
|
|
9543
9517
|
const t = [], n = Rn(o);
|
|
9544
9518
|
return t.push(Number(n & 0xFFn)), t.push(Number(n >> 8n & 0xFFn)), t.push(Number(n >> 16n & 0xFFn)), t.push(Number(n >> 24n & 0xFFn)), t;
|
|
9545
9519
|
}
|
|
9546
|
-
function
|
|
9520
|
+
function Ts(o) {
|
|
9547
9521
|
for (var t = [], n = 0; n < o.length; n++) {
|
|
9548
9522
|
var e = o.charCodeAt(n);
|
|
9549
9523
|
e < 128 ? t.push(e) : e < 2048 ? t.push(
|
|
@@ -9563,7 +9537,7 @@ function zs(o) {
|
|
|
9563
9537
|
return t;
|
|
9564
9538
|
}
|
|
9565
9539
|
function Hn(o) {
|
|
9566
|
-
const t =
|
|
9540
|
+
const t = Ts(o);
|
|
9567
9541
|
return [...Ft(t.length), ...t];
|
|
9568
9542
|
}
|
|
9569
9543
|
function ua(o) {
|
|
@@ -9580,7 +9554,7 @@ function ua(o) {
|
|
|
9580
9554
|
}
|
|
9581
9555
|
function _a(o) {
|
|
9582
9556
|
let t, n;
|
|
9583
|
-
const e =
|
|
9557
|
+
const e = zs(o);
|
|
9584
9558
|
o < 0 ? (n = !0, t = (1n << BigInt(e)) + o) : (n = !1, t = Rn(o));
|
|
9585
9559
|
const i = 7 - e % 7, s = (1n << BigInt(i)) - 1n << BigInt(e), d = (1 << 7 - i) - 1 | 128, r = ua(t + s);
|
|
9586
9560
|
return n || (r[r.length - 1] = r[r.length - 1] & d), r;
|
|
@@ -9927,7 +9901,7 @@ class Ds {
|
|
|
9927
9901
|
return [];
|
|
9928
9902
|
}
|
|
9929
9903
|
}
|
|
9930
|
-
const
|
|
9904
|
+
const Te = {
|
|
9931
9905
|
i32: 127,
|
|
9932
9906
|
i64: 126,
|
|
9933
9907
|
f32: 125,
|
|
@@ -9970,13 +9944,13 @@ class ni {
|
|
|
9970
9944
|
this.returnType = t;
|
|
9971
9945
|
}
|
|
9972
9946
|
getSignature() {
|
|
9973
|
-
const t = [...Ft(this.params.length), ...this.params.map((e) =>
|
|
9947
|
+
const t = [...Ft(this.params.length), ...this.params.map((e) => Te[e.type])], n = this.returnType ? [1, Te[this.returnType]] : [0];
|
|
9974
9948
|
return [96, ...t, ...n];
|
|
9975
9949
|
}
|
|
9976
9950
|
getBody() {
|
|
9977
9951
|
const t = this.locals.map((e) => [
|
|
9978
9952
|
...Ft(e.length),
|
|
9979
|
-
|
|
9953
|
+
Te[e.type]
|
|
9980
9954
|
]), n = [
|
|
9981
9955
|
...Ft(this.locals.length),
|
|
9982
9956
|
...[].concat(...t),
|
|
@@ -10005,8 +9979,8 @@ class ga {
|
|
|
10005
9979
|
}
|
|
10006
9980
|
build() {
|
|
10007
9981
|
return this._setSignatures(), new Uint8Array([
|
|
10008
|
-
...
|
|
10009
|
-
...
|
|
9982
|
+
...ze(1836278016),
|
|
9983
|
+
...ze(1),
|
|
10010
9984
|
...this._buildType(),
|
|
10011
9985
|
...this._buildImport(),
|
|
10012
9986
|
...this._buildFunctionDeclarations(),
|
|
@@ -10190,7 +10164,7 @@ class ga {
|
|
|
10190
10164
|
0,
|
|
10191
10165
|
11,
|
|
10192
10166
|
4,
|
|
10193
|
-
...
|
|
10167
|
+
...ze(this.free)
|
|
10194
10168
|
]);
|
|
10195
10169
|
for (let n = 0; n < this.datas.length; n++)
|
|
10196
10170
|
t.push([
|
|
@@ -10218,11 +10192,11 @@ async function fa(o, t) {
|
|
|
10218
10192
|
const i = {
|
|
10219
10193
|
name: "bn128",
|
|
10220
10194
|
wasm: e,
|
|
10221
|
-
q:
|
|
10222
|
-
r:
|
|
10195
|
+
q: Tt("21888242871839275222246405745257275088696311157297823662689037894645226208583"),
|
|
10196
|
+
r: Tt("21888242871839275222246405745257275088548364400416034343698204186575808495617"),
|
|
10223
10197
|
n8q: 32,
|
|
10224
10198
|
n8r: 32,
|
|
10225
|
-
cofactorG2:
|
|
10199
|
+
cofactorG2: Tt("30644e72e131a029b85045b68181585e06ceecda572a2489345f2299c0f9fa8d", 16),
|
|
10226
10200
|
singleThread: !!o
|
|
10227
10201
|
}, s = await ra(i);
|
|
10228
10202
|
return s.terminate = async function() {
|
|
@@ -10240,23 +10214,23 @@ async function ha(o, t) {
|
|
|
10240
10214
|
const i = {
|
|
10241
10215
|
name: "bls12381",
|
|
10242
10216
|
wasm: e,
|
|
10243
|
-
q:
|
|
10244
|
-
r:
|
|
10217
|
+
q: Tt("1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab", 16),
|
|
10218
|
+
r: Tt("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001", 16),
|
|
10245
10219
|
n8q: 48,
|
|
10246
10220
|
n8r: 32,
|
|
10247
|
-
cofactorG1:
|
|
10248
|
-
cofactorG2:
|
|
10221
|
+
cofactorG1: Tt("0x396c8c005555e1568c00aaab0000aaab", 16),
|
|
10222
|
+
cofactorG2: Tt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5", 16),
|
|
10249
10223
|
singleThread: !!o
|
|
10250
10224
|
}, s = await ra(i);
|
|
10251
10225
|
return s.terminate = async function() {
|
|
10252
10226
|
i.singleThread || (globalThis.curve_bls12381 = null, await this.tm.terminate());
|
|
10253
10227
|
}, o || (globalThis.curve_bls12381 = s), s;
|
|
10254
10228
|
}
|
|
10255
|
-
|
|
10256
|
-
|
|
10257
|
-
|
|
10258
|
-
|
|
10259
|
-
const
|
|
10229
|
+
Tt("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001", 16);
|
|
10230
|
+
Tt("21888242871839275222246405745257275088548364400416034343698204186575808495617");
|
|
10231
|
+
Tt("1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab", 16);
|
|
10232
|
+
Tt("21888242871839275222246405745257275088696311157297823662689037894645226208583");
|
|
10233
|
+
const Mt = Cc, ne = Ss;
|
|
10260
10234
|
var pa = {};
|
|
10261
10235
|
async function La(o, t, n, e) {
|
|
10262
10236
|
if (n = n || 4096 * 64, typeof t != "number" && ["w+", "wx+", "r", "ax+", "a+"].indexOf(t) < 0)
|
|
@@ -10767,29 +10741,29 @@ async function oe(o, t) {
|
|
|
10767
10741
|
}
|
|
10768
10742
|
async function Xs(o, t, n, e) {
|
|
10769
10743
|
const i = new Uint8Array(n);
|
|
10770
|
-
|
|
10744
|
+
Mt.toRprLE(i, 0, t, n), await o.write(i, e);
|
|
10771
10745
|
}
|
|
10772
10746
|
async function Sn(o, t, n) {
|
|
10773
10747
|
const e = await o.read(t, n);
|
|
10774
|
-
return
|
|
10748
|
+
return Mt.fromRprLE(e, 0, t);
|
|
10775
10749
|
}
|
|
10776
10750
|
async function Bn(o, t, n, e, i) {
|
|
10777
10751
|
if (e = typeof e > "u" ? 0 : e, i = typeof i > "u" ? t[n][0].size - e : i, e + i > t[n][0].size)
|
|
10778
10752
|
throw new Error("Reading out of the range of the section");
|
|
10779
10753
|
let s;
|
|
10780
|
-
return i < 1 << 30 ? s = new Uint8Array(i) : s = new
|
|
10754
|
+
return i < 1 << 30 ? s = new Uint8Array(i) : s = new Qt(i), await o.readToBuffer(s, 0, i, t[n][0].p + e), s;
|
|
10781
10755
|
}
|
|
10782
|
-
|
|
10783
|
-
|
|
10784
|
-
const tl =
|
|
10756
|
+
Mt.e("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001", 16);
|
|
10757
|
+
Mt.e("21888242871839275222246405745257275088548364400416034343698204186575808495617");
|
|
10758
|
+
const tl = Mt.e("1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab", 16), nl = Mt.e("21888242871839275222246405745257275088696311157297823662689037894645226208583");
|
|
10785
10759
|
async function Co(o, t) {
|
|
10786
10760
|
let n, e = t && t.singleThread;
|
|
10787
|
-
if (
|
|
10761
|
+
if (Mt.eq(o, nl))
|
|
10788
10762
|
n = await fa(e);
|
|
10789
|
-
else if (
|
|
10763
|
+
else if (Mt.eq(o, tl))
|
|
10790
10764
|
n = await ha(e);
|
|
10791
10765
|
else
|
|
10792
|
-
throw new Error(`Curve not supported: ${
|
|
10766
|
+
throw new Error(`Curve not supported: ${Mt.toString(o)}`);
|
|
10793
10767
|
return n;
|
|
10794
10768
|
}
|
|
10795
10769
|
async function el(o, t) {
|
|
@@ -11084,7 +11058,7 @@ var Ll = {
|
|
|
11084
11058
|
}
|
|
11085
11059
|
return I;
|
|
11086
11060
|
}
|
|
11087
|
-
function
|
|
11061
|
+
function z(c, w, I = 0, h = 0, S = c.byteLength) {
|
|
11088
11062
|
if (S > 0 && S < h || S === h || c.byteLength === 0 || w.byteLength === 0)
|
|
11089
11063
|
return 0;
|
|
11090
11064
|
if (I < 0)
|
|
@@ -11122,14 +11096,14 @@ var Ll = {
|
|
|
11122
11096
|
for (let W = I; W < h; ++W)
|
|
11123
11097
|
c[W] = w;
|
|
11124
11098
|
else {
|
|
11125
|
-
w = u(w) ? w :
|
|
11099
|
+
w = u(w) ? w : T(w, S);
|
|
11126
11100
|
const W = w.byteLength;
|
|
11127
11101
|
for (let N = 0; N < h - I; ++N)
|
|
11128
11102
|
c[N + I] = w[N % W];
|
|
11129
11103
|
}
|
|
11130
11104
|
return c;
|
|
11131
11105
|
}
|
|
11132
|
-
function
|
|
11106
|
+
function T(c, w, I) {
|
|
11133
11107
|
return typeof c == "string" ? rt(c, w) : Array.isArray(c) ? F(c) : ArrayBuffer.isView(c) ? f(c) : L(c, w, I);
|
|
11134
11108
|
}
|
|
11135
11109
|
function rt(c, w) {
|
|
@@ -11163,7 +11137,7 @@ var Ll = {
|
|
|
11163
11137
|
else
|
|
11164
11138
|
return -1;
|
|
11165
11139
|
if (typeof w == "string")
|
|
11166
|
-
w =
|
|
11140
|
+
w = T(w, h);
|
|
11167
11141
|
else if (typeof w == "number")
|
|
11168
11142
|
return w = w & 255, S ? c.indexOf(w, I) : c.lastIndexOf(w, I);
|
|
11169
11143
|
if (w.byteLength === 0)
|
|
@@ -11201,7 +11175,7 @@ var Ll = {
|
|
|
11201
11175
|
/* first */
|
|
11202
11176
|
);
|
|
11203
11177
|
}
|
|
11204
|
-
function
|
|
11178
|
+
function Q(c, w, I, h) {
|
|
11205
11179
|
return $(
|
|
11206
11180
|
c,
|
|
11207
11181
|
w,
|
|
@@ -11282,13 +11256,13 @@ var Ll = {
|
|
|
11282
11256
|
byteLength: O,
|
|
11283
11257
|
compare: P,
|
|
11284
11258
|
concat: E,
|
|
11285
|
-
copy:
|
|
11259
|
+
copy: z,
|
|
11286
11260
|
equals: x,
|
|
11287
11261
|
fill: ot,
|
|
11288
|
-
from:
|
|
11262
|
+
from: T,
|
|
11289
11263
|
includes: V,
|
|
11290
11264
|
indexOf: X,
|
|
11291
|
-
lastIndexOf:
|
|
11265
|
+
lastIndexOf: Q,
|
|
11292
11266
|
swap16: v,
|
|
11293
11267
|
swap32: D,
|
|
11294
11268
|
swap64: it,
|
|
@@ -11425,7 +11399,7 @@ async function Fl(o, t, n, e) {
|
|
|
11425
11399
|
}
|
|
11426
11400
|
async function xl(o, t, n) {
|
|
11427
11401
|
await si(o, 1);
|
|
11428
|
-
const e = (Math.floor((
|
|
11402
|
+
const e = (Math.floor((Mt.bitLength(n) - 1) / 64) + 1) * 8;
|
|
11429
11403
|
if (await o.writeULE32(e), await Xs(o, n, e), t.byteLength % e != 0)
|
|
11430
11404
|
throw new Error("Invalid witness length");
|
|
11431
11405
|
await o.writeULE32(t.byteLength / e), await li(o), await si(o, 2), await o.write(t), await li(o);
|
|
@@ -11440,7 +11414,7 @@ async function va(o, t, n, e) {
|
|
|
11440
11414
|
const { fd: i, sections: s } = await ci(t, "wtns", 2), d = await Sl(i, s), { fd: r, sections: b } = await ci(o, "zkey", 2), u = await wl(r, b, void 0, e);
|
|
11441
11415
|
if (u.protocol != "groth16")
|
|
11442
11416
|
throw new Error("zkey file is not groth16");
|
|
11443
|
-
if (!
|
|
11417
|
+
if (!Mt.eq(u.r, d.q))
|
|
11444
11418
|
throw new Error("Curve of the witness does not match the curve of the proving key");
|
|
11445
11419
|
if (d.nWitness != u.nVars)
|
|
11446
11420
|
throw new Error(`Invalid witness length. Circuit: ${u.nVars}, witness: ${d.nWitness}`);
|
|
@@ -11450,7 +11424,7 @@ async function va(o, t, n, e) {
|
|
|
11450
11424
|
n && n.debug("Reading Coeffs");
|
|
11451
11425
|
const E = await Bn(r, b, 4);
|
|
11452
11426
|
n && n.debug("Building ABC");
|
|
11453
|
-
const [
|
|
11427
|
+
const [z, x, ot] = await Ol(l, u, P, E, n), T = O == C.s ? l.Fr.shift : l.Fr.w[O + 1], rt = await C.ifft(z, "", "", n, "IFFT_A"), F = await C.batchApplyKey(rt, C.e(1), T), f = await C.fft(F, "", "", n, "FFT_A"), L = await C.ifft(x, "", "", n, "IFFT_B"), V = await C.batchApplyKey(L, C.e(1), T), $ = await C.fft(V, "", "", n, "FFT_B"), X = await C.ifft(ot, "", "", n, "IFFT_C"), Q = await C.batchApplyKey(X, C.e(1), T), y = await C.fft(Q, "", "", n, "FFT_C");
|
|
11454
11428
|
n && n.debug("Join ABC");
|
|
11455
11429
|
const v = await vl(l, u, f, $, y, n);
|
|
11456
11430
|
let D = {};
|
|
@@ -11469,19 +11443,19 @@ async function va(o, t, n, e) {
|
|
|
11469
11443
|
let p = [];
|
|
11470
11444
|
for (let a = 1; a <= u.nPublic; a++) {
|
|
11471
11445
|
const m = P.slice(a * C.n8, a * C.n8 + C.n8);
|
|
11472
|
-
p.push(
|
|
11446
|
+
p.push(Mt.fromRprLE(m));
|
|
11473
11447
|
}
|
|
11474
11448
|
return D.pi_a = B.toObject(B.toAffine(D.pi_a)), D.pi_b = A.toObject(A.toAffine(D.pi_b)), D.pi_c = B.toObject(B.toAffine(D.pi_c)), D.protocol = "groth16", D.curve = l.name, await r.close(), await i.close(), D = Ai(D), p = Ai(p), { proof: D, publicSignals: p };
|
|
11475
11449
|
}
|
|
11476
11450
|
async function Ol(o, t, n, e, i) {
|
|
11477
|
-
const s = o.Fr.n8, d = 4 * 3 + t.n8r, r = (e.byteLength - 4) / d, b = new
|
|
11451
|
+
const s = o.Fr.n8, d = 4 * 3 + t.n8r, r = (e.byteLength - 4) / d, b = new Qt(t.domainSize * s), u = new Qt(t.domainSize * s), l = new Qt(t.domainSize * s), C = [b, u];
|
|
11478
11452
|
for (let B = 0; B < r; B++) {
|
|
11479
11453
|
i && B % 1e6 == 0 && i.debug(`QAP AB: ${B}/${r}`);
|
|
11480
|
-
const A = e.slice(4 + B * d, 4 + B * d + d), O = new DataView(A.buffer), P = O.getUint32(0, !0), E = O.getUint32(4, !0),
|
|
11454
|
+
const A = e.slice(4 + B * d, 4 + B * d + d), O = new DataView(A.buffer), P = O.getUint32(0, !0), E = O.getUint32(4, !0), z = O.getUint32(8, !0), x = A.slice(12, 12 + s);
|
|
11481
11455
|
C[P].set(
|
|
11482
11456
|
o.Fr.add(
|
|
11483
11457
|
C[P].slice(E * s, E * s + s),
|
|
11484
|
-
o.Fr.mul(x, n.slice(
|
|
11458
|
+
o.Fr.mul(x, n.slice(z * s, z * s + s))
|
|
11485
11459
|
),
|
|
11486
11460
|
E * s
|
|
11487
11461
|
);
|
|
@@ -11500,8 +11474,8 @@ async function vl(o, t, n, e, i, s) {
|
|
|
11500
11474
|
const r = o.Fr.n8, b = Math.floor(n.byteLength / o.Fr.n8), u = [];
|
|
11501
11475
|
for (let A = 0; A < b; A += 4194304) {
|
|
11502
11476
|
s && s.debug(`JoinABC: ${A}/${b}`);
|
|
11503
|
-
const O = Math.min(b - A, 4194304), P = [], E = n.slice(A * r, (A + O) * r),
|
|
11504
|
-
P.push({ cmd: "ALLOCSET", var: 0, buff: E }), P.push({ cmd: "ALLOCSET", var: 1, buff:
|
|
11477
|
+
const O = Math.min(b - A, 4194304), P = [], E = n.slice(A * r, (A + O) * r), z = e.slice(A * r, (A + O) * r), x = i.slice(A * r, (A + O) * r);
|
|
11478
|
+
P.push({ cmd: "ALLOCSET", var: 0, buff: E }), P.push({ cmd: "ALLOCSET", var: 1, buff: z }), P.push({ cmd: "ALLOCSET", var: 2, buff: x }), P.push({ cmd: "ALLOC", var: 3, len: O * r }), P.push({ cmd: "CALL", fnName: "qap_joinABC", params: [
|
|
11505
11479
|
{ var: 0 },
|
|
11506
11480
|
{ var: 1 },
|
|
11507
11481
|
{ var: 2 },
|
|
@@ -11515,7 +11489,7 @@ async function vl(o, t, n, e, i, s) {
|
|
|
11515
11489
|
}
|
|
11516
11490
|
const l = await Promise.all(u);
|
|
11517
11491
|
let C;
|
|
11518
|
-
n instanceof
|
|
11492
|
+
n instanceof Qt ? C = new Qt(n.byteLength) : C = new Uint8Array(n.byteLength);
|
|
11519
11493
|
let B = 0;
|
|
11520
11494
|
for (let A = 0; A < l.length; A++)
|
|
11521
11495
|
C.set(l[A][0], B), B += l[A][0].byteLength;
|
|
@@ -11557,7 +11531,7 @@ function ql(o, t) {
|
|
|
11557
11531
|
}
|
|
11558
11532
|
return n;
|
|
11559
11533
|
}
|
|
11560
|
-
async function
|
|
11534
|
+
async function Ql(o, t) {
|
|
11561
11535
|
let n, e, i;
|
|
11562
11536
|
t = t || {};
|
|
11563
11537
|
let s = 1, d = 0, r = 0, b = !1;
|
|
@@ -11571,9 +11545,9 @@ async function Ml(o, t) {
|
|
|
11571
11545
|
for (; !A; )
|
|
11572
11546
|
try {
|
|
11573
11547
|
i = new WebAssembly.Memory({ initial: B }), A = !0;
|
|
11574
|
-
} catch (
|
|
11548
|
+
} catch (z) {
|
|
11575
11549
|
if (B <= 1)
|
|
11576
|
-
throw
|
|
11550
|
+
throw z;
|
|
11577
11551
|
console.warn("Could not allocate " + B * 1024 * 64 + " bytes. This may cause severe instability. Trying with " + B * 1024 * 64 / 2 + " bytes"), B = Math.floor(B / 2);
|
|
11578
11552
|
}
|
|
11579
11553
|
const O = await WebAssembly.compile(o);
|
|
@@ -11583,12 +11557,12 @@ async function Ml(o, t) {
|
|
|
11583
11557
|
memory: i
|
|
11584
11558
|
},
|
|
11585
11559
|
runtime: {
|
|
11586
|
-
printDebug: function(
|
|
11587
|
-
console.log("printDebug:",
|
|
11560
|
+
printDebug: function(z) {
|
|
11561
|
+
console.log("printDebug:", z);
|
|
11588
11562
|
},
|
|
11589
|
-
exceptionHandler: function(
|
|
11563
|
+
exceptionHandler: function(z) {
|
|
11590
11564
|
let x;
|
|
11591
|
-
throw
|
|
11565
|
+
throw z === 1 ? x = "Signal not found. " : z === 2 ? x = "Too many signals set. " : z === 3 ? x = "Signal already set. " : z === 4 ? x = "Assert Failed. " : z === 5 ? x = "Not enough memory. " : z === 6 ? x = "Input signal array access exceeds the size. " : x = "Unknown error. ", console.error("ERROR: ", z, P), new Error(x + P);
|
|
11592
11566
|
},
|
|
11593
11567
|
// A new way of logging messages was added in Circom 2.0.7 that requires 2 new imports
|
|
11594
11568
|
// `printErrorMessage` and `writeBufferMessage`.
|
|
@@ -11597,39 +11571,39 @@ async function Ml(o, t) {
|
|
|
11597
11571
|
`;
|
|
11598
11572
|
},
|
|
11599
11573
|
writeBufferMessage: function() {
|
|
11600
|
-
const
|
|
11601
|
-
|
|
11602
|
-
` ? (console.log(E), E = "") : (E !== "" && (E += " "), E +=
|
|
11574
|
+
const z = l();
|
|
11575
|
+
z === `
|
|
11576
|
+
` ? (console.log(E), E = "") : (E !== "" && (E += " "), E += z);
|
|
11603
11577
|
},
|
|
11604
11578
|
showSharedRWMemory: function() {
|
|
11605
|
-
const
|
|
11606
|
-
for (let ot = 0; ot <
|
|
11607
|
-
x[
|
|
11579
|
+
const z = n.exports.getFieldNumLen32(), x = new Uint32Array(z);
|
|
11580
|
+
for (let ot = 0; ot < z; ot++)
|
|
11581
|
+
x[z - 1 - ot] = n.exports.readSharedRWMemory(ot);
|
|
11608
11582
|
if (s >= 2 && (d >= 1 || r >= 7)) {
|
|
11609
11583
|
E !== "" && (E += " ");
|
|
11610
|
-
const ot =
|
|
11584
|
+
const ot = Mt.fromArray(x, 4294967296).toString();
|
|
11611
11585
|
E += ot;
|
|
11612
11586
|
} else
|
|
11613
|
-
console.log(
|
|
11587
|
+
console.log(Mt.fromArray(x, 4294967296));
|
|
11614
11588
|
},
|
|
11615
|
-
error: function(
|
|
11589
|
+
error: function(z, x, ot, T, rt, F) {
|
|
11616
11590
|
let f;
|
|
11617
|
-
throw
|
|
11591
|
+
throw z === 7 ? f = C(x) + " " + e.getFr(T).toString() + " != " + e.getFr(rt).toString() + " " + C(F) : z === 9 ? f = C(x) + " " + e.getFr(T).toString() + " " + C(rt) : z === 5 && t.sym ? f = C(x) + " " + t.sym.labelIdx2Name[rt] : f = C(x) + " " + ot + " " + T + " " + rt + " " + F, console.log("ERROR: ", z, f), new Error(f);
|
|
11618
11592
|
},
|
|
11619
|
-
log: function(
|
|
11620
|
-
console.log(e.getFr(
|
|
11593
|
+
log: function(z) {
|
|
11594
|
+
console.log(e.getFr(z).toString());
|
|
11621
11595
|
},
|
|
11622
|
-
logGetSignal: function(
|
|
11623
|
-
t.logGetSignal && t.logGetSignal(
|
|
11596
|
+
logGetSignal: function(z, x) {
|
|
11597
|
+
t.logGetSignal && t.logGetSignal(z, e.getFr(x));
|
|
11624
11598
|
},
|
|
11625
|
-
logSetSignal: function(
|
|
11626
|
-
t.logSetSignal && t.logSetSignal(
|
|
11599
|
+
logSetSignal: function(z, x) {
|
|
11600
|
+
t.logSetSignal && t.logSetSignal(z, e.getFr(x));
|
|
11627
11601
|
},
|
|
11628
|
-
logStartComponent: function(
|
|
11629
|
-
t.logStartComponent && t.logStartComponent(
|
|
11602
|
+
logStartComponent: function(z) {
|
|
11603
|
+
t.logStartComponent && t.logStartComponent(z);
|
|
11630
11604
|
},
|
|
11631
|
-
logFinishComponent: function(
|
|
11632
|
-
t.logFinishComponent && t.logFinishComponent(
|
|
11605
|
+
logFinishComponent: function(z) {
|
|
11606
|
+
t.logFinishComponent && t.logFinishComponent(z);
|
|
11633
11607
|
}
|
|
11634
11608
|
}
|
|
11635
11609
|
});
|
|
@@ -11641,7 +11615,7 @@ async function Ml(o, t) {
|
|
|
11641
11615
|
else if (s === 1) {
|
|
11642
11616
|
if (b)
|
|
11643
11617
|
throw new Error("Loading code from WebAssembly instance is not supported for circom version 1");
|
|
11644
|
-
e = new
|
|
11618
|
+
e = new Ml(i, n, u);
|
|
11645
11619
|
} else
|
|
11646
11620
|
throw new Error(`Unsupported circom version: ${s}`);
|
|
11647
11621
|
return e;
|
|
@@ -11658,13 +11632,13 @@ async function Ml(o, t) {
|
|
|
11658
11632
|
return String.fromCharCode.apply(null, O);
|
|
11659
11633
|
}
|
|
11660
11634
|
}
|
|
11661
|
-
class
|
|
11635
|
+
class Ml {
|
|
11662
11636
|
constructor(t, n, e) {
|
|
11663
11637
|
this.memory = t, this.i32 = new Uint32Array(t.buffer), this.instance = n, this.n32 = (this.instance.exports.getFrLen() >> 2) - 2;
|
|
11664
11638
|
const i = this.instance.exports.getPRawPrime(), s = new Array(this.n32);
|
|
11665
11639
|
for (let d = 0; d < this.n32; d++)
|
|
11666
11640
|
s[this.n32 - 1 - d] = this.i32[(i >> 2) + d];
|
|
11667
|
-
this.prime =
|
|
11641
|
+
this.prime = Mt.fromArray(s, 4294967296), this.Fr = new Mc(this.prime), this.mask32 = Mt.fromString("FFFFFFFF", 16), this.NVars = this.instance.exports.getNVars(), this.n64 = Math.floor((this.Fr.bitLength - 1) / 64) + 1, this.R = this.Fr.e(Mt.shiftLeft(1, this.n64 * 64)), this.RInv = this.Fr.inv(this.R), this.sanityCheck = e;
|
|
11668
11642
|
}
|
|
11669
11643
|
circom_version() {
|
|
11670
11644
|
return 1;
|
|
@@ -11721,7 +11695,7 @@ class Ql {
|
|
|
11721
11695
|
const s = new Array(n.n32);
|
|
11722
11696
|
for (let r = 0; r < n.n32; r++)
|
|
11723
11697
|
s[n.n32 - 1 - r] = n.i32[e + 2 + r];
|
|
11724
|
-
const d = n.Fr.e(
|
|
11698
|
+
const d = n.Fr.e(Mt.fromArray(s, 4294967296));
|
|
11725
11699
|
return n.i32[e + 1] & 1073741824 ? i(d) : d;
|
|
11726
11700
|
} else
|
|
11727
11701
|
return n.i32[e] & 2147483648 ? n.Fr.e(n.i32[e] - 4294967296) : n.Fr.e(n.i32[e]);
|
|
@@ -11735,11 +11709,11 @@ class Ql {
|
|
|
11735
11709
|
const i = e.Fr.neg(e.Fr.e("80000000", 16)), s = e.Fr.e("7FFFFFFF", 16);
|
|
11736
11710
|
if (e.Fr.geq(n, i) && e.Fr.leq(n, s)) {
|
|
11737
11711
|
let r;
|
|
11738
|
-
e.Fr.geq(n, e.Fr.zero) ? r =
|
|
11712
|
+
e.Fr.geq(n, e.Fr.zero) ? r = Mt.toNumber(n) : (r = Mt.toNumber(e.Fr.sub(n, i)), r = r - 2147483648, r = 4294967296 + r), e.i32[t >> 2] = r, e.i32[(t >> 2) + 1] = 0;
|
|
11739
11713
|
return;
|
|
11740
11714
|
}
|
|
11741
11715
|
e.i32[t >> 2] = 0, e.i32[(t >> 2) + 1] = 2147483648;
|
|
11742
|
-
const d =
|
|
11716
|
+
const d = Mt.toArray(n, 4294967296);
|
|
11743
11717
|
for (let r = 0; r < e.n32; r++) {
|
|
11744
11718
|
const b = d.length - 1 - r;
|
|
11745
11719
|
b >= 0 ? e.i32[(t >> 2) + 2 + r] = d[b] : e.i32[(t >> 2) + 2 + r] = 0;
|
|
@@ -11752,7 +11726,7 @@ class Ul {
|
|
|
11752
11726
|
const e = new Uint32Array(this.n32);
|
|
11753
11727
|
for (let i = 0; i < this.n32; i++)
|
|
11754
11728
|
e[this.n32 - 1 - i] = this.instance.exports.readSharedRWMemory(i);
|
|
11755
|
-
this.prime =
|
|
11729
|
+
this.prime = Mt.fromArray(e, 4294967296), this.witnessSize = this.instance.exports.getWitnessSize(), this.sanityCheck = n;
|
|
11756
11730
|
}
|
|
11757
11731
|
circom_version() {
|
|
11758
11732
|
return this.instance.exports.getVersion();
|
|
@@ -11796,7 +11770,7 @@ class Ul {
|
|
|
11796
11770
|
const s = new Uint32Array(this.n32);
|
|
11797
11771
|
for (let d = 0; d < this.n32; d++)
|
|
11798
11772
|
s[this.n32 - 1 - d] = this.instance.exports.readSharedRWMemory(d);
|
|
11799
|
-
e.push(
|
|
11773
|
+
e.push(Mt.fromArray(s, 4294967296));
|
|
11800
11774
|
}
|
|
11801
11775
|
return e;
|
|
11802
11776
|
}
|
|
@@ -11820,11 +11794,11 @@ class Ul {
|
|
|
11820
11794
|
return i;
|
|
11821
11795
|
}
|
|
11822
11796
|
}
|
|
11823
|
-
const { unstringifyBigInts:
|
|
11824
|
-
async function
|
|
11825
|
-
const i =
|
|
11797
|
+
const { unstringifyBigInts: zl } = ne;
|
|
11798
|
+
async function Tl(o, t, n, e) {
|
|
11799
|
+
const i = zl(o), s = await ma(t), d = await s.read(s.totalSize);
|
|
11826
11800
|
await s.close();
|
|
11827
|
-
const r = await
|
|
11801
|
+
const r = await Ql(d, e);
|
|
11828
11802
|
if (r.circom_version() === 1) {
|
|
11829
11803
|
const b = await r.calculateBinWitness(i), u = await Ws(n, "wtns", 2, 2);
|
|
11830
11804
|
await xl(u, b, r.prime), await u.close();
|
|
@@ -11838,23 +11812,23 @@ async function Dl(o, t, n, e, i, s) {
|
|
|
11838
11812
|
const d = Rl(o), r = {
|
|
11839
11813
|
type: "mem"
|
|
11840
11814
|
};
|
|
11841
|
-
return await
|
|
11815
|
+
return await Tl(d, t, r, i), await va(n, r, e, s);
|
|
11842
11816
|
}
|
|
11843
11817
|
const { unstringifyBigInts: De } = ne;
|
|
11844
11818
|
async function kl(o, t, n, e) {
|
|
11845
11819
|
const i = De(o), s = De(n), d = De(t), r = await el(i.curve), b = r.G1.fromObject(i.IC[0]), u = new Uint8Array(r.G1.F.n8 * 2 * d.length), l = new Uint8Array(r.Fr.n8 * d.length);
|
|
11846
11820
|
if (!Gl(r, d))
|
|
11847
11821
|
return e && e.error("Public inputs are not valid."), !1;
|
|
11848
|
-
for (let
|
|
11849
|
-
const rt = r.G1.fromObject(i.IC[
|
|
11850
|
-
u.set(rt,
|
|
11822
|
+
for (let T = 0; T < d.length; T++) {
|
|
11823
|
+
const rt = r.G1.fromObject(i.IC[T + 1]);
|
|
11824
|
+
u.set(rt, T * r.G1.F.n8 * 2), Mt.toRprLE(l, r.Fr.n8 * T, d[T], r.Fr.n8);
|
|
11851
11825
|
}
|
|
11852
11826
|
let C = await r.G1.multiExpAffine(u, l);
|
|
11853
11827
|
C = r.G1.add(C, b);
|
|
11854
11828
|
const B = r.G1.fromObject(s.pi_a), A = r.G2.fromObject(s.pi_b), O = r.G1.fromObject(s.pi_c);
|
|
11855
11829
|
if (!Nl(r, { pi_a: B, pi_b: A, pi_c: O }))
|
|
11856
11830
|
return e && e.error("Proof commitments are not valid."), !1;
|
|
11857
|
-
const P = r.G2.fromObject(i.vk_gamma_2), E = r.G2.fromObject(i.vk_delta_2),
|
|
11831
|
+
const P = r.G2.fromObject(i.vk_gamma_2), E = r.G2.fromObject(i.vk_delta_2), z = r.G1.fromObject(i.vk_alpha_1), x = r.G2.fromObject(i.vk_beta_2);
|
|
11858
11832
|
return await r.pairingEq(
|
|
11859
11833
|
r.G1.neg(B),
|
|
11860
11834
|
A,
|
|
@@ -11862,7 +11836,7 @@ async function kl(o, t, n, e) {
|
|
|
11862
11836
|
P,
|
|
11863
11837
|
O,
|
|
11864
11838
|
E,
|
|
11865
|
-
|
|
11839
|
+
z,
|
|
11866
11840
|
x
|
|
11867
11841
|
) ? (e && e.info("OK!"), !0) : (e && e.error("Invalid proof"), !1);
|
|
11868
11842
|
}
|
|
@@ -11872,7 +11846,7 @@ function Nl(o, t) {
|
|
|
11872
11846
|
}
|
|
11873
11847
|
function Gl(o, t) {
|
|
11874
11848
|
for (let n = 0; n < t.length; n++)
|
|
11875
|
-
if (!
|
|
11849
|
+
if (!Mt.lt(t[n], o.r))
|
|
11876
11850
|
return !1;
|
|
11877
11851
|
return !0;
|
|
11878
11852
|
}
|
|
@@ -11898,8 +11872,8 @@ var yi = /* @__PURE__ */ Object.freeze({
|
|
|
11898
11872
|
verify: kl,
|
|
11899
11873
|
exportSolidityCallData: Kl
|
|
11900
11874
|
});
|
|
11901
|
-
|
|
11902
|
-
|
|
11875
|
+
Mt.e("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001", 16);
|
|
11876
|
+
Mt.e("21888242871839275222246405745257275088548364400416034343698204186575808495617");
|
|
11903
11877
|
var Hl = { exports: {} };
|
|
11904
11878
|
/**
|
|
11905
11879
|
* [js-sha3]{@link https://github.com/emn178/js-sha3}
|
|
@@ -11964,7 +11938,7 @@ var Hl = { exports: {} };
|
|
|
11964
11938
|
0,
|
|
11965
11939
|
2147516424,
|
|
11966
11940
|
2147483648
|
|
11967
|
-
], E = [224, 256, 384, 512],
|
|
11941
|
+
], E = [224, 256, 384, 512], z = [128, 256], x = ["hex", "buffer", "arrayBuffer", "array", "digest"], ot = {
|
|
11968
11942
|
128: 168,
|
|
11969
11943
|
256: 136
|
|
11970
11944
|
};
|
|
@@ -11973,7 +11947,7 @@ var Hl = { exports: {} };
|
|
|
11973
11947
|
}), b && (i.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView) && (ArrayBuffer.isView = function(p) {
|
|
11974
11948
|
return typeof p == "object" && p.buffer && p.buffer.constructor === ArrayBuffer;
|
|
11975
11949
|
});
|
|
11976
|
-
for (var
|
|
11950
|
+
for (var T = function(p, a, m) {
|
|
11977
11951
|
return function(c) {
|
|
11978
11952
|
return new At(p, a, p).update(c)[m]();
|
|
11979
11953
|
};
|
|
@@ -11996,12 +11970,12 @@ var Hl = { exports: {} };
|
|
|
11996
11970
|
}
|
|
11997
11971
|
return p;
|
|
11998
11972
|
}, V = function(p, a) {
|
|
11999
|
-
var m =
|
|
11973
|
+
var m = T(p, a, "hex");
|
|
12000
11974
|
return m.create = function() {
|
|
12001
11975
|
return new At(p, a, p);
|
|
12002
11976
|
}, m.update = function(c) {
|
|
12003
11977
|
return m.create().update(c);
|
|
12004
|
-
}, L(m,
|
|
11978
|
+
}, L(m, T, p, a);
|
|
12005
11979
|
}, $ = function(p, a) {
|
|
12006
11980
|
var m = rt(p, a, "hex");
|
|
12007
11981
|
return m.create = function(c) {
|
|
@@ -12016,7 +11990,7 @@ var Hl = { exports: {} };
|
|
|
12016
11990
|
}, c.update = function(w, I, h, S) {
|
|
12017
11991
|
return c.create(I, h, S).update(w);
|
|
12018
11992
|
}, L(c, F, p, a);
|
|
12019
|
-
},
|
|
11993
|
+
}, Q = function(p, a) {
|
|
12020
11994
|
var m = ot[p], c = f(p, a, "hex");
|
|
12021
11995
|
return c.create = function(w, I, h) {
|
|
12022
11996
|
return new Bt(p, a, I).bytepad(["KMAC", h], m).bytepad([w], m);
|
|
@@ -12026,9 +12000,9 @@ var Hl = { exports: {} };
|
|
|
12026
12000
|
}, y = [
|
|
12027
12001
|
{ name: "keccak", padding: B, bits: E, createMethod: V },
|
|
12028
12002
|
{ name: "sha3", padding: A, bits: E, createMethod: V },
|
|
12029
|
-
{ name: "shake", padding: l, bits:
|
|
12030
|
-
{ name: "cshake", padding: C, bits:
|
|
12031
|
-
{ name: "kmac", padding: C, bits:
|
|
12003
|
+
{ name: "shake", padding: l, bits: z, createMethod: $ },
|
|
12004
|
+
{ name: "cshake", padding: C, bits: z, createMethod: X },
|
|
12005
|
+
{ name: "kmac", padding: C, bits: z, createMethod: Q }
|
|
12032
12006
|
], v = {}, D = [], it = 0; it < y.length; ++it)
|
|
12033
12007
|
for (var nt = y[it], K = nt.bits, ct = 0; ct < K.length; ++ct) {
|
|
12034
12008
|
var J = nt.name + "_" + K[ct];
|
|
@@ -12154,9 +12128,9 @@ var Hl = { exports: {} };
|
|
|
12154
12128
|
return this.encode(this.outputBits, !0), At.prototype.finalize.call(this);
|
|
12155
12129
|
};
|
|
12156
12130
|
var pt = function(p) {
|
|
12157
|
-
var a, m, c, w, I, h, S, W, N, at, It, ut, Lt, St, gt, dt, yt, vt, Ut, Vt, Dt, jt,
|
|
12131
|
+
var a, m, c, w, I, h, S, W, N, at, It, ut, Lt, St, gt, dt, yt, vt, Ut, Vt, Dt, jt, zt, Nt, Kt, en, Zt, G, _, g, M, R, q, k, U, j, Y, Z, H, et, ft, _t, lt, bt, mt, Ot, Ct, wt, ht, qt, Ht, Wt, On, pn, Ln, vn, An, bn, Pn, ln, on, wn, ce;
|
|
12158
12132
|
for (c = 0; c < 48; c += 2)
|
|
12159
|
-
w = p[0] ^ p[10] ^ p[20] ^ p[30] ^ p[40], I = p[1] ^ p[11] ^ p[21] ^ p[31] ^ p[41], h = p[2] ^ p[12] ^ p[22] ^ p[32] ^ p[42], S = p[3] ^ p[13] ^ p[23] ^ p[33] ^ p[43], W = p[4] ^ p[14] ^ p[24] ^ p[34] ^ p[44], N = p[5] ^ p[15] ^ p[25] ^ p[35] ^ p[45], at = p[6] ^ p[16] ^ p[26] ^ p[36] ^ p[46], It = p[7] ^ p[17] ^ p[27] ^ p[37] ^ p[47], ut = p[8] ^ p[18] ^ p[28] ^ p[38] ^ p[48], Lt = p[9] ^ p[19] ^ p[29] ^ p[39] ^ p[49], a = ut ^ (h << 1 | S >>> 31), m = Lt ^ (S << 1 | h >>> 31), p[0] ^= a, p[1] ^= m, p[10] ^= a, p[11] ^= m, p[20] ^= a, p[21] ^= m, p[30] ^= a, p[31] ^= m, p[40] ^= a, p[41] ^= m, a = w ^ (W << 1 | N >>> 31), m = I ^ (N << 1 | W >>> 31), p[2] ^= a, p[3] ^= m, p[12] ^= a, p[13] ^= m, p[22] ^= a, p[23] ^= m, p[32] ^= a, p[33] ^= m, p[42] ^= a, p[43] ^= m, a = h ^ (at << 1 | It >>> 31), m = S ^ (It << 1 | at >>> 31), p[4] ^= a, p[5] ^= m, p[14] ^= a, p[15] ^= m, p[24] ^= a, p[25] ^= m, p[34] ^= a, p[35] ^= m, p[44] ^= a, p[45] ^= m, a = W ^ (ut << 1 | Lt >>> 31), m = N ^ (Lt << 1 | ut >>> 31), p[6] ^= a, p[7] ^= m, p[16] ^= a, p[17] ^= m, p[26] ^= a, p[27] ^= m, p[36] ^= a, p[37] ^= m, p[46] ^= a, p[47] ^= m, a = at ^ (w << 1 | I >>> 31), m = It ^ (I << 1 | w >>> 31), p[8] ^= a, p[9] ^= m, p[18] ^= a, p[19] ^= m, p[28] ^= a, p[29] ^= m, p[38] ^= a, p[39] ^= m, p[48] ^= a, p[49] ^= m, St = p[0], gt = p[1], Ot = p[11] << 4 | p[10] >>> 28, Ct = p[10] << 4 | p[11] >>> 28, G = p[20] << 3 | p[21] >>> 29, _ = p[21] << 3 | p[20] >>> 29, ln = p[31] << 9 | p[30] >>> 23, on = p[30] << 9 | p[31] >>> 23, _t = p[40] << 18 | p[41] >>> 14, lt = p[41] << 18 | p[40] >>> 14, k = p[2] << 1 | p[3] >>> 31, U = p[3] << 1 | p[2] >>> 31, dt = p[13] << 12 | p[12] >>> 20, yt = p[12] << 12 | p[13] >>> 20, wt = p[22] << 10 | p[23] >>> 22, ht = p[23] << 10 | p[22] >>> 22, g = p[33] << 13 | p[32] >>> 19,
|
|
12133
|
+
w = p[0] ^ p[10] ^ p[20] ^ p[30] ^ p[40], I = p[1] ^ p[11] ^ p[21] ^ p[31] ^ p[41], h = p[2] ^ p[12] ^ p[22] ^ p[32] ^ p[42], S = p[3] ^ p[13] ^ p[23] ^ p[33] ^ p[43], W = p[4] ^ p[14] ^ p[24] ^ p[34] ^ p[44], N = p[5] ^ p[15] ^ p[25] ^ p[35] ^ p[45], at = p[6] ^ p[16] ^ p[26] ^ p[36] ^ p[46], It = p[7] ^ p[17] ^ p[27] ^ p[37] ^ p[47], ut = p[8] ^ p[18] ^ p[28] ^ p[38] ^ p[48], Lt = p[9] ^ p[19] ^ p[29] ^ p[39] ^ p[49], a = ut ^ (h << 1 | S >>> 31), m = Lt ^ (S << 1 | h >>> 31), p[0] ^= a, p[1] ^= m, p[10] ^= a, p[11] ^= m, p[20] ^= a, p[21] ^= m, p[30] ^= a, p[31] ^= m, p[40] ^= a, p[41] ^= m, a = w ^ (W << 1 | N >>> 31), m = I ^ (N << 1 | W >>> 31), p[2] ^= a, p[3] ^= m, p[12] ^= a, p[13] ^= m, p[22] ^= a, p[23] ^= m, p[32] ^= a, p[33] ^= m, p[42] ^= a, p[43] ^= m, a = h ^ (at << 1 | It >>> 31), m = S ^ (It << 1 | at >>> 31), p[4] ^= a, p[5] ^= m, p[14] ^= a, p[15] ^= m, p[24] ^= a, p[25] ^= m, p[34] ^= a, p[35] ^= m, p[44] ^= a, p[45] ^= m, a = W ^ (ut << 1 | Lt >>> 31), m = N ^ (Lt << 1 | ut >>> 31), p[6] ^= a, p[7] ^= m, p[16] ^= a, p[17] ^= m, p[26] ^= a, p[27] ^= m, p[36] ^= a, p[37] ^= m, p[46] ^= a, p[47] ^= m, a = at ^ (w << 1 | I >>> 31), m = It ^ (I << 1 | w >>> 31), p[8] ^= a, p[9] ^= m, p[18] ^= a, p[19] ^= m, p[28] ^= a, p[29] ^= m, p[38] ^= a, p[39] ^= m, p[48] ^= a, p[49] ^= m, St = p[0], gt = p[1], Ot = p[11] << 4 | p[10] >>> 28, Ct = p[10] << 4 | p[11] >>> 28, G = p[20] << 3 | p[21] >>> 29, _ = p[21] << 3 | p[20] >>> 29, ln = p[31] << 9 | p[30] >>> 23, on = p[30] << 9 | p[31] >>> 23, _t = p[40] << 18 | p[41] >>> 14, lt = p[41] << 18 | p[40] >>> 14, k = p[2] << 1 | p[3] >>> 31, U = p[3] << 1 | p[2] >>> 31, dt = p[13] << 12 | p[12] >>> 20, yt = p[12] << 12 | p[13] >>> 20, wt = p[22] << 10 | p[23] >>> 22, ht = p[23] << 10 | p[22] >>> 22, g = p[33] << 13 | p[32] >>> 19, M = p[32] << 13 | p[33] >>> 19, wn = p[42] << 2 | p[43] >>> 30, ce = p[43] << 2 | p[42] >>> 30, pn = p[5] << 30 | p[4] >>> 2, Ln = p[4] << 30 | p[5] >>> 2, j = p[14] << 6 | p[15] >>> 26, Y = p[15] << 6 | p[14] >>> 26, vt = p[25] << 11 | p[24] >>> 21, Ut = p[24] << 11 | p[25] >>> 21, qt = p[34] << 15 | p[35] >>> 17, Ht = p[35] << 15 | p[34] >>> 17, R = p[45] << 29 | p[44] >>> 3, q = p[44] << 29 | p[45] >>> 3, Nt = p[6] << 28 | p[7] >>> 4, Kt = p[7] << 28 | p[6] >>> 4, vn = p[17] << 23 | p[16] >>> 9, An = p[16] << 23 | p[17] >>> 9, Z = p[26] << 25 | p[27] >>> 7, H = p[27] << 25 | p[26] >>> 7, Vt = p[36] << 21 | p[37] >>> 11, Dt = p[37] << 21 | p[36] >>> 11, Wt = p[47] << 24 | p[46] >>> 8, On = p[46] << 24 | p[47] >>> 8, bt = p[8] << 27 | p[9] >>> 5, mt = p[9] << 27 | p[8] >>> 5, en = p[18] << 20 | p[19] >>> 12, Zt = p[19] << 20 | p[18] >>> 12, bn = p[29] << 7 | p[28] >>> 25, Pn = p[28] << 7 | p[29] >>> 25, et = p[38] << 8 | p[39] >>> 24, ft = p[39] << 8 | p[38] >>> 24, jt = p[48] << 14 | p[49] >>> 18, zt = p[49] << 14 | p[48] >>> 18, p[0] = St ^ ~dt & vt, p[1] = gt ^ ~yt & Ut, p[10] = Nt ^ ~en & G, p[11] = Kt ^ ~Zt & _, p[20] = k ^ ~j & Z, p[21] = U ^ ~Y & H, p[30] = bt ^ ~Ot & wt, p[31] = mt ^ ~Ct & ht, p[40] = pn ^ ~vn & bn, p[41] = Ln ^ ~An & Pn, p[2] = dt ^ ~vt & Vt, p[3] = yt ^ ~Ut & Dt, p[12] = en ^ ~G & g, p[13] = Zt ^ ~_ & M, p[22] = j ^ ~Z & et, p[23] = Y ^ ~H & ft, p[32] = Ot ^ ~wt & qt, p[33] = Ct ^ ~ht & Ht, p[42] = vn ^ ~bn & ln, p[43] = An ^ ~Pn & on, p[4] = vt ^ ~Vt & jt, p[5] = Ut ^ ~Dt & zt, p[14] = G ^ ~g & R, p[15] = _ ^ ~M & q, p[24] = Z ^ ~et & _t, p[25] = H ^ ~ft & lt, p[34] = wt ^ ~qt & Wt, p[35] = ht ^ ~Ht & On, p[44] = bn ^ ~ln & wn, p[45] = Pn ^ ~on & ce, p[6] = Vt ^ ~jt & St, p[7] = Dt ^ ~zt & gt, p[16] = g ^ ~R & Nt, p[17] = M ^ ~q & Kt, p[26] = et ^ ~_t & k, p[27] = ft ^ ~lt & U, p[36] = qt ^ ~Wt & bt, p[37] = Ht ^ ~On & mt, p[46] = ln ^ ~wn & pn, p[47] = on ^ ~ce & Ln, p[8] = jt ^ ~St & dt, p[9] = zt ^ ~gt & yt, p[18] = R ^ ~Nt & en, p[19] = q ^ ~Kt & Zt, p[28] = _t ^ ~k & j, p[29] = lt ^ ~U & Y, p[38] = Wt ^ ~bt & Ot, p[39] = On ^ ~mt & Ct, p[48] = wn ^ ~pn & vn, p[49] = ce ^ ~Ln & An, p[0] ^= P[c], p[1] ^= P[c + 1];
|
|
12160
12134
|
};
|
|
12161
12135
|
if (r)
|
|
12162
12136
|
o.exports = v;
|
|
@@ -12165,7 +12139,7 @@ var Hl = { exports: {} };
|
|
|
12165
12139
|
i[D[it]] = v[D[it]];
|
|
12166
12140
|
})();
|
|
12167
12141
|
})(Hl);
|
|
12168
|
-
function
|
|
12142
|
+
function Qa(o, t) {
|
|
12169
12143
|
return function() {
|
|
12170
12144
|
return o.apply(t, arguments);
|
|
12171
12145
|
};
|
|
@@ -12177,10 +12151,10 @@ const { toString: Vl } = Object.prototype, { getPrototypeOf: mo } = Object, ye =
|
|
|
12177
12151
|
function jl(o) {
|
|
12178
12152
|
return o !== null && !Jn(o) && o.constructor !== null && !Jn(o.constructor) && nn(o.constructor.isBuffer) && o.constructor.isBuffer(o);
|
|
12179
12153
|
}
|
|
12180
|
-
const
|
|
12154
|
+
const Ma = sn("ArrayBuffer");
|
|
12181
12155
|
function $l(o) {
|
|
12182
12156
|
let t;
|
|
12183
|
-
return typeof ArrayBuffer < "u" && ArrayBuffer.isView ? t = ArrayBuffer.isView(o) : t = o && o.buffer &&
|
|
12157
|
+
return typeof ArrayBuffer < "u" && ArrayBuffer.isView ? t = ArrayBuffer.isView(o) : t = o && o.buffer && Ma(o.buffer), t;
|
|
12184
12158
|
}
|
|
12185
12159
|
const Yl = Ie("string"), nn = Ie("function"), Ua = Ie("number"), Ce = (o) => o !== null && typeof o == "object", Zl = (o) => o === !0 || o === !1, de = (o) => {
|
|
12186
12160
|
if (ye(o) !== "object")
|
|
@@ -12206,7 +12180,7 @@ function ie(o, t, { allOwnKeys: n = !1 } = {}) {
|
|
|
12206
12180
|
r = s[e], t.call(null, o[r], r, o);
|
|
12207
12181
|
}
|
|
12208
12182
|
}
|
|
12209
|
-
function
|
|
12183
|
+
function za(o, t) {
|
|
12210
12184
|
t = t.toLowerCase();
|
|
12211
12185
|
const n = Object.keys(o);
|
|
12212
12186
|
let e = n.length, i;
|
|
@@ -12215,10 +12189,10 @@ function Ta(o, t) {
|
|
|
12215
12189
|
return i;
|
|
12216
12190
|
return null;
|
|
12217
12191
|
}
|
|
12218
|
-
const
|
|
12192
|
+
const Ta = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : global, Ra = (o) => !Jn(o) && o !== Ta;
|
|
12219
12193
|
function io() {
|
|
12220
12194
|
const { caseless: o } = Ra(this) && this || {}, t = {}, n = (e, i) => {
|
|
12221
|
-
const s = o &&
|
|
12195
|
+
const s = o && za(t, i) || i;
|
|
12222
12196
|
de(t[s]) && de(e) ? t[s] = io(t[s], e) : de(e) ? t[s] = io({}, e) : Dn(e) ? t[s] = e.slice() : t[s] = e;
|
|
12223
12197
|
};
|
|
12224
12198
|
for (let e = 0, i = arguments.length; e < i; e++)
|
|
@@ -12226,7 +12200,7 @@ function io() {
|
|
|
12226
12200
|
return t;
|
|
12227
12201
|
}
|
|
12228
12202
|
const ar = (o, t, n, { allOwnKeys: e } = {}) => (ie(t, (i, s) => {
|
|
12229
|
-
n && nn(i) ? o[s] =
|
|
12203
|
+
n && nn(i) ? o[s] = Qa(i, n) : o[s] = i;
|
|
12230
12204
|
}, { allOwnKeys: e }), o), cr = (o) => (o.charCodeAt(0) === 65279 && (o = o.slice(1)), o), sr = (o, t, n, e) => {
|
|
12231
12205
|
o.prototype = Object.create(t.prototype, e), o.prototype.constructor = o, Object.defineProperty(o, "super", {
|
|
12232
12206
|
value: t.prototype
|
|
@@ -12339,7 +12313,7 @@ const mr = (o) => {
|
|
|
12339
12313
|
}, wr = sn("AsyncFunction"), Br = (o) => o && (Ce(o) || nn(o)) && nn(o.then) && nn(o.catch);
|
|
12340
12314
|
var tt = {
|
|
12341
12315
|
isArray: Dn,
|
|
12342
|
-
isArrayBuffer:
|
|
12316
|
+
isArrayBuffer: Ma,
|
|
12343
12317
|
isBuffer: jl,
|
|
12344
12318
|
isFormData: er,
|
|
12345
12319
|
isArrayBufferView: $l,
|
|
@@ -12381,8 +12355,8 @@ var tt = {
|
|
|
12381
12355
|
toCamelCase: hr,
|
|
12382
12356
|
noop: br,
|
|
12383
12357
|
toFiniteNumber: yr,
|
|
12384
|
-
findKey:
|
|
12385
|
-
global:
|
|
12358
|
+
findKey: za,
|
|
12359
|
+
global: Ta,
|
|
12386
12360
|
isContextDefined: Ra,
|
|
12387
12361
|
ALPHABET: ka,
|
|
12388
12362
|
generateString: Ir,
|
|
@@ -12482,15 +12456,15 @@ function me(o, t, n) {
|
|
|
12482
12456
|
return tt.isArrayBuffer(O) || tt.isTypedArray(O) ? b && typeof Blob == "function" ? new Blob([O]) : Buffer.from(O) : O;
|
|
12483
12457
|
}
|
|
12484
12458
|
function l(O, P, E) {
|
|
12485
|
-
let
|
|
12459
|
+
let z = O;
|
|
12486
12460
|
if (O && !E && typeof O == "object") {
|
|
12487
12461
|
if (tt.endsWith(P, "{}"))
|
|
12488
12462
|
P = e ? P : P.slice(0, -2), O = JSON.stringify(O);
|
|
12489
|
-
else if (tt.isArray(O) && Fr(O) || (tt.isFileList(O) || tt.endsWith(P, "[]")) && (
|
|
12490
|
-
return P = Ka(P),
|
|
12463
|
+
else if (tt.isArray(O) && Fr(O) || (tt.isFileList(O) || tt.endsWith(P, "[]")) && (z = tt.toArray(O)))
|
|
12464
|
+
return P = Ka(P), z.forEach(function(ot, T) {
|
|
12491
12465
|
!(tt.isUndefined(ot) || ot === null) && t.append(
|
|
12492
12466
|
// eslint-disable-next-line no-nested-ternary
|
|
12493
|
-
d === !0 ? mi([P],
|
|
12467
|
+
d === !0 ? mi([P], T, s) : d === null ? P : P + "[]",
|
|
12494
12468
|
u(ot)
|
|
12495
12469
|
);
|
|
12496
12470
|
}), !1;
|
|
@@ -12506,14 +12480,14 @@ function me(o, t, n) {
|
|
|
12506
12480
|
if (!tt.isUndefined(O)) {
|
|
12507
12481
|
if (C.indexOf(O) !== -1)
|
|
12508
12482
|
throw Error("Circular reference detected in " + P.join("."));
|
|
12509
|
-
C.push(O), tt.forEach(O, function(
|
|
12510
|
-
(!(tt.isUndefined(
|
|
12483
|
+
C.push(O), tt.forEach(O, function(z, x) {
|
|
12484
|
+
(!(tt.isUndefined(z) || z === null) && i.call(
|
|
12511
12485
|
t,
|
|
12512
|
-
|
|
12486
|
+
z,
|
|
12513
12487
|
tt.isString(x) ? x.trim() : x,
|
|
12514
12488
|
P,
|
|
12515
12489
|
B
|
|
12516
|
-
)) === !0 && A(
|
|
12490
|
+
)) === !0 && A(z, P ? P.concat(x) : [x]);
|
|
12517
12491
|
}), C.pop();
|
|
12518
12492
|
}
|
|
12519
12493
|
}
|
|
@@ -12631,25 +12605,25 @@ var ja = {
|
|
|
12631
12605
|
},
|
|
12632
12606
|
protocols: ["http", "https", "file", "blob", "url", "data"]
|
|
12633
12607
|
};
|
|
12634
|
-
const $a = typeof window < "u" && typeof document < "u",
|
|
12608
|
+
const $a = typeof window < "u" && typeof document < "u", Qr = ((o) => $a && ["ReactNative", "NativeScript", "NS"].indexOf(o) < 0)(typeof navigator < "u" && navigator.product), Mr = typeof WorkerGlobalScope < "u" && // eslint-disable-next-line no-undef
|
|
12635
12609
|
self instanceof WorkerGlobalScope && typeof self.importScripts == "function";
|
|
12636
12610
|
var Ur = /* @__PURE__ */ Object.freeze({
|
|
12637
12611
|
__proto__: null,
|
|
12638
12612
|
hasBrowserEnv: $a,
|
|
12639
|
-
hasStandardBrowserEnv:
|
|
12640
|
-
hasStandardBrowserWebWorkerEnv:
|
|
12613
|
+
hasStandardBrowserEnv: Qr,
|
|
12614
|
+
hasStandardBrowserWebWorkerEnv: Mr
|
|
12641
12615
|
}), cn = {
|
|
12642
12616
|
...Ur,
|
|
12643
12617
|
...qr
|
|
12644
12618
|
};
|
|
12645
|
-
function
|
|
12619
|
+
function zr(o, t) {
|
|
12646
12620
|
return me(o, new cn.classes.URLSearchParams(), Object.assign({
|
|
12647
12621
|
visitor: function(n, e, i, s) {
|
|
12648
12622
|
return cn.isNode && tt.isBuffer(n) ? (this.append(e, n.toString("base64")), !1) : s.defaultVisitor.apply(this, arguments);
|
|
12649
12623
|
}
|
|
12650
12624
|
}, t));
|
|
12651
12625
|
}
|
|
12652
|
-
function
|
|
12626
|
+
function Tr(o) {
|
|
12653
12627
|
return tt.matchAll(/\w+|\[(\w*)]/g, o).map((t) => t[0] === "[]" ? "" : t[1] || t[0]);
|
|
12654
12628
|
}
|
|
12655
12629
|
function Rr(o) {
|
|
@@ -12672,7 +12646,7 @@ function Ya(o) {
|
|
|
12672
12646
|
if (tt.isFormData(o) && tt.isFunction(o.entries)) {
|
|
12673
12647
|
const n = {};
|
|
12674
12648
|
return tt.forEachEntry(o, (e, i) => {
|
|
12675
|
-
t(
|
|
12649
|
+
t(Tr(e), i, n, 0);
|
|
12676
12650
|
}), n;
|
|
12677
12651
|
}
|
|
12678
12652
|
return null;
|
|
@@ -12703,7 +12677,7 @@ const Bo = {
|
|
|
12703
12677
|
let r;
|
|
12704
12678
|
if (s) {
|
|
12705
12679
|
if (e.indexOf("application/x-www-form-urlencoded") > -1)
|
|
12706
|
-
return
|
|
12680
|
+
return zr(t, this.formSerializer).toString();
|
|
12707
12681
|
if ((r = tt.isFileList(t)) || e.indexOf("multipart/form-data") > -1) {
|
|
12708
12682
|
const b = this.env && this.env.FormData;
|
|
12709
12683
|
return me(
|
|
@@ -13088,7 +13062,7 @@ var nd = td && function(o) {
|
|
|
13088
13062
|
if (cn.hasStandardBrowserEnv || cn.hasStandardBrowserWebWorkerEnv)
|
|
13089
13063
|
s.setContentType(!1);
|
|
13090
13064
|
else if ((l = s.getContentType()) !== !1) {
|
|
13091
|
-
const [P, ...E] = l ? l.split(";").map((
|
|
13065
|
+
const [P, ...E] = l ? l.split(";").map((z) => z.trim()).filter(Boolean) : [];
|
|
13092
13066
|
s.setContentType([P || "multipart/form-data", ...E].join("; "));
|
|
13093
13067
|
}
|
|
13094
13068
|
}
|
|
@@ -13104,7 +13078,7 @@ var nd = td && function(o) {
|
|
|
13104
13078
|
return;
|
|
13105
13079
|
const P = fn.from(
|
|
13106
13080
|
"getAllResponseHeaders" in C && C.getAllResponseHeaders()
|
|
13107
|
-
),
|
|
13081
|
+
), z = {
|
|
13108
13082
|
data: !d || d === "text" || d === "json" ? C.responseText : C.response,
|
|
13109
13083
|
status: C.status,
|
|
13110
13084
|
statusText: C.statusText,
|
|
@@ -13116,7 +13090,7 @@ var nd = td && function(o) {
|
|
|
13116
13090
|
n(ot), u();
|
|
13117
13091
|
}, function(ot) {
|
|
13118
13092
|
e(ot), u();
|
|
13119
|
-
},
|
|
13093
|
+
}, z), C = null;
|
|
13120
13094
|
}
|
|
13121
13095
|
if ("onloadend" in C ? C.onloadend = A : C.onreadystatechange = function() {
|
|
13122
13096
|
!C || C.readyState !== 4 || C.status === 0 && !(C.responseURL && C.responseURL.indexOf("file:") === 0) || setTimeout(A);
|
|
@@ -13126,10 +13100,10 @@ var nd = td && function(o) {
|
|
|
13126
13100
|
e(new Pt("Network Error", Pt.ERR_NETWORK, o, C)), C = null;
|
|
13127
13101
|
}, C.ontimeout = function() {
|
|
13128
13102
|
let E = o.timeout ? "timeout of " + o.timeout + "ms exceeded" : "timeout exceeded";
|
|
13129
|
-
const
|
|
13103
|
+
const z = o.transitional || ja;
|
|
13130
13104
|
o.timeoutErrorMessage && (E = o.timeoutErrorMessage), e(new Pt(
|
|
13131
13105
|
E,
|
|
13132
|
-
|
|
13106
|
+
z.clarifyTimeoutError ? Pt.ETIMEDOUT : Pt.ECONNABORTED,
|
|
13133
13107
|
o,
|
|
13134
13108
|
C
|
|
13135
13109
|
)), C = null;
|
|
@@ -13137,8 +13111,8 @@ var nd = td && function(o) {
|
|
|
13137
13111
|
const P = o.xsrfHeaderName && o.xsrfCookieName && $r.read(o.xsrfCookieName);
|
|
13138
13112
|
P && s.set(o.xsrfHeaderName, P);
|
|
13139
13113
|
}
|
|
13140
|
-
i === void 0 && s.setContentType(null), "setRequestHeader" in C && tt.forEach(s.toJSON(), function(E,
|
|
13141
|
-
C.setRequestHeader(
|
|
13114
|
+
i === void 0 && s.setContentType(null), "setRequestHeader" in C && tt.forEach(s.toJSON(), function(E, z) {
|
|
13115
|
+
C.setRequestHeader(z, E);
|
|
13142
13116
|
}), tt.isUndefined(o.withCredentials) || (C.withCredentials = !!o.withCredentials), d && d !== "json" && (C.responseType = o.responseType), typeof o.onDownloadProgress == "function" && C.addEventListener("progress", Fi(o.onDownloadProgress, !0)), typeof o.onUploadProgress == "function" && C.upload && C.upload.addEventListener("progress", Fi(o.onUploadProgress)), (o.cancelToken || o.signal) && (b = (P) => {
|
|
13143
13117
|
C && (e(!P || P.type ? new ae(null, o, C) : P), C.abort(), C = null);
|
|
13144
13118
|
}, o.cancelToken && o.cancelToken.subscribe(b), o.signal && (o.signal.aborted ? b() : o.signal.addEventListener("abort", b)));
|
|
@@ -13218,7 +13192,7 @@ function Si(o) {
|
|
|
13218
13192
|
});
|
|
13219
13193
|
}
|
|
13220
13194
|
const Oi = (o) => o instanceof fn ? { ...o } : o;
|
|
13221
|
-
function
|
|
13195
|
+
function Tn(o, t) {
|
|
13222
13196
|
t = t || {};
|
|
13223
13197
|
const n = {};
|
|
13224
13198
|
function e(u, l, C) {
|
|
@@ -13361,7 +13335,7 @@ class pe {
|
|
|
13361
13335
|
}
|
|
13362
13336
|
}
|
|
13363
13337
|
_request(t, n) {
|
|
13364
|
-
typeof t == "string" ? (n = n || {}, n.url = t) : n = t || {}, n =
|
|
13338
|
+
typeof t == "string" ? (n = n || {}, n.url = t) : n = t || {}, n = Tn(this.defaults, n);
|
|
13365
13339
|
const { transitional: e, paramsSerializer: i, headers: s } = n;
|
|
13366
13340
|
e !== void 0 && so.assertOptions(e, {
|
|
13367
13341
|
silentJSONParsing: In.transitional(In.boolean),
|
|
@@ -13420,14 +13394,14 @@ class pe {
|
|
|
13420
13394
|
return l;
|
|
13421
13395
|
}
|
|
13422
13396
|
getUri(t) {
|
|
13423
|
-
t =
|
|
13397
|
+
t = Tn(this.defaults, t);
|
|
13424
13398
|
const n = Ja(t.baseURL, t.url);
|
|
13425
13399
|
return Va(n, t.params, t.paramsSerializer);
|
|
13426
13400
|
}
|
|
13427
13401
|
}
|
|
13428
13402
|
tt.forEach(["delete", "get", "head", "options"], function(t) {
|
|
13429
13403
|
pe.prototype[t] = function(n, e) {
|
|
13430
|
-
return this.request(
|
|
13404
|
+
return this.request(Tn(e || {}, {
|
|
13431
13405
|
method: t,
|
|
13432
13406
|
url: n,
|
|
13433
13407
|
data: (e || {}).data
|
|
@@ -13437,7 +13411,7 @@ tt.forEach(["delete", "get", "head", "options"], function(t) {
|
|
|
13437
13411
|
tt.forEach(["post", "put", "patch"], function(t) {
|
|
13438
13412
|
function n(e) {
|
|
13439
13413
|
return function(s, d, r) {
|
|
13440
|
-
return this.request(
|
|
13414
|
+
return this.request(Tn(r || {}, {
|
|
13441
13415
|
method: t,
|
|
13442
13416
|
headers: e ? {
|
|
13443
13417
|
"Content-Type": "multipart/form-data"
|
|
@@ -13597,9 +13571,9 @@ Object.entries(lo).forEach(([o, t]) => {
|
|
|
13597
13571
|
});
|
|
13598
13572
|
var sd = lo;
|
|
13599
13573
|
function tc(o) {
|
|
13600
|
-
const t = new _e(o), n =
|
|
13574
|
+
const t = new _e(o), n = Qa(_e.prototype.request, t);
|
|
13601
13575
|
return tt.extend(n, _e.prototype, t, { allOwnKeys: !0 }), tt.extend(n, t, null, { allOwnKeys: !0 }), n.create = function(i) {
|
|
13602
|
-
return tc(
|
|
13576
|
+
return tc(Tn(o, i));
|
|
13603
13577
|
}, n;
|
|
13604
13578
|
}
|
|
13605
13579
|
const Rt = tc(Eo);
|
|
@@ -13616,7 +13590,7 @@ Rt.all = function(t) {
|
|
|
13616
13590
|
};
|
|
13617
13591
|
Rt.spread = ad;
|
|
13618
13592
|
Rt.isAxiosError = cd;
|
|
13619
|
-
Rt.mergeConfig =
|
|
13593
|
+
Rt.mergeConfig = Tn;
|
|
13620
13594
|
Rt.AxiosHeaders = fn;
|
|
13621
13595
|
Rt.formToJSON = (o) => Ya(tt.isHTMLForm(o) ? new FormData(o) : o);
|
|
13622
13596
|
Rt.getAdapter = Wa.getAdapter;
|
|
@@ -13638,8 +13612,8 @@ const ro = new nc(), Pi = async (o) => {
|
|
|
13638
13612
|
const B = b.startsWith("https://");
|
|
13639
13613
|
if (Ee && !B) {
|
|
13640
13614
|
Oo ? (b = `libs/hardhat/test/circuits/${n}`, u = `libs/hardhat/test/circuits/${e}`) : !Oo && d && (b = `test/circuits/${n}`, u = `test/circuits/${e}`);
|
|
13641
|
-
const
|
|
13642
|
-
b =
|
|
13615
|
+
const z = require("path");
|
|
13616
|
+
b = z.resolve(b), u = z.resolve(u);
|
|
13643
13617
|
}
|
|
13644
13618
|
Ee && B ? (l = await Pi(b), C = await Pi(u)) : i === r.localhost && !Ee && (b = `${s}/${n}`, u = `${s}/${e}`);
|
|
13645
13619
|
const { proof: A, publicSignals: O } = await yi.fullProve(
|