@unknownncat/curve25519-node 2.0.0 → 2.1.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/NOTICE.md +89 -0
- package/README.en.md +110 -20
- package/README.md +102 -12
- package/SECURITY.md +23 -0
- package/THIRD_PARTY_NOTICE.md +3 -0
- package/THIRD_PARTY_NOTICES.md +5 -0
- package/dist/axlsign.d.ts.map +1 -1
- package/dist/axlsign.js +29 -7
- package/dist/axlsign.js.map +1 -1
- package/dist/cjs/axlsign.js +28 -6
- package/dist/cjs/axlsign.js.map +1 -1
- package/dist/cjs/ed25519.js +46 -10
- package/dist/cjs/ed25519.js.map +1 -1
- package/dist/cjs/index.js +27 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/internal/assert.js.map +1 -1
- package/dist/cjs/internal/curve25519-wasm/LICENSE +21 -0
- package/dist/cjs/internal/curve25519-wasm/curve25519_wasm.d.ts +12 -0
- package/dist/cjs/internal/curve25519-wasm/curve25519_wasm.js +165 -0
- package/dist/cjs/internal/curve25519-wasm/curve25519_wasm_bg.wasm +0 -0
- package/dist/cjs/internal/curve25519-wasm/curve25519_wasm_bg.wasm.d.ts +13 -0
- package/dist/cjs/internal/curve25519-wasm/package.json +17 -0
- package/dist/cjs/wasm.js +228 -0
- package/dist/cjs/wasm.js.map +1 -0
- package/dist/cjs/x25519.js +73 -12
- package/dist/cjs/x25519.js.map +1 -1
- package/dist/ed25519.d.ts +21 -0
- package/dist/ed25519.d.ts.map +1 -1
- package/dist/ed25519.js +44 -13
- package/dist/ed25519.js.map +1 -1
- package/dist/index.d.ts +87 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/assert.js.map +1 -1
- package/dist/internal/curve25519-wasm/LICENSE +21 -0
- package/dist/internal/curve25519-wasm/curve25519_wasm.d.ts +12 -0
- package/dist/internal/curve25519-wasm/curve25519_wasm.js +165 -0
- package/dist/internal/curve25519-wasm/curve25519_wasm_bg.wasm +0 -0
- package/dist/internal/curve25519-wasm/curve25519_wasm_bg.wasm.d.ts +13 -0
- package/dist/internal/curve25519-wasm/package.json +17 -0
- package/dist/types.d.ts +2 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/wasm.d.ts +92 -0
- package/dist/wasm.d.ts.map +1 -0
- package/dist/wasm.js +204 -0
- package/dist/wasm.js.map +1 -0
- package/dist/x25519.d.ts +29 -0
- package/dist/x25519.d.ts.map +1 -1
- package/dist/x25519.js +66 -12
- package/dist/x25519.js.map +1 -1
- package/package.json +28 -5
package/dist/cjs/wasm.js
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ed25519 = exports.x25519 = void 0;
|
|
4
|
+
exports.isAllZero32 = isAllZero32;
|
|
5
|
+
exports.x25519CreatePrivateKeyObject = x25519CreatePrivateKeyObject;
|
|
6
|
+
exports.x25519CreatePublicKeyObject = x25519CreatePublicKeyObject;
|
|
7
|
+
exports.x25519PublicKeyFromPrivateKeyObject = x25519PublicKeyFromPrivateKeyObject;
|
|
8
|
+
exports.x25519PublicKey = x25519PublicKey;
|
|
9
|
+
exports.x25519SharedKeyFromKeyObjects = x25519SharedKeyFromKeyObjects;
|
|
10
|
+
exports.x25519SharedKey = x25519SharedKey;
|
|
11
|
+
exports.x25519SharedKeyStrictFromKeyObjects = x25519SharedKeyStrictFromKeyObjects;
|
|
12
|
+
exports.x25519SharedKeyStrict = x25519SharedKeyStrict;
|
|
13
|
+
exports.x25519GenerateKeyPair = x25519GenerateKeyPair;
|
|
14
|
+
exports.ed25519CreatePrivateKeyObject = ed25519CreatePrivateKeyObject;
|
|
15
|
+
exports.ed25519CreatePublicKeyObject = ed25519CreatePublicKeyObject;
|
|
16
|
+
exports.ed25519PublicKeyFromPrivateKeyObject = ed25519PublicKeyFromPrivateKeyObject;
|
|
17
|
+
exports.ed25519PublicKey = ed25519PublicKey;
|
|
18
|
+
exports.ed25519GenerateKeyPair = ed25519GenerateKeyPair;
|
|
19
|
+
exports.ed25519SignWithPrivateKey = ed25519SignWithPrivateKey;
|
|
20
|
+
exports.ed25519Sign = ed25519Sign;
|
|
21
|
+
exports.ed25519VerifyWithPublicKey = ed25519VerifyWithPublicKey;
|
|
22
|
+
exports.ed25519Verify = ed25519Verify;
|
|
23
|
+
exports.ed25519SignMessage = ed25519SignMessage;
|
|
24
|
+
exports.ed25519OpenMessage = ed25519OpenMessage;
|
|
25
|
+
const node_path_1 = require("node:path");
|
|
26
|
+
const node_module_1 = require("node:module");
|
|
27
|
+
const assert_js_1 = require("./internal/assert.js");
|
|
28
|
+
const SELF_PACKAGE_NAME = "@unknownncat/curve25519-node";
|
|
29
|
+
const requireBase = typeof __filename === "string"
|
|
30
|
+
? __filename
|
|
31
|
+
: typeof process.argv[1] === "string"
|
|
32
|
+
? process.argv[1]
|
|
33
|
+
: (0, node_path_1.join)(process.cwd(), "index.js");
|
|
34
|
+
const nodeRequire = (0, node_module_1.createRequire)(requireBase);
|
|
35
|
+
let wasmModulePath;
|
|
36
|
+
let wasmBindings;
|
|
37
|
+
function getWasmBindings() {
|
|
38
|
+
if (wasmBindings !== undefined) {
|
|
39
|
+
return wasmBindings;
|
|
40
|
+
}
|
|
41
|
+
if (wasmModulePath === undefined) {
|
|
42
|
+
const packageJsonPath = nodeRequire.resolve(`${SELF_PACKAGE_NAME}/package.json`);
|
|
43
|
+
wasmModulePath = (0, node_path_1.join)((0, node_path_1.dirname)(packageJsonPath), "dist", "internal", "curve25519-wasm", "curve25519_wasm.js");
|
|
44
|
+
}
|
|
45
|
+
// Lazy-load WASM bindings so node:crypto users avoid startup overhead.
|
|
46
|
+
wasmBindings = nodeRequire(wasmModulePath);
|
|
47
|
+
return wasmBindings;
|
|
48
|
+
}
|
|
49
|
+
function copyBytes32(bytes32, label) {
|
|
50
|
+
const out = new Uint8Array(32);
|
|
51
|
+
out.set(bytes32);
|
|
52
|
+
return (0, assert_js_1.asBytes32)(out, label);
|
|
53
|
+
}
|
|
54
|
+
function clampScalar(seed32) {
|
|
55
|
+
const out = new Uint8Array(32);
|
|
56
|
+
out.set(seed32);
|
|
57
|
+
out[0] = (out[0] ?? 0) & 248;
|
|
58
|
+
const last = out[31] ?? 0;
|
|
59
|
+
out[31] = (last & 127) | 64;
|
|
60
|
+
return (0, assert_js_1.asBytes32)(out, "clamped scalar");
|
|
61
|
+
}
|
|
62
|
+
function isRecord(value) {
|
|
63
|
+
return typeof value === "object" && value !== null;
|
|
64
|
+
}
|
|
65
|
+
function assertWasmKeyObject(value, expectedType, label) {
|
|
66
|
+
if (!isRecord(value) || value.type !== expectedType || !(value.bytes instanceof Uint8Array)) {
|
|
67
|
+
throw new TypeError(`${label} must be a ${expectedType} key object`);
|
|
68
|
+
}
|
|
69
|
+
(0, assert_js_1.assertBytes32)(value.bytes, `${label}.bytes`);
|
|
70
|
+
}
|
|
71
|
+
function isAllZero32(bytes32) {
|
|
72
|
+
(0, assert_js_1.assertBytes32)(bytes32, "bytes32");
|
|
73
|
+
let acc = 0;
|
|
74
|
+
for (let i = 0; i < 32; i += 1) {
|
|
75
|
+
acc |= bytes32[i] ?? 0;
|
|
76
|
+
}
|
|
77
|
+
return acc === 0;
|
|
78
|
+
}
|
|
79
|
+
function x25519CreatePrivateKeyObject(secretKey32) {
|
|
80
|
+
(0, assert_js_1.assertBytes32)(secretKey32, "secretKey32");
|
|
81
|
+
return Object.freeze({
|
|
82
|
+
type: "x25519-private",
|
|
83
|
+
bytes: copyBytes32(secretKey32, "x25519 private key object bytes"),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function x25519CreatePublicKeyObject(publicKey32) {
|
|
87
|
+
(0, assert_js_1.assertBytes32)(publicKey32, "publicKey32");
|
|
88
|
+
return Object.freeze({
|
|
89
|
+
type: "x25519-public",
|
|
90
|
+
bytes: copyBytes32(publicKey32, "x25519 public key object bytes"),
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function x25519PublicKeyFromPrivateKeyObject(privateKey) {
|
|
94
|
+
assertWasmKeyObject(privateKey, "x25519-private", "privateKey");
|
|
95
|
+
return (0, assert_js_1.asBytes32)(getWasmBindings().x25519PublicKey(privateKey.bytes), "x25519 public key");
|
|
96
|
+
}
|
|
97
|
+
function x25519PublicKey(secretKey32) {
|
|
98
|
+
return x25519PublicKeyFromPrivateKeyObject(x25519CreatePrivateKeyObject(secretKey32));
|
|
99
|
+
}
|
|
100
|
+
function x25519SharedKeyFromKeyObjects(privateKey, publicKey) {
|
|
101
|
+
assertWasmKeyObject(privateKey, "x25519-private", "privateKey");
|
|
102
|
+
assertWasmKeyObject(publicKey, "x25519-public", "publicKey");
|
|
103
|
+
return (0, assert_js_1.asBytes32)(getWasmBindings().x25519SharedKey(privateKey.bytes, publicKey.bytes), "x25519 shared key");
|
|
104
|
+
}
|
|
105
|
+
function x25519SharedKey(secretKey32, publicKey32) {
|
|
106
|
+
const privateKey = x25519CreatePrivateKeyObject(secretKey32);
|
|
107
|
+
const publicKey = x25519CreatePublicKeyObject(publicKey32);
|
|
108
|
+
return x25519SharedKeyFromKeyObjects(privateKey, publicKey);
|
|
109
|
+
}
|
|
110
|
+
function x25519SharedKeyStrictFromKeyObjects(privateKey, publicKey) {
|
|
111
|
+
const shared = x25519SharedKeyFromKeyObjects(privateKey, publicKey);
|
|
112
|
+
if (isAllZero32(shared)) {
|
|
113
|
+
throw new Error("X25519 shared secret is all-zero; reject low-order/invalid peer public key in protocol flow.");
|
|
114
|
+
}
|
|
115
|
+
return shared;
|
|
116
|
+
}
|
|
117
|
+
function x25519SharedKeyStrict(secretKey32, publicKey32) {
|
|
118
|
+
const privateKey = x25519CreatePrivateKeyObject(secretKey32);
|
|
119
|
+
const publicKey = x25519CreatePublicKeyObject(publicKey32);
|
|
120
|
+
return x25519SharedKeyStrictFromKeyObjects(privateKey, publicKey);
|
|
121
|
+
}
|
|
122
|
+
function x25519GenerateKeyPair(seed32) {
|
|
123
|
+
(0, assert_js_1.assertBytes32)(seed32, "seed32");
|
|
124
|
+
const privateKey = clampScalar(seed32);
|
|
125
|
+
const publicKey32 = x25519PublicKey(privateKey);
|
|
126
|
+
return {
|
|
127
|
+
public: publicKey32,
|
|
128
|
+
private: privateKey,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function ed25519CreatePrivateKeyObject(secretSeed32) {
|
|
132
|
+
(0, assert_js_1.assertBytes32)(secretSeed32, "secretSeed32");
|
|
133
|
+
return Object.freeze({
|
|
134
|
+
type: "ed25519-private",
|
|
135
|
+
bytes: copyBytes32(secretSeed32, "ed25519 private key object bytes"),
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
function ed25519CreatePublicKeyObject(publicKey32) {
|
|
139
|
+
(0, assert_js_1.assertBytes32)(publicKey32, "publicKey32");
|
|
140
|
+
return Object.freeze({
|
|
141
|
+
type: "ed25519-public",
|
|
142
|
+
bytes: copyBytes32(publicKey32, "ed25519 public key object bytes"),
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
function ed25519PublicKeyFromPrivateKeyObject(privateKey) {
|
|
146
|
+
assertWasmKeyObject(privateKey, "ed25519-private", "privateKey");
|
|
147
|
+
return (0, assert_js_1.asBytes32)(getWasmBindings().ed25519PublicKey(privateKey.bytes), "ed25519 public key");
|
|
148
|
+
}
|
|
149
|
+
function ed25519PublicKey(secretSeed32) {
|
|
150
|
+
return ed25519PublicKeyFromPrivateKeyObject(ed25519CreatePrivateKeyObject(secretSeed32));
|
|
151
|
+
}
|
|
152
|
+
function ed25519GenerateKeyPair(seed32) {
|
|
153
|
+
(0, assert_js_1.assertBytes32)(seed32, "seed32");
|
|
154
|
+
return {
|
|
155
|
+
public: ed25519PublicKey(seed32),
|
|
156
|
+
private: seed32,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
function ed25519SignWithPrivateKey(privateKey, msg) {
|
|
160
|
+
assertWasmKeyObject(privateKey, "ed25519-private", "privateKey");
|
|
161
|
+
(0, assert_js_1.assertUint8Array)(msg, "msg");
|
|
162
|
+
return (0, assert_js_1.asBytes64)(getWasmBindings().ed25519Sign(privateKey.bytes, msg), "ed25519 signature");
|
|
163
|
+
}
|
|
164
|
+
function ed25519Sign(secretSeed32, msg) {
|
|
165
|
+
return ed25519SignWithPrivateKey(ed25519CreatePrivateKeyObject(secretSeed32), msg);
|
|
166
|
+
}
|
|
167
|
+
function ed25519VerifyWithPublicKey(publicKey, msg, signature64) {
|
|
168
|
+
assertWasmKeyObject(publicKey, "ed25519-public", "publicKey");
|
|
169
|
+
(0, assert_js_1.assertUint8Array)(msg, "msg");
|
|
170
|
+
(0, assert_js_1.assertBytes64)(signature64, "signature64");
|
|
171
|
+
return getWasmBindings().ed25519Verify(publicKey.bytes, msg, signature64);
|
|
172
|
+
}
|
|
173
|
+
function ed25519Verify(publicKey32, msg, signature64) {
|
|
174
|
+
return ed25519VerifyWithPublicKey(ed25519CreatePublicKeyObject(publicKey32), msg, signature64);
|
|
175
|
+
}
|
|
176
|
+
function ed25519SignMessage(secretSeed32, msg) {
|
|
177
|
+
(0, assert_js_1.assertBytes32)(secretSeed32, "secretSeed32");
|
|
178
|
+
(0, assert_js_1.assertUint8Array)(msg, "msg");
|
|
179
|
+
const signature64 = ed25519Sign(secretSeed32, msg);
|
|
180
|
+
const signed = new Uint8Array(64 + msg.byteLength);
|
|
181
|
+
signed.set(signature64, 0);
|
|
182
|
+
signed.set(msg, 64);
|
|
183
|
+
return signed;
|
|
184
|
+
}
|
|
185
|
+
function ed25519OpenMessage(publicKey32, signedMsg) {
|
|
186
|
+
(0, assert_js_1.assertBytes32)(publicKey32, "publicKey32");
|
|
187
|
+
(0, assert_js_1.assertUint8Array)(signedMsg, "signedMsg");
|
|
188
|
+
if (signedMsg.byteLength < 64) {
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
const signature64 = (0, assert_js_1.asBytes64)(signedMsg.subarray(0, 64), "signedMsg signature");
|
|
192
|
+
const msg = signedMsg.subarray(64);
|
|
193
|
+
if (!ed25519Verify(publicKey32, msg, signature64)) {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
return new Uint8Array(msg);
|
|
197
|
+
}
|
|
198
|
+
exports.x25519 = {
|
|
199
|
+
createPrivateKeyObject: x25519CreatePrivateKeyObject,
|
|
200
|
+
createPublicKeyObject: x25519CreatePublicKeyObject,
|
|
201
|
+
publicKeyFromPrivateKeyObject: x25519PublicKeyFromPrivateKeyObject,
|
|
202
|
+
publicKey: x25519PublicKey,
|
|
203
|
+
sharedKey: x25519SharedKey,
|
|
204
|
+
sharedKeyFromKeyObjects: x25519SharedKeyFromKeyObjects,
|
|
205
|
+
sharedKeyStrict: x25519SharedKeyStrict,
|
|
206
|
+
sharedKeyStrictFromKeyObjects: x25519SharedKeyStrictFromKeyObjects,
|
|
207
|
+
isAllZero32,
|
|
208
|
+
generateKeyPair: x25519GenerateKeyPair,
|
|
209
|
+
};
|
|
210
|
+
exports.ed25519 = {
|
|
211
|
+
createPrivateKeyObject: ed25519CreatePrivateKeyObject,
|
|
212
|
+
createPublicKeyObject: ed25519CreatePublicKeyObject,
|
|
213
|
+
publicKeyFromPrivateKeyObject: ed25519PublicKeyFromPrivateKeyObject,
|
|
214
|
+
publicKey: ed25519PublicKey,
|
|
215
|
+
generateKeyPair: ed25519GenerateKeyPair,
|
|
216
|
+
sign: ed25519Sign,
|
|
217
|
+
signWithPrivateKey: ed25519SignWithPrivateKey,
|
|
218
|
+
verify: ed25519Verify,
|
|
219
|
+
verifyWithPublicKey: ed25519VerifyWithPublicKey,
|
|
220
|
+
signMessage: ed25519SignMessage,
|
|
221
|
+
openMessage: ed25519OpenMessage,
|
|
222
|
+
};
|
|
223
|
+
const api = {
|
|
224
|
+
x25519: exports.x25519,
|
|
225
|
+
ed25519: exports.ed25519,
|
|
226
|
+
};
|
|
227
|
+
exports.default = api;
|
|
228
|
+
//# sourceMappingURL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WAAW,EAAE,kBAAkB;CACvB,CAAC;AAEX,MAAM,GAAG,GAAG;IACV,MAAM,EAAN,cAAM;IACN,OAAO,EAAP,eAAO;CACC,CAAC;AAEX,kBAAe,GAAG,CAAC"}
|
package/dist/cjs/x25519.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isAllZero32 = isAllZero32;
|
|
4
|
+
exports.createPrivateKeyObject = createPrivateKeyObject;
|
|
5
|
+
exports.createPublicKeyObject = createPublicKeyObject;
|
|
6
|
+
exports.publicKeyFromPrivateKeyObject = publicKeyFromPrivateKeyObject;
|
|
3
7
|
exports.publicKey = publicKey;
|
|
8
|
+
exports.sharedKeyFromKeyObjects = sharedKeyFromKeyObjects;
|
|
4
9
|
exports.sharedKey = sharedKey;
|
|
10
|
+
exports.sharedKeyStrict = sharedKeyStrict;
|
|
11
|
+
exports.sharedKeyStrictFromKeyObjects = sharedKeyStrictFromKeyObjects;
|
|
5
12
|
exports.generateKeyPair = generateKeyPair;
|
|
6
13
|
const node_crypto_1 = require("node:crypto");
|
|
7
14
|
const assert_js_1 = require("./internal/assert.js");
|
|
@@ -14,28 +21,82 @@ function clampScalar(seed32) {
|
|
|
14
21
|
clamped[31] = (last & 127) | 64;
|
|
15
22
|
return (0, assert_js_1.asBytes32)(clamped, "clamped scalar");
|
|
16
23
|
}
|
|
24
|
+
function normalizeSharedSecret(shared) {
|
|
25
|
+
if (shared.byteLength !== 32) {
|
|
26
|
+
throw new Error(`X25519 shared secret must be 32 bytes, received ${shared.byteLength}`);
|
|
27
|
+
}
|
|
28
|
+
return (0, assert_js_1.asBytes32)(new Uint8Array(shared.buffer, shared.byteOffset, shared.byteLength), "sharedKey");
|
|
29
|
+
}
|
|
17
30
|
/**
|
|
18
|
-
*
|
|
31
|
+
* Constant-time style 32-byte zero check for shared-secret hardening.
|
|
19
32
|
*/
|
|
20
|
-
function
|
|
33
|
+
function isAllZero32(bytes32) {
|
|
34
|
+
(0, assert_js_1.assertBytes32)(bytes32, "bytes32");
|
|
35
|
+
let acc = 0;
|
|
36
|
+
for (let i = 0; i < 32; i += 1) {
|
|
37
|
+
acc |= bytes32[i] ?? 0;
|
|
38
|
+
}
|
|
39
|
+
return acc === 0;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Builds a reusable X25519 private KeyObject from a raw 32-byte secret scalar.
|
|
43
|
+
*/
|
|
44
|
+
function createPrivateKeyObject(secretKey32) {
|
|
21
45
|
(0, assert_js_1.assertBytes32)(secretKey32, "secretKey32");
|
|
22
|
-
|
|
46
|
+
return (0, der_js_1.keyFromX25519Private)(secretKey32);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Builds a reusable X25519 public KeyObject from a raw 32-byte public key.
|
|
50
|
+
*/
|
|
51
|
+
function createPublicKeyObject(publicKey32) {
|
|
52
|
+
(0, assert_js_1.assertBytes32)(publicKey32, "publicKey32");
|
|
53
|
+
return (0, der_js_1.keyFromX25519Public)(publicKey32);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Derives raw 32-byte X25519 public key from a private KeyObject.
|
|
57
|
+
*/
|
|
58
|
+
function publicKeyFromPrivateKeyObject(privateKey) {
|
|
23
59
|
return (0, der_js_1.rawPublicFromX25519Spki)((0, node_crypto_1.createPublicKey)(privateKey));
|
|
24
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Derives an X25519 public key from a raw 32-byte secret scalar.
|
|
63
|
+
*/
|
|
64
|
+
function publicKey(secretKey32) {
|
|
65
|
+
return publicKeyFromPrivateKeyObject(createPrivateKeyObject(secretKey32));
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Computes X25519 ECDH shared secret (raw 32 bytes) from reusable KeyObjects.
|
|
69
|
+
*/
|
|
70
|
+
function sharedKeyFromKeyObjects(privateKey, publicKey) {
|
|
71
|
+
return normalizeSharedSecret((0, node_crypto_1.diffieHellman)({ privateKey, publicKey }));
|
|
72
|
+
}
|
|
25
73
|
/**
|
|
26
74
|
* Computes X25519 ECDH shared secret (raw 32 bytes).
|
|
27
75
|
*/
|
|
28
76
|
function sharedKey(secretKey32, publicKey32) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
77
|
+
const privateKey = createPrivateKeyObject(secretKey32);
|
|
78
|
+
const publicKey = createPublicKeyObject(publicKey32);
|
|
79
|
+
return sharedKeyFromKeyObjects(privateKey, publicKey);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Strict X25519 ECDH: rejects all-zero shared secret.
|
|
83
|
+
*/
|
|
84
|
+
function sharedKeyStrict(secretKey32, publicKey32) {
|
|
85
|
+
const shared = sharedKey(secretKey32, publicKey32);
|
|
86
|
+
if (isAllZero32(shared)) {
|
|
87
|
+
throw new Error("X25519 shared secret is all-zero; reject low-order/invalid peer public key in protocol flow.");
|
|
37
88
|
}
|
|
38
|
-
return
|
|
89
|
+
return shared;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Strict X25519 ECDH from reusable KeyObjects: rejects all-zero shared secret.
|
|
93
|
+
*/
|
|
94
|
+
function sharedKeyStrictFromKeyObjects(privateKey, publicKey) {
|
|
95
|
+
const shared = sharedKeyFromKeyObjects(privateKey, publicKey);
|
|
96
|
+
if (isAllZero32(shared)) {
|
|
97
|
+
throw new Error("X25519 shared secret is all-zero; reject low-order/invalid peer public key in protocol flow.");
|
|
98
|
+
}
|
|
99
|
+
return shared;
|
|
39
100
|
}
|
|
40
101
|
/**
|
|
41
102
|
* Deterministically creates an X25519 key pair from a 32-byte seed.
|
package/dist/cjs/x25519.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"x25519.js","sourceRoot":"","sources":["../../src/x25519.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,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AAS,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IACnD,IAAI,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CACb,8FAA8F,CAC/F,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,SAAgB,6BAA6B,CAC3C,UAAqB,EACrB,SAAoB;IAEpB,MAAM,MAAM,GAAG,uBAAuB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;IAC9D,IAAI,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CACb,8FAA8F,CAC/F,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,SAAgB,eAAe,CAAC,MAAe;IAC7C,IAAA,yBAAa,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAChC,MAAM,UAAU,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IACvC,MAAM,WAAW,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;IAC1C,OAAO;QACL,MAAM,EAAE,WAAW;QACnB,OAAO,EAAE,UAAU;KACpB,CAAC;AACJ,CAAC"}
|
package/dist/ed25519.d.ts
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
|
+
import { type KeyObject } from "node:crypto";
|
|
1
2
|
import type { Bytes32, Bytes64, KeyPair32 } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Builds a reusable Ed25519 private KeyObject from a raw 32-byte seed.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createPrivateKeyObject(secretSeed32: Bytes32): KeyObject;
|
|
7
|
+
/**
|
|
8
|
+
* Builds a reusable Ed25519 public KeyObject from a raw 32-byte public key.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createPublicKeyObject(publicKey32: Bytes32): KeyObject;
|
|
11
|
+
/**
|
|
12
|
+
* Derives raw 32-byte Ed25519 public key from a private KeyObject.
|
|
13
|
+
*/
|
|
14
|
+
export declare function publicKeyFromPrivateKeyObject(privateKey: KeyObject): Bytes32;
|
|
2
15
|
/**
|
|
3
16
|
* Derives an Ed25519 public key from a raw 32-byte seed.
|
|
4
17
|
*/
|
|
@@ -12,10 +25,18 @@ export declare function generateKeyPair(seed32: Bytes32): KeyPair32;
|
|
|
12
25
|
* Signs a message with Ed25519 and returns the 64-byte detached signature.
|
|
13
26
|
*/
|
|
14
27
|
export declare function sign(secretSeed32: Bytes32, msg: Uint8Array): Bytes64;
|
|
28
|
+
/**
|
|
29
|
+
* Signs a message with Ed25519 using a reusable private KeyObject.
|
|
30
|
+
*/
|
|
31
|
+
export declare function signWithPrivateKey(privateKey: KeyObject, msg: Uint8Array): Bytes64;
|
|
15
32
|
/**
|
|
16
33
|
* Verifies a detached Ed25519 signature.
|
|
17
34
|
*/
|
|
18
35
|
export declare function verify(publicKey32: Bytes32, msg: Uint8Array, signature64: Bytes64): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Verifies a detached Ed25519 signature using a reusable public KeyObject.
|
|
38
|
+
*/
|
|
39
|
+
export declare function verifyWithPublicKey(publicKey: KeyObject, msg: Uint8Array, signature64: Bytes64): boolean;
|
|
19
40
|
/**
|
|
20
41
|
* Returns signature || message.
|
|
21
42
|
*/
|
package/dist/ed25519.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ed25519.d.ts","sourceRoot":"","sources":["../src/ed25519.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ed25519.d.ts","sourceRoot":"","sources":["../src/ed25519.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,SAAS,EAEf,MAAM,aAAa,CAAC;AAarB,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAY9D;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,OAAO,GAAG,SAAS,CAGvE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,OAAO,GAAG,SAAS,CAGrE;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAAC,UAAU,EAAE,SAAS,GAAG,OAAO,CAE5E;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,YAAY,EAAE,OAAO,GAAG,OAAO,CAExD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,CAM1D;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,YAAY,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAEpE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,SAAS,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAGlF;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,WAAW,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,GAAG,OAAO,CAE3F;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,UAAU,EACf,WAAW,EAAE,OAAO,GACnB,OAAO,CAIT;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,YAAY,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,GAAG,UAAU,CAS9E;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI,CAgB1F"}
|
package/dist/ed25519.js
CHANGED
|
@@ -1,12 +1,37 @@
|
|
|
1
|
-
import { createPublicKey, sign as cryptoSign, verify as cryptoVerify } from "node:crypto";
|
|
2
|
-
import { asBytes64, assertBytes32, assertBytes64, assertUint8Array, toBufferView } from "./internal/assert.js";
|
|
3
|
-
import { keyFromEd25519Private, keyFromEd25519Public, rawPublicFromEd25519Spki } from "./internal/der.js";
|
|
1
|
+
import { createPublicKey, sign as cryptoSign, verify as cryptoVerify, } from "node:crypto";
|
|
2
|
+
import { asBytes64, assertBytes32, assertBytes64, assertUint8Array, toBufferView, } from "./internal/assert.js";
|
|
3
|
+
import { keyFromEd25519Private, keyFromEd25519Public, rawPublicFromEd25519Spki, } from "./internal/der.js";
|
|
4
|
+
function normalizeSignature(signature) {
|
|
5
|
+
if (signature.byteLength !== 64) {
|
|
6
|
+
throw new Error(`Ed25519 signature must be 64 bytes, received ${signature.byteLength}`);
|
|
7
|
+
}
|
|
8
|
+
return asBytes64(new Uint8Array(signature.buffer, signature.byteOffset, signature.byteLength), "signature");
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Builds a reusable Ed25519 private KeyObject from a raw 32-byte seed.
|
|
12
|
+
*/
|
|
13
|
+
export function createPrivateKeyObject(secretSeed32) {
|
|
14
|
+
assertBytes32(secretSeed32, "secretSeed32");
|
|
15
|
+
return keyFromEd25519Private(secretSeed32);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Builds a reusable Ed25519 public KeyObject from a raw 32-byte public key.
|
|
19
|
+
*/
|
|
20
|
+
export function createPublicKeyObject(publicKey32) {
|
|
21
|
+
assertBytes32(publicKey32, "publicKey32");
|
|
22
|
+
return keyFromEd25519Public(publicKey32);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Derives raw 32-byte Ed25519 public key from a private KeyObject.
|
|
26
|
+
*/
|
|
27
|
+
export function publicKeyFromPrivateKeyObject(privateKey) {
|
|
28
|
+
return rawPublicFromEd25519Spki(createPublicKey(privateKey));
|
|
29
|
+
}
|
|
4
30
|
/**
|
|
5
31
|
* Derives an Ed25519 public key from a raw 32-byte seed.
|
|
6
32
|
*/
|
|
7
33
|
export function publicKey(secretSeed32) {
|
|
8
|
-
|
|
9
|
-
return rawPublicFromEd25519Spki(createPublicKey(keyFromEd25519Private(secretSeed32)));
|
|
34
|
+
return publicKeyFromPrivateKeyObject(createPrivateKeyObject(secretSeed32));
|
|
10
35
|
}
|
|
11
36
|
/**
|
|
12
37
|
* Deterministically creates an Ed25519 key pair from a 32-byte seed.
|
|
@@ -23,22 +48,28 @@ export function generateKeyPair(seed32) {
|
|
|
23
48
|
* Signs a message with Ed25519 and returns the 64-byte detached signature.
|
|
24
49
|
*/
|
|
25
50
|
export function sign(secretSeed32, msg) {
|
|
26
|
-
|
|
51
|
+
return signWithPrivateKey(createPrivateKeyObject(secretSeed32), msg);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Signs a message with Ed25519 using a reusable private KeyObject.
|
|
55
|
+
*/
|
|
56
|
+
export function signWithPrivateKey(privateKey, msg) {
|
|
27
57
|
assertUint8Array(msg, "msg");
|
|
28
|
-
|
|
29
|
-
if (signature.byteLength !== 64) {
|
|
30
|
-
throw new Error(`Ed25519 signature must be 64 bytes, received ${signature.byteLength}`);
|
|
31
|
-
}
|
|
32
|
-
return asBytes64(new Uint8Array(signature.buffer, signature.byteOffset, signature.byteLength), "signature");
|
|
58
|
+
return normalizeSignature(cryptoSign(null, toBufferView(msg), privateKey));
|
|
33
59
|
}
|
|
34
60
|
/**
|
|
35
61
|
* Verifies a detached Ed25519 signature.
|
|
36
62
|
*/
|
|
37
63
|
export function verify(publicKey32, msg, signature64) {
|
|
38
|
-
|
|
64
|
+
return verifyWithPublicKey(createPublicKeyObject(publicKey32), msg, signature64);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Verifies a detached Ed25519 signature using a reusable public KeyObject.
|
|
68
|
+
*/
|
|
69
|
+
export function verifyWithPublicKey(publicKey, msg, signature64) {
|
|
39
70
|
assertUint8Array(msg, "msg");
|
|
40
71
|
assertBytes64(signature64, "signature64");
|
|
41
|
-
return cryptoVerify(null, toBufferView(msg),
|
|
72
|
+
return cryptoVerify(null, toBufferView(msg), publicKey, toBufferView(signature64));
|
|
42
73
|
}
|
|
43
74
|
/**
|
|
44
75
|
* Returns signature || message.
|
package/dist/ed25519.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ed25519.js","sourceRoot":"","sources":["../src/ed25519.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ed25519.js","sourceRoot":"","sources":["../src/ed25519.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,IAAI,IAAI,UAAU,EAElB,MAAM,IAAI,YAAY,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,SAAS,EACT,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,YAAY,GACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,mBAAmB,CAAC;AAG3B,SAAS,kBAAkB,CAAC,SAAiB;IAC3C,IAAI,SAAS,CAAC,UAAU,KAAK,EAAE,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,gDAAgD,SAAS,CAAC,UAAU,EAAE,CAAC,CAAC;IAC1F,CAAC;IACD,OAAO,SAAS,CACd,IAAI,UAAU,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,UAAU,EAAE,SAAS,CAAC,UAAU,CAAC,EAC5E,WAAW,CACZ,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,YAAqB;IAC1D,aAAa,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;IAC5C,OAAO,qBAAqB,CAAC,YAAY,CAAC,CAAC;AAC7C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,WAAoB;IACxD,aAAa,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IAC1C,OAAO,oBAAoB,CAAC,WAAW,CAAC,CAAC;AAC3C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,6BAA6B,CAAC,UAAqB;IACjE,OAAO,wBAAwB,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED;;GAEG;AACH,MAA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aAAa,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;IAC5C,gBAAgB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAE7B,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;IAC1C,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,EAAE,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC;IACnD,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IACzB,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACpB,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,WAAoB,EAAE,SAAqB;IACrE,aAAa,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IAC1C,gBAAgB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IAEzC,IAAI,SAAS,CAAC,UAAU,GAAG,EAAE,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,WAAW,GAAG,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,qBAAqB,CAAC,CAAC;IAChF,MAAM,GAAG,GAAG,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACnC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,EAAE,WAAW,CAAC,EAAE,CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,8EAA8E;IAC9E,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as axlsignApi from "./axlsign.js";
|
|
2
|
+
import * as wasmApi from "./wasm.js";
|
|
2
3
|
import * as ed25519Api from "./ed25519.js";
|
|
3
4
|
import * as x25519Api from "./x25519.js";
|
|
4
5
|
import type { Bytes32, Bytes64 } from "./types.js";
|
|
@@ -8,18 +9,30 @@ export type { Bytes32, Bytes64, KeyPair32 } from "./types.js";
|
|
|
8
9
|
* Standard X25519 namespace.
|
|
9
10
|
*/
|
|
10
11
|
export declare const x25519: {
|
|
12
|
+
readonly createPrivateKeyObject: typeof x25519Api.createPrivateKeyObject;
|
|
13
|
+
readonly createPublicKeyObject: typeof x25519Api.createPublicKeyObject;
|
|
14
|
+
readonly publicKeyFromPrivateKeyObject: typeof x25519Api.publicKeyFromPrivateKeyObject;
|
|
11
15
|
readonly publicKey: typeof x25519Api.publicKey;
|
|
12
16
|
readonly sharedKey: typeof x25519Api.sharedKey;
|
|
17
|
+
readonly sharedKeyFromKeyObjects: typeof x25519Api.sharedKeyFromKeyObjects;
|
|
18
|
+
readonly sharedKeyStrict: typeof x25519Api.sharedKeyStrict;
|
|
19
|
+
readonly sharedKeyStrictFromKeyObjects: typeof x25519Api.sharedKeyStrictFromKeyObjects;
|
|
20
|
+
readonly isAllZero32: typeof x25519Api.isAllZero32;
|
|
13
21
|
readonly generateKeyPair: typeof x25519Api.generateKeyPair;
|
|
14
22
|
};
|
|
15
23
|
/**
|
|
16
24
|
* Standard Ed25519 namespace.
|
|
17
25
|
*/
|
|
18
26
|
export declare const ed25519: {
|
|
27
|
+
readonly createPrivateKeyObject: typeof ed25519Api.createPrivateKeyObject;
|
|
28
|
+
readonly createPublicKeyObject: typeof ed25519Api.createPublicKeyObject;
|
|
29
|
+
readonly publicKeyFromPrivateKeyObject: typeof ed25519Api.publicKeyFromPrivateKeyObject;
|
|
19
30
|
readonly publicKey: typeof ed25519Api.publicKey;
|
|
20
31
|
readonly generateKeyPair: typeof ed25519Api.generateKeyPair;
|
|
21
32
|
readonly sign: typeof ed25519Api.sign;
|
|
33
|
+
readonly signWithPrivateKey: typeof ed25519Api.signWithPrivateKey;
|
|
22
34
|
readonly verify: typeof ed25519Api.verify;
|
|
35
|
+
readonly verifyWithPublicKey: typeof ed25519Api.verifyWithPublicKey;
|
|
23
36
|
readonly signMessage: typeof ed25519Api.signMessage;
|
|
24
37
|
readonly openMessage: typeof ed25519Api.openMessage;
|
|
25
38
|
};
|
|
@@ -35,10 +48,44 @@ export declare const axlsign: {
|
|
|
35
48
|
readonly signMessage: typeof axlsignApi.signMessage;
|
|
36
49
|
readonly openMessage: typeof axlsignApi.openMessage;
|
|
37
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* Optional modern WASM namespace with X25519 + Ed25519 parity methods.
|
|
53
|
+
*/
|
|
54
|
+
export declare const wasm: {
|
|
55
|
+
readonly x25519: {
|
|
56
|
+
readonly createPrivateKeyObject: typeof wasmApi.x25519CreatePrivateKeyObject;
|
|
57
|
+
readonly createPublicKeyObject: typeof wasmApi.x25519CreatePublicKeyObject;
|
|
58
|
+
readonly publicKeyFromPrivateKeyObject: typeof wasmApi.x25519PublicKeyFromPrivateKeyObject;
|
|
59
|
+
readonly publicKey: typeof wasmApi.x25519PublicKey;
|
|
60
|
+
readonly sharedKey: typeof wasmApi.x25519SharedKey;
|
|
61
|
+
readonly sharedKeyFromKeyObjects: typeof wasmApi.x25519SharedKeyFromKeyObjects;
|
|
62
|
+
readonly sharedKeyStrict: typeof wasmApi.x25519SharedKeyStrict;
|
|
63
|
+
readonly sharedKeyStrictFromKeyObjects: typeof wasmApi.x25519SharedKeyStrictFromKeyObjects;
|
|
64
|
+
readonly isAllZero32: typeof wasmApi.isAllZero32;
|
|
65
|
+
readonly generateKeyPair: typeof wasmApi.x25519GenerateKeyPair;
|
|
66
|
+
};
|
|
67
|
+
readonly ed25519: {
|
|
68
|
+
readonly createPrivateKeyObject: typeof wasmApi.ed25519CreatePrivateKeyObject;
|
|
69
|
+
readonly createPublicKeyObject: typeof wasmApi.ed25519CreatePublicKeyObject;
|
|
70
|
+
readonly publicKeyFromPrivateKeyObject: typeof wasmApi.ed25519PublicKeyFromPrivateKeyObject;
|
|
71
|
+
readonly publicKey: typeof wasmApi.ed25519PublicKey;
|
|
72
|
+
readonly generateKeyPair: typeof wasmApi.ed25519GenerateKeyPair;
|
|
73
|
+
readonly sign: typeof wasmApi.ed25519Sign;
|
|
74
|
+
readonly signWithPrivateKey: typeof wasmApi.ed25519SignWithPrivateKey;
|
|
75
|
+
readonly verify: typeof wasmApi.ed25519Verify;
|
|
76
|
+
readonly verifyWithPublicKey: typeof wasmApi.ed25519VerifyWithPublicKey;
|
|
77
|
+
readonly signMessage: typeof wasmApi.ed25519SignMessage;
|
|
78
|
+
readonly openMessage: typeof wasmApi.ed25519OpenMessage;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
38
81
|
/**
|
|
39
82
|
* Top-level compatibility alias for X25519 shared secret.
|
|
40
83
|
*/
|
|
41
84
|
export declare const sharedKey: typeof x25519Api.sharedKey;
|
|
85
|
+
/**
|
|
86
|
+
* Top-level strict X25519 shared secret helper that rejects all-zero results.
|
|
87
|
+
*/
|
|
88
|
+
export declare const sharedKeyStrict: typeof x25519Api.sharedKeyStrict;
|
|
42
89
|
/**
|
|
43
90
|
* Top-level compatibility alias for X25519 deterministic key generation.
|
|
44
91
|
*/
|
|
@@ -71,15 +118,27 @@ export declare const openMessage: typeof ed25519Api.openMessage;
|
|
|
71
118
|
export declare const verify: typeof ed25519Api.verify;
|
|
72
119
|
declare const api: {
|
|
73
120
|
readonly x25519: {
|
|
121
|
+
readonly createPrivateKeyObject: typeof x25519Api.createPrivateKeyObject;
|
|
122
|
+
readonly createPublicKeyObject: typeof x25519Api.createPublicKeyObject;
|
|
123
|
+
readonly publicKeyFromPrivateKeyObject: typeof x25519Api.publicKeyFromPrivateKeyObject;
|
|
74
124
|
readonly publicKey: typeof x25519Api.publicKey;
|
|
75
125
|
readonly sharedKey: typeof x25519Api.sharedKey;
|
|
126
|
+
readonly sharedKeyFromKeyObjects: typeof x25519Api.sharedKeyFromKeyObjects;
|
|
127
|
+
readonly sharedKeyStrict: typeof x25519Api.sharedKeyStrict;
|
|
128
|
+
readonly sharedKeyStrictFromKeyObjects: typeof x25519Api.sharedKeyStrictFromKeyObjects;
|
|
129
|
+
readonly isAllZero32: typeof x25519Api.isAllZero32;
|
|
76
130
|
readonly generateKeyPair: typeof x25519Api.generateKeyPair;
|
|
77
131
|
};
|
|
78
132
|
readonly ed25519: {
|
|
133
|
+
readonly createPrivateKeyObject: typeof ed25519Api.createPrivateKeyObject;
|
|
134
|
+
readonly createPublicKeyObject: typeof ed25519Api.createPublicKeyObject;
|
|
135
|
+
readonly publicKeyFromPrivateKeyObject: typeof ed25519Api.publicKeyFromPrivateKeyObject;
|
|
79
136
|
readonly publicKey: typeof ed25519Api.publicKey;
|
|
80
137
|
readonly generateKeyPair: typeof ed25519Api.generateKeyPair;
|
|
81
138
|
readonly sign: typeof ed25519Api.sign;
|
|
139
|
+
readonly signWithPrivateKey: typeof ed25519Api.signWithPrivateKey;
|
|
82
140
|
readonly verify: typeof ed25519Api.verify;
|
|
141
|
+
readonly verifyWithPublicKey: typeof ed25519Api.verifyWithPublicKey;
|
|
83
142
|
readonly signMessage: typeof ed25519Api.signMessage;
|
|
84
143
|
readonly openMessage: typeof ed25519Api.openMessage;
|
|
85
144
|
};
|
|
@@ -92,7 +151,35 @@ declare const api: {
|
|
|
92
151
|
readonly signMessage: typeof axlsignApi.signMessage;
|
|
93
152
|
readonly openMessage: typeof axlsignApi.openMessage;
|
|
94
153
|
};
|
|
154
|
+
readonly wasm: {
|
|
155
|
+
readonly x25519: {
|
|
156
|
+
readonly createPrivateKeyObject: typeof wasmApi.x25519CreatePrivateKeyObject;
|
|
157
|
+
readonly createPublicKeyObject: typeof wasmApi.x25519CreatePublicKeyObject;
|
|
158
|
+
readonly publicKeyFromPrivateKeyObject: typeof wasmApi.x25519PublicKeyFromPrivateKeyObject;
|
|
159
|
+
readonly publicKey: typeof wasmApi.x25519PublicKey;
|
|
160
|
+
readonly sharedKey: typeof wasmApi.x25519SharedKey;
|
|
161
|
+
readonly sharedKeyFromKeyObjects: typeof wasmApi.x25519SharedKeyFromKeyObjects;
|
|
162
|
+
readonly sharedKeyStrict: typeof wasmApi.x25519SharedKeyStrict;
|
|
163
|
+
readonly sharedKeyStrictFromKeyObjects: typeof wasmApi.x25519SharedKeyStrictFromKeyObjects;
|
|
164
|
+
readonly isAllZero32: typeof wasmApi.isAllZero32;
|
|
165
|
+
readonly generateKeyPair: typeof wasmApi.x25519GenerateKeyPair;
|
|
166
|
+
};
|
|
167
|
+
readonly ed25519: {
|
|
168
|
+
readonly createPrivateKeyObject: typeof wasmApi.ed25519CreatePrivateKeyObject;
|
|
169
|
+
readonly createPublicKeyObject: typeof wasmApi.ed25519CreatePublicKeyObject;
|
|
170
|
+
readonly publicKeyFromPrivateKeyObject: typeof wasmApi.ed25519PublicKeyFromPrivateKeyObject;
|
|
171
|
+
readonly publicKey: typeof wasmApi.ed25519PublicKey;
|
|
172
|
+
readonly generateKeyPair: typeof wasmApi.ed25519GenerateKeyPair;
|
|
173
|
+
readonly sign: typeof wasmApi.ed25519Sign;
|
|
174
|
+
readonly signWithPrivateKey: typeof wasmApi.ed25519SignWithPrivateKey;
|
|
175
|
+
readonly verify: typeof wasmApi.ed25519Verify;
|
|
176
|
+
readonly verifyWithPublicKey: typeof wasmApi.ed25519VerifyWithPublicKey;
|
|
177
|
+
readonly signMessage: typeof wasmApi.ed25519SignMessage;
|
|
178
|
+
readonly openMessage: typeof wasmApi.ed25519OpenMessage;
|
|
179
|
+
};
|
|
180
|
+
};
|
|
95
181
|
readonly sharedKey: typeof x25519Api.sharedKey;
|
|
182
|
+
readonly sharedKeyStrict: typeof x25519Api.sharedKeyStrict;
|
|
96
183
|
readonly generateKeyPair: typeof x25519Api.generateKeyPair;
|
|
97
184
|
readonly generateKeyPairX25519: typeof x25519Api.generateKeyPair;
|
|
98
185
|
readonly generateKeyPairEd25519: typeof ed25519Api.generateKeyPair;
|