nolo-cli 0.9.1 → 0.11.0
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 +1 -1
- package/{_executeModel-UD44KGZ4.js → _executeModel-ZEDPX6OF.js} +50 -48
- package/{action-ZJWE3Y5S.js → action-AA4IJ5K2.js} +11 -11
- package/{addContentAction-TVDBNJM5.js → addContentAction-QYVO4SYP.js} +10 -10
- package/{addDialogAgentAction-EKH774VT.js → addDialogAgentAction-WVVKT5WQ.js} +12 -12
- package/{agentDeleteCommand-TCPEFJTF.js → agentDeleteCommand-RDPGYIWF.js} +25 -25
- package/{agentEmailCommands-CZ3UILZ4.js → agentEmailCommands-2HJJKS5F.js} +62 -59
- package/{agentListCommands-SJKO2FFB.js → agentListCommands-HFEVV3ZW.js} +30 -29
- package/{agentMachineCommands-PSNABISZ.js → agentMachineCommands-25ZOENJU.js} +29 -29
- package/{agentRecordCommands-MH2JKFHS.js → agentRecordCommands-GTCOAM3L.js} +53 -50
- package/{agentRunCommand-4KH6MIZR.js → agentRunCommand-YBS3JDLD.js} +62 -56
- package/{agentRuntimeLocal-SKHJUWSS.js → agentRuntimeLocal-UQBMQI2M.js} +12 -12
- package/{agentSlice-3WXXN4VK.js → agentSlice-6EKOBCCS.js} +11 -11
- package/{authCommand-PXFX6JDT.js → authCommand-O2OWACN4.js} +12 -12
- package/{authCommands-356AYWEK.js → authCommands-H7365TZP.js} +6 -6
- package/{chunk-MKMWT7SA.js → chunk-2W2VYVI5.js} +336 -92
- package/{chunk-TSS3XJY4.js → chunk-3NSIQZZ6.js} +5 -5
- package/{chunk-AUQ747NZ.js → chunk-4SOKXIW4.js} +70 -6
- package/{chunk-ZIG5LJ7X.js → chunk-5MOUAAMK.js} +106 -2342
- package/{chunk-6GANEXVO.js → chunk-5OIFWVX7.js} +1 -1
- package/{chunk-MGOJ5R6J.js → chunk-7D3JY6C2.js} +2 -2
- package/{chunk-7OOXPE3N.js → chunk-AEZAORLG.js} +4 -4
- package/chunk-AFON4QUU.js +112 -0
- package/{chunk-YBWOP46I.js → chunk-BX6U3ETE.js} +20 -13
- package/{chunk-2PUGVR6E.js → chunk-C2MDQQ4O.js} +1 -1
- package/{chunk-SL35K7AH.js → chunk-C4FTUXVF.js} +2 -82
- package/{chunk-GAKEBQD6.js → chunk-D6OQHXVG.js} +11 -7
- package/{chunk-WKM6FH35.js → chunk-DWGAEFJL.js} +1 -1
- package/{chunk-PG5PNA7Y.js → chunk-E4HNJSHC.js} +20 -20
- package/{chunk-SBR32ZZS.js → chunk-EVZKZF32.js} +73 -40
- package/{chunk-C3RUNRHT.js → chunk-FXXSGWAJ.js} +1 -1
- package/{chunk-KTVVPRJS.js → chunk-GBDSZATH.js} +4 -4
- package/{chunk-3TZDXYSF.js → chunk-HNW7IJSK.js} +1 -1
- package/{chunk-2EISRLRC.js → chunk-IPYUUY4E.js} +2 -2
- package/{chunk-2K2ECKSG.js → chunk-KJR5KAUQ.js} +2 -2
- package/{chunk-XE635NI4.js → chunk-KQQVGRA3.js} +24 -24
- package/{chunk-AVMKZHBC.js → chunk-L53FGHA4.js} +3 -2
- package/{chunk-GG4AJPSR.js → chunk-LAX2JSTX.js} +2 -2
- package/{chunk-5PJ3VWCS.js → chunk-LP65VRCI.js} +7 -13
- package/chunk-LTRXGFMS.js +83 -0
- package/{chunk-63SLEOLK.js → chunk-MQI77IRB.js} +4 -4
- package/{chunk-PCWC3JTN.js → chunk-MTU75CZ2.js} +1 -1
- package/{chunk-3WYQEUBI.js → chunk-NEM67FX7.js} +1 -1
- package/{chunk-COMXDWNM.js → chunk-O26GI2JP.js} +10 -10
- package/{chunk-SH2CFQOH.js → chunk-O4BU24WZ.js} +2 -181
- package/{chunk-EYEEHCU4.js → chunk-OOM6SJNR.js} +10 -10
- package/chunk-OOSFSFMA.js +271 -0
- package/{chunk-PAKN26FP.js → chunk-OUI3ZHYD.js} +1 -1
- package/{chunk-EXTIQUCI.js → chunk-PNEW2Z3T.js} +9 -9
- package/{chunk-CPB2YM4D.js → chunk-PXQN7IBQ.js} +2 -2
- package/{chunk-4IJYA27C.js → chunk-PXZAAB4L.js} +4 -4
- package/{chunk-4K2KKCSD.js → chunk-Q3UKJVU4.js} +12 -16
- package/{chunk-XKIMRZO2.js → chunk-QNMFBBZK.js} +1 -1
- package/{chunk-XS466O7S.js → chunk-S3GS2PRL.js} +65 -30
- package/{chunk-YYUCRDOK.js → chunk-SOTZ6RDN.js} +1 -1
- package/{chunk-G43KEVSC.js → chunk-SV5MWASH.js} +17 -17
- package/{chunk-7QRKCBOP.js → chunk-TACHTH5D.js} +15 -15
- package/chunk-VC6OZXO5.js +298 -0
- package/{chunk-ZQ2UM4KG.js → chunk-WZSRQNQG.js} +1 -292
- package/{chunk-LARL2V6G.js → chunk-X2S7JTIG.js} +298 -66
- package/{chunk-Q2YZULBH.js → chunk-XENYHRUE.js} +1 -1
- package/{chunk-ELRRLDWI.js → chunk-XFOLQLDN.js} +2 -2
- package/{chunk-UUJDGGAK.js → chunk-XYZA7S7V.js} +6 -6
- package/{chunk-KOCA5FCS.js → chunk-ZEYDOXHF.js} +185 -147
- package/{chunk-5KLGBAAR.js → chunk-ZPRK73XY.js} +1 -1
- package/{cliExecutor-DNE7TCC4.js → cliExecutor-K3F7DMRO.js} +2 -2
- package/{createAgentAutomationAction-63OIP6X5.js → createAgentAutomationAction-LTI5QU35.js} +25 -25
- package/{createDialogAction-ZLYZDYBB.js → createDialogAction-OJJ7L3L3.js} +26 -25
- package/{createPageAction-AL5FSDCK.js → createPageAction-5MXWVRGY.js} +30 -29
- package/{dbSlice-PR44QPXY.js → dbSlice-RQFQQVHT.js} +9 -9
- package/{deleteFile-4SKGPHOZ.js → deleteFile-7XP5BGC7.js} +6 -6
- package/{dialogCommands-F6YI5742.js → dialogCommands-JTJ3RPPW.js} +23 -23
- package/{dialogSlice-JSBNZRLR.js → dialogSlice-OWROKURJ.js} +22 -22
- package/{docCreateCommands-4CTO7ERT.js → docCreateCommands-WJBEW2V7.js} +23 -22
- package/{docDeleteCommands-VBWERDRG.js → docDeleteCommands-BVEHJOY5.js} +25 -24
- package/{docReadCommands-KNP4MFYB.js → docReadCommands-NEWOZIJV.js} +23 -22
- package/{docStore-ADP5VYY4.js → docStore-3DXRYBMD.js} +23 -23
- package/{docUpdateCommands-4BCBJQHA.js → docUpdateCommands-C7WHT7UU.js} +23 -22
- package/{fetchMessages-U6ZHN56A.js → fetchMessages-KTNM7QAR.js} +3 -3
- package/{handleSendMessageAction-IJDQ6ARA.js → handleSendMessageAction-B5PRR7BE.js} +27 -27
- package/index.js +58 -58
- package/{localDialogRead-Z5UTAJPU.js → localDialogRead-YSKFFRTT.js} +2 -2
- package/{machineCommands-EA3M4XTN.js → machineCommands-IIIREAEK.js} +67 -62
- package/{machineWsRunDispatch-NAPKE5ZA.js → machineWsRunDispatch-3SIU6ILW.js} +52 -49
- package/package.json +4 -2
- package/{read-RIJCIVKX.js → read-QJNKRROM.js} +6 -6
- package/{readDocTool-GZD2N3LO.js → readDocTool-H6X6KO6X.js} +1 -1
- package/{readlineWorkspace-KMWT4T4S.js → readlineWorkspace-HGP3I3OC.js} +97 -79
- package/{removeDialogAgentAction-GJQJNDW6.js → removeDialogAgentAction-TCT35SOF.js} +14 -14
- package/{runAgentClientLoop-U5Q6NDTJ.js → runAgentClientLoop-EFM4PTVI.js} +46 -44
- package/{setDialogExtraReferencesAction-M7OQG54N.js → setDialogExtraReferencesAction-CGYLZMFH.js} +12 -12
- package/{setPrimaryDialogAgentAction-46UNFJDL.js → setPrimaryDialogAgentAction-F6BFQDJU.js} +14 -14
- package/{settingSlice-FVUUH4JA.js → settingSlice-2I5HMG47.js} +10 -10
- package/skillDiscovery-UGSQGX2U.js +16 -0
- package/{spaceCommands-E2CFRPZJ.js → spaceCommands-MT7BWCIL.js} +32 -36
- package/{spaceSlice-L3R6IMXE.js → spaceSlice-BS5TSW3W.js} +22 -22
- package/{streamAgentChatTurn-UBDAOQWE.js → streamAgentChatTurn-I3VBFNR3.js} +85 -81
- package/{tableCommands-GOFP7QKA.js → tableCommands-M3DJUETS.js} +11 -11
- package/{toolApiClient-QI3YBNWB.js → toolApiClient-C7P7YSE4.js} +2 -2
- package/{tools-TMJXZTCA.js → tools-XSD2BOEN.js} +34 -32
- package/{tuiSummaryLlmCaller-RV3THLZF.js → tuiSummaryLlmCaller-32NRHTT2.js} +3 -3
- package/{understanding-GQKNDDWM.js → understanding-ZOESBLF3.js} +5 -5
- package/{updateDialogTitleAction-ZTWRDXI2.js → updateDialogTitleAction-7FYNJOGP.js} +25 -25
- package/chunk-QYXLLLGL.js +0 -4519
- package/{agentPullCommand-O2MTUAFR.js → agentPullCommand-GOL2S4W2.js} +1 -1
- package/{chunk-DZ3XJVET.js → chunk-3QAF2LTL.js} +3 -3
- package/{chunk-EHLHSX7R.js → chunk-5MMZUWSG.js} +3 -3
- package/{chunk-X7W4TNB4.js → chunk-CMKUBIGW.js} +3 -3
- package/{chunk-4CQLVGRV.js → chunk-ID4G2MAR.js} +3 -3
- package/{chunk-5MIDPSSK.js → chunk-JK7VW2FN.js} +3 -3
- package/{chunk-TILFE6LV.js → chunk-YOCHZD7D.js} +3 -3
- package/{chunk-JRKKFRAV.js → chunk-YTBMA7NO.js} +3 -3
- package/{db-HCJ5PRB5.js → db-6QED3ZVO.js} +3 -3
- package/{runtimeDoctorCommands-LRHLPDRC.js → runtimeDoctorCommands-ID43Z7VX.js} +3 -3
|
@@ -8,17 +8,17 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
buildDialogAttachmentPlan,
|
|
10
10
|
extractFileContentIds
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-MTU75CZ2.js";
|
|
12
12
|
import {
|
|
13
13
|
getApproxPricePerImage
|
|
14
14
|
} from "./chunk-CWMSB67P.js";
|
|
15
15
|
import {
|
|
16
16
|
deleteServerSyncedCredential,
|
|
17
17
|
runLlm
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-Q3UKJVU4.js";
|
|
19
19
|
import {
|
|
20
20
|
cleanupCliSessionForDialog
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-GBDSZATH.js";
|
|
22
22
|
import {
|
|
23
23
|
getDialogAgentIds,
|
|
24
24
|
getPrimaryDialogAgentId
|
|
@@ -26,61 +26,26 @@ import {
|
|
|
26
26
|
import {
|
|
27
27
|
require_date_fns
|
|
28
28
|
} from "./chunk-M76ECQRD.js";
|
|
29
|
+
import {
|
|
30
|
+
isSystemAdmin,
|
|
31
|
+
nolotusId,
|
|
32
|
+
selectRemoteServer,
|
|
33
|
+
selectRemoteServers,
|
|
34
|
+
selectRemoteSyncServers
|
|
35
|
+
} from "./chunk-3NSIQZZ6.js";
|
|
29
36
|
import {
|
|
30
37
|
fetchMessages
|
|
31
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-SOTZ6RDN.js";
|
|
32
39
|
import {
|
|
33
40
|
UNCATEGORIZED_ID,
|
|
34
41
|
addContentAction,
|
|
35
42
|
checkSpaceMembership,
|
|
36
43
|
localSpaceAuthorityPatchStamp
|
|
37
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-7D3JY6C2.js";
|
|
38
45
|
import {
|
|
39
46
|
createSpaceKey,
|
|
40
47
|
normalizeSpaceId
|
|
41
48
|
} from "./chunk-UAD2WT54.js";
|
|
42
|
-
import {
|
|
43
|
-
ALL_MODELS
|
|
44
|
-
} from "./chunk-DCOA4QSN.js";
|
|
45
|
-
import {
|
|
46
|
-
MODEL_LOOKUP_MAP,
|
|
47
|
-
findModelConfig,
|
|
48
|
-
getModelConfig
|
|
49
|
-
} from "./chunk-BBYVOSU2.js";
|
|
50
|
-
import {
|
|
51
|
-
createFileCredentialBroker
|
|
52
|
-
} from "./chunk-5CS33IBL.js";
|
|
53
|
-
import {
|
|
54
|
-
extractCustomId,
|
|
55
|
-
extractUserId
|
|
56
|
-
} from "./chunk-DFFIZ25G.js";
|
|
57
|
-
import {
|
|
58
|
-
abortActiveControllers,
|
|
59
|
-
addPageReferenceToRuntime,
|
|
60
|
-
applyClearDialogStateRuntime,
|
|
61
|
-
applyUpdateTokensFulfilled,
|
|
62
|
-
clearActiveControllers,
|
|
63
|
-
clearPendingAttachments,
|
|
64
|
-
clearPendingUserInputQueue,
|
|
65
|
-
deleteDialogRuntime,
|
|
66
|
-
getActiveDialogKey,
|
|
67
|
-
getDialogRuntimeTokens,
|
|
68
|
-
require_react,
|
|
69
|
-
resetDialogRuntimeSessionState,
|
|
70
|
-
selectCurrentDialogKey,
|
|
71
|
-
setActiveDialogKey,
|
|
72
|
-
setDialogConfigError
|
|
73
|
-
} from "./chunk-3ASDTTEI.js";
|
|
74
|
-
import {
|
|
75
|
-
toErrorMessage
|
|
76
|
-
} from "./chunk-HNMXYYJR.js";
|
|
77
|
-
import {
|
|
78
|
-
isSystemAdmin,
|
|
79
|
-
nolotusId,
|
|
80
|
-
selectRemoteServer,
|
|
81
|
-
selectRemoteServers,
|
|
82
|
-
selectRemoteSyncServers
|
|
83
|
-
} from "./chunk-TSS3XJY4.js";
|
|
84
49
|
import {
|
|
85
50
|
patch,
|
|
86
51
|
read,
|
|
@@ -93,10 +58,21 @@ import {
|
|
|
93
58
|
uploadFileAction,
|
|
94
59
|
upsertSSREntity,
|
|
95
60
|
write
|
|
96
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-O26GI2JP.js";
|
|
97
62
|
import {
|
|
98
63
|
resolveFileCategory
|
|
99
64
|
} from "./chunk-AZPCASRE.js";
|
|
65
|
+
import {
|
|
66
|
+
ALL_MODELS
|
|
67
|
+
} from "./chunk-DCOA4QSN.js";
|
|
68
|
+
import {
|
|
69
|
+
MODEL_LOOKUP_MAP,
|
|
70
|
+
findModelConfig,
|
|
71
|
+
getModelConfig
|
|
72
|
+
} from "./chunk-BBYVOSU2.js";
|
|
73
|
+
import {
|
|
74
|
+
createFileCredentialBroker
|
|
75
|
+
} from "./chunk-5CS33IBL.js";
|
|
100
76
|
import {
|
|
101
77
|
asRecordOrEmpty
|
|
102
78
|
} from "./chunk-KX6YBIHG.js";
|
|
@@ -120,12 +96,11 @@ import {
|
|
|
120
96
|
isTableMetaKey,
|
|
121
97
|
isTaskKey,
|
|
122
98
|
metaKey,
|
|
123
|
-
require_index_umd,
|
|
124
99
|
rowKey,
|
|
125
100
|
splitKey,
|
|
126
101
|
toTrimmedString,
|
|
127
102
|
ulid
|
|
128
|
-
} from "./chunk-
|
|
103
|
+
} from "./chunk-O4BU24WZ.js";
|
|
129
104
|
import {
|
|
130
105
|
asNonEmptyStringArray,
|
|
131
106
|
asTrimmedNonEmptyStringArray
|
|
@@ -133,12 +108,36 @@ import {
|
|
|
133
108
|
import {
|
|
134
109
|
asOptionalFiniteNumber
|
|
135
110
|
} from "./chunk-WWC7I6TA.js";
|
|
111
|
+
import {
|
|
112
|
+
extractCustomId,
|
|
113
|
+
extractUserId
|
|
114
|
+
} from "./chunk-DFFIZ25G.js";
|
|
115
|
+
import {
|
|
116
|
+
abortActiveControllers,
|
|
117
|
+
addPageReferenceToRuntime,
|
|
118
|
+
applyClearDialogStateRuntime,
|
|
119
|
+
applyUpdateTokensFulfilled,
|
|
120
|
+
clearActiveControllers,
|
|
121
|
+
clearPendingAttachments,
|
|
122
|
+
clearPendingUserInputQueue,
|
|
123
|
+
deleteDialogRuntime,
|
|
124
|
+
getActiveDialogKey,
|
|
125
|
+
getDialogRuntimeTokens,
|
|
126
|
+
require_react,
|
|
127
|
+
resetDialogRuntimeSessionState,
|
|
128
|
+
selectCurrentDialogKey,
|
|
129
|
+
setActiveDialogKey,
|
|
130
|
+
setDialogConfigError
|
|
131
|
+
} from "./chunk-3ASDTTEI.js";
|
|
136
132
|
import {
|
|
137
133
|
asTrimmedLowercaseString
|
|
138
134
|
} from "./chunk-QSJ3HFEF.js";
|
|
135
|
+
import {
|
|
136
|
+
toErrorMessage
|
|
137
|
+
} from "./chunk-HNMXYYJR.js";
|
|
139
138
|
import {
|
|
140
139
|
readAction
|
|
141
|
-
} from "./chunk-
|
|
140
|
+
} from "./chunk-XFOLQLDN.js";
|
|
142
141
|
import {
|
|
143
142
|
DEVICE_LOCAL_OWNER_ID,
|
|
144
143
|
asyncThunkCreator,
|
|
@@ -159,39 +158,39 @@ import {
|
|
|
159
158
|
selectIdentityToken,
|
|
160
159
|
selectIdentityUserId,
|
|
161
160
|
selectRuntimeSnapshot
|
|
162
|
-
} from "./chunk-
|
|
161
|
+
} from "./chunk-OOM6SJNR.js";
|
|
163
162
|
import {
|
|
163
|
+
createClientLogger,
|
|
164
164
|
fetchFromServer,
|
|
165
165
|
fetchWithTransientReadRetry,
|
|
166
166
|
getAllServers,
|
|
167
167
|
isAbortError,
|
|
168
|
-
logger
|
|
169
|
-
|
|
170
|
-
} from "./chunk-QYXLLLGL.js";
|
|
168
|
+
logger
|
|
169
|
+
} from "./chunk-OOSFSFMA.js";
|
|
171
170
|
import {
|
|
172
171
|
buildTombstoneRecord,
|
|
173
172
|
isTombstoneRecord,
|
|
174
173
|
shouldReplaceWithNextRecord
|
|
175
174
|
} from "./chunk-GBRG75BQ.js";
|
|
176
|
-
import {
|
|
177
|
-
API_ENDPOINTS,
|
|
178
|
-
API_VERSION
|
|
179
|
-
} from "./chunk-LCBAMY2M.js";
|
|
180
175
|
import {
|
|
181
176
|
asTrimmedString
|
|
182
177
|
} from "./chunk-3EUW3WEO.js";
|
|
183
178
|
import {
|
|
184
179
|
asOptionalPositiveFiniteNumber
|
|
185
180
|
} from "./chunk-U6VC4MU4.js";
|
|
181
|
+
import {
|
|
182
|
+
isRecord
|
|
183
|
+
} from "./chunk-KUG52IAP.js";
|
|
184
|
+
import {
|
|
185
|
+
API_ENDPOINTS,
|
|
186
|
+
API_VERSION
|
|
187
|
+
} from "./chunk-LCBAMY2M.js";
|
|
186
188
|
import {
|
|
187
189
|
normalizeServerOrigin
|
|
188
190
|
} from "./chunk-CF7PE763.js";
|
|
189
191
|
import {
|
|
190
192
|
asOptionalTrimmedString
|
|
191
193
|
} from "./chunk-G3SUCT4W.js";
|
|
192
|
-
import {
|
|
193
|
-
isRecord
|
|
194
|
-
} from "./chunk-KUG52IAP.js";
|
|
195
194
|
import {
|
|
196
195
|
__commonJS,
|
|
197
196
|
__require,
|
|
@@ -2675,2230 +2674,6 @@ var require_browser_image_compression = __commonJS({
|
|
|
2675
2674
|
}
|
|
2676
2675
|
});
|
|
2677
2676
|
|
|
2678
|
-
// node_modules/tweetnacl/nacl-fast.js
|
|
2679
|
-
var require_nacl_fast = __commonJS({
|
|
2680
|
-
"node_modules/tweetnacl/nacl-fast.js"(exports, module) {
|
|
2681
|
-
(function(nacl4) {
|
|
2682
|
-
"use strict";
|
|
2683
|
-
var gf = function(init2) {
|
|
2684
|
-
var i, r = new Float64Array(16);
|
|
2685
|
-
if (init2) for (i = 0; i < init2.length; i++) r[i] = init2[i];
|
|
2686
|
-
return r;
|
|
2687
|
-
};
|
|
2688
|
-
var randombytes = function() {
|
|
2689
|
-
throw new Error("no PRNG");
|
|
2690
|
-
};
|
|
2691
|
-
var _0 = new Uint8Array(16);
|
|
2692
|
-
var _9 = new Uint8Array(32);
|
|
2693
|
-
_9[0] = 9;
|
|
2694
|
-
var gf0 = gf(), gf1 = gf([1]), _121665 = gf([56129, 1]), D = gf([30883, 4953, 19914, 30187, 55467, 16705, 2637, 112, 59544, 30585, 16505, 36039, 65139, 11119, 27886, 20995]), D2 = gf([61785, 9906, 39828, 60374, 45398, 33411, 5274, 224, 53552, 61171, 33010, 6542, 64743, 22239, 55772, 9222]), X = gf([54554, 36645, 11616, 51542, 42930, 38181, 51040, 26924, 56412, 64982, 57905, 49316, 21502, 52590, 14035, 8553]), Y = gf([26200, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214]), I = gf([41136, 18958, 6951, 50414, 58488, 44335, 6150, 12099, 55207, 15867, 153, 11085, 57099, 20417, 9344, 11139]);
|
|
2695
|
-
function ts64(x, i, h, l) {
|
|
2696
|
-
x[i] = h >> 24 & 255;
|
|
2697
|
-
x[i + 1] = h >> 16 & 255;
|
|
2698
|
-
x[i + 2] = h >> 8 & 255;
|
|
2699
|
-
x[i + 3] = h & 255;
|
|
2700
|
-
x[i + 4] = l >> 24 & 255;
|
|
2701
|
-
x[i + 5] = l >> 16 & 255;
|
|
2702
|
-
x[i + 6] = l >> 8 & 255;
|
|
2703
|
-
x[i + 7] = l & 255;
|
|
2704
|
-
}
|
|
2705
|
-
function vn(x, xi, y, yi, n) {
|
|
2706
|
-
var i, d = 0;
|
|
2707
|
-
for (i = 0; i < n; i++) d |= x[xi + i] ^ y[yi + i];
|
|
2708
|
-
return (1 & d - 1 >>> 8) - 1;
|
|
2709
|
-
}
|
|
2710
|
-
function crypto_verify_16(x, xi, y, yi) {
|
|
2711
|
-
return vn(x, xi, y, yi, 16);
|
|
2712
|
-
}
|
|
2713
|
-
function crypto_verify_32(x, xi, y, yi) {
|
|
2714
|
-
return vn(x, xi, y, yi, 32);
|
|
2715
|
-
}
|
|
2716
|
-
function core_salsa20(o, p, k, c) {
|
|
2717
|
-
var j0 = c[0] & 255 | (c[1] & 255) << 8 | (c[2] & 255) << 16 | (c[3] & 255) << 24, j1 = k[0] & 255 | (k[1] & 255) << 8 | (k[2] & 255) << 16 | (k[3] & 255) << 24, j2 = k[4] & 255 | (k[5] & 255) << 8 | (k[6] & 255) << 16 | (k[7] & 255) << 24, j3 = k[8] & 255 | (k[9] & 255) << 8 | (k[10] & 255) << 16 | (k[11] & 255) << 24, j4 = k[12] & 255 | (k[13] & 255) << 8 | (k[14] & 255) << 16 | (k[15] & 255) << 24, j5 = c[4] & 255 | (c[5] & 255) << 8 | (c[6] & 255) << 16 | (c[7] & 255) << 24, j6 = p[0] & 255 | (p[1] & 255) << 8 | (p[2] & 255) << 16 | (p[3] & 255) << 24, j7 = p[4] & 255 | (p[5] & 255) << 8 | (p[6] & 255) << 16 | (p[7] & 255) << 24, j8 = p[8] & 255 | (p[9] & 255) << 8 | (p[10] & 255) << 16 | (p[11] & 255) << 24, j9 = p[12] & 255 | (p[13] & 255) << 8 | (p[14] & 255) << 16 | (p[15] & 255) << 24, j10 = c[8] & 255 | (c[9] & 255) << 8 | (c[10] & 255) << 16 | (c[11] & 255) << 24, j11 = k[16] & 255 | (k[17] & 255) << 8 | (k[18] & 255) << 16 | (k[19] & 255) << 24, j12 = k[20] & 255 | (k[21] & 255) << 8 | (k[22] & 255) << 16 | (k[23] & 255) << 24, j13 = k[24] & 255 | (k[25] & 255) << 8 | (k[26] & 255) << 16 | (k[27] & 255) << 24, j14 = k[28] & 255 | (k[29] & 255) << 8 | (k[30] & 255) << 16 | (k[31] & 255) << 24, j15 = c[12] & 255 | (c[13] & 255) << 8 | (c[14] & 255) << 16 | (c[15] & 255) << 24;
|
|
2718
|
-
var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7, x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14, x15 = j15, u;
|
|
2719
|
-
for (var i = 0; i < 20; i += 2) {
|
|
2720
|
-
u = x0 + x12 | 0;
|
|
2721
|
-
x4 ^= u << 7 | u >>> 32 - 7;
|
|
2722
|
-
u = x4 + x0 | 0;
|
|
2723
|
-
x8 ^= u << 9 | u >>> 32 - 9;
|
|
2724
|
-
u = x8 + x4 | 0;
|
|
2725
|
-
x12 ^= u << 13 | u >>> 32 - 13;
|
|
2726
|
-
u = x12 + x8 | 0;
|
|
2727
|
-
x0 ^= u << 18 | u >>> 32 - 18;
|
|
2728
|
-
u = x5 + x1 | 0;
|
|
2729
|
-
x9 ^= u << 7 | u >>> 32 - 7;
|
|
2730
|
-
u = x9 + x5 | 0;
|
|
2731
|
-
x13 ^= u << 9 | u >>> 32 - 9;
|
|
2732
|
-
u = x13 + x9 | 0;
|
|
2733
|
-
x1 ^= u << 13 | u >>> 32 - 13;
|
|
2734
|
-
u = x1 + x13 | 0;
|
|
2735
|
-
x5 ^= u << 18 | u >>> 32 - 18;
|
|
2736
|
-
u = x10 + x6 | 0;
|
|
2737
|
-
x14 ^= u << 7 | u >>> 32 - 7;
|
|
2738
|
-
u = x14 + x10 | 0;
|
|
2739
|
-
x2 ^= u << 9 | u >>> 32 - 9;
|
|
2740
|
-
u = x2 + x14 | 0;
|
|
2741
|
-
x6 ^= u << 13 | u >>> 32 - 13;
|
|
2742
|
-
u = x6 + x2 | 0;
|
|
2743
|
-
x10 ^= u << 18 | u >>> 32 - 18;
|
|
2744
|
-
u = x15 + x11 | 0;
|
|
2745
|
-
x3 ^= u << 7 | u >>> 32 - 7;
|
|
2746
|
-
u = x3 + x15 | 0;
|
|
2747
|
-
x7 ^= u << 9 | u >>> 32 - 9;
|
|
2748
|
-
u = x7 + x3 | 0;
|
|
2749
|
-
x11 ^= u << 13 | u >>> 32 - 13;
|
|
2750
|
-
u = x11 + x7 | 0;
|
|
2751
|
-
x15 ^= u << 18 | u >>> 32 - 18;
|
|
2752
|
-
u = x0 + x3 | 0;
|
|
2753
|
-
x1 ^= u << 7 | u >>> 32 - 7;
|
|
2754
|
-
u = x1 + x0 | 0;
|
|
2755
|
-
x2 ^= u << 9 | u >>> 32 - 9;
|
|
2756
|
-
u = x2 + x1 | 0;
|
|
2757
|
-
x3 ^= u << 13 | u >>> 32 - 13;
|
|
2758
|
-
u = x3 + x2 | 0;
|
|
2759
|
-
x0 ^= u << 18 | u >>> 32 - 18;
|
|
2760
|
-
u = x5 + x4 | 0;
|
|
2761
|
-
x6 ^= u << 7 | u >>> 32 - 7;
|
|
2762
|
-
u = x6 + x5 | 0;
|
|
2763
|
-
x7 ^= u << 9 | u >>> 32 - 9;
|
|
2764
|
-
u = x7 + x6 | 0;
|
|
2765
|
-
x4 ^= u << 13 | u >>> 32 - 13;
|
|
2766
|
-
u = x4 + x7 | 0;
|
|
2767
|
-
x5 ^= u << 18 | u >>> 32 - 18;
|
|
2768
|
-
u = x10 + x9 | 0;
|
|
2769
|
-
x11 ^= u << 7 | u >>> 32 - 7;
|
|
2770
|
-
u = x11 + x10 | 0;
|
|
2771
|
-
x8 ^= u << 9 | u >>> 32 - 9;
|
|
2772
|
-
u = x8 + x11 | 0;
|
|
2773
|
-
x9 ^= u << 13 | u >>> 32 - 13;
|
|
2774
|
-
u = x9 + x8 | 0;
|
|
2775
|
-
x10 ^= u << 18 | u >>> 32 - 18;
|
|
2776
|
-
u = x15 + x14 | 0;
|
|
2777
|
-
x12 ^= u << 7 | u >>> 32 - 7;
|
|
2778
|
-
u = x12 + x15 | 0;
|
|
2779
|
-
x13 ^= u << 9 | u >>> 32 - 9;
|
|
2780
|
-
u = x13 + x12 | 0;
|
|
2781
|
-
x14 ^= u << 13 | u >>> 32 - 13;
|
|
2782
|
-
u = x14 + x13 | 0;
|
|
2783
|
-
x15 ^= u << 18 | u >>> 32 - 18;
|
|
2784
|
-
}
|
|
2785
|
-
x0 = x0 + j0 | 0;
|
|
2786
|
-
x1 = x1 + j1 | 0;
|
|
2787
|
-
x2 = x2 + j2 | 0;
|
|
2788
|
-
x3 = x3 + j3 | 0;
|
|
2789
|
-
x4 = x4 + j4 | 0;
|
|
2790
|
-
x5 = x5 + j5 | 0;
|
|
2791
|
-
x6 = x6 + j6 | 0;
|
|
2792
|
-
x7 = x7 + j7 | 0;
|
|
2793
|
-
x8 = x8 + j8 | 0;
|
|
2794
|
-
x9 = x9 + j9 | 0;
|
|
2795
|
-
x10 = x10 + j10 | 0;
|
|
2796
|
-
x11 = x11 + j11 | 0;
|
|
2797
|
-
x12 = x12 + j12 | 0;
|
|
2798
|
-
x13 = x13 + j13 | 0;
|
|
2799
|
-
x14 = x14 + j14 | 0;
|
|
2800
|
-
x15 = x15 + j15 | 0;
|
|
2801
|
-
o[0] = x0 >>> 0 & 255;
|
|
2802
|
-
o[1] = x0 >>> 8 & 255;
|
|
2803
|
-
o[2] = x0 >>> 16 & 255;
|
|
2804
|
-
o[3] = x0 >>> 24 & 255;
|
|
2805
|
-
o[4] = x1 >>> 0 & 255;
|
|
2806
|
-
o[5] = x1 >>> 8 & 255;
|
|
2807
|
-
o[6] = x1 >>> 16 & 255;
|
|
2808
|
-
o[7] = x1 >>> 24 & 255;
|
|
2809
|
-
o[8] = x2 >>> 0 & 255;
|
|
2810
|
-
o[9] = x2 >>> 8 & 255;
|
|
2811
|
-
o[10] = x2 >>> 16 & 255;
|
|
2812
|
-
o[11] = x2 >>> 24 & 255;
|
|
2813
|
-
o[12] = x3 >>> 0 & 255;
|
|
2814
|
-
o[13] = x3 >>> 8 & 255;
|
|
2815
|
-
o[14] = x3 >>> 16 & 255;
|
|
2816
|
-
o[15] = x3 >>> 24 & 255;
|
|
2817
|
-
o[16] = x4 >>> 0 & 255;
|
|
2818
|
-
o[17] = x4 >>> 8 & 255;
|
|
2819
|
-
o[18] = x4 >>> 16 & 255;
|
|
2820
|
-
o[19] = x4 >>> 24 & 255;
|
|
2821
|
-
o[20] = x5 >>> 0 & 255;
|
|
2822
|
-
o[21] = x5 >>> 8 & 255;
|
|
2823
|
-
o[22] = x5 >>> 16 & 255;
|
|
2824
|
-
o[23] = x5 >>> 24 & 255;
|
|
2825
|
-
o[24] = x6 >>> 0 & 255;
|
|
2826
|
-
o[25] = x6 >>> 8 & 255;
|
|
2827
|
-
o[26] = x6 >>> 16 & 255;
|
|
2828
|
-
o[27] = x6 >>> 24 & 255;
|
|
2829
|
-
o[28] = x7 >>> 0 & 255;
|
|
2830
|
-
o[29] = x7 >>> 8 & 255;
|
|
2831
|
-
o[30] = x7 >>> 16 & 255;
|
|
2832
|
-
o[31] = x7 >>> 24 & 255;
|
|
2833
|
-
o[32] = x8 >>> 0 & 255;
|
|
2834
|
-
o[33] = x8 >>> 8 & 255;
|
|
2835
|
-
o[34] = x8 >>> 16 & 255;
|
|
2836
|
-
o[35] = x8 >>> 24 & 255;
|
|
2837
|
-
o[36] = x9 >>> 0 & 255;
|
|
2838
|
-
o[37] = x9 >>> 8 & 255;
|
|
2839
|
-
o[38] = x9 >>> 16 & 255;
|
|
2840
|
-
o[39] = x9 >>> 24 & 255;
|
|
2841
|
-
o[40] = x10 >>> 0 & 255;
|
|
2842
|
-
o[41] = x10 >>> 8 & 255;
|
|
2843
|
-
o[42] = x10 >>> 16 & 255;
|
|
2844
|
-
o[43] = x10 >>> 24 & 255;
|
|
2845
|
-
o[44] = x11 >>> 0 & 255;
|
|
2846
|
-
o[45] = x11 >>> 8 & 255;
|
|
2847
|
-
o[46] = x11 >>> 16 & 255;
|
|
2848
|
-
o[47] = x11 >>> 24 & 255;
|
|
2849
|
-
o[48] = x12 >>> 0 & 255;
|
|
2850
|
-
o[49] = x12 >>> 8 & 255;
|
|
2851
|
-
o[50] = x12 >>> 16 & 255;
|
|
2852
|
-
o[51] = x12 >>> 24 & 255;
|
|
2853
|
-
o[52] = x13 >>> 0 & 255;
|
|
2854
|
-
o[53] = x13 >>> 8 & 255;
|
|
2855
|
-
o[54] = x13 >>> 16 & 255;
|
|
2856
|
-
o[55] = x13 >>> 24 & 255;
|
|
2857
|
-
o[56] = x14 >>> 0 & 255;
|
|
2858
|
-
o[57] = x14 >>> 8 & 255;
|
|
2859
|
-
o[58] = x14 >>> 16 & 255;
|
|
2860
|
-
o[59] = x14 >>> 24 & 255;
|
|
2861
|
-
o[60] = x15 >>> 0 & 255;
|
|
2862
|
-
o[61] = x15 >>> 8 & 255;
|
|
2863
|
-
o[62] = x15 >>> 16 & 255;
|
|
2864
|
-
o[63] = x15 >>> 24 & 255;
|
|
2865
|
-
}
|
|
2866
|
-
function core_hsalsa20(o, p, k, c) {
|
|
2867
|
-
var j0 = c[0] & 255 | (c[1] & 255) << 8 | (c[2] & 255) << 16 | (c[3] & 255) << 24, j1 = k[0] & 255 | (k[1] & 255) << 8 | (k[2] & 255) << 16 | (k[3] & 255) << 24, j2 = k[4] & 255 | (k[5] & 255) << 8 | (k[6] & 255) << 16 | (k[7] & 255) << 24, j3 = k[8] & 255 | (k[9] & 255) << 8 | (k[10] & 255) << 16 | (k[11] & 255) << 24, j4 = k[12] & 255 | (k[13] & 255) << 8 | (k[14] & 255) << 16 | (k[15] & 255) << 24, j5 = c[4] & 255 | (c[5] & 255) << 8 | (c[6] & 255) << 16 | (c[7] & 255) << 24, j6 = p[0] & 255 | (p[1] & 255) << 8 | (p[2] & 255) << 16 | (p[3] & 255) << 24, j7 = p[4] & 255 | (p[5] & 255) << 8 | (p[6] & 255) << 16 | (p[7] & 255) << 24, j8 = p[8] & 255 | (p[9] & 255) << 8 | (p[10] & 255) << 16 | (p[11] & 255) << 24, j9 = p[12] & 255 | (p[13] & 255) << 8 | (p[14] & 255) << 16 | (p[15] & 255) << 24, j10 = c[8] & 255 | (c[9] & 255) << 8 | (c[10] & 255) << 16 | (c[11] & 255) << 24, j11 = k[16] & 255 | (k[17] & 255) << 8 | (k[18] & 255) << 16 | (k[19] & 255) << 24, j12 = k[20] & 255 | (k[21] & 255) << 8 | (k[22] & 255) << 16 | (k[23] & 255) << 24, j13 = k[24] & 255 | (k[25] & 255) << 8 | (k[26] & 255) << 16 | (k[27] & 255) << 24, j14 = k[28] & 255 | (k[29] & 255) << 8 | (k[30] & 255) << 16 | (k[31] & 255) << 24, j15 = c[12] & 255 | (c[13] & 255) << 8 | (c[14] & 255) << 16 | (c[15] & 255) << 24;
|
|
2868
|
-
var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7, x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14, x15 = j15, u;
|
|
2869
|
-
for (var i = 0; i < 20; i += 2) {
|
|
2870
|
-
u = x0 + x12 | 0;
|
|
2871
|
-
x4 ^= u << 7 | u >>> 32 - 7;
|
|
2872
|
-
u = x4 + x0 | 0;
|
|
2873
|
-
x8 ^= u << 9 | u >>> 32 - 9;
|
|
2874
|
-
u = x8 + x4 | 0;
|
|
2875
|
-
x12 ^= u << 13 | u >>> 32 - 13;
|
|
2876
|
-
u = x12 + x8 | 0;
|
|
2877
|
-
x0 ^= u << 18 | u >>> 32 - 18;
|
|
2878
|
-
u = x5 + x1 | 0;
|
|
2879
|
-
x9 ^= u << 7 | u >>> 32 - 7;
|
|
2880
|
-
u = x9 + x5 | 0;
|
|
2881
|
-
x13 ^= u << 9 | u >>> 32 - 9;
|
|
2882
|
-
u = x13 + x9 | 0;
|
|
2883
|
-
x1 ^= u << 13 | u >>> 32 - 13;
|
|
2884
|
-
u = x1 + x13 | 0;
|
|
2885
|
-
x5 ^= u << 18 | u >>> 32 - 18;
|
|
2886
|
-
u = x10 + x6 | 0;
|
|
2887
|
-
x14 ^= u << 7 | u >>> 32 - 7;
|
|
2888
|
-
u = x14 + x10 | 0;
|
|
2889
|
-
x2 ^= u << 9 | u >>> 32 - 9;
|
|
2890
|
-
u = x2 + x14 | 0;
|
|
2891
|
-
x6 ^= u << 13 | u >>> 32 - 13;
|
|
2892
|
-
u = x6 + x2 | 0;
|
|
2893
|
-
x10 ^= u << 18 | u >>> 32 - 18;
|
|
2894
|
-
u = x15 + x11 | 0;
|
|
2895
|
-
x3 ^= u << 7 | u >>> 32 - 7;
|
|
2896
|
-
u = x3 + x15 | 0;
|
|
2897
|
-
x7 ^= u << 9 | u >>> 32 - 9;
|
|
2898
|
-
u = x7 + x3 | 0;
|
|
2899
|
-
x11 ^= u << 13 | u >>> 32 - 13;
|
|
2900
|
-
u = x11 + x7 | 0;
|
|
2901
|
-
x15 ^= u << 18 | u >>> 32 - 18;
|
|
2902
|
-
u = x0 + x3 | 0;
|
|
2903
|
-
x1 ^= u << 7 | u >>> 32 - 7;
|
|
2904
|
-
u = x1 + x0 | 0;
|
|
2905
|
-
x2 ^= u << 9 | u >>> 32 - 9;
|
|
2906
|
-
u = x2 + x1 | 0;
|
|
2907
|
-
x3 ^= u << 13 | u >>> 32 - 13;
|
|
2908
|
-
u = x3 + x2 | 0;
|
|
2909
|
-
x0 ^= u << 18 | u >>> 32 - 18;
|
|
2910
|
-
u = x5 + x4 | 0;
|
|
2911
|
-
x6 ^= u << 7 | u >>> 32 - 7;
|
|
2912
|
-
u = x6 + x5 | 0;
|
|
2913
|
-
x7 ^= u << 9 | u >>> 32 - 9;
|
|
2914
|
-
u = x7 + x6 | 0;
|
|
2915
|
-
x4 ^= u << 13 | u >>> 32 - 13;
|
|
2916
|
-
u = x4 + x7 | 0;
|
|
2917
|
-
x5 ^= u << 18 | u >>> 32 - 18;
|
|
2918
|
-
u = x10 + x9 | 0;
|
|
2919
|
-
x11 ^= u << 7 | u >>> 32 - 7;
|
|
2920
|
-
u = x11 + x10 | 0;
|
|
2921
|
-
x8 ^= u << 9 | u >>> 32 - 9;
|
|
2922
|
-
u = x8 + x11 | 0;
|
|
2923
|
-
x9 ^= u << 13 | u >>> 32 - 13;
|
|
2924
|
-
u = x9 + x8 | 0;
|
|
2925
|
-
x10 ^= u << 18 | u >>> 32 - 18;
|
|
2926
|
-
u = x15 + x14 | 0;
|
|
2927
|
-
x12 ^= u << 7 | u >>> 32 - 7;
|
|
2928
|
-
u = x12 + x15 | 0;
|
|
2929
|
-
x13 ^= u << 9 | u >>> 32 - 9;
|
|
2930
|
-
u = x13 + x12 | 0;
|
|
2931
|
-
x14 ^= u << 13 | u >>> 32 - 13;
|
|
2932
|
-
u = x14 + x13 | 0;
|
|
2933
|
-
x15 ^= u << 18 | u >>> 32 - 18;
|
|
2934
|
-
}
|
|
2935
|
-
o[0] = x0 >>> 0 & 255;
|
|
2936
|
-
o[1] = x0 >>> 8 & 255;
|
|
2937
|
-
o[2] = x0 >>> 16 & 255;
|
|
2938
|
-
o[3] = x0 >>> 24 & 255;
|
|
2939
|
-
o[4] = x5 >>> 0 & 255;
|
|
2940
|
-
o[5] = x5 >>> 8 & 255;
|
|
2941
|
-
o[6] = x5 >>> 16 & 255;
|
|
2942
|
-
o[7] = x5 >>> 24 & 255;
|
|
2943
|
-
o[8] = x10 >>> 0 & 255;
|
|
2944
|
-
o[9] = x10 >>> 8 & 255;
|
|
2945
|
-
o[10] = x10 >>> 16 & 255;
|
|
2946
|
-
o[11] = x10 >>> 24 & 255;
|
|
2947
|
-
o[12] = x15 >>> 0 & 255;
|
|
2948
|
-
o[13] = x15 >>> 8 & 255;
|
|
2949
|
-
o[14] = x15 >>> 16 & 255;
|
|
2950
|
-
o[15] = x15 >>> 24 & 255;
|
|
2951
|
-
o[16] = x6 >>> 0 & 255;
|
|
2952
|
-
o[17] = x6 >>> 8 & 255;
|
|
2953
|
-
o[18] = x6 >>> 16 & 255;
|
|
2954
|
-
o[19] = x6 >>> 24 & 255;
|
|
2955
|
-
o[20] = x7 >>> 0 & 255;
|
|
2956
|
-
o[21] = x7 >>> 8 & 255;
|
|
2957
|
-
o[22] = x7 >>> 16 & 255;
|
|
2958
|
-
o[23] = x7 >>> 24 & 255;
|
|
2959
|
-
o[24] = x8 >>> 0 & 255;
|
|
2960
|
-
o[25] = x8 >>> 8 & 255;
|
|
2961
|
-
o[26] = x8 >>> 16 & 255;
|
|
2962
|
-
o[27] = x8 >>> 24 & 255;
|
|
2963
|
-
o[28] = x9 >>> 0 & 255;
|
|
2964
|
-
o[29] = x9 >>> 8 & 255;
|
|
2965
|
-
o[30] = x9 >>> 16 & 255;
|
|
2966
|
-
o[31] = x9 >>> 24 & 255;
|
|
2967
|
-
}
|
|
2968
|
-
function crypto_core_salsa20(out, inp, k, c) {
|
|
2969
|
-
core_salsa20(out, inp, k, c);
|
|
2970
|
-
}
|
|
2971
|
-
function crypto_core_hsalsa20(out, inp, k, c) {
|
|
2972
|
-
core_hsalsa20(out, inp, k, c);
|
|
2973
|
-
}
|
|
2974
|
-
var sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);
|
|
2975
|
-
function crypto_stream_salsa20_xor(c, cpos, m, mpos, b, n, k) {
|
|
2976
|
-
var z = new Uint8Array(16), x = new Uint8Array(64);
|
|
2977
|
-
var u, i;
|
|
2978
|
-
for (i = 0; i < 16; i++) z[i] = 0;
|
|
2979
|
-
for (i = 0; i < 8; i++) z[i] = n[i];
|
|
2980
|
-
while (b >= 64) {
|
|
2981
|
-
crypto_core_salsa20(x, z, k, sigma);
|
|
2982
|
-
for (i = 0; i < 64; i++) c[cpos + i] = m[mpos + i] ^ x[i];
|
|
2983
|
-
u = 1;
|
|
2984
|
-
for (i = 8; i < 16; i++) {
|
|
2985
|
-
u = u + (z[i] & 255) | 0;
|
|
2986
|
-
z[i] = u & 255;
|
|
2987
|
-
u >>>= 8;
|
|
2988
|
-
}
|
|
2989
|
-
b -= 64;
|
|
2990
|
-
cpos += 64;
|
|
2991
|
-
mpos += 64;
|
|
2992
|
-
}
|
|
2993
|
-
if (b > 0) {
|
|
2994
|
-
crypto_core_salsa20(x, z, k, sigma);
|
|
2995
|
-
for (i = 0; i < b; i++) c[cpos + i] = m[mpos + i] ^ x[i];
|
|
2996
|
-
}
|
|
2997
|
-
return 0;
|
|
2998
|
-
}
|
|
2999
|
-
function crypto_stream_salsa20(c, cpos, b, n, k) {
|
|
3000
|
-
var z = new Uint8Array(16), x = new Uint8Array(64);
|
|
3001
|
-
var u, i;
|
|
3002
|
-
for (i = 0; i < 16; i++) z[i] = 0;
|
|
3003
|
-
for (i = 0; i < 8; i++) z[i] = n[i];
|
|
3004
|
-
while (b >= 64) {
|
|
3005
|
-
crypto_core_salsa20(x, z, k, sigma);
|
|
3006
|
-
for (i = 0; i < 64; i++) c[cpos + i] = x[i];
|
|
3007
|
-
u = 1;
|
|
3008
|
-
for (i = 8; i < 16; i++) {
|
|
3009
|
-
u = u + (z[i] & 255) | 0;
|
|
3010
|
-
z[i] = u & 255;
|
|
3011
|
-
u >>>= 8;
|
|
3012
|
-
}
|
|
3013
|
-
b -= 64;
|
|
3014
|
-
cpos += 64;
|
|
3015
|
-
}
|
|
3016
|
-
if (b > 0) {
|
|
3017
|
-
crypto_core_salsa20(x, z, k, sigma);
|
|
3018
|
-
for (i = 0; i < b; i++) c[cpos + i] = x[i];
|
|
3019
|
-
}
|
|
3020
|
-
return 0;
|
|
3021
|
-
}
|
|
3022
|
-
function crypto_stream(c, cpos, d, n, k) {
|
|
3023
|
-
var s = new Uint8Array(32);
|
|
3024
|
-
crypto_core_hsalsa20(s, n, k, sigma);
|
|
3025
|
-
var sn = new Uint8Array(8);
|
|
3026
|
-
for (var i = 0; i < 8; i++) sn[i] = n[i + 16];
|
|
3027
|
-
return crypto_stream_salsa20(c, cpos, d, sn, s);
|
|
3028
|
-
}
|
|
3029
|
-
function crypto_stream_xor(c, cpos, m, mpos, d, n, k) {
|
|
3030
|
-
var s = new Uint8Array(32);
|
|
3031
|
-
crypto_core_hsalsa20(s, n, k, sigma);
|
|
3032
|
-
var sn = new Uint8Array(8);
|
|
3033
|
-
for (var i = 0; i < 8; i++) sn[i] = n[i + 16];
|
|
3034
|
-
return crypto_stream_salsa20_xor(c, cpos, m, mpos, d, sn, s);
|
|
3035
|
-
}
|
|
3036
|
-
var poly1305 = function(key) {
|
|
3037
|
-
this.buffer = new Uint8Array(16);
|
|
3038
|
-
this.r = new Uint16Array(10);
|
|
3039
|
-
this.h = new Uint16Array(10);
|
|
3040
|
-
this.pad = new Uint16Array(8);
|
|
3041
|
-
this.leftover = 0;
|
|
3042
|
-
this.fin = 0;
|
|
3043
|
-
var t0, t1, t2, t3, t4, t5, t6, t7;
|
|
3044
|
-
t0 = key[0] & 255 | (key[1] & 255) << 8;
|
|
3045
|
-
this.r[0] = t0 & 8191;
|
|
3046
|
-
t1 = key[2] & 255 | (key[3] & 255) << 8;
|
|
3047
|
-
this.r[1] = (t0 >>> 13 | t1 << 3) & 8191;
|
|
3048
|
-
t2 = key[4] & 255 | (key[5] & 255) << 8;
|
|
3049
|
-
this.r[2] = (t1 >>> 10 | t2 << 6) & 7939;
|
|
3050
|
-
t3 = key[6] & 255 | (key[7] & 255) << 8;
|
|
3051
|
-
this.r[3] = (t2 >>> 7 | t3 << 9) & 8191;
|
|
3052
|
-
t4 = key[8] & 255 | (key[9] & 255) << 8;
|
|
3053
|
-
this.r[4] = (t3 >>> 4 | t4 << 12) & 255;
|
|
3054
|
-
this.r[5] = t4 >>> 1 & 8190;
|
|
3055
|
-
t5 = key[10] & 255 | (key[11] & 255) << 8;
|
|
3056
|
-
this.r[6] = (t4 >>> 14 | t5 << 2) & 8191;
|
|
3057
|
-
t6 = key[12] & 255 | (key[13] & 255) << 8;
|
|
3058
|
-
this.r[7] = (t5 >>> 11 | t6 << 5) & 8065;
|
|
3059
|
-
t7 = key[14] & 255 | (key[15] & 255) << 8;
|
|
3060
|
-
this.r[8] = (t6 >>> 8 | t7 << 8) & 8191;
|
|
3061
|
-
this.r[9] = t7 >>> 5 & 127;
|
|
3062
|
-
this.pad[0] = key[16] & 255 | (key[17] & 255) << 8;
|
|
3063
|
-
this.pad[1] = key[18] & 255 | (key[19] & 255) << 8;
|
|
3064
|
-
this.pad[2] = key[20] & 255 | (key[21] & 255) << 8;
|
|
3065
|
-
this.pad[3] = key[22] & 255 | (key[23] & 255) << 8;
|
|
3066
|
-
this.pad[4] = key[24] & 255 | (key[25] & 255) << 8;
|
|
3067
|
-
this.pad[5] = key[26] & 255 | (key[27] & 255) << 8;
|
|
3068
|
-
this.pad[6] = key[28] & 255 | (key[29] & 255) << 8;
|
|
3069
|
-
this.pad[7] = key[30] & 255 | (key[31] & 255) << 8;
|
|
3070
|
-
};
|
|
3071
|
-
poly1305.prototype.blocks = function(m, mpos, bytes) {
|
|
3072
|
-
var hibit = this.fin ? 0 : 1 << 11;
|
|
3073
|
-
var t0, t1, t2, t3, t4, t5, t6, t7, c;
|
|
3074
|
-
var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;
|
|
3075
|
-
var h0 = this.h[0], h1 = this.h[1], h2 = this.h[2], h3 = this.h[3], h4 = this.h[4], h5 = this.h[5], h6 = this.h[6], h7 = this.h[7], h8 = this.h[8], h9 = this.h[9];
|
|
3076
|
-
var r0 = this.r[0], r1 = this.r[1], r2 = this.r[2], r3 = this.r[3], r4 = this.r[4], r5 = this.r[5], r6 = this.r[6], r7 = this.r[7], r8 = this.r[8], r9 = this.r[9];
|
|
3077
|
-
while (bytes >= 16) {
|
|
3078
|
-
t0 = m[mpos + 0] & 255 | (m[mpos + 1] & 255) << 8;
|
|
3079
|
-
h0 += t0 & 8191;
|
|
3080
|
-
t1 = m[mpos + 2] & 255 | (m[mpos + 3] & 255) << 8;
|
|
3081
|
-
h1 += (t0 >>> 13 | t1 << 3) & 8191;
|
|
3082
|
-
t2 = m[mpos + 4] & 255 | (m[mpos + 5] & 255) << 8;
|
|
3083
|
-
h2 += (t1 >>> 10 | t2 << 6) & 8191;
|
|
3084
|
-
t3 = m[mpos + 6] & 255 | (m[mpos + 7] & 255) << 8;
|
|
3085
|
-
h3 += (t2 >>> 7 | t3 << 9) & 8191;
|
|
3086
|
-
t4 = m[mpos + 8] & 255 | (m[mpos + 9] & 255) << 8;
|
|
3087
|
-
h4 += (t3 >>> 4 | t4 << 12) & 8191;
|
|
3088
|
-
h5 += t4 >>> 1 & 8191;
|
|
3089
|
-
t5 = m[mpos + 10] & 255 | (m[mpos + 11] & 255) << 8;
|
|
3090
|
-
h6 += (t4 >>> 14 | t5 << 2) & 8191;
|
|
3091
|
-
t6 = m[mpos + 12] & 255 | (m[mpos + 13] & 255) << 8;
|
|
3092
|
-
h7 += (t5 >>> 11 | t6 << 5) & 8191;
|
|
3093
|
-
t7 = m[mpos + 14] & 255 | (m[mpos + 15] & 255) << 8;
|
|
3094
|
-
h8 += (t6 >>> 8 | t7 << 8) & 8191;
|
|
3095
|
-
h9 += t7 >>> 5 | hibit;
|
|
3096
|
-
c = 0;
|
|
3097
|
-
d0 = c;
|
|
3098
|
-
d0 += h0 * r0;
|
|
3099
|
-
d0 += h1 * (5 * r9);
|
|
3100
|
-
d0 += h2 * (5 * r8);
|
|
3101
|
-
d0 += h3 * (5 * r7);
|
|
3102
|
-
d0 += h4 * (5 * r6);
|
|
3103
|
-
c = d0 >>> 13;
|
|
3104
|
-
d0 &= 8191;
|
|
3105
|
-
d0 += h5 * (5 * r5);
|
|
3106
|
-
d0 += h6 * (5 * r4);
|
|
3107
|
-
d0 += h7 * (5 * r3);
|
|
3108
|
-
d0 += h8 * (5 * r2);
|
|
3109
|
-
d0 += h9 * (5 * r1);
|
|
3110
|
-
c += d0 >>> 13;
|
|
3111
|
-
d0 &= 8191;
|
|
3112
|
-
d1 = c;
|
|
3113
|
-
d1 += h0 * r1;
|
|
3114
|
-
d1 += h1 * r0;
|
|
3115
|
-
d1 += h2 * (5 * r9);
|
|
3116
|
-
d1 += h3 * (5 * r8);
|
|
3117
|
-
d1 += h4 * (5 * r7);
|
|
3118
|
-
c = d1 >>> 13;
|
|
3119
|
-
d1 &= 8191;
|
|
3120
|
-
d1 += h5 * (5 * r6);
|
|
3121
|
-
d1 += h6 * (5 * r5);
|
|
3122
|
-
d1 += h7 * (5 * r4);
|
|
3123
|
-
d1 += h8 * (5 * r3);
|
|
3124
|
-
d1 += h9 * (5 * r2);
|
|
3125
|
-
c += d1 >>> 13;
|
|
3126
|
-
d1 &= 8191;
|
|
3127
|
-
d2 = c;
|
|
3128
|
-
d2 += h0 * r2;
|
|
3129
|
-
d2 += h1 * r1;
|
|
3130
|
-
d2 += h2 * r0;
|
|
3131
|
-
d2 += h3 * (5 * r9);
|
|
3132
|
-
d2 += h4 * (5 * r8);
|
|
3133
|
-
c = d2 >>> 13;
|
|
3134
|
-
d2 &= 8191;
|
|
3135
|
-
d2 += h5 * (5 * r7);
|
|
3136
|
-
d2 += h6 * (5 * r6);
|
|
3137
|
-
d2 += h7 * (5 * r5);
|
|
3138
|
-
d2 += h8 * (5 * r4);
|
|
3139
|
-
d2 += h9 * (5 * r3);
|
|
3140
|
-
c += d2 >>> 13;
|
|
3141
|
-
d2 &= 8191;
|
|
3142
|
-
d3 = c;
|
|
3143
|
-
d3 += h0 * r3;
|
|
3144
|
-
d3 += h1 * r2;
|
|
3145
|
-
d3 += h2 * r1;
|
|
3146
|
-
d3 += h3 * r0;
|
|
3147
|
-
d3 += h4 * (5 * r9);
|
|
3148
|
-
c = d3 >>> 13;
|
|
3149
|
-
d3 &= 8191;
|
|
3150
|
-
d3 += h5 * (5 * r8);
|
|
3151
|
-
d3 += h6 * (5 * r7);
|
|
3152
|
-
d3 += h7 * (5 * r6);
|
|
3153
|
-
d3 += h8 * (5 * r5);
|
|
3154
|
-
d3 += h9 * (5 * r4);
|
|
3155
|
-
c += d3 >>> 13;
|
|
3156
|
-
d3 &= 8191;
|
|
3157
|
-
d4 = c;
|
|
3158
|
-
d4 += h0 * r4;
|
|
3159
|
-
d4 += h1 * r3;
|
|
3160
|
-
d4 += h2 * r2;
|
|
3161
|
-
d4 += h3 * r1;
|
|
3162
|
-
d4 += h4 * r0;
|
|
3163
|
-
c = d4 >>> 13;
|
|
3164
|
-
d4 &= 8191;
|
|
3165
|
-
d4 += h5 * (5 * r9);
|
|
3166
|
-
d4 += h6 * (5 * r8);
|
|
3167
|
-
d4 += h7 * (5 * r7);
|
|
3168
|
-
d4 += h8 * (5 * r6);
|
|
3169
|
-
d4 += h9 * (5 * r5);
|
|
3170
|
-
c += d4 >>> 13;
|
|
3171
|
-
d4 &= 8191;
|
|
3172
|
-
d5 = c;
|
|
3173
|
-
d5 += h0 * r5;
|
|
3174
|
-
d5 += h1 * r4;
|
|
3175
|
-
d5 += h2 * r3;
|
|
3176
|
-
d5 += h3 * r2;
|
|
3177
|
-
d5 += h4 * r1;
|
|
3178
|
-
c = d5 >>> 13;
|
|
3179
|
-
d5 &= 8191;
|
|
3180
|
-
d5 += h5 * r0;
|
|
3181
|
-
d5 += h6 * (5 * r9);
|
|
3182
|
-
d5 += h7 * (5 * r8);
|
|
3183
|
-
d5 += h8 * (5 * r7);
|
|
3184
|
-
d5 += h9 * (5 * r6);
|
|
3185
|
-
c += d5 >>> 13;
|
|
3186
|
-
d5 &= 8191;
|
|
3187
|
-
d6 = c;
|
|
3188
|
-
d6 += h0 * r6;
|
|
3189
|
-
d6 += h1 * r5;
|
|
3190
|
-
d6 += h2 * r4;
|
|
3191
|
-
d6 += h3 * r3;
|
|
3192
|
-
d6 += h4 * r2;
|
|
3193
|
-
c = d6 >>> 13;
|
|
3194
|
-
d6 &= 8191;
|
|
3195
|
-
d6 += h5 * r1;
|
|
3196
|
-
d6 += h6 * r0;
|
|
3197
|
-
d6 += h7 * (5 * r9);
|
|
3198
|
-
d6 += h8 * (5 * r8);
|
|
3199
|
-
d6 += h9 * (5 * r7);
|
|
3200
|
-
c += d6 >>> 13;
|
|
3201
|
-
d6 &= 8191;
|
|
3202
|
-
d7 = c;
|
|
3203
|
-
d7 += h0 * r7;
|
|
3204
|
-
d7 += h1 * r6;
|
|
3205
|
-
d7 += h2 * r5;
|
|
3206
|
-
d7 += h3 * r4;
|
|
3207
|
-
d7 += h4 * r3;
|
|
3208
|
-
c = d7 >>> 13;
|
|
3209
|
-
d7 &= 8191;
|
|
3210
|
-
d7 += h5 * r2;
|
|
3211
|
-
d7 += h6 * r1;
|
|
3212
|
-
d7 += h7 * r0;
|
|
3213
|
-
d7 += h8 * (5 * r9);
|
|
3214
|
-
d7 += h9 * (5 * r8);
|
|
3215
|
-
c += d7 >>> 13;
|
|
3216
|
-
d7 &= 8191;
|
|
3217
|
-
d8 = c;
|
|
3218
|
-
d8 += h0 * r8;
|
|
3219
|
-
d8 += h1 * r7;
|
|
3220
|
-
d8 += h2 * r6;
|
|
3221
|
-
d8 += h3 * r5;
|
|
3222
|
-
d8 += h4 * r4;
|
|
3223
|
-
c = d8 >>> 13;
|
|
3224
|
-
d8 &= 8191;
|
|
3225
|
-
d8 += h5 * r3;
|
|
3226
|
-
d8 += h6 * r2;
|
|
3227
|
-
d8 += h7 * r1;
|
|
3228
|
-
d8 += h8 * r0;
|
|
3229
|
-
d8 += h9 * (5 * r9);
|
|
3230
|
-
c += d8 >>> 13;
|
|
3231
|
-
d8 &= 8191;
|
|
3232
|
-
d9 = c;
|
|
3233
|
-
d9 += h0 * r9;
|
|
3234
|
-
d9 += h1 * r8;
|
|
3235
|
-
d9 += h2 * r7;
|
|
3236
|
-
d9 += h3 * r6;
|
|
3237
|
-
d9 += h4 * r5;
|
|
3238
|
-
c = d9 >>> 13;
|
|
3239
|
-
d9 &= 8191;
|
|
3240
|
-
d9 += h5 * r4;
|
|
3241
|
-
d9 += h6 * r3;
|
|
3242
|
-
d9 += h7 * r2;
|
|
3243
|
-
d9 += h8 * r1;
|
|
3244
|
-
d9 += h9 * r0;
|
|
3245
|
-
c += d9 >>> 13;
|
|
3246
|
-
d9 &= 8191;
|
|
3247
|
-
c = (c << 2) + c | 0;
|
|
3248
|
-
c = c + d0 | 0;
|
|
3249
|
-
d0 = c & 8191;
|
|
3250
|
-
c = c >>> 13;
|
|
3251
|
-
d1 += c;
|
|
3252
|
-
h0 = d0;
|
|
3253
|
-
h1 = d1;
|
|
3254
|
-
h2 = d2;
|
|
3255
|
-
h3 = d3;
|
|
3256
|
-
h4 = d4;
|
|
3257
|
-
h5 = d5;
|
|
3258
|
-
h6 = d6;
|
|
3259
|
-
h7 = d7;
|
|
3260
|
-
h8 = d8;
|
|
3261
|
-
h9 = d9;
|
|
3262
|
-
mpos += 16;
|
|
3263
|
-
bytes -= 16;
|
|
3264
|
-
}
|
|
3265
|
-
this.h[0] = h0;
|
|
3266
|
-
this.h[1] = h1;
|
|
3267
|
-
this.h[2] = h2;
|
|
3268
|
-
this.h[3] = h3;
|
|
3269
|
-
this.h[4] = h4;
|
|
3270
|
-
this.h[5] = h5;
|
|
3271
|
-
this.h[6] = h6;
|
|
3272
|
-
this.h[7] = h7;
|
|
3273
|
-
this.h[8] = h8;
|
|
3274
|
-
this.h[9] = h9;
|
|
3275
|
-
};
|
|
3276
|
-
poly1305.prototype.finish = function(mac, macpos) {
|
|
3277
|
-
var g = new Uint16Array(10);
|
|
3278
|
-
var c, mask, f, i;
|
|
3279
|
-
if (this.leftover) {
|
|
3280
|
-
i = this.leftover;
|
|
3281
|
-
this.buffer[i++] = 1;
|
|
3282
|
-
for (; i < 16; i++) this.buffer[i] = 0;
|
|
3283
|
-
this.fin = 1;
|
|
3284
|
-
this.blocks(this.buffer, 0, 16);
|
|
3285
|
-
}
|
|
3286
|
-
c = this.h[1] >>> 13;
|
|
3287
|
-
this.h[1] &= 8191;
|
|
3288
|
-
for (i = 2; i < 10; i++) {
|
|
3289
|
-
this.h[i] += c;
|
|
3290
|
-
c = this.h[i] >>> 13;
|
|
3291
|
-
this.h[i] &= 8191;
|
|
3292
|
-
}
|
|
3293
|
-
this.h[0] += c * 5;
|
|
3294
|
-
c = this.h[0] >>> 13;
|
|
3295
|
-
this.h[0] &= 8191;
|
|
3296
|
-
this.h[1] += c;
|
|
3297
|
-
c = this.h[1] >>> 13;
|
|
3298
|
-
this.h[1] &= 8191;
|
|
3299
|
-
this.h[2] += c;
|
|
3300
|
-
g[0] = this.h[0] + 5;
|
|
3301
|
-
c = g[0] >>> 13;
|
|
3302
|
-
g[0] &= 8191;
|
|
3303
|
-
for (i = 1; i < 10; i++) {
|
|
3304
|
-
g[i] = this.h[i] + c;
|
|
3305
|
-
c = g[i] >>> 13;
|
|
3306
|
-
g[i] &= 8191;
|
|
3307
|
-
}
|
|
3308
|
-
g[9] -= 1 << 13;
|
|
3309
|
-
mask = (c ^ 1) - 1;
|
|
3310
|
-
for (i = 0; i < 10; i++) g[i] &= mask;
|
|
3311
|
-
mask = ~mask;
|
|
3312
|
-
for (i = 0; i < 10; i++) this.h[i] = this.h[i] & mask | g[i];
|
|
3313
|
-
this.h[0] = (this.h[0] | this.h[1] << 13) & 65535;
|
|
3314
|
-
this.h[1] = (this.h[1] >>> 3 | this.h[2] << 10) & 65535;
|
|
3315
|
-
this.h[2] = (this.h[2] >>> 6 | this.h[3] << 7) & 65535;
|
|
3316
|
-
this.h[3] = (this.h[3] >>> 9 | this.h[4] << 4) & 65535;
|
|
3317
|
-
this.h[4] = (this.h[4] >>> 12 | this.h[5] << 1 | this.h[6] << 14) & 65535;
|
|
3318
|
-
this.h[5] = (this.h[6] >>> 2 | this.h[7] << 11) & 65535;
|
|
3319
|
-
this.h[6] = (this.h[7] >>> 5 | this.h[8] << 8) & 65535;
|
|
3320
|
-
this.h[7] = (this.h[8] >>> 8 | this.h[9] << 5) & 65535;
|
|
3321
|
-
f = this.h[0] + this.pad[0];
|
|
3322
|
-
this.h[0] = f & 65535;
|
|
3323
|
-
for (i = 1; i < 8; i++) {
|
|
3324
|
-
f = (this.h[i] + this.pad[i] | 0) + (f >>> 16) | 0;
|
|
3325
|
-
this.h[i] = f & 65535;
|
|
3326
|
-
}
|
|
3327
|
-
mac[macpos + 0] = this.h[0] >>> 0 & 255;
|
|
3328
|
-
mac[macpos + 1] = this.h[0] >>> 8 & 255;
|
|
3329
|
-
mac[macpos + 2] = this.h[1] >>> 0 & 255;
|
|
3330
|
-
mac[macpos + 3] = this.h[1] >>> 8 & 255;
|
|
3331
|
-
mac[macpos + 4] = this.h[2] >>> 0 & 255;
|
|
3332
|
-
mac[macpos + 5] = this.h[2] >>> 8 & 255;
|
|
3333
|
-
mac[macpos + 6] = this.h[3] >>> 0 & 255;
|
|
3334
|
-
mac[macpos + 7] = this.h[3] >>> 8 & 255;
|
|
3335
|
-
mac[macpos + 8] = this.h[4] >>> 0 & 255;
|
|
3336
|
-
mac[macpos + 9] = this.h[4] >>> 8 & 255;
|
|
3337
|
-
mac[macpos + 10] = this.h[5] >>> 0 & 255;
|
|
3338
|
-
mac[macpos + 11] = this.h[5] >>> 8 & 255;
|
|
3339
|
-
mac[macpos + 12] = this.h[6] >>> 0 & 255;
|
|
3340
|
-
mac[macpos + 13] = this.h[6] >>> 8 & 255;
|
|
3341
|
-
mac[macpos + 14] = this.h[7] >>> 0 & 255;
|
|
3342
|
-
mac[macpos + 15] = this.h[7] >>> 8 & 255;
|
|
3343
|
-
};
|
|
3344
|
-
poly1305.prototype.update = function(m, mpos, bytes) {
|
|
3345
|
-
var i, want;
|
|
3346
|
-
if (this.leftover) {
|
|
3347
|
-
want = 16 - this.leftover;
|
|
3348
|
-
if (want > bytes)
|
|
3349
|
-
want = bytes;
|
|
3350
|
-
for (i = 0; i < want; i++)
|
|
3351
|
-
this.buffer[this.leftover + i] = m[mpos + i];
|
|
3352
|
-
bytes -= want;
|
|
3353
|
-
mpos += want;
|
|
3354
|
-
this.leftover += want;
|
|
3355
|
-
if (this.leftover < 16)
|
|
3356
|
-
return;
|
|
3357
|
-
this.blocks(this.buffer, 0, 16);
|
|
3358
|
-
this.leftover = 0;
|
|
3359
|
-
}
|
|
3360
|
-
if (bytes >= 16) {
|
|
3361
|
-
want = bytes - bytes % 16;
|
|
3362
|
-
this.blocks(m, mpos, want);
|
|
3363
|
-
mpos += want;
|
|
3364
|
-
bytes -= want;
|
|
3365
|
-
}
|
|
3366
|
-
if (bytes) {
|
|
3367
|
-
for (i = 0; i < bytes; i++)
|
|
3368
|
-
this.buffer[this.leftover + i] = m[mpos + i];
|
|
3369
|
-
this.leftover += bytes;
|
|
3370
|
-
}
|
|
3371
|
-
};
|
|
3372
|
-
function crypto_onetimeauth(out, outpos, m, mpos, n, k) {
|
|
3373
|
-
var s = new poly1305(k);
|
|
3374
|
-
s.update(m, mpos, n);
|
|
3375
|
-
s.finish(out, outpos);
|
|
3376
|
-
return 0;
|
|
3377
|
-
}
|
|
3378
|
-
function crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {
|
|
3379
|
-
var x = new Uint8Array(16);
|
|
3380
|
-
crypto_onetimeauth(x, 0, m, mpos, n, k);
|
|
3381
|
-
return crypto_verify_16(h, hpos, x, 0);
|
|
3382
|
-
}
|
|
3383
|
-
function crypto_secretbox(c, m, d, n, k) {
|
|
3384
|
-
var i;
|
|
3385
|
-
if (d < 32) return -1;
|
|
3386
|
-
crypto_stream_xor(c, 0, m, 0, d, n, k);
|
|
3387
|
-
crypto_onetimeauth(c, 16, c, 32, d - 32, c);
|
|
3388
|
-
for (i = 0; i < 16; i++) c[i] = 0;
|
|
3389
|
-
return 0;
|
|
3390
|
-
}
|
|
3391
|
-
function crypto_secretbox_open(m, c, d, n, k) {
|
|
3392
|
-
var i;
|
|
3393
|
-
var x = new Uint8Array(32);
|
|
3394
|
-
if (d < 32) return -1;
|
|
3395
|
-
crypto_stream(x, 0, 32, n, k);
|
|
3396
|
-
if (crypto_onetimeauth_verify(c, 16, c, 32, d - 32, x) !== 0) return -1;
|
|
3397
|
-
crypto_stream_xor(m, 0, c, 0, d, n, k);
|
|
3398
|
-
for (i = 0; i < 32; i++) m[i] = 0;
|
|
3399
|
-
return 0;
|
|
3400
|
-
}
|
|
3401
|
-
function set25519(r, a) {
|
|
3402
|
-
var i;
|
|
3403
|
-
for (i = 0; i < 16; i++) r[i] = a[i] | 0;
|
|
3404
|
-
}
|
|
3405
|
-
function car25519(o) {
|
|
3406
|
-
var i, v, c = 1;
|
|
3407
|
-
for (i = 0; i < 16; i++) {
|
|
3408
|
-
v = o[i] + c + 65535;
|
|
3409
|
-
c = Math.floor(v / 65536);
|
|
3410
|
-
o[i] = v - c * 65536;
|
|
3411
|
-
}
|
|
3412
|
-
o[0] += c - 1 + 37 * (c - 1);
|
|
3413
|
-
}
|
|
3414
|
-
function sel25519(p, q, b) {
|
|
3415
|
-
var t2, c = ~(b - 1);
|
|
3416
|
-
for (var i = 0; i < 16; i++) {
|
|
3417
|
-
t2 = c & (p[i] ^ q[i]);
|
|
3418
|
-
p[i] ^= t2;
|
|
3419
|
-
q[i] ^= t2;
|
|
3420
|
-
}
|
|
3421
|
-
}
|
|
3422
|
-
function pack25519(o, n) {
|
|
3423
|
-
var i, j, b;
|
|
3424
|
-
var m = gf(), t2 = gf();
|
|
3425
|
-
for (i = 0; i < 16; i++) t2[i] = n[i];
|
|
3426
|
-
car25519(t2);
|
|
3427
|
-
car25519(t2);
|
|
3428
|
-
car25519(t2);
|
|
3429
|
-
for (j = 0; j < 2; j++) {
|
|
3430
|
-
m[0] = t2[0] - 65517;
|
|
3431
|
-
for (i = 1; i < 15; i++) {
|
|
3432
|
-
m[i] = t2[i] - 65535 - (m[i - 1] >> 16 & 1);
|
|
3433
|
-
m[i - 1] &= 65535;
|
|
3434
|
-
}
|
|
3435
|
-
m[15] = t2[15] - 32767 - (m[14] >> 16 & 1);
|
|
3436
|
-
b = m[15] >> 16 & 1;
|
|
3437
|
-
m[14] &= 65535;
|
|
3438
|
-
sel25519(t2, m, 1 - b);
|
|
3439
|
-
}
|
|
3440
|
-
for (i = 0; i < 16; i++) {
|
|
3441
|
-
o[2 * i] = t2[i] & 255;
|
|
3442
|
-
o[2 * i + 1] = t2[i] >> 8;
|
|
3443
|
-
}
|
|
3444
|
-
}
|
|
3445
|
-
function neq25519(a, b) {
|
|
3446
|
-
var c = new Uint8Array(32), d = new Uint8Array(32);
|
|
3447
|
-
pack25519(c, a);
|
|
3448
|
-
pack25519(d, b);
|
|
3449
|
-
return crypto_verify_32(c, 0, d, 0);
|
|
3450
|
-
}
|
|
3451
|
-
function par25519(a) {
|
|
3452
|
-
var d = new Uint8Array(32);
|
|
3453
|
-
pack25519(d, a);
|
|
3454
|
-
return d[0] & 1;
|
|
3455
|
-
}
|
|
3456
|
-
function unpack25519(o, n) {
|
|
3457
|
-
var i;
|
|
3458
|
-
for (i = 0; i < 16; i++) o[i] = n[2 * i] + (n[2 * i + 1] << 8);
|
|
3459
|
-
o[15] &= 32767;
|
|
3460
|
-
}
|
|
3461
|
-
function A(o, a, b) {
|
|
3462
|
-
for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];
|
|
3463
|
-
}
|
|
3464
|
-
function Z(o, a, b) {
|
|
3465
|
-
for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];
|
|
3466
|
-
}
|
|
3467
|
-
function M(o, a, b) {
|
|
3468
|
-
var v, c, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7], b8 = b[8], b9 = b[9], b10 = b[10], b11 = b[11], b12 = b[12], b13 = b[13], b14 = b[14], b15 = b[15];
|
|
3469
|
-
v = a[0];
|
|
3470
|
-
t0 += v * b0;
|
|
3471
|
-
t1 += v * b1;
|
|
3472
|
-
t2 += v * b2;
|
|
3473
|
-
t3 += v * b3;
|
|
3474
|
-
t4 += v * b4;
|
|
3475
|
-
t5 += v * b5;
|
|
3476
|
-
t6 += v * b6;
|
|
3477
|
-
t7 += v * b7;
|
|
3478
|
-
t8 += v * b8;
|
|
3479
|
-
t9 += v * b9;
|
|
3480
|
-
t10 += v * b10;
|
|
3481
|
-
t11 += v * b11;
|
|
3482
|
-
t12 += v * b12;
|
|
3483
|
-
t13 += v * b13;
|
|
3484
|
-
t14 += v * b14;
|
|
3485
|
-
t15 += v * b15;
|
|
3486
|
-
v = a[1];
|
|
3487
|
-
t1 += v * b0;
|
|
3488
|
-
t2 += v * b1;
|
|
3489
|
-
t3 += v * b2;
|
|
3490
|
-
t4 += v * b3;
|
|
3491
|
-
t5 += v * b4;
|
|
3492
|
-
t6 += v * b5;
|
|
3493
|
-
t7 += v * b6;
|
|
3494
|
-
t8 += v * b7;
|
|
3495
|
-
t9 += v * b8;
|
|
3496
|
-
t10 += v * b9;
|
|
3497
|
-
t11 += v * b10;
|
|
3498
|
-
t12 += v * b11;
|
|
3499
|
-
t13 += v * b12;
|
|
3500
|
-
t14 += v * b13;
|
|
3501
|
-
t15 += v * b14;
|
|
3502
|
-
t16 += v * b15;
|
|
3503
|
-
v = a[2];
|
|
3504
|
-
t2 += v * b0;
|
|
3505
|
-
t3 += v * b1;
|
|
3506
|
-
t4 += v * b2;
|
|
3507
|
-
t5 += v * b3;
|
|
3508
|
-
t6 += v * b4;
|
|
3509
|
-
t7 += v * b5;
|
|
3510
|
-
t8 += v * b6;
|
|
3511
|
-
t9 += v * b7;
|
|
3512
|
-
t10 += v * b8;
|
|
3513
|
-
t11 += v * b9;
|
|
3514
|
-
t12 += v * b10;
|
|
3515
|
-
t13 += v * b11;
|
|
3516
|
-
t14 += v * b12;
|
|
3517
|
-
t15 += v * b13;
|
|
3518
|
-
t16 += v * b14;
|
|
3519
|
-
t17 += v * b15;
|
|
3520
|
-
v = a[3];
|
|
3521
|
-
t3 += v * b0;
|
|
3522
|
-
t4 += v * b1;
|
|
3523
|
-
t5 += v * b2;
|
|
3524
|
-
t6 += v * b3;
|
|
3525
|
-
t7 += v * b4;
|
|
3526
|
-
t8 += v * b5;
|
|
3527
|
-
t9 += v * b6;
|
|
3528
|
-
t10 += v * b7;
|
|
3529
|
-
t11 += v * b8;
|
|
3530
|
-
t12 += v * b9;
|
|
3531
|
-
t13 += v * b10;
|
|
3532
|
-
t14 += v * b11;
|
|
3533
|
-
t15 += v * b12;
|
|
3534
|
-
t16 += v * b13;
|
|
3535
|
-
t17 += v * b14;
|
|
3536
|
-
t18 += v * b15;
|
|
3537
|
-
v = a[4];
|
|
3538
|
-
t4 += v * b0;
|
|
3539
|
-
t5 += v * b1;
|
|
3540
|
-
t6 += v * b2;
|
|
3541
|
-
t7 += v * b3;
|
|
3542
|
-
t8 += v * b4;
|
|
3543
|
-
t9 += v * b5;
|
|
3544
|
-
t10 += v * b6;
|
|
3545
|
-
t11 += v * b7;
|
|
3546
|
-
t12 += v * b8;
|
|
3547
|
-
t13 += v * b9;
|
|
3548
|
-
t14 += v * b10;
|
|
3549
|
-
t15 += v * b11;
|
|
3550
|
-
t16 += v * b12;
|
|
3551
|
-
t17 += v * b13;
|
|
3552
|
-
t18 += v * b14;
|
|
3553
|
-
t19 += v * b15;
|
|
3554
|
-
v = a[5];
|
|
3555
|
-
t5 += v * b0;
|
|
3556
|
-
t6 += v * b1;
|
|
3557
|
-
t7 += v * b2;
|
|
3558
|
-
t8 += v * b3;
|
|
3559
|
-
t9 += v * b4;
|
|
3560
|
-
t10 += v * b5;
|
|
3561
|
-
t11 += v * b6;
|
|
3562
|
-
t12 += v * b7;
|
|
3563
|
-
t13 += v * b8;
|
|
3564
|
-
t14 += v * b9;
|
|
3565
|
-
t15 += v * b10;
|
|
3566
|
-
t16 += v * b11;
|
|
3567
|
-
t17 += v * b12;
|
|
3568
|
-
t18 += v * b13;
|
|
3569
|
-
t19 += v * b14;
|
|
3570
|
-
t20 += v * b15;
|
|
3571
|
-
v = a[6];
|
|
3572
|
-
t6 += v * b0;
|
|
3573
|
-
t7 += v * b1;
|
|
3574
|
-
t8 += v * b2;
|
|
3575
|
-
t9 += v * b3;
|
|
3576
|
-
t10 += v * b4;
|
|
3577
|
-
t11 += v * b5;
|
|
3578
|
-
t12 += v * b6;
|
|
3579
|
-
t13 += v * b7;
|
|
3580
|
-
t14 += v * b8;
|
|
3581
|
-
t15 += v * b9;
|
|
3582
|
-
t16 += v * b10;
|
|
3583
|
-
t17 += v * b11;
|
|
3584
|
-
t18 += v * b12;
|
|
3585
|
-
t19 += v * b13;
|
|
3586
|
-
t20 += v * b14;
|
|
3587
|
-
t21 += v * b15;
|
|
3588
|
-
v = a[7];
|
|
3589
|
-
t7 += v * b0;
|
|
3590
|
-
t8 += v * b1;
|
|
3591
|
-
t9 += v * b2;
|
|
3592
|
-
t10 += v * b3;
|
|
3593
|
-
t11 += v * b4;
|
|
3594
|
-
t12 += v * b5;
|
|
3595
|
-
t13 += v * b6;
|
|
3596
|
-
t14 += v * b7;
|
|
3597
|
-
t15 += v * b8;
|
|
3598
|
-
t16 += v * b9;
|
|
3599
|
-
t17 += v * b10;
|
|
3600
|
-
t18 += v * b11;
|
|
3601
|
-
t19 += v * b12;
|
|
3602
|
-
t20 += v * b13;
|
|
3603
|
-
t21 += v * b14;
|
|
3604
|
-
t22 += v * b15;
|
|
3605
|
-
v = a[8];
|
|
3606
|
-
t8 += v * b0;
|
|
3607
|
-
t9 += v * b1;
|
|
3608
|
-
t10 += v * b2;
|
|
3609
|
-
t11 += v * b3;
|
|
3610
|
-
t12 += v * b4;
|
|
3611
|
-
t13 += v * b5;
|
|
3612
|
-
t14 += v * b6;
|
|
3613
|
-
t15 += v * b7;
|
|
3614
|
-
t16 += v * b8;
|
|
3615
|
-
t17 += v * b9;
|
|
3616
|
-
t18 += v * b10;
|
|
3617
|
-
t19 += v * b11;
|
|
3618
|
-
t20 += v * b12;
|
|
3619
|
-
t21 += v * b13;
|
|
3620
|
-
t22 += v * b14;
|
|
3621
|
-
t23 += v * b15;
|
|
3622
|
-
v = a[9];
|
|
3623
|
-
t9 += v * b0;
|
|
3624
|
-
t10 += v * b1;
|
|
3625
|
-
t11 += v * b2;
|
|
3626
|
-
t12 += v * b3;
|
|
3627
|
-
t13 += v * b4;
|
|
3628
|
-
t14 += v * b5;
|
|
3629
|
-
t15 += v * b6;
|
|
3630
|
-
t16 += v * b7;
|
|
3631
|
-
t17 += v * b8;
|
|
3632
|
-
t18 += v * b9;
|
|
3633
|
-
t19 += v * b10;
|
|
3634
|
-
t20 += v * b11;
|
|
3635
|
-
t21 += v * b12;
|
|
3636
|
-
t22 += v * b13;
|
|
3637
|
-
t23 += v * b14;
|
|
3638
|
-
t24 += v * b15;
|
|
3639
|
-
v = a[10];
|
|
3640
|
-
t10 += v * b0;
|
|
3641
|
-
t11 += v * b1;
|
|
3642
|
-
t12 += v * b2;
|
|
3643
|
-
t13 += v * b3;
|
|
3644
|
-
t14 += v * b4;
|
|
3645
|
-
t15 += v * b5;
|
|
3646
|
-
t16 += v * b6;
|
|
3647
|
-
t17 += v * b7;
|
|
3648
|
-
t18 += v * b8;
|
|
3649
|
-
t19 += v * b9;
|
|
3650
|
-
t20 += v * b10;
|
|
3651
|
-
t21 += v * b11;
|
|
3652
|
-
t22 += v * b12;
|
|
3653
|
-
t23 += v * b13;
|
|
3654
|
-
t24 += v * b14;
|
|
3655
|
-
t25 += v * b15;
|
|
3656
|
-
v = a[11];
|
|
3657
|
-
t11 += v * b0;
|
|
3658
|
-
t12 += v * b1;
|
|
3659
|
-
t13 += v * b2;
|
|
3660
|
-
t14 += v * b3;
|
|
3661
|
-
t15 += v * b4;
|
|
3662
|
-
t16 += v * b5;
|
|
3663
|
-
t17 += v * b6;
|
|
3664
|
-
t18 += v * b7;
|
|
3665
|
-
t19 += v * b8;
|
|
3666
|
-
t20 += v * b9;
|
|
3667
|
-
t21 += v * b10;
|
|
3668
|
-
t22 += v * b11;
|
|
3669
|
-
t23 += v * b12;
|
|
3670
|
-
t24 += v * b13;
|
|
3671
|
-
t25 += v * b14;
|
|
3672
|
-
t26 += v * b15;
|
|
3673
|
-
v = a[12];
|
|
3674
|
-
t12 += v * b0;
|
|
3675
|
-
t13 += v * b1;
|
|
3676
|
-
t14 += v * b2;
|
|
3677
|
-
t15 += v * b3;
|
|
3678
|
-
t16 += v * b4;
|
|
3679
|
-
t17 += v * b5;
|
|
3680
|
-
t18 += v * b6;
|
|
3681
|
-
t19 += v * b7;
|
|
3682
|
-
t20 += v * b8;
|
|
3683
|
-
t21 += v * b9;
|
|
3684
|
-
t22 += v * b10;
|
|
3685
|
-
t23 += v * b11;
|
|
3686
|
-
t24 += v * b12;
|
|
3687
|
-
t25 += v * b13;
|
|
3688
|
-
t26 += v * b14;
|
|
3689
|
-
t27 += v * b15;
|
|
3690
|
-
v = a[13];
|
|
3691
|
-
t13 += v * b0;
|
|
3692
|
-
t14 += v * b1;
|
|
3693
|
-
t15 += v * b2;
|
|
3694
|
-
t16 += v * b3;
|
|
3695
|
-
t17 += v * b4;
|
|
3696
|
-
t18 += v * b5;
|
|
3697
|
-
t19 += v * b6;
|
|
3698
|
-
t20 += v * b7;
|
|
3699
|
-
t21 += v * b8;
|
|
3700
|
-
t22 += v * b9;
|
|
3701
|
-
t23 += v * b10;
|
|
3702
|
-
t24 += v * b11;
|
|
3703
|
-
t25 += v * b12;
|
|
3704
|
-
t26 += v * b13;
|
|
3705
|
-
t27 += v * b14;
|
|
3706
|
-
t28 += v * b15;
|
|
3707
|
-
v = a[14];
|
|
3708
|
-
t14 += v * b0;
|
|
3709
|
-
t15 += v * b1;
|
|
3710
|
-
t16 += v * b2;
|
|
3711
|
-
t17 += v * b3;
|
|
3712
|
-
t18 += v * b4;
|
|
3713
|
-
t19 += v * b5;
|
|
3714
|
-
t20 += v * b6;
|
|
3715
|
-
t21 += v * b7;
|
|
3716
|
-
t22 += v * b8;
|
|
3717
|
-
t23 += v * b9;
|
|
3718
|
-
t24 += v * b10;
|
|
3719
|
-
t25 += v * b11;
|
|
3720
|
-
t26 += v * b12;
|
|
3721
|
-
t27 += v * b13;
|
|
3722
|
-
t28 += v * b14;
|
|
3723
|
-
t29 += v * b15;
|
|
3724
|
-
v = a[15];
|
|
3725
|
-
t15 += v * b0;
|
|
3726
|
-
t16 += v * b1;
|
|
3727
|
-
t17 += v * b2;
|
|
3728
|
-
t18 += v * b3;
|
|
3729
|
-
t19 += v * b4;
|
|
3730
|
-
t20 += v * b5;
|
|
3731
|
-
t21 += v * b6;
|
|
3732
|
-
t22 += v * b7;
|
|
3733
|
-
t23 += v * b8;
|
|
3734
|
-
t24 += v * b9;
|
|
3735
|
-
t25 += v * b10;
|
|
3736
|
-
t26 += v * b11;
|
|
3737
|
-
t27 += v * b12;
|
|
3738
|
-
t28 += v * b13;
|
|
3739
|
-
t29 += v * b14;
|
|
3740
|
-
t30 += v * b15;
|
|
3741
|
-
t0 += 38 * t16;
|
|
3742
|
-
t1 += 38 * t17;
|
|
3743
|
-
t2 += 38 * t18;
|
|
3744
|
-
t3 += 38 * t19;
|
|
3745
|
-
t4 += 38 * t20;
|
|
3746
|
-
t5 += 38 * t21;
|
|
3747
|
-
t6 += 38 * t22;
|
|
3748
|
-
t7 += 38 * t23;
|
|
3749
|
-
t8 += 38 * t24;
|
|
3750
|
-
t9 += 38 * t25;
|
|
3751
|
-
t10 += 38 * t26;
|
|
3752
|
-
t11 += 38 * t27;
|
|
3753
|
-
t12 += 38 * t28;
|
|
3754
|
-
t13 += 38 * t29;
|
|
3755
|
-
t14 += 38 * t30;
|
|
3756
|
-
c = 1;
|
|
3757
|
-
v = t0 + c + 65535;
|
|
3758
|
-
c = Math.floor(v / 65536);
|
|
3759
|
-
t0 = v - c * 65536;
|
|
3760
|
-
v = t1 + c + 65535;
|
|
3761
|
-
c = Math.floor(v / 65536);
|
|
3762
|
-
t1 = v - c * 65536;
|
|
3763
|
-
v = t2 + c + 65535;
|
|
3764
|
-
c = Math.floor(v / 65536);
|
|
3765
|
-
t2 = v - c * 65536;
|
|
3766
|
-
v = t3 + c + 65535;
|
|
3767
|
-
c = Math.floor(v / 65536);
|
|
3768
|
-
t3 = v - c * 65536;
|
|
3769
|
-
v = t4 + c + 65535;
|
|
3770
|
-
c = Math.floor(v / 65536);
|
|
3771
|
-
t4 = v - c * 65536;
|
|
3772
|
-
v = t5 + c + 65535;
|
|
3773
|
-
c = Math.floor(v / 65536);
|
|
3774
|
-
t5 = v - c * 65536;
|
|
3775
|
-
v = t6 + c + 65535;
|
|
3776
|
-
c = Math.floor(v / 65536);
|
|
3777
|
-
t6 = v - c * 65536;
|
|
3778
|
-
v = t7 + c + 65535;
|
|
3779
|
-
c = Math.floor(v / 65536);
|
|
3780
|
-
t7 = v - c * 65536;
|
|
3781
|
-
v = t8 + c + 65535;
|
|
3782
|
-
c = Math.floor(v / 65536);
|
|
3783
|
-
t8 = v - c * 65536;
|
|
3784
|
-
v = t9 + c + 65535;
|
|
3785
|
-
c = Math.floor(v / 65536);
|
|
3786
|
-
t9 = v - c * 65536;
|
|
3787
|
-
v = t10 + c + 65535;
|
|
3788
|
-
c = Math.floor(v / 65536);
|
|
3789
|
-
t10 = v - c * 65536;
|
|
3790
|
-
v = t11 + c + 65535;
|
|
3791
|
-
c = Math.floor(v / 65536);
|
|
3792
|
-
t11 = v - c * 65536;
|
|
3793
|
-
v = t12 + c + 65535;
|
|
3794
|
-
c = Math.floor(v / 65536);
|
|
3795
|
-
t12 = v - c * 65536;
|
|
3796
|
-
v = t13 + c + 65535;
|
|
3797
|
-
c = Math.floor(v / 65536);
|
|
3798
|
-
t13 = v - c * 65536;
|
|
3799
|
-
v = t14 + c + 65535;
|
|
3800
|
-
c = Math.floor(v / 65536);
|
|
3801
|
-
t14 = v - c * 65536;
|
|
3802
|
-
v = t15 + c + 65535;
|
|
3803
|
-
c = Math.floor(v / 65536);
|
|
3804
|
-
t15 = v - c * 65536;
|
|
3805
|
-
t0 += c - 1 + 37 * (c - 1);
|
|
3806
|
-
c = 1;
|
|
3807
|
-
v = t0 + c + 65535;
|
|
3808
|
-
c = Math.floor(v / 65536);
|
|
3809
|
-
t0 = v - c * 65536;
|
|
3810
|
-
v = t1 + c + 65535;
|
|
3811
|
-
c = Math.floor(v / 65536);
|
|
3812
|
-
t1 = v - c * 65536;
|
|
3813
|
-
v = t2 + c + 65535;
|
|
3814
|
-
c = Math.floor(v / 65536);
|
|
3815
|
-
t2 = v - c * 65536;
|
|
3816
|
-
v = t3 + c + 65535;
|
|
3817
|
-
c = Math.floor(v / 65536);
|
|
3818
|
-
t3 = v - c * 65536;
|
|
3819
|
-
v = t4 + c + 65535;
|
|
3820
|
-
c = Math.floor(v / 65536);
|
|
3821
|
-
t4 = v - c * 65536;
|
|
3822
|
-
v = t5 + c + 65535;
|
|
3823
|
-
c = Math.floor(v / 65536);
|
|
3824
|
-
t5 = v - c * 65536;
|
|
3825
|
-
v = t6 + c + 65535;
|
|
3826
|
-
c = Math.floor(v / 65536);
|
|
3827
|
-
t6 = v - c * 65536;
|
|
3828
|
-
v = t7 + c + 65535;
|
|
3829
|
-
c = Math.floor(v / 65536);
|
|
3830
|
-
t7 = v - c * 65536;
|
|
3831
|
-
v = t8 + c + 65535;
|
|
3832
|
-
c = Math.floor(v / 65536);
|
|
3833
|
-
t8 = v - c * 65536;
|
|
3834
|
-
v = t9 + c + 65535;
|
|
3835
|
-
c = Math.floor(v / 65536);
|
|
3836
|
-
t9 = v - c * 65536;
|
|
3837
|
-
v = t10 + c + 65535;
|
|
3838
|
-
c = Math.floor(v / 65536);
|
|
3839
|
-
t10 = v - c * 65536;
|
|
3840
|
-
v = t11 + c + 65535;
|
|
3841
|
-
c = Math.floor(v / 65536);
|
|
3842
|
-
t11 = v - c * 65536;
|
|
3843
|
-
v = t12 + c + 65535;
|
|
3844
|
-
c = Math.floor(v / 65536);
|
|
3845
|
-
t12 = v - c * 65536;
|
|
3846
|
-
v = t13 + c + 65535;
|
|
3847
|
-
c = Math.floor(v / 65536);
|
|
3848
|
-
t13 = v - c * 65536;
|
|
3849
|
-
v = t14 + c + 65535;
|
|
3850
|
-
c = Math.floor(v / 65536);
|
|
3851
|
-
t14 = v - c * 65536;
|
|
3852
|
-
v = t15 + c + 65535;
|
|
3853
|
-
c = Math.floor(v / 65536);
|
|
3854
|
-
t15 = v - c * 65536;
|
|
3855
|
-
t0 += c - 1 + 37 * (c - 1);
|
|
3856
|
-
o[0] = t0;
|
|
3857
|
-
o[1] = t1;
|
|
3858
|
-
o[2] = t2;
|
|
3859
|
-
o[3] = t3;
|
|
3860
|
-
o[4] = t4;
|
|
3861
|
-
o[5] = t5;
|
|
3862
|
-
o[6] = t6;
|
|
3863
|
-
o[7] = t7;
|
|
3864
|
-
o[8] = t8;
|
|
3865
|
-
o[9] = t9;
|
|
3866
|
-
o[10] = t10;
|
|
3867
|
-
o[11] = t11;
|
|
3868
|
-
o[12] = t12;
|
|
3869
|
-
o[13] = t13;
|
|
3870
|
-
o[14] = t14;
|
|
3871
|
-
o[15] = t15;
|
|
3872
|
-
}
|
|
3873
|
-
function S(o, a) {
|
|
3874
|
-
M(o, a, a);
|
|
3875
|
-
}
|
|
3876
|
-
function inv25519(o, i) {
|
|
3877
|
-
var c = gf();
|
|
3878
|
-
var a;
|
|
3879
|
-
for (a = 0; a < 16; a++) c[a] = i[a];
|
|
3880
|
-
for (a = 253; a >= 0; a--) {
|
|
3881
|
-
S(c, c);
|
|
3882
|
-
if (a !== 2 && a !== 4) M(c, c, i);
|
|
3883
|
-
}
|
|
3884
|
-
for (a = 0; a < 16; a++) o[a] = c[a];
|
|
3885
|
-
}
|
|
3886
|
-
function pow2523(o, i) {
|
|
3887
|
-
var c = gf();
|
|
3888
|
-
var a;
|
|
3889
|
-
for (a = 0; a < 16; a++) c[a] = i[a];
|
|
3890
|
-
for (a = 250; a >= 0; a--) {
|
|
3891
|
-
S(c, c);
|
|
3892
|
-
if (a !== 1) M(c, c, i);
|
|
3893
|
-
}
|
|
3894
|
-
for (a = 0; a < 16; a++) o[a] = c[a];
|
|
3895
|
-
}
|
|
3896
|
-
function crypto_scalarmult(q, n, p) {
|
|
3897
|
-
var z = new Uint8Array(32);
|
|
3898
|
-
var x = new Float64Array(80), r, i;
|
|
3899
|
-
var a = gf(), b = gf(), c = gf(), d = gf(), e = gf(), f = gf();
|
|
3900
|
-
for (i = 0; i < 31; i++) z[i] = n[i];
|
|
3901
|
-
z[31] = n[31] & 127 | 64;
|
|
3902
|
-
z[0] &= 248;
|
|
3903
|
-
unpack25519(x, p);
|
|
3904
|
-
for (i = 0; i < 16; i++) {
|
|
3905
|
-
b[i] = x[i];
|
|
3906
|
-
d[i] = a[i] = c[i] = 0;
|
|
3907
|
-
}
|
|
3908
|
-
a[0] = d[0] = 1;
|
|
3909
|
-
for (i = 254; i >= 0; --i) {
|
|
3910
|
-
r = z[i >>> 3] >>> (i & 7) & 1;
|
|
3911
|
-
sel25519(a, b, r);
|
|
3912
|
-
sel25519(c, d, r);
|
|
3913
|
-
A(e, a, c);
|
|
3914
|
-
Z(a, a, c);
|
|
3915
|
-
A(c, b, d);
|
|
3916
|
-
Z(b, b, d);
|
|
3917
|
-
S(d, e);
|
|
3918
|
-
S(f, a);
|
|
3919
|
-
M(a, c, a);
|
|
3920
|
-
M(c, b, e);
|
|
3921
|
-
A(e, a, c);
|
|
3922
|
-
Z(a, a, c);
|
|
3923
|
-
S(b, a);
|
|
3924
|
-
Z(c, d, f);
|
|
3925
|
-
M(a, c, _121665);
|
|
3926
|
-
A(a, a, d);
|
|
3927
|
-
M(c, c, a);
|
|
3928
|
-
M(a, d, f);
|
|
3929
|
-
M(d, b, x);
|
|
3930
|
-
S(b, e);
|
|
3931
|
-
sel25519(a, b, r);
|
|
3932
|
-
sel25519(c, d, r);
|
|
3933
|
-
}
|
|
3934
|
-
for (i = 0; i < 16; i++) {
|
|
3935
|
-
x[i + 16] = a[i];
|
|
3936
|
-
x[i + 32] = c[i];
|
|
3937
|
-
x[i + 48] = b[i];
|
|
3938
|
-
x[i + 64] = d[i];
|
|
3939
|
-
}
|
|
3940
|
-
var x32 = x.subarray(32);
|
|
3941
|
-
var x16 = x.subarray(16);
|
|
3942
|
-
inv25519(x32, x32);
|
|
3943
|
-
M(x16, x16, x32);
|
|
3944
|
-
pack25519(q, x16);
|
|
3945
|
-
return 0;
|
|
3946
|
-
}
|
|
3947
|
-
function crypto_scalarmult_base(q, n) {
|
|
3948
|
-
return crypto_scalarmult(q, n, _9);
|
|
3949
|
-
}
|
|
3950
|
-
function crypto_box_keypair(y, x) {
|
|
3951
|
-
randombytes(x, 32);
|
|
3952
|
-
return crypto_scalarmult_base(y, x);
|
|
3953
|
-
}
|
|
3954
|
-
function crypto_box_beforenm(k, y, x) {
|
|
3955
|
-
var s = new Uint8Array(32);
|
|
3956
|
-
crypto_scalarmult(s, x, y);
|
|
3957
|
-
return crypto_core_hsalsa20(k, _0, s, sigma);
|
|
3958
|
-
}
|
|
3959
|
-
var crypto_box_afternm = crypto_secretbox;
|
|
3960
|
-
var crypto_box_open_afternm = crypto_secretbox_open;
|
|
3961
|
-
function crypto_box(c, m, d, n, y, x) {
|
|
3962
|
-
var k = new Uint8Array(32);
|
|
3963
|
-
crypto_box_beforenm(k, y, x);
|
|
3964
|
-
return crypto_box_afternm(c, m, d, n, k);
|
|
3965
|
-
}
|
|
3966
|
-
function crypto_box_open(m, c, d, n, y, x) {
|
|
3967
|
-
var k = new Uint8Array(32);
|
|
3968
|
-
crypto_box_beforenm(k, y, x);
|
|
3969
|
-
return crypto_box_open_afternm(m, c, d, n, k);
|
|
3970
|
-
}
|
|
3971
|
-
var K = [
|
|
3972
|
-
1116352408,
|
|
3973
|
-
3609767458,
|
|
3974
|
-
1899447441,
|
|
3975
|
-
602891725,
|
|
3976
|
-
3049323471,
|
|
3977
|
-
3964484399,
|
|
3978
|
-
3921009573,
|
|
3979
|
-
2173295548,
|
|
3980
|
-
961987163,
|
|
3981
|
-
4081628472,
|
|
3982
|
-
1508970993,
|
|
3983
|
-
3053834265,
|
|
3984
|
-
2453635748,
|
|
3985
|
-
2937671579,
|
|
3986
|
-
2870763221,
|
|
3987
|
-
3664609560,
|
|
3988
|
-
3624381080,
|
|
3989
|
-
2734883394,
|
|
3990
|
-
310598401,
|
|
3991
|
-
1164996542,
|
|
3992
|
-
607225278,
|
|
3993
|
-
1323610764,
|
|
3994
|
-
1426881987,
|
|
3995
|
-
3590304994,
|
|
3996
|
-
1925078388,
|
|
3997
|
-
4068182383,
|
|
3998
|
-
2162078206,
|
|
3999
|
-
991336113,
|
|
4000
|
-
2614888103,
|
|
4001
|
-
633803317,
|
|
4002
|
-
3248222580,
|
|
4003
|
-
3479774868,
|
|
4004
|
-
3835390401,
|
|
4005
|
-
2666613458,
|
|
4006
|
-
4022224774,
|
|
4007
|
-
944711139,
|
|
4008
|
-
264347078,
|
|
4009
|
-
2341262773,
|
|
4010
|
-
604807628,
|
|
4011
|
-
2007800933,
|
|
4012
|
-
770255983,
|
|
4013
|
-
1495990901,
|
|
4014
|
-
1249150122,
|
|
4015
|
-
1856431235,
|
|
4016
|
-
1555081692,
|
|
4017
|
-
3175218132,
|
|
4018
|
-
1996064986,
|
|
4019
|
-
2198950837,
|
|
4020
|
-
2554220882,
|
|
4021
|
-
3999719339,
|
|
4022
|
-
2821834349,
|
|
4023
|
-
766784016,
|
|
4024
|
-
2952996808,
|
|
4025
|
-
2566594879,
|
|
4026
|
-
3210313671,
|
|
4027
|
-
3203337956,
|
|
4028
|
-
3336571891,
|
|
4029
|
-
1034457026,
|
|
4030
|
-
3584528711,
|
|
4031
|
-
2466948901,
|
|
4032
|
-
113926993,
|
|
4033
|
-
3758326383,
|
|
4034
|
-
338241895,
|
|
4035
|
-
168717936,
|
|
4036
|
-
666307205,
|
|
4037
|
-
1188179964,
|
|
4038
|
-
773529912,
|
|
4039
|
-
1546045734,
|
|
4040
|
-
1294757372,
|
|
4041
|
-
1522805485,
|
|
4042
|
-
1396182291,
|
|
4043
|
-
2643833823,
|
|
4044
|
-
1695183700,
|
|
4045
|
-
2343527390,
|
|
4046
|
-
1986661051,
|
|
4047
|
-
1014477480,
|
|
4048
|
-
2177026350,
|
|
4049
|
-
1206759142,
|
|
4050
|
-
2456956037,
|
|
4051
|
-
344077627,
|
|
4052
|
-
2730485921,
|
|
4053
|
-
1290863460,
|
|
4054
|
-
2820302411,
|
|
4055
|
-
3158454273,
|
|
4056
|
-
3259730800,
|
|
4057
|
-
3505952657,
|
|
4058
|
-
3345764771,
|
|
4059
|
-
106217008,
|
|
4060
|
-
3516065817,
|
|
4061
|
-
3606008344,
|
|
4062
|
-
3600352804,
|
|
4063
|
-
1432725776,
|
|
4064
|
-
4094571909,
|
|
4065
|
-
1467031594,
|
|
4066
|
-
275423344,
|
|
4067
|
-
851169720,
|
|
4068
|
-
430227734,
|
|
4069
|
-
3100823752,
|
|
4070
|
-
506948616,
|
|
4071
|
-
1363258195,
|
|
4072
|
-
659060556,
|
|
4073
|
-
3750685593,
|
|
4074
|
-
883997877,
|
|
4075
|
-
3785050280,
|
|
4076
|
-
958139571,
|
|
4077
|
-
3318307427,
|
|
4078
|
-
1322822218,
|
|
4079
|
-
3812723403,
|
|
4080
|
-
1537002063,
|
|
4081
|
-
2003034995,
|
|
4082
|
-
1747873779,
|
|
4083
|
-
3602036899,
|
|
4084
|
-
1955562222,
|
|
4085
|
-
1575990012,
|
|
4086
|
-
2024104815,
|
|
4087
|
-
1125592928,
|
|
4088
|
-
2227730452,
|
|
4089
|
-
2716904306,
|
|
4090
|
-
2361852424,
|
|
4091
|
-
442776044,
|
|
4092
|
-
2428436474,
|
|
4093
|
-
593698344,
|
|
4094
|
-
2756734187,
|
|
4095
|
-
3733110249,
|
|
4096
|
-
3204031479,
|
|
4097
|
-
2999351573,
|
|
4098
|
-
3329325298,
|
|
4099
|
-
3815920427,
|
|
4100
|
-
3391569614,
|
|
4101
|
-
3928383900,
|
|
4102
|
-
3515267271,
|
|
4103
|
-
566280711,
|
|
4104
|
-
3940187606,
|
|
4105
|
-
3454069534,
|
|
4106
|
-
4118630271,
|
|
4107
|
-
4000239992,
|
|
4108
|
-
116418474,
|
|
4109
|
-
1914138554,
|
|
4110
|
-
174292421,
|
|
4111
|
-
2731055270,
|
|
4112
|
-
289380356,
|
|
4113
|
-
3203993006,
|
|
4114
|
-
460393269,
|
|
4115
|
-
320620315,
|
|
4116
|
-
685471733,
|
|
4117
|
-
587496836,
|
|
4118
|
-
852142971,
|
|
4119
|
-
1086792851,
|
|
4120
|
-
1017036298,
|
|
4121
|
-
365543100,
|
|
4122
|
-
1126000580,
|
|
4123
|
-
2618297676,
|
|
4124
|
-
1288033470,
|
|
4125
|
-
3409855158,
|
|
4126
|
-
1501505948,
|
|
4127
|
-
4234509866,
|
|
4128
|
-
1607167915,
|
|
4129
|
-
987167468,
|
|
4130
|
-
1816402316,
|
|
4131
|
-
1246189591
|
|
4132
|
-
];
|
|
4133
|
-
function crypto_hashblocks_hl(hh, hl, m, n) {
|
|
4134
|
-
var wh = new Int32Array(16), wl = new Int32Array(16), bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7, bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7, th, tl, i, j, h, l, a, b, c, d;
|
|
4135
|
-
var ah0 = hh[0], ah1 = hh[1], ah2 = hh[2], ah3 = hh[3], ah4 = hh[4], ah5 = hh[5], ah6 = hh[6], ah7 = hh[7], al0 = hl[0], al1 = hl[1], al2 = hl[2], al3 = hl[3], al4 = hl[4], al5 = hl[5], al6 = hl[6], al7 = hl[7];
|
|
4136
|
-
var pos = 0;
|
|
4137
|
-
while (n >= 128) {
|
|
4138
|
-
for (i = 0; i < 16; i++) {
|
|
4139
|
-
j = 8 * i + pos;
|
|
4140
|
-
wh[i] = m[j + 0] << 24 | m[j + 1] << 16 | m[j + 2] << 8 | m[j + 3];
|
|
4141
|
-
wl[i] = m[j + 4] << 24 | m[j + 5] << 16 | m[j + 6] << 8 | m[j + 7];
|
|
4142
|
-
}
|
|
4143
|
-
for (i = 0; i < 80; i++) {
|
|
4144
|
-
bh0 = ah0;
|
|
4145
|
-
bh1 = ah1;
|
|
4146
|
-
bh2 = ah2;
|
|
4147
|
-
bh3 = ah3;
|
|
4148
|
-
bh4 = ah4;
|
|
4149
|
-
bh5 = ah5;
|
|
4150
|
-
bh6 = ah6;
|
|
4151
|
-
bh7 = ah7;
|
|
4152
|
-
bl0 = al0;
|
|
4153
|
-
bl1 = al1;
|
|
4154
|
-
bl2 = al2;
|
|
4155
|
-
bl3 = al3;
|
|
4156
|
-
bl4 = al4;
|
|
4157
|
-
bl5 = al5;
|
|
4158
|
-
bl6 = al6;
|
|
4159
|
-
bl7 = al7;
|
|
4160
|
-
h = ah7;
|
|
4161
|
-
l = al7;
|
|
4162
|
-
a = l & 65535;
|
|
4163
|
-
b = l >>> 16;
|
|
4164
|
-
c = h & 65535;
|
|
4165
|
-
d = h >>> 16;
|
|
4166
|
-
h = (ah4 >>> 14 | al4 << 32 - 14) ^ (ah4 >>> 18 | al4 << 32 - 18) ^ (al4 >>> 41 - 32 | ah4 << 32 - (41 - 32));
|
|
4167
|
-
l = (al4 >>> 14 | ah4 << 32 - 14) ^ (al4 >>> 18 | ah4 << 32 - 18) ^ (ah4 >>> 41 - 32 | al4 << 32 - (41 - 32));
|
|
4168
|
-
a += l & 65535;
|
|
4169
|
-
b += l >>> 16;
|
|
4170
|
-
c += h & 65535;
|
|
4171
|
-
d += h >>> 16;
|
|
4172
|
-
h = ah4 & ah5 ^ ~ah4 & ah6;
|
|
4173
|
-
l = al4 & al5 ^ ~al4 & al6;
|
|
4174
|
-
a += l & 65535;
|
|
4175
|
-
b += l >>> 16;
|
|
4176
|
-
c += h & 65535;
|
|
4177
|
-
d += h >>> 16;
|
|
4178
|
-
h = K[i * 2];
|
|
4179
|
-
l = K[i * 2 + 1];
|
|
4180
|
-
a += l & 65535;
|
|
4181
|
-
b += l >>> 16;
|
|
4182
|
-
c += h & 65535;
|
|
4183
|
-
d += h >>> 16;
|
|
4184
|
-
h = wh[i % 16];
|
|
4185
|
-
l = wl[i % 16];
|
|
4186
|
-
a += l & 65535;
|
|
4187
|
-
b += l >>> 16;
|
|
4188
|
-
c += h & 65535;
|
|
4189
|
-
d += h >>> 16;
|
|
4190
|
-
b += a >>> 16;
|
|
4191
|
-
c += b >>> 16;
|
|
4192
|
-
d += c >>> 16;
|
|
4193
|
-
th = c & 65535 | d << 16;
|
|
4194
|
-
tl = a & 65535 | b << 16;
|
|
4195
|
-
h = th;
|
|
4196
|
-
l = tl;
|
|
4197
|
-
a = l & 65535;
|
|
4198
|
-
b = l >>> 16;
|
|
4199
|
-
c = h & 65535;
|
|
4200
|
-
d = h >>> 16;
|
|
4201
|
-
h = (ah0 >>> 28 | al0 << 32 - 28) ^ (al0 >>> 34 - 32 | ah0 << 32 - (34 - 32)) ^ (al0 >>> 39 - 32 | ah0 << 32 - (39 - 32));
|
|
4202
|
-
l = (al0 >>> 28 | ah0 << 32 - 28) ^ (ah0 >>> 34 - 32 | al0 << 32 - (34 - 32)) ^ (ah0 >>> 39 - 32 | al0 << 32 - (39 - 32));
|
|
4203
|
-
a += l & 65535;
|
|
4204
|
-
b += l >>> 16;
|
|
4205
|
-
c += h & 65535;
|
|
4206
|
-
d += h >>> 16;
|
|
4207
|
-
h = ah0 & ah1 ^ ah0 & ah2 ^ ah1 & ah2;
|
|
4208
|
-
l = al0 & al1 ^ al0 & al2 ^ al1 & al2;
|
|
4209
|
-
a += l & 65535;
|
|
4210
|
-
b += l >>> 16;
|
|
4211
|
-
c += h & 65535;
|
|
4212
|
-
d += h >>> 16;
|
|
4213
|
-
b += a >>> 16;
|
|
4214
|
-
c += b >>> 16;
|
|
4215
|
-
d += c >>> 16;
|
|
4216
|
-
bh7 = c & 65535 | d << 16;
|
|
4217
|
-
bl7 = a & 65535 | b << 16;
|
|
4218
|
-
h = bh3;
|
|
4219
|
-
l = bl3;
|
|
4220
|
-
a = l & 65535;
|
|
4221
|
-
b = l >>> 16;
|
|
4222
|
-
c = h & 65535;
|
|
4223
|
-
d = h >>> 16;
|
|
4224
|
-
h = th;
|
|
4225
|
-
l = tl;
|
|
4226
|
-
a += l & 65535;
|
|
4227
|
-
b += l >>> 16;
|
|
4228
|
-
c += h & 65535;
|
|
4229
|
-
d += h >>> 16;
|
|
4230
|
-
b += a >>> 16;
|
|
4231
|
-
c += b >>> 16;
|
|
4232
|
-
d += c >>> 16;
|
|
4233
|
-
bh3 = c & 65535 | d << 16;
|
|
4234
|
-
bl3 = a & 65535 | b << 16;
|
|
4235
|
-
ah1 = bh0;
|
|
4236
|
-
ah2 = bh1;
|
|
4237
|
-
ah3 = bh2;
|
|
4238
|
-
ah4 = bh3;
|
|
4239
|
-
ah5 = bh4;
|
|
4240
|
-
ah6 = bh5;
|
|
4241
|
-
ah7 = bh6;
|
|
4242
|
-
ah0 = bh7;
|
|
4243
|
-
al1 = bl0;
|
|
4244
|
-
al2 = bl1;
|
|
4245
|
-
al3 = bl2;
|
|
4246
|
-
al4 = bl3;
|
|
4247
|
-
al5 = bl4;
|
|
4248
|
-
al6 = bl5;
|
|
4249
|
-
al7 = bl6;
|
|
4250
|
-
al0 = bl7;
|
|
4251
|
-
if (i % 16 === 15) {
|
|
4252
|
-
for (j = 0; j < 16; j++) {
|
|
4253
|
-
h = wh[j];
|
|
4254
|
-
l = wl[j];
|
|
4255
|
-
a = l & 65535;
|
|
4256
|
-
b = l >>> 16;
|
|
4257
|
-
c = h & 65535;
|
|
4258
|
-
d = h >>> 16;
|
|
4259
|
-
h = wh[(j + 9) % 16];
|
|
4260
|
-
l = wl[(j + 9) % 16];
|
|
4261
|
-
a += l & 65535;
|
|
4262
|
-
b += l >>> 16;
|
|
4263
|
-
c += h & 65535;
|
|
4264
|
-
d += h >>> 16;
|
|
4265
|
-
th = wh[(j + 1) % 16];
|
|
4266
|
-
tl = wl[(j + 1) % 16];
|
|
4267
|
-
h = (th >>> 1 | tl << 32 - 1) ^ (th >>> 8 | tl << 32 - 8) ^ th >>> 7;
|
|
4268
|
-
l = (tl >>> 1 | th << 32 - 1) ^ (tl >>> 8 | th << 32 - 8) ^ (tl >>> 7 | th << 32 - 7);
|
|
4269
|
-
a += l & 65535;
|
|
4270
|
-
b += l >>> 16;
|
|
4271
|
-
c += h & 65535;
|
|
4272
|
-
d += h >>> 16;
|
|
4273
|
-
th = wh[(j + 14) % 16];
|
|
4274
|
-
tl = wl[(j + 14) % 16];
|
|
4275
|
-
h = (th >>> 19 | tl << 32 - 19) ^ (tl >>> 61 - 32 | th << 32 - (61 - 32)) ^ th >>> 6;
|
|
4276
|
-
l = (tl >>> 19 | th << 32 - 19) ^ (th >>> 61 - 32 | tl << 32 - (61 - 32)) ^ (tl >>> 6 | th << 32 - 6);
|
|
4277
|
-
a += l & 65535;
|
|
4278
|
-
b += l >>> 16;
|
|
4279
|
-
c += h & 65535;
|
|
4280
|
-
d += h >>> 16;
|
|
4281
|
-
b += a >>> 16;
|
|
4282
|
-
c += b >>> 16;
|
|
4283
|
-
d += c >>> 16;
|
|
4284
|
-
wh[j] = c & 65535 | d << 16;
|
|
4285
|
-
wl[j] = a & 65535 | b << 16;
|
|
4286
|
-
}
|
|
4287
|
-
}
|
|
4288
|
-
}
|
|
4289
|
-
h = ah0;
|
|
4290
|
-
l = al0;
|
|
4291
|
-
a = l & 65535;
|
|
4292
|
-
b = l >>> 16;
|
|
4293
|
-
c = h & 65535;
|
|
4294
|
-
d = h >>> 16;
|
|
4295
|
-
h = hh[0];
|
|
4296
|
-
l = hl[0];
|
|
4297
|
-
a += l & 65535;
|
|
4298
|
-
b += l >>> 16;
|
|
4299
|
-
c += h & 65535;
|
|
4300
|
-
d += h >>> 16;
|
|
4301
|
-
b += a >>> 16;
|
|
4302
|
-
c += b >>> 16;
|
|
4303
|
-
d += c >>> 16;
|
|
4304
|
-
hh[0] = ah0 = c & 65535 | d << 16;
|
|
4305
|
-
hl[0] = al0 = a & 65535 | b << 16;
|
|
4306
|
-
h = ah1;
|
|
4307
|
-
l = al1;
|
|
4308
|
-
a = l & 65535;
|
|
4309
|
-
b = l >>> 16;
|
|
4310
|
-
c = h & 65535;
|
|
4311
|
-
d = h >>> 16;
|
|
4312
|
-
h = hh[1];
|
|
4313
|
-
l = hl[1];
|
|
4314
|
-
a += l & 65535;
|
|
4315
|
-
b += l >>> 16;
|
|
4316
|
-
c += h & 65535;
|
|
4317
|
-
d += h >>> 16;
|
|
4318
|
-
b += a >>> 16;
|
|
4319
|
-
c += b >>> 16;
|
|
4320
|
-
d += c >>> 16;
|
|
4321
|
-
hh[1] = ah1 = c & 65535 | d << 16;
|
|
4322
|
-
hl[1] = al1 = a & 65535 | b << 16;
|
|
4323
|
-
h = ah2;
|
|
4324
|
-
l = al2;
|
|
4325
|
-
a = l & 65535;
|
|
4326
|
-
b = l >>> 16;
|
|
4327
|
-
c = h & 65535;
|
|
4328
|
-
d = h >>> 16;
|
|
4329
|
-
h = hh[2];
|
|
4330
|
-
l = hl[2];
|
|
4331
|
-
a += l & 65535;
|
|
4332
|
-
b += l >>> 16;
|
|
4333
|
-
c += h & 65535;
|
|
4334
|
-
d += h >>> 16;
|
|
4335
|
-
b += a >>> 16;
|
|
4336
|
-
c += b >>> 16;
|
|
4337
|
-
d += c >>> 16;
|
|
4338
|
-
hh[2] = ah2 = c & 65535 | d << 16;
|
|
4339
|
-
hl[2] = al2 = a & 65535 | b << 16;
|
|
4340
|
-
h = ah3;
|
|
4341
|
-
l = al3;
|
|
4342
|
-
a = l & 65535;
|
|
4343
|
-
b = l >>> 16;
|
|
4344
|
-
c = h & 65535;
|
|
4345
|
-
d = h >>> 16;
|
|
4346
|
-
h = hh[3];
|
|
4347
|
-
l = hl[3];
|
|
4348
|
-
a += l & 65535;
|
|
4349
|
-
b += l >>> 16;
|
|
4350
|
-
c += h & 65535;
|
|
4351
|
-
d += h >>> 16;
|
|
4352
|
-
b += a >>> 16;
|
|
4353
|
-
c += b >>> 16;
|
|
4354
|
-
d += c >>> 16;
|
|
4355
|
-
hh[3] = ah3 = c & 65535 | d << 16;
|
|
4356
|
-
hl[3] = al3 = a & 65535 | b << 16;
|
|
4357
|
-
h = ah4;
|
|
4358
|
-
l = al4;
|
|
4359
|
-
a = l & 65535;
|
|
4360
|
-
b = l >>> 16;
|
|
4361
|
-
c = h & 65535;
|
|
4362
|
-
d = h >>> 16;
|
|
4363
|
-
h = hh[4];
|
|
4364
|
-
l = hl[4];
|
|
4365
|
-
a += l & 65535;
|
|
4366
|
-
b += l >>> 16;
|
|
4367
|
-
c += h & 65535;
|
|
4368
|
-
d += h >>> 16;
|
|
4369
|
-
b += a >>> 16;
|
|
4370
|
-
c += b >>> 16;
|
|
4371
|
-
d += c >>> 16;
|
|
4372
|
-
hh[4] = ah4 = c & 65535 | d << 16;
|
|
4373
|
-
hl[4] = al4 = a & 65535 | b << 16;
|
|
4374
|
-
h = ah5;
|
|
4375
|
-
l = al5;
|
|
4376
|
-
a = l & 65535;
|
|
4377
|
-
b = l >>> 16;
|
|
4378
|
-
c = h & 65535;
|
|
4379
|
-
d = h >>> 16;
|
|
4380
|
-
h = hh[5];
|
|
4381
|
-
l = hl[5];
|
|
4382
|
-
a += l & 65535;
|
|
4383
|
-
b += l >>> 16;
|
|
4384
|
-
c += h & 65535;
|
|
4385
|
-
d += h >>> 16;
|
|
4386
|
-
b += a >>> 16;
|
|
4387
|
-
c += b >>> 16;
|
|
4388
|
-
d += c >>> 16;
|
|
4389
|
-
hh[5] = ah5 = c & 65535 | d << 16;
|
|
4390
|
-
hl[5] = al5 = a & 65535 | b << 16;
|
|
4391
|
-
h = ah6;
|
|
4392
|
-
l = al6;
|
|
4393
|
-
a = l & 65535;
|
|
4394
|
-
b = l >>> 16;
|
|
4395
|
-
c = h & 65535;
|
|
4396
|
-
d = h >>> 16;
|
|
4397
|
-
h = hh[6];
|
|
4398
|
-
l = hl[6];
|
|
4399
|
-
a += l & 65535;
|
|
4400
|
-
b += l >>> 16;
|
|
4401
|
-
c += h & 65535;
|
|
4402
|
-
d += h >>> 16;
|
|
4403
|
-
b += a >>> 16;
|
|
4404
|
-
c += b >>> 16;
|
|
4405
|
-
d += c >>> 16;
|
|
4406
|
-
hh[6] = ah6 = c & 65535 | d << 16;
|
|
4407
|
-
hl[6] = al6 = a & 65535 | b << 16;
|
|
4408
|
-
h = ah7;
|
|
4409
|
-
l = al7;
|
|
4410
|
-
a = l & 65535;
|
|
4411
|
-
b = l >>> 16;
|
|
4412
|
-
c = h & 65535;
|
|
4413
|
-
d = h >>> 16;
|
|
4414
|
-
h = hh[7];
|
|
4415
|
-
l = hl[7];
|
|
4416
|
-
a += l & 65535;
|
|
4417
|
-
b += l >>> 16;
|
|
4418
|
-
c += h & 65535;
|
|
4419
|
-
d += h >>> 16;
|
|
4420
|
-
b += a >>> 16;
|
|
4421
|
-
c += b >>> 16;
|
|
4422
|
-
d += c >>> 16;
|
|
4423
|
-
hh[7] = ah7 = c & 65535 | d << 16;
|
|
4424
|
-
hl[7] = al7 = a & 65535 | b << 16;
|
|
4425
|
-
pos += 128;
|
|
4426
|
-
n -= 128;
|
|
4427
|
-
}
|
|
4428
|
-
return n;
|
|
4429
|
-
}
|
|
4430
|
-
function crypto_hash(out, m, n) {
|
|
4431
|
-
var hh = new Int32Array(8), hl = new Int32Array(8), x = new Uint8Array(256), i, b = n;
|
|
4432
|
-
hh[0] = 1779033703;
|
|
4433
|
-
hh[1] = 3144134277;
|
|
4434
|
-
hh[2] = 1013904242;
|
|
4435
|
-
hh[3] = 2773480762;
|
|
4436
|
-
hh[4] = 1359893119;
|
|
4437
|
-
hh[5] = 2600822924;
|
|
4438
|
-
hh[6] = 528734635;
|
|
4439
|
-
hh[7] = 1541459225;
|
|
4440
|
-
hl[0] = 4089235720;
|
|
4441
|
-
hl[1] = 2227873595;
|
|
4442
|
-
hl[2] = 4271175723;
|
|
4443
|
-
hl[3] = 1595750129;
|
|
4444
|
-
hl[4] = 2917565137;
|
|
4445
|
-
hl[5] = 725511199;
|
|
4446
|
-
hl[6] = 4215389547;
|
|
4447
|
-
hl[7] = 327033209;
|
|
4448
|
-
crypto_hashblocks_hl(hh, hl, m, n);
|
|
4449
|
-
n %= 128;
|
|
4450
|
-
for (i = 0; i < n; i++) x[i] = m[b - n + i];
|
|
4451
|
-
x[n] = 128;
|
|
4452
|
-
n = 256 - 128 * (n < 112 ? 1 : 0);
|
|
4453
|
-
x[n - 9] = 0;
|
|
4454
|
-
ts64(x, n - 8, b / 536870912 | 0, b << 3);
|
|
4455
|
-
crypto_hashblocks_hl(hh, hl, x, n);
|
|
4456
|
-
for (i = 0; i < 8; i++) ts64(out, 8 * i, hh[i], hl[i]);
|
|
4457
|
-
return 0;
|
|
4458
|
-
}
|
|
4459
|
-
function add2(p, q) {
|
|
4460
|
-
var a = gf(), b = gf(), c = gf(), d = gf(), e = gf(), f = gf(), g = gf(), h = gf(), t2 = gf();
|
|
4461
|
-
Z(a, p[1], p[0]);
|
|
4462
|
-
Z(t2, q[1], q[0]);
|
|
4463
|
-
M(a, a, t2);
|
|
4464
|
-
A(b, p[0], p[1]);
|
|
4465
|
-
A(t2, q[0], q[1]);
|
|
4466
|
-
M(b, b, t2);
|
|
4467
|
-
M(c, p[3], q[3]);
|
|
4468
|
-
M(c, c, D2);
|
|
4469
|
-
M(d, p[2], q[2]);
|
|
4470
|
-
A(d, d, d);
|
|
4471
|
-
Z(e, b, a);
|
|
4472
|
-
Z(f, d, c);
|
|
4473
|
-
A(g, d, c);
|
|
4474
|
-
A(h, b, a);
|
|
4475
|
-
M(p[0], e, f);
|
|
4476
|
-
M(p[1], h, g);
|
|
4477
|
-
M(p[2], g, f);
|
|
4478
|
-
M(p[3], e, h);
|
|
4479
|
-
}
|
|
4480
|
-
function cswap(p, q, b) {
|
|
4481
|
-
var i;
|
|
4482
|
-
for (i = 0; i < 4; i++) {
|
|
4483
|
-
sel25519(p[i], q[i], b);
|
|
4484
|
-
}
|
|
4485
|
-
}
|
|
4486
|
-
function pack(r, p) {
|
|
4487
|
-
var tx = gf(), ty = gf(), zi = gf();
|
|
4488
|
-
inv25519(zi, p[2]);
|
|
4489
|
-
M(tx, p[0], zi);
|
|
4490
|
-
M(ty, p[1], zi);
|
|
4491
|
-
pack25519(r, ty);
|
|
4492
|
-
r[31] ^= par25519(tx) << 7;
|
|
4493
|
-
}
|
|
4494
|
-
function scalarmult(p, q, s) {
|
|
4495
|
-
var b, i;
|
|
4496
|
-
set25519(p[0], gf0);
|
|
4497
|
-
set25519(p[1], gf1);
|
|
4498
|
-
set25519(p[2], gf1);
|
|
4499
|
-
set25519(p[3], gf0);
|
|
4500
|
-
for (i = 255; i >= 0; --i) {
|
|
4501
|
-
b = s[i / 8 | 0] >> (i & 7) & 1;
|
|
4502
|
-
cswap(p, q, b);
|
|
4503
|
-
add2(q, p);
|
|
4504
|
-
add2(p, p);
|
|
4505
|
-
cswap(p, q, b);
|
|
4506
|
-
}
|
|
4507
|
-
}
|
|
4508
|
-
function scalarbase(p, s) {
|
|
4509
|
-
var q = [gf(), gf(), gf(), gf()];
|
|
4510
|
-
set25519(q[0], X);
|
|
4511
|
-
set25519(q[1], Y);
|
|
4512
|
-
set25519(q[2], gf1);
|
|
4513
|
-
M(q[3], X, Y);
|
|
4514
|
-
scalarmult(p, q, s);
|
|
4515
|
-
}
|
|
4516
|
-
function crypto_sign_keypair(pk, sk, seeded) {
|
|
4517
|
-
var d = new Uint8Array(64);
|
|
4518
|
-
var p = [gf(), gf(), gf(), gf()];
|
|
4519
|
-
var i;
|
|
4520
|
-
if (!seeded) randombytes(sk, 32);
|
|
4521
|
-
crypto_hash(d, sk, 32);
|
|
4522
|
-
d[0] &= 248;
|
|
4523
|
-
d[31] &= 127;
|
|
4524
|
-
d[31] |= 64;
|
|
4525
|
-
scalarbase(p, d);
|
|
4526
|
-
pack(pk, p);
|
|
4527
|
-
for (i = 0; i < 32; i++) sk[i + 32] = pk[i];
|
|
4528
|
-
return 0;
|
|
4529
|
-
}
|
|
4530
|
-
var L = new Float64Array([237, 211, 245, 92, 26, 99, 18, 88, 214, 156, 247, 162, 222, 249, 222, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16]);
|
|
4531
|
-
function modL(r, x) {
|
|
4532
|
-
var carry, i, j, k;
|
|
4533
|
-
for (i = 63; i >= 32; --i) {
|
|
4534
|
-
carry = 0;
|
|
4535
|
-
for (j = i - 32, k = i - 12; j < k; ++j) {
|
|
4536
|
-
x[j] += carry - 16 * x[i] * L[j - (i - 32)];
|
|
4537
|
-
carry = Math.floor((x[j] + 128) / 256);
|
|
4538
|
-
x[j] -= carry * 256;
|
|
4539
|
-
}
|
|
4540
|
-
x[j] += carry;
|
|
4541
|
-
x[i] = 0;
|
|
4542
|
-
}
|
|
4543
|
-
carry = 0;
|
|
4544
|
-
for (j = 0; j < 32; j++) {
|
|
4545
|
-
x[j] += carry - (x[31] >> 4) * L[j];
|
|
4546
|
-
carry = x[j] >> 8;
|
|
4547
|
-
x[j] &= 255;
|
|
4548
|
-
}
|
|
4549
|
-
for (j = 0; j < 32; j++) x[j] -= carry * L[j];
|
|
4550
|
-
for (i = 0; i < 32; i++) {
|
|
4551
|
-
x[i + 1] += x[i] >> 8;
|
|
4552
|
-
r[i] = x[i] & 255;
|
|
4553
|
-
}
|
|
4554
|
-
}
|
|
4555
|
-
function reduce(r) {
|
|
4556
|
-
var x = new Float64Array(64), i;
|
|
4557
|
-
for (i = 0; i < 64; i++) x[i] = r[i];
|
|
4558
|
-
for (i = 0; i < 64; i++) r[i] = 0;
|
|
4559
|
-
modL(r, x);
|
|
4560
|
-
}
|
|
4561
|
-
function crypto_sign(sm, m, n, sk) {
|
|
4562
|
-
var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);
|
|
4563
|
-
var i, j, x = new Float64Array(64);
|
|
4564
|
-
var p = [gf(), gf(), gf(), gf()];
|
|
4565
|
-
crypto_hash(d, sk, 32);
|
|
4566
|
-
d[0] &= 248;
|
|
4567
|
-
d[31] &= 127;
|
|
4568
|
-
d[31] |= 64;
|
|
4569
|
-
var smlen = n + 64;
|
|
4570
|
-
for (i = 0; i < n; i++) sm[64 + i] = m[i];
|
|
4571
|
-
for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];
|
|
4572
|
-
crypto_hash(r, sm.subarray(32), n + 32);
|
|
4573
|
-
reduce(r);
|
|
4574
|
-
scalarbase(p, r);
|
|
4575
|
-
pack(sm, p);
|
|
4576
|
-
for (i = 32; i < 64; i++) sm[i] = sk[i];
|
|
4577
|
-
crypto_hash(h, sm, n + 64);
|
|
4578
|
-
reduce(h);
|
|
4579
|
-
for (i = 0; i < 64; i++) x[i] = 0;
|
|
4580
|
-
for (i = 0; i < 32; i++) x[i] = r[i];
|
|
4581
|
-
for (i = 0; i < 32; i++) {
|
|
4582
|
-
for (j = 0; j < 32; j++) {
|
|
4583
|
-
x[i + j] += h[i] * d[j];
|
|
4584
|
-
}
|
|
4585
|
-
}
|
|
4586
|
-
modL(sm.subarray(32), x);
|
|
4587
|
-
return smlen;
|
|
4588
|
-
}
|
|
4589
|
-
function unpackneg(r, p) {
|
|
4590
|
-
var t2 = gf(), chk = gf(), num = gf(), den = gf(), den2 = gf(), den4 = gf(), den6 = gf();
|
|
4591
|
-
set25519(r[2], gf1);
|
|
4592
|
-
unpack25519(r[1], p);
|
|
4593
|
-
S(num, r[1]);
|
|
4594
|
-
M(den, num, D);
|
|
4595
|
-
Z(num, num, r[2]);
|
|
4596
|
-
A(den, r[2], den);
|
|
4597
|
-
S(den2, den);
|
|
4598
|
-
S(den4, den2);
|
|
4599
|
-
M(den6, den4, den2);
|
|
4600
|
-
M(t2, den6, num);
|
|
4601
|
-
M(t2, t2, den);
|
|
4602
|
-
pow2523(t2, t2);
|
|
4603
|
-
M(t2, t2, num);
|
|
4604
|
-
M(t2, t2, den);
|
|
4605
|
-
M(t2, t2, den);
|
|
4606
|
-
M(r[0], t2, den);
|
|
4607
|
-
S(chk, r[0]);
|
|
4608
|
-
M(chk, chk, den);
|
|
4609
|
-
if (neq25519(chk, num)) M(r[0], r[0], I);
|
|
4610
|
-
S(chk, r[0]);
|
|
4611
|
-
M(chk, chk, den);
|
|
4612
|
-
if (neq25519(chk, num)) return -1;
|
|
4613
|
-
if (par25519(r[0]) === p[31] >> 7) Z(r[0], gf0, r[0]);
|
|
4614
|
-
M(r[3], r[0], r[1]);
|
|
4615
|
-
return 0;
|
|
4616
|
-
}
|
|
4617
|
-
function crypto_sign_open(m, sm, n, pk) {
|
|
4618
|
-
var i;
|
|
4619
|
-
var t2 = new Uint8Array(32), h = new Uint8Array(64);
|
|
4620
|
-
var p = [gf(), gf(), gf(), gf()], q = [gf(), gf(), gf(), gf()];
|
|
4621
|
-
if (n < 64) return -1;
|
|
4622
|
-
if (unpackneg(q, pk)) return -1;
|
|
4623
|
-
for (i = 0; i < n; i++) m[i] = sm[i];
|
|
4624
|
-
for (i = 0; i < 32; i++) m[i + 32] = pk[i];
|
|
4625
|
-
crypto_hash(h, m, n);
|
|
4626
|
-
reduce(h);
|
|
4627
|
-
scalarmult(p, q, h);
|
|
4628
|
-
scalarbase(q, sm.subarray(32));
|
|
4629
|
-
add2(p, q);
|
|
4630
|
-
pack(t2, p);
|
|
4631
|
-
n -= 64;
|
|
4632
|
-
if (crypto_verify_32(sm, 0, t2, 0)) {
|
|
4633
|
-
for (i = 0; i < n; i++) m[i] = 0;
|
|
4634
|
-
return -1;
|
|
4635
|
-
}
|
|
4636
|
-
for (i = 0; i < n; i++) m[i] = sm[i + 64];
|
|
4637
|
-
return n;
|
|
4638
|
-
}
|
|
4639
|
-
var crypto_secretbox_KEYBYTES = 32, crypto_secretbox_NONCEBYTES = 24, crypto_secretbox_ZEROBYTES = 32, crypto_secretbox_BOXZEROBYTES = 16, crypto_scalarmult_BYTES = 32, crypto_scalarmult_SCALARBYTES = 32, crypto_box_PUBLICKEYBYTES = 32, crypto_box_SECRETKEYBYTES = 32, crypto_box_BEFORENMBYTES = 32, crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES, crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES, crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES, crypto_sign_BYTES = 64, crypto_sign_PUBLICKEYBYTES = 32, crypto_sign_SECRETKEYBYTES = 64, crypto_sign_SEEDBYTES = 32, crypto_hash_BYTES = 64;
|
|
4640
|
-
nacl4.lowlevel = {
|
|
4641
|
-
crypto_core_hsalsa20,
|
|
4642
|
-
crypto_stream_xor,
|
|
4643
|
-
crypto_stream,
|
|
4644
|
-
crypto_stream_salsa20_xor,
|
|
4645
|
-
crypto_stream_salsa20,
|
|
4646
|
-
crypto_onetimeauth,
|
|
4647
|
-
crypto_onetimeauth_verify,
|
|
4648
|
-
crypto_verify_16,
|
|
4649
|
-
crypto_verify_32,
|
|
4650
|
-
crypto_secretbox,
|
|
4651
|
-
crypto_secretbox_open,
|
|
4652
|
-
crypto_scalarmult,
|
|
4653
|
-
crypto_scalarmult_base,
|
|
4654
|
-
crypto_box_beforenm,
|
|
4655
|
-
crypto_box_afternm,
|
|
4656
|
-
crypto_box,
|
|
4657
|
-
crypto_box_open,
|
|
4658
|
-
crypto_box_keypair,
|
|
4659
|
-
crypto_hash,
|
|
4660
|
-
crypto_sign,
|
|
4661
|
-
crypto_sign_keypair,
|
|
4662
|
-
crypto_sign_open,
|
|
4663
|
-
crypto_secretbox_KEYBYTES,
|
|
4664
|
-
crypto_secretbox_NONCEBYTES,
|
|
4665
|
-
crypto_secretbox_ZEROBYTES,
|
|
4666
|
-
crypto_secretbox_BOXZEROBYTES,
|
|
4667
|
-
crypto_scalarmult_BYTES,
|
|
4668
|
-
crypto_scalarmult_SCALARBYTES,
|
|
4669
|
-
crypto_box_PUBLICKEYBYTES,
|
|
4670
|
-
crypto_box_SECRETKEYBYTES,
|
|
4671
|
-
crypto_box_BEFORENMBYTES,
|
|
4672
|
-
crypto_box_NONCEBYTES,
|
|
4673
|
-
crypto_box_ZEROBYTES,
|
|
4674
|
-
crypto_box_BOXZEROBYTES,
|
|
4675
|
-
crypto_sign_BYTES,
|
|
4676
|
-
crypto_sign_PUBLICKEYBYTES,
|
|
4677
|
-
crypto_sign_SECRETKEYBYTES,
|
|
4678
|
-
crypto_sign_SEEDBYTES,
|
|
4679
|
-
crypto_hash_BYTES,
|
|
4680
|
-
gf,
|
|
4681
|
-
D,
|
|
4682
|
-
L,
|
|
4683
|
-
pack25519,
|
|
4684
|
-
unpack25519,
|
|
4685
|
-
M,
|
|
4686
|
-
A,
|
|
4687
|
-
S,
|
|
4688
|
-
Z,
|
|
4689
|
-
pow2523,
|
|
4690
|
-
add: add2,
|
|
4691
|
-
set25519,
|
|
4692
|
-
modL,
|
|
4693
|
-
scalarmult,
|
|
4694
|
-
scalarbase
|
|
4695
|
-
};
|
|
4696
|
-
function checkLengths(k, n) {
|
|
4697
|
-
if (k.length !== crypto_secretbox_KEYBYTES) throw new Error("bad key size");
|
|
4698
|
-
if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error("bad nonce size");
|
|
4699
|
-
}
|
|
4700
|
-
function checkBoxLengths(pk, sk) {
|
|
4701
|
-
if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error("bad public key size");
|
|
4702
|
-
if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error("bad secret key size");
|
|
4703
|
-
}
|
|
4704
|
-
function checkArrayTypes() {
|
|
4705
|
-
for (var i = 0; i < arguments.length; i++) {
|
|
4706
|
-
if (!(arguments[i] instanceof Uint8Array))
|
|
4707
|
-
throw new TypeError("unexpected type, use Uint8Array");
|
|
4708
|
-
}
|
|
4709
|
-
}
|
|
4710
|
-
function cleanup(arr) {
|
|
4711
|
-
for (var i = 0; i < arr.length; i++) arr[i] = 0;
|
|
4712
|
-
}
|
|
4713
|
-
nacl4.randomBytes = function(n) {
|
|
4714
|
-
var b = new Uint8Array(n);
|
|
4715
|
-
randombytes(b, n);
|
|
4716
|
-
return b;
|
|
4717
|
-
};
|
|
4718
|
-
nacl4.secretbox = function(msg, nonce, key) {
|
|
4719
|
-
checkArrayTypes(msg, nonce, key);
|
|
4720
|
-
checkLengths(key, nonce);
|
|
4721
|
-
var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);
|
|
4722
|
-
var c = new Uint8Array(m.length);
|
|
4723
|
-
for (var i = 0; i < msg.length; i++) m[i + crypto_secretbox_ZEROBYTES] = msg[i];
|
|
4724
|
-
crypto_secretbox(c, m, m.length, nonce, key);
|
|
4725
|
-
return c.subarray(crypto_secretbox_BOXZEROBYTES);
|
|
4726
|
-
};
|
|
4727
|
-
nacl4.secretbox.open = function(box, nonce, key) {
|
|
4728
|
-
checkArrayTypes(box, nonce, key);
|
|
4729
|
-
checkLengths(key, nonce);
|
|
4730
|
-
var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);
|
|
4731
|
-
var m = new Uint8Array(c.length);
|
|
4732
|
-
for (var i = 0; i < box.length; i++) c[i + crypto_secretbox_BOXZEROBYTES] = box[i];
|
|
4733
|
-
if (c.length < 32) return null;
|
|
4734
|
-
if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;
|
|
4735
|
-
return m.subarray(crypto_secretbox_ZEROBYTES);
|
|
4736
|
-
};
|
|
4737
|
-
nacl4.secretbox.keyLength = crypto_secretbox_KEYBYTES;
|
|
4738
|
-
nacl4.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;
|
|
4739
|
-
nacl4.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;
|
|
4740
|
-
nacl4.scalarMult = function(n, p) {
|
|
4741
|
-
checkArrayTypes(n, p);
|
|
4742
|
-
if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error("bad n size");
|
|
4743
|
-
if (p.length !== crypto_scalarmult_BYTES) throw new Error("bad p size");
|
|
4744
|
-
var q = new Uint8Array(crypto_scalarmult_BYTES);
|
|
4745
|
-
crypto_scalarmult(q, n, p);
|
|
4746
|
-
return q;
|
|
4747
|
-
};
|
|
4748
|
-
nacl4.scalarMult.base = function(n) {
|
|
4749
|
-
checkArrayTypes(n);
|
|
4750
|
-
if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error("bad n size");
|
|
4751
|
-
var q = new Uint8Array(crypto_scalarmult_BYTES);
|
|
4752
|
-
crypto_scalarmult_base(q, n);
|
|
4753
|
-
return q;
|
|
4754
|
-
};
|
|
4755
|
-
nacl4.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;
|
|
4756
|
-
nacl4.scalarMult.groupElementLength = crypto_scalarmult_BYTES;
|
|
4757
|
-
nacl4.box = function(msg, nonce, publicKey, secretKey) {
|
|
4758
|
-
var k = nacl4.box.before(publicKey, secretKey);
|
|
4759
|
-
return nacl4.secretbox(msg, nonce, k);
|
|
4760
|
-
};
|
|
4761
|
-
nacl4.box.before = function(publicKey, secretKey) {
|
|
4762
|
-
checkArrayTypes(publicKey, secretKey);
|
|
4763
|
-
checkBoxLengths(publicKey, secretKey);
|
|
4764
|
-
var k = new Uint8Array(crypto_box_BEFORENMBYTES);
|
|
4765
|
-
crypto_box_beforenm(k, publicKey, secretKey);
|
|
4766
|
-
return k;
|
|
4767
|
-
};
|
|
4768
|
-
nacl4.box.after = nacl4.secretbox;
|
|
4769
|
-
nacl4.box.open = function(msg, nonce, publicKey, secretKey) {
|
|
4770
|
-
var k = nacl4.box.before(publicKey, secretKey);
|
|
4771
|
-
return nacl4.secretbox.open(msg, nonce, k);
|
|
4772
|
-
};
|
|
4773
|
-
nacl4.box.open.after = nacl4.secretbox.open;
|
|
4774
|
-
nacl4.box.keyPair = function() {
|
|
4775
|
-
var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
|
|
4776
|
-
var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);
|
|
4777
|
-
crypto_box_keypair(pk, sk);
|
|
4778
|
-
return { publicKey: pk, secretKey: sk };
|
|
4779
|
-
};
|
|
4780
|
-
nacl4.box.keyPair.fromSecretKey = function(secretKey) {
|
|
4781
|
-
checkArrayTypes(secretKey);
|
|
4782
|
-
if (secretKey.length !== crypto_box_SECRETKEYBYTES)
|
|
4783
|
-
throw new Error("bad secret key size");
|
|
4784
|
-
var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
|
|
4785
|
-
crypto_scalarmult_base(pk, secretKey);
|
|
4786
|
-
return { publicKey: pk, secretKey: new Uint8Array(secretKey) };
|
|
4787
|
-
};
|
|
4788
|
-
nacl4.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;
|
|
4789
|
-
nacl4.box.secretKeyLength = crypto_box_SECRETKEYBYTES;
|
|
4790
|
-
nacl4.box.sharedKeyLength = crypto_box_BEFORENMBYTES;
|
|
4791
|
-
nacl4.box.nonceLength = crypto_box_NONCEBYTES;
|
|
4792
|
-
nacl4.box.overheadLength = nacl4.secretbox.overheadLength;
|
|
4793
|
-
nacl4.sign = function(msg, secretKey) {
|
|
4794
|
-
checkArrayTypes(msg, secretKey);
|
|
4795
|
-
if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
|
|
4796
|
-
throw new Error("bad secret key size");
|
|
4797
|
-
var signedMsg = new Uint8Array(crypto_sign_BYTES + msg.length);
|
|
4798
|
-
crypto_sign(signedMsg, msg, msg.length, secretKey);
|
|
4799
|
-
return signedMsg;
|
|
4800
|
-
};
|
|
4801
|
-
nacl4.sign.open = function(signedMsg, publicKey) {
|
|
4802
|
-
checkArrayTypes(signedMsg, publicKey);
|
|
4803
|
-
if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
|
|
4804
|
-
throw new Error("bad public key size");
|
|
4805
|
-
var tmp = new Uint8Array(signedMsg.length);
|
|
4806
|
-
var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);
|
|
4807
|
-
if (mlen < 0) return null;
|
|
4808
|
-
var m = new Uint8Array(mlen);
|
|
4809
|
-
for (var i = 0; i < m.length; i++) m[i] = tmp[i];
|
|
4810
|
-
return m;
|
|
4811
|
-
};
|
|
4812
|
-
nacl4.sign.detached = function(msg, secretKey) {
|
|
4813
|
-
var signedMsg = nacl4.sign(msg, secretKey);
|
|
4814
|
-
var sig = new Uint8Array(crypto_sign_BYTES);
|
|
4815
|
-
for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];
|
|
4816
|
-
return sig;
|
|
4817
|
-
};
|
|
4818
|
-
nacl4.sign.detached.verify = function(msg, sig, publicKey) {
|
|
4819
|
-
checkArrayTypes(msg, sig, publicKey);
|
|
4820
|
-
if (sig.length !== crypto_sign_BYTES)
|
|
4821
|
-
throw new Error("bad signature size");
|
|
4822
|
-
if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
|
|
4823
|
-
throw new Error("bad public key size");
|
|
4824
|
-
var sm = new Uint8Array(crypto_sign_BYTES + msg.length);
|
|
4825
|
-
var m = new Uint8Array(crypto_sign_BYTES + msg.length);
|
|
4826
|
-
var i;
|
|
4827
|
-
for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];
|
|
4828
|
-
for (i = 0; i < msg.length; i++) sm[i + crypto_sign_BYTES] = msg[i];
|
|
4829
|
-
return crypto_sign_open(m, sm, sm.length, publicKey) >= 0;
|
|
4830
|
-
};
|
|
4831
|
-
nacl4.sign.keyPair = function() {
|
|
4832
|
-
var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
|
|
4833
|
-
var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
|
|
4834
|
-
crypto_sign_keypair(pk, sk);
|
|
4835
|
-
return { publicKey: pk, secretKey: sk };
|
|
4836
|
-
};
|
|
4837
|
-
nacl4.sign.keyPair.fromSecretKey = function(secretKey) {
|
|
4838
|
-
checkArrayTypes(secretKey);
|
|
4839
|
-
if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
|
|
4840
|
-
throw new Error("bad secret key size");
|
|
4841
|
-
var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
|
|
4842
|
-
for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32 + i];
|
|
4843
|
-
return { publicKey: pk, secretKey: new Uint8Array(secretKey) };
|
|
4844
|
-
};
|
|
4845
|
-
nacl4.sign.keyPair.fromSeed = function(seed) {
|
|
4846
|
-
checkArrayTypes(seed);
|
|
4847
|
-
if (seed.length !== crypto_sign_SEEDBYTES)
|
|
4848
|
-
throw new Error("bad seed size");
|
|
4849
|
-
var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
|
|
4850
|
-
var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
|
|
4851
|
-
for (var i = 0; i < 32; i++) sk[i] = seed[i];
|
|
4852
|
-
crypto_sign_keypair(pk, sk, true);
|
|
4853
|
-
return { publicKey: pk, secretKey: sk };
|
|
4854
|
-
};
|
|
4855
|
-
nacl4.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;
|
|
4856
|
-
nacl4.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;
|
|
4857
|
-
nacl4.sign.seedLength = crypto_sign_SEEDBYTES;
|
|
4858
|
-
nacl4.sign.signatureLength = crypto_sign_BYTES;
|
|
4859
|
-
nacl4.hash = function(msg) {
|
|
4860
|
-
checkArrayTypes(msg);
|
|
4861
|
-
var h = new Uint8Array(crypto_hash_BYTES);
|
|
4862
|
-
crypto_hash(h, msg, msg.length);
|
|
4863
|
-
return h;
|
|
4864
|
-
};
|
|
4865
|
-
nacl4.hash.hashLength = crypto_hash_BYTES;
|
|
4866
|
-
nacl4.verify = function(x, y) {
|
|
4867
|
-
checkArrayTypes(x, y);
|
|
4868
|
-
if (x.length === 0 || y.length === 0) return false;
|
|
4869
|
-
if (x.length !== y.length) return false;
|
|
4870
|
-
return vn(x, 0, y, 0, x.length) === 0 ? true : false;
|
|
4871
|
-
};
|
|
4872
|
-
nacl4.setPRNG = function(fn) {
|
|
4873
|
-
randombytes = fn;
|
|
4874
|
-
};
|
|
4875
|
-
(function() {
|
|
4876
|
-
var crypto = typeof self !== "undefined" ? self.crypto || self.msCrypto : null;
|
|
4877
|
-
if (crypto && crypto.getRandomValues) {
|
|
4878
|
-
var QUOTA = 65536;
|
|
4879
|
-
nacl4.setPRNG(function(x, n) {
|
|
4880
|
-
var i, v = new Uint8Array(n);
|
|
4881
|
-
for (i = 0; i < n; i += QUOTA) {
|
|
4882
|
-
crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));
|
|
4883
|
-
}
|
|
4884
|
-
for (i = 0; i < n; i++) x[i] = v[i];
|
|
4885
|
-
cleanup(v);
|
|
4886
|
-
});
|
|
4887
|
-
} else if (typeof __require !== "undefined") {
|
|
4888
|
-
crypto = __require("crypto");
|
|
4889
|
-
if (crypto && crypto.randomBytes) {
|
|
4890
|
-
nacl4.setPRNG(function(x, n) {
|
|
4891
|
-
var i, v = crypto.randomBytes(n);
|
|
4892
|
-
for (i = 0; i < n; i++) x[i] = v[i];
|
|
4893
|
-
cleanup(v);
|
|
4894
|
-
});
|
|
4895
|
-
}
|
|
4896
|
-
}
|
|
4897
|
-
})();
|
|
4898
|
-
})(typeof module !== "undefined" && module.exports ? module.exports : self.nacl = self.nacl || {});
|
|
4899
|
-
}
|
|
4900
|
-
});
|
|
4901
|
-
|
|
4902
2677
|
// node_modules/crypto-js/core.js
|
|
4903
2678
|
var require_core = __commonJS({
|
|
4904
2679
|
"node_modules/crypto-js/core.js"(exports, module) {
|
|
@@ -11539,7 +9314,7 @@ var require_html_parse_stringify = __commonJS({
|
|
|
11539
9314
|
});
|
|
11540
9315
|
|
|
11541
9316
|
// packages/create/space/category/categoryActions.ts
|
|
11542
|
-
|
|
9317
|
+
import { ulid as ulid2 } from "ulid";
|
|
11543
9318
|
|
|
11544
9319
|
// packages/create/space/spaceCollapsedState.ts
|
|
11545
9320
|
var SPACE_COLLAPSE_STORAGE_PREFIX = "space-collapsed-categories:";
|
|
@@ -11684,7 +9459,7 @@ var createCategoryActions = (create) => ({
|
|
|
11684
9459
|
dbKey: spaceKey
|
|
11685
9460
|
})).unwrap();
|
|
11686
9461
|
checkSpaceMembership(spaceData, currentUserId);
|
|
11687
|
-
const newCategoryId = categoryId || (
|
|
9462
|
+
const newCategoryId = categoryId || ulid2();
|
|
11688
9463
|
if (spaceData.categories?.[newCategoryId]) {
|
|
11689
9464
|
throw new Error(`\u5206\u7C7B ID "${newCategoryId}" \u5DF2\u5B58\u5728\u3002`);
|
|
11690
9465
|
}
|
|
@@ -13610,6 +11385,10 @@ function buildFallbackActivity(toolName, args) {
|
|
|
13610
11385
|
refs: [{ type: "file", path }]
|
|
13611
11386
|
};
|
|
13612
11387
|
}
|
|
11388
|
+
case "loadSkill": {
|
|
11389
|
+
const name = asTrimmedString(args.name);
|
|
11390
|
+
return name ? { title: "\u52A0\u8F7D\u6280\u80FD", detail: name } : void 0;
|
|
11391
|
+
}
|
|
13613
11392
|
case "execShell": {
|
|
13614
11393
|
const command = asTrimmedString(
|
|
13615
11394
|
typeof args.cmd === "string" ? args.cmd : args.command
|
|
@@ -14037,7 +11816,7 @@ async function captureUnderstandingFromCompletedUiTurn(input) {
|
|
|
14037
11816
|
if (!input.agentKey) return;
|
|
14038
11817
|
const latestUserInput = getLatestUserInputFromMessages(input.messages);
|
|
14039
11818
|
if (!latestUserInput) return;
|
|
14040
|
-
const { captureUnderstandingMemoryFromDialog } = await import("./understanding-
|
|
11819
|
+
const { captureUnderstandingMemoryFromDialog } = await import("./understanding-ZOESBLF3.js");
|
|
14041
11820
|
await captureUnderstandingMemoryFromDialog({
|
|
14042
11821
|
db: input.db,
|
|
14043
11822
|
userId: selectIdentityUserId(input.state),
|
|
@@ -14962,7 +12741,7 @@ var messageSlice = createSliceWithThunks({
|
|
|
14962
12741
|
runtimeOptions: args.runtimeOptions
|
|
14963
12742
|
});
|
|
14964
12743
|
if (agentKeyToUse) {
|
|
14965
|
-
const { streamAgentChatTurn } = await import("./agentSlice-
|
|
12744
|
+
const { streamAgentChatTurn } = await import("./agentSlice-6EKOBCCS.js");
|
|
14966
12745
|
await dispatch(
|
|
14967
12746
|
streamAgentChatTurn({
|
|
14968
12747
|
agentKey: agentKeyToUse,
|
|
@@ -15080,12 +12859,11 @@ function clearWorkflow() {
|
|
|
15080
12859
|
}
|
|
15081
12860
|
|
|
15082
12861
|
// packages/chat/dialog/actions/updateTokensAction.ts
|
|
15083
|
-
var import_ulid2 = __toESM(require_index_umd());
|
|
15084
12862
|
var import_date_fns = __toESM(require_date_fns());
|
|
12863
|
+
import { ulid as ulid3 } from "ulid";
|
|
15085
12864
|
|
|
15086
12865
|
// packages/ai/token/saveTokenRecord.ts
|
|
15087
|
-
var
|
|
15088
|
-
var logger2 = (0, import_pino.pino)({ name: "token-record", level: "info" });
|
|
12866
|
+
var logger2 = createClientLogger("token-record");
|
|
15089
12867
|
var createTokenRecord = (data, { cost, inputPrice, outputPrice } = {}) => ({
|
|
15090
12868
|
...data,
|
|
15091
12869
|
cost: cost || data.cost,
|
|
@@ -15118,21 +12896,18 @@ var saveTokenRecord = async (tokenData, record, thunkApi) => {
|
|
|
15118
12896
|
}
|
|
15119
12897
|
};
|
|
15120
12898
|
|
|
15121
|
-
// packages/chat/dialog/actions/updateTokensAction.ts
|
|
15122
|
-
var import_pino2 = __toESM(require_pino());
|
|
15123
|
-
|
|
15124
12899
|
// packages/core/generateMainKey.ts
|
|
15125
|
-
|
|
12900
|
+
import nacl from "tweetnacl";
|
|
15126
12901
|
var generateUserIdV1 = (publicKey, username, language, extra = "") => {
|
|
15127
12902
|
const text = publicKey + username + language + extra;
|
|
15128
12903
|
const encodedText = new TextEncoder().encode(text);
|
|
15129
|
-
const hash =
|
|
12904
|
+
const hash = nacl.hash(encodedText);
|
|
15130
12905
|
const hexString = Array.from(hash).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
15131
12906
|
return hexString.slice(0, 10);
|
|
15132
12907
|
};
|
|
15133
12908
|
|
|
15134
12909
|
// packages/core/generateKeyPairFromSeedV1.ts
|
|
15135
|
-
|
|
12910
|
+
import nacl2 from "tweetnacl";
|
|
15136
12911
|
|
|
15137
12912
|
// node_modules/js-base64/base64.mjs
|
|
15138
12913
|
var version3 = "3.7.7";
|
|
@@ -15292,9 +13067,9 @@ var gBase64 = {
|
|
|
15292
13067
|
// packages/core/generateKeyPairFromSeedV1.ts
|
|
15293
13068
|
var generateKeyPairFromSeedV1 = (seedData) => {
|
|
15294
13069
|
const seed = new TextEncoder().encode(seedData);
|
|
15295
|
-
const hashSeed =
|
|
13070
|
+
const hashSeed = nacl2.hash(seed);
|
|
15296
13071
|
const seed32 = hashSeed.slice(0, 32);
|
|
15297
|
-
const keyPair =
|
|
13072
|
+
const keyPair = nacl2.sign.keyPair.fromSeed(seed32);
|
|
15298
13073
|
return {
|
|
15299
13074
|
publicKey: gBase64.fromUint8Array(keyPair.publicKey, true),
|
|
15300
13075
|
secretKey: gBase64.fromUint8Array(keyPair.secretKey, true)
|
|
@@ -16133,9 +13908,9 @@ var resetAuthScopedClientState = async (dispatch) => {
|
|
|
16133
13908
|
};
|
|
16134
13909
|
|
|
16135
13910
|
// packages/core/crypto.ts
|
|
16136
|
-
|
|
13911
|
+
import nacl3 from "tweetnacl";
|
|
16137
13912
|
var verifySignedMessage = (signedMessageBase64, publicKeyBase64) => {
|
|
16138
|
-
const message =
|
|
13913
|
+
const message = nacl3.sign.open(
|
|
16139
13914
|
gBase64.toUint8Array(signedMessageBase64),
|
|
16140
13915
|
gBase64.toUint8Array(publicKeyBase64)
|
|
16141
13916
|
);
|
|
@@ -16143,7 +13918,7 @@ var verifySignedMessage = (signedMessageBase64, publicKeyBase64) => {
|
|
|
16143
13918
|
return new TextDecoder().decode(message);
|
|
16144
13919
|
};
|
|
16145
13920
|
var detachedSign = (message, secretKeyBase64) => {
|
|
16146
|
-
const signature =
|
|
13921
|
+
const signature = nacl3.sign.detached(
|
|
16147
13922
|
new TextEncoder().encode(message),
|
|
16148
13923
|
gBase64.toUint8Array(secretKeyBase64)
|
|
16149
13924
|
);
|
|
@@ -17357,7 +15132,7 @@ async function runKeyed(key, task) {
|
|
|
17357
15132
|
}
|
|
17358
15133
|
|
|
17359
15134
|
// packages/chat/dialog/actions/updateTokensAction.ts
|
|
17360
|
-
var logger3 = (
|
|
15135
|
+
var logger3 = createClientLogger("token-usage");
|
|
17361
15136
|
var dialogTokenPatchQueue = /* @__PURE__ */ new Map();
|
|
17362
15137
|
var queueDialogTokenPatch = async (dialogKey, task) => {
|
|
17363
15138
|
const previousTask = dialogTokenPatchQueue.get(dialogKey) ?? Promise.resolve();
|
|
@@ -17425,7 +15200,7 @@ var saveTokenUsage = async (data, thunkApi) => {
|
|
|
17425
15200
|
);
|
|
17426
15201
|
return {
|
|
17427
15202
|
success: true,
|
|
17428
|
-
id: (
|
|
15203
|
+
id: ulid3(Date.now()),
|
|
17429
15204
|
record: updatedStats
|
|
17430
15205
|
};
|
|
17431
15206
|
} catch (error) {
|
|
@@ -17472,7 +15247,7 @@ var updateTokensAction = async ({ dialogId, dialogKey, usage: usageRaw, agentCon
|
|
|
17472
15247
|
const persistedTokenData = {
|
|
17473
15248
|
...tokenData,
|
|
17474
15249
|
type: "token" /* TOKEN */,
|
|
17475
|
-
id: (
|
|
15250
|
+
id: ulid3(timestamp),
|
|
17476
15251
|
dateKey: (0, import_date_fns.format)(timestamp, "yyyy-MM-dd"),
|
|
17477
15252
|
// Keep the same clock used for id/dateKey so record keys never see
|
|
17478
15253
|
// undefined when a prepare helper omits timestamp.
|
|
@@ -17600,7 +15375,7 @@ var deleteOwnedDialogAttachments = async (args) => {
|
|
|
17600
15375
|
metadataReadFailures
|
|
17601
15376
|
});
|
|
17602
15377
|
if (!plan.deleteCandidates.length) return plan;
|
|
17603
|
-
const { deleteFileAction } = await import("./deleteFile-
|
|
15378
|
+
const { deleteFileAction } = await import("./deleteFile-7XP5BGC7.js");
|
|
17604
15379
|
for (const candidate of plan.deleteCandidates) {
|
|
17605
15380
|
if (candidate.fileDbKey) {
|
|
17606
15381
|
await deleteFileAction(candidate.fileDbKey, args.thunkApi);
|
|
@@ -17662,7 +15437,7 @@ var deleteDialogThunk = async (payload, thunkApi) => {
|
|
|
17662
15437
|
}
|
|
17663
15438
|
if (isCurrentDialog) {
|
|
17664
15439
|
await thunkApi.dispatch(resetMsgs());
|
|
17665
|
-
const { clearPendingAttachments: clearPendingAttachments2 } = await import("./dialogSlice-
|
|
15440
|
+
const { clearPendingAttachments: clearPendingAttachments2 } = await import("./dialogSlice-OWROKURJ.js");
|
|
17666
15441
|
dispatch(clearPendingAttachments2());
|
|
17667
15442
|
clearWorkflow();
|
|
17668
15443
|
}
|
|
@@ -17671,35 +15446,35 @@ var deleteDialogThunk = async (payload, thunkApi) => {
|
|
|
17671
15446
|
|
|
17672
15447
|
// packages/chat/dialog/dialogSlice.ts
|
|
17673
15448
|
var runCreateDialogAction = async (args, thunkApi) => {
|
|
17674
|
-
const { createDialogAction } = await import("./createDialogAction-
|
|
15449
|
+
const { createDialogAction } = await import("./createDialogAction-OJJ7L3L3.js");
|
|
17675
15450
|
return createDialogAction(args, thunkApi);
|
|
17676
15451
|
};
|
|
17677
15452
|
var runCreateAgentAutomationAction = async (args, thunkApi) => {
|
|
17678
|
-
const { createAgentAutomationAction } = await import("./createAgentAutomationAction-
|
|
15453
|
+
const { createAgentAutomationAction } = await import("./createAgentAutomationAction-LTI5QU35.js");
|
|
17679
15454
|
return createAgentAutomationAction(args, thunkApi);
|
|
17680
15455
|
};
|
|
17681
15456
|
var runUpdateDialogTitleAction = async (args, thunkApi) => {
|
|
17682
|
-
const { updateDialogTitleAction } = await import("./updateDialogTitleAction-
|
|
15457
|
+
const { updateDialogTitleAction } = await import("./updateDialogTitleAction-7FYNJOGP.js");
|
|
17683
15458
|
return updateDialogTitleAction(args, thunkApi);
|
|
17684
15459
|
};
|
|
17685
15460
|
var runAddDialogAgentAction = async (args, thunkApi) => {
|
|
17686
|
-
const { addDialogAgentAction } = await import("./addDialogAgentAction-
|
|
15461
|
+
const { addDialogAgentAction } = await import("./addDialogAgentAction-WVVKT5WQ.js");
|
|
17687
15462
|
return addDialogAgentAction(args, thunkApi);
|
|
17688
15463
|
};
|
|
17689
15464
|
var runRemoveDialogAgentAction = async (args, thunkApi) => {
|
|
17690
|
-
const { removeDialogAgentAction } = await import("./removeDialogAgentAction-
|
|
15465
|
+
const { removeDialogAgentAction } = await import("./removeDialogAgentAction-TCT35SOF.js");
|
|
17691
15466
|
return removeDialogAgentAction(args, thunkApi);
|
|
17692
15467
|
};
|
|
17693
15468
|
var runSetPrimaryDialogAgentAction = async (args, thunkApi) => {
|
|
17694
|
-
const { setPrimaryDialogAgentAction } = await import("./setPrimaryDialogAgentAction-
|
|
15469
|
+
const { setPrimaryDialogAgentAction } = await import("./setPrimaryDialogAgentAction-F6BFQDJU.js");
|
|
17695
15470
|
return setPrimaryDialogAgentAction(args, thunkApi);
|
|
17696
15471
|
};
|
|
17697
15472
|
var runSetDialogExtraReferencesAction = async (args, thunkApi) => {
|
|
17698
|
-
const { setDialogExtraReferencesAction } = await import("./setDialogExtraReferencesAction-
|
|
15473
|
+
const { setDialogExtraReferencesAction } = await import("./setDialogExtraReferencesAction-CGYLZMFH.js");
|
|
17699
15474
|
return setDialogExtraReferencesAction(args, thunkApi);
|
|
17700
15475
|
};
|
|
17701
15476
|
var runHandleSendMessageAction = async (args, thunkApi) => {
|
|
17702
|
-
const { handleSendMessageAction } = await import("./handleSendMessageAction-
|
|
15477
|
+
const { handleSendMessageAction } = await import("./handleSendMessageAction-B5PRR7BE.js");
|
|
17703
15478
|
return handleSendMessageAction(args, thunkApi);
|
|
17704
15479
|
};
|
|
17705
15480
|
function clearDialogState() {
|
|
@@ -17712,7 +15487,7 @@ var createPageAndAddReference = createAsyncThunk(
|
|
|
17712
15487
|
async (payload, { dispatch, getState, rejectWithValue }) => {
|
|
17713
15488
|
const { slateData, jsonData, title, type, fileId, groupId, dialogKey } = payload;
|
|
17714
15489
|
try {
|
|
17715
|
-
const { createDocState } = await import("./docStore-
|
|
15490
|
+
const { createDocState } = await import("./docStore-3DXRYBMD.js");
|
|
17716
15491
|
const pageKey = await createDocState(
|
|
17717
15492
|
{ slateData, title },
|
|
17718
15493
|
{ dispatch, getState }
|
|
@@ -17870,7 +15645,7 @@ var selectTotalDialogTokens = selectCurrentDialogTokens;
|
|
|
17870
15645
|
|
|
17871
15646
|
// packages/render/table/tableSlice.ts
|
|
17872
15647
|
var import_date_fns3 = __toESM(require_date_fns(), 1);
|
|
17873
|
-
|
|
15648
|
+
import { ulid as ulid5 } from "ulid";
|
|
17874
15649
|
|
|
17875
15650
|
// packages/render/table/fetchAndCacheTableRows.ts
|
|
17876
15651
|
var getRowTimestamp = (row) => {
|
|
@@ -18069,7 +15844,7 @@ var fetchAndCacheTableRows = async ({
|
|
|
18069
15844
|
|
|
18070
15845
|
// packages/render/table/createTableAction.ts
|
|
18071
15846
|
var import_date_fns2 = __toESM(require_date_fns(), 1);
|
|
18072
|
-
|
|
15847
|
+
import { ulid as ulid4 } from "ulid";
|
|
18073
15848
|
|
|
18074
15849
|
// node_modules/i18next/dist/esm/i18next.js
|
|
18075
15850
|
var consoleLogger = {
|
|
@@ -20573,7 +18348,7 @@ var normalizeColumns = (inputColumns) => {
|
|
|
20573
18348
|
const name = c.name.trim();
|
|
20574
18349
|
if (!name) return null;
|
|
20575
18350
|
const col = {
|
|
20576
|
-
id: asOptionalTrimmedString(c.id) ?? (
|
|
18351
|
+
id: asOptionalTrimmedString(c.id) ?? ulid4(),
|
|
20577
18352
|
name
|
|
20578
18353
|
};
|
|
20579
18354
|
const label = asOptionalTrimmedString(c.label);
|
|
@@ -20605,7 +18380,7 @@ var normalizeColumns = (inputColumns) => {
|
|
|
20605
18380
|
}
|
|
20606
18381
|
return DEFAULT_COLUMNS.map((c) => ({
|
|
20607
18382
|
...c,
|
|
20608
|
-
id: (
|
|
18383
|
+
id: ulid4()
|
|
20609
18384
|
}));
|
|
20610
18385
|
};
|
|
20611
18386
|
var normalizeStringArray2 = (value) => {
|
|
@@ -20648,7 +18423,7 @@ var createTableAction = async ({
|
|
|
20648
18423
|
const userId = selectIdentityUserId(state3);
|
|
20649
18424
|
if (!userId) throw new Error("User ID not found.");
|
|
20650
18425
|
const spaceId = customSpaceId ?? selectCurrentSpaceId(state3);
|
|
20651
|
-
const tableId = (
|
|
18426
|
+
const tableId = ulid4();
|
|
20652
18427
|
const now = /* @__PURE__ */ new Date();
|
|
20653
18428
|
const nowIso = (0, import_date_fns2.formatISO)(now);
|
|
20654
18429
|
const dbKey = metaKey(userId, tableId);
|
|
@@ -21078,7 +18853,7 @@ var tableSlice = createSliceWithThunks3({
|
|
|
21078
18853
|
try {
|
|
21079
18854
|
const nowIso = (0, import_date_fns3.formatISO)(/* @__PURE__ */ new Date());
|
|
21080
18855
|
const newColumn = {
|
|
21081
|
-
id: (
|
|
18856
|
+
id: ulid5(),
|
|
21082
18857
|
name: columnName,
|
|
21083
18858
|
// 默认显示名与机器名一致;之后用户可以单独改 label
|
|
21084
18859
|
label: columnName
|
|
@@ -21669,11 +19444,11 @@ var ENTITY_DELETE_STRATEGIES = {
|
|
|
21669
19444
|
await dispatch(deleteTable({ dbKey: key })).unwrap();
|
|
21670
19445
|
},
|
|
21671
19446
|
file: async (key, { thunkAPI }) => {
|
|
21672
|
-
const { deleteFileAction } = await import("./deleteFile-
|
|
19447
|
+
const { deleteFileAction } = await import("./deleteFile-7XP5BGC7.js");
|
|
21673
19448
|
await deleteFileAction(key, thunkAPI);
|
|
21674
19449
|
},
|
|
21675
19450
|
image: async (key, { thunkAPI }) => {
|
|
21676
|
-
const { deleteFileAction } = await import("./deleteFile-
|
|
19451
|
+
const { deleteFileAction } = await import("./deleteFile-7XP5BGC7.js");
|
|
21677
19452
|
await deleteFileAction(key, thunkAPI);
|
|
21678
19453
|
},
|
|
21679
19454
|
agent: async (key, { dispatch, userId, sourceServerOrigin }) => {
|
|
@@ -21769,12 +19544,7 @@ var deleteContentFromSpaceAction = async (input, thunkAPI) => {
|
|
|
21769
19544
|
};
|
|
21770
19545
|
|
|
21771
19546
|
// packages/create/space/content/moveContentAction.ts
|
|
21772
|
-
var
|
|
21773
|
-
var logger4 = (0, import_pino3.default)({
|
|
21774
|
-
level: "info"
|
|
21775
|
-
// 或根据环境调整
|
|
21776
|
-
// transport: { target: "pino-pretty" },
|
|
21777
|
-
});
|
|
19547
|
+
var logger4 = createClientLogger("move-content");
|
|
21778
19548
|
var moveContentAction = async (input, thunkAPI) => {
|
|
21779
19549
|
const {
|
|
21780
19550
|
contentKey,
|
|
@@ -22235,13 +20005,7 @@ var updateContentCategoryAction = async (input, thunkAPI) => {
|
|
|
22235
20005
|
};
|
|
22236
20006
|
|
|
22237
20007
|
// packages/create/space/content/deleteMultipleContentAction.ts
|
|
22238
|
-
var
|
|
22239
|
-
var logger5 = (0, import_pino4.default)({
|
|
22240
|
-
level: "info"
|
|
22241
|
-
// transport: {
|
|
22242
|
-
// target: "pino-pretty",
|
|
22243
|
-
// },
|
|
22244
|
-
});
|
|
20008
|
+
var logger5 = createClientLogger("delete-multiple-content");
|
|
22245
20009
|
var deleteMultipleContentAction = async (input, thunkAPI) => {
|
|
22246
20010
|
const { contentKeys, spaceId } = input;
|
|
22247
20011
|
if (!contentKeys || contentKeys.length === 0) {
|
|
@@ -23235,7 +20999,7 @@ async function fetchUserData(db, types, userId, options = {}) {
|
|
|
23235
20999
|
}
|
|
23236
21000
|
|
|
23237
21001
|
// packages/create/space/addSpaceAction.ts
|
|
23238
|
-
|
|
21002
|
+
import { ulid as ulid6 } from "ulid";
|
|
23239
21003
|
async function getUserDataOnce({
|
|
23240
21004
|
types,
|
|
23241
21005
|
userId,
|
|
@@ -23268,7 +21032,7 @@ var addSpaceAction = async (input, thunkAPI) => {
|
|
|
23268
21032
|
const state3 = getState();
|
|
23269
21033
|
const accountUserId = selectIdentityUserId(state3);
|
|
23270
21034
|
const userId = resolveEffectiveSpaceActorId(accountUserId);
|
|
23271
|
-
const spaceId = (
|
|
21035
|
+
const spaceId = ulid6();
|
|
23272
21036
|
const now = Date.now();
|
|
23273
21037
|
const nowISO = new Date(now).toISOString();
|
|
23274
21038
|
const spaceData = {
|
|
@@ -23852,7 +21616,7 @@ var fetchSpaceAction = async (input, thunkAPI) => {
|
|
|
23852
21616
|
const spaceKey = createSpaceKey.space(spaceId);
|
|
23853
21617
|
const readSpace = async (dbKey) => {
|
|
23854
21618
|
try {
|
|
23855
|
-
const { read: read2, readAndWait: readAndWait2 } = await import("./dbSlice-
|
|
21619
|
+
const { read: read2, readAndWait: readAndWait2 } = await import("./dbSlice-RQFQQVHT.js");
|
|
23856
21620
|
if (fresh) {
|
|
23857
21621
|
return await dispatch(readAndWait2(dbKey)).unwrap();
|
|
23858
21622
|
}
|