@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secp256k1.js","sourceRoot":"","sources":["../../../src/core/crypto/secp256k1.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,sCAAsC;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,YAAY,EAA4B,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAY,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"secp256k1.js","sourceRoot":"","sources":["../../../src/core/crypto/secp256k1.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,sCAAsC;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4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CAClG,CAAC;QACJ,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,GAAG,GAAG,YAAY,CAAC,gBAAgB,EAAE,CAAC;QAC5C,OAAO,IAAI,kBAAkB,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC"}
|
|
@@ -53,10 +53,49 @@ export declare class Secp256r1PublicKey extends PublicKey {
|
|
|
53
53
|
* @category Serialization
|
|
54
54
|
*/
|
|
55
55
|
bcsToBytes(): Uint8Array<ArrayBufferLike>;
|
|
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 Secp256r1PrivateKey.signBytes}.
|
|
60
|
+
*
|
|
61
|
+
* The message is SHA3-256 hashed before verification (matching the
|
|
62
|
+
* Aptos-side Secp256r1 signing convention), and the signature is required
|
|
63
|
+
* to be in canonical low-S form for malleability resistance.
|
|
64
|
+
*
|
|
65
|
+
* @param args - The arguments for verification.
|
|
66
|
+
* @param args.message - The exact bytes that were signed.
|
|
67
|
+
* @param args.signature - The signature to verify.
|
|
68
|
+
* @group Implementation
|
|
69
|
+
* @category Serialization
|
|
70
|
+
*/
|
|
71
|
+
verifyBytes(args: {
|
|
72
|
+
message: Uint8Array;
|
|
73
|
+
signature: Signature;
|
|
74
|
+
}): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Verifies a signature against the UTF-8 encoding of `message`. The input
|
|
77
|
+
* is always treated as text — there is no hex/text heuristic. Pair with
|
|
78
|
+
* {@link Secp256r1PrivateKey.signText}.
|
|
79
|
+
*
|
|
80
|
+
* @param args - The arguments for verification.
|
|
81
|
+
* @param args.message - The text that was signed.
|
|
82
|
+
* @param args.signature - The signature to verify.
|
|
83
|
+
* @group Implementation
|
|
84
|
+
* @category Serialization
|
|
85
|
+
*/
|
|
86
|
+
verifyText(args: {
|
|
87
|
+
message: string;
|
|
88
|
+
signature: Signature;
|
|
89
|
+
}): boolean;
|
|
56
90
|
/**
|
|
57
91
|
* Verifies a Secp256r1 signature against the public key.
|
|
58
92
|
*
|
|
59
|
-
*
|
|
93
|
+
* @deprecated The polymorphic `message: HexInput` input is ambiguous — a
|
|
94
|
+
* bare even-length string of hex characters (e.g., `"cafe"`) is verified
|
|
95
|
+
* against the 2 bytes `[0xCA, 0xFE]`, not 4 UTF-8 text bytes. Use
|
|
96
|
+
* {@link verifyBytes} for `Uint8Array` input or {@link verifyText} for
|
|
97
|
+
* `string` input; both are unambiguous. See
|
|
98
|
+
* {@link convertSigningMessage} for the full legacy rule.
|
|
60
99
|
*
|
|
61
100
|
* @param args - The arguments for verifying the signature.
|
|
62
101
|
* @param args.message - The message that was signed.
|
|
@@ -148,6 +187,11 @@ export declare class Secp256r1PrivateKey extends PrivateKey {
|
|
|
148
187
|
* @category Serialization
|
|
149
188
|
*/
|
|
150
189
|
private readonly key;
|
|
190
|
+
/**
|
|
191
|
+
* Whether the key has been cleared from memory.
|
|
192
|
+
* @private
|
|
193
|
+
*/
|
|
194
|
+
private cleared;
|
|
151
195
|
/**
|
|
152
196
|
* Create a new PrivateKey instance from a Uint8Array or String.
|
|
153
197
|
*
|
|
@@ -163,6 +207,7 @@ export declare class Secp256r1PrivateKey extends PrivateKey {
|
|
|
163
207
|
* Get the private key in bytes (Uint8Array).
|
|
164
208
|
*
|
|
165
209
|
* @returns
|
|
210
|
+
* @throws Error if the private key has been cleared from memory.
|
|
166
211
|
* @group Implementation
|
|
167
212
|
* @category Serialization
|
|
168
213
|
*/
|
|
@@ -170,7 +215,15 @@ export declare class Secp256r1PrivateKey extends PrivateKey {
|
|
|
170
215
|
/**
|
|
171
216
|
* Get the private key as a string representation.
|
|
172
217
|
*
|
|
218
|
+
* SECURITY: This produces an immutable JS string containing the key
|
|
219
|
+
* material. Strings cannot be zeroed by `clear()` (see the `clear()`
|
|
220
|
+
* JSDoc for the four classes of unreachable copies). Avoid calling this
|
|
221
|
+
* method on long-lived `Secp256r1PrivateKey` instances in processes
|
|
222
|
+
* where memory hygiene matters; prefer `toUint8Array()`, which returns
|
|
223
|
+
* a clearable `Uint8Array`.
|
|
224
|
+
*
|
|
173
225
|
* @returns string representation of the private key
|
|
226
|
+
* @throws Error if the private key has been cleared from memory.
|
|
174
227
|
* @group Implementation
|
|
175
228
|
* @category Serialization
|
|
176
229
|
*/
|
|
@@ -178,15 +231,54 @@ export declare class Secp256r1PrivateKey extends PrivateKey {
|
|
|
178
231
|
/**
|
|
179
232
|
* Get the private key as a hex string with the 0x prefix.
|
|
180
233
|
*
|
|
234
|
+
* SECURITY: Same caveat as `toString()` — produces an immutable JS string
|
|
235
|
+
* containing the key material; cannot be zeroed by `clear()`.
|
|
236
|
+
*
|
|
181
237
|
* @returns string representation of the private key.
|
|
238
|
+
* @throws Error if the private key has been cleared from memory.
|
|
182
239
|
*/
|
|
183
240
|
toHexString(): string;
|
|
241
|
+
/**
|
|
242
|
+
* Sign exactly the bytes of `message`. The input is interpreted as raw
|
|
243
|
+
* bytes regardless of what they encode. Pair with
|
|
244
|
+
* {@link Secp256r1PublicKey.verifyBytes}.
|
|
245
|
+
*
|
|
246
|
+
* The message is SHA3-256 hashed before signing (matching the Aptos-side
|
|
247
|
+
* Secp256r1 signing convention).
|
|
248
|
+
*
|
|
249
|
+
* @param message - The exact bytes to sign.
|
|
250
|
+
* @returns The generated signature for the provided bytes.
|
|
251
|
+
* @throws Error if the private key has been cleared from memory.
|
|
252
|
+
* @group Implementation
|
|
253
|
+
* @category Serialization
|
|
254
|
+
*/
|
|
255
|
+
signBytes(message: Uint8Array): Secp256r1Signature;
|
|
256
|
+
/**
|
|
257
|
+
* Sign the UTF-8 encoding of `message`. The input is always treated as
|
|
258
|
+
* text — there is no hex/text heuristic. Pair with
|
|
259
|
+
* {@link Secp256r1PublicKey.verifyText}.
|
|
260
|
+
*
|
|
261
|
+
* @param message - The text to sign.
|
|
262
|
+
* @returns The generated signature for the UTF-8 bytes of the provided text.
|
|
263
|
+
* @throws Error if the private key has been cleared from memory.
|
|
264
|
+
* @group Implementation
|
|
265
|
+
* @category Serialization
|
|
266
|
+
*/
|
|
267
|
+
signText(message: string): Secp256r1Signature;
|
|
184
268
|
/**
|
|
185
269
|
* Sign the given message with the private key.
|
|
186
270
|
* This function generates a cryptographic signature for the provided message.
|
|
187
271
|
*
|
|
272
|
+
* @deprecated The polymorphic `message: HexInput` input is ambiguous — a
|
|
273
|
+
* bare even-length string of hex characters (e.g., `"cafe"`) is signed
|
|
274
|
+
* as the 2 bytes `[0xCA, 0xFE]`, not 4 UTF-8 text bytes. Use
|
|
275
|
+
* {@link signBytes} for `Uint8Array` input or {@link signText} for
|
|
276
|
+
* `string` input; both are unambiguous. See
|
|
277
|
+
* {@link convertSigningMessage} for the full legacy rule.
|
|
278
|
+
*
|
|
188
279
|
* @param message - A message in HexInput format to be signed.
|
|
189
280
|
* @returns Signature - The generated signature for the provided message.
|
|
281
|
+
* @throws Error if the private key has been cleared from memory.
|
|
190
282
|
* @group Implementation
|
|
191
283
|
* @category Serialization
|
|
192
284
|
*/
|
|
@@ -221,10 +313,38 @@ export declare class Secp256r1PrivateKey extends PrivateKey {
|
|
|
221
313
|
* Derive the Secp256r1PublicKey from this private key.
|
|
222
314
|
*
|
|
223
315
|
* @returns Secp256r1PublicKey The derived public key.
|
|
316
|
+
* @throws Error if the private key has been cleared from memory.
|
|
224
317
|
* @group Implementation
|
|
225
318
|
* @category Serialization
|
|
226
319
|
*/
|
|
227
320
|
publicKey(): Secp256r1PublicKey;
|
|
321
|
+
/**
|
|
322
|
+
* Throws if the key has already been cleared.
|
|
323
|
+
* @private
|
|
324
|
+
*/
|
|
325
|
+
private ensureNotCleared;
|
|
326
|
+
/**
|
|
327
|
+
* Overwrites the underlying private-key byte buffer with random bytes and
|
|
328
|
+
* then zeros. After calling this method the key can no longer sign or
|
|
329
|
+
* derive a public key.
|
|
330
|
+
*
|
|
331
|
+
* SECURITY: This is a best-effort window-narrowing tool, NOT a true
|
|
332
|
+
* zeroization guarantee. See `Ed25519PrivateKey.clear()` for the full
|
|
333
|
+
* enumeration of JavaScript-level limits (immutable string copies, noble
|
|
334
|
+
* `BigInt` intermediates, JIT register/stack residue, GC-relocated
|
|
335
|
+
* copies). For Secp256r1 specifically, non-extractable `crypto.subtle`
|
|
336
|
+
* P-256 keys are universally supported across modern runtimes and are
|
|
337
|
+
* the architecturally-correct path for callers who need real memory
|
|
338
|
+
* hygiene; consider that alternative for new code.
|
|
339
|
+
*
|
|
340
|
+
* @group Implementation
|
|
341
|
+
* @category Serialization
|
|
342
|
+
*/
|
|
343
|
+
clear(): void;
|
|
344
|
+
/**
|
|
345
|
+
* Returns whether `clear()` has been called.
|
|
346
|
+
*/
|
|
347
|
+
isCleared(): boolean;
|
|
228
348
|
}
|
|
229
349
|
export declare class WebAuthnSignature extends Signature {
|
|
230
350
|
signature: Hex;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secp256r1.d.ts","sourceRoot":"","sources":["../../../src/core/crypto/secp256r1.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EACL,QAAQ,EAIT,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,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;;;;;;OAOG;IACH,MAAM,CAAC,WAAW,CAAC,YAAY,EAAE,YAAY,GAAG,kBAAkB;CAInE"}
|
|
@@ -9,6 +9,8 @@ import { PublicKey } from "./publicKey.js";
|
|
|
9
9
|
import { PrivateKey } from "./privateKey.js";
|
|
10
10
|
import { Signature } from "./signature.js";
|
|
11
11
|
import { AuthenticationKey } from "../authenticationKey.js";
|
|
12
|
+
import { convertSigningMessage } from "./utils.js";
|
|
13
|
+
import { TEXT_ENCODER } from "../../utils/const.js";
|
|
12
14
|
/**
|
|
13
15
|
* Represents a Secp256r1 ECDSA public key.
|
|
14
16
|
*
|
|
@@ -83,10 +85,49 @@ export class Secp256r1PublicKey extends PublicKey {
|
|
|
83
85
|
this.serialize(serializer);
|
|
84
86
|
return serializer.toUint8Array();
|
|
85
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Verifies a signature against the exact bytes of `message`. This is the
|
|
90
|
+
* unambiguous form — the input is interpreted as raw bytes regardless of
|
|
91
|
+
* what they encode. Pair with {@link Secp256r1PrivateKey.signBytes}.
|
|
92
|
+
*
|
|
93
|
+
* The message is SHA3-256 hashed before verification (matching the
|
|
94
|
+
* Aptos-side Secp256r1 signing convention), and the signature is required
|
|
95
|
+
* to be in canonical low-S form for malleability resistance.
|
|
96
|
+
*
|
|
97
|
+
* @param args - The arguments for verification.
|
|
98
|
+
* @param args.message - The exact bytes that were signed.
|
|
99
|
+
* @param args.signature - The signature to verify.
|
|
100
|
+
* @group Implementation
|
|
101
|
+
* @category Serialization
|
|
102
|
+
*/
|
|
103
|
+
verifyBytes(args) {
|
|
104
|
+
const { message, signature } = args;
|
|
105
|
+
const sha3Message = sha3_256(message);
|
|
106
|
+
return p256.verify(signature.toUint8Array(), sha3Message, this.toUint8Array(), { prehash: false, lowS: true });
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Verifies a signature against the UTF-8 encoding of `message`. The input
|
|
110
|
+
* is always treated as text — there is no hex/text heuristic. Pair with
|
|
111
|
+
* {@link Secp256r1PrivateKey.signText}.
|
|
112
|
+
*
|
|
113
|
+
* @param args - The arguments for verification.
|
|
114
|
+
* @param args.message - The text that was signed.
|
|
115
|
+
* @param args.signature - The signature to verify.
|
|
116
|
+
* @group Implementation
|
|
117
|
+
* @category Serialization
|
|
118
|
+
*/
|
|
119
|
+
verifyText(args) {
|
|
120
|
+
return this.verifyBytes({ message: TEXT_ENCODER.encode(args.message), signature: args.signature });
|
|
121
|
+
}
|
|
86
122
|
/**
|
|
87
123
|
* Verifies a Secp256r1 signature against the public key.
|
|
88
124
|
*
|
|
89
|
-
*
|
|
125
|
+
* @deprecated The polymorphic `message: HexInput` input is ambiguous — a
|
|
126
|
+
* bare even-length string of hex characters (e.g., `"cafe"`) is verified
|
|
127
|
+
* against the 2 bytes `[0xCA, 0xFE]`, not 4 UTF-8 text bytes. Use
|
|
128
|
+
* {@link verifyBytes} for `Uint8Array` input or {@link verifyText} for
|
|
129
|
+
* `string` input; both are unambiguous. See
|
|
130
|
+
* {@link convertSigningMessage} for the full legacy rule.
|
|
90
131
|
*
|
|
91
132
|
* @param args - The arguments for verifying the signature.
|
|
92
133
|
* @param args.message - The message that was signed.
|
|
@@ -96,10 +137,9 @@ export class Secp256r1PublicKey extends PublicKey {
|
|
|
96
137
|
*/
|
|
97
138
|
verifySignature(args) {
|
|
98
139
|
const { message, signature } = args;
|
|
99
|
-
const
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
return p256.verify(rawSignature, sha3Message, this.toUint8Array(), { prehash: false });
|
|
140
|
+
const messageToVerify = convertSigningMessage(message);
|
|
141
|
+
const msgBytes = Hex.fromHexInput(messageToVerify).toUint8Array();
|
|
142
|
+
return this.verifyBytes({ message: msgBytes, signature });
|
|
103
143
|
}
|
|
104
144
|
/**
|
|
105
145
|
* Note: Secp256r1Signatures can be verified synchronously.
|
|
@@ -211,6 +251,11 @@ export class Secp256r1PrivateKey extends PrivateKey {
|
|
|
211
251
|
* @category Serialization
|
|
212
252
|
*/
|
|
213
253
|
key;
|
|
254
|
+
/**
|
|
255
|
+
* Whether the key has been cleared from memory.
|
|
256
|
+
* @private
|
|
257
|
+
*/
|
|
258
|
+
cleared = false;
|
|
214
259
|
/**
|
|
215
260
|
* Create a new PrivateKey instance from a Uint8Array or String.
|
|
216
261
|
*
|
|
@@ -234,44 +279,101 @@ export class Secp256r1PrivateKey extends PrivateKey {
|
|
|
234
279
|
* Get the private key in bytes (Uint8Array).
|
|
235
280
|
*
|
|
236
281
|
* @returns
|
|
282
|
+
* @throws Error if the private key has been cleared from memory.
|
|
237
283
|
* @group Implementation
|
|
238
284
|
* @category Serialization
|
|
239
285
|
*/
|
|
240
286
|
toUint8Array() {
|
|
287
|
+
this.ensureNotCleared();
|
|
241
288
|
return this.key.toUint8Array();
|
|
242
289
|
}
|
|
243
290
|
/**
|
|
244
291
|
* Get the private key as a string representation.
|
|
245
292
|
*
|
|
293
|
+
* SECURITY: This produces an immutable JS string containing the key
|
|
294
|
+
* material. Strings cannot be zeroed by `clear()` (see the `clear()`
|
|
295
|
+
* JSDoc for the four classes of unreachable copies). Avoid calling this
|
|
296
|
+
* method on long-lived `Secp256r1PrivateKey` instances in processes
|
|
297
|
+
* where memory hygiene matters; prefer `toUint8Array()`, which returns
|
|
298
|
+
* a clearable `Uint8Array`.
|
|
299
|
+
*
|
|
246
300
|
* @returns string representation of the private key
|
|
301
|
+
* @throws Error if the private key has been cleared from memory.
|
|
247
302
|
* @group Implementation
|
|
248
303
|
* @category Serialization
|
|
249
304
|
*/
|
|
250
305
|
toString() {
|
|
306
|
+
this.ensureNotCleared();
|
|
251
307
|
return PrivateKey.formatPrivateKey(this.key.toString(), PrivateKeyVariants.Secp256r1);
|
|
252
308
|
}
|
|
253
309
|
/**
|
|
254
310
|
* Get the private key as a hex string with the 0x prefix.
|
|
255
311
|
*
|
|
312
|
+
* SECURITY: Same caveat as `toString()` — produces an immutable JS string
|
|
313
|
+
* containing the key material; cannot be zeroed by `clear()`.
|
|
314
|
+
*
|
|
256
315
|
* @returns string representation of the private key.
|
|
316
|
+
* @throws Error if the private key has been cleared from memory.
|
|
257
317
|
*/
|
|
258
318
|
toHexString() {
|
|
319
|
+
this.ensureNotCleared();
|
|
259
320
|
return this.key.toString();
|
|
260
321
|
}
|
|
322
|
+
/**
|
|
323
|
+
* Sign exactly the bytes of `message`. The input is interpreted as raw
|
|
324
|
+
* bytes regardless of what they encode. Pair with
|
|
325
|
+
* {@link Secp256r1PublicKey.verifyBytes}.
|
|
326
|
+
*
|
|
327
|
+
* The message is SHA3-256 hashed before signing (matching the Aptos-side
|
|
328
|
+
* Secp256r1 signing convention).
|
|
329
|
+
*
|
|
330
|
+
* @param message - The exact bytes to sign.
|
|
331
|
+
* @returns The generated signature for the provided bytes.
|
|
332
|
+
* @throws Error if the private key has been cleared from memory.
|
|
333
|
+
* @group Implementation
|
|
334
|
+
* @category Serialization
|
|
335
|
+
*/
|
|
336
|
+
signBytes(message) {
|
|
337
|
+
this.ensureNotCleared();
|
|
338
|
+
const sha3Message = sha3_256(message);
|
|
339
|
+
const signature = p256.sign(sha3Message, this.key.toUint8Array(), { prehash: false });
|
|
340
|
+
return new Secp256r1Signature(signature);
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Sign the UTF-8 encoding of `message`. The input is always treated as
|
|
344
|
+
* text — there is no hex/text heuristic. Pair with
|
|
345
|
+
* {@link Secp256r1PublicKey.verifyText}.
|
|
346
|
+
*
|
|
347
|
+
* @param message - The text to sign.
|
|
348
|
+
* @returns The generated signature for the UTF-8 bytes of the provided text.
|
|
349
|
+
* @throws Error if the private key has been cleared from memory.
|
|
350
|
+
* @group Implementation
|
|
351
|
+
* @category Serialization
|
|
352
|
+
*/
|
|
353
|
+
signText(message) {
|
|
354
|
+
return this.signBytes(TEXT_ENCODER.encode(message));
|
|
355
|
+
}
|
|
261
356
|
/**
|
|
262
357
|
* Sign the given message with the private key.
|
|
263
358
|
* This function generates a cryptographic signature for the provided message.
|
|
264
359
|
*
|
|
360
|
+
* @deprecated The polymorphic `message: HexInput` input is ambiguous — a
|
|
361
|
+
* bare even-length string of hex characters (e.g., `"cafe"`) is signed
|
|
362
|
+
* as the 2 bytes `[0xCA, 0xFE]`, not 4 UTF-8 text bytes. Use
|
|
363
|
+
* {@link signBytes} for `Uint8Array` input or {@link signText} for
|
|
364
|
+
* `string` input; both are unambiguous. See
|
|
365
|
+
* {@link convertSigningMessage} for the full legacy rule.
|
|
366
|
+
*
|
|
265
367
|
* @param message - A message in HexInput format to be signed.
|
|
266
368
|
* @returns Signature - The generated signature for the provided message.
|
|
369
|
+
* @throws Error if the private key has been cleared from memory.
|
|
267
370
|
* @group Implementation
|
|
268
371
|
* @category Serialization
|
|
269
372
|
*/
|
|
270
373
|
sign(message) {
|
|
271
|
-
const
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
return new Secp256r1Signature(signature);
|
|
374
|
+
const messageToSign = convertSigningMessage(message);
|
|
375
|
+
const msgBytes = Hex.fromHexInput(messageToSign).toUint8Array();
|
|
376
|
+
return this.signBytes(msgBytes);
|
|
275
377
|
}
|
|
276
378
|
/**
|
|
277
379
|
* Serializes the data into a byte array using the provided serializer.
|
|
@@ -311,13 +413,58 @@ export class Secp256r1PrivateKey extends PrivateKey {
|
|
|
311
413
|
* Derive the Secp256r1PublicKey from this private key.
|
|
312
414
|
*
|
|
313
415
|
* @returns Secp256r1PublicKey The derived public key.
|
|
416
|
+
* @throws Error if the private key has been cleared from memory.
|
|
314
417
|
* @group Implementation
|
|
315
418
|
* @category Serialization
|
|
316
419
|
*/
|
|
317
420
|
publicKey() {
|
|
421
|
+
this.ensureNotCleared();
|
|
318
422
|
const bytes = p256.getPublicKey(this.key.toUint8Array(), false);
|
|
319
423
|
return new Secp256r1PublicKey(bytes);
|
|
320
424
|
}
|
|
425
|
+
/**
|
|
426
|
+
* Throws if the key has already been cleared.
|
|
427
|
+
* @private
|
|
428
|
+
*/
|
|
429
|
+
ensureNotCleared() {
|
|
430
|
+
if (this.cleared) {
|
|
431
|
+
throw new Error("Private key has been cleared from memory and can no longer be used");
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Overwrites the underlying private-key byte buffer with random bytes and
|
|
436
|
+
* then zeros. After calling this method the key can no longer sign or
|
|
437
|
+
* derive a public key.
|
|
438
|
+
*
|
|
439
|
+
* SECURITY: This is a best-effort window-narrowing tool, NOT a true
|
|
440
|
+
* zeroization guarantee. See `Ed25519PrivateKey.clear()` for the full
|
|
441
|
+
* enumeration of JavaScript-level limits (immutable string copies, noble
|
|
442
|
+
* `BigInt` intermediates, JIT register/stack residue, GC-relocated
|
|
443
|
+
* copies). For Secp256r1 specifically, non-extractable `crypto.subtle`
|
|
444
|
+
* P-256 keys are universally supported across modern runtimes and are
|
|
445
|
+
* the architecturally-correct path for callers who need real memory
|
|
446
|
+
* hygiene; consider that alternative for new code.
|
|
447
|
+
*
|
|
448
|
+
* @group Implementation
|
|
449
|
+
* @category Serialization
|
|
450
|
+
*/
|
|
451
|
+
clear() {
|
|
452
|
+
if (!this.cleared) {
|
|
453
|
+
const keyBytes = this.key.toUint8Array();
|
|
454
|
+
// Multiple overwrite passes for consistency with the other private-key classes.
|
|
455
|
+
crypto.getRandomValues(keyBytes);
|
|
456
|
+
keyBytes.fill(0xff);
|
|
457
|
+
crypto.getRandomValues(keyBytes);
|
|
458
|
+
keyBytes.fill(0);
|
|
459
|
+
this.cleared = true;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Returns whether `clear()` has been called.
|
|
464
|
+
*/
|
|
465
|
+
isCleared() {
|
|
466
|
+
return this.cleared;
|
|
467
|
+
}
|
|
321
468
|
}
|
|
322
469
|
export class WebAuthnSignature extends Signature {
|
|
323
470
|
signature;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secp256r1.js","sourceRoot":"","sources":["../../../src/core/crypto/secp256r1.ts"],"names":[],"mappings":"AAA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IACtD,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,WAAW,CAAC,YAA0B;QAC3C,MAAM,GAAG,GAAG,YAAY,CAAC,gBAAgB,EAAE,CAAC;QAC5C,OAAO,IAAI,kBAAkB,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC"}
|
|
@@ -2,7 +2,34 @@ import { HexInput, SigningScheme } from "../../types/index.js";
|
|
|
2
2
|
import { AccountPublicKey } from "./publicKey.js";
|
|
3
3
|
import { BaseAccountPublicKey } from "./types.js";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Normalizes a sign/verify message into a {@link HexInput} that downstream
|
|
6
|
+
* callers can pass to `Hex.fromHexInput()`.
|
|
7
|
+
*
|
|
8
|
+
* Behavior — be aware before passing a string:
|
|
9
|
+
* - `Uint8Array` → returned as-is (used as raw bytes).
|
|
10
|
+
* - String that parses as hex via `Hex.isValid()` (with or without a `0x`
|
|
11
|
+
* prefix) → returned as the original hex string, which downstream
|
|
12
|
+
* `Hex.fromHexInput()` decodes to its byte form.
|
|
13
|
+
* - Any other string → returned as the UTF-8 byte encoding of the string.
|
|
14
|
+
*
|
|
15
|
+
* **AMBIGUITY**: a bare even-length string of hex characters is *always*
|
|
16
|
+
* interpreted as hex, even when the caller intended it as text. For example:
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* sign("cafe") // signs 2 bytes: [0xCA, 0xFE]
|
|
20
|
+
* sign("decade") // signs 3 bytes: [0xDE, 0xCA, 0xDE]
|
|
21
|
+
* sign("0xcafe") // signs 2 bytes: [0xCA, 0xFE] (explicit hex)
|
|
22
|
+
* sign("hello") // signs 5 bytes: UTF-8 "hello" (not valid hex)
|
|
23
|
+
* sign(new TextEncoder().encode("cafe")) // signs 4 bytes: UTF-8 "cafe"
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* If you mean *text*, pass `TextEncoder.encode(text)` or any `Uint8Array`.
|
|
27
|
+
* If you mean *hex bytes*, the most explicit form is also a `Uint8Array`
|
|
28
|
+
* (`Hex.fromHexInput("0x...").toUint8Array()`), or a string prefixed with
|
|
29
|
+
* `0x` for clarity. The heuristic is preserved as-is for backwards
|
|
30
|
+
* compatibility — changing it would silently re-interpret bytes signed by
|
|
31
|
+
* existing dApps and wallets — but new code should treat string inputs to
|
|
32
|
+
* `sign()` / `verifySignature()` as untyped and prefer `Uint8Array`.
|
|
6
33
|
*
|
|
7
34
|
* @param message a message as a string or Uint8Array
|
|
8
35
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/core/crypto/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAM/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAGlD
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/core/crypto/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAM/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAGlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,qBAAqB,GAAI,SAAS,QAAQ,KAAG,QAazD,CAAC;AAEF,eAAO,MAAM,sCAAsC,GAAI,WAAW,gBAAgB,KAAG,oBAiBpF,CAAC;AAEF,eAAO,MAAM,+BAA+B,GAAI,WAAW,gBAAgB,KAAG,aAe7E,CAAC"}
|
|
@@ -7,7 +7,34 @@ import { MultiKey } from "./multiKey.js";
|
|
|
7
7
|
import { AnyPublicKey } from "./singleKey.js";
|
|
8
8
|
import { detectPublicKeyVariant } from "./anyKeyRegistry.js";
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Normalizes a sign/verify message into a {@link HexInput} that downstream
|
|
11
|
+
* callers can pass to `Hex.fromHexInput()`.
|
|
12
|
+
*
|
|
13
|
+
* Behavior — be aware before passing a string:
|
|
14
|
+
* - `Uint8Array` → returned as-is (used as raw bytes).
|
|
15
|
+
* - String that parses as hex via `Hex.isValid()` (with or without a `0x`
|
|
16
|
+
* prefix) → returned as the original hex string, which downstream
|
|
17
|
+
* `Hex.fromHexInput()` decodes to its byte form.
|
|
18
|
+
* - Any other string → returned as the UTF-8 byte encoding of the string.
|
|
19
|
+
*
|
|
20
|
+
* **AMBIGUITY**: a bare even-length string of hex characters is *always*
|
|
21
|
+
* interpreted as hex, even when the caller intended it as text. For example:
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* sign("cafe") // signs 2 bytes: [0xCA, 0xFE]
|
|
25
|
+
* sign("decade") // signs 3 bytes: [0xDE, 0xCA, 0xDE]
|
|
26
|
+
* sign("0xcafe") // signs 2 bytes: [0xCA, 0xFE] (explicit hex)
|
|
27
|
+
* sign("hello") // signs 5 bytes: UTF-8 "hello" (not valid hex)
|
|
28
|
+
* sign(new TextEncoder().encode("cafe")) // signs 4 bytes: UTF-8 "cafe"
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* If you mean *text*, pass `TextEncoder.encode(text)` or any `Uint8Array`.
|
|
32
|
+
* If you mean *hex bytes*, the most explicit form is also a `Uint8Array`
|
|
33
|
+
* (`Hex.fromHexInput("0x...").toUint8Array()`), or a string prefixed with
|
|
34
|
+
* `0x` for clarity. The heuristic is preserved as-is for backwards
|
|
35
|
+
* compatibility — changing it would silently re-interpret bytes signed by
|
|
36
|
+
* existing dApps and wallets — but new code should treat string inputs to
|
|
37
|
+
* `sign()` / `verifySignature()` as untyped and prefer `Uint8Array`.
|
|
11
38
|
*
|
|
12
39
|
* @param message a message as a string or Uint8Array
|
|
13
40
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/core/crypto/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/core/crypto/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,OAAiB,EAAY,EAAE;IACnE,gEAAgE;IAChE,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CA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;IAChC,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,2BAA2B,oBAAoB,EAAE,CAAC,CAAC;AACrE,CAAC,CAAC"}
|
package/dist/errors/index.d.ts
CHANGED
|
@@ -102,11 +102,30 @@ type AptosApiErrorOpts = {
|
|
|
102
102
|
* @param statusText - The message associated with the response status.
|
|
103
103
|
* @param data - The response data returned from the API.
|
|
104
104
|
* @param request - The original AptosRequest that triggered the error.
|
|
105
|
+
*
|
|
106
|
+
* SECURITY: `Error.message` is sanitized for `AptosApiType.PEPPER` and
|
|
107
|
+
* `AptosApiType.PROVER` so that response bodies (which can contain JWT claims
|
|
108
|
+
* or pepper-derived material) don't leak into default log/crash sinks. The
|
|
109
|
+
* `data` field, however, ALWAYS holds the raw response body — including for
|
|
110
|
+
* those sensitive API types — so callers that log or serialize
|
|
111
|
+
* `AptosApiError.data` (e.g., `JSON.stringify(error)`, Sentry's automatic
|
|
112
|
+
* field capture, custom structured loggers) must treat it accordingly. If
|
|
113
|
+
* you only need a human-readable summary, prefer `error.message`.
|
|
105
114
|
*/
|
|
106
115
|
export declare class AptosApiError extends Error {
|
|
107
116
|
readonly url: string;
|
|
108
117
|
readonly status: number;
|
|
109
118
|
readonly statusText: string;
|
|
119
|
+
/**
|
|
120
|
+
* The raw response body returned by the API.
|
|
121
|
+
*
|
|
122
|
+
* SECURITY: For `AptosApiType.PEPPER` and `AptosApiType.PROVER`, this can
|
|
123
|
+
* contain sensitive keyless-flow material (JWT claims, pepper-derived
|
|
124
|
+
* state). It is NOT redacted here — only `Error.message` is. Treat
|
|
125
|
+
* `error.data` as sensitive when handling errors from those API types,
|
|
126
|
+
* especially before passing the error to a structured logger or crash
|
|
127
|
+
* reporter.
|
|
128
|
+
*/
|
|
110
129
|
readonly data: any;
|
|
111
130
|
readonly request: AptosRequest;
|
|
112
131
|
/**
|