@bounded-sh/client 0.0.17 → 0.0.19
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/README.md +2 -1
- package/dist/auth/index.d.ts +2 -4
- package/dist/auth/providers/mock-auth-provider.d.ts +0 -1
- package/dist/auth/providers/offchain-auth-provider.d.ts +3 -4
- package/dist/auth/providers/phantom-wallet-provider.d.ts +3 -2
- package/dist/auth/providers/privy-wallet-provider.d.ts +10 -7
- package/dist/auth/providers/solana-mobile-wallet-provider.d.ts +3 -2
- package/dist/auth/solana-rpc.d.ts +8 -0
- package/dist/index.js +310 -2682
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +310 -2682
- package/dist/index.mjs.map +1 -1
- package/dist/{index.native-DoiNBZlU.js → index.native-DI_Xgv-n.js} +205 -2558
- package/dist/index.native-DI_Xgv-n.js.map +1 -0
- package/dist/{index.native-DlMO7aHv.mjs → index.native-DWI_i6-6.mjs} +202 -2556
- package/dist/index.native-DWI_i6-6.mjs.map +1 -0
- package/dist/index.native.js +2 -2
- package/dist/index.native.mjs +2 -2
- package/dist/{phantom-wallet-provider-DWG1LVJf.mjs → phantom-wallet-provider-DDwgNMg_.mjs} +7 -18
- package/dist/phantom-wallet-provider-DDwgNMg_.mjs.map +1 -0
- package/dist/{phantom-wallet-provider-DUdnFoyb.js → phantom-wallet-provider-fyOrJZP6.js} +7 -18
- package/dist/phantom-wallet-provider-fyOrJZP6.js.map +1 -0
- package/dist/{privy-wallet-provider-Kv6H3xcS.js → privy-wallet-provider-BIr9lDS7.js} +69 -90
- package/dist/privy-wallet-provider-BIr9lDS7.js.map +1 -0
- package/dist/{privy-wallet-provider-CyNLekvY.mjs → privy-wallet-provider-D7VoQCYf.mjs} +68 -89
- package/dist/privy-wallet-provider-D7VoQCYf.mjs.map +1 -0
- package/dist/{solana-mobile-wallet-provider-BfHBucO0.js → solana-mobile-wallet-provider-Cush-URL.js} +39 -25
- package/dist/solana-mobile-wallet-provider-Cush-URL.js.map +1 -0
- package/dist/{solana-mobile-wallet-provider-CKOSbLRd.mjs → solana-mobile-wallet-provider-DgcGxDoL.mjs} +39 -25
- package/dist/solana-mobile-wallet-provider-DgcGxDoL.mjs.map +1 -0
- package/package.json +2 -2
- package/dist/index.native-DlMO7aHv.mjs.map +0 -1
- package/dist/index.native-DoiNBZlU.js.map +0 -1
- package/dist/phantom-wallet-provider-DUdnFoyb.js.map +0 -1
- package/dist/phantom-wallet-provider-DWG1LVJf.mjs.map +0 -1
- package/dist/privy-wallet-provider-CyNLekvY.mjs.map +0 -1
- package/dist/privy-wallet-provider-Kv6H3xcS.js.map +0 -1
- package/dist/solana-mobile-wallet-provider-BfHBucO0.js.map +0 -1
- package/dist/solana-mobile-wallet-provider-CKOSbLRd.mjs.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var core = require('@bounded-sh/core');
|
|
4
|
-
var web3_js = require('@solana/web3.js');
|
|
5
4
|
var React = require('react');
|
|
5
|
+
var web3_js = require('@solana/web3.js');
|
|
6
6
|
var anchor = require('@coral-xyz/anchor');
|
|
7
7
|
|
|
8
8
|
function _interopNamespaceDefault(e) {
|
|
@@ -245,9 +245,7 @@ class MockAuthProvider {
|
|
|
245
245
|
}
|
|
246
246
|
async signMessageMock(message) {
|
|
247
247
|
const address = getPlatform().sessionStorage.getItem('test-user-address') || DEFAULT_TEST_ADDRESS;
|
|
248
|
-
|
|
249
|
-
// mock provider deterministic so mockAuth exercises the same integrity check.
|
|
250
|
-
const signature = await this.generateOffchainSignature(message);
|
|
248
|
+
const signature = `mock_sig_${Math.random().toString(36).substring(2, 15)}`;
|
|
251
249
|
console.log('[MockAuth] Mock message signed:', {
|
|
252
250
|
address,
|
|
253
251
|
message,
|
|
@@ -255,13 +253,6 @@ class MockAuthProvider {
|
|
|
255
253
|
});
|
|
256
254
|
return signature;
|
|
257
255
|
}
|
|
258
|
-
async generateOffchainSignature(message) {
|
|
259
|
-
const platform = getPlatform();
|
|
260
|
-
const data = platform.textEncode(message);
|
|
261
|
-
const hashBuffer = await platform.sha256(data);
|
|
262
|
-
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
263
|
-
return platform.btoa(String.fromCharCode(...hashArray));
|
|
264
|
-
}
|
|
265
256
|
/**
|
|
266
257
|
* Mock transaction signing - returns the transaction as-is (no actual signing)
|
|
267
258
|
*/
|
|
@@ -320,9 +311,9 @@ class MockAuthProvider {
|
|
|
320
311
|
/**
|
|
321
312
|
* OffchainAuthProvider wraps a real auth provider (e.g., Phantom) for the poofnet environment.
|
|
322
313
|
*
|
|
323
|
-
* For signMessageMock, this shows a custom confirmation modal and
|
|
324
|
-
*
|
|
325
|
-
*
|
|
314
|
+
* For signMessageMock, this shows a custom confirmation modal and then delegates
|
|
315
|
+
* to the wrapped provider for a real detached signature over the exact offchain
|
|
316
|
+
* transaction message.
|
|
326
317
|
*/
|
|
327
318
|
class OffchainAuthProvider {
|
|
328
319
|
constructor(wrappedProvider, config = {}) {
|
|
@@ -390,8 +381,7 @@ class OffchainAuthProvider {
|
|
|
390
381
|
throw new Error("Transaction rejected by user");
|
|
391
382
|
}
|
|
392
383
|
}
|
|
393
|
-
|
|
394
|
-
const signature = await this.generateMockSignature(message);
|
|
384
|
+
const signature = await this.wrappedProvider.signMessage(message);
|
|
395
385
|
// Callback: signing complete
|
|
396
386
|
(_d = (_c = this.config).onSigningComplete) === null || _d === void 0 ? void 0 : _d.call(_c, signature);
|
|
397
387
|
return signature;
|
|
@@ -1000,26 +990,12 @@ class OffchainAuthProvider {
|
|
|
1000
990
|
}
|
|
1001
991
|
`;
|
|
1002
992
|
}
|
|
1003
|
-
async generateMockSignature(message) {
|
|
1004
|
-
// Generate a deterministic signature using SHA-256 hash of message
|
|
1005
|
-
// This can be verified on the backend by hashing the same message
|
|
1006
|
-
const platform = getPlatform();
|
|
1007
|
-
const data = platform.textEncode(message);
|
|
1008
|
-
const hashBuffer = await platform.sha256(data);
|
|
1009
|
-
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
1010
|
-
const base64 = platform.btoa(String.fromCharCode(...hashArray));
|
|
1011
|
-
return base64;
|
|
1012
|
-
}
|
|
1013
993
|
}
|
|
1014
994
|
|
|
1015
995
|
function getDefaultExportFromCjs (x) {
|
|
1016
996
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
1017
997
|
}
|
|
1018
998
|
|
|
1019
|
-
function getDefaultExportFromNamespaceIfNotNamed (n) {
|
|
1020
|
-
return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1 ? n['default'] : n;
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
999
|
var safeBuffer = {exports: {}};
|
|
1024
1000
|
|
|
1025
1001
|
var buffer = {};
|
|
@@ -3609,2444 +3585,24 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
3609
3585
|
default: bs58
|
|
3610
3586
|
});
|
|
3611
3587
|
|
|
3612
|
-
function commonjsRequire(path) {
|
|
3613
|
-
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
3614
|
-
}
|
|
3615
|
-
|
|
3616
|
-
var naclFast = {exports: {}};
|
|
3617
|
-
|
|
3618
|
-
var _nodeResolve_empty = {};
|
|
3619
|
-
|
|
3620
|
-
var _nodeResolve_empty$1 = /*#__PURE__*/Object.freeze({
|
|
3621
|
-
__proto__: null,
|
|
3622
|
-
default: _nodeResolve_empty
|
|
3623
|
-
});
|
|
3624
|
-
|
|
3625
|
-
var require$$0 = /*@__PURE__*/getDefaultExportFromNamespaceIfNotNamed(_nodeResolve_empty$1);
|
|
3626
|
-
|
|
3627
|
-
var hasRequiredNaclFast;
|
|
3628
|
-
|
|
3629
|
-
function requireNaclFast () {
|
|
3630
|
-
if (hasRequiredNaclFast) return naclFast.exports;
|
|
3631
|
-
hasRequiredNaclFast = 1;
|
|
3632
|
-
(function (module) {
|
|
3633
|
-
(function(nacl) {
|
|
3634
|
-
|
|
3635
|
-
// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.
|
|
3636
|
-
// Public domain.
|
|
3637
|
-
//
|
|
3638
|
-
// Implementation derived from TweetNaCl version 20140427.
|
|
3639
|
-
// See for details: http://tweetnacl.cr.yp.to/
|
|
3640
|
-
|
|
3641
|
-
var gf = function(init) {
|
|
3642
|
-
var i, r = new Float64Array(16);
|
|
3643
|
-
if (init) for (i = 0; i < init.length; i++) r[i] = init[i];
|
|
3644
|
-
return r;
|
|
3645
|
-
};
|
|
3646
|
-
|
|
3647
|
-
// Pluggable, initialized in high-level API below.
|
|
3648
|
-
var randombytes = function(/* x, n */) { throw new Error('no PRNG'); };
|
|
3649
|
-
|
|
3650
|
-
var _0 = new Uint8Array(16);
|
|
3651
|
-
var _9 = new Uint8Array(32); _9[0] = 9;
|
|
3652
|
-
|
|
3653
|
-
var gf0 = gf(),
|
|
3654
|
-
gf1 = gf([1]),
|
|
3655
|
-
_121665 = gf([0xdb41, 1]),
|
|
3656
|
-
D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),
|
|
3657
|
-
D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),
|
|
3658
|
-
X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),
|
|
3659
|
-
Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),
|
|
3660
|
-
I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);
|
|
3661
|
-
|
|
3662
|
-
function ts64(x, i, h, l) {
|
|
3663
|
-
x[i] = (h >> 24) & 0xff;
|
|
3664
|
-
x[i+1] = (h >> 16) & 0xff;
|
|
3665
|
-
x[i+2] = (h >> 8) & 0xff;
|
|
3666
|
-
x[i+3] = h & 0xff;
|
|
3667
|
-
x[i+4] = (l >> 24) & 0xff;
|
|
3668
|
-
x[i+5] = (l >> 16) & 0xff;
|
|
3669
|
-
x[i+6] = (l >> 8) & 0xff;
|
|
3670
|
-
x[i+7] = l & 0xff;
|
|
3671
|
-
}
|
|
3672
|
-
|
|
3673
|
-
function vn(x, xi, y, yi, n) {
|
|
3674
|
-
var i,d = 0;
|
|
3675
|
-
for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];
|
|
3676
|
-
return (1 & ((d - 1) >>> 8)) - 1;
|
|
3677
|
-
}
|
|
3678
|
-
|
|
3679
|
-
function crypto_verify_16(x, xi, y, yi) {
|
|
3680
|
-
return vn(x,xi,y,yi,16);
|
|
3681
|
-
}
|
|
3682
|
-
|
|
3683
|
-
function crypto_verify_32(x, xi, y, yi) {
|
|
3684
|
-
return vn(x,xi,y,yi,32);
|
|
3685
|
-
}
|
|
3686
|
-
|
|
3687
|
-
function core_salsa20(o, p, k, c) {
|
|
3688
|
-
var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
|
|
3689
|
-
j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
|
|
3690
|
-
j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
|
|
3691
|
-
j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
|
|
3692
|
-
j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
|
|
3693
|
-
j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
|
|
3694
|
-
j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
|
|
3695
|
-
j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
|
|
3696
|
-
j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
|
|
3697
|
-
j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
|
|
3698
|
-
j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
|
|
3699
|
-
j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
|
|
3700
|
-
j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
|
|
3701
|
-
j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
|
|
3702
|
-
j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
|
|
3703
|
-
j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
|
|
3704
|
-
|
|
3705
|
-
var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
|
|
3706
|
-
x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
|
|
3707
|
-
x15 = j15, u;
|
|
3708
|
-
|
|
3709
|
-
for (var i = 0; i < 20; i += 2) {
|
|
3710
|
-
u = x0 + x12 | 0;
|
|
3711
|
-
x4 ^= u<<7 | u>>>(32-7);
|
|
3712
|
-
u = x4 + x0 | 0;
|
|
3713
|
-
x8 ^= u<<9 | u>>>(32-9);
|
|
3714
|
-
u = x8 + x4 | 0;
|
|
3715
|
-
x12 ^= u<<13 | u>>>(32-13);
|
|
3716
|
-
u = x12 + x8 | 0;
|
|
3717
|
-
x0 ^= u<<18 | u>>>(32-18);
|
|
3718
|
-
|
|
3719
|
-
u = x5 + x1 | 0;
|
|
3720
|
-
x9 ^= u<<7 | u>>>(32-7);
|
|
3721
|
-
u = x9 + x5 | 0;
|
|
3722
|
-
x13 ^= u<<9 | u>>>(32-9);
|
|
3723
|
-
u = x13 + x9 | 0;
|
|
3724
|
-
x1 ^= u<<13 | u>>>(32-13);
|
|
3725
|
-
u = x1 + x13 | 0;
|
|
3726
|
-
x5 ^= u<<18 | u>>>(32-18);
|
|
3727
|
-
|
|
3728
|
-
u = x10 + x6 | 0;
|
|
3729
|
-
x14 ^= u<<7 | u>>>(32-7);
|
|
3730
|
-
u = x14 + x10 | 0;
|
|
3731
|
-
x2 ^= u<<9 | u>>>(32-9);
|
|
3732
|
-
u = x2 + x14 | 0;
|
|
3733
|
-
x6 ^= u<<13 | u>>>(32-13);
|
|
3734
|
-
u = x6 + x2 | 0;
|
|
3735
|
-
x10 ^= u<<18 | u>>>(32-18);
|
|
3736
|
-
|
|
3737
|
-
u = x15 + x11 | 0;
|
|
3738
|
-
x3 ^= u<<7 | u>>>(32-7);
|
|
3739
|
-
u = x3 + x15 | 0;
|
|
3740
|
-
x7 ^= u<<9 | u>>>(32-9);
|
|
3741
|
-
u = x7 + x3 | 0;
|
|
3742
|
-
x11 ^= u<<13 | u>>>(32-13);
|
|
3743
|
-
u = x11 + x7 | 0;
|
|
3744
|
-
x15 ^= u<<18 | u>>>(32-18);
|
|
3745
|
-
|
|
3746
|
-
u = x0 + x3 | 0;
|
|
3747
|
-
x1 ^= u<<7 | u>>>(32-7);
|
|
3748
|
-
u = x1 + x0 | 0;
|
|
3749
|
-
x2 ^= u<<9 | u>>>(32-9);
|
|
3750
|
-
u = x2 + x1 | 0;
|
|
3751
|
-
x3 ^= u<<13 | u>>>(32-13);
|
|
3752
|
-
u = x3 + x2 | 0;
|
|
3753
|
-
x0 ^= u<<18 | u>>>(32-18);
|
|
3754
|
-
|
|
3755
|
-
u = x5 + x4 | 0;
|
|
3756
|
-
x6 ^= u<<7 | u>>>(32-7);
|
|
3757
|
-
u = x6 + x5 | 0;
|
|
3758
|
-
x7 ^= u<<9 | u>>>(32-9);
|
|
3759
|
-
u = x7 + x6 | 0;
|
|
3760
|
-
x4 ^= u<<13 | u>>>(32-13);
|
|
3761
|
-
u = x4 + x7 | 0;
|
|
3762
|
-
x5 ^= u<<18 | u>>>(32-18);
|
|
3763
|
-
|
|
3764
|
-
u = x10 + x9 | 0;
|
|
3765
|
-
x11 ^= u<<7 | u>>>(32-7);
|
|
3766
|
-
u = x11 + x10 | 0;
|
|
3767
|
-
x8 ^= u<<9 | u>>>(32-9);
|
|
3768
|
-
u = x8 + x11 | 0;
|
|
3769
|
-
x9 ^= u<<13 | u>>>(32-13);
|
|
3770
|
-
u = x9 + x8 | 0;
|
|
3771
|
-
x10 ^= u<<18 | u>>>(32-18);
|
|
3772
|
-
|
|
3773
|
-
u = x15 + x14 | 0;
|
|
3774
|
-
x12 ^= u<<7 | u>>>(32-7);
|
|
3775
|
-
u = x12 + x15 | 0;
|
|
3776
|
-
x13 ^= u<<9 | u>>>(32-9);
|
|
3777
|
-
u = x13 + x12 | 0;
|
|
3778
|
-
x14 ^= u<<13 | u>>>(32-13);
|
|
3779
|
-
u = x14 + x13 | 0;
|
|
3780
|
-
x15 ^= u<<18 | u>>>(32-18);
|
|
3781
|
-
}
|
|
3782
|
-
x0 = x0 + j0 | 0;
|
|
3783
|
-
x1 = x1 + j1 | 0;
|
|
3784
|
-
x2 = x2 + j2 | 0;
|
|
3785
|
-
x3 = x3 + j3 | 0;
|
|
3786
|
-
x4 = x4 + j4 | 0;
|
|
3787
|
-
x5 = x5 + j5 | 0;
|
|
3788
|
-
x6 = x6 + j6 | 0;
|
|
3789
|
-
x7 = x7 + j7 | 0;
|
|
3790
|
-
x8 = x8 + j8 | 0;
|
|
3791
|
-
x9 = x9 + j9 | 0;
|
|
3792
|
-
x10 = x10 + j10 | 0;
|
|
3793
|
-
x11 = x11 + j11 | 0;
|
|
3794
|
-
x12 = x12 + j12 | 0;
|
|
3795
|
-
x13 = x13 + j13 | 0;
|
|
3796
|
-
x14 = x14 + j14 | 0;
|
|
3797
|
-
x15 = x15 + j15 | 0;
|
|
3798
|
-
|
|
3799
|
-
o[ 0] = x0 >>> 0 & 0xff;
|
|
3800
|
-
o[ 1] = x0 >>> 8 & 0xff;
|
|
3801
|
-
o[ 2] = x0 >>> 16 & 0xff;
|
|
3802
|
-
o[ 3] = x0 >>> 24 & 0xff;
|
|
3803
|
-
|
|
3804
|
-
o[ 4] = x1 >>> 0 & 0xff;
|
|
3805
|
-
o[ 5] = x1 >>> 8 & 0xff;
|
|
3806
|
-
o[ 6] = x1 >>> 16 & 0xff;
|
|
3807
|
-
o[ 7] = x1 >>> 24 & 0xff;
|
|
3808
|
-
|
|
3809
|
-
o[ 8] = x2 >>> 0 & 0xff;
|
|
3810
|
-
o[ 9] = x2 >>> 8 & 0xff;
|
|
3811
|
-
o[10] = x2 >>> 16 & 0xff;
|
|
3812
|
-
o[11] = x2 >>> 24 & 0xff;
|
|
3813
|
-
|
|
3814
|
-
o[12] = x3 >>> 0 & 0xff;
|
|
3815
|
-
o[13] = x3 >>> 8 & 0xff;
|
|
3816
|
-
o[14] = x3 >>> 16 & 0xff;
|
|
3817
|
-
o[15] = x3 >>> 24 & 0xff;
|
|
3818
|
-
|
|
3819
|
-
o[16] = x4 >>> 0 & 0xff;
|
|
3820
|
-
o[17] = x4 >>> 8 & 0xff;
|
|
3821
|
-
o[18] = x4 >>> 16 & 0xff;
|
|
3822
|
-
o[19] = x4 >>> 24 & 0xff;
|
|
3823
|
-
|
|
3824
|
-
o[20] = x5 >>> 0 & 0xff;
|
|
3825
|
-
o[21] = x5 >>> 8 & 0xff;
|
|
3826
|
-
o[22] = x5 >>> 16 & 0xff;
|
|
3827
|
-
o[23] = x5 >>> 24 & 0xff;
|
|
3828
|
-
|
|
3829
|
-
o[24] = x6 >>> 0 & 0xff;
|
|
3830
|
-
o[25] = x6 >>> 8 & 0xff;
|
|
3831
|
-
o[26] = x6 >>> 16 & 0xff;
|
|
3832
|
-
o[27] = x6 >>> 24 & 0xff;
|
|
3833
|
-
|
|
3834
|
-
o[28] = x7 >>> 0 & 0xff;
|
|
3835
|
-
o[29] = x7 >>> 8 & 0xff;
|
|
3836
|
-
o[30] = x7 >>> 16 & 0xff;
|
|
3837
|
-
o[31] = x7 >>> 24 & 0xff;
|
|
3838
|
-
|
|
3839
|
-
o[32] = x8 >>> 0 & 0xff;
|
|
3840
|
-
o[33] = x8 >>> 8 & 0xff;
|
|
3841
|
-
o[34] = x8 >>> 16 & 0xff;
|
|
3842
|
-
o[35] = x8 >>> 24 & 0xff;
|
|
3843
|
-
|
|
3844
|
-
o[36] = x9 >>> 0 & 0xff;
|
|
3845
|
-
o[37] = x9 >>> 8 & 0xff;
|
|
3846
|
-
o[38] = x9 >>> 16 & 0xff;
|
|
3847
|
-
o[39] = x9 >>> 24 & 0xff;
|
|
3848
|
-
|
|
3849
|
-
o[40] = x10 >>> 0 & 0xff;
|
|
3850
|
-
o[41] = x10 >>> 8 & 0xff;
|
|
3851
|
-
o[42] = x10 >>> 16 & 0xff;
|
|
3852
|
-
o[43] = x10 >>> 24 & 0xff;
|
|
3853
|
-
|
|
3854
|
-
o[44] = x11 >>> 0 & 0xff;
|
|
3855
|
-
o[45] = x11 >>> 8 & 0xff;
|
|
3856
|
-
o[46] = x11 >>> 16 & 0xff;
|
|
3857
|
-
o[47] = x11 >>> 24 & 0xff;
|
|
3858
|
-
|
|
3859
|
-
o[48] = x12 >>> 0 & 0xff;
|
|
3860
|
-
o[49] = x12 >>> 8 & 0xff;
|
|
3861
|
-
o[50] = x12 >>> 16 & 0xff;
|
|
3862
|
-
o[51] = x12 >>> 24 & 0xff;
|
|
3863
|
-
|
|
3864
|
-
o[52] = x13 >>> 0 & 0xff;
|
|
3865
|
-
o[53] = x13 >>> 8 & 0xff;
|
|
3866
|
-
o[54] = x13 >>> 16 & 0xff;
|
|
3867
|
-
o[55] = x13 >>> 24 & 0xff;
|
|
3868
|
-
|
|
3869
|
-
o[56] = x14 >>> 0 & 0xff;
|
|
3870
|
-
o[57] = x14 >>> 8 & 0xff;
|
|
3871
|
-
o[58] = x14 >>> 16 & 0xff;
|
|
3872
|
-
o[59] = x14 >>> 24 & 0xff;
|
|
3873
|
-
|
|
3874
|
-
o[60] = x15 >>> 0 & 0xff;
|
|
3875
|
-
o[61] = x15 >>> 8 & 0xff;
|
|
3876
|
-
o[62] = x15 >>> 16 & 0xff;
|
|
3877
|
-
o[63] = x15 >>> 24 & 0xff;
|
|
3878
|
-
}
|
|
3879
|
-
|
|
3880
|
-
function core_hsalsa20(o,p,k,c) {
|
|
3881
|
-
var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
|
|
3882
|
-
j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
|
|
3883
|
-
j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
|
|
3884
|
-
j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
|
|
3885
|
-
j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
|
|
3886
|
-
j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
|
|
3887
|
-
j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
|
|
3888
|
-
j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
|
|
3889
|
-
j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
|
|
3890
|
-
j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
|
|
3891
|
-
j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
|
|
3892
|
-
j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
|
|
3893
|
-
j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
|
|
3894
|
-
j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
|
|
3895
|
-
j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
|
|
3896
|
-
j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
|
|
3897
|
-
|
|
3898
|
-
var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
|
|
3899
|
-
x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
|
|
3900
|
-
x15 = j15, u;
|
|
3901
|
-
|
|
3902
|
-
for (var i = 0; i < 20; i += 2) {
|
|
3903
|
-
u = x0 + x12 | 0;
|
|
3904
|
-
x4 ^= u<<7 | u>>>(32-7);
|
|
3905
|
-
u = x4 + x0 | 0;
|
|
3906
|
-
x8 ^= u<<9 | u>>>(32-9);
|
|
3907
|
-
u = x8 + x4 | 0;
|
|
3908
|
-
x12 ^= u<<13 | u>>>(32-13);
|
|
3909
|
-
u = x12 + x8 | 0;
|
|
3910
|
-
x0 ^= u<<18 | u>>>(32-18);
|
|
3911
|
-
|
|
3912
|
-
u = x5 + x1 | 0;
|
|
3913
|
-
x9 ^= u<<7 | u>>>(32-7);
|
|
3914
|
-
u = x9 + x5 | 0;
|
|
3915
|
-
x13 ^= u<<9 | u>>>(32-9);
|
|
3916
|
-
u = x13 + x9 | 0;
|
|
3917
|
-
x1 ^= u<<13 | u>>>(32-13);
|
|
3918
|
-
u = x1 + x13 | 0;
|
|
3919
|
-
x5 ^= u<<18 | u>>>(32-18);
|
|
3920
|
-
|
|
3921
|
-
u = x10 + x6 | 0;
|
|
3922
|
-
x14 ^= u<<7 | u>>>(32-7);
|
|
3923
|
-
u = x14 + x10 | 0;
|
|
3924
|
-
x2 ^= u<<9 | u>>>(32-9);
|
|
3925
|
-
u = x2 + x14 | 0;
|
|
3926
|
-
x6 ^= u<<13 | u>>>(32-13);
|
|
3927
|
-
u = x6 + x2 | 0;
|
|
3928
|
-
x10 ^= u<<18 | u>>>(32-18);
|
|
3929
|
-
|
|
3930
|
-
u = x15 + x11 | 0;
|
|
3931
|
-
x3 ^= u<<7 | u>>>(32-7);
|
|
3932
|
-
u = x3 + x15 | 0;
|
|
3933
|
-
x7 ^= u<<9 | u>>>(32-9);
|
|
3934
|
-
u = x7 + x3 | 0;
|
|
3935
|
-
x11 ^= u<<13 | u>>>(32-13);
|
|
3936
|
-
u = x11 + x7 | 0;
|
|
3937
|
-
x15 ^= u<<18 | u>>>(32-18);
|
|
3938
|
-
|
|
3939
|
-
u = x0 + x3 | 0;
|
|
3940
|
-
x1 ^= u<<7 | u>>>(32-7);
|
|
3941
|
-
u = x1 + x0 | 0;
|
|
3942
|
-
x2 ^= u<<9 | u>>>(32-9);
|
|
3943
|
-
u = x2 + x1 | 0;
|
|
3944
|
-
x3 ^= u<<13 | u>>>(32-13);
|
|
3945
|
-
u = x3 + x2 | 0;
|
|
3946
|
-
x0 ^= u<<18 | u>>>(32-18);
|
|
3947
|
-
|
|
3948
|
-
u = x5 + x4 | 0;
|
|
3949
|
-
x6 ^= u<<7 | u>>>(32-7);
|
|
3950
|
-
u = x6 + x5 | 0;
|
|
3951
|
-
x7 ^= u<<9 | u>>>(32-9);
|
|
3952
|
-
u = x7 + x6 | 0;
|
|
3953
|
-
x4 ^= u<<13 | u>>>(32-13);
|
|
3954
|
-
u = x4 + x7 | 0;
|
|
3955
|
-
x5 ^= u<<18 | u>>>(32-18);
|
|
3956
|
-
|
|
3957
|
-
u = x10 + x9 | 0;
|
|
3958
|
-
x11 ^= u<<7 | u>>>(32-7);
|
|
3959
|
-
u = x11 + x10 | 0;
|
|
3960
|
-
x8 ^= u<<9 | u>>>(32-9);
|
|
3961
|
-
u = x8 + x11 | 0;
|
|
3962
|
-
x9 ^= u<<13 | u>>>(32-13);
|
|
3963
|
-
u = x9 + x8 | 0;
|
|
3964
|
-
x10 ^= u<<18 | u>>>(32-18);
|
|
3965
|
-
|
|
3966
|
-
u = x15 + x14 | 0;
|
|
3967
|
-
x12 ^= u<<7 | u>>>(32-7);
|
|
3968
|
-
u = x12 + x15 | 0;
|
|
3969
|
-
x13 ^= u<<9 | u>>>(32-9);
|
|
3970
|
-
u = x13 + x12 | 0;
|
|
3971
|
-
x14 ^= u<<13 | u>>>(32-13);
|
|
3972
|
-
u = x14 + x13 | 0;
|
|
3973
|
-
x15 ^= u<<18 | u>>>(32-18);
|
|
3974
|
-
}
|
|
3975
|
-
|
|
3976
|
-
o[ 0] = x0 >>> 0 & 0xff;
|
|
3977
|
-
o[ 1] = x0 >>> 8 & 0xff;
|
|
3978
|
-
o[ 2] = x0 >>> 16 & 0xff;
|
|
3979
|
-
o[ 3] = x0 >>> 24 & 0xff;
|
|
3980
|
-
|
|
3981
|
-
o[ 4] = x5 >>> 0 & 0xff;
|
|
3982
|
-
o[ 5] = x5 >>> 8 & 0xff;
|
|
3983
|
-
o[ 6] = x5 >>> 16 & 0xff;
|
|
3984
|
-
o[ 7] = x5 >>> 24 & 0xff;
|
|
3985
|
-
|
|
3986
|
-
o[ 8] = x10 >>> 0 & 0xff;
|
|
3987
|
-
o[ 9] = x10 >>> 8 & 0xff;
|
|
3988
|
-
o[10] = x10 >>> 16 & 0xff;
|
|
3989
|
-
o[11] = x10 >>> 24 & 0xff;
|
|
3990
|
-
|
|
3991
|
-
o[12] = x15 >>> 0 & 0xff;
|
|
3992
|
-
o[13] = x15 >>> 8 & 0xff;
|
|
3993
|
-
o[14] = x15 >>> 16 & 0xff;
|
|
3994
|
-
o[15] = x15 >>> 24 & 0xff;
|
|
3995
|
-
|
|
3996
|
-
o[16] = x6 >>> 0 & 0xff;
|
|
3997
|
-
o[17] = x6 >>> 8 & 0xff;
|
|
3998
|
-
o[18] = x6 >>> 16 & 0xff;
|
|
3999
|
-
o[19] = x6 >>> 24 & 0xff;
|
|
4000
|
-
|
|
4001
|
-
o[20] = x7 >>> 0 & 0xff;
|
|
4002
|
-
o[21] = x7 >>> 8 & 0xff;
|
|
4003
|
-
o[22] = x7 >>> 16 & 0xff;
|
|
4004
|
-
o[23] = x7 >>> 24 & 0xff;
|
|
4005
|
-
|
|
4006
|
-
o[24] = x8 >>> 0 & 0xff;
|
|
4007
|
-
o[25] = x8 >>> 8 & 0xff;
|
|
4008
|
-
o[26] = x8 >>> 16 & 0xff;
|
|
4009
|
-
o[27] = x8 >>> 24 & 0xff;
|
|
4010
|
-
|
|
4011
|
-
o[28] = x9 >>> 0 & 0xff;
|
|
4012
|
-
o[29] = x9 >>> 8 & 0xff;
|
|
4013
|
-
o[30] = x9 >>> 16 & 0xff;
|
|
4014
|
-
o[31] = x9 >>> 24 & 0xff;
|
|
4015
|
-
}
|
|
4016
|
-
|
|
4017
|
-
function crypto_core_salsa20(out,inp,k,c) {
|
|
4018
|
-
core_salsa20(out,inp,k,c);
|
|
4019
|
-
}
|
|
4020
|
-
|
|
4021
|
-
function crypto_core_hsalsa20(out,inp,k,c) {
|
|
4022
|
-
core_hsalsa20(out,inp,k,c);
|
|
4023
|
-
}
|
|
4024
|
-
|
|
4025
|
-
var sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);
|
|
4026
|
-
// "expand 32-byte k"
|
|
4027
|
-
|
|
4028
|
-
function crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {
|
|
4029
|
-
var z = new Uint8Array(16), x = new Uint8Array(64);
|
|
4030
|
-
var u, i;
|
|
4031
|
-
for (i = 0; i < 16; i++) z[i] = 0;
|
|
4032
|
-
for (i = 0; i < 8; i++) z[i] = n[i];
|
|
4033
|
-
while (b >= 64) {
|
|
4034
|
-
crypto_core_salsa20(x,z,k,sigma);
|
|
4035
|
-
for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];
|
|
4036
|
-
u = 1;
|
|
4037
|
-
for (i = 8; i < 16; i++) {
|
|
4038
|
-
u = u + (z[i] & 0xff) | 0;
|
|
4039
|
-
z[i] = u & 0xff;
|
|
4040
|
-
u >>>= 8;
|
|
4041
|
-
}
|
|
4042
|
-
b -= 64;
|
|
4043
|
-
cpos += 64;
|
|
4044
|
-
mpos += 64;
|
|
4045
|
-
}
|
|
4046
|
-
if (b > 0) {
|
|
4047
|
-
crypto_core_salsa20(x,z,k,sigma);
|
|
4048
|
-
for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];
|
|
4049
|
-
}
|
|
4050
|
-
return 0;
|
|
4051
|
-
}
|
|
4052
|
-
|
|
4053
|
-
function crypto_stream_salsa20(c,cpos,b,n,k) {
|
|
4054
|
-
var z = new Uint8Array(16), x = new Uint8Array(64);
|
|
4055
|
-
var u, i;
|
|
4056
|
-
for (i = 0; i < 16; i++) z[i] = 0;
|
|
4057
|
-
for (i = 0; i < 8; i++) z[i] = n[i];
|
|
4058
|
-
while (b >= 64) {
|
|
4059
|
-
crypto_core_salsa20(x,z,k,sigma);
|
|
4060
|
-
for (i = 0; i < 64; i++) c[cpos+i] = x[i];
|
|
4061
|
-
u = 1;
|
|
4062
|
-
for (i = 8; i < 16; i++) {
|
|
4063
|
-
u = u + (z[i] & 0xff) | 0;
|
|
4064
|
-
z[i] = u & 0xff;
|
|
4065
|
-
u >>>= 8;
|
|
4066
|
-
}
|
|
4067
|
-
b -= 64;
|
|
4068
|
-
cpos += 64;
|
|
4069
|
-
}
|
|
4070
|
-
if (b > 0) {
|
|
4071
|
-
crypto_core_salsa20(x,z,k,sigma);
|
|
4072
|
-
for (i = 0; i < b; i++) c[cpos+i] = x[i];
|
|
4073
|
-
}
|
|
4074
|
-
return 0;
|
|
4075
|
-
}
|
|
4076
|
-
|
|
4077
|
-
function crypto_stream(c,cpos,d,n,k) {
|
|
4078
|
-
var s = new Uint8Array(32);
|
|
4079
|
-
crypto_core_hsalsa20(s,n,k,sigma);
|
|
4080
|
-
var sn = new Uint8Array(8);
|
|
4081
|
-
for (var i = 0; i < 8; i++) sn[i] = n[i+16];
|
|
4082
|
-
return crypto_stream_salsa20(c,cpos,d,sn,s);
|
|
4083
|
-
}
|
|
4084
|
-
|
|
4085
|
-
function crypto_stream_xor(c,cpos,m,mpos,d,n,k) {
|
|
4086
|
-
var s = new Uint8Array(32);
|
|
4087
|
-
crypto_core_hsalsa20(s,n,k,sigma);
|
|
4088
|
-
var sn = new Uint8Array(8);
|
|
4089
|
-
for (var i = 0; i < 8; i++) sn[i] = n[i+16];
|
|
4090
|
-
return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);
|
|
4091
|
-
}
|
|
4092
|
-
|
|
4093
|
-
/*
|
|
4094
|
-
* Port of Andrew Moon's Poly1305-donna-16. Public domain.
|
|
4095
|
-
* https://github.com/floodyberry/poly1305-donna
|
|
4096
|
-
*/
|
|
4097
|
-
|
|
4098
|
-
var poly1305 = function(key) {
|
|
4099
|
-
this.buffer = new Uint8Array(16);
|
|
4100
|
-
this.r = new Uint16Array(10);
|
|
4101
|
-
this.h = new Uint16Array(10);
|
|
4102
|
-
this.pad = new Uint16Array(8);
|
|
4103
|
-
this.leftover = 0;
|
|
4104
|
-
this.fin = 0;
|
|
4105
|
-
|
|
4106
|
-
var t0, t1, t2, t3, t4, t5, t6, t7;
|
|
4107
|
-
|
|
4108
|
-
t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;
|
|
4109
|
-
t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;
|
|
4110
|
-
t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;
|
|
4111
|
-
t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;
|
|
4112
|
-
t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;
|
|
4113
|
-
this.r[5] = ((t4 >>> 1)) & 0x1ffe;
|
|
4114
|
-
t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;
|
|
4115
|
-
t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;
|
|
4116
|
-
t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;
|
|
4117
|
-
this.r[9] = ((t7 >>> 5)) & 0x007f;
|
|
4118
|
-
|
|
4119
|
-
this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;
|
|
4120
|
-
this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;
|
|
4121
|
-
this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;
|
|
4122
|
-
this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;
|
|
4123
|
-
this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;
|
|
4124
|
-
this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;
|
|
4125
|
-
this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;
|
|
4126
|
-
this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;
|
|
4127
|
-
};
|
|
4128
|
-
|
|
4129
|
-
poly1305.prototype.blocks = function(m, mpos, bytes) {
|
|
4130
|
-
var hibit = this.fin ? 0 : (1 << 11);
|
|
4131
|
-
var t0, t1, t2, t3, t4, t5, t6, t7, c;
|
|
4132
|
-
var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;
|
|
4133
|
-
|
|
4134
|
-
var h0 = this.h[0],
|
|
4135
|
-
h1 = this.h[1],
|
|
4136
|
-
h2 = this.h[2],
|
|
4137
|
-
h3 = this.h[3],
|
|
4138
|
-
h4 = this.h[4],
|
|
4139
|
-
h5 = this.h[5],
|
|
4140
|
-
h6 = this.h[6],
|
|
4141
|
-
h7 = this.h[7],
|
|
4142
|
-
h8 = this.h[8],
|
|
4143
|
-
h9 = this.h[9];
|
|
4144
|
-
|
|
4145
|
-
var r0 = this.r[0],
|
|
4146
|
-
r1 = this.r[1],
|
|
4147
|
-
r2 = this.r[2],
|
|
4148
|
-
r3 = this.r[3],
|
|
4149
|
-
r4 = this.r[4],
|
|
4150
|
-
r5 = this.r[5],
|
|
4151
|
-
r6 = this.r[6],
|
|
4152
|
-
r7 = this.r[7],
|
|
4153
|
-
r8 = this.r[8],
|
|
4154
|
-
r9 = this.r[9];
|
|
4155
|
-
|
|
4156
|
-
while (bytes >= 16) {
|
|
4157
|
-
t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;
|
|
4158
|
-
t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;
|
|
4159
|
-
t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;
|
|
4160
|
-
t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;
|
|
4161
|
-
t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;
|
|
4162
|
-
h5 += ((t4 >>> 1)) & 0x1fff;
|
|
4163
|
-
t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;
|
|
4164
|
-
t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;
|
|
4165
|
-
t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;
|
|
4166
|
-
h9 += ((t7 >>> 5)) | hibit;
|
|
4167
|
-
|
|
4168
|
-
c = 0;
|
|
4169
|
-
|
|
4170
|
-
d0 = c;
|
|
4171
|
-
d0 += h0 * r0;
|
|
4172
|
-
d0 += h1 * (5 * r9);
|
|
4173
|
-
d0 += h2 * (5 * r8);
|
|
4174
|
-
d0 += h3 * (5 * r7);
|
|
4175
|
-
d0 += h4 * (5 * r6);
|
|
4176
|
-
c = (d0 >>> 13); d0 &= 0x1fff;
|
|
4177
|
-
d0 += h5 * (5 * r5);
|
|
4178
|
-
d0 += h6 * (5 * r4);
|
|
4179
|
-
d0 += h7 * (5 * r3);
|
|
4180
|
-
d0 += h8 * (5 * r2);
|
|
4181
|
-
d0 += h9 * (5 * r1);
|
|
4182
|
-
c += (d0 >>> 13); d0 &= 0x1fff;
|
|
4183
|
-
|
|
4184
|
-
d1 = c;
|
|
4185
|
-
d1 += h0 * r1;
|
|
4186
|
-
d1 += h1 * r0;
|
|
4187
|
-
d1 += h2 * (5 * r9);
|
|
4188
|
-
d1 += h3 * (5 * r8);
|
|
4189
|
-
d1 += h4 * (5 * r7);
|
|
4190
|
-
c = (d1 >>> 13); d1 &= 0x1fff;
|
|
4191
|
-
d1 += h5 * (5 * r6);
|
|
4192
|
-
d1 += h6 * (5 * r5);
|
|
4193
|
-
d1 += h7 * (5 * r4);
|
|
4194
|
-
d1 += h8 * (5 * r3);
|
|
4195
|
-
d1 += h9 * (5 * r2);
|
|
4196
|
-
c += (d1 >>> 13); d1 &= 0x1fff;
|
|
4197
|
-
|
|
4198
|
-
d2 = c;
|
|
4199
|
-
d2 += h0 * r2;
|
|
4200
|
-
d2 += h1 * r1;
|
|
4201
|
-
d2 += h2 * r0;
|
|
4202
|
-
d2 += h3 * (5 * r9);
|
|
4203
|
-
d2 += h4 * (5 * r8);
|
|
4204
|
-
c = (d2 >>> 13); d2 &= 0x1fff;
|
|
4205
|
-
d2 += h5 * (5 * r7);
|
|
4206
|
-
d2 += h6 * (5 * r6);
|
|
4207
|
-
d2 += h7 * (5 * r5);
|
|
4208
|
-
d2 += h8 * (5 * r4);
|
|
4209
|
-
d2 += h9 * (5 * r3);
|
|
4210
|
-
c += (d2 >>> 13); d2 &= 0x1fff;
|
|
4211
|
-
|
|
4212
|
-
d3 = c;
|
|
4213
|
-
d3 += h0 * r3;
|
|
4214
|
-
d3 += h1 * r2;
|
|
4215
|
-
d3 += h2 * r1;
|
|
4216
|
-
d3 += h3 * r0;
|
|
4217
|
-
d3 += h4 * (5 * r9);
|
|
4218
|
-
c = (d3 >>> 13); d3 &= 0x1fff;
|
|
4219
|
-
d3 += h5 * (5 * r8);
|
|
4220
|
-
d3 += h6 * (5 * r7);
|
|
4221
|
-
d3 += h7 * (5 * r6);
|
|
4222
|
-
d3 += h8 * (5 * r5);
|
|
4223
|
-
d3 += h9 * (5 * r4);
|
|
4224
|
-
c += (d3 >>> 13); d3 &= 0x1fff;
|
|
4225
|
-
|
|
4226
|
-
d4 = c;
|
|
4227
|
-
d4 += h0 * r4;
|
|
4228
|
-
d4 += h1 * r3;
|
|
4229
|
-
d4 += h2 * r2;
|
|
4230
|
-
d4 += h3 * r1;
|
|
4231
|
-
d4 += h4 * r0;
|
|
4232
|
-
c = (d4 >>> 13); d4 &= 0x1fff;
|
|
4233
|
-
d4 += h5 * (5 * r9);
|
|
4234
|
-
d4 += h6 * (5 * r8);
|
|
4235
|
-
d4 += h7 * (5 * r7);
|
|
4236
|
-
d4 += h8 * (5 * r6);
|
|
4237
|
-
d4 += h9 * (5 * r5);
|
|
4238
|
-
c += (d4 >>> 13); d4 &= 0x1fff;
|
|
4239
|
-
|
|
4240
|
-
d5 = c;
|
|
4241
|
-
d5 += h0 * r5;
|
|
4242
|
-
d5 += h1 * r4;
|
|
4243
|
-
d5 += h2 * r3;
|
|
4244
|
-
d5 += h3 * r2;
|
|
4245
|
-
d5 += h4 * r1;
|
|
4246
|
-
c = (d5 >>> 13); d5 &= 0x1fff;
|
|
4247
|
-
d5 += h5 * r0;
|
|
4248
|
-
d5 += h6 * (5 * r9);
|
|
4249
|
-
d5 += h7 * (5 * r8);
|
|
4250
|
-
d5 += h8 * (5 * r7);
|
|
4251
|
-
d5 += h9 * (5 * r6);
|
|
4252
|
-
c += (d5 >>> 13); d5 &= 0x1fff;
|
|
4253
|
-
|
|
4254
|
-
d6 = c;
|
|
4255
|
-
d6 += h0 * r6;
|
|
4256
|
-
d6 += h1 * r5;
|
|
4257
|
-
d6 += h2 * r4;
|
|
4258
|
-
d6 += h3 * r3;
|
|
4259
|
-
d6 += h4 * r2;
|
|
4260
|
-
c = (d6 >>> 13); d6 &= 0x1fff;
|
|
4261
|
-
d6 += h5 * r1;
|
|
4262
|
-
d6 += h6 * r0;
|
|
4263
|
-
d6 += h7 * (5 * r9);
|
|
4264
|
-
d6 += h8 * (5 * r8);
|
|
4265
|
-
d6 += h9 * (5 * r7);
|
|
4266
|
-
c += (d6 >>> 13); d6 &= 0x1fff;
|
|
4267
|
-
|
|
4268
|
-
d7 = c;
|
|
4269
|
-
d7 += h0 * r7;
|
|
4270
|
-
d7 += h1 * r6;
|
|
4271
|
-
d7 += h2 * r5;
|
|
4272
|
-
d7 += h3 * r4;
|
|
4273
|
-
d7 += h4 * r3;
|
|
4274
|
-
c = (d7 >>> 13); d7 &= 0x1fff;
|
|
4275
|
-
d7 += h5 * r2;
|
|
4276
|
-
d7 += h6 * r1;
|
|
4277
|
-
d7 += h7 * r0;
|
|
4278
|
-
d7 += h8 * (5 * r9);
|
|
4279
|
-
d7 += h9 * (5 * r8);
|
|
4280
|
-
c += (d7 >>> 13); d7 &= 0x1fff;
|
|
4281
|
-
|
|
4282
|
-
d8 = c;
|
|
4283
|
-
d8 += h0 * r8;
|
|
4284
|
-
d8 += h1 * r7;
|
|
4285
|
-
d8 += h2 * r6;
|
|
4286
|
-
d8 += h3 * r5;
|
|
4287
|
-
d8 += h4 * r4;
|
|
4288
|
-
c = (d8 >>> 13); d8 &= 0x1fff;
|
|
4289
|
-
d8 += h5 * r3;
|
|
4290
|
-
d8 += h6 * r2;
|
|
4291
|
-
d8 += h7 * r1;
|
|
4292
|
-
d8 += h8 * r0;
|
|
4293
|
-
d8 += h9 * (5 * r9);
|
|
4294
|
-
c += (d8 >>> 13); d8 &= 0x1fff;
|
|
4295
|
-
|
|
4296
|
-
d9 = c;
|
|
4297
|
-
d9 += h0 * r9;
|
|
4298
|
-
d9 += h1 * r8;
|
|
4299
|
-
d9 += h2 * r7;
|
|
4300
|
-
d9 += h3 * r6;
|
|
4301
|
-
d9 += h4 * r5;
|
|
4302
|
-
c = (d9 >>> 13); d9 &= 0x1fff;
|
|
4303
|
-
d9 += h5 * r4;
|
|
4304
|
-
d9 += h6 * r3;
|
|
4305
|
-
d9 += h7 * r2;
|
|
4306
|
-
d9 += h8 * r1;
|
|
4307
|
-
d9 += h9 * r0;
|
|
4308
|
-
c += (d9 >>> 13); d9 &= 0x1fff;
|
|
4309
|
-
|
|
4310
|
-
c = (((c << 2) + c)) | 0;
|
|
4311
|
-
c = (c + d0) | 0;
|
|
4312
|
-
d0 = c & 0x1fff;
|
|
4313
|
-
c = (c >>> 13);
|
|
4314
|
-
d1 += c;
|
|
4315
|
-
|
|
4316
|
-
h0 = d0;
|
|
4317
|
-
h1 = d1;
|
|
4318
|
-
h2 = d2;
|
|
4319
|
-
h3 = d3;
|
|
4320
|
-
h4 = d4;
|
|
4321
|
-
h5 = d5;
|
|
4322
|
-
h6 = d6;
|
|
4323
|
-
h7 = d7;
|
|
4324
|
-
h8 = d8;
|
|
4325
|
-
h9 = d9;
|
|
4326
|
-
|
|
4327
|
-
mpos += 16;
|
|
4328
|
-
bytes -= 16;
|
|
4329
|
-
}
|
|
4330
|
-
this.h[0] = h0;
|
|
4331
|
-
this.h[1] = h1;
|
|
4332
|
-
this.h[2] = h2;
|
|
4333
|
-
this.h[3] = h3;
|
|
4334
|
-
this.h[4] = h4;
|
|
4335
|
-
this.h[5] = h5;
|
|
4336
|
-
this.h[6] = h6;
|
|
4337
|
-
this.h[7] = h7;
|
|
4338
|
-
this.h[8] = h8;
|
|
4339
|
-
this.h[9] = h9;
|
|
4340
|
-
};
|
|
4341
|
-
|
|
4342
|
-
poly1305.prototype.finish = function(mac, macpos) {
|
|
4343
|
-
var g = new Uint16Array(10);
|
|
4344
|
-
var c, mask, f, i;
|
|
4345
|
-
|
|
4346
|
-
if (this.leftover) {
|
|
4347
|
-
i = this.leftover;
|
|
4348
|
-
this.buffer[i++] = 1;
|
|
4349
|
-
for (; i < 16; i++) this.buffer[i] = 0;
|
|
4350
|
-
this.fin = 1;
|
|
4351
|
-
this.blocks(this.buffer, 0, 16);
|
|
4352
|
-
}
|
|
4353
|
-
|
|
4354
|
-
c = this.h[1] >>> 13;
|
|
4355
|
-
this.h[1] &= 0x1fff;
|
|
4356
|
-
for (i = 2; i < 10; i++) {
|
|
4357
|
-
this.h[i] += c;
|
|
4358
|
-
c = this.h[i] >>> 13;
|
|
4359
|
-
this.h[i] &= 0x1fff;
|
|
4360
|
-
}
|
|
4361
|
-
this.h[0] += (c * 5);
|
|
4362
|
-
c = this.h[0] >>> 13;
|
|
4363
|
-
this.h[0] &= 0x1fff;
|
|
4364
|
-
this.h[1] += c;
|
|
4365
|
-
c = this.h[1] >>> 13;
|
|
4366
|
-
this.h[1] &= 0x1fff;
|
|
4367
|
-
this.h[2] += c;
|
|
4368
|
-
|
|
4369
|
-
g[0] = this.h[0] + 5;
|
|
4370
|
-
c = g[0] >>> 13;
|
|
4371
|
-
g[0] &= 0x1fff;
|
|
4372
|
-
for (i = 1; i < 10; i++) {
|
|
4373
|
-
g[i] = this.h[i] + c;
|
|
4374
|
-
c = g[i] >>> 13;
|
|
4375
|
-
g[i] &= 0x1fff;
|
|
4376
|
-
}
|
|
4377
|
-
g[9] -= (1 << 13);
|
|
4378
|
-
|
|
4379
|
-
mask = (c ^ 1) - 1;
|
|
4380
|
-
for (i = 0; i < 10; i++) g[i] &= mask;
|
|
4381
|
-
mask = ~mask;
|
|
4382
|
-
for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];
|
|
4383
|
-
|
|
4384
|
-
this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;
|
|
4385
|
-
this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;
|
|
4386
|
-
this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;
|
|
4387
|
-
this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;
|
|
4388
|
-
this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;
|
|
4389
|
-
this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;
|
|
4390
|
-
this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;
|
|
4391
|
-
this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;
|
|
4392
|
-
|
|
4393
|
-
f = this.h[0] + this.pad[0];
|
|
4394
|
-
this.h[0] = f & 0xffff;
|
|
4395
|
-
for (i = 1; i < 8; i++) {
|
|
4396
|
-
f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;
|
|
4397
|
-
this.h[i] = f & 0xffff;
|
|
4398
|
-
}
|
|
4399
|
-
|
|
4400
|
-
mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;
|
|
4401
|
-
mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;
|
|
4402
|
-
mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;
|
|
4403
|
-
mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;
|
|
4404
|
-
mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;
|
|
4405
|
-
mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;
|
|
4406
|
-
mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;
|
|
4407
|
-
mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;
|
|
4408
|
-
mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;
|
|
4409
|
-
mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;
|
|
4410
|
-
mac[macpos+10] = (this.h[5] >>> 0) & 0xff;
|
|
4411
|
-
mac[macpos+11] = (this.h[5] >>> 8) & 0xff;
|
|
4412
|
-
mac[macpos+12] = (this.h[6] >>> 0) & 0xff;
|
|
4413
|
-
mac[macpos+13] = (this.h[6] >>> 8) & 0xff;
|
|
4414
|
-
mac[macpos+14] = (this.h[7] >>> 0) & 0xff;
|
|
4415
|
-
mac[macpos+15] = (this.h[7] >>> 8) & 0xff;
|
|
4416
|
-
};
|
|
4417
|
-
|
|
4418
|
-
poly1305.prototype.update = function(m, mpos, bytes) {
|
|
4419
|
-
var i, want;
|
|
4420
|
-
|
|
4421
|
-
if (this.leftover) {
|
|
4422
|
-
want = (16 - this.leftover);
|
|
4423
|
-
if (want > bytes)
|
|
4424
|
-
want = bytes;
|
|
4425
|
-
for (i = 0; i < want; i++)
|
|
4426
|
-
this.buffer[this.leftover + i] = m[mpos+i];
|
|
4427
|
-
bytes -= want;
|
|
4428
|
-
mpos += want;
|
|
4429
|
-
this.leftover += want;
|
|
4430
|
-
if (this.leftover < 16)
|
|
4431
|
-
return;
|
|
4432
|
-
this.blocks(this.buffer, 0, 16);
|
|
4433
|
-
this.leftover = 0;
|
|
4434
|
-
}
|
|
4435
|
-
|
|
4436
|
-
if (bytes >= 16) {
|
|
4437
|
-
want = bytes - (bytes % 16);
|
|
4438
|
-
this.blocks(m, mpos, want);
|
|
4439
|
-
mpos += want;
|
|
4440
|
-
bytes -= want;
|
|
4441
|
-
}
|
|
4442
|
-
|
|
4443
|
-
if (bytes) {
|
|
4444
|
-
for (i = 0; i < bytes; i++)
|
|
4445
|
-
this.buffer[this.leftover + i] = m[mpos+i];
|
|
4446
|
-
this.leftover += bytes;
|
|
4447
|
-
}
|
|
4448
|
-
};
|
|
4449
|
-
|
|
4450
|
-
function crypto_onetimeauth(out, outpos, m, mpos, n, k) {
|
|
4451
|
-
var s = new poly1305(k);
|
|
4452
|
-
s.update(m, mpos, n);
|
|
4453
|
-
s.finish(out, outpos);
|
|
4454
|
-
return 0;
|
|
4455
|
-
}
|
|
4456
|
-
|
|
4457
|
-
function crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {
|
|
4458
|
-
var x = new Uint8Array(16);
|
|
4459
|
-
crypto_onetimeauth(x,0,m,mpos,n,k);
|
|
4460
|
-
return crypto_verify_16(h,hpos,x,0);
|
|
4461
|
-
}
|
|
4462
|
-
|
|
4463
|
-
function crypto_secretbox(c,m,d,n,k) {
|
|
4464
|
-
var i;
|
|
4465
|
-
if (d < 32) return -1;
|
|
4466
|
-
crypto_stream_xor(c,0,m,0,d,n,k);
|
|
4467
|
-
crypto_onetimeauth(c, 16, c, 32, d - 32, c);
|
|
4468
|
-
for (i = 0; i < 16; i++) c[i] = 0;
|
|
4469
|
-
return 0;
|
|
4470
|
-
}
|
|
4471
|
-
|
|
4472
|
-
function crypto_secretbox_open(m,c,d,n,k) {
|
|
4473
|
-
var i;
|
|
4474
|
-
var x = new Uint8Array(32);
|
|
4475
|
-
if (d < 32) return -1;
|
|
4476
|
-
crypto_stream(x,0,32,n,k);
|
|
4477
|
-
if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;
|
|
4478
|
-
crypto_stream_xor(m,0,c,0,d,n,k);
|
|
4479
|
-
for (i = 0; i < 32; i++) m[i] = 0;
|
|
4480
|
-
return 0;
|
|
4481
|
-
}
|
|
4482
|
-
|
|
4483
|
-
function set25519(r, a) {
|
|
4484
|
-
var i;
|
|
4485
|
-
for (i = 0; i < 16; i++) r[i] = a[i]|0;
|
|
4486
|
-
}
|
|
4487
|
-
|
|
4488
|
-
function car25519(o) {
|
|
4489
|
-
var i, v, c = 1;
|
|
4490
|
-
for (i = 0; i < 16; i++) {
|
|
4491
|
-
v = o[i] + c + 65535;
|
|
4492
|
-
c = Math.floor(v / 65536);
|
|
4493
|
-
o[i] = v - c * 65536;
|
|
4494
|
-
}
|
|
4495
|
-
o[0] += c-1 + 37 * (c-1);
|
|
4496
|
-
}
|
|
4497
|
-
|
|
4498
|
-
function sel25519(p, q, b) {
|
|
4499
|
-
var t, c = ~(b-1);
|
|
4500
|
-
for (var i = 0; i < 16; i++) {
|
|
4501
|
-
t = c & (p[i] ^ q[i]);
|
|
4502
|
-
p[i] ^= t;
|
|
4503
|
-
q[i] ^= t;
|
|
4504
|
-
}
|
|
4505
|
-
}
|
|
4506
|
-
|
|
4507
|
-
function pack25519(o, n) {
|
|
4508
|
-
var i, j, b;
|
|
4509
|
-
var m = gf(), t = gf();
|
|
4510
|
-
for (i = 0; i < 16; i++) t[i] = n[i];
|
|
4511
|
-
car25519(t);
|
|
4512
|
-
car25519(t);
|
|
4513
|
-
car25519(t);
|
|
4514
|
-
for (j = 0; j < 2; j++) {
|
|
4515
|
-
m[0] = t[0] - 0xffed;
|
|
4516
|
-
for (i = 1; i < 15; i++) {
|
|
4517
|
-
m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);
|
|
4518
|
-
m[i-1] &= 0xffff;
|
|
4519
|
-
}
|
|
4520
|
-
m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);
|
|
4521
|
-
b = (m[15]>>16) & 1;
|
|
4522
|
-
m[14] &= 0xffff;
|
|
4523
|
-
sel25519(t, m, 1-b);
|
|
4524
|
-
}
|
|
4525
|
-
for (i = 0; i < 16; i++) {
|
|
4526
|
-
o[2*i] = t[i] & 0xff;
|
|
4527
|
-
o[2*i+1] = t[i]>>8;
|
|
4528
|
-
}
|
|
4529
|
-
}
|
|
4530
|
-
|
|
4531
|
-
function neq25519(a, b) {
|
|
4532
|
-
var c = new Uint8Array(32), d = new Uint8Array(32);
|
|
4533
|
-
pack25519(c, a);
|
|
4534
|
-
pack25519(d, b);
|
|
4535
|
-
return crypto_verify_32(c, 0, d, 0);
|
|
4536
|
-
}
|
|
4537
|
-
|
|
4538
|
-
function par25519(a) {
|
|
4539
|
-
var d = new Uint8Array(32);
|
|
4540
|
-
pack25519(d, a);
|
|
4541
|
-
return d[0] & 1;
|
|
4542
|
-
}
|
|
4543
|
-
|
|
4544
|
-
function unpack25519(o, n) {
|
|
4545
|
-
var i;
|
|
4546
|
-
for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);
|
|
4547
|
-
o[15] &= 0x7fff;
|
|
4548
|
-
}
|
|
4549
|
-
|
|
4550
|
-
function A(o, a, b) {
|
|
4551
|
-
for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];
|
|
4552
|
-
}
|
|
4553
|
-
|
|
4554
|
-
function Z(o, a, b) {
|
|
4555
|
-
for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];
|
|
4556
|
-
}
|
|
4557
|
-
|
|
4558
|
-
function M(o, a, b) {
|
|
4559
|
-
var v, c,
|
|
4560
|
-
t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,
|
|
4561
|
-
t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,
|
|
4562
|
-
t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,
|
|
4563
|
-
t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,
|
|
4564
|
-
b0 = b[0],
|
|
4565
|
-
b1 = b[1],
|
|
4566
|
-
b2 = b[2],
|
|
4567
|
-
b3 = b[3],
|
|
4568
|
-
b4 = b[4],
|
|
4569
|
-
b5 = b[5],
|
|
4570
|
-
b6 = b[6],
|
|
4571
|
-
b7 = b[7],
|
|
4572
|
-
b8 = b[8],
|
|
4573
|
-
b9 = b[9],
|
|
4574
|
-
b10 = b[10],
|
|
4575
|
-
b11 = b[11],
|
|
4576
|
-
b12 = b[12],
|
|
4577
|
-
b13 = b[13],
|
|
4578
|
-
b14 = b[14],
|
|
4579
|
-
b15 = b[15];
|
|
4580
|
-
|
|
4581
|
-
v = a[0];
|
|
4582
|
-
t0 += v * b0;
|
|
4583
|
-
t1 += v * b1;
|
|
4584
|
-
t2 += v * b2;
|
|
4585
|
-
t3 += v * b3;
|
|
4586
|
-
t4 += v * b4;
|
|
4587
|
-
t5 += v * b5;
|
|
4588
|
-
t6 += v * b6;
|
|
4589
|
-
t7 += v * b7;
|
|
4590
|
-
t8 += v * b8;
|
|
4591
|
-
t9 += v * b9;
|
|
4592
|
-
t10 += v * b10;
|
|
4593
|
-
t11 += v * b11;
|
|
4594
|
-
t12 += v * b12;
|
|
4595
|
-
t13 += v * b13;
|
|
4596
|
-
t14 += v * b14;
|
|
4597
|
-
t15 += v * b15;
|
|
4598
|
-
v = a[1];
|
|
4599
|
-
t1 += v * b0;
|
|
4600
|
-
t2 += v * b1;
|
|
4601
|
-
t3 += v * b2;
|
|
4602
|
-
t4 += v * b3;
|
|
4603
|
-
t5 += v * b4;
|
|
4604
|
-
t6 += v * b5;
|
|
4605
|
-
t7 += v * b6;
|
|
4606
|
-
t8 += v * b7;
|
|
4607
|
-
t9 += v * b8;
|
|
4608
|
-
t10 += v * b9;
|
|
4609
|
-
t11 += v * b10;
|
|
4610
|
-
t12 += v * b11;
|
|
4611
|
-
t13 += v * b12;
|
|
4612
|
-
t14 += v * b13;
|
|
4613
|
-
t15 += v * b14;
|
|
4614
|
-
t16 += v * b15;
|
|
4615
|
-
v = a[2];
|
|
4616
|
-
t2 += v * b0;
|
|
4617
|
-
t3 += v * b1;
|
|
4618
|
-
t4 += v * b2;
|
|
4619
|
-
t5 += v * b3;
|
|
4620
|
-
t6 += v * b4;
|
|
4621
|
-
t7 += v * b5;
|
|
4622
|
-
t8 += v * b6;
|
|
4623
|
-
t9 += v * b7;
|
|
4624
|
-
t10 += v * b8;
|
|
4625
|
-
t11 += v * b9;
|
|
4626
|
-
t12 += v * b10;
|
|
4627
|
-
t13 += v * b11;
|
|
4628
|
-
t14 += v * b12;
|
|
4629
|
-
t15 += v * b13;
|
|
4630
|
-
t16 += v * b14;
|
|
4631
|
-
t17 += v * b15;
|
|
4632
|
-
v = a[3];
|
|
4633
|
-
t3 += v * b0;
|
|
4634
|
-
t4 += v * b1;
|
|
4635
|
-
t5 += v * b2;
|
|
4636
|
-
t6 += v * b3;
|
|
4637
|
-
t7 += v * b4;
|
|
4638
|
-
t8 += v * b5;
|
|
4639
|
-
t9 += v * b6;
|
|
4640
|
-
t10 += v * b7;
|
|
4641
|
-
t11 += v * b8;
|
|
4642
|
-
t12 += v * b9;
|
|
4643
|
-
t13 += v * b10;
|
|
4644
|
-
t14 += v * b11;
|
|
4645
|
-
t15 += v * b12;
|
|
4646
|
-
t16 += v * b13;
|
|
4647
|
-
t17 += v * b14;
|
|
4648
|
-
t18 += v * b15;
|
|
4649
|
-
v = a[4];
|
|
4650
|
-
t4 += v * b0;
|
|
4651
|
-
t5 += v * b1;
|
|
4652
|
-
t6 += v * b2;
|
|
4653
|
-
t7 += v * b3;
|
|
4654
|
-
t8 += v * b4;
|
|
4655
|
-
t9 += v * b5;
|
|
4656
|
-
t10 += v * b6;
|
|
4657
|
-
t11 += v * b7;
|
|
4658
|
-
t12 += v * b8;
|
|
4659
|
-
t13 += v * b9;
|
|
4660
|
-
t14 += v * b10;
|
|
4661
|
-
t15 += v * b11;
|
|
4662
|
-
t16 += v * b12;
|
|
4663
|
-
t17 += v * b13;
|
|
4664
|
-
t18 += v * b14;
|
|
4665
|
-
t19 += v * b15;
|
|
4666
|
-
v = a[5];
|
|
4667
|
-
t5 += v * b0;
|
|
4668
|
-
t6 += v * b1;
|
|
4669
|
-
t7 += v * b2;
|
|
4670
|
-
t8 += v * b3;
|
|
4671
|
-
t9 += v * b4;
|
|
4672
|
-
t10 += v * b5;
|
|
4673
|
-
t11 += v * b6;
|
|
4674
|
-
t12 += v * b7;
|
|
4675
|
-
t13 += v * b8;
|
|
4676
|
-
t14 += v * b9;
|
|
4677
|
-
t15 += v * b10;
|
|
4678
|
-
t16 += v * b11;
|
|
4679
|
-
t17 += v * b12;
|
|
4680
|
-
t18 += v * b13;
|
|
4681
|
-
t19 += v * b14;
|
|
4682
|
-
t20 += v * b15;
|
|
4683
|
-
v = a[6];
|
|
4684
|
-
t6 += v * b0;
|
|
4685
|
-
t7 += v * b1;
|
|
4686
|
-
t8 += v * b2;
|
|
4687
|
-
t9 += v * b3;
|
|
4688
|
-
t10 += v * b4;
|
|
4689
|
-
t11 += v * b5;
|
|
4690
|
-
t12 += v * b6;
|
|
4691
|
-
t13 += v * b7;
|
|
4692
|
-
t14 += v * b8;
|
|
4693
|
-
t15 += v * b9;
|
|
4694
|
-
t16 += v * b10;
|
|
4695
|
-
t17 += v * b11;
|
|
4696
|
-
t18 += v * b12;
|
|
4697
|
-
t19 += v * b13;
|
|
4698
|
-
t20 += v * b14;
|
|
4699
|
-
t21 += v * b15;
|
|
4700
|
-
v = a[7];
|
|
4701
|
-
t7 += v * b0;
|
|
4702
|
-
t8 += v * b1;
|
|
4703
|
-
t9 += v * b2;
|
|
4704
|
-
t10 += v * b3;
|
|
4705
|
-
t11 += v * b4;
|
|
4706
|
-
t12 += v * b5;
|
|
4707
|
-
t13 += v * b6;
|
|
4708
|
-
t14 += v * b7;
|
|
4709
|
-
t15 += v * b8;
|
|
4710
|
-
t16 += v * b9;
|
|
4711
|
-
t17 += v * b10;
|
|
4712
|
-
t18 += v * b11;
|
|
4713
|
-
t19 += v * b12;
|
|
4714
|
-
t20 += v * b13;
|
|
4715
|
-
t21 += v * b14;
|
|
4716
|
-
t22 += v * b15;
|
|
4717
|
-
v = a[8];
|
|
4718
|
-
t8 += v * b0;
|
|
4719
|
-
t9 += v * b1;
|
|
4720
|
-
t10 += v * b2;
|
|
4721
|
-
t11 += v * b3;
|
|
4722
|
-
t12 += v * b4;
|
|
4723
|
-
t13 += v * b5;
|
|
4724
|
-
t14 += v * b6;
|
|
4725
|
-
t15 += v * b7;
|
|
4726
|
-
t16 += v * b8;
|
|
4727
|
-
t17 += v * b9;
|
|
4728
|
-
t18 += v * b10;
|
|
4729
|
-
t19 += v * b11;
|
|
4730
|
-
t20 += v * b12;
|
|
4731
|
-
t21 += v * b13;
|
|
4732
|
-
t22 += v * b14;
|
|
4733
|
-
t23 += v * b15;
|
|
4734
|
-
v = a[9];
|
|
4735
|
-
t9 += v * b0;
|
|
4736
|
-
t10 += v * b1;
|
|
4737
|
-
t11 += v * b2;
|
|
4738
|
-
t12 += v * b3;
|
|
4739
|
-
t13 += v * b4;
|
|
4740
|
-
t14 += v * b5;
|
|
4741
|
-
t15 += v * b6;
|
|
4742
|
-
t16 += v * b7;
|
|
4743
|
-
t17 += v * b8;
|
|
4744
|
-
t18 += v * b9;
|
|
4745
|
-
t19 += v * b10;
|
|
4746
|
-
t20 += v * b11;
|
|
4747
|
-
t21 += v * b12;
|
|
4748
|
-
t22 += v * b13;
|
|
4749
|
-
t23 += v * b14;
|
|
4750
|
-
t24 += v * b15;
|
|
4751
|
-
v = a[10];
|
|
4752
|
-
t10 += v * b0;
|
|
4753
|
-
t11 += v * b1;
|
|
4754
|
-
t12 += v * b2;
|
|
4755
|
-
t13 += v * b3;
|
|
4756
|
-
t14 += v * b4;
|
|
4757
|
-
t15 += v * b5;
|
|
4758
|
-
t16 += v * b6;
|
|
4759
|
-
t17 += v * b7;
|
|
4760
|
-
t18 += v * b8;
|
|
4761
|
-
t19 += v * b9;
|
|
4762
|
-
t20 += v * b10;
|
|
4763
|
-
t21 += v * b11;
|
|
4764
|
-
t22 += v * b12;
|
|
4765
|
-
t23 += v * b13;
|
|
4766
|
-
t24 += v * b14;
|
|
4767
|
-
t25 += v * b15;
|
|
4768
|
-
v = a[11];
|
|
4769
|
-
t11 += v * b0;
|
|
4770
|
-
t12 += v * b1;
|
|
4771
|
-
t13 += v * b2;
|
|
4772
|
-
t14 += v * b3;
|
|
4773
|
-
t15 += v * b4;
|
|
4774
|
-
t16 += v * b5;
|
|
4775
|
-
t17 += v * b6;
|
|
4776
|
-
t18 += v * b7;
|
|
4777
|
-
t19 += v * b8;
|
|
4778
|
-
t20 += v * b9;
|
|
4779
|
-
t21 += v * b10;
|
|
4780
|
-
t22 += v * b11;
|
|
4781
|
-
t23 += v * b12;
|
|
4782
|
-
t24 += v * b13;
|
|
4783
|
-
t25 += v * b14;
|
|
4784
|
-
t26 += v * b15;
|
|
4785
|
-
v = a[12];
|
|
4786
|
-
t12 += v * b0;
|
|
4787
|
-
t13 += v * b1;
|
|
4788
|
-
t14 += v * b2;
|
|
4789
|
-
t15 += v * b3;
|
|
4790
|
-
t16 += v * b4;
|
|
4791
|
-
t17 += v * b5;
|
|
4792
|
-
t18 += v * b6;
|
|
4793
|
-
t19 += v * b7;
|
|
4794
|
-
t20 += v * b8;
|
|
4795
|
-
t21 += v * b9;
|
|
4796
|
-
t22 += v * b10;
|
|
4797
|
-
t23 += v * b11;
|
|
4798
|
-
t24 += v * b12;
|
|
4799
|
-
t25 += v * b13;
|
|
4800
|
-
t26 += v * b14;
|
|
4801
|
-
t27 += v * b15;
|
|
4802
|
-
v = a[13];
|
|
4803
|
-
t13 += v * b0;
|
|
4804
|
-
t14 += v * b1;
|
|
4805
|
-
t15 += v * b2;
|
|
4806
|
-
t16 += v * b3;
|
|
4807
|
-
t17 += v * b4;
|
|
4808
|
-
t18 += v * b5;
|
|
4809
|
-
t19 += v * b6;
|
|
4810
|
-
t20 += v * b7;
|
|
4811
|
-
t21 += v * b8;
|
|
4812
|
-
t22 += v * b9;
|
|
4813
|
-
t23 += v * b10;
|
|
4814
|
-
t24 += v * b11;
|
|
4815
|
-
t25 += v * b12;
|
|
4816
|
-
t26 += v * b13;
|
|
4817
|
-
t27 += v * b14;
|
|
4818
|
-
t28 += v * b15;
|
|
4819
|
-
v = a[14];
|
|
4820
|
-
t14 += v * b0;
|
|
4821
|
-
t15 += v * b1;
|
|
4822
|
-
t16 += v * b2;
|
|
4823
|
-
t17 += v * b3;
|
|
4824
|
-
t18 += v * b4;
|
|
4825
|
-
t19 += v * b5;
|
|
4826
|
-
t20 += v * b6;
|
|
4827
|
-
t21 += v * b7;
|
|
4828
|
-
t22 += v * b8;
|
|
4829
|
-
t23 += v * b9;
|
|
4830
|
-
t24 += v * b10;
|
|
4831
|
-
t25 += v * b11;
|
|
4832
|
-
t26 += v * b12;
|
|
4833
|
-
t27 += v * b13;
|
|
4834
|
-
t28 += v * b14;
|
|
4835
|
-
t29 += v * b15;
|
|
4836
|
-
v = a[15];
|
|
4837
|
-
t15 += v * b0;
|
|
4838
|
-
t16 += v * b1;
|
|
4839
|
-
t17 += v * b2;
|
|
4840
|
-
t18 += v * b3;
|
|
4841
|
-
t19 += v * b4;
|
|
4842
|
-
t20 += v * b5;
|
|
4843
|
-
t21 += v * b6;
|
|
4844
|
-
t22 += v * b7;
|
|
4845
|
-
t23 += v * b8;
|
|
4846
|
-
t24 += v * b9;
|
|
4847
|
-
t25 += v * b10;
|
|
4848
|
-
t26 += v * b11;
|
|
4849
|
-
t27 += v * b12;
|
|
4850
|
-
t28 += v * b13;
|
|
4851
|
-
t29 += v * b14;
|
|
4852
|
-
t30 += v * b15;
|
|
4853
|
-
|
|
4854
|
-
t0 += 38 * t16;
|
|
4855
|
-
t1 += 38 * t17;
|
|
4856
|
-
t2 += 38 * t18;
|
|
4857
|
-
t3 += 38 * t19;
|
|
4858
|
-
t4 += 38 * t20;
|
|
4859
|
-
t5 += 38 * t21;
|
|
4860
|
-
t6 += 38 * t22;
|
|
4861
|
-
t7 += 38 * t23;
|
|
4862
|
-
t8 += 38 * t24;
|
|
4863
|
-
t9 += 38 * t25;
|
|
4864
|
-
t10 += 38 * t26;
|
|
4865
|
-
t11 += 38 * t27;
|
|
4866
|
-
t12 += 38 * t28;
|
|
4867
|
-
t13 += 38 * t29;
|
|
4868
|
-
t14 += 38 * t30;
|
|
4869
|
-
// t15 left as is
|
|
4870
|
-
|
|
4871
|
-
// first car
|
|
4872
|
-
c = 1;
|
|
4873
|
-
v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;
|
|
4874
|
-
v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;
|
|
4875
|
-
v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;
|
|
4876
|
-
v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;
|
|
4877
|
-
v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;
|
|
4878
|
-
v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;
|
|
4879
|
-
v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;
|
|
4880
|
-
v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;
|
|
4881
|
-
v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;
|
|
4882
|
-
v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;
|
|
4883
|
-
v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;
|
|
4884
|
-
v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;
|
|
4885
|
-
v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;
|
|
4886
|
-
v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;
|
|
4887
|
-
v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;
|
|
4888
|
-
v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;
|
|
4889
|
-
t0 += c-1 + 37 * (c-1);
|
|
4890
|
-
|
|
4891
|
-
// second car
|
|
4892
|
-
c = 1;
|
|
4893
|
-
v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;
|
|
4894
|
-
v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;
|
|
4895
|
-
v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;
|
|
4896
|
-
v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;
|
|
4897
|
-
v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;
|
|
4898
|
-
v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;
|
|
4899
|
-
v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;
|
|
4900
|
-
v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;
|
|
4901
|
-
v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;
|
|
4902
|
-
v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;
|
|
4903
|
-
v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;
|
|
4904
|
-
v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;
|
|
4905
|
-
v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;
|
|
4906
|
-
v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;
|
|
4907
|
-
v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;
|
|
4908
|
-
v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;
|
|
4909
|
-
t0 += c-1 + 37 * (c-1);
|
|
4910
|
-
|
|
4911
|
-
o[ 0] = t0;
|
|
4912
|
-
o[ 1] = t1;
|
|
4913
|
-
o[ 2] = t2;
|
|
4914
|
-
o[ 3] = t3;
|
|
4915
|
-
o[ 4] = t4;
|
|
4916
|
-
o[ 5] = t5;
|
|
4917
|
-
o[ 6] = t6;
|
|
4918
|
-
o[ 7] = t7;
|
|
4919
|
-
o[ 8] = t8;
|
|
4920
|
-
o[ 9] = t9;
|
|
4921
|
-
o[10] = t10;
|
|
4922
|
-
o[11] = t11;
|
|
4923
|
-
o[12] = t12;
|
|
4924
|
-
o[13] = t13;
|
|
4925
|
-
o[14] = t14;
|
|
4926
|
-
o[15] = t15;
|
|
4927
|
-
}
|
|
4928
|
-
|
|
4929
|
-
function S(o, a) {
|
|
4930
|
-
M(o, a, a);
|
|
4931
|
-
}
|
|
4932
|
-
|
|
4933
|
-
function inv25519(o, i) {
|
|
4934
|
-
var c = gf();
|
|
4935
|
-
var a;
|
|
4936
|
-
for (a = 0; a < 16; a++) c[a] = i[a];
|
|
4937
|
-
for (a = 253; a >= 0; a--) {
|
|
4938
|
-
S(c, c);
|
|
4939
|
-
if(a !== 2 && a !== 4) M(c, c, i);
|
|
4940
|
-
}
|
|
4941
|
-
for (a = 0; a < 16; a++) o[a] = c[a];
|
|
4942
|
-
}
|
|
4943
|
-
|
|
4944
|
-
function pow2523(o, i) {
|
|
4945
|
-
var c = gf();
|
|
4946
|
-
var a;
|
|
4947
|
-
for (a = 0; a < 16; a++) c[a] = i[a];
|
|
4948
|
-
for (a = 250; a >= 0; a--) {
|
|
4949
|
-
S(c, c);
|
|
4950
|
-
if(a !== 1) M(c, c, i);
|
|
4951
|
-
}
|
|
4952
|
-
for (a = 0; a < 16; a++) o[a] = c[a];
|
|
4953
|
-
}
|
|
4954
|
-
|
|
4955
|
-
function crypto_scalarmult(q, n, p) {
|
|
4956
|
-
var z = new Uint8Array(32);
|
|
4957
|
-
var x = new Float64Array(80), r, i;
|
|
4958
|
-
var a = gf(), b = gf(), c = gf(),
|
|
4959
|
-
d = gf(), e = gf(), f = gf();
|
|
4960
|
-
for (i = 0; i < 31; i++) z[i] = n[i];
|
|
4961
|
-
z[31]=(n[31]&127)|64;
|
|
4962
|
-
z[0]&=248;
|
|
4963
|
-
unpack25519(x,p);
|
|
4964
|
-
for (i = 0; i < 16; i++) {
|
|
4965
|
-
b[i]=x[i];
|
|
4966
|
-
d[i]=a[i]=c[i]=0;
|
|
4967
|
-
}
|
|
4968
|
-
a[0]=d[0]=1;
|
|
4969
|
-
for (i=254; i>=0; --i) {
|
|
4970
|
-
r=(z[i>>>3]>>>(i&7))&1;
|
|
4971
|
-
sel25519(a,b,r);
|
|
4972
|
-
sel25519(c,d,r);
|
|
4973
|
-
A(e,a,c);
|
|
4974
|
-
Z(a,a,c);
|
|
4975
|
-
A(c,b,d);
|
|
4976
|
-
Z(b,b,d);
|
|
4977
|
-
S(d,e);
|
|
4978
|
-
S(f,a);
|
|
4979
|
-
M(a,c,a);
|
|
4980
|
-
M(c,b,e);
|
|
4981
|
-
A(e,a,c);
|
|
4982
|
-
Z(a,a,c);
|
|
4983
|
-
S(b,a);
|
|
4984
|
-
Z(c,d,f);
|
|
4985
|
-
M(a,c,_121665);
|
|
4986
|
-
A(a,a,d);
|
|
4987
|
-
M(c,c,a);
|
|
4988
|
-
M(a,d,f);
|
|
4989
|
-
M(d,b,x);
|
|
4990
|
-
S(b,e);
|
|
4991
|
-
sel25519(a,b,r);
|
|
4992
|
-
sel25519(c,d,r);
|
|
4993
|
-
}
|
|
4994
|
-
for (i = 0; i < 16; i++) {
|
|
4995
|
-
x[i+16]=a[i];
|
|
4996
|
-
x[i+32]=c[i];
|
|
4997
|
-
x[i+48]=b[i];
|
|
4998
|
-
x[i+64]=d[i];
|
|
4999
|
-
}
|
|
5000
|
-
var x32 = x.subarray(32);
|
|
5001
|
-
var x16 = x.subarray(16);
|
|
5002
|
-
inv25519(x32,x32);
|
|
5003
|
-
M(x16,x16,x32);
|
|
5004
|
-
pack25519(q,x16);
|
|
5005
|
-
return 0;
|
|
5006
|
-
}
|
|
5007
|
-
|
|
5008
|
-
function crypto_scalarmult_base(q, n) {
|
|
5009
|
-
return crypto_scalarmult(q, n, _9);
|
|
5010
|
-
}
|
|
5011
|
-
|
|
5012
|
-
function crypto_box_keypair(y, x) {
|
|
5013
|
-
randombytes(x, 32);
|
|
5014
|
-
return crypto_scalarmult_base(y, x);
|
|
5015
|
-
}
|
|
5016
|
-
|
|
5017
|
-
function crypto_box_beforenm(k, y, x) {
|
|
5018
|
-
var s = new Uint8Array(32);
|
|
5019
|
-
crypto_scalarmult(s, x, y);
|
|
5020
|
-
return crypto_core_hsalsa20(k, _0, s, sigma);
|
|
5021
|
-
}
|
|
5022
|
-
|
|
5023
|
-
var crypto_box_afternm = crypto_secretbox;
|
|
5024
|
-
var crypto_box_open_afternm = crypto_secretbox_open;
|
|
5025
|
-
|
|
5026
|
-
function crypto_box(c, m, d, n, y, x) {
|
|
5027
|
-
var k = new Uint8Array(32);
|
|
5028
|
-
crypto_box_beforenm(k, y, x);
|
|
5029
|
-
return crypto_box_afternm(c, m, d, n, k);
|
|
5030
|
-
}
|
|
5031
|
-
|
|
5032
|
-
function crypto_box_open(m, c, d, n, y, x) {
|
|
5033
|
-
var k = new Uint8Array(32);
|
|
5034
|
-
crypto_box_beforenm(k, y, x);
|
|
5035
|
-
return crypto_box_open_afternm(m, c, d, n, k);
|
|
5036
|
-
}
|
|
5037
|
-
|
|
5038
|
-
var K = [
|
|
5039
|
-
0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
|
|
5040
|
-
0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
|
|
5041
|
-
0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
|
|
5042
|
-
0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
|
|
5043
|
-
0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
|
|
5044
|
-
0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
|
|
5045
|
-
0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
|
|
5046
|
-
0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
|
|
5047
|
-
0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
|
|
5048
|
-
0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
|
|
5049
|
-
0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
|
|
5050
|
-
0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
|
|
5051
|
-
0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
|
|
5052
|
-
0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
|
|
5053
|
-
0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
|
|
5054
|
-
0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
|
|
5055
|
-
0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
|
|
5056
|
-
0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
|
|
5057
|
-
0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
|
|
5058
|
-
0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
|
|
5059
|
-
0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
|
|
5060
|
-
0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
|
|
5061
|
-
0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
|
|
5062
|
-
0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
|
|
5063
|
-
0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
|
|
5064
|
-
0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
|
|
5065
|
-
0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
|
|
5066
|
-
0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
|
|
5067
|
-
0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
|
|
5068
|
-
0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
|
|
5069
|
-
0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
|
|
5070
|
-
0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
|
|
5071
|
-
0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
|
|
5072
|
-
0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
|
|
5073
|
-
0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
|
|
5074
|
-
0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
|
|
5075
|
-
0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
|
|
5076
|
-
0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
|
|
5077
|
-
0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
|
|
5078
|
-
0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
|
|
5079
|
-
];
|
|
5080
|
-
|
|
5081
|
-
function crypto_hashblocks_hl(hh, hl, m, n) {
|
|
5082
|
-
var wh = new Int32Array(16), wl = new Int32Array(16),
|
|
5083
|
-
bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,
|
|
5084
|
-
bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,
|
|
5085
|
-
th, tl, i, j, h, l, a, b, c, d;
|
|
5086
|
-
|
|
5087
|
-
var ah0 = hh[0],
|
|
5088
|
-
ah1 = hh[1],
|
|
5089
|
-
ah2 = hh[2],
|
|
5090
|
-
ah3 = hh[3],
|
|
5091
|
-
ah4 = hh[4],
|
|
5092
|
-
ah5 = hh[5],
|
|
5093
|
-
ah6 = hh[6],
|
|
5094
|
-
ah7 = hh[7],
|
|
5095
|
-
|
|
5096
|
-
al0 = hl[0],
|
|
5097
|
-
al1 = hl[1],
|
|
5098
|
-
al2 = hl[2],
|
|
5099
|
-
al3 = hl[3],
|
|
5100
|
-
al4 = hl[4],
|
|
5101
|
-
al5 = hl[5],
|
|
5102
|
-
al6 = hl[6],
|
|
5103
|
-
al7 = hl[7];
|
|
5104
|
-
|
|
5105
|
-
var pos = 0;
|
|
5106
|
-
while (n >= 128) {
|
|
5107
|
-
for (i = 0; i < 16; i++) {
|
|
5108
|
-
j = 8 * i + pos;
|
|
5109
|
-
wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];
|
|
5110
|
-
wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];
|
|
5111
|
-
}
|
|
5112
|
-
for (i = 0; i < 80; i++) {
|
|
5113
|
-
bh0 = ah0;
|
|
5114
|
-
bh1 = ah1;
|
|
5115
|
-
bh2 = ah2;
|
|
5116
|
-
bh3 = ah3;
|
|
5117
|
-
bh4 = ah4;
|
|
5118
|
-
bh5 = ah5;
|
|
5119
|
-
bh6 = ah6;
|
|
5120
|
-
bh7 = ah7;
|
|
5121
|
-
|
|
5122
|
-
bl0 = al0;
|
|
5123
|
-
bl1 = al1;
|
|
5124
|
-
bl2 = al2;
|
|
5125
|
-
bl3 = al3;
|
|
5126
|
-
bl4 = al4;
|
|
5127
|
-
bl5 = al5;
|
|
5128
|
-
bl6 = al6;
|
|
5129
|
-
bl7 = al7;
|
|
5130
|
-
|
|
5131
|
-
// add
|
|
5132
|
-
h = ah7;
|
|
5133
|
-
l = al7;
|
|
5134
|
-
|
|
5135
|
-
a = l & 0xffff; b = l >>> 16;
|
|
5136
|
-
c = h & 0xffff; d = h >>> 16;
|
|
5137
|
-
|
|
5138
|
-
// Sigma1
|
|
5139
|
-
h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));
|
|
5140
|
-
l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));
|
|
5141
|
-
|
|
5142
|
-
a += l & 0xffff; b += l >>> 16;
|
|
5143
|
-
c += h & 0xffff; d += h >>> 16;
|
|
5144
|
-
|
|
5145
|
-
// Ch
|
|
5146
|
-
h = (ah4 & ah5) ^ (~ah4 & ah6);
|
|
5147
|
-
l = (al4 & al5) ^ (~al4 & al6);
|
|
5148
|
-
|
|
5149
|
-
a += l & 0xffff; b += l >>> 16;
|
|
5150
|
-
c += h & 0xffff; d += h >>> 16;
|
|
5151
|
-
|
|
5152
|
-
// K
|
|
5153
|
-
h = K[i*2];
|
|
5154
|
-
l = K[i*2+1];
|
|
5155
|
-
|
|
5156
|
-
a += l & 0xffff; b += l >>> 16;
|
|
5157
|
-
c += h & 0xffff; d += h >>> 16;
|
|
5158
|
-
|
|
5159
|
-
// w
|
|
5160
|
-
h = wh[i%16];
|
|
5161
|
-
l = wl[i%16];
|
|
5162
|
-
|
|
5163
|
-
a += l & 0xffff; b += l >>> 16;
|
|
5164
|
-
c += h & 0xffff; d += h >>> 16;
|
|
5165
|
-
|
|
5166
|
-
b += a >>> 16;
|
|
5167
|
-
c += b >>> 16;
|
|
5168
|
-
d += c >>> 16;
|
|
5169
|
-
|
|
5170
|
-
th = c & 0xffff | d << 16;
|
|
5171
|
-
tl = a & 0xffff | b << 16;
|
|
5172
|
-
|
|
5173
|
-
// add
|
|
5174
|
-
h = th;
|
|
5175
|
-
l = tl;
|
|
5176
|
-
|
|
5177
|
-
a = l & 0xffff; b = l >>> 16;
|
|
5178
|
-
c = h & 0xffff; d = h >>> 16;
|
|
5179
|
-
|
|
5180
|
-
// Sigma0
|
|
5181
|
-
h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));
|
|
5182
|
-
l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));
|
|
5183
|
-
|
|
5184
|
-
a += l & 0xffff; b += l >>> 16;
|
|
5185
|
-
c += h & 0xffff; d += h >>> 16;
|
|
5186
|
-
|
|
5187
|
-
// Maj
|
|
5188
|
-
h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);
|
|
5189
|
-
l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);
|
|
5190
|
-
|
|
5191
|
-
a += l & 0xffff; b += l >>> 16;
|
|
5192
|
-
c += h & 0xffff; d += h >>> 16;
|
|
5193
|
-
|
|
5194
|
-
b += a >>> 16;
|
|
5195
|
-
c += b >>> 16;
|
|
5196
|
-
d += c >>> 16;
|
|
5197
|
-
|
|
5198
|
-
bh7 = (c & 0xffff) | (d << 16);
|
|
5199
|
-
bl7 = (a & 0xffff) | (b << 16);
|
|
5200
|
-
|
|
5201
|
-
// add
|
|
5202
|
-
h = bh3;
|
|
5203
|
-
l = bl3;
|
|
5204
|
-
|
|
5205
|
-
a = l & 0xffff; b = l >>> 16;
|
|
5206
|
-
c = h & 0xffff; d = h >>> 16;
|
|
5207
|
-
|
|
5208
|
-
h = th;
|
|
5209
|
-
l = tl;
|
|
5210
|
-
|
|
5211
|
-
a += l & 0xffff; b += l >>> 16;
|
|
5212
|
-
c += h & 0xffff; d += h >>> 16;
|
|
5213
|
-
|
|
5214
|
-
b += a >>> 16;
|
|
5215
|
-
c += b >>> 16;
|
|
5216
|
-
d += c >>> 16;
|
|
5217
|
-
|
|
5218
|
-
bh3 = (c & 0xffff) | (d << 16);
|
|
5219
|
-
bl3 = (a & 0xffff) | (b << 16);
|
|
5220
|
-
|
|
5221
|
-
ah1 = bh0;
|
|
5222
|
-
ah2 = bh1;
|
|
5223
|
-
ah3 = bh2;
|
|
5224
|
-
ah4 = bh3;
|
|
5225
|
-
ah5 = bh4;
|
|
5226
|
-
ah6 = bh5;
|
|
5227
|
-
ah7 = bh6;
|
|
5228
|
-
ah0 = bh7;
|
|
5229
|
-
|
|
5230
|
-
al1 = bl0;
|
|
5231
|
-
al2 = bl1;
|
|
5232
|
-
al3 = bl2;
|
|
5233
|
-
al4 = bl3;
|
|
5234
|
-
al5 = bl4;
|
|
5235
|
-
al6 = bl5;
|
|
5236
|
-
al7 = bl6;
|
|
5237
|
-
al0 = bl7;
|
|
5238
|
-
|
|
5239
|
-
if (i%16 === 15) {
|
|
5240
|
-
for (j = 0; j < 16; j++) {
|
|
5241
|
-
// add
|
|
5242
|
-
h = wh[j];
|
|
5243
|
-
l = wl[j];
|
|
5244
|
-
|
|
5245
|
-
a = l & 0xffff; b = l >>> 16;
|
|
5246
|
-
c = h & 0xffff; d = h >>> 16;
|
|
5247
|
-
|
|
5248
|
-
h = wh[(j+9)%16];
|
|
5249
|
-
l = wl[(j+9)%16];
|
|
5250
|
-
|
|
5251
|
-
a += l & 0xffff; b += l >>> 16;
|
|
5252
|
-
c += h & 0xffff; d += h >>> 16;
|
|
5253
|
-
|
|
5254
|
-
// sigma0
|
|
5255
|
-
th = wh[(j+1)%16];
|
|
5256
|
-
tl = wl[(j+1)%16];
|
|
5257
|
-
h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);
|
|
5258
|
-
l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));
|
|
5259
|
-
|
|
5260
|
-
a += l & 0xffff; b += l >>> 16;
|
|
5261
|
-
c += h & 0xffff; d += h >>> 16;
|
|
5262
|
-
|
|
5263
|
-
// sigma1
|
|
5264
|
-
th = wh[(j+14)%16];
|
|
5265
|
-
tl = wl[(j+14)%16];
|
|
5266
|
-
h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);
|
|
5267
|
-
l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));
|
|
5268
|
-
|
|
5269
|
-
a += l & 0xffff; b += l >>> 16;
|
|
5270
|
-
c += h & 0xffff; d += h >>> 16;
|
|
5271
|
-
|
|
5272
|
-
b += a >>> 16;
|
|
5273
|
-
c += b >>> 16;
|
|
5274
|
-
d += c >>> 16;
|
|
5275
|
-
|
|
5276
|
-
wh[j] = (c & 0xffff) | (d << 16);
|
|
5277
|
-
wl[j] = (a & 0xffff) | (b << 16);
|
|
5278
|
-
}
|
|
5279
|
-
}
|
|
5280
|
-
}
|
|
5281
|
-
|
|
5282
|
-
// add
|
|
5283
|
-
h = ah0;
|
|
5284
|
-
l = al0;
|
|
5285
|
-
|
|
5286
|
-
a = l & 0xffff; b = l >>> 16;
|
|
5287
|
-
c = h & 0xffff; d = h >>> 16;
|
|
5288
|
-
|
|
5289
|
-
h = hh[0];
|
|
5290
|
-
l = hl[0];
|
|
5291
|
-
|
|
5292
|
-
a += l & 0xffff; b += l >>> 16;
|
|
5293
|
-
c += h & 0xffff; d += h >>> 16;
|
|
5294
|
-
|
|
5295
|
-
b += a >>> 16;
|
|
5296
|
-
c += b >>> 16;
|
|
5297
|
-
d += c >>> 16;
|
|
5298
|
-
|
|
5299
|
-
hh[0] = ah0 = (c & 0xffff) | (d << 16);
|
|
5300
|
-
hl[0] = al0 = (a & 0xffff) | (b << 16);
|
|
5301
|
-
|
|
5302
|
-
h = ah1;
|
|
5303
|
-
l = al1;
|
|
5304
|
-
|
|
5305
|
-
a = l & 0xffff; b = l >>> 16;
|
|
5306
|
-
c = h & 0xffff; d = h >>> 16;
|
|
5307
|
-
|
|
5308
|
-
h = hh[1];
|
|
5309
|
-
l = hl[1];
|
|
5310
|
-
|
|
5311
|
-
a += l & 0xffff; b += l >>> 16;
|
|
5312
|
-
c += h & 0xffff; d += h >>> 16;
|
|
5313
|
-
|
|
5314
|
-
b += a >>> 16;
|
|
5315
|
-
c += b >>> 16;
|
|
5316
|
-
d += c >>> 16;
|
|
5317
|
-
|
|
5318
|
-
hh[1] = ah1 = (c & 0xffff) | (d << 16);
|
|
5319
|
-
hl[1] = al1 = (a & 0xffff) | (b << 16);
|
|
5320
|
-
|
|
5321
|
-
h = ah2;
|
|
5322
|
-
l = al2;
|
|
5323
|
-
|
|
5324
|
-
a = l & 0xffff; b = l >>> 16;
|
|
5325
|
-
c = h & 0xffff; d = h >>> 16;
|
|
5326
|
-
|
|
5327
|
-
h = hh[2];
|
|
5328
|
-
l = hl[2];
|
|
5329
|
-
|
|
5330
|
-
a += l & 0xffff; b += l >>> 16;
|
|
5331
|
-
c += h & 0xffff; d += h >>> 16;
|
|
5332
|
-
|
|
5333
|
-
b += a >>> 16;
|
|
5334
|
-
c += b >>> 16;
|
|
5335
|
-
d += c >>> 16;
|
|
5336
|
-
|
|
5337
|
-
hh[2] = ah2 = (c & 0xffff) | (d << 16);
|
|
5338
|
-
hl[2] = al2 = (a & 0xffff) | (b << 16);
|
|
5339
|
-
|
|
5340
|
-
h = ah3;
|
|
5341
|
-
l = al3;
|
|
5342
|
-
|
|
5343
|
-
a = l & 0xffff; b = l >>> 16;
|
|
5344
|
-
c = h & 0xffff; d = h >>> 16;
|
|
5345
|
-
|
|
5346
|
-
h = hh[3];
|
|
5347
|
-
l = hl[3];
|
|
5348
|
-
|
|
5349
|
-
a += l & 0xffff; b += l >>> 16;
|
|
5350
|
-
c += h & 0xffff; d += h >>> 16;
|
|
5351
|
-
|
|
5352
|
-
b += a >>> 16;
|
|
5353
|
-
c += b >>> 16;
|
|
5354
|
-
d += c >>> 16;
|
|
5355
|
-
|
|
5356
|
-
hh[3] = ah3 = (c & 0xffff) | (d << 16);
|
|
5357
|
-
hl[3] = al3 = (a & 0xffff) | (b << 16);
|
|
5358
|
-
|
|
5359
|
-
h = ah4;
|
|
5360
|
-
l = al4;
|
|
5361
|
-
|
|
5362
|
-
a = l & 0xffff; b = l >>> 16;
|
|
5363
|
-
c = h & 0xffff; d = h >>> 16;
|
|
5364
|
-
|
|
5365
|
-
h = hh[4];
|
|
5366
|
-
l = hl[4];
|
|
5367
|
-
|
|
5368
|
-
a += l & 0xffff; b += l >>> 16;
|
|
5369
|
-
c += h & 0xffff; d += h >>> 16;
|
|
5370
|
-
|
|
5371
|
-
b += a >>> 16;
|
|
5372
|
-
c += b >>> 16;
|
|
5373
|
-
d += c >>> 16;
|
|
5374
|
-
|
|
5375
|
-
hh[4] = ah4 = (c & 0xffff) | (d << 16);
|
|
5376
|
-
hl[4] = al4 = (a & 0xffff) | (b << 16);
|
|
5377
|
-
|
|
5378
|
-
h = ah5;
|
|
5379
|
-
l = al5;
|
|
5380
|
-
|
|
5381
|
-
a = l & 0xffff; b = l >>> 16;
|
|
5382
|
-
c = h & 0xffff; d = h >>> 16;
|
|
5383
|
-
|
|
5384
|
-
h = hh[5];
|
|
5385
|
-
l = hl[5];
|
|
5386
|
-
|
|
5387
|
-
a += l & 0xffff; b += l >>> 16;
|
|
5388
|
-
c += h & 0xffff; d += h >>> 16;
|
|
5389
|
-
|
|
5390
|
-
b += a >>> 16;
|
|
5391
|
-
c += b >>> 16;
|
|
5392
|
-
d += c >>> 16;
|
|
5393
|
-
|
|
5394
|
-
hh[5] = ah5 = (c & 0xffff) | (d << 16);
|
|
5395
|
-
hl[5] = al5 = (a & 0xffff) | (b << 16);
|
|
5396
|
-
|
|
5397
|
-
h = ah6;
|
|
5398
|
-
l = al6;
|
|
5399
|
-
|
|
5400
|
-
a = l & 0xffff; b = l >>> 16;
|
|
5401
|
-
c = h & 0xffff; d = h >>> 16;
|
|
5402
|
-
|
|
5403
|
-
h = hh[6];
|
|
5404
|
-
l = hl[6];
|
|
5405
|
-
|
|
5406
|
-
a += l & 0xffff; b += l >>> 16;
|
|
5407
|
-
c += h & 0xffff; d += h >>> 16;
|
|
5408
|
-
|
|
5409
|
-
b += a >>> 16;
|
|
5410
|
-
c += b >>> 16;
|
|
5411
|
-
d += c >>> 16;
|
|
5412
|
-
|
|
5413
|
-
hh[6] = ah6 = (c & 0xffff) | (d << 16);
|
|
5414
|
-
hl[6] = al6 = (a & 0xffff) | (b << 16);
|
|
5415
|
-
|
|
5416
|
-
h = ah7;
|
|
5417
|
-
l = al7;
|
|
5418
|
-
|
|
5419
|
-
a = l & 0xffff; b = l >>> 16;
|
|
5420
|
-
c = h & 0xffff; d = h >>> 16;
|
|
5421
|
-
|
|
5422
|
-
h = hh[7];
|
|
5423
|
-
l = hl[7];
|
|
5424
|
-
|
|
5425
|
-
a += l & 0xffff; b += l >>> 16;
|
|
5426
|
-
c += h & 0xffff; d += h >>> 16;
|
|
5427
|
-
|
|
5428
|
-
b += a >>> 16;
|
|
5429
|
-
c += b >>> 16;
|
|
5430
|
-
d += c >>> 16;
|
|
5431
|
-
|
|
5432
|
-
hh[7] = ah7 = (c & 0xffff) | (d << 16);
|
|
5433
|
-
hl[7] = al7 = (a & 0xffff) | (b << 16);
|
|
5434
|
-
|
|
5435
|
-
pos += 128;
|
|
5436
|
-
n -= 128;
|
|
5437
|
-
}
|
|
5438
|
-
|
|
5439
|
-
return n;
|
|
5440
|
-
}
|
|
5441
|
-
|
|
5442
|
-
function crypto_hash(out, m, n) {
|
|
5443
|
-
var hh = new Int32Array(8),
|
|
5444
|
-
hl = new Int32Array(8),
|
|
5445
|
-
x = new Uint8Array(256),
|
|
5446
|
-
i, b = n;
|
|
5447
|
-
|
|
5448
|
-
hh[0] = 0x6a09e667;
|
|
5449
|
-
hh[1] = 0xbb67ae85;
|
|
5450
|
-
hh[2] = 0x3c6ef372;
|
|
5451
|
-
hh[3] = 0xa54ff53a;
|
|
5452
|
-
hh[4] = 0x510e527f;
|
|
5453
|
-
hh[5] = 0x9b05688c;
|
|
5454
|
-
hh[6] = 0x1f83d9ab;
|
|
5455
|
-
hh[7] = 0x5be0cd19;
|
|
5456
|
-
|
|
5457
|
-
hl[0] = 0xf3bcc908;
|
|
5458
|
-
hl[1] = 0x84caa73b;
|
|
5459
|
-
hl[2] = 0xfe94f82b;
|
|
5460
|
-
hl[3] = 0x5f1d36f1;
|
|
5461
|
-
hl[4] = 0xade682d1;
|
|
5462
|
-
hl[5] = 0x2b3e6c1f;
|
|
5463
|
-
hl[6] = 0xfb41bd6b;
|
|
5464
|
-
hl[7] = 0x137e2179;
|
|
5465
|
-
|
|
5466
|
-
crypto_hashblocks_hl(hh, hl, m, n);
|
|
5467
|
-
n %= 128;
|
|
5468
|
-
|
|
5469
|
-
for (i = 0; i < n; i++) x[i] = m[b-n+i];
|
|
5470
|
-
x[n] = 128;
|
|
5471
|
-
|
|
5472
|
-
n = 256-128*(n<112?1:0);
|
|
5473
|
-
x[n-9] = 0;
|
|
5474
|
-
ts64(x, n-8, (b / 0x20000000) | 0, b << 3);
|
|
5475
|
-
crypto_hashblocks_hl(hh, hl, x, n);
|
|
5476
|
-
|
|
5477
|
-
for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);
|
|
5478
|
-
|
|
5479
|
-
return 0;
|
|
5480
|
-
}
|
|
5481
|
-
|
|
5482
|
-
function add(p, q) {
|
|
5483
|
-
var a = gf(), b = gf(), c = gf(),
|
|
5484
|
-
d = gf(), e = gf(), f = gf(),
|
|
5485
|
-
g = gf(), h = gf(), t = gf();
|
|
5486
|
-
|
|
5487
|
-
Z(a, p[1], p[0]);
|
|
5488
|
-
Z(t, q[1], q[0]);
|
|
5489
|
-
M(a, a, t);
|
|
5490
|
-
A(b, p[0], p[1]);
|
|
5491
|
-
A(t, q[0], q[1]);
|
|
5492
|
-
M(b, b, t);
|
|
5493
|
-
M(c, p[3], q[3]);
|
|
5494
|
-
M(c, c, D2);
|
|
5495
|
-
M(d, p[2], q[2]);
|
|
5496
|
-
A(d, d, d);
|
|
5497
|
-
Z(e, b, a);
|
|
5498
|
-
Z(f, d, c);
|
|
5499
|
-
A(g, d, c);
|
|
5500
|
-
A(h, b, a);
|
|
5501
|
-
|
|
5502
|
-
M(p[0], e, f);
|
|
5503
|
-
M(p[1], h, g);
|
|
5504
|
-
M(p[2], g, f);
|
|
5505
|
-
M(p[3], e, h);
|
|
5506
|
-
}
|
|
5507
|
-
|
|
5508
|
-
function cswap(p, q, b) {
|
|
5509
|
-
var i;
|
|
5510
|
-
for (i = 0; i < 4; i++) {
|
|
5511
|
-
sel25519(p[i], q[i], b);
|
|
5512
|
-
}
|
|
5513
|
-
}
|
|
5514
|
-
|
|
5515
|
-
function pack(r, p) {
|
|
5516
|
-
var tx = gf(), ty = gf(), zi = gf();
|
|
5517
|
-
inv25519(zi, p[2]);
|
|
5518
|
-
M(tx, p[0], zi);
|
|
5519
|
-
M(ty, p[1], zi);
|
|
5520
|
-
pack25519(r, ty);
|
|
5521
|
-
r[31] ^= par25519(tx) << 7;
|
|
5522
|
-
}
|
|
5523
|
-
|
|
5524
|
-
function scalarmult(p, q, s) {
|
|
5525
|
-
var b, i;
|
|
5526
|
-
set25519(p[0], gf0);
|
|
5527
|
-
set25519(p[1], gf1);
|
|
5528
|
-
set25519(p[2], gf1);
|
|
5529
|
-
set25519(p[3], gf0);
|
|
5530
|
-
for (i = 255; i >= 0; --i) {
|
|
5531
|
-
b = (s[(i/8)|0] >> (i&7)) & 1;
|
|
5532
|
-
cswap(p, q, b);
|
|
5533
|
-
add(q, p);
|
|
5534
|
-
add(p, p);
|
|
5535
|
-
cswap(p, q, b);
|
|
5536
|
-
}
|
|
5537
|
-
}
|
|
5538
|
-
|
|
5539
|
-
function scalarbase(p, s) {
|
|
5540
|
-
var q = [gf(), gf(), gf(), gf()];
|
|
5541
|
-
set25519(q[0], X);
|
|
5542
|
-
set25519(q[1], Y);
|
|
5543
|
-
set25519(q[2], gf1);
|
|
5544
|
-
M(q[3], X, Y);
|
|
5545
|
-
scalarmult(p, q, s);
|
|
5546
|
-
}
|
|
5547
|
-
|
|
5548
|
-
function crypto_sign_keypair(pk, sk, seeded) {
|
|
5549
|
-
var d = new Uint8Array(64);
|
|
5550
|
-
var p = [gf(), gf(), gf(), gf()];
|
|
5551
|
-
var i;
|
|
5552
|
-
|
|
5553
|
-
if (!seeded) randombytes(sk, 32);
|
|
5554
|
-
crypto_hash(d, sk, 32);
|
|
5555
|
-
d[0] &= 248;
|
|
5556
|
-
d[31] &= 127;
|
|
5557
|
-
d[31] |= 64;
|
|
5558
|
-
|
|
5559
|
-
scalarbase(p, d);
|
|
5560
|
-
pack(pk, p);
|
|
5561
|
-
|
|
5562
|
-
for (i = 0; i < 32; i++) sk[i+32] = pk[i];
|
|
5563
|
-
return 0;
|
|
5564
|
-
}
|
|
5565
|
-
|
|
5566
|
-
var L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);
|
|
5567
|
-
|
|
5568
|
-
function modL(r, x) {
|
|
5569
|
-
var carry, i, j, k;
|
|
5570
|
-
for (i = 63; i >= 32; --i) {
|
|
5571
|
-
carry = 0;
|
|
5572
|
-
for (j = i - 32, k = i - 12; j < k; ++j) {
|
|
5573
|
-
x[j] += carry - 16 * x[i] * L[j - (i - 32)];
|
|
5574
|
-
carry = Math.floor((x[j] + 128) / 256);
|
|
5575
|
-
x[j] -= carry * 256;
|
|
5576
|
-
}
|
|
5577
|
-
x[j] += carry;
|
|
5578
|
-
x[i] = 0;
|
|
5579
|
-
}
|
|
5580
|
-
carry = 0;
|
|
5581
|
-
for (j = 0; j < 32; j++) {
|
|
5582
|
-
x[j] += carry - (x[31] >> 4) * L[j];
|
|
5583
|
-
carry = x[j] >> 8;
|
|
5584
|
-
x[j] &= 255;
|
|
5585
|
-
}
|
|
5586
|
-
for (j = 0; j < 32; j++) x[j] -= carry * L[j];
|
|
5587
|
-
for (i = 0; i < 32; i++) {
|
|
5588
|
-
x[i+1] += x[i] >> 8;
|
|
5589
|
-
r[i] = x[i] & 255;
|
|
5590
|
-
}
|
|
5591
|
-
}
|
|
5592
|
-
|
|
5593
|
-
function reduce(r) {
|
|
5594
|
-
var x = new Float64Array(64), i;
|
|
5595
|
-
for (i = 0; i < 64; i++) x[i] = r[i];
|
|
5596
|
-
for (i = 0; i < 64; i++) r[i] = 0;
|
|
5597
|
-
modL(r, x);
|
|
5598
|
-
}
|
|
5599
|
-
|
|
5600
|
-
// Note: difference from C - smlen returned, not passed as argument.
|
|
5601
|
-
function crypto_sign(sm, m, n, sk) {
|
|
5602
|
-
var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);
|
|
5603
|
-
var i, j, x = new Float64Array(64);
|
|
5604
|
-
var p = [gf(), gf(), gf(), gf()];
|
|
5605
|
-
|
|
5606
|
-
crypto_hash(d, sk, 32);
|
|
5607
|
-
d[0] &= 248;
|
|
5608
|
-
d[31] &= 127;
|
|
5609
|
-
d[31] |= 64;
|
|
5610
|
-
|
|
5611
|
-
var smlen = n + 64;
|
|
5612
|
-
for (i = 0; i < n; i++) sm[64 + i] = m[i];
|
|
5613
|
-
for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];
|
|
5614
|
-
|
|
5615
|
-
crypto_hash(r, sm.subarray(32), n+32);
|
|
5616
|
-
reduce(r);
|
|
5617
|
-
scalarbase(p, r);
|
|
5618
|
-
pack(sm, p);
|
|
5619
|
-
|
|
5620
|
-
for (i = 32; i < 64; i++) sm[i] = sk[i];
|
|
5621
|
-
crypto_hash(h, sm, n + 64);
|
|
5622
|
-
reduce(h);
|
|
5623
|
-
|
|
5624
|
-
for (i = 0; i < 64; i++) x[i] = 0;
|
|
5625
|
-
for (i = 0; i < 32; i++) x[i] = r[i];
|
|
5626
|
-
for (i = 0; i < 32; i++) {
|
|
5627
|
-
for (j = 0; j < 32; j++) {
|
|
5628
|
-
x[i+j] += h[i] * d[j];
|
|
5629
|
-
}
|
|
5630
|
-
}
|
|
5631
|
-
|
|
5632
|
-
modL(sm.subarray(32), x);
|
|
5633
|
-
return smlen;
|
|
5634
|
-
}
|
|
5635
|
-
|
|
5636
|
-
function unpackneg(r, p) {
|
|
5637
|
-
var t = gf(), chk = gf(), num = gf(),
|
|
5638
|
-
den = gf(), den2 = gf(), den4 = gf(),
|
|
5639
|
-
den6 = gf();
|
|
5640
|
-
|
|
5641
|
-
set25519(r[2], gf1);
|
|
5642
|
-
unpack25519(r[1], p);
|
|
5643
|
-
S(num, r[1]);
|
|
5644
|
-
M(den, num, D);
|
|
5645
|
-
Z(num, num, r[2]);
|
|
5646
|
-
A(den, r[2], den);
|
|
5647
|
-
|
|
5648
|
-
S(den2, den);
|
|
5649
|
-
S(den4, den2);
|
|
5650
|
-
M(den6, den4, den2);
|
|
5651
|
-
M(t, den6, num);
|
|
5652
|
-
M(t, t, den);
|
|
5653
|
-
|
|
5654
|
-
pow2523(t, t);
|
|
5655
|
-
M(t, t, num);
|
|
5656
|
-
M(t, t, den);
|
|
5657
|
-
M(t, t, den);
|
|
5658
|
-
M(r[0], t, den);
|
|
5659
|
-
|
|
5660
|
-
S(chk, r[0]);
|
|
5661
|
-
M(chk, chk, den);
|
|
5662
|
-
if (neq25519(chk, num)) M(r[0], r[0], I);
|
|
5663
|
-
|
|
5664
|
-
S(chk, r[0]);
|
|
5665
|
-
M(chk, chk, den);
|
|
5666
|
-
if (neq25519(chk, num)) return -1;
|
|
5667
|
-
|
|
5668
|
-
if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);
|
|
5669
|
-
|
|
5670
|
-
M(r[3], r[0], r[1]);
|
|
5671
|
-
return 0;
|
|
5672
|
-
}
|
|
5673
|
-
|
|
5674
|
-
function crypto_sign_open(m, sm, n, pk) {
|
|
5675
|
-
var i;
|
|
5676
|
-
var t = new Uint8Array(32), h = new Uint8Array(64);
|
|
5677
|
-
var p = [gf(), gf(), gf(), gf()],
|
|
5678
|
-
q = [gf(), gf(), gf(), gf()];
|
|
5679
|
-
|
|
5680
|
-
if (n < 64) return -1;
|
|
5681
|
-
|
|
5682
|
-
if (unpackneg(q, pk)) return -1;
|
|
5683
|
-
|
|
5684
|
-
for (i = 0; i < n; i++) m[i] = sm[i];
|
|
5685
|
-
for (i = 0; i < 32; i++) m[i+32] = pk[i];
|
|
5686
|
-
crypto_hash(h, m, n);
|
|
5687
|
-
reduce(h);
|
|
5688
|
-
scalarmult(p, q, h);
|
|
5689
|
-
|
|
5690
|
-
scalarbase(q, sm.subarray(32));
|
|
5691
|
-
add(p, q);
|
|
5692
|
-
pack(t, p);
|
|
5693
|
-
|
|
5694
|
-
n -= 64;
|
|
5695
|
-
if (crypto_verify_32(sm, 0, t, 0)) {
|
|
5696
|
-
for (i = 0; i < n; i++) m[i] = 0;
|
|
5697
|
-
return -1;
|
|
5698
|
-
}
|
|
5699
|
-
|
|
5700
|
-
for (i = 0; i < n; i++) m[i] = sm[i + 64];
|
|
5701
|
-
return n;
|
|
5702
|
-
}
|
|
5703
|
-
|
|
5704
|
-
var crypto_secretbox_KEYBYTES = 32,
|
|
5705
|
-
crypto_secretbox_NONCEBYTES = 24,
|
|
5706
|
-
crypto_secretbox_ZEROBYTES = 32,
|
|
5707
|
-
crypto_secretbox_BOXZEROBYTES = 16,
|
|
5708
|
-
crypto_scalarmult_BYTES = 32,
|
|
5709
|
-
crypto_scalarmult_SCALARBYTES = 32,
|
|
5710
|
-
crypto_box_PUBLICKEYBYTES = 32,
|
|
5711
|
-
crypto_box_SECRETKEYBYTES = 32,
|
|
5712
|
-
crypto_box_BEFORENMBYTES = 32,
|
|
5713
|
-
crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,
|
|
5714
|
-
crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,
|
|
5715
|
-
crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,
|
|
5716
|
-
crypto_sign_BYTES = 64,
|
|
5717
|
-
crypto_sign_PUBLICKEYBYTES = 32,
|
|
5718
|
-
crypto_sign_SECRETKEYBYTES = 64,
|
|
5719
|
-
crypto_sign_SEEDBYTES = 32,
|
|
5720
|
-
crypto_hash_BYTES = 64;
|
|
5721
|
-
|
|
5722
|
-
nacl.lowlevel = {
|
|
5723
|
-
crypto_core_hsalsa20: crypto_core_hsalsa20,
|
|
5724
|
-
crypto_stream_xor: crypto_stream_xor,
|
|
5725
|
-
crypto_stream: crypto_stream,
|
|
5726
|
-
crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,
|
|
5727
|
-
crypto_stream_salsa20: crypto_stream_salsa20,
|
|
5728
|
-
crypto_onetimeauth: crypto_onetimeauth,
|
|
5729
|
-
crypto_onetimeauth_verify: crypto_onetimeauth_verify,
|
|
5730
|
-
crypto_verify_16: crypto_verify_16,
|
|
5731
|
-
crypto_verify_32: crypto_verify_32,
|
|
5732
|
-
crypto_secretbox: crypto_secretbox,
|
|
5733
|
-
crypto_secretbox_open: crypto_secretbox_open,
|
|
5734
|
-
crypto_scalarmult: crypto_scalarmult,
|
|
5735
|
-
crypto_scalarmult_base: crypto_scalarmult_base,
|
|
5736
|
-
crypto_box_beforenm: crypto_box_beforenm,
|
|
5737
|
-
crypto_box_afternm: crypto_box_afternm,
|
|
5738
|
-
crypto_box: crypto_box,
|
|
5739
|
-
crypto_box_open: crypto_box_open,
|
|
5740
|
-
crypto_box_keypair: crypto_box_keypair,
|
|
5741
|
-
crypto_hash: crypto_hash,
|
|
5742
|
-
crypto_sign: crypto_sign,
|
|
5743
|
-
crypto_sign_keypair: crypto_sign_keypair,
|
|
5744
|
-
crypto_sign_open: crypto_sign_open,
|
|
5745
|
-
|
|
5746
|
-
crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,
|
|
5747
|
-
crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,
|
|
5748
|
-
crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,
|
|
5749
|
-
crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,
|
|
5750
|
-
crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,
|
|
5751
|
-
crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,
|
|
5752
|
-
crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,
|
|
5753
|
-
crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,
|
|
5754
|
-
crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,
|
|
5755
|
-
crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,
|
|
5756
|
-
crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,
|
|
5757
|
-
crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,
|
|
5758
|
-
crypto_sign_BYTES: crypto_sign_BYTES,
|
|
5759
|
-
crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,
|
|
5760
|
-
crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,
|
|
5761
|
-
crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,
|
|
5762
|
-
crypto_hash_BYTES: crypto_hash_BYTES,
|
|
5763
|
-
|
|
5764
|
-
gf: gf,
|
|
5765
|
-
D: D,
|
|
5766
|
-
L: L,
|
|
5767
|
-
pack25519: pack25519,
|
|
5768
|
-
unpack25519: unpack25519,
|
|
5769
|
-
M: M,
|
|
5770
|
-
A: A,
|
|
5771
|
-
S: S,
|
|
5772
|
-
Z: Z,
|
|
5773
|
-
pow2523: pow2523,
|
|
5774
|
-
add: add,
|
|
5775
|
-
set25519: set25519,
|
|
5776
|
-
modL: modL,
|
|
5777
|
-
scalarmult: scalarmult,
|
|
5778
|
-
scalarbase: scalarbase,
|
|
5779
|
-
};
|
|
5780
|
-
|
|
5781
|
-
/* High-level API */
|
|
5782
|
-
|
|
5783
|
-
function checkLengths(k, n) {
|
|
5784
|
-
if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');
|
|
5785
|
-
if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');
|
|
5786
|
-
}
|
|
5787
|
-
|
|
5788
|
-
function checkBoxLengths(pk, sk) {
|
|
5789
|
-
if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');
|
|
5790
|
-
if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');
|
|
5791
|
-
}
|
|
5792
|
-
|
|
5793
|
-
function checkArrayTypes() {
|
|
5794
|
-
for (var i = 0; i < arguments.length; i++) {
|
|
5795
|
-
if (!(arguments[i] instanceof Uint8Array))
|
|
5796
|
-
throw new TypeError('unexpected type, use Uint8Array');
|
|
5797
|
-
}
|
|
5798
|
-
}
|
|
5799
|
-
|
|
5800
|
-
function cleanup(arr) {
|
|
5801
|
-
for (var i = 0; i < arr.length; i++) arr[i] = 0;
|
|
5802
|
-
}
|
|
5803
|
-
|
|
5804
|
-
nacl.randomBytes = function(n) {
|
|
5805
|
-
var b = new Uint8Array(n);
|
|
5806
|
-
randombytes(b, n);
|
|
5807
|
-
return b;
|
|
5808
|
-
};
|
|
5809
|
-
|
|
5810
|
-
nacl.secretbox = function(msg, nonce, key) {
|
|
5811
|
-
checkArrayTypes(msg, nonce, key);
|
|
5812
|
-
checkLengths(key, nonce);
|
|
5813
|
-
var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);
|
|
5814
|
-
var c = new Uint8Array(m.length);
|
|
5815
|
-
for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];
|
|
5816
|
-
crypto_secretbox(c, m, m.length, nonce, key);
|
|
5817
|
-
return c.subarray(crypto_secretbox_BOXZEROBYTES);
|
|
5818
|
-
};
|
|
5819
|
-
|
|
5820
|
-
nacl.secretbox.open = function(box, nonce, key) {
|
|
5821
|
-
checkArrayTypes(box, nonce, key);
|
|
5822
|
-
checkLengths(key, nonce);
|
|
5823
|
-
var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);
|
|
5824
|
-
var m = new Uint8Array(c.length);
|
|
5825
|
-
for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];
|
|
5826
|
-
if (c.length < 32) return null;
|
|
5827
|
-
if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;
|
|
5828
|
-
return m.subarray(crypto_secretbox_ZEROBYTES);
|
|
5829
|
-
};
|
|
5830
|
-
|
|
5831
|
-
nacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;
|
|
5832
|
-
nacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;
|
|
5833
|
-
nacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;
|
|
5834
|
-
|
|
5835
|
-
nacl.scalarMult = function(n, p) {
|
|
5836
|
-
checkArrayTypes(n, p);
|
|
5837
|
-
if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');
|
|
5838
|
-
if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');
|
|
5839
|
-
var q = new Uint8Array(crypto_scalarmult_BYTES);
|
|
5840
|
-
crypto_scalarmult(q, n, p);
|
|
5841
|
-
return q;
|
|
5842
|
-
};
|
|
5843
|
-
|
|
5844
|
-
nacl.scalarMult.base = function(n) {
|
|
5845
|
-
checkArrayTypes(n);
|
|
5846
|
-
if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');
|
|
5847
|
-
var q = new Uint8Array(crypto_scalarmult_BYTES);
|
|
5848
|
-
crypto_scalarmult_base(q, n);
|
|
5849
|
-
return q;
|
|
5850
|
-
};
|
|
5851
|
-
|
|
5852
|
-
nacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;
|
|
5853
|
-
nacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;
|
|
5854
|
-
|
|
5855
|
-
nacl.box = function(msg, nonce, publicKey, secretKey) {
|
|
5856
|
-
var k = nacl.box.before(publicKey, secretKey);
|
|
5857
|
-
return nacl.secretbox(msg, nonce, k);
|
|
5858
|
-
};
|
|
5859
|
-
|
|
5860
|
-
nacl.box.before = function(publicKey, secretKey) {
|
|
5861
|
-
checkArrayTypes(publicKey, secretKey);
|
|
5862
|
-
checkBoxLengths(publicKey, secretKey);
|
|
5863
|
-
var k = new Uint8Array(crypto_box_BEFORENMBYTES);
|
|
5864
|
-
crypto_box_beforenm(k, publicKey, secretKey);
|
|
5865
|
-
return k;
|
|
5866
|
-
};
|
|
5867
|
-
|
|
5868
|
-
nacl.box.after = nacl.secretbox;
|
|
5869
|
-
|
|
5870
|
-
nacl.box.open = function(msg, nonce, publicKey, secretKey) {
|
|
5871
|
-
var k = nacl.box.before(publicKey, secretKey);
|
|
5872
|
-
return nacl.secretbox.open(msg, nonce, k);
|
|
5873
|
-
};
|
|
5874
|
-
|
|
5875
|
-
nacl.box.open.after = nacl.secretbox.open;
|
|
5876
|
-
|
|
5877
|
-
nacl.box.keyPair = function() {
|
|
5878
|
-
var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
|
|
5879
|
-
var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);
|
|
5880
|
-
crypto_box_keypair(pk, sk);
|
|
5881
|
-
return {publicKey: pk, secretKey: sk};
|
|
5882
|
-
};
|
|
5883
|
-
|
|
5884
|
-
nacl.box.keyPair.fromSecretKey = function(secretKey) {
|
|
5885
|
-
checkArrayTypes(secretKey);
|
|
5886
|
-
if (secretKey.length !== crypto_box_SECRETKEYBYTES)
|
|
5887
|
-
throw new Error('bad secret key size');
|
|
5888
|
-
var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
|
|
5889
|
-
crypto_scalarmult_base(pk, secretKey);
|
|
5890
|
-
return {publicKey: pk, secretKey: new Uint8Array(secretKey)};
|
|
5891
|
-
};
|
|
5892
|
-
|
|
5893
|
-
nacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;
|
|
5894
|
-
nacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;
|
|
5895
|
-
nacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;
|
|
5896
|
-
nacl.box.nonceLength = crypto_box_NONCEBYTES;
|
|
5897
|
-
nacl.box.overheadLength = nacl.secretbox.overheadLength;
|
|
5898
|
-
|
|
5899
|
-
nacl.sign = function(msg, secretKey) {
|
|
5900
|
-
checkArrayTypes(msg, secretKey);
|
|
5901
|
-
if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
|
|
5902
|
-
throw new Error('bad secret key size');
|
|
5903
|
-
var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);
|
|
5904
|
-
crypto_sign(signedMsg, msg, msg.length, secretKey);
|
|
5905
|
-
return signedMsg;
|
|
5906
|
-
};
|
|
5907
|
-
|
|
5908
|
-
nacl.sign.open = function(signedMsg, publicKey) {
|
|
5909
|
-
checkArrayTypes(signedMsg, publicKey);
|
|
5910
|
-
if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
|
|
5911
|
-
throw new Error('bad public key size');
|
|
5912
|
-
var tmp = new Uint8Array(signedMsg.length);
|
|
5913
|
-
var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);
|
|
5914
|
-
if (mlen < 0) return null;
|
|
5915
|
-
var m = new Uint8Array(mlen);
|
|
5916
|
-
for (var i = 0; i < m.length; i++) m[i] = tmp[i];
|
|
5917
|
-
return m;
|
|
5918
|
-
};
|
|
5919
|
-
|
|
5920
|
-
nacl.sign.detached = function(msg, secretKey) {
|
|
5921
|
-
var signedMsg = nacl.sign(msg, secretKey);
|
|
5922
|
-
var sig = new Uint8Array(crypto_sign_BYTES);
|
|
5923
|
-
for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];
|
|
5924
|
-
return sig;
|
|
5925
|
-
};
|
|
5926
|
-
|
|
5927
|
-
nacl.sign.detached.verify = function(msg, sig, publicKey) {
|
|
5928
|
-
checkArrayTypes(msg, sig, publicKey);
|
|
5929
|
-
if (sig.length !== crypto_sign_BYTES)
|
|
5930
|
-
throw new Error('bad signature size');
|
|
5931
|
-
if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
|
|
5932
|
-
throw new Error('bad public key size');
|
|
5933
|
-
var sm = new Uint8Array(crypto_sign_BYTES + msg.length);
|
|
5934
|
-
var m = new Uint8Array(crypto_sign_BYTES + msg.length);
|
|
5935
|
-
var i;
|
|
5936
|
-
for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];
|
|
5937
|
-
for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];
|
|
5938
|
-
return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);
|
|
5939
|
-
};
|
|
5940
|
-
|
|
5941
|
-
nacl.sign.keyPair = function() {
|
|
5942
|
-
var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
|
|
5943
|
-
var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
|
|
5944
|
-
crypto_sign_keypair(pk, sk);
|
|
5945
|
-
return {publicKey: pk, secretKey: sk};
|
|
5946
|
-
};
|
|
5947
|
-
|
|
5948
|
-
nacl.sign.keyPair.fromSecretKey = function(secretKey) {
|
|
5949
|
-
checkArrayTypes(secretKey);
|
|
5950
|
-
if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
|
|
5951
|
-
throw new Error('bad secret key size');
|
|
5952
|
-
var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
|
|
5953
|
-
for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];
|
|
5954
|
-
return {publicKey: pk, secretKey: new Uint8Array(secretKey)};
|
|
5955
|
-
};
|
|
5956
|
-
|
|
5957
|
-
nacl.sign.keyPair.fromSeed = function(seed) {
|
|
5958
|
-
checkArrayTypes(seed);
|
|
5959
|
-
if (seed.length !== crypto_sign_SEEDBYTES)
|
|
5960
|
-
throw new Error('bad seed size');
|
|
5961
|
-
var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
|
|
5962
|
-
var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
|
|
5963
|
-
for (var i = 0; i < 32; i++) sk[i] = seed[i];
|
|
5964
|
-
crypto_sign_keypair(pk, sk, true);
|
|
5965
|
-
return {publicKey: pk, secretKey: sk};
|
|
5966
|
-
};
|
|
5967
|
-
|
|
5968
|
-
nacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;
|
|
5969
|
-
nacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;
|
|
5970
|
-
nacl.sign.seedLength = crypto_sign_SEEDBYTES;
|
|
5971
|
-
nacl.sign.signatureLength = crypto_sign_BYTES;
|
|
5972
|
-
|
|
5973
|
-
nacl.hash = function(msg) {
|
|
5974
|
-
checkArrayTypes(msg);
|
|
5975
|
-
var h = new Uint8Array(crypto_hash_BYTES);
|
|
5976
|
-
crypto_hash(h, msg, msg.length);
|
|
5977
|
-
return h;
|
|
5978
|
-
};
|
|
5979
|
-
|
|
5980
|
-
nacl.hash.hashLength = crypto_hash_BYTES;
|
|
5981
|
-
|
|
5982
|
-
nacl.verify = function(x, y) {
|
|
5983
|
-
checkArrayTypes(x, y);
|
|
5984
|
-
// Zero length arguments are considered not equal.
|
|
5985
|
-
if (x.length === 0 || y.length === 0) return false;
|
|
5986
|
-
if (x.length !== y.length) return false;
|
|
5987
|
-
return (vn(x, 0, y, 0, x.length) === 0) ? true : false;
|
|
5988
|
-
};
|
|
5989
|
-
|
|
5990
|
-
nacl.setPRNG = function(fn) {
|
|
5991
|
-
randombytes = fn;
|
|
5992
|
-
};
|
|
5993
|
-
|
|
5994
|
-
(function() {
|
|
5995
|
-
// Initialize PRNG if environment provides CSPRNG.
|
|
5996
|
-
// If not, methods calling randombytes will throw.
|
|
5997
|
-
var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;
|
|
5998
|
-
if (crypto && crypto.getRandomValues) {
|
|
5999
|
-
// Browsers.
|
|
6000
|
-
var QUOTA = 65536;
|
|
6001
|
-
nacl.setPRNG(function(x, n) {
|
|
6002
|
-
var i, v = new Uint8Array(n);
|
|
6003
|
-
for (i = 0; i < n; i += QUOTA) {
|
|
6004
|
-
crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));
|
|
6005
|
-
}
|
|
6006
|
-
for (i = 0; i < n; i++) x[i] = v[i];
|
|
6007
|
-
cleanup(v);
|
|
6008
|
-
});
|
|
6009
|
-
} else if (typeof commonjsRequire !== 'undefined') {
|
|
6010
|
-
// Node.js.
|
|
6011
|
-
crypto = require$$0;
|
|
6012
|
-
if (crypto && crypto.randomBytes) {
|
|
6013
|
-
nacl.setPRNG(function(x, n) {
|
|
6014
|
-
var i, v = crypto.randomBytes(n);
|
|
6015
|
-
for (i = 0; i < n; i++) x[i] = v[i];
|
|
6016
|
-
cleanup(v);
|
|
6017
|
-
});
|
|
6018
|
-
}
|
|
6019
|
-
}
|
|
6020
|
-
})();
|
|
6021
|
-
|
|
6022
|
-
})(module.exports ? module.exports : (self.nacl = self.nacl || {}));
|
|
6023
|
-
} (naclFast));
|
|
6024
|
-
return naclFast.exports;
|
|
6025
|
-
}
|
|
6026
|
-
|
|
6027
|
-
var naclFastExports = requireNaclFast();
|
|
6028
|
-
var nacl = /*@__PURE__*/getDefaultExportFromCjs(naclFastExports);
|
|
6029
|
-
|
|
6030
3588
|
// guest-keystore.ts — durable per-device keypair for anonymous ("guest") auth.
|
|
6031
3589
|
//
|
|
6032
3590
|
// A guest is an ed25519 keypair generated on the device. Its public key is the
|
|
6033
3591
|
// Bounded account address; it signs the auth challenge exactly like a wallet.
|
|
6034
3592
|
//
|
|
6035
|
-
//
|
|
6036
|
-
//
|
|
6037
|
-
//
|
|
6038
|
-
//
|
|
6039
|
-
// 2. tweetnacl keypair in platform storage (React Native / older browsers) —
|
|
6040
|
-
// the secret is stored as bytes. Simpler, but exfiltratable by XSS, so
|
|
6041
|
-
// treat it as a low-stakes guest identity and tell users to upgrade
|
|
6042
|
-
// (link an email) before they care about not losing it.
|
|
3593
|
+
// Guest auth has one backend: WebCrypto Ed25519 + IndexedDB. The key is
|
|
3594
|
+
// NON-EXTRACTABLE: an XSS can ask it to sign but can never read the private
|
|
3595
|
+
// bytes. If WebCrypto or IndexedDB is unavailable, guest auth fails closed
|
|
3596
|
+
// instead of silently creating an extractable/stored-secret credential.
|
|
6043
3597
|
//
|
|
6044
|
-
//
|
|
3598
|
+
// The public output is a base58 address + a base64
|
|
6045
3599
|
// detached signature, which is the format the session endpoint already accepts.
|
|
6046
|
-
const
|
|
3600
|
+
const LEGACY_STORED_SECRET_KEY = 'bounded_guest_key_v1';
|
|
6047
3601
|
const IDB_NAME = 'bounded-guest';
|
|
6048
3602
|
const IDB_STORE = 'keys';
|
|
6049
3603
|
const IDB_KEY = 'ed25519';
|
|
3604
|
+
const GUEST_KEY_REQUIREMENT = 'Guest auth requires non-extractable WebCrypto Ed25519 keys persisted in IndexedDB; ' +
|
|
3605
|
+
'stored-secret guest credentials are disabled.';
|
|
6050
3606
|
function toBase64(bytes) {
|
|
6051
3607
|
let bin = '';
|
|
6052
3608
|
for (let i = 0; i < bytes.length; i++)
|
|
@@ -6081,10 +3637,17 @@ function idbPut(db, key, val) {
|
|
|
6081
3637
|
r.onerror = () => reject(r.error);
|
|
6082
3638
|
});
|
|
6083
3639
|
}
|
|
6084
|
-
|
|
3640
|
+
function guestKeyUnavailable(cause) {
|
|
3641
|
+
const detail = cause instanceof Error && cause.message ? ` Cause: ${cause.message}` : '';
|
|
3642
|
+
return new Error(`${GUEST_KEY_REQUIREMENT}${detail}`);
|
|
3643
|
+
}
|
|
3644
|
+
async function webCryptoKey() {
|
|
6085
3645
|
const s = subtle();
|
|
6086
|
-
if (!s
|
|
6087
|
-
|
|
3646
|
+
if (!s)
|
|
3647
|
+
throw guestKeyUnavailable(new Error('WebCrypto subtle crypto is unavailable.'));
|
|
3648
|
+
if (typeof globalThis.indexedDB === 'undefined') {
|
|
3649
|
+
throw guestKeyUnavailable(new Error('IndexedDB is unavailable.'));
|
|
3650
|
+
}
|
|
6088
3651
|
try {
|
|
6089
3652
|
const db = await idb();
|
|
6090
3653
|
let pair = (await idbGet(db, IDB_KEY));
|
|
@@ -6108,49 +3671,23 @@ async function tryWebCrypto() {
|
|
|
6108
3671
|
},
|
|
6109
3672
|
};
|
|
6110
3673
|
}
|
|
6111
|
-
catch (
|
|
6112
|
-
|
|
3674
|
+
catch (error) {
|
|
3675
|
+
throw guestKeyUnavailable(error);
|
|
6113
3676
|
}
|
|
6114
3677
|
}
|
|
6115
|
-
// ----- tweetnacl (stored-secret) fallback ------------------------------------
|
|
6116
|
-
function fallbackKey() {
|
|
6117
|
-
const store = getPlatform().storage;
|
|
6118
|
-
let secret;
|
|
6119
|
-
const saved = store.getItem(FALLBACK_STORE_KEY);
|
|
6120
|
-
if (saved) {
|
|
6121
|
-
secret = bs58.decode(saved);
|
|
6122
|
-
}
|
|
6123
|
-
else {
|
|
6124
|
-
const kp = web3_js.Keypair.generate();
|
|
6125
|
-
secret = kp.secretKey; // 64 bytes
|
|
6126
|
-
store.setItem(FALLBACK_STORE_KEY, bs58.encode(secret));
|
|
6127
|
-
}
|
|
6128
|
-
const kp = web3_js.Keypair.fromSecretKey(secret);
|
|
6129
|
-
const address = kp.publicKey.toBase58();
|
|
6130
|
-
return {
|
|
6131
|
-
address,
|
|
6132
|
-
nonExtractable: false,
|
|
6133
|
-
async sign(message) {
|
|
6134
|
-
const data = new TextEncoder().encode(message);
|
|
6135
|
-
const sig = nacl.sign.detached(data, secret);
|
|
6136
|
-
return toBase64(sig);
|
|
6137
|
-
},
|
|
6138
|
-
};
|
|
6139
|
-
}
|
|
6140
3678
|
let cached = null;
|
|
6141
3679
|
/** Get (or create) this device's durable guest key. */
|
|
6142
3680
|
async function getGuestKey() {
|
|
6143
|
-
var _a;
|
|
6144
3681
|
if (cached)
|
|
6145
3682
|
return cached;
|
|
6146
|
-
cached =
|
|
3683
|
+
cached = await webCryptoKey();
|
|
6147
3684
|
return cached;
|
|
6148
3685
|
}
|
|
6149
3686
|
/** Forget the guest key on this device (a fresh signInAnonymously mints a new one). */
|
|
6150
3687
|
async function clearGuestKey() {
|
|
6151
3688
|
cached = null;
|
|
6152
3689
|
try {
|
|
6153
|
-
getPlatform().storage.removeItem(
|
|
3690
|
+
getPlatform().storage.removeItem(LEGACY_STORED_SECRET_KEY);
|
|
6154
3691
|
}
|
|
6155
3692
|
catch (_a) { }
|
|
6156
3693
|
try {
|
|
@@ -6692,6 +4229,50 @@ const MODAL_CSS = `
|
|
|
6692
4229
|
#bounded-auth-modal .hidden{display:none;}
|
|
6693
4230
|
@media (max-width:480px){#bounded-auth-modal .ba-card{max-width:none;border-radius:16px;}}`;
|
|
6694
4231
|
|
|
4232
|
+
const SURFNET_RPC_URL = "https://surfpool.fly.dev";
|
|
4233
|
+
const SUPPORTED_SOLANA_NETWORKS = new Set([
|
|
4234
|
+
"solana_devnet",
|
|
4235
|
+
"solana_mainnet",
|
|
4236
|
+
"surfnet",
|
|
4237
|
+
]);
|
|
4238
|
+
function normalizeSolanaRpcUrl(rpcUrl) {
|
|
4239
|
+
if (typeof rpcUrl !== "string")
|
|
4240
|
+
return null;
|
|
4241
|
+
const trimmed = rpcUrl.trim();
|
|
4242
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
4243
|
+
}
|
|
4244
|
+
function isSupportedSolanaRpcNetwork(network) {
|
|
4245
|
+
return typeof network === "string" && SUPPORTED_SOLANA_NETWORKS.has(network);
|
|
4246
|
+
}
|
|
4247
|
+
function resolveSolanaWalletStandardChain(network, context) {
|
|
4248
|
+
switch (network) {
|
|
4249
|
+
case "solana_devnet":
|
|
4250
|
+
return "solana:devnet";
|
|
4251
|
+
case "solana_mainnet":
|
|
4252
|
+
return "solana:mainnet";
|
|
4253
|
+
case "surfnet":
|
|
4254
|
+
return "solana:localnet";
|
|
4255
|
+
case undefined:
|
|
4256
|
+
case null:
|
|
4257
|
+
case "":
|
|
4258
|
+
throw new Error(`${context} requires an explicit Solana network. ` +
|
|
4259
|
+
`Provide one of: solana_devnet, solana_mainnet, surfnet.`);
|
|
4260
|
+
default:
|
|
4261
|
+
throw new Error(`${context} does not support Solana network "${network}". ` +
|
|
4262
|
+
`Expected one of: solana_devnet, solana_mainnet, surfnet.`);
|
|
4263
|
+
}
|
|
4264
|
+
}
|
|
4265
|
+
function resolveSolanaRpcUrl(explicitRpcUrl, network, context) {
|
|
4266
|
+
if (network != null && network !== "" && !isSupportedSolanaRpcNetwork(network)) {
|
|
4267
|
+
throw new Error(`${context} does not support Solana network "${network}". ` +
|
|
4268
|
+
`Expected one of: solana_devnet, solana_mainnet, surfnet.`);
|
|
4269
|
+
}
|
|
4270
|
+
const rpcUrl = normalizeSolanaRpcUrl(explicitRpcUrl);
|
|
4271
|
+
if (rpcUrl)
|
|
4272
|
+
return rpcUrl;
|
|
4273
|
+
throw new Error(`${context} requires an explicit Solana RPC URL. Pass config.rpcUrl before signing or submitting onchain transactions.`);
|
|
4274
|
+
}
|
|
4275
|
+
|
|
6695
4276
|
const PKCE_STORE_KEY = 'bounded.oidc.pkce';
|
|
6696
4277
|
// Active session store (Web on web, RN on React Native) — selected by config,
|
|
6697
4278
|
// not by `typeof window` (truthy on RN). OIDC redirect/popup is web-only, but the
|
|
@@ -6998,7 +4579,7 @@ async function exchangeCode(code, verifier, redirectUri) {
|
|
|
6998
4579
|
let currentAuthProvider = null;
|
|
6999
4580
|
let currentAuthMethod = null;
|
|
7000
4581
|
let initConfig = null;
|
|
7001
|
-
// --- localStorage helpers: track which auth method the
|
|
4582
|
+
// --- localStorage helpers: track which auth method created the active session ---
|
|
7002
4583
|
const STORED_AUTH_METHOD_KEY = 'bounded_last_auth_method';
|
|
7003
4584
|
function getStoredAuthMethod() {
|
|
7004
4585
|
try {
|
|
@@ -7022,7 +4603,7 @@ function setStoredAuthMethod(method) {
|
|
|
7022
4603
|
}
|
|
7023
4604
|
}
|
|
7024
4605
|
/**
|
|
7025
|
-
* Clears the session if it was created
|
|
4606
|
+
* Clears the session if it was created by a different auth method.
|
|
7026
4607
|
* Returns true if the session was cleared, false if the session is compatible.
|
|
7027
4608
|
*
|
|
7028
4609
|
* Dispatches to the correct session manager based on the current auth method
|
|
@@ -7030,47 +4611,128 @@ function setStoredAuthMethod(method) {
|
|
|
7030
4611
|
* are properly cleared.
|
|
7031
4612
|
*/
|
|
7032
4613
|
function clearIncompatibleSession() {
|
|
7033
|
-
if (getStoredAuthMethod()
|
|
7034
|
-
return false;
|
|
4614
|
+
if (getStoredAuthMethod() === currentAuthMethod) {
|
|
4615
|
+
return false;
|
|
7035
4616
|
}
|
|
7036
|
-
//
|
|
7037
|
-
//
|
|
7038
|
-
// Clear both managers — on web the RN manager is a no-op (not configured),
|
|
7039
|
-
// on RN the web manager is a no-op (no localStorage).
|
|
4617
|
+
// Clear both managers: on web the RN manager is a no-op (not configured),
|
|
4618
|
+
// and on RN the web manager is a no-op (no localStorage).
|
|
7040
4619
|
core.WebSessionManager.clearSession();
|
|
7041
4620
|
try {
|
|
7042
4621
|
core.ReactNativeSessionManager.clearSession();
|
|
7043
4622
|
}
|
|
7044
4623
|
catch ( /* not configured on web */_a) { /* not configured on web */ }
|
|
4624
|
+
setStoredAuthMethod(null);
|
|
7045
4625
|
return true;
|
|
7046
4626
|
}
|
|
7047
4627
|
// Lazy loaders for web-only providers.
|
|
7048
4628
|
// Using dynamic import() ensures Metro (RN) never resolves these modules.
|
|
7049
4629
|
async function loadPhantomWalletProvider() {
|
|
7050
|
-
const mod = await Promise.resolve().then(function () { return require('./phantom-wallet-provider-
|
|
4630
|
+
const mod = await Promise.resolve().then(function () { return require('./phantom-wallet-provider-fyOrJZP6.js'); });
|
|
7051
4631
|
return { PhantomWalletProvider: mod.PhantomWalletProvider };
|
|
7052
4632
|
}
|
|
7053
4633
|
// Web Privy provider (depends on react-dom + @privy-io/react-auth). Lazy so Metro
|
|
7054
4634
|
// never bundles it into the RN build — RN uses the @privy-io/expo provider instead.
|
|
7055
4635
|
async function loadPrivyWalletProvider() {
|
|
7056
|
-
const mod = await Promise.resolve().then(function () { return require('./privy-wallet-provider-
|
|
4636
|
+
const mod = await Promise.resolve().then(function () { return require('./privy-wallet-provider-BIr9lDS7.js'); });
|
|
7057
4637
|
return mod.PrivyWalletProvider;
|
|
7058
4638
|
}
|
|
7059
4639
|
async function loadSolanaMobileWalletProvider() {
|
|
7060
|
-
const mod = await Promise.resolve().then(function () { return require('./solana-mobile-wallet-provider-
|
|
4640
|
+
const mod = await Promise.resolve().then(function () { return require('./solana-mobile-wallet-provider-Cush-URL.js'); });
|
|
7061
4641
|
return mod.SolanaMobileWalletProvider;
|
|
7062
4642
|
}
|
|
4643
|
+
function requireWebPrivyConfig(config) {
|
|
4644
|
+
if (!config.privyConfig || typeof config.privyConfig.appId !== 'string' || config.privyConfig.appId.trim() === '') {
|
|
4645
|
+
throw new Error('Privy auth requires config.privyConfig.appId; no default Privy app is used.');
|
|
4646
|
+
}
|
|
4647
|
+
if (!config.privyConfig.config || typeof config.privyConfig.config !== 'object') {
|
|
4648
|
+
throw new Error('Privy auth requires config.privyConfig.config for the app-scoped Privy provider.');
|
|
4649
|
+
}
|
|
4650
|
+
return config.privyConfig;
|
|
4651
|
+
}
|
|
4652
|
+
function getConfiguredSolanaNetwork(config) {
|
|
4653
|
+
if (typeof config.chain !== 'string')
|
|
4654
|
+
return null;
|
|
4655
|
+
const chain = config.chain.trim();
|
|
4656
|
+
if (chain === '' || chain === 'offchain')
|
|
4657
|
+
return null;
|
|
4658
|
+
return chain;
|
|
4659
|
+
}
|
|
4660
|
+
function mobileWalletClusterFromNetwork(network) {
|
|
4661
|
+
switch (network) {
|
|
4662
|
+
case "solana_devnet":
|
|
4663
|
+
return "devnet";
|
|
4664
|
+
case "solana_mainnet":
|
|
4665
|
+
return "mainnet-beta";
|
|
4666
|
+
case "surfnet":
|
|
4667
|
+
return "localnet";
|
|
4668
|
+
case null:
|
|
4669
|
+
return null;
|
|
4670
|
+
default:
|
|
4671
|
+
resolveSolanaWalletStandardChain(network, "Mobile wallet auth");
|
|
4672
|
+
return null;
|
|
4673
|
+
}
|
|
4674
|
+
}
|
|
4675
|
+
function requireMobileWalletConfig(config) {
|
|
4676
|
+
var _a, _b, _c;
|
|
4677
|
+
const configuredNetwork = getConfiguredSolanaNetwork(config);
|
|
4678
|
+
const cluster = (_b = (_a = config.mobileWalletConfig) === null || _a === void 0 ? void 0 : _a.cluster) !== null && _b !== void 0 ? _b : mobileWalletClusterFromNetwork(configuredNetwork);
|
|
4679
|
+
if (!cluster) {
|
|
4680
|
+
throw new Error("Mobile wallet auth requires an explicit Solana network. " +
|
|
4681
|
+
"Pass config.chain as solana_devnet, solana_mainnet, or surfnet, " +
|
|
4682
|
+
"or pass mobileWalletConfig.cluster.");
|
|
4683
|
+
}
|
|
4684
|
+
return Object.assign(Object.assign({}, ((_c = config.mobileWalletConfig) !== null && _c !== void 0 ? _c : {})), { cluster });
|
|
4685
|
+
}
|
|
4686
|
+
function isLocalOrTestUrl(value) {
|
|
4687
|
+
if (!value)
|
|
4688
|
+
return false;
|
|
4689
|
+
try {
|
|
4690
|
+
const hostname = new URL(value).hostname.toLowerCase();
|
|
4691
|
+
return hostname === 'localhost' ||
|
|
4692
|
+
hostname === '127.0.0.1' ||
|
|
4693
|
+
hostname === '::1' ||
|
|
4694
|
+
hostname.endsWith('.localhost') ||
|
|
4695
|
+
hostname.endsWith('.test');
|
|
4696
|
+
}
|
|
4697
|
+
catch (_a) {
|
|
4698
|
+
return false;
|
|
4699
|
+
}
|
|
4700
|
+
}
|
|
4701
|
+
function assertMockAuthLocalOnly(config) {
|
|
4702
|
+
const requiredEndpoints = [
|
|
4703
|
+
config.apiUrl,
|
|
4704
|
+
config.wsApiUrl,
|
|
4705
|
+
config.authApiUrl,
|
|
4706
|
+
];
|
|
4707
|
+
const optionalEndpoints = [
|
|
4708
|
+
config.rpcUrl,
|
|
4709
|
+
config.humanAuthApiUrl,
|
|
4710
|
+
config.functionsUrl,
|
|
4711
|
+
].filter((value) => typeof value === 'string' && value.trim() !== '');
|
|
4712
|
+
if (requiredEndpoints.every(isLocalOrTestUrl) && optionalEndpoints.every(isLocalOrTestUrl)) {
|
|
4713
|
+
return;
|
|
4714
|
+
}
|
|
4715
|
+
throw new Error("mockAuth is local/test-only. Pass explicit localhost/.test apiUrl, wsApiUrl, and authApiUrl values; " +
|
|
4716
|
+
"mockAuth cannot be used with Bounded production or staging endpoints.");
|
|
4717
|
+
}
|
|
7063
4718
|
async function hotSwapToMWAProvider(config) {
|
|
7064
|
-
var _a
|
|
7065
|
-
const rpcUrl = (
|
|
4719
|
+
var _a;
|
|
4720
|
+
const rpcUrl = normalizeSolanaRpcUrl(config.rpcUrl);
|
|
4721
|
+
const configuredNetwork = getConfiguredSolanaNetwork(config);
|
|
7066
4722
|
const SolanaMobileWalletProvider = await loadSolanaMobileWalletProvider();
|
|
7067
|
-
const mwaConfig =
|
|
7068
|
-
|
|
7069
|
-
|
|
7070
|
-
|
|
7071
|
-
|
|
7072
|
-
|
|
7073
|
-
|
|
4723
|
+
const mwaConfig = config.mobileWalletConfig
|
|
4724
|
+
? requireMobileWalletConfig(config)
|
|
4725
|
+
: {
|
|
4726
|
+
appIdentity: {
|
|
4727
|
+
name: config.name || undefined,
|
|
4728
|
+
uri: getPlatform().getLocationOrigin(),
|
|
4729
|
+
},
|
|
4730
|
+
cluster: (_a = mobileWalletClusterFromNetwork(configuredNetwork)) !== null && _a !== void 0 ? _a : undefined,
|
|
4731
|
+
};
|
|
4732
|
+
if (!mwaConfig.cluster) {
|
|
4733
|
+
throw new Error("Mobile wallet auth requires config.chain or mobileWalletConfig.cluster before switching providers.");
|
|
4734
|
+
}
|
|
4735
|
+
const mwaProvider = new SolanaMobileWalletProvider(rpcUrl, mwaConfig, configuredNetwork);
|
|
7074
4736
|
let provider = mwaProvider;
|
|
7075
4737
|
if (config.chain === "offchain") {
|
|
7076
4738
|
provider = new OffchainAuthProvider(mwaProvider);
|
|
@@ -7085,11 +4747,8 @@ async function hotSwapToMWAProvider(config) {
|
|
|
7085
4747
|
setAuthProviderInstance(provider);
|
|
7086
4748
|
return provider;
|
|
7087
4749
|
}
|
|
7088
|
-
const SOLANA_DEVNET_RPC_URL = "https://idelle-8nxsep-fast-devnet.helius-rpc.com";
|
|
7089
|
-
const SOLANA_MAINNET_RPC_URL = "https://celestia-cegncv-fast-mainnet.helius-rpc.com";
|
|
7090
|
-
const SURFNET_RPC_URL$1 = "https://surfpool.fly.dev";
|
|
7091
4750
|
async function getAuthProvider(config) {
|
|
7092
|
-
var _a, _b
|
|
4751
|
+
var _a, _b;
|
|
7093
4752
|
if (currentAuthProvider) {
|
|
7094
4753
|
return currentAuthProvider;
|
|
7095
4754
|
}
|
|
@@ -7099,21 +4758,17 @@ async function getAuthProvider(config) {
|
|
|
7099
4758
|
initConfig = config;
|
|
7100
4759
|
// If mockAuth is enabled, use MockAuthProvider regardless of authMethod
|
|
7101
4760
|
if (config.mockAuth) {
|
|
4761
|
+
assertMockAuthLocalOnly(config);
|
|
7102
4762
|
console.log("[MockAuth] Mock authentication enabled");
|
|
7103
4763
|
currentAuthProvider = new MockAuthProvider();
|
|
7104
4764
|
return currentAuthProvider;
|
|
7105
4765
|
}
|
|
7106
|
-
|
|
7107
|
-
|
|
7108
|
-
|
|
7109
|
-
|
|
7110
|
-
|
|
7111
|
-
|
|
7112
|
-
if (storedMethod && !validAuthMethods.includes(storedMethod)) {
|
|
7113
|
-
// Invalid stored value — clear it
|
|
7114
|
-
setStoredAuthMethod(null);
|
|
7115
|
-
}
|
|
7116
|
-
const rpcUrl = (_a = config.rpcUrl) !== null && _a !== void 0 ? _a : null;
|
|
4766
|
+
const authMethod = config.authMethod;
|
|
4767
|
+
if (!authMethod) {
|
|
4768
|
+
throw new Error("authMethod is required to initialize auth provider; configure the single intended auth method explicitly.");
|
|
4769
|
+
}
|
|
4770
|
+
const rpcUrl = normalizeSolanaRpcUrl(config.rpcUrl);
|
|
4771
|
+
const configuredNetwork = getConfiguredSolanaNetwork(config);
|
|
7117
4772
|
currentAuthMethod = authMethod;
|
|
7118
4773
|
// Clear, actionable error when the BROWSER build (`bounded-sh`) is loaded in a
|
|
7119
4774
|
// non-browser (Node) runtime. The wallet providers below need `window`; without
|
|
@@ -7125,8 +4780,8 @@ async function getAuthProvider(config) {
|
|
|
7125
4780
|
if (typeof window === 'undefined' && browserWalletMethods.includes(authMethod)) {
|
|
7126
4781
|
throw new Error(`bounded-sh: '${authMethod}' auth requires a browser, but no \`window\` was found ` +
|
|
7127
4782
|
`(you're likely running in Node). In server/Node code, import from 'bounded-sh/server' ` +
|
|
7128
|
-
`instead of 'bounded-sh' — it signs with
|
|
7129
|
-
`
|
|
4783
|
+
`instead of 'bounded-sh' — it signs with an explicit keypair passed to createWalletClient({ keypair }) ` +
|
|
4784
|
+
`and needs no browser.`);
|
|
7130
4785
|
}
|
|
7131
4786
|
switch (authMethod) {
|
|
7132
4787
|
case "email":
|
|
@@ -7143,7 +4798,7 @@ async function getAuthProvider(config) {
|
|
|
7143
4798
|
break;
|
|
7144
4799
|
case "phantom": {
|
|
7145
4800
|
const { PhantomWalletProvider } = await loadPhantomWalletProvider();
|
|
7146
|
-
currentAuthProvider = new PhantomWalletProvider(rpcUrl, config.phantomConfig);
|
|
4801
|
+
currentAuthProvider = new PhantomWalletProvider(rpcUrl, config.phantomConfig, configuredNetwork);
|
|
7147
4802
|
// MWA hot-swap is always available (custom modal shows MWA button on Android)
|
|
7148
4803
|
currentAuthProvider.onSwitchToMWA =
|
|
7149
4804
|
() => hotSwapToMWAProvider(config);
|
|
@@ -7153,8 +4808,9 @@ async function getAuthProvider(config) {
|
|
|
7153
4808
|
// Web Privy: a co-equal login route alongside email/phantom/guest. The
|
|
7154
4809
|
// Privy embedded/external Solana wallet signs the SIWS challenge, so the
|
|
7155
4810
|
// session is minted through the same wallet path as Phantom.
|
|
4811
|
+
const privyConfig = requireWebPrivyConfig(config);
|
|
7156
4812
|
const PrivyWalletProvider = await loadPrivyWalletProvider();
|
|
7157
|
-
currentAuthProvider = new PrivyWalletProvider((
|
|
4813
|
+
currentAuthProvider = new PrivyWalletProvider((_a = config.name) !== null && _a !== void 0 ? _a : null, (_b = config.logoUrl) !== null && _b !== void 0 ? _b : null, privyConfig, rpcUrl, configuredNetwork);
|
|
7158
4814
|
break;
|
|
7159
4815
|
}
|
|
7160
4816
|
case "privy-expo":
|
|
@@ -7169,7 +4825,7 @@ async function getAuthProvider(config) {
|
|
|
7169
4825
|
break;
|
|
7170
4826
|
case "mobile-wallet-adapter": {
|
|
7171
4827
|
const SolanaMobileWalletProvider = await loadSolanaMobileWalletProvider();
|
|
7172
|
-
currentAuthProvider = new SolanaMobileWalletProvider(rpcUrl, config
|
|
4828
|
+
currentAuthProvider = new SolanaMobileWalletProvider(rpcUrl, requireMobileWalletConfig(config), configuredNetwork);
|
|
7173
4829
|
break;
|
|
7174
4830
|
}
|
|
7175
4831
|
case "onboard":
|
|
@@ -7202,7 +4858,7 @@ function assertBrowserAuthEnv(method) {
|
|
|
7202
4858
|
throw new Error(`bounded-sh: '${method}' is a browser/React-Native auth flow — it needs \`window\`/\`localStorage\` ` +
|
|
7203
4859
|
`to persist the session, which Node doesn't have (the session would be silently dropped, then every ` +
|
|
7204
4860
|
`request 403s). In Node/server code import from 'bounded-sh/server' and sign with a keypair ` +
|
|
7205
|
-
`
|
|
4861
|
+
`by using createWalletClient({ keypair }).`);
|
|
7206
4862
|
}
|
|
7207
4863
|
}
|
|
7208
4864
|
/**
|
|
@@ -7239,13 +4895,14 @@ async function signInAnonymously() {
|
|
|
7239
4895
|
* (web localStorage / RN storage) and identity model. `init()` must have run first.
|
|
7240
4896
|
*/
|
|
7241
4897
|
async function loginWithPrivy(options) {
|
|
7242
|
-
var _a, _b
|
|
4898
|
+
var _a, _b;
|
|
7243
4899
|
assertBrowserAuthEnv('loginWithPrivy');
|
|
7244
4900
|
const coreConfig = await core.getConfig();
|
|
7245
4901
|
let provider;
|
|
7246
4902
|
if (getPlatform().hasDOM) {
|
|
4903
|
+
const privyConfig = requireWebPrivyConfig(coreConfig);
|
|
7247
4904
|
const PrivyWalletProvider = await loadPrivyWalletProvider();
|
|
7248
|
-
provider = new PrivyWalletProvider((_a = coreConfig.name) !== null && _a !== void 0 ? _a : null, (_b = coreConfig.logoUrl) !== null && _b !== void 0 ? _b : null,
|
|
4905
|
+
provider = new PrivyWalletProvider((_a = coreConfig.name) !== null && _a !== void 0 ? _a : null, (_b = coreConfig.logoUrl) !== null && _b !== void 0 ? _b : null, privyConfig, normalizeSolanaRpcUrl(coreConfig.rpcUrl), getConfiguredSolanaNetwork(coreConfig));
|
|
7249
4906
|
currentAuthMethod = 'privy';
|
|
7250
4907
|
}
|
|
7251
4908
|
else {
|
|
@@ -7391,15 +5048,13 @@ async function logout$1() {
|
|
|
7391
5048
|
throw new Error("Auth provider not initialized. Please call init() first.");
|
|
7392
5049
|
}
|
|
7393
5050
|
// Revoke the refresh-token family server-side BEFORE the provider clears the
|
|
7394
|
-
// local session (so we still have the token + issuer to revoke).
|
|
7395
|
-
//
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
}
|
|
7402
|
-
catch ( /* proceed with local logout regardless */_b) { /* proceed with local logout regardless */ }
|
|
5051
|
+
// local session (so we still have the token + issuer to revoke). If revoke
|
|
5052
|
+
// fails, surface the error and leave local state intact so callers do not
|
|
5053
|
+
// mistake a local-only logout for server revocation.
|
|
5054
|
+
const sm = core.getActiveSessionManager();
|
|
5055
|
+
const refreshToken = sm.getRefreshToken();
|
|
5056
|
+
if (refreshToken)
|
|
5057
|
+
await core.revokeSession(refreshToken, (_a = sm.getIssuer()) !== null && _a !== void 0 ? _a : undefined);
|
|
7403
5058
|
await currentAuthProvider.logout();
|
|
7404
5059
|
setStoredAuthMethod(null);
|
|
7405
5060
|
currentAuthProvider = null;
|
|
@@ -7730,7 +5385,6 @@ async function confirmAndCheckTransaction(connection, signature) {
|
|
|
7730
5385
|
* to host Privy's React context, this provider expects the RN app itself
|
|
7731
5386
|
* to render <PrivyProvider> and then bridge the hooks via setPrivyMethods().
|
|
7732
5387
|
*/
|
|
7733
|
-
const SURFNET_RPC_URL = 'https://surfpool.fly.dev';
|
|
7734
5388
|
// -----------------------------------------------------------------------
|
|
7735
5389
|
// Provider implementation
|
|
7736
5390
|
// -----------------------------------------------------------------------
|
|
@@ -7738,7 +5392,7 @@ class PrivyExpoProvider {
|
|
|
7738
5392
|
constructor(appId, networkUrl = null) {
|
|
7739
5393
|
this.privyMethods = null;
|
|
7740
5394
|
this.appId = appId;
|
|
7741
|
-
this.networkUrl = networkUrl;
|
|
5395
|
+
this.networkUrl = normalizeSolanaRpcUrl(networkUrl);
|
|
7742
5396
|
}
|
|
7743
5397
|
/**
|
|
7744
5398
|
* Bridge Privy hooks from the app's React tree into this provider.
|
|
@@ -8023,15 +5677,7 @@ class PrivyExpoProvider {
|
|
|
8023
5677
|
return { signature, txInfo };
|
|
8024
5678
|
}
|
|
8025
5679
|
getRpcUrl(network) {
|
|
8026
|
-
|
|
8027
|
-
return this.networkUrl;
|
|
8028
|
-
if (network === 'solana_devnet')
|
|
8029
|
-
return SOLANA_DEVNET_RPC_URL;
|
|
8030
|
-
if (network === 'solana_mainnet')
|
|
8031
|
-
return SOLANA_MAINNET_RPC_URL;
|
|
8032
|
-
if (network === 'surfnet')
|
|
8033
|
-
return SURFNET_RPC_URL;
|
|
8034
|
-
return SOLANA_MAINNET_RPC_URL;
|
|
5680
|
+
return resolveSolanaRpcUrl(this.networkUrl, network, "Privy Expo Solana transaction");
|
|
8035
5681
|
}
|
|
8036
5682
|
async ensureReady(timeoutMs = 15000) {
|
|
8037
5683
|
if (!this.privyMethods) {
|
|
@@ -8063,9 +5709,7 @@ exports.DEFAULT_TEST_ADDRESS = DEFAULT_TEST_ADDRESS;
|
|
|
8063
5709
|
exports.MockAuthProvider = MockAuthProvider;
|
|
8064
5710
|
exports.OffchainAuthProvider = OffchainAuthProvider;
|
|
8065
5711
|
exports.PrivyExpoProvider = PrivyExpoProvider;
|
|
8066
|
-
exports.
|
|
8067
|
-
exports.SOLANA_MAINNET_RPC_URL = SOLANA_MAINNET_RPC_URL;
|
|
8068
|
-
exports.SURFNET_RPC_URL = SURFNET_RPC_URL$1;
|
|
5712
|
+
exports.SURFNET_RPC_URL = SURFNET_RPC_URL;
|
|
8069
5713
|
exports.bs58 = bs58;
|
|
8070
5714
|
exports.bufferExports = bufferExports;
|
|
8071
5715
|
exports.completeLoginFromRedirect = completeLoginFromRedirect;
|
|
@@ -8088,8 +5732,11 @@ exports.loginWithPopup = loginWithPopup;
|
|
|
8088
5732
|
exports.loginWithPrivy = loginWithPrivy;
|
|
8089
5733
|
exports.loginWithRedirect = loginWithRedirect;
|
|
8090
5734
|
exports.logout = logout;
|
|
5735
|
+
exports.normalizeSolanaRpcUrl = normalizeSolanaRpcUrl;
|
|
8091
5736
|
exports.onAuthLoadingChanged = onAuthLoadingChanged;
|
|
8092
5737
|
exports.onAuthStateChanged = onAuthStateChanged;
|
|
5738
|
+
exports.resolveSolanaRpcUrl = resolveSolanaRpcUrl;
|
|
5739
|
+
exports.resolveSolanaWalletStandardChain = resolveSolanaWalletStandardChain;
|
|
8093
5740
|
exports.sendEmailOtp = sendEmailOtp;
|
|
8094
5741
|
exports.sendTextOtp = sendTextOtp;
|
|
8095
5742
|
exports.setAuthLoading = setAuthLoading;
|
|
@@ -8099,4 +5746,4 @@ exports.signInAnonymously = signInAnonymously;
|
|
|
8099
5746
|
exports.useAuth = useAuth;
|
|
8100
5747
|
exports.verifyEmailOtp = verifyEmailOtp;
|
|
8101
5748
|
exports.verifyTextOtp = verifyTextOtp;
|
|
8102
|
-
//# sourceMappingURL=index.native-
|
|
5749
|
+
//# sourceMappingURL=index.native-DI_Xgv-n.js.map
|