@aptos-labs/ts-sdk 7.0.0 → 7.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/dist/account/AbstractKeylessAccount.d.ts.map +1 -1
- package/dist/account/AbstractKeylessAccount.js +3 -0
- package/dist/account/AbstractKeylessAccount.js.map +1 -1
- package/dist/account/EphemeralKeyPair.d.ts +29 -6
- package/dist/account/EphemeralKeyPair.d.ts.map +1 -1
- package/dist/account/EphemeralKeyPair.js +35 -8
- package/dist/account/EphemeralKeyPair.js.map +1 -1
- package/dist/bcs/deserializer.d.ts.map +1 -1
- package/dist/bcs/deserializer.js +15 -0
- package/dist/bcs/deserializer.js.map +1 -1
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +1 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/localNode.d.ts.map +1 -1
- package/dist/cli/localNode.js +6 -0
- package/dist/cli/localNode.js.map +1 -1
- package/dist/cli/move.d.ts.map +1 -1
- package/dist/cli/move.js +8 -0
- package/dist/cli/move.js.map +1 -1
- package/dist/cli/spawnArgs.d.ts +12 -0
- package/dist/cli/spawnArgs.d.ts.map +1 -0
- package/dist/cli/spawnArgs.js +51 -0
- package/dist/cli/spawnArgs.js.map +1 -0
- package/dist/core/crypto/ed25519.d.ts +117 -4
- package/dist/core/crypto/ed25519.d.ts.map +1 -1
- package/dist/core/crypto/ed25519.js +128 -14
- package/dist/core/crypto/ed25519.js.map +1 -1
- package/dist/core/crypto/keyless.d.ts +14 -0
- package/dist/core/crypto/keyless.d.ts.map +1 -1
- package/dist/core/crypto/keyless.js +22 -3
- package/dist/core/crypto/keyless.js.map +1 -1
- package/dist/core/crypto/poseidon.js +5 -5
- package/dist/core/crypto/poseidon.js.map +1 -1
- package/dist/core/crypto/secp256k1.d.ts +123 -5
- package/dist/core/crypto/secp256k1.d.ts.map +1 -1
- package/dist/core/crypto/secp256k1.js +137 -13
- package/dist/core/crypto/secp256k1.js.map +1 -1
- package/dist/core/crypto/secp256r1.d.ts +121 -1
- package/dist/core/crypto/secp256r1.d.ts.map +1 -1
- package/dist/core/crypto/secp256r1.js +156 -9
- package/dist/core/crypto/secp256r1.js.map +1 -1
- package/dist/core/crypto/utils.d.ts +28 -1
- package/dist/core/crypto/utils.d.ts.map +1 -1
- package/dist/core/crypto/utils.js +28 -1
- package/dist/core/crypto/utils.js.map +1 -1
- package/dist/errors/index.d.ts +19 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +35 -0
- package/dist/errors/index.js.map +1 -1
- package/dist/internal/account.d.ts +17 -0
- package/dist/internal/account.d.ts.map +1 -1
- package/dist/internal/account.js +66 -17
- package/dist/internal/account.js.map +1 -1
- package/dist/internal/keyless.d.ts.map +1 -1
- package/dist/internal/keyless.js +86 -2
- package/dist/internal/keyless.js.map +1 -1
- package/dist/internal/transaction.d.ts.map +1 -1
- package/dist/internal/transaction.js +20 -3
- package/dist/internal/transaction.js.map +1 -1
- package/dist/transactions/transactionBuilder/encryptPayload.d.ts.map +1 -1
- package/dist/transactions/transactionBuilder/encryptPayload.js +42 -41
- package/dist/transactions/transactionBuilder/encryptPayload.js.map +1 -1
- package/dist/transactions/types.d.ts +17 -13
- package/dist/transactions/types.d.ts.map +1 -1
- package/dist/utils/helpers.d.ts +16 -0
- package/dist/utils/helpers.d.ts.map +1 -1
- package/dist/utils/helpers.js +29 -0
- package/dist/utils/helpers.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -2
- package/src/account/AbstractKeylessAccount.ts +3 -0
- package/src/account/EphemeralKeyPair.ts +35 -8
- package/src/bcs/deserializer.ts +16 -0
- package/src/cli/index.ts +1 -0
- package/src/cli/localNode.ts +7 -0
- package/src/cli/move.ts +9 -0
- package/src/cli/spawnArgs.ts +55 -0
- package/src/core/crypto/ed25519.ts +132 -15
- package/src/core/crypto/keyless.ts +22 -3
- package/src/core/crypto/poseidon.ts +5 -5
- package/src/core/crypto/secp256k1.ts +141 -13
- package/src/core/crypto/secp256r1.ts +164 -11
- package/src/core/crypto/utils.ts +28 -1
- package/src/errors/index.ts +37 -0
- package/src/internal/account.ts +73 -17
- package/src/internal/keyless.ts +88 -2
- package/src/internal/transaction.ts +22 -3
- package/src/transactions/transactionBuilder/encryptPayload.ts +56 -49
- package/src/transactions/types.ts +17 -13
- package/src/utils/helpers.ts +33 -0
- package/src/version.ts +1 -1
|
@@ -53,9 +53,49 @@ export declare class Ed25519PublicKey extends AccountPublicKey {
|
|
|
53
53
|
* @category Serialization
|
|
54
54
|
*/
|
|
55
55
|
constructor(hexInput: HexInput);
|
|
56
|
+
/**
|
|
57
|
+
* Verifies a signature against the exact bytes of `message`. This is the
|
|
58
|
+
* unambiguous form — the input is interpreted as raw bytes regardless of
|
|
59
|
+
* what they encode. Pair with {@link Ed25519PrivateKey.signBytes}.
|
|
60
|
+
*
|
|
61
|
+
* Performs an Ed25519 malleability check (rejects non-canonical S values)
|
|
62
|
+
* before delegating to the underlying curve verifier.
|
|
63
|
+
*
|
|
64
|
+
* @param args - The arguments for verification.
|
|
65
|
+
* @param args.message - The exact bytes that were signed.
|
|
66
|
+
* @param args.signature - The signature to verify.
|
|
67
|
+
* @group Implementation
|
|
68
|
+
* @category Serialization
|
|
69
|
+
*/
|
|
70
|
+
verifyBytes(args: {
|
|
71
|
+
message: Uint8Array;
|
|
72
|
+
signature: Signature;
|
|
73
|
+
}): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Verifies a signature against the UTF-8 encoding of `message`. The input
|
|
76
|
+
* is always treated as text — there is no hex/text heuristic. Pair with
|
|
77
|
+
* {@link Ed25519PrivateKey.signText}.
|
|
78
|
+
*
|
|
79
|
+
* @param args - The arguments for verification.
|
|
80
|
+
* @param args.message - The text that was signed.
|
|
81
|
+
* @param args.signature - The signature to verify.
|
|
82
|
+
* @group Implementation
|
|
83
|
+
* @category Serialization
|
|
84
|
+
*/
|
|
85
|
+
verifyText(args: {
|
|
86
|
+
message: string;
|
|
87
|
+
signature: Signature;
|
|
88
|
+
}): boolean;
|
|
56
89
|
/**
|
|
57
90
|
* Verifies a signed message using a public key.
|
|
58
91
|
*
|
|
92
|
+
* @deprecated The polymorphic `message: HexInput` input is ambiguous — a
|
|
93
|
+
* bare even-length string of hex characters (e.g., `"cafe"`) is
|
|
94
|
+
* interpreted as the 2 bytes `[0xCA, 0xFE]`, not as 4 UTF-8 text bytes.
|
|
95
|
+
* Use {@link verifyBytes} for `Uint8Array` input or {@link verifyText}
|
|
96
|
+
* for `string` input; both are unambiguous. See
|
|
97
|
+
* {@link convertSigningMessage} for the full legacy rule.
|
|
98
|
+
*
|
|
59
99
|
* @param args - The arguments for verification.
|
|
60
100
|
* @param args.message - A signed message as a Hex string or Uint8Array.
|
|
61
101
|
* @param args.signature - The signature of the message.
|
|
@@ -217,11 +257,40 @@ export declare class Ed25519PrivateKey extends Serializable implements PrivateKe
|
|
|
217
257
|
*/
|
|
218
258
|
private ensureNotCleared;
|
|
219
259
|
/**
|
|
220
|
-
*
|
|
221
|
-
* After calling this method
|
|
260
|
+
* Overwrites the underlying private-key byte buffer with random bytes and
|
|
261
|
+
* then zeros. After calling this method the key can no longer sign or
|
|
262
|
+
* derive a public key.
|
|
263
|
+
*
|
|
264
|
+
* SECURITY: This is a best-effort window-narrowing tool, NOT a true
|
|
265
|
+
* zeroization guarantee. In JavaScript, four classes of copies cannot be
|
|
266
|
+
* reached from user code and so survive `clear()`:
|
|
267
|
+
*
|
|
268
|
+
* 1. **JS string copies.** Any value previously produced by `toString()`,
|
|
269
|
+
* `toHexString()`, or `bcsToHex().toString()` is an immutable string
|
|
270
|
+
* in the heap. The language provides no API to overwrite string
|
|
271
|
+
* memory; it is reclaimed only when GC collects it.
|
|
272
|
+
* 2. **noble-curves internals.** The sign path inside `@noble/curves`
|
|
273
|
+
* expands the private key into scalar `BigInt` field elements, which
|
|
274
|
+
* are also immutable in V8/JSC/Hermes. Even if noble explicitly zeroed
|
|
275
|
+
* its own byte copies after use, the `BigInt` intermediates persist.
|
|
276
|
+
* 3. **JIT register / stack residue.** The engine may have held key
|
|
277
|
+
* bytes in CPU registers or on the engine stack during a sign call.
|
|
278
|
+
* There is no JS-visible way to scrub those.
|
|
279
|
+
* 4. **GC-relocated copies.** Generational GCs (V8, JSC) copy live
|
|
280
|
+
* objects between heap regions during minor/major collections. The
|
|
281
|
+
* `Uint8Array` we zeroed may have stale copies sitting in survivor
|
|
282
|
+
* space until the next cycle reclaims them.
|
|
283
|
+
*
|
|
284
|
+
* This method zeros the SDK's own `Uint8Array` (the most reachable
|
|
285
|
+
* copy), but downstream consumers should treat it as a hardening signal,
|
|
286
|
+
* not a guarantee. If you need real key-material hygiene, prefer
|
|
287
|
+
* non-extractable `crypto.subtle` keys (where the underlying algorithm
|
|
288
|
+
* is supported by the host runtime), a WASM-backed crypto library, or
|
|
289
|
+
* hardware-backed keys (passkeys / secure enclave / HSM).
|
|
222
290
|
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
291
|
+
* To minimize the size of the unreachable-copy set, avoid calling
|
|
292
|
+
* `toString()` / `toHexString()` on private keys at all in long-lived
|
|
293
|
+
* processes — the byte form is what gets cleared.
|
|
225
294
|
*
|
|
226
295
|
* @group Implementation
|
|
227
296
|
* @category Serialization
|
|
@@ -244,10 +313,41 @@ export declare class Ed25519PrivateKey extends Serializable implements PrivateKe
|
|
|
244
313
|
* @category Serialization
|
|
245
314
|
*/
|
|
246
315
|
publicKey(): Ed25519PublicKey;
|
|
316
|
+
/**
|
|
317
|
+
* Sign exactly the bytes of `message`. The input is interpreted as raw
|
|
318
|
+
* bytes regardless of what they encode. Pair with
|
|
319
|
+
* {@link Ed25519PublicKey.verifyBytes}.
|
|
320
|
+
*
|
|
321
|
+
* @param message - The exact bytes to sign.
|
|
322
|
+
* @returns A digital signature for the provided bytes.
|
|
323
|
+
* @throws Error if the private key has been cleared from memory.
|
|
324
|
+
* @group Implementation
|
|
325
|
+
* @category Serialization
|
|
326
|
+
*/
|
|
327
|
+
signBytes(message: Uint8Array): Ed25519Signature;
|
|
328
|
+
/**
|
|
329
|
+
* Sign the UTF-8 encoding of `message`. The input is always treated as
|
|
330
|
+
* text — there is no hex/text heuristic. Pair with
|
|
331
|
+
* {@link Ed25519PublicKey.verifyText}.
|
|
332
|
+
*
|
|
333
|
+
* @param message - The text to sign.
|
|
334
|
+
* @returns A digital signature for the UTF-8 bytes of the provided text.
|
|
335
|
+
* @throws Error if the private key has been cleared from memory.
|
|
336
|
+
* @group Implementation
|
|
337
|
+
* @category Serialization
|
|
338
|
+
*/
|
|
339
|
+
signText(message: string): Ed25519Signature;
|
|
247
340
|
/**
|
|
248
341
|
* Sign the given message with the private key.
|
|
249
342
|
* This function generates a digital signature for the specified message, ensuring its authenticity and integrity.
|
|
250
343
|
*
|
|
344
|
+
* @deprecated The polymorphic `message: HexInput` input is ambiguous — a
|
|
345
|
+
* bare even-length string of hex characters (e.g., `"cafe"`) is signed
|
|
346
|
+
* as the 2 bytes `[0xCA, 0xFE]`, not as 4 UTF-8 text bytes. Use
|
|
347
|
+
* {@link signBytes} for `Uint8Array` input or {@link signText} for
|
|
348
|
+
* `string` input; both are unambiguous. See
|
|
349
|
+
* {@link convertSigningMessage} for the full legacy rule.
|
|
350
|
+
*
|
|
251
351
|
* @param message - A message as a string or Uint8Array in HexInput format.
|
|
252
352
|
* @returns A digital signature for the provided message.
|
|
253
353
|
* @throws Error if the private key has been cleared from memory.
|
|
@@ -267,6 +367,13 @@ export declare class Ed25519PrivateKey extends Serializable implements PrivateKe
|
|
|
267
367
|
/**
|
|
268
368
|
* Get the private key as a hex string with the 0x prefix.
|
|
269
369
|
*
|
|
370
|
+
* SECURITY: This produces an immutable JS string containing the key
|
|
371
|
+
* material in hex. Strings cannot be zeroed by `clear()` (see the
|
|
372
|
+
* `clear()` JSDoc for the four classes of unreachable copies). Avoid
|
|
373
|
+
* calling this method on long-lived `Ed25519PrivateKey` instances in
|
|
374
|
+
* processes where memory hygiene matters; prefer `toUint8Array()`,
|
|
375
|
+
* which returns a clearable `Uint8Array`.
|
|
376
|
+
*
|
|
270
377
|
* @returns string representation of the private key.
|
|
271
378
|
* @throws Error if the private key has been cleared from memory.
|
|
272
379
|
* @group Implementation
|
|
@@ -276,6 +383,9 @@ export declare class Ed25519PrivateKey extends Serializable implements PrivateKe
|
|
|
276
383
|
/**
|
|
277
384
|
* Get the private key as a hex string with the 0x prefix.
|
|
278
385
|
*
|
|
386
|
+
* SECURITY: Same caveat as `toString()` — the returned string is an
|
|
387
|
+
* immutable JS heap allocation that `clear()` cannot zero.
|
|
388
|
+
*
|
|
279
389
|
* @returns string representation of the private key.
|
|
280
390
|
* @throws Error if the private key has been cleared from memory.
|
|
281
391
|
*/
|
|
@@ -285,6 +395,9 @@ export declare class Ed25519PrivateKey extends Serializable implements PrivateKe
|
|
|
285
395
|
*
|
|
286
396
|
* [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)
|
|
287
397
|
*
|
|
398
|
+
* SECURITY: Same caveat as `toString()` — produces an immutable JS string
|
|
399
|
+
* containing the key material; cannot be zeroed by `clear()`.
|
|
400
|
+
*
|
|
288
401
|
* @returns AIP-80 compliant string representation of the private key.
|
|
289
402
|
* @throws Error if the private key has been cleared from memory.
|
|
290
403
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ed25519.d.ts","sourceRoot":"","sources":["../../../src/core/crypto/ed25519.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,QAAQ,EAAgE,MAAM,sBAAsB,CAAC;AAE9G,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7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ET, isValidHardenedPath, mnemonicToSee
|
|
|
9
9
|
import { PrivateKey } from "./privateKey.js";
|
|
10
10
|
import { AccountPublicKey } from "./publicKey.js";
|
|
11
11
|
import { Signature } from "./signature.js";
|
|
12
|
+
import { TEXT_ENCODER } from "../../utils/const.js";
|
|
12
13
|
import { convertSigningMessage } from "./utils.js";
|
|
13
14
|
/**
|
|
14
15
|
* L is the value that greater than or equal to will produce a non-canonical signature, and must be rejected
|
|
@@ -87,9 +88,51 @@ export class Ed25519PublicKey extends AccountPublicKey {
|
|
|
87
88
|
this.key = hex;
|
|
88
89
|
}
|
|
89
90
|
// region AccountPublicKey
|
|
91
|
+
/**
|
|
92
|
+
* Verifies a signature against the exact bytes of `message`. This is the
|
|
93
|
+
* unambiguous form — the input is interpreted as raw bytes regardless of
|
|
94
|
+
* what they encode. Pair with {@link Ed25519PrivateKey.signBytes}.
|
|
95
|
+
*
|
|
96
|
+
* Performs an Ed25519 malleability check (rejects non-canonical S values)
|
|
97
|
+
* before delegating to the underlying curve verifier.
|
|
98
|
+
*
|
|
99
|
+
* @param args - The arguments for verification.
|
|
100
|
+
* @param args.message - The exact bytes that were signed.
|
|
101
|
+
* @param args.signature - The signature to verify.
|
|
102
|
+
* @group Implementation
|
|
103
|
+
* @category Serialization
|
|
104
|
+
*/
|
|
105
|
+
verifyBytes(args) {
|
|
106
|
+
const { message, signature } = args;
|
|
107
|
+
if (!isCanonicalEd25519Signature(signature)) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
return ed25519.verify(signature.toUint8Array(), message, this.key.toUint8Array());
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Verifies a signature against the UTF-8 encoding of `message`. The input
|
|
114
|
+
* is always treated as text — there is no hex/text heuristic. Pair with
|
|
115
|
+
* {@link Ed25519PrivateKey.signText}.
|
|
116
|
+
*
|
|
117
|
+
* @param args - The arguments for verification.
|
|
118
|
+
* @param args.message - The text that was signed.
|
|
119
|
+
* @param args.signature - The signature to verify.
|
|
120
|
+
* @group Implementation
|
|
121
|
+
* @category Serialization
|
|
122
|
+
*/
|
|
123
|
+
verifyText(args) {
|
|
124
|
+
return this.verifyBytes({ message: TEXT_ENCODER.encode(args.message), signature: args.signature });
|
|
125
|
+
}
|
|
90
126
|
/**
|
|
91
127
|
* Verifies a signed message using a public key.
|
|
92
128
|
*
|
|
129
|
+
* @deprecated The polymorphic `message: HexInput` input is ambiguous — a
|
|
130
|
+
* bare even-length string of hex characters (e.g., `"cafe"`) is
|
|
131
|
+
* interpreted as the 2 bytes `[0xCA, 0xFE]`, not as 4 UTF-8 text bytes.
|
|
132
|
+
* Use {@link verifyBytes} for `Uint8Array` input or {@link verifyText}
|
|
133
|
+
* for `string` input; both are unambiguous. See
|
|
134
|
+
* {@link convertSigningMessage} for the full legacy rule.
|
|
135
|
+
*
|
|
93
136
|
* @param args - The arguments for verification.
|
|
94
137
|
* @param args.message - A signed message as a Hex string or Uint8Array.
|
|
95
138
|
* @param args.signature - The signature of the message.
|
|
@@ -98,15 +141,9 @@ export class Ed25519PublicKey extends AccountPublicKey {
|
|
|
98
141
|
*/
|
|
99
142
|
verifySignature(args) {
|
|
100
143
|
const { message, signature } = args;
|
|
101
|
-
// Verify malleability
|
|
102
|
-
if (!isCanonicalEd25519Signature(signature)) {
|
|
103
|
-
return false;
|
|
104
|
-
}
|
|
105
144
|
const messageToVerify = convertSigningMessage(message);
|
|
106
145
|
const messageBytes = Hex.fromHexInput(messageToVerify).toUint8Array();
|
|
107
|
-
|
|
108
|
-
const publicKeyBytes = this.key.toUint8Array();
|
|
109
|
-
return ed25519.verify(signatureBytes, messageBytes, publicKeyBytes);
|
|
146
|
+
return this.verifyBytes({ message: messageBytes, signature });
|
|
110
147
|
}
|
|
111
148
|
/**
|
|
112
149
|
* Note: Ed25519Signatures can be verified syncronously.
|
|
@@ -322,11 +359,40 @@ export class Ed25519PrivateKey extends Serializable {
|
|
|
322
359
|
}
|
|
323
360
|
}
|
|
324
361
|
/**
|
|
325
|
-
*
|
|
326
|
-
* After calling this method
|
|
362
|
+
* Overwrites the underlying private-key byte buffer with random bytes and
|
|
363
|
+
* then zeros. After calling this method the key can no longer sign or
|
|
364
|
+
* derive a public key.
|
|
365
|
+
*
|
|
366
|
+
* SECURITY: This is a best-effort window-narrowing tool, NOT a true
|
|
367
|
+
* zeroization guarantee. In JavaScript, four classes of copies cannot be
|
|
368
|
+
* reached from user code and so survive `clear()`:
|
|
327
369
|
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
370
|
+
* 1. **JS string copies.** Any value previously produced by `toString()`,
|
|
371
|
+
* `toHexString()`, or `bcsToHex().toString()` is an immutable string
|
|
372
|
+
* in the heap. The language provides no API to overwrite string
|
|
373
|
+
* memory; it is reclaimed only when GC collects it.
|
|
374
|
+
* 2. **noble-curves internals.** The sign path inside `@noble/curves`
|
|
375
|
+
* expands the private key into scalar `BigInt` field elements, which
|
|
376
|
+
* are also immutable in V8/JSC/Hermes. Even if noble explicitly zeroed
|
|
377
|
+
* its own byte copies after use, the `BigInt` intermediates persist.
|
|
378
|
+
* 3. **JIT register / stack residue.** The engine may have held key
|
|
379
|
+
* bytes in CPU registers or on the engine stack during a sign call.
|
|
380
|
+
* There is no JS-visible way to scrub those.
|
|
381
|
+
* 4. **GC-relocated copies.** Generational GCs (V8, JSC) copy live
|
|
382
|
+
* objects between heap regions during minor/major collections. The
|
|
383
|
+
* `Uint8Array` we zeroed may have stale copies sitting in survivor
|
|
384
|
+
* space until the next cycle reclaims them.
|
|
385
|
+
*
|
|
386
|
+
* This method zeros the SDK's own `Uint8Array` (the most reachable
|
|
387
|
+
* copy), but downstream consumers should treat it as a hardening signal,
|
|
388
|
+
* not a guarantee. If you need real key-material hygiene, prefer
|
|
389
|
+
* non-extractable `crypto.subtle` keys (where the underlying algorithm
|
|
390
|
+
* is supported by the host runtime), a WASM-backed crypto library, or
|
|
391
|
+
* hardware-backed keys (passkeys / secure enclave / HSM).
|
|
392
|
+
*
|
|
393
|
+
* To minimize the size of the unreachable-copy set, avoid calling
|
|
394
|
+
* `toString()` / `toHexString()` on private keys at all in long-lived
|
|
395
|
+
* processes — the byte form is what gets cleared.
|
|
330
396
|
*
|
|
331
397
|
* @group Implementation
|
|
332
398
|
* @category Serialization
|
|
@@ -369,10 +435,47 @@ export class Ed25519PrivateKey extends Serializable {
|
|
|
369
435
|
const bytes = ed25519.getPublicKey(this.signingKey.toUint8Array());
|
|
370
436
|
return new Ed25519PublicKey(bytes);
|
|
371
437
|
}
|
|
438
|
+
/**
|
|
439
|
+
* Sign exactly the bytes of `message`. The input is interpreted as raw
|
|
440
|
+
* bytes regardless of what they encode. Pair with
|
|
441
|
+
* {@link Ed25519PublicKey.verifyBytes}.
|
|
442
|
+
*
|
|
443
|
+
* @param message - The exact bytes to sign.
|
|
444
|
+
* @returns A digital signature for the provided bytes.
|
|
445
|
+
* @throws Error if the private key has been cleared from memory.
|
|
446
|
+
* @group Implementation
|
|
447
|
+
* @category Serialization
|
|
448
|
+
*/
|
|
449
|
+
signBytes(message) {
|
|
450
|
+
this.ensureNotCleared();
|
|
451
|
+
const signatureBytes = ed25519.sign(message, this.signingKey.toUint8Array());
|
|
452
|
+
return new Ed25519Signature(signatureBytes);
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Sign the UTF-8 encoding of `message`. The input is always treated as
|
|
456
|
+
* text — there is no hex/text heuristic. Pair with
|
|
457
|
+
* {@link Ed25519PublicKey.verifyText}.
|
|
458
|
+
*
|
|
459
|
+
* @param message - The text to sign.
|
|
460
|
+
* @returns A digital signature for the UTF-8 bytes of the provided text.
|
|
461
|
+
* @throws Error if the private key has been cleared from memory.
|
|
462
|
+
* @group Implementation
|
|
463
|
+
* @category Serialization
|
|
464
|
+
*/
|
|
465
|
+
signText(message) {
|
|
466
|
+
return this.signBytes(TEXT_ENCODER.encode(message));
|
|
467
|
+
}
|
|
372
468
|
/**
|
|
373
469
|
* Sign the given message with the private key.
|
|
374
470
|
* This function generates a digital signature for the specified message, ensuring its authenticity and integrity.
|
|
375
471
|
*
|
|
472
|
+
* @deprecated The polymorphic `message: HexInput` input is ambiguous — a
|
|
473
|
+
* bare even-length string of hex characters (e.g., `"cafe"`) is signed
|
|
474
|
+
* as the 2 bytes `[0xCA, 0xFE]`, not as 4 UTF-8 text bytes. Use
|
|
475
|
+
* {@link signBytes} for `Uint8Array` input or {@link signText} for
|
|
476
|
+
* `string` input; both are unambiguous. See
|
|
477
|
+
* {@link convertSigningMessage} for the full legacy rule.
|
|
478
|
+
*
|
|
376
479
|
* @param message - A message as a string or Uint8Array in HexInput format.
|
|
377
480
|
* @returns A digital signature for the provided message.
|
|
378
481
|
* @throws Error if the private key has been cleared from memory.
|
|
@@ -380,11 +483,9 @@ export class Ed25519PrivateKey extends Serializable {
|
|
|
380
483
|
* @category Serialization
|
|
381
484
|
*/
|
|
382
485
|
sign(message) {
|
|
383
|
-
this.ensureNotCleared();
|
|
384
486
|
const messageToSign = convertSigningMessage(message);
|
|
385
487
|
const messageBytes = Hex.fromHexInput(messageToSign).toUint8Array();
|
|
386
|
-
|
|
387
|
-
return new Ed25519Signature(signatureBytes);
|
|
488
|
+
return this.signBytes(messageBytes);
|
|
388
489
|
}
|
|
389
490
|
/**
|
|
390
491
|
* Get the private key in bytes (Uint8Array).
|
|
@@ -401,6 +502,13 @@ export class Ed25519PrivateKey extends Serializable {
|
|
|
401
502
|
/**
|
|
402
503
|
* Get the private key as a hex string with the 0x prefix.
|
|
403
504
|
*
|
|
505
|
+
* SECURITY: This produces an immutable JS string containing the key
|
|
506
|
+
* material in hex. Strings cannot be zeroed by `clear()` (see the
|
|
507
|
+
* `clear()` JSDoc for the four classes of unreachable copies). Avoid
|
|
508
|
+
* calling this method on long-lived `Ed25519PrivateKey` instances in
|
|
509
|
+
* processes where memory hygiene matters; prefer `toUint8Array()`,
|
|
510
|
+
* which returns a clearable `Uint8Array`.
|
|
511
|
+
*
|
|
404
512
|
* @returns string representation of the private key.
|
|
405
513
|
* @throws Error if the private key has been cleared from memory.
|
|
406
514
|
* @group Implementation
|
|
@@ -413,6 +521,9 @@ export class Ed25519PrivateKey extends Serializable {
|
|
|
413
521
|
/**
|
|
414
522
|
* Get the private key as a hex string with the 0x prefix.
|
|
415
523
|
*
|
|
524
|
+
* SECURITY: Same caveat as `toString()` — the returned string is an
|
|
525
|
+
* immutable JS heap allocation that `clear()` cannot zero.
|
|
526
|
+
*
|
|
416
527
|
* @returns string representation of the private key.
|
|
417
528
|
* @throws Error if the private key has been cleared from memory.
|
|
418
529
|
*/
|
|
@@ -425,6 +536,9 @@ export class Ed25519PrivateKey extends Serializable {
|
|
|
425
536
|
*
|
|
426
537
|
* [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)
|
|
427
538
|
*
|
|
539
|
+
* SECURITY: Same caveat as `toString()` — produces an immutable JS string
|
|
540
|
+
* containing the key material; cannot be zeroed by `clear()`.
|
|
541
|
+
*
|
|
428
542
|
* @returns AIP-80 compliant string representation of the private key.
|
|
429
543
|
* @throws Error if the private key has been cleared from memory.
|
|
430
544
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ed25519.js","sourceRoot":"","sources":["../../../src/core/crypto/ed25519.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,sCAAsC;AAEtC,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAc,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAY,aAAa,IAAI,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC9G,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,mBAAmB,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACjH,OAAO,EAAE,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AAC,MAAM,EAAE,CAAC;YAC3D,MAAM,IAAI,KAAK,CAAC,8BAA8B,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAAC;QAC3E,CAAC;QACD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,YAAY;IAEZ,mBAAmB;IAEnB,YAAY;QACV,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;IAClC,CAAC;IAED,YAAY;IAEZ,sBAAsB;IAEtB,SAAS,CAAC,UAAsB;QAC9B,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;IACtD,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,YAA0B;QAC3C,MAAM,KAAK,GAAG,YAAY,CAAC,gBAAgB,EAAE,CAAC;QAC9C,OAAO,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC"}
|
|
@@ -207,6 +207,14 @@ export declare class KeylessPublicKey extends AccountPublicKey {
|
|
|
207
207
|
* Creates a KeylessPublicKey instance from a JWT and a pepper value.
|
|
208
208
|
* This function is useful for generating a public key that can be used for authentication based on the provided JWT claims and pepper.
|
|
209
209
|
*
|
|
210
|
+
* SECURITY: `jwtDecode` is a decode-only library — it does NOT verify the
|
|
211
|
+
* JWT signature. The cryptographic binding between the JWT and the user's
|
|
212
|
+
* identity is enforced on-chain by the keyless verifier (which validates
|
|
213
|
+
* the JWT signature against the JWK set published on-chain). Callers MUST
|
|
214
|
+
* therefore obtain `jwt` directly from a trusted IdP redirect/OAuth flow;
|
|
215
|
+
* do not accept arbitrary user-supplied JWT strings here, since a tampered
|
|
216
|
+
* JWT will derive a different account address than the chain expects.
|
|
217
|
+
*
|
|
210
218
|
* @param args - The arguments for creating the KeylessPublicKey.
|
|
211
219
|
* @param args.jwt - The JSON Web Token to decode.
|
|
212
220
|
* @param args.pepper - The pepper value used in the key creation process.
|
|
@@ -728,6 +736,12 @@ export declare function getKeylessConfig(args: {
|
|
|
728
736
|
/**
|
|
729
737
|
* Parses a JWT and returns the 'iss', 'aud', and 'uid' values.
|
|
730
738
|
*
|
|
739
|
+
* SECURITY: This function decodes claims without verifying the JWT signature.
|
|
740
|
+
* The keyless on-chain verifier is the authority that binds a JWT to its IdP;
|
|
741
|
+
* the SDK only uses these claims to derive the keyless account address and
|
|
742
|
+
* package the JWT for the prover service. Callers must source `jwt` from a
|
|
743
|
+
* trusted IdP redirect flow.
|
|
744
|
+
*
|
|
731
745
|
* @param args - The arguments for parsing the JWT.
|
|
732
746
|
* @param args.jwt - The JWT to parse.
|
|
733
747
|
* @param args.uidKey - The key to use for the 'uid' value; defaults to 'sub'.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyless.d.ts","sourceRoot":"","sources":["../../../src/core/crypto/keyless.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAE5E,OAAO,EACL,QAAQ,EACR,2BAA2B,EAG3B,UAAU,EACV,gBAAgB,EAEjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAExE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EACL,8BAA8B,EAC9B,4BAA4B,EAC5B,aAAa,EAEd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"keyless.d.ts","sourceRoot":"","sources":["../../../src/core/crypto/keyless.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAA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AC,IAAI,EAAE;IACzC,WAAW,EAAE,WAAW,CAAC;IACzB,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,CAkBlC;AAgDD,qBAAa,OAAQ,SAAQ,YAAY;IAChC,GAAG,EAAE,MAAM,CAAC;IAEZ,GAAG,EAAE,MAAM,CAAC;IAEZ,GAAG,EAAE,MAAM,CAAC;IAEZ,CAAC,EAAE,MAAM,CAAC;IAEV,CAAC,EAAE,MAAM,CAAC;gBAEL,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE;IAUjF,SAAS,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI;IAQvC,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO;IAMrD,QAAQ,IAAI,MAAM;IAelB,MAAM,CAAC,WAAW,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO;CAQxD;AAkBD,UAAU,SAAS;IACjB,GAAG,EAAE,MAAM,CAAC;CACb;AACD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAqB3D"}
|
|
@@ -12,6 +12,7 @@ import { bigIntToBytesLE, bytesToBigIntLE, hashStrToField, padAndPackBytesWithLe
|
|
|
12
12
|
import { AuthenticationKey } from "../authenticationKey.js";
|
|
13
13
|
import { Proof } from "./proof.js";
|
|
14
14
|
import { Ed25519PublicKey, Ed25519Signature } from "./ed25519.js";
|
|
15
|
+
import { u64ToNumberSafe } from "../../utils/helpers.js";
|
|
15
16
|
import { getAptosFullNode } from "../../client/index.js";
|
|
16
17
|
import { memoizeAsync } from "../../utils/memoize.js";
|
|
17
18
|
import { AccountAddress } from "../accountAddress.js";
|
|
@@ -248,6 +249,14 @@ export class KeylessPublicKey extends AccountPublicKey {
|
|
|
248
249
|
* Creates a KeylessPublicKey instance from a JWT and a pepper value.
|
|
249
250
|
* This function is useful for generating a public key that can be used for authentication based on the provided JWT claims and pepper.
|
|
250
251
|
*
|
|
252
|
+
* SECURITY: `jwtDecode` is a decode-only library — it does NOT verify the
|
|
253
|
+
* JWT signature. The cryptographic binding between the JWT and the user's
|
|
254
|
+
* identity is enforced on-chain by the keyless verifier (which validates
|
|
255
|
+
* the JWT signature against the JWK set published on-chain). Callers MUST
|
|
256
|
+
* therefore obtain `jwt` directly from a trusted IdP redirect/OAuth flow;
|
|
257
|
+
* do not accept arbitrary user-supplied JWT strings here, since a tampered
|
|
258
|
+
* JWT will derive a different account address than the chain expects.
|
|
259
|
+
*
|
|
251
260
|
* @param args - The arguments for creating the KeylessPublicKey.
|
|
252
261
|
* @param args.jwt - The JSON Web Token to decode.
|
|
253
262
|
* @param args.pepper - The pepper value used in the key creation process.
|
|
@@ -258,6 +267,7 @@ export class KeylessPublicKey extends AccountPublicKey {
|
|
|
258
267
|
*/
|
|
259
268
|
static fromJwtAndPepper(args) {
|
|
260
269
|
const { jwt, pepper, uidKey = "sub" } = args;
|
|
270
|
+
// SECURITY: signature is not verified here — see method-level JSDoc.
|
|
261
271
|
const jwtPayload = jwtDecode(jwt);
|
|
262
272
|
if (typeof jwtPayload.iss !== "string") {
|
|
263
273
|
throw new Error("iss was not found");
|
|
@@ -543,7 +553,7 @@ export class KeylessSignature extends Signature {
|
|
|
543
553
|
const ephemeralSignature = EphemeralSignature.deserialize(deserializer);
|
|
544
554
|
return new KeylessSignature({
|
|
545
555
|
jwtHeader,
|
|
546
|
-
expiryDateSecs:
|
|
556
|
+
expiryDateSecs: u64ToNumberSafe(expiryDateSecs, "KeylessSignature.expiryDateSecs"),
|
|
547
557
|
ephemeralCertificate,
|
|
548
558
|
ephemeralPublicKey,
|
|
549
559
|
ephemeralSignature,
|
|
@@ -944,7 +954,7 @@ export class ZeroKnowledgeSig extends Signature {
|
|
|
944
954
|
}
|
|
945
955
|
static deserialize(deserializer) {
|
|
946
956
|
const proof = ZkProof.deserialize(deserializer);
|
|
947
|
-
const expHorizonSecs =
|
|
957
|
+
const expHorizonSecs = u64ToNumberSafe(deserializer.deserializeU64(), "ZeroKnowledgeSig.expHorizonSecs");
|
|
948
958
|
const extraField = deserializer.deserializeOption("string");
|
|
949
959
|
const overrideAudVal = deserializer.deserializeOption("string");
|
|
950
960
|
const trainingWheelsSignature = deserializer.deserializeOption(EphemeralSignature);
|
|
@@ -1030,7 +1040,9 @@ export class KeylessConfiguration {
|
|
|
1030
1040
|
gammaAbcG1: res.gamma_abc_g1,
|
|
1031
1041
|
gammaG2: res.gamma_g2,
|
|
1032
1042
|
}),
|
|
1033
|
-
|
|
1043
|
+
// Chain config returns u64 as a decimal string; widen → safe-narrow so
|
|
1044
|
+
// a malformed/exotic value throws rather than silently truncates.
|
|
1045
|
+
maxExpHorizonSecs: u64ToNumberSafe(BigInt(config.max_exp_horizon_secs), "KeylessConfiguration.maxExpHorizonSecs"),
|
|
1034
1046
|
trainingWheelsPubkey: config.training_wheels_pubkey.vec[0],
|
|
1035
1047
|
maxExtraFieldBytes: config.max_extra_field_bytes,
|
|
1036
1048
|
maxJwtHeaderB64Bytes: config.max_jwt_header_b64_bytes,
|
|
@@ -1229,6 +1241,12 @@ export async function getKeylessConfig(args) {
|
|
|
1229
1241
|
/**
|
|
1230
1242
|
* Parses a JWT and returns the 'iss', 'aud', and 'uid' values.
|
|
1231
1243
|
*
|
|
1244
|
+
* SECURITY: This function decodes claims without verifying the JWT signature.
|
|
1245
|
+
* The keyless on-chain verifier is the authority that binds a JWT to its IdP;
|
|
1246
|
+
* the SDK only uses these claims to derive the keyless account address and
|
|
1247
|
+
* package the JWT for the prover service. Callers must source `jwt` from a
|
|
1248
|
+
* trusted IdP redirect flow.
|
|
1249
|
+
*
|
|
1232
1250
|
* @param args - The arguments for parsing the JWT.
|
|
1233
1251
|
* @param args.jwt - The JWT to parse.
|
|
1234
1252
|
* @param args.uidKey - The key to use for the 'uid' value; defaults to 'sub'.
|
|
@@ -1238,6 +1256,7 @@ export function getIssAudAndUidVal(args) {
|
|
|
1238
1256
|
const { jwt, uidKey = "sub" } = args;
|
|
1239
1257
|
let jwtPayload;
|
|
1240
1258
|
try {
|
|
1259
|
+
// SECURITY: signature is not verified here — see function-level JSDoc.
|
|
1241
1260
|
jwtPayload = jwtDecode(jwt);
|
|
1242
1261
|
}
|
|
1243
1262
|
catch {
|