@starknetfoundation/krusty-kms-wasm 0.8.1 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,7 +23,9 @@ export class WasmAccount {
23
23
  *
24
24
  * # Arguments
25
25
  * * `ciphertext` - The ciphertext to decrypt
26
- * * `max_search` - Maximum value to search for (default: 1,000,000)
26
+ * * `max_search` - Maximum value to search for (default: 1,000,000;
27
+ * capped at 2^20 — see [`Self::MAX_SEARCH_CEILING`] for why the cap has
28
+ * to be this small)
27
29
  *
28
30
  * # Returns
29
31
  * The decrypted balance as a string (for large number support in JS)
@@ -1312,11 +1314,21 @@ export function encryptWithKey(plaintext: string, key_hex: string): WasmEncrypte
1312
1314
  * Generate a compact summary of candidate addresses grouped by derivation index.
1313
1315
  *
1314
1316
  * Returns a JSON object where keys are derivation indices and values are
1315
- * objects mapping wallet type to address. Useful for quick discovery without
1316
- * needing the full candidate details. Never includes private keys.
1317
+ * objects mapping wallet type to **all** candidate addresses for that type.
1318
+ * Useful for quick discovery without needing the full candidate details.
1319
+ * Never includes private keys.
1320
+ *
1321
+ * # Why every address, not just the first
1322
+ *
1323
+ * A wallet type can have several address variants at one index: OpenZeppelin
1324
+ * has two salt policies (`salt = public_key` and the legacy `salt = 0`),
1325
+ * Argent legacy spans three Cairo 1 class hashes, and Argent Cairo 0 spans
1326
+ * four proxy implementations. This is a funds-recovery path, so collapsing to
1327
+ * one address per wallet type silently hides deployed accounts — every
1328
+ * omitted variant is an account the caller cannot find.
1317
1329
  *
1318
1330
  * # Returns
1319
- * JSON string: `{ "0": { "Braavos": "0x...", "Argent": "0x...", ... }, "1": { ... } }`
1331
+ * JSON string: `{ "0": { "Braavos": ["0x..."], "OpenZeppelin": ["0x...", "0x..."], ... } }`
1320
1332
  */
1321
1333
  export function generateAccountAddresses(mnemonic: string, max_index?: number | null): string;
1322
1334
 
@@ -1499,13 +1511,16 @@ export function isValidFelt(hex_str: string): boolean;
1499
1511
  /**
1500
1512
  * Check whether a hex string is a valid Stark private key.
1501
1513
  *
1502
- * A valid private key must parse as a felt and must not be zero.
1514
+ * A valid private key must parse as a felt, must not be zero, and must be
1515
+ * strictly below the Stark curve order `n`. Values in `[n, p)` parse as
1516
+ * felts but silently reduce mod `n` when used for signing — i.e. they alias
1517
+ * to a *different* key — so they are rejected here.
1503
1518
  *
1504
1519
  * # Arguments
1505
1520
  * * `hex_str` - Hex string to validate (with or without `0x` prefix)
1506
1521
  *
1507
1522
  * # Returns
1508
- * `true` if the string is a non-zero valid felt, `false` otherwise
1523
+ * `true` if the string is a valid in-range private key, `false` otherwise
1509
1524
  */
1510
1525
  export function isValidStarkPrivateKey(hex_str: string): boolean;
1511
1526
 
@@ -1580,7 +1595,9 @@ export function poseidonHashMany(inputs: string[]): string;
1580
1595
  * Uses a cryptographically secure random number generator.
1581
1596
  *
1582
1597
  * # Arguments
1583
- * * `length` - Number of random bytes to generate
1598
+ * * `length` - Number of random bytes to generate (maximum 1024 — this API
1599
+ * exists for keys/nonces/salts, and an unbounded caller-supplied length is
1600
+ * an allocation-DoS vector)
1584
1601
  *
1585
1602
  * # Returns
1586
1603
  * Hex-encoded bytes with `0x` prefix
@@ -2029,22 +2046,6 @@ export interface InitOutput {
2029
2046
  readonly __wbg_set_wasmstarkxonlykeypair_private_key: (a: number, b: number, c: number) => void;
2030
2047
  readonly __wbg_set_wasmstarkxonlykeypair_public_key_x: (a: number, b: number, c: number) => void;
2031
2048
  readonly __wbg_set_wasmstarkxonlypublickey_public_key_x: (a: number, b: number, c: number) => void;
2032
- readonly grindKey: (a: number, b: number) => [number, number, number, number];
2033
- readonly isValidFelt: (a: number, b: number) => number;
2034
- readonly isValidStarkPrivateKey: (a: number, b: number) => number;
2035
- readonly randomBytesHex: (a: number) => [number, number, number, number];
2036
- readonly deserializePublicKey: (a: number, b: number) => [number, number, number];
2037
- readonly getBuildInfo: () => any;
2038
- readonly getGenerator: () => number;
2039
- readonly getVersion: () => [number, number];
2040
- readonly init: () => void;
2041
- readonly pointAdd: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number];
2042
- readonly poseidonHash: (a: number, b: number, c: number, d: number) => [number, number, number, number];
2043
- readonly poseidonHashMany: (a: number, b: number) => [number, number, number, number];
2044
- readonly randomFelt: () => [number, number];
2045
- readonly scalarMul: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
2046
- readonly scalarMulGenerator: (a: number, b: number) => [number, number, number];
2047
- readonly serializePublicKey: (a: number, b: number, c: number, d: number) => [number, number, number, number];
2048
2049
  readonly __wbg_get_wasmencryptedkey_encryptedKey: (a: number) => [number, number];
2049
2050
  readonly __wbg_get_wasmencryptedkey_nonce: (a: number) => [number, number];
2050
2051
  readonly __wbg_get_wasmencryptedkey_salt: (a: number) => [number, number];
@@ -2057,28 +2058,48 @@ export interface InitOutput {
2057
2058
  readonly decryptKeystore: (a: number, b: number, c: number, d: number) => [number, number, number, number];
2058
2059
  readonly decryptPrivateKey: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number, number, number];
2059
2060
  readonly decryptWithKey: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
2061
+ readonly deriveArgentLegacyKeypair: (a: number, b: number, c: number, d: number) => [number, number, number];
2062
+ readonly deriveArgentLegacyPublicKey: (a: number, b: number, c: number, d: number) => [number, number, number];
2063
+ readonly deriveKeypair: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
2064
+ readonly derivePublicKey: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
2065
+ readonly deriveStarknetKeypair: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
2066
+ readonly deriveStarknetPublicKey: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
2060
2067
  readonly encryptKeystore: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
2061
2068
  readonly encryptPrivateKey: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
2062
2069
  readonly encryptWithKey: (a: number, b: number, c: number, d: number) => [number, number, number];
2063
- readonly nostrPublicKey: (a: number, b: number) => [number, number, number, number];
2064
- readonly signNostrEventId: (a: number, b: number, c: number, d: number) => [number, number, number];
2065
- readonly signNostrMessage: (a: number, b: number, c: number, d: number) => [number, number, number];
2066
- readonly signStarkHash: (a: number, b: number, c: number, d: number) => [number, number, number];
2067
- readonly starkPublicKey: (a: number, b: number) => [number, number, number, number];
2070
+ readonly generateMnemonic: (a: number) => [number, number, number, number];
2071
+ readonly getNostrCoinType: () => number;
2072
+ readonly getStarknetCoinType: () => number;
2073
+ readonly getTongoCoinType: () => number;
2074
+ readonly validateMnemonic: (a: number, b: number) => number;
2068
2075
  readonly __wbg_get_wasmencryptedpayload_ciphertext: (a: number) => [number, number];
2069
2076
  readonly __wbg_get_wasmencryptedpayload_nonce: (a: number) => [number, number];
2070
2077
  readonly __wbg_set_wasmencryptedpayload_ciphertext: (a: number, b: number, c: number) => void;
2071
2078
  readonly __wbg_set_wasmencryptedpayload_nonce: (a: number, b: number, c: number) => void;
2079
+ readonly deserializePublicKey: (a: number, b: number) => [number, number, number];
2080
+ readonly getBuildInfo: () => any;
2081
+ readonly getGenerator: () => number;
2082
+ readonly getVersion: () => [number, number];
2083
+ readonly init: () => void;
2084
+ readonly pointAdd: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number];
2085
+ readonly poseidonHash: (a: number, b: number, c: number, d: number) => [number, number, number, number];
2086
+ readonly poseidonHashMany: (a: number, b: number) => [number, number, number, number];
2087
+ readonly randomFelt: () => [number, number];
2088
+ readonly scalarMul: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
2089
+ readonly scalarMulGenerator: (a: number, b: number) => [number, number, number];
2090
+ readonly serializePublicKey: (a: number, b: number, c: number, d: number) => [number, number, number, number];
2072
2091
  readonly compileCalls: (a: number, b: number) => [number, number, number, number];
2073
2092
  readonly decodeShortString: (a: number, b: number) => [number, number, number, number];
2074
- readonly deriveNostrKeypair: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
2075
- readonly deriveNostrPublicKey: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
2076
2093
  readonly deriveStrk20ViewingKey: (a: number, b: number) => [number, number, number, number];
2077
2094
  readonly encodeFelt: (a: number, b: number) => [number, number, number, number];
2078
2095
  readonly encodeShortString: (a: number, b: number) => [number, number, number, number];
2079
2096
  readonly getSelectorFromName: (a: number, b: number) => [number, number, number, number];
2097
+ readonly grindKey: (a: number, b: number) => [number, number, number, number];
2098
+ readonly isValidFelt: (a: number, b: number) => number;
2099
+ readonly isValidStarkPrivateKey: (a: number, b: number) => number;
2080
2100
  readonly pedersenHash: (a: number, b: number, c: number, d: number) => [number, number, number, number];
2081
2101
  readonly pedersenHashMany: (a: number, b: number) => [number, number, number, number];
2102
+ readonly randomBytesHex: (a: number) => [number, number, number, number];
2082
2103
  readonly starknetKeccak: (a: number, b: number, c: number, d: number) => [number, number, number, number];
2083
2104
  readonly computeDeclareTransactionHashV2: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => [number, number, number, number];
2084
2105
  readonly computeDeclareTransactionHashV3: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: any, n: number, o: number, p: number, q: number, r: number, s: number) => [number, number, number, number];
@@ -2087,28 +2108,12 @@ export interface InitOutput {
2087
2108
  readonly computeInvokeTransactionHashV1: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number, number, number];
2088
2109
  readonly computeInvokeTransactionHashV3: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: any, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number) => [number, number, number, number];
2089
2110
  readonly computeTypedDataMessageHash: (a: number, b: number, c: number, d: number) => [number, number, number, number];
2090
- readonly deriveArgentLegacyKeypair: (a: number, b: number, c: number, d: number) => [number, number, number];
2091
- readonly deriveArgentLegacyPublicKey: (a: number, b: number, c: number, d: number) => [number, number, number];
2092
- readonly deriveDiscoveryKeypairs: (a: number, b: number, c: number) => [number, number, number, number];
2093
- readonly deriveDiscoveryKeypairsWithSecrets: (a: number, b: number, c: number) => [number, number, number, number];
2094
- readonly deriveKeypair: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
2095
- readonly derivePublicKey: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
2096
- readonly deriveStarknetKeypair: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
2097
- readonly deriveStarknetPublicKey: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
2098
- readonly discoverAccountsFromMnemonic: (a: number, b: number, c: number) => [number, number, number, number];
2099
- readonly discoverAccountsFromMnemonicWithSecrets: (a: number, b: number, c: number) => [number, number, number, number];
2100
- readonly generateAccountAddresses: (a: number, b: number, c: number) => [number, number, number, number];
2101
- readonly generateAccountCandidates: (a: number, b: number, c: number) => [number, number, number, number];
2102
- readonly generateAccountCandidatesWithSecrets: (a: number, b: number, c: number) => [number, number, number, number];
2103
- readonly generateMnemonic: (a: number) => [number, number, number, number];
2104
- readonly getNostrCoinType: () => number;
2105
- readonly getStarknetCoinType: () => number;
2106
- readonly getTongoCoinType: () => number;
2107
- readonly validateMnemonic: (a: number, b: number) => number;
2108
2111
  readonly __wbg_wasmaccount_free: (a: number, b: number) => void;
2109
2112
  readonly calculateContractAddress: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number, number];
2110
2113
  readonly deriveArgentAccountAddress: (a: number, b: number, c: number, d: number) => [number, number, number, number];
2111
2114
  readonly deriveBraavosAccountAddress: (a: number, b: number, c: number, d: number) => [number, number, number, number];
2115
+ readonly deriveNostrKeypair: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
2116
+ readonly deriveNostrPublicKey: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
2112
2117
  readonly deriveOzAccountAddress: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
2113
2118
  readonly getAccountClassHashes: () => [number, number];
2114
2119
  readonly wasmaccount_contractAddress: (a: number) => [number, number];
@@ -2121,6 +2126,18 @@ export interface InitOutput {
2121
2126
  readonly wasmaccount_ownerPublicKeyHex: (a: number) => [number, number, number, number];
2122
2127
  readonly wasmaccount_totalBalance: (a: number) => [number, number, number, number];
2123
2128
  readonly wasmaccount_updateState: (a: number, b: number) => [number, number];
2129
+ readonly deriveDiscoveryKeypairs: (a: number, b: number, c: number) => [number, number, number, number];
2130
+ readonly deriveDiscoveryKeypairsWithSecrets: (a: number, b: number, c: number) => [number, number, number, number];
2131
+ readonly discoverAccountsFromMnemonic: (a: number, b: number, c: number) => [number, number, number, number];
2132
+ readonly discoverAccountsFromMnemonicWithSecrets: (a: number, b: number, c: number) => [number, number, number, number];
2133
+ readonly generateAccountAddresses: (a: number, b: number, c: number) => [number, number, number, number];
2134
+ readonly generateAccountCandidates: (a: number, b: number, c: number) => [number, number, number, number];
2135
+ readonly generateAccountCandidatesWithSecrets: (a: number, b: number, c: number) => [number, number, number, number];
2136
+ readonly nostrPublicKey: (a: number, b: number) => [number, number, number, number];
2137
+ readonly signNostrEventId: (a: number, b: number, c: number, d: number) => [number, number, number];
2138
+ readonly signNostrMessage: (a: number, b: number, c: number, d: number) => [number, number, number];
2139
+ readonly signStarkHash: (a: number, b: number, c: number, d: number) => [number, number, number];
2140
+ readonly starkPublicKey: (a: number, b: number) => [number, number, number, number];
2124
2141
  readonly __wbindgen_malloc: (a: number, b: number) => number;
2125
2142
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
2126
2143
  readonly __wbindgen_exn_store: (a: number) => void;
@@ -48,7 +48,9 @@ export class WasmAccount {
48
48
  *
49
49
  * # Arguments
50
50
  * * `ciphertext` - The ciphertext to decrypt
51
- * * `max_search` - Maximum value to search for (default: 1,000,000)
51
+ * * `max_search` - Maximum value to search for (default: 1,000,000;
52
+ * capped at 2^20 — see [`Self::MAX_SEARCH_CEILING`] for why the cap has
53
+ * to be this small)
52
54
  *
53
55
  * # Returns
54
56
  * The decrypted balance as a string (for large number support in JS)
@@ -6073,11 +6075,21 @@ export function encryptWithKey(plaintext, key_hex) {
6073
6075
  * Generate a compact summary of candidate addresses grouped by derivation index.
6074
6076
  *
6075
6077
  * Returns a JSON object where keys are derivation indices and values are
6076
- * objects mapping wallet type to address. Useful for quick discovery without
6077
- * needing the full candidate details. Never includes private keys.
6078
+ * objects mapping wallet type to **all** candidate addresses for that type.
6079
+ * Useful for quick discovery without needing the full candidate details.
6080
+ * Never includes private keys.
6081
+ *
6082
+ * # Why every address, not just the first
6083
+ *
6084
+ * A wallet type can have several address variants at one index: OpenZeppelin
6085
+ * has two salt policies (`salt = public_key` and the legacy `salt = 0`),
6086
+ * Argent legacy spans three Cairo 1 class hashes, and Argent Cairo 0 spans
6087
+ * four proxy implementations. This is a funds-recovery path, so collapsing to
6088
+ * one address per wallet type silently hides deployed accounts — every
6089
+ * omitted variant is an account the caller cannot find.
6078
6090
  *
6079
6091
  * # Returns
6080
- * JSON string: `{ "0": { "Braavos": "0x...", "Argent": "0x...", ... }, "1": { ... } }`
6092
+ * JSON string: `{ "0": { "Braavos": ["0x..."], "OpenZeppelin": ["0x...", "0x..."], ... } }`
6081
6093
  * @param {string} mnemonic
6082
6094
  * @param {number | null} [max_index]
6083
6095
  * @returns {string}
@@ -6495,13 +6507,16 @@ export function isValidFelt(hex_str) {
6495
6507
  /**
6496
6508
  * Check whether a hex string is a valid Stark private key.
6497
6509
  *
6498
- * A valid private key must parse as a felt and must not be zero.
6510
+ * A valid private key must parse as a felt, must not be zero, and must be
6511
+ * strictly below the Stark curve order `n`. Values in `[n, p)` parse as
6512
+ * felts but silently reduce mod `n` when used for signing — i.e. they alias
6513
+ * to a *different* key — so they are rejected here.
6499
6514
  *
6500
6515
  * # Arguments
6501
6516
  * * `hex_str` - Hex string to validate (with or without `0x` prefix)
6502
6517
  *
6503
6518
  * # Returns
6504
- * `true` if the string is a non-zero valid felt, `false` otherwise
6519
+ * `true` if the string is a valid in-range private key, `false` otherwise
6505
6520
  * @param {string} hex_str
6506
6521
  * @returns {boolean}
6507
6522
  */
@@ -6713,7 +6728,9 @@ export function poseidonHashMany(inputs) {
6713
6728
  * Uses a cryptographically secure random number generator.
6714
6729
  *
6715
6730
  * # Arguments
6716
- * * `length` - Number of random bytes to generate
6731
+ * * `length` - Number of random bytes to generate (maximum 1024 — this API
6732
+ * exists for keys/nonces/salts, and an unbounded caller-supplied length is
6733
+ * an allocation-DoS vector)
6717
6734
  *
6718
6735
  * # Returns
6719
6736
  * Hex-encoded bytes with `0x` prefix
Binary file
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "Krusty KMS Contributors"
6
6
  ],
7
7
  "description": "WASM bindings for krusty-kms account and protocol utilities",
8
- "version": "0.8.1",
8
+ "version": "0.9.1",
9
9
  "license": "MIT OR Apache-2.0",
10
10
  "repository": {
11
11
  "type": "git",