@starknetfoundation/krusty-kms-wasm 0.11.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/krusty_kms_wasm.d.ts +231 -69
- package/krusty_kms_wasm.js +257 -26
- package/krusty_kms_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,6 +25,21 @@ console.log(getVersion());
|
|
|
25
25
|
console.log(poseidonHash("0x1", "0x2"));
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
+
Run `init()` once and share its promise. Once `init()` has resolved, calling
|
|
29
|
+
it again returns the same instance, but two calls that overlap (the second
|
|
30
|
+
starting while the first is still loading) each instantiate the module. The
|
|
31
|
+
one that finishes last replaces the instance under every object created on
|
|
32
|
+
the other: their getters fail with `RuntimeError: Out of bounds memory
|
|
33
|
+
access`, and their frees can release objects the new instance has since
|
|
34
|
+
created.
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
// krusty.ts: the one place that initializes the module
|
|
38
|
+
import init from "@starknetfoundation/krusty-kms-wasm";
|
|
39
|
+
|
|
40
|
+
export const krustyReady = init();
|
|
41
|
+
```
|
|
42
|
+
|
|
28
43
|
This package is generated with `wasm-pack --target web` and is intended for
|
|
29
44
|
browser-oriented ESM toolchains that support loading WebAssembly modules.
|
|
30
45
|
|
package/krusty_kms_wasm.d.ts
CHANGED
|
@@ -265,8 +265,11 @@ export class WasmFundProofResult {
|
|
|
265
265
|
*
|
|
266
266
|
* This type intentionally exposes `private_key` as a plain hex string for
|
|
267
267
|
* JS interop (signing, export, wallet recovery). That string lives in the
|
|
268
|
-
* JS heap and **cannot** be reliably wiped.
|
|
269
|
-
*
|
|
268
|
+
* JS heap and **cannot** be reliably wiped. The copy this object owns in
|
|
269
|
+
* WASM memory is zeroized when the object is freed (`free()` or garbage
|
|
270
|
+
* collection); each getter read makes a temporary copy that is freed
|
|
271
|
+
* without being wiped. Prefer companion public-only APIs
|
|
272
|
+
* (`derivePublicKey`, etc.) when private material is not required.
|
|
270
273
|
* Never `console.log` this value; `Debug` redacts the private key.
|
|
271
274
|
*/
|
|
272
275
|
export class WasmKeypair {
|
|
@@ -305,8 +308,10 @@ export class WasmKeypair {
|
|
|
305
308
|
* # Security / threat model
|
|
306
309
|
*
|
|
307
310
|
* `private_key` is a plain hex string in the JS heap and cannot be reliably
|
|
308
|
-
* wiped.
|
|
309
|
-
*
|
|
311
|
+
* wiped. The copy this object owns in WASM memory is zeroized when the
|
|
312
|
+
* object is freed, as for [`WasmKeypair`]. Prefer [`WasmNostrPublicKey`] /
|
|
313
|
+
* `deriveNostrPublicKey` when private material is not required. `Debug`
|
|
314
|
+
* redacts the private key.
|
|
310
315
|
*/
|
|
311
316
|
export class WasmNostrKeypair {
|
|
312
317
|
free(): void;
|
|
@@ -558,8 +563,10 @@ export class WasmStarkSignature {
|
|
|
558
563
|
* # Security / threat model
|
|
559
564
|
*
|
|
560
565
|
* `private_key` is a plain hex string in the JS heap and cannot be reliably
|
|
561
|
-
* wiped.
|
|
562
|
-
*
|
|
566
|
+
* wiped. The copy this object owns in WASM memory is zeroized when the
|
|
567
|
+
* object is freed, as for [`WasmKeypair`]. Prefer [`WasmStarkXOnlyPublicKey`]
|
|
568
|
+
* when private material is not required. `Debug` redacts the private key;
|
|
569
|
+
* default `Serialize` omits it.
|
|
563
570
|
*/
|
|
564
571
|
export class WasmStarkXOnlyKeypair {
|
|
565
572
|
free(): void;
|
|
@@ -1008,21 +1015,59 @@ export function decryptWithKey(nonce: string, ciphertext: string, key_hex: strin
|
|
|
1008
1015
|
* Derive an Argent account contract address from a public key.
|
|
1009
1016
|
*
|
|
1010
1017
|
* Uses the standard Argent deployment (salt = public key, Starknet-key owner,
|
|
1011
|
-
* no guardian). The constructor calldata
|
|
1012
|
-
* `[0, public_key, 1]` for v0.4.0 and `[public_key, 0]` for v0.3.x
|
|
1018
|
+
* no guardian). The constructor calldata follows the class version:
|
|
1019
|
+
* `[0, public_key, 1]` for v0.4.0 and v0.5.0, `[public_key, 0]` for v0.3.x;
|
|
1020
|
+
* `getAccountClassRegistry()` publishes the convention next to each class.
|
|
1021
|
+
*
|
|
1022
|
+
* This is the only Argent deployment a seed phrase reproduces on its own. An
|
|
1023
|
+
* account deployed with a guardian has a different address that discovery
|
|
1024
|
+
* cannot enumerate; once its address is known, feed its `DEPLOY_ACCOUNT`
|
|
1025
|
+
* fields to `inspectAccountDeployment`, or take the guardian from that
|
|
1026
|
+
* calldata and use `deriveArgentAccountAddressWithGuardian`.
|
|
1013
1027
|
*
|
|
1014
1028
|
* # Arguments
|
|
1015
1029
|
* * `public_key` - The Stark public key (hex string)
|
|
1016
|
-
* * `class_hash` - Optional
|
|
1017
|
-
*
|
|
1018
|
-
*
|
|
1019
|
-
*
|
|
1030
|
+
* * `class_hash` - Optional class hash (hex string). Defaults to the Argent
|
|
1031
|
+
* v0.4.0 class hash. The accepted set is the Argent Cairo 1 classes:
|
|
1032
|
+
* v0.5.0, v0.4.0, v0.3.1 and v0.3.0, which are the `getAccountClassRegistry()`
|
|
1033
|
+
* entries whose constructor shape is `argent_signer_with_optional_guardian`
|
|
1034
|
+
* or `argent_owner_guardian_felts`. The Cairo 0 proxy is not accepted: its
|
|
1035
|
+
* address also depends on the implementation hash, which this export takes
|
|
1036
|
+
* no argument for, so derive it with `calculateContractAddress` and the
|
|
1037
|
+
* proxy's own calldata. Any other class hash is rejected, because its
|
|
1038
|
+
* constructor layout is unknown and an address derived for it could be
|
|
1039
|
+
* undeployable.
|
|
1020
1040
|
*
|
|
1021
1041
|
* # Returns
|
|
1022
1042
|
* The derived account contract address as hex string
|
|
1023
1043
|
*/
|
|
1024
1044
|
export function deriveArgentAccountAddress(public_key: string, class_hash?: string | null): string;
|
|
1025
1045
|
|
|
1046
|
+
/**
|
|
1047
|
+
* Derive an Argent account contract address for an owner **with** a
|
|
1048
|
+
* Starknet-key guardian.
|
|
1049
|
+
*
|
|
1050
|
+
* Salt = public key; constructor calldata `[public_key, guardian]` for
|
|
1051
|
+
* v0.3.x and `[0, public_key, 0, 0, guardian]` for v0.4.0 and v0.5.0. The
|
|
1052
|
+
* guardian is per-account and not derived from the seed, so this cannot find
|
|
1053
|
+
* accounts from a phrase. It verifies an account whose address is already
|
|
1054
|
+
* known: take the guardian from that account's `DEPLOY_ACCOUNT` calldata and
|
|
1055
|
+
* compare the result with the address. Only the deploy-time guardian fixes
|
|
1056
|
+
* the address; an account's current guardian (`get_guardian`) can have been
|
|
1057
|
+
* changed or removed since and reproduces nothing.
|
|
1058
|
+
*
|
|
1059
|
+
* # Arguments
|
|
1060
|
+
* * `public_key` - The owner's Stark public key (hex string)
|
|
1061
|
+
* * `guardian_public_key` - The guardian's Stark public key at deployment
|
|
1062
|
+
* (hex string). `"0x0"` means no guardian and gives the same address as
|
|
1063
|
+
* `deriveArgentAccountAddress`
|
|
1064
|
+
* * `class_hash` - Optional class hash, as for `deriveArgentAccountAddress`
|
|
1065
|
+
*
|
|
1066
|
+
* # Returns
|
|
1067
|
+
* The derived account contract address as hex string
|
|
1068
|
+
*/
|
|
1069
|
+
export function deriveArgentAccountAddressWithGuardian(public_key: string, guardian_public_key: string, class_hash?: string | null): string;
|
|
1070
|
+
|
|
1026
1071
|
/**
|
|
1027
1072
|
* Derive a Starknet keypair using old Argent's "double derivation" scheme.
|
|
1028
1073
|
*
|
|
@@ -1060,12 +1105,19 @@ export function deriveArgentLegacyPublicKey(mnemonic: string, address_index: num
|
|
|
1060
1105
|
/**
|
|
1061
1106
|
* Derive a Braavos account contract address from a public key.
|
|
1062
1107
|
*
|
|
1063
|
-
* Uses the
|
|
1108
|
+
* Uses the Braavos base-account deployment: salt = public key, constructor
|
|
1109
|
+
* calldata `[public_key]`. Braavos accounts are deployed with a **base**
|
|
1110
|
+
* class and upgrade themselves to an **implementation** class in the same
|
|
1111
|
+
* transaction, so the address is fixed by the base class alone and the class
|
|
1112
|
+
* an account runs today (`starknet_getClassHashAt`) never reproduces it.
|
|
1064
1113
|
*
|
|
1065
1114
|
* # Arguments
|
|
1066
1115
|
* * `public_key` - The Stark public key (hex string)
|
|
1067
|
-
* * `class_hash` - Optional
|
|
1068
|
-
*
|
|
1116
|
+
* * `class_hash` - Optional base class hash (hex string). Defaults to the
|
|
1117
|
+
* current base class (v1.1.0 and later); the v1.0.0 base class is the other
|
|
1118
|
+
* accepted value, see `getAccountClassRegistry()` (family `braavos`, role
|
|
1119
|
+
* `deployment`). A known implementation class or an unrecognised class hash
|
|
1120
|
+
* is rejected rather than deriving an address no deployment produces.
|
|
1069
1121
|
*
|
|
1070
1122
|
* # Returns
|
|
1071
1123
|
* The derived account contract address as hex string
|
|
@@ -1336,12 +1388,10 @@ export function foldStrk20ViewingKey(public_key: string, message_hash: string, r
|
|
|
1336
1388
|
*
|
|
1337
1389
|
* # Why every address, not just the first
|
|
1338
1390
|
*
|
|
1339
|
-
* A wallet type
|
|
1340
|
-
*
|
|
1341
|
-
*
|
|
1342
|
-
*
|
|
1343
|
-
* one address per wallet type silently hides deployed accounts — every
|
|
1344
|
-
* omitted variant is an account the caller cannot find.
|
|
1391
|
+
* A wallet type has several address variants at one index: two OpenZeppelin
|
|
1392
|
+
* salt policies, two Braavos base classes, four Argent Cairo 1 classes under
|
|
1393
|
+
* each key scheme, four Argent Cairo 0 implementations. This is a
|
|
1394
|
+
* funds-recovery path: collapsing to one address per type hides accounts.
|
|
1345
1395
|
*
|
|
1346
1396
|
* # Returns
|
|
1347
1397
|
* JSON string: `{ "0": { "Braavos": ["0x..."], "OpenZeppelin": ["0x...", "0x..."], ... } }`
|
|
@@ -1357,7 +1407,9 @@ export function generateAccountAddresses(mnemonic: string, max_index?: number |
|
|
|
1357
1407
|
* This is a pure cryptographic operation — no network calls are made.
|
|
1358
1408
|
* Each candidate is a possible on-chain account address. To find which
|
|
1359
1409
|
* ones are actually deployed, check each address via an RPC provider
|
|
1360
|
-
* (e.g., `provider.getClassHashAt(address)` in starknet.js).
|
|
1410
|
+
* (e.g., `provider.getClassHashAt(address)` in starknet.js). That call returns
|
|
1411
|
+
* the class the account *runs*, for Braavos always an implementation class,
|
|
1412
|
+
* never the `classHash` derived from; `getAccountClassRegistry()` labels both.
|
|
1361
1413
|
*
|
|
1362
1414
|
* # Security
|
|
1363
1415
|
*
|
|
@@ -1377,7 +1429,7 @@ export function generateAccountAddresses(mnemonic: string, max_index?: number |
|
|
|
1377
1429
|
* - `publicKey`: hex string
|
|
1378
1430
|
* - `derivationIndex`: number
|
|
1379
1431
|
* - `derivationPath`: string (e.g., "m/44'/9004'/0'/0/0")
|
|
1380
|
-
* - `classVersion`: string (e.g., "v0.4.0", "
|
|
1432
|
+
* - `classVersion`: string (e.g., "v0.4.0", "base v1.1.0")
|
|
1381
1433
|
*
|
|
1382
1434
|
* # Example (JavaScript)
|
|
1383
1435
|
* ```javascript
|
|
@@ -1443,14 +1495,80 @@ export function generateWithdrawProof(account: WasmAccount, params: WasmWithdraw
|
|
|
1443
1495
|
/**
|
|
1444
1496
|
* Get known account class hashes for common Starknet account implementations.
|
|
1445
1497
|
*
|
|
1446
|
-
*
|
|
1447
|
-
*
|
|
1498
|
+
* A flat map of class hashes by family and version label. It does not say
|
|
1499
|
+
* which role a class plays, and that distinction matters: an address is fixed
|
|
1500
|
+
* by the class an account was **deployed** with, while the class it **runs**
|
|
1501
|
+
* today (what a signer must accept) is a different one for every Braavos
|
|
1502
|
+
* account. Prefer `getAccountClassRegistry()`, which labels every entry by
|
|
1503
|
+
* role; this export is kept for callers that rely on its shape.
|
|
1504
|
+
*
|
|
1505
|
+
* Braavos keys: `"1.0.0"` is the historical name of the base (deployment)
|
|
1506
|
+
* class introduced in v1.1.0 and still current; `"base-1.0.0"` is the v1.0.0
|
|
1507
|
+
* base class; `"legacy"` is the v1.0.0 account implementation and
|
|
1508
|
+
* `"account-1.1.0"` / `"account-1.2.0"` the later ones. Only the two base
|
|
1509
|
+
* classes derive addresses.
|
|
1448
1510
|
*
|
|
1449
1511
|
* # Returns
|
|
1450
|
-
* JSON string with nested object:
|
|
1512
|
+
* JSON string with nested object:
|
|
1513
|
+
* `{ oz: { ... }, argent: { ... }, argent_legacy: { ... }, braavos: { ... } }`
|
|
1451
1514
|
*/
|
|
1452
1515
|
export function getAccountClassHashes(): string;
|
|
1453
1516
|
|
|
1517
|
+
/**
|
|
1518
|
+
* Every account class this crate knows, labelled by the role it plays.
|
|
1519
|
+
*
|
|
1520
|
+
* A class hash plays one of two roles, and a wallet needs both lists:
|
|
1521
|
+
*
|
|
1522
|
+
* - `deployment`: the class an account is deployed with. It fixes the
|
|
1523
|
+
* address, so it is the class to **derive from** when looking for an
|
|
1524
|
+
* account from a seed.
|
|
1525
|
+
* - `implementation`: a class an account's address can report on chain
|
|
1526
|
+
* (`starknet_getClassHashAt`) and what to **accept when signing**. An entry
|
|
1527
|
+
* may also have the `deployment` role; only implementation-only entries
|
|
1528
|
+
* must not be used for address derivation.
|
|
1529
|
+
* - `proxy_target`: the class a proxy delegates to, named in the proxy's
|
|
1530
|
+
* constructor calldata. It is code the account runs, but no address ever
|
|
1531
|
+
* reports it, so a signing allowlist must not expect it. These are the
|
|
1532
|
+
* values the Argent Cairo 0 proxy's `implementation` input takes.
|
|
1533
|
+
*
|
|
1534
|
+
* Braavos accounts are deployed with a base class and upgraded to an
|
|
1535
|
+
* implementation class in the same transaction, so every Braavos account
|
|
1536
|
+
* runs a different class than it was deployed with. Argent and OpenZeppelin
|
|
1537
|
+
* classes play both roles, including the Argent Cairo 0 proxy: an unupgraded
|
|
1538
|
+
* Cairo 0 account reports the proxy's class hash, not its target's.
|
|
1539
|
+
*
|
|
1540
|
+
* # Returns
|
|
1541
|
+
* JSON string: array of objects with fields:
|
|
1542
|
+
* - `family`: "open_zeppelin" | "argent" | "braavos"
|
|
1543
|
+
* - `classHash`: hex string
|
|
1544
|
+
* - `version`: vendor release label (e.g. "1.2.0", "0.4.0", "proxy")
|
|
1545
|
+
* - `label`: human-readable name
|
|
1546
|
+
* - `roles`: array of "deployment" | "implementation" | "proxy_target"
|
|
1547
|
+
* - `constructor`: the class's calldata convention, or `null` for a class
|
|
1548
|
+
* that is never deployed with. An object with `shape` ("public_key" |
|
|
1549
|
+
* "argent_owner_guardian_felts" | "argent_signer_with_optional_guardian" |
|
|
1550
|
+
* "argent_cairo0_proxy"), `fromSeed` (the calldata a seed reproduces, e.g.
|
|
1551
|
+
* `"[0, owner, 1]"`), `withGuardian` (the calldata once a guardian is set,
|
|
1552
|
+
* e.g. `"[0, owner, 0, 0, guardian]"`, or `null`) and `inputsOutsideSeed`
|
|
1553
|
+
* (constructor inputs a phrase cannot supply, e.g. `["guardian"]`). The
|
|
1554
|
+
* convention varies by version and by guardian presence and cannot be
|
|
1555
|
+
* inferred from the class hash, which is why it travels with the class.
|
|
1556
|
+
* An `implementation` placeholder takes its values from this registry's
|
|
1557
|
+
* `proxy_target` entries for the same family, so a template can be
|
|
1558
|
+
* rendered from the registry alone.
|
|
1559
|
+
* - `source`: URL of the public listing the entry was checked against
|
|
1560
|
+
*
|
|
1561
|
+
* # Example (JavaScript)
|
|
1562
|
+
* ```javascript
|
|
1563
|
+
* const registry = JSON.parse(getAccountClassRegistry());
|
|
1564
|
+
* const deriveFrom = registry.filter(c => c.family === "braavos" && c.roles.includes("deployment"));
|
|
1565
|
+
* const acceptWhenSigning = registry.filter(c => c.family === "braavos" && c.roles.includes("implementation"));
|
|
1566
|
+
* // Values the Argent Cairo 0 proxy's `implementation` input takes:
|
|
1567
|
+
* const proxyTargets = registry.filter(c => c.family === "argent" && c.roles.includes("proxy_target"));
|
|
1568
|
+
* ```
|
|
1569
|
+
*/
|
|
1570
|
+
export function getAccountClassRegistry(): string;
|
|
1571
|
+
|
|
1454
1572
|
/**
|
|
1455
1573
|
* Get build information.
|
|
1456
1574
|
*/
|
|
@@ -1513,6 +1631,47 @@ export function grindKey(seed_hex: string): string;
|
|
|
1513
1631
|
*/
|
|
1514
1632
|
export function init(): void;
|
|
1515
1633
|
|
|
1634
|
+
/**
|
|
1635
|
+
* State whether an account deployment can be found from a seed phrase.
|
|
1636
|
+
*
|
|
1637
|
+
* Takes the three `DEPLOY_ACCOUNT` fields that fix an address. An account
|
|
1638
|
+
* that exists but whose address depends on inputs outside the seed (an
|
|
1639
|
+
* Argent guardian, a non-Starknet owner, a server-assigned salt) is
|
|
1640
|
+
* reported as `not_from_seed` with the reason, so a recovery flow can tell
|
|
1641
|
+
* "not discoverable from a phrase" apart from "no such account". Such an
|
|
1642
|
+
* account is still verifiable: check that `address` is the account's and
|
|
1643
|
+
* that `ownerPublicKey` is one of the seed's derived keys. `guardianPublicKey`
|
|
1644
|
+
* is the deploy-time guardian, which is the one that fixes the address; an
|
|
1645
|
+
* account's current guardian can have changed since.
|
|
1646
|
+
*
|
|
1647
|
+
* Pass the class hash from the deploy transaction, not the class the account
|
|
1648
|
+
* runs today: for an upgraded account the current class is an implementation
|
|
1649
|
+
* class and the answer is `not_from_seed` / `implementation_class`.
|
|
1650
|
+
*
|
|
1651
|
+
* # Arguments
|
|
1652
|
+
* * `class_hash` - `DEPLOY_ACCOUNT.class_hash` (hex string)
|
|
1653
|
+
* * `salt` - `DEPLOY_ACCOUNT.contract_address_salt` (hex string)
|
|
1654
|
+
* * `constructor_calldata` - `DEPLOY_ACCOUNT.constructor_calldata` (hex strings)
|
|
1655
|
+
*
|
|
1656
|
+
* # Returns
|
|
1657
|
+
* JSON string with fields:
|
|
1658
|
+
* - `address`: the address these fields fix (deployer zero). Compare it with
|
|
1659
|
+
* the account being checked before trusting anything else in the result:
|
|
1660
|
+
* the fields are usually an RPC response, and fields that do not hash to
|
|
1661
|
+
* the account say nothing about it
|
|
1662
|
+
* - `known`: whether the class hash is in the registry
|
|
1663
|
+
* - `class`: the registry entry (see `getAccountClassRegistry`), or `null`
|
|
1664
|
+
* - `ownerPublicKey`: the Stark key the constructor binds as owner, or `null`
|
|
1665
|
+
* - `guardianPublicKey`: the guardian's Stark key when a Starknet-key
|
|
1666
|
+
* guardian is set, or `null`
|
|
1667
|
+
* - `derivability`: "from_seed" | "not_from_seed" | "unknown_class"
|
|
1668
|
+
* - `reason`: for `not_from_seed`, one of "guardian" | "non_starknet_owner" |
|
|
1669
|
+
* "salt_not_public_key" | "implementation_class" | "proxy_target_class" |
|
|
1670
|
+
* "unknown_proxy_implementation" | "unexpected_constructor_calldata";
|
|
1671
|
+
* otherwise `null`
|
|
1672
|
+
*/
|
|
1673
|
+
export function inspectAccountDeployment(class_hash: string, salt: string, constructor_calldata: string[]): string;
|
|
1674
|
+
|
|
1516
1675
|
/**
|
|
1517
1676
|
* Check whether a hex string is a valid Stark field element.
|
|
1518
1677
|
*
|
|
@@ -2077,17 +2236,24 @@ export interface InitOutput {
|
|
|
2077
2236
|
readonly __wbg_set_wasmstarkxonlykeypair_private_key: (a: number, b: number, c: number) => void;
|
|
2078
2237
|
readonly __wbg_set_wasmstarkxonlykeypair_public_key_x: (a: number, b: number, c: number) => void;
|
|
2079
2238
|
readonly __wbg_set_wasmstarkxonlypublickey_public_key_x: (a: number, b: number, c: number) => void;
|
|
2239
|
+
readonly __wbg_get_wasmencryptedkey_encryptedKey: (a: number) => [number, number];
|
|
2240
|
+
readonly __wbg_get_wasmencryptedkey_nonce: (a: number) => [number, number];
|
|
2241
|
+
readonly __wbg_get_wasmencryptedkey_salt: (a: number) => [number, number];
|
|
2242
|
+
readonly __wbg_set_wasmencryptedkey_encryptedKey: (a: number, b: number, c: number) => void;
|
|
2243
|
+
readonly __wbg_set_wasmencryptedkey_nonce: (a: number, b: number, c: number) => void;
|
|
2244
|
+
readonly __wbg_set_wasmencryptedkey_salt: (a: number, b: number, c: number) => void;
|
|
2245
|
+
readonly __wbg_wasmaccount_free: (a: number, b: number) => void;
|
|
2246
|
+
readonly __wbg_wasmencryptedkey_free: (a: number, b: number) => void;
|
|
2247
|
+
readonly __wbg_wasmencryptedpayload_free: (a: number, b: number) => void;
|
|
2248
|
+
readonly decryptEthersKeystore: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
2249
|
+
readonly decryptKeystore: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
2250
|
+
readonly decryptPrivateKey: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number, number, number];
|
|
2251
|
+
readonly decryptWithKey: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
2080
2252
|
readonly deriveNostrKeypair: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
2081
2253
|
readonly deriveNostrPublicKey: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
2082
|
-
readonly
|
|
2083
|
-
readonly
|
|
2084
|
-
readonly
|
|
2085
|
-
readonly foldStrk20ViewingKey: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number, number];
|
|
2086
|
-
readonly getSelectorFromName: (a: number, b: number) => [number, number, number, number];
|
|
2087
|
-
readonly pedersenHash: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
2088
|
-
readonly pedersenHashMany: (a: number, b: number) => [number, number, number, number];
|
|
2089
|
-
readonly starknetKeccak: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
2090
|
-
readonly strk20ViewingKeyMessageHash: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
2254
|
+
readonly encryptKeystore: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
2255
|
+
readonly encryptPrivateKey: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
2256
|
+
readonly encryptWithKey: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
2091
2257
|
readonly wasmaccount_contractAddress: (a: number) => [number, number];
|
|
2092
2258
|
readonly wasmaccount_decryptBalance: (a: number, b: number, c: number, d: bigint) => [number, number, number, number];
|
|
2093
2259
|
readonly wasmaccount_decryptToPoint: (a: number, b: number) => [number, number, number];
|
|
@@ -2098,15 +2264,23 @@ export interface InitOutput {
|
|
|
2098
2264
|
readonly wasmaccount_ownerPublicKeyHex: (a: number) => [number, number, number, number];
|
|
2099
2265
|
readonly wasmaccount_totalBalance: (a: number) => [number, number, number, number];
|
|
2100
2266
|
readonly wasmaccount_updateState: (a: number, b: number) => [number, number];
|
|
2267
|
+
readonly __wbg_get_wasmencryptedpayload_ciphertext: (a: number) => [number, number];
|
|
2268
|
+
readonly __wbg_get_wasmencryptedpayload_nonce: (a: number) => [number, number];
|
|
2269
|
+
readonly __wbg_set_wasmencryptedpayload_ciphertext: (a: number, b: number, c: number) => void;
|
|
2270
|
+
readonly __wbg_set_wasmencryptedpayload_nonce: (a: number, b: number, c: number) => void;
|
|
2101
2271
|
readonly deserializePublicKey: (a: number, b: number) => [number, number, number];
|
|
2102
2272
|
readonly getBuildInfo: () => any;
|
|
2103
2273
|
readonly getGenerator: () => number;
|
|
2104
2274
|
readonly getVersion: () => [number, number];
|
|
2275
|
+
readonly grindKey: (a: number, b: number) => [number, number, number, number];
|
|
2105
2276
|
readonly init: () => void;
|
|
2277
|
+
readonly isValidFelt: (a: number, b: number) => number;
|
|
2278
|
+
readonly isValidStarkPrivateKey: (a: number, b: number) => number;
|
|
2106
2279
|
readonly nostrPublicKey: (a: number, b: number) => [number, number, number, number];
|
|
2107
2280
|
readonly pointAdd: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number];
|
|
2108
2281
|
readonly poseidonHash: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
2109
2282
|
readonly poseidonHashMany: (a: number, b: number) => [number, number, number, number];
|
|
2283
|
+
readonly randomBytesHex: (a: number) => [number, number, number, number];
|
|
2110
2284
|
readonly randomFelt: () => [number, number];
|
|
2111
2285
|
readonly scalarMul: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
2112
2286
|
readonly scalarMulGenerator: (a: number, b: number) => [number, number, number];
|
|
@@ -2115,13 +2289,10 @@ export interface InitOutput {
|
|
|
2115
2289
|
readonly signNostrMessage: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
2116
2290
|
readonly signStarkHash: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
2117
2291
|
readonly starkPublicKey: (a: number, b: number) => [number, number, number, number];
|
|
2118
|
-
readonly
|
|
2119
|
-
readonly
|
|
2120
|
-
readonly
|
|
2121
|
-
readonly
|
|
2122
|
-
readonly getAccountClassHashes: () => [number, number];
|
|
2123
|
-
readonly openNostrApplicationData: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number, number];
|
|
2124
|
-
readonly wrapNostrApplicationData: (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];
|
|
2292
|
+
readonly compileCalls: (a: number, b: number) => [number, number, number, number];
|
|
2293
|
+
readonly decodeShortString: (a: number, b: number) => [number, number, number, number];
|
|
2294
|
+
readonly encodeFelt: (a: number, b: number) => [number, number, number, number];
|
|
2295
|
+
readonly encodeShortString: (a: number, b: number) => [number, number, number, number];
|
|
2125
2296
|
readonly deriveArgentLegacyKeypair: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
2126
2297
|
readonly deriveArgentLegacyPublicKey: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
2127
2298
|
readonly deriveDiscoveryKeypairs: (a: number, b: number, c: number) => [number, number, number, number];
|
|
@@ -2140,6 +2311,18 @@ export interface InitOutput {
|
|
|
2140
2311
|
readonly getStarknetCoinType: () => number;
|
|
2141
2312
|
readonly getTongoCoinType: () => number;
|
|
2142
2313
|
readonly validateMnemonic: (a: number, b: number) => number;
|
|
2314
|
+
readonly calculateContractAddress: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number, number];
|
|
2315
|
+
readonly deriveArgentAccountAddress: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
2316
|
+
readonly deriveArgentAccountAddressWithGuardian: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
2317
|
+
readonly deriveBraavosAccountAddress: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
2318
|
+
readonly deriveOzAccountAddress: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
2319
|
+
readonly deriveScopedStrk20ViewingKey: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
2320
|
+
readonly deriveStrk20ViewingKey: (a: number, b: number) => [number, number, number, number];
|
|
2321
|
+
readonly foldStrk20ViewingKey: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number, number];
|
|
2322
|
+
readonly getAccountClassHashes: () => [number, number];
|
|
2323
|
+
readonly openNostrApplicationData: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number, number];
|
|
2324
|
+
readonly strk20ViewingKeyMessageHash: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
2325
|
+
readonly wrapNostrApplicationData: (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];
|
|
2143
2326
|
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];
|
|
2144
2327
|
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];
|
|
2145
2328
|
readonly computeDeployAccountTransactionHashV1: (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: number, n: number) => [number, number, number, number];
|
|
@@ -2147,33 +2330,12 @@ export interface InitOutput {
|
|
|
2147
2330
|
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];
|
|
2148
2331
|
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];
|
|
2149
2332
|
readonly computeTypedDataMessageHash: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
2150
|
-
readonly
|
|
2151
|
-
readonly
|
|
2152
|
-
readonly
|
|
2153
|
-
readonly
|
|
2154
|
-
readonly
|
|
2155
|
-
readonly
|
|
2156
|
-
readonly __wbg_wasmencryptedkey_free: (a: number, b: number) => void;
|
|
2157
|
-
readonly __wbg_wasmencryptedpayload_free: (a: number, b: number) => void;
|
|
2158
|
-
readonly decryptEthersKeystore: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
2159
|
-
readonly decryptKeystore: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
2160
|
-
readonly decryptPrivateKey: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number, number, number];
|
|
2161
|
-
readonly decryptWithKey: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
2162
|
-
readonly encryptKeystore: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
2163
|
-
readonly encryptPrivateKey: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
2164
|
-
readonly encryptWithKey: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
2165
|
-
readonly grindKey: (a: number, b: number) => [number, number, number, number];
|
|
2166
|
-
readonly isValidFelt: (a: number, b: number) => number;
|
|
2167
|
-
readonly isValidStarkPrivateKey: (a: number, b: number) => number;
|
|
2168
|
-
readonly randomBytesHex: (a: number) => [number, number, number, number];
|
|
2169
|
-
readonly __wbg_get_wasmencryptedpayload_ciphertext: (a: number) => [number, number];
|
|
2170
|
-
readonly __wbg_get_wasmencryptedpayload_nonce: (a: number) => [number, number];
|
|
2171
|
-
readonly __wbg_set_wasmencryptedpayload_ciphertext: (a: number, b: number, c: number) => void;
|
|
2172
|
-
readonly __wbg_set_wasmencryptedpayload_nonce: (a: number, b: number, c: number) => void;
|
|
2173
|
-
readonly compileCalls: (a: number, b: number) => [number, number, number, number];
|
|
2174
|
-
readonly decodeShortString: (a: number, b: number) => [number, number, number, number];
|
|
2175
|
-
readonly encodeFelt: (a: number, b: number) => [number, number, number, number];
|
|
2176
|
-
readonly encodeShortString: (a: number, b: number) => [number, number, number, number];
|
|
2333
|
+
readonly getSelectorFromName: (a: number, b: number) => [number, number, number, number];
|
|
2334
|
+
readonly pedersenHash: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
2335
|
+
readonly pedersenHashMany: (a: number, b: number) => [number, number, number, number];
|
|
2336
|
+
readonly starknetKeccak: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
2337
|
+
readonly getAccountClassRegistry: () => [number, number, number, number];
|
|
2338
|
+
readonly inspectAccountDeployment: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
2177
2339
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
2178
2340
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
2179
2341
|
readonly __wbindgen_exn_store: (a: number) => void;
|
package/krusty_kms_wasm.js
CHANGED
|
@@ -1213,8 +1213,11 @@ if (Symbol.dispose) WasmFundProofResult.prototype[Symbol.dispose] = WasmFundProo
|
|
|
1213
1213
|
*
|
|
1214
1214
|
* This type intentionally exposes `private_key` as a plain hex string for
|
|
1215
1215
|
* JS interop (signing, export, wallet recovery). That string lives in the
|
|
1216
|
-
* JS heap and **cannot** be reliably wiped.
|
|
1217
|
-
*
|
|
1216
|
+
* JS heap and **cannot** be reliably wiped. The copy this object owns in
|
|
1217
|
+
* WASM memory is zeroized when the object is freed (`free()` or garbage
|
|
1218
|
+
* collection); each getter read makes a temporary copy that is freed
|
|
1219
|
+
* without being wiped. Prefer companion public-only APIs
|
|
1220
|
+
* (`derivePublicKey`, etc.) when private material is not required.
|
|
1218
1221
|
* Never `console.log` this value; `Debug` redacts the private key.
|
|
1219
1222
|
*/
|
|
1220
1223
|
export class WasmKeypair {
|
|
@@ -1371,8 +1374,10 @@ if (Symbol.dispose) WasmKeypair.prototype[Symbol.dispose] = WasmKeypair.prototyp
|
|
|
1371
1374
|
* # Security / threat model
|
|
1372
1375
|
*
|
|
1373
1376
|
* `private_key` is a plain hex string in the JS heap and cannot be reliably
|
|
1374
|
-
* wiped.
|
|
1375
|
-
*
|
|
1377
|
+
* wiped. The copy this object owns in WASM memory is zeroized when the
|
|
1378
|
+
* object is freed, as for [`WasmKeypair`]. Prefer [`WasmNostrPublicKey`] /
|
|
1379
|
+
* `deriveNostrPublicKey` when private material is not required. `Debug`
|
|
1380
|
+
* redacts the private key.
|
|
1376
1381
|
*/
|
|
1377
1382
|
export class WasmNostrKeypair {
|
|
1378
1383
|
static __wrap(ptr) {
|
|
@@ -2738,8 +2743,10 @@ if (Symbol.dispose) WasmStarkSignature.prototype[Symbol.dispose] = WasmStarkSign
|
|
|
2738
2743
|
* # Security / threat model
|
|
2739
2744
|
*
|
|
2740
2745
|
* `private_key` is a plain hex string in the JS heap and cannot be reliably
|
|
2741
|
-
* wiped.
|
|
2742
|
-
*
|
|
2746
|
+
* wiped. The copy this object owns in WASM memory is zeroized when the
|
|
2747
|
+
* object is freed, as for [`WasmKeypair`]. Prefer [`WasmStarkXOnlyPublicKey`]
|
|
2748
|
+
* when private material is not required. `Debug` redacts the private key;
|
|
2749
|
+
* default `Serialize` omits it.
|
|
2743
2750
|
*/
|
|
2744
2751
|
export class WasmStarkXOnlyKeypair {
|
|
2745
2752
|
static __wrap(ptr) {
|
|
@@ -5344,15 +5351,28 @@ export function decryptWithKey(nonce, ciphertext, key_hex) {
|
|
|
5344
5351
|
* Derive an Argent account contract address from a public key.
|
|
5345
5352
|
*
|
|
5346
5353
|
* Uses the standard Argent deployment (salt = public key, Starknet-key owner,
|
|
5347
|
-
* no guardian). The constructor calldata
|
|
5348
|
-
* `[0, public_key, 1]` for v0.4.0 and `[public_key, 0]` for v0.3.x
|
|
5354
|
+
* no guardian). The constructor calldata follows the class version:
|
|
5355
|
+
* `[0, public_key, 1]` for v0.4.0 and v0.5.0, `[public_key, 0]` for v0.3.x;
|
|
5356
|
+
* `getAccountClassRegistry()` publishes the convention next to each class.
|
|
5357
|
+
*
|
|
5358
|
+
* This is the only Argent deployment a seed phrase reproduces on its own. An
|
|
5359
|
+
* account deployed with a guardian has a different address that discovery
|
|
5360
|
+
* cannot enumerate; once its address is known, feed its `DEPLOY_ACCOUNT`
|
|
5361
|
+
* fields to `inspectAccountDeployment`, or take the guardian from that
|
|
5362
|
+
* calldata and use `deriveArgentAccountAddressWithGuardian`.
|
|
5349
5363
|
*
|
|
5350
5364
|
* # Arguments
|
|
5351
5365
|
* * `public_key` - The Stark public key (hex string)
|
|
5352
|
-
* * `class_hash` - Optional
|
|
5353
|
-
*
|
|
5354
|
-
*
|
|
5355
|
-
*
|
|
5366
|
+
* * `class_hash` - Optional class hash (hex string). Defaults to the Argent
|
|
5367
|
+
* v0.4.0 class hash. The accepted set is the Argent Cairo 1 classes:
|
|
5368
|
+
* v0.5.0, v0.4.0, v0.3.1 and v0.3.0, which are the `getAccountClassRegistry()`
|
|
5369
|
+
* entries whose constructor shape is `argent_signer_with_optional_guardian`
|
|
5370
|
+
* or `argent_owner_guardian_felts`. The Cairo 0 proxy is not accepted: its
|
|
5371
|
+
* address also depends on the implementation hash, which this export takes
|
|
5372
|
+
* no argument for, so derive it with `calculateContractAddress` and the
|
|
5373
|
+
* proxy's own calldata. Any other class hash is rejected, because its
|
|
5374
|
+
* constructor layout is unknown and an address derived for it could be
|
|
5375
|
+
* undeployable.
|
|
5356
5376
|
*
|
|
5357
5377
|
* # Returns
|
|
5358
5378
|
* The derived account contract address as hex string
|
|
@@ -5383,6 +5403,58 @@ export function deriveArgentAccountAddress(public_key, class_hash) {
|
|
|
5383
5403
|
}
|
|
5384
5404
|
}
|
|
5385
5405
|
|
|
5406
|
+
/**
|
|
5407
|
+
* Derive an Argent account contract address for an owner **with** a
|
|
5408
|
+
* Starknet-key guardian.
|
|
5409
|
+
*
|
|
5410
|
+
* Salt = public key; constructor calldata `[public_key, guardian]` for
|
|
5411
|
+
* v0.3.x and `[0, public_key, 0, 0, guardian]` for v0.4.0 and v0.5.0. The
|
|
5412
|
+
* guardian is per-account and not derived from the seed, so this cannot find
|
|
5413
|
+
* accounts from a phrase. It verifies an account whose address is already
|
|
5414
|
+
* known: take the guardian from that account's `DEPLOY_ACCOUNT` calldata and
|
|
5415
|
+
* compare the result with the address. Only the deploy-time guardian fixes
|
|
5416
|
+
* the address; an account's current guardian (`get_guardian`) can have been
|
|
5417
|
+
* changed or removed since and reproduces nothing.
|
|
5418
|
+
*
|
|
5419
|
+
* # Arguments
|
|
5420
|
+
* * `public_key` - The owner's Stark public key (hex string)
|
|
5421
|
+
* * `guardian_public_key` - The guardian's Stark public key at deployment
|
|
5422
|
+
* (hex string). `"0x0"` means no guardian and gives the same address as
|
|
5423
|
+
* `deriveArgentAccountAddress`
|
|
5424
|
+
* * `class_hash` - Optional class hash, as for `deriveArgentAccountAddress`
|
|
5425
|
+
*
|
|
5426
|
+
* # Returns
|
|
5427
|
+
* The derived account contract address as hex string
|
|
5428
|
+
* @param {string} public_key
|
|
5429
|
+
* @param {string} guardian_public_key
|
|
5430
|
+
* @param {string | null} [class_hash]
|
|
5431
|
+
* @returns {string}
|
|
5432
|
+
*/
|
|
5433
|
+
export function deriveArgentAccountAddressWithGuardian(public_key, guardian_public_key, class_hash) {
|
|
5434
|
+
let deferred5_0;
|
|
5435
|
+
let deferred5_1;
|
|
5436
|
+
try {
|
|
5437
|
+
const ptr0 = passStringToWasm0(public_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
5438
|
+
const len0 = WASM_VECTOR_LEN;
|
|
5439
|
+
const ptr1 = passStringToWasm0(guardian_public_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
5440
|
+
const len1 = WASM_VECTOR_LEN;
|
|
5441
|
+
var ptr2 = isLikeNone(class_hash) ? 0 : passStringToWasm0(class_hash, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
5442
|
+
var len2 = WASM_VECTOR_LEN;
|
|
5443
|
+
const ret = wasm.deriveArgentAccountAddressWithGuardian(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
5444
|
+
var ptr4 = ret[0];
|
|
5445
|
+
var len4 = ret[1];
|
|
5446
|
+
if (ret[3]) {
|
|
5447
|
+
ptr4 = 0; len4 = 0;
|
|
5448
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
5449
|
+
}
|
|
5450
|
+
deferred5_0 = ptr4;
|
|
5451
|
+
deferred5_1 = len4;
|
|
5452
|
+
return getStringFromWasm0(ptr4, len4);
|
|
5453
|
+
} finally {
|
|
5454
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
5455
|
+
}
|
|
5456
|
+
}
|
|
5457
|
+
|
|
5386
5458
|
/**
|
|
5387
5459
|
* Derive a Starknet keypair using old Argent's "double derivation" scheme.
|
|
5388
5460
|
*
|
|
@@ -5444,12 +5516,19 @@ export function deriveArgentLegacyPublicKey(mnemonic, address_index, account_ind
|
|
|
5444
5516
|
/**
|
|
5445
5517
|
* Derive a Braavos account contract address from a public key.
|
|
5446
5518
|
*
|
|
5447
|
-
* Uses the
|
|
5519
|
+
* Uses the Braavos base-account deployment: salt = public key, constructor
|
|
5520
|
+
* calldata `[public_key]`. Braavos accounts are deployed with a **base**
|
|
5521
|
+
* class and upgrade themselves to an **implementation** class in the same
|
|
5522
|
+
* transaction, so the address is fixed by the base class alone and the class
|
|
5523
|
+
* an account runs today (`starknet_getClassHashAt`) never reproduces it.
|
|
5448
5524
|
*
|
|
5449
5525
|
* # Arguments
|
|
5450
5526
|
* * `public_key` - The Stark public key (hex string)
|
|
5451
|
-
* * `class_hash` - Optional
|
|
5452
|
-
*
|
|
5527
|
+
* * `class_hash` - Optional base class hash (hex string). Defaults to the
|
|
5528
|
+
* current base class (v1.1.0 and later); the v1.0.0 base class is the other
|
|
5529
|
+
* accepted value, see `getAccountClassRegistry()` (family `braavos`, role
|
|
5530
|
+
* `deployment`). A known implementation class or an unrecognised class hash
|
|
5531
|
+
* is rejected rather than deriving an address no deployment produces.
|
|
5453
5532
|
*
|
|
5454
5533
|
* # Returns
|
|
5455
5534
|
* The derived account contract address as hex string
|
|
@@ -6131,12 +6210,10 @@ export function foldStrk20ViewingKey(public_key, message_hash, r, s) {
|
|
|
6131
6210
|
*
|
|
6132
6211
|
* # Why every address, not just the first
|
|
6133
6212
|
*
|
|
6134
|
-
* A wallet type
|
|
6135
|
-
*
|
|
6136
|
-
*
|
|
6137
|
-
*
|
|
6138
|
-
* one address per wallet type silently hides deployed accounts — every
|
|
6139
|
-
* omitted variant is an account the caller cannot find.
|
|
6213
|
+
* A wallet type has several address variants at one index: two OpenZeppelin
|
|
6214
|
+
* salt policies, two Braavos base classes, four Argent Cairo 1 classes under
|
|
6215
|
+
* each key scheme, four Argent Cairo 0 implementations. This is a
|
|
6216
|
+
* funds-recovery path: collapsing to one address per type hides accounts.
|
|
6140
6217
|
*
|
|
6141
6218
|
* # Returns
|
|
6142
6219
|
* JSON string: `{ "0": { "Braavos": ["0x..."], "OpenZeppelin": ["0x...", "0x..."], ... } }`
|
|
@@ -6174,7 +6251,9 @@ export function generateAccountAddresses(mnemonic, max_index) {
|
|
|
6174
6251
|
* This is a pure cryptographic operation — no network calls are made.
|
|
6175
6252
|
* Each candidate is a possible on-chain account address. To find which
|
|
6176
6253
|
* ones are actually deployed, check each address via an RPC provider
|
|
6177
|
-
* (e.g., `provider.getClassHashAt(address)` in starknet.js).
|
|
6254
|
+
* (e.g., `provider.getClassHashAt(address)` in starknet.js). That call returns
|
|
6255
|
+
* the class the account *runs*, for Braavos always an implementation class,
|
|
6256
|
+
* never the `classHash` derived from; `getAccountClassRegistry()` labels both.
|
|
6178
6257
|
*
|
|
6179
6258
|
* # Security
|
|
6180
6259
|
*
|
|
@@ -6194,7 +6273,7 @@ export function generateAccountAddresses(mnemonic, max_index) {
|
|
|
6194
6273
|
* - `publicKey`: hex string
|
|
6195
6274
|
* - `derivationIndex`: number
|
|
6196
6275
|
* - `derivationPath`: string (e.g., "m/44'/9004'/0'/0/0")
|
|
6197
|
-
* - `classVersion`: string (e.g., "v0.4.0", "
|
|
6276
|
+
* - `classVersion`: string (e.g., "v0.4.0", "base v1.1.0")
|
|
6198
6277
|
*
|
|
6199
6278
|
* # Example (JavaScript)
|
|
6200
6279
|
* ```javascript
|
|
@@ -6378,11 +6457,22 @@ export function generateWithdrawProof(account, params) {
|
|
|
6378
6457
|
/**
|
|
6379
6458
|
* Get known account class hashes for common Starknet account implementations.
|
|
6380
6459
|
*
|
|
6381
|
-
*
|
|
6382
|
-
*
|
|
6460
|
+
* A flat map of class hashes by family and version label. It does not say
|
|
6461
|
+
* which role a class plays, and that distinction matters: an address is fixed
|
|
6462
|
+
* by the class an account was **deployed** with, while the class it **runs**
|
|
6463
|
+
* today (what a signer must accept) is a different one for every Braavos
|
|
6464
|
+
* account. Prefer `getAccountClassRegistry()`, which labels every entry by
|
|
6465
|
+
* role; this export is kept for callers that rely on its shape.
|
|
6466
|
+
*
|
|
6467
|
+
* Braavos keys: `"1.0.0"` is the historical name of the base (deployment)
|
|
6468
|
+
* class introduced in v1.1.0 and still current; `"base-1.0.0"` is the v1.0.0
|
|
6469
|
+
* base class; `"legacy"` is the v1.0.0 account implementation and
|
|
6470
|
+
* `"account-1.1.0"` / `"account-1.2.0"` the later ones. Only the two base
|
|
6471
|
+
* classes derive addresses.
|
|
6383
6472
|
*
|
|
6384
6473
|
* # Returns
|
|
6385
|
-
* JSON string with nested object:
|
|
6474
|
+
* JSON string with nested object:
|
|
6475
|
+
* `{ oz: { ... }, argent: { ... }, argent_legacy: { ... }, braavos: { ... } }`
|
|
6386
6476
|
* @returns {string}
|
|
6387
6477
|
*/
|
|
6388
6478
|
export function getAccountClassHashes() {
|
|
@@ -6398,6 +6488,79 @@ export function getAccountClassHashes() {
|
|
|
6398
6488
|
}
|
|
6399
6489
|
}
|
|
6400
6490
|
|
|
6491
|
+
/**
|
|
6492
|
+
* Every account class this crate knows, labelled by the role it plays.
|
|
6493
|
+
*
|
|
6494
|
+
* A class hash plays one of two roles, and a wallet needs both lists:
|
|
6495
|
+
*
|
|
6496
|
+
* - `deployment`: the class an account is deployed with. It fixes the
|
|
6497
|
+
* address, so it is the class to **derive from** when looking for an
|
|
6498
|
+
* account from a seed.
|
|
6499
|
+
* - `implementation`: a class an account's address can report on chain
|
|
6500
|
+
* (`starknet_getClassHashAt`) and what to **accept when signing**. An entry
|
|
6501
|
+
* may also have the `deployment` role; only implementation-only entries
|
|
6502
|
+
* must not be used for address derivation.
|
|
6503
|
+
* - `proxy_target`: the class a proxy delegates to, named in the proxy's
|
|
6504
|
+
* constructor calldata. It is code the account runs, but no address ever
|
|
6505
|
+
* reports it, so a signing allowlist must not expect it. These are the
|
|
6506
|
+
* values the Argent Cairo 0 proxy's `implementation` input takes.
|
|
6507
|
+
*
|
|
6508
|
+
* Braavos accounts are deployed with a base class and upgraded to an
|
|
6509
|
+
* implementation class in the same transaction, so every Braavos account
|
|
6510
|
+
* runs a different class than it was deployed with. Argent and OpenZeppelin
|
|
6511
|
+
* classes play both roles, including the Argent Cairo 0 proxy: an unupgraded
|
|
6512
|
+
* Cairo 0 account reports the proxy's class hash, not its target's.
|
|
6513
|
+
*
|
|
6514
|
+
* # Returns
|
|
6515
|
+
* JSON string: array of objects with fields:
|
|
6516
|
+
* - `family`: "open_zeppelin" | "argent" | "braavos"
|
|
6517
|
+
* - `classHash`: hex string
|
|
6518
|
+
* - `version`: vendor release label (e.g. "1.2.0", "0.4.0", "proxy")
|
|
6519
|
+
* - `label`: human-readable name
|
|
6520
|
+
* - `roles`: array of "deployment" | "implementation" | "proxy_target"
|
|
6521
|
+
* - `constructor`: the class's calldata convention, or `null` for a class
|
|
6522
|
+
* that is never deployed with. An object with `shape` ("public_key" |
|
|
6523
|
+
* "argent_owner_guardian_felts" | "argent_signer_with_optional_guardian" |
|
|
6524
|
+
* "argent_cairo0_proxy"), `fromSeed` (the calldata a seed reproduces, e.g.
|
|
6525
|
+
* `"[0, owner, 1]"`), `withGuardian` (the calldata once a guardian is set,
|
|
6526
|
+
* e.g. `"[0, owner, 0, 0, guardian]"`, or `null`) and `inputsOutsideSeed`
|
|
6527
|
+
* (constructor inputs a phrase cannot supply, e.g. `["guardian"]`). The
|
|
6528
|
+
* convention varies by version and by guardian presence and cannot be
|
|
6529
|
+
* inferred from the class hash, which is why it travels with the class.
|
|
6530
|
+
* An `implementation` placeholder takes its values from this registry's
|
|
6531
|
+
* `proxy_target` entries for the same family, so a template can be
|
|
6532
|
+
* rendered from the registry alone.
|
|
6533
|
+
* - `source`: URL of the public listing the entry was checked against
|
|
6534
|
+
*
|
|
6535
|
+
* # Example (JavaScript)
|
|
6536
|
+
* ```javascript
|
|
6537
|
+
* const registry = JSON.parse(getAccountClassRegistry());
|
|
6538
|
+
* const deriveFrom = registry.filter(c => c.family === "braavos" && c.roles.includes("deployment"));
|
|
6539
|
+
* const acceptWhenSigning = registry.filter(c => c.family === "braavos" && c.roles.includes("implementation"));
|
|
6540
|
+
* // Values the Argent Cairo 0 proxy's `implementation` input takes:
|
|
6541
|
+
* const proxyTargets = registry.filter(c => c.family === "argent" && c.roles.includes("proxy_target"));
|
|
6542
|
+
* ```
|
|
6543
|
+
* @returns {string}
|
|
6544
|
+
*/
|
|
6545
|
+
export function getAccountClassRegistry() {
|
|
6546
|
+
let deferred2_0;
|
|
6547
|
+
let deferred2_1;
|
|
6548
|
+
try {
|
|
6549
|
+
const ret = wasm.getAccountClassRegistry();
|
|
6550
|
+
var ptr1 = ret[0];
|
|
6551
|
+
var len1 = ret[1];
|
|
6552
|
+
if (ret[3]) {
|
|
6553
|
+
ptr1 = 0; len1 = 0;
|
|
6554
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
6555
|
+
}
|
|
6556
|
+
deferred2_0 = ptr1;
|
|
6557
|
+
deferred2_1 = len1;
|
|
6558
|
+
return getStringFromWasm0(ptr1, len1);
|
|
6559
|
+
} finally {
|
|
6560
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
6561
|
+
}
|
|
6562
|
+
}
|
|
6563
|
+
|
|
6401
6564
|
/**
|
|
6402
6565
|
* Get build information.
|
|
6403
6566
|
* @returns {any}
|
|
@@ -6536,6 +6699,74 @@ export function init() {
|
|
|
6536
6699
|
wasm.init();
|
|
6537
6700
|
}
|
|
6538
6701
|
|
|
6702
|
+
/**
|
|
6703
|
+
* State whether an account deployment can be found from a seed phrase.
|
|
6704
|
+
*
|
|
6705
|
+
* Takes the three `DEPLOY_ACCOUNT` fields that fix an address. An account
|
|
6706
|
+
* that exists but whose address depends on inputs outside the seed (an
|
|
6707
|
+
* Argent guardian, a non-Starknet owner, a server-assigned salt) is
|
|
6708
|
+
* reported as `not_from_seed` with the reason, so a recovery flow can tell
|
|
6709
|
+
* "not discoverable from a phrase" apart from "no such account". Such an
|
|
6710
|
+
* account is still verifiable: check that `address` is the account's and
|
|
6711
|
+
* that `ownerPublicKey` is one of the seed's derived keys. `guardianPublicKey`
|
|
6712
|
+
* is the deploy-time guardian, which is the one that fixes the address; an
|
|
6713
|
+
* account's current guardian can have changed since.
|
|
6714
|
+
*
|
|
6715
|
+
* Pass the class hash from the deploy transaction, not the class the account
|
|
6716
|
+
* runs today: for an upgraded account the current class is an implementation
|
|
6717
|
+
* class and the answer is `not_from_seed` / `implementation_class`.
|
|
6718
|
+
*
|
|
6719
|
+
* # Arguments
|
|
6720
|
+
* * `class_hash` - `DEPLOY_ACCOUNT.class_hash` (hex string)
|
|
6721
|
+
* * `salt` - `DEPLOY_ACCOUNT.contract_address_salt` (hex string)
|
|
6722
|
+
* * `constructor_calldata` - `DEPLOY_ACCOUNT.constructor_calldata` (hex strings)
|
|
6723
|
+
*
|
|
6724
|
+
* # Returns
|
|
6725
|
+
* JSON string with fields:
|
|
6726
|
+
* - `address`: the address these fields fix (deployer zero). Compare it with
|
|
6727
|
+
* the account being checked before trusting anything else in the result:
|
|
6728
|
+
* the fields are usually an RPC response, and fields that do not hash to
|
|
6729
|
+
* the account say nothing about it
|
|
6730
|
+
* - `known`: whether the class hash is in the registry
|
|
6731
|
+
* - `class`: the registry entry (see `getAccountClassRegistry`), or `null`
|
|
6732
|
+
* - `ownerPublicKey`: the Stark key the constructor binds as owner, or `null`
|
|
6733
|
+
* - `guardianPublicKey`: the guardian's Stark key when a Starknet-key
|
|
6734
|
+
* guardian is set, or `null`
|
|
6735
|
+
* - `derivability`: "from_seed" | "not_from_seed" | "unknown_class"
|
|
6736
|
+
* - `reason`: for `not_from_seed`, one of "guardian" | "non_starknet_owner" |
|
|
6737
|
+
* "salt_not_public_key" | "implementation_class" | "proxy_target_class" |
|
|
6738
|
+
* "unknown_proxy_implementation" | "unexpected_constructor_calldata";
|
|
6739
|
+
* otherwise `null`
|
|
6740
|
+
* @param {string} class_hash
|
|
6741
|
+
* @param {string} salt
|
|
6742
|
+
* @param {string[]} constructor_calldata
|
|
6743
|
+
* @returns {string}
|
|
6744
|
+
*/
|
|
6745
|
+
export function inspectAccountDeployment(class_hash, salt, constructor_calldata) {
|
|
6746
|
+
let deferred5_0;
|
|
6747
|
+
let deferred5_1;
|
|
6748
|
+
try {
|
|
6749
|
+
const ptr0 = passStringToWasm0(class_hash, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
6750
|
+
const len0 = WASM_VECTOR_LEN;
|
|
6751
|
+
const ptr1 = passStringToWasm0(salt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
6752
|
+
const len1 = WASM_VECTOR_LEN;
|
|
6753
|
+
const ptr2 = passArrayJsValueToWasm0(constructor_calldata, wasm.__wbindgen_malloc);
|
|
6754
|
+
const len2 = WASM_VECTOR_LEN;
|
|
6755
|
+
const ret = wasm.inspectAccountDeployment(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
6756
|
+
var ptr4 = ret[0];
|
|
6757
|
+
var len4 = ret[1];
|
|
6758
|
+
if (ret[3]) {
|
|
6759
|
+
ptr4 = 0; len4 = 0;
|
|
6760
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
6761
|
+
}
|
|
6762
|
+
deferred5_0 = ptr4;
|
|
6763
|
+
deferred5_1 = len4;
|
|
6764
|
+
return getStringFromWasm0(ptr4, len4);
|
|
6765
|
+
} finally {
|
|
6766
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
6767
|
+
}
|
|
6768
|
+
}
|
|
6769
|
+
|
|
6539
6770
|
/**
|
|
6540
6771
|
* Check whether a hex string is a valid Stark field element.
|
|
6541
6772
|
*
|
package/krusty_kms_wasm_bg.wasm
CHANGED
|
Binary file
|