@zubari/sdk 0.1.4 → 0.1.6
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/dist/{WalletManager-CYJNiww6.d.ts → WalletManager-YnFArqAt.d.ts} +22 -17
- package/dist/{WalletManager-Dmmcbtiw.d.mts → WalletManager-zKc_xew_.d.mts} +22 -17
- package/dist/{index-OxzgPoRG.d.ts → index-CLssrNf2.d.ts} +1 -1
- package/dist/{index-poGbMJzn.d.mts → index-DXTHGOnP.d.mts} +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +502 -2902
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +499 -2906
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +2 -2
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +421 -2849
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +423 -2851
- package/dist/react/index.mjs.map +1 -1
- package/dist/services/index.d.mts +290 -55
- package/dist/services/index.d.ts +290 -55
- package/dist/services/index.js +340 -2744
- package/dist/services/index.js.map +1 -1
- package/dist/services/index.mjs +338 -2743
- package/dist/services/index.mjs.map +1 -1
- package/dist/wallet/index.d.mts +2 -2
- package/dist/wallet/index.d.ts +2 -2
- package/dist/wallet/index.js +420 -2850
- package/dist/wallet/index.js.map +1 -1
- package/dist/wallet/index.mjs +422 -2852
- package/dist/wallet/index.mjs.map +1 -1
- package/package.json +9 -5
- package/dist/TransactionService-CxwB1kpN.d.mts +0 -205
- package/dist/TransactionService-DdL6H6M-.d.ts +0 -205
package/dist/services/index.js
CHANGED
|
@@ -8,2460 +8,11 @@ var base = require('@scure/base');
|
|
|
8
8
|
var sha256 = require('@noble/hashes/sha256');
|
|
9
9
|
var ripemd160 = require('@noble/hashes/ripemd160');
|
|
10
10
|
|
|
11
|
-
var __create = Object.create;
|
|
12
11
|
var __defProp = Object.defineProperty;
|
|
13
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
14
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
15
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
16
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
17
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
18
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
19
|
-
}) : x)(function(x) {
|
|
20
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
21
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
22
|
-
});
|
|
23
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
24
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
25
|
-
};
|
|
26
12
|
var __export = (target, all) => {
|
|
27
13
|
for (var name in all)
|
|
28
14
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
29
15
|
};
|
|
30
|
-
var __copyProps = (to, from, except, desc) => {
|
|
31
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
32
|
-
for (let key of __getOwnPropNames(from))
|
|
33
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
34
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
35
|
-
}
|
|
36
|
-
return to;
|
|
37
|
-
};
|
|
38
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
39
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
40
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
41
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
42
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
43
|
-
!mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
44
|
-
mod
|
|
45
|
-
));
|
|
46
|
-
|
|
47
|
-
// ../../node_modules/tweetnacl/nacl-fast.js
|
|
48
|
-
var require_nacl_fast = __commonJS({
|
|
49
|
-
"../../node_modules/tweetnacl/nacl-fast.js"(exports$1, module) {
|
|
50
|
-
(function(nacl) {
|
|
51
|
-
var gf = function(init) {
|
|
52
|
-
var i, r = new Float64Array(16);
|
|
53
|
-
if (init) for (i = 0; i < init.length; i++) r[i] = init[i];
|
|
54
|
-
return r;
|
|
55
|
-
};
|
|
56
|
-
var randombytes = function() {
|
|
57
|
-
throw new Error("no PRNG");
|
|
58
|
-
};
|
|
59
|
-
var _0 = new Uint8Array(16);
|
|
60
|
-
var _9 = new Uint8Array(32);
|
|
61
|
-
_9[0] = 9;
|
|
62
|
-
var gf0 = gf(), gf1 = gf([1]), _121665 = gf([56129, 1]), D = gf([30883, 4953, 19914, 30187, 55467, 16705, 2637, 112, 59544, 30585, 16505, 36039, 65139, 11119, 27886, 20995]), D2 = gf([61785, 9906, 39828, 60374, 45398, 33411, 5274, 224, 53552, 61171, 33010, 6542, 64743, 22239, 55772, 9222]), X = gf([54554, 36645, 11616, 51542, 42930, 38181, 51040, 26924, 56412, 64982, 57905, 49316, 21502, 52590, 14035, 8553]), Y = gf([26200, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214]), I = gf([41136, 18958, 6951, 50414, 58488, 44335, 6150, 12099, 55207, 15867, 153, 11085, 57099, 20417, 9344, 11139]);
|
|
63
|
-
function ts64(x, i, h, l) {
|
|
64
|
-
x[i] = h >> 24 & 255;
|
|
65
|
-
x[i + 1] = h >> 16 & 255;
|
|
66
|
-
x[i + 2] = h >> 8 & 255;
|
|
67
|
-
x[i + 3] = h & 255;
|
|
68
|
-
x[i + 4] = l >> 24 & 255;
|
|
69
|
-
x[i + 5] = l >> 16 & 255;
|
|
70
|
-
x[i + 6] = l >> 8 & 255;
|
|
71
|
-
x[i + 7] = l & 255;
|
|
72
|
-
}
|
|
73
|
-
function vn(x, xi, y, yi, n) {
|
|
74
|
-
var i, d = 0;
|
|
75
|
-
for (i = 0; i < n; i++) d |= x[xi + i] ^ y[yi + i];
|
|
76
|
-
return (1 & d - 1 >>> 8) - 1;
|
|
77
|
-
}
|
|
78
|
-
function crypto_verify_16(x, xi, y, yi) {
|
|
79
|
-
return vn(x, xi, y, yi, 16);
|
|
80
|
-
}
|
|
81
|
-
function crypto_verify_32(x, xi, y, yi) {
|
|
82
|
-
return vn(x, xi, y, yi, 32);
|
|
83
|
-
}
|
|
84
|
-
function core_salsa20(o, p, k, c) {
|
|
85
|
-
var j0 = c[0] & 255 | (c[1] & 255) << 8 | (c[2] & 255) << 16 | (c[3] & 255) << 24, j1 = k[0] & 255 | (k[1] & 255) << 8 | (k[2] & 255) << 16 | (k[3] & 255) << 24, j2 = k[4] & 255 | (k[5] & 255) << 8 | (k[6] & 255) << 16 | (k[7] & 255) << 24, j3 = k[8] & 255 | (k[9] & 255) << 8 | (k[10] & 255) << 16 | (k[11] & 255) << 24, j4 = k[12] & 255 | (k[13] & 255) << 8 | (k[14] & 255) << 16 | (k[15] & 255) << 24, j5 = c[4] & 255 | (c[5] & 255) << 8 | (c[6] & 255) << 16 | (c[7] & 255) << 24, j6 = p[0] & 255 | (p[1] & 255) << 8 | (p[2] & 255) << 16 | (p[3] & 255) << 24, j7 = p[4] & 255 | (p[5] & 255) << 8 | (p[6] & 255) << 16 | (p[7] & 255) << 24, j8 = p[8] & 255 | (p[9] & 255) << 8 | (p[10] & 255) << 16 | (p[11] & 255) << 24, j9 = p[12] & 255 | (p[13] & 255) << 8 | (p[14] & 255) << 16 | (p[15] & 255) << 24, j10 = c[8] & 255 | (c[9] & 255) << 8 | (c[10] & 255) << 16 | (c[11] & 255) << 24, j11 = k[16] & 255 | (k[17] & 255) << 8 | (k[18] & 255) << 16 | (k[19] & 255) << 24, j12 = k[20] & 255 | (k[21] & 255) << 8 | (k[22] & 255) << 16 | (k[23] & 255) << 24, j13 = k[24] & 255 | (k[25] & 255) << 8 | (k[26] & 255) << 16 | (k[27] & 255) << 24, j14 = k[28] & 255 | (k[29] & 255) << 8 | (k[30] & 255) << 16 | (k[31] & 255) << 24, j15 = c[12] & 255 | (c[13] & 255) << 8 | (c[14] & 255) << 16 | (c[15] & 255) << 24;
|
|
86
|
-
var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7, x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14, x15 = j15, u;
|
|
87
|
-
for (var i = 0; i < 20; i += 2) {
|
|
88
|
-
u = x0 + x12 | 0;
|
|
89
|
-
x4 ^= u << 7 | u >>> 32 - 7;
|
|
90
|
-
u = x4 + x0 | 0;
|
|
91
|
-
x8 ^= u << 9 | u >>> 32 - 9;
|
|
92
|
-
u = x8 + x4 | 0;
|
|
93
|
-
x12 ^= u << 13 | u >>> 32 - 13;
|
|
94
|
-
u = x12 + x8 | 0;
|
|
95
|
-
x0 ^= u << 18 | u >>> 32 - 18;
|
|
96
|
-
u = x5 + x1 | 0;
|
|
97
|
-
x9 ^= u << 7 | u >>> 32 - 7;
|
|
98
|
-
u = x9 + x5 | 0;
|
|
99
|
-
x13 ^= u << 9 | u >>> 32 - 9;
|
|
100
|
-
u = x13 + x9 | 0;
|
|
101
|
-
x1 ^= u << 13 | u >>> 32 - 13;
|
|
102
|
-
u = x1 + x13 | 0;
|
|
103
|
-
x5 ^= u << 18 | u >>> 32 - 18;
|
|
104
|
-
u = x10 + x6 | 0;
|
|
105
|
-
x14 ^= u << 7 | u >>> 32 - 7;
|
|
106
|
-
u = x14 + x10 | 0;
|
|
107
|
-
x2 ^= u << 9 | u >>> 32 - 9;
|
|
108
|
-
u = x2 + x14 | 0;
|
|
109
|
-
x6 ^= u << 13 | u >>> 32 - 13;
|
|
110
|
-
u = x6 + x2 | 0;
|
|
111
|
-
x10 ^= u << 18 | u >>> 32 - 18;
|
|
112
|
-
u = x15 + x11 | 0;
|
|
113
|
-
x3 ^= u << 7 | u >>> 32 - 7;
|
|
114
|
-
u = x3 + x15 | 0;
|
|
115
|
-
x7 ^= u << 9 | u >>> 32 - 9;
|
|
116
|
-
u = x7 + x3 | 0;
|
|
117
|
-
x11 ^= u << 13 | u >>> 32 - 13;
|
|
118
|
-
u = x11 + x7 | 0;
|
|
119
|
-
x15 ^= u << 18 | u >>> 32 - 18;
|
|
120
|
-
u = x0 + x3 | 0;
|
|
121
|
-
x1 ^= u << 7 | u >>> 32 - 7;
|
|
122
|
-
u = x1 + x0 | 0;
|
|
123
|
-
x2 ^= u << 9 | u >>> 32 - 9;
|
|
124
|
-
u = x2 + x1 | 0;
|
|
125
|
-
x3 ^= u << 13 | u >>> 32 - 13;
|
|
126
|
-
u = x3 + x2 | 0;
|
|
127
|
-
x0 ^= u << 18 | u >>> 32 - 18;
|
|
128
|
-
u = x5 + x4 | 0;
|
|
129
|
-
x6 ^= u << 7 | u >>> 32 - 7;
|
|
130
|
-
u = x6 + x5 | 0;
|
|
131
|
-
x7 ^= u << 9 | u >>> 32 - 9;
|
|
132
|
-
u = x7 + x6 | 0;
|
|
133
|
-
x4 ^= u << 13 | u >>> 32 - 13;
|
|
134
|
-
u = x4 + x7 | 0;
|
|
135
|
-
x5 ^= u << 18 | u >>> 32 - 18;
|
|
136
|
-
u = x10 + x9 | 0;
|
|
137
|
-
x11 ^= u << 7 | u >>> 32 - 7;
|
|
138
|
-
u = x11 + x10 | 0;
|
|
139
|
-
x8 ^= u << 9 | u >>> 32 - 9;
|
|
140
|
-
u = x8 + x11 | 0;
|
|
141
|
-
x9 ^= u << 13 | u >>> 32 - 13;
|
|
142
|
-
u = x9 + x8 | 0;
|
|
143
|
-
x10 ^= u << 18 | u >>> 32 - 18;
|
|
144
|
-
u = x15 + x14 | 0;
|
|
145
|
-
x12 ^= u << 7 | u >>> 32 - 7;
|
|
146
|
-
u = x12 + x15 | 0;
|
|
147
|
-
x13 ^= u << 9 | u >>> 32 - 9;
|
|
148
|
-
u = x13 + x12 | 0;
|
|
149
|
-
x14 ^= u << 13 | u >>> 32 - 13;
|
|
150
|
-
u = x14 + x13 | 0;
|
|
151
|
-
x15 ^= u << 18 | u >>> 32 - 18;
|
|
152
|
-
}
|
|
153
|
-
x0 = x0 + j0 | 0;
|
|
154
|
-
x1 = x1 + j1 | 0;
|
|
155
|
-
x2 = x2 + j2 | 0;
|
|
156
|
-
x3 = x3 + j3 | 0;
|
|
157
|
-
x4 = x4 + j4 | 0;
|
|
158
|
-
x5 = x5 + j5 | 0;
|
|
159
|
-
x6 = x6 + j6 | 0;
|
|
160
|
-
x7 = x7 + j7 | 0;
|
|
161
|
-
x8 = x8 + j8 | 0;
|
|
162
|
-
x9 = x9 + j9 | 0;
|
|
163
|
-
x10 = x10 + j10 | 0;
|
|
164
|
-
x11 = x11 + j11 | 0;
|
|
165
|
-
x12 = x12 + j12 | 0;
|
|
166
|
-
x13 = x13 + j13 | 0;
|
|
167
|
-
x14 = x14 + j14 | 0;
|
|
168
|
-
x15 = x15 + j15 | 0;
|
|
169
|
-
o[0] = x0 >>> 0 & 255;
|
|
170
|
-
o[1] = x0 >>> 8 & 255;
|
|
171
|
-
o[2] = x0 >>> 16 & 255;
|
|
172
|
-
o[3] = x0 >>> 24 & 255;
|
|
173
|
-
o[4] = x1 >>> 0 & 255;
|
|
174
|
-
o[5] = x1 >>> 8 & 255;
|
|
175
|
-
o[6] = x1 >>> 16 & 255;
|
|
176
|
-
o[7] = x1 >>> 24 & 255;
|
|
177
|
-
o[8] = x2 >>> 0 & 255;
|
|
178
|
-
o[9] = x2 >>> 8 & 255;
|
|
179
|
-
o[10] = x2 >>> 16 & 255;
|
|
180
|
-
o[11] = x2 >>> 24 & 255;
|
|
181
|
-
o[12] = x3 >>> 0 & 255;
|
|
182
|
-
o[13] = x3 >>> 8 & 255;
|
|
183
|
-
o[14] = x3 >>> 16 & 255;
|
|
184
|
-
o[15] = x3 >>> 24 & 255;
|
|
185
|
-
o[16] = x4 >>> 0 & 255;
|
|
186
|
-
o[17] = x4 >>> 8 & 255;
|
|
187
|
-
o[18] = x4 >>> 16 & 255;
|
|
188
|
-
o[19] = x4 >>> 24 & 255;
|
|
189
|
-
o[20] = x5 >>> 0 & 255;
|
|
190
|
-
o[21] = x5 >>> 8 & 255;
|
|
191
|
-
o[22] = x5 >>> 16 & 255;
|
|
192
|
-
o[23] = x5 >>> 24 & 255;
|
|
193
|
-
o[24] = x6 >>> 0 & 255;
|
|
194
|
-
o[25] = x6 >>> 8 & 255;
|
|
195
|
-
o[26] = x6 >>> 16 & 255;
|
|
196
|
-
o[27] = x6 >>> 24 & 255;
|
|
197
|
-
o[28] = x7 >>> 0 & 255;
|
|
198
|
-
o[29] = x7 >>> 8 & 255;
|
|
199
|
-
o[30] = x7 >>> 16 & 255;
|
|
200
|
-
o[31] = x7 >>> 24 & 255;
|
|
201
|
-
o[32] = x8 >>> 0 & 255;
|
|
202
|
-
o[33] = x8 >>> 8 & 255;
|
|
203
|
-
o[34] = x8 >>> 16 & 255;
|
|
204
|
-
o[35] = x8 >>> 24 & 255;
|
|
205
|
-
o[36] = x9 >>> 0 & 255;
|
|
206
|
-
o[37] = x9 >>> 8 & 255;
|
|
207
|
-
o[38] = x9 >>> 16 & 255;
|
|
208
|
-
o[39] = x9 >>> 24 & 255;
|
|
209
|
-
o[40] = x10 >>> 0 & 255;
|
|
210
|
-
o[41] = x10 >>> 8 & 255;
|
|
211
|
-
o[42] = x10 >>> 16 & 255;
|
|
212
|
-
o[43] = x10 >>> 24 & 255;
|
|
213
|
-
o[44] = x11 >>> 0 & 255;
|
|
214
|
-
o[45] = x11 >>> 8 & 255;
|
|
215
|
-
o[46] = x11 >>> 16 & 255;
|
|
216
|
-
o[47] = x11 >>> 24 & 255;
|
|
217
|
-
o[48] = x12 >>> 0 & 255;
|
|
218
|
-
o[49] = x12 >>> 8 & 255;
|
|
219
|
-
o[50] = x12 >>> 16 & 255;
|
|
220
|
-
o[51] = x12 >>> 24 & 255;
|
|
221
|
-
o[52] = x13 >>> 0 & 255;
|
|
222
|
-
o[53] = x13 >>> 8 & 255;
|
|
223
|
-
o[54] = x13 >>> 16 & 255;
|
|
224
|
-
o[55] = x13 >>> 24 & 255;
|
|
225
|
-
o[56] = x14 >>> 0 & 255;
|
|
226
|
-
o[57] = x14 >>> 8 & 255;
|
|
227
|
-
o[58] = x14 >>> 16 & 255;
|
|
228
|
-
o[59] = x14 >>> 24 & 255;
|
|
229
|
-
o[60] = x15 >>> 0 & 255;
|
|
230
|
-
o[61] = x15 >>> 8 & 255;
|
|
231
|
-
o[62] = x15 >>> 16 & 255;
|
|
232
|
-
o[63] = x15 >>> 24 & 255;
|
|
233
|
-
}
|
|
234
|
-
function core_hsalsa20(o, p, k, c) {
|
|
235
|
-
var j0 = c[0] & 255 | (c[1] & 255) << 8 | (c[2] & 255) << 16 | (c[3] & 255) << 24, j1 = k[0] & 255 | (k[1] & 255) << 8 | (k[2] & 255) << 16 | (k[3] & 255) << 24, j2 = k[4] & 255 | (k[5] & 255) << 8 | (k[6] & 255) << 16 | (k[7] & 255) << 24, j3 = k[8] & 255 | (k[9] & 255) << 8 | (k[10] & 255) << 16 | (k[11] & 255) << 24, j4 = k[12] & 255 | (k[13] & 255) << 8 | (k[14] & 255) << 16 | (k[15] & 255) << 24, j5 = c[4] & 255 | (c[5] & 255) << 8 | (c[6] & 255) << 16 | (c[7] & 255) << 24, j6 = p[0] & 255 | (p[1] & 255) << 8 | (p[2] & 255) << 16 | (p[3] & 255) << 24, j7 = p[4] & 255 | (p[5] & 255) << 8 | (p[6] & 255) << 16 | (p[7] & 255) << 24, j8 = p[8] & 255 | (p[9] & 255) << 8 | (p[10] & 255) << 16 | (p[11] & 255) << 24, j9 = p[12] & 255 | (p[13] & 255) << 8 | (p[14] & 255) << 16 | (p[15] & 255) << 24, j10 = c[8] & 255 | (c[9] & 255) << 8 | (c[10] & 255) << 16 | (c[11] & 255) << 24, j11 = k[16] & 255 | (k[17] & 255) << 8 | (k[18] & 255) << 16 | (k[19] & 255) << 24, j12 = k[20] & 255 | (k[21] & 255) << 8 | (k[22] & 255) << 16 | (k[23] & 255) << 24, j13 = k[24] & 255 | (k[25] & 255) << 8 | (k[26] & 255) << 16 | (k[27] & 255) << 24, j14 = k[28] & 255 | (k[29] & 255) << 8 | (k[30] & 255) << 16 | (k[31] & 255) << 24, j15 = c[12] & 255 | (c[13] & 255) << 8 | (c[14] & 255) << 16 | (c[15] & 255) << 24;
|
|
236
|
-
var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7, x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14, x15 = j15, u;
|
|
237
|
-
for (var i = 0; i < 20; i += 2) {
|
|
238
|
-
u = x0 + x12 | 0;
|
|
239
|
-
x4 ^= u << 7 | u >>> 32 - 7;
|
|
240
|
-
u = x4 + x0 | 0;
|
|
241
|
-
x8 ^= u << 9 | u >>> 32 - 9;
|
|
242
|
-
u = x8 + x4 | 0;
|
|
243
|
-
x12 ^= u << 13 | u >>> 32 - 13;
|
|
244
|
-
u = x12 + x8 | 0;
|
|
245
|
-
x0 ^= u << 18 | u >>> 32 - 18;
|
|
246
|
-
u = x5 + x1 | 0;
|
|
247
|
-
x9 ^= u << 7 | u >>> 32 - 7;
|
|
248
|
-
u = x9 + x5 | 0;
|
|
249
|
-
x13 ^= u << 9 | u >>> 32 - 9;
|
|
250
|
-
u = x13 + x9 | 0;
|
|
251
|
-
x1 ^= u << 13 | u >>> 32 - 13;
|
|
252
|
-
u = x1 + x13 | 0;
|
|
253
|
-
x5 ^= u << 18 | u >>> 32 - 18;
|
|
254
|
-
u = x10 + x6 | 0;
|
|
255
|
-
x14 ^= u << 7 | u >>> 32 - 7;
|
|
256
|
-
u = x14 + x10 | 0;
|
|
257
|
-
x2 ^= u << 9 | u >>> 32 - 9;
|
|
258
|
-
u = x2 + x14 | 0;
|
|
259
|
-
x6 ^= u << 13 | u >>> 32 - 13;
|
|
260
|
-
u = x6 + x2 | 0;
|
|
261
|
-
x10 ^= u << 18 | u >>> 32 - 18;
|
|
262
|
-
u = x15 + x11 | 0;
|
|
263
|
-
x3 ^= u << 7 | u >>> 32 - 7;
|
|
264
|
-
u = x3 + x15 | 0;
|
|
265
|
-
x7 ^= u << 9 | u >>> 32 - 9;
|
|
266
|
-
u = x7 + x3 | 0;
|
|
267
|
-
x11 ^= u << 13 | u >>> 32 - 13;
|
|
268
|
-
u = x11 + x7 | 0;
|
|
269
|
-
x15 ^= u << 18 | u >>> 32 - 18;
|
|
270
|
-
u = x0 + x3 | 0;
|
|
271
|
-
x1 ^= u << 7 | u >>> 32 - 7;
|
|
272
|
-
u = x1 + x0 | 0;
|
|
273
|
-
x2 ^= u << 9 | u >>> 32 - 9;
|
|
274
|
-
u = x2 + x1 | 0;
|
|
275
|
-
x3 ^= u << 13 | u >>> 32 - 13;
|
|
276
|
-
u = x3 + x2 | 0;
|
|
277
|
-
x0 ^= u << 18 | u >>> 32 - 18;
|
|
278
|
-
u = x5 + x4 | 0;
|
|
279
|
-
x6 ^= u << 7 | u >>> 32 - 7;
|
|
280
|
-
u = x6 + x5 | 0;
|
|
281
|
-
x7 ^= u << 9 | u >>> 32 - 9;
|
|
282
|
-
u = x7 + x6 | 0;
|
|
283
|
-
x4 ^= u << 13 | u >>> 32 - 13;
|
|
284
|
-
u = x4 + x7 | 0;
|
|
285
|
-
x5 ^= u << 18 | u >>> 32 - 18;
|
|
286
|
-
u = x10 + x9 | 0;
|
|
287
|
-
x11 ^= u << 7 | u >>> 32 - 7;
|
|
288
|
-
u = x11 + x10 | 0;
|
|
289
|
-
x8 ^= u << 9 | u >>> 32 - 9;
|
|
290
|
-
u = x8 + x11 | 0;
|
|
291
|
-
x9 ^= u << 13 | u >>> 32 - 13;
|
|
292
|
-
u = x9 + x8 | 0;
|
|
293
|
-
x10 ^= u << 18 | u >>> 32 - 18;
|
|
294
|
-
u = x15 + x14 | 0;
|
|
295
|
-
x12 ^= u << 7 | u >>> 32 - 7;
|
|
296
|
-
u = x12 + x15 | 0;
|
|
297
|
-
x13 ^= u << 9 | u >>> 32 - 9;
|
|
298
|
-
u = x13 + x12 | 0;
|
|
299
|
-
x14 ^= u << 13 | u >>> 32 - 13;
|
|
300
|
-
u = x14 + x13 | 0;
|
|
301
|
-
x15 ^= u << 18 | u >>> 32 - 18;
|
|
302
|
-
}
|
|
303
|
-
o[0] = x0 >>> 0 & 255;
|
|
304
|
-
o[1] = x0 >>> 8 & 255;
|
|
305
|
-
o[2] = x0 >>> 16 & 255;
|
|
306
|
-
o[3] = x0 >>> 24 & 255;
|
|
307
|
-
o[4] = x5 >>> 0 & 255;
|
|
308
|
-
o[5] = x5 >>> 8 & 255;
|
|
309
|
-
o[6] = x5 >>> 16 & 255;
|
|
310
|
-
o[7] = x5 >>> 24 & 255;
|
|
311
|
-
o[8] = x10 >>> 0 & 255;
|
|
312
|
-
o[9] = x10 >>> 8 & 255;
|
|
313
|
-
o[10] = x10 >>> 16 & 255;
|
|
314
|
-
o[11] = x10 >>> 24 & 255;
|
|
315
|
-
o[12] = x15 >>> 0 & 255;
|
|
316
|
-
o[13] = x15 >>> 8 & 255;
|
|
317
|
-
o[14] = x15 >>> 16 & 255;
|
|
318
|
-
o[15] = x15 >>> 24 & 255;
|
|
319
|
-
o[16] = x6 >>> 0 & 255;
|
|
320
|
-
o[17] = x6 >>> 8 & 255;
|
|
321
|
-
o[18] = x6 >>> 16 & 255;
|
|
322
|
-
o[19] = x6 >>> 24 & 255;
|
|
323
|
-
o[20] = x7 >>> 0 & 255;
|
|
324
|
-
o[21] = x7 >>> 8 & 255;
|
|
325
|
-
o[22] = x7 >>> 16 & 255;
|
|
326
|
-
o[23] = x7 >>> 24 & 255;
|
|
327
|
-
o[24] = x8 >>> 0 & 255;
|
|
328
|
-
o[25] = x8 >>> 8 & 255;
|
|
329
|
-
o[26] = x8 >>> 16 & 255;
|
|
330
|
-
o[27] = x8 >>> 24 & 255;
|
|
331
|
-
o[28] = x9 >>> 0 & 255;
|
|
332
|
-
o[29] = x9 >>> 8 & 255;
|
|
333
|
-
o[30] = x9 >>> 16 & 255;
|
|
334
|
-
o[31] = x9 >>> 24 & 255;
|
|
335
|
-
}
|
|
336
|
-
function crypto_core_salsa20(out, inp, k, c) {
|
|
337
|
-
core_salsa20(out, inp, k, c);
|
|
338
|
-
}
|
|
339
|
-
function crypto_core_hsalsa20(out, inp, k, c) {
|
|
340
|
-
core_hsalsa20(out, inp, k, c);
|
|
341
|
-
}
|
|
342
|
-
var sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);
|
|
343
|
-
function crypto_stream_salsa20_xor(c, cpos, m, mpos, b, n, k) {
|
|
344
|
-
var z = new Uint8Array(16), x = new Uint8Array(64);
|
|
345
|
-
var u, i;
|
|
346
|
-
for (i = 0; i < 16; i++) z[i] = 0;
|
|
347
|
-
for (i = 0; i < 8; i++) z[i] = n[i];
|
|
348
|
-
while (b >= 64) {
|
|
349
|
-
crypto_core_salsa20(x, z, k, sigma);
|
|
350
|
-
for (i = 0; i < 64; i++) c[cpos + i] = m[mpos + i] ^ x[i];
|
|
351
|
-
u = 1;
|
|
352
|
-
for (i = 8; i < 16; i++) {
|
|
353
|
-
u = u + (z[i] & 255) | 0;
|
|
354
|
-
z[i] = u & 255;
|
|
355
|
-
u >>>= 8;
|
|
356
|
-
}
|
|
357
|
-
b -= 64;
|
|
358
|
-
cpos += 64;
|
|
359
|
-
mpos += 64;
|
|
360
|
-
}
|
|
361
|
-
if (b > 0) {
|
|
362
|
-
crypto_core_salsa20(x, z, k, sigma);
|
|
363
|
-
for (i = 0; i < b; i++) c[cpos + i] = m[mpos + i] ^ x[i];
|
|
364
|
-
}
|
|
365
|
-
return 0;
|
|
366
|
-
}
|
|
367
|
-
function crypto_stream_salsa20(c, cpos, b, n, k) {
|
|
368
|
-
var z = new Uint8Array(16), x = new Uint8Array(64);
|
|
369
|
-
var u, i;
|
|
370
|
-
for (i = 0; i < 16; i++) z[i] = 0;
|
|
371
|
-
for (i = 0; i < 8; i++) z[i] = n[i];
|
|
372
|
-
while (b >= 64) {
|
|
373
|
-
crypto_core_salsa20(x, z, k, sigma);
|
|
374
|
-
for (i = 0; i < 64; i++) c[cpos + i] = x[i];
|
|
375
|
-
u = 1;
|
|
376
|
-
for (i = 8; i < 16; i++) {
|
|
377
|
-
u = u + (z[i] & 255) | 0;
|
|
378
|
-
z[i] = u & 255;
|
|
379
|
-
u >>>= 8;
|
|
380
|
-
}
|
|
381
|
-
b -= 64;
|
|
382
|
-
cpos += 64;
|
|
383
|
-
}
|
|
384
|
-
if (b > 0) {
|
|
385
|
-
crypto_core_salsa20(x, z, k, sigma);
|
|
386
|
-
for (i = 0; i < b; i++) c[cpos + i] = x[i];
|
|
387
|
-
}
|
|
388
|
-
return 0;
|
|
389
|
-
}
|
|
390
|
-
function crypto_stream(c, cpos, d, n, k) {
|
|
391
|
-
var s = new Uint8Array(32);
|
|
392
|
-
crypto_core_hsalsa20(s, n, k, sigma);
|
|
393
|
-
var sn = new Uint8Array(8);
|
|
394
|
-
for (var i = 0; i < 8; i++) sn[i] = n[i + 16];
|
|
395
|
-
return crypto_stream_salsa20(c, cpos, d, sn, s);
|
|
396
|
-
}
|
|
397
|
-
function crypto_stream_xor(c, cpos, m, mpos, d, n, k) {
|
|
398
|
-
var s = new Uint8Array(32);
|
|
399
|
-
crypto_core_hsalsa20(s, n, k, sigma);
|
|
400
|
-
var sn = new Uint8Array(8);
|
|
401
|
-
for (var i = 0; i < 8; i++) sn[i] = n[i + 16];
|
|
402
|
-
return crypto_stream_salsa20_xor(c, cpos, m, mpos, d, sn, s);
|
|
403
|
-
}
|
|
404
|
-
var poly1305 = function(key) {
|
|
405
|
-
this.buffer = new Uint8Array(16);
|
|
406
|
-
this.r = new Uint16Array(10);
|
|
407
|
-
this.h = new Uint16Array(10);
|
|
408
|
-
this.pad = new Uint16Array(8);
|
|
409
|
-
this.leftover = 0;
|
|
410
|
-
this.fin = 0;
|
|
411
|
-
var t0, t1, t2, t3, t4, t5, t6, t7;
|
|
412
|
-
t0 = key[0] & 255 | (key[1] & 255) << 8;
|
|
413
|
-
this.r[0] = t0 & 8191;
|
|
414
|
-
t1 = key[2] & 255 | (key[3] & 255) << 8;
|
|
415
|
-
this.r[1] = (t0 >>> 13 | t1 << 3) & 8191;
|
|
416
|
-
t2 = key[4] & 255 | (key[5] & 255) << 8;
|
|
417
|
-
this.r[2] = (t1 >>> 10 | t2 << 6) & 7939;
|
|
418
|
-
t3 = key[6] & 255 | (key[7] & 255) << 8;
|
|
419
|
-
this.r[3] = (t2 >>> 7 | t3 << 9) & 8191;
|
|
420
|
-
t4 = key[8] & 255 | (key[9] & 255) << 8;
|
|
421
|
-
this.r[4] = (t3 >>> 4 | t4 << 12) & 255;
|
|
422
|
-
this.r[5] = t4 >>> 1 & 8190;
|
|
423
|
-
t5 = key[10] & 255 | (key[11] & 255) << 8;
|
|
424
|
-
this.r[6] = (t4 >>> 14 | t5 << 2) & 8191;
|
|
425
|
-
t6 = key[12] & 255 | (key[13] & 255) << 8;
|
|
426
|
-
this.r[7] = (t5 >>> 11 | t6 << 5) & 8065;
|
|
427
|
-
t7 = key[14] & 255 | (key[15] & 255) << 8;
|
|
428
|
-
this.r[8] = (t6 >>> 8 | t7 << 8) & 8191;
|
|
429
|
-
this.r[9] = t7 >>> 5 & 127;
|
|
430
|
-
this.pad[0] = key[16] & 255 | (key[17] & 255) << 8;
|
|
431
|
-
this.pad[1] = key[18] & 255 | (key[19] & 255) << 8;
|
|
432
|
-
this.pad[2] = key[20] & 255 | (key[21] & 255) << 8;
|
|
433
|
-
this.pad[3] = key[22] & 255 | (key[23] & 255) << 8;
|
|
434
|
-
this.pad[4] = key[24] & 255 | (key[25] & 255) << 8;
|
|
435
|
-
this.pad[5] = key[26] & 255 | (key[27] & 255) << 8;
|
|
436
|
-
this.pad[6] = key[28] & 255 | (key[29] & 255) << 8;
|
|
437
|
-
this.pad[7] = key[30] & 255 | (key[31] & 255) << 8;
|
|
438
|
-
};
|
|
439
|
-
poly1305.prototype.blocks = function(m, mpos, bytes) {
|
|
440
|
-
var hibit = this.fin ? 0 : 1 << 11;
|
|
441
|
-
var t0, t1, t2, t3, t4, t5, t6, t7, c;
|
|
442
|
-
var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;
|
|
443
|
-
var h0 = this.h[0], h1 = this.h[1], h2 = this.h[2], h3 = this.h[3], h4 = this.h[4], h5 = this.h[5], h6 = this.h[6], h7 = this.h[7], h8 = this.h[8], h9 = this.h[9];
|
|
444
|
-
var r0 = this.r[0], r1 = this.r[1], r2 = this.r[2], r3 = this.r[3], r4 = this.r[4], r5 = this.r[5], r6 = this.r[6], r7 = this.r[7], r8 = this.r[8], r9 = this.r[9];
|
|
445
|
-
while (bytes >= 16) {
|
|
446
|
-
t0 = m[mpos + 0] & 255 | (m[mpos + 1] & 255) << 8;
|
|
447
|
-
h0 += t0 & 8191;
|
|
448
|
-
t1 = m[mpos + 2] & 255 | (m[mpos + 3] & 255) << 8;
|
|
449
|
-
h1 += (t0 >>> 13 | t1 << 3) & 8191;
|
|
450
|
-
t2 = m[mpos + 4] & 255 | (m[mpos + 5] & 255) << 8;
|
|
451
|
-
h2 += (t1 >>> 10 | t2 << 6) & 8191;
|
|
452
|
-
t3 = m[mpos + 6] & 255 | (m[mpos + 7] & 255) << 8;
|
|
453
|
-
h3 += (t2 >>> 7 | t3 << 9) & 8191;
|
|
454
|
-
t4 = m[mpos + 8] & 255 | (m[mpos + 9] & 255) << 8;
|
|
455
|
-
h4 += (t3 >>> 4 | t4 << 12) & 8191;
|
|
456
|
-
h5 += t4 >>> 1 & 8191;
|
|
457
|
-
t5 = m[mpos + 10] & 255 | (m[mpos + 11] & 255) << 8;
|
|
458
|
-
h6 += (t4 >>> 14 | t5 << 2) & 8191;
|
|
459
|
-
t6 = m[mpos + 12] & 255 | (m[mpos + 13] & 255) << 8;
|
|
460
|
-
h7 += (t5 >>> 11 | t6 << 5) & 8191;
|
|
461
|
-
t7 = m[mpos + 14] & 255 | (m[mpos + 15] & 255) << 8;
|
|
462
|
-
h8 += (t6 >>> 8 | t7 << 8) & 8191;
|
|
463
|
-
h9 += t7 >>> 5 | hibit;
|
|
464
|
-
c = 0;
|
|
465
|
-
d0 = c;
|
|
466
|
-
d0 += h0 * r0;
|
|
467
|
-
d0 += h1 * (5 * r9);
|
|
468
|
-
d0 += h2 * (5 * r8);
|
|
469
|
-
d0 += h3 * (5 * r7);
|
|
470
|
-
d0 += h4 * (5 * r6);
|
|
471
|
-
c = d0 >>> 13;
|
|
472
|
-
d0 &= 8191;
|
|
473
|
-
d0 += h5 * (5 * r5);
|
|
474
|
-
d0 += h6 * (5 * r4);
|
|
475
|
-
d0 += h7 * (5 * r3);
|
|
476
|
-
d0 += h8 * (5 * r2);
|
|
477
|
-
d0 += h9 * (5 * r1);
|
|
478
|
-
c += d0 >>> 13;
|
|
479
|
-
d0 &= 8191;
|
|
480
|
-
d1 = c;
|
|
481
|
-
d1 += h0 * r1;
|
|
482
|
-
d1 += h1 * r0;
|
|
483
|
-
d1 += h2 * (5 * r9);
|
|
484
|
-
d1 += h3 * (5 * r8);
|
|
485
|
-
d1 += h4 * (5 * r7);
|
|
486
|
-
c = d1 >>> 13;
|
|
487
|
-
d1 &= 8191;
|
|
488
|
-
d1 += h5 * (5 * r6);
|
|
489
|
-
d1 += h6 * (5 * r5);
|
|
490
|
-
d1 += h7 * (5 * r4);
|
|
491
|
-
d1 += h8 * (5 * r3);
|
|
492
|
-
d1 += h9 * (5 * r2);
|
|
493
|
-
c += d1 >>> 13;
|
|
494
|
-
d1 &= 8191;
|
|
495
|
-
d2 = c;
|
|
496
|
-
d2 += h0 * r2;
|
|
497
|
-
d2 += h1 * r1;
|
|
498
|
-
d2 += h2 * r0;
|
|
499
|
-
d2 += h3 * (5 * r9);
|
|
500
|
-
d2 += h4 * (5 * r8);
|
|
501
|
-
c = d2 >>> 13;
|
|
502
|
-
d2 &= 8191;
|
|
503
|
-
d2 += h5 * (5 * r7);
|
|
504
|
-
d2 += h6 * (5 * r6);
|
|
505
|
-
d2 += h7 * (5 * r5);
|
|
506
|
-
d2 += h8 * (5 * r4);
|
|
507
|
-
d2 += h9 * (5 * r3);
|
|
508
|
-
c += d2 >>> 13;
|
|
509
|
-
d2 &= 8191;
|
|
510
|
-
d3 = c;
|
|
511
|
-
d3 += h0 * r3;
|
|
512
|
-
d3 += h1 * r2;
|
|
513
|
-
d3 += h2 * r1;
|
|
514
|
-
d3 += h3 * r0;
|
|
515
|
-
d3 += h4 * (5 * r9);
|
|
516
|
-
c = d3 >>> 13;
|
|
517
|
-
d3 &= 8191;
|
|
518
|
-
d3 += h5 * (5 * r8);
|
|
519
|
-
d3 += h6 * (5 * r7);
|
|
520
|
-
d3 += h7 * (5 * r6);
|
|
521
|
-
d3 += h8 * (5 * r5);
|
|
522
|
-
d3 += h9 * (5 * r4);
|
|
523
|
-
c += d3 >>> 13;
|
|
524
|
-
d3 &= 8191;
|
|
525
|
-
d4 = c;
|
|
526
|
-
d4 += h0 * r4;
|
|
527
|
-
d4 += h1 * r3;
|
|
528
|
-
d4 += h2 * r2;
|
|
529
|
-
d4 += h3 * r1;
|
|
530
|
-
d4 += h4 * r0;
|
|
531
|
-
c = d4 >>> 13;
|
|
532
|
-
d4 &= 8191;
|
|
533
|
-
d4 += h5 * (5 * r9);
|
|
534
|
-
d4 += h6 * (5 * r8);
|
|
535
|
-
d4 += h7 * (5 * r7);
|
|
536
|
-
d4 += h8 * (5 * r6);
|
|
537
|
-
d4 += h9 * (5 * r5);
|
|
538
|
-
c += d4 >>> 13;
|
|
539
|
-
d4 &= 8191;
|
|
540
|
-
d5 = c;
|
|
541
|
-
d5 += h0 * r5;
|
|
542
|
-
d5 += h1 * r4;
|
|
543
|
-
d5 += h2 * r3;
|
|
544
|
-
d5 += h3 * r2;
|
|
545
|
-
d5 += h4 * r1;
|
|
546
|
-
c = d5 >>> 13;
|
|
547
|
-
d5 &= 8191;
|
|
548
|
-
d5 += h5 * r0;
|
|
549
|
-
d5 += h6 * (5 * r9);
|
|
550
|
-
d5 += h7 * (5 * r8);
|
|
551
|
-
d5 += h8 * (5 * r7);
|
|
552
|
-
d5 += h9 * (5 * r6);
|
|
553
|
-
c += d5 >>> 13;
|
|
554
|
-
d5 &= 8191;
|
|
555
|
-
d6 = c;
|
|
556
|
-
d6 += h0 * r6;
|
|
557
|
-
d6 += h1 * r5;
|
|
558
|
-
d6 += h2 * r4;
|
|
559
|
-
d6 += h3 * r3;
|
|
560
|
-
d6 += h4 * r2;
|
|
561
|
-
c = d6 >>> 13;
|
|
562
|
-
d6 &= 8191;
|
|
563
|
-
d6 += h5 * r1;
|
|
564
|
-
d6 += h6 * r0;
|
|
565
|
-
d6 += h7 * (5 * r9);
|
|
566
|
-
d6 += h8 * (5 * r8);
|
|
567
|
-
d6 += h9 * (5 * r7);
|
|
568
|
-
c += d6 >>> 13;
|
|
569
|
-
d6 &= 8191;
|
|
570
|
-
d7 = c;
|
|
571
|
-
d7 += h0 * r7;
|
|
572
|
-
d7 += h1 * r6;
|
|
573
|
-
d7 += h2 * r5;
|
|
574
|
-
d7 += h3 * r4;
|
|
575
|
-
d7 += h4 * r3;
|
|
576
|
-
c = d7 >>> 13;
|
|
577
|
-
d7 &= 8191;
|
|
578
|
-
d7 += h5 * r2;
|
|
579
|
-
d7 += h6 * r1;
|
|
580
|
-
d7 += h7 * r0;
|
|
581
|
-
d7 += h8 * (5 * r9);
|
|
582
|
-
d7 += h9 * (5 * r8);
|
|
583
|
-
c += d7 >>> 13;
|
|
584
|
-
d7 &= 8191;
|
|
585
|
-
d8 = c;
|
|
586
|
-
d8 += h0 * r8;
|
|
587
|
-
d8 += h1 * r7;
|
|
588
|
-
d8 += h2 * r6;
|
|
589
|
-
d8 += h3 * r5;
|
|
590
|
-
d8 += h4 * r4;
|
|
591
|
-
c = d8 >>> 13;
|
|
592
|
-
d8 &= 8191;
|
|
593
|
-
d8 += h5 * r3;
|
|
594
|
-
d8 += h6 * r2;
|
|
595
|
-
d8 += h7 * r1;
|
|
596
|
-
d8 += h8 * r0;
|
|
597
|
-
d8 += h9 * (5 * r9);
|
|
598
|
-
c += d8 >>> 13;
|
|
599
|
-
d8 &= 8191;
|
|
600
|
-
d9 = c;
|
|
601
|
-
d9 += h0 * r9;
|
|
602
|
-
d9 += h1 * r8;
|
|
603
|
-
d9 += h2 * r7;
|
|
604
|
-
d9 += h3 * r6;
|
|
605
|
-
d9 += h4 * r5;
|
|
606
|
-
c = d9 >>> 13;
|
|
607
|
-
d9 &= 8191;
|
|
608
|
-
d9 += h5 * r4;
|
|
609
|
-
d9 += h6 * r3;
|
|
610
|
-
d9 += h7 * r2;
|
|
611
|
-
d9 += h8 * r1;
|
|
612
|
-
d9 += h9 * r0;
|
|
613
|
-
c += d9 >>> 13;
|
|
614
|
-
d9 &= 8191;
|
|
615
|
-
c = (c << 2) + c | 0;
|
|
616
|
-
c = c + d0 | 0;
|
|
617
|
-
d0 = c & 8191;
|
|
618
|
-
c = c >>> 13;
|
|
619
|
-
d1 += c;
|
|
620
|
-
h0 = d0;
|
|
621
|
-
h1 = d1;
|
|
622
|
-
h2 = d2;
|
|
623
|
-
h3 = d3;
|
|
624
|
-
h4 = d4;
|
|
625
|
-
h5 = d5;
|
|
626
|
-
h6 = d6;
|
|
627
|
-
h7 = d7;
|
|
628
|
-
h8 = d8;
|
|
629
|
-
h9 = d9;
|
|
630
|
-
mpos += 16;
|
|
631
|
-
bytes -= 16;
|
|
632
|
-
}
|
|
633
|
-
this.h[0] = h0;
|
|
634
|
-
this.h[1] = h1;
|
|
635
|
-
this.h[2] = h2;
|
|
636
|
-
this.h[3] = h3;
|
|
637
|
-
this.h[4] = h4;
|
|
638
|
-
this.h[5] = h5;
|
|
639
|
-
this.h[6] = h6;
|
|
640
|
-
this.h[7] = h7;
|
|
641
|
-
this.h[8] = h8;
|
|
642
|
-
this.h[9] = h9;
|
|
643
|
-
};
|
|
644
|
-
poly1305.prototype.finish = function(mac, macpos) {
|
|
645
|
-
var g = new Uint16Array(10);
|
|
646
|
-
var c, mask, f, i;
|
|
647
|
-
if (this.leftover) {
|
|
648
|
-
i = this.leftover;
|
|
649
|
-
this.buffer[i++] = 1;
|
|
650
|
-
for (; i < 16; i++) this.buffer[i] = 0;
|
|
651
|
-
this.fin = 1;
|
|
652
|
-
this.blocks(this.buffer, 0, 16);
|
|
653
|
-
}
|
|
654
|
-
c = this.h[1] >>> 13;
|
|
655
|
-
this.h[1] &= 8191;
|
|
656
|
-
for (i = 2; i < 10; i++) {
|
|
657
|
-
this.h[i] += c;
|
|
658
|
-
c = this.h[i] >>> 13;
|
|
659
|
-
this.h[i] &= 8191;
|
|
660
|
-
}
|
|
661
|
-
this.h[0] += c * 5;
|
|
662
|
-
c = this.h[0] >>> 13;
|
|
663
|
-
this.h[0] &= 8191;
|
|
664
|
-
this.h[1] += c;
|
|
665
|
-
c = this.h[1] >>> 13;
|
|
666
|
-
this.h[1] &= 8191;
|
|
667
|
-
this.h[2] += c;
|
|
668
|
-
g[0] = this.h[0] + 5;
|
|
669
|
-
c = g[0] >>> 13;
|
|
670
|
-
g[0] &= 8191;
|
|
671
|
-
for (i = 1; i < 10; i++) {
|
|
672
|
-
g[i] = this.h[i] + c;
|
|
673
|
-
c = g[i] >>> 13;
|
|
674
|
-
g[i] &= 8191;
|
|
675
|
-
}
|
|
676
|
-
g[9] -= 1 << 13;
|
|
677
|
-
mask = (c ^ 1) - 1;
|
|
678
|
-
for (i = 0; i < 10; i++) g[i] &= mask;
|
|
679
|
-
mask = ~mask;
|
|
680
|
-
for (i = 0; i < 10; i++) this.h[i] = this.h[i] & mask | g[i];
|
|
681
|
-
this.h[0] = (this.h[0] | this.h[1] << 13) & 65535;
|
|
682
|
-
this.h[1] = (this.h[1] >>> 3 | this.h[2] << 10) & 65535;
|
|
683
|
-
this.h[2] = (this.h[2] >>> 6 | this.h[3] << 7) & 65535;
|
|
684
|
-
this.h[3] = (this.h[3] >>> 9 | this.h[4] << 4) & 65535;
|
|
685
|
-
this.h[4] = (this.h[4] >>> 12 | this.h[5] << 1 | this.h[6] << 14) & 65535;
|
|
686
|
-
this.h[5] = (this.h[6] >>> 2 | this.h[7] << 11) & 65535;
|
|
687
|
-
this.h[6] = (this.h[7] >>> 5 | this.h[8] << 8) & 65535;
|
|
688
|
-
this.h[7] = (this.h[8] >>> 8 | this.h[9] << 5) & 65535;
|
|
689
|
-
f = this.h[0] + this.pad[0];
|
|
690
|
-
this.h[0] = f & 65535;
|
|
691
|
-
for (i = 1; i < 8; i++) {
|
|
692
|
-
f = (this.h[i] + this.pad[i] | 0) + (f >>> 16) | 0;
|
|
693
|
-
this.h[i] = f & 65535;
|
|
694
|
-
}
|
|
695
|
-
mac[macpos + 0] = this.h[0] >>> 0 & 255;
|
|
696
|
-
mac[macpos + 1] = this.h[0] >>> 8 & 255;
|
|
697
|
-
mac[macpos + 2] = this.h[1] >>> 0 & 255;
|
|
698
|
-
mac[macpos + 3] = this.h[1] >>> 8 & 255;
|
|
699
|
-
mac[macpos + 4] = this.h[2] >>> 0 & 255;
|
|
700
|
-
mac[macpos + 5] = this.h[2] >>> 8 & 255;
|
|
701
|
-
mac[macpos + 6] = this.h[3] >>> 0 & 255;
|
|
702
|
-
mac[macpos + 7] = this.h[3] >>> 8 & 255;
|
|
703
|
-
mac[macpos + 8] = this.h[4] >>> 0 & 255;
|
|
704
|
-
mac[macpos + 9] = this.h[4] >>> 8 & 255;
|
|
705
|
-
mac[macpos + 10] = this.h[5] >>> 0 & 255;
|
|
706
|
-
mac[macpos + 11] = this.h[5] >>> 8 & 255;
|
|
707
|
-
mac[macpos + 12] = this.h[6] >>> 0 & 255;
|
|
708
|
-
mac[macpos + 13] = this.h[6] >>> 8 & 255;
|
|
709
|
-
mac[macpos + 14] = this.h[7] >>> 0 & 255;
|
|
710
|
-
mac[macpos + 15] = this.h[7] >>> 8 & 255;
|
|
711
|
-
};
|
|
712
|
-
poly1305.prototype.update = function(m, mpos, bytes) {
|
|
713
|
-
var i, want;
|
|
714
|
-
if (this.leftover) {
|
|
715
|
-
want = 16 - this.leftover;
|
|
716
|
-
if (want > bytes)
|
|
717
|
-
want = bytes;
|
|
718
|
-
for (i = 0; i < want; i++)
|
|
719
|
-
this.buffer[this.leftover + i] = m[mpos + i];
|
|
720
|
-
bytes -= want;
|
|
721
|
-
mpos += want;
|
|
722
|
-
this.leftover += want;
|
|
723
|
-
if (this.leftover < 16)
|
|
724
|
-
return;
|
|
725
|
-
this.blocks(this.buffer, 0, 16);
|
|
726
|
-
this.leftover = 0;
|
|
727
|
-
}
|
|
728
|
-
if (bytes >= 16) {
|
|
729
|
-
want = bytes - bytes % 16;
|
|
730
|
-
this.blocks(m, mpos, want);
|
|
731
|
-
mpos += want;
|
|
732
|
-
bytes -= want;
|
|
733
|
-
}
|
|
734
|
-
if (bytes) {
|
|
735
|
-
for (i = 0; i < bytes; i++)
|
|
736
|
-
this.buffer[this.leftover + i] = m[mpos + i];
|
|
737
|
-
this.leftover += bytes;
|
|
738
|
-
}
|
|
739
|
-
};
|
|
740
|
-
function crypto_onetimeauth(out, outpos, m, mpos, n, k) {
|
|
741
|
-
var s = new poly1305(k);
|
|
742
|
-
s.update(m, mpos, n);
|
|
743
|
-
s.finish(out, outpos);
|
|
744
|
-
return 0;
|
|
745
|
-
}
|
|
746
|
-
function crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {
|
|
747
|
-
var x = new Uint8Array(16);
|
|
748
|
-
crypto_onetimeauth(x, 0, m, mpos, n, k);
|
|
749
|
-
return crypto_verify_16(h, hpos, x, 0);
|
|
750
|
-
}
|
|
751
|
-
function crypto_secretbox(c, m, d, n, k) {
|
|
752
|
-
var i;
|
|
753
|
-
if (d < 32) return -1;
|
|
754
|
-
crypto_stream_xor(c, 0, m, 0, d, n, k);
|
|
755
|
-
crypto_onetimeauth(c, 16, c, 32, d - 32, c);
|
|
756
|
-
for (i = 0; i < 16; i++) c[i] = 0;
|
|
757
|
-
return 0;
|
|
758
|
-
}
|
|
759
|
-
function crypto_secretbox_open(m, c, d, n, k) {
|
|
760
|
-
var i;
|
|
761
|
-
var x = new Uint8Array(32);
|
|
762
|
-
if (d < 32) return -1;
|
|
763
|
-
crypto_stream(x, 0, 32, n, k);
|
|
764
|
-
if (crypto_onetimeauth_verify(c, 16, c, 32, d - 32, x) !== 0) return -1;
|
|
765
|
-
crypto_stream_xor(m, 0, c, 0, d, n, k);
|
|
766
|
-
for (i = 0; i < 32; i++) m[i] = 0;
|
|
767
|
-
return 0;
|
|
768
|
-
}
|
|
769
|
-
function set25519(r, a) {
|
|
770
|
-
var i;
|
|
771
|
-
for (i = 0; i < 16; i++) r[i] = a[i] | 0;
|
|
772
|
-
}
|
|
773
|
-
function car25519(o) {
|
|
774
|
-
var i, v, c = 1;
|
|
775
|
-
for (i = 0; i < 16; i++) {
|
|
776
|
-
v = o[i] + c + 65535;
|
|
777
|
-
c = Math.floor(v / 65536);
|
|
778
|
-
o[i] = v - c * 65536;
|
|
779
|
-
}
|
|
780
|
-
o[0] += c - 1 + 37 * (c - 1);
|
|
781
|
-
}
|
|
782
|
-
function sel25519(p, q, b) {
|
|
783
|
-
var t, c = ~(b - 1);
|
|
784
|
-
for (var i = 0; i < 16; i++) {
|
|
785
|
-
t = c & (p[i] ^ q[i]);
|
|
786
|
-
p[i] ^= t;
|
|
787
|
-
q[i] ^= t;
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
function pack25519(o, n) {
|
|
791
|
-
var i, j, b;
|
|
792
|
-
var m = gf(), t = gf();
|
|
793
|
-
for (i = 0; i < 16; i++) t[i] = n[i];
|
|
794
|
-
car25519(t);
|
|
795
|
-
car25519(t);
|
|
796
|
-
car25519(t);
|
|
797
|
-
for (j = 0; j < 2; j++) {
|
|
798
|
-
m[0] = t[0] - 65517;
|
|
799
|
-
for (i = 1; i < 15; i++) {
|
|
800
|
-
m[i] = t[i] - 65535 - (m[i - 1] >> 16 & 1);
|
|
801
|
-
m[i - 1] &= 65535;
|
|
802
|
-
}
|
|
803
|
-
m[15] = t[15] - 32767 - (m[14] >> 16 & 1);
|
|
804
|
-
b = m[15] >> 16 & 1;
|
|
805
|
-
m[14] &= 65535;
|
|
806
|
-
sel25519(t, m, 1 - b);
|
|
807
|
-
}
|
|
808
|
-
for (i = 0; i < 16; i++) {
|
|
809
|
-
o[2 * i] = t[i] & 255;
|
|
810
|
-
o[2 * i + 1] = t[i] >> 8;
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
function neq25519(a, b) {
|
|
814
|
-
var c = new Uint8Array(32), d = new Uint8Array(32);
|
|
815
|
-
pack25519(c, a);
|
|
816
|
-
pack25519(d, b);
|
|
817
|
-
return crypto_verify_32(c, 0, d, 0);
|
|
818
|
-
}
|
|
819
|
-
function par25519(a) {
|
|
820
|
-
var d = new Uint8Array(32);
|
|
821
|
-
pack25519(d, a);
|
|
822
|
-
return d[0] & 1;
|
|
823
|
-
}
|
|
824
|
-
function unpack25519(o, n) {
|
|
825
|
-
var i;
|
|
826
|
-
for (i = 0; i < 16; i++) o[i] = n[2 * i] + (n[2 * i + 1] << 8);
|
|
827
|
-
o[15] &= 32767;
|
|
828
|
-
}
|
|
829
|
-
function A(o, a, b) {
|
|
830
|
-
for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];
|
|
831
|
-
}
|
|
832
|
-
function Z(o, a, b) {
|
|
833
|
-
for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];
|
|
834
|
-
}
|
|
835
|
-
function M(o, a, b) {
|
|
836
|
-
var v, c, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7], b8 = b[8], b9 = b[9], b10 = b[10], b11 = b[11], b12 = b[12], b13 = b[13], b14 = b[14], b15 = b[15];
|
|
837
|
-
v = a[0];
|
|
838
|
-
t0 += v * b0;
|
|
839
|
-
t1 += v * b1;
|
|
840
|
-
t2 += v * b2;
|
|
841
|
-
t3 += v * b3;
|
|
842
|
-
t4 += v * b4;
|
|
843
|
-
t5 += v * b5;
|
|
844
|
-
t6 += v * b6;
|
|
845
|
-
t7 += v * b7;
|
|
846
|
-
t8 += v * b8;
|
|
847
|
-
t9 += v * b9;
|
|
848
|
-
t10 += v * b10;
|
|
849
|
-
t11 += v * b11;
|
|
850
|
-
t12 += v * b12;
|
|
851
|
-
t13 += v * b13;
|
|
852
|
-
t14 += v * b14;
|
|
853
|
-
t15 += v * b15;
|
|
854
|
-
v = a[1];
|
|
855
|
-
t1 += v * b0;
|
|
856
|
-
t2 += v * b1;
|
|
857
|
-
t3 += v * b2;
|
|
858
|
-
t4 += v * b3;
|
|
859
|
-
t5 += v * b4;
|
|
860
|
-
t6 += v * b5;
|
|
861
|
-
t7 += v * b6;
|
|
862
|
-
t8 += v * b7;
|
|
863
|
-
t9 += v * b8;
|
|
864
|
-
t10 += v * b9;
|
|
865
|
-
t11 += v * b10;
|
|
866
|
-
t12 += v * b11;
|
|
867
|
-
t13 += v * b12;
|
|
868
|
-
t14 += v * b13;
|
|
869
|
-
t15 += v * b14;
|
|
870
|
-
t16 += v * b15;
|
|
871
|
-
v = a[2];
|
|
872
|
-
t2 += v * b0;
|
|
873
|
-
t3 += v * b1;
|
|
874
|
-
t4 += v * b2;
|
|
875
|
-
t5 += v * b3;
|
|
876
|
-
t6 += v * b4;
|
|
877
|
-
t7 += v * b5;
|
|
878
|
-
t8 += v * b6;
|
|
879
|
-
t9 += v * b7;
|
|
880
|
-
t10 += v * b8;
|
|
881
|
-
t11 += v * b9;
|
|
882
|
-
t12 += v * b10;
|
|
883
|
-
t13 += v * b11;
|
|
884
|
-
t14 += v * b12;
|
|
885
|
-
t15 += v * b13;
|
|
886
|
-
t16 += v * b14;
|
|
887
|
-
t17 += v * b15;
|
|
888
|
-
v = a[3];
|
|
889
|
-
t3 += v * b0;
|
|
890
|
-
t4 += v * b1;
|
|
891
|
-
t5 += v * b2;
|
|
892
|
-
t6 += v * b3;
|
|
893
|
-
t7 += v * b4;
|
|
894
|
-
t8 += v * b5;
|
|
895
|
-
t9 += v * b6;
|
|
896
|
-
t10 += v * b7;
|
|
897
|
-
t11 += v * b8;
|
|
898
|
-
t12 += v * b9;
|
|
899
|
-
t13 += v * b10;
|
|
900
|
-
t14 += v * b11;
|
|
901
|
-
t15 += v * b12;
|
|
902
|
-
t16 += v * b13;
|
|
903
|
-
t17 += v * b14;
|
|
904
|
-
t18 += v * b15;
|
|
905
|
-
v = a[4];
|
|
906
|
-
t4 += v * b0;
|
|
907
|
-
t5 += v * b1;
|
|
908
|
-
t6 += v * b2;
|
|
909
|
-
t7 += v * b3;
|
|
910
|
-
t8 += v * b4;
|
|
911
|
-
t9 += v * b5;
|
|
912
|
-
t10 += v * b6;
|
|
913
|
-
t11 += v * b7;
|
|
914
|
-
t12 += v * b8;
|
|
915
|
-
t13 += v * b9;
|
|
916
|
-
t14 += v * b10;
|
|
917
|
-
t15 += v * b11;
|
|
918
|
-
t16 += v * b12;
|
|
919
|
-
t17 += v * b13;
|
|
920
|
-
t18 += v * b14;
|
|
921
|
-
t19 += v * b15;
|
|
922
|
-
v = a[5];
|
|
923
|
-
t5 += v * b0;
|
|
924
|
-
t6 += v * b1;
|
|
925
|
-
t7 += v * b2;
|
|
926
|
-
t8 += v * b3;
|
|
927
|
-
t9 += v * b4;
|
|
928
|
-
t10 += v * b5;
|
|
929
|
-
t11 += v * b6;
|
|
930
|
-
t12 += v * b7;
|
|
931
|
-
t13 += v * b8;
|
|
932
|
-
t14 += v * b9;
|
|
933
|
-
t15 += v * b10;
|
|
934
|
-
t16 += v * b11;
|
|
935
|
-
t17 += v * b12;
|
|
936
|
-
t18 += v * b13;
|
|
937
|
-
t19 += v * b14;
|
|
938
|
-
t20 += v * b15;
|
|
939
|
-
v = a[6];
|
|
940
|
-
t6 += v * b0;
|
|
941
|
-
t7 += v * b1;
|
|
942
|
-
t8 += v * b2;
|
|
943
|
-
t9 += v * b3;
|
|
944
|
-
t10 += v * b4;
|
|
945
|
-
t11 += v * b5;
|
|
946
|
-
t12 += v * b6;
|
|
947
|
-
t13 += v * b7;
|
|
948
|
-
t14 += v * b8;
|
|
949
|
-
t15 += v * b9;
|
|
950
|
-
t16 += v * b10;
|
|
951
|
-
t17 += v * b11;
|
|
952
|
-
t18 += v * b12;
|
|
953
|
-
t19 += v * b13;
|
|
954
|
-
t20 += v * b14;
|
|
955
|
-
t21 += v * b15;
|
|
956
|
-
v = a[7];
|
|
957
|
-
t7 += v * b0;
|
|
958
|
-
t8 += v * b1;
|
|
959
|
-
t9 += v * b2;
|
|
960
|
-
t10 += v * b3;
|
|
961
|
-
t11 += v * b4;
|
|
962
|
-
t12 += v * b5;
|
|
963
|
-
t13 += v * b6;
|
|
964
|
-
t14 += v * b7;
|
|
965
|
-
t15 += v * b8;
|
|
966
|
-
t16 += v * b9;
|
|
967
|
-
t17 += v * b10;
|
|
968
|
-
t18 += v * b11;
|
|
969
|
-
t19 += v * b12;
|
|
970
|
-
t20 += v * b13;
|
|
971
|
-
t21 += v * b14;
|
|
972
|
-
t22 += v * b15;
|
|
973
|
-
v = a[8];
|
|
974
|
-
t8 += v * b0;
|
|
975
|
-
t9 += v * b1;
|
|
976
|
-
t10 += v * b2;
|
|
977
|
-
t11 += v * b3;
|
|
978
|
-
t12 += v * b4;
|
|
979
|
-
t13 += v * b5;
|
|
980
|
-
t14 += v * b6;
|
|
981
|
-
t15 += v * b7;
|
|
982
|
-
t16 += v * b8;
|
|
983
|
-
t17 += v * b9;
|
|
984
|
-
t18 += v * b10;
|
|
985
|
-
t19 += v * b11;
|
|
986
|
-
t20 += v * b12;
|
|
987
|
-
t21 += v * b13;
|
|
988
|
-
t22 += v * b14;
|
|
989
|
-
t23 += v * b15;
|
|
990
|
-
v = a[9];
|
|
991
|
-
t9 += v * b0;
|
|
992
|
-
t10 += v * b1;
|
|
993
|
-
t11 += v * b2;
|
|
994
|
-
t12 += v * b3;
|
|
995
|
-
t13 += v * b4;
|
|
996
|
-
t14 += v * b5;
|
|
997
|
-
t15 += v * b6;
|
|
998
|
-
t16 += v * b7;
|
|
999
|
-
t17 += v * b8;
|
|
1000
|
-
t18 += v * b9;
|
|
1001
|
-
t19 += v * b10;
|
|
1002
|
-
t20 += v * b11;
|
|
1003
|
-
t21 += v * b12;
|
|
1004
|
-
t22 += v * b13;
|
|
1005
|
-
t23 += v * b14;
|
|
1006
|
-
t24 += v * b15;
|
|
1007
|
-
v = a[10];
|
|
1008
|
-
t10 += v * b0;
|
|
1009
|
-
t11 += v * b1;
|
|
1010
|
-
t12 += v * b2;
|
|
1011
|
-
t13 += v * b3;
|
|
1012
|
-
t14 += v * b4;
|
|
1013
|
-
t15 += v * b5;
|
|
1014
|
-
t16 += v * b6;
|
|
1015
|
-
t17 += v * b7;
|
|
1016
|
-
t18 += v * b8;
|
|
1017
|
-
t19 += v * b9;
|
|
1018
|
-
t20 += v * b10;
|
|
1019
|
-
t21 += v * b11;
|
|
1020
|
-
t22 += v * b12;
|
|
1021
|
-
t23 += v * b13;
|
|
1022
|
-
t24 += v * b14;
|
|
1023
|
-
t25 += v * b15;
|
|
1024
|
-
v = a[11];
|
|
1025
|
-
t11 += v * b0;
|
|
1026
|
-
t12 += v * b1;
|
|
1027
|
-
t13 += v * b2;
|
|
1028
|
-
t14 += v * b3;
|
|
1029
|
-
t15 += v * b4;
|
|
1030
|
-
t16 += v * b5;
|
|
1031
|
-
t17 += v * b6;
|
|
1032
|
-
t18 += v * b7;
|
|
1033
|
-
t19 += v * b8;
|
|
1034
|
-
t20 += v * b9;
|
|
1035
|
-
t21 += v * b10;
|
|
1036
|
-
t22 += v * b11;
|
|
1037
|
-
t23 += v * b12;
|
|
1038
|
-
t24 += v * b13;
|
|
1039
|
-
t25 += v * b14;
|
|
1040
|
-
t26 += v * b15;
|
|
1041
|
-
v = a[12];
|
|
1042
|
-
t12 += v * b0;
|
|
1043
|
-
t13 += v * b1;
|
|
1044
|
-
t14 += v * b2;
|
|
1045
|
-
t15 += v * b3;
|
|
1046
|
-
t16 += v * b4;
|
|
1047
|
-
t17 += v * b5;
|
|
1048
|
-
t18 += v * b6;
|
|
1049
|
-
t19 += v * b7;
|
|
1050
|
-
t20 += v * b8;
|
|
1051
|
-
t21 += v * b9;
|
|
1052
|
-
t22 += v * b10;
|
|
1053
|
-
t23 += v * b11;
|
|
1054
|
-
t24 += v * b12;
|
|
1055
|
-
t25 += v * b13;
|
|
1056
|
-
t26 += v * b14;
|
|
1057
|
-
t27 += v * b15;
|
|
1058
|
-
v = a[13];
|
|
1059
|
-
t13 += v * b0;
|
|
1060
|
-
t14 += v * b1;
|
|
1061
|
-
t15 += v * b2;
|
|
1062
|
-
t16 += v * b3;
|
|
1063
|
-
t17 += v * b4;
|
|
1064
|
-
t18 += v * b5;
|
|
1065
|
-
t19 += v * b6;
|
|
1066
|
-
t20 += v * b7;
|
|
1067
|
-
t21 += v * b8;
|
|
1068
|
-
t22 += v * b9;
|
|
1069
|
-
t23 += v * b10;
|
|
1070
|
-
t24 += v * b11;
|
|
1071
|
-
t25 += v * b12;
|
|
1072
|
-
t26 += v * b13;
|
|
1073
|
-
t27 += v * b14;
|
|
1074
|
-
t28 += v * b15;
|
|
1075
|
-
v = a[14];
|
|
1076
|
-
t14 += v * b0;
|
|
1077
|
-
t15 += v * b1;
|
|
1078
|
-
t16 += v * b2;
|
|
1079
|
-
t17 += v * b3;
|
|
1080
|
-
t18 += v * b4;
|
|
1081
|
-
t19 += v * b5;
|
|
1082
|
-
t20 += v * b6;
|
|
1083
|
-
t21 += v * b7;
|
|
1084
|
-
t22 += v * b8;
|
|
1085
|
-
t23 += v * b9;
|
|
1086
|
-
t24 += v * b10;
|
|
1087
|
-
t25 += v * b11;
|
|
1088
|
-
t26 += v * b12;
|
|
1089
|
-
t27 += v * b13;
|
|
1090
|
-
t28 += v * b14;
|
|
1091
|
-
t29 += v * b15;
|
|
1092
|
-
v = a[15];
|
|
1093
|
-
t15 += v * b0;
|
|
1094
|
-
t16 += v * b1;
|
|
1095
|
-
t17 += v * b2;
|
|
1096
|
-
t18 += v * b3;
|
|
1097
|
-
t19 += v * b4;
|
|
1098
|
-
t20 += v * b5;
|
|
1099
|
-
t21 += v * b6;
|
|
1100
|
-
t22 += v * b7;
|
|
1101
|
-
t23 += v * b8;
|
|
1102
|
-
t24 += v * b9;
|
|
1103
|
-
t25 += v * b10;
|
|
1104
|
-
t26 += v * b11;
|
|
1105
|
-
t27 += v * b12;
|
|
1106
|
-
t28 += v * b13;
|
|
1107
|
-
t29 += v * b14;
|
|
1108
|
-
t30 += v * b15;
|
|
1109
|
-
t0 += 38 * t16;
|
|
1110
|
-
t1 += 38 * t17;
|
|
1111
|
-
t2 += 38 * t18;
|
|
1112
|
-
t3 += 38 * t19;
|
|
1113
|
-
t4 += 38 * t20;
|
|
1114
|
-
t5 += 38 * t21;
|
|
1115
|
-
t6 += 38 * t22;
|
|
1116
|
-
t7 += 38 * t23;
|
|
1117
|
-
t8 += 38 * t24;
|
|
1118
|
-
t9 += 38 * t25;
|
|
1119
|
-
t10 += 38 * t26;
|
|
1120
|
-
t11 += 38 * t27;
|
|
1121
|
-
t12 += 38 * t28;
|
|
1122
|
-
t13 += 38 * t29;
|
|
1123
|
-
t14 += 38 * t30;
|
|
1124
|
-
c = 1;
|
|
1125
|
-
v = t0 + c + 65535;
|
|
1126
|
-
c = Math.floor(v / 65536);
|
|
1127
|
-
t0 = v - c * 65536;
|
|
1128
|
-
v = t1 + c + 65535;
|
|
1129
|
-
c = Math.floor(v / 65536);
|
|
1130
|
-
t1 = v - c * 65536;
|
|
1131
|
-
v = t2 + c + 65535;
|
|
1132
|
-
c = Math.floor(v / 65536);
|
|
1133
|
-
t2 = v - c * 65536;
|
|
1134
|
-
v = t3 + c + 65535;
|
|
1135
|
-
c = Math.floor(v / 65536);
|
|
1136
|
-
t3 = v - c * 65536;
|
|
1137
|
-
v = t4 + c + 65535;
|
|
1138
|
-
c = Math.floor(v / 65536);
|
|
1139
|
-
t4 = v - c * 65536;
|
|
1140
|
-
v = t5 + c + 65535;
|
|
1141
|
-
c = Math.floor(v / 65536);
|
|
1142
|
-
t5 = v - c * 65536;
|
|
1143
|
-
v = t6 + c + 65535;
|
|
1144
|
-
c = Math.floor(v / 65536);
|
|
1145
|
-
t6 = v - c * 65536;
|
|
1146
|
-
v = t7 + c + 65535;
|
|
1147
|
-
c = Math.floor(v / 65536);
|
|
1148
|
-
t7 = v - c * 65536;
|
|
1149
|
-
v = t8 + c + 65535;
|
|
1150
|
-
c = Math.floor(v / 65536);
|
|
1151
|
-
t8 = v - c * 65536;
|
|
1152
|
-
v = t9 + c + 65535;
|
|
1153
|
-
c = Math.floor(v / 65536);
|
|
1154
|
-
t9 = v - c * 65536;
|
|
1155
|
-
v = t10 + c + 65535;
|
|
1156
|
-
c = Math.floor(v / 65536);
|
|
1157
|
-
t10 = v - c * 65536;
|
|
1158
|
-
v = t11 + c + 65535;
|
|
1159
|
-
c = Math.floor(v / 65536);
|
|
1160
|
-
t11 = v - c * 65536;
|
|
1161
|
-
v = t12 + c + 65535;
|
|
1162
|
-
c = Math.floor(v / 65536);
|
|
1163
|
-
t12 = v - c * 65536;
|
|
1164
|
-
v = t13 + c + 65535;
|
|
1165
|
-
c = Math.floor(v / 65536);
|
|
1166
|
-
t13 = v - c * 65536;
|
|
1167
|
-
v = t14 + c + 65535;
|
|
1168
|
-
c = Math.floor(v / 65536);
|
|
1169
|
-
t14 = v - c * 65536;
|
|
1170
|
-
v = t15 + c + 65535;
|
|
1171
|
-
c = Math.floor(v / 65536);
|
|
1172
|
-
t15 = v - c * 65536;
|
|
1173
|
-
t0 += c - 1 + 37 * (c - 1);
|
|
1174
|
-
c = 1;
|
|
1175
|
-
v = t0 + c + 65535;
|
|
1176
|
-
c = Math.floor(v / 65536);
|
|
1177
|
-
t0 = v - c * 65536;
|
|
1178
|
-
v = t1 + c + 65535;
|
|
1179
|
-
c = Math.floor(v / 65536);
|
|
1180
|
-
t1 = v - c * 65536;
|
|
1181
|
-
v = t2 + c + 65535;
|
|
1182
|
-
c = Math.floor(v / 65536);
|
|
1183
|
-
t2 = v - c * 65536;
|
|
1184
|
-
v = t3 + c + 65535;
|
|
1185
|
-
c = Math.floor(v / 65536);
|
|
1186
|
-
t3 = v - c * 65536;
|
|
1187
|
-
v = t4 + c + 65535;
|
|
1188
|
-
c = Math.floor(v / 65536);
|
|
1189
|
-
t4 = v - c * 65536;
|
|
1190
|
-
v = t5 + c + 65535;
|
|
1191
|
-
c = Math.floor(v / 65536);
|
|
1192
|
-
t5 = v - c * 65536;
|
|
1193
|
-
v = t6 + c + 65535;
|
|
1194
|
-
c = Math.floor(v / 65536);
|
|
1195
|
-
t6 = v - c * 65536;
|
|
1196
|
-
v = t7 + c + 65535;
|
|
1197
|
-
c = Math.floor(v / 65536);
|
|
1198
|
-
t7 = v - c * 65536;
|
|
1199
|
-
v = t8 + c + 65535;
|
|
1200
|
-
c = Math.floor(v / 65536);
|
|
1201
|
-
t8 = v - c * 65536;
|
|
1202
|
-
v = t9 + c + 65535;
|
|
1203
|
-
c = Math.floor(v / 65536);
|
|
1204
|
-
t9 = v - c * 65536;
|
|
1205
|
-
v = t10 + c + 65535;
|
|
1206
|
-
c = Math.floor(v / 65536);
|
|
1207
|
-
t10 = v - c * 65536;
|
|
1208
|
-
v = t11 + c + 65535;
|
|
1209
|
-
c = Math.floor(v / 65536);
|
|
1210
|
-
t11 = v - c * 65536;
|
|
1211
|
-
v = t12 + c + 65535;
|
|
1212
|
-
c = Math.floor(v / 65536);
|
|
1213
|
-
t12 = v - c * 65536;
|
|
1214
|
-
v = t13 + c + 65535;
|
|
1215
|
-
c = Math.floor(v / 65536);
|
|
1216
|
-
t13 = v - c * 65536;
|
|
1217
|
-
v = t14 + c + 65535;
|
|
1218
|
-
c = Math.floor(v / 65536);
|
|
1219
|
-
t14 = v - c * 65536;
|
|
1220
|
-
v = t15 + c + 65535;
|
|
1221
|
-
c = Math.floor(v / 65536);
|
|
1222
|
-
t15 = v - c * 65536;
|
|
1223
|
-
t0 += c - 1 + 37 * (c - 1);
|
|
1224
|
-
o[0] = t0;
|
|
1225
|
-
o[1] = t1;
|
|
1226
|
-
o[2] = t2;
|
|
1227
|
-
o[3] = t3;
|
|
1228
|
-
o[4] = t4;
|
|
1229
|
-
o[5] = t5;
|
|
1230
|
-
o[6] = t6;
|
|
1231
|
-
o[7] = t7;
|
|
1232
|
-
o[8] = t8;
|
|
1233
|
-
o[9] = t9;
|
|
1234
|
-
o[10] = t10;
|
|
1235
|
-
o[11] = t11;
|
|
1236
|
-
o[12] = t12;
|
|
1237
|
-
o[13] = t13;
|
|
1238
|
-
o[14] = t14;
|
|
1239
|
-
o[15] = t15;
|
|
1240
|
-
}
|
|
1241
|
-
function S(o, a) {
|
|
1242
|
-
M(o, a, a);
|
|
1243
|
-
}
|
|
1244
|
-
function inv25519(o, i) {
|
|
1245
|
-
var c = gf();
|
|
1246
|
-
var a;
|
|
1247
|
-
for (a = 0; a < 16; a++) c[a] = i[a];
|
|
1248
|
-
for (a = 253; a >= 0; a--) {
|
|
1249
|
-
S(c, c);
|
|
1250
|
-
if (a !== 2 && a !== 4) M(c, c, i);
|
|
1251
|
-
}
|
|
1252
|
-
for (a = 0; a < 16; a++) o[a] = c[a];
|
|
1253
|
-
}
|
|
1254
|
-
function pow2523(o, i) {
|
|
1255
|
-
var c = gf();
|
|
1256
|
-
var a;
|
|
1257
|
-
for (a = 0; a < 16; a++) c[a] = i[a];
|
|
1258
|
-
for (a = 250; a >= 0; a--) {
|
|
1259
|
-
S(c, c);
|
|
1260
|
-
if (a !== 1) M(c, c, i);
|
|
1261
|
-
}
|
|
1262
|
-
for (a = 0; a < 16; a++) o[a] = c[a];
|
|
1263
|
-
}
|
|
1264
|
-
function crypto_scalarmult(q, n, p) {
|
|
1265
|
-
var z = new Uint8Array(32);
|
|
1266
|
-
var x = new Float64Array(80), r, i;
|
|
1267
|
-
var a = gf(), b = gf(), c = gf(), d = gf(), e = gf(), f = gf();
|
|
1268
|
-
for (i = 0; i < 31; i++) z[i] = n[i];
|
|
1269
|
-
z[31] = n[31] & 127 | 64;
|
|
1270
|
-
z[0] &= 248;
|
|
1271
|
-
unpack25519(x, p);
|
|
1272
|
-
for (i = 0; i < 16; i++) {
|
|
1273
|
-
b[i] = x[i];
|
|
1274
|
-
d[i] = a[i] = c[i] = 0;
|
|
1275
|
-
}
|
|
1276
|
-
a[0] = d[0] = 1;
|
|
1277
|
-
for (i = 254; i >= 0; --i) {
|
|
1278
|
-
r = z[i >>> 3] >>> (i & 7) & 1;
|
|
1279
|
-
sel25519(a, b, r);
|
|
1280
|
-
sel25519(c, d, r);
|
|
1281
|
-
A(e, a, c);
|
|
1282
|
-
Z(a, a, c);
|
|
1283
|
-
A(c, b, d);
|
|
1284
|
-
Z(b, b, d);
|
|
1285
|
-
S(d, e);
|
|
1286
|
-
S(f, a);
|
|
1287
|
-
M(a, c, a);
|
|
1288
|
-
M(c, b, e);
|
|
1289
|
-
A(e, a, c);
|
|
1290
|
-
Z(a, a, c);
|
|
1291
|
-
S(b, a);
|
|
1292
|
-
Z(c, d, f);
|
|
1293
|
-
M(a, c, _121665);
|
|
1294
|
-
A(a, a, d);
|
|
1295
|
-
M(c, c, a);
|
|
1296
|
-
M(a, d, f);
|
|
1297
|
-
M(d, b, x);
|
|
1298
|
-
S(b, e);
|
|
1299
|
-
sel25519(a, b, r);
|
|
1300
|
-
sel25519(c, d, r);
|
|
1301
|
-
}
|
|
1302
|
-
for (i = 0; i < 16; i++) {
|
|
1303
|
-
x[i + 16] = a[i];
|
|
1304
|
-
x[i + 32] = c[i];
|
|
1305
|
-
x[i + 48] = b[i];
|
|
1306
|
-
x[i + 64] = d[i];
|
|
1307
|
-
}
|
|
1308
|
-
var x32 = x.subarray(32);
|
|
1309
|
-
var x16 = x.subarray(16);
|
|
1310
|
-
inv25519(x32, x32);
|
|
1311
|
-
M(x16, x16, x32);
|
|
1312
|
-
pack25519(q, x16);
|
|
1313
|
-
return 0;
|
|
1314
|
-
}
|
|
1315
|
-
function crypto_scalarmult_base(q, n) {
|
|
1316
|
-
return crypto_scalarmult(q, n, _9);
|
|
1317
|
-
}
|
|
1318
|
-
function crypto_box_keypair(y, x) {
|
|
1319
|
-
randombytes(x, 32);
|
|
1320
|
-
return crypto_scalarmult_base(y, x);
|
|
1321
|
-
}
|
|
1322
|
-
function crypto_box_beforenm(k, y, x) {
|
|
1323
|
-
var s = new Uint8Array(32);
|
|
1324
|
-
crypto_scalarmult(s, x, y);
|
|
1325
|
-
return crypto_core_hsalsa20(k, _0, s, sigma);
|
|
1326
|
-
}
|
|
1327
|
-
var crypto_box_afternm = crypto_secretbox;
|
|
1328
|
-
var crypto_box_open_afternm = crypto_secretbox_open;
|
|
1329
|
-
function crypto_box(c, m, d, n, y, x) {
|
|
1330
|
-
var k = new Uint8Array(32);
|
|
1331
|
-
crypto_box_beforenm(k, y, x);
|
|
1332
|
-
return crypto_box_afternm(c, m, d, n, k);
|
|
1333
|
-
}
|
|
1334
|
-
function crypto_box_open(m, c, d, n, y, x) {
|
|
1335
|
-
var k = new Uint8Array(32);
|
|
1336
|
-
crypto_box_beforenm(k, y, x);
|
|
1337
|
-
return crypto_box_open_afternm(m, c, d, n, k);
|
|
1338
|
-
}
|
|
1339
|
-
var K = [
|
|
1340
|
-
1116352408,
|
|
1341
|
-
3609767458,
|
|
1342
|
-
1899447441,
|
|
1343
|
-
602891725,
|
|
1344
|
-
3049323471,
|
|
1345
|
-
3964484399,
|
|
1346
|
-
3921009573,
|
|
1347
|
-
2173295548,
|
|
1348
|
-
961987163,
|
|
1349
|
-
4081628472,
|
|
1350
|
-
1508970993,
|
|
1351
|
-
3053834265,
|
|
1352
|
-
2453635748,
|
|
1353
|
-
2937671579,
|
|
1354
|
-
2870763221,
|
|
1355
|
-
3664609560,
|
|
1356
|
-
3624381080,
|
|
1357
|
-
2734883394,
|
|
1358
|
-
310598401,
|
|
1359
|
-
1164996542,
|
|
1360
|
-
607225278,
|
|
1361
|
-
1323610764,
|
|
1362
|
-
1426881987,
|
|
1363
|
-
3590304994,
|
|
1364
|
-
1925078388,
|
|
1365
|
-
4068182383,
|
|
1366
|
-
2162078206,
|
|
1367
|
-
991336113,
|
|
1368
|
-
2614888103,
|
|
1369
|
-
633803317,
|
|
1370
|
-
3248222580,
|
|
1371
|
-
3479774868,
|
|
1372
|
-
3835390401,
|
|
1373
|
-
2666613458,
|
|
1374
|
-
4022224774,
|
|
1375
|
-
944711139,
|
|
1376
|
-
264347078,
|
|
1377
|
-
2341262773,
|
|
1378
|
-
604807628,
|
|
1379
|
-
2007800933,
|
|
1380
|
-
770255983,
|
|
1381
|
-
1495990901,
|
|
1382
|
-
1249150122,
|
|
1383
|
-
1856431235,
|
|
1384
|
-
1555081692,
|
|
1385
|
-
3175218132,
|
|
1386
|
-
1996064986,
|
|
1387
|
-
2198950837,
|
|
1388
|
-
2554220882,
|
|
1389
|
-
3999719339,
|
|
1390
|
-
2821834349,
|
|
1391
|
-
766784016,
|
|
1392
|
-
2952996808,
|
|
1393
|
-
2566594879,
|
|
1394
|
-
3210313671,
|
|
1395
|
-
3203337956,
|
|
1396
|
-
3336571891,
|
|
1397
|
-
1034457026,
|
|
1398
|
-
3584528711,
|
|
1399
|
-
2466948901,
|
|
1400
|
-
113926993,
|
|
1401
|
-
3758326383,
|
|
1402
|
-
338241895,
|
|
1403
|
-
168717936,
|
|
1404
|
-
666307205,
|
|
1405
|
-
1188179964,
|
|
1406
|
-
773529912,
|
|
1407
|
-
1546045734,
|
|
1408
|
-
1294757372,
|
|
1409
|
-
1522805485,
|
|
1410
|
-
1396182291,
|
|
1411
|
-
2643833823,
|
|
1412
|
-
1695183700,
|
|
1413
|
-
2343527390,
|
|
1414
|
-
1986661051,
|
|
1415
|
-
1014477480,
|
|
1416
|
-
2177026350,
|
|
1417
|
-
1206759142,
|
|
1418
|
-
2456956037,
|
|
1419
|
-
344077627,
|
|
1420
|
-
2730485921,
|
|
1421
|
-
1290863460,
|
|
1422
|
-
2820302411,
|
|
1423
|
-
3158454273,
|
|
1424
|
-
3259730800,
|
|
1425
|
-
3505952657,
|
|
1426
|
-
3345764771,
|
|
1427
|
-
106217008,
|
|
1428
|
-
3516065817,
|
|
1429
|
-
3606008344,
|
|
1430
|
-
3600352804,
|
|
1431
|
-
1432725776,
|
|
1432
|
-
4094571909,
|
|
1433
|
-
1467031594,
|
|
1434
|
-
275423344,
|
|
1435
|
-
851169720,
|
|
1436
|
-
430227734,
|
|
1437
|
-
3100823752,
|
|
1438
|
-
506948616,
|
|
1439
|
-
1363258195,
|
|
1440
|
-
659060556,
|
|
1441
|
-
3750685593,
|
|
1442
|
-
883997877,
|
|
1443
|
-
3785050280,
|
|
1444
|
-
958139571,
|
|
1445
|
-
3318307427,
|
|
1446
|
-
1322822218,
|
|
1447
|
-
3812723403,
|
|
1448
|
-
1537002063,
|
|
1449
|
-
2003034995,
|
|
1450
|
-
1747873779,
|
|
1451
|
-
3602036899,
|
|
1452
|
-
1955562222,
|
|
1453
|
-
1575990012,
|
|
1454
|
-
2024104815,
|
|
1455
|
-
1125592928,
|
|
1456
|
-
2227730452,
|
|
1457
|
-
2716904306,
|
|
1458
|
-
2361852424,
|
|
1459
|
-
442776044,
|
|
1460
|
-
2428436474,
|
|
1461
|
-
593698344,
|
|
1462
|
-
2756734187,
|
|
1463
|
-
3733110249,
|
|
1464
|
-
3204031479,
|
|
1465
|
-
2999351573,
|
|
1466
|
-
3329325298,
|
|
1467
|
-
3815920427,
|
|
1468
|
-
3391569614,
|
|
1469
|
-
3928383900,
|
|
1470
|
-
3515267271,
|
|
1471
|
-
566280711,
|
|
1472
|
-
3940187606,
|
|
1473
|
-
3454069534,
|
|
1474
|
-
4118630271,
|
|
1475
|
-
4000239992,
|
|
1476
|
-
116418474,
|
|
1477
|
-
1914138554,
|
|
1478
|
-
174292421,
|
|
1479
|
-
2731055270,
|
|
1480
|
-
289380356,
|
|
1481
|
-
3203993006,
|
|
1482
|
-
460393269,
|
|
1483
|
-
320620315,
|
|
1484
|
-
685471733,
|
|
1485
|
-
587496836,
|
|
1486
|
-
852142971,
|
|
1487
|
-
1086792851,
|
|
1488
|
-
1017036298,
|
|
1489
|
-
365543100,
|
|
1490
|
-
1126000580,
|
|
1491
|
-
2618297676,
|
|
1492
|
-
1288033470,
|
|
1493
|
-
3409855158,
|
|
1494
|
-
1501505948,
|
|
1495
|
-
4234509866,
|
|
1496
|
-
1607167915,
|
|
1497
|
-
987167468,
|
|
1498
|
-
1816402316,
|
|
1499
|
-
1246189591
|
|
1500
|
-
];
|
|
1501
|
-
function crypto_hashblocks_hl(hh, hl, m, n) {
|
|
1502
|
-
var wh = new Int32Array(16), wl = new Int32Array(16), bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7, bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7, th, tl, i, j, h, l, a, b, c, d;
|
|
1503
|
-
var ah0 = hh[0], ah1 = hh[1], ah2 = hh[2], ah3 = hh[3], ah4 = hh[4], ah5 = hh[5], ah6 = hh[6], ah7 = hh[7], al0 = hl[0], al1 = hl[1], al2 = hl[2], al3 = hl[3], al4 = hl[4], al5 = hl[5], al6 = hl[6], al7 = hl[7];
|
|
1504
|
-
var pos = 0;
|
|
1505
|
-
while (n >= 128) {
|
|
1506
|
-
for (i = 0; i < 16; i++) {
|
|
1507
|
-
j = 8 * i + pos;
|
|
1508
|
-
wh[i] = m[j + 0] << 24 | m[j + 1] << 16 | m[j + 2] << 8 | m[j + 3];
|
|
1509
|
-
wl[i] = m[j + 4] << 24 | m[j + 5] << 16 | m[j + 6] << 8 | m[j + 7];
|
|
1510
|
-
}
|
|
1511
|
-
for (i = 0; i < 80; i++) {
|
|
1512
|
-
bh0 = ah0;
|
|
1513
|
-
bh1 = ah1;
|
|
1514
|
-
bh2 = ah2;
|
|
1515
|
-
bh3 = ah3;
|
|
1516
|
-
bh4 = ah4;
|
|
1517
|
-
bh5 = ah5;
|
|
1518
|
-
bh6 = ah6;
|
|
1519
|
-
bh7 = ah7;
|
|
1520
|
-
bl0 = al0;
|
|
1521
|
-
bl1 = al1;
|
|
1522
|
-
bl2 = al2;
|
|
1523
|
-
bl3 = al3;
|
|
1524
|
-
bl4 = al4;
|
|
1525
|
-
bl5 = al5;
|
|
1526
|
-
bl6 = al6;
|
|
1527
|
-
bl7 = al7;
|
|
1528
|
-
h = ah7;
|
|
1529
|
-
l = al7;
|
|
1530
|
-
a = l & 65535;
|
|
1531
|
-
b = l >>> 16;
|
|
1532
|
-
c = h & 65535;
|
|
1533
|
-
d = h >>> 16;
|
|
1534
|
-
h = (ah4 >>> 14 | al4 << 32 - 14) ^ (ah4 >>> 18 | al4 << 32 - 18) ^ (al4 >>> 41 - 32 | ah4 << 32 - (41 - 32));
|
|
1535
|
-
l = (al4 >>> 14 | ah4 << 32 - 14) ^ (al4 >>> 18 | ah4 << 32 - 18) ^ (ah4 >>> 41 - 32 | al4 << 32 - (41 - 32));
|
|
1536
|
-
a += l & 65535;
|
|
1537
|
-
b += l >>> 16;
|
|
1538
|
-
c += h & 65535;
|
|
1539
|
-
d += h >>> 16;
|
|
1540
|
-
h = ah4 & ah5 ^ ~ah4 & ah6;
|
|
1541
|
-
l = al4 & al5 ^ ~al4 & al6;
|
|
1542
|
-
a += l & 65535;
|
|
1543
|
-
b += l >>> 16;
|
|
1544
|
-
c += h & 65535;
|
|
1545
|
-
d += h >>> 16;
|
|
1546
|
-
h = K[i * 2];
|
|
1547
|
-
l = K[i * 2 + 1];
|
|
1548
|
-
a += l & 65535;
|
|
1549
|
-
b += l >>> 16;
|
|
1550
|
-
c += h & 65535;
|
|
1551
|
-
d += h >>> 16;
|
|
1552
|
-
h = wh[i % 16];
|
|
1553
|
-
l = wl[i % 16];
|
|
1554
|
-
a += l & 65535;
|
|
1555
|
-
b += l >>> 16;
|
|
1556
|
-
c += h & 65535;
|
|
1557
|
-
d += h >>> 16;
|
|
1558
|
-
b += a >>> 16;
|
|
1559
|
-
c += b >>> 16;
|
|
1560
|
-
d += c >>> 16;
|
|
1561
|
-
th = c & 65535 | d << 16;
|
|
1562
|
-
tl = a & 65535 | b << 16;
|
|
1563
|
-
h = th;
|
|
1564
|
-
l = tl;
|
|
1565
|
-
a = l & 65535;
|
|
1566
|
-
b = l >>> 16;
|
|
1567
|
-
c = h & 65535;
|
|
1568
|
-
d = h >>> 16;
|
|
1569
|
-
h = (ah0 >>> 28 | al0 << 32 - 28) ^ (al0 >>> 34 - 32 | ah0 << 32 - (34 - 32)) ^ (al0 >>> 39 - 32 | ah0 << 32 - (39 - 32));
|
|
1570
|
-
l = (al0 >>> 28 | ah0 << 32 - 28) ^ (ah0 >>> 34 - 32 | al0 << 32 - (34 - 32)) ^ (ah0 >>> 39 - 32 | al0 << 32 - (39 - 32));
|
|
1571
|
-
a += l & 65535;
|
|
1572
|
-
b += l >>> 16;
|
|
1573
|
-
c += h & 65535;
|
|
1574
|
-
d += h >>> 16;
|
|
1575
|
-
h = ah0 & ah1 ^ ah0 & ah2 ^ ah1 & ah2;
|
|
1576
|
-
l = al0 & al1 ^ al0 & al2 ^ al1 & al2;
|
|
1577
|
-
a += l & 65535;
|
|
1578
|
-
b += l >>> 16;
|
|
1579
|
-
c += h & 65535;
|
|
1580
|
-
d += h >>> 16;
|
|
1581
|
-
b += a >>> 16;
|
|
1582
|
-
c += b >>> 16;
|
|
1583
|
-
d += c >>> 16;
|
|
1584
|
-
bh7 = c & 65535 | d << 16;
|
|
1585
|
-
bl7 = a & 65535 | b << 16;
|
|
1586
|
-
h = bh3;
|
|
1587
|
-
l = bl3;
|
|
1588
|
-
a = l & 65535;
|
|
1589
|
-
b = l >>> 16;
|
|
1590
|
-
c = h & 65535;
|
|
1591
|
-
d = h >>> 16;
|
|
1592
|
-
h = th;
|
|
1593
|
-
l = tl;
|
|
1594
|
-
a += l & 65535;
|
|
1595
|
-
b += l >>> 16;
|
|
1596
|
-
c += h & 65535;
|
|
1597
|
-
d += h >>> 16;
|
|
1598
|
-
b += a >>> 16;
|
|
1599
|
-
c += b >>> 16;
|
|
1600
|
-
d += c >>> 16;
|
|
1601
|
-
bh3 = c & 65535 | d << 16;
|
|
1602
|
-
bl3 = a & 65535 | b << 16;
|
|
1603
|
-
ah1 = bh0;
|
|
1604
|
-
ah2 = bh1;
|
|
1605
|
-
ah3 = bh2;
|
|
1606
|
-
ah4 = bh3;
|
|
1607
|
-
ah5 = bh4;
|
|
1608
|
-
ah6 = bh5;
|
|
1609
|
-
ah7 = bh6;
|
|
1610
|
-
ah0 = bh7;
|
|
1611
|
-
al1 = bl0;
|
|
1612
|
-
al2 = bl1;
|
|
1613
|
-
al3 = bl2;
|
|
1614
|
-
al4 = bl3;
|
|
1615
|
-
al5 = bl4;
|
|
1616
|
-
al6 = bl5;
|
|
1617
|
-
al7 = bl6;
|
|
1618
|
-
al0 = bl7;
|
|
1619
|
-
if (i % 16 === 15) {
|
|
1620
|
-
for (j = 0; j < 16; j++) {
|
|
1621
|
-
h = wh[j];
|
|
1622
|
-
l = wl[j];
|
|
1623
|
-
a = l & 65535;
|
|
1624
|
-
b = l >>> 16;
|
|
1625
|
-
c = h & 65535;
|
|
1626
|
-
d = h >>> 16;
|
|
1627
|
-
h = wh[(j + 9) % 16];
|
|
1628
|
-
l = wl[(j + 9) % 16];
|
|
1629
|
-
a += l & 65535;
|
|
1630
|
-
b += l >>> 16;
|
|
1631
|
-
c += h & 65535;
|
|
1632
|
-
d += h >>> 16;
|
|
1633
|
-
th = wh[(j + 1) % 16];
|
|
1634
|
-
tl = wl[(j + 1) % 16];
|
|
1635
|
-
h = (th >>> 1 | tl << 32 - 1) ^ (th >>> 8 | tl << 32 - 8) ^ th >>> 7;
|
|
1636
|
-
l = (tl >>> 1 | th << 32 - 1) ^ (tl >>> 8 | th << 32 - 8) ^ (tl >>> 7 | th << 32 - 7);
|
|
1637
|
-
a += l & 65535;
|
|
1638
|
-
b += l >>> 16;
|
|
1639
|
-
c += h & 65535;
|
|
1640
|
-
d += h >>> 16;
|
|
1641
|
-
th = wh[(j + 14) % 16];
|
|
1642
|
-
tl = wl[(j + 14) % 16];
|
|
1643
|
-
h = (th >>> 19 | tl << 32 - 19) ^ (tl >>> 61 - 32 | th << 32 - (61 - 32)) ^ th >>> 6;
|
|
1644
|
-
l = (tl >>> 19 | th << 32 - 19) ^ (th >>> 61 - 32 | tl << 32 - (61 - 32)) ^ (tl >>> 6 | th << 32 - 6);
|
|
1645
|
-
a += l & 65535;
|
|
1646
|
-
b += l >>> 16;
|
|
1647
|
-
c += h & 65535;
|
|
1648
|
-
d += h >>> 16;
|
|
1649
|
-
b += a >>> 16;
|
|
1650
|
-
c += b >>> 16;
|
|
1651
|
-
d += c >>> 16;
|
|
1652
|
-
wh[j] = c & 65535 | d << 16;
|
|
1653
|
-
wl[j] = a & 65535 | b << 16;
|
|
1654
|
-
}
|
|
1655
|
-
}
|
|
1656
|
-
}
|
|
1657
|
-
h = ah0;
|
|
1658
|
-
l = al0;
|
|
1659
|
-
a = l & 65535;
|
|
1660
|
-
b = l >>> 16;
|
|
1661
|
-
c = h & 65535;
|
|
1662
|
-
d = h >>> 16;
|
|
1663
|
-
h = hh[0];
|
|
1664
|
-
l = hl[0];
|
|
1665
|
-
a += l & 65535;
|
|
1666
|
-
b += l >>> 16;
|
|
1667
|
-
c += h & 65535;
|
|
1668
|
-
d += h >>> 16;
|
|
1669
|
-
b += a >>> 16;
|
|
1670
|
-
c += b >>> 16;
|
|
1671
|
-
d += c >>> 16;
|
|
1672
|
-
hh[0] = ah0 = c & 65535 | d << 16;
|
|
1673
|
-
hl[0] = al0 = a & 65535 | b << 16;
|
|
1674
|
-
h = ah1;
|
|
1675
|
-
l = al1;
|
|
1676
|
-
a = l & 65535;
|
|
1677
|
-
b = l >>> 16;
|
|
1678
|
-
c = h & 65535;
|
|
1679
|
-
d = h >>> 16;
|
|
1680
|
-
h = hh[1];
|
|
1681
|
-
l = hl[1];
|
|
1682
|
-
a += l & 65535;
|
|
1683
|
-
b += l >>> 16;
|
|
1684
|
-
c += h & 65535;
|
|
1685
|
-
d += h >>> 16;
|
|
1686
|
-
b += a >>> 16;
|
|
1687
|
-
c += b >>> 16;
|
|
1688
|
-
d += c >>> 16;
|
|
1689
|
-
hh[1] = ah1 = c & 65535 | d << 16;
|
|
1690
|
-
hl[1] = al1 = a & 65535 | b << 16;
|
|
1691
|
-
h = ah2;
|
|
1692
|
-
l = al2;
|
|
1693
|
-
a = l & 65535;
|
|
1694
|
-
b = l >>> 16;
|
|
1695
|
-
c = h & 65535;
|
|
1696
|
-
d = h >>> 16;
|
|
1697
|
-
h = hh[2];
|
|
1698
|
-
l = hl[2];
|
|
1699
|
-
a += l & 65535;
|
|
1700
|
-
b += l >>> 16;
|
|
1701
|
-
c += h & 65535;
|
|
1702
|
-
d += h >>> 16;
|
|
1703
|
-
b += a >>> 16;
|
|
1704
|
-
c += b >>> 16;
|
|
1705
|
-
d += c >>> 16;
|
|
1706
|
-
hh[2] = ah2 = c & 65535 | d << 16;
|
|
1707
|
-
hl[2] = al2 = a & 65535 | b << 16;
|
|
1708
|
-
h = ah3;
|
|
1709
|
-
l = al3;
|
|
1710
|
-
a = l & 65535;
|
|
1711
|
-
b = l >>> 16;
|
|
1712
|
-
c = h & 65535;
|
|
1713
|
-
d = h >>> 16;
|
|
1714
|
-
h = hh[3];
|
|
1715
|
-
l = hl[3];
|
|
1716
|
-
a += l & 65535;
|
|
1717
|
-
b += l >>> 16;
|
|
1718
|
-
c += h & 65535;
|
|
1719
|
-
d += h >>> 16;
|
|
1720
|
-
b += a >>> 16;
|
|
1721
|
-
c += b >>> 16;
|
|
1722
|
-
d += c >>> 16;
|
|
1723
|
-
hh[3] = ah3 = c & 65535 | d << 16;
|
|
1724
|
-
hl[3] = al3 = a & 65535 | b << 16;
|
|
1725
|
-
h = ah4;
|
|
1726
|
-
l = al4;
|
|
1727
|
-
a = l & 65535;
|
|
1728
|
-
b = l >>> 16;
|
|
1729
|
-
c = h & 65535;
|
|
1730
|
-
d = h >>> 16;
|
|
1731
|
-
h = hh[4];
|
|
1732
|
-
l = hl[4];
|
|
1733
|
-
a += l & 65535;
|
|
1734
|
-
b += l >>> 16;
|
|
1735
|
-
c += h & 65535;
|
|
1736
|
-
d += h >>> 16;
|
|
1737
|
-
b += a >>> 16;
|
|
1738
|
-
c += b >>> 16;
|
|
1739
|
-
d += c >>> 16;
|
|
1740
|
-
hh[4] = ah4 = c & 65535 | d << 16;
|
|
1741
|
-
hl[4] = al4 = a & 65535 | b << 16;
|
|
1742
|
-
h = ah5;
|
|
1743
|
-
l = al5;
|
|
1744
|
-
a = l & 65535;
|
|
1745
|
-
b = l >>> 16;
|
|
1746
|
-
c = h & 65535;
|
|
1747
|
-
d = h >>> 16;
|
|
1748
|
-
h = hh[5];
|
|
1749
|
-
l = hl[5];
|
|
1750
|
-
a += l & 65535;
|
|
1751
|
-
b += l >>> 16;
|
|
1752
|
-
c += h & 65535;
|
|
1753
|
-
d += h >>> 16;
|
|
1754
|
-
b += a >>> 16;
|
|
1755
|
-
c += b >>> 16;
|
|
1756
|
-
d += c >>> 16;
|
|
1757
|
-
hh[5] = ah5 = c & 65535 | d << 16;
|
|
1758
|
-
hl[5] = al5 = a & 65535 | b << 16;
|
|
1759
|
-
h = ah6;
|
|
1760
|
-
l = al6;
|
|
1761
|
-
a = l & 65535;
|
|
1762
|
-
b = l >>> 16;
|
|
1763
|
-
c = h & 65535;
|
|
1764
|
-
d = h >>> 16;
|
|
1765
|
-
h = hh[6];
|
|
1766
|
-
l = hl[6];
|
|
1767
|
-
a += l & 65535;
|
|
1768
|
-
b += l >>> 16;
|
|
1769
|
-
c += h & 65535;
|
|
1770
|
-
d += h >>> 16;
|
|
1771
|
-
b += a >>> 16;
|
|
1772
|
-
c += b >>> 16;
|
|
1773
|
-
d += c >>> 16;
|
|
1774
|
-
hh[6] = ah6 = c & 65535 | d << 16;
|
|
1775
|
-
hl[6] = al6 = a & 65535 | b << 16;
|
|
1776
|
-
h = ah7;
|
|
1777
|
-
l = al7;
|
|
1778
|
-
a = l & 65535;
|
|
1779
|
-
b = l >>> 16;
|
|
1780
|
-
c = h & 65535;
|
|
1781
|
-
d = h >>> 16;
|
|
1782
|
-
h = hh[7];
|
|
1783
|
-
l = hl[7];
|
|
1784
|
-
a += l & 65535;
|
|
1785
|
-
b += l >>> 16;
|
|
1786
|
-
c += h & 65535;
|
|
1787
|
-
d += h >>> 16;
|
|
1788
|
-
b += a >>> 16;
|
|
1789
|
-
c += b >>> 16;
|
|
1790
|
-
d += c >>> 16;
|
|
1791
|
-
hh[7] = ah7 = c & 65535 | d << 16;
|
|
1792
|
-
hl[7] = al7 = a & 65535 | b << 16;
|
|
1793
|
-
pos += 128;
|
|
1794
|
-
n -= 128;
|
|
1795
|
-
}
|
|
1796
|
-
return n;
|
|
1797
|
-
}
|
|
1798
|
-
function crypto_hash(out, m, n) {
|
|
1799
|
-
var hh = new Int32Array(8), hl = new Int32Array(8), x = new Uint8Array(256), i, b = n;
|
|
1800
|
-
hh[0] = 1779033703;
|
|
1801
|
-
hh[1] = 3144134277;
|
|
1802
|
-
hh[2] = 1013904242;
|
|
1803
|
-
hh[3] = 2773480762;
|
|
1804
|
-
hh[4] = 1359893119;
|
|
1805
|
-
hh[5] = 2600822924;
|
|
1806
|
-
hh[6] = 528734635;
|
|
1807
|
-
hh[7] = 1541459225;
|
|
1808
|
-
hl[0] = 4089235720;
|
|
1809
|
-
hl[1] = 2227873595;
|
|
1810
|
-
hl[2] = 4271175723;
|
|
1811
|
-
hl[3] = 1595750129;
|
|
1812
|
-
hl[4] = 2917565137;
|
|
1813
|
-
hl[5] = 725511199;
|
|
1814
|
-
hl[6] = 4215389547;
|
|
1815
|
-
hl[7] = 327033209;
|
|
1816
|
-
crypto_hashblocks_hl(hh, hl, m, n);
|
|
1817
|
-
n %= 128;
|
|
1818
|
-
for (i = 0; i < n; i++) x[i] = m[b - n + i];
|
|
1819
|
-
x[n] = 128;
|
|
1820
|
-
n = 256 - 128 * (n < 112 ? 1 : 0);
|
|
1821
|
-
x[n - 9] = 0;
|
|
1822
|
-
ts64(x, n - 8, b / 536870912 | 0, b << 3);
|
|
1823
|
-
crypto_hashblocks_hl(hh, hl, x, n);
|
|
1824
|
-
for (i = 0; i < 8; i++) ts64(out, 8 * i, hh[i], hl[i]);
|
|
1825
|
-
return 0;
|
|
1826
|
-
}
|
|
1827
|
-
function add(p, q) {
|
|
1828
|
-
var a = gf(), b = gf(), c = gf(), d = gf(), e = gf(), f = gf(), g = gf(), h = gf(), t = gf();
|
|
1829
|
-
Z(a, p[1], p[0]);
|
|
1830
|
-
Z(t, q[1], q[0]);
|
|
1831
|
-
M(a, a, t);
|
|
1832
|
-
A(b, p[0], p[1]);
|
|
1833
|
-
A(t, q[0], q[1]);
|
|
1834
|
-
M(b, b, t);
|
|
1835
|
-
M(c, p[3], q[3]);
|
|
1836
|
-
M(c, c, D2);
|
|
1837
|
-
M(d, p[2], q[2]);
|
|
1838
|
-
A(d, d, d);
|
|
1839
|
-
Z(e, b, a);
|
|
1840
|
-
Z(f, d, c);
|
|
1841
|
-
A(g, d, c);
|
|
1842
|
-
A(h, b, a);
|
|
1843
|
-
M(p[0], e, f);
|
|
1844
|
-
M(p[1], h, g);
|
|
1845
|
-
M(p[2], g, f);
|
|
1846
|
-
M(p[3], e, h);
|
|
1847
|
-
}
|
|
1848
|
-
function cswap(p, q, b) {
|
|
1849
|
-
var i;
|
|
1850
|
-
for (i = 0; i < 4; i++) {
|
|
1851
|
-
sel25519(p[i], q[i], b);
|
|
1852
|
-
}
|
|
1853
|
-
}
|
|
1854
|
-
function pack(r, p) {
|
|
1855
|
-
var tx = gf(), ty = gf(), zi = gf();
|
|
1856
|
-
inv25519(zi, p[2]);
|
|
1857
|
-
M(tx, p[0], zi);
|
|
1858
|
-
M(ty, p[1], zi);
|
|
1859
|
-
pack25519(r, ty);
|
|
1860
|
-
r[31] ^= par25519(tx) << 7;
|
|
1861
|
-
}
|
|
1862
|
-
function scalarmult(p, q, s) {
|
|
1863
|
-
var b, i;
|
|
1864
|
-
set25519(p[0], gf0);
|
|
1865
|
-
set25519(p[1], gf1);
|
|
1866
|
-
set25519(p[2], gf1);
|
|
1867
|
-
set25519(p[3], gf0);
|
|
1868
|
-
for (i = 255; i >= 0; --i) {
|
|
1869
|
-
b = s[i / 8 | 0] >> (i & 7) & 1;
|
|
1870
|
-
cswap(p, q, b);
|
|
1871
|
-
add(q, p);
|
|
1872
|
-
add(p, p);
|
|
1873
|
-
cswap(p, q, b);
|
|
1874
|
-
}
|
|
1875
|
-
}
|
|
1876
|
-
function scalarbase(p, s) {
|
|
1877
|
-
var q = [gf(), gf(), gf(), gf()];
|
|
1878
|
-
set25519(q[0], X);
|
|
1879
|
-
set25519(q[1], Y);
|
|
1880
|
-
set25519(q[2], gf1);
|
|
1881
|
-
M(q[3], X, Y);
|
|
1882
|
-
scalarmult(p, q, s);
|
|
1883
|
-
}
|
|
1884
|
-
function crypto_sign_keypair(pk, sk, seeded) {
|
|
1885
|
-
var d = new Uint8Array(64);
|
|
1886
|
-
var p = [gf(), gf(), gf(), gf()];
|
|
1887
|
-
var i;
|
|
1888
|
-
if (!seeded) randombytes(sk, 32);
|
|
1889
|
-
crypto_hash(d, sk, 32);
|
|
1890
|
-
d[0] &= 248;
|
|
1891
|
-
d[31] &= 127;
|
|
1892
|
-
d[31] |= 64;
|
|
1893
|
-
scalarbase(p, d);
|
|
1894
|
-
pack(pk, p);
|
|
1895
|
-
for (i = 0; i < 32; i++) sk[i + 32] = pk[i];
|
|
1896
|
-
return 0;
|
|
1897
|
-
}
|
|
1898
|
-
var L = new Float64Array([237, 211, 245, 92, 26, 99, 18, 88, 214, 156, 247, 162, 222, 249, 222, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16]);
|
|
1899
|
-
function modL(r, x) {
|
|
1900
|
-
var carry, i, j, k;
|
|
1901
|
-
for (i = 63; i >= 32; --i) {
|
|
1902
|
-
carry = 0;
|
|
1903
|
-
for (j = i - 32, k = i - 12; j < k; ++j) {
|
|
1904
|
-
x[j] += carry - 16 * x[i] * L[j - (i - 32)];
|
|
1905
|
-
carry = Math.floor((x[j] + 128) / 256);
|
|
1906
|
-
x[j] -= carry * 256;
|
|
1907
|
-
}
|
|
1908
|
-
x[j] += carry;
|
|
1909
|
-
x[i] = 0;
|
|
1910
|
-
}
|
|
1911
|
-
carry = 0;
|
|
1912
|
-
for (j = 0; j < 32; j++) {
|
|
1913
|
-
x[j] += carry - (x[31] >> 4) * L[j];
|
|
1914
|
-
carry = x[j] >> 8;
|
|
1915
|
-
x[j] &= 255;
|
|
1916
|
-
}
|
|
1917
|
-
for (j = 0; j < 32; j++) x[j] -= carry * L[j];
|
|
1918
|
-
for (i = 0; i < 32; i++) {
|
|
1919
|
-
x[i + 1] += x[i] >> 8;
|
|
1920
|
-
r[i] = x[i] & 255;
|
|
1921
|
-
}
|
|
1922
|
-
}
|
|
1923
|
-
function reduce(r) {
|
|
1924
|
-
var x = new Float64Array(64), i;
|
|
1925
|
-
for (i = 0; i < 64; i++) x[i] = r[i];
|
|
1926
|
-
for (i = 0; i < 64; i++) r[i] = 0;
|
|
1927
|
-
modL(r, x);
|
|
1928
|
-
}
|
|
1929
|
-
function crypto_sign(sm, m, n, sk) {
|
|
1930
|
-
var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);
|
|
1931
|
-
var i, j, x = new Float64Array(64);
|
|
1932
|
-
var p = [gf(), gf(), gf(), gf()];
|
|
1933
|
-
crypto_hash(d, sk, 32);
|
|
1934
|
-
d[0] &= 248;
|
|
1935
|
-
d[31] &= 127;
|
|
1936
|
-
d[31] |= 64;
|
|
1937
|
-
var smlen = n + 64;
|
|
1938
|
-
for (i = 0; i < n; i++) sm[64 + i] = m[i];
|
|
1939
|
-
for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];
|
|
1940
|
-
crypto_hash(r, sm.subarray(32), n + 32);
|
|
1941
|
-
reduce(r);
|
|
1942
|
-
scalarbase(p, r);
|
|
1943
|
-
pack(sm, p);
|
|
1944
|
-
for (i = 32; i < 64; i++) sm[i] = sk[i];
|
|
1945
|
-
crypto_hash(h, sm, n + 64);
|
|
1946
|
-
reduce(h);
|
|
1947
|
-
for (i = 0; i < 64; i++) x[i] = 0;
|
|
1948
|
-
for (i = 0; i < 32; i++) x[i] = r[i];
|
|
1949
|
-
for (i = 0; i < 32; i++) {
|
|
1950
|
-
for (j = 0; j < 32; j++) {
|
|
1951
|
-
x[i + j] += h[i] * d[j];
|
|
1952
|
-
}
|
|
1953
|
-
}
|
|
1954
|
-
modL(sm.subarray(32), x);
|
|
1955
|
-
return smlen;
|
|
1956
|
-
}
|
|
1957
|
-
function unpackneg(r, p) {
|
|
1958
|
-
var t = gf(), chk = gf(), num = gf(), den = gf(), den2 = gf(), den4 = gf(), den6 = gf();
|
|
1959
|
-
set25519(r[2], gf1);
|
|
1960
|
-
unpack25519(r[1], p);
|
|
1961
|
-
S(num, r[1]);
|
|
1962
|
-
M(den, num, D);
|
|
1963
|
-
Z(num, num, r[2]);
|
|
1964
|
-
A(den, r[2], den);
|
|
1965
|
-
S(den2, den);
|
|
1966
|
-
S(den4, den2);
|
|
1967
|
-
M(den6, den4, den2);
|
|
1968
|
-
M(t, den6, num);
|
|
1969
|
-
M(t, t, den);
|
|
1970
|
-
pow2523(t, t);
|
|
1971
|
-
M(t, t, num);
|
|
1972
|
-
M(t, t, den);
|
|
1973
|
-
M(t, t, den);
|
|
1974
|
-
M(r[0], t, den);
|
|
1975
|
-
S(chk, r[0]);
|
|
1976
|
-
M(chk, chk, den);
|
|
1977
|
-
if (neq25519(chk, num)) M(r[0], r[0], I);
|
|
1978
|
-
S(chk, r[0]);
|
|
1979
|
-
M(chk, chk, den);
|
|
1980
|
-
if (neq25519(chk, num)) return -1;
|
|
1981
|
-
if (par25519(r[0]) === p[31] >> 7) Z(r[0], gf0, r[0]);
|
|
1982
|
-
M(r[3], r[0], r[1]);
|
|
1983
|
-
return 0;
|
|
1984
|
-
}
|
|
1985
|
-
function crypto_sign_open(m, sm, n, pk) {
|
|
1986
|
-
var i;
|
|
1987
|
-
var t = new Uint8Array(32), h = new Uint8Array(64);
|
|
1988
|
-
var p = [gf(), gf(), gf(), gf()], q = [gf(), gf(), gf(), gf()];
|
|
1989
|
-
if (n < 64) return -1;
|
|
1990
|
-
if (unpackneg(q, pk)) return -1;
|
|
1991
|
-
for (i = 0; i < n; i++) m[i] = sm[i];
|
|
1992
|
-
for (i = 0; i < 32; i++) m[i + 32] = pk[i];
|
|
1993
|
-
crypto_hash(h, m, n);
|
|
1994
|
-
reduce(h);
|
|
1995
|
-
scalarmult(p, q, h);
|
|
1996
|
-
scalarbase(q, sm.subarray(32));
|
|
1997
|
-
add(p, q);
|
|
1998
|
-
pack(t, p);
|
|
1999
|
-
n -= 64;
|
|
2000
|
-
if (crypto_verify_32(sm, 0, t, 0)) {
|
|
2001
|
-
for (i = 0; i < n; i++) m[i] = 0;
|
|
2002
|
-
return -1;
|
|
2003
|
-
}
|
|
2004
|
-
for (i = 0; i < n; i++) m[i] = sm[i + 64];
|
|
2005
|
-
return n;
|
|
2006
|
-
}
|
|
2007
|
-
var crypto_secretbox_KEYBYTES = 32, crypto_secretbox_NONCEBYTES = 24, crypto_secretbox_ZEROBYTES = 32, crypto_secretbox_BOXZEROBYTES = 16, crypto_scalarmult_BYTES = 32, crypto_scalarmult_SCALARBYTES = 32, crypto_box_PUBLICKEYBYTES = 32, crypto_box_SECRETKEYBYTES = 32, crypto_box_BEFORENMBYTES = 32, crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES, crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES, crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES, crypto_sign_BYTES = 64, crypto_sign_PUBLICKEYBYTES = 32, crypto_sign_SECRETKEYBYTES = 64, crypto_sign_SEEDBYTES = 32, crypto_hash_BYTES = 64;
|
|
2008
|
-
nacl.lowlevel = {
|
|
2009
|
-
crypto_core_hsalsa20,
|
|
2010
|
-
crypto_stream_xor,
|
|
2011
|
-
crypto_stream,
|
|
2012
|
-
crypto_stream_salsa20_xor,
|
|
2013
|
-
crypto_stream_salsa20,
|
|
2014
|
-
crypto_onetimeauth,
|
|
2015
|
-
crypto_onetimeauth_verify,
|
|
2016
|
-
crypto_verify_16,
|
|
2017
|
-
crypto_verify_32,
|
|
2018
|
-
crypto_secretbox,
|
|
2019
|
-
crypto_secretbox_open,
|
|
2020
|
-
crypto_scalarmult,
|
|
2021
|
-
crypto_scalarmult_base,
|
|
2022
|
-
crypto_box_beforenm,
|
|
2023
|
-
crypto_box_afternm,
|
|
2024
|
-
crypto_box,
|
|
2025
|
-
crypto_box_open,
|
|
2026
|
-
crypto_box_keypair,
|
|
2027
|
-
crypto_hash,
|
|
2028
|
-
crypto_sign,
|
|
2029
|
-
crypto_sign_keypair,
|
|
2030
|
-
crypto_sign_open,
|
|
2031
|
-
crypto_secretbox_KEYBYTES,
|
|
2032
|
-
crypto_secretbox_NONCEBYTES,
|
|
2033
|
-
crypto_secretbox_ZEROBYTES,
|
|
2034
|
-
crypto_secretbox_BOXZEROBYTES,
|
|
2035
|
-
crypto_scalarmult_BYTES,
|
|
2036
|
-
crypto_scalarmult_SCALARBYTES,
|
|
2037
|
-
crypto_box_PUBLICKEYBYTES,
|
|
2038
|
-
crypto_box_SECRETKEYBYTES,
|
|
2039
|
-
crypto_box_BEFORENMBYTES,
|
|
2040
|
-
crypto_box_NONCEBYTES,
|
|
2041
|
-
crypto_box_ZEROBYTES,
|
|
2042
|
-
crypto_box_BOXZEROBYTES,
|
|
2043
|
-
crypto_sign_BYTES,
|
|
2044
|
-
crypto_sign_PUBLICKEYBYTES,
|
|
2045
|
-
crypto_sign_SECRETKEYBYTES,
|
|
2046
|
-
crypto_sign_SEEDBYTES,
|
|
2047
|
-
crypto_hash_BYTES,
|
|
2048
|
-
gf,
|
|
2049
|
-
D,
|
|
2050
|
-
L,
|
|
2051
|
-
pack25519,
|
|
2052
|
-
unpack25519,
|
|
2053
|
-
M,
|
|
2054
|
-
A,
|
|
2055
|
-
S,
|
|
2056
|
-
Z,
|
|
2057
|
-
pow2523,
|
|
2058
|
-
add,
|
|
2059
|
-
set25519,
|
|
2060
|
-
modL,
|
|
2061
|
-
scalarmult,
|
|
2062
|
-
scalarbase
|
|
2063
|
-
};
|
|
2064
|
-
function checkLengths(k, n) {
|
|
2065
|
-
if (k.length !== crypto_secretbox_KEYBYTES) throw new Error("bad key size");
|
|
2066
|
-
if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error("bad nonce size");
|
|
2067
|
-
}
|
|
2068
|
-
function checkBoxLengths(pk, sk) {
|
|
2069
|
-
if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error("bad public key size");
|
|
2070
|
-
if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error("bad secret key size");
|
|
2071
|
-
}
|
|
2072
|
-
function checkArrayTypes() {
|
|
2073
|
-
for (var i = 0; i < arguments.length; i++) {
|
|
2074
|
-
if (!(arguments[i] instanceof Uint8Array))
|
|
2075
|
-
throw new TypeError("unexpected type, use Uint8Array");
|
|
2076
|
-
}
|
|
2077
|
-
}
|
|
2078
|
-
function cleanup(arr) {
|
|
2079
|
-
for (var i = 0; i < arr.length; i++) arr[i] = 0;
|
|
2080
|
-
}
|
|
2081
|
-
nacl.randomBytes = function(n) {
|
|
2082
|
-
var b = new Uint8Array(n);
|
|
2083
|
-
randombytes(b, n);
|
|
2084
|
-
return b;
|
|
2085
|
-
};
|
|
2086
|
-
nacl.secretbox = function(msg, nonce, key) {
|
|
2087
|
-
checkArrayTypes(msg, nonce, key);
|
|
2088
|
-
checkLengths(key, nonce);
|
|
2089
|
-
var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);
|
|
2090
|
-
var c = new Uint8Array(m.length);
|
|
2091
|
-
for (var i = 0; i < msg.length; i++) m[i + crypto_secretbox_ZEROBYTES] = msg[i];
|
|
2092
|
-
crypto_secretbox(c, m, m.length, nonce, key);
|
|
2093
|
-
return c.subarray(crypto_secretbox_BOXZEROBYTES);
|
|
2094
|
-
};
|
|
2095
|
-
nacl.secretbox.open = function(box, nonce, key) {
|
|
2096
|
-
checkArrayTypes(box, nonce, key);
|
|
2097
|
-
checkLengths(key, nonce);
|
|
2098
|
-
var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);
|
|
2099
|
-
var m = new Uint8Array(c.length);
|
|
2100
|
-
for (var i = 0; i < box.length; i++) c[i + crypto_secretbox_BOXZEROBYTES] = box[i];
|
|
2101
|
-
if (c.length < 32) return null;
|
|
2102
|
-
if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;
|
|
2103
|
-
return m.subarray(crypto_secretbox_ZEROBYTES);
|
|
2104
|
-
};
|
|
2105
|
-
nacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;
|
|
2106
|
-
nacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;
|
|
2107
|
-
nacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;
|
|
2108
|
-
nacl.scalarMult = function(n, p) {
|
|
2109
|
-
checkArrayTypes(n, p);
|
|
2110
|
-
if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error("bad n size");
|
|
2111
|
-
if (p.length !== crypto_scalarmult_BYTES) throw new Error("bad p size");
|
|
2112
|
-
var q = new Uint8Array(crypto_scalarmult_BYTES);
|
|
2113
|
-
crypto_scalarmult(q, n, p);
|
|
2114
|
-
return q;
|
|
2115
|
-
};
|
|
2116
|
-
nacl.scalarMult.base = function(n) {
|
|
2117
|
-
checkArrayTypes(n);
|
|
2118
|
-
if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error("bad n size");
|
|
2119
|
-
var q = new Uint8Array(crypto_scalarmult_BYTES);
|
|
2120
|
-
crypto_scalarmult_base(q, n);
|
|
2121
|
-
return q;
|
|
2122
|
-
};
|
|
2123
|
-
nacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;
|
|
2124
|
-
nacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;
|
|
2125
|
-
nacl.box = function(msg, nonce, publicKey, secretKey) {
|
|
2126
|
-
var k = nacl.box.before(publicKey, secretKey);
|
|
2127
|
-
return nacl.secretbox(msg, nonce, k);
|
|
2128
|
-
};
|
|
2129
|
-
nacl.box.before = function(publicKey, secretKey) {
|
|
2130
|
-
checkArrayTypes(publicKey, secretKey);
|
|
2131
|
-
checkBoxLengths(publicKey, secretKey);
|
|
2132
|
-
var k = new Uint8Array(crypto_box_BEFORENMBYTES);
|
|
2133
|
-
crypto_box_beforenm(k, publicKey, secretKey);
|
|
2134
|
-
return k;
|
|
2135
|
-
};
|
|
2136
|
-
nacl.box.after = nacl.secretbox;
|
|
2137
|
-
nacl.box.open = function(msg, nonce, publicKey, secretKey) {
|
|
2138
|
-
var k = nacl.box.before(publicKey, secretKey);
|
|
2139
|
-
return nacl.secretbox.open(msg, nonce, k);
|
|
2140
|
-
};
|
|
2141
|
-
nacl.box.open.after = nacl.secretbox.open;
|
|
2142
|
-
nacl.box.keyPair = function() {
|
|
2143
|
-
var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
|
|
2144
|
-
var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);
|
|
2145
|
-
crypto_box_keypair(pk, sk);
|
|
2146
|
-
return { publicKey: pk, secretKey: sk };
|
|
2147
|
-
};
|
|
2148
|
-
nacl.box.keyPair.fromSecretKey = function(secretKey) {
|
|
2149
|
-
checkArrayTypes(secretKey);
|
|
2150
|
-
if (secretKey.length !== crypto_box_SECRETKEYBYTES)
|
|
2151
|
-
throw new Error("bad secret key size");
|
|
2152
|
-
var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
|
|
2153
|
-
crypto_scalarmult_base(pk, secretKey);
|
|
2154
|
-
return { publicKey: pk, secretKey: new Uint8Array(secretKey) };
|
|
2155
|
-
};
|
|
2156
|
-
nacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;
|
|
2157
|
-
nacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;
|
|
2158
|
-
nacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;
|
|
2159
|
-
nacl.box.nonceLength = crypto_box_NONCEBYTES;
|
|
2160
|
-
nacl.box.overheadLength = nacl.secretbox.overheadLength;
|
|
2161
|
-
nacl.sign = function(msg, secretKey) {
|
|
2162
|
-
checkArrayTypes(msg, secretKey);
|
|
2163
|
-
if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
|
|
2164
|
-
throw new Error("bad secret key size");
|
|
2165
|
-
var signedMsg = new Uint8Array(crypto_sign_BYTES + msg.length);
|
|
2166
|
-
crypto_sign(signedMsg, msg, msg.length, secretKey);
|
|
2167
|
-
return signedMsg;
|
|
2168
|
-
};
|
|
2169
|
-
nacl.sign.open = function(signedMsg, publicKey) {
|
|
2170
|
-
checkArrayTypes(signedMsg, publicKey);
|
|
2171
|
-
if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
|
|
2172
|
-
throw new Error("bad public key size");
|
|
2173
|
-
var tmp = new Uint8Array(signedMsg.length);
|
|
2174
|
-
var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);
|
|
2175
|
-
if (mlen < 0) return null;
|
|
2176
|
-
var m = new Uint8Array(mlen);
|
|
2177
|
-
for (var i = 0; i < m.length; i++) m[i] = tmp[i];
|
|
2178
|
-
return m;
|
|
2179
|
-
};
|
|
2180
|
-
nacl.sign.detached = function(msg, secretKey) {
|
|
2181
|
-
var signedMsg = nacl.sign(msg, secretKey);
|
|
2182
|
-
var sig = new Uint8Array(crypto_sign_BYTES);
|
|
2183
|
-
for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];
|
|
2184
|
-
return sig;
|
|
2185
|
-
};
|
|
2186
|
-
nacl.sign.detached.verify = function(msg, sig, publicKey) {
|
|
2187
|
-
checkArrayTypes(msg, sig, publicKey);
|
|
2188
|
-
if (sig.length !== crypto_sign_BYTES)
|
|
2189
|
-
throw new Error("bad signature size");
|
|
2190
|
-
if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
|
|
2191
|
-
throw new Error("bad public key size");
|
|
2192
|
-
var sm = new Uint8Array(crypto_sign_BYTES + msg.length);
|
|
2193
|
-
var m = new Uint8Array(crypto_sign_BYTES + msg.length);
|
|
2194
|
-
var i;
|
|
2195
|
-
for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];
|
|
2196
|
-
for (i = 0; i < msg.length; i++) sm[i + crypto_sign_BYTES] = msg[i];
|
|
2197
|
-
return crypto_sign_open(m, sm, sm.length, publicKey) >= 0;
|
|
2198
|
-
};
|
|
2199
|
-
nacl.sign.keyPair = function() {
|
|
2200
|
-
var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
|
|
2201
|
-
var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
|
|
2202
|
-
crypto_sign_keypair(pk, sk);
|
|
2203
|
-
return { publicKey: pk, secretKey: sk };
|
|
2204
|
-
};
|
|
2205
|
-
nacl.sign.keyPair.fromSecretKey = function(secretKey) {
|
|
2206
|
-
checkArrayTypes(secretKey);
|
|
2207
|
-
if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
|
|
2208
|
-
throw new Error("bad secret key size");
|
|
2209
|
-
var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
|
|
2210
|
-
for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32 + i];
|
|
2211
|
-
return { publicKey: pk, secretKey: new Uint8Array(secretKey) };
|
|
2212
|
-
};
|
|
2213
|
-
nacl.sign.keyPair.fromSeed = function(seed) {
|
|
2214
|
-
checkArrayTypes(seed);
|
|
2215
|
-
if (seed.length !== crypto_sign_SEEDBYTES)
|
|
2216
|
-
throw new Error("bad seed size");
|
|
2217
|
-
var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
|
|
2218
|
-
var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
|
|
2219
|
-
for (var i = 0; i < 32; i++) sk[i] = seed[i];
|
|
2220
|
-
crypto_sign_keypair(pk, sk, true);
|
|
2221
|
-
return { publicKey: pk, secretKey: sk };
|
|
2222
|
-
};
|
|
2223
|
-
nacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;
|
|
2224
|
-
nacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;
|
|
2225
|
-
nacl.sign.seedLength = crypto_sign_SEEDBYTES;
|
|
2226
|
-
nacl.sign.signatureLength = crypto_sign_BYTES;
|
|
2227
|
-
nacl.hash = function(msg) {
|
|
2228
|
-
checkArrayTypes(msg);
|
|
2229
|
-
var h = new Uint8Array(crypto_hash_BYTES);
|
|
2230
|
-
crypto_hash(h, msg, msg.length);
|
|
2231
|
-
return h;
|
|
2232
|
-
};
|
|
2233
|
-
nacl.hash.hashLength = crypto_hash_BYTES;
|
|
2234
|
-
nacl.verify = function(x, y) {
|
|
2235
|
-
checkArrayTypes(x, y);
|
|
2236
|
-
if (x.length === 0 || y.length === 0) return false;
|
|
2237
|
-
if (x.length !== y.length) return false;
|
|
2238
|
-
return vn(x, 0, y, 0, x.length) === 0 ? true : false;
|
|
2239
|
-
};
|
|
2240
|
-
nacl.setPRNG = function(fn) {
|
|
2241
|
-
randombytes = fn;
|
|
2242
|
-
};
|
|
2243
|
-
(function() {
|
|
2244
|
-
var crypto = typeof self !== "undefined" ? self.crypto || self.msCrypto : null;
|
|
2245
|
-
if (crypto && crypto.getRandomValues) {
|
|
2246
|
-
var QUOTA = 65536;
|
|
2247
|
-
nacl.setPRNG(function(x, n) {
|
|
2248
|
-
var i, v = new Uint8Array(n);
|
|
2249
|
-
for (i = 0; i < n; i += QUOTA) {
|
|
2250
|
-
crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));
|
|
2251
|
-
}
|
|
2252
|
-
for (i = 0; i < n; i++) x[i] = v[i];
|
|
2253
|
-
cleanup(v);
|
|
2254
|
-
});
|
|
2255
|
-
} else if (typeof __require !== "undefined") {
|
|
2256
|
-
crypto = __require("crypto");
|
|
2257
|
-
if (crypto && crypto.randomBytes) {
|
|
2258
|
-
nacl.setPRNG(function(x, n) {
|
|
2259
|
-
var i, v = crypto.randomBytes(n);
|
|
2260
|
-
for (i = 0; i < n; i++) x[i] = v[i];
|
|
2261
|
-
cleanup(v);
|
|
2262
|
-
});
|
|
2263
|
-
}
|
|
2264
|
-
}
|
|
2265
|
-
})();
|
|
2266
|
-
})(typeof module !== "undefined" && module.exports ? module.exports : self.nacl = self.nacl || {});
|
|
2267
|
-
}
|
|
2268
|
-
});
|
|
2269
|
-
|
|
2270
|
-
// ../../node_modules/base-x/src/index.js
|
|
2271
|
-
var require_src = __commonJS({
|
|
2272
|
-
"../../node_modules/base-x/src/index.js"(exports$1, module) {
|
|
2273
|
-
function base(ALPHABET) {
|
|
2274
|
-
if (ALPHABET.length >= 255) {
|
|
2275
|
-
throw new TypeError("Alphabet too long");
|
|
2276
|
-
}
|
|
2277
|
-
var BASE_MAP = new Uint8Array(256);
|
|
2278
|
-
for (var j = 0; j < BASE_MAP.length; j++) {
|
|
2279
|
-
BASE_MAP[j] = 255;
|
|
2280
|
-
}
|
|
2281
|
-
for (var i = 0; i < ALPHABET.length; i++) {
|
|
2282
|
-
var x = ALPHABET.charAt(i);
|
|
2283
|
-
var xc = x.charCodeAt(0);
|
|
2284
|
-
if (BASE_MAP[xc] !== 255) {
|
|
2285
|
-
throw new TypeError(x + " is ambiguous");
|
|
2286
|
-
}
|
|
2287
|
-
BASE_MAP[xc] = i;
|
|
2288
|
-
}
|
|
2289
|
-
var BASE = ALPHABET.length;
|
|
2290
|
-
var LEADER = ALPHABET.charAt(0);
|
|
2291
|
-
var FACTOR = Math.log(BASE) / Math.log(256);
|
|
2292
|
-
var iFACTOR = Math.log(256) / Math.log(BASE);
|
|
2293
|
-
function encode(source) {
|
|
2294
|
-
if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {
|
|
2295
|
-
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
2296
|
-
} else if (Array.isArray(source)) {
|
|
2297
|
-
source = Uint8Array.from(source);
|
|
2298
|
-
}
|
|
2299
|
-
if (!(source instanceof Uint8Array)) {
|
|
2300
|
-
throw new TypeError("Expected Uint8Array");
|
|
2301
|
-
}
|
|
2302
|
-
if (source.length === 0) {
|
|
2303
|
-
return "";
|
|
2304
|
-
}
|
|
2305
|
-
var zeroes = 0;
|
|
2306
|
-
var length = 0;
|
|
2307
|
-
var pbegin = 0;
|
|
2308
|
-
var pend = source.length;
|
|
2309
|
-
while (pbegin !== pend && source[pbegin] === 0) {
|
|
2310
|
-
pbegin++;
|
|
2311
|
-
zeroes++;
|
|
2312
|
-
}
|
|
2313
|
-
var size = (pend - pbegin) * iFACTOR + 1 >>> 0;
|
|
2314
|
-
var b58 = new Uint8Array(size);
|
|
2315
|
-
while (pbegin !== pend) {
|
|
2316
|
-
var carry = source[pbegin];
|
|
2317
|
-
var i2 = 0;
|
|
2318
|
-
for (var it1 = size - 1; (carry !== 0 || i2 < length) && it1 !== -1; it1--, i2++) {
|
|
2319
|
-
carry += 256 * b58[it1] >>> 0;
|
|
2320
|
-
b58[it1] = carry % BASE >>> 0;
|
|
2321
|
-
carry = carry / BASE >>> 0;
|
|
2322
|
-
}
|
|
2323
|
-
if (carry !== 0) {
|
|
2324
|
-
throw new Error("Non-zero carry");
|
|
2325
|
-
}
|
|
2326
|
-
length = i2;
|
|
2327
|
-
pbegin++;
|
|
2328
|
-
}
|
|
2329
|
-
var it2 = size - length;
|
|
2330
|
-
while (it2 !== size && b58[it2] === 0) {
|
|
2331
|
-
it2++;
|
|
2332
|
-
}
|
|
2333
|
-
var str = LEADER.repeat(zeroes);
|
|
2334
|
-
for (; it2 < size; ++it2) {
|
|
2335
|
-
str += ALPHABET.charAt(b58[it2]);
|
|
2336
|
-
}
|
|
2337
|
-
return str;
|
|
2338
|
-
}
|
|
2339
|
-
function decodeUnsafe(source) {
|
|
2340
|
-
if (typeof source !== "string") {
|
|
2341
|
-
throw new TypeError("Expected String");
|
|
2342
|
-
}
|
|
2343
|
-
if (source.length === 0) {
|
|
2344
|
-
return new Uint8Array();
|
|
2345
|
-
}
|
|
2346
|
-
var psz = 0;
|
|
2347
|
-
var zeroes = 0;
|
|
2348
|
-
var length = 0;
|
|
2349
|
-
while (source[psz] === LEADER) {
|
|
2350
|
-
zeroes++;
|
|
2351
|
-
psz++;
|
|
2352
|
-
}
|
|
2353
|
-
var size = (source.length - psz) * FACTOR + 1 >>> 0;
|
|
2354
|
-
var b256 = new Uint8Array(size);
|
|
2355
|
-
while (source[psz]) {
|
|
2356
|
-
var charCode = source.charCodeAt(psz);
|
|
2357
|
-
if (charCode > 255) {
|
|
2358
|
-
return;
|
|
2359
|
-
}
|
|
2360
|
-
var carry = BASE_MAP[charCode];
|
|
2361
|
-
if (carry === 255) {
|
|
2362
|
-
return;
|
|
2363
|
-
}
|
|
2364
|
-
var i2 = 0;
|
|
2365
|
-
for (var it3 = size - 1; (carry !== 0 || i2 < length) && it3 !== -1; it3--, i2++) {
|
|
2366
|
-
carry += BASE * b256[it3] >>> 0;
|
|
2367
|
-
b256[it3] = carry % 256 >>> 0;
|
|
2368
|
-
carry = carry / 256 >>> 0;
|
|
2369
|
-
}
|
|
2370
|
-
if (carry !== 0) {
|
|
2371
|
-
throw new Error("Non-zero carry");
|
|
2372
|
-
}
|
|
2373
|
-
length = i2;
|
|
2374
|
-
psz++;
|
|
2375
|
-
}
|
|
2376
|
-
var it4 = size - length;
|
|
2377
|
-
while (it4 !== size && b256[it4] === 0) {
|
|
2378
|
-
it4++;
|
|
2379
|
-
}
|
|
2380
|
-
var vch = new Uint8Array(zeroes + (size - it4));
|
|
2381
|
-
var j2 = zeroes;
|
|
2382
|
-
while (it4 !== size) {
|
|
2383
|
-
vch[j2++] = b256[it4++];
|
|
2384
|
-
}
|
|
2385
|
-
return vch;
|
|
2386
|
-
}
|
|
2387
|
-
function decode(string) {
|
|
2388
|
-
var buffer = decodeUnsafe(string);
|
|
2389
|
-
if (buffer) {
|
|
2390
|
-
return buffer;
|
|
2391
|
-
}
|
|
2392
|
-
throw new Error("Non-base" + BASE + " character");
|
|
2393
|
-
}
|
|
2394
|
-
return {
|
|
2395
|
-
encode,
|
|
2396
|
-
decodeUnsafe,
|
|
2397
|
-
decode
|
|
2398
|
-
};
|
|
2399
|
-
}
|
|
2400
|
-
module.exports = base;
|
|
2401
|
-
}
|
|
2402
|
-
});
|
|
2403
|
-
|
|
2404
|
-
// ../../node_modules/bs58/index.js
|
|
2405
|
-
var require_bs58 = __commonJS({
|
|
2406
|
-
"../../node_modules/bs58/index.js"(exports$1, module) {
|
|
2407
|
-
var basex = require_src();
|
|
2408
|
-
var ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
2409
|
-
module.exports = basex(ALPHABET);
|
|
2410
|
-
}
|
|
2411
|
-
});
|
|
2412
|
-
|
|
2413
|
-
// ../../node_modules/bs58check/base.js
|
|
2414
|
-
var require_base = __commonJS({
|
|
2415
|
-
"../../node_modules/bs58check/base.js"(exports$1, module) {
|
|
2416
|
-
var base58 = require_bs58();
|
|
2417
|
-
module.exports = function(checksumFn) {
|
|
2418
|
-
function encode(payload) {
|
|
2419
|
-
var payloadU8 = Uint8Array.from(payload);
|
|
2420
|
-
var checksum = checksumFn(payloadU8);
|
|
2421
|
-
var length = payloadU8.length + 4;
|
|
2422
|
-
var both = new Uint8Array(length);
|
|
2423
|
-
both.set(payloadU8, 0);
|
|
2424
|
-
both.set(checksum.subarray(0, 4), payloadU8.length);
|
|
2425
|
-
return base58.encode(both, length);
|
|
2426
|
-
}
|
|
2427
|
-
function decodeRaw(buffer) {
|
|
2428
|
-
var payload = buffer.slice(0, -4);
|
|
2429
|
-
var checksum = buffer.slice(-4);
|
|
2430
|
-
var newChecksum = checksumFn(payload);
|
|
2431
|
-
if (checksum[0] ^ newChecksum[0] | checksum[1] ^ newChecksum[1] | checksum[2] ^ newChecksum[2] | checksum[3] ^ newChecksum[3]) return;
|
|
2432
|
-
return payload;
|
|
2433
|
-
}
|
|
2434
|
-
function decodeUnsafe(string) {
|
|
2435
|
-
var buffer = base58.decodeUnsafe(string);
|
|
2436
|
-
if (!buffer) return;
|
|
2437
|
-
return decodeRaw(buffer);
|
|
2438
|
-
}
|
|
2439
|
-
function decode(string) {
|
|
2440
|
-
var buffer = base58.decode(string);
|
|
2441
|
-
var payload = decodeRaw(buffer);
|
|
2442
|
-
if (!payload) throw new Error("Invalid checksum");
|
|
2443
|
-
return payload;
|
|
2444
|
-
}
|
|
2445
|
-
return {
|
|
2446
|
-
encode,
|
|
2447
|
-
decode,
|
|
2448
|
-
decodeUnsafe
|
|
2449
|
-
};
|
|
2450
|
-
};
|
|
2451
|
-
}
|
|
2452
|
-
});
|
|
2453
|
-
|
|
2454
|
-
// ../../node_modules/bs58check/index.js
|
|
2455
|
-
var require_bs58check = __commonJS({
|
|
2456
|
-
"../../node_modules/bs58check/index.js"(exports$1, module) {
|
|
2457
|
-
var { sha256: sha2562 } = __require("@noble/hashes/sha256");
|
|
2458
|
-
var bs58checkBase = require_base();
|
|
2459
|
-
function sha256x2(buffer) {
|
|
2460
|
-
return sha2562(sha2562(buffer));
|
|
2461
|
-
}
|
|
2462
|
-
module.exports = bs58checkBase(sha256x2);
|
|
2463
|
-
}
|
|
2464
|
-
});
|
|
2465
16
|
|
|
2466
17
|
// src/config/contracts.ts
|
|
2467
18
|
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
@@ -2672,7 +223,7 @@ var WdkApiClient = class {
|
|
|
2672
223
|
}
|
|
2673
224
|
}
|
|
2674
225
|
};
|
|
2675
|
-
var DEFAULT_API_URL = process.env.NEXT_PUBLIC_API_URL || "
|
|
226
|
+
var DEFAULT_API_URL = process.env.NEXT_PUBLIC_API_URL || "https://ckgwifsxka.us-east-2.awsapprunner.com";
|
|
2676
227
|
var wdkApiClient = null;
|
|
2677
228
|
function getWdkApiClient(baseUrl) {
|
|
2678
229
|
if (!wdkApiClient || baseUrl && wdkApiClient["config"].baseUrl !== baseUrl) {
|
|
@@ -2732,11 +283,12 @@ function deriveBitcoinAddress(seed, network = "testnet") {
|
|
|
2732
283
|
}
|
|
2733
284
|
async function deriveSolanaAddress(seed) {
|
|
2734
285
|
try {
|
|
2735
|
-
const [ed25519, nacl,
|
|
286
|
+
const [ed25519, nacl, bs58Module] = await Promise.all([
|
|
2736
287
|
import('ed25519-hd-key'),
|
|
2737
|
-
|
|
2738
|
-
|
|
288
|
+
import('tweetnacl'),
|
|
289
|
+
import('bs58')
|
|
2739
290
|
]);
|
|
291
|
+
const bs58 = bs58Module.default || bs58Module;
|
|
2740
292
|
const seedBytes = bip39.mnemonicToSeedSync(seed);
|
|
2741
293
|
const derived = ed25519.derivePath(DERIVATION_PATHS.solana, Buffer.from(seedBytes).toString("hex"));
|
|
2742
294
|
const keypair = nacl.sign.keyPair.fromSeed(new Uint8Array(derived.key));
|
|
@@ -2750,7 +302,7 @@ async function deriveTonAddress(seed) {
|
|
|
2750
302
|
try {
|
|
2751
303
|
const [ed25519, nacl] = await Promise.all([
|
|
2752
304
|
import('ed25519-hd-key'),
|
|
2753
|
-
|
|
305
|
+
import('tweetnacl')
|
|
2754
306
|
]);
|
|
2755
307
|
const seedBytes = bip39.mnemonicToSeedSync(seed);
|
|
2756
308
|
const derived = ed25519.derivePath(DERIVATION_PATHS.ton, Buffer.from(seedBytes).toString("hex"));
|
|
@@ -2786,9 +338,8 @@ function crc16(data) {
|
|
|
2786
338
|
}
|
|
2787
339
|
return crc;
|
|
2788
340
|
}
|
|
2789
|
-
|
|
341
|
+
function deriveTronAddress(seed) {
|
|
2790
342
|
try {
|
|
2791
|
-
const bs58check = await Promise.resolve().then(() => __toESM(require_bs58check()));
|
|
2792
343
|
const hdNode = ethers.HDNodeWallet.fromPhrase(seed, void 0, DERIVATION_PATHS.tron);
|
|
2793
344
|
const ethAddressHex = hdNode.address.slice(2).toLowerCase();
|
|
2794
345
|
const addressBytes = new Uint8Array(21);
|
|
@@ -2796,7 +347,8 @@ async function deriveTronAddress(seed) {
|
|
|
2796
347
|
for (let i = 0; i < 20; i++) {
|
|
2797
348
|
addressBytes[i + 1] = parseInt(ethAddressHex.slice(i * 2, i * 2 + 2), 16);
|
|
2798
349
|
}
|
|
2799
|
-
|
|
350
|
+
const tronBase58check = base.base58check(sha256.sha256);
|
|
351
|
+
return tronBase58check.encode(addressBytes);
|
|
2800
352
|
} catch (error) {
|
|
2801
353
|
console.error("TRON address derivation failed:", error);
|
|
2802
354
|
throw error;
|
|
@@ -2846,10 +398,14 @@ async function deriveAllAddresses(seed, network = "testnet") {
|
|
|
2846
398
|
} catch (e) {
|
|
2847
399
|
console.error("Spark derivation failed:", e);
|
|
2848
400
|
}
|
|
2849
|
-
|
|
401
|
+
try {
|
|
402
|
+
addresses.tron = deriveTronAddress(seed);
|
|
403
|
+
} catch (e) {
|
|
404
|
+
console.error("TRON derivation failed:", e);
|
|
405
|
+
}
|
|
406
|
+
const [solResult, tonResult] = await Promise.allSettled([
|
|
2850
407
|
deriveSolanaAddress(seed),
|
|
2851
|
-
deriveTonAddress(seed)
|
|
2852
|
-
deriveTronAddress(seed)
|
|
408
|
+
deriveTonAddress(seed)
|
|
2853
409
|
]);
|
|
2854
410
|
if (solResult.status === "fulfilled") {
|
|
2855
411
|
addresses.solana = solResult.value;
|
|
@@ -2861,11 +417,6 @@ async function deriveAllAddresses(seed, network = "testnet") {
|
|
|
2861
417
|
} else {
|
|
2862
418
|
console.error("TON derivation failed:", tonResult.reason);
|
|
2863
419
|
}
|
|
2864
|
-
if (tronResult.status === "fulfilled") {
|
|
2865
|
-
addresses.tron = tronResult.value;
|
|
2866
|
-
} else {
|
|
2867
|
-
console.error("TRON derivation failed:", tronResult.reason);
|
|
2868
|
-
}
|
|
2869
420
|
return addresses;
|
|
2870
421
|
}
|
|
2871
422
|
function isValidSeed(seed) {
|
|
@@ -2875,344 +426,388 @@ function generateSeedPhrase() {
|
|
|
2875
426
|
return bip39.generateMnemonic(english.wordlist);
|
|
2876
427
|
}
|
|
2877
428
|
|
|
2878
|
-
// src/services/
|
|
2879
|
-
var
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
var WalletManagerTon;
|
|
2884
|
-
var WalletManagerTron;
|
|
2885
|
-
var WalletManagerSpark;
|
|
2886
|
-
var wdkLoaded = false;
|
|
2887
|
-
var wdkLoadError = null;
|
|
429
|
+
// src/services/ZubariWdkService.ts
|
|
430
|
+
var DEFAULT_API_URL2 = "https://ckgwifsxka.us-east-2.awsapprunner.com";
|
|
431
|
+
function isBrowser() {
|
|
432
|
+
return typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
433
|
+
}
|
|
2888
434
|
var dynamicImport = new Function("specifier", "return import(specifier)");
|
|
2889
|
-
async function
|
|
2890
|
-
if (
|
|
2891
|
-
|
|
435
|
+
async function canUseNativeWdk() {
|
|
436
|
+
if (isBrowser()) {
|
|
437
|
+
return false;
|
|
438
|
+
}
|
|
2892
439
|
try {
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
dynamicImport("@tetherto/wdk-wallet-solana"),
|
|
2898
|
-
dynamicImport("@tetherto/wdk-wallet-ton"),
|
|
2899
|
-
dynamicImport("@tetherto/wdk-wallet-tron"),
|
|
2900
|
-
dynamicImport("@tetherto/wdk-wallet-spark")
|
|
2901
|
-
]);
|
|
2902
|
-
WdkManager = wdk.default;
|
|
2903
|
-
WalletManagerBtc = btc.default;
|
|
2904
|
-
WalletManagerEvm = evm.default;
|
|
2905
|
-
WalletManagerSolana = solana.default;
|
|
2906
|
-
WalletManagerTon = ton.default;
|
|
2907
|
-
WalletManagerTron = tron.default;
|
|
2908
|
-
WalletManagerSpark = spark.default;
|
|
2909
|
-
wdkLoaded = true;
|
|
2910
|
-
} catch (error) {
|
|
2911
|
-
wdkLoadError = error instanceof Error ? error : new Error("Failed to load WDK modules");
|
|
2912
|
-
console.error("Failed to load WDK modules:", error);
|
|
2913
|
-
throw wdkLoadError;
|
|
440
|
+
await dynamicImport("@tetherto/wdk");
|
|
441
|
+
return true;
|
|
442
|
+
} catch {
|
|
443
|
+
return false;
|
|
2914
444
|
}
|
|
2915
445
|
}
|
|
2916
|
-
var
|
|
2917
|
-
bitcoin: "m/84'/0'/0'/0/0",
|
|
2918
|
-
// BIP-84 for native SegWit
|
|
2919
|
-
ethereum: "m/44'/60'/0'/0/0",
|
|
2920
|
-
ton: "m/44'/607'/0'",
|
|
2921
|
-
// Updated for v1.0.0-beta.6+
|
|
2922
|
-
tron: "m/44'/195'/0'/0/0",
|
|
2923
|
-
solana: "m/44'/501'/0'/0'",
|
|
2924
|
-
// Updated for v1.0.0-beta.4+
|
|
2925
|
-
spark: "m/44'/998'/0'/0/0"
|
|
2926
|
-
};
|
|
2927
|
-
var DEFAULT_RPC_URLS = {
|
|
2928
|
-
mainnet: {
|
|
2929
|
-
ethereum: "https://eth.llamarpc.com",
|
|
2930
|
-
solana: "https://api.mainnet-beta.solana.com",
|
|
2931
|
-
ton: "https://toncenter.com/api/v2/jsonRPC",
|
|
2932
|
-
tron: "https://api.trongrid.io"
|
|
2933
|
-
},
|
|
2934
|
-
testnet: {
|
|
2935
|
-
ethereum: "https://ethereum-sepolia-rpc.publicnode.com",
|
|
2936
|
-
solana: "https://api.devnet.solana.com",
|
|
2937
|
-
ton: "https://testnet.toncenter.com/api/v2/jsonRPC",
|
|
2938
|
-
tron: "https://api.shasta.trongrid.io"
|
|
2939
|
-
}
|
|
2940
|
-
};
|
|
2941
|
-
var WdkService = class {
|
|
2942
|
-
seed = null;
|
|
446
|
+
var ZubariWdkService = class {
|
|
2943
447
|
config;
|
|
2944
|
-
|
|
2945
|
-
|
|
448
|
+
apiClient;
|
|
449
|
+
nativeWdkService = null;
|
|
450
|
+
initialized = false;
|
|
451
|
+
useNativeWdk = false;
|
|
2946
452
|
constructor(config = {}) {
|
|
2947
453
|
this.config = {
|
|
2948
454
|
network: config.network || "testnet",
|
|
2949
|
-
|
|
455
|
+
apiUrl: config.apiUrl || process.env.NEXT_PUBLIC_API_URL || DEFAULT_API_URL2,
|
|
456
|
+
forceApi: config.forceApi ?? false,
|
|
457
|
+
timeout: config.timeout || 3e4
|
|
2950
458
|
};
|
|
459
|
+
this.apiClient = getWdkApiClient(this.config.apiUrl);
|
|
2951
460
|
}
|
|
2952
461
|
/**
|
|
2953
|
-
*
|
|
462
|
+
* Initialize the service and determine the best strategy
|
|
2954
463
|
*/
|
|
2955
|
-
|
|
2956
|
-
return
|
|
464
|
+
async initialize() {
|
|
465
|
+
if (this.initialized) return;
|
|
466
|
+
if (isBrowser() || this.config.forceApi) {
|
|
467
|
+
this.useNativeWdk = false;
|
|
468
|
+
this.initialized = true;
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
if (await canUseNativeWdk()) {
|
|
472
|
+
try {
|
|
473
|
+
const WdkServiceModule = await dynamicImport("./WdkService");
|
|
474
|
+
const WdkService = WdkServiceModule.WdkService || WdkServiceModule.default;
|
|
475
|
+
this.nativeWdkService = new WdkService({
|
|
476
|
+
network: this.config.network
|
|
477
|
+
});
|
|
478
|
+
this.useNativeWdk = true;
|
|
479
|
+
} catch (error) {
|
|
480
|
+
console.warn("Failed to initialize native WDK, falling back to API:", error);
|
|
481
|
+
this.useNativeWdk = false;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
this.initialized = true;
|
|
2957
485
|
}
|
|
2958
486
|
/**
|
|
2959
|
-
*
|
|
487
|
+
* Get the current execution mode
|
|
2960
488
|
*/
|
|
2961
|
-
|
|
2962
|
-
|
|
489
|
+
getMode() {
|
|
490
|
+
if (this.useNativeWdk) return "native";
|
|
491
|
+
if (isBrowser()) return "api";
|
|
492
|
+
return "api";
|
|
2963
493
|
}
|
|
2964
494
|
/**
|
|
2965
|
-
*
|
|
495
|
+
* Check if running in browser
|
|
2966
496
|
*/
|
|
2967
|
-
|
|
2968
|
-
|
|
497
|
+
isBrowserEnvironment() {
|
|
498
|
+
return isBrowser();
|
|
2969
499
|
}
|
|
2970
500
|
/**
|
|
2971
|
-
* Generate a
|
|
501
|
+
* Generate a new BIP-39 seed phrase (12 words)
|
|
2972
502
|
*/
|
|
2973
|
-
async
|
|
2974
|
-
await this.
|
|
2975
|
-
|
|
503
|
+
async generateSeed() {
|
|
504
|
+
await this.initialize();
|
|
505
|
+
try {
|
|
506
|
+
const response = await this.apiClient.generateSeed();
|
|
507
|
+
if (response.success && response.seed) {
|
|
508
|
+
return response.seed;
|
|
509
|
+
}
|
|
510
|
+
} catch (error) {
|
|
511
|
+
console.warn("API seed generation failed:", error);
|
|
512
|
+
}
|
|
513
|
+
if (this.useNativeWdk && this.nativeWdkService) {
|
|
514
|
+
try {
|
|
515
|
+
const wdk = this.nativeWdkService;
|
|
516
|
+
return await wdk.generateSeedPhrase();
|
|
517
|
+
} catch (error) {
|
|
518
|
+
console.warn("Native WDK seed generation failed:", error);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
return generateSeedPhrase();
|
|
2976
522
|
}
|
|
2977
523
|
/**
|
|
2978
524
|
* Validate a BIP-39 seed phrase
|
|
2979
525
|
*/
|
|
2980
|
-
async
|
|
2981
|
-
await this.
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
return words.length === 12 || words.length === 24;
|
|
2990
|
-
}
|
|
2991
|
-
/**
|
|
2992
|
-
* Initialize the service with a seed phrase
|
|
2993
|
-
*/
|
|
2994
|
-
async initialize(seed) {
|
|
2995
|
-
await this.ensureLoaded();
|
|
2996
|
-
if (!WdkManager.isValidSeed(seed)) {
|
|
2997
|
-
throw new Error("Invalid seed phrase");
|
|
526
|
+
async validateSeed(seed) {
|
|
527
|
+
await this.initialize();
|
|
528
|
+
try {
|
|
529
|
+
const response = await this.apiClient.validateSeed(seed);
|
|
530
|
+
if (response.success) {
|
|
531
|
+
return response.isValid ?? false;
|
|
532
|
+
}
|
|
533
|
+
} catch (error) {
|
|
534
|
+
console.warn("API seed validation failed:", error);
|
|
2998
535
|
}
|
|
2999
|
-
this.
|
|
3000
|
-
|
|
536
|
+
if (this.useNativeWdk && this.nativeWdkService) {
|
|
537
|
+
try {
|
|
538
|
+
const wdk = this.nativeWdkService;
|
|
539
|
+
return await wdk.isValidSeed(seed);
|
|
540
|
+
} catch (error) {
|
|
541
|
+
console.warn("Native WDK seed validation failed:", error);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
return isValidSeed(seed);
|
|
3001
545
|
}
|
|
3002
546
|
/**
|
|
3003
|
-
*
|
|
547
|
+
* Derive address for a specific chain
|
|
3004
548
|
*/
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
549
|
+
async deriveAddress(seed, chain) {
|
|
550
|
+
await this.initialize();
|
|
551
|
+
const path = this.getDerivationPath(chain);
|
|
552
|
+
try {
|
|
553
|
+
const response = await this.apiClient.deriveAddress(seed, chain, this.config.network);
|
|
554
|
+
if (response.success && response.address) {
|
|
555
|
+
return {
|
|
556
|
+
chain,
|
|
557
|
+
address: response.address,
|
|
558
|
+
path: response.path || path
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
} catch (error) {
|
|
562
|
+
console.warn(`API address derivation failed for ${chain}:`, error);
|
|
3009
563
|
}
|
|
3010
|
-
|
|
564
|
+
if (this.useNativeWdk && this.nativeWdkService) {
|
|
565
|
+
try {
|
|
566
|
+
const wdk = this.nativeWdkService;
|
|
567
|
+
await wdk.initialize(seed);
|
|
568
|
+
return await wdk.deriveAddress(chain);
|
|
569
|
+
} catch (error) {
|
|
570
|
+
console.warn(`Native WDK address derivation failed for ${chain}:`, error);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
return this.deriveBrowserAddress(seed, chain);
|
|
3011
574
|
}
|
|
3012
575
|
/**
|
|
3013
|
-
*
|
|
576
|
+
* Derive addresses for all supported chains
|
|
3014
577
|
*/
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
if (!this.seed) {
|
|
3018
|
-
throw new Error("WDK service not initialized. Call initialize() first.");
|
|
3019
|
-
}
|
|
3020
|
-
if (this.wallets[chain]) {
|
|
3021
|
-
return this.wallets[chain];
|
|
3022
|
-
}
|
|
3023
|
-
const isTestnet = this.config.network === "testnet";
|
|
578
|
+
async deriveAllAddresses(seed) {
|
|
579
|
+
await this.initialize();
|
|
3024
580
|
try {
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
});
|
|
3036
|
-
this.wallets[chain] = wallet;
|
|
3037
|
-
return wallet;
|
|
3038
|
-
}
|
|
3039
|
-
case "solana": {
|
|
3040
|
-
const rpcUrl = this.getRpcUrl("solana");
|
|
3041
|
-
const wallet = new WalletManagerSolana(this.seed, {
|
|
3042
|
-
rpcUrl
|
|
3043
|
-
});
|
|
3044
|
-
this.wallets[chain] = wallet;
|
|
3045
|
-
return wallet;
|
|
3046
|
-
}
|
|
3047
|
-
case "ton": {
|
|
3048
|
-
const url = this.getRpcUrl("ton");
|
|
3049
|
-
const wallet = new WalletManagerTon(this.seed, {
|
|
3050
|
-
tonClient: { url }
|
|
3051
|
-
});
|
|
3052
|
-
this.wallets[chain] = wallet;
|
|
3053
|
-
return wallet;
|
|
3054
|
-
}
|
|
3055
|
-
case "tron": {
|
|
3056
|
-
const fullHost = this.getRpcUrl("tron");
|
|
3057
|
-
const wallet = new WalletManagerTron(this.seed, {
|
|
3058
|
-
provider: fullHost
|
|
3059
|
-
});
|
|
3060
|
-
this.wallets[chain] = wallet;
|
|
3061
|
-
return wallet;
|
|
3062
|
-
}
|
|
3063
|
-
case "spark": {
|
|
3064
|
-
const wallet = new WalletManagerSpark(this.seed, {
|
|
3065
|
-
network: isTestnet ? "TESTNET" : "MAINNET"
|
|
3066
|
-
});
|
|
3067
|
-
this.wallets[chain] = wallet;
|
|
3068
|
-
return wallet;
|
|
3069
|
-
}
|
|
3070
|
-
default:
|
|
3071
|
-
throw new Error(`Unsupported chain: ${chain}`);
|
|
581
|
+
const response = await this.apiClient.deriveAllAddresses(seed, this.config.network);
|
|
582
|
+
if (response.success && response.addresses) {
|
|
583
|
+
return {
|
|
584
|
+
ethereum: response.addresses.ethereum || null,
|
|
585
|
+
bitcoin: response.addresses.bitcoin || null,
|
|
586
|
+
ton: response.addresses.ton || null,
|
|
587
|
+
tron: response.addresses.tron || null,
|
|
588
|
+
solana: response.addresses.solana || null,
|
|
589
|
+
spark: response.addresses.spark || null
|
|
590
|
+
};
|
|
3072
591
|
}
|
|
3073
592
|
} catch (error) {
|
|
3074
|
-
console.
|
|
3075
|
-
|
|
593
|
+
console.warn("API address derivation failed:", error);
|
|
594
|
+
}
|
|
595
|
+
if (this.useNativeWdk && this.nativeWdkService) {
|
|
596
|
+
try {
|
|
597
|
+
const wdk = this.nativeWdkService;
|
|
598
|
+
await wdk.initialize(seed);
|
|
599
|
+
return await wdk.deriveAllAddresses();
|
|
600
|
+
} catch (error) {
|
|
601
|
+
console.warn("Native WDK multi-chain derivation failed:", error);
|
|
602
|
+
}
|
|
3076
603
|
}
|
|
604
|
+
return this.deriveAllBrowserAddresses(seed);
|
|
3077
605
|
}
|
|
3078
606
|
/**
|
|
3079
|
-
*
|
|
607
|
+
* Get balances for all chains
|
|
3080
608
|
*/
|
|
3081
|
-
async
|
|
3082
|
-
|
|
609
|
+
async getAllBalances(seed) {
|
|
610
|
+
await this.initialize();
|
|
3083
611
|
try {
|
|
3084
|
-
const
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
612
|
+
const response = await fetch(`${this.config.apiUrl}/api/wallets/wdk/balances`, {
|
|
613
|
+
method: "POST",
|
|
614
|
+
headers: { "Content-Type": "application/json" },
|
|
615
|
+
body: JSON.stringify({ seed, network: this.config.network })
|
|
616
|
+
});
|
|
617
|
+
if (response.ok) {
|
|
618
|
+
const data = await response.json();
|
|
619
|
+
if (data.success) {
|
|
620
|
+
return data.balances;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
3092
623
|
} catch (error) {
|
|
3093
|
-
console.
|
|
3094
|
-
throw error;
|
|
624
|
+
console.warn("Failed to fetch balances:", error);
|
|
3095
625
|
}
|
|
626
|
+
return {};
|
|
3096
627
|
}
|
|
3097
628
|
/**
|
|
3098
|
-
*
|
|
629
|
+
* Get fee rates for a chain
|
|
3099
630
|
*/
|
|
3100
|
-
async
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
return { chain, address: result.address };
|
|
3114
|
-
})
|
|
3115
|
-
);
|
|
3116
|
-
for (const result of results) {
|
|
3117
|
-
if (result.status === "fulfilled") {
|
|
3118
|
-
addresses[result.value.chain] = result.value.address;
|
|
3119
|
-
} else {
|
|
3120
|
-
console.error("Failed to derive address:", result.reason);
|
|
631
|
+
async getFeeRates(seed, chain) {
|
|
632
|
+
await this.initialize();
|
|
633
|
+
try {
|
|
634
|
+
const response = await fetch(`${this.config.apiUrl}/api/wallets/wdk/fee-rates`, {
|
|
635
|
+
method: "POST",
|
|
636
|
+
headers: { "Content-Type": "application/json" },
|
|
637
|
+
body: JSON.stringify({ seed, chain, network: this.config.network })
|
|
638
|
+
});
|
|
639
|
+
if (response.ok) {
|
|
640
|
+
const data = await response.json();
|
|
641
|
+
if (data.success && data.feeRates) {
|
|
642
|
+
return data.feeRates;
|
|
643
|
+
}
|
|
3121
644
|
}
|
|
645
|
+
} catch (error) {
|
|
646
|
+
console.warn(`Failed to fetch fee rates for ${chain}:`, error);
|
|
3122
647
|
}
|
|
3123
|
-
return
|
|
648
|
+
return { slow: "0", normal: "0", fast: "0" };
|
|
3124
649
|
}
|
|
3125
650
|
/**
|
|
3126
|
-
*
|
|
651
|
+
* Estimate transaction fee
|
|
3127
652
|
*/
|
|
3128
|
-
async
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
653
|
+
async estimateFee(seed, chain, to, amount) {
|
|
654
|
+
await this.initialize();
|
|
655
|
+
try {
|
|
656
|
+
const response = await fetch(`${this.config.apiUrl}/api/wallets/wdk/estimate-fee`, {
|
|
657
|
+
method: "POST",
|
|
658
|
+
headers: { "Content-Type": "application/json" },
|
|
659
|
+
body: JSON.stringify({ seed, chain, to, amount, network: this.config.network })
|
|
660
|
+
});
|
|
661
|
+
if (response.ok) {
|
|
662
|
+
const data = await response.json();
|
|
663
|
+
if (data.success) {
|
|
664
|
+
return { fee: data.fee, symbol: data.symbol };
|
|
665
|
+
}
|
|
3139
666
|
}
|
|
667
|
+
} catch (error) {
|
|
668
|
+
console.warn(`Failed to estimate fee for ${chain}:`, error);
|
|
3140
669
|
}
|
|
3141
|
-
return
|
|
670
|
+
return { fee: "0", symbol: this.getChainSymbol(chain) };
|
|
3142
671
|
}
|
|
3143
672
|
/**
|
|
3144
|
-
*
|
|
673
|
+
* Send a transaction
|
|
3145
674
|
*/
|
|
3146
|
-
async
|
|
3147
|
-
|
|
3148
|
-
throw new Error("WDK service not initialized. Call initialize() first.");
|
|
3149
|
-
}
|
|
675
|
+
async sendTransaction(seed, chain, to, amount) {
|
|
676
|
+
await this.initialize();
|
|
3150
677
|
try {
|
|
3151
|
-
const
|
|
3152
|
-
|
|
678
|
+
const response = await fetch(`${this.config.apiUrl}/api/wallets/wdk/send`, {
|
|
679
|
+
method: "POST",
|
|
680
|
+
headers: { "Content-Type": "application/json" },
|
|
681
|
+
body: JSON.stringify({ seed, chain, to, amount, network: this.config.network })
|
|
682
|
+
});
|
|
683
|
+
if (response.ok) {
|
|
684
|
+
const data = await response.json();
|
|
685
|
+
return {
|
|
686
|
+
success: data.success,
|
|
687
|
+
txHash: data.txHash,
|
|
688
|
+
from: data.from,
|
|
689
|
+
to: data.to,
|
|
690
|
+
amount: data.amount,
|
|
691
|
+
chain: data.chain,
|
|
692
|
+
network: data.network
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
const errorData = await response.json().catch(() => ({}));
|
|
3153
696
|
return {
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
fast: (feeRates.fast || feeRates.high || "0").toString()
|
|
697
|
+
success: false,
|
|
698
|
+
error: errorData.error || `HTTP ${response.status}`
|
|
3157
699
|
};
|
|
3158
700
|
} catch (error) {
|
|
3159
|
-
|
|
3160
|
-
|
|
701
|
+
return {
|
|
702
|
+
success: false,
|
|
703
|
+
error: error instanceof Error ? error.message : "Transaction failed"
|
|
704
|
+
};
|
|
3161
705
|
}
|
|
3162
706
|
}
|
|
3163
707
|
/**
|
|
3164
|
-
* Get the
|
|
708
|
+
* Get the network configuration
|
|
3165
709
|
*/
|
|
3166
710
|
getNetwork() {
|
|
3167
711
|
return this.config.network;
|
|
3168
712
|
}
|
|
3169
713
|
/**
|
|
3170
|
-
*
|
|
714
|
+
* Get API URL
|
|
3171
715
|
*/
|
|
3172
|
-
|
|
3173
|
-
return this.
|
|
716
|
+
getApiUrl() {
|
|
717
|
+
return this.config.apiUrl;
|
|
718
|
+
}
|
|
719
|
+
// ==========================================
|
|
720
|
+
// Private Helper Methods
|
|
721
|
+
// ==========================================
|
|
722
|
+
getDerivationPath(chain) {
|
|
723
|
+
const paths = {
|
|
724
|
+
bitcoin: this.config.network === "testnet" ? "m/84'/1'/0'/0/0" : "m/84'/0'/0'/0/0",
|
|
725
|
+
ethereum: "m/44'/60'/0'/0/0",
|
|
726
|
+
ton: "m/44'/607'/0'/0'/0'",
|
|
727
|
+
tron: "m/44'/195'/0'/0/0",
|
|
728
|
+
solana: "m/44'/501'/0'/0'",
|
|
729
|
+
spark: "m/44'/998'/0'/0/0"
|
|
730
|
+
};
|
|
731
|
+
return paths[chain];
|
|
732
|
+
}
|
|
733
|
+
getChainSymbol(chain) {
|
|
734
|
+
const symbols = {
|
|
735
|
+
ethereum: "ETH",
|
|
736
|
+
bitcoin: "BTC",
|
|
737
|
+
ton: "TON",
|
|
738
|
+
tron: "TRX",
|
|
739
|
+
solana: "SOL",
|
|
740
|
+
spark: "SAT"
|
|
741
|
+
};
|
|
742
|
+
return symbols[chain];
|
|
3174
743
|
}
|
|
3175
744
|
/**
|
|
3176
|
-
*
|
|
745
|
+
* Derive address using browser-compatible libraries
|
|
3177
746
|
*/
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
747
|
+
async deriveBrowserAddress(seed, chain) {
|
|
748
|
+
const path = this.getDerivationPath(chain);
|
|
749
|
+
try {
|
|
750
|
+
let address;
|
|
751
|
+
switch (chain) {
|
|
752
|
+
case "ethereum":
|
|
753
|
+
address = deriveEthereumAddress(seed);
|
|
754
|
+
break;
|
|
755
|
+
case "bitcoin":
|
|
756
|
+
address = deriveBitcoinAddress(seed, this.config.network);
|
|
757
|
+
break;
|
|
758
|
+
case "tron":
|
|
759
|
+
address = deriveTronAddress(seed);
|
|
760
|
+
break;
|
|
761
|
+
case "spark":
|
|
762
|
+
address = deriveSparkAddress(seed, this.config.network);
|
|
763
|
+
break;
|
|
764
|
+
case "solana":
|
|
765
|
+
address = await deriveSolanaAddress(seed);
|
|
766
|
+
break;
|
|
767
|
+
case "ton":
|
|
768
|
+
address = await deriveTonAddress(seed);
|
|
769
|
+
break;
|
|
770
|
+
default:
|
|
771
|
+
throw new Error(`Unsupported chain: ${chain}`);
|
|
3185
772
|
}
|
|
773
|
+
return { chain, address, path };
|
|
774
|
+
} catch (error) {
|
|
775
|
+
console.error(`Browser derivation failed for ${chain}:`, error);
|
|
776
|
+
throw error;
|
|
3186
777
|
}
|
|
3187
|
-
|
|
3188
|
-
|
|
778
|
+
}
|
|
779
|
+
/**
|
|
780
|
+
* Derive all addresses using browser-compatible libraries
|
|
781
|
+
*/
|
|
782
|
+
async deriveAllBrowserAddresses(seed) {
|
|
783
|
+
return deriveAllAddresses(seed, this.config.network);
|
|
3189
784
|
}
|
|
3190
785
|
};
|
|
3191
|
-
var
|
|
3192
|
-
function
|
|
3193
|
-
if (!
|
|
3194
|
-
|
|
786
|
+
var defaultService = null;
|
|
787
|
+
function getZubariWdkService(config) {
|
|
788
|
+
if (!defaultService || config && config.network !== defaultService.getNetwork()) {
|
|
789
|
+
defaultService = new ZubariWdkService(config);
|
|
3195
790
|
}
|
|
3196
|
-
return
|
|
791
|
+
return defaultService;
|
|
3197
792
|
}
|
|
3198
|
-
function
|
|
3199
|
-
return new
|
|
793
|
+
function createZubariWdkService(config) {
|
|
794
|
+
return new ZubariWdkService(config);
|
|
3200
795
|
}
|
|
3201
796
|
|
|
3202
797
|
// src/services/TransactionService.ts
|
|
3203
|
-
var
|
|
3204
|
-
var
|
|
3205
|
-
var
|
|
3206
|
-
var
|
|
3207
|
-
var
|
|
3208
|
-
var
|
|
3209
|
-
var
|
|
3210
|
-
var
|
|
3211
|
-
var
|
|
798
|
+
var WdkManager;
|
|
799
|
+
var WalletManagerBtc;
|
|
800
|
+
var WalletManagerEvm;
|
|
801
|
+
var WalletManagerSolana;
|
|
802
|
+
var WalletManagerTon;
|
|
803
|
+
var WalletManagerTron;
|
|
804
|
+
var WalletManagerSpark;
|
|
805
|
+
var wdkLoaded = false;
|
|
806
|
+
var wdkLoadError = null;
|
|
3212
807
|
var dynamicImport2 = new Function("specifier", "return import(specifier)");
|
|
3213
|
-
async function
|
|
3214
|
-
if (
|
|
3215
|
-
if (
|
|
808
|
+
async function loadWdkModules() {
|
|
809
|
+
if (wdkLoaded) return;
|
|
810
|
+
if (wdkLoadError) throw wdkLoadError;
|
|
3216
811
|
try {
|
|
3217
812
|
const [wdk, btc, evm, solana, ton, tron, spark] = await Promise.all([
|
|
3218
813
|
dynamicImport2("@tetherto/wdk"),
|
|
@@ -3223,21 +818,21 @@ async function loadWdkModules2() {
|
|
|
3223
818
|
dynamicImport2("@tetherto/wdk-wallet-tron"),
|
|
3224
819
|
dynamicImport2("@tetherto/wdk-wallet-spark")
|
|
3225
820
|
]);
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
821
|
+
WdkManager = wdk.default;
|
|
822
|
+
WalletManagerBtc = btc.default;
|
|
823
|
+
WalletManagerEvm = evm.default;
|
|
824
|
+
WalletManagerSolana = solana.default;
|
|
825
|
+
WalletManagerTon = ton.default;
|
|
826
|
+
WalletManagerTron = tron.default;
|
|
827
|
+
WalletManagerSpark = spark.default;
|
|
828
|
+
wdkLoaded = true;
|
|
3234
829
|
} catch (error) {
|
|
3235
|
-
|
|
830
|
+
wdkLoadError = error instanceof Error ? error : new Error("Failed to load WDK modules");
|
|
3236
831
|
console.error("Failed to load WDK modules:", error);
|
|
3237
|
-
throw
|
|
832
|
+
throw wdkLoadError;
|
|
3238
833
|
}
|
|
3239
834
|
}
|
|
3240
|
-
var
|
|
835
|
+
var DEFAULT_RPC_URLS = {
|
|
3241
836
|
mainnet: {
|
|
3242
837
|
ethereum: "https://eth.llamarpc.com",
|
|
3243
838
|
bitcoin: "",
|
|
@@ -3292,13 +887,13 @@ var TransactionService = class {
|
|
|
3292
887
|
* Ensure WDK modules are loaded
|
|
3293
888
|
*/
|
|
3294
889
|
async ensureLoaded() {
|
|
3295
|
-
await
|
|
890
|
+
await loadWdkModules();
|
|
3296
891
|
}
|
|
3297
892
|
/**
|
|
3298
893
|
* Get RPC URL for a chain
|
|
3299
894
|
*/
|
|
3300
895
|
getRpcUrl(chain) {
|
|
3301
|
-
const networkUrls =
|
|
896
|
+
const networkUrls = DEFAULT_RPC_URLS[this.config.network];
|
|
3302
897
|
if (this.config.rpcUrls?.[chain]) {
|
|
3303
898
|
return this.config.rpcUrls[chain];
|
|
3304
899
|
}
|
|
@@ -3317,7 +912,7 @@ var TransactionService = class {
|
|
|
3317
912
|
*/
|
|
3318
913
|
async initialize(seed) {
|
|
3319
914
|
await this.ensureLoaded();
|
|
3320
|
-
if (!
|
|
915
|
+
if (!WdkManager.isValidSeed(seed)) {
|
|
3321
916
|
throw new Error("Invalid seed phrase");
|
|
3322
917
|
}
|
|
3323
918
|
this.seed = seed;
|
|
@@ -3345,12 +940,12 @@ var TransactionService = class {
|
|
|
3345
940
|
switch (chain) {
|
|
3346
941
|
case "ethereum": {
|
|
3347
942
|
const rpcUrl = this.getRpcUrl("ethereum");
|
|
3348
|
-
const wallet = new
|
|
943
|
+
const wallet = new WalletManagerEvm(this.seed, { provider: rpcUrl });
|
|
3349
944
|
this.wallets[chain] = wallet;
|
|
3350
945
|
return wallet;
|
|
3351
946
|
}
|
|
3352
947
|
case "bitcoin": {
|
|
3353
|
-
const wallet = new
|
|
948
|
+
const wallet = new WalletManagerBtc(this.seed, {
|
|
3354
949
|
network: isTestnet ? "testnet" : "bitcoin"
|
|
3355
950
|
});
|
|
3356
951
|
this.wallets[chain] = wallet;
|
|
@@ -3358,7 +953,7 @@ var TransactionService = class {
|
|
|
3358
953
|
}
|
|
3359
954
|
case "solana": {
|
|
3360
955
|
const rpcUrl = this.getRpcUrl("solana");
|
|
3361
|
-
const wallet = new
|
|
956
|
+
const wallet = new WalletManagerSolana(this.seed, {
|
|
3362
957
|
rpcUrl
|
|
3363
958
|
});
|
|
3364
959
|
this.wallets[chain] = wallet;
|
|
@@ -3366,7 +961,7 @@ var TransactionService = class {
|
|
|
3366
961
|
}
|
|
3367
962
|
case "ton": {
|
|
3368
963
|
const url = this.getRpcUrl("ton");
|
|
3369
|
-
const wallet = new
|
|
964
|
+
const wallet = new WalletManagerTon(this.seed, {
|
|
3370
965
|
tonClient: { url }
|
|
3371
966
|
});
|
|
3372
967
|
this.wallets[chain] = wallet;
|
|
@@ -3374,14 +969,14 @@ var TransactionService = class {
|
|
|
3374
969
|
}
|
|
3375
970
|
case "tron": {
|
|
3376
971
|
const fullHost = this.getRpcUrl("tron");
|
|
3377
|
-
const wallet = new
|
|
972
|
+
const wallet = new WalletManagerTron(this.seed, {
|
|
3378
973
|
provider: fullHost
|
|
3379
974
|
});
|
|
3380
975
|
this.wallets[chain] = wallet;
|
|
3381
976
|
return wallet;
|
|
3382
977
|
}
|
|
3383
978
|
case "spark": {
|
|
3384
|
-
const wallet = new
|
|
979
|
+
const wallet = new WalletManagerSpark(this.seed, {
|
|
3385
980
|
network: isTestnet ? "TESTNET" : "MAINNET"
|
|
3386
981
|
});
|
|
3387
982
|
this.wallets[chain] = wallet;
|
|
@@ -3607,11 +1202,12 @@ exports.BrowserAddressDerivation = BrowserAddressDerivation_exports;
|
|
|
3607
1202
|
exports.SwapService = SwapService;
|
|
3608
1203
|
exports.TransactionService = TransactionService;
|
|
3609
1204
|
exports.WdkApiClient = WdkApiClient;
|
|
3610
|
-
exports.
|
|
1205
|
+
exports.ZubariWdkService = ZubariWdkService;
|
|
3611
1206
|
exports.createTransactionService = createTransactionService;
|
|
3612
|
-
exports.
|
|
1207
|
+
exports.createZubariWdkService = createZubariWdkService;
|
|
3613
1208
|
exports.getTransactionService = getTransactionService;
|
|
3614
1209
|
exports.getWdkApiClient = getWdkApiClient;
|
|
3615
|
-
exports.
|
|
1210
|
+
exports.getZubariWdkService = getZubariWdkService;
|
|
1211
|
+
exports.isBrowser = isBrowser;
|
|
3616
1212
|
//# sourceMappingURL=index.js.map
|
|
3617
1213
|
//# sourceMappingURL=index.js.map
|