@sabaaa1/common 0.1.2 → 0.1.3
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-B7rmy0gx.js} +1 -1
- package/assets/{snarkjsWorkerLogic-BTc2hrlU.js → snarkjsWorkerLogic-C3GGRlcw.js} +412 -390
- package/assets/{utxoWorkerLauncher-B6d6svhO.js → utxoWorkerLauncher-BP1uNzSU.js} +1 -1
- package/assets/{utxoWorkerLogic-YPywVy-e.js → utxoWorkerLogic-KxVg3qs6.js} +1625 -1603
- package/assets/{zkProofWorkerLauncher-CCedBtfh.js → zkProofWorkerLauncher-D-WqUrAW.js} +1 -1
- package/assets/{zkProofWorkerLogic-B_sgmDOg.js → zkProofWorkerLogic-CenLarOM.js} +1607 -1585
- 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/workerProxy.cjs +1 -1
- package/webworker/workerProxy.d.ts +2 -0
- package/webworker/workerProxy.mjs +34 -12
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
class nc {
|
|
2
2
|
isNode = !1;
|
|
3
3
|
isSandbox = !1;
|
|
4
|
+
errorCount = 0;
|
|
5
|
+
MAX_ERRORS = 5;
|
|
4
6
|
/**
|
|
5
7
|
* This allow browser or main thread to listen for worker response message
|
|
6
8
|
* using the normal `worker.onmessage = () => {}` syntax. Is should only be side on the
|
|
@@ -43,17 +45,30 @@ class nc {
|
|
|
43
45
|
e.postMessage && e.postMessage(t);
|
|
44
46
|
}
|
|
45
47
|
postErrorToMainThread(t) {
|
|
48
|
+
if (this.errorCount++, this.errorCount > this.MAX_ERRORS) {
|
|
49
|
+
console.error("Too many errors, stopping error reporting"), typeof self < "u" && self.close && self.close();
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
46
52
|
const n = { data: { error: t } };
|
|
47
53
|
if (this.onerror) {
|
|
48
|
-
|
|
54
|
+
try {
|
|
55
|
+
this.onerror(n);
|
|
56
|
+
} catch (i) {
|
|
57
|
+
console.error("Error in onerror handler:", i);
|
|
58
|
+
}
|
|
49
59
|
return;
|
|
50
60
|
}
|
|
51
61
|
const e = {
|
|
52
62
|
error: !0,
|
|
53
63
|
message: t instanceof Error ? t.message : String(t),
|
|
54
64
|
stack: t instanceof Error ? t.stack : void 0
|
|
55
|
-
}
|
|
56
|
-
|
|
65
|
+
};
|
|
66
|
+
try {
|
|
67
|
+
const i = typeof self < "u" ? self : globalThis;
|
|
68
|
+
i.postMessage && i.postMessage(e);
|
|
69
|
+
} catch (i) {
|
|
70
|
+
console.error("Failed to post error:", i);
|
|
71
|
+
}
|
|
57
72
|
}
|
|
58
73
|
attachWorkerSideOnMessage(t) {
|
|
59
74
|
if (this.isNode) {
|
|
@@ -70,15 +85,22 @@ class nc {
|
|
|
70
85
|
}
|
|
71
86
|
const n = typeof self < "u" ? self : globalThis;
|
|
72
87
|
n.addEventListener && n.addEventListener("message", (e) => {
|
|
73
|
-
|
|
74
|
-
|
|
88
|
+
if (this.errorCount = 0, !e || !e.data) {
|
|
89
|
+
console.warn("Worker received invalid message:", e);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
t(e.data);
|
|
94
|
+
} catch (i) {
|
|
95
|
+
console.error("Error in message handler:", i), this.postErrorToMainThread(i);
|
|
96
|
+
}
|
|
75
97
|
});
|
|
76
98
|
}
|
|
77
99
|
}
|
|
78
100
|
function ec(o, t) {
|
|
79
101
|
return Object.values(o).includes(t);
|
|
80
102
|
}
|
|
81
|
-
function
|
|
103
|
+
function Mi(o, t, n = !1) {
|
|
82
104
|
if (ec(o, t))
|
|
83
105
|
return t;
|
|
84
106
|
const e = `Value ${JSON.stringify(t)} is not a valid member of enum ${JSON.stringify(o)}.`;
|
|
@@ -97,13 +119,13 @@ function Fe(o, t) {
|
|
|
97
119
|
const oc = () => (require("dotenv").config({
|
|
98
120
|
// allow overriding .env file path, see startServer.sh script for explenation on why it is needed
|
|
99
121
|
path: "DOTENV_OVERRIDE" in process.env ? process.env.DOTENV_OVERRIDE : void 0
|
|
100
|
-
}),
|
|
122
|
+
}), Mi(uo, process.env.DEPLOYMENT_MODE) || "development"), ic = () => {
|
|
101
123
|
if (!So && typeof window > "u")
|
|
102
124
|
return;
|
|
103
125
|
if (So)
|
|
104
126
|
return oc();
|
|
105
127
|
if (window?.location?.protocol === "chrome-extension:") {
|
|
106
|
-
const t =
|
|
128
|
+
const t = Mi(uo, WALLET_DEPLOYMENT_MODE);
|
|
107
129
|
return t || "staging";
|
|
108
130
|
}
|
|
109
131
|
const o = window?.location?.host;
|
|
@@ -129,7 +151,7 @@ function Wn(o) {
|
|
|
129
151
|
const t = o.toString(16);
|
|
130
152
|
return (t.length - 1) * 4 + ac[parseInt(t[0], 16)];
|
|
131
153
|
}
|
|
132
|
-
function
|
|
154
|
+
function qi(o) {
|
|
133
155
|
return BigInt(o) < BigInt(0);
|
|
134
156
|
}
|
|
135
157
|
function Qi(o) {
|
|
@@ -138,10 +160,10 @@ function Qi(o) {
|
|
|
138
160
|
function ge(o, t) {
|
|
139
161
|
return BigInt(o) << BigInt(t);
|
|
140
162
|
}
|
|
141
|
-
function
|
|
163
|
+
function qn(o, t) {
|
|
142
164
|
return BigInt(o) >> BigInt(t);
|
|
143
165
|
}
|
|
144
|
-
const sc = ge, lc =
|
|
166
|
+
const sc = ge, lc = qn;
|
|
145
167
|
function _o(o) {
|
|
146
168
|
return (BigInt(o) & BigInt(1)) == BigInt(1);
|
|
147
169
|
}
|
|
@@ -250,7 +272,7 @@ function Yn(o, t, n, e) {
|
|
|
250
272
|
for (let r = d; r < s.length; r++)
|
|
251
273
|
s[r] = 0;
|
|
252
274
|
for (let r = s.length * 4; r < e; r++)
|
|
253
|
-
o[r] = Ti(fo(
|
|
275
|
+
o[r] = Ti(fo(qn(n, r * 8), 255));
|
|
254
276
|
}
|
|
255
277
|
function ki(o, t, n, e) {
|
|
256
278
|
const i = "0000000" + n.toString(16), s = new DataView(o.buffer, o.byteOffset + t, e), d = ((i.length - 7) * 4 - 1 >> 5) + 1;
|
|
@@ -298,7 +320,7 @@ var Cc = /* @__PURE__ */ Object.freeze({
|
|
|
298
320
|
fromString: Le,
|
|
299
321
|
geq: Di,
|
|
300
322
|
gt: He,
|
|
301
|
-
isNegative:
|
|
323
|
+
isNegative: qi,
|
|
302
324
|
isOdd: _o,
|
|
303
325
|
isZero: Qi,
|
|
304
326
|
land: bc,
|
|
@@ -314,7 +336,7 @@ var Cc = /* @__PURE__ */ Object.freeze({
|
|
|
314
336
|
one: Fn,
|
|
315
337
|
pow: Xn,
|
|
316
338
|
shiftLeft: ge,
|
|
317
|
-
shiftRight:
|
|
339
|
+
shiftRight: qn,
|
|
318
340
|
shl: sc,
|
|
319
341
|
shr: lc,
|
|
320
342
|
square: uc,
|
|
@@ -492,7 +514,7 @@ function Hi(o) {
|
|
|
492
514
|
t[n] = Math.random() * 4294967296 >>> 0;
|
|
493
515
|
return t;
|
|
494
516
|
}
|
|
495
|
-
function
|
|
517
|
+
function Mc() {
|
|
496
518
|
const o = Hi(32), t = new Uint32Array(o.buffer), n = [];
|
|
497
519
|
for (let e = 0; e < 8; e++)
|
|
498
520
|
n.push(t[e]);
|
|
@@ -500,9 +522,9 @@ function qc() {
|
|
|
500
522
|
}
|
|
501
523
|
let se = null;
|
|
502
524
|
function ho() {
|
|
503
|
-
return se || (se = new Pc(
|
|
525
|
+
return se || (se = new Pc(Mc()), se);
|
|
504
526
|
}
|
|
505
|
-
class
|
|
527
|
+
class qc {
|
|
506
528
|
constructor(t, n, e) {
|
|
507
529
|
this.F = n, this.G = t, this.opMulGF = e;
|
|
508
530
|
let i = n.sqrt_t || n.t, s = n.sqrt_s || n.s, d = n.one;
|
|
@@ -574,7 +596,7 @@ class Qc {
|
|
|
574
596
|
this.nqr = this.nqr + this.one, e = this.pow(this.nqr, n);
|
|
575
597
|
for (this.s = 0, this.t = this.negone; (this.t & this.one) == this.zero; )
|
|
576
598
|
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
|
|
599
|
+
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
600
|
}
|
|
579
601
|
e(t, n) {
|
|
580
602
|
let e;
|
|
@@ -996,7 +1018,7 @@ var Uc = function(t, n, e) {
|
|
|
996
1018
|
let D, it;
|
|
997
1019
|
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
1020
|
}
|
|
999
|
-
let X = "c0",
|
|
1021
|
+
let X = "c0", q = "c1";
|
|
1000
1022
|
for (let y = 0; y < s * 2 - 1; y++) {
|
|
1001
1023
|
for (let v = Math.max(0, y - s + 1); v <= y && v < s; v++) {
|
|
1002
1024
|
const D = y - v;
|
|
@@ -1013,9 +1035,9 @@ var Uc = function(t, n, e) {
|
|
|
1013
1035
|
)
|
|
1014
1036
|
), F.addCode(
|
|
1015
1037
|
f.setLocal(
|
|
1016
|
-
|
|
1038
|
+
q,
|
|
1017
1039
|
f.i64_add(
|
|
1018
|
-
f.getLocal(
|
|
1040
|
+
f.getLocal(q),
|
|
1019
1041
|
f.i64_shr_u(
|
|
1020
1042
|
f.getLocal(X),
|
|
1021
1043
|
f.i64_const(32)
|
|
@@ -1030,9 +1052,9 @@ var Uc = function(t, n, e) {
|
|
|
1030
1052
|
y * 4,
|
|
1031
1053
|
f.getLocal(X)
|
|
1032
1054
|
)
|
|
1033
|
-
), [X,
|
|
1055
|
+
), [X, q] = [q, X], F.addCode(
|
|
1034
1056
|
f.setLocal(
|
|
1035
|
-
|
|
1057
|
+
q,
|
|
1036
1058
|
f.i64_shr_u(
|
|
1037
1059
|
f.getLocal(X),
|
|
1038
1060
|
f.i64_const(32)
|
|
@@ -1058,7 +1080,7 @@ var Uc = function(t, n, e) {
|
|
|
1058
1080
|
let it, nt;
|
|
1059
1081
|
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
1082
|
}
|
|
1061
|
-
let $ = "c0", X = "c1",
|
|
1083
|
+
let $ = "c0", X = "c1", q = "c0_old", y = "c1_old";
|
|
1062
1084
|
for (let v = 0; v < s * 2 - 1; v++) {
|
|
1063
1085
|
F.addCode(
|
|
1064
1086
|
f.setLocal($, f.i64_const(0)),
|
|
@@ -1146,7 +1168,7 @@ var Uc = function(t, n, e) {
|
|
|
1146
1168
|
f.i64_const(4294967295)
|
|
1147
1169
|
),
|
|
1148
1170
|
f.i64_and(
|
|
1149
|
-
f.getLocal(
|
|
1171
|
+
f.getLocal(q),
|
|
1150
1172
|
f.i64_const(4294967295)
|
|
1151
1173
|
)
|
|
1152
1174
|
)
|
|
@@ -1173,13 +1195,13 @@ var Uc = function(t, n, e) {
|
|
|
1173
1195
|
)
|
|
1174
1196
|
), F.addCode(
|
|
1175
1197
|
f.setLocal(
|
|
1176
|
-
|
|
1198
|
+
q,
|
|
1177
1199
|
f.getLocal(X)
|
|
1178
1200
|
),
|
|
1179
1201
|
f.setLocal(
|
|
1180
1202
|
y,
|
|
1181
1203
|
f.i64_shr_u(
|
|
1182
|
-
f.getLocal(
|
|
1204
|
+
f.getLocal(q),
|
|
1183
1205
|
f.i64_const(32)
|
|
1184
1206
|
)
|
|
1185
1207
|
)
|
|
@@ -1189,7 +1211,7 @@ var Uc = function(t, n, e) {
|
|
|
1189
1211
|
f.i64_store32(
|
|
1190
1212
|
f.getLocal("r"),
|
|
1191
1213
|
s * 4 * 2 - 4,
|
|
1192
|
-
f.getLocal(
|
|
1214
|
+
f.getLocal(q)
|
|
1193
1215
|
)
|
|
1194
1216
|
);
|
|
1195
1217
|
}
|
|
@@ -1292,7 +1314,7 @@ var Uc = function(t, n, e) {
|
|
|
1292
1314
|
x(), ot();
|
|
1293
1315
|
const F = t.addFunction(i + "_div");
|
|
1294
1316
|
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"),
|
|
1317
|
+
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
1318
|
F.addCode(f.if(
|
|
1297
1319
|
f.getLocal("c"),
|
|
1298
1320
|
f.setLocal("cc", f.getLocal("c")),
|
|
@@ -1301,7 +1323,7 @@ var Uc = function(t, n, e) {
|
|
|
1301
1323
|
f.getLocal("r"),
|
|
1302
1324
|
f.setLocal("rr", f.getLocal("r")),
|
|
1303
1325
|
f.setLocal("rr", $)
|
|
1304
|
-
)), F.addCode(f.call(i + "_copy", f.getLocal("x"),
|
|
1326
|
+
)), 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
1327
|
f.br_if(
|
|
1306
1328
|
1,
|
|
1307
1329
|
f.i32_or(
|
|
@@ -1348,7 +1370,7 @@ var Uc = function(t, n, e) {
|
|
|
1348
1370
|
1,
|
|
1349
1371
|
f.i32_or(
|
|
1350
1372
|
f.i32_load8_u(
|
|
1351
|
-
f.i32_add(
|
|
1373
|
+
f.i32_add(q, f.getLocal("eX")),
|
|
1352
1374
|
0,
|
|
1353
1375
|
0
|
|
1354
1376
|
),
|
|
@@ -1365,7 +1387,7 @@ var Uc = function(t, n, e) {
|
|
|
1365
1387
|
"sx",
|
|
1366
1388
|
f.i64_load(
|
|
1367
1389
|
f.i32_sub(
|
|
1368
|
-
f.i32_add(
|
|
1390
|
+
f.i32_add(q, f.getLocal("eX")),
|
|
1369
1391
|
f.i32_const(7)
|
|
1370
1392
|
),
|
|
1371
1393
|
0,
|
|
@@ -1427,7 +1449,7 @@ var Uc = function(t, n, e) {
|
|
|
1427
1449
|
[
|
|
1428
1450
|
...f.br_if(
|
|
1429
1451
|
2,
|
|
1430
|
-
f.i32_eqz(f.call(i + "_gte",
|
|
1452
|
+
f.i32_eqz(f.call(i + "_gte", q, L))
|
|
1431
1453
|
),
|
|
1432
1454
|
...f.setLocal("sx", f.i64_const(1)),
|
|
1433
1455
|
...f.setLocal("ec", f.i32_const(0))
|
|
@@ -1436,9 +1458,9 @@ var Uc = function(t, n, e) {
|
|
|
1436
1458
|
f.call(i + "__mul1", L, f.getLocal("sx"), D),
|
|
1437
1459
|
f.drop(f.call(
|
|
1438
1460
|
i + "_sub",
|
|
1439
|
-
|
|
1461
|
+
q,
|
|
1440
1462
|
f.i32_sub(D, f.getLocal("ec")),
|
|
1441
|
-
|
|
1463
|
+
q
|
|
1442
1464
|
)),
|
|
1443
1465
|
f.call(
|
|
1444
1466
|
i + "__add1",
|
|
@@ -1451,7 +1473,7 @@ var Uc = function(t, n, e) {
|
|
|
1451
1473
|
function rt() {
|
|
1452
1474
|
const F = t.addFunction(i + "_inverseMod");
|
|
1453
1475
|
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)),
|
|
1476
|
+
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
1477
|
F.addCode(
|
|
1456
1478
|
f.setLocal("t", L),
|
|
1457
1479
|
f.call(i + "_zero", L),
|
|
@@ -1466,7 +1488,7 @@ var Uc = function(t, n, e) {
|
|
|
1466
1488
|
), F.addCode(
|
|
1467
1489
|
f.setLocal("newr", X),
|
|
1468
1490
|
f.call(i + "_copy", f.getLocal("px"), X)
|
|
1469
|
-
), F.addCode(f.setLocal("qq",
|
|
1491
|
+
), 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
1492
|
f.br_if(
|
|
1471
1493
|
1,
|
|
1472
1494
|
f.call(i + "_isZero", f.getLocal("newr"))
|
|
@@ -1863,7 +1885,7 @@ function Ji(o, t, n) {
|
|
|
1863
1885
|
function Nc(o, t) {
|
|
1864
1886
|
return o = o >= 0n ? o : -o, t = t >= 0n ? t : -t, o === t ? 0 : o > t ? 1 : -1;
|
|
1865
1887
|
}
|
|
1866
|
-
function
|
|
1888
|
+
function Mo(o, t) {
|
|
1867
1889
|
return t === 0n ? !1 : Tn(t) ? !0 : Nc(t, 2n) === 0 ? bo(o) : o % t === 0n;
|
|
1868
1890
|
}
|
|
1869
1891
|
function Gc(o) {
|
|
@@ -1872,7 +1894,7 @@ function Gc(o) {
|
|
|
1872
1894
|
return !1;
|
|
1873
1895
|
if (t === 2n || t === 3n || t === 5n)
|
|
1874
1896
|
return !0;
|
|
1875
|
-
if (bo(t) ||
|
|
1897
|
+
if (bo(t) || Mo(t, 3n) || Mo(t, 5n))
|
|
1876
1898
|
return !1;
|
|
1877
1899
|
if (t < 49n)
|
|
1878
1900
|
return !0;
|
|
@@ -1880,7 +1902,7 @@ function Gc(o) {
|
|
|
1880
1902
|
function Kc(o) {
|
|
1881
1903
|
return o - 1n;
|
|
1882
1904
|
}
|
|
1883
|
-
function
|
|
1905
|
+
function qo(o, t) {
|
|
1884
1906
|
for (var n = Kc(o), e = n, i = 0, s, d, r; bo(e); )
|
|
1885
1907
|
e = e / 2n, i++;
|
|
1886
1908
|
t:
|
|
@@ -1902,10 +1924,10 @@ function Hc(o) {
|
|
|
1902
1924
|
return t;
|
|
1903
1925
|
var n = te(o), e = Yi(n);
|
|
1904
1926
|
if (e <= 64)
|
|
1905
|
-
return
|
|
1927
|
+
return qo(n, [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]);
|
|
1906
1928
|
for (var i = Math.log(2) * Number(e), s = Math.ceil(i), d = [], r = 0; r < s; r++)
|
|
1907
1929
|
d.push(BigInt(r + 2));
|
|
1908
|
-
return
|
|
1930
|
+
return qo(n, d);
|
|
1909
1931
|
}
|
|
1910
1932
|
Yt.bitLength = Yi;
|
|
1911
1933
|
Yt.isOdd = $i;
|
|
@@ -2197,7 +2219,7 @@ var yo = function(t, n, e, i) {
|
|
|
2197
2219
|
)
|
|
2198
2220
|
);
|
|
2199
2221
|
}
|
|
2200
|
-
function
|
|
2222
|
+
function q() {
|
|
2201
2223
|
const I = t.addFunction(u + "_square");
|
|
2202
2224
|
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
2225
|
for (let dt = 0; dt < r; dt++)
|
|
@@ -2575,7 +2597,7 @@ var yo = function(t, n, e, i) {
|
|
|
2575
2597
|
h.ret(h.call(l + "_eq", h.getLocal("x"), h.i32_const(A)))
|
|
2576
2598
|
);
|
|
2577
2599
|
}
|
|
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(),
|
|
2600
|
+
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(), z(), 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
2601
|
t,
|
|
2580
2602
|
u + "_exp",
|
|
2581
2603
|
b,
|
|
@@ -2631,55 +2653,55 @@ var Xi = function(t, n, e, i) {
|
|
|
2631
2653
|
n64: t.modules[i].n64 * 2
|
|
2632
2654
|
};
|
|
2633
2655
|
function r() {
|
|
2634
|
-
const
|
|
2635
|
-
|
|
2636
|
-
const y =
|
|
2637
|
-
|
|
2656
|
+
const q = t.addFunction(e + "_add");
|
|
2657
|
+
q.addParam("x", "i32"), q.addParam("y", "i32"), q.addParam("r", "i32");
|
|
2658
|
+
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));
|
|
2659
|
+
q.addCode(
|
|
2638
2660
|
y.call(i + "_add", v, it, K),
|
|
2639
2661
|
y.call(i + "_add", D, nt, ct)
|
|
2640
2662
|
);
|
|
2641
2663
|
}
|
|
2642
2664
|
function b() {
|
|
2643
|
-
const
|
|
2644
|
-
|
|
2645
|
-
const y =
|
|
2646
|
-
|
|
2665
|
+
const q = t.addFunction(e + "_timesScalar");
|
|
2666
|
+
q.addParam("x", "i32"), q.addParam("scalar", "i32"), q.addParam("scalarLen", "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("r"), nt = y.i32_add(y.getLocal("r"), y.i32_const(s));
|
|
2668
|
+
q.addCode(
|
|
2647
2669
|
y.call(i + "_timesScalar", v, y.getLocal("scalar"), y.getLocal("scalarLen"), it),
|
|
2648
2670
|
y.call(i + "_timesScalar", D, y.getLocal("scalar"), y.getLocal("scalarLen"), nt)
|
|
2649
2671
|
);
|
|
2650
2672
|
}
|
|
2651
2673
|
function u() {
|
|
2652
|
-
const
|
|
2653
|
-
|
|
2654
|
-
const y =
|
|
2655
|
-
|
|
2674
|
+
const q = t.addFunction(e + "_sub");
|
|
2675
|
+
q.addParam("x", "i32"), q.addParam("y", "i32"), q.addParam("r", "i32");
|
|
2676
|
+
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));
|
|
2677
|
+
q.addCode(
|
|
2656
2678
|
y.call(i + "_sub", v, it, K),
|
|
2657
2679
|
y.call(i + "_sub", D, nt, ct)
|
|
2658
2680
|
);
|
|
2659
2681
|
}
|
|
2660
2682
|
function l() {
|
|
2661
|
-
const
|
|
2662
|
-
|
|
2663
|
-
const y =
|
|
2664
|
-
|
|
2683
|
+
const q = t.addFunction(e + "_neg");
|
|
2684
|
+
q.addParam("x", "i32"), q.addParam("r", "i32");
|
|
2685
|
+
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));
|
|
2686
|
+
q.addCode(
|
|
2665
2687
|
y.call(i + "_neg", v, it),
|
|
2666
2688
|
y.call(i + "_neg", D, nt)
|
|
2667
2689
|
);
|
|
2668
2690
|
}
|
|
2669
2691
|
function C() {
|
|
2670
|
-
const
|
|
2671
|
-
|
|
2672
|
-
const y =
|
|
2673
|
-
|
|
2692
|
+
const q = t.addFunction(e + "_conjugate");
|
|
2693
|
+
q.addParam("x", "i32"), q.addParam("r", "i32");
|
|
2694
|
+
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));
|
|
2695
|
+
q.addCode(
|
|
2674
2696
|
y.call(i + "_copy", v, it),
|
|
2675
2697
|
y.call(i + "_neg", D, nt)
|
|
2676
2698
|
);
|
|
2677
2699
|
}
|
|
2678
2700
|
function B() {
|
|
2679
|
-
const
|
|
2680
|
-
|
|
2681
|
-
const y =
|
|
2682
|
-
|
|
2701
|
+
const q = t.addFunction(e + "_isNegative");
|
|
2702
|
+
q.addParam("x", "i32"), q.setReturnType("i32");
|
|
2703
|
+
const y = q.getCodeBuilder(), v = y.getLocal("x"), D = y.i32_add(y.getLocal("x"), y.i32_const(s));
|
|
2704
|
+
q.addCode(
|
|
2683
2705
|
y.if(
|
|
2684
2706
|
y.call(i + "_isZero", D),
|
|
2685
2707
|
y.ret(y.call(i + "_isNegative", v))
|
|
@@ -2688,10 +2710,10 @@ var Xi = function(t, n, e, i) {
|
|
|
2688
2710
|
);
|
|
2689
2711
|
}
|
|
2690
2712
|
function A() {
|
|
2691
|
-
const
|
|
2692
|
-
|
|
2693
|
-
const y =
|
|
2694
|
-
|
|
2713
|
+
const q = t.addFunction(e + "_mul");
|
|
2714
|
+
q.addParam("x", "i32"), q.addParam("y", "i32"), q.addParam("r", "i32");
|
|
2715
|
+
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));
|
|
2716
|
+
q.addCode(
|
|
2695
2717
|
y.call(i + "_mul", v, it, J),
|
|
2696
2718
|
// A = x0*y0
|
|
2697
2719
|
y.call(i + "_mul", D, nt, st),
|
|
@@ -2714,10 +2736,10 @@ var Xi = function(t, n, e, i) {
|
|
|
2714
2736
|
);
|
|
2715
2737
|
}
|
|
2716
2738
|
function O() {
|
|
2717
|
-
const
|
|
2718
|
-
|
|
2719
|
-
const y =
|
|
2720
|
-
|
|
2739
|
+
const q = t.addFunction(e + "_mul1");
|
|
2740
|
+
q.addParam("x", "i32"), q.addParam("y", "i32"), q.addParam("r", "i32");
|
|
2741
|
+
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));
|
|
2742
|
+
q.addCode(
|
|
2721
2743
|
y.call(i + "_mul", v, it, nt),
|
|
2722
2744
|
// A = x0*y
|
|
2723
2745
|
y.call(i + "_mul", D, it, K)
|
|
@@ -2725,10 +2747,10 @@ var Xi = function(t, n, e, i) {
|
|
|
2725
2747
|
);
|
|
2726
2748
|
}
|
|
2727
2749
|
function P() {
|
|
2728
|
-
const
|
|
2729
|
-
|
|
2730
|
-
const y =
|
|
2731
|
-
|
|
2750
|
+
const q = t.addFunction(e + "_square");
|
|
2751
|
+
q.addParam("x", "i32"), q.addParam("r", "i32");
|
|
2752
|
+
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));
|
|
2753
|
+
q.addCode(
|
|
2732
2754
|
// AB = x0*y1
|
|
2733
2755
|
y.call(i + "_mul", v, D, K),
|
|
2734
2756
|
// APB = x0+y1
|
|
@@ -2747,55 +2769,55 @@ var Xi = function(t, n, e, i) {
|
|
|
2747
2769
|
);
|
|
2748
2770
|
}
|
|
2749
2771
|
function E() {
|
|
2750
|
-
const
|
|
2751
|
-
|
|
2752
|
-
const y =
|
|
2753
|
-
|
|
2772
|
+
const q = t.addFunction(e + "_toMontgomery");
|
|
2773
|
+
q.addParam("x", "i32"), q.addParam("r", "i32");
|
|
2774
|
+
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));
|
|
2775
|
+
q.addCode(
|
|
2754
2776
|
y.call(i + "_toMontgomery", v, it),
|
|
2755
2777
|
y.call(i + "_toMontgomery", D, nt)
|
|
2756
2778
|
);
|
|
2757
2779
|
}
|
|
2758
2780
|
function T() {
|
|
2759
|
-
const
|
|
2760
|
-
|
|
2761
|
-
const y =
|
|
2762
|
-
|
|
2781
|
+
const q = t.addFunction(e + "_fromMontgomery");
|
|
2782
|
+
q.addParam("x", "i32"), q.addParam("r", "i32");
|
|
2783
|
+
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));
|
|
2784
|
+
q.addCode(
|
|
2763
2785
|
y.call(i + "_fromMontgomery", v, it),
|
|
2764
2786
|
y.call(i + "_fromMontgomery", D, nt)
|
|
2765
2787
|
);
|
|
2766
2788
|
}
|
|
2767
2789
|
function x() {
|
|
2768
|
-
const
|
|
2769
|
-
|
|
2770
|
-
const y =
|
|
2771
|
-
|
|
2790
|
+
const q = t.addFunction(e + "_copy");
|
|
2791
|
+
q.addParam("x", "i32"), q.addParam("r", "i32");
|
|
2792
|
+
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));
|
|
2793
|
+
q.addCode(
|
|
2772
2794
|
y.call(i + "_copy", v, it),
|
|
2773
2795
|
y.call(i + "_copy", D, nt)
|
|
2774
2796
|
);
|
|
2775
2797
|
}
|
|
2776
2798
|
function ot() {
|
|
2777
|
-
const
|
|
2778
|
-
|
|
2779
|
-
const y =
|
|
2780
|
-
|
|
2799
|
+
const q = t.addFunction(e + "_zero");
|
|
2800
|
+
q.addParam("x", "i32");
|
|
2801
|
+
const y = q.getCodeBuilder(), v = y.getLocal("x"), D = y.i32_add(y.getLocal("x"), y.i32_const(s));
|
|
2802
|
+
q.addCode(
|
|
2781
2803
|
y.call(i + "_zero", v),
|
|
2782
2804
|
y.call(i + "_zero", D)
|
|
2783
2805
|
);
|
|
2784
2806
|
}
|
|
2785
2807
|
function z() {
|
|
2786
|
-
const
|
|
2787
|
-
|
|
2788
|
-
const y =
|
|
2789
|
-
|
|
2808
|
+
const q = t.addFunction(e + "_one");
|
|
2809
|
+
q.addParam("x", "i32");
|
|
2810
|
+
const y = q.getCodeBuilder(), v = y.getLocal("x"), D = y.i32_add(y.getLocal("x"), y.i32_const(s));
|
|
2811
|
+
q.addCode(
|
|
2790
2812
|
y.call(i + "_one", v),
|
|
2791
2813
|
y.call(i + "_zero", D)
|
|
2792
2814
|
);
|
|
2793
2815
|
}
|
|
2794
2816
|
function rt() {
|
|
2795
|
-
const
|
|
2796
|
-
|
|
2797
|
-
const y =
|
|
2798
|
-
|
|
2817
|
+
const q = t.addFunction(e + "_eq");
|
|
2818
|
+
q.addParam("x", "i32"), q.addParam("y", "i32"), q.setReturnType("i32");
|
|
2819
|
+
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));
|
|
2820
|
+
q.addCode(
|
|
2799
2821
|
y.i32_and(
|
|
2800
2822
|
y.call(i + "_eq", v, it),
|
|
2801
2823
|
y.call(i + "_eq", D, nt)
|
|
@@ -2803,10 +2825,10 @@ var Xi = function(t, n, e, i) {
|
|
|
2803
2825
|
);
|
|
2804
2826
|
}
|
|
2805
2827
|
function F() {
|
|
2806
|
-
const
|
|
2807
|
-
|
|
2808
|
-
const y =
|
|
2809
|
-
|
|
2828
|
+
const q = t.addFunction(e + "_isZero");
|
|
2829
|
+
q.addParam("x", "i32"), q.setReturnType("i32");
|
|
2830
|
+
const y = q.getCodeBuilder(), v = y.getLocal("x"), D = y.i32_add(y.getLocal("x"), y.i32_const(s));
|
|
2831
|
+
q.addCode(
|
|
2810
2832
|
y.i32_and(
|
|
2811
2833
|
y.call(i + "_isZero", v),
|
|
2812
2834
|
y.call(i + "_isZero", D)
|
|
@@ -2814,10 +2836,10 @@ var Xi = function(t, n, e, i) {
|
|
|
2814
2836
|
);
|
|
2815
2837
|
}
|
|
2816
2838
|
function f() {
|
|
2817
|
-
const
|
|
2818
|
-
|
|
2819
|
-
const y =
|
|
2820
|
-
|
|
2839
|
+
const q = t.addFunction(e + "_inverse");
|
|
2840
|
+
q.addParam("x", "i32"), q.addParam("r", "i32");
|
|
2841
|
+
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));
|
|
2842
|
+
q.addCode(
|
|
2821
2843
|
y.call(i + "_square", v, K),
|
|
2822
2844
|
y.call(i + "_square", D, ct),
|
|
2823
2845
|
// c.call(f1mPrefix+"_mul", t1, c.i32_const(pNonResidue), t2),
|
|
@@ -2830,10 +2852,10 @@ var Xi = function(t, n, e, i) {
|
|
|
2830
2852
|
);
|
|
2831
2853
|
}
|
|
2832
2854
|
function L() {
|
|
2833
|
-
const
|
|
2834
|
-
|
|
2835
|
-
const y =
|
|
2836
|
-
|
|
2855
|
+
const q = t.addFunction(e + "_sign");
|
|
2856
|
+
q.addParam("x", "i32"), q.addLocal("s", "i32"), q.setReturnType("i32");
|
|
2857
|
+
const y = q.getCodeBuilder(), v = y.getLocal("x"), D = y.i32_add(y.getLocal("x"), y.i32_const(s));
|
|
2858
|
+
q.addCode(
|
|
2837
2859
|
y.setLocal("s", y.call(i + "_sign", D)),
|
|
2838
2860
|
y.if(
|
|
2839
2861
|
y.getLocal("s"),
|
|
@@ -2843,10 +2865,10 @@ var Xi = function(t, n, e, i) {
|
|
|
2843
2865
|
);
|
|
2844
2866
|
}
|
|
2845
2867
|
function V() {
|
|
2846
|
-
const
|
|
2847
|
-
|
|
2848
|
-
const y =
|
|
2849
|
-
|
|
2868
|
+
const q = t.addFunction(e + "_isOne");
|
|
2869
|
+
q.addParam("x", "i32"), q.setReturnType("i32");
|
|
2870
|
+
const y = q.getCodeBuilder(), v = y.getLocal("x"), D = y.i32_add(y.getLocal("x"), y.i32_const(s));
|
|
2871
|
+
q.addCode(
|
|
2850
2872
|
y.ret(y.i32_and(
|
|
2851
2873
|
y.call(i + "_isOne", v),
|
|
2852
2874
|
y.call(i + "_isZero", D)
|
|
@@ -2854,10 +2876,10 @@ var Xi = function(t, n, e, i) {
|
|
|
2854
2876
|
);
|
|
2855
2877
|
}
|
|
2856
2878
|
function $() {
|
|
2857
|
-
const
|
|
2858
|
-
|
|
2859
|
-
const y =
|
|
2860
|
-
|
|
2879
|
+
const q = t.addFunction(e + "_sqrt");
|
|
2880
|
+
q.addParam("a", "i32"), q.addParam("pr", "i32");
|
|
2881
|
+
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));
|
|
2882
|
+
q.addCode(
|
|
2861
2883
|
y.call(e + "_one", st),
|
|
2862
2884
|
y.call(e + "_neg", st, st),
|
|
2863
2885
|
// const a1 = F.pow(a, F.sqrt_e34);
|
|
@@ -2893,10 +2915,10 @@ var Xi = function(t, n, e, i) {
|
|
|
2893
2915
|
);
|
|
2894
2916
|
}
|
|
2895
2917
|
function X() {
|
|
2896
|
-
const
|
|
2897
|
-
|
|
2898
|
-
const y =
|
|
2899
|
-
|
|
2918
|
+
const q = t.addFunction(e + "_isSquare");
|
|
2919
|
+
q.addParam("a", "i32"), q.setReturnType("i32");
|
|
2920
|
+
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);
|
|
2921
|
+
q.addCode(
|
|
2900
2922
|
y.call(e + "_one", J),
|
|
2901
2923
|
y.call(e + "_neg", J, J),
|
|
2902
2924
|
// const a1 = F.pow(a, F.sqrt_e34);
|
|
@@ -2940,9 +2962,9 @@ var ta = function(t, n, e, i) {
|
|
|
2940
2962
|
function d() {
|
|
2941
2963
|
const f = t.addFunction(e + "_add");
|
|
2942
2964
|
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)),
|
|
2965
|
+
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
2966
|
f.addCode(
|
|
2945
|
-
L.call(i + "_add", V,
|
|
2967
|
+
L.call(i + "_add", V, q, D),
|
|
2946
2968
|
L.call(i + "_add", $, y, it),
|
|
2947
2969
|
L.call(i + "_add", X, v, nt)
|
|
2948
2970
|
);
|
|
@@ -2950,9 +2972,9 @@ var ta = function(t, n, e, i) {
|
|
|
2950
2972
|
function r() {
|
|
2951
2973
|
const f = t.addFunction(e + "_timesScalar");
|
|
2952
2974
|
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)),
|
|
2975
|
+
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
2976
|
f.addCode(
|
|
2955
|
-
L.call(i + "_timesScalar", V, L.getLocal("scalar"), L.getLocal("scalarLen"),
|
|
2977
|
+
L.call(i + "_timesScalar", V, L.getLocal("scalar"), L.getLocal("scalarLen"), q),
|
|
2956
2978
|
L.call(i + "_timesScalar", $, L.getLocal("scalar"), L.getLocal("scalarLen"), y),
|
|
2957
2979
|
L.call(i + "_timesScalar", X, L.getLocal("scalar"), L.getLocal("scalarLen"), v)
|
|
2958
2980
|
);
|
|
@@ -2960,9 +2982,9 @@ var ta = function(t, n, e, i) {
|
|
|
2960
2982
|
function b() {
|
|
2961
2983
|
const f = t.addFunction(e + "_sub");
|
|
2962
2984
|
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)),
|
|
2985
|
+
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
2986
|
f.addCode(
|
|
2965
|
-
L.call(i + "_sub", V,
|
|
2987
|
+
L.call(i + "_sub", V, q, D),
|
|
2966
2988
|
L.call(i + "_sub", $, y, it),
|
|
2967
2989
|
L.call(i + "_sub", X, v, nt)
|
|
2968
2990
|
);
|
|
@@ -2970,9 +2992,9 @@ var ta = function(t, n, e, i) {
|
|
|
2970
2992
|
function u() {
|
|
2971
2993
|
const f = t.addFunction(e + "_neg");
|
|
2972
2994
|
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)),
|
|
2995
|
+
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
2996
|
f.addCode(
|
|
2975
|
-
L.call(i + "_neg", V,
|
|
2997
|
+
L.call(i + "_neg", V, q),
|
|
2976
2998
|
L.call(i + "_neg", $, y),
|
|
2977
2999
|
L.call(i + "_neg", X, v)
|
|
2978
3000
|
);
|
|
@@ -2996,15 +3018,15 @@ var ta = function(t, n, e, i) {
|
|
|
2996
3018
|
function C() {
|
|
2997
3019
|
const f = t.addFunction(e + "_mul");
|
|
2998
3020
|
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)),
|
|
3021
|
+
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
3022
|
f.addCode(
|
|
3001
|
-
L.call(i + "_mul", V,
|
|
3023
|
+
L.call(i + "_mul", V, q, K),
|
|
3002
3024
|
L.call(i + "_mul", $, y, ct),
|
|
3003
3025
|
L.call(i + "_mul", X, v, J),
|
|
3004
3026
|
L.call(i + "_add", V, $, st),
|
|
3005
|
-
L.call(i + "_add",
|
|
3027
|
+
L.call(i + "_add", q, y, At),
|
|
3006
3028
|
L.call(i + "_add", V, X, Bt),
|
|
3007
|
-
L.call(i + "_add",
|
|
3029
|
+
L.call(i + "_add", q, v, pt),
|
|
3008
3030
|
L.call(i + "_add", $, X, p),
|
|
3009
3031
|
L.call(i + "_add", y, v, a),
|
|
3010
3032
|
L.call(i + "_add", K, ct, m),
|
|
@@ -3026,7 +3048,7 @@ var ta = function(t, n, e, i) {
|
|
|
3026
3048
|
function B() {
|
|
3027
3049
|
const f = t.addFunction(e + "_square");
|
|
3028
3050
|
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)),
|
|
3051
|
+
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
3052
|
f.addCode(
|
|
3031
3053
|
L.call(i + "_square", V, D),
|
|
3032
3054
|
L.call(i + "_mul", V, $, it),
|
|
@@ -3037,8 +3059,8 @@ var ta = function(t, n, e, i) {
|
|
|
3037
3059
|
L.call(i + "_mul", $, X, ct),
|
|
3038
3060
|
L.call(i + "_add", ct, ct, J),
|
|
3039
3061
|
L.call(i + "_square", X, st),
|
|
3040
|
-
L.call(n, J,
|
|
3041
|
-
L.call(i + "_add", D,
|
|
3062
|
+
L.call(n, J, q),
|
|
3063
|
+
L.call(i + "_add", D, q, q),
|
|
3042
3064
|
L.call(n, st, y),
|
|
3043
3065
|
L.call(i + "_add", nt, y, y),
|
|
3044
3066
|
L.call(i + "_add", D, st, v),
|
|
@@ -3050,9 +3072,9 @@ var ta = function(t, n, e, i) {
|
|
|
3050
3072
|
function A() {
|
|
3051
3073
|
const f = t.addFunction(e + "_toMontgomery");
|
|
3052
3074
|
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)),
|
|
3075
|
+
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
3076
|
f.addCode(
|
|
3055
|
-
L.call(i + "_toMontgomery", V,
|
|
3077
|
+
L.call(i + "_toMontgomery", V, q),
|
|
3056
3078
|
L.call(i + "_toMontgomery", $, y),
|
|
3057
3079
|
L.call(i + "_toMontgomery", X, v)
|
|
3058
3080
|
);
|
|
@@ -3060,9 +3082,9 @@ var ta = function(t, n, e, i) {
|
|
|
3060
3082
|
function O() {
|
|
3061
3083
|
const f = t.addFunction(e + "_fromMontgomery");
|
|
3062
3084
|
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)),
|
|
3085
|
+
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
3086
|
f.addCode(
|
|
3065
|
-
L.call(i + "_fromMontgomery", V,
|
|
3087
|
+
L.call(i + "_fromMontgomery", V, q),
|
|
3066
3088
|
L.call(i + "_fromMontgomery", $, y),
|
|
3067
3089
|
L.call(i + "_fromMontgomery", X, v)
|
|
3068
3090
|
);
|
|
@@ -3070,9 +3092,9 @@ var ta = function(t, n, e, i) {
|
|
|
3070
3092
|
function P() {
|
|
3071
3093
|
const f = t.addFunction(e + "_copy");
|
|
3072
3094
|
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)),
|
|
3095
|
+
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
3096
|
f.addCode(
|
|
3075
|
-
L.call(i + "_copy", V,
|
|
3097
|
+
L.call(i + "_copy", V, q),
|
|
3076
3098
|
L.call(i + "_copy", $, y),
|
|
3077
3099
|
L.call(i + "_copy", X, v)
|
|
3078
3100
|
);
|
|
@@ -3100,11 +3122,11 @@ var ta = function(t, n, e, i) {
|
|
|
3100
3122
|
function x() {
|
|
3101
3123
|
const f = t.addFunction(e + "_eq");
|
|
3102
3124
|
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)),
|
|
3125
|
+
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
3126
|
f.addCode(
|
|
3105
3127
|
L.i32_and(
|
|
3106
3128
|
L.i32_and(
|
|
3107
|
-
L.call(i + "_eq", V,
|
|
3129
|
+
L.call(i + "_eq", V, q),
|
|
3108
3130
|
L.call(i + "_eq", $, y)
|
|
3109
3131
|
),
|
|
3110
3132
|
L.call(i + "_eq", X, v)
|
|
@@ -3128,7 +3150,7 @@ var ta = function(t, n, e, i) {
|
|
|
3128
3150
|
function z() {
|
|
3129
3151
|
const f = t.addFunction(e + "_inverse");
|
|
3130
3152
|
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)),
|
|
3153
|
+
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
3154
|
f.addCode(
|
|
3133
3155
|
L.call(i + "_square", V, D),
|
|
3134
3156
|
L.call(i + "_square", $, it),
|
|
@@ -3148,7 +3170,7 @@ var ta = function(t, n, e, i) {
|
|
|
3148
3170
|
L.call(i + "_mul", V, st, p),
|
|
3149
3171
|
L.call(i + "_add", p, pt, pt),
|
|
3150
3172
|
L.call(i + "_inverse", pt, pt),
|
|
3151
|
-
L.call(i + "_mul", pt, st,
|
|
3173
|
+
L.call(i + "_mul", pt, st, q),
|
|
3152
3174
|
L.call(i + "_mul", pt, At, y),
|
|
3153
3175
|
L.call(i + "_mul", pt, Bt, v)
|
|
3154
3176
|
);
|
|
@@ -4348,7 +4370,7 @@ var na = function(t, n, e, i) {
|
|
|
4348
4370
|
a.call(n + "_add", a.getLocal("p1"), m, a.getLocal("pr"))
|
|
4349
4371
|
);
|
|
4350
4372
|
}
|
|
4351
|
-
function
|
|
4373
|
+
function q() {
|
|
4352
4374
|
const p = t.addFunction(n + "_subMixed");
|
|
4353
4375
|
p.addParam("p1", "i32"), p.addParam("p2", "i32"), p.addParam("pr", "i32");
|
|
4354
4376
|
const a = p.getCodeBuilder(), m = a.i32_const(t.alloc(d * 3));
|
|
@@ -4666,7 +4688,7 @@ var na = function(t, n, e, i) {
|
|
|
4666
4688
|
)
|
|
4667
4689
|
);
|
|
4668
4690
|
}
|
|
4669
|
-
return b(), r(), B(), C(), l(), u(), it(), T(), O(), A(), E(), P(), L(), f(), F(), $(), V(), y(),
|
|
4691
|
+
return b(), r(), B(), C(), l(), u(), it(), T(), O(), A(), E(), P(), L(), f(), F(), $(), V(), y(), q(), X(), rt(), z(), 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), zo(t, n, n + "_multiexp", n + "_add", d * 3), zo(t, n, n + "_multiexpAffine", n + "_addMixed", d * 2), To(
|
|
4670
4692
|
t,
|
|
4671
4693
|
n + "_timesScalar",
|
|
4672
4694
|
d * 3,
|
|
@@ -4726,10 +4748,10 @@ var ea = function(t, n, e, i, s) {
|
|
|
4726
4748
|
m & 1 << w && (c = c | 128 >> w);
|
|
4727
4749
|
return c;
|
|
4728
4750
|
}
|
|
4729
|
-
const
|
|
4751
|
+
const q = Array(256);
|
|
4730
4752
|
for (let m = 0; m < 256; m++)
|
|
4731
|
-
|
|
4732
|
-
const y = t.alloc(
|
|
4753
|
+
q[m] = X(m);
|
|
4754
|
+
const y = t.alloc(q);
|
|
4733
4755
|
function v() {
|
|
4734
4756
|
const m = t.addFunction(n + "__log2");
|
|
4735
4757
|
m.addParam("n", "i32"), m.setReturnType("i32"), m.addLocal("bits", "i32"), m.addLocal("aux", "i32");
|
|
@@ -6196,7 +6218,7 @@ var hs = function(t, n) {
|
|
|
6196
6218
|
0n,
|
|
6197
6219
|
0n
|
|
6198
6220
|
]
|
|
6199
|
-
],
|
|
6221
|
+
], q = t.alloc(
|
|
6200
6222
|
[
|
|
6201
6223
|
...xt.bigInt2BytesLE(z(X[0][0]), u),
|
|
6202
6224
|
...xt.bigInt2BytesLE(z(X[0][1]), u),
|
|
@@ -6274,7 +6296,7 @@ var hs = function(t, n) {
|
|
|
6274
6296
|
pG1zero: L,
|
|
6275
6297
|
pG1b: O,
|
|
6276
6298
|
pG2gen: $,
|
|
6277
|
-
pG2zero:
|
|
6299
|
+
pG2zero: q,
|
|
6278
6300
|
pG2b: T,
|
|
6279
6301
|
pq: t.modules.f1m.pq,
|
|
6280
6302
|
pr: B,
|
|
@@ -6317,14 +6339,14 @@ var hs = function(t, n) {
|
|
|
6317
6339
|
function at() {
|
|
6318
6340
|
const G = t.addFunction(e + "_prepAddStep");
|
|
6319
6341
|
G.addParam("pQ", "i32"), G.addParam("pR", "i32"), G.addParam("pCoef", "i32");
|
|
6320
|
-
const _ = G.getCodeBuilder(), g = _.getLocal("pQ"), Q = _.i32_add(_.getLocal("pQ"), _.i32_const(l)), R = _.getLocal("pR"),
|
|
6342
|
+
const _ = G.getCodeBuilder(), g = _.getLocal("pQ"), Q = _.i32_add(_.getLocal("pQ"), _.i32_const(l)), R = _.getLocal("pR"), M = _.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
6343
|
G.addCode(
|
|
6322
6344
|
// D = X1 - X2*Z1
|
|
6323
6345
|
_.call(E + "_mul", g, k, Z),
|
|
6324
6346
|
_.call(E + "_sub", R, Z, Z),
|
|
6325
6347
|
// E = Y1 - Y2*Z1
|
|
6326
6348
|
_.call(E + "_mul", Q, k, H),
|
|
6327
|
-
_.call(E + "_sub",
|
|
6349
|
+
_.call(E + "_sub", M, H, H),
|
|
6328
6350
|
// F = D^2
|
|
6329
6351
|
_.call(E + "_square", Z, et),
|
|
6330
6352
|
// G = E^2
|
|
@@ -6341,10 +6363,10 @@ var hs = function(t, n) {
|
|
|
6341
6363
|
// X3 (X1) = D*J
|
|
6342
6364
|
_.call(E + "_mul", Z, bt, R),
|
|
6343
6365
|
// Y3 (Y1) = E*(I-J)-(H*Y1)
|
|
6344
|
-
_.call(E + "_mul", _t,
|
|
6366
|
+
_.call(E + "_mul", _t, M, M),
|
|
6345
6367
|
_.call(E + "_sub", lt, bt, mt),
|
|
6346
6368
|
_.call(E + "_mul", H, mt, mt),
|
|
6347
|
-
_.call(E + "_sub", mt,
|
|
6369
|
+
_.call(E + "_sub", mt, M, M),
|
|
6348
6370
|
// Z3 (Z1) = Z1*H
|
|
6349
6371
|
_.call(E + "_mul", k, _t, k),
|
|
6350
6372
|
// ell_0 = xi * (E * X2 - D * Y2)
|
|
@@ -6361,7 +6383,7 @@ var hs = function(t, n) {
|
|
|
6361
6383
|
function It() {
|
|
6362
6384
|
const G = t.addFunction(e + "_prepDblStep");
|
|
6363
6385
|
G.addParam("pR", "i32"), G.addParam("pCoef", "i32");
|
|
6364
|
-
const _ = G.getCodeBuilder(), g = _.getLocal("pR"), Q = _.i32_add(_.getLocal("pR"), _.i32_const(l)), R = _.i32_add(_.getLocal("pR"), _.i32_const(2 * l)),
|
|
6386
|
+
const _ = G.getCodeBuilder(), g = _.getLocal("pR"), Q = _.i32_add(_.getLocal("pR"), _.i32_const(l)), R = _.i32_add(_.getLocal("pR"), _.i32_const(2 * l)), M = _.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
6387
|
G.addCode(
|
|
6366
6388
|
// A = X1 * Y1 / 2
|
|
6367
6389
|
_.call(E + "_mul", Q, _.i32_const(D), j),
|
|
@@ -6403,7 +6425,7 @@ var hs = function(t, n) {
|
|
|
6403
6425
|
// Z3 (Z1) = B * H
|
|
6404
6426
|
_.call(E + "_mul", Y, lt, R),
|
|
6405
6427
|
// ell_0 = xi * I
|
|
6406
|
-
_.call(E + "_mul", _.i32_const(it), bt,
|
|
6428
|
+
_.call(E + "_mul", _.i32_const(it), bt, M),
|
|
6407
6429
|
// ell_VW = - H (later: * yP)
|
|
6408
6430
|
_.call(E + "_neg", lt, k),
|
|
6409
6431
|
// ell_VV = 3*J (later: * xP)
|
|
@@ -6414,7 +6436,7 @@ var hs = function(t, n) {
|
|
|
6414
6436
|
function ut() {
|
|
6415
6437
|
const G = t.addFunction(e + "_mulByQ");
|
|
6416
6438
|
G.addParam("p1", "i32"), G.addParam("pr", "i32");
|
|
6417
|
-
const _ = G.getCodeBuilder(), g = _.getLocal("p1"), Q = _.i32_add(_.getLocal("p1"), _.i32_const(l)), R = _.i32_add(_.getLocal("p1"), _.i32_const(l * 2)),
|
|
6439
|
+
const _ = G.getCodeBuilder(), g = _.getLocal("p1"), Q = _.i32_add(_.getLocal("p1"), _.i32_const(l)), R = _.i32_add(_.getLocal("p1"), _.i32_const(l * 2)), M = _.getLocal("pr"), k = _.i32_add(_.getLocal("pr"), _.i32_const(l)), U = _.i32_add(_.getLocal("pr"), _.i32_const(l * 2)), j = _.i32_const(t.alloc([
|
|
6418
6440
|
...xt.bigInt2BytesLE(z("21575463638280843010398324269430826099269044274347216827212613867836435027261"), u),
|
|
6419
6441
|
...xt.bigInt2BytesLE(z("10307601595873709700152284273816112264069230130616436755625194854815875713954"), u)
|
|
6420
6442
|
])), Y = _.i32_const(t.alloc([
|
|
@@ -6423,8 +6445,8 @@ var hs = function(t, n) {
|
|
|
6423
6445
|
]));
|
|
6424
6446
|
G.addCode(
|
|
6425
6447
|
// The frobeniusMap(1) in this field, is the conjugate
|
|
6426
|
-
_.call(E + "_conjugate", g,
|
|
6427
|
-
_.call(E + "_mul", j,
|
|
6448
|
+
_.call(E + "_conjugate", g, M),
|
|
6449
|
+
_.call(E + "_mul", j, M, M),
|
|
6428
6450
|
_.call(E + "_conjugate", Q, k),
|
|
6429
6451
|
_.call(E + "_mul", Y, k, k),
|
|
6430
6452
|
_.call(E + "_conjugate", R, U)
|
|
@@ -6434,11 +6456,11 @@ var hs = function(t, n) {
|
|
|
6434
6456
|
ut();
|
|
6435
6457
|
const G = t.addFunction(e + "_prepareG2");
|
|
6436
6458
|
G.addParam("pQ", "i32"), G.addParam("ppreQ", "i32"), G.addLocal("pCoef", "i32"), G.addLocal("i", "i32");
|
|
6437
|
-
const _ = G.getCodeBuilder(), g = _.getLocal("pQ"), Q = t.alloc(l * 3), R = _.i32_const(Q),
|
|
6459
|
+
const _ = G.getCodeBuilder(), g = _.getLocal("pQ"), Q = t.alloc(l * 3), R = _.i32_const(Q), M = _.i32_const(Q), k = _.i32_const(Q + l), U = _.i32_const(Q + 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
6460
|
G.addCode(
|
|
6439
6461
|
_.call(x + "_normalize", g, j),
|
|
6440
6462
|
// TODO Remove if already in affine
|
|
6441
|
-
_.call(E + "_copy", j,
|
|
6463
|
+
_.call(E + "_copy", j, M),
|
|
6442
6464
|
_.call(E + "_copy", Y, k),
|
|
6443
6465
|
_.call(E + "_one", U)
|
|
6444
6466
|
), G.addCode(
|
|
@@ -6472,7 +6494,7 @@ var hs = function(t, n) {
|
|
|
6472
6494
|
function St() {
|
|
6473
6495
|
const G = t.addFunction(e + "__mulBy024Old");
|
|
6474
6496
|
G.addParam("pEll0", "i32"), G.addParam("pEllVW", "i32"), G.addParam("pEllVV", "i32"), G.addParam("pR", "i32");
|
|
6475
|
-
const _ = G.getCodeBuilder(), g = _.getLocal("pEll0"), Q = _.getLocal("pEllVV"), R = _.getLocal("pEllVW"),
|
|
6497
|
+
const _ = G.getCodeBuilder(), g = _.getLocal("pEll0"), Q = _.getLocal("pEllVV"), R = _.getLocal("pEllVW"), M = _.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
6498
|
G.addCode(
|
|
6477
6499
|
_.call(E + "_copy", g, j),
|
|
6478
6500
|
_.call(E + "_zero", Y),
|
|
@@ -6480,24 +6502,24 @@ var hs = function(t, n) {
|
|
|
6480
6502
|
_.call(E + "_zero", H),
|
|
6481
6503
|
_.call(E + "_copy", R, et),
|
|
6482
6504
|
_.call(E + "_zero", ft),
|
|
6483
|
-
_.call(st + "_mul", U,
|
|
6505
|
+
_.call(st + "_mul", U, M, M)
|
|
6484
6506
|
);
|
|
6485
6507
|
}
|
|
6486
6508
|
function gt() {
|
|
6487
6509
|
const G = t.addFunction(e + "__mulBy024");
|
|
6488
6510
|
G.addParam("pEll0", "i32"), G.addParam("pEllVW", "i32"), G.addParam("pEllVV", "i32"), G.addParam("pR", "i32");
|
|
6489
|
-
const _ = G.getCodeBuilder(), g = _.getLocal("pEll0"), Q = _.getLocal("pEllVV"), R = _.getLocal("pEllVW"),
|
|
6511
|
+
const _ = G.getCodeBuilder(), g = _.getLocal("pEll0"), Q = _.getLocal("pEllVV"), R = _.getLocal("pEllVW"), M = _.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
6512
|
G.addCode(
|
|
6491
6513
|
// D0 = z0 * x0;
|
|
6492
|
-
_.call(E + "_mul",
|
|
6514
|
+
_.call(E + "_mul", M, g, mt),
|
|
6493
6515
|
// D2 = z2 * x2;
|
|
6494
6516
|
_.call(E + "_mul", U, Q, Ot),
|
|
6495
6517
|
// D4 = z4 * x4;
|
|
6496
6518
|
_.call(E + "_mul", Y, R, Ct),
|
|
6497
6519
|
// t2 = z0 + z4;
|
|
6498
|
-
_.call(E + "_add",
|
|
6520
|
+
_.call(E + "_add", M, Y, ft),
|
|
6499
6521
|
// t1 = z0 + z2;
|
|
6500
|
-
_.call(E + "_add",
|
|
6522
|
+
_.call(E + "_add", M, U, et),
|
|
6501
6523
|
// s0 = z1 + z3 + z5;
|
|
6502
6524
|
_.call(E + "_add", k, j, _t),
|
|
6503
6525
|
_.call(E + "_add", _t, Z, _t),
|
|
@@ -6508,7 +6530,7 @@ var hs = function(t, n) {
|
|
|
6508
6530
|
_.call(E + "_add", wt, Ct, lt),
|
|
6509
6531
|
// T4 = my_Fp6::non_residue * T3 + D0;
|
|
6510
6532
|
_.call(E + "_mul", _.i32_const(v), lt, bt),
|
|
6511
|
-
_.call(E + "_add", bt, mt,
|
|
6533
|
+
_.call(E + "_add", bt, mt, M),
|
|
6512
6534
|
// z0 = T4;
|
|
6513
6535
|
// For z.a_.b_ = z1
|
|
6514
6536
|
// T3 = z5 * x4;
|
|
@@ -6587,21 +6609,21 @@ var hs = function(t, n) {
|
|
|
6587
6609
|
function dt() {
|
|
6588
6610
|
const G = t.addFunction(e + "_millerLoop");
|
|
6589
6611
|
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"), Q = _.i32_add(_.getLocal("ppreP"), _.i32_const(u)), R = _.getLocal("pCoef"),
|
|
6612
|
+
const _ = G.getCodeBuilder(), g = _.getLocal("ppreP"), Q = _.i32_add(_.getLocal("ppreP"), _.i32_const(u)), R = _.getLocal("pCoef"), M = _.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
6613
|
G.addCode(
|
|
6592
6614
|
_.call(st + "_one", H),
|
|
6593
6615
|
_.setLocal("pCoef", _.i32_add(_.getLocal("ppreQ"), _.i32_const(l * 3))),
|
|
6594
6616
|
_.setLocal("i", _.i32_const(Bt.length - 2)),
|
|
6595
6617
|
_.block(_.loop(
|
|
6596
6618
|
_.call(st + "_square", H, H),
|
|
6597
|
-
_.call(E + "_mul1",
|
|
6619
|
+
_.call(E + "_mul1", M, Q, j),
|
|
6598
6620
|
_.call(E + "_mul1", k, g, Z),
|
|
6599
6621
|
_.call(e + "__mulBy024", R, j, Z, H),
|
|
6600
6622
|
_.setLocal("pCoef", _.i32_add(_.getLocal("pCoef"), _.i32_const(p))),
|
|
6601
6623
|
_.if(
|
|
6602
6624
|
_.i32_load8_s(_.getLocal("i"), pt),
|
|
6603
6625
|
[
|
|
6604
|
-
..._.call(E + "_mul1",
|
|
6626
|
+
..._.call(E + "_mul1", M, Q, j),
|
|
6605
6627
|
..._.call(E + "_mul1", k, g, Z),
|
|
6606
6628
|
..._.call(e + "__mulBy024", R, j, Z, H),
|
|
6607
6629
|
..._.setLocal("pCoef", _.i32_add(_.getLocal("pCoef"), _.i32_const(p)))
|
|
@@ -6612,11 +6634,11 @@ var hs = function(t, n) {
|
|
|
6612
6634
|
_.br(0)
|
|
6613
6635
|
))
|
|
6614
6636
|
), G.addCode(
|
|
6615
|
-
_.call(E + "_mul1",
|
|
6637
|
+
_.call(E + "_mul1", M, Q, j),
|
|
6616
6638
|
_.call(E + "_mul1", k, g, Z),
|
|
6617
6639
|
_.call(e + "__mulBy024", R, j, Z, H),
|
|
6618
6640
|
_.setLocal("pCoef", _.i32_add(_.getLocal("pCoef"), _.i32_const(p))),
|
|
6619
|
-
_.call(E + "_mul1",
|
|
6641
|
+
_.call(E + "_mul1", M, Q, j),
|
|
6620
6642
|
_.call(E + "_mul1", k, g, Z),
|
|
6621
6643
|
_.call(e + "__mulBy024", R, j, Z, H),
|
|
6622
6644
|
_.setLocal("pCoef", _.i32_add(_.getLocal("pCoef"), _.i32_const(p)))
|
|
@@ -6681,7 +6703,7 @@ var hs = function(t, n) {
|
|
|
6681
6703
|
Q.addParam("x", "i32"), Q.addParam("r", "i32");
|
|
6682
6704
|
const R = Q.getCodeBuilder();
|
|
6683
6705
|
for (let k = 0; k < 6; k++) {
|
|
6684
|
-
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 =
|
|
6706
|
+
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 = M(_[Math.floor(k / 3)][G % 12], g[k % 3][G % 6]), _t = t.alloc([
|
|
6685
6707
|
...xt.bigInt2BytesLE(z(ft[0]), 32),
|
|
6686
6708
|
...xt.bigInt2BytesLE(z(ft[1]), 32)
|
|
6687
6709
|
]);
|
|
@@ -6691,7 +6713,7 @@ var hs = function(t, n) {
|
|
|
6691
6713
|
R.call(E + "_mul", Z, R.i32_const(_t), Z)
|
|
6692
6714
|
) : Q.addCode(R.call(E + "_mul", U, R.i32_const(_t), Z));
|
|
6693
6715
|
}
|
|
6694
|
-
function
|
|
6716
|
+
function M(k, U) {
|
|
6695
6717
|
const j = BigInt(k[0]), Y = BigInt(k[1]), Z = BigInt(U[0]), H = BigInt(U[1]), et = [
|
|
6696
6718
|
(j * Z - Y * H) % i,
|
|
6697
6719
|
(j * H + Y * Z) % i
|
|
@@ -6702,7 +6724,7 @@ var hs = function(t, n) {
|
|
|
6702
6724
|
function vt() {
|
|
6703
6725
|
const G = t.addFunction(e + "__finalExponentiationFirstChunk");
|
|
6704
6726
|
G.addParam("x", "i32"), G.addParam("r", "i32");
|
|
6705
|
-
const _ = G.getCodeBuilder(), g = _.getLocal("x"), Q = g, R = _.i32_add(g, _.i32_const(r * 6)),
|
|
6727
|
+
const _ = G.getCodeBuilder(), g = _.getLocal("x"), Q = g, R = _.i32_add(g, _.i32_const(r * 6)), M = _.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
6728
|
G.addCode(
|
|
6707
6729
|
// const alt_bn128_Fq12 A = alt_bn128_Fq12(elt.c0,-elt.c1);
|
|
6708
6730
|
_.call(ct + "_copy", Q, j),
|
|
@@ -6714,13 +6736,13 @@ var hs = function(t, n) {
|
|
|
6714
6736
|
// const alt_bn128_Fq12 D = C.Frobenius_map(2);
|
|
6715
6737
|
_.call(e + "__frobeniusMap2", H, et),
|
|
6716
6738
|
// const alt_bn128_Fq12 result = D * C;
|
|
6717
|
-
_.call(st + "_mul", H, et,
|
|
6739
|
+
_.call(st + "_mul", H, et, M)
|
|
6718
6740
|
);
|
|
6719
6741
|
}
|
|
6720
6742
|
function Ut() {
|
|
6721
6743
|
const G = t.addFunction(e + "__cyclotomicSquare");
|
|
6722
6744
|
G.addParam("x", "i32"), G.addParam("r", "i32");
|
|
6723
|
-
const _ = G.getCodeBuilder(), g = _.getLocal("x"), Q = _.i32_add(_.getLocal("x"), _.i32_const(l)), R = _.i32_add(_.getLocal("x"), _.i32_const(2 * l)),
|
|
6745
|
+
const _ = G.getCodeBuilder(), g = _.getLocal("x"), Q = _.i32_add(_.getLocal("x"), _.i32_const(l)), R = _.i32_add(_.getLocal("x"), _.i32_const(2 * l)), M = _.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
6746
|
G.addCode(
|
|
6725
6747
|
// // t0 + t1*y = (z0 + z1*y)^2 = a^2
|
|
6726
6748
|
// tmp = z0 * z1;
|
|
@@ -6739,10 +6761,10 @@ var hs = function(t, n) {
|
|
|
6739
6761
|
// tmp = z2 * z3;
|
|
6740
6762
|
// t2 = (z2 + z3) * (z2 + my_Fp6::non_residue * z3) - tmp - my_Fp6::non_residue * tmp;
|
|
6741
6763
|
// t3 = tmp + tmp;
|
|
6742
|
-
_.call(E + "_mul",
|
|
6764
|
+
_.call(E + "_mul", M, R, wt),
|
|
6743
6765
|
_.call(E + "_mul", R, _.i32_const(v), bt),
|
|
6744
|
-
_.call(E + "_add",
|
|
6745
|
-
_.call(E + "_add",
|
|
6766
|
+
_.call(E + "_add", M, bt, bt),
|
|
6767
|
+
_.call(E + "_add", M, R, ht),
|
|
6746
6768
|
_.call(E + "_mul", ht, bt, bt),
|
|
6747
6769
|
_.call(E + "_mul", _.i32_const(v), wt, ht),
|
|
6748
6770
|
_.call(E + "_add", wt, ht, ht),
|
|
@@ -6773,7 +6795,7 @@ var hs = function(t, n) {
|
|
|
6773
6795
|
// For B
|
|
6774
6796
|
// z2 = 3 * (xi * t5) + 2 * z2
|
|
6775
6797
|
_.call(E + "_mul", Ct, _.i32_const(it), ht),
|
|
6776
|
-
_.call(E + "_add", ht,
|
|
6798
|
+
_.call(E + "_add", ht, M, H),
|
|
6777
6799
|
_.call(E + "_add", H, H, H),
|
|
6778
6800
|
_.call(E + "_add", ht, H, H),
|
|
6779
6801
|
// z3 = 3 * t4 - 2 * z3
|
|
@@ -6794,38 +6816,38 @@ var hs = function(t, n) {
|
|
|
6794
6816
|
function Vt(G, _) {
|
|
6795
6817
|
const g = S(G).map((Y) => Y == -1 ? 255 : Y), Q = t.alloc(g), R = t.addFunction(e + "__cyclotomicExp_" + _);
|
|
6796
6818
|
R.addParam("x", "i32"), R.addParam("r", "i32"), R.addLocal("bit", "i32"), R.addLocal("i", "i32");
|
|
6797
|
-
const
|
|
6819
|
+
const M = R.getCodeBuilder(), k = M.getLocal("x"), U = M.getLocal("r"), j = M.i32_const(t.alloc(C));
|
|
6798
6820
|
R.addCode(
|
|
6799
|
-
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
|
|
6803
|
-
|
|
6804
|
-
|
|
6805
|
-
|
|
6806
|
-
|
|
6821
|
+
M.call(st + "_conjugate", k, j),
|
|
6822
|
+
M.call(st + "_one", U),
|
|
6823
|
+
M.if(
|
|
6824
|
+
M.teeLocal("bit", M.i32_load8_s(M.i32_const(g.length - 1), Q)),
|
|
6825
|
+
M.if(
|
|
6826
|
+
M.i32_eq(
|
|
6827
|
+
M.getLocal("bit"),
|
|
6828
|
+
M.i32_const(1)
|
|
6807
6829
|
),
|
|
6808
|
-
|
|
6809
|
-
|
|
6830
|
+
M.call(st + "_mul", U, k, U),
|
|
6831
|
+
M.call(st + "_mul", U, j, U)
|
|
6810
6832
|
)
|
|
6811
6833
|
),
|
|
6812
|
-
|
|
6813
|
-
|
|
6814
|
-
|
|
6815
|
-
|
|
6816
|
-
|
|
6817
|
-
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
|
|
6834
|
+
M.setLocal("i", M.i32_const(g.length - 2)),
|
|
6835
|
+
M.block(M.loop(
|
|
6836
|
+
M.call(e + "__cyclotomicSquare", U, U),
|
|
6837
|
+
M.if(
|
|
6838
|
+
M.teeLocal("bit", M.i32_load8_s(M.getLocal("i"), Q)),
|
|
6839
|
+
M.if(
|
|
6840
|
+
M.i32_eq(
|
|
6841
|
+
M.getLocal("bit"),
|
|
6842
|
+
M.i32_const(1)
|
|
6821
6843
|
),
|
|
6822
|
-
|
|
6823
|
-
|
|
6844
|
+
M.call(st + "_mul", U, k, U),
|
|
6845
|
+
M.call(st + "_mul", U, j, U)
|
|
6824
6846
|
)
|
|
6825
6847
|
),
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
|
|
6848
|
+
M.br_if(1, M.i32_eqz(M.getLocal("i"))),
|
|
6849
|
+
M.setLocal("i", M.i32_sub(M.getLocal("i"), M.i32_const(1))),
|
|
6850
|
+
M.br(0)
|
|
6829
6851
|
))
|
|
6830
6852
|
);
|
|
6831
6853
|
}
|
|
@@ -6833,17 +6855,17 @@ var hs = function(t, n) {
|
|
|
6833
6855
|
Ut(), Vt(h, "w0");
|
|
6834
6856
|
const G = t.addFunction(e + "__finalExponentiationLastChunk");
|
|
6835
6857
|
G.addParam("x", "i32"), G.addParam("r", "i32");
|
|
6836
|
-
const _ = G.getCodeBuilder(), g = _.getLocal("x"), Q = _.getLocal("r"), R = _.i32_const(t.alloc(C)),
|
|
6858
|
+
const _ = G.getCodeBuilder(), g = _.getLocal("x"), Q = _.getLocal("r"), R = _.i32_const(t.alloc(C)), M = _.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)), Mt = _.i32_const(t.alloc(C)), Ht = _.i32_const(t.alloc(C)), Wt = _.i32_const(t.alloc(C));
|
|
6837
6859
|
G.addCode(
|
|
6838
6860
|
// A = exp_by_neg_z(elt) // = elt^(-z)
|
|
6839
6861
|
_.call(e + "__cyclotomicExp_w0", g, R),
|
|
6840
6862
|
_.call(st + "_conjugate", R, R),
|
|
6841
6863
|
// B = A^2 // = elt^(-2*z)
|
|
6842
|
-
_.call(e + "__cyclotomicSquare", R,
|
|
6864
|
+
_.call(e + "__cyclotomicSquare", R, M),
|
|
6843
6865
|
// C = B^2 // = elt^(-4*z)
|
|
6844
|
-
_.call(e + "__cyclotomicSquare",
|
|
6866
|
+
_.call(e + "__cyclotomicSquare", M, k),
|
|
6845
6867
|
// D = C * B // = elt^(-6*z)
|
|
6846
|
-
_.call(st + "_mul", k,
|
|
6868
|
+
_.call(st + "_mul", k, M, U),
|
|
6847
6869
|
// E = exp_by_neg_z(D) // = elt^(6*z^2)
|
|
6848
6870
|
_.call(e + "__cyclotomicExp_w0", U, j),
|
|
6849
6871
|
_.call(st + "_conjugate", j, j),
|
|
@@ -6861,7 +6883,7 @@ var hs = function(t, n) {
|
|
|
6861
6883
|
// K = J * H // = elt^(12*z^3 + 6*z^2 + 6*z)
|
|
6862
6884
|
_.call(st + "_mul", ft, H, _t),
|
|
6863
6885
|
// L = K * B // = elt^(12*z^3 + 6*z^2 + 4*z)
|
|
6864
|
-
_.call(st + "_mul", _t,
|
|
6886
|
+
_.call(st + "_mul", _t, M, lt),
|
|
6865
6887
|
// M = K * E // = elt^(12*z^3 + 12*z^2 + 6*z)
|
|
6866
6888
|
_.call(st + "_mul", _t, j, bt),
|
|
6867
6889
|
// N = M * elt // = elt^(12*z^3 + 12*z^2 + 6*z + 1)
|
|
@@ -6875,9 +6897,9 @@ var hs = function(t, n) {
|
|
|
6875
6897
|
// R = Q * P // = elt^(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))
|
|
6876
6898
|
_.call(st + "_mul", wt, Ct, ht),
|
|
6877
6899
|
// S = conj(elt) // = elt^(-1)
|
|
6878
|
-
_.call(st + "_conjugate", g,
|
|
6900
|
+
_.call(st + "_conjugate", g, Mt),
|
|
6879
6901
|
// T = S * L // = elt^(12*z^3 + 6*z^2 + 4*z - 1)
|
|
6880
|
-
_.call(st + "_mul",
|
|
6902
|
+
_.call(st + "_mul", Mt, lt, Ht),
|
|
6881
6903
|
// U = T.Frobenius_map(3) // = elt^(q^3(12*z^3 + 6*z^2 + 4*z - 1))
|
|
6882
6904
|
_.call(e + "__frobeniusMap3", Ht, Wt),
|
|
6883
6905
|
// 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))
|
|
@@ -6906,13 +6928,13 @@ var hs = function(t, n) {
|
|
|
6906
6928
|
const Nt = t.alloc(w), Kt = t.alloc(I);
|
|
6907
6929
|
function en(G) {
|
|
6908
6930
|
const _ = t.addFunction(e + "_pairingEq" + G);
|
|
6909
|
-
for (let
|
|
6910
|
-
_.addParam("p_" +
|
|
6931
|
+
for (let M = 0; M < G; M++)
|
|
6932
|
+
_.addParam("p_" + M, "i32"), _.addParam("q_" + M, "i32");
|
|
6911
6933
|
_.addParam("c", "i32"), _.setReturnType("i32");
|
|
6912
6934
|
const g = _.getCodeBuilder(), Q = g.i32_const(t.alloc(C)), R = g.i32_const(t.alloc(C));
|
|
6913
6935
|
_.addCode(g.call(st + "_one", Q));
|
|
6914
|
-
for (let
|
|
6915
|
-
_.addCode(g.call(e + "_prepareG1", g.getLocal("p_" +
|
|
6936
|
+
for (let M = 0; M < G; M++)
|
|
6937
|
+
_.addCode(g.call(e + "_prepareG1", g.getLocal("p_" + M), g.i32_const(Nt))), _.addCode(g.call(e + "_prepareG2", g.getLocal("q_" + M), g.i32_const(Kt))), _.addCode(g.call(e + "_millerLoop", g.i32_const(Nt), g.i32_const(Kt), R)), _.addCode(g.call(st + "_mul", Q, R, Q));
|
|
6916
6938
|
_.addCode(g.call(e + "_finalExponentiation", Q, Q)), _.addCode(g.call(st + "_eq", Q, g.getLocal("c")));
|
|
6917
6939
|
}
|
|
6918
6940
|
function Zt() {
|
|
@@ -6929,7 +6951,7 @@ var hs = function(t, n) {
|
|
|
6929
6951
|
en(G), t.exportFunction(e + "_pairingEq" + G);
|
|
6930
6952
|
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");
|
|
6931
6953
|
};
|
|
6932
|
-
const Et = mn, ps = yo, Ls = Wi, Go = Xi, As = ta, Ko = na,
|
|
6954
|
+
const Et = mn, ps = yo, Ls = Wi, Go = Xi, As = ta, Ko = na, Me = ea, bs = oa, ys = ia, Kn = aa, { bitLength: Ho, isOdd: Vo, isNegative: Is } = Yt;
|
|
6933
6955
|
var Cs = function(t, n) {
|
|
6934
6956
|
const e = n || "bls12381";
|
|
6935
6957
|
if (t.modules[e])
|
|
@@ -6937,7 +6959,7 @@ var Cs = function(t, n) {
|
|
|
6937
6959
|
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
6960
|
Ls(t, s, "fr", "frm", "intr");
|
|
6939
6961
|
const E = t.alloc(Et.bigInt2BytesLE(F(4n), b)), T = Ko(t, "g1m", "f1m", E);
|
|
6940
|
-
|
|
6962
|
+
Me(t, "frm", "frm", "frm", "frm_mul"), bs(t, "pol", "frm"), ys(t, "qap", "frm");
|
|
6941
6963
|
const x = Go(t, "f1m_neg", "f2m", "f1m"), ot = t.alloc([
|
|
6942
6964
|
...Et.bigInt2BytesLE(F(4n), b),
|
|
6943
6965
|
...Et.bigInt2BytesLE(F(4n), b)
|
|
@@ -6945,19 +6967,19 @@ var Cs = function(t, n) {
|
|
|
6945
6967
|
function rt(_, g) {
|
|
6946
6968
|
const Q = t.addFunction(_);
|
|
6947
6969
|
Q.addParam("pG", "i32"), Q.addParam("pFr", "i32"), Q.addParam("pr", "i32");
|
|
6948
|
-
const R = Q.getCodeBuilder(),
|
|
6970
|
+
const R = Q.getCodeBuilder(), M = R.i32_const(t.alloc(B));
|
|
6949
6971
|
Q.addCode(
|
|
6950
|
-
R.call("frm_fromMontgomery", R.getLocal("pFr"),
|
|
6972
|
+
R.call("frm_fromMontgomery", R.getLocal("pFr"), M),
|
|
6951
6973
|
R.call(
|
|
6952
6974
|
g,
|
|
6953
6975
|
R.getLocal("pG"),
|
|
6954
|
-
|
|
6976
|
+
M,
|
|
6955
6977
|
R.i32_const(B),
|
|
6956
6978
|
R.getLocal("pr")
|
|
6957
6979
|
)
|
|
6958
6980
|
), t.exportFunction(_);
|
|
6959
6981
|
}
|
|
6960
|
-
rt("g1m_timesFr", "g1m_timesScalar"),
|
|
6982
|
+
rt("g1m_timesFr", "g1m_timesScalar"), Me(t, "g1m", "g1m", "frm", "g1m_timesFr"), rt("g2m_timesFr", "g2m_timesScalar"), Me(t, "g2m", "g2m", "frm", "g2m_timesFr"), rt("g1m_timesFrAffine", "g1m_timesScalarAffine"), rt("g2m_timesFrAffine", "g2m_timesScalarAffine"), Kn(t, "frm_batchApplyKey", "fmr", "frm", B, B, B, "frm_mul"), Kn(t, "g1m_batchApplyKey", "g1m", "frm", r * 3, r * 3, B, "g1m_timesFr"), Kn(t, "g1m_batchApplyKeyMixed", "g1m", "frm", r * 2, r * 3, B, "g1m_timesFrAffine"), Kn(t, "g2m_batchApplyKey", "g2m", "frm", r * 2 * 3, r * 3 * 2, B, "g2m_timesFr"), Kn(t, "g2m_batchApplyKeyMixed", "g2m", "frm", r * 2 * 2, r * 3 * 2, B, "g2m_timesFrAffine");
|
|
6961
6983
|
function F(_) {
|
|
6962
6984
|
return BigInt(_) * (1n << BigInt(b * 8)) % i;
|
|
6963
6985
|
}
|
|
@@ -6994,7 +7016,7 @@ var Cs = function(t, n) {
|
|
|
6994
7016
|
1n,
|
|
6995
7017
|
0n
|
|
6996
7018
|
]
|
|
6997
|
-
],
|
|
7019
|
+
], q = t.alloc(
|
|
6998
7020
|
[
|
|
6999
7021
|
...Et.bigInt2BytesLE(F(X[0][0]), b),
|
|
7000
7022
|
...Et.bigInt2BytesLE(F(X[0][1]), b),
|
|
@@ -7045,11 +7067,11 @@ var Cs = function(t, n) {
|
|
|
7045
7067
|
function nt() {
|
|
7046
7068
|
const _ = t.addFunction(x + "_mulNR");
|
|
7047
7069
|
_.addParam("x", "i32"), _.addParam("pr", "i32");
|
|
7048
|
-
const g = _.getCodeBuilder(), Q = g.i32_const(t.alloc(b)), R = g.getLocal("x"),
|
|
7070
|
+
const g = _.getCodeBuilder(), Q = g.i32_const(t.alloc(b)), R = g.getLocal("x"), M = 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
7071
|
_.addCode(
|
|
7050
7072
|
g.call(P + "_copy", R, Q),
|
|
7051
|
-
g.call(P + "_sub", R,
|
|
7052
|
-
g.call(P + "_add", Q,
|
|
7073
|
+
g.call(P + "_sub", R, M, k),
|
|
7074
|
+
g.call(P + "_add", Q, M, U)
|
|
7053
7075
|
);
|
|
7054
7076
|
}
|
|
7055
7077
|
nt();
|
|
@@ -7091,7 +7113,7 @@ var Cs = function(t, n) {
|
|
|
7091
7113
|
pG1gen: L,
|
|
7092
7114
|
pG1zero: $,
|
|
7093
7115
|
pG1b: E,
|
|
7094
|
-
pG2gen:
|
|
7116
|
+
pG2gen: q,
|
|
7095
7117
|
pG2zero: v,
|
|
7096
7118
|
pG2b: ot,
|
|
7097
7119
|
pq: t.modules.f1m.pq,
|
|
@@ -7134,7 +7156,7 @@ var Cs = function(t, n) {
|
|
|
7134
7156
|
function at() {
|
|
7135
7157
|
const _ = t.addFunction(e + "_prepDblStep");
|
|
7136
7158
|
_.addParam("R", "i32"), _.addParam("r", "i32");
|
|
7137
|
-
const g = _.getCodeBuilder(), Q = g.getLocal("R"), R = g.i32_add(g.getLocal("R"), g.i32_const(2 * r)),
|
|
7159
|
+
const g = _.getCodeBuilder(), Q = g.getLocal("R"), R = g.i32_add(g.getLocal("R"), g.i32_const(2 * r)), M = 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
7160
|
_.addCode(
|
|
7139
7161
|
// tmp0 = r.x.square();
|
|
7140
7162
|
g.call(x + "_square", Q, k),
|
|
@@ -7157,15 +7179,15 @@ var Cs = function(t, n) {
|
|
|
7157
7179
|
// tmp5 = tmp4.square();
|
|
7158
7180
|
g.call(x + "_square", et, ft),
|
|
7159
7181
|
// zsquared = r.z.square();
|
|
7160
|
-
g.call(x + "_square",
|
|
7182
|
+
g.call(x + "_square", M, Y),
|
|
7161
7183
|
// r.x = tmp5 - tmp3 - tmp3;
|
|
7162
7184
|
g.call(x + "_sub", ft, U, Q),
|
|
7163
7185
|
g.call(x + "_sub", Q, U, Q),
|
|
7164
7186
|
// r.z = (r.z + r.y).square() - tmp1 - zsquared;
|
|
7165
|
-
g.call(x + "_add",
|
|
7166
|
-
g.call(x + "_square",
|
|
7167
|
-
g.call(x + "_sub",
|
|
7168
|
-
g.call(x + "_sub",
|
|
7187
|
+
g.call(x + "_add", M, R, M),
|
|
7188
|
+
g.call(x + "_square", M, M),
|
|
7189
|
+
g.call(x + "_sub", M, Z, M),
|
|
7190
|
+
g.call(x + "_sub", M, Y, M),
|
|
7169
7191
|
// r.y = (tmp3 - r.x) * tmp4;
|
|
7170
7192
|
g.call(x + "_sub", U, Q, R),
|
|
7171
7193
|
g.call(x + "_mul", R, et, R),
|
|
@@ -7194,7 +7216,7 @@ var Cs = function(t, n) {
|
|
|
7194
7216
|
// tmp6 = tmp6 - tmp1;
|
|
7195
7217
|
g.call(x + "_sub", j, Z, j),
|
|
7196
7218
|
// tmp0 = r.z * zsquared;
|
|
7197
|
-
g.call(x + "_mul",
|
|
7219
|
+
g.call(x + "_mul", M, Y, k),
|
|
7198
7220
|
// tmp0 = tmp0 + tmp0;
|
|
7199
7221
|
g.call(x + "_add", k, k, k)
|
|
7200
7222
|
);
|
|
@@ -7202,16 +7224,16 @@ var Cs = function(t, n) {
|
|
|
7202
7224
|
function It() {
|
|
7203
7225
|
const _ = t.addFunction(e + "_prepAddStep");
|
|
7204
7226
|
_.addParam("R", "i32"), _.addParam("Q", "i32"), _.addParam("r", "i32");
|
|
7205
|
-
const g = _.getCodeBuilder(), Q = g.getLocal("R"), R = g.i32_add(g.getLocal("R"), g.i32_const(2 * r)),
|
|
7227
|
+
const g = _.getCodeBuilder(), Q = g.getLocal("R"), R = g.i32_add(g.getLocal("R"), g.i32_const(2 * r)), M = 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
7228
|
_.addCode(
|
|
7207
7229
|
// zsquared = r.z.square();
|
|
7208
|
-
g.call(x + "_square",
|
|
7230
|
+
g.call(x + "_square", M, H),
|
|
7209
7231
|
// ysquared = q.y.square();
|
|
7210
7232
|
g.call(x + "_square", U, et),
|
|
7211
7233
|
// t0 = zsquared * q.x;
|
|
7212
7234
|
g.call(x + "_mul", H, k, _t),
|
|
7213
7235
|
// t1 = ((q.y + r.z).square() - ysquared - zsquared) * zsquared;
|
|
7214
|
-
g.call(x + "_add", U,
|
|
7236
|
+
g.call(x + "_add", U, M, Y),
|
|
7215
7237
|
g.call(x + "_square", Y, Y),
|
|
7216
7238
|
g.call(x + "_sub", Y, et, Y),
|
|
7217
7239
|
g.call(x + "_sub", Y, H, Y),
|
|
@@ -7239,12 +7261,12 @@ var Cs = function(t, n) {
|
|
|
7239
7261
|
g.call(x + "_sub", Q, wt, Q),
|
|
7240
7262
|
g.call(x + "_sub", Q, wt, Q),
|
|
7241
7263
|
// r.z = (r.z + t2).square() - zsquared - t3;
|
|
7242
|
-
g.call(x + "_add",
|
|
7243
|
-
g.call(x + "_square",
|
|
7244
|
-
g.call(x + "_sub",
|
|
7245
|
-
g.call(x + "_sub",
|
|
7264
|
+
g.call(x + "_add", M, lt, M),
|
|
7265
|
+
g.call(x + "_square", M, M),
|
|
7266
|
+
g.call(x + "_sub", M, H, M),
|
|
7267
|
+
g.call(x + "_sub", M, bt, M),
|
|
7246
7268
|
// t10 = q.y + r.z;
|
|
7247
|
-
g.call(x + "_add", U,
|
|
7269
|
+
g.call(x + "_add", U, M, j),
|
|
7248
7270
|
// t8 = (t7 - r.x) * t6;
|
|
7249
7271
|
g.call(x + "_sub", wt, Q, ht),
|
|
7250
7272
|
g.call(x + "_mul", ht, Ct, ht),
|
|
@@ -7258,14 +7280,14 @@ var Cs = function(t, n) {
|
|
|
7258
7280
|
g.call(x + "_square", j, j),
|
|
7259
7281
|
g.call(x + "_sub", j, et, j),
|
|
7260
7282
|
// ztsquared = r.z.square();
|
|
7261
|
-
g.call(x + "_square",
|
|
7283
|
+
g.call(x + "_square", M, ft),
|
|
7262
7284
|
// t10 = t10 - ztsquared;
|
|
7263
7285
|
g.call(x + "_sub", j, ft, j),
|
|
7264
7286
|
// t9 = t9 + t9 - t10;
|
|
7265
7287
|
g.call(x + "_add", Z, Z, Z),
|
|
7266
7288
|
g.call(x + "_sub", Z, j, Z),
|
|
7267
7289
|
// t10 = r.z + r.z;
|
|
7268
|
-
g.call(x + "_add",
|
|
7290
|
+
g.call(x + "_add", M, M, j),
|
|
7269
7291
|
// t6 = -t6;
|
|
7270
7292
|
g.call(x + "_neg", Ct, Ct),
|
|
7271
7293
|
// t1 = t6 + t6;
|
|
@@ -7275,24 +7297,24 @@ var Cs = function(t, n) {
|
|
|
7275
7297
|
function ut() {
|
|
7276
7298
|
const _ = t.addFunction(e + "_prepareG2");
|
|
7277
7299
|
_.addParam("pQ", "i32"), _.addParam("ppreQ", "i32"), _.addLocal("pCoef", "i32"), _.addLocal("i", "i32");
|
|
7278
|
-
const g = _.getCodeBuilder(), Q = g.getLocal("pQ"), R = t.alloc(u * 3),
|
|
7300
|
+
const g = _.getCodeBuilder(), Q = g.getLocal("pQ"), R = t.alloc(u * 3), M = g.i32_const(R), k = g.getLocal("ppreQ");
|
|
7279
7301
|
_.addCode(
|
|
7280
7302
|
g.call(z + "_normalize", Q, k),
|
|
7281
7303
|
g.if(
|
|
7282
7304
|
g.call(z + "_isZero", k),
|
|
7283
7305
|
g.ret([])
|
|
7284
7306
|
),
|
|
7285
|
-
g.call(z + "_copy", k,
|
|
7307
|
+
g.call(z + "_copy", k, M),
|
|
7286
7308
|
g.setLocal("pCoef", g.i32_add(g.getLocal("ppreQ"), g.i32_const(u * 3)))
|
|
7287
7309
|
), _.addCode(
|
|
7288
7310
|
g.setLocal("i", g.i32_const(At.length - 2)),
|
|
7289
7311
|
g.block(g.loop(
|
|
7290
|
-
g.call(e + "_prepDblStep",
|
|
7312
|
+
g.call(e + "_prepDblStep", M, g.getLocal("pCoef")),
|
|
7291
7313
|
g.setLocal("pCoef", g.i32_add(g.getLocal("pCoef"), g.i32_const(pt))),
|
|
7292
7314
|
g.if(
|
|
7293
7315
|
g.i32_load8_s(g.getLocal("i"), Bt),
|
|
7294
7316
|
[
|
|
7295
|
-
...g.call(e + "_prepAddStep",
|
|
7317
|
+
...g.call(e + "_prepAddStep", M, k, g.getLocal("pCoef")),
|
|
7296
7318
|
...g.setLocal("pCoef", g.i32_add(g.getLocal("pCoef"), g.i32_const(pt)))
|
|
7297
7319
|
]
|
|
7298
7320
|
),
|
|
@@ -7305,10 +7327,10 @@ var Cs = function(t, n) {
|
|
|
7305
7327
|
function Lt() {
|
|
7306
7328
|
const _ = t.addFunction(K + "_mul1");
|
|
7307
7329
|
_.addParam("pA", "i32"), _.addParam("pC1", "i32"), _.addParam("pR", "i32");
|
|
7308
|
-
const g = _.getCodeBuilder(), Q = g.getLocal("pA"), R = g.i32_add(g.getLocal("pA"), g.i32_const(b * 2)),
|
|
7330
|
+
const g = _.getCodeBuilder(), Q = g.getLocal("pA"), R = g.i32_add(g.getLocal("pA"), g.i32_const(b * 2)), M = 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
7331
|
_.addCode(
|
|
7310
7332
|
g.call(x + "_add", Q, R, Z),
|
|
7311
|
-
g.call(x + "_add", R,
|
|
7333
|
+
g.call(x + "_add", R, M, H),
|
|
7312
7334
|
// let b_b = self.c1 * c1;
|
|
7313
7335
|
g.call(x + "_mul", R, k, Y),
|
|
7314
7336
|
// let t1 = (self.c1 + self.c2) * c1 - b_b;
|
|
@@ -7325,16 +7347,16 @@ var Cs = function(t, n) {
|
|
|
7325
7347
|
function St() {
|
|
7326
7348
|
const _ = t.addFunction(K + "_mul01");
|
|
7327
7349
|
_.addParam("pA", "i32"), _.addParam("pC0", "i32"), _.addParam("pC1", "i32"), _.addParam("pR", "i32");
|
|
7328
|
-
const g = _.getCodeBuilder(), Q = g.getLocal("pA"), R = g.i32_add(g.getLocal("pA"), g.i32_const(b * 2)),
|
|
7350
|
+
const g = _.getCodeBuilder(), Q = g.getLocal("pA"), R = g.i32_add(g.getLocal("pA"), g.i32_const(b * 2)), M = 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
7351
|
_.addCode(
|
|
7330
7352
|
// let a_a = self.c0 * c0;
|
|
7331
7353
|
g.call(x + "_mul", Q, k, H),
|
|
7332
7354
|
// let b_b = self.c1 * c1;
|
|
7333
7355
|
g.call(x + "_mul", R, U, et),
|
|
7334
7356
|
g.call(x + "_add", Q, R, ft),
|
|
7335
|
-
g.call(x + "_add", Q,
|
|
7357
|
+
g.call(x + "_add", Q, M, _t),
|
|
7336
7358
|
// let t1 = (self.c1 + self.c2) * c1 - b_b;
|
|
7337
|
-
g.call(x + "_add", R,
|
|
7359
|
+
g.call(x + "_add", R, M, j),
|
|
7338
7360
|
g.call(x + "_mul", j, U, j),
|
|
7339
7361
|
g.call(x + "_sub", j, et, j),
|
|
7340
7362
|
// let t1 = t1.mul_by_nonresidue() + a_a;
|
|
@@ -7355,10 +7377,10 @@ var Cs = function(t, n) {
|
|
|
7355
7377
|
function gt() {
|
|
7356
7378
|
const _ = t.addFunction(J + "_mul014");
|
|
7357
7379
|
_.addParam("pA", "i32"), _.addParam("pC0", "i32"), _.addParam("pC1", "i32"), _.addParam("pC4", "i32"), _.addParam("pR", "i32");
|
|
7358
|
-
const g = _.getCodeBuilder(), Q = g.getLocal("pA"), R = g.i32_add(g.getLocal("pA"), g.i32_const(b * 6)),
|
|
7380
|
+
const g = _.getCodeBuilder(), Q = g.getLocal("pA"), R = g.i32_add(g.getLocal("pA"), g.i32_const(b * 6)), M = 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
7381
|
_.addCode(
|
|
7360
7382
|
// let aa = self.c0.mul_by_01(c0, c1);
|
|
7361
|
-
g.call(K + "_mul01", Q,
|
|
7383
|
+
g.call(K + "_mul01", Q, M, k, j),
|
|
7362
7384
|
// let bb = self.c1.mul_by_1(c4);
|
|
7363
7385
|
g.call(K + "_mul1", R, U, Y),
|
|
7364
7386
|
// let o = c1 + c4;
|
|
@@ -7366,7 +7388,7 @@ var Cs = function(t, n) {
|
|
|
7366
7388
|
// let c1 = self.c1 + self.c0;
|
|
7367
7389
|
g.call(K + "_add", R, Q, et),
|
|
7368
7390
|
// let c1 = c1.mul_by_01(c0, &o);
|
|
7369
|
-
g.call(K + "_mul01", et,
|
|
7391
|
+
g.call(K + "_mul01", et, M, Z, et),
|
|
7370
7392
|
// let c1 = c1 - aa - bb;
|
|
7371
7393
|
g.call(K + "_sub", et, j, et),
|
|
7372
7394
|
g.call(K + "_sub", et, Y, et),
|
|
@@ -7382,7 +7404,7 @@ var Cs = function(t, n) {
|
|
|
7382
7404
|
function dt() {
|
|
7383
7405
|
const _ = t.addFunction(e + "_ell");
|
|
7384
7406
|
_.addParam("pP", "i32"), _.addParam("pCoefs", "i32"), _.addParam("pF", "i32");
|
|
7385
|
-
const g = _.getCodeBuilder(), Q = g.getLocal("pP"), R = g.i32_add(g.getLocal("pP"), g.i32_const(r)),
|
|
7407
|
+
const g = _.getCodeBuilder(), Q = g.getLocal("pP"), R = g.i32_add(g.getLocal("pP"), g.i32_const(r)), M = 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
7408
|
_.addCode(
|
|
7387
7409
|
// let mut c0 = coeffs.0;
|
|
7388
7410
|
// let mut c1 = coeffs.1;
|
|
@@ -7398,16 +7420,16 @@ var Cs = function(t, n) {
|
|
|
7398
7420
|
g.call(P + "_mul", U, R, _t),
|
|
7399
7421
|
g.call(P + "_mul", j, Q, mt),
|
|
7400
7422
|
g.call(P + "_mul", Y, Q, Ot),
|
|
7401
|
-
g.call(J + "_mul014",
|
|
7423
|
+
g.call(J + "_mul014", M, Z, bt, et, M)
|
|
7402
7424
|
);
|
|
7403
7425
|
}
|
|
7404
7426
|
dt();
|
|
7405
7427
|
function yt() {
|
|
7406
7428
|
const _ = t.addFunction(e + "_millerLoop");
|
|
7407
7429
|
_.addParam("ppreP", "i32"), _.addParam("ppreQ", "i32"), _.addParam("r", "i32"), _.addLocal("pCoef", "i32"), _.addLocal("i", "i32");
|
|
7408
|
-
const g = _.getCodeBuilder(), Q = g.getLocal("ppreP"), R = g.getLocal("pCoef"),
|
|
7430
|
+
const g = _.getCodeBuilder(), Q = g.getLocal("ppreP"), R = g.getLocal("pCoef"), M = g.getLocal("r");
|
|
7409
7431
|
_.addCode(
|
|
7410
|
-
g.call(J + "_one",
|
|
7432
|
+
g.call(J + "_one", M),
|
|
7411
7433
|
g.if(
|
|
7412
7434
|
g.call(T + "_isZero", Q),
|
|
7413
7435
|
g.ret([])
|
|
@@ -7419,23 +7441,23 @@ var Cs = function(t, n) {
|
|
|
7419
7441
|
g.setLocal("pCoef", g.i32_add(g.getLocal("ppreQ"), g.i32_const(u * 3))),
|
|
7420
7442
|
g.setLocal("i", g.i32_const(At.length - 2)),
|
|
7421
7443
|
g.block(g.loop(
|
|
7422
|
-
g.call(e + "_ell", Q, R,
|
|
7444
|
+
g.call(e + "_ell", Q, R, M),
|
|
7423
7445
|
g.setLocal("pCoef", g.i32_add(g.getLocal("pCoef"), g.i32_const(pt))),
|
|
7424
7446
|
g.if(
|
|
7425
7447
|
g.i32_load8_s(g.getLocal("i"), Bt),
|
|
7426
7448
|
[
|
|
7427
|
-
...g.call(e + "_ell", Q, R,
|
|
7449
|
+
...g.call(e + "_ell", Q, R, M),
|
|
7428
7450
|
...g.setLocal("pCoef", g.i32_add(g.getLocal("pCoef"), g.i32_const(pt)))
|
|
7429
7451
|
]
|
|
7430
7452
|
),
|
|
7431
|
-
g.call(J + "_square",
|
|
7453
|
+
g.call(J + "_square", M, M),
|
|
7432
7454
|
g.br_if(1, g.i32_eq(g.getLocal("i"), g.i32_const(1))),
|
|
7433
7455
|
g.setLocal("i", g.i32_sub(g.getLocal("i"), g.i32_const(1))),
|
|
7434
7456
|
g.br(0)
|
|
7435
7457
|
)),
|
|
7436
|
-
g.call(e + "_ell", Q, R,
|
|
7458
|
+
g.call(e + "_ell", Q, R, M)
|
|
7437
7459
|
), _.addCode(
|
|
7438
|
-
g.call(J + "_conjugate",
|
|
7460
|
+
g.call(J + "_conjugate", M, M)
|
|
7439
7461
|
);
|
|
7440
7462
|
}
|
|
7441
7463
|
function vt(_) {
|
|
@@ -7495,17 +7517,17 @@ var Cs = function(t, n) {
|
|
|
7495
7517
|
]
|
|
7496
7518
|
], R = t.addFunction(J + "_frobeniusMap" + _);
|
|
7497
7519
|
R.addParam("x", "i32"), R.addParam("r", "i32");
|
|
7498
|
-
const
|
|
7520
|
+
const M = R.getCodeBuilder();
|
|
7499
7521
|
for (let U = 0; U < 6; U++) {
|
|
7500
|
-
const j = U == 0 ?
|
|
7522
|
+
const j = U == 0 ? M.getLocal("x") : M.i32_add(M.getLocal("x"), M.i32_const(U * u)), Y = j, Z = M.i32_add(M.getLocal("x"), M.i32_const(U * u + b)), H = U == 0 ? M.getLocal("r") : M.i32_add(M.getLocal("r"), M.i32_const(U * u)), et = H, ft = M.i32_add(M.getLocal("r"), M.i32_const(U * u + b)), _t = k(g[Math.floor(U / 3)][_ % 12], Q[U % 3][_ % 6]), lt = t.alloc([
|
|
7501
7523
|
...Et.bigInt2BytesLE(F(_t[0]), r),
|
|
7502
7524
|
...Et.bigInt2BytesLE(F(_t[1]), r)
|
|
7503
7525
|
]);
|
|
7504
7526
|
_ % 2 == 1 ? R.addCode(
|
|
7505
|
-
|
|
7506
|
-
|
|
7507
|
-
|
|
7508
|
-
) : R.addCode(
|
|
7527
|
+
M.call(P + "_copy", Y, et),
|
|
7528
|
+
M.call(P + "_neg", Z, ft),
|
|
7529
|
+
M.call(x + "_mul", H, M.i32_const(lt), H)
|
|
7530
|
+
) : R.addCode(M.call(x + "_mul", j, M.i32_const(lt), H));
|
|
7509
7531
|
}
|
|
7510
7532
|
function k(U, j) {
|
|
7511
7533
|
const Y = U[0], Z = U[1], H = j[0], et = j[1], ft = [
|
|
@@ -7518,7 +7540,7 @@ var Cs = function(t, n) {
|
|
|
7518
7540
|
function Ut() {
|
|
7519
7541
|
const _ = t.addFunction(e + "__cyclotomicSquare");
|
|
7520
7542
|
_.addParam("x", "i32"), _.addParam("r", "i32");
|
|
7521
|
-
const g = _.getCodeBuilder(), Q = g.getLocal("x"), R = g.i32_add(g.getLocal("x"), g.i32_const(u)),
|
|
7543
|
+
const g = _.getCodeBuilder(), Q = g.getLocal("x"), R = g.i32_add(g.getLocal("x"), g.i32_const(u)), M = 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)), Mt = g.i32_const(t.alloc(u));
|
|
7522
7544
|
_.addCode(
|
|
7523
7545
|
// // t0 + t1*y = (z0 + z1*y)^2 = a^2
|
|
7524
7546
|
// tmp = z0 * z1;
|
|
@@ -7527,24 +7549,24 @@ var Cs = function(t, n) {
|
|
|
7527
7549
|
g.call(x + "_mul", Q, U, ht),
|
|
7528
7550
|
g.call(x + "_mulNR", U, lt),
|
|
7529
7551
|
g.call(x + "_add", Q, lt, lt),
|
|
7530
|
-
g.call(x + "_add", Q, U,
|
|
7531
|
-
g.call(x + "_mul",
|
|
7532
|
-
g.call(x + "_mulNR", ht,
|
|
7533
|
-
g.call(x + "_add", ht,
|
|
7534
|
-
g.call(x + "_sub", lt,
|
|
7552
|
+
g.call(x + "_add", Q, U, Mt),
|
|
7553
|
+
g.call(x + "_mul", Mt, lt, lt),
|
|
7554
|
+
g.call(x + "_mulNR", ht, Mt),
|
|
7555
|
+
g.call(x + "_add", ht, Mt, Mt),
|
|
7556
|
+
g.call(x + "_sub", lt, Mt, lt),
|
|
7535
7557
|
g.call(x + "_add", ht, ht, bt),
|
|
7536
7558
|
// // t2 + t3*y = (z2 + z3*y)^2 = b^2
|
|
7537
7559
|
// tmp = z2 * z3;
|
|
7538
7560
|
// t2 = (z2 + z3) * (z2 + my_Fp6::non_residue * z3) - tmp - my_Fp6::non_residue * tmp;
|
|
7539
7561
|
// t3 = tmp + tmp;
|
|
7540
|
-
g.call(x + "_mul", k,
|
|
7541
|
-
g.call(x + "_mulNR",
|
|
7562
|
+
g.call(x + "_mul", k, M, ht),
|
|
7563
|
+
g.call(x + "_mulNR", M, mt),
|
|
7542
7564
|
g.call(x + "_add", k, mt, mt),
|
|
7543
|
-
g.call(x + "_add", k,
|
|
7544
|
-
g.call(x + "_mul",
|
|
7545
|
-
g.call(x + "_mulNR", ht,
|
|
7546
|
-
g.call(x + "_add", ht,
|
|
7547
|
-
g.call(x + "_sub", mt,
|
|
7565
|
+
g.call(x + "_add", k, M, Mt),
|
|
7566
|
+
g.call(x + "_mul", Mt, mt, mt),
|
|
7567
|
+
g.call(x + "_mulNR", ht, Mt),
|
|
7568
|
+
g.call(x + "_add", ht, Mt, Mt),
|
|
7569
|
+
g.call(x + "_sub", mt, Mt, mt),
|
|
7548
7570
|
g.call(x + "_add", ht, ht, Ot),
|
|
7549
7571
|
// // t4 + t5*y = (z4 + z5*y)^2 = c^2
|
|
7550
7572
|
// tmp = z4 * z5;
|
|
@@ -7553,11 +7575,11 @@ var Cs = function(t, n) {
|
|
|
7553
7575
|
g.call(x + "_mul", R, j, ht),
|
|
7554
7576
|
g.call(x + "_mulNR", j, Ct),
|
|
7555
7577
|
g.call(x + "_add", R, Ct, Ct),
|
|
7556
|
-
g.call(x + "_add", R, j,
|
|
7557
|
-
g.call(x + "_mul",
|
|
7558
|
-
g.call(x + "_mulNR", ht,
|
|
7559
|
-
g.call(x + "_add", ht,
|
|
7560
|
-
g.call(x + "_sub", Ct,
|
|
7578
|
+
g.call(x + "_add", R, j, Mt),
|
|
7579
|
+
g.call(x + "_mul", Mt, Ct, Ct),
|
|
7580
|
+
g.call(x + "_mulNR", ht, Mt),
|
|
7581
|
+
g.call(x + "_add", ht, Mt, Mt),
|
|
7582
|
+
g.call(x + "_sub", Ct, Mt, Ct),
|
|
7561
7583
|
g.call(x + "_add", ht, ht, wt),
|
|
7562
7584
|
// For A
|
|
7563
7585
|
// z0 = 3 * t0 - 2 * z0
|
|
@@ -7570,12 +7592,12 @@ var Cs = function(t, n) {
|
|
|
7570
7592
|
g.call(x + "_add", bt, ft, ft),
|
|
7571
7593
|
// For B
|
|
7572
7594
|
// z2 = 3 * (xi * t5) + 2 * z2
|
|
7573
|
-
g.call(x + "_mul", wt, g.i32_const(it),
|
|
7574
|
-
g.call(x + "_add",
|
|
7595
|
+
g.call(x + "_mul", wt, g.i32_const(it), Mt),
|
|
7596
|
+
g.call(x + "_add", Mt, k, et),
|
|
7575
7597
|
g.call(x + "_add", et, et, et),
|
|
7576
|
-
g.call(x + "_add",
|
|
7598
|
+
g.call(x + "_add", Mt, et, et),
|
|
7577
7599
|
// z3 = 3 * t4 - 2 * z3
|
|
7578
|
-
g.call(x + "_sub", Ct,
|
|
7600
|
+
g.call(x + "_sub", Ct, M, H),
|
|
7579
7601
|
g.call(x + "_add", H, H, H),
|
|
7580
7602
|
g.call(x + "_add", Ct, H, H),
|
|
7581
7603
|
// For C
|
|
@@ -7590,14 +7612,14 @@ var Cs = function(t, n) {
|
|
|
7590
7612
|
);
|
|
7591
7613
|
}
|
|
7592
7614
|
function Vt(_, g, Q) {
|
|
7593
|
-
const R = S(_).map((H) => H == -1 ? 255 : H),
|
|
7615
|
+
const R = S(_).map((H) => H == -1 ? 255 : H), M = t.alloc(R), k = t.addFunction(e + "__cyclotomicExp_" + Q);
|
|
7594
7616
|
k.addParam("x", "i32"), k.addParam("r", "i32"), k.addLocal("bit", "i32"), k.addLocal("i", "i32");
|
|
7595
7617
|
const U = k.getCodeBuilder(), j = U.getLocal("x"), Y = U.getLocal("r"), Z = U.i32_const(t.alloc(l));
|
|
7596
7618
|
k.addCode(
|
|
7597
7619
|
U.call(J + "_conjugate", j, Z),
|
|
7598
7620
|
U.call(J + "_one", Y),
|
|
7599
7621
|
U.if(
|
|
7600
|
-
U.teeLocal("bit", U.i32_load8_s(U.i32_const(R.length - 1),
|
|
7622
|
+
U.teeLocal("bit", U.i32_load8_s(U.i32_const(R.length - 1), M)),
|
|
7601
7623
|
U.if(
|
|
7602
7624
|
U.i32_eq(
|
|
7603
7625
|
U.getLocal("bit"),
|
|
@@ -7611,7 +7633,7 @@ var Cs = function(t, n) {
|
|
|
7611
7633
|
U.block(U.loop(
|
|
7612
7634
|
U.call(e + "__cyclotomicSquare", Y, Y),
|
|
7613
7635
|
U.if(
|
|
7614
|
-
U.teeLocal("bit", U.i32_load8_s(U.getLocal("i"),
|
|
7636
|
+
U.teeLocal("bit", U.i32_load8_s(U.getLocal("i"), M)),
|
|
7615
7637
|
U.if(
|
|
7616
7638
|
U.i32_eq(
|
|
7617
7639
|
U.getLocal("bit"),
|
|
@@ -7633,14 +7655,14 @@ var Cs = function(t, n) {
|
|
|
7633
7655
|
Ut(), Vt(h, I, "w0");
|
|
7634
7656
|
const _ = t.addFunction(e + "_finalExponentiation");
|
|
7635
7657
|
_.addParam("x", "i32"), _.addParam("r", "i32");
|
|
7636
|
-
const g = _.getCodeBuilder(), Q = g.getLocal("x"), R = g.getLocal("r"),
|
|
7658
|
+
const g = _.getCodeBuilder(), Q = g.getLocal("x"), R = g.getLocal("r"), M = 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
7659
|
_.addCode(
|
|
7638
7660
|
// let mut t0 = f.frobenius_map(6)
|
|
7639
|
-
g.call(J + "_frobeniusMap6", Q,
|
|
7661
|
+
g.call(J + "_frobeniusMap6", Q, M),
|
|
7640
7662
|
// let t1 = f.invert()
|
|
7641
7663
|
g.call(J + "_inverse", Q, k),
|
|
7642
7664
|
// let mut t2 = t0 * t1;
|
|
7643
|
-
g.call(J + "_mul",
|
|
7665
|
+
g.call(J + "_mul", M, k, U),
|
|
7644
7666
|
// t1 = t2.clone();
|
|
7645
7667
|
g.call(J + "_copy", U, k),
|
|
7646
7668
|
// t2 = t2.frobenius_map().frobenius_map();
|
|
@@ -7659,9 +7681,9 @@ var Cs = function(t, n) {
|
|
|
7659
7681
|
// t1 = cycolotomic_exp(t5);
|
|
7660
7682
|
g.call(e + "__cyclotomicExp_w0", Z, k),
|
|
7661
7683
|
// t0 = cycolotomic_exp(t1);
|
|
7662
|
-
g.call(e + "__cyclotomicExp_w0", k,
|
|
7684
|
+
g.call(e + "__cyclotomicExp_w0", k, M),
|
|
7663
7685
|
// let mut t6 = cycolotomic_exp(t0);
|
|
7664
|
-
g.call(e + "__cyclotomicExp_w0",
|
|
7686
|
+
g.call(e + "__cyclotomicExp_w0", M, H),
|
|
7665
7687
|
// t6 *= t4;
|
|
7666
7688
|
g.call(J + "_mul", H, Y, H),
|
|
7667
7689
|
// t4 = cycolotomic_exp(t6);
|
|
@@ -7682,7 +7704,7 @@ var Cs = function(t, n) {
|
|
|
7682
7704
|
// t6 = t6.frobenius_map();
|
|
7683
7705
|
g.call(J + "_frobeniusMap1", H, H),
|
|
7684
7706
|
// t3 *= t0;
|
|
7685
|
-
g.call(J + "_mul", j,
|
|
7707
|
+
g.call(J + "_mul", j, M, j),
|
|
7686
7708
|
// t3 = t3.frobenius_map().frobenius_map();
|
|
7687
7709
|
g.call(J + "_frobeniusMap2", j, j),
|
|
7688
7710
|
// t3 *= t1;
|
|
@@ -7707,7 +7729,7 @@ var Cs = function(t, n) {
|
|
|
7707
7729
|
for (let k = 0; k < _; k++)
|
|
7708
7730
|
g.addParam("p_" + k, "i32"), g.addParam("q_" + k, "i32");
|
|
7709
7731
|
g.addParam("c", "i32"), g.setReturnType("i32");
|
|
7710
|
-
const Q = g.getCodeBuilder(), R = Q.i32_const(t.alloc(l)),
|
|
7732
|
+
const Q = g.getCodeBuilder(), R = Q.i32_const(t.alloc(l)), M = Q.i32_const(t.alloc(l));
|
|
7711
7733
|
g.addCode(Q.call(J + "_one", R));
|
|
7712
7734
|
for (let k = 0; k < _; k++)
|
|
7713
7735
|
g.addCode(Q.call(e + "_prepareG1", Q.getLocal("p_" + k), Q.i32_const(Tt))), g.addCode(Q.call(e + "_prepareG2", Q.getLocal("q_" + k), Q.i32_const(Nt))), g.addCode(
|
|
@@ -7719,7 +7741,7 @@ var Cs = function(t, n) {
|
|
|
7719
7741
|
Q.i32_eqz(Q.call(z + "_inGroupAffine", Q.i32_const(Nt))),
|
|
7720
7742
|
Q.ret(Q.i32_const(0))
|
|
7721
7743
|
)
|
|
7722
|
-
), g.addCode(Q.call(e + "_millerLoop", Q.i32_const(Tt), Q.i32_const(Nt),
|
|
7744
|
+
), g.addCode(Q.call(e + "_millerLoop", Q.i32_const(Tt), Q.i32_const(Nt), M)), g.addCode(Q.call(J + "_mul", R, M, R));
|
|
7723
7745
|
g.addCode(Q.call(e + "_finalExponentiation", R, R)), g.addCode(Q.call(J + "_eq", R, Q.getLocal("c")));
|
|
7724
7746
|
}
|
|
7725
7747
|
function en() {
|
|
@@ -7734,16 +7756,16 @@ var Cs = function(t, n) {
|
|
|
7734
7756
|
const g = _.getCodeBuilder(), Q = [
|
|
7735
7757
|
2001204777610833696708894912867952078278441409969503942666029068062015825245418932221343814564507832018947136279894n,
|
|
7736
7758
|
2001204777610833696708894912867952078278441409969503942666029068062015825245418932221343814564507832018947136279893n
|
|
7737
|
-
], R = 4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939436n,
|
|
7759
|
+
], R = 4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939436n, M = [
|
|
7738
7760
|
2973677408986561043442465346520108879172042883009249989176415018091420807192182638567116318576472649347015917690530n,
|
|
7739
7761
|
2973677408986561043442465346520108879172042883009249989176415018091420807192182638567116318576472649347015917690530n
|
|
7740
7762
|
], k = g.i32_const(t.alloc([
|
|
7741
7763
|
...Et.bigInt2BytesLE(F(Q[0]), r),
|
|
7742
7764
|
...Et.bigInt2BytesLE(F(Q[1]), r)
|
|
7743
7765
|
])), U = g.i32_const(t.alloc(Et.bigInt2BytesLE(F(R), r))), j = g.i32_const(t.alloc([
|
|
7744
|
-
...Et.bigInt2BytesLE(F(
|
|
7745
|
-
...Et.bigInt2BytesLE(F(
|
|
7746
|
-
])), 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),
|
|
7766
|
+
...Et.bigInt2BytesLE(F(M[0]), r),
|
|
7767
|
+
...Et.bigInt2BytesLE(F(M[1]), r)
|
|
7768
|
+
])), 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), Mt = 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
7769
|
_.addCode(
|
|
7748
7770
|
g.if(
|
|
7749
7771
|
g.call(z + "_isZeroAffine", g.getLocal("p")),
|
|
@@ -7762,8 +7784,8 @@ var Cs = function(t, n) {
|
|
|
7762
7784
|
g.call(P + "_sub", Ot, Ct, et),
|
|
7763
7785
|
g.call(P + "_add", Ot, Ct, Ct),
|
|
7764
7786
|
g.call(P + "_copy", et, Ot),
|
|
7765
|
-
g.call(P + "_sub", ht,
|
|
7766
|
-
g.call(P + "_add", ht,
|
|
7787
|
+
g.call(P + "_sub", ht, Mt, et),
|
|
7788
|
+
g.call(P + "_add", ht, Mt, Mt),
|
|
7767
7789
|
g.call(P + "_copy", et, ht),
|
|
7768
7790
|
g.call(P + "_add", pn, Ln, et),
|
|
7769
7791
|
g.call(P + "_sub", pn, Ln, Ln),
|
|
@@ -7791,7 +7813,7 @@ var Cs = function(t, n) {
|
|
|
7791
7813
|
function G() {
|
|
7792
7814
|
const _ = t.addFunction(T + "_inGroupAffine");
|
|
7793
7815
|
_.addParam("p", "i32"), _.setReturnType("i32");
|
|
7794
|
-
const g = _.getCodeBuilder(), Q = 4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939436n, R = 793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620350n,
|
|
7816
|
+
const g = _.getCodeBuilder(), Q = 4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939436n, R = 793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620350n, M = (h * h - 1n) / 3n, k = g.i32_const(t.alloc(Et.bigInt2BytesLE(F(Q), r))), U = g.i32_const(t.alloc(Et.bigInt2BytesLE(F(R), r))), j = g.i32_const(t.alloc(Et.bigInt2BytesLE(M, 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
7817
|
_.addCode(
|
|
7796
7818
|
g.if(
|
|
7797
7819
|
g.call(T + "_isZeroAffine", g.getLocal("p")),
|
|
@@ -7985,7 +8007,7 @@ var Ss = /* @__PURE__ */ Object.freeze({
|
|
|
7985
8007
|
unstringifyFElements: Ye
|
|
7986
8008
|
});
|
|
7987
8009
|
const Gt = 1 << 30;
|
|
7988
|
-
class
|
|
8010
|
+
class qt {
|
|
7989
8011
|
constructor(t) {
|
|
7990
8012
|
this.buffers = [], this.byteLength = t;
|
|
7991
8013
|
for (let n = 0; n < t; n += Gt) {
|
|
@@ -8003,7 +8025,7 @@ class Mt {
|
|
|
8003
8025
|
const l = b + u > Gt ? Gt - b : u, C = new Uint8Array(this.buffers[r].buffer, this.buffers[r].byteOffset + b, l);
|
|
8004
8026
|
if (l == e)
|
|
8005
8027
|
return C.slice();
|
|
8006
|
-
d || (e <= Gt ? d = new Uint8Array(e) : d = new
|
|
8028
|
+
d || (e <= Gt ? d = new Uint8Array(e) : d = new qt(e)), d.set(C, e - u), u = u - l, r++, b = 0;
|
|
8007
8029
|
}
|
|
8008
8030
|
return d;
|
|
8009
8031
|
}
|
|
@@ -8014,7 +8036,7 @@ class Mt {
|
|
|
8014
8036
|
return;
|
|
8015
8037
|
const i = Math.floor(n / Gt), s = Math.floor((n + e - 1) / Gt);
|
|
8016
8038
|
if (i == s)
|
|
8017
|
-
return t instanceof
|
|
8039
|
+
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
8040
|
let d = i, r = n % Gt, b = e;
|
|
8019
8041
|
for (; b > 0; ) {
|
|
8020
8042
|
const u = r + b > Gt ? Gt - r : b, l = t.slice(e - b, e - b + u);
|
|
@@ -8048,7 +8070,7 @@ function Cn(o, t, n, e) {
|
|
|
8048
8070
|
}
|
|
8049
8071
|
const u = await Promise.all(b);
|
|
8050
8072
|
let l;
|
|
8051
|
-
s instanceof
|
|
8073
|
+
s instanceof qt ? l = new qt(d * e) : l = new Uint8Array(d * e);
|
|
8052
8074
|
let C = 0;
|
|
8053
8075
|
for (let B = 0; B < u.length; B++)
|
|
8054
8076
|
l.set(u[B][0], C), C += u[B][0].byteLength;
|
|
@@ -8057,16 +8079,16 @@ function Cn(o, t, n, e) {
|
|
|
8057
8079
|
}
|
|
8058
8080
|
class jo {
|
|
8059
8081
|
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 =
|
|
8082
|
+
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
8083
|
throw new Error("n8 must be a multiple of 8");
|
|
8062
|
-
this.half =
|
|
8084
|
+
this.half = qn(this.p, Fn), this.nqr = this.two;
|
|
8063
8085
|
let s = this.exp(this.nqr, this.half);
|
|
8064
8086
|
for (; !this.eq(s, this.negone); )
|
|
8065
8087
|
this.nqr = this.add(this.nqr, this.one), s = this.exp(this.nqr, this.half);
|
|
8066
8088
|
this.shift = this.mul(this.nqr, this.nqr), this.shiftInv = this.inv(this.shift), this.s = 0;
|
|
8067
8089
|
let d = _n(this.p, Fn);
|
|
8068
8090
|
for (; !_o(d); )
|
|
8069
|
-
this.s = this.s + 1, d =
|
|
8091
|
+
this.s = this.s + 1, d = qn(d, Fn);
|
|
8070
8092
|
this.w = [], this.w[this.s] = this.exp(this.nqr, d);
|
|
8071
8093
|
for (let r = this.s - 1; r >= 0; r--)
|
|
8072
8094
|
this.w[r] = this.square(this.w[r + 1]);
|
|
@@ -8135,7 +8157,7 @@ class jo {
|
|
|
8135
8157
|
if (t instanceof Uint8Array)
|
|
8136
8158
|
return t;
|
|
8137
8159
|
let e = zt(t, n);
|
|
8138
|
-
|
|
8160
|
+
qi(e) ? (e = zi(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
8161
|
const i = ca(e, this.n8);
|
|
8140
8162
|
return this.toMontgomery(i);
|
|
8141
8163
|
}
|
|
@@ -8211,7 +8233,7 @@ class jo {
|
|
|
8211
8233
|
}
|
|
8212
8234
|
const b = await Promise.all(r);
|
|
8213
8235
|
let u;
|
|
8214
|
-
t instanceof
|
|
8236
|
+
t instanceof qt ? u = new qt(s * i) : u = new Uint8Array(s * i);
|
|
8215
8237
|
let l = 0;
|
|
8216
8238
|
for (let C = 0; C < b.length; C++)
|
|
8217
8239
|
u.set(b[C][0], l), l += b[C][0].byteLength;
|
|
@@ -8729,7 +8751,7 @@ function vs(o) {
|
|
|
8729
8751
|
}
|
|
8730
8752
|
return u;
|
|
8731
8753
|
}
|
|
8732
|
-
const
|
|
8754
|
+
const qe = 25;
|
|
8733
8755
|
class Zo {
|
|
8734
8756
|
constructor() {
|
|
8735
8757
|
this.promise = new Promise((t, n) => {
|
|
@@ -8866,9 +8888,9 @@ if (globalThis?.Blob) {
|
|
|
8866
8888
|
Ze = URL.createObjectURL(t);
|
|
8867
8889
|
} else
|
|
8868
8890
|
Ze = "data:application/javascript;base64," + globalThis.btoa(Jo);
|
|
8869
|
-
async function
|
|
8870
|
-
const n = new
|
|
8871
|
-
n.memory = new WebAssembly.Memory({ initial:
|
|
8891
|
+
async function Ms(o, t) {
|
|
8892
|
+
const n = new qs();
|
|
8893
|
+
n.memory = new WebAssembly.Memory({ initial: qe }), n.u8 = new Uint8Array(n.memory.buffer), n.u32 = new Uint32Array(n.memory.buffer);
|
|
8872
8894
|
const e = await WebAssembly.compile(o.code);
|
|
8873
8895
|
if (n.instance = await WebAssembly.instantiate(e, {
|
|
8874
8896
|
env: {
|
|
@@ -8877,7 +8899,7 @@ async function qs(o, t) {
|
|
|
8877
8899
|
}), 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
8900
|
n.code = o.code, n.taskManager = vs(), await n.taskManager([{
|
|
8879
8901
|
cmd: "INIT",
|
|
8880
|
-
init:
|
|
8902
|
+
init: qe,
|
|
8881
8903
|
code: n.code.slice()
|
|
8882
8904
|
}]), n.concurrency = 1;
|
|
8883
8905
|
else {
|
|
@@ -8891,7 +8913,7 @@ async function qs(o, t) {
|
|
|
8891
8913
|
const b = o.code.slice();
|
|
8892
8914
|
d.push(n.postAction(r, [{
|
|
8893
8915
|
cmd: "INIT",
|
|
8894
|
-
init:
|
|
8916
|
+
init: qe,
|
|
8895
8917
|
code: b
|
|
8896
8918
|
}], [b.buffer]));
|
|
8897
8919
|
}
|
|
@@ -8905,7 +8927,7 @@ async function qs(o, t) {
|
|
|
8905
8927
|
};
|
|
8906
8928
|
}
|
|
8907
8929
|
}
|
|
8908
|
-
class
|
|
8930
|
+
class qs {
|
|
8909
8931
|
constructor() {
|
|
8910
8932
|
this.actionQueue = [], this.oldPFree = 0;
|
|
8911
8933
|
}
|
|
@@ -9016,7 +9038,7 @@ function Qe(o, t) {
|
|
|
9016
9038
|
}
|
|
9017
9039
|
const ot = await Promise.all(T);
|
|
9018
9040
|
let z;
|
|
9019
|
-
s instanceof
|
|
9041
|
+
s instanceof qt ? z = new qt(P * O) : z = new Uint8Array(P * O);
|
|
9020
9042
|
let rt = 0;
|
|
9021
9043
|
for (let F = 0; F < ot.length; F++)
|
|
9022
9044
|
z.set(ot[F][0], rt), rt += ot[F][0].byteLength;
|
|
@@ -9229,7 +9251,7 @@ function Ue(o, t) {
|
|
|
9229
9251
|
}
|
|
9230
9252
|
let X;
|
|
9231
9253
|
l && (X = e.inv(e.e(V)));
|
|
9232
|
-
let
|
|
9254
|
+
let q;
|
|
9233
9255
|
la(u, E);
|
|
9234
9256
|
let y, v = Math.min(1 << P, V), D = V / v;
|
|
9235
9257
|
for (; D < i.concurrency && v >= 16; )
|
|
@@ -9281,16 +9303,16 @@ function Ue(o, t) {
|
|
|
9281
9303
|
y[p] = m[0], y[a] = m[1];
|
|
9282
9304
|
}
|
|
9283
9305
|
}
|
|
9284
|
-
if (u instanceof
|
|
9285
|
-
|
|
9306
|
+
if (u instanceof qt ? q = new qt(V * x) : q = new Uint8Array(V * x), l) {
|
|
9307
|
+
q.set(y[0].slice((v - 1) * x));
|
|
9286
9308
|
let K = x;
|
|
9287
9309
|
for (let ct = D - 1; ct > 0; ct--)
|
|
9288
|
-
|
|
9289
|
-
|
|
9310
|
+
q.set(y[ct], K), K += v * x, delete y[ct];
|
|
9311
|
+
q.set(y[0].slice(0, (v - 1) * x), K), delete y[0];
|
|
9290
9312
|
} else
|
|
9291
9313
|
for (let K = 0; K < D; K++)
|
|
9292
|
-
|
|
9293
|
-
return L ? he(
|
|
9314
|
+
q.set(y[K], v * x * K), delete y[K];
|
|
9315
|
+
return L ? he(q, x) : q;
|
|
9294
9316
|
}
|
|
9295
9317
|
async function d(u, l, C, B, A) {
|
|
9296
9318
|
let O, P;
|
|
@@ -9299,7 +9321,7 @@ function Ue(o, t) {
|
|
|
9299
9321
|
[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
9322
|
const T = await Promise.all(E);
|
|
9301
9323
|
let x;
|
|
9302
|
-
return T[0].byteLength > 1 << 28 ? x = new
|
|
9324
|
+
return T[0].byteLength > 1 << 28 ? x = new qt(T[0].byteLength * 2) : x = new Uint8Array(T[0].byteLength * 2), x.set(T[0]), x.set(T[1], T[0].byteLength), x;
|
|
9303
9325
|
}
|
|
9304
9326
|
async function r(u, l, C, B, A) {
|
|
9305
9327
|
let O, P;
|
|
@@ -9308,7 +9330,7 @@ function Ue(o, t) {
|
|
|
9308
9330
|
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
9331
|
const T = await b(O, P, "fftJoinExtInv", e.one, e.shiftInv, "jacobian", C, B, A);
|
|
9310
9332
|
let x;
|
|
9311
|
-
return T[0].byteLength > 1 << 28 ? x = new
|
|
9333
|
+
return T[0].byteLength > 1 << 28 ? x = new qt(T[0].byteLength * 2) : x = new Uint8Array(T[0].byteLength * 2), x.set(T[0]), x.set(T[1], T[0].byteLength), x;
|
|
9312
9334
|
}
|
|
9313
9335
|
async function b(u, l, C, B, A, O, P, E, T) {
|
|
9314
9336
|
let z, rt, F, f, L, V;
|
|
@@ -9327,7 +9349,7 @@ function Ue(o, t) {
|
|
|
9327
9349
|
throw new Error("Invalid number of points");
|
|
9328
9350
|
let X = Math.floor($ / i.concurrency);
|
|
9329
9351
|
X < 16 && (X = 16), X > 65536 && (X = 65536);
|
|
9330
|
-
const
|
|
9352
|
+
const q = [];
|
|
9331
9353
|
for (let nt = 0; nt < $; nt += X) {
|
|
9332
9354
|
E && E.debug(`${T}: fftJoinExt Start: ${nt}/${$}`);
|
|
9333
9355
|
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);
|
|
@@ -9338,13 +9360,13 @@ function Ue(o, t) {
|
|
|
9338
9360
|
{ var: 2 },
|
|
9339
9361
|
{ var: 3 },
|
|
9340
9362
|
{ 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 }),
|
|
9363
|
+
] }), 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(
|
|
9342
9364
|
i.queueAction(J).then((Bt) => (E && E.debug(`${T}: fftJoinExt End: ${nt}/${$}`), Bt))
|
|
9343
9365
|
);
|
|
9344
9366
|
}
|
|
9345
|
-
const y = await Promise.all(
|
|
9367
|
+
const y = await Promise.all(q);
|
|
9346
9368
|
let v, D;
|
|
9347
|
-
$ * f > 1 << 28 ? (v = new
|
|
9369
|
+
$ * f > 1 << 28 ? (v = new qt($ * f), D = new qt($ * f)) : (v = new Uint8Array($ * f), D = new Uint8Array($ * f));
|
|
9348
9370
|
let it = 0;
|
|
9349
9371
|
for (let nt = 0; nt < y.length; nt++)
|
|
9350
9372
|
v.set(y[nt][0], it), D.set(y[nt][1], it), it += y[nt][0].byteLength;
|
|
@@ -9378,7 +9400,7 @@ function Ue(o, t) {
|
|
|
9378
9400
|
const rt = [];
|
|
9379
9401
|
rt.push(s(T, !0, "jacobian", C, B, A + " t0")), rt.push(s(x, !0, "jacobian", C, B, A + " t1")), [T, x] = await Promise.all(rt);
|
|
9380
9402
|
let F;
|
|
9381
|
-
return T.byteLength > 1 << 28 ? F = new
|
|
9403
|
+
return T.byteLength > 1 << 28 ? F = new qt(T.byteLength * 2) : F = new Uint8Array(T.byteLength * 2), F.set(T), F.set(x, T.byteLength), F;
|
|
9382
9404
|
}, n.fftMix = async function(l) {
|
|
9383
9405
|
const C = n.F.n8 * 3;
|
|
9384
9406
|
let B, A;
|
|
@@ -9423,15 +9445,15 @@ function Ue(o, t) {
|
|
|
9423
9445
|
{ var: 3 }
|
|
9424
9446
|
] }), ct.push({ cmd: "GET", out: 0, var: 0, len: T * C }), ct.push({ cmd: "GET", out: 1, var: 1, len: T * C }), X.push(i.queueAction(ct));
|
|
9425
9447
|
}
|
|
9426
|
-
const
|
|
9448
|
+
const q = await Promise.all(X);
|
|
9427
9449
|
for (let y = 0; y < V; y++)
|
|
9428
9450
|
for (let v = 0; v < $ / 2; v++) {
|
|
9429
|
-
const D = y * $ + v, it = y * $ + v + $ / 2, nt =
|
|
9451
|
+
const D = y * $ + v, it = y * $ + v + $ / 2, nt = q.shift();
|
|
9430
9452
|
rt[D] = nt[0], rt[it] = nt[1];
|
|
9431
9453
|
}
|
|
9432
9454
|
}
|
|
9433
9455
|
let F;
|
|
9434
|
-
l instanceof
|
|
9456
|
+
l instanceof qt ? F = new qt(O * C) : F = new Uint8Array(O * C);
|
|
9435
9457
|
let f = 0;
|
|
9436
9458
|
for (let L = 0; L < E; L++)
|
|
9437
9459
|
F.set(rt[L], f), f += rt[L].byteLength;
|
|
@@ -9456,8 +9478,8 @@ function Ue(o, t) {
|
|
|
9456
9478
|
E <= T * 2 && (T = 1);
|
|
9457
9479
|
const x = E / T, ot = [];
|
|
9458
9480
|
for (let L = 0; L < T; 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:
|
|
9481
|
+
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);
|
|
9482
|
+
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
9483
|
{ var: 0 },
|
|
9462
9484
|
{ var: 1 },
|
|
9463
9485
|
{ val: x },
|
|
@@ -9469,7 +9491,7 @@ function Ue(o, t) {
|
|
|
9469
9491
|
}
|
|
9470
9492
|
const z = await Promise.all(ot);
|
|
9471
9493
|
let rt, F;
|
|
9472
|
-
l instanceof
|
|
9494
|
+
l instanceof qt ? (rt = new qt(E * O), F = new qt(E * O)) : (rt = new Uint8Array(E * O), F = new Uint8Array(E * O));
|
|
9473
9495
|
let f = 0;
|
|
9474
9496
|
for (let L = 0; L < z.length; L++)
|
|
9475
9497
|
rt.set(z[L][0], f), F.set(z[L][1], f), f += z[L][0].byteLength;
|
|
@@ -9506,7 +9528,7 @@ function Ue(o, t) {
|
|
|
9506
9528
|
}
|
|
9507
9529
|
const ot = await Promise.all(x);
|
|
9508
9530
|
let z;
|
|
9509
|
-
l instanceof
|
|
9531
|
+
l instanceof qt ? z = new qt(E * A) : z = new Uint8Array(E * A);
|
|
9510
9532
|
let rt = 0;
|
|
9511
9533
|
for (let F = ot.length - 1; F >= 0; F--)
|
|
9512
9534
|
z.set(ot[F][0], rt), rt += ot[F][0].byteLength;
|
|
@@ -9514,7 +9536,7 @@ function Ue(o, t) {
|
|
|
9514
9536
|
};
|
|
9515
9537
|
}
|
|
9516
9538
|
async function ra(o) {
|
|
9517
|
-
const t = await
|
|
9539
|
+
const t = await Ms(o.wasm, o.singleThread), n = {};
|
|
9518
9540
|
return n.q = zt(o.wasm.q.toString()), n.r = zt(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, Qe(n, "G1"), Qe(n, "G2"), Qe(n, "Fr"), Xo(n, "G1"), Xo(n, "G2"), Ue(n, "G1"), Ue(n, "G2"), Ue(n, "Fr"), Qs(n), n.array2buffer = function(e, i) {
|
|
9519
9541
|
const s = new Uint8Array(i * e.length);
|
|
9520
9542
|
for (let d = 0; d < e.length; d++)
|
|
@@ -10777,7 +10799,7 @@ async function Bn(o, t, n, e, i) {
|
|
|
10777
10799
|
if (e = typeof e > "u" ? 0 : e, i = typeof i > "u" ? t[n][0].size - e : i, e + i > t[n][0].size)
|
|
10778
10800
|
throw new Error("Reading out of the range of the section");
|
|
10779
10801
|
let s;
|
|
10780
|
-
return i < 1 << 30 ? s = new Uint8Array(i) : s = new
|
|
10802
|
+
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
10803
|
}
|
|
10782
10804
|
Qt.e("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001", 16);
|
|
10783
10805
|
Qt.e("21888242871839275222246405745257275088548364400416034343698204186575808495617");
|
|
@@ -10838,9 +10860,9 @@ var sl = {
|
|
|
10838
10860
|
toString: al,
|
|
10839
10861
|
write: cl
|
|
10840
10862
|
};
|
|
10841
|
-
const
|
|
10842
|
-
for (let o = 0; o <
|
|
10843
|
-
xn[
|
|
10863
|
+
const Mn = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", xn = new Uint8Array(256);
|
|
10864
|
+
for (let o = 0; o < Mn.length; o++)
|
|
10865
|
+
xn[Mn.charCodeAt(o)] = o;
|
|
10844
10866
|
xn[
|
|
10845
10867
|
/* - */
|
|
10846
10868
|
45
|
|
@@ -10857,7 +10879,7 @@ function ll(o) {
|
|
|
10857
10879
|
const t = o.byteLength;
|
|
10858
10880
|
let n = "";
|
|
10859
10881
|
for (let e = 0; e < t; e += 3)
|
|
10860
|
-
n +=
|
|
10882
|
+
n += Mn[o[e] >> 2] + Mn[(o[e] & 3) << 4 | o[e + 1] >> 4] + Mn[(o[e + 1] & 15) << 2 | o[e + 2] >> 6] + Mn[o[e + 2] & 63];
|
|
10861
10883
|
return t % 3 === 2 ? n = n.substring(0, n.length - 1) + "=" : t % 3 === 1 && (n = n.substring(0, n.length - 2) + "=="), n;
|
|
10862
10884
|
}
|
|
10863
10885
|
function rl(o, t, n = 0, e = Fa(t)) {
|
|
@@ -11201,7 +11223,7 @@ var Ll = {
|
|
|
11201
11223
|
/* first */
|
|
11202
11224
|
);
|
|
11203
11225
|
}
|
|
11204
|
-
function
|
|
11226
|
+
function q(c, w, I, h) {
|
|
11205
11227
|
return $(
|
|
11206
11228
|
c,
|
|
11207
11229
|
w,
|
|
@@ -11288,7 +11310,7 @@ var Ll = {
|
|
|
11288
11310
|
from: z,
|
|
11289
11311
|
includes: V,
|
|
11290
11312
|
indexOf: X,
|
|
11291
|
-
lastIndexOf:
|
|
11313
|
+
lastIndexOf: q,
|
|
11292
11314
|
swap16: v,
|
|
11293
11315
|
swap32: D,
|
|
11294
11316
|
swap64: it,
|
|
@@ -11450,7 +11472,7 @@ async function va(o, t, n, e) {
|
|
|
11450
11472
|
n && n.debug("Reading Coeffs");
|
|
11451
11473
|
const E = await Bn(r, b, 4);
|
|
11452
11474
|
n && n.debug("Building ABC");
|
|
11453
|
-
const [T, x, ot] = await Ol(l, u, P, E, n), z = O == C.s ? l.Fr.shift : l.Fr.w[O + 1], rt = await C.ifft(T, "", "", n, "IFFT_A"), F = await C.batchApplyKey(rt, C.e(1), z), f = await C.fft(F, "", "", n, "FFT_A"), L = await C.ifft(x, "", "", n, "IFFT_B"), V = await C.batchApplyKey(L, C.e(1), z), $ = await C.fft(V, "", "", n, "FFT_B"), X = await C.ifft(ot, "", "", n, "IFFT_C"),
|
|
11475
|
+
const [T, x, ot] = await Ol(l, u, P, E, n), z = O == C.s ? l.Fr.shift : l.Fr.w[O + 1], rt = await C.ifft(T, "", "", n, "IFFT_A"), F = await C.batchApplyKey(rt, C.e(1), z), f = await C.fft(F, "", "", n, "FFT_A"), L = await C.ifft(x, "", "", n, "IFFT_B"), V = await C.batchApplyKey(L, C.e(1), z), $ = await C.fft(V, "", "", n, "FFT_B"), X = await C.ifft(ot, "", "", n, "IFFT_C"), q = await C.batchApplyKey(X, C.e(1), z), y = await C.fft(q, "", "", n, "FFT_C");
|
|
11454
11476
|
n && n.debug("Join ABC");
|
|
11455
11477
|
const v = await vl(l, u, f, $, y, n);
|
|
11456
11478
|
let D = {};
|
|
@@ -11474,7 +11496,7 @@ async function va(o, t, n, e) {
|
|
|
11474
11496
|
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
11497
|
}
|
|
11476
11498
|
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
|
|
11499
|
+
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
11500
|
for (let B = 0; B < r; B++) {
|
|
11479
11501
|
i && B % 1e6 == 0 && i.debug(`QAP AB: ${B}/${r}`);
|
|
11480
11502
|
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), T = O.getUint32(8, !0), x = A.slice(12, 12 + s);
|
|
@@ -11515,7 +11537,7 @@ async function vl(o, t, n, e, i, s) {
|
|
|
11515
11537
|
}
|
|
11516
11538
|
const l = await Promise.all(u);
|
|
11517
11539
|
let C;
|
|
11518
|
-
n instanceof
|
|
11540
|
+
n instanceof qt ? C = new qt(n.byteLength) : C = new Uint8Array(n.byteLength);
|
|
11519
11541
|
let B = 0;
|
|
11520
11542
|
for (let A = 0; A < l.length; A++)
|
|
11521
11543
|
C.set(l[A][0], B), B += l[A][0].byteLength;
|
|
@@ -11536,7 +11558,7 @@ function Pl(o, t) {
|
|
|
11536
11558
|
let n = BigInt(o) % t;
|
|
11537
11559
|
return n < 0 && (n += t), n;
|
|
11538
11560
|
}
|
|
11539
|
-
function
|
|
11561
|
+
function Ma(o) {
|
|
11540
11562
|
const t = BigInt(2) ** BigInt(64);
|
|
11541
11563
|
let n = BigInt("0xCBF29CE484222325");
|
|
11542
11564
|
for (let s = 0; s < o.length; s++)
|
|
@@ -11544,7 +11566,7 @@ function qa(o) {
|
|
|
11544
11566
|
let e = n.toString(16), i = 16 - e.length;
|
|
11545
11567
|
return e = "0".repeat(i).concat(e), e;
|
|
11546
11568
|
}
|
|
11547
|
-
function
|
|
11569
|
+
function Ml(o, t) {
|
|
11548
11570
|
const n = [];
|
|
11549
11571
|
let e = BigInt(o);
|
|
11550
11572
|
const i = BigInt(4294967296);
|
|
@@ -11557,7 +11579,7 @@ function ql(o, t) {
|
|
|
11557
11579
|
}
|
|
11558
11580
|
return n;
|
|
11559
11581
|
}
|
|
11560
|
-
async function
|
|
11582
|
+
async function ql(o, t) {
|
|
11561
11583
|
let n, e, i;
|
|
11562
11584
|
t = t || {};
|
|
11563
11585
|
let s = 1, d = 0, r = 0, b = !1;
|
|
@@ -11673,7 +11695,7 @@ class Ql {
|
|
|
11673
11695
|
this.instance.exports.init(this.sanityCheck || n ? 1 : 0);
|
|
11674
11696
|
const e = this.allocInt(), i = this.allocFr();
|
|
11675
11697
|
Object.keys(t).forEach((d) => {
|
|
11676
|
-
const r =
|
|
11698
|
+
const r = Ma(d), b = parseInt(r.slice(0, 8), 16), u = parseInt(r.slice(8, 16), 16);
|
|
11677
11699
|
try {
|
|
11678
11700
|
this.instance.exports.getSignalOffset32(e, 0, b, u);
|
|
11679
11701
|
} catch {
|
|
@@ -11762,7 +11784,7 @@ class Ul {
|
|
|
11762
11784
|
const e = Object.keys(t);
|
|
11763
11785
|
let i = 0;
|
|
11764
11786
|
if (e.forEach((s) => {
|
|
11765
|
-
const d =
|
|
11787
|
+
const d = Ma(s), r = parseInt(d.slice(0, 8), 16), b = parseInt(d.slice(8, 16), 16), u = Pa(t[s]);
|
|
11766
11788
|
if (typeof this.instance.exports.getInputSignalSize == "function") {
|
|
11767
11789
|
let l = this.instance.exports.getInputSignalSize(r, b);
|
|
11768
11790
|
if (l < 0)
|
|
@@ -11776,7 +11798,7 @@ class Ul {
|
|
|
11776
11798
|
`);
|
|
11777
11799
|
}
|
|
11778
11800
|
for (let l = 0; l < u.length; l++) {
|
|
11779
|
-
const C =
|
|
11801
|
+
const C = Ml(Pl(u[l], this.prime), this.n32);
|
|
11780
11802
|
for (let B = 0; B < this.n32; B++)
|
|
11781
11803
|
this.instance.exports.writeSharedRWMemory(B, C[this.n32 - 1 - B]);
|
|
11782
11804
|
try {
|
|
@@ -11824,7 +11846,7 @@ const { unstringifyBigInts: Tl } = ne;
|
|
|
11824
11846
|
async function zl(o, t, n, e) {
|
|
11825
11847
|
const i = Tl(o), s = await ma(t), d = await s.read(s.totalSize);
|
|
11826
11848
|
await s.close();
|
|
11827
|
-
const r = await
|
|
11849
|
+
const r = await ql(d, e);
|
|
11828
11850
|
if (r.circom_version() === 1) {
|
|
11829
11851
|
const b = await r.calculateBinWitness(i), u = await Ws(n, "wtns", 2, 2);
|
|
11830
11852
|
await xl(u, b, r.prime), await u.close();
|
|
@@ -12016,7 +12038,7 @@ var Hl = { exports: {} };
|
|
|
12016
12038
|
}, c.update = function(w, I, h, S) {
|
|
12017
12039
|
return c.create(I, h, S).update(w);
|
|
12018
12040
|
}, L(c, F, p, a);
|
|
12019
|
-
},
|
|
12041
|
+
}, q = function(p, a) {
|
|
12020
12042
|
var m = ot[p], c = f(p, a, "hex");
|
|
12021
12043
|
return c.create = function(w, I, h) {
|
|
12022
12044
|
return new Bt(p, a, I).bytepad(["KMAC", h], m).bytepad([w], m);
|
|
@@ -12028,7 +12050,7 @@ var Hl = { exports: {} };
|
|
|
12028
12050
|
{ name: "sha3", padding: A, bits: E, createMethod: V },
|
|
12029
12051
|
{ name: "shake", padding: l, bits: T, createMethod: $ },
|
|
12030
12052
|
{ name: "cshake", padding: C, bits: T, createMethod: X },
|
|
12031
|
-
{ name: "kmac", padding: C, bits: T, createMethod:
|
|
12053
|
+
{ name: "kmac", padding: C, bits: T, createMethod: q }
|
|
12032
12054
|
], v = {}, D = [], it = 0; it < y.length; ++it)
|
|
12033
12055
|
for (var nt = y[it], K = nt.bits, ct = 0; ct < K.length; ++ct) {
|
|
12034
12056
|
var J = nt.name + "_" + K[ct];
|
|
@@ -12154,9 +12176,9 @@ var Hl = { exports: {} };
|
|
|
12154
12176
|
return this.encode(this.outputBits, !0), At.prototype.finalize.call(this);
|
|
12155
12177
|
};
|
|
12156
12178
|
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, Tt, Nt, Kt, en, Zt, G, _, g, Q, R,
|
|
12179
|
+
var a, m, c, w, I, h, S, W, N, at, It, ut, Lt, St, gt, dt, yt, vt, Ut, Vt, Dt, jt, Tt, Nt, Kt, en, Zt, G, _, g, Q, R, M, k, U, j, Y, Z, H, et, ft, _t, lt, bt, mt, Ot, Ct, wt, ht, Mt, Ht, Wt, On, pn, Ln, vn, An, bn, Pn, ln, on, wn, ce;
|
|
12158
12180
|
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, Q = 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,
|
|
12181
|
+
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, Q = 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, Mt = p[34] << 15 | p[35] >>> 17, Ht = p[35] << 15 | p[34] >>> 17, R = p[45] << 29 | p[44] >>> 3, M = 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, Tt = 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 ^ ~_ & Q, p[22] = j ^ ~Z & et, p[23] = Y ^ ~H & ft, p[32] = Ot ^ ~wt & Mt, p[33] = Ct ^ ~ht & Ht, p[42] = vn ^ ~bn & ln, p[43] = An ^ ~Pn & on, p[4] = vt ^ ~Vt & jt, p[5] = Ut ^ ~Dt & Tt, p[14] = G ^ ~g & R, p[15] = _ ^ ~Q & M, p[24] = Z ^ ~et & _t, p[25] = H ^ ~ft & lt, p[34] = wt ^ ~Mt & Wt, p[35] = ht ^ ~Ht & On, p[44] = bn ^ ~ln & wn, p[45] = Pn ^ ~on & ce, p[6] = Vt ^ ~jt & St, p[7] = Dt ^ ~Tt & gt, p[16] = g ^ ~R & Nt, p[17] = Q ^ ~M & Kt, p[26] = et ^ ~_t & k, p[27] = ft ^ ~lt & U, p[36] = Mt ^ ~Wt & bt, p[37] = Ht ^ ~On & mt, p[46] = ln ^ ~wn & pn, p[47] = on ^ ~ce & Ln, p[8] = jt ^ ~St & dt, p[9] = Tt ^ ~gt & yt, p[18] = R ^ ~Nt & en, p[19] = M ^ ~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
12182
|
};
|
|
12161
12183
|
if (r)
|
|
12162
12184
|
o.exports = v;
|
|
@@ -12165,7 +12187,7 @@ var Hl = { exports: {} };
|
|
|
12165
12187
|
i[D[it]] = v[D[it]];
|
|
12166
12188
|
})();
|
|
12167
12189
|
})(Hl);
|
|
12168
|
-
function
|
|
12190
|
+
function qa(o, t) {
|
|
12169
12191
|
return function() {
|
|
12170
12192
|
return o.apply(t, arguments);
|
|
12171
12193
|
};
|
|
@@ -12226,7 +12248,7 @@ function io() {
|
|
|
12226
12248
|
return t;
|
|
12227
12249
|
}
|
|
12228
12250
|
const ar = (o, t, n, { allOwnKeys: e } = {}) => (ie(t, (i, s) => {
|
|
12229
|
-
n && nn(i) ? o[s] =
|
|
12251
|
+
n && nn(i) ? o[s] = qa(i, n) : o[s] = i;
|
|
12230
12252
|
}, { allOwnKeys: e }), o), cr = (o) => (o.charCodeAt(0) === 65279 && (o = o.slice(1)), o), sr = (o, t, n, e) => {
|
|
12231
12253
|
o.prototype = Object.create(t.prototype, e), o.prototype.constructor = o, Object.defineProperty(o, "super", {
|
|
12232
12254
|
value: t.prototype
|
|
@@ -12622,7 +12644,7 @@ var ja = {
|
|
|
12622
12644
|
silentJSONParsing: !0,
|
|
12623
12645
|
forcedJSONParsing: !0,
|
|
12624
12646
|
clarifyTimeoutError: !1
|
|
12625
|
-
}, Or = typeof URLSearchParams < "u" ? URLSearchParams : wo, vr = typeof FormData < "u" ? FormData : null, Pr = typeof Blob < "u" ? Blob : null,
|
|
12647
|
+
}, Or = typeof URLSearchParams < "u" ? URLSearchParams : wo, vr = typeof FormData < "u" ? FormData : null, Pr = typeof Blob < "u" ? Blob : null, Mr = {
|
|
12626
12648
|
isBrowser: !0,
|
|
12627
12649
|
classes: {
|
|
12628
12650
|
URLSearchParams: Or,
|
|
@@ -12631,16 +12653,16 @@ var ja = {
|
|
|
12631
12653
|
},
|
|
12632
12654
|
protocols: ["http", "https", "file", "blob", "url", "data"]
|
|
12633
12655
|
};
|
|
12634
|
-
const $a = typeof window < "u" && typeof document < "u",
|
|
12656
|
+
const $a = typeof window < "u" && typeof document < "u", qr = ((o) => $a && ["ReactNative", "NativeScript", "NS"].indexOf(o) < 0)(typeof navigator < "u" && navigator.product), Qr = typeof WorkerGlobalScope < "u" && // eslint-disable-next-line no-undef
|
|
12635
12657
|
self instanceof WorkerGlobalScope && typeof self.importScripts == "function";
|
|
12636
12658
|
var Ur = /* @__PURE__ */ Object.freeze({
|
|
12637
12659
|
__proto__: null,
|
|
12638
12660
|
hasBrowserEnv: $a,
|
|
12639
|
-
hasStandardBrowserEnv:
|
|
12661
|
+
hasStandardBrowserEnv: qr,
|
|
12640
12662
|
hasStandardBrowserWebWorkerEnv: Qr
|
|
12641
12663
|
}), cn = {
|
|
12642
12664
|
...Ur,
|
|
12643
|
-
...
|
|
12665
|
+
...Mr
|
|
12644
12666
|
};
|
|
12645
12667
|
function Tr(o, t) {
|
|
12646
12668
|
return me(o, new cn.classes.URLSearchParams(), Object.assign({
|
|
@@ -13597,7 +13619,7 @@ Object.entries(lo).forEach(([o, t]) => {
|
|
|
13597
13619
|
});
|
|
13598
13620
|
var sd = lo;
|
|
13599
13621
|
function tc(o) {
|
|
13600
|
-
const t = new _e(o), n =
|
|
13622
|
+
const t = new _e(o), n = qa(_e.prototype.request, t);
|
|
13601
13623
|
return tt.extend(n, _e.prototype, t, { allOwnKeys: !0 }), tt.extend(n, t, null, { allOwnKeys: !0 }), n.create = function(i) {
|
|
13602
13624
|
return tc(zn(o, i));
|
|
13603
13625
|
}, n;
|