@vex-chat/crypto 1.1.1 → 2.0.1
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 +88 -12
- package/dist/index.d.ts +107 -89
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +207 -171
- package/dist/index.js.map +1 -1
- package/package.json +67 -34
- package/src/__tests__/XKeyConvert.ts +68 -0
- package/src/__tests__/XUtils/bytesEqual.ts +16 -0
- package/src/__tests__/XUtils/emptyHeader.ts +12 -0
- package/src/__tests__/XUtils/numberToUint8Arr.ts +22 -0
- package/src/__tests__/XUtils/packMessage.ts +23 -0
- package/src/__tests__/XUtils/stringEncoding.ts +68 -0
- package/src/__tests__/XUtils/uint8ArrToNumber.ts +19 -0
- package/src/__tests__/XUtils/unpackMessage.ts +25 -0
- package/src/__tests__/xConcat.ts +18 -0
- package/src/__tests__/xDH.ts +16 -0
- package/src/__tests__/xEncode.ts +11 -0
- package/src/__tests__/xHMAC.ts +26 -0
- package/src/__tests__/xMnemonic.ts +12 -0
- package/src/index.ts +540 -0
package/dist/index.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { decode as decodeBase64, encode as encodeBase64, } from "@stablelib/base64";
|
|
2
|
-
import { decode as encodeUTF8, encode as decodeUTF8 } from "@stablelib/utf8";
|
|
3
|
-
import * as bip39 from "bip39";
|
|
4
|
-
import { hmac } from "@noble/hashes/hmac.js";
|
|
5
|
-
import { sha256, sha512 } from "@noble/hashes/sha2.js";
|
|
6
1
|
import { hkdf } from "@noble/hashes/hkdf.js";
|
|
2
|
+
import { hmac } from "@noble/hashes/hmac.js";
|
|
7
3
|
import { pbkdf2 as noblePbkdf2 } from "@noble/hashes/pbkdf2.js";
|
|
4
|
+
import { sha256, sha512 } from "@noble/hashes/sha2.js";
|
|
5
|
+
import { decode as decodeBase64, encode as encodeBase64, } from "@stablelib/base64";
|
|
6
|
+
import { encode as decodeUTF8, decode as encodeUTF8 } from "@stablelib/utf8";
|
|
7
|
+
import * as bip39 from "bip39";
|
|
8
8
|
import ed2curve from "ed2curve";
|
|
9
9
|
import { Packr } from "msgpackr";
|
|
10
10
|
import nacl from "tweetnacl";
|
|
11
|
+
import { z } from "zod/v4";
|
|
11
12
|
// msgpackr with useRecords:false emits standard msgpack (no nonstandard record extension).
|
|
12
13
|
// moreTypes:false keeps the extension set to only what other decoders understand.
|
|
13
14
|
// pack() returns Node Buffer (tight view) so consumers like axios send the correct bytes.
|
|
14
|
-
const packer = new Packr({
|
|
15
|
+
const packer = new Packr({ moreTypes: false, useRecords: false });
|
|
15
16
|
const msgpackEncode = packer.pack.bind(packer);
|
|
16
17
|
const msgpackDecode = packer.unpack.bind(packer);
|
|
17
18
|
/**
|
|
@@ -23,13 +24,15 @@ export const XKeyConvert = ed2curve;
|
|
|
23
24
|
* Provides several methods that are useful in working with bytes and
|
|
24
25
|
* vex messages.
|
|
25
26
|
*/
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-extraneous-class -- intentional static utility namespace (public API surface)
|
|
26
28
|
export class XUtils {
|
|
27
|
-
static
|
|
29
|
+
static decodeBase64 = decodeBase64;
|
|
28
30
|
static decodeUTF8 = decodeUTF8;
|
|
29
31
|
static encodeBase64 = encodeBase64;
|
|
30
|
-
static
|
|
32
|
+
static encodeUTF8 = encodeUTF8;
|
|
31
33
|
/**
|
|
32
34
|
* Checks if two buffer-like objects are equal.
|
|
35
|
+
* When lengths match, comparison is constant-time in the inputs (no early exit on first differing byte).
|
|
33
36
|
*
|
|
34
37
|
* @param buf1
|
|
35
38
|
* @param buf2
|
|
@@ -42,99 +45,86 @@ export class XUtils {
|
|
|
42
45
|
if (a.byteLength !== b.byteLength) {
|
|
43
46
|
return false;
|
|
44
47
|
}
|
|
48
|
+
let diff = 0;
|
|
45
49
|
for (let i = 0; i !== a.byteLength; i++) {
|
|
46
|
-
|
|
50
|
+
const x = a[i];
|
|
51
|
+
const y = b[i];
|
|
52
|
+
if (x === undefined || y === undefined) {
|
|
47
53
|
return false;
|
|
48
54
|
}
|
|
55
|
+
diff |= x ^ y;
|
|
49
56
|
}
|
|
50
|
-
return
|
|
57
|
+
return diff === 0;
|
|
51
58
|
}
|
|
52
59
|
/**
|
|
53
|
-
*
|
|
54
|
-
* The integer must be positive, and it must be able to be stored
|
|
55
|
-
* in six bytes.
|
|
60
|
+
* Decodes a hex string into a Uint8Array.
|
|
56
61
|
*
|
|
57
|
-
* @
|
|
58
|
-
* @returns The Uint8Array representation of n.
|
|
62
|
+
* @returns The Uint8Array.
|
|
59
63
|
*/
|
|
60
|
-
static
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
let str = n.toString(16);
|
|
65
|
-
while (str.length < 12) {
|
|
66
|
-
str = "0" + str;
|
|
64
|
+
static decodeHex(hexString) {
|
|
65
|
+
if (hexString.length === 0) {
|
|
66
|
+
return new Uint8Array();
|
|
67
67
|
}
|
|
68
|
-
|
|
68
|
+
const matches = hexString.match(/.{1,2}/g) ?? [];
|
|
69
|
+
return new Uint8Array(matches.map((byte) => parseInt(byte, 16)));
|
|
69
70
|
}
|
|
70
71
|
/**
|
|
71
|
-
*
|
|
72
|
+
* Decrypts a secret key from the binary format produced by encryptKeyData().
|
|
73
|
+
* No I/O — the caller handles reading the data.
|
|
72
74
|
*
|
|
73
|
-
* @param
|
|
74
|
-
* @
|
|
75
|
+
* @param keyData The encrypted key data as a Uint8Array.
|
|
76
|
+
* @param password The password used to encrypt.
|
|
77
|
+
* @returns The hex-encoded secret key.
|
|
75
78
|
*/
|
|
76
|
-
static
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
static decryptKeyData = (keyData, password) => {
|
|
80
|
+
const ITERATIONS = XUtils.uint8ArrToNumber(keyData.slice(0, 6));
|
|
81
|
+
const PKBDF_SALT = keyData.slice(6, 30);
|
|
82
|
+
const ENCRYPTION_NONCE = keyData.slice(30, 54);
|
|
83
|
+
const ENCRYPTED_KEY = keyData.slice(54);
|
|
84
|
+
const DERIVED_KEY = noblePbkdf2(sha512, password, PKBDF_SALT, {
|
|
85
|
+
c: ITERATIONS,
|
|
86
|
+
dkLen: 32,
|
|
87
|
+
});
|
|
88
|
+
const DECRYPTED_SIGNKEY = nacl.secretbox.open(ENCRYPTED_KEY, ENCRYPTION_NONCE, DERIVED_KEY);
|
|
89
|
+
if (DECRYPTED_SIGNKEY === null) {
|
|
90
|
+
throw new Error("Decryption failed. Wrong password?");
|
|
80
91
|
}
|
|
81
|
-
return
|
|
82
|
-
}
|
|
92
|
+
return XUtils.encodeHex(DECRYPTED_SIGNKEY);
|
|
93
|
+
};
|
|
83
94
|
/**
|
|
84
|
-
*
|
|
85
|
-
* respresentation of its body.
|
|
95
|
+
* Returns the empty header (32 0's)
|
|
86
96
|
*
|
|
87
|
-
* @
|
|
88
|
-
* @returns [32 byte header, message body]
|
|
97
|
+
* @returns The empty header.
|
|
89
98
|
*/
|
|
90
|
-
static
|
|
91
|
-
|
|
92
|
-
const msgh = msgp.slice(0, xConstants.HEADER_SIZE);
|
|
93
|
-
const msgb = msgpackDecode(msgp.slice(xConstants.HEADER_SIZE));
|
|
94
|
-
return [msgh, msgb];
|
|
99
|
+
static emptyHeader() {
|
|
100
|
+
return new Uint8Array(xConstants.HEADER_SIZE);
|
|
95
101
|
}
|
|
96
102
|
/**
|
|
97
|
-
*
|
|
103
|
+
* Encodes a Uint8Array to a hex string.
|
|
98
104
|
*
|
|
99
|
-
* @
|
|
100
|
-
* @returns the packed message.
|
|
105
|
+
* @returns The hex string.
|
|
101
106
|
*/
|
|
102
|
-
static
|
|
103
|
-
|
|
104
|
-
const msgh = header || XUtils.emptyHeader();
|
|
105
|
-
return xConcat(msgh, msgb);
|
|
107
|
+
static encodeHex(bytes) {
|
|
108
|
+
return bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, "0"), "");
|
|
106
109
|
}
|
|
107
110
|
/**
|
|
108
|
-
*
|
|
111
|
+
* Encrypts a secret key into a portable binary format.
|
|
112
|
+
* The result can be written to disk, sent over the network, etc.
|
|
113
|
+
* No I/O — the caller handles persistence.
|
|
109
114
|
*
|
|
110
|
-
*
|
|
115
|
+
* Format: [iterations(6)|salt(24)|nonce(24)|ciphertext(N)]
|
|
116
|
+
*
|
|
117
|
+
* @param password The password to derive the encryption key from.
|
|
118
|
+
* @param keyToSave The hex-encoded secret key to encrypt.
|
|
119
|
+
* @param iterationOverride Optional PBKDF2 iteration count (random if omitted).
|
|
120
|
+
* @returns The encrypted key data as a Uint8Array.
|
|
111
121
|
*/
|
|
112
|
-
static emptyHeader() {
|
|
113
|
-
return new Uint8Array(xConstants.HEADER_SIZE);
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Encrypts a secret key with a password and saves it as a file.
|
|
117
|
-
*
|
|
118
|
-
* @param path The path to save the keyfile.
|
|
119
|
-
/**
|
|
120
|
-
* Encrypts a secret key into a portable binary format.
|
|
121
|
-
* The result can be written to disk, sent over the network, etc.
|
|
122
|
-
* No I/O — the caller handles persistence.
|
|
123
|
-
*
|
|
124
|
-
* Format: [iterations(6)|salt(24)|nonce(24)|ciphertext(N)]
|
|
125
|
-
*
|
|
126
|
-
* @param password The password to derive the encryption key from.
|
|
127
|
-
* @param keyToSave The hex-encoded secret key to encrypt.
|
|
128
|
-
* @param iterationOverride Optional PBKDF2 iteration count (random if omitted).
|
|
129
|
-
* @returns The encrypted key data as a Uint8Array.
|
|
130
|
-
*/
|
|
131
122
|
static encryptKeyData = (password, keyToSave, iterationOverride) => {
|
|
132
123
|
const UNENCRYPTED_SIGNKEY = XUtils.decodeHex(keyToSave);
|
|
133
124
|
const OFFSET = 1000;
|
|
134
125
|
const rand = nacl.randomBytes(2);
|
|
135
|
-
const N1 =
|
|
136
|
-
const
|
|
137
|
-
const iterations = iterationOverride
|
|
126
|
+
const [N1 = 0, N2 = 0] = rand;
|
|
127
|
+
const iterations = iterationOverride !== undefined && iterationOverride !== 0
|
|
138
128
|
? iterationOverride
|
|
139
129
|
: N1 * N2 + OFFSET;
|
|
140
130
|
const ITERATIONS = XUtils.numberToUint8Arr(iterations);
|
|
@@ -160,57 +150,71 @@ export class XUtils {
|
|
|
160
150
|
return result;
|
|
161
151
|
};
|
|
162
152
|
/**
|
|
163
|
-
*
|
|
164
|
-
*
|
|
153
|
+
* Returns a six bit Uint8Array representation of an integer.
|
|
154
|
+
* The integer must be positive, and it must be able to be stored
|
|
155
|
+
* in six bytes.
|
|
165
156
|
*
|
|
166
|
-
* @param
|
|
167
|
-
* @
|
|
168
|
-
* @returns The hex-encoded secret key.
|
|
157
|
+
* @param n The number to convert.
|
|
158
|
+
* @returns The Uint8Array representation of n.
|
|
169
159
|
*/
|
|
170
|
-
static
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
const ENCRYPTED_KEY = keyData.slice(54);
|
|
175
|
-
const DERIVED_KEY = noblePbkdf2(sha512, password, PKBDF_SALT, {
|
|
176
|
-
c: ITERATIONS,
|
|
177
|
-
dkLen: 32,
|
|
178
|
-
});
|
|
179
|
-
const DECRYPTED_SIGNKEY = nacl.secretbox.open(ENCRYPTED_KEY, ENCRYPTION_NONCE, DERIVED_KEY);
|
|
180
|
-
if (!DECRYPTED_SIGNKEY) {
|
|
181
|
-
throw new Error("Decryption failed. Wrong password?");
|
|
160
|
+
static numberToUint8Arr(n) {
|
|
161
|
+
if (n < 0 || n > 281474976710655) {
|
|
162
|
+
throw new Error("Expected integer 0 < n < 281474976710655, received " +
|
|
163
|
+
String(n));
|
|
182
164
|
}
|
|
183
|
-
|
|
184
|
-
|
|
165
|
+
let str = n.toString(16);
|
|
166
|
+
while (str.length < 12) {
|
|
167
|
+
str = "0" + str;
|
|
168
|
+
}
|
|
169
|
+
return XUtils.decodeHex(str);
|
|
170
|
+
}
|
|
185
171
|
/**
|
|
186
|
-
*
|
|
172
|
+
* Packs a javascript object and a 32 byte header into a vex message.
|
|
187
173
|
*
|
|
188
|
-
* @
|
|
174
|
+
* @param msg Message body (msgpack-serialized).
|
|
175
|
+
* @param header Optional 32-byte header; defaults to an empty header.
|
|
176
|
+
* @returns the packed message.
|
|
189
177
|
*/
|
|
190
|
-
static
|
|
191
|
-
|
|
192
|
-
|
|
178
|
+
static packMessage(msg, header) {
|
|
179
|
+
const msgb = msgpackEncode(msg);
|
|
180
|
+
const msgh = header ?? XUtils.emptyHeader();
|
|
181
|
+
return xConcat(msgh, msgb);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Converts a Uint8Array representation of an integer back into a number.
|
|
185
|
+
*
|
|
186
|
+
* @param arr The array to convert.
|
|
187
|
+
* @returns the number representation of arr.
|
|
188
|
+
*/
|
|
189
|
+
static uint8ArrToNumber(arr) {
|
|
190
|
+
let n = 0;
|
|
191
|
+
for (const byte of arr) {
|
|
192
|
+
n = n * 256 + byte;
|
|
193
193
|
}
|
|
194
|
-
return
|
|
194
|
+
return n;
|
|
195
195
|
}
|
|
196
196
|
/**
|
|
197
|
-
*
|
|
197
|
+
* Takes a vex message and unpacks it into its header and a javascript object
|
|
198
|
+
* representation of its body.
|
|
198
199
|
*
|
|
199
|
-
* @
|
|
200
|
+
* @param msg Full wire message (32-byte header + msgpack body).
|
|
201
|
+
* @returns [32 byte header, message body]
|
|
200
202
|
*/
|
|
201
|
-
static
|
|
202
|
-
|
|
203
|
+
static unpackMessage(msg) {
|
|
204
|
+
const msgp = Uint8Array.from(msg);
|
|
205
|
+
const msgh = msgp.slice(0, xConstants.HEADER_SIZE);
|
|
206
|
+
// Validate base fields exist, keep all extra fields for the caller to narrow
|
|
207
|
+
const raw = msgpackDecode(msgp.slice(xConstants.HEADER_SIZE));
|
|
208
|
+
const msgb = z
|
|
209
|
+
.object({
|
|
210
|
+
transmissionID: z.string(),
|
|
211
|
+
type: z.string(),
|
|
212
|
+
})
|
|
213
|
+
.loose()
|
|
214
|
+
.parse(raw);
|
|
215
|
+
return [msgh, msgb];
|
|
203
216
|
}
|
|
204
217
|
}
|
|
205
|
-
/**
|
|
206
|
-
* Gets a word list representation of a byte sequence.
|
|
207
|
-
*
|
|
208
|
-
* @param entropy The bytes to derive the wordlist from.
|
|
209
|
-
* @param wordList Optional, override the wordlist. See bip39 docs for details.
|
|
210
|
-
*/
|
|
211
|
-
export function xMnemonic(entropy, wordList) {
|
|
212
|
-
return bip39.entropyToMnemonic(XUtils.encodeHex(entropy), wordList);
|
|
213
|
-
}
|
|
214
218
|
/**
|
|
215
219
|
* Returns a 32 byte HMAC of a javscript object.
|
|
216
220
|
*
|
|
@@ -221,60 +225,33 @@ export function xHMAC(msg, SK) {
|
|
|
221
225
|
const packedMsg = msgpackEncode(msg);
|
|
222
226
|
return hmac(sha256, SK, packedMsg);
|
|
223
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* Gets a word list representation of a byte sequence.
|
|
230
|
+
*
|
|
231
|
+
* @param entropy The bytes to derive the wordlist from.
|
|
232
|
+
* @param wordList Optional, override the wordlist. See bip39 docs for details.
|
|
233
|
+
*/
|
|
234
|
+
export function xMnemonic(entropy, wordList) {
|
|
235
|
+
return bip39.entropyToMnemonic(XUtils.encodeHex(entropy), wordList);
|
|
236
|
+
}
|
|
224
237
|
/**
|
|
225
238
|
* Constants for vex.
|
|
226
239
|
*/
|
|
227
240
|
export const xConstants = {
|
|
228
241
|
CURVE: "X25519",
|
|
229
242
|
HASH: "SHA-512",
|
|
230
|
-
|
|
243
|
+
HEADER_SIZE: 32,
|
|
231
244
|
INFO: "xchat",
|
|
245
|
+
KEY_LENGTH: 32,
|
|
232
246
|
MIN_OTK_SUPPLY: 100,
|
|
233
|
-
HEADER_SIZE: 32,
|
|
234
247
|
};
|
|
235
|
-
/**
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
export function xMakeNonce() {
|
|
239
|
-
return nacl.randomBytes(24);
|
|
248
|
+
/** Generate a fresh X25519 box key pair. */
|
|
249
|
+
export function xBoxKeyPair() {
|
|
250
|
+
return nacl.box.keyPair();
|
|
240
251
|
}
|
|
241
|
-
/**
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
* @param IKM the initial key material.
|
|
245
|
-
* @returns The generated key.
|
|
246
|
-
*/
|
|
247
|
-
// export function xKDF(IKM: Uint8Array): Uint8Array {
|
|
248
|
-
// return Uint8Array.from(
|
|
249
|
-
// hkdf(Buffer.from(IKM), xConstants.KEY_LENGTH, {
|
|
250
|
-
// salt: Buffer.from(xMakeSalt(xConstants.CURVE)),
|
|
251
|
-
// info: xConstants.INFO,
|
|
252
|
-
// hash: xConstants.HASH,
|
|
253
|
-
// })
|
|
254
|
-
// );
|
|
255
|
-
// }
|
|
256
|
-
export function xKDF(IKM) {
|
|
257
|
-
return hkdf(sha512, IKM, xMakeSalt(xConstants.CURVE), new TextEncoder().encode(xConstants.INFO), xConstants.KEY_LENGTH);
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Hashes some data.
|
|
261
|
-
*
|
|
262
|
-
* @param data the data to hash.
|
|
263
|
-
* @returns The hash of the data.
|
|
264
|
-
*/
|
|
265
|
-
export function xHash(data) {
|
|
266
|
-
return XUtils.encodeHex(sha512(data));
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* Derives a shared Secret Key from a known private key and
|
|
270
|
-
* a peer's known public key.
|
|
271
|
-
*
|
|
272
|
-
* @param myPrivateKey Your own private key
|
|
273
|
-
* @param theirPublicKey Their public key
|
|
274
|
-
* @returns The derived shared secret, SK.
|
|
275
|
-
*/
|
|
276
|
-
export function xDH(myPrivateKey, theirPublicKey) {
|
|
277
|
-
return nacl.box.before(theirPublicKey, myPrivateKey);
|
|
252
|
+
/** Restore an X25519 box key pair from a 32-byte secret key. */
|
|
253
|
+
export function xBoxKeyPairFromSecret(secretKey) {
|
|
254
|
+
return nacl.box.keyPair.fromSecretKey(secretKey);
|
|
278
255
|
}
|
|
279
256
|
/**
|
|
280
257
|
* Concatanates multiple Uint8Arrays.
|
|
@@ -283,7 +260,7 @@ export function xDH(myPrivateKey, theirPublicKey) {
|
|
|
283
260
|
*/
|
|
284
261
|
export function xConcat(...arrays) {
|
|
285
262
|
const totalLength = arrays.reduce((acc, value) => acc + value.length, 0);
|
|
286
|
-
if (
|
|
263
|
+
if (arrays.length === 0) {
|
|
287
264
|
return new Uint8Array();
|
|
288
265
|
}
|
|
289
266
|
const result = new Uint8Array(totalLength);
|
|
@@ -296,6 +273,18 @@ export function xConcat(...arrays) {
|
|
|
296
273
|
}
|
|
297
274
|
return result;
|
|
298
275
|
}
|
|
276
|
+
/**
|
|
277
|
+
* Derives a shared Secret Key from a known private key and
|
|
278
|
+
* a peer's known public key.
|
|
279
|
+
*
|
|
280
|
+
* @param myPrivateKey Your own private key
|
|
281
|
+
* @param theirPublicKey Their public key
|
|
282
|
+
* @returns The derived shared secret, SK.
|
|
283
|
+
*/
|
|
284
|
+
export function xDH(myPrivateKey, theirPublicKey) {
|
|
285
|
+
return nacl.box.before(theirPublicKey, myPrivateKey);
|
|
286
|
+
}
|
|
287
|
+
// ── Key pair type ───────────────────────────────────────────────────────────
|
|
299
288
|
/**
|
|
300
289
|
* Encode an X25519 or X448 public key PK into a byte sequence.
|
|
301
290
|
* The encoding consists of 0 or 1 to represent the type of curve, followed by l
|
|
@@ -305,17 +294,17 @@ export function xConcat(...arrays) {
|
|
|
305
294
|
export function xEncode(curveType, publicKey) {
|
|
306
295
|
if (publicKey.length !== 32) {
|
|
307
296
|
throw new Error("Invalid key length, received key of length " +
|
|
308
|
-
publicKey.length +
|
|
297
|
+
String(publicKey.length) +
|
|
309
298
|
" and expected length 32.");
|
|
310
299
|
}
|
|
311
300
|
const bytes = [];
|
|
312
301
|
switch (curveType) {
|
|
313
|
-
case "X25519":
|
|
314
|
-
bytes.push(0);
|
|
315
|
-
break;
|
|
316
302
|
case "X448":
|
|
317
303
|
bytes.push(1);
|
|
318
304
|
break;
|
|
305
|
+
case "X25519":
|
|
306
|
+
bytes.push(0);
|
|
307
|
+
break;
|
|
319
308
|
}
|
|
320
309
|
const key = BigInt("0x" + XUtils.encodeHex(publicKey));
|
|
321
310
|
if (isEven(key)) {
|
|
@@ -329,25 +318,58 @@ export function xEncode(curveType, publicKey) {
|
|
|
329
318
|
}
|
|
330
319
|
return Uint8Array.from(bytes);
|
|
331
320
|
}
|
|
321
|
+
// ── Key generation ─────────────────────────────────────────────────────────
|
|
332
322
|
/**
|
|
333
|
-
*
|
|
323
|
+
* Hashes some data.
|
|
324
|
+
*
|
|
325
|
+
* @param data the data to hash.
|
|
326
|
+
* @returns The hash of the data.
|
|
334
327
|
*/
|
|
335
|
-
function
|
|
336
|
-
return
|
|
328
|
+
export function xHash(data) {
|
|
329
|
+
return XUtils.encodeHex(sha512(data));
|
|
330
|
+
}
|
|
331
|
+
export function xKDF(IKM) {
|
|
332
|
+
return hkdf(sha512, IKM, xMakeSalt(xConstants.CURVE), new TextEncoder().encode(xConstants.INFO), xConstants.KEY_LENGTH);
|
|
337
333
|
}
|
|
338
334
|
/**
|
|
339
|
-
*
|
|
335
|
+
* Returns a 24 byte random nonce of cryptographic quality.
|
|
340
336
|
*/
|
|
341
|
-
function
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
337
|
+
export function xMakeNonce() {
|
|
338
|
+
return nacl.randomBytes(24);
|
|
339
|
+
}
|
|
340
|
+
/** Cryptographically secure random bytes. */
|
|
341
|
+
export function xRandomBytes(length) {
|
|
342
|
+
return nacl.randomBytes(length);
|
|
343
|
+
}
|
|
344
|
+
// ── Signing ────────────────────────────────────────────────────────────────
|
|
345
|
+
/** Encrypt with a shared secret key. */
|
|
346
|
+
export function xSecretbox(plaintext, nonce, key) {
|
|
347
|
+
return nacl.secretbox(plaintext, nonce, key);
|
|
348
|
+
}
|
|
349
|
+
/** Decrypt with a shared secret key. Returns null if authentication fails. */
|
|
350
|
+
export function xSecretboxOpen(ciphertext, nonce, key) {
|
|
351
|
+
return nacl.secretbox.open(ciphertext, nonce, key);
|
|
352
|
+
}
|
|
353
|
+
// ── Symmetric encryption (XSalsa20-Poly1305) ──────────────────────────────
|
|
354
|
+
/** Sign a message with an Ed25519 secret key. Returns signed message (64-byte signature prefix + message). */
|
|
355
|
+
export function xSign(message, secretKey) {
|
|
356
|
+
return nacl.sign(message, secretKey);
|
|
357
|
+
}
|
|
358
|
+
/** Generate a fresh Ed25519 signing key pair. */
|
|
359
|
+
export function xSignKeyPair() {
|
|
360
|
+
return nacl.sign.keyPair();
|
|
361
|
+
}
|
|
362
|
+
// ── Random ─────────────────────────────────────────────────────────────────
|
|
363
|
+
/** Restore an Ed25519 signing key pair from a 64-byte secret key. */
|
|
364
|
+
export function xSignKeyPairFromSecret(secretKey) {
|
|
365
|
+
return nacl.sign.keyPair.fromSecretKey(secretKey);
|
|
366
|
+
}
|
|
367
|
+
/** Verify and open a signed message. Returns the original message, or null if verification fails. */
|
|
368
|
+
export function xSignOpen(signedMessage, publicKey) {
|
|
369
|
+
return nacl.sign.open(signedMessage, publicKey);
|
|
348
370
|
}
|
|
349
371
|
/**
|
|
350
|
-
* @
|
|
372
|
+
* @internal
|
|
351
373
|
*/
|
|
352
374
|
function isEven(value) {
|
|
353
375
|
if (value % BigInt(2) === BigInt(0)) {
|
|
@@ -357,4 +379,18 @@ function isEven(value) {
|
|
|
357
379
|
return false;
|
|
358
380
|
}
|
|
359
381
|
}
|
|
382
|
+
/**
|
|
383
|
+
* @internal
|
|
384
|
+
*/
|
|
385
|
+
function keyLength(curve) {
|
|
386
|
+
return curve === "X25519" ? 32 : 57;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* @internal
|
|
390
|
+
*/
|
|
391
|
+
function xMakeSalt(curve) {
|
|
392
|
+
const salt = new Uint8Array(keyLength(curve));
|
|
393
|
+
salt.fill(0xff);
|
|
394
|
+
return salt;
|
|
395
|
+
}
|
|
360
396
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sour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