@starknetfoundation/krusty-kms-wasm 0.4.5 → 0.5.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/krusty_kms_wasm.d.ts +290 -45
- package/krusty_kms_wasm.js +746 -82
- package/krusty_kms_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/krusty_kms_wasm.js
CHANGED
|
@@ -1212,7 +1212,15 @@ export class WasmFundProofResult {
|
|
|
1212
1212
|
if (Symbol.dispose) WasmFundProofResult.prototype[Symbol.dispose] = WasmFundProofResult.prototype.free;
|
|
1213
1213
|
|
|
1214
1214
|
/**
|
|
1215
|
-
* Keypair for Tongo operations.
|
|
1215
|
+
* Keypair for Tongo / Starknet operations.
|
|
1216
|
+
*
|
|
1217
|
+
* # Security / threat model
|
|
1218
|
+
*
|
|
1219
|
+
* This type intentionally exposes `private_key` as a plain hex string for
|
|
1220
|
+
* JS interop (signing, export, wallet recovery). That string lives in the
|
|
1221
|
+
* JS heap and **cannot** be reliably wiped. Prefer companion public-only
|
|
1222
|
+
* APIs (`derivePublicKey`, etc.) when private material is not required.
|
|
1223
|
+
* Never `console.log` this value; `Debug` redacts the private key.
|
|
1216
1224
|
*/
|
|
1217
1225
|
export class WasmKeypair {
|
|
1218
1226
|
static __wrap(ptr) {
|
|
@@ -1233,7 +1241,10 @@ export class WasmKeypair {
|
|
|
1233
1241
|
wasm.__wbg_wasmkeypair_free(ptr, 0);
|
|
1234
1242
|
}
|
|
1235
1243
|
/**
|
|
1236
|
-
* Private key as hex string (0x-prefixed)
|
|
1244
|
+
* Private key as hex string (0x-prefixed). Treat as secret.
|
|
1245
|
+
*
|
|
1246
|
+
* Omitted from default `Serialize` (use the wasm-bindgen getter for the
|
|
1247
|
+
* intentional secret-returning API).
|
|
1237
1248
|
* @returns {string}
|
|
1238
1249
|
*/
|
|
1239
1250
|
get private_key() {
|
|
@@ -1281,7 +1292,10 @@ export class WasmKeypair {
|
|
|
1281
1292
|
}
|
|
1282
1293
|
}
|
|
1283
1294
|
/**
|
|
1284
|
-
* Private key as hex string (0x-prefixed)
|
|
1295
|
+
* Private key as hex string (0x-prefixed). Treat as secret.
|
|
1296
|
+
*
|
|
1297
|
+
* Omitted from default `Serialize` (use the wasm-bindgen getter for the
|
|
1298
|
+
* intentional secret-returning API).
|
|
1285
1299
|
* @param {string} arg0
|
|
1286
1300
|
*/
|
|
1287
1301
|
set private_key(arg0) {
|
|
@@ -1320,24 +1334,35 @@ export class WasmKeypair {
|
|
|
1320
1334
|
const ptr2 = passStringToWasm0(public_key_y, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1321
1335
|
const len2 = WASM_VECTOR_LEN;
|
|
1322
1336
|
const ret = wasm.wasmkeypair_new(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
1323
|
-
|
|
1337
|
+
if (ret[2]) {
|
|
1338
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1339
|
+
}
|
|
1340
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
1324
1341
|
WasmKeypairFinalization.register(this, this.__wbg_ptr, this);
|
|
1325
1342
|
return this;
|
|
1326
1343
|
}
|
|
1327
1344
|
/**
|
|
1328
|
-
* Get the full public key as
|
|
1345
|
+
* Get the full public key as fixed-width `0x` + 128 hex digits (x||y).
|
|
1346
|
+
*
|
|
1347
|
+
* Compatible with `deserializePublicKey`.
|
|
1329
1348
|
* @returns {string}
|
|
1330
1349
|
*/
|
|
1331
1350
|
publicKeyHex() {
|
|
1332
|
-
let
|
|
1333
|
-
let
|
|
1351
|
+
let deferred2_0;
|
|
1352
|
+
let deferred2_1;
|
|
1334
1353
|
try {
|
|
1335
1354
|
const ret = wasm.wasmkeypair_publicKeyHex(this.__wbg_ptr);
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1355
|
+
var ptr1 = ret[0];
|
|
1356
|
+
var len1 = ret[1];
|
|
1357
|
+
if (ret[3]) {
|
|
1358
|
+
ptr1 = 0; len1 = 0;
|
|
1359
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1360
|
+
}
|
|
1361
|
+
deferred2_0 = ptr1;
|
|
1362
|
+
deferred2_1 = len1;
|
|
1363
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1339
1364
|
} finally {
|
|
1340
|
-
wasm.__wbindgen_free(
|
|
1365
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1341
1366
|
}
|
|
1342
1367
|
}
|
|
1343
1368
|
}
|
|
@@ -1348,6 +1373,12 @@ if (Symbol.dispose) WasmKeypair.prototype[Symbol.dispose] = WasmKeypair.prototyp
|
|
|
1348
1373
|
*
|
|
1349
1374
|
* Used for NIP-04/NIP-44 encrypted messaging.
|
|
1350
1375
|
* Public key is x-only (32 bytes, BIP-340 format).
|
|
1376
|
+
*
|
|
1377
|
+
* # Security / threat model
|
|
1378
|
+
*
|
|
1379
|
+
* `private_key` is a plain hex string in the JS heap and cannot be reliably
|
|
1380
|
+
* wiped. Prefer [`WasmNostrPublicKey`] / `deriveNostrPublicKey` when private
|
|
1381
|
+
* material is not required. `Debug` redacts the private key.
|
|
1351
1382
|
*/
|
|
1352
1383
|
export class WasmNostrKeypair {
|
|
1353
1384
|
static __wrap(ptr) {
|
|
@@ -1368,7 +1399,10 @@ export class WasmNostrKeypair {
|
|
|
1368
1399
|
wasm.__wbg_wasmnostrkeypair_free(ptr, 0);
|
|
1369
1400
|
}
|
|
1370
1401
|
/**
|
|
1371
|
-
* Private key as hex string (64 hex chars, no 0x prefix)
|
|
1402
|
+
* Private key as hex string (64 hex chars, no 0x prefix). Treat as secret.
|
|
1403
|
+
*
|
|
1404
|
+
* Omitted from default `Serialize` (use the wasm-bindgen getter for the
|
|
1405
|
+
* intentional secret-returning API).
|
|
1372
1406
|
* @returns {string}
|
|
1373
1407
|
*/
|
|
1374
1408
|
get private_key() {
|
|
@@ -1400,7 +1434,10 @@ export class WasmNostrKeypair {
|
|
|
1400
1434
|
}
|
|
1401
1435
|
}
|
|
1402
1436
|
/**
|
|
1403
|
-
* Private key as hex string (64 hex chars, no 0x prefix)
|
|
1437
|
+
* Private key as hex string (64 hex chars, no 0x prefix). Treat as secret.
|
|
1438
|
+
*
|
|
1439
|
+
* Omitted from default `Serialize` (use the wasm-bindgen getter for the
|
|
1440
|
+
* intentional secret-returning API).
|
|
1404
1441
|
* @param {string} arg0
|
|
1405
1442
|
*/
|
|
1406
1443
|
set private_key(arg0) {
|
|
@@ -1434,6 +1471,66 @@ export class WasmNostrKeypair {
|
|
|
1434
1471
|
}
|
|
1435
1472
|
if (Symbol.dispose) WasmNostrKeypair.prototype[Symbol.dispose] = WasmNostrKeypair.prototype.free;
|
|
1436
1473
|
|
|
1474
|
+
/**
|
|
1475
|
+
* Public-only Nostr key (x-only, BIP-340). No private key material.
|
|
1476
|
+
*/
|
|
1477
|
+
export class WasmNostrPublicKey {
|
|
1478
|
+
static __wrap(ptr) {
|
|
1479
|
+
ptr = ptr >>> 0;
|
|
1480
|
+
const obj = Object.create(WasmNostrPublicKey.prototype);
|
|
1481
|
+
obj.__wbg_ptr = ptr;
|
|
1482
|
+
WasmNostrPublicKeyFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1483
|
+
return obj;
|
|
1484
|
+
}
|
|
1485
|
+
__destroy_into_raw() {
|
|
1486
|
+
const ptr = this.__wbg_ptr;
|
|
1487
|
+
this.__wbg_ptr = 0;
|
|
1488
|
+
WasmNostrPublicKeyFinalization.unregister(this);
|
|
1489
|
+
return ptr;
|
|
1490
|
+
}
|
|
1491
|
+
free() {
|
|
1492
|
+
const ptr = this.__destroy_into_raw();
|
|
1493
|
+
wasm.__wbg_wasmnostrpublickey_free(ptr, 0);
|
|
1494
|
+
}
|
|
1495
|
+
/**
|
|
1496
|
+
* Public key as x-only hex string (64 hex chars, no 0x prefix)
|
|
1497
|
+
* @returns {string}
|
|
1498
|
+
*/
|
|
1499
|
+
get public_key() {
|
|
1500
|
+
let deferred1_0;
|
|
1501
|
+
let deferred1_1;
|
|
1502
|
+
try {
|
|
1503
|
+
const ret = wasm.__wbg_get_wasmnostrpublickey_public_key(this.__wbg_ptr);
|
|
1504
|
+
deferred1_0 = ret[0];
|
|
1505
|
+
deferred1_1 = ret[1];
|
|
1506
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1507
|
+
} finally {
|
|
1508
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
/**
|
|
1512
|
+
* Public key as x-only hex string (64 hex chars, no 0x prefix)
|
|
1513
|
+
* @param {string} arg0
|
|
1514
|
+
*/
|
|
1515
|
+
set public_key(arg0) {
|
|
1516
|
+
const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1517
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1518
|
+
wasm.__wbg_set_wasmciphertext_l_x(this.__wbg_ptr, ptr0, len0);
|
|
1519
|
+
}
|
|
1520
|
+
/**
|
|
1521
|
+
* @param {string} public_key
|
|
1522
|
+
*/
|
|
1523
|
+
constructor(public_key) {
|
|
1524
|
+
const ptr0 = passStringToWasm0(public_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1525
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1526
|
+
const ret = wasm.wasmnostrpublickey_new(ptr0, len0);
|
|
1527
|
+
this.__wbg_ptr = ret >>> 0;
|
|
1528
|
+
WasmNostrPublicKeyFinalization.register(this, this.__wbg_ptr, this);
|
|
1529
|
+
return this;
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
if (Symbol.dispose) WasmNostrPublicKey.prototype[Symbol.dispose] = WasmNostrPublicKey.prototype.free;
|
|
1533
|
+
|
|
1437
1534
|
/**
|
|
1438
1535
|
* Nostr BIP-340 Schnorr signature result.
|
|
1439
1536
|
*/
|
|
@@ -1595,6 +1692,125 @@ export class WasmPoint {
|
|
|
1595
1692
|
}
|
|
1596
1693
|
if (Symbol.dispose) WasmPoint.prototype[Symbol.dispose] = WasmPoint.prototype.free;
|
|
1597
1694
|
|
|
1695
|
+
/**
|
|
1696
|
+
* Public-only Stark / Tongo key material (no private key).
|
|
1697
|
+
*
|
|
1698
|
+
* Prefer this over [`WasmKeypair`] when only the public key is needed
|
|
1699
|
+
* (address derivation, display, API lookups). Both affine coordinates are
|
|
1700
|
+
* populated; for x-only Stark keys use [`WasmStarkXOnlyPublicKey`].
|
|
1701
|
+
*/
|
|
1702
|
+
export class WasmPublicKey {
|
|
1703
|
+
static __wrap(ptr) {
|
|
1704
|
+
ptr = ptr >>> 0;
|
|
1705
|
+
const obj = Object.create(WasmPublicKey.prototype);
|
|
1706
|
+
obj.__wbg_ptr = ptr;
|
|
1707
|
+
WasmPublicKeyFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1708
|
+
return obj;
|
|
1709
|
+
}
|
|
1710
|
+
__destroy_into_raw() {
|
|
1711
|
+
const ptr = this.__wbg_ptr;
|
|
1712
|
+
this.__wbg_ptr = 0;
|
|
1713
|
+
WasmPublicKeyFinalization.unregister(this);
|
|
1714
|
+
return ptr;
|
|
1715
|
+
}
|
|
1716
|
+
free() {
|
|
1717
|
+
const ptr = this.__destroy_into_raw();
|
|
1718
|
+
wasm.__wbg_wasmpublickey_free(ptr, 0);
|
|
1719
|
+
}
|
|
1720
|
+
/**
|
|
1721
|
+
* Public key X coordinate as hex string
|
|
1722
|
+
* @returns {string}
|
|
1723
|
+
*/
|
|
1724
|
+
get public_key_x() {
|
|
1725
|
+
let deferred1_0;
|
|
1726
|
+
let deferred1_1;
|
|
1727
|
+
try {
|
|
1728
|
+
const ret = wasm.__wbg_get_wasmpublickey_public_key_x(this.__wbg_ptr);
|
|
1729
|
+
deferred1_0 = ret[0];
|
|
1730
|
+
deferred1_1 = ret[1];
|
|
1731
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1732
|
+
} finally {
|
|
1733
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
/**
|
|
1737
|
+
* Public key Y coordinate as hex string
|
|
1738
|
+
* @returns {string}
|
|
1739
|
+
*/
|
|
1740
|
+
get public_key_y() {
|
|
1741
|
+
let deferred1_0;
|
|
1742
|
+
let deferred1_1;
|
|
1743
|
+
try {
|
|
1744
|
+
const ret = wasm.__wbg_get_wasmpublickey_public_key_y(this.__wbg_ptr);
|
|
1745
|
+
deferred1_0 = ret[0];
|
|
1746
|
+
deferred1_1 = ret[1];
|
|
1747
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1748
|
+
} finally {
|
|
1749
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
/**
|
|
1753
|
+
* Public key X coordinate as hex string
|
|
1754
|
+
* @param {string} arg0
|
|
1755
|
+
*/
|
|
1756
|
+
set public_key_x(arg0) {
|
|
1757
|
+
const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1758
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1759
|
+
wasm.__wbg_set_wasmciphertext_l_x(this.__wbg_ptr, ptr0, len0);
|
|
1760
|
+
}
|
|
1761
|
+
/**
|
|
1762
|
+
* Public key Y coordinate as hex string
|
|
1763
|
+
* @param {string} arg0
|
|
1764
|
+
*/
|
|
1765
|
+
set public_key_y(arg0) {
|
|
1766
|
+
const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1767
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1768
|
+
wasm.__wbg_set_wasmciphertext_l_y(this.__wbg_ptr, ptr0, len0);
|
|
1769
|
+
}
|
|
1770
|
+
/**
|
|
1771
|
+
* @param {string} public_key_x
|
|
1772
|
+
* @param {string} public_key_y
|
|
1773
|
+
*/
|
|
1774
|
+
constructor(public_key_x, public_key_y) {
|
|
1775
|
+
const ptr0 = passStringToWasm0(public_key_x, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1776
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1777
|
+
const ptr1 = passStringToWasm0(public_key_y, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1778
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1779
|
+
const ret = wasm.wasmpublickey_new(ptr0, len0, ptr1, len1);
|
|
1780
|
+
if (ret[2]) {
|
|
1781
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1782
|
+
}
|
|
1783
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
1784
|
+
WasmPublicKeyFinalization.register(this, this.__wbg_ptr, this);
|
|
1785
|
+
return this;
|
|
1786
|
+
}
|
|
1787
|
+
/**
|
|
1788
|
+
* Get the full public key as fixed-width `0x` + 128 hex digits (x||y).
|
|
1789
|
+
*
|
|
1790
|
+
* Compatible with `deserializePublicKey`.
|
|
1791
|
+
* @returns {string}
|
|
1792
|
+
*/
|
|
1793
|
+
publicKeyHex() {
|
|
1794
|
+
let deferred2_0;
|
|
1795
|
+
let deferred2_1;
|
|
1796
|
+
try {
|
|
1797
|
+
const ret = wasm.wasmpublickey_publicKeyHex(this.__wbg_ptr);
|
|
1798
|
+
var ptr1 = ret[0];
|
|
1799
|
+
var len1 = ret[1];
|
|
1800
|
+
if (ret[3]) {
|
|
1801
|
+
ptr1 = 0; len1 = 0;
|
|
1802
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1803
|
+
}
|
|
1804
|
+
deferred2_0 = ptr1;
|
|
1805
|
+
deferred2_1 = len1;
|
|
1806
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1807
|
+
} finally {
|
|
1808
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
if (Symbol.dispose) WasmPublicKey.prototype[Symbol.dispose] = WasmPublicKey.prototype.free;
|
|
1813
|
+
|
|
1598
1814
|
/**
|
|
1599
1815
|
* Parameters for generating a ragequit proof.
|
|
1600
1816
|
*/
|
|
@@ -2428,70 +2644,260 @@ export class WasmRolloverProofResult {
|
|
|
2428
2644
|
wasm.__wbg_set_wasmfundparams_nonce(this.__wbg_ptr, ptr0, len0);
|
|
2429
2645
|
}
|
|
2430
2646
|
}
|
|
2431
|
-
if (Symbol.dispose) WasmRolloverProofResult.prototype[Symbol.dispose] = WasmRolloverProofResult.prototype.free;
|
|
2647
|
+
if (Symbol.dispose) WasmRolloverProofResult.prototype[Symbol.dispose] = WasmRolloverProofResult.prototype.free;
|
|
2648
|
+
|
|
2649
|
+
/**
|
|
2650
|
+
* Stark ECDSA signature result.
|
|
2651
|
+
*/
|
|
2652
|
+
export class WasmStarkSignature {
|
|
2653
|
+
static __wrap(ptr) {
|
|
2654
|
+
ptr = ptr >>> 0;
|
|
2655
|
+
const obj = Object.create(WasmStarkSignature.prototype);
|
|
2656
|
+
obj.__wbg_ptr = ptr;
|
|
2657
|
+
WasmStarkSignatureFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
2658
|
+
return obj;
|
|
2659
|
+
}
|
|
2660
|
+
__destroy_into_raw() {
|
|
2661
|
+
const ptr = this.__wbg_ptr;
|
|
2662
|
+
this.__wbg_ptr = 0;
|
|
2663
|
+
WasmStarkSignatureFinalization.unregister(this);
|
|
2664
|
+
return ptr;
|
|
2665
|
+
}
|
|
2666
|
+
free() {
|
|
2667
|
+
const ptr = this.__destroy_into_raw();
|
|
2668
|
+
wasm.__wbg_wasmstarksignature_free(ptr, 0);
|
|
2669
|
+
}
|
|
2670
|
+
/**
|
|
2671
|
+
* Public key (hex)
|
|
2672
|
+
* @returns {string}
|
|
2673
|
+
*/
|
|
2674
|
+
get publicKey() {
|
|
2675
|
+
let deferred1_0;
|
|
2676
|
+
let deferred1_1;
|
|
2677
|
+
try {
|
|
2678
|
+
const ret = wasm.__wbg_get_wasmstarksignature_publicKey(this.__wbg_ptr);
|
|
2679
|
+
deferred1_0 = ret[0];
|
|
2680
|
+
deferred1_1 = ret[1];
|
|
2681
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
2682
|
+
} finally {
|
|
2683
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
/**
|
|
2687
|
+
* Signature r component (hex)
|
|
2688
|
+
* @returns {string}
|
|
2689
|
+
*/
|
|
2690
|
+
get r() {
|
|
2691
|
+
let deferred1_0;
|
|
2692
|
+
let deferred1_1;
|
|
2693
|
+
try {
|
|
2694
|
+
const ret = wasm.__wbg_get_wasmstarksignature_r(this.__wbg_ptr);
|
|
2695
|
+
deferred1_0 = ret[0];
|
|
2696
|
+
deferred1_1 = ret[1];
|
|
2697
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
2698
|
+
} finally {
|
|
2699
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
2700
|
+
}
|
|
2701
|
+
}
|
|
2702
|
+
/**
|
|
2703
|
+
* Signature s component (hex)
|
|
2704
|
+
* @returns {string}
|
|
2705
|
+
*/
|
|
2706
|
+
get s() {
|
|
2707
|
+
let deferred1_0;
|
|
2708
|
+
let deferred1_1;
|
|
2709
|
+
try {
|
|
2710
|
+
const ret = wasm.__wbg_get_wasmstarksignature_s(this.__wbg_ptr);
|
|
2711
|
+
deferred1_0 = ret[0];
|
|
2712
|
+
deferred1_1 = ret[1];
|
|
2713
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
2714
|
+
} finally {
|
|
2715
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
2716
|
+
}
|
|
2717
|
+
}
|
|
2718
|
+
/**
|
|
2719
|
+
* Public key (hex)
|
|
2720
|
+
* @param {string} arg0
|
|
2721
|
+
*/
|
|
2722
|
+
set publicKey(arg0) {
|
|
2723
|
+
const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2724
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2725
|
+
wasm.__wbg_set_wasmaccountstate_pending_balance(this.__wbg_ptr, ptr0, len0);
|
|
2726
|
+
}
|
|
2727
|
+
/**
|
|
2728
|
+
* Signature r component (hex)
|
|
2729
|
+
* @param {string} arg0
|
|
2730
|
+
*/
|
|
2731
|
+
set r(arg0) {
|
|
2732
|
+
const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2733
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2734
|
+
wasm.__wbg_set_wasmciphertext_l_x(this.__wbg_ptr, ptr0, len0);
|
|
2735
|
+
}
|
|
2736
|
+
/**
|
|
2737
|
+
* Signature s component (hex)
|
|
2738
|
+
* @param {string} arg0
|
|
2739
|
+
*/
|
|
2740
|
+
set s(arg0) {
|
|
2741
|
+
const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2742
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2743
|
+
wasm.__wbg_set_wasmciphertext_l_y(this.__wbg_ptr, ptr0, len0);
|
|
2744
|
+
}
|
|
2745
|
+
}
|
|
2746
|
+
if (Symbol.dispose) WasmStarkSignature.prototype[Symbol.dispose] = WasmStarkSignature.prototype.free;
|
|
2747
|
+
|
|
2748
|
+
/**
|
|
2749
|
+
* Stark x-only keypair (private key + x-coordinate public key).
|
|
2750
|
+
*
|
|
2751
|
+
* Used by Argent-legacy derivation where `stark_public_key` does not produce Y.
|
|
2752
|
+
*
|
|
2753
|
+
* # Security / threat model
|
|
2754
|
+
*
|
|
2755
|
+
* `private_key` is a plain hex string in the JS heap and cannot be reliably
|
|
2756
|
+
* wiped. Prefer [`WasmStarkXOnlyPublicKey`] when private material is not
|
|
2757
|
+
* required. `Debug` redacts the private key; default `Serialize` omits it.
|
|
2758
|
+
*/
|
|
2759
|
+
export class WasmStarkXOnlyKeypair {
|
|
2760
|
+
static __wrap(ptr) {
|
|
2761
|
+
ptr = ptr >>> 0;
|
|
2762
|
+
const obj = Object.create(WasmStarkXOnlyKeypair.prototype);
|
|
2763
|
+
obj.__wbg_ptr = ptr;
|
|
2764
|
+
WasmStarkXOnlyKeypairFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
2765
|
+
return obj;
|
|
2766
|
+
}
|
|
2767
|
+
__destroy_into_raw() {
|
|
2768
|
+
const ptr = this.__wbg_ptr;
|
|
2769
|
+
this.__wbg_ptr = 0;
|
|
2770
|
+
WasmStarkXOnlyKeypairFinalization.unregister(this);
|
|
2771
|
+
return ptr;
|
|
2772
|
+
}
|
|
2773
|
+
free() {
|
|
2774
|
+
const ptr = this.__destroy_into_raw();
|
|
2775
|
+
wasm.__wbg_wasmstarkxonlykeypair_free(ptr, 0);
|
|
2776
|
+
}
|
|
2777
|
+
/**
|
|
2778
|
+
* Private key as hex string (0x-prefixed). Treat as secret.
|
|
2779
|
+
* @returns {string}
|
|
2780
|
+
*/
|
|
2781
|
+
get private_key() {
|
|
2782
|
+
let deferred1_0;
|
|
2783
|
+
let deferred1_1;
|
|
2784
|
+
try {
|
|
2785
|
+
const ret = wasm.__wbg_get_wasmstarkxonlykeypair_private_key(this.__wbg_ptr);
|
|
2786
|
+
deferred1_0 = ret[0];
|
|
2787
|
+
deferred1_1 = ret[1];
|
|
2788
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
2789
|
+
} finally {
|
|
2790
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2793
|
+
/**
|
|
2794
|
+
* Public key X coordinate as hex string
|
|
2795
|
+
* @returns {string}
|
|
2796
|
+
*/
|
|
2797
|
+
get public_key_x() {
|
|
2798
|
+
let deferred1_0;
|
|
2799
|
+
let deferred1_1;
|
|
2800
|
+
try {
|
|
2801
|
+
const ret = wasm.__wbg_get_wasmstarkxonlykeypair_public_key_x(this.__wbg_ptr);
|
|
2802
|
+
deferred1_0 = ret[0];
|
|
2803
|
+
deferred1_1 = ret[1];
|
|
2804
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
2805
|
+
} finally {
|
|
2806
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
2807
|
+
}
|
|
2808
|
+
}
|
|
2809
|
+
/**
|
|
2810
|
+
* Private key as hex string (0x-prefixed). Treat as secret.
|
|
2811
|
+
* @param {string} arg0
|
|
2812
|
+
*/
|
|
2813
|
+
set private_key(arg0) {
|
|
2814
|
+
const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2815
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2816
|
+
wasm.__wbg_set_wasmciphertext_l_x(this.__wbg_ptr, ptr0, len0);
|
|
2817
|
+
}
|
|
2818
|
+
/**
|
|
2819
|
+
* Public key X coordinate as hex string
|
|
2820
|
+
* @param {string} arg0
|
|
2821
|
+
*/
|
|
2822
|
+
set public_key_x(arg0) {
|
|
2823
|
+
const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2824
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2825
|
+
wasm.__wbg_set_wasmciphertext_l_y(this.__wbg_ptr, ptr0, len0);
|
|
2826
|
+
}
|
|
2827
|
+
/**
|
|
2828
|
+
* @param {string} private_key
|
|
2829
|
+
* @param {string} public_key_x
|
|
2830
|
+
*/
|
|
2831
|
+
constructor(private_key, public_key_x) {
|
|
2832
|
+
const ptr0 = passStringToWasm0(private_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2833
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2834
|
+
const ptr1 = passStringToWasm0(public_key_x, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2835
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2836
|
+
const ret = wasm.wasmstarkxonlykeypair_new(ptr0, len0, ptr1, len1);
|
|
2837
|
+
if (ret[2]) {
|
|
2838
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2839
|
+
}
|
|
2840
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
2841
|
+
WasmStarkXOnlyKeypairFinalization.register(this, this.__wbg_ptr, this);
|
|
2842
|
+
return this;
|
|
2843
|
+
}
|
|
2844
|
+
/**
|
|
2845
|
+
* Return the x-only public key as fixed-width `0x` + 64 hex digits.
|
|
2846
|
+
* @returns {string}
|
|
2847
|
+
*/
|
|
2848
|
+
publicKeyHex() {
|
|
2849
|
+
let deferred2_0;
|
|
2850
|
+
let deferred2_1;
|
|
2851
|
+
try {
|
|
2852
|
+
const ret = wasm.wasmstarkxonlykeypair_publicKeyHex(this.__wbg_ptr);
|
|
2853
|
+
var ptr1 = ret[0];
|
|
2854
|
+
var len1 = ret[1];
|
|
2855
|
+
if (ret[3]) {
|
|
2856
|
+
ptr1 = 0; len1 = 0;
|
|
2857
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2858
|
+
}
|
|
2859
|
+
deferred2_0 = ptr1;
|
|
2860
|
+
deferred2_1 = len1;
|
|
2861
|
+
return getStringFromWasm0(ptr1, len1);
|
|
2862
|
+
} finally {
|
|
2863
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
2864
|
+
}
|
|
2865
|
+
}
|
|
2866
|
+
}
|
|
2867
|
+
if (Symbol.dispose) WasmStarkXOnlyKeypair.prototype[Symbol.dispose] = WasmStarkXOnlyKeypair.prototype.free;
|
|
2432
2868
|
|
|
2433
2869
|
/**
|
|
2434
|
-
* Stark
|
|
2870
|
+
* Stark public key as an x-only felt (no Y coordinate).
|
|
2871
|
+
*
|
|
2872
|
+
* Matches `stark_public_key` / account address derivation inputs.
|
|
2435
2873
|
*/
|
|
2436
|
-
export class
|
|
2874
|
+
export class WasmStarkXOnlyPublicKey {
|
|
2437
2875
|
static __wrap(ptr) {
|
|
2438
2876
|
ptr = ptr >>> 0;
|
|
2439
|
-
const obj = Object.create(
|
|
2877
|
+
const obj = Object.create(WasmStarkXOnlyPublicKey.prototype);
|
|
2440
2878
|
obj.__wbg_ptr = ptr;
|
|
2441
|
-
|
|
2879
|
+
WasmStarkXOnlyPublicKeyFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
2442
2880
|
return obj;
|
|
2443
2881
|
}
|
|
2444
2882
|
__destroy_into_raw() {
|
|
2445
2883
|
const ptr = this.__wbg_ptr;
|
|
2446
2884
|
this.__wbg_ptr = 0;
|
|
2447
|
-
|
|
2885
|
+
WasmStarkXOnlyPublicKeyFinalization.unregister(this);
|
|
2448
2886
|
return ptr;
|
|
2449
2887
|
}
|
|
2450
2888
|
free() {
|
|
2451
2889
|
const ptr = this.__destroy_into_raw();
|
|
2452
|
-
wasm.
|
|
2453
|
-
}
|
|
2454
|
-
/**
|
|
2455
|
-
* Public key (hex)
|
|
2456
|
-
* @returns {string}
|
|
2457
|
-
*/
|
|
2458
|
-
get publicKey() {
|
|
2459
|
-
let deferred1_0;
|
|
2460
|
-
let deferred1_1;
|
|
2461
|
-
try {
|
|
2462
|
-
const ret = wasm.__wbg_get_wasmstarksignature_publicKey(this.__wbg_ptr);
|
|
2463
|
-
deferred1_0 = ret[0];
|
|
2464
|
-
deferred1_1 = ret[1];
|
|
2465
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
2466
|
-
} finally {
|
|
2467
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
2468
|
-
}
|
|
2469
|
-
}
|
|
2470
|
-
/**
|
|
2471
|
-
* Signature r component (hex)
|
|
2472
|
-
* @returns {string}
|
|
2473
|
-
*/
|
|
2474
|
-
get r() {
|
|
2475
|
-
let deferred1_0;
|
|
2476
|
-
let deferred1_1;
|
|
2477
|
-
try {
|
|
2478
|
-
const ret = wasm.__wbg_get_wasmstarksignature_r(this.__wbg_ptr);
|
|
2479
|
-
deferred1_0 = ret[0];
|
|
2480
|
-
deferred1_1 = ret[1];
|
|
2481
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
2482
|
-
} finally {
|
|
2483
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
2484
|
-
}
|
|
2890
|
+
wasm.__wbg_wasmstarkxonlypublickey_free(ptr, 0);
|
|
2485
2891
|
}
|
|
2486
2892
|
/**
|
|
2487
|
-
*
|
|
2893
|
+
* Public key X coordinate as hex string
|
|
2488
2894
|
* @returns {string}
|
|
2489
2895
|
*/
|
|
2490
|
-
get
|
|
2896
|
+
get public_key_x() {
|
|
2491
2897
|
let deferred1_0;
|
|
2492
2898
|
let deferred1_1;
|
|
2493
2899
|
try {
|
|
2494
|
-
const ret = wasm.
|
|
2900
|
+
const ret = wasm.__wbg_get_wasmstarkxonlypublickey_public_key_x(this.__wbg_ptr);
|
|
2495
2901
|
deferred1_0 = ret[0];
|
|
2496
2902
|
deferred1_1 = ret[1];
|
|
2497
2903
|
return getStringFromWasm0(ret[0], ret[1]);
|
|
@@ -2500,34 +2906,52 @@ export class WasmStarkSignature {
|
|
|
2500
2906
|
}
|
|
2501
2907
|
}
|
|
2502
2908
|
/**
|
|
2503
|
-
* Public key
|
|
2909
|
+
* Public key X coordinate as hex string
|
|
2504
2910
|
* @param {string} arg0
|
|
2505
2911
|
*/
|
|
2506
|
-
set
|
|
2912
|
+
set public_key_x(arg0) {
|
|
2507
2913
|
const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2508
2914
|
const len0 = WASM_VECTOR_LEN;
|
|
2509
|
-
wasm.
|
|
2915
|
+
wasm.__wbg_set_wasmciphertext_l_x(this.__wbg_ptr, ptr0, len0);
|
|
2510
2916
|
}
|
|
2511
2917
|
/**
|
|
2512
|
-
*
|
|
2513
|
-
* @param {string} arg0
|
|
2918
|
+
* @param {string} public_key_x
|
|
2514
2919
|
*/
|
|
2515
|
-
|
|
2516
|
-
const ptr0 = passStringToWasm0(
|
|
2920
|
+
constructor(public_key_x) {
|
|
2921
|
+
const ptr0 = passStringToWasm0(public_key_x, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2517
2922
|
const len0 = WASM_VECTOR_LEN;
|
|
2518
|
-
wasm.
|
|
2923
|
+
const ret = wasm.wasmstarkxonlypublickey_new(ptr0, len0);
|
|
2924
|
+
if (ret[2]) {
|
|
2925
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2926
|
+
}
|
|
2927
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
2928
|
+
WasmStarkXOnlyPublicKeyFinalization.register(this, this.__wbg_ptr, this);
|
|
2929
|
+
return this;
|
|
2519
2930
|
}
|
|
2520
2931
|
/**
|
|
2521
|
-
*
|
|
2522
|
-
* @
|
|
2932
|
+
* Return the x-only public key as fixed-width `0x` + 64 hex digits.
|
|
2933
|
+
* @returns {string}
|
|
2523
2934
|
*/
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2935
|
+
publicKeyHex() {
|
|
2936
|
+
let deferred2_0;
|
|
2937
|
+
let deferred2_1;
|
|
2938
|
+
try {
|
|
2939
|
+
const ret = wasm.wasmstarkxonlypublickey_publicKeyHex(this.__wbg_ptr);
|
|
2940
|
+
var ptr1 = ret[0];
|
|
2941
|
+
var len1 = ret[1];
|
|
2942
|
+
if (ret[3]) {
|
|
2943
|
+
ptr1 = 0; len1 = 0;
|
|
2944
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2945
|
+
}
|
|
2946
|
+
deferred2_0 = ptr1;
|
|
2947
|
+
deferred2_1 = len1;
|
|
2948
|
+
return getStringFromWasm0(ptr1, len1);
|
|
2949
|
+
} finally {
|
|
2950
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
2951
|
+
}
|
|
2528
2952
|
}
|
|
2529
2953
|
}
|
|
2530
|
-
if (Symbol.dispose)
|
|
2954
|
+
if (Symbol.dispose) WasmStarkXOnlyPublicKey.prototype[Symbol.dispose] = WasmStarkXOnlyPublicKey.prototype.free;
|
|
2531
2955
|
|
|
2532
2956
|
/**
|
|
2533
2957
|
* Parameters for generating a transfer proof.
|
|
@@ -4986,6 +5410,14 @@ export function deriveArgentAccountAddress(public_key, class_hash) {
|
|
|
4986
5410
|
* This is needed to recover keys for accounts created with old Argent-X.
|
|
4987
5411
|
* Braavos and new Argent use direct `m/44'/9004'/0'/0/{index}` derivation instead.
|
|
4988
5412
|
*
|
|
5413
|
+
* Returns an x-only Stark keypair ([`WasmStarkXOnlyKeypair`]) because
|
|
5414
|
+
* `stark_public_key` does not produce an affine Y coordinate.
|
|
5415
|
+
*
|
|
5416
|
+
* # Security / threat model
|
|
5417
|
+
*
|
|
5418
|
+
* Returns the private key as a hex string in the JS heap. Prefer
|
|
5419
|
+
* [`derive_argent_legacy_public_key`] when only the public key is needed.
|
|
5420
|
+
*
|
|
4989
5421
|
* # Arguments
|
|
4990
5422
|
* * `mnemonic` - 12 or 24 word BIP-39 mnemonic
|
|
4991
5423
|
* * `address_index` - HD wallet address index (default: 0)
|
|
@@ -4993,7 +5425,7 @@ export function deriveArgentAccountAddress(public_key, class_hash) {
|
|
|
4993
5425
|
* @param {string} mnemonic
|
|
4994
5426
|
* @param {number} address_index
|
|
4995
5427
|
* @param {number} account_index
|
|
4996
|
-
* @returns {
|
|
5428
|
+
* @returns {WasmStarkXOnlyKeypair}
|
|
4997
5429
|
*/
|
|
4998
5430
|
export function deriveArgentLegacyKeypair(mnemonic, address_index, account_index) {
|
|
4999
5431
|
const ptr0 = passStringToWasm0(mnemonic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -5002,7 +5434,28 @@ export function deriveArgentLegacyKeypair(mnemonic, address_index, account_index
|
|
|
5002
5434
|
if (ret[2]) {
|
|
5003
5435
|
throw takeFromExternrefTable0(ret[1]);
|
|
5004
5436
|
}
|
|
5005
|
-
return
|
|
5437
|
+
return WasmStarkXOnlyKeypair.__wrap(ret[0]);
|
|
5438
|
+
}
|
|
5439
|
+
|
|
5440
|
+
/**
|
|
5441
|
+
* Derive the Argent-legacy Stark public key only (x-coordinate).
|
|
5442
|
+
*
|
|
5443
|
+
* Prefer this over [`derive_argent_legacy_keypair`] when private key material
|
|
5444
|
+
* is not needed. Returns [`WasmStarkXOnlyPublicKey`] because
|
|
5445
|
+
* `stark_public_key` is x-only (not a full affine point).
|
|
5446
|
+
* @param {string} mnemonic
|
|
5447
|
+
* @param {number} address_index
|
|
5448
|
+
* @param {number} account_index
|
|
5449
|
+
* @returns {WasmStarkXOnlyPublicKey}
|
|
5450
|
+
*/
|
|
5451
|
+
export function deriveArgentLegacyPublicKey(mnemonic, address_index, account_index) {
|
|
5452
|
+
const ptr0 = passStringToWasm0(mnemonic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
5453
|
+
const len0 = WASM_VECTOR_LEN;
|
|
5454
|
+
const ret = wasm.deriveArgentLegacyPublicKey(ptr0, len0, address_index, account_index);
|
|
5455
|
+
if (ret[2]) {
|
|
5456
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
5457
|
+
}
|
|
5458
|
+
return WasmStarkXOnlyPublicKey.__wrap(ret[0]);
|
|
5006
5459
|
}
|
|
5007
5460
|
|
|
5008
5461
|
/**
|
|
@@ -5045,9 +5498,9 @@ export function deriveBraavosAccountAddress(public_key, class_hash) {
|
|
|
5045
5498
|
}
|
|
5046
5499
|
|
|
5047
5500
|
/**
|
|
5048
|
-
* Derive
|
|
5501
|
+
* Derive discovery keypairs for a mnemonic without computing addresses (public-only).
|
|
5049
5502
|
*
|
|
5050
|
-
* Returns one
|
|
5503
|
+
* Returns one entry per derivation scheme per index:
|
|
5051
5504
|
* - **Direct**: `m/44'/9004'/0'/0/{index}` — shared by Braavos, new Argent, OpenZeppelin
|
|
5052
5505
|
* - **ArgentLegacy**: double derivation via ETH key — used by legacy Argent wallets
|
|
5053
5506
|
*
|
|
@@ -5055,11 +5508,15 @@ export function deriveBraavosAccountAddress(public_key, class_hash) {
|
|
|
5055
5508
|
* Use these public keys to query external APIs (e.g., Argent's smart account
|
|
5056
5509
|
* discovery endpoint) for accounts whose addresses can't be derived locally.
|
|
5057
5510
|
*
|
|
5511
|
+
* # Security
|
|
5512
|
+
*
|
|
5513
|
+
* Private keys are **not** included. Use
|
|
5514
|
+
* [`derive_discovery_keypairs_with_secrets`] when key material is required.
|
|
5515
|
+
*
|
|
5058
5516
|
* # Returns
|
|
5059
5517
|
* JSON string: array of objects with fields:
|
|
5060
5518
|
* - `derivationType`: "Direct" | "ArgentLegacy"
|
|
5061
5519
|
* - `publicKey`: hex string
|
|
5062
|
-
* - `privateKey`: hex string (handle with care!)
|
|
5063
5520
|
* - `derivationIndex`: number
|
|
5064
5521
|
* - `derivationPath`: string
|
|
5065
5522
|
*
|
|
@@ -5098,8 +5555,46 @@ export function deriveDiscoveryKeypairs(mnemonic, max_index) {
|
|
|
5098
5555
|
}
|
|
5099
5556
|
}
|
|
5100
5557
|
|
|
5558
|
+
/**
|
|
5559
|
+
* Like [`derive_discovery_keypairs`], but includes `privateKey` on each entry.
|
|
5560
|
+
*
|
|
5561
|
+
* # Security
|
|
5562
|
+
*
|
|
5563
|
+
* **Opt-in secret API.** Treat the returned JSON as secret material.
|
|
5564
|
+
* @param {string} mnemonic
|
|
5565
|
+
* @param {number | null} [max_index]
|
|
5566
|
+
* @returns {string}
|
|
5567
|
+
*/
|
|
5568
|
+
export function deriveDiscoveryKeypairsWithSecrets(mnemonic, max_index) {
|
|
5569
|
+
let deferred3_0;
|
|
5570
|
+
let deferred3_1;
|
|
5571
|
+
try {
|
|
5572
|
+
const ptr0 = passStringToWasm0(mnemonic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
5573
|
+
const len0 = WASM_VECTOR_LEN;
|
|
5574
|
+
const ret = wasm.deriveDiscoveryKeypairsWithSecrets(ptr0, len0, isLikeNone(max_index) ? 0x100000001 : (max_index) >>> 0);
|
|
5575
|
+
var ptr2 = ret[0];
|
|
5576
|
+
var len2 = ret[1];
|
|
5577
|
+
if (ret[3]) {
|
|
5578
|
+
ptr2 = 0; len2 = 0;
|
|
5579
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
5580
|
+
}
|
|
5581
|
+
deferred3_0 = ptr2;
|
|
5582
|
+
deferred3_1 = len2;
|
|
5583
|
+
return getStringFromWasm0(ptr2, len2);
|
|
5584
|
+
} finally {
|
|
5585
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
5586
|
+
}
|
|
5587
|
+
}
|
|
5588
|
+
|
|
5101
5589
|
/**
|
|
5102
5590
|
* Derive a keypair from mnemonic (for external use).
|
|
5591
|
+
*
|
|
5592
|
+
* # Security / threat model
|
|
5593
|
+
*
|
|
5594
|
+
* Returns the private key as a hex string in the JS heap. Prefer
|
|
5595
|
+
* [`derive_public_key`] when only the public key is needed. Never log the
|
|
5596
|
+
* returned [`WasmKeypair`]; its `Debug` form redacts the private key, but
|
|
5597
|
+
* JS property access still exposes it.
|
|
5103
5598
|
* @param {string} mnemonic
|
|
5104
5599
|
* @param {number} address_index
|
|
5105
5600
|
* @param {number} account_index
|
|
@@ -5126,6 +5621,11 @@ export function deriveKeypair(mnemonic, address_index, account_index, passphrase
|
|
|
5126
5621
|
*
|
|
5127
5622
|
* Derivation path: m/44'/1237'/{account_index}'/0/{address_index}
|
|
5128
5623
|
*
|
|
5624
|
+
* # Security / threat model
|
|
5625
|
+
*
|
|
5626
|
+
* Returns the private key as a hex string in the JS heap. Prefer
|
|
5627
|
+
* [`derive_nostr_public_key`] when only the public key is needed.
|
|
5628
|
+
*
|
|
5129
5629
|
* # Arguments
|
|
5130
5630
|
* * `mnemonic` - 12 or 24 word BIP-39 mnemonic
|
|
5131
5631
|
* * `address_index` - HD wallet address index (default: 0)
|
|
@@ -5152,6 +5652,28 @@ export function deriveNostrKeypair(mnemonic, address_index, account_index, passp
|
|
|
5152
5652
|
return WasmNostrKeypair.__wrap(ret[0]);
|
|
5153
5653
|
}
|
|
5154
5654
|
|
|
5655
|
+
/**
|
|
5656
|
+
* Derive the Nostr x-only public key only from a mnemonic (coin type 1237).
|
|
5657
|
+
*
|
|
5658
|
+
* Prefer this over [`derive_nostr_keypair`] when private key material is not needed.
|
|
5659
|
+
* @param {string} mnemonic
|
|
5660
|
+
* @param {number} address_index
|
|
5661
|
+
* @param {number} account_index
|
|
5662
|
+
* @param {string | null} [passphrase]
|
|
5663
|
+
* @returns {WasmNostrPublicKey}
|
|
5664
|
+
*/
|
|
5665
|
+
export function deriveNostrPublicKey(mnemonic, address_index, account_index, passphrase) {
|
|
5666
|
+
const ptr0 = passStringToWasm0(mnemonic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
5667
|
+
const len0 = WASM_VECTOR_LEN;
|
|
5668
|
+
var ptr1 = isLikeNone(passphrase) ? 0 : passStringToWasm0(passphrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
5669
|
+
var len1 = WASM_VECTOR_LEN;
|
|
5670
|
+
const ret = wasm.deriveNostrPublicKey(ptr0, len0, address_index, account_index, ptr1, len1);
|
|
5671
|
+
if (ret[2]) {
|
|
5672
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
5673
|
+
}
|
|
5674
|
+
return WasmNostrPublicKey.__wrap(ret[0]);
|
|
5675
|
+
}
|
|
5676
|
+
|
|
5155
5677
|
/**
|
|
5156
5678
|
* Derive an OpenZeppelin account contract address from a public key.
|
|
5157
5679
|
*
|
|
@@ -5161,7 +5683,7 @@ export function deriveNostrKeypair(mnemonic, address_index, account_index, passp
|
|
|
5161
5683
|
* # Arguments
|
|
5162
5684
|
* * `public_key_x` - The x-coordinate of the Stark public key (hex string)
|
|
5163
5685
|
* * `class_hash` - The OpenZeppelin account class hash (hex string)
|
|
5164
|
-
* * `salt` - Optional salt for address derivation (hex string
|
|
5686
|
+
* * `salt` - Optional salt for address derivation (hex string; defaults to the public key)
|
|
5165
5687
|
*
|
|
5166
5688
|
* # Returns
|
|
5167
5689
|
* The derived account contract address as hex string
|
|
@@ -5195,12 +5717,39 @@ export function deriveOzAccountAddress(public_key_x, class_hash, salt) {
|
|
|
5195
5717
|
}
|
|
5196
5718
|
}
|
|
5197
5719
|
|
|
5720
|
+
/**
|
|
5721
|
+
* Derive the public key only from a mnemonic (Tongo coin type).
|
|
5722
|
+
*
|
|
5723
|
+
* Prefer this over [`derive_keypair`] when private key material is not needed.
|
|
5724
|
+
* @param {string} mnemonic
|
|
5725
|
+
* @param {number} address_index
|
|
5726
|
+
* @param {number} account_index
|
|
5727
|
+
* @param {string | null} [passphrase]
|
|
5728
|
+
* @returns {WasmPublicKey}
|
|
5729
|
+
*/
|
|
5730
|
+
export function derivePublicKey(mnemonic, address_index, account_index, passphrase) {
|
|
5731
|
+
const ptr0 = passStringToWasm0(mnemonic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
5732
|
+
const len0 = WASM_VECTOR_LEN;
|
|
5733
|
+
var ptr1 = isLikeNone(passphrase) ? 0 : passStringToWasm0(passphrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
5734
|
+
var len1 = WASM_VECTOR_LEN;
|
|
5735
|
+
const ret = wasm.derivePublicKey(ptr0, len0, address_index, account_index, ptr1, len1);
|
|
5736
|
+
if (ret[2]) {
|
|
5737
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
5738
|
+
}
|
|
5739
|
+
return WasmPublicKey.__wrap(ret[0]);
|
|
5740
|
+
}
|
|
5741
|
+
|
|
5198
5742
|
/**
|
|
5199
5743
|
* Derive a Starknet account keypair from mnemonic (coin type 9004).
|
|
5200
5744
|
*
|
|
5201
5745
|
* This is used for signing Starknet transactions and deriving the
|
|
5202
5746
|
* OpenZeppelin account contract address.
|
|
5203
5747
|
*
|
|
5748
|
+
* # Security / threat model
|
|
5749
|
+
*
|
|
5750
|
+
* Returns the private key as a hex string in the JS heap. Prefer
|
|
5751
|
+
* [`derive_starknet_public_key`] when only the public key is needed.
|
|
5752
|
+
*
|
|
5204
5753
|
* # Arguments
|
|
5205
5754
|
* * `mnemonic` - 12 or 24 word BIP-39 mnemonic
|
|
5206
5755
|
* * `address_index` - HD wallet address index (default: 0)
|
|
@@ -5227,6 +5776,29 @@ export function deriveStarknetKeypair(mnemonic, address_index, account_index, pa
|
|
|
5227
5776
|
return WasmKeypair.__wrap(ret[0]);
|
|
5228
5777
|
}
|
|
5229
5778
|
|
|
5779
|
+
/**
|
|
5780
|
+
* Derive the Starknet public key only from a mnemonic (coin type 9004).
|
|
5781
|
+
*
|
|
5782
|
+
* Prefer this over [`derive_starknet_keypair`] when private key material is
|
|
5783
|
+
* not needed (e.g. address derivation).
|
|
5784
|
+
* @param {string} mnemonic
|
|
5785
|
+
* @param {number} address_index
|
|
5786
|
+
* @param {number} account_index
|
|
5787
|
+
* @param {string | null} [passphrase]
|
|
5788
|
+
* @returns {WasmPublicKey}
|
|
5789
|
+
*/
|
|
5790
|
+
export function deriveStarknetPublicKey(mnemonic, address_index, account_index, passphrase) {
|
|
5791
|
+
const ptr0 = passStringToWasm0(mnemonic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
5792
|
+
const len0 = WASM_VECTOR_LEN;
|
|
5793
|
+
var ptr1 = isLikeNone(passphrase) ? 0 : passStringToWasm0(passphrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
5794
|
+
var len1 = WASM_VECTOR_LEN;
|
|
5795
|
+
const ret = wasm.deriveStarknetPublicKey(ptr0, len0, address_index, account_index, ptr1, len1);
|
|
5796
|
+
if (ret[2]) {
|
|
5797
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
5798
|
+
}
|
|
5799
|
+
return WasmPublicKey.__wrap(ret[0]);
|
|
5800
|
+
}
|
|
5801
|
+
|
|
5230
5802
|
/**
|
|
5231
5803
|
* Derive the STRK20 viewing key from a Stark private key.
|
|
5232
5804
|
*
|
|
@@ -5284,14 +5856,19 @@ export function deserializePublicKey(hex) {
|
|
|
5284
5856
|
}
|
|
5285
5857
|
|
|
5286
5858
|
/**
|
|
5287
|
-
* Perform full account discovery in a single call.
|
|
5859
|
+
* Perform full account discovery in a single call (public-only).
|
|
5288
5860
|
*
|
|
5289
5861
|
* Returns a JSON object with two fields:
|
|
5290
|
-
* - `keypairs`: array of DerivedKeypair objects (for API-based smart account lookup)
|
|
5291
|
-
* - `candidates`: array of CandidateAccount objects (for local address derivation)
|
|
5862
|
+
* - `keypairs`: array of public-only DerivedKeypair objects (for API-based smart account lookup)
|
|
5863
|
+
* - `candidates`: array of public-only CandidateAccount objects (for local address derivation)
|
|
5292
5864
|
*
|
|
5293
5865
|
* This combines `deriveDiscoveryKeypairs` and `generateAccountCandidates` into
|
|
5294
5866
|
* a single WASM call, eliminating one JS→WASM round-trip.
|
|
5867
|
+
*
|
|
5868
|
+
* # Security
|
|
5869
|
+
*
|
|
5870
|
+
* Private keys are **not** included. Use
|
|
5871
|
+
* [`discover_accounts_from_mnemonic_with_secrets`] when key material is required.
|
|
5295
5872
|
* @param {string} mnemonic
|
|
5296
5873
|
* @param {number | null} [max_index]
|
|
5297
5874
|
* @returns {string}
|
|
@@ -5317,6 +5894,37 @@ export function discoverAccountsFromMnemonic(mnemonic, max_index) {
|
|
|
5317
5894
|
}
|
|
5318
5895
|
}
|
|
5319
5896
|
|
|
5897
|
+
/**
|
|
5898
|
+
* Like [`discover_accounts_from_mnemonic`], but includes private keys.
|
|
5899
|
+
*
|
|
5900
|
+
* # Security
|
|
5901
|
+
*
|
|
5902
|
+
* **Opt-in secret API.** Treat the returned JSON as secret material.
|
|
5903
|
+
* @param {string} mnemonic
|
|
5904
|
+
* @param {number | null} [max_index]
|
|
5905
|
+
* @returns {string}
|
|
5906
|
+
*/
|
|
5907
|
+
export function discoverAccountsFromMnemonicWithSecrets(mnemonic, max_index) {
|
|
5908
|
+
let deferred3_0;
|
|
5909
|
+
let deferred3_1;
|
|
5910
|
+
try {
|
|
5911
|
+
const ptr0 = passStringToWasm0(mnemonic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
5912
|
+
const len0 = WASM_VECTOR_LEN;
|
|
5913
|
+
const ret = wasm.discoverAccountsFromMnemonicWithSecrets(ptr0, len0, isLikeNone(max_index) ? 0x100000001 : (max_index) >>> 0);
|
|
5914
|
+
var ptr2 = ret[0];
|
|
5915
|
+
var len2 = ret[1];
|
|
5916
|
+
if (ret[3]) {
|
|
5917
|
+
ptr2 = 0; len2 = 0;
|
|
5918
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
5919
|
+
}
|
|
5920
|
+
deferred3_0 = ptr2;
|
|
5921
|
+
deferred3_1 = len2;
|
|
5922
|
+
return getStringFromWasm0(ptr2, len2);
|
|
5923
|
+
} finally {
|
|
5924
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
5925
|
+
}
|
|
5926
|
+
}
|
|
5927
|
+
|
|
5320
5928
|
/**
|
|
5321
5929
|
* Encode a value as a Felt hex string.
|
|
5322
5930
|
*
|
|
@@ -5466,7 +6074,7 @@ export function encryptWithKey(plaintext, key_hex) {
|
|
|
5466
6074
|
*
|
|
5467
6075
|
* Returns a JSON object where keys are derivation indices and values are
|
|
5468
6076
|
* objects mapping wallet type to address. Useful for quick discovery without
|
|
5469
|
-
* needing the full candidate details.
|
|
6077
|
+
* needing the full candidate details. Never includes private keys.
|
|
5470
6078
|
*
|
|
5471
6079
|
* # Returns
|
|
5472
6080
|
* JSON string: `{ "0": { "Braavos": "0x...", "Argent": "0x...", ... }, "1": { ... } }`
|
|
@@ -5496,7 +6104,7 @@ export function generateAccountAddresses(mnemonic, max_index) {
|
|
|
5496
6104
|
}
|
|
5497
6105
|
|
|
5498
6106
|
/**
|
|
5499
|
-
* Generate all candidate account addresses for a mnemonic.
|
|
6107
|
+
* Generate all candidate account addresses for a mnemonic (public-only).
|
|
5500
6108
|
*
|
|
5501
6109
|
* Returns a JSON array of candidate accounts across all known wallet types
|
|
5502
6110
|
* (Braavos, Argent, Argent Legacy, Argent Cairo 0, OpenZeppelin).
|
|
@@ -5506,6 +6114,11 @@ export function generateAccountAddresses(mnemonic, max_index) {
|
|
|
5506
6114
|
* ones are actually deployed, check each address via an RPC provider
|
|
5507
6115
|
* (e.g., `provider.getClassHashAt(address)` in starknet.js).
|
|
5508
6116
|
*
|
|
6117
|
+
* # Security
|
|
6118
|
+
*
|
|
6119
|
+
* Private keys are **not** included (default `CandidateAccount` Serialize).
|
|
6120
|
+
* Use [`generate_account_candidates_with_secrets`] when key material is required.
|
|
6121
|
+
*
|
|
5509
6122
|
* # Arguments
|
|
5510
6123
|
* * `mnemonic` - BIP-39 mnemonic phrase (12 or 24 words)
|
|
5511
6124
|
* * `max_index` - Maximum derivation index to scan (default: 5).
|
|
@@ -5517,7 +6130,6 @@ export function generateAccountAddresses(mnemonic, max_index) {
|
|
|
5517
6130
|
* - `classHash`: hex string
|
|
5518
6131
|
* - `address`: hex string
|
|
5519
6132
|
* - `publicKey`: hex string
|
|
5520
|
-
* - `privateKey`: hex string (handle with care!)
|
|
5521
6133
|
* - `derivationIndex`: number
|
|
5522
6134
|
* - `derivationPath`: string (e.g., "m/44'/9004'/0'/0/0")
|
|
5523
6135
|
* - `classVersion`: string (e.g., "v0.4.0", "braavos-base")
|
|
@@ -5557,6 +6169,39 @@ export function generateAccountCandidates(mnemonic, max_index) {
|
|
|
5557
6169
|
}
|
|
5558
6170
|
}
|
|
5559
6171
|
|
|
6172
|
+
/**
|
|
6173
|
+
* Like [`generate_account_candidates`], but includes `privateKey` on each candidate.
|
|
6174
|
+
*
|
|
6175
|
+
* # Security
|
|
6176
|
+
*
|
|
6177
|
+
* **Opt-in secret API.** The returned JSON contains private keys. Do not log,
|
|
6178
|
+
* cache in localStorage, or pass through untrusted JavaScript. Prefer the
|
|
6179
|
+
* default public-only API for discovery scans.
|
|
6180
|
+
* @param {string} mnemonic
|
|
6181
|
+
* @param {number | null} [max_index]
|
|
6182
|
+
* @returns {string}
|
|
6183
|
+
*/
|
|
6184
|
+
export function generateAccountCandidatesWithSecrets(mnemonic, max_index) {
|
|
6185
|
+
let deferred3_0;
|
|
6186
|
+
let deferred3_1;
|
|
6187
|
+
try {
|
|
6188
|
+
const ptr0 = passStringToWasm0(mnemonic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
6189
|
+
const len0 = WASM_VECTOR_LEN;
|
|
6190
|
+
const ret = wasm.generateAccountCandidatesWithSecrets(ptr0, len0, isLikeNone(max_index) ? 0x100000001 : (max_index) >>> 0);
|
|
6191
|
+
var ptr2 = ret[0];
|
|
6192
|
+
var len2 = ret[1];
|
|
6193
|
+
if (ret[3]) {
|
|
6194
|
+
ptr2 = 0; len2 = 0;
|
|
6195
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
6196
|
+
}
|
|
6197
|
+
deferred3_0 = ptr2;
|
|
6198
|
+
deferred3_1 = len2;
|
|
6199
|
+
return getStringFromWasm0(ptr2, len2);
|
|
6200
|
+
} finally {
|
|
6201
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
6202
|
+
}
|
|
6203
|
+
}
|
|
6204
|
+
|
|
5560
6205
|
/**
|
|
5561
6206
|
* Generate a fund (deposit) proof.
|
|
5562
6207
|
* @param {WasmAccount} account
|
|
@@ -5575,6 +6220,13 @@ export function generateFundProof(account, params) {
|
|
|
5575
6220
|
|
|
5576
6221
|
/**
|
|
5577
6222
|
* Generate a new random mnemonic phrase.
|
|
6223
|
+
*
|
|
6224
|
+
* # Security / threat model
|
|
6225
|
+
*
|
|
6226
|
+
* The mnemonic is returned as a plain JavaScript string and cannot be
|
|
6227
|
+
* reliably wiped from the JS heap. Treat it as high-value secret material:
|
|
6228
|
+
* never log it, never persist it unencrypted, and prefer keeping it only in
|
|
6229
|
+
* secure storage after generation.
|
|
5578
6230
|
* @param {number | null} [word_count]
|
|
5579
6231
|
* @returns {string}
|
|
5580
6232
|
*/
|
|
@@ -6566,12 +7218,18 @@ const WasmKeypairFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
6566
7218
|
const WasmNostrKeypairFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
6567
7219
|
? { register: () => {}, unregister: () => {} }
|
|
6568
7220
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmnostrkeypair_free(ptr >>> 0, 1));
|
|
7221
|
+
const WasmNostrPublicKeyFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
7222
|
+
? { register: () => {}, unregister: () => {} }
|
|
7223
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmnostrpublickey_free(ptr >>> 0, 1));
|
|
6569
7224
|
const WasmNostrSignatureFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
6570
7225
|
? { register: () => {}, unregister: () => {} }
|
|
6571
7226
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmnostrsignature_free(ptr >>> 0, 1));
|
|
6572
7227
|
const WasmPointFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
6573
7228
|
? { register: () => {}, unregister: () => {} }
|
|
6574
7229
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmpoint_free(ptr >>> 0, 1));
|
|
7230
|
+
const WasmPublicKeyFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
7231
|
+
? { register: () => {}, unregister: () => {} }
|
|
7232
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmpublickey_free(ptr >>> 0, 1));
|
|
6575
7233
|
const WasmRagequitParamsFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
6576
7234
|
? { register: () => {}, unregister: () => {} }
|
|
6577
7235
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmragequitparams_free(ptr >>> 0, 1));
|
|
@@ -6587,6 +7245,12 @@ const WasmRolloverProofResultFinalization = (typeof FinalizationRegistry === 'un
|
|
|
6587
7245
|
const WasmStarkSignatureFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
6588
7246
|
? { register: () => {}, unregister: () => {} }
|
|
6589
7247
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmstarksignature_free(ptr >>> 0, 1));
|
|
7248
|
+
const WasmStarkXOnlyKeypairFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
7249
|
+
? { register: () => {}, unregister: () => {} }
|
|
7250
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmstarkxonlykeypair_free(ptr >>> 0, 1));
|
|
7251
|
+
const WasmStarkXOnlyPublicKeyFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
7252
|
+
? { register: () => {}, unregister: () => {} }
|
|
7253
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmstarkxonlypublickey_free(ptr >>> 0, 1));
|
|
6590
7254
|
const WasmTransferParamsFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
6591
7255
|
? { register: () => {}, unregister: () => {} }
|
|
6592
7256
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmtransferparams_free(ptr >>> 0, 1));
|