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